diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 52b581965e88..83eefabc2a0f 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -634,7 +634,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM msg := callMsg{call} txContext := core.NewEVMTxContext(msg) - evmContext := core.NewEVMBlockContext(block.Header(), b.blockchain, nil) + evmContext := core.NewEVMBlockContext(block.Header(), b.blockchain, b.config, nil) // Create a new environment which holds all relevant information // about the transaction and calling mechanisms. vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true}) diff --git a/core/evm.go b/core/evm.go index c5d71a316f3c..f9f33086c3a9 100644 --- a/core/evm.go +++ b/core/evm.go @@ -23,6 +23,7 @@ import ( "github.com/scroll-tech/go-ethereum/consensus" "github.com/scroll-tech/go-ethereum/core/types" "github.com/scroll-tech/go-ethereum/core/vm" + "github.com/scroll-tech/go-ethereum/params" ) // ChainContext supports retrieving headers and consensus parameters from the @@ -36,14 +37,16 @@ type ChainContext interface { } // NewEVMBlockContext creates a new context for use in the EVM. -func NewEVMBlockContext(header *types.Header, chain ChainContext, author *common.Address) vm.BlockContext { +func NewEVMBlockContext(header *types.Header, chain ChainContext, chainConfig *params.ChainConfig, author *common.Address) vm.BlockContext { var ( beneficiary common.Address baseFee *big.Int ) // If we don't have an explicit author (i.e. not mining), extract from the header - if author == nil { + if chainConfig.Scroll.FeeVaultEnabled() { + beneficiary = *chainConfig.Scroll.FeeVaultAddress + } else if author == nil { beneficiary, _ = chain.Engine().Author(header) // Ignore error, we're past header validation } else { beneficiary = *author diff --git a/core/state_prefetcher.go b/core/state_prefetcher.go index 47bf31c766b4..c0f669d9c79d 100644 --- a/core/state_prefetcher.go +++ b/core/state_prefetcher.go @@ -53,7 +53,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c var ( header = block.Header() gaspool = new(GasPool).AddGas(block.GasLimit()) - blockContext = NewEVMBlockContext(header, p.bc, nil) + blockContext = NewEVMBlockContext(header, p.bc, p.config, nil) evm = vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) signer = types.MakeSigner(p.config, header.Number) ) diff --git a/core/state_processor.go b/core/state_processor.go index 8011adf243e6..9e3968cc6748 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -71,7 +71,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg if p.config.DAOForkSupport && p.config.DAOForkBlock != nil && p.config.DAOForkBlock.Cmp(block.Number()) == 0 { misc.ApplyDAOHardFork(statedb) } - blockContext := NewEVMBlockContext(header, p.bc, nil) + blockContext := NewEVMBlockContext(header, p.bc, p.config, nil) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg) // Iterate over and process the individual transactions for i, tx := range block.Transactions() { @@ -159,7 +159,7 @@ func ApplyTransaction(config *params.ChainConfig, bc ChainContext, author *commo return nil, err } // Create a new context to be used in the EVM environment - blockContext := NewEVMBlockContext(header, bc, author) + blockContext := NewEVMBlockContext(header, bc, config, author) vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, config, cfg) return applyTransaction(msg, config, bc, author, gp, statedb, header.Number, header.Hash(), tx, usedGas, vmenv) } diff --git a/core/state_transition.go b/core/state_transition.go index 3aeb75c02ed4..c0a72edcdde2 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -413,16 +413,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { } } - if st.evm.ChainConfig().Scroll.FeeVaultEnabled() { - // The L2 Fee is the same as the fee that is charged in the normal geth - // codepath. Add the L1DataFee to the L2 fee for the total fee that is sent - // to the sequencer. - l2Fee := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip) - fee := new(big.Int).Add(st.l1DataFee, l2Fee) - st.state.AddBalance(st.evm.FeeRecipient(), fee) - } else { - st.state.AddBalance(st.evm.FeeRecipient(), new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip)) - } + // The L2 Fee is the same as the fee that is charged in the normal geth + // codepath. Add the L1DataFee to the L2 fee for the total fee that is sent + // to the sequencer. + l2Fee := new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip) + fee := new(big.Int).Add(st.l1DataFee, l2Fee) + st.state.AddBalance(st.evm.FeeRecipient(), fee) return &ExecutionResult{ L1DataFee: st.l1DataFee, diff --git a/core/trace.go b/core/trace.go index 05ef96aece36..c5558c12f22d 100644 --- a/core/trace.go +++ b/core/trace.go @@ -105,7 +105,7 @@ func CreateTraceEnv(chainConfig *params.ChainConfig, chainContext ChainContext, coinbase: coinbase, signer: types.MakeSigner(chainConfig, block.Number()), state: statedb, - blockCtx: NewEVMBlockContext(block.Header(), chainContext, nil), + blockCtx: NewEVMBlockContext(block.Header(), chainContext, chainConfig, nil), StorageTrace: &types.StorageTrace{ RootBefore: parent.Root(), RootAfter: block.Root(), diff --git a/core/vm/evm.go b/core/vm/evm.go index 8404ba2bed0f..1e8689aa02b7 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -537,9 +537,5 @@ func (evm *EVM) ChainConfig() *params.ChainConfig { return evm.chainConfig } // FeeRecipient returns the environment's transaction fee recipient address. func (evm *EVM) FeeRecipient() common.Address { - if evm.ChainConfig().Scroll.FeeVaultEnabled() { - return *evm.chainConfig.Scroll.FeeVaultAddress - } else { - return evm.Context.Coinbase - } + return evm.Context.Coinbase } diff --git a/eth/api_backend.go b/eth/api_backend.go index 9be299ad39ef..7aa7525e978f 100644 --- a/eth/api_backend.go +++ b/eth/api_backend.go @@ -211,7 +211,7 @@ func (b *EthAPIBackend) GetEVM(ctx context.Context, msg core.Message, state *sta vmConfig = b.eth.blockchain.GetVMConfig() } txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(header, b.eth.BlockChain(), nil) + context := core.NewEVMBlockContext(header, b.eth.BlockChain(), b.eth.blockchain.Config(), nil) return vm.NewEVM(context, txContext, state, b.eth.blockchain.Config(), *vmConfig), vmError, nil } diff --git a/eth/state_accessor.go b/eth/state_accessor.go index 6c2d2f9bfec7..a82bc05288d7 100644 --- a/eth/state_accessor.go +++ b/eth/state_accessor.go @@ -185,7 +185,7 @@ func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec // Assemble the transaction call message and return if the requested offset msg, _ := tx.AsMessage(signer, block.BaseFee()) txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(block.Header(), eth.blockchain, nil) + context := core.NewEVMBlockContext(block.Header(), eth.blockchain, eth.blockchain.Config(), nil) if idx == txIndex { return msg, context, statedb, nil } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 708b82813247..6347a2ddd770 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -274,7 +274,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config // Fetch and execute the next block trace tasks for task := range tasks { signer := types.MakeSigner(api.backend.ChainConfig(), task.block.Number()) - blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), nil) + blockCtx := core.NewEVMBlockContext(task.block.Header(), api.chainContext(localctx), api.backend.ChainConfig(), nil) // Trace all the transactions contained within for i, tx := range task.block.Transactions() { msg, _ := tx.AsMessage(signer, task.block.BaseFee()) @@ -533,7 +533,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config roots []common.Hash signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) chainConfig = api.backend.ChainConfig() - vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) + vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), api.backend.ChainConfig(), nil) deleteEmptyObjects = chainConfig.IsEIP158(block.Number()) ) for i, tx := range block.Transactions() { @@ -610,7 +610,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac if threads > len(txs) { threads = len(txs) } - blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) + blockCtx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), api.backend.ChainConfig(), nil) blockHash := block.Hash() for th := 0; th < threads; th++ { pend.Add(1) @@ -714,7 +714,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block dumps []string signer = types.MakeSigner(api.backend.ChainConfig(), block.Number()) chainConfig = api.backend.ChainConfig() - vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) + vmctx = core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), api.backend.ChainConfig(), nil) canon = true ) // Check if there are any overrides: the caller may wish to enable a future @@ -880,7 +880,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc if err != nil { return nil, err } - vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), nil) + vmctx := core.NewEVMBlockContext(block.Header(), api.chainContext(ctx), api.backend.ChainConfig(), nil) var traceConfig *TraceConfig if config != nil { diff --git a/eth/tracers/api_test.go b/eth/tracers/api_test.go index 6f3f2656af64..52e6eed9432a 100644 --- a/eth/tracers/api_test.go +++ b/eth/tracers/api_test.go @@ -168,7 +168,7 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block for idx, tx := range block.Transactions() { msg, _ := tx.AsMessage(signer, block.BaseFee()) txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(block.Header(), b.chain, nil) + context := core.NewEVMBlockContext(block.Header(), b.chain, b.chainConfig, nil) if idx == txIndex { return msg, context, statedb, nil } diff --git a/les/api_backend.go b/les/api_backend.go index b2bf572d850b..2e2e1209f300 100644 --- a/les/api_backend.go +++ b/les/api_backend.go @@ -191,7 +191,7 @@ func (b *LesApiBackend) GetEVM(ctx context.Context, msg core.Message, state *sta vmConfig = new(vm.Config) } txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(header, b.eth.blockchain, nil) + context := core.NewEVMBlockContext(header, b.eth.blockchain, b.eth.chainConfig, nil) return vm.NewEVM(context, txContext, state, b.eth.chainConfig, *vmConfig), state.Error, nil } diff --git a/les/odr_test.go b/les/odr_test.go index 2f7af21d6413..6878e3479ec6 100644 --- a/les/odr_test.go +++ b/les/odr_test.go @@ -138,7 +138,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai msg := callmsg{types.NewMessage(from.Address(), &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true)} - context := core.NewEVMBlockContext(header, bc, nil) + context := core.NewEVMBlockContext(header, bc, config, nil) txContext := core.NewEVMTxContext(msg) vmenv := vm.NewEVM(context, txContext, statedb, config, vm.Config{NoBaseFee: true}) @@ -154,7 +154,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai state := light.NewState(ctx, header, lc.Odr()) state.SetBalance(bankAddr, math.MaxBig256) msg := callmsg{types.NewMessage(bankAddr, &testContractAddr, 0, new(big.Int), 100000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true)} - context := core.NewEVMBlockContext(header, lc, nil) + context := core.NewEVMBlockContext(header, lc, config, nil) txContext := core.NewEVMTxContext(msg) vmenv := vm.NewEVM(context, txContext, state, config, vm.Config{NoBaseFee: true}) gp := new(core.GasPool).AddGas(math.MaxUint64) diff --git a/les/state_accessor.go b/les/state_accessor.go index 93ed93e53a5f..e343beae69a1 100644 --- a/les/state_accessor.go +++ b/les/state_accessor.go @@ -58,7 +58,7 @@ func (leth *LightEthereum) stateAtTransaction(ctx context.Context, block *types. // Assemble the transaction call message and return if the requested offset msg, _ := tx.AsMessage(signer, block.BaseFee()) txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(block.Header(), leth.blockchain, nil) + context := core.NewEVMBlockContext(block.Header(), leth.blockchain, leth.blockchain.Config(), nil) statedb.Prepare(tx.Hash(), idx) if idx == txIndex { return msg, context, statedb, nil diff --git a/light/odr_test.go b/light/odr_test.go index a7123b1825ed..a19c0d228efc 100644 --- a/light/odr_test.go +++ b/light/odr_test.go @@ -197,7 +197,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain st.SetBalance(testBankAddress, math.MaxBig256) msg := callmsg{types.NewMessage(testBankAddress, &testContractAddr, 0, new(big.Int), 1000000, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), new(big.Int), data, nil, true)} txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(header, chain, nil) + context := core.NewEVMBlockContext(header, chain, config, nil) vmenv := vm.NewEVM(context, txContext, st, config, vm.Config{NoBaseFee: true}) gp := new(core.GasPool).AddGas(math.MaxUint64) signer := types.MakeSigner(config, header.Number) diff --git a/params/version.go b/params/version.go index 8e46982c0a37..7577f094ba35 100644 --- a/params/version.go +++ b/params/version.go @@ -24,7 +24,7 @@ import ( const ( VersionMajor = 4 // Major version component of the current release VersionMinor = 3 // Minor version component of the current release - VersionPatch = 41 // Patch version component of the current release + VersionPatch = 42 // Patch version component of the current release VersionMeta = "sepolia" // Version metadata to append to the version string ) @@ -44,7 +44,8 @@ var VersionWithMeta = func() string { // ArchiveVersion holds the textual version string used for Geth archives. // e.g. "1.8.11-dea1ce05" for stable releases, or -// "1.8.13-unstable-21c059b6" for unstable releases +// +// "1.8.13-unstable-21c059b6" for unstable releases func ArchiveVersion(gitCommit string) string { vsn := Version if VersionMeta != "stable" { diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 14457613f5a6..0172239e71c2 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -217,7 +217,7 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh // Prepare the EVM. txContext := core.NewEVMTxContext(msg) - context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase) + context := core.NewEVMBlockContext(block.Header(), nil, config, &t.json.Env.Coinbase) context.GetHash = vmTestBlockHash context.BaseFee = baseFee evm := vm.NewEVM(context, txContext, statedb, config, vmconfig)