@@ -26,8 +26,8 @@ var ErrPrunedAncestry = errors.New("cannot resolve pruned ancestor")
2626// [b<-qc_b] [b'<-qc_b'] [b*]
2727type ancestryChain struct {
2828 block * BlockContainer
29- oneChain * BlockQC
30- twoChain * BlockQC
29+ oneChain * model. CertifiedBlock
30+ twoChain * model. CertifiedBlock
3131}
3232
3333// Forks enforces structural validity of the consensus state and implements
@@ -40,13 +40,13 @@ type Forks struct {
4040 forest forest.LevelledForest
4141
4242 finalizationCallback module.Finalizer
43- newestView uint64 // newestView is the highest view of block proposal stored in Forks
44- lastFinalized * BlockQC // lastFinalized is the QC that POINTS TO the most recently finalized locked block
43+ newestView uint64 // newestView is the highest view of block proposal stored in Forks
44+ lastFinalized * model. CertifiedBlock // the most recently finalized block and the QC that certifies it
4545}
4646
4747var _ hotstuff.Forks = (* Forks )(nil )
4848
49- func New (trustedRoot * BlockQC , finalizationCallback module.Finalizer , notifier hotstuff.FinalizationConsumer ) (* Forks , error ) {
49+ func New (trustedRoot * model. CertifiedBlock , finalizationCallback module.Finalizer , notifier hotstuff.FinalizationConsumer ) (* Forks , error ) {
5050 if (trustedRoot .Block .BlockID != trustedRoot .QC .BlockID ) || (trustedRoot .Block .View != trustedRoot .QC .View ) {
5151 return nil , model .NewConfigurationErrorf ("invalid root: root QC is not pointing to root block" )
5252 }
@@ -341,7 +341,7 @@ func (f *Forks) getTwoChain(blockContainer *BlockContainer) (*ancestryChain, err
341341// - model.MissingBlockError if the parent block does not exist in the forest
342342// (but is above the pruned view)
343343// - generic error in case of unexpected bug or internal state corruption
344- func (f * Forks ) getNextAncestryLevel (block * model.Block ) (* BlockQC , error ) {
344+ func (f * Forks ) getNextAncestryLevel (block * model.Block ) (* model. CertifiedBlock , error ) {
345345 // The finalizer prunes all blocks in forest which are below the most recently finalized block.
346346 // Hence, we have a pruned ancestry if and only if either of the following conditions applies:
347347 // (a) if a block's parent view (i.e. block.QC.View) is below the most recently finalized block.
@@ -367,9 +367,11 @@ func (f *Forks) getNextAncestryLevel(block *model.Block) (*BlockQC, error) {
367367 block .BlockID , block .View , block .QC .View , block .QC .BlockID , parentBlock .BlockID , parentBlock .View )
368368 }
369369
370- blockQC := BlockQC {Block : parentBlock , QC : block .QC }
371-
372- return & blockQC , nil
370+ certifiedBlock , err := model .NewCertifiedBlock (parentBlock , block .QC )
371+ if err != nil {
372+ return nil , fmt .Errorf ("constructing certified block failed: %w" , err )
373+ }
374+ return & certifiedBlock , nil
373375}
374376
375377// finalizeUpToBlock finalizes all blocks up to (and including) the block pointed to by `qc`.
@@ -416,7 +418,10 @@ func (f *Forks) finalizeUpToBlock(qc *flow.QuorumCertificate) error {
416418 }
417419
418420 // finalize block itself:
419- f .lastFinalized = & BlockQC {Block : block , QC : qc }
421+ * f .lastFinalized , err = model .NewCertifiedBlock (block , qc )
422+ if err != nil {
423+ return fmt .Errorf ("constructing certified block failed: %w" , err )
424+ }
420425 err = f .forest .PruneUpToLevel (block .View )
421426 if err != nil {
422427 if mempool .IsBelowPrunedThresholdError (err ) {
0 commit comments