|
|
@ -247,15 +247,26 @@ func (consensus *Consensus) processResponseMessage(payload []byte) { |
|
|
|
log.Error("Failed to aggregate responses") |
|
|
|
log.Error("Failed to aggregate responses") |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
collectiveSig, err := crypto.Sign(crypto.Ed25519Curve, consensus.aggregatedCommitment, aggResponse, consensus.bitmap) |
|
|
|
collectiveSigAndBitmap, err := crypto.Sign(crypto.Ed25519Curve, consensus.aggregatedCommitment, aggResponse, consensus.bitmap) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Error("Failed to create collective signature") |
|
|
|
log.Error("Failed to create collective signature") |
|
|
|
return |
|
|
|
return |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
log.Info("CollectiveSig created.", "size", len(collectiveSig)) |
|
|
|
log.Info("CollectiveSig and Bitmap created.", "size", len(collectiveSigAndBitmap)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Start the second round of Cosi
|
|
|
|
|
|
|
|
collectiveSig := [64]byte{} |
|
|
|
|
|
|
|
copy(collectiveSig[:], collectiveSigAndBitmap[:64]) |
|
|
|
|
|
|
|
bitmap := collectiveSigAndBitmap[64:] |
|
|
|
|
|
|
|
msgToSend := consensus.constructCollectiveSigMessage(collectiveSig, bitmap) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
p2p.BroadcastMessage(consensus.getValidatorPeers(), msgToSend) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set state to CHALLENGE_DONE
|
|
|
|
|
|
|
|
consensus.state = COLLECTIVE_SIG_DONE |
|
|
|
|
|
|
|
|
|
|
|
consensus.Log.Debug("Consensus reached with signatures.", "numOfSignatures", len(consensus.responses)) |
|
|
|
consensus.Log.Debug("Consensus reached with signatures.", "numOfSignatures", len(consensus.responses)) |
|
|
|
// Reset state to FINISHED, and clear other data.
|
|
|
|
// Reset state to FINISHED, and clear other data.
|
|
|
|
consensus.ResetState() |
|
|
|
consensus.ResetState() |
|
|
@ -273,7 +284,8 @@ func (consensus *Consensus) processResponseMessage(payload []byte) { |
|
|
|
|
|
|
|
|
|
|
|
// Sign the block
|
|
|
|
// Sign the block
|
|
|
|
// TODO(RJ): populate bitmap
|
|
|
|
// TODO(RJ): populate bitmap
|
|
|
|
copy(blockHeaderObj.Signature[:], collectiveSig) |
|
|
|
copy(blockHeaderObj.Signature[:], collectiveSig[:]) |
|
|
|
|
|
|
|
copy(blockHeaderObj.Bitmap[:], bitmap) |
|
|
|
consensus.OnConsensusDone(&blockHeaderObj) |
|
|
|
consensus.OnConsensusDone(&blockHeaderObj) |
|
|
|
|
|
|
|
|
|
|
|
// TODO: @ricl these logic are irrelevant to consensus, move them to another file, say profiler.
|
|
|
|
// TODO: @ricl these logic are irrelevant to consensus, move them to another file, say profiler.
|
|
|
|