From 6e8d261e42179b5a3c29e38fa2279037514b125d Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Wed, 8 Oct 2025 12:38:32 +0800 Subject: [PATCH] all: eliminate zero owner variables (#1587) --- accounts/abi/bind/backends/simulated.go | 3 +-- core/token_validator.go | 3 +-- eth/state_accessor.go | 3 +-- eth/tracers/api.go | 6 ++---- eth/tracers/api_test.go | 3 +-- internal/ethapi/api.go | 4 +--- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 14dd30620b..f63e1e4012 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -768,8 +768,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM // about the transaction and calling mechanisms. vmenv := vm.NewEVM(evmContext, txContext, stateDB, nil, b.config, vm.Config{NoBaseFee: true}) gaspool := new(core.GasPool).AddGas(gomath.MaxUint64) - owner := common.Address{} - return core.NewStateTransition(vmenv, msg, gaspool).TransitionDb(owner) + return core.NewStateTransition(vmenv, msg, gaspool).TransitionDb(common.Address{}) } // SendTransaction updates the pending block to include the given transaction. diff --git a/core/token_validator.go b/core/token_validator.go index b4ab9f09b9..9b09ccd7d3 100644 --- a/core/token_validator.go +++ b/core/token_validator.go @@ -111,8 +111,7 @@ func CallContractWithState(call ethereum.CallMsg, chain consensus.ChainContext, evmContext := NewEVMBlockContext(chain.CurrentHeader(), chain, nil) vmenv := vm.NewEVM(evmContext, txContext, statedb, nil, chain.Config(), vm.Config{}) gaspool := new(GasPool).AddGas(1000000) - owner := common.Address{} - result, err := NewStateTransition(vmenv, msg, gaspool).TransitionDb(owner) + result, err := NewStateTransition(vmenv, msg, gaspool).TransitionDb(common.Address{}) if err != nil { return nil, err } diff --git a/eth/state_accessor.go b/eth/state_accessor.go index acf976c030..8e875faebc 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -229,8 +229,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block, // Not yet the searched for transaction, execute on top of the current state vmenv := vm.NewEVM(context, txContext, statedb, nil, eth.blockchain.Config(), vm.Config{}) statedb.SetTxContext(tx.Hash(), idx) - owner := common.Address{} - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), owner); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), common.Address{}); err != nil { return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err) } // Ensure any modifications are committed to the state diff --git a/eth/tracers/api.go b/eth/tracers/api.go index af4d18f7d3..458e033b3c 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -522,8 +522,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config vmenv = vm.NewEVM(vmctx, txContext, statedb, nil, chainConfig, vm.Config{}) ) statedb.SetTxContext(tx.Hash(), i) - owner := common.Address{} - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), owner); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), common.Address{}); err != nil { log.Warn("Tracing intermediate roots did not complete", "txindex", i, "txhash", tx.Hash(), "err", err) // We intentionally don't return the error here: if we do, then the RPC server will not // return the roots. Most likely, the caller already knows that a certain transaction fails to @@ -693,8 +692,7 @@ txloop: msg, _ := core.TransactionToMessage(tx, signer, balance, header.Number, header.BaseFee) statedb.SetTxContext(tx.Hash(), i) vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, nil, api.backend.ChainConfig(), vm.Config{}) - owner := common.Address{} - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), owner); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), common.Address{}); err != nil { failed = err break txloop } diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 4ba56a512e..0bafbe03e4 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -181,8 +181,7 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block return tx, context, statedb, release, nil } vmenv := vm.NewEVM(context, txContext, statedb, nil, b.chainConfig, vm.Config{}) - owner := common.Address{} - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), owner); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.Gas()), common.Address{}); err != nil { return nil, vm.BlockContext{}, nil, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err) } statedb.Finalise(vmenv.ChainConfig().IsEIP158(block.Number())) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 18759a1f88..748320ccda 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -1790,7 +1790,6 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH if err != nil { return nil, 0, nil, err } - owner := common.Address{} // Ensure any missing fields are filled, extract the recipient and input data if err := args.setDefaults(ctx, b, true); err != nil { @@ -1835,8 +1834,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH if err != nil { return nil, 0, nil, err } - // TODO: determine the value of owner - res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), owner) + res, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.GasLimit), common.Address{}) if err != nil { return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.ToTransaction().Hash(), err) }