Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbft: fix the deadlock reason in four-good-nodes setup #3

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ type Context struct {

// PreparationPayloads stores consensus Prepare* payloads for the current epoch.
PreparationPayloads []payload.ConsensusPayload
// CommitPayloads stores consensus Commit payloads for the current epoch.
// CommitPayloads stores consensus Commit payloads sent throughout all epochs. It
// is assumed that valid Commit payload can only be sent once by a single node per
// the whole set of consensus epochs for particular block. Invalid commit payloads
// are kicked off this list immediately (if PrepareRequest was received for the
// current round, so it's possible to verify Commit against it) or stored till
// the corresponding PrepareRequest receiving.
CommitPayloads []payload.ConsensusPayload
// ChangeViewPayloads stores consensus ChangeView payloads for the current epoch.
ChangeViewPayloads []payload.ConsensusPayload
Expand Down Expand Up @@ -101,7 +106,8 @@ func (c *Context) IsBackup() bool {
// WatchOnly returns true iff node takes no active part in consensus.
func (c *Context) WatchOnly() bool { return c.MyIndex < 0 || c.Config.WatchOnly() }

// CountCommitted returns number of received Commit messages for the current epoch.
// CountCommitted returns number of received Commit messages not only for the current
// epoch but also for any other epoch.
func (c *Context) CountCommitted() (count int) {
for i := range c.CommitPayloads {
if c.CommitPayloads[i] != nil {
Expand Down Expand Up @@ -135,7 +141,8 @@ func (c *Context) ResponseSent() bool {
return !c.WatchOnly() && c.PreparationPayloads[c.MyIndex] != nil
}

// CommitSent returns true iff Commit message was sent for the current epoch.
// CommitSent returns true iff Commit message was sent for the current epoch
// assuming that the node can't go further than current epoch after commit was sent.
func (c *Context) CommitSent() bool {
return !c.WatchOnly() && c.CommitPayloads[c.MyIndex] != nil
}
Expand Down Expand Up @@ -203,7 +210,9 @@ func (c *Context) reset(view byte, ts uint64) {

n := len(c.Validators)
c.ChangeViewPayloads = make([]payload.ConsensusPayload, n)
c.CommitPayloads = make([]payload.ConsensusPayload, n)
if view == 0 {
roman-khimov marked this conversation as resolved.
Show resolved Hide resolved
c.CommitPayloads = make([]payload.ConsensusPayload, n)
}
c.PreparationPayloads = make([]payload.ConsensusPayload, n)

c.Transactions = make(map[util.Uint256]block.Transaction)
Expand Down