From d23cadf79f24a76e2604f55f1ef1a56fff4880a6 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sun, 16 Jun 2019 12:04:54 -0700 Subject: [PATCH 1/8] add index information of leader in HOORAY message --- consensus/consensus_v2.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 975cff0c7..c1833c70a 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -589,7 +589,7 @@ func (consensus *Consensus) finalizeCommits() { consensus.consensusTimeout[timeoutConsensus].Start() consensus.OnConsensusDone(&blockObj) - consensus.getLogger().Info("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!", "numOfSignatures", len(consensus.commitSigs), "BlockNum", consensus.blockNum-1, "ViewId", consensus.viewID-1, "BlockHash", blockObj.Hash()) + consensus.getLogger().Info("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!", "numOfSignatures", len(consensus.commitSigs), "BlockNum", consensus.blockNum-1, "ViewId", consensus.viewID-1, "BlockHash", blockObj.Hash(), "index", consensus.getIndexOfPubKey(consensus.PubKey)) // TODO: wait for validators receive committed message; remove this temporary delay time.Sleep(time.Second) From 2a08057b5f6c43496a1426aba217d5906e56d068 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sun, 16 Jun 2019 13:19:44 -0700 Subject: [PATCH 2/8] in sync trigger buffer changed from 10 to 2; not continue if not catchup in view changing mode --- consensus/config.go | 2 +- consensus/consensus_v2.go | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/consensus/config.go b/consensus/config.go index 28eced21d..614154d7a 100644 --- a/consensus/config.go +++ b/consensus/config.go @@ -14,7 +14,7 @@ const ( bootstrapDuration time.Duration = 300 * time.Second maxLogSize uint32 = 1000 // threshold between received consensus message blockNum and my blockNum - consensusBlockNumBuffer uint64 = 10 + consensusBlockNumBuffer uint64 = 2 ) // TimeoutType is the type of timeout in view change protocol diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index c1833c70a..34d97de83 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -176,13 +176,13 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { consensus.pbftLog.AddMessage(recvMsg) consensus.pbftLog.AddBlock(&blockObj) + consensus.tryCatchup() // we have already added message and block, skip check viewID and send prepare message if is in ViewChanging mode if consensus.mode.Mode() == ViewChanging { + consensus.getLogger().Debug("[OnAnnounce] Still in ViewChanging Mode, Exiting !!") return } - consensus.tryCatchup() - consensus.mutex.Lock() defer consensus.mutex.Unlock() @@ -383,13 +383,12 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { consensus.getLogger().Debug("[OnPrepared] Prepared message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) consensus.pbftLog.AddMessage(recvMsg) + consensus.tryCatchup() if consensus.mode.Mode() == ViewChanging { - consensus.getLogger().Debug("[OnPrepared] Exiting after viewchange!!") + consensus.getLogger().Debug("[OnPrepared] Still in ViewChanging mode, Exiting !!") return } - consensus.tryCatchup() - if consensus.checkViewID(recvMsg) != nil { consensus.getLogger().Debug("[OnPrepared] ViewID check failed", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) return @@ -678,6 +677,10 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { // } consensus.tryCatchup() + if consensus.mode.Mode() == ViewChanging { + consensus.getLogger().Debug("[OnCommitted] Still in ViewChanging mode, Exiting !!") + return + } if consensus.consensusTimeout[timeoutBootstrap].IsActive() { consensus.consensusTimeout[timeoutBootstrap].Stop() From 4ea2e34af00259377ad30ba1c957f82aafa61927 Mon Sep 17 00:00:00 2001 From: chao Date: Sat, 15 Jun 2019 22:58:08 -0700 Subject: [PATCH 3/8] move block from announce to prepared message --- api/proto/message/message.pb.go | 129 ++++++++++++++++-------------- api/proto/message/message.proto | 1 + consensus/consensus_leader_msg.go | 4 +- 3 files changed, 72 insertions(+), 62 deletions(-) diff --git a/api/proto/message/message.pb.go b/api/proto/message/message.pb.go index a399cf042..3163f138a 100644 --- a/api/proto/message/message.pb.go +++ b/api/proto/message/message.pb.go @@ -527,6 +527,7 @@ type ConsensusRequest struct { BlockHash []byte `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` SenderPubkey []byte `protobuf:"bytes,5,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` + Block []byte `protobuf:"bytes,7,opt,name=block,proto3" json:"block,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -599,6 +600,13 @@ func (m *ConsensusRequest) GetPayload() []byte { return nil } +func (m *ConsensusRequest) GetBlock() []byte { + if m != nil { + return m.Block + } + return nil +} + type DrandRequest struct { ShardId uint32 `protobuf:"varint,1,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` SenderPubkey []byte `protobuf:"bytes,2,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` @@ -808,66 +816,67 @@ func init() { func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 934 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xdf, 0x6e, 0xe2, 0x46, - 0x14, 0xc6, 0x31, 0x10, 0x0c, 0xc7, 0x86, 0xcc, 0x4e, 0xdb, 0x5d, 0x6f, 0xba, 0x55, 0x23, 0x56, - 0x95, 0xa2, 0x95, 0x1a, 0xad, 0xe0, 0xa2, 0xaa, 0xd4, 0x1b, 0x02, 0xa3, 0xc4, 0x4a, 0x62, 0xe8, - 0xe0, 0x6c, 0xd4, 0x2b, 0x6b, 0x82, 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1, 0x80, 0x04, 0x17, - 0xa4, 0xd7, 0x1f, 0x7a, 0xc1, 0x7a, 0xa9, 0x12, 0xb6, 0xa1, 0xde, 0xf3, 0xbc, 0xe1, 0x9d, 0xd7, - 0x27, 0xc8, 0x90, 0xbb, 0x8c, 0x28, 0x19, 0xf5, 0x28, 0x41, 0x65, 0x99, 0xca, 0x83, 0x01, 0xaa, - 0xc8, 0xfb, 0xdd, 0x1f, 0xde, 0xde, 0xba, 0x3e, 0xaa, 0xea, 0xde, 0xe4, 0x6f, 0x9f, 0x0c, 0xd0, - 0x11, 0x6e, 0x01, 0x7c, 0x70, 0xc9, 0x7d, 0xff, 0xaa, 0xe7, 0x5d, 0x12, 0x54, 0x93, 0xab, 0x78, - 0xe4, 0x5e, 0x4a, 0xc8, 0x94, 0x49, 0xd5, 0x6b, 0xe0, 0x7a, 0xae, 0x8f, 0x00, 0x23, 0xb0, 0x75, - 0x9c, 0xaf, 0x66, 0xe1, 0x2f, 0xe0, 0xf8, 0x66, 0xe8, 0xfb, 0x84, 0xfe, 0x12, 0x50, 0xf2, 0xf3, - 0x1d, 0x19, 0xfb, 0xc8, 0xee, 0xf4, 0xa0, 0xd9, 0x9f, 0x45, 0x3c, 0xce, 0x72, 0x4f, 0xf0, 0x7b, - 0x30, 0x47, 0x69, 0x32, 0xe1, 0x42, 0x60, 0xb4, 0xff, 0x66, 0x9f, 0xbc, 0xd8, 0x28, 0xeb, 0x67, - 0xb5, 0x5d, 0x7a, 0xa8, 0xa9, 0xff, 0xfd, 0xee, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xe3, 0x60, - 0x9a, 0xe1, 0x08, 0x08, 0x00, 0x00, + // 946 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0xdf, 0x6e, 0xe2, 0xc6, + 0x17, 0xc7, 0x31, 0xff, 0x0c, 0xc7, 0x86, 0xcc, 0xce, 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xef, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x88, 0xb0, 0x14, 0x1e, 0x08, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/api/proto/message/message.proto b/api/proto/message/message.proto index 893a06a94..ccf8d4739 100644 --- a/api/proto/message/message.proto +++ b/api/proto/message/message.proto @@ -86,6 +86,7 @@ message ConsensusRequest { bytes block_hash = 4; bytes sender_pubkey = 5; bytes payload = 6; + bytes block = 7; } message DrandRequest { diff --git a/consensus/consensus_leader_msg.go b/consensus/consensus_leader_msg.go index 7f760c9e2..d44b66bac 100644 --- a/consensus/consensus_leader_msg.go +++ b/consensus/consensus_leader_msg.go @@ -21,8 +21,6 @@ func (consensus *Consensus) constructAnnounceMessage() []byte { } consensusMsg := message.GetConsensus() consensus.populateMessageFields(consensusMsg) - // n byte of block header - consensusMsg.Payload = consensus.block // TODO: send only block header in the announce phase. marshaledMessage, err := consensus.signAndMarshalConsensusMessage(message) if err != nil { @@ -43,6 +41,8 @@ func (consensus *Consensus) constructPreparedMessage() ([]byte, *bls.Sign) { consensusMsg := message.GetConsensus() consensus.populateMessageFields(consensusMsg) + // add block content in prepared message for slow validators to catchup + consensusMsg.Block = consensus.block //// Payload buffer := bytes.NewBuffer([]byte{}) From e74a3983852fcbc2a10000821301b0c4ba15ab6c Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sun, 16 Jun 2019 15:52:52 -0700 Subject: [PATCH 4/8] move block broadcast into prepared phase --- consensus/consensus_v2.go | 109 +++++++++++++++++++------------------- consensus/pbft_log.go | 4 ++ 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 34d97de83..2195ccf46 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -3,6 +3,7 @@ package consensus import ( "bytes" "encoding/binary" + "encoding/hex" "time" "github.com/ethereum/go-ethereum/common" @@ -136,83 +137,51 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { consensus.getLogger().Debug("[OnAnnounce] Unparseable leader message", "error", err, "MsgBlockNum", recvMsg.BlockNum) return } - block := recvMsg.Payload - // check block header is valid - var blockObj types.Block - err = rlp.DecodeBytes(block, &blockObj) - if err != nil { - consensus.getLogger().Warn("[OnAnnounce] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum, "MsgPayloadBlockNum", blockObj.NumberU64()) - return - } - - if blockObj.NumberU64() != recvMsg.BlockNum || recvMsg.BlockNum < consensus.blockNum { - consensus.getLogger().Warn("[OnAnnounce] BlockNum not match", "MsgBlockNum", recvMsg.BlockNum, "blockNum", blockObj.NumberU64()) - return - } - - if consensus.mode.Mode() == Normal { - // skip verify header when node is in Syncing mode - if err := consensus.VerifyHeader(consensus.ChainReader, blockObj.Header(), false); err != nil { - consensus.getLogger().Warn("[OnAnnounce] Block content is not verified successfully", "error", err, "inChain", consensus.ChainReader.CurrentHeader().Number, "MsgBlockNum", blockObj.Header().Number) - return - } - } - - //blockObj.Logger(consensus.getLogger()).Debug("received announce", "viewID", recvMsg.ViewID, "msgBlockNum", recvMsg.BlockNum) logMsgs := consensus.pbftLog.GetMessagesByTypeSeqView(msg_pb.MessageType_ANNOUNCE, recvMsg.BlockNum, recvMsg.ViewID) if len(logMsgs) > 0 { - if logMsgs[0].BlockHash != blockObj.Header().Hash() { + if logMsgs[0].BlockHash != recvMsg.BlockHash { consensus.getLogger().Debug("[OnAnnounce] Leader is malicious", "leaderKey", consensus.LeaderPubKey.SerializeToHexStr()) consensus.startViewChange(consensus.viewID + 1) } return } - blockPayload := make([]byte, len(block)) - copy(blockPayload[:], block[:]) - consensus.block = blockPayload - consensus.blockHash = recvMsg.BlockHash - consensus.getLogger().Debug("[OnAnnounce] Announce Block Added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) + + consensus.getLogger().Debug("[OnAnnounce] Announce message Added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) consensus.pbftLog.AddMessage(recvMsg) - consensus.pbftLog.AddBlock(&blockObj) - consensus.tryCatchup() + consensus.mutex.Lock() + defer consensus.mutex.Unlock() + + consensus.blockHash = recvMsg.BlockHash + // we have already added message and block, skip check viewID and send prepare message if is in ViewChanging mode if consensus.mode.Mode() == ViewChanging { consensus.getLogger().Debug("[OnAnnounce] Still in ViewChanging Mode, Exiting !!") return } - consensus.mutex.Lock() - defer consensus.mutex.Unlock() - if consensus.checkViewID(recvMsg) != nil { consensus.getLogger().Debug("[OnAnnounce] ViewID check failed", "MsgViewID", recvMsg.ViewID, "msgBlockNum", recvMsg.BlockNum) return } - consensus.prepare(&blockObj) + consensus.prepare() return } // tryPrepare will try to send prepare message -func (consensus *Consensus) prepare(block *types.Block) { - // if consensus.blockNum != block.NumberU64() || !consensus.pbftLog.HasMatchingViewAnnounce(consensus.blockNum, consensus.viewID, hash) { - // consensus.getLogger().Debug("blockNum or announce message not match") - // return - // } - - consensus.getLogger().Debug("[Announce] Switching Phase", "From", consensus.phase, "To", Prepare) - consensus.switchPhase(Prepare, true) - +func (consensus *Consensus) prepare() { // Construct and send prepare message msgToSend := consensus.constructPrepareMessage() // TODO: this will not return immediatey, may block if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { consensus.getLogger().Warn("[OnAnnounce] Cannot send prepare message") } else { - consensus.getLogger().Info("[OnAnnounce] Sent Prepare Message!!", "BlockHash", block.Hash(), "BlockNum", block.NumberU64()) + consensus.getLogger().Info("[OnAnnounce] Sent Prepare Message!!", "BlockHash", hex.EncodeToString(consensus.blockHash[:])) } + consensus.getLogger().Debug("[Announce] Switching Phase", "From", consensus.phase, "To", Prepare) + consensus.switchPhase(Prepare, true) } // TODO: move to consensus_leader.go later @@ -357,22 +326,17 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { return } + // check validity of prepared signature blockHash := recvMsg.BlockHash aggSig, mask, err := consensus.readSignatureBitmapPayload(recvMsg.Payload, 0) if err != nil { consensus.getLogger().Error("ReadSignatureBitmapPayload failed!!", "error", err) return } - - consensus.mutex.Lock() - defer consensus.mutex.Unlock() - - // check has 2f+1 signatures if count := utils.CountOneBits(mask.Bitmap); count < consensus.Quorum() { consensus.getLogger().Debug("Not enough signatures in the Prepared msg", "Need", consensus.Quorum(), "Got", count) return } - if !aggSig.VerifyHash(mask.AggregatePublic, blockHash[:]) { myBlockHash := common.Hash{} myBlockHash.SetBytes(consensus.blockHash[:]) @@ -380,9 +344,37 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { return } - consensus.getLogger().Debug("[OnPrepared] Prepared message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) + // check validity of block + block := recvMsg.Block + var blockObj types.Block + err = rlp.DecodeBytes(block, &blockObj) + if err != nil { + consensus.getLogger().Warn("[OnPrepared] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum, "MsgPayloadBlockNum", blockObj.NumberU64()) + return + } + if blockObj.NumberU64() != recvMsg.BlockNum || recvMsg.BlockNum < consensus.blockNum { + consensus.getLogger().Warn("[OnPrepared] BlockNum not match", "MsgBlockNum", recvMsg.BlockNum, "blockNum", blockObj.NumberU64()) + return + } + if blockObj.Header().Hash() != recvMsg.BlockHash { + consensus.getLogger().Warn("[OnPrepared] BlockHash not match", "MsgBlockNum", recvMsg.BlockNum, "MsgBlockHash", recvMsg.BlockHash, "blockObjHash", blockObj.Header().Hash()) + return + } + if consensus.mode.Mode() == Normal { + if err := consensus.VerifyHeader(consensus.ChainReader, blockObj.Header(), false); err != nil { + consensus.getLogger().Warn("[OnPrepared] Block content is not verified successfully", "error", err, "inChain", consensus.ChainReader.CurrentHeader().Number, "MsgBlockNum", blockObj.Header().Number) + return + } + } + + consensus.getLogger().Debug("[OnPrepared] Prepared message and block added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum, "blockHash", recvMsg.BlockHash) + consensus.pbftLog.AddBlock(&blockObj) + recvMsg.Block = []byte{} // save memory space consensus.pbftLog.AddMessage(recvMsg) + consensus.mutex.Lock() + defer consensus.mutex.Unlock() + consensus.tryCatchup() if consensus.mode.Mode() == ViewChanging { consensus.getLogger().Debug("[OnPrepared] Still in ViewChanging mode, Exiting !!") @@ -399,10 +391,16 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { return } + // add block field + blockPayload := make([]byte, len(block)) + copy(blockPayload[:], block[:]) + consensus.block = blockPayload + + // add preparedSig field consensus.aggregatedPrepareSig = aggSig consensus.prepareBitmap = mask - // Optimistically sign on the blockhash of prepare message + // Optimistically add blockhash field of prepare message emptyHash := [32]byte{} if bytes.Compare(consensus.blockHash[:], emptyHash[:]) == 0 { copy(consensus.blockHash[:], blockHash[:]) @@ -648,13 +646,14 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { return } + consensus.getLogger().Debug("[OnCommitted] Committed message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) + consensus.pbftLog.AddMessage(recvMsg) + consensus.mutex.Lock() defer consensus.mutex.Unlock() consensus.aggregatedCommitSig = aggSig consensus.commitBitmap = mask - consensus.getLogger().Debug("[OnCommitted] Committed message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) - consensus.pbftLog.AddMessage(recvMsg) if recvMsg.BlockNum-consensus.blockNum > consensusBlockNumBuffer { consensus.getLogger().Debug("[OnCommitted] out of sync", "MsgBlockNum", recvMsg.BlockNum) diff --git a/consensus/pbft_log.go b/consensus/pbft_log.go index 892da2c0c..abc8d9a48 100644 --- a/consensus/pbft_log.go +++ b/consensus/pbft_log.go @@ -27,6 +27,7 @@ type PbftMessage struct { ViewID uint32 BlockNum uint64 BlockHash common.Hash + Block []byte SenderPubkey *bls.PublicKey LeaderPubkey *bls.PublicKey Payload []byte @@ -217,6 +218,9 @@ func ParsePbftMessage(msg *msg_pb.Message) (*PbftMessage, error) { copy(pbftMsg.BlockHash[:], consensusMsg.BlockHash[:]) pbftMsg.Payload = make([]byte, len(consensusMsg.Payload)) copy(pbftMsg.Payload[:], consensusMsg.Payload[:]) + pbftMsg.Block = make([]byte, len(consensusMsg.Block)) + copy(pbftMsg.Block[:], consensusMsg.Block[:]) + pubKey, err := bls_cosi.BytesToBlsPublicKey(consensusMsg.SenderPubkey) if err != nil { return nil, err From 4d21380604cff0b308704fe540bf9369f587912e Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sun, 16 Jun 2019 21:00:10 -0700 Subject: [PATCH 5/8] change location of consensus message protobuf --- api/proto/message/message.pb.go | 140 ++++++++++++++++---------------- api/proto/message/message.proto | 6 +- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/api/proto/message/message.pb.go b/api/proto/message/message.pb.go index 3163f138a..2655781f7 100644 --- a/api/proto/message/message.pb.go +++ b/api/proto/message/message.pb.go @@ -525,9 +525,9 @@ type ConsensusRequest struct { BlockNum uint64 `protobuf:"varint,2,opt,name=block_num,json=blockNum,proto3" json:"block_num,omitempty"` ShardId uint32 `protobuf:"varint,3,opt,name=shard_id,json=shardId,proto3" json:"shard_id,omitempty"` BlockHash []byte `protobuf:"bytes,4,opt,name=block_hash,json=blockHash,proto3" json:"block_hash,omitempty"` - SenderPubkey []byte `protobuf:"bytes,5,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` - Payload []byte `protobuf:"bytes,6,opt,name=payload,proto3" json:"payload,omitempty"` - Block []byte `protobuf:"bytes,7,opt,name=block,proto3" json:"block,omitempty"` + Block []byte `protobuf:"bytes,5,opt,name=block,proto3" json:"block,omitempty"` + SenderPubkey []byte `protobuf:"bytes,6,opt,name=sender_pubkey,json=senderPubkey,proto3" json:"sender_pubkey,omitempty"` + Payload []byte `protobuf:"bytes,7,opt,name=payload,proto3" json:"payload,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -586,23 +586,23 @@ func (m *ConsensusRequest) GetBlockHash() []byte { return nil } -func (m *ConsensusRequest) GetSenderPubkey() []byte { +func (m *ConsensusRequest) GetBlock() []byte { if m != nil { - return m.SenderPubkey + return m.Block } return nil } -func (m *ConsensusRequest) GetPayload() []byte { +func (m *ConsensusRequest) GetSenderPubkey() []byte { if m != nil { - return m.Payload + return m.SenderPubkey } return nil } -func (m *ConsensusRequest) GetBlock() []byte { +func (m *ConsensusRequest) GetPayload() []byte { if m != nil { - return m.Block + return m.Payload } return nil } @@ -816,67 +816,67 @@ func init() { func init() { proto.RegisterFile("message.proto", fileDescriptor_33c57e4bae7b9afd) } var fileDescriptor_33c57e4bae7b9afd = []byte{ - // 946 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x96, 0xdf, 0x6e, 0xe2, 0xc6, - 0x17, 0xc7, 0x31, 0xff, 0x0c, 0xc7, 0x86, 0xcc, 0xce, 0x6f, 0x7f, 0xbb, 0xde, 0x74, 0xab, 0x46, - 0xac, 0x2a, 0x45, 0x2b, 0x35, 0x5a, 0xc1, 0x45, 0x55, 0xa9, 0x37, 0x04, 0x46, 0x89, 0x95, 0xc4, - 0xd0, 0xc1, 0xd9, 0xa8, 0x57, 0xd6, 0x04, 0x8f, 0x88, 0x15, 0xb0, 0xa9, 0xc7, 0x64, 0xc5, 0x0b, - 0xb4, 0x0f, 0xd3, 0xfb, 0x5e, 0xb7, 0x4f, 0xd1, 0xd7, 0xa9, 0x66, 0xc6, 0x60, 0x20, 0x5b, 0xf5, - 0xa6, 0xea, 0x1d, 0xe7, 0x7b, 0xce, 0xe7, 0xf8, 0x9c, 0xaf, 0x3d, 0x23, 0xa0, 0xb5, 0xe0, 0x42, - 0xb0, 0x19, 0x3f, 0x5b, 0xa6, 0x49, 0x96, 0x60, 0x33, 0x0f, 0x3b, 0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0x1f, 0xad, 0xfe, 0x1a, 0xda, 0xc5, - 0x95, 0x14, 0x88, 0x68, 0x96, 0x7b, 0xde, 0x2a, 0xd4, 0x49, 0x34, 0x93, 0x56, 0x49, 0x21, 0x0a, - 0x55, 0x49, 0x43, 0x5b, 0xa5, 0x95, 0x3c, 0xbd, 0xe8, 0x06, 0x6c, 0x36, 0x13, 0xd1, 0x4c, 0x38, - 0x4d, 0x9d, 0x5e, 0x74, 0xfb, 0x5a, 0x90, 0x06, 0x2c, 0xba, 0xc1, 0x7d, 0x94, 0x2d, 0xd8, 0xd2, - 0x01, 0x95, 0x6d, 0x2c, 0xba, 0xe7, 0x2a, 0x56, 0x6c, 0x6f, 0xcb, 0x5a, 0x39, 0xdb, 0xdb, 0x65, - 0x7b, 0x1b, 0xd6, 0xce, 0xd9, 0x9e, 0x66, 0xdf, 0x5f, 0x82, 0xb5, 0x73, 0x93, 0xe1, 0x16, 0x34, - 0x07, 0x23, 0x6f, 0x42, 0xbc, 0xc9, 0xed, 0x04, 0x95, 0xb0, 0x05, 0xe6, 0xc4, 0xef, 0x5f, 0xb9, - 0xde, 0x05, 0x32, 0xe4, 0x61, 0x1c, 0xd2, 0xbe, 0x37, 0x44, 0x65, 0x8c, 0xa1, 0x3d, 0xb8, 0x76, - 0x89, 0xe7, 0x07, 0x93, 0xdb, 0xf1, 0x78, 0x44, 0x7d, 0x54, 0x79, 0xff, 0x87, 0x01, 0xd6, 0xce, - 0x1d, 0x87, 0x8f, 0xe1, 0x95, 0x47, 0xee, 0xbc, 0xd1, 0x90, 0x04, 0xe7, 0xa4, 0x3f, 0x18, 0x79, - 0xc1, 0xa6, 0x55, 0x09, 0xdb, 0xd0, 0xe8, 0x7b, 0xde, 0xe8, 0xd6, 0x1b, 0x10, 0x64, 0xc8, 0xa7, - 0x8c, 0x29, 0x19, 0xf7, 0x29, 0x41, 0x65, 0x99, 0xca, 0x83, 0x21, 0xaa, 0xc8, 0x53, 0x3f, 0x18, - 0xdd, 0xdc, 0xb8, 0x3e, 0xaa, 0xea, 0xd9, 0xe4, 0x6f, 0x9f, 0x0c, 0x51, 0x0d, 0xb7, 0x01, 0x3e, - 0xba, 0xe4, 0x6e, 0x70, 0xd9, 0xf7, 0x2e, 0x08, 0xaa, 0xcb, 0x2e, 0x1e, 0xb9, 0x93, 0x12, 0x32, - 0x65, 0x52, 0xcd, 0x1a, 0xb8, 0x9e, 0xeb, 0x23, 0xc0, 0x08, 0x6c, 0x1d, 0xe7, 0xdd, 0x2c, 0xfc, - 0x3f, 0x38, 0xba, 0x1e, 0xf9, 0x3e, 0xa1, 0x3f, 0x06, 0x94, 0xfc, 0x70, 0x4b, 0x26, 0x3e, 0xb2, - 0xbb, 0x7d, 0x68, 0x0d, 0xe6, 0x11, 0x8f, 0xb3, 0xdc, 0x13, 0xfc, 0x01, 0xcc, 0x71, 0x9a, 0x4c, - 0xb9, 0x10, 0x18, 0x1d, 0xde, 0xe4, 0xc7, 0x2f, 0xb6, 0xca, 0xe6, 0xb2, 0xed, 0x94, 0xee, 0xeb, - 0xea, 0xdf, 0x40, 0xef, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf4, 0x88, 0xb0, 0x14, 0x1e, 0x08, - 0x00, 0x00, + // 948 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xdd, 0x6e, 0xe2, 0x46, + 0x14, 0xc6, 0x40, 0x30, 0x1c, 0x1b, 0x32, 0x3b, 0xdd, 0xee, 0x7a, 0xd3, 0xad, 0x1a, 0xb1, 0xaa, + 0x14, 0xad, 0xd4, 0x68, 0x05, 0x17, 0x55, 0xa5, 0xde, 0x10, 0x18, 0x25, 0x56, 0x12, 0x43, 0x07, + 0x67, 0xa3, 0x5e, 0x59, 0x13, 0x3c, 0x22, 0x56, 0xc0, 0xa6, 0x1e, 0x93, 0x15, 0x2f, 0xd0, 0x3e, + 0x4c, 0xef, 0x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1, 0x80, 0x04, 0x17, 0xa4, + 0xd7, 0x1f, 0x7a, 0xc1, 0xba, 0x54, 0x09, 0xdb, 0x50, 0xef, 0x79, 0xde, 0xf0, 0xce, 0xeb, 0x13, + 0x64, 0xc8, 0x53, 0x46, 0x94, 0x8c, 0x7a, 0x94, 0xa0, 0xb2, 0x0c, 0xe5, 0x60, 0x80, 0x2a, 0x72, + 0xeb, 0xfb, 0xc3, 0xdb, 0x5b, 0xd7, 0x47, 0x55, 0xdd, 0x9b, 0xfc, 0xed, 0x93, 0x01, 0x3a, 0xc2, + 0x2d, 0x80, 0x8f, 0x2e, 0xb9, 0xef, 0x5f, 0xf5, 0xbc, 0x4b, 0x82, 0x6a, 0xb2, 0x8a, 0x47, 0xee, + 0x25, 0x85, 0x4c, 0x19, 0x54, 0xbd, 0x06, 0xae, 0xe7, 0xfa, 0x08, 0x30, 0x02, 0x5b, 0xe3, 0xbc, + 0x9a, 0x85, 0xbf, 0x80, 0xe3, 0x9b, 0xa1, 0xef, 0x13, 0xfa, 0x73, 0x40, 0xc9, 0x4f, 0x77, 0x64, + 0xec, 0x23, 0xbb, 0xd3, 0x83, 0x66, 0x7f, 0x16, 0xf1, 0x38, 0xcb, 0x3d, 0xc1, 0x1f, 0xc0, 0x1c, + 0xa5, 0xc9, 0x84, 0x0b, 0x81, 0xd1, 0xfe, 0x4b, 0x7e, 0xf2, 0x62, 0xc3, 0xac, 0x1f, 0xdb, 0x76, + 0xe9, 0xa1, 0xa6, 0xfe, 0x0d, 0x74, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0x3b, 0x51, 0x67, 0xf4, + 0x1e, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/api/proto/message/message.proto b/api/proto/message/message.proto index ccf8d4739..dafd0fc64 100644 --- a/api/proto/message/message.proto +++ b/api/proto/message/message.proto @@ -84,9 +84,9 @@ message ConsensusRequest { uint64 block_num = 2; uint32 shard_id = 3; bytes block_hash = 4; - bytes sender_pubkey = 5; - bytes payload = 6; - bytes block = 7; + bytes block = 5; + bytes sender_pubkey = 6; + bytes payload = 7; } message DrandRequest { From abbadacaa92a1653a937b38d3c2912529f0b36c1 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Sun, 16 Jun 2019 21:15:32 -0700 Subject: [PATCH 6/8] add block header information in announce message; add block header content verification in onAnnounce --- consensus/consensus.go | 2 ++ consensus/consensus_leader_msg.go | 1 + consensus/consensus_v2.go | 39 ++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/consensus/consensus.go b/consensus/consensus.go index 6a4075341..a0d1a622b 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -103,6 +103,8 @@ type Consensus struct { blockHash [32]byte // Block to run consensus on block []byte + // BlockHeader to run consensus on + blockHeader []byte // Array of block hashes. blockHashes [][32]byte // Shard Id which this node belongs to diff --git a/consensus/consensus_leader_msg.go b/consensus/consensus_leader_msg.go index d44b66bac..2ea0545c9 100644 --- a/consensus/consensus_leader_msg.go +++ b/consensus/consensus_leader_msg.go @@ -21,6 +21,7 @@ func (consensus *Consensus) constructAnnounceMessage() []byte { } consensusMsg := message.GetConsensus() consensus.populateMessageFields(consensusMsg) + consensusMsg.Payload = consensus.blockHeader marshaledMessage, err := consensus.signAndMarshalConsensusMessage(message) if err != nil { diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index 2195ccf46..d16854734 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -83,7 +83,14 @@ func (consensus *Consensus) announce(block *types.Block) { consensus.getLogger().Debug("[Announce] Failed encoding block") return } + encodedBlockHeader, err := rlp.EncodeToBytes(block.Header()) + if err != nil { + consensus.getLogger().Debug("[Announce] Failed encoding block header") + return + } + consensus.block = encodedBlock + consensus.blockHeader = encodedBlockHeader msgToSend := consensus.constructAnnounceMessage() consensus.getLogger().Debug("[Announce] Switching phase", "From", consensus.phase, "To", Prepare) consensus.switchPhase(Prepare, true) @@ -138,6 +145,26 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { return } + // verify validity of block header object + blockHeader := recvMsg.Payload + var headerObj types.Header + err = rlp.DecodeBytes(blockHeader, &headerObj) + if err != nil { + consensus.getLogger().Warn("[OnAnnounce] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum, "MsgPayloadBlockNum", headerObj.Number) + return + } + + if recvMsg.BlockNum < consensus.blockNum || recvMsg.BlockNum != headerObj.Number.Uint64() { + consensus.getLogger().Debug("[OnAnnounce] BlockNum not match", "MsgBlockNum", recvMsg.BlockNum, "BlockNum", headerObj.Number) + return + } + if consensus.mode.Mode() == Normal { + if err = consensus.VerifyHeader(consensus.ChainReader, &headerObj, false); err != nil { + consensus.getLogger().Warn("[OnAnnounce] Block content is not verified successfully", "error", err, "inChain", consensus.ChainReader.CurrentHeader().Number, "MsgBlockNum", headerObj.Number) + return + } + } + logMsgs := consensus.pbftLog.GetMessagesByTypeSeqView(msg_pb.MessageType_ANNOUNCE, recvMsg.BlockNum, recvMsg.ViewID) if len(logMsgs) > 0 { if logMsgs[0].BlockHash != recvMsg.BlockHash { @@ -362,15 +389,21 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { } if consensus.mode.Mode() == Normal { if err := consensus.VerifyHeader(consensus.ChainReader, blockObj.Header(), false); err != nil { - consensus.getLogger().Warn("[OnPrepared] Block content is not verified successfully", "error", err, "inChain", consensus.ChainReader.CurrentHeader().Number, "MsgBlockNum", blockObj.Header().Number) + consensus.getLogger().Warn("[OnPrepared] Block header is not verified successfully", "error", err, "inChain", consensus.ChainReader.CurrentHeader().Number, "MsgBlockNum", blockObj.Header().Number) + return + } + if consensus.BlockVerifier == nil { + // do nothing + } else if err := consensus.BlockVerifier(&blockObj); err != nil { + consensus.getLogger().Info("[OnPrepared] Block verification faied") return } } - consensus.getLogger().Debug("[OnPrepared] Prepared message and block added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum, "blockHash", recvMsg.BlockHash) consensus.pbftLog.AddBlock(&blockObj) recvMsg.Block = []byte{} // save memory space consensus.pbftLog.AddMessage(recvMsg) + consensus.getLogger().Debug("[OnPrepared] Prepared message and block added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum, "blockHash", recvMsg.BlockHash) consensus.mutex.Lock() defer consensus.mutex.Unlock() @@ -646,8 +679,8 @@ func (consensus *Consensus) onCommitted(msg *msg_pb.Message) { return } - consensus.getLogger().Debug("[OnCommitted] Committed message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) consensus.pbftLog.AddMessage(recvMsg) + consensus.getLogger().Debug("[OnCommitted] Committed message added", "MsgViewID", recvMsg.ViewID, "MsgBlockNum", recvMsg.BlockNum) consensus.mutex.Lock() defer consensus.mutex.Unlock() From d770979ba06bb908568b9edf5992ca4c33ca3d41 Mon Sep 17 00:00:00 2001 From: Chao Ma Date: Mon, 17 Jun 2019 00:14:27 -0700 Subject: [PATCH 7/8] clean and make the finalizeCommits code more robust in the case of leader change --- consensus/consensus_service.go | 6 +- consensus/consensus_v2.go | 110 ++++++++++++++++++--------------- consensus/view_change.go | 4 ++ 3 files changed, 67 insertions(+), 53 deletions(-) diff --git a/consensus/consensus_service.go b/consensus/consensus_service.go index 6773c0695..3bd4ff3e4 100644 --- a/consensus/consensus_service.go +++ b/consensus/consensus_service.go @@ -331,11 +331,13 @@ func (consensus *Consensus) ResetState() { consensus.getLogger().Debug("[ResetState] Resetting consensus state", "Phase", consensus.phase) consensus.switchPhase(Announce, true) consensus.blockHash = [32]byte{} + consensus.blockHeader = []byte{} + consensus.block = []byte{} consensus.prepareSigs = map[string]*bls.Sign{} consensus.commitSigs = map[string]*bls.Sign{} - prepareBitmap, _ := bls_cosi.NewMask(consensus.PublicKeys, consensus.LeaderPubKey) - commitBitmap, _ := bls_cosi.NewMask(consensus.PublicKeys, consensus.LeaderPubKey) + prepareBitmap, _ := bls_cosi.NewMask(consensus.PublicKeys, nil) + commitBitmap, _ := bls_cosi.NewMask(consensus.PublicKeys, nil) consensus.prepareBitmap = prepareBitmap consensus.commitBitmap = commitBitmap consensus.aggregatedPrepareSig = nil diff --git a/consensus/consensus_v2.go b/consensus/consensus_v2.go index d16854734..422113834 100644 --- a/consensus/consensus_v2.go +++ b/consensus/consensus_v2.go @@ -15,7 +15,6 @@ import ( "github.com/harmony-one/harmony/api/service/explorer" "github.com/harmony-one/harmony/core/types" nodeconfig "github.com/harmony-one/harmony/internal/configs/node" - "github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" "github.com/harmony-one/harmony/p2p/host" @@ -92,8 +91,6 @@ func (consensus *Consensus) announce(block *types.Block) { consensus.block = encodedBlock consensus.blockHeader = encodedBlockHeader msgToSend := consensus.constructAnnounceMessage() - consensus.getLogger().Debug("[Announce] Switching phase", "From", consensus.phase, "To", Prepare) - consensus.switchPhase(Prepare, true) // save announce message to pbftLog msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend) @@ -110,6 +107,10 @@ func (consensus *Consensus) announce(block *types.Block) { // Leader sign the block hash itself consensus.prepareSigs[consensus.PubKey.SerializeToHexStr()] = consensus.priKey.SignHash(consensus.blockHash[:]) + if err := consensus.prepareBitmap.SetKey(consensus.PubKey, true); err != nil { + consensus.getLogger().Warn("[Announce] Leader prepareBitmap SetKey failed", "error", err) + return + } // Construct broadcast p2p message if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { @@ -117,6 +118,9 @@ func (consensus *Consensus) announce(block *types.Block) { } else { consensus.getLogger().Debug("[Announce] Sent Announce Message!!", "BlockHash", block.Hash(), "BlockNum", block.NumberU64()) } + + consensus.getLogger().Debug("[Announce] Switching phase", "From", consensus.phase, "To", Prepare) + consensus.switchPhase(Prepare, true) } func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { @@ -150,7 +154,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) { var headerObj types.Header err = rlp.DecodeBytes(blockHeader, &headerObj) if err != nil { - consensus.getLogger().Warn("[OnAnnounce] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum, "MsgPayloadBlockNum", headerObj.Number) + consensus.getLogger().Warn("[OnAnnounce] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum) return } @@ -280,7 +284,8 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { prepareSigs[validatorPubKey] = &sign // Set the bitmap indicating that this validator signed. if err := prepareBitmap.SetKey(recvMsg.SenderPubkey, true); err != nil { - ctxerror.Warn(consensus.getLogger(), err, "[OnPrepare] prepareBitmap.SetKey failed") + consensus.getLogger().Warn("[OnPrepare] prepareBitmap.SetKey failed", "error", err) + return } if len(prepareSigs) >= consensus.Quorum() { @@ -289,7 +294,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { msgToSend, aggSig := consensus.constructPreparedMessage() consensus.aggregatedPrepareSig = aggSig - // add prepared message to log + //leader adds prepared message to log msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend) msg := &msg_pb.Message{} _ = protobuf.Unmarshal(msgPayload, msg) @@ -300,14 +305,6 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { } consensus.pbftLog.AddMessage(pbftMsg) - if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { - consensus.getLogger().Warn("[OnPrepare] Cannot send prepared message") - } else { - consensus.getLogger().Debug("[OnPrepare] Sent Prepared Message!!", "BlockHash", consensus.blockHash, "BlockNum", consensus.blockNum) - } - - consensus.getLogger().Debug("[OnPrepare] Switching phase", "From", consensus.phase, "To", Commit) - consensus.switchPhase(Commit, true) // Leader add commit phase signature blockNumHash := make([]byte, 8) binary.LittleEndian.PutUint64(blockNumHash, consensus.blockNum) @@ -315,7 +312,16 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) { consensus.commitSigs[consensus.PubKey.SerializeToHexStr()] = consensus.priKey.SignHash(commitPayload) if err := consensus.commitBitmap.SetKey(consensus.PubKey, true); err != nil { consensus.getLogger().Debug("[OnPrepare] Leader commit bitmap set failed") + return + } + + if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { + consensus.getLogger().Warn("[OnPrepare] Cannot send prepared message") + } else { + consensus.getLogger().Debug("[OnPrepare] Sent Prepared Message!!", "BlockHash", consensus.blockHash, "BlockNum", consensus.blockNum) } + consensus.getLogger().Debug("[OnPrepare] Switching phase", "From", consensus.phase, "To", Commit) + consensus.switchPhase(Commit, true) } return } @@ -376,7 +382,7 @@ func (consensus *Consensus) onPrepared(msg *msg_pb.Message) { var blockObj types.Block err = rlp.DecodeBytes(block, &blockObj) if err != nil { - consensus.getLogger().Warn("[OnPrepared] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum, "MsgPayloadBlockNum", blockObj.NumberU64()) + consensus.getLogger().Warn("[OnPrepared] Unparseable block header data", "error", err, "MsgBlockNum", recvMsg.BlockNum) return } if blockObj.NumberU64() != recvMsg.BlockNum || recvMsg.BlockNum < consensus.blockNum { @@ -542,7 +548,8 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { commitSigs[validatorPubKey] = &sign // Set the bitmap indicating that this validator signed. if err := commitBitmap.SetKey(recvMsg.SenderPubkey, true); err != nil { - ctxerror.Warn(consensus.getLogger(), err, "[OnCommit] commitBitmap.SetKey failed") + consensus.getLogger().Warn("[OnCommit] commitBitmap.SetKey failed", "error", err) + return } quorumIsMet := len(commitSigs) >= consensus.Quorum() @@ -568,47 +575,49 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) { func (consensus *Consensus) finalizeCommits() { consensus.getLogger().Info("[Finalizing] Finalizing Block", "NumCommits", len(consensus.commitSigs)) - // Construct and broadcast committed message - msgToSend, aggSig := consensus.constructCommittedMessage() - consensus.aggregatedCommitSig = aggSig + beforeCatchupNum := consensus.blockNum + beforeCatchupViewID := consensus.viewID - if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { - ctxerror.Warn(consensus.getLogger(), err, "[Finalizing] Cannot send committed message") - } else { - consensus.getLogger().Debug("[Finalizing] Sent Committed Message", "BlockHash", consensus.blockHash, "BlockNum", consensus.blockNum) - } + // Construct committed message + msgToSend, aggSig := consensus.constructCommittedMessage() + consensus.aggregatedCommitSig = aggSig // this may not needed - consensus.getLogger().Debug("[Finalizing] Switching phase", "From", consensus.phase, "To", Announce) - consensus.switchPhase(Announce, true) - var blockObj types.Block - err := rlp.DecodeBytes(consensus.block, &blockObj) + // leader adds committed message to log + msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend) + msg := &msg_pb.Message{} + _ = protobuf.Unmarshal(msgPayload, msg) + pbftMsg, err := ParsePbftMessage(msg) if err != nil { - consensus.getLogger().Debug("[Finalizing] failed to construct the new block after consensus") + consensus.getLogger().Warn("[FinalizeCommits] Unable to parse pbft message", "error", err) + return } + consensus.pbftLog.AddMessage(pbftMsg) - // Sign the block - blockObj.SetPrepareSig( - consensus.aggregatedPrepareSig.Serialize(), - consensus.prepareBitmap.Bitmap) - blockObj.SetCommitSig( - consensus.aggregatedCommitSig.Serialize(), - consensus.commitBitmap.Bitmap) - - select { - case consensus.VerifiedNewBlock <- &blockObj: - default: - consensus.getLogger().Info("[SYNC] Failed to send consensus verified block for state sync", "blockHash", blockObj.Hash()) + // find correct block content + block := consensus.pbftLog.GetBlockByHash(consensus.blockHash) + if block == nil { + consensus.getLogger().Warn("[FinalizeCommits] Cannot find block by hash", "blockHash", hex.EncodeToString(consensus.blockHash[:])) + return + } + consensus.tryCatchup() + if consensus.blockNum-beforeCatchupNum != 1 { + consensus.getLogger().Warn("[FinalizeCommits] Leader cannot provide the correct block for committed message", "beforeCatchupBlockNum", beforeCatchupNum) + return + } + // if leader success finalize the block, send committed message to validators + if err := consensus.host.SendMessageToGroups([]p2p.GroupID{p2p.NewGroupIDByShardID(p2p.ShardID(consensus.ShardID))}, host.ConstructP2pMessage(byte(17), msgToSend)); err != nil { + consensus.getLogger().Warn("[Finalizing] Cannot send committed message", "error", err) + } else { + consensus.getLogger().Debug("[Finalizing] Sent Committed Message", "BlockHash", consensus.blockHash, "BlockNum", consensus.blockNum) } - consensus.reportMetrics(blockObj) - - // Dump new block into level db. - explorer.GetStorageInstance(consensus.leader.IP, consensus.leader.Port, true).Dump(&blockObj, consensus.viewID) + consensus.reportMetrics(*block) - // Reset state to Finished, and clear other data. - consensus.ResetState() - consensus.viewID++ - consensus.blockNum++ + // Dump new block into level db + // In current code, we add signatures in block in tryCatchup, the block dump to explorer does not contains signatures + // but since explorer doesn't need signatures, it should be fine + // in future, we will move signatures to next block + explorer.GetStorageInstance(consensus.leader.IP, consensus.leader.Port, true).Dump(block, beforeCatchupViewID) if consensus.consensusTimeout[timeoutBootstrap].IsActive() { consensus.consensusTimeout[timeoutBootstrap].Stop() @@ -618,8 +627,7 @@ func (consensus *Consensus) finalizeCommits() { } consensus.consensusTimeout[timeoutConsensus].Start() - consensus.OnConsensusDone(&blockObj) - consensus.getLogger().Info("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!", "numOfSignatures", len(consensus.commitSigs), "BlockNum", consensus.blockNum-1, "ViewId", consensus.viewID-1, "BlockHash", blockObj.Hash(), "index", consensus.getIndexOfPubKey(consensus.PubKey)) + consensus.getLogger().Info("HOORAY!!!!!!! CONSENSUS REACHED!!!!!!!", "BlockNum", beforeCatchupNum, "ViewId", beforeCatchupViewID, "BlockHash", block.Hash(), "index", consensus.getIndexOfPubKey(consensus.PubKey)) // TODO: wait for validators receive committed message; remove this temporary delay time.Sleep(time.Second) diff --git a/consensus/view_change.go b/consensus/view_change.go index 26d45a558..925615e65 100644 --- a/consensus/view_change.go +++ b/consensus/view_change.go @@ -367,6 +367,10 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) { binary.LittleEndian.PutUint64(blockNumBytes, consensus.blockNum) commitPayload := append(blockNumBytes, consensus.blockHash[:]...) consensus.commitSigs[consensus.PubKey.SerializeToHexStr()] = consensus.priKey.SignHash(commitPayload) + if err = consensus.commitBitmap.SetKey(consensus.PubKey, true); err != nil { + consensus.getLogger().Debug("[OnViewChange] New Leader commit bitmap set failed") + return + } } consensus.mode.SetViewID(recvMsg.ViewID) From 174fe06605796a0920c289ec3c3260070a68fcb6 Mon Sep 17 00:00:00 2001 From: Minh Doan Date: Sat, 15 Jun 2019 18:59:59 -0700 Subject: [PATCH 8/8] add log for pbft log because it stores block by memory --- consensus/consensus.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/consensus/consensus.go b/consensus/consensus.go index a0d1a622b..0529cfbed 100644 --- a/consensus/consensus.go +++ b/consensus/consensus.go @@ -19,6 +19,7 @@ import ( nodeconfig "github.com/harmony-one/harmony/internal/configs/node" "github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/genesis" + "github.com/harmony-one/harmony/internal/memprofiling" "github.com/harmony-one/harmony/internal/utils" "github.com/harmony-one/harmony/p2p" ) @@ -277,6 +278,7 @@ func New(host p2p.Host, ShardID uint32, leader p2p.Peer, blsPriKey *bls.SecretKe consensus.uniqueIDInstance = utils.GetUniqueValidatorIDInstance() + memprofiling.GetMemProfiling().Add("consensus.pbftLog", consensus.pbftLog) return &consensus, nil }