Browse Source

Add more comments for Valid*

pull/1569/head
Jae Kwon 7 years ago
committed by Ethan Buchman
parent
commit
ff5dfc0c15
2 changed files with 11 additions and 10 deletions
  1. +8
    -7
      consensus/state.go
  2. +3
    -3
      consensus/types/round_state.go

+ 8
- 7
consensus/state.go View File

@ -1317,19 +1317,20 @@ func (cs *ConsensusState) addProposalBlockPart(height int64, part *types.Part, v
// NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal // NOTE: it's possible to receive complete proposal blocks for future rounds without having the proposal
cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash()) cs.Logger.Info("Received complete proposal block", "height", cs.ProposalBlock.Height, "hash", cs.ProposalBlock.Hash())
// Update ValidBlock
// Update Valid* if we can.
prevotes := cs.Votes.Prevotes(cs.Round) prevotes := cs.Votes.Prevotes(cs.Round)
blockID, ok := prevotes.TwoThirdsMajority()
if ok && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
// update valid value
blockID, hasTwoThirds := prevotes.TwoThirdsMajority()
if hasTwoThirds && !blockID.IsZero() && (cs.ValidRound < cs.Round) {
if cs.ProposalBlock.HashesTo(blockID.Hash) { if cs.ProposalBlock.HashesTo(blockID.Hash) {
cs.ValidRound = cs.Round cs.ValidRound = cs.Round
cs.ValidBlock = cs.ProposalBlock cs.ValidBlock = cs.ProposalBlock
cs.ValidBlockParts = cs.ProposalBlockParts cs.ValidBlockParts = cs.ProposalBlockParts
} }
//TODO: In case there is +2/3 majority in Prevotes set for some block and cs.ProposalBlock contains different block,
//either proposer is faulty or voting power of faulty processes is more than 1/3. We should
//trigger in the future accountability procedure at this point.
// TODO: In case there is +2/3 majority in Prevotes set for some
// block and cs.ProposalBlock contains different block, either
// proposer is faulty or voting power of faulty processes is more
// than 1/3. We should trigger in the future accountability
// procedure at this point.
} }
if cs.Step == cstypes.RoundStepPropose && cs.isProposalComplete() { if cs.Step == cstypes.RoundStepPropose && cs.isProposalComplete() {


+ 3
- 3
consensus/types/round_state.go View File

@ -70,9 +70,9 @@ type RoundState struct {
LockedRound int `json:"locked_round"` LockedRound int `json:"locked_round"`
LockedBlock *types.Block `json:"locked_block"` LockedBlock *types.Block `json:"locked_block"`
LockedBlockParts *types.PartSet `json:"locked_block_parts"` LockedBlockParts *types.PartSet `json:"locked_block_parts"`
ValidRound int `json:"valid_round"`
ValidBlock *types.Block `json:"valid_block"`
ValidBlockParts *types.PartSet `json:"valid_block_parts"`
ValidRound int `json:"valid_round"` // Last known round with POL for non-nil valid block.
ValidBlock *types.Block `json:"valid_block"` // Last known block of POL mentioned above.
ValidBlockParts *types.PartSet `json:"valid_block_parts"` // Last known block parts of POL metnioned above.
Votes *HeightVoteSet `json:"votes"` Votes *HeightVoteSet `json:"votes"`
CommitRound int `json:"commit_round"` // CommitRound int `json:"commit_round"` //
LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1 LastCommit *types.VoteSet `json:"last_commit"` // Last precommits at Height-1


Loading…
Cancel
Save