Skip to content

Commit

Permalink
Merge pull request #6027 from onflow/janez/port-6003
Browse files Browse the repository at this point in the history
Add more information to panic
  • Loading branch information
janezpodhostnik authored Jun 21, 2024
2 parents 2a589d8 + 0f0a104 commit 741cb37
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion engine/execution/block_result.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package execution

import (
"fmt"

"github.com/onflow/flow-go/fvm/storage/snapshot"
"github.com/onflow/flow-go/model/flow"
"github.com/onflow/flow-go/module/executiondatasync/execution_data"
Expand Down Expand Up @@ -31,7 +33,7 @@ func (er *BlockExecutionResult) Size() int {
}

func (er *BlockExecutionResult) CollectionExecutionResultAt(colIndex int) *CollectionExecutionResult {
if colIndex < 0 && colIndex > len(er.collectionExecutionResults) {
if colIndex < 0 || colIndex > len(er.collectionExecutionResults) {
return nil
}
return &er.collectionExecutionResults[colIndex]
Expand Down Expand Up @@ -185,6 +187,12 @@ func (ar *BlockAttestationResult) ChunkAt(index int) *flow.Chunk {
execRes := ar.collectionExecutionResults[index]
attestRes := ar.collectionAttestationResults[index]

if execRes.executionSnapshot == nil {
// This should never happen
// In case it does, attach additional information to the error message
panic(fmt.Sprintf("execution snapshot is nil. Block ID: %s, EndState: %s", ar.Block.ID(), attestRes.endStateCommit))
}

return flow.NewChunk(
ar.Block.ID(),
index,
Expand Down

0 comments on commit 741cb37

Please sign in to comment.