diff --git a/rpc/jsonrpc/eth_call.go b/rpc/jsonrpc/eth_call.go index f1cd0e2fb43..dbb12e9739c 100644 --- a/rpc/jsonrpc/eth_call.go +++ b/rpc/jsonrpc/eth_call.go @@ -432,11 +432,20 @@ func (api *APIImpl) GetProof(ctx context.Context, address common.Address, storag } defer roTx.Rollback() - requestedBlockNr, _, _, err := rpchelper.GetCanonicalBlockNumber(ctx, blockNrOrHash, roTx, api._blockReader, api.filters) + // nil filters: the gate below and the commitment-history reads both go through + // this plain roTx, so the tag has to resolve on that same committed view. + requestedBlockNr, _, _, err := rpchelper.GetCanonicalBlockNumber(ctx, blockNrOrHash, roTx, api._blockReader, nil) if err != nil { return nil, err } + // A canonical hash exists for blocks the header stage has downloaded but + // execution has not reached; the commitment history getProof needs is only + // written by execution. + if err := rpchelper.CheckBlockExecuted(roTx, uint64(requestedBlockNr)); err != nil { + return nil, err + } + err = api.BaseAPI.checkPruneHistory(ctx, roTx, uint64(requestedBlockNr)) if err != nil { return nil, err diff --git a/rpc/jsonrpc/parity_api.go b/rpc/jsonrpc/parity_api.go index 2a4276248d7..582e34c717d 100644 --- a/rpc/jsonrpc/parity_api.go +++ b/rpc/jsonrpc/parity_api.go @@ -75,7 +75,12 @@ func (api *ParityAPIImpl) ListStorageKeys(ctx context.Context, account common.Ad } bn := rawdb.ReadCurrentBlockNumber(tx) - minTxNum, err := api._txNumReader.Min(ctx, tx, *bn) + if bn == nil { + return nil, errors.New("current block number not found") + } + // Min(bn+1) is the first txNum past bn — the state the latest-state account + // read above sees. Min(bn) would scan storage as of the end of bn-1. + minTxNum, err := api._txNumReader.Min(ctx, tx, *bn+1) if err != nil { return nil, err }