pull/3405/head
Rongjian Lan 4 years ago
parent a36da0c28d
commit 5e90f2fc98
  1. 4
      consensus/consensus_v2.go
  2. 2
      consensus/leader.go
  3. 4
      consensus/quorum/one-node-staked-vote.go
  4. 6
      consensus/validator.go

@ -156,7 +156,7 @@ func (consensus *Consensus) finalCommit() {
// included in the next block and sent in next prepared message. // included in the next block and sent in next prepared message.
sendImmediately := false sendImmediately := false
if !consensus.IsLeader() { if !consensus.IsLeader() || block.IsLastBlockInEpoch() {
sendImmediately = true sendImmediately = true
} }
if err := consensus.msgSender.SendWithRetry( if err := consensus.msgSender.SendWithRetry(
@ -522,6 +522,7 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
// If I am still the leader // If I am still the leader
//if consensus.IsLeader() { //if consensus.IsLeader() {
// if leader success finalize the block, send committed message to validators // if leader success finalize the block, send committed message to validators
if !blk.IsLastBlockInEpoch() {
if err := consensus.msgSender.SendWithRetry( if err := consensus.msgSender.SendWithRetry(
blk.NumberU64(), blk.NumberU64(),
msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{ msg_pb.MessageType_COMMITTED, []nodeconfig.GroupID{
@ -535,6 +536,7 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
Uint64("blockNum", consensus.blockNum). Uint64("blockNum", consensus.blockNum).
Msg("[preCommitAndPropose] Sent Committed Message") Msg("[preCommitAndPropose] Sent Committed Message")
} }
}
// Send signal to Node to propose the new block for consensus // Send signal to Node to propose the new block for consensus
consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] sending block proposal signal") consensus.getLogger().Warn().Err(err).Msg("[preCommitAndPropose] sending block proposal signal")

@ -202,7 +202,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
func (consensus *Consensus) onCommit(msg *msg_pb.Message) { func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
utils.Logger().Info().Msgf("ViewChanging %d %d", consensus.GetCurBlockViewID(), consensus.GetViewChangingID()) utils.Logger().Info().Msgf("ViewChanging %d %d", consensus.GetCurBlockViewID(), consensus.GetViewChangingID())
if consensus.GetCurBlockViewID()%7 == 0 { if consensus.GetCurBlockViewID()%8== 0 {
return return
} }
recvMsg, err := consensus.ParseFBFTMessage(msg) recvMsg, err := consensus.ParseFBFTMessage(msg)

@ -112,12 +112,12 @@ func (v *stakedVoteWeight) AddNewVote(
t := v.QuorumThreshold() t := v.QuorumThreshold()
msg := "Attempt to reach quorum" msg := "[AddNewVote] New Vote Added!"
if !tallyQuorum.quorumAchieved { if !tallyQuorum.quorumAchieved {
tallyQuorum.quorumAchieved = tallyQuorum.tally.GT(t) tallyQuorum.quorumAchieved = tallyQuorum.tally.GT(t)
if tallyQuorum.quorumAchieved { if tallyQuorum.quorumAchieved {
msg = "Quorum Achieved!" msg = "[AddNewVote] Quorum Achieved!"
} }
} }
utils.Logger().Info(). utils.Logger().Info().

@ -1,12 +1,11 @@
package consensus package consensus
import ( import (
"bytes"
"encoding/hex" "encoding/hex"
"time" "time"
"github.com/harmony-one/harmony/crypto/bls" "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/common"
"github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/rlp"
@ -224,10 +223,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) {
consensus.prepareBitmap = mask consensus.prepareBitmap = mask
// Optimistically add blockhash field of prepare message // 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. // tryCatchup is also run in onCommitted(), so need to lock with commitMutex.
if consensus.current.Mode() != Normal { if consensus.current.Mode() != Normal {

Loading…
Cancel
Save