Browse Source

improve debug output for action & step

pull/9/head
Jae Kwon 10 years ago
parent
commit
71c59cb36b
2 changed files with 67 additions and 16 deletions
  1. +5
    -5
      consensus/reactor.go
  2. +62
    -11
      consensus/state.go

+ 5
- 5
consensus/reactor.go View File

@ -279,7 +279,7 @@ OUTER_LOOP:
// If height and round doesn't match, sleep.
if rs.Height != prs.Height || rs.Round != prs.Round {
log.Debug("Height or Round mismatch, sleeping", "peerHeight", prs.Height, "peerRound", prs.Round)
log.Debug("Height or Round mismatch, sleeping", "peerHeight", prs.Height, "peerRound", prs.Round, "peer", peer)
time.Sleep(peerGossipSleepDuration)
continue OUTER_LOOP
}
@ -696,7 +696,7 @@ type NewRoundStepMessage struct {
func (m *NewRoundStepMessage) TypeByte() byte { return msgTypeNewRoundStep }
func (m *NewRoundStepMessage) String() string {
return fmt.Sprintf("[NewRoundStep %v/%v/%X]", m.Height, m.Round, m.Step)
return fmt.Sprintf("[NewRoundStep H:%v R:%v S:%v]", m.Height, m.Round, m.Step)
}
//-------------------------------------
@ -710,7 +710,7 @@ type CommitStepMessage struct {
func (m *CommitStepMessage) TypeByte() byte { return msgTypeCommitStep }
func (m *CommitStepMessage) String() string {
return fmt.Sprintf("[CommitStep %v %v %v]", m.Height, m.BlockParts, m.BlockBitArray)
return fmt.Sprintf("[CommitStep H:%v BP:%v BA:%v]", m.Height, m.BlockParts, m.BlockBitArray)
}
//-------------------------------------
@ -730,7 +730,7 @@ type PartMessage struct {
func (m *PartMessage) TypeByte() byte { return msgTypePart }
func (m *PartMessage) String() string {
return fmt.Sprintf("[Part %v/%v T:%X %v]", m.Height, m.Round, m.Type, m.Part)
return fmt.Sprintf("[Part H:%v R:%v T:%X P:%v]", m.Height, m.Round, m.Type, m.Part)
}
//-------------------------------------
@ -743,7 +743,7 @@ type VoteMessage struct {
func (m *VoteMessage) TypeByte() byte { return msgTypeVote }
func (m *VoteMessage) String() string {
return fmt.Sprintf("[Vote ValidatorIndex:%v Vote:%v]", m.ValidatorIndex, m.Vote)
return fmt.Sprintf("[Vote VI:%v V:%v]", m.ValidatorIndex, m.Vote)
}
//-------------------------------------


+ 62
- 11
consensus/state.go View File

@ -70,8 +70,22 @@ import (
"github.com/tendermint/tendermint/state"
)
const (
roundDuration0 = 60 * time.Second // The first round is 60 seconds long.
roundDurationDelta = 15 * time.Second // Each successive round lasts 15 seconds longer.
roundDeadlinePrevote = float64(1.0 / 3.0) // When the prevote is due.
roundDeadlinePrecommit = float64(2.0 / 3.0) // When the precommit vote is due.
newHeightDelta = roundDuration0 / 3 // The time to wait between commitTime and startTime of next consensus rounds.
)
var (
ErrInvalidProposalSignature = errors.New("Error invalid proposal signature")
)
//-----------------------------------------------------------------------------
// RoundStep enum type
type RoundStep uint8
type RoundActionType uint8
const (
RoundStepNewHeight = RoundStep(0x00) // Round0 for new height started, wait til CommitTime + Delta
@ -80,24 +94,61 @@ const (
RoundStepPrevote = RoundStep(0x11) // Did prevote, gossip prevotes
RoundStepPrecommit = RoundStep(0x12) // Did precommit, gossip precommits
RoundStepCommit = RoundStep(0x20) // Entered commit state machine
)
func (rs RoundStep) String() string {
switch rs {
case RoundStepNewHeight:
return "RoundStepNewHeight"
case RoundStepNewRound:
return "RoundStepNewRound"
case RoundStepPropose:
return "RoundStepPropose"
case RoundStepPrevote:
return "RoundStepPrevote"
case RoundStepPrecommit:
return "RoundStepPrecommit"
case RoundStepCommit:
return "RoundStepCommit"
default:
panic(Fmt("Unknown RoundStep %X", rs))
}
}
//-----------------------------------------------------------------------------
// RoundAction enum type
type RoundActionType uint8
const (
RoundActionPropose = RoundActionType(0xA0) // Propose and goto RoundStepPropose
RoundActionPrevote = RoundActionType(0xA1) // Prevote and goto RoundStepPrevote
RoundActionPrecommit = RoundActionType(0xA2) // Precommit and goto RoundStepPrecommit
RoundActionTryCommit = RoundActionType(0xC0) // Goto RoundStepCommit, or RoundStepPropose for next round.
RoundActionCommit = RoundActionType(0xC1) // Goto RoundStepCommit upon +2/3 commits
RoundActionTryFinalize = RoundActionType(0xC2) // Maybe goto RoundStepPropose for next round.
roundDuration0 = 60 * time.Second // The first round is 60 seconds long.
roundDurationDelta = 15 * time.Second // Each successive round lasts 15 seconds longer.
roundDeadlinePrevote = float64(1.0 / 3.0) // When the prevote is due.
roundDeadlinePrecommit = float64(2.0 / 3.0) // When the precommit vote is due.
newHeightDelta = roundDuration0 / 3 // The time to wait between commitTime and startTime of next consensus rounds.
)
var (
ErrInvalidProposalSignature = errors.New("Error invalid proposal signature")
)
func (ra RoundActionType) String() string {
switch ra {
case RoundActionPropose:
return "RoundActionPropose"
case RoundActionPrevote:
return "RoundActionPrevote"
case RoundActionPrecommit:
return "RoundActionPrecommit"
case RoundActionTryCommit:
return "RoundActionTryCommit"
case RoundActionCommit:
return "RoundActionCommit"
case RoundActionTryFinalize:
return "RoundActionTryFinalize"
default:
panic(Fmt("Unknown RoundAction %X", ra))
}
}
//-----------------------------------------------------------------------------
type RoundAction struct {
Height uint // The block height for which consensus is reaching for.
@ -167,7 +218,7 @@ func (rs *RoundState) StringIndented(indent string) string {
}
func (rs *RoundState) StringShort() string {
return fmt.Sprintf(`RS{%v/%v/%X %v}`,
return fmt.Sprintf(`RoundState{H:%v R:%v S:%v ST:%v}`,
rs.Height, rs.Round, rs.Step, rs.StartTime)
}


Loading…
Cancel
Save