diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 9edd5591f8..23a31efd17 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1367,11 +1367,20 @@ func (e *revertError) ErrorData() interface{} { // Note, this function doesn't make and changes in the state/blockchain and is // useful to execute and retrieve values. func (s *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockNrOrHash *rpc.BlockNumberOrHash, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error) { - if blockNrOrHash == nil { - latest := rpc.BlockNumberOrHashWithNumber(rpc.LatestBlockNumber) - blockNrOrHash = &latest - } - result, err := DoCall(ctx, s.b, args, *blockNrOrHash, overrides, blockOverrides, s.b.RPCEVMTimeout(), s.b.RPCGasCap()) + return s.CallWithState(ctx, args, *blockNrOrHash, nil, overrides, blockOverrides) +} + +// CallWithState executes the given transaction on the given state for +// the given block number. Note that as it does an EVM call, fields in +// the underlying state will change. Make sure to handle it outside of +// this function (ideally by sending a copy of state). +// +// Additionally, the caller can specify a batch of contract for fields overriding. +// +// Note, this function doesn't make and changes in the state/blockchain and is +// useful to execute and retrieve values. +func (s *BlockChainAPI) CallWithState(ctx context.Context, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, state *state.StateDB, overrides *StateOverride, blockOverrides *BlockOverrides) (hexutil.Bytes, error) { + result, err := DoCall(ctx, s.b, args, blockNrOrHash, state, overrides, blockOverrides, s.b.RPCEVMTimeout(), s.b.RPCGasCap()) if err != nil { return nil, err } diff --git a/miner/test_backend.go b/miner/test_backend.go index 77baeb0c6f..b2fa96b059 100644 --- a/miner/test_backend.go +++ b/miner/test_backend.go @@ -512,7 +512,7 @@ func (w *worker) commitTransactionsWithDelay(env *environment, txs *transactions var depsWg sync.WaitGroup - EnableMVHashMap := w.chainConfig.Bor.IsParallelUniverse(env.header.Number) + EnableMVHashMap := w.chainConfig.IsCancun(env.header.Number) // create and add empty mvHashMap in statedb if EnableMVHashMap {