Skip to content

Commit

Permalink
Merge pull request #7050 from onflow/mpeter/fix-evm-block-view-creati…
Browse files Browse the repository at this point in the history
…on-v2

Update EVM `ViewProvider` to return block `View` at its end state
  • Loading branch information
peterargue authored Feb 18, 2025
2 parents aa64e4d + 58e3799 commit 2181389
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fvm/evm/offchain/query/viewProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ func NewViewProvider(
}
}

// GetBlockView returns the block view for the given height
// GetBlockView returns the block view for the given height (at the end of a block!)
// The `GetSnapshotAt` function of `storageProvider`, will return
// the block state at its start, before any transaction executions.
// This is the intended functionality, when replaying & verifying blocks.
// However, when reading the state from a block, we are interested
// in its end state, after all transaction executions.
// That is why we fetch the block snapshot at the next height.
func (evp *ViewProvider) GetBlockView(height uint64) (*View, error) {
readOnly, err := evp.storageProvider.GetSnapshotAt(height)
readOnly, err := evp.storageProvider.GetSnapshotAt(height + 1)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 2181389

Please sign in to comment.