mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-26 15:22:15 +00:00
fixes to state transition upon addVote
This commit is contained in:
parent
01b5540ffe
commit
15e80c6c28
@ -932,10 +932,8 @@ func (cs *ConsensusState) AddProposalBlockPart(height uint, round uint, part *ty
|
|||||||
var err error
|
var err error
|
||||||
cs.ProposalBlock = binary.ReadBinary(&types.Block{}, cs.ProposalBlockParts.GetReader(), &n, &err).(*types.Block)
|
cs.ProposalBlock = binary.ReadBinary(&types.Block{}, cs.ProposalBlockParts.GetReader(), &n, &err).(*types.Block)
|
||||||
log.Debug("Received complete proposal", "hash", cs.ProposalBlock.Hash())
|
log.Debug("Received complete proposal", "hash", cs.ProposalBlock.Hash())
|
||||||
if cs.Step == RoundStepPropose {
|
if cs.Step == RoundStepPropose && cs.isProposalComplete() {
|
||||||
if cs.isProposalComplete() {
|
|
||||||
go cs.EnterPrevote(height, round)
|
go cs.EnterPrevote(height, round)
|
||||||
}
|
|
||||||
} else if cs.Step == RoundStepCommit {
|
} else if cs.Step == RoundStepCommit {
|
||||||
cs.TryFinalizeCommit(height)
|
cs.TryFinalizeCommit(height)
|
||||||
}
|
}
|
||||||
@ -975,21 +973,23 @@ func (cs *ConsensusState) addVote(address []byte, vote *types.Vote) (added bool,
|
|||||||
go func() {
|
go func() {
|
||||||
cs.EnterNewRound(height, vote.Round)
|
cs.EnterNewRound(height, vote.Round)
|
||||||
cs.EnterPrevote(height, vote.Round)
|
cs.EnterPrevote(height, vote.Round)
|
||||||
|
cs.EnterPrevoteWait(height, vote.Round)
|
||||||
}()
|
}()
|
||||||
}
|
} else if cs.Round == vote.Round {
|
||||||
if cs.Round == vote.Round {
|
|
||||||
if cs.Votes.Prevotes(cs.Round).HasTwoThirdsMajority() {
|
if cs.Votes.Prevotes(cs.Round).HasTwoThirdsMajority() {
|
||||||
// Goto Precommit, whether for block or nil.
|
// Goto Precommit, whether for block or nil.
|
||||||
go func() {
|
go cs.EnterPrecommit(height, cs.Round)
|
||||||
cs.EnterPrecommit(height, cs.Round)
|
} else if cs.Votes.Prevotes(cs.Round).HasTwoThirdsAny() {
|
||||||
}()
|
|
||||||
}
|
|
||||||
if cs.Votes.Prevotes(cs.Round).HasTwoThirdsAny() {
|
|
||||||
// Goto PrevoteWait
|
// Goto PrevoteWait
|
||||||
go func() {
|
go func() {
|
||||||
|
cs.EnterPrevote(height, cs.Round)
|
||||||
cs.EnterPrevoteWait(height, cs.Round)
|
cs.EnterPrevoteWait(height, cs.Round)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
} else if cs.Proposal != nil && cs.Proposal.POLRound == vote.Round {
|
||||||
|
if cs.isProposalComplete() {
|
||||||
|
go cs.EnterPrevote(height, cs.Round)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case types.VoteTypePrecommit:
|
case types.VoteTypePrecommit:
|
||||||
log.Debug(Fmt("Added to precommit: %v", cs.Votes.Precommits(vote.Round).StringShort()))
|
log.Debug(Fmt("Added to precommit: %v", cs.Votes.Precommits(vote.Round).StringShort()))
|
||||||
@ -998,21 +998,21 @@ func (cs *ConsensusState) addVote(address []byte, vote *types.Vote) (added bool,
|
|||||||
go func() {
|
go func() {
|
||||||
cs.EnterNewRound(height, vote.Round)
|
cs.EnterNewRound(height, vote.Round)
|
||||||
cs.EnterPrecommit(height, vote.Round)
|
cs.EnterPrecommit(height, vote.Round)
|
||||||
|
cs.EnterPrecommitWait(height, vote.Round)
|
||||||
}()
|
}()
|
||||||
}
|
} else if cs.Round == vote.Round {
|
||||||
if cs.Round == vote.Round {
|
|
||||||
if hash, _, ok := cs.Votes.Precommits(cs.Round).TwoThirdsMajority(); ok {
|
if hash, _, ok := cs.Votes.Precommits(cs.Round).TwoThirdsMajority(); ok {
|
||||||
if len(hash) == 0 {
|
if len(hash) == 0 {
|
||||||
// If hash is nil, goto NewRound
|
// If hash is nil, goto NewRound
|
||||||
cs.EnterNewRound(height, cs.Round+1)
|
go cs.EnterNewRound(height, cs.Round+1)
|
||||||
} else {
|
} else {
|
||||||
// If hash is block, goto Commit
|
// If hash is block, goto Commit
|
||||||
cs.EnterCommit(height, cs.Round)
|
go cs.EnterCommit(height, cs.Round)
|
||||||
}
|
}
|
||||||
}
|
} else if cs.Votes.Precommits(cs.Round).HasTwoThirdsAny() {
|
||||||
if cs.Votes.Precommits(cs.Round).HasTwoThirdsAny() {
|
|
||||||
// Goto PrecommitWait
|
// Goto PrecommitWait
|
||||||
go func() {
|
go func() {
|
||||||
|
cs.EnterPrecommit(height, cs.Round)
|
||||||
cs.EnterPrecommitWait(height, cs.Round)
|
cs.EnterPrecommitWait(height, cs.Round)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user