@ -125,13 +125,16 @@ func (consensus *Consensus) processPrepareMessage(message consensus_proto.Messag
if err != nil {
if err != nil {
utils . GetLogInstance ( ) . Warn ( "Failed to marshal the prepare message" , "error" , err )
utils . GetLogInstance ( ) . Warn ( "Failed to marshal the prepare message" , "error" , err )
}
}
_ = messageBytes
_ = signature
msgSig := bls . Sign { }
// TODO: verify message signature
err = msgSig . Deserialize ( signature )
//if schnorr.Verify(crypto.Ed25519Curve, value.PubKey, messageBytes, signature) != nil {
if err != nil {
// consensus.Log.Warn("Received message with invalid signature", "validatorKey", consensus.leader.PubKey, "consensus", consensus)
utils . GetLogInstance ( ) . Warn ( "Failed to deserialize message signature" , "validator ID" , validatorID )
// return
}
//}
if msgSig . VerifyHash ( value . PubKey , messageBytes ) {
utils . GetLogInstance ( ) . Warn ( "Received message with invalid signature" , "validator ID" , validatorID )
return
}
// check consensus Id
// check consensus Id
consensus . mutex . Lock ( )
consensus . mutex . Lock ( )
@ -210,11 +213,11 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
// check consensus Id
// check consensus Id
if consensusID != consensus . consensusID {
if consensusID != consensus . consensusID {
shouldProcess = false
shouldProcess = false
utils . GetLogInstance ( ) . Warn ( "Received Response with wrong consensus Id" , "myConsensusId" , consensus . consensusID , "theirConsensusId" , consensusID , "consensus" , consensus )
utils . GetLogInstance ( ) . Warn ( "Received Commit with wrong consensus Id" , "myConsensusId" , consensus . consensusID , "theirConsensusId" , consensusID , "consensus" , consensus )
}
}
if ! bytes . Equal ( blockHash , consensus . blockHash [ : ] ) {
if ! bytes . Equal ( blockHash , consensus . blockHash [ : ] ) {
utils . GetLogInstance ( ) . Warn ( "Received Response with wrong blockHash" , "myConsensusId" , consensus . consensusID , "theirConsensusId" , consensusID , "consensus" , consensus )
utils . GetLogInstance ( ) . Warn ( "Received Commit with wrong blockHash" , "myConsensusId" , consensus . consensusID , "theirConsensusId" , consensusID , "consensus" , consensus )
return
return
}
}
@ -234,13 +237,16 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
if err != nil {
if err != nil {
utils . GetLogInstance ( ) . Warn ( "Failed to marshal the commit message" , "error" , err )
utils . GetLogInstance ( ) . Warn ( "Failed to marshal the commit message" , "error" , err )
}
}
_ = messageBytes
_ = signature
msgSig := bls . Sign { }
// TODO: verify message signature
err = msgSig . Deserialize ( signature )
//if schnorr.Verify(crypto.Ed25519Curve, value.PubKey, messageBytes, signature) != nil {
if err != nil {
// consensus.Log.Warn("Received message with invalid signature", "validatorKey", consensus.leader.PubKey, "consensus", consensus)
utils . GetLogInstance ( ) . Warn ( "Failed to deserialize message signature" , "validator ID" , validatorID )
// return
}
//}
if msgSig . VerifyHash ( value . PubKey , messageBytes ) {
utils . GetLogInstance ( ) . Warn ( "Received message with invalid signature" , "validator ID" , validatorID )
return
}
commitSigs := consensus . commitSigs
commitSigs := consensus . commitSigs
commitBitmap := consensus . commitBitmap
commitBitmap := consensus . commitBitmap
@ -311,8 +317,6 @@ func (consensus *Consensus) processCommitMessage(message consensus_proto.Message
utils . GetLogInstance ( ) . Debug ( "HOORAY!!! CONSENSUS REACHED!!!" , "consensusID" , consensus . consensusID , "numOfSignatures" , len ( * commitSigs ) )
utils . GetLogInstance ( ) . Debug ( "HOORAY!!! CONSENSUS REACHED!!!" , "consensusID" , consensus . consensusID , "numOfSignatures" , len ( * commitSigs ) )
// TODO: remove this temporary delay
time . Sleep ( 500 * time . Millisecond )
// Send signal to Node so the new block can be added and new round of consensus can be triggered
// Send signal to Node so the new block can be added and new round of consensus can be triggered
consensus . ReadySignal <- struct { } { }
consensus . ReadySignal <- struct { } { }
}
}