Merge pull request #3442 from rlan35/main

Avoid reset state that's resetting committed content.
pull/3444/head
Rongjian Lan 4 years ago committed by GitHub
commit 80a8ff4c7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      api/service/syncing/syncing.go
  2. 7
      consensus/consensus_v2.go
  3. 4
      consensus/leader.go

@ -1025,7 +1025,6 @@ func (ss *StateSync) SyncLoop(bc *core.BlockChain, worker *worker.Worker, isBeac
if err := ss.addConsensusLastMile(bc, consensus); err != nil {
utils.Logger().Error().Err(err).Msg("[SYNC] Add consensus last mile")
}
consensus.SetMode(consensus.UpdateConsensusInformation())
}
ss.purgeAllBlocksFromCache()
}

@ -535,14 +535,14 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
}
// Construct committed message
consensus.mutex.Lock()
network, err := consensus.construct(msg_pb.MessageType_COMMITTED, nil, []*bls.PrivateKeyWrapper{leaderPriKey})
consensus.mutex.Unlock()
if err != nil {
consensus.getLogger().Warn().Err(err).
Msg("[preCommitAndPropose] Unable to construct Committed message")
return err
}
go func() {
msgToSend, FBFTMsg :=
network.Bytes,
network.FBFTMsg
@ -553,7 +553,6 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, true); err != nil {
consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain")
return err
}
// if leader successfully finalizes the block, send committed message to validators
@ -576,6 +575,8 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
consensus.getLogger().Info().Msg("[preCommitAndPropose] sending block proposal signal")
consensus.ReadySignal <- AsyncProposal
}()
return nil
}

@ -302,10 +302,10 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
if !blockObj.IsLastBlockInEpoch() {
// only do early commit if it's not epoch block to avoid problems
go func() {
// TODO: make it synchronized with commitFinishChan
consensus.preCommitAndPropose(blockObj)
}()
}
consensus.getLogger().Info().Msg("[OnCommit] Starting Grace Period")

Loading…
Cancel
Save