@@ -429,6 +429,29 @@ func deriveExecutionReceiptHash(spork *config.Spork, receipt flow.ExecutionRecei
429429 }
430430}
431431
432+ func deriveCollectionGuaranteeID (spork * config.Spork , guarantee * entities.CollectionGuarantee ) flow.Identifier {
433+ switch spork .Version {
434+ case 1 , 2 , 3 , 4 , 5 , 6 , 7 :
435+ return toFlowIdentifier (guarantee .CollectionId )
436+ case 8 :
437+ return flow .MakeID (struct {
438+ CollectionID flow.Identifier
439+ ReferenceBlockID flow.Identifier
440+ ChainID flow.ChainID
441+ SignerIndices []byte
442+ Signature crypto.Signature
443+ }{
444+ CollectionID : toFlowIdentifier (guarantee .CollectionId ),
445+ ReferenceBlockID : toFlowIdentifier (guarantee .ReferenceBlockId ),
446+ ChainID : flow .ChainID ("" ), // TODO update Access API
447+ SignerIndices : guarantee .SignerIndices ,
448+ Signature : guarantee .Signature ,
449+ })
450+ default :
451+ panic ("unreachable code" )
452+ }
453+ }
454+
432455func toFlowIdentifier (v []byte ) flow.Identifier {
433456 id := flow.Identifier {}
434457 copy (id [:], v )
@@ -503,11 +526,12 @@ func verifyBlockHash(spork *config.Spork, hash []byte, height uint64, hdr *entit
503526 )
504527 return false
505528 }
506- var collectionIDs []flow.Identifier
529+ var guaranteeIDs []flow.Identifier
507530 for _ , src := range block .CollectionGuarantees {
508- collectionIDs = append (collectionIDs , toFlowIdentifier (src .CollectionId ))
531+ guaranteeID := deriveCollectionGuaranteeID (spork , src )
532+ guaranteeIDs = append (guaranteeIDs , guaranteeID )
509533 }
510- collectionHash := flow .MerkleRoot (collectionIDs ... )
534+ collectionHash := flow .MerkleRoot (guaranteeIDs ... )
511535 var sealIDs []flow.Identifier
512536 for _ , src := range block .BlockSeals {
513537 seal := & flow.Seal {
@@ -562,6 +586,7 @@ func verifyBlockHash(spork *config.Spork, hash []byte, height uint64, hdr *entit
562586 }
563587 return true
564588}
589+
565590func derivePayloadHash (
566591 sporkVersion int ,
567592 collectionHash flow.Identifier ,
0 commit comments