mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
eth: fix an issue when use debug.storageRangeAt
apply the transaction with the previous found state
This commit is contained in:
parent
507ae53d67
commit
19861d8639
1 changed files with 12 additions and 1 deletions
13
eth/api.go
13
eth/api.go
|
|
@ -34,6 +34,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/rawdb"
|
"github.com/ethereum/go-ethereum/core/rawdb"
|
||||||
"github.com/ethereum/go-ethereum/core/state"
|
"github.com/ethereum/go-ethereum/core/state"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
|
"github.com/ethereum/go-ethereum/core/vm"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi"
|
"github.com/ethereum/go-ethereum/internal/ethapi"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
|
@ -351,10 +352,20 @@ type storageEntry struct {
|
||||||
|
|
||||||
// StorageRangeAt returns the storage at the given block height and transaction index.
|
// StorageRangeAt returns the storage at the given block height and transaction index.
|
||||||
func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) {
|
func (api *PrivateDebugAPI) StorageRangeAt(ctx context.Context, blockHash common.Hash, txIndex int, contractAddress common.Address, keyStart hexutil.Bytes, maxResult int) (StorageRangeResult, error) {
|
||||||
_, _, statedb, err := api.computeTxEnv(blockHash, txIndex, 0)
|
msg, context, statedb, err := api.computeTxEnv(blockHash, txIndex, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return StorageRangeResult{}, err
|
return StorageRangeResult{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// execute the tx on top of the current state
|
||||||
|
vmenv := vm.NewEVM(context, statedb, api.config, vm.Config{})
|
||||||
|
if _, _, _, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas())); err != nil {
|
||||||
|
return StorageRangeResult{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure any modifications are committed to the state
|
||||||
|
statedb.Finalise(true)
|
||||||
|
|
||||||
st := statedb.StorageTrie(contractAddress)
|
st := statedb.StorageTrie(contractAddress)
|
||||||
if st == nil {
|
if st == nil {
|
||||||
return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress)
|
return StorageRangeResult{}, fmt.Errorf("account %x doesn't exist", contractAddress)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue