Leader itself commits to the consensus multi-sig

pull/346/head
Rongjian Lan 6 years ago
parent 4c9e421932
commit 0f84320401
  1. 9
      consensus/consensus_leader.go
  2. 4
      consensus/consensus_validator_msg.go

@ -93,7 +93,10 @@ func (consensus *Consensus) startConsensus(newBlock *types.Block) {
// Set state to AnnounceDone
consensus.state = AnnounceDone
// TODO: sign for leader itself
// Leader sign the multi-sig itself
(*consensus.prepareSigs)[consensus.nodeID] = consensus.priKey.SignHash(consensus.blockHash[:])
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)
}
@ -180,6 +183,10 @@ func (consensus *Consensus) processPrepareMessage(message consensus_proto.Messag
msgToSend, aggSig := consensus.constructPreparedMessage()
consensus.aggregatedPrepareSig = aggSig
// Leader sign the multi-sig itself
// TODO: sign on the prepared multi-sig, rather than the block hash
(*consensus.commitSigs)[consensus.nodeID] = consensus.priKey.SignHash(consensus.blockHash[:])
// Broadcast prepared message
host.BroadcastMessageFromLeader(consensus.host, consensus.GetValidatorPeers(), msgToSend, consensus.OfflinePeers)

@ -24,7 +24,7 @@ func (consensus *Consensus) constructPrepareMessage() []byte {
// 48 byte of bls signature
sign := consensus.priKey.SignHash(message.BlockHash)
if sign != nil {
message.Payload = consensus.priKey.SignHash(message.BlockHash).Serialize()
message.Payload = sign.Serialize()
}
marshaledMessage, err := protobuf.Marshal(&message)
@ -61,7 +61,7 @@ func (consensus *Consensus) constructCommitMessage() []byte {
// TODO: sign on the prepared message hash, rather than the block hash
sign := consensus.priKey.SignHash(message.BlockHash)
if sign != nil {
message.Payload = consensus.priKey.SignHash(message.BlockHash).Serialize()
message.Payload = sign.Serialize()
}
marshaledMessage, err := protobuf.Marshal(&message)

Loading…
Cancel
Save