mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 14:46:42 +00:00
core: fixed calls to NewEVM and call
This commit is contained in:
parent
c23db04a2d
commit
1684eaec99
7 changed files with 14 additions and 17 deletions
|
|
@ -707,9 +707,8 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
|
|||
|
||||
// Create a new environment which holds all relevant information
|
||||
// about the transaction and calling mechanisms.
|
||||
txContext := core.NewEVMTxContext(msg)
|
||||
evmContext := core.NewEVMBlockContext(header, b.blockchain, nil)
|
||||
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true})
|
||||
vmEnv := vm.NewEVM(evmContext, stateDB, b.config, vm.Config{NoBaseFee: true})
|
||||
gasPool := new(core.GasPool).AddGas(gomath.MaxUint64)
|
||||
|
||||
return core.ApplyMessage(vmEnv, msg, gasPool, context.Background())
|
||||
|
|
|
|||
|
|
@ -81,12 +81,12 @@ func ApplyMessage(
|
|||
|
||||
// Create a new environment which holds all relevant information
|
||||
// about the transaction and calling mechanisms.
|
||||
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, state, chainConfig, vm.Config{})
|
||||
vmenv := vm.NewEVM(blockContext, state, chainConfig, vm.Config{})
|
||||
|
||||
// nolint : contextcheck
|
||||
// Apply the transaction to the current state (included in the env)
|
||||
ret, gasLeft, err := vmenv.Call(
|
||||
vm.AccountRef(msg.From()),
|
||||
msg.From(),
|
||||
*msg.To(),
|
||||
msg.Data(),
|
||||
msg.Gas(),
|
||||
|
|
@ -124,7 +124,7 @@ func ApplyBorMessage(vmenv *vm.EVM, msg Callmsg) (*core.ExecutionResult, error)
|
|||
|
||||
// Apply the transaction to the current state (included in the env)
|
||||
ret, gasLeft, err := vmenv.Call(
|
||||
vm.AccountRef(msg.From()),
|
||||
msg.From(),
|
||||
*msg.To(),
|
||||
msg.Data(),
|
||||
msg.Gas(),
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ func (task *ExecutionTask) Execute(mvh *blockstm.MVHashMap, incarnation int) (er
|
|||
task.statedb.SetMVHashmap(mvh)
|
||||
task.statedb.SetIncarnation(incarnation)
|
||||
|
||||
evm := vm.NewEVM(task.blockContext, vm.TxContext{}, task.statedb, task.config, task.evmConfig)
|
||||
evm := vm.NewEVM(task.blockContext, task.statedb, task.config, task.evmConfig)
|
||||
|
||||
// Create a new context to be used in the EVM environment.
|
||||
txContext := NewEVMTxContext(&task.msg)
|
||||
|
|
@ -303,7 +303,7 @@ func (p *ParallelStateProcessor) Process(block *types.Block, statedb *state.Stat
|
|||
blockContext := NewEVMBlockContext(header, p.bc, nil)
|
||||
context := NewEVMBlockContext(header, p.bc.hc, nil)
|
||||
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, statedb, p.config, cfg)
|
||||
vmenv := vm.NewEVM(context, statedb, p.config, cfg)
|
||||
var tracingStateDB = vm.StateDB(statedb)
|
||||
if hooks := cfg.Tracer; hooks != nil {
|
||||
tracingStateDB = state.NewHookedState(statedb, hooks)
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ func ProcessBeaconBlockRoot(beaconRoot common.Hash, evm *vm.EVM) {
|
|||
}
|
||||
evm.SetTxContext(NewEVMTxContext(msg))
|
||||
evm.StateDB.AddAddressToAccessList(params.BeaconRootsAddress)
|
||||
_, _, _ = evm.Call(msg.From, *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||
_, _, _ = evm.Call(msg.From, *msg.To, msg.Data, 30_000_000, common.U2560, nil)
|
||||
evm.StateDB.Finalise(true)
|
||||
}
|
||||
|
||||
|
|
@ -357,7 +357,7 @@ func processRequestsSystemCall(requests *[][]byte, evm *vm.EVM, requestType byte
|
|||
}
|
||||
evm.SetTxContext(NewEVMTxContext(msg))
|
||||
evm.StateDB.AddAddressToAccessList(addr)
|
||||
ret, _, _ := evm.Call(msg.From, *msg.To, msg.Data, 30_000_000, common.U2560)
|
||||
ret, _, _ := evm.Call(msg.From, *msg.To, msg.Data, 30_000_000, common.U2560, nil)
|
||||
evm.StateDB.Finalise(true)
|
||||
if len(ret) == 0 {
|
||||
return // skip empty output
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
|
||||
traceTxn := func(indx int, tx *types.Transaction, borTx bool, stateSyncHash common.Hash) *TxTraceResult {
|
||||
message, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||
txContext := core.NewEVMTxContext(message)
|
||||
txHash := tx.Hash()
|
||||
if borTx {
|
||||
txHash = stateSyncHash
|
||||
|
|
@ -86,7 +85,7 @@ func (api *API) traceBorBlock(ctx context.Context, block *types.Block, config *T
|
|||
tracer := logger.NewStructLogger(config.Config)
|
||||
|
||||
// Run the transaction with tracing enabled.
|
||||
vmenv := vm.NewEVM(blockCtx, txContext, statedb, api.backend.ChainConfig(), vm.Config{Tracer: tracer.Hooks(), NoBaseFee: true})
|
||||
vmenv := vm.NewEVM(blockCtx, statedb, api.backend.ChainConfig(), vm.Config{Tracer: tracer.Hooks(), NoBaseFee: true})
|
||||
|
||||
// Call Prepare to clear out the statedb access list
|
||||
// Not sure if we need to do this
|
||||
|
|
|
|||
|
|
@ -187,11 +187,10 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block
|
|||
}
|
||||
// Recompute transactions up to the target index.
|
||||
signer := types.MakeSigner(b.chainConfig, block.Number(), block.Time())
|
||||
context := core.NewEVMBlockContext(block.Header(), b.chain, nil)
|
||||
evm := vm.NewEVM(context, statedb, b.chainConfig, vm.Config{})
|
||||
blockContext := core.NewEVMBlockContext(block.Header(), b.chain, nil)
|
||||
evm := vm.NewEVM(blockContext, statedb, b.chainConfig, vm.Config{})
|
||||
for idx, tx := range block.Transactions() {
|
||||
msg, _ := core.TransactionToMessage(tx, signer, block.BaseFee())
|
||||
txContext := core.NewEVMTxContext(msg)
|
||||
|
||||
blockContext := core.NewEVMBlockContext(block.Header(), b.chain, nil)
|
||||
if idx == txIndex {
|
||||
|
|
|
|||
|
|
@ -1306,12 +1306,12 @@ func (w *worker) prepareWork(genParams *generateParams, witness bool) (*environm
|
|||
}
|
||||
if header.ParentBeaconRoot != nil {
|
||||
context := core.NewEVMBlockContext(header, w.chain, nil)
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, w.chainConfig, vm.Config{})
|
||||
vmenv := vm.NewEVM(context, env.state, w.chainConfig, vm.Config{})
|
||||
core.ProcessBeaconBlockRoot(*header.ParentBeaconRoot, vmenv, env.state)
|
||||
}
|
||||
if w.chainConfig.IsPrague(header.Number) {
|
||||
context := core.NewEVMBlockContext(header, w.chain, nil)
|
||||
vmenv := vm.NewEVM(context, vm.TxContext{}, env.state, w.chainConfig, vm.Config{})
|
||||
vmenv := vm.NewEVM(context, env.state, w.chainConfig, vm.Config{})
|
||||
core.ProcessParentBlockHash(header.ParentHash, vmenv, env.state)
|
||||
}
|
||||
return env, nil
|
||||
|
|
@ -1437,7 +1437,7 @@ func (w *worker) generateWork(params *generateParams, witness bool) *newPayloadR
|
|||
requests = append(requests, depositRequests)
|
||||
// create EVM for system calls
|
||||
blockContext := core.NewEVMBlockContext(work.header, w.chain, &work.header.Coinbase)
|
||||
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, work.state, w.chainConfig, vm.Config{})
|
||||
vmenv := vm.NewEVM(blockContext, work.state, w.chainConfig, vm.Config{})
|
||||
// EIP-7002 withdrawals
|
||||
withdrawalRequests := core.ProcessWithdrawalQueue(vmenv, work.state)
|
||||
requests = append(requests, withdrawalRequests)
|
||||
|
|
|
|||
Loading…
Reference in a new issue