diff --git a/consensus.go b/consensus.go index 6f3878a1..417149e9 100644 --- a/consensus.go +++ b/consensus.go @@ -348,11 +348,9 @@ func (p *Pbft) runAcceptState(ctx context.Context) { // start new round // send the preprepare message p.sendPreprepareMsg() + p.sendPrepareMsg() - if !p.state.IsLocked() { - // send the prepare message since we are ready to move the state - p.sendPrepareMsg() - } else { + if p.state.IsLocked() { // proposer node is already locked to the same proposal => fast-track and send commit message straight away p.sendCommitMsg() } @@ -400,7 +398,8 @@ func (p *Pbft) runAcceptState(ctx context.Context) { // start new round if p.state.IsLocked() { // the state is locked, we need to receive the same proposal if p.state.proposal.Equal(proposal) { - // fast-track (send a commit message) and wait for validations + // fast-track (send prepare and commit message) and wait for validations + p.sendPrepareMsg() p.sendCommitMsg() p.setState(ValidateState) } else { @@ -411,6 +410,7 @@ func (p *Pbft) runAcceptState(ctx context.Context) { // start new round p.logger.Printf("[%s] Relocking to a propsal: %v", p.validator.NodeID(), proposal.Data) p.state.proposal = proposal p.state.lock(msg.View.Round) + p.sendPrepareMsg() p.sendCommitMsg() p.setState(ValidateState) } else { diff --git a/consensus_test.go b/consensus_test.go index 38aca75b..50a5b5c4 100644 --- a/consensus_test.go +++ b/consensus_test.go @@ -82,7 +82,7 @@ func TestTransition_AcceptState_Proposer_Locked(t *testing.T) { sequence: 1, state: ValidateState, locked: true, - outgoing: 2, // preprepare and prepare + outgoing: 3, // preprepare, prepare and commit }) assert.Equal(t, i.state.proposal.Data, mockProposal) } @@ -282,7 +282,7 @@ func TestTransition_AcceptState_Validator_LockCorrect(t *testing.T) { sequence: 1, state: ValidateState, locked: true, - outgoing: 1, // prepare message + outgoing: 2, // prepare message }) } diff --git a/e2e/e2e_partition_test.go b/e2e/e2e_partition_test.go index 3e9a53f0..5fc6740b 100644 --- a/e2e/e2e_partition_test.go +++ b/e2e/e2e_partition_test.go @@ -259,8 +259,8 @@ func TestE2E_Network_Stuck_Locked_Node_Dropped(t *testing.T) { t.Logf("Node %v, running: %v, isProposalLocked: %v, no proposal set\n", n.name, n.IsRunning(), n.pbft.IsLocked()) } } - // TODO: Temporary assertion until liveness issue is fixed - assert.Error(t, err) + + assert.NoError(t, err) } func TestE2E_Partition_OneMajority(t *testing.T) {