diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index b2120a0e8..8e45c8c4f 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -156,7 +156,7 @@ func (consensus *Consensus) finalCommit() { // included in the next block and sent in next prepared message. sendImmediately := false - if !consensus.IsLeader() { + if !consensus.IsLeader() || block.IsLastBlockInEpoch() { sendImmediately = true } if err := consensus.msgSender.SendWithRetry( @@ -522,18 +522,20 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error { // If I am still the leader //if consensus.IsLeader() { // if leader success finalize the block, send committed message to validators - if err := consensus.msgSender.SendWithRetry( - blk.NumberU64(), - msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ - nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), - }, - p2p.ConstructMessage(msgToSend), true); err != nil { - consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] Cannot send committed message") - } else { - consensus.getLogger().Info(). - Str("blockHash", blk.Hash().Hex()). - Uint64("blockNum", consensus.blockNum). - Msg("[preCommitAndPropose] Sent Committed Message") + if !blk.IsLastBlockInEpoch() { + if err := consensus.msgSender.SendWithRetry( + blk.NumberU64(), + msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ + nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID)), + }, + p2p.ConstructMessage(msgToSend), true); err != nil { + consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] Cannot send committed message") + } else { + consensus.getLogger().Info(). + Str("blockHash", blk.Hash().Hex()). + Uint64("blockNum", consensus.blockNum). + Msg("[preCommitAndPropose] Sent Committed Message") + } } // Send signal to Node to propose the new block for consensus diff --git a/consensus/leader.go b/consensus/leader.go index e5b614c8b..a03dab0f7 100644 --- a/consensus/leader.go +++ b/consensus/leader.go @@ -202,7 +202,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { func (consensus *Consensus) onCommit(msg *msg_pb.Message) { utils.Logger().Info().Msgf("ViewChanging %d %d", consensus.GetCurBlockViewID(), consensus.GetViewChangingID()) - if consensus.GetCurBlockViewID()%7 == 0 { + if consensus.GetCurBlockViewID()%8== 0 { return } recvMsg, err := consensus.ParseFBFTMessage(msg) diff --git a/consensus/quorum/one-node-staked-vote.go b/consensus/quorum/one-node-staked-vote.go index 0f65257c9..f0099f968 100644 --- a/consensus/quorum/one-node-staked-vote.go +++ b/consensus/quorum/one-node-staked-vote.go @@ -112,12 +112,12 @@ func (v *stakedVoteWeight) AddNewVote( t := v.QuorumThreshold() - msg := "Attempt to reach quorum" + msg := "[AddNewVote] New Vote Added!" if !tallyQuorum.quorumAchieved { tallyQuorum.quorumAchieved = tallyQuorum.tally.GT(t) if tallyQuorum.quorumAchieved { - msg = "Quorum Achieved!" + msg = "[AddNewVote] Quorum Achieved!" } } utils.Logger().Info(). diff --git a/consensus/validator.go b/consensus/validator.go index 275421ad4..57e73cf80 100644 --- a/consensus/validator.go +++ b/consensus/validator.go @@ -1,12 +1,11 @@ package consensus import ( - "bytes" "encoding/hex" "time" "github.com/harmony-one/harmony/crypto/bls" - nodeconfig "github.com/harmony-one/harmony/internal/configs/node" + "github.com/harmony-one/harmony/internal/configs/node" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/rlp" @@ -224,10 +223,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { consensus.prepareBitmap = mask // Optimistically add blockhash field of prepare message - emptyHash := [32]byte{} - if bytes.Equal(consensus.blockHash[:], emptyHash[:]) { - copy(consensus.blockHash[:], blockHash[:]) - } + copy(consensus.blockHash[:], blockHash[:]) // tryCatchup is also run in onCommitted(), so need to lock with commitMutex. if consensus.current.Mode() != Normal {