Fix viewID issue on prepared block during view change (#2972)

* Fix viewID issue on prepared block during view change

* Add more checks and remove comments

* Fix lint

* update rlp encode pointer

* Revert go gen changes

* add go gen code

* [api] Fix proto to pass travis

Co-authored-by: Edgar Aroutiounian <edgar.factorial@gmail.com>
pull/2975/head v1.3.12
Rongjian Lan 5 years ago committed by GitHub
parent 7b25c672d9
commit 7c292f64be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 137
      api/proto/message/message.pb.go
  2. 2
      api/proto/message/message.proto
  3. 29
      consensus/consensus_viewchange_msg.go
  4. 4
      consensus/fbft_log.go
  5. 70
      consensus/view_change.go

@ -702,6 +702,7 @@ type ViewChangeRequest struct {
M2Bitmap []byte `protobuf:"bytes,10,opt,name=m2_bitmap,json=m2Bitmap,proto3" json:"m2_bitmap,omitempty"` M2Bitmap []byte `protobuf:"bytes,10,opt,name=m2_bitmap,json=m2Bitmap,proto3" json:"m2_bitmap,omitempty"`
M3Aggsigs []byte `protobuf:"bytes,11,opt,name=m3_aggsigs,json=m3Aggsigs,proto3" json:"m3_aggsigs,omitempty"` M3Aggsigs []byte `protobuf:"bytes,11,opt,name=m3_aggsigs,json=m3Aggsigs,proto3" json:"m3_aggsigs,omitempty"`
M3Bitmap []byte `protobuf:"bytes,12,opt,name=m3_bitmap,json=m3Bitmap,proto3" json:"m3_bitmap,omitempty"` M3Bitmap []byte `protobuf:"bytes,12,opt,name=m3_bitmap,json=m3Bitmap,proto3" json:"m3_bitmap,omitempty"`
PreparedBlock []byte `protobuf:"bytes,13,opt,name=prepared_block,json=preparedBlock,proto3" json:"prepared_block,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"` XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"` XXX_sizecache int32 `json:"-"`
@ -816,6 +817,13 @@ func (m *ViewChangeRequest) GetM3Bitmap() []byte {
return nil return nil
} }
func (m *ViewChangeRequest) GetPreparedBlock() []byte {
if m != nil {
return m.PreparedBlock
}
return nil
}
func init() { func init() {
proto.RegisterEnum("message.ServiceType", ServiceType_name, ServiceType_value) proto.RegisterEnum("message.ServiceType", ServiceType_name, ServiceType_value)
proto.RegisterEnum("message.MessageType", MessageType_name, MessageType_value) proto.RegisterEnum("message.MessageType", MessageType_name, MessageType_value)
@ -835,70 +843,71 @@ func init() {
} }
var fileDescriptor_33c57e4bae7b9afd = []byte{ var fileDescriptor_33c57e4bae7b9afd = []byte{
// 998 bytes of a gzipped FileDescriptorProto // 1014 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xdf, 0x6e, 0xe3, 0xc4, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0xdd, 0x6e, 0xe3, 0x44,
0x17, 0xae, 0xf3, 0xcf, 0xc9, 0xb1, 0x93, 0x7a, 0xe7, 0xd7, 0x1f, 0xf5, 0x76, 0xbb, 0xab, 0x92, 0x14, 0xae, 0xf3, 0xe7, 0xe4, 0xd8, 0x4e, 0xbd, 0xc3, 0x42, 0xbd, 0xdd, 0xee, 0xaa, 0xa4, 0xac,
0x82, 0xa8, 0xf6, 0xa2, 0x82, 0x14, 0x69, 0x05, 0xe2, 0x26, 0x4d, 0xcc, 0xd6, 0x6a, 0xeb, 0x84, 0xa8, 0xf6, 0xa2, 0x82, 0x14, 0x69, 0x05, 0xe2, 0x26, 0x4d, 0xcc, 0xd6, 0x6a, 0xeb, 0x84, 0x89,
0xb1, 0xbb, 0x15, 0x57, 0xd6, 0x34, 0x1e, 0x25, 0x56, 0x13, 0x3b, 0x78, 0x9c, 0xae, 0xf2, 0x02, 0xbb, 0x15, 0x57, 0xd6, 0x34, 0x1e, 0x25, 0x56, 0x13, 0xc7, 0x78, 0x9c, 0xae, 0xf2, 0x24, 0x3c,
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x83, 0x8d, 0x75, 0x94, 0x2c, 0x27, 0x94, 0x31, 0x64, 0xee, 0xfe, 0x88, 0x1c, 0x3e, 0x2b, 0x90, 0xfc, 0x8d,
0x35, 0xd0, 0x7e, 0x08, 0x00, 0x00, 0xef, 0xec, 0xdd, 0x37, 0xc4, 0x9f, 0x92, 0xf3, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x76, 0xe0,
0x82, 0x48, 0xa5, 0x08, 0x00, 0x00,
} }
// Reference imports to suppress errors if they are not otherwise used. // Reference imports to suppress errors if they are not otherwise used.

@ -112,5 +112,5 @@ message ViewChangeRequest {
bytes m2_bitmap = 10; bytes m2_bitmap = 10;
bytes m3_aggsigs = 11; // m3: |viewID| bytes m3_aggsigs = 11; // m3: |viewID|
bytes m3_bitmap= 12; bytes m3_bitmap= 12;
bytes prepared_block = 13;
} }

@ -3,6 +3,8 @@ package consensus
import ( import (
"encoding/binary" "encoding/binary"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
"github.com/harmony-one/harmony/api/proto" "github.com/harmony-one/harmony/api/proto"
msg_pb "github.com/harmony-one/harmony/api/proto/message" msg_pb "github.com/harmony-one/harmony/api/proto/message"
@ -35,14 +37,27 @@ func (consensus *Consensus) constructViewChangeMessage(pubKey *bls.PublicKey, pr
) )
preparedMsg := consensus.FBFTLog.FindMessageByMaxViewID(preparedMsgs) preparedMsg := consensus.FBFTLog.FindMessageByMaxViewID(preparedMsgs)
var encodedBlock []byte
if preparedMsg != nil {
block := consensus.FBFTLog.GetBlockByHash(preparedMsg.BlockHash)
if block != nil {
tmpEncoded, err := rlp.EncodeToBytes(block)
if err != nil {
consensus.getLogger().Err(err).Msg("[constructViewChangeMessage] Failed encoding block")
}
encodedBlock = tmpEncoded
}
}
var msgToSign []byte var msgToSign []byte
if preparedMsg == nil { if len(encodedBlock) == 0 {
msgToSign = NIL // m2 type message msgToSign = NIL // m2 type message
vcMsg.Payload = []byte{} vcMsg.Payload = []byte{}
} else { } else {
// m1 type message // m1 type message
msgToSign = append(preparedMsg.BlockHash[:], preparedMsg.Payload...) msgToSign = append(preparedMsg.BlockHash[:], preparedMsg.Payload...)
vcMsg.Payload = append(msgToSign[:0:0], msgToSign...) vcMsg.Payload = append(msgToSign[:0:0], msgToSign...)
vcMsg.PreparedBlock = encodedBlock
} }
utils.Logger().Debug(). utils.Logger().Debug().
@ -91,6 +106,18 @@ func (consensus *Consensus) constructNewViewMessage(viewID uint64, pubKey *bls.P
// sender address // sender address
vcMsg.SenderPubkey = pubKey.Serialize() vcMsg.SenderPubkey = pubKey.Serialize()
vcMsg.Payload = consensus.m1Payload vcMsg.Payload = consensus.m1Payload
if len(consensus.m1Payload) != 0 {
block := consensus.FBFTLog.GetBlockByHash(consensus.blockHash)
if block != nil {
encodedBlock, err := rlp.EncodeToBytes(block)
if err != nil {
consensus.getLogger().Err(err).Msg("[constructNewViewMessage] Failed encoding prepared block")
}
if len(encodedBlock) != 0 {
vcMsg.PreparedBlock = encodedBlock
}
}
}
sig2arr := consensus.GetNilSigsArray(viewID) sig2arr := consensus.GetNilSigsArray(viewID)
utils.Logger().Debug().Int("len", len(sig2arr)).Msg("[constructNewViewMessage] M2 (NIL) type signatures") utils.Logger().Debug().Int("len", len(sig2arr)).Msg("[constructNewViewMessage] M2 (NIL) type signatures")

@ -261,6 +261,8 @@ func ParseViewChangeMessage(msg *msg_pb.Message) (*FBFTMessage, error) {
vcMsg := msg.GetViewchange() vcMsg := msg.GetViewchange()
pbftMsg.ViewID = vcMsg.ViewId pbftMsg.ViewID = vcMsg.ViewId
pbftMsg.BlockNum = vcMsg.BlockNum pbftMsg.BlockNum = vcMsg.BlockNum
pbftMsg.Block = make([]byte, len(vcMsg.PreparedBlock))
copy(pbftMsg.Block[:], vcMsg.PreparedBlock[:])
pbftMsg.Payload = make([]byte, len(vcMsg.Payload)) pbftMsg.Payload = make([]byte, len(vcMsg.Payload))
copy(pbftMsg.Payload[:], vcMsg.Payload[:]) copy(pbftMsg.Payload[:], vcMsg.Payload[:])
@ -309,6 +311,8 @@ func (consensus *Consensus) ParseNewViewMessage(msg *msg_pb.Message) (*FBFTMessa
FBFTMsg.BlockNum = vcMsg.BlockNum FBFTMsg.BlockNum = vcMsg.BlockNum
FBFTMsg.Payload = make([]byte, len(vcMsg.Payload)) FBFTMsg.Payload = make([]byte, len(vcMsg.Payload))
copy(FBFTMsg.Payload[:], vcMsg.Payload[:]) copy(FBFTMsg.Payload[:], vcMsg.Payload[:])
FBFTMsg.Block = make([]byte, len(vcMsg.PreparedBlock))
copy(FBFTMsg.Block[:], vcMsg.PreparedBlock[:])
pubKey, err := bls_cosi.BytesToBLSPublicKey(vcMsg.SenderPubkey) pubKey, err := bls_cosi.BytesToBLSPublicKey(vcMsg.SenderPubkey)
if err != nil { if err != nil {

@ -3,10 +3,14 @@ package consensus
import ( import (
"bytes" "bytes"
"encoding/binary" "encoding/binary"
"encoding/hex"
"math/big" "math/big"
"sync" "sync"
"time" "time"
"github.com/ethereum/go-ethereum/rlp"
"github.com/harmony-one/harmony/core/types"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/harmony-one/bls/ffi/go/bls" "github.com/harmony-one/bls/ffi/go/bls"
msg_pb "github.com/harmony-one/harmony/api/proto/message" msg_pb "github.com/harmony-one/harmony/api/proto/message"
@ -192,7 +196,8 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
msg_pb.MessageType_PREPARED, recvMsg.BlockNum, msg_pb.MessageType_PREPARED, recvMsg.BlockNum,
) )
preparedMsg := consensus.FBFTLog.FindMessageByMaxViewID(preparedMsgs) preparedMsg := consensus.FBFTLog.FindMessageByMaxViewID(preparedMsgs)
if preparedMsg == nil { block := consensus.FBFTLog.GetBlockByHash(preparedMsg.BlockHash)
if preparedMsg == nil || block == nil {
consensus.getLogger().Debug().Msg("[onViewChange] add my M2(NIL) type messaage") consensus.getLogger().Debug().Msg("[onViewChange] add my M2(NIL) type messaage")
for i, key := range consensus.PubKey.PublicKey { for i, key := range consensus.PubKey.PublicKey {
priKey := consensus.priKey.PrivateKey[i] priKey := consensus.priKey.PrivateKey[i]
@ -221,8 +226,19 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
} }
} }
preparedBlock := &types.Block{}
if len(recvMsg.Payload) != 0 && len(recvMsg.Block) != 0 {
if err := rlp.DecodeBytes(recvMsg.Block, preparedBlock); err != nil {
consensus.getLogger().Warn().
Err(err).
Uint64("MsgBlockNum", recvMsg.BlockNum).
Msg("[onViewChange] Unparseable prepared block data")
return
}
}
// m2 type message // m2 type message
if len(recvMsg.Payload) == 0 { if preparedBlock == nil {
_, ok := consensus.nilSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()] _, ok := consensus.nilSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()]
if ok { if ok {
consensus.getLogger().Debug(). consensus.getLogger().Debug().
@ -242,6 +258,10 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.nilSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()] = recvMsg.ViewchangeSig consensus.nilSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()] = recvMsg.ViewchangeSig
consensus.nilBitmap[recvMsg.ViewID].SetKey(recvMsg.SenderPubkey, true) // Set the bitmap indicating that this validator signed. consensus.nilBitmap[recvMsg.ViewID].SetKey(recvMsg.SenderPubkey, true) // Set the bitmap indicating that this validator signed.
} else { // m1 type message } else { // m1 type message
if consensus.BlockVerifier(preparedBlock); err != nil {
consensus.getLogger().Error().Err(err).Msg("[onViewChange] Prepared block verification failed")
return
}
_, ok := consensus.bhpSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()] _, ok := consensus.bhpSigs[recvMsg.ViewID][senderKey.SerializeToHexStr()]
if ok { if ok {
consensus.getLogger().Debug(). consensus.getLogger().Debug().
@ -299,6 +319,8 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
preparedMsg.SenderPubkey = newLeaderKey preparedMsg.SenderPubkey = newLeaderKey
consensus.getLogger().Info().Msg("[onViewChange] New Leader Prepared Message Added") consensus.getLogger().Info().Msg("[onViewChange] New Leader Prepared Message Added")
consensus.FBFTLog.AddMessage(&preparedMsg) consensus.FBFTLog.AddMessage(&preparedMsg)
consensus.FBFTLog.AddBlock(preparedBlock)
} }
} }
consensus.getLogger().Debug(). consensus.getLogger().Debug().
@ -342,6 +364,8 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.ResetState() consensus.ResetState()
if len(consensus.m1Payload) == 0 { if len(consensus.m1Payload) == 0 {
// TODO(Chao): explain why ReadySignal is sent only in this case but not the other case. // TODO(Chao): explain why ReadySignal is sent only in this case but not the other case.
// Make sure the newly proposed block have the correct view ID
consensus.viewID = recvMsg.ViewID
go func() { go func() {
consensus.ReadySignal <- struct{}{} consensus.ReadySignal <- struct{}{}
}() }()
@ -352,7 +376,7 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
Msg("[OnViewChange] Switching phase") Msg("[OnViewChange] Switching phase")
consensus.switchPhase(FBFTCommit, true) consensus.switchPhase(FBFTCommit, true)
copy(consensus.blockHash[:], consensus.m1Payload[:32]) copy(consensus.blockHash[:], consensus.m1Payload[:32])
aggSig, mask, err := consensus.ReadSignatureBitmapPayload(recvMsg.Payload, 32) aggSig, mask, err := consensus.ReadSignatureBitmapPayload(consensus.m1Payload, 32)
if err != nil { if err != nil {
consensus.getLogger().Error().Err(err). consensus.getLogger().Error().Err(err).
@ -363,8 +387,13 @@ func (consensus *Consensus) onViewChange(msg *msg_pb.Message) {
consensus.aggregatedPrepareSig = aggSig consensus.aggregatedPrepareSig = aggSig
consensus.prepareBitmap = mask consensus.prepareBitmap = mask
// Leader sign and add commit message // Leader sign and add commit message
block := consensus.FBFTLog.GetBlockByHash(consensus.blockHash)
if block == nil {
consensus.getLogger().Debug().Msg("[onViewChange] failed to get prepared block for self commit")
return
}
commitPayload := signature.ConstructCommitPayload(consensus.ChainReader, commitPayload := signature.ConstructCommitPayload(consensus.ChainReader,
new(big.Int).SetUint64(consensus.epoch), consensus.blockHash, consensus.blockNum, recvMsg.ViewID) new(big.Int).SetUint64(consensus.epoch), consensus.blockHash, consensus.blockNum, block.Header().ViewID().Uint64())
for i, key := range consensus.PubKey.PublicKey { for i, key := range consensus.PubKey.PublicKey {
priKey := consensus.priKey.PrivateKey[i] priKey := consensus.priKey.PrivateKey[i]
if _, err := consensus.Decider.SubmitVote( if _, err := consensus.Decider.SubmitVote(
@ -476,6 +505,28 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) {
} }
// check when M3 sigs > M2 sigs, then M1 (recvMsg.Payload) should not be empty // check when M3 sigs > M2 sigs, then M1 (recvMsg.Payload) should not be empty
preparedBlock := &types.Block{}
if len(recvMsg.Payload) != 0 && len(recvMsg.Block) != 0 {
if err := rlp.DecodeBytes(recvMsg.Block, preparedBlock); err != nil {
consensus.getLogger().Warn().
Err(err).
Uint64("MsgBlockNum", recvMsg.BlockNum).
Msg("[onNewView] Unparseable prepared block data")
return
}
blockHash := recvMsg.Payload[:32]
preparedBlockHash := preparedBlock.Hash()
if !bytes.Equal(preparedBlockHash[:], blockHash) {
consensus.getLogger().Warn().
Err(err).
Str("blockHash", preparedBlock.Hash().Hex()).
Str("payloadBlockHash", hex.EncodeToString(blockHash)).
Msg("[onNewView] Prepared block hash doesn't match msg block hash.")
return
}
}
if m2Mask == nil || m2Mask.Bitmap == nil || if m2Mask == nil || m2Mask.Bitmap == nil ||
(m2Mask != nil && m2Mask.Bitmap != nil && (m2Mask != nil && m2Mask.Bitmap != nil &&
utils.CountOneBits(m3Mask.Bitmap) > utils.CountOneBits(m2Mask.Bitmap)) { utils.CountOneBits(m3Mask.Bitmap) > utils.CountOneBits(m2Mask.Bitmap)) {
@ -512,6 +563,8 @@ func (consensus *Consensus) onNewView(msg *msg_pb.Message) {
copy(preparedMsg.Payload[:], recvMsg.Payload[32:]) copy(preparedMsg.Payload[:], recvMsg.Payload[32:])
preparedMsg.SenderPubkey = senderKey preparedMsg.SenderPubkey = senderKey
consensus.FBFTLog.AddMessage(&preparedMsg) consensus.FBFTLog.AddMessage(&preparedMsg)
consensus.FBFTLog.AddBlock(preparedBlock)
} }
// newView message verified success, override my state // newView message verified success, override my state
@ -530,11 +583,14 @@ 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
// TODO: check magic number 32 if preparedBlock != nil {
if len(recvMsg.Payload) > 32 {
// Construct and send the commit message // Construct and send the commit message
if consensus.BlockVerifier(preparedBlock); err != nil {
consensus.getLogger().Error().Err(err).Msg("[onNewView] Prepared block verification failed")
return
}
commitPayload := signature.ConstructCommitPayload(consensus.ChainReader, commitPayload := signature.ConstructCommitPayload(consensus.ChainReader,
new(big.Int).SetUint64(consensus.epoch), consensus.blockHash, consensus.blockNum, consensus.viewID) new(big.Int).SetUint64(consensus.epoch), preparedBlock.Hash(), preparedBlock.NumberU64(), preparedBlock.Header().ViewID().Uint64())
groupID := []nodeconfig.GroupID{ groupID := []nodeconfig.GroupID{
nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))} nodeconfig.NewGroupIDByShardID(nodeconfig.ShardID(consensus.ShardID))}
for i, key := range consensus.PubKey.PublicKey { for i, key := range consensus.PubKey.PublicKey {

Loading…
Cancel
Save