Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update L1 data fee in Curie hard fork #755

Merged
merged 29 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
21025d6
update fee calculation
Thegaram May 17, 2024
1b2fa46
add missing GPO slots to trace
Thegaram May 17, 2024
1cf9935
add placeholder for contract update logic
Thegaram May 17, 2024
8d3e6be
nit
Thegaram May 17, 2024
328145a
update fee calculation
Thegaram May 17, 2024
5bba53c
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 21, 2024
0bf47ae
update formula
Thegaram May 21, 2024
5d5a0ff
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 22, 2024
e034053
update GPO slots
Thegaram May 22, 2024
d24b861
update L1GPO bytecode
Thegaram May 22, 2024
7b2cf06
apply Curie in new worker
Thegaram May 23, 2024
19a269d
move bytecode to config
Thegaram May 23, 2024
df68328
create an empty block for curie hard fork
omerfirmak May 23, 2024
626f789
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 23, 2024
b8581d5
initialize L1GasPriceOracle storage slots
Thegaram May 23, 2024
5a2118e
add comments
Thegaram May 23, 2024
896a5c7
add test
Thegaram May 23, 2024
ec5c347
add IsCurie to traces and tests
Thegaram May 23, 2024
63c9bd9
group GPO storage slots into a struct
Thegaram May 23, 2024
8f38fc4
update unit test
Thegaram May 23, 2024
fd406f4
chore: auto version bump [bot]
Thegaram May 23, 2024
8316a6e
trigger ci
Thegaram May 23, 2024
8dc419a
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 26, 2024
5c02f09
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 28, 2024
110238a
update bytecode
Thegaram May 28, 2024
71f9770
remove leading 0x
Thegaram May 28, 2024
3310746
update comments
Thegaram May 28, 2024
70d5402
include rollup fee tests in CI
Thegaram May 28, 2024
6c50ae0
Merge branch 'develop' into feat-curie-gas-oracle
Thegaram May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ func (b *SimulatedBackend) callContract(ctx context.Context, call ethereum.CallM
vmEnv := vm.NewEVM(evmContext, txContext, stateDB, b.config, vm.Config{NoBaseFee: true})
gasPool := new(core.GasPool).AddGas(math.MaxUint64)
signer := types.MakeSigner(b.blockchain.Config(), head.Number)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, head.BaseFee, b.blockchain.Config().ChainID, signer, stateDB)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, head.BaseFee, b.blockchain.Config(), signer, stateDB, head.Number)
if err != nil {
return nil, err
}
Expand Down
6 changes: 5 additions & 1 deletion cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
chainConfig.DAOForkBlock.Cmp(new(big.Int).SetUint64(pre.Env.Number)) == 0 {
misc.ApplyDAOHardFork(statedb)
}
// Apply Curie hard fork
if chainConfig.CurieBlock != nil && chainConfig.CurieBlock.Cmp(new(big.Int).SetUint64(pre.Env.Number)) == 0 {
misc.ApplyCurieHardFork(statedb)
}

