|
|
@ -9,7 +9,6 @@ import ( |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
"github.com/ethereum/go-ethereum/common" |
|
|
|
msg_pb "github.com/harmony-one/harmony/api/proto/message" |
|
|
|
msg_pb "github.com/harmony-one/harmony/api/proto/message" |
|
|
|
"github.com/harmony-one/harmony/consensus/quorum" |
|
|
|
"github.com/harmony-one/harmony/consensus/quorum" |
|
|
|
"github.com/harmony-one/harmony/consensus/signature" |
|
|
|
|
|
|
|
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" |
|
|
|
nodeconfig "github.com/harmony-one/harmony/internal/configs/node" |
|
|
|
"github.com/harmony-one/harmony/internal/utils" |
|
|
|
"github.com/harmony-one/harmony/internal/utils" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
|
"github.com/harmony-one/harmony/p2p" |
|
|
@ -381,6 +380,8 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.consensusTimeout[timeoutViewChange].Stop() |
|
|
|
|
|
|
|
|
|
|
|
// newView message verified success, override my state
|
|
|
|
// newView message verified success, override my state
|
|
|
|
consensus.SetViewIDs(recvMsg.ViewID) |
|
|
|
consensus.SetViewIDs(recvMsg.ViewID) |
|
|
|
consensus.LeaderPubKey = recvMsg.SenderPubkey |
|
|
|
consensus.LeaderPubKey = recvMsg.SenderPubkey |
|
|
@ -388,31 +389,7 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) { |
|
|
|
|
|
|
|
|
|
|
|
// NewView message is verified, change state to normal consensus
|
|
|
|
// NewView message is verified, change state to normal consensus
|
|
|
|
if preparedBlock != nil { |
|
|
|
if preparedBlock != nil { |
|
|
|
// Construct and send the commit message
|
|
|
|
consensus.sendCommitMessages(preparedBlock) |
|
|
|
commitPayload := signature.ConstructCommitPayload(consensus.ChainReader, |
|
|
|
|
|
|
|
preparedBlock.Epoch(), preparedBlock.Hash(), preparedBlock.NumberU64(), preparedBlock.Header().ViewID().Uint64()) |
|
|
|
|
|
|
|
groupID := []nodeconfig.GroupID{ |
|
|
|
|
|
|
|
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))} |
|
|
|
|
|
|
|
for _, key := range consensus.priKey { |
|
|
|
|
|
|
|
if !consensus.IsValidatorInCommittee(key.Pub.Bytes) { |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
network, err := consensus.construct( |
|
|
|
|
|
|
|
msg_pb.MessageType_COMMIT, |
|
|
|
|
|
|
|
commitPayload, |
|
|
|
|
|
|
|
&key, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
consensus.getLogger().Err(err).Msg("could not create commit message") |
|
|
|
|
|
|
|
continue |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
msgToSend := network.Bytes |
|
|
|
|
|
|
|
consensus.getLogger().Info().Msg("onNewView === commit") |
|
|
|
|
|
|
|
consensus.host.SendMessageToGroups( |
|
|
|
|
|
|
|
groupID, |
|
|
|
|
|
|
|
p2p.ConstructMessage(msgToSend), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
consensus.switchPhase("onNewView", FBFTCommit) |
|
|
|
consensus.switchPhase("onNewView", FBFTCommit) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
consensus.ResetState() |
|
|
|
consensus.ResetState() |
|
|
@ -422,7 +399,6 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) { |
|
|
|
Str("newLeaderKey", consensus.LeaderPubKey.Bytes.Hex()). |
|
|
|
Str("newLeaderKey", consensus.LeaderPubKey.Bytes.Hex()). |
|
|
|
Msg("new leader changed") |
|
|
|
Msg("new leader changed") |
|
|
|
consensus.consensusTimeout[timeoutConsensus].Start() |
|
|
|
consensus.consensusTimeout[timeoutConsensus].Start() |
|
|
|
consensus.consensusTimeout[timeoutViewChange].Stop() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// ResetViewChangeState resets the view change structure
|
|
|
|
// ResetViewChangeState resets the view change structure
|
|
|
|