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

Consensus halt fix #94

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 8 additions & 5 deletions core/ibft.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func (i *IBFT) RunSequence(ctx context.Context, h uint64) {
// The consensus cycle for the block height is finished.
// Stop all running worker threads
teardown()
i.insertBlock()

return
case <-ctxRound.Done():
Expand Down Expand Up @@ -553,10 +554,7 @@ func (i *IBFT) runStates(ctx context.Context) {
case commit:
timeout = i.runCommit(ctx)
case fin:
i.runFin()
// Block inserted without any errors,
// sequence is complete
i.signalRoundDone(ctx)
i.runFin(ctx)

return
}
Expand Down Expand Up @@ -960,10 +958,15 @@ func (i *IBFT) handleCommit(view *proto.View) bool {
}

// runFin runs the fin state (block insertion)
func (i *IBFT) runFin() {
func (i *IBFT) runFin(ctx context.Context) {
i.log.Debug("enter: fin state")
defer i.log.Debug("exit: fin state")

i.signalRoundDone(ctx)
}

// insertBlock inserts the block
func (i *IBFT) insertBlock() {
// Insert the block to the node's underlying
// blockchain layer
i.backend.InsertProposal(
Expand Down
9 changes: 5 additions & 4 deletions core/ibft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1080,19 +1080,20 @@ func TestRunCommit(t *testing.T) {
i.startRound(ctx)

i.wg.Wait()
i.insertBlock()

// Make sure the node changed the state to fin
assert.Equal(t, fin, i.state.name)
require.Equal(t, fin, i.state.name)

// Make sure the inserted proposal was the one present
assert.Equal(t, insertedProposal, correctRoundMessage.proposal.RawProposal)
require.Equal(t, insertedProposal, correctRoundMessage.proposal.RawProposal)

// Make sure the inserted committed seals were correct
assert.Equal(t, insertedCommittedSeals, committedSeals)
require.Equal(t, insertedCommittedSeals, committedSeals)

// Make sure the proper done channel was notified
wg.Wait()
assert.True(t, doneReceived)
require.True(t, doneReceived)
},
)
}
Expand Down
Loading