for i, tx := range txs {
msg, err := tx.AsMessage(signer, pre.Env.BaseFee)
Expand All @@ -167,7 +171,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
snapshot := statedb.Snapshot()
evm := vm.NewEVM(vmContext, txContext, statedb, chainConfig, vmConfig)

l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, chainConfig, new(big.Int).SetUint64(pre.Env.Number))
if err != nil {
log.Info("rejected tx due to fees.CalculateL1DataFee", "index", i, "hash", tx.Hash(), "from", msg.From(), "error", err)
rejectedTxs = append(rejectedTxs, &rejectedTx{i, err.Error()})
Expand Down
9 changes: 9 additions & 0 deletions consensus/misc/curie.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package misc

import "github.com/scroll-tech/go-ethereum/core/state"

// ApplyCurieHardFork modifies the state database according to the Curie hard-fork
// rules, updating the bytecode of the L1GasPriceOracle contract.
func ApplyCurieHardFork(statedb *state.StateDB) {
// TODO
}
3 changes: 3 additions & 0 deletions core/chain_makers.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ func GenerateChain(config *params.ChainConfig, parent *types.Block, engine conse
if config.DAOForkSupport && config.DAOForkBlock != nil && config.DAOForkBlock.Cmp(b.header.Number) == 0 {
misc.ApplyDAOHardFork(statedb)
}
if config.CurieBlock != nil && config.CurieBlock.Cmp(b.header.Number) == 0 {
misc.ApplyCurieHardFork(statedb)
}
// Execute any user modifications to the block
if gen != nil {
gen(i, b)
Expand Down
2 changes: 1 addition & 1 deletion core/state_prefetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (p *statePrefetcher) Prefetch(block *types.Block, statedb *state.StateDB, c
}
statedb.SetTxContext(tx.Hash(), i)

l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, p.config, block.Number())
if err != nil {
return
}
Expand Down
6 changes: 5 additions & 1 deletion core/state_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ 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)
}
// Apply Curie hard fork
if p.config.CurieBlock != nil && p.config.CurieBlock.Cmp(block.Number()) == 0 {
misc.ApplyCurieHardFork(statedb)
}
blockContext := NewEVMBlockContext(header, p.bc, p.config, nil)
vmenv := vm.NewEVM(blockContext, vm.TxContext{}, statedb, p.config, cfg)
processorBlockTransactionGauge.Update(int64(block.Transactions().Len()))
Expand Down Expand Up @@ -120,7 +124,7 @@ func applyTransaction(msg types.Message, config *params.ChainConfig, bc ChainCon
txContext := NewEVMTxContext(msg)
evm.Reset(txContext, statedb)

l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, config, blockNumber)
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions core/tx_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/scroll-tech/go-ethereum/core/state"
"github.com/scroll-tech/go-ethereum/core/types"
"github.com/scroll-tech/go-ethereum/log"
"github.com/scroll-tech/go-ethereum/params"
"github.com/scroll-tech/go-ethereum/rollup/fees"
)

