Merge pull request #3579 from rlan35/main

avoid unnecessary header sig checking
pull/3582/head
Rongjian Lan 4 years ago committed by GitHub
commit 2bcd319d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      consensus/consensus_v2.go
  2. 1
      consensus/leader.go
  3. 2
      node/node_explorer.go

@ -588,7 +588,7 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
go func() { go func() {
blk.SetCurrentCommitSig(bareMinimumCommit) blk.SetCurrentCommitSig(bareMinimumCommit)
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, true); err != nil { if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, !consensus.FBFTLog.IsBlockVerified(blk)); err != nil {
consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain") consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain")
return return
} }
@ -690,7 +690,7 @@ func (consensus *Consensus) tryCatchup() error {
func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMessage) error { func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMessage) error {
if consensus.Blockchain.CurrentBlock().NumberU64() < blk.NumberU64() { if consensus.Blockchain.CurrentBlock().NumberU64() < blk.NumberU64() {
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, true); err != nil { if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, !consensus.FBFTLog.IsBlockVerified(blk)); err != nil {
consensus.getLogger().Error().Err(err).Msg("[commitBlock] Failed to add block to chain") consensus.getLogger().Error().Err(err).Msg("[commitBlock] Failed to add block to chain")
return err return err
} }

@ -296,6 +296,7 @@ func (consensus *Consensus) onCommit(recvMsg *FBFTMessage) {
if !quorumWasMet && quorumIsMet { if !quorumWasMet && quorumIsMet {
logger.Info().Msg("[OnCommit] 2/3 Enough commits received") logger.Info().Msg("[OnCommit] 2/3 Enough commits received")
consensus.FBFTLog.MarkBlockVerified(blockObj)
if !blockObj.IsLastBlockInEpoch() { if !blockObj.IsLastBlockInEpoch() {
// only do early commit if it's not epoch block to avoid problems // only do early commit if it's not epoch block to avoid problems

@ -122,7 +122,7 @@ func (node *Node) explorerMessageHandler(ctx context.Context, msg *msg_pb.Messag
// AddNewBlockForExplorer add new block for explorer. // AddNewBlockForExplorer add new block for explorer.
func (node *Node) AddNewBlockForExplorer(block *types.Block) { func (node *Node) AddNewBlockForExplorer(block *types.Block) {
utils.Logger().Info().Uint64("blockHeight", block.NumberU64()).Msg("[Explorer] Adding new block for explorer node") utils.Logger().Info().Uint64("blockHeight", block.NumberU64()).Msg("[Explorer] Adding new block for explorer node")
if _, err := node.Blockchain().InsertChain([]*types.Block{block}, true); err == nil { if _, err := node.Blockchain().InsertChain([]*types.Block{block}, false); err == nil {
if block.IsLastBlockInEpoch() { if block.IsLastBlockInEpoch() {
node.Consensus.UpdateConsensusInformation() node.Consensus.UpdateConsensusInformation()
} }

Loading…
Cancel
Save