|
|
@ -153,8 +153,16 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { |
|
|
|
if !consensus.onPreparedSanityChecks(&blockObj, recvMsg) { |
|
|
|
if !consensus.onPreparedSanityChecks(&blockObj, recvMsg) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnPrepared] Received OnPrepared message11111111") |
|
|
|
consensus.mutex.Lock() |
|
|
|
consensus.mutex.Lock() |
|
|
|
defer consensus.mutex.Unlock() |
|
|
|
defer consensus.mutex.Unlock() |
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnPrepared] Received OnPrepared message222222") |
|
|
|
|
|
|
|
|
|
|
|
if consensus.BlockVerifier == nil { |
|
|
|
if consensus.BlockVerifier == nil { |
|
|
|
consensus.getLogger().Debug().Msg("[onPrepared] consensus received message before init. Ignoring") |
|
|
|
consensus.getLogger().Debug().Msg("[onPrepared] consensus received message before init. Ignoring") |
|
|
@ -164,9 +172,21 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { |
|
|
|
consensus.getLogger().Error().Err(err).Msg("[OnPrepared] Block verification failed") |
|
|
|
consensus.getLogger().Error().Err(err).Msg("[OnPrepared] Block verification failed") |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnPrepared] Received OnPrepared message3333") |
|
|
|
consensus.FBFTLog.MarkBlockVerified(&blockObj) |
|
|
|
consensus.FBFTLog.MarkBlockVerified(&blockObj) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnPrepared] Received OnPrepared message44444") |
|
|
|
consensus.FBFTLog.AddBlock(&blockObj) |
|
|
|
consensus.FBFTLog.AddBlock(&blockObj) |
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnPrepared] Received OnPrepared message555555") |
|
|
|
// add block field
|
|
|
|
// add block field
|
|
|
|
blockPayload := make([]byte, len(recvMsg.Block)) |
|
|
|
blockPayload := make([]byte, len(recvMsg.Block)) |
|
|
|
copy(blockPayload[:], recvMsg.Block[:]) |
|
|
|
copy(blockPayload[:], recvMsg.Block[:]) |
|
|
@ -247,6 +267,10 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
consensus.spinUpStateSync() |
|
|
|
consensus.spinUpStateSync() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message11111111") |
|
|
|
aggSig, mask, err := consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 0) |
|
|
|
aggSig, mask, err := consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 0) |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
consensus.getLogger().Error().Err(err).Msg("[OnCommitted] readSignatureBitmapPayload failed") |
|
|
|
consensus.getLogger().Error().Err(err).Msg("[OnCommitted] readSignatureBitmapPayload failed") |
|
|
@ -257,6 +281,13 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.mutex.Lock() |
|
|
|
|
|
|
|
defer consensus.mutex.Unlock() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message222222") |
|
|
|
// Must have the corresponding block to verify committed message.
|
|
|
|
// Must have the corresponding block to verify committed message.
|
|
|
|
blockObj := consensus.FBFTLog.GetBlockByHash(recvMsg.BlockHash) |
|
|
|
blockObj := consensus.FBFTLog.GetBlockByHash(recvMsg.BlockHash) |
|
|
|
if blockObj == nil { |
|
|
|
if blockObj == nil { |
|
|
@ -267,6 +298,10 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
Msg("[OnCommitted] Failed finding a matching block for committed message") |
|
|
|
Msg("[OnCommitted] Failed finding a matching block for committed message") |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message333333") |
|
|
|
commitPayload := signature.ConstructCommitPayload(consensus.Blockchain, |
|
|
|
commitPayload := signature.ConstructCommitPayload(consensus.Blockchain, |
|
|
|
blockObj.Epoch(), blockObj.Hash(), blockObj.NumberU64(), blockObj.Header().ViewID().Uint64()) |
|
|
|
blockObj.Epoch(), blockObj.Hash(), blockObj.NumberU64(), blockObj.Header().ViewID().Uint64()) |
|
|
|
if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) { |
|
|
|
if !aggSig.VerifyHash(mask.AggregatePublic, commitPayload) { |
|
|
@ -276,11 +311,21 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message444444") |
|
|
|
consensus.FBFTLog.AddMessage(recvMsg) |
|
|
|
consensus.FBFTLog.AddMessage(recvMsg) |
|
|
|
|
|
|
|
|
|
|
|
consensus.mutex.Lock() |
|
|
|
consensus.getLogger().Info(). |
|
|
|
defer consensus.mutex.Unlock() |
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message555555") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
consensus.getLogger().Info(). |
|
|
|
|
|
|
|
Uint64("MsgBlockNum", recvMsg.BlockNum). |
|
|
|
|
|
|
|
Uint64("MsgViewID", recvMsg.ViewID). |
|
|
|
|
|
|
|
Msg("[OnCommitted] Received committed message666666") |
|
|
|
consensus.aggregatedCommitSig = aggSig |
|
|
|
consensus.aggregatedCommitSig = aggSig |
|
|
|
consensus.commitBitmap = mask |
|
|
|
consensus.commitBitmap = mask |
|
|
|
|
|
|
|
|
|
|
|