Expand Down Expand Up @@ -281,7 +282,7 @@ func (l *txList) Overlaps(tx *types.Transaction) bool {
//
// If the new transaction is accepted into the list, the lists' cost and gas
// thresholds are also potentially updated.
func (l *txList) Add(tx *types.Transaction, state *state.StateDB, priceBump uint64) (bool, *types.Transaction) {
func (l *txList) Add(tx *types.Transaction, state *state.StateDB, priceBump uint64, chainconfig *params.ChainConfig, blockNumber *big.Int) (bool, *types.Transaction) {
// If there's an older better transaction, abort
old := l.txs.Get(tx.Nonce())
if old != nil {
Expand All @@ -307,9 +308,9 @@ func (l *txList) Add(tx *types.Transaction, state *state.StateDB, priceBump uint
}
// Otherwise overwrite the old transaction with the current one
l1DataFee := big.NewInt(0)
if state != nil {
if state != nil && chainconfig != nil {
var err error
l1DataFee, err = fees.CalculateL1DataFee(tx, state)
l1DataFee, err = fees.CalculateL1DataFee(tx, state, chainconfig, blockNumber)
if err != nil {
log.Error("Failed to calculate L1 data fee", "err", err, "tx", tx)
return false, nil
Expand Down
4 changes: 2 additions & 2 deletions core/tx_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func TestStrictTxListAdd(t *testing.T) {
// Insert the transactions in a random order
list := newTxList(true)
for _, v := range rand.Perm(len(txs)) {
list.Add(txs[v], nil, DefaultTxPoolConfig.PriceBump)
list.Add(txs[v], nil, DefaultTxPoolConfig.PriceBump, nil, nil)
}
// Verify internal state
if len(list.txs.items) != len(txs) {
Expand All @@ -65,7 +65,7 @@ func BenchmarkTxListAdd(b *testing.B) {
for i := 0; i < b.N; i++ {
list := newTxList(true)
for _, v := range rand.Perm(len(txs)) {
list.Add(txs[v], nil, DefaultTxPoolConfig.PriceBump)
list.Add(txs[v], nil, DefaultTxPoolConfig.PriceBump, nil, nil)
list.Filter(priceLimit, DefaultTxPoolConfig.PriceBump)
}
}
Expand Down
14 changes: 9 additions & 5 deletions core/tx_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ type TxPool struct {
shanghai bool // Fork indicator whether we are in the Shanghai stage.

currentState *state.StateDB // Current state in the blockchain head
currentHead *big.Int // Current blockchain head
pendingNonces *txNoncer // Pending state tracking virtual nonces
currentMaxGas uint64 // Current gas limit for transaction caps

Expand Down Expand Up @@ -664,7 +665,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
// 2. If FeeVault is enabled, perform an additional check for L1 data fees.
if pool.chainconfig.Scroll.FeeVaultEnabled() {
// Get L1 data fee in current state
l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState)
l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState, pool.chainconfig, pool.currentHead)
if err != nil {
return fmt.Errorf("failed to calculate L1 data fee, err: %w", err)
}
Expand Down Expand Up @@ -751,7 +752,7 @@ func (pool *TxPool) add(tx *types.Transaction, local bool) (replaced bool, err e
from, _ := types.Sender(pool.signer, tx) // already validated
if list := pool.pending[from]; list != nil && list.Overlaps(tx) {
// Nonce already pending, check if required price bump is met
inserted, old := list.Add(tx, pool.currentState, pool.config.PriceBump)
inserted, old := list.Add(tx, pool.currentState, pool.config.PriceBump, pool.chainconfig, pool.currentHead)
if !inserted {
pendingDiscardMeter.Mark(1)
return false, ErrReplaceUnderpriced
Expand Down Expand Up @@ -802,7 +803,7 @@ func (pool *TxPool) enqueueTx(hash common.Hash, tx *types.Transaction, local boo
pool.queue[from] = newTxList(false)
}

inserted, old := pool.queue[from].Add(tx, pool.currentState, pool.config.PriceBump)
inserted, old := pool.queue[from].Add(tx, pool.currentState, pool.config.PriceBump, pool.chainconfig, pool.currentHead)
if !inserted {
// An older transaction was better, discard this
queuedDiscardMeter.Mark(1)
Expand Down Expand Up @@ -856,7 +857,7 @@ func (pool *TxPool) promoteTx(addr common.Address, hash common.Hash, tx *types.T
}
list := pool.pending[addr]

inserted, old := list.Add(tx, pool.currentState, pool.config.PriceBump)
inserted, old := list.Add(tx, pool.currentState, pool.config.PriceBump, pool.chainconfig, pool.currentHead)
if !inserted {
// An older transaction was better, discard this
pool.all.Remove(hash)
Expand Down Expand Up @@ -1357,6 +1358,9 @@ func (pool *TxPool) reset(oldHead, newHead *types.Header) {
pool.eip2718 = pool.chainconfig.IsCurie(next)
pool.eip1559 = pool.chainconfig.IsCurie(next)
pool.shanghai = pool.chainconfig.IsShanghai(next)

// Update current head
pool.currentHead = next
}

// promoteExecutables moves transactions that have become processable from the
Expand Down Expand Up @@ -1435,7 +1439,7 @@ func (pool *TxPool) executableTxFilter(costLimit *big.Int) func(tx *types.Transa

if pool.chainconfig.Scroll.FeeVaultEnabled() {
// recheck L1 data fee, as the oracle price may have changed
l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState)
l1DataFee, err := fees.CalculateL1DataFee(tx, pool.currentState, pool.chainconfig, pool.currentHead)
if err != nil {
log.Error("Failed to calculate L1 data fee", "err", err, "tx", tx)
return false
Expand Down
2 changes: 1 addition & 1 deletion eth/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func (eth *Ethereum) stateAtTransaction(block *types.Block, txIndex int, reexec
// Not yet the searched for transaction, execute on top of the current state
vmenv := vm.NewEVM(context, txContext, statedb, eth.blockchain.Config(), vm.Config{})
statedb.SetTxContext(tx.Hash(), idx)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, eth.blockchain.Config(), block.Number())
if err != nil {
return nil, vm.BlockContext{}, nil, err
}
Expand Down
14 changes: 7 additions & 7 deletions eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (api *API) traceChain(ctx context.Context, start, end *types.Block, config
TxHash: tx.Hash(),
}

l1DataFee, err := fees.CalculateL1DataFee(tx, task.statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, task.statedb, api.backend.ChainConfig(), task.block.Number())
if err != nil {
// though it's not a "tracing error", we still need to put it here
task.results[i] = &txTraceResult{Error: err.Error()}
Expand Down Expand Up @@ -545,7 +545,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config
)
statedb.SetTxContext(tx.Hash(), i)

l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, api.backend.ChainConfig(), block.Number())
if err != nil {
log.Warn("Tracing intermediate roots did not complete due to fees.CalculateL1DataFee", "txindex", i, "txhash", tx.Hash(), "err", err)
return nil, err
Expand Down Expand Up @@ -626,7 +626,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
TxHash: txs[task.index].Hash(),
}

l1DataFee, err := fees.CalculateL1DataFee(txs[task.index], task.statedb)
l1DataFee, err := fees.CalculateL1DataFee(txs[task.index], task.statedb, api.backend.ChainConfig(), block.Number())
if err != nil {
// though it's not a "tracing error", we still need to put it here
results[task.index] = &txTraceResult{Error: err.Error()}
Expand All @@ -651,7 +651,7 @@ func (api *API) traceBlock(ctx context.Context, block *types.Block, config *Trac
msg, _ := tx.AsMessage(signer, block.BaseFee())
statedb.SetTxContext(tx.Hash(), i)
vmenv := vm.NewEVM(blockCtx, core.NewEVMTxContext(msg), statedb, api.backend.ChainConfig(), vm.Config{})
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, api.backend.ChainConfig(), block.Number())
if err != nil {
failed = err
break
Expand Down Expand Up @@ -769,7 +769,7 @@ func (api *API) standardTraceBlockToFile(ctx context.Context, block *types.Block
// Execute the transaction and flush any traces to disk
vmenv := vm.NewEVM(vmctx, txContext, statedb, chainConfig, vmConf)
statedb.SetTxContext(tx.Hash(), i)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, api.backend.ChainConfig(), block.Number())
if err == nil {
_, err = core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), l1DataFee)
}
Expand Down Expand Up @@ -834,7 +834,7 @@ func (api *API) TraceTransaction(ctx context.Context, hash common.Hash, config *
TxIndex: int(index),
TxHash: hash,
}
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, api.backend.ChainConfig(), block.Number())
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -894,7 +894,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
}

signer := types.MakeSigner(api.backend.ChainConfig(), block.Number())
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, block.BaseFee(), api.backend.ChainConfig().ChainID, signer, statedb)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, block.BaseFee(), api.backend.ChainConfig(), signer, statedb, block.Number())
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (b *testBackend) StateAtTransaction(ctx context.Context, block *types.Block
return msg, context, statedb, nil
}
vmenv := vm.NewEVM(context, txContext, statedb, b.chainConfig, vm.Config{})
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, b.chainConfig, block.Number())
if err != nil {
return nil, vm.BlockContext{}, nil, err
}
Expand Down
6 changes: 3 additions & 3 deletions eth/tracers/internal/tracetest/calltrace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) {
if err != nil {
t.Fatalf("failed to prepare transaction for tracing: %v", err)
}
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, test.Genesis.Config, context.BlockNumber)
if err != nil {
t.Fatalf("failed to calculate l1DataFee: %v", err)
}
Expand Down Expand Up @@ -308,7 +308,7 @@ func benchTracer(tracerName string, test *callTracerTest, b *testing.B) {
}
evm := vm.NewEVM(context, txContext, statedb, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer})
snap := statedb.Snapshot()
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, test.Genesis.Config, context.BlockNumber)
if err != nil {
b.Fatalf("failed to calculate l1DataFee: %v", err)
}
Expand Down Expand Up @@ -381,7 +381,7 @@ func TestZeroValueToNotExitCall(t *testing.T) {
if err != nil {
t.Fatalf("failed to prepare transaction for tracing: %v", err)
}
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, params.MainnetChainConfig, context.BlockNumber)
if err != nil {
t.Fatalf("failed to calculate l1DataFee: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion eth/tracers/tracers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func BenchmarkTransactionTrace(b *testing.B) {

for i := 0; i < b.N; i++ {
snap := statedb.Snapshot()
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, params.AllEthashProtocolChanges, context.BlockNumber)
if err != nil {
b.Fatal(err)
}
Expand Down
8 changes: 5 additions & 3 deletions ethclient/ethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,11 @@ var genesis = &core.Genesis{
rcfg.L1GasPriceOracleAddress: {
Balance: big.NewInt(0),
Storage: map[common.Hash]common.Hash{
rcfg.L1BaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.OverheadSlot: common.BigToHash(big.NewInt(10000)),
rcfg.ScalarSlot: common.BigToHash(big.NewInt(10000)),
rcfg.L1BaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.OverheadSlot: common.BigToHash(big.NewInt(10000)),
rcfg.ScalarSlot: common.BigToHash(big.NewInt(10000)),
rcfg.L1BlobBaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.BlobScalarSlot: common.BigToHash(big.NewInt(10000)),
Thegaram marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
8 changes: 5 additions & 3 deletions ethclient/gethclient/gethclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ func generateTestChain() (*core.Genesis, []*types.Block) {
rcfg.L1GasPriceOracleAddress: {
Balance: big.NewInt(0),
Storage: map[common.Hash]common.Hash{
rcfg.L1BaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.OverheadSlot: common.BigToHash(big.NewInt(10000)),
rcfg.ScalarSlot: common.BigToHash(big.NewInt(10000)),
rcfg.L1BaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.OverheadSlot: common.BigToHash(big.NewInt(10000)),
rcfg.ScalarSlot: common.BigToHash(big.NewInt(10000)),
rcfg.L1BlobBaseFeeSlot: common.BigToHash(big.NewInt(10000)),
rcfg.BlobScalarSlot: common.BigToHash(big.NewInt(10000)),
Thegaram marked this conversation as resolved.
Show resolved Hide resolved
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ func EstimateL1MsgFee(ctx context.Context, b Backend, args TransactionArgs, bloc
}()

signer := types.MakeSigner(config, header.Number)
return fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config.ChainID, signer, evm.StateDB)
return fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config, signer, evm.StateDB, header.Number)
}

func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides *StateOverride, timeout time.Duration, globalGasCap uint64) (*core.ExecutionResult, error) {
Expand Down Expand Up @@ -1496,7 +1496,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
return nil, 0, nil, err
}
signer := types.MakeSigner(b.ChainConfig(), header.Number)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, b.ChainConfig().ChainID, signer, statedb)
l1DataFee, err := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, b.ChainConfig(), signer, statedb, header.Number)
if err != nil {
return nil, 0, nil, fmt.Errorf("failed to apply transaction: %v err: %v", args.toTransaction().Hash(), err)
}
Expand Down
4 changes: 2 additions & 2 deletions les/odr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
//vmenv := core.NewEnv(statedb, config, bc, msg, header, vm.Config{})
gp := new(core.GasPool).AddGas(math.MaxUint64)
signer := types.MakeSigner(config, header.Number)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config.ChainID, signer, statedb)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config, signer, statedb, header.Number)
result, _ := core.ApplyMessage(vmenv, msg, gp, l1DataFee)
res = append(res, result.Return()...)
}
Expand All @@ -159,7 +159,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, config *params.Chai
vmenv := vm.NewEVM(context, txContext, state, config, vm.Config{NoBaseFee: true})
gp := new(core.GasPool).AddGas(math.MaxUint64)
signer := types.MakeSigner(config, header.Number)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config.ChainID, signer, state)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config, signer, state, header.Number)
result, _ := core.ApplyMessage(vmenv, msg, gp, l1DataFee)
if state.Error() == nil {
res = append(res, result.Return()...)
Expand Down
2 changes: 1 addition & 1 deletion les/state_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (leth *LightEthereum) stateAtTransaction(ctx context.Context, block *types.
}
// Not yet the searched for transaction, execute on top of the current state
vmenv := vm.NewEVM(context, txContext, statedb, leth.blockchain.Config(), vm.Config{})
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb)
l1DataFee, err := fees.CalculateL1DataFee(tx, statedb, leth.blockchain.Config(), block.Number())
if err != nil {
return nil, vm.BlockContext{}, nil, fmt.Errorf("transaction %#x failed: %v", tx.Hash(), err)
}
Expand Down
2 changes: 1 addition & 1 deletion light/odr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func odrContractCall(ctx context.Context, db ethdb.Database, bc *core.BlockChain
vmenv := vm.NewEVM(context, txContext, st, config, vm.Config{NoBaseFee: true})
gp := new(core.GasPool).AddGas(math.MaxUint64)
signer := types.MakeSigner(config, header.Number)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config.ChainID, signer, st)
l1DataFee, _ := fees.EstimateL1DataFeeForMessage(msg, header.BaseFee, config, signer, st, header.Number)
result, _ := core.ApplyMessage(vmenv, msg, gp, l1DataFee)
res = append(res, result.Return()...)
if st.Error() != nil {
Expand Down
Loading