From 97d00bac579d6fd77937f268d4562c2bd2df189d Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 23 May 2023 17:22:58 +0200 Subject: [PATCH] eth: make StorageRangeAt take a block hash or number Co-authored-by: Martin Holst Swende Co-authored-by: Sina Mahmoodi --- eth/api_debug.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/eth/api_debug.go b/eth/api_debug.go index fbc48e349651..929e0460f7c5 100644 --- a/eth/api_debug.go +++ b/eth/api_debug.go @@ -204,11 +204,16 @@ type storageEntry struct { } // StorageRangeAt returns the storage at the given block height and transaction index. -func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { - // Retrieve the block - block := api.eth.blockchain.GetBlockByHash(blockHash) +func (api *DebugAPI) StorageRangeAt(ctx context.Context, blockNrOrHash rpc.BlockNumberOrHash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) { + var block *types.Block + + block, err := api.eth.APIBackend.BlockByNumberOrHash(ctx, blockNrOrHash) + if err != nil { + return StorageRangeResult{}, err + } + if block == nil { - return StorageRangeResult{}, fmt.Errorf("block %#x not found", blockHash) + return StorageRangeResult{}, fmt.Errorf("block %v not found", blockNrOrHash) } _, _, statedb, release, err := api.eth.stateAtTransaction(ctx, block, txIndex, 0) if err != nil {