@@ -695,7 +695,7 @@ func (e *Epoch) indexFinalizationCertificates(startRound uint64) {
695695 return
696696 }
697697 if round .fCert .Finalization .Seq != e .Storage .Height () {
698- e .Logger .Debug ("Finalization certificate does not correspond to the next sequence to commit" ,
698+ e .Logger .Debug ("Finalization certificate does not correspond to the next sequence to commit" ,
699699 zap .Uint64 ("seq" , round .fCert .Finalization .Seq ), zap .Uint64 ("height" , e .Storage .Height ()))
700700 return
701701 }
@@ -852,7 +852,6 @@ func (e *Epoch) handleNotarizationMessage(message *Notarization, from NodeID) er
852852 return e .persistNotarization (* message )
853853}
854854
855-
856855func (e * Epoch ) handleBlockMessage (message * BlockMessage , from NodeID ) error {
857856 block := message .Block
858857 if block == nil {
@@ -961,20 +960,22 @@ func (e *Epoch) handleBlockMessage(message *BlockMessage, from NodeID) error {
961960 return nil
962961}
963962
964- func (e * Epoch ) processFinalizedBlock (sequenceData * SequenceData ) error {
965- round , exists := e .rounds [sequenceData .FCert .Finalization .Round ]
963+ // processFinalizedBlock processes a block that has a finalization certificate.
964+ // if the block has already been verified, it will index the finalization certificate,
965+ // otherwise it will verify the block first.
966+ func (e * Epoch ) processFinalizedBlock (finalizedBlock * FinalizedBlock ) error {
967+ round , exists := e .rounds [finalizedBlock .FCert .Finalization .Round ]
966968 // dont create a block verification task if the block is already in the rounds map
967969 if exists {
968970 roundDigest := round .block .BlockHeader ().Digest
969- seqDigest := sequenceData .FCert .Finalization .BlockHeader .Digest
971+ seqDigest := finalizedBlock .FCert .Finalization .BlockHeader .Digest
970972 if ! bytes .Equal (roundDigest [:], seqDigest [:]) {
971973 e .Logger .Warn ("Received finalized block that is different from the one we have in the rounds map" ,
972974 zap .Stringer ("roundDigest" , roundDigest ), zap .Stringer ("seqDigest" , seqDigest ))
973975 return nil
974976 }
975- round .fCert = & sequenceData .FCert
977+ round .fCert = & finalizedBlock .FCert
976978 e .indexFinalizationCertificates (round .num )
977- e .replicationState .maybeCollectFutureFinalizationCertificates (e .round , e .Storage .Height ())
978979 e .processReplicationState ()
979980 return e .maybeLoadFutureMessages ()
980981 }
@@ -984,14 +985,14 @@ func (e *Epoch) processFinalizedBlock(sequenceData *SequenceData) error {
984985 e .Logger .Warn ("Too many blocks being verified to ingest another one" , zap .Int ("pendingBlocks" , pendingBlocks ))
985986 return nil
986987 }
987- md := sequenceData .Block .BlockHeader ()
988- if ! e .verifyProposalIsPartOfOurChain (sequenceData .Block ) {
988+ md := finalizedBlock .Block .BlockHeader ()
989+ if ! e .verifyProposalIsPartOfOurChain (finalizedBlock .Block ) {
989990 e .Logger .Debug ("Got invalid block in a BlockMessage" )
990991 return nil
991992 }
992993
993994 // Create a task that will verify the block in the future, after its predecessors have also been verified.
994- task := e .createBlockFinalizedVerificationTask (* sequenceData )
995+ task := e .createBlockFinalizedVerificationTask (* finalizedBlock )
995996
996997 // isBlockReadyToBeScheduled checks if the block is known to us either from some previous round,
997998 // or from storage. If so, then we have verified it in the past, since only verified blocks are saved in memory.
@@ -1053,8 +1054,8 @@ func (e *Epoch) createBlockVerificationTask(block Block, from NodeID, vote Vote)
10531054 }
10541055}
10551056
1056- func (e * Epoch ) createBlockFinalizedVerificationTask (sequenceData SequenceData ) func () Digest {
1057- block := sequenceData .Block
1057+ func (e * Epoch ) createBlockFinalizedVerificationTask (finalizedBlock FinalizedBlock ) func () Digest {
1058+ block := finalizedBlock .Block
10581059 return func () Digest {
10591060 md := block .BlockHeader ()
10601061
@@ -1086,10 +1087,9 @@ func (e *Epoch) createBlockFinalizedVerificationTask(sequenceData SequenceData)
10861087 e .Logger .Error ("programming error: round not found" , zap .Uint64 ("round" , md .Round ))
10871088 return md .Digest
10881089 }
1089- round .fCert = & sequenceData .FCert
1090+ round .fCert = & finalizedBlock .FCert
10901091
10911092 e .indexFinalizationCertificates (round .num )
1092- e .replicationState .maybeCollectFutureFinalizationCertificates (e .round , e .Storage .Height ())
10931093 e .processReplicationState ()
10941094 err := e .maybeLoadFutureMessages ()
10951095 if err != nil {
0 commit comments