Disable pipelining during epoch change

pull/3405/head
Rongjian Lan 4 years ago
parent 9e8ee26645
commit 9cc1d5c14e
  1. 21
      consensus/consensus_v2.go
  2. 4
      consensus/leader.go

@ -136,12 +136,12 @@ func (consensus *Consensus) finalCommit() {
}
block.SetCurrentCommitSig(commitSigAndBitmap)
consensus.commitBlock(block, FBFTMsg)
err = consensus.commitBlock(block, FBFTMsg)
if consensus.blockNum-beforeCatchupNum != 1 {
consensus.getLogger().Warn().
if err != nil || consensus.blockNum-beforeCatchupNum != 1 {
consensus.getLogger().Err(err).
Uint64("beforeCatchupBlockNum", beforeCatchupNum).
Msg("[finalCommit] Leader cannot provide the correct block for committed message")
Msg("[finalCommit] Leader failed to commit the confirmed block")
return
}
@ -170,6 +170,10 @@ func (consensus *Consensus) finalCommit() {
Msg("[finalCommit] Sent Committed Message")
}
if consensus.IsLeader() && block.IsLastBlockInEpoch() {
consensus.ReadySignal <- AsyncProposal
}
// Dump new block into level db
// In current code, we add signatures in block in tryCatchup, the block dump to explorer does not contains signatures
// but since explorer doesn't need signatures, it should be fine
@ -507,14 +511,6 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
network.FBFTMsg
consensus.FBFTLog.AddMessage(FBFTMsg)
blk.SetCurrentCommitSig(FBFTMsg.Payload)
if err := consensus.OnConsensusDone(blk); err != nil {
consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain")
return err
}
// If it's not the epoch block, do pipelining and send committed message to validators now at 67% committed.
if !blk.IsLastBlockInEpoch() {
if err := consensus.msgSender.SendWithRetry(
blk.NumberU64(),
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{
@ -528,7 +524,6 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
Uint64("blockNum", consensus.blockNum).
Msg("[preCommitAndPropose] Sent Committed Message")
}
}
// Send signal to Node to propose the new block for consensus
consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] sending block proposal signal")

@ -300,10 +300,14 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
if !quorumWasMet && quorumIsMet {
logger.Info().Msg("[OnCommit] 2/3 Enough commits received")
// If it's not the epoch block, do pipelining and send committed message to validators now at 67% committed.
if !blockObj.IsLastBlockInEpoch() {
go func() {
// TODO: make it synchronized with commitFinishChan
consensus.preCommitAndPropose(blockObj)
}()
}
consensus.getLogger().Info().Msg("[OnCommit] Starting Grace Period")
go func(viewID uint64) {

Loading…
Cancel
Save