@@ -23,15 +23,15 @@ import (
2323 "github.com/onflow/rosetta/log"
2424)
2525
26- func convertExecutionResult (hash []byte , height uint64 , result * entities.ExecutionResult ) (flowExecutionResult , bool ) {
26+ func convertExecutionResult (sporkVersion int , hash []byte , height uint64 , result * entities.ExecutionResult ) (flowExecutionResult , bool ) {
2727 // todo: add V6 version branching here directly after mainnet23 spork
2828 exec := flowExecutionResult {
2929 BlockID : toFlowIdentifier (result .BlockId ),
3030 ExecutionDataID : toFlowIdentifier (result .ExecutionDataId ),
3131 PreviousResultID : toFlowIdentifier (result .PreviousResultId ),
3232 }
3333 for _ , chunk := range result .Chunks {
34- convertedChunk , err := convert . MessageToChunk ( chunk )
34+ convertedChunk , err := convertChunk ( sporkVersion , chunk )
3535 if err != nil {
3636 log .Errorf ("Failed to convert chunk in block %x at height %d: %v" , hash , height , err )
3737 return flowExecutionResult {}, false
@@ -53,6 +53,25 @@ func convertExecutionResult(hash []byte, height uint64, result *entities.Executi
5353 return exec , true
5454}
5555
56+ func convertChunk (sporkVersion int , protobufChunk * entities.Chunk ) (* flow.Chunk , error ) {
57+ if sporkVersion < 7 {
58+ chunk , err := convert .MessageToChunk (protobufChunk )
59+ if err != nil {
60+ return nil , err
61+ }
62+ // Protocol State v1: ServiceEventCount field not yet added.
63+ // Access Nodes running up-to-date software encode nil ServiceEventCount fields in a detectable way,
64+ // but we assume that we are querying historical Access Nodes that are running prior software versions.
65+ // In this case, the new Protobuf field is automatically set to 0.
66+ // See https://github.com/onflow/flow-go/pull/6744 for additional context
67+ chunk .ServiceEventCount = nil
68+ return chunk , nil
69+ }
70+
71+ // Protocol State v2+
72+ return convert .MessageToChunk (protobufChunk )
73+ }
74+
5675func decodeEvent (typ string , evt * entities.Event , hash []byte , height uint64 ) (cadence.Event , error ) {
5776 val , err := decodePayload (evt .Payload )
5877 if err != nil {
@@ -426,7 +445,7 @@ func verifyBlockHash(spork *config.Spork, hash []byte, height uint64, hdr *entit
426445
427446 var resultIDs []flow.Identifier
428447 for _ , src := range block .ExecutionResultList {
429- exec , ok := convertExecutionResult (hash , height , src )
448+ exec , ok := convertExecutionResult (spork . Version , hash , height , src )
430449 if ok {
431450 resultIDs = append (resultIDs , deriveExecutionResult (spork , exec ))
432451 }
0 commit comments