diff --git a/accounts/abi/bind/backends/simulated.go b/accounts/abi/bind/backends/simulated.go index 7829045ed..e0af33899 100644 --- a/accounts/abi/bind/backends/simulated.go +++ b/accounts/abi/bind/backends/simulated.go @@ -172,7 +172,7 @@ func (b *SimulatedBackend) emptyPendingBlock() { b.pendingBlock = chain.Blocks[0] b.pendingReceipts = chain.Receipts[0] b.pendingHeader = chain.Headers[0] - b.gasPool = new(core.GasPool).AddGas(b.pendingHeader.GasLimit) + b.gasPool = new(core.GasPool).AddGas(b.pendingHeader.GasLimit).AddDataGas(params.MaxDataGasPerBlock) if b.pendingReaderTx != nil { b.pendingReaderTx.Rollback() } @@ -693,7 +693,7 @@ func (b *SimulatedBackend) callContract(_ context.Context, call ethereum.CallMsg // Create a new environment which holds all relevant information // about the transaction and calling mechanisms. vmEnv := vm.NewEVM(evmContext, txContext, statedb, b.m.ChainConfig, vm.Config{}) - gasPool := new(core.GasPool).AddGas(math.MaxUint64) + gasPool := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64) return core.NewStateTransition(vmEnv, msg, gasPool).TransitionDb(true /* refunds */, false /* gasBailout */) } diff --git a/cmd/rpcdaemon/commands/eth_block.go b/cmd/rpcdaemon/commands/eth_block.go index 8257bbd4a..49b38049b 100644 --- a/cmd/rpcdaemon/commands/eth_block.go +++ b/cmd/rpcdaemon/commands/eth_block.go @@ -150,7 +150,7 @@ func (api *APIImpl) CallBundle(ctx context.Context, txHashes []common.Hash, stat // Setup the gas pool (also for unmetered requests) // and apply the message. - gp := new(core.GasPool).AddGas(math.MaxUint64) + gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64) results := []map[string]interface{}{} diff --git a/cmd/rpcdaemon/commands/eth_call.go b/cmd/rpcdaemon/commands/eth_call.go index 7769abc51..333805b53 100644 --- a/cmd/rpcdaemon/commands/eth_call.go +++ b/cmd/rpcdaemon/commands/eth_call.go @@ -543,7 +543,7 @@ func (api *APIImpl) CreateAccessList(ctx context.Context, args ethapi2.CallArgs, txCtx := core.NewEVMTxContext(msg) evm := vm.NewEVM(blockCtx, txCtx, state, chainConfig, config) - gp := new(core.GasPool).AddGas(msg.Gas()) + gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()) res, err := core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */) if err != nil { return nil, err diff --git a/cmd/rpcdaemon/commands/eth_callMany.go b/cmd/rpcdaemon/commands/eth_callMany.go index 5d18b2c44..b605a0bd3 100644 --- a/cmd/rpcdaemon/commands/eth_callMany.go +++ b/cmd/rpcdaemon/commands/eth_callMany.go @@ -205,7 +205,7 @@ func (api *APIImpl) CallMany(ctx context.Context, bundles []Bundle, simulateCont // Setup the gas pool (also for unmetered requests) // and apply the message. - gp := new(core.GasPool).AddGas(math.MaxUint64) + gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64) for idx, txn := range replayTransactions { st.SetTxContext(txn.Hash(), block.Hash(), idx) msg, err := txn.AsMessage(*signer, block.BaseFee(), rules) diff --git a/cmd/rpcdaemon/commands/eth_receipts.go b/cmd/rpcdaemon/commands/eth_receipts.go index 85d2bd2d4..e1efb51b8 100644 --- a/cmd/rpcdaemon/commands/eth_receipts.go +++ b/cmd/rpcdaemon/commands/eth_receipts.go @@ -31,6 +31,7 @@ import ( "github.com/ledgerwatch/erigon/core/vm/evmtypes" "github.com/ledgerwatch/erigon/eth/filters" "github.com/ledgerwatch/erigon/ethdb/cbor" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rpc" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/erigon/turbo/services" @@ -49,7 +50,7 @@ func (api *BaseAPI) getReceipts(ctx context.Context, tx kv.Tx, chainConfig *chai } usedGas := new(uint64) - gp := new(core.GasPool).AddGas(block.GasLimit()) + gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) noopWriter := state.NewNoopWriter() @@ -516,7 +517,7 @@ func (e *intraBlockExec) execTx(txNum uint64, txIndex int, txn types.Transaction txHash := txn.Hash() e.ibs.Reset() e.ibs.SetTxContext(txHash, e.blockHash, txIndex) - gp := new(core.GasPool).AddGas(txn.GetGas()) + gp := new(core.GasPool).AddGas(txn.GetGas()).AddDataGas(txn.GetDataGas()) msg, err := txn.AsMessage(*e.signer, e.header.BaseFee, e.rules) if err != nil { return nil, nil, err diff --git a/cmd/rpcdaemon/commands/otterscan_api.go b/cmd/rpcdaemon/commands/otterscan_api.go index c0d82fa2c..b04e7e1a6 100644 --- a/cmd/rpcdaemon/commands/otterscan_api.go +++ b/cmd/rpcdaemon/commands/otterscan_api.go @@ -142,7 +142,7 @@ func (api *OtterscanAPIImpl) runTracer(ctx context.Context, tx kv.Tx, hash commo } vmenv := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig) - result, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()), true, false /* gasBailout */) + result, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()), true, false /* gasBailout */) if err != nil { return nil, fmt.Errorf("tracing failed: %v", err) } diff --git a/cmd/rpcdaemon/commands/otterscan_generic_tracer.go b/cmd/rpcdaemon/commands/otterscan_generic_tracer.go index c12acd10d..3996699bc 100644 --- a/cmd/rpcdaemon/commands/otterscan_generic_tracer.go +++ b/cmd/rpcdaemon/commands/otterscan_generic_tracer.go @@ -93,7 +93,7 @@ func (api *OtterscanAPIImpl) genericTracer(dbtx kv.Tx, ctx context.Context, bloc TxContext := core.NewEVMTxContext(msg) vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer}) - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()), true /* refunds */, false /* gasBailout */); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */); err != nil { return err } _ = ibs.FinalizeTx(rules, cachedWriter) diff --git a/cmd/rpcdaemon/commands/otterscan_search_trace.go b/cmd/rpcdaemon/commands/otterscan_search_trace.go index 921d69347..f78920a81 100644 --- a/cmd/rpcdaemon/commands/otterscan_search_trace.go +++ b/cmd/rpcdaemon/commands/otterscan_search_trace.go @@ -90,7 +90,7 @@ func (api *OtterscanAPIImpl) traceBlock(dbtx kv.Tx, ctx context.Context, blockNu TxContext := core.NewEVMTxContext(msg) vmenv := vm.NewEVM(BlockContext, TxContext, ibs, chainConfig, vm.Config{Debug: true, Tracer: tracer}) - if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()), true /* refunds */, false /* gasBailout */); err != nil { + if _, err := core.ApplyMessage(vmenv, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */); err != nil { return false, nil, err } _ = ibs.FinalizeTx(rules, cachedWriter) diff --git a/cmd/rpcdaemon/commands/trace_adhoc.go b/cmd/rpcdaemon/commands/trace_adhoc.go index cd63c916d..5244279ed 100644 --- a/cmd/rpcdaemon/commands/trace_adhoc.go +++ b/cmd/rpcdaemon/commands/trace_adhoc.go @@ -971,7 +971,7 @@ func (api *TraceAPIImpl) Call(ctx context.Context, args TraceCallParam, traceTyp evm.Cancel() }() - gp := new(core.GasPool).AddGas(msg.Gas()) + gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()) var execResult *core.ExecutionResult ibs.SetTxContext(libcommon.Hash{}, libcommon.Hash{}, 0) execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, true /* gasBailout */) @@ -1187,7 +1187,7 @@ func (api *TraceAPIImpl) doCallMany(ctx context.Context, dbtx kv.Tx, msgs []type evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig) - gp := new(core.GasPool).AddGas(msg.Gas()) + gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()) var execResult *core.ExecutionResult // Clone the state cache before applying the changes, clone is discarded var cloneReader state.StateReader diff --git a/cmd/rpcdaemon/commands/trace_filtering.go b/cmd/rpcdaemon/commands/trace_filtering.go index ad8c33e94..31bb5336e 100644 --- a/cmd/rpcdaemon/commands/trace_filtering.go +++ b/cmd/rpcdaemon/commands/trace_filtering.go @@ -835,7 +835,7 @@ func (api *TraceAPIImpl) filterV3(ctx context.Context, dbtx kv.TemporalTx, fromB txCtx := core.NewEVMTxContext(msg) evm := vm.NewEVM(blockCtx, txCtx, ibs, chainConfig, vmConfig) - gp := new(core.GasPool).AddGas(msg.Gas()) + gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()) ibs.SetTxContext(txHash, lastBlockHash, txIndex) var execResult *core.ExecutionResult execResult, err = core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */) diff --git a/cmd/rpcdaemon/commands/tracing.go b/cmd/rpcdaemon/commands/tracing.go index 23d954390..1e39959cb 100644 --- a/cmd/rpcdaemon/commands/tracing.go +++ b/cmd/rpcdaemon/commands/tracing.go @@ -449,7 +449,7 @@ func (api *PrivateDebugAPIImpl) TraceCallMany(ctx context.Context, bundles []Bun // Setup the gas pool (also for unmetered requests) // and apply the message. - gp := new(core.GasPool).AddGas(math.MaxUint64) + gp := new(core.GasPool).AddGas(math.MaxUint64).AddDataGas(math.MaxUint64) for idx, txn := range replayTransactions { st.SetTxContext(txn.Hash(), block.Hash(), idx) msg, err := txn.AsMessage(*signer, block.BaseFee(), rules) diff --git a/cmd/state/commands/history22.go b/cmd/state/commands/history22.go index 94d260f1d..b965434a3 100644 --- a/cmd/state/commands/history22.go +++ b/cmd/state/commands/history22.go @@ -30,6 +30,7 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/eth/ethconfig" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/services" "github.com/ledgerwatch/erigon/turbo/snapshotsync" ) @@ -235,7 +236,7 @@ func runHistory22(trace bool, blockNum, txNumStart uint64, hw *state.HistoryRead excessDataGas := header.ParentExcessDataGas(getHeader) vmConfig.TraceJumpDest = true engine := ethash.NewFullFaker() - gp := new(core.GasPool).AddGas(block.GasLimit()) + gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) usedGas := new(uint64) var receipts types.Receipts rules := chainConfig.Rules(block.NumberU64(), block.Time()) diff --git a/cmd/state/commands/opcode_tracer.go b/cmd/state/commands/opcode_tracer.go index e0c1a045a..aca55ec99 100644 --- a/cmd/state/commands/opcode_tracer.go +++ b/cmd/state/commands/opcode_tracer.go @@ -18,6 +18,7 @@ import ( "github.com/ledgerwatch/erigon-lib/kv" "github.com/ledgerwatch/erigon-lib/kv/kvcfg" "github.com/ledgerwatch/erigon-lib/kv/mdbx" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/turbo/rpchelper" "github.com/ledgerwatch/log/v3" "github.com/spf13/cobra" @@ -705,7 +706,7 @@ func runBlock(engine consensus.Engine, ibs *state.IntraBlockState, txnWriter sta header := block.Header() excessDataGas := header.ParentExcessDataGas(getHeader) vmConfig.TraceJumpDest = true - gp := new(core.GasPool).AddGas(block.GasLimit()) + gp := new(core.GasPool).AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) usedGas := new(uint64) var receipts types.Receipts if chainConfig.DAOForkBlock != nil && chainConfig.DAOForkBlock.Cmp(block.Number()) == 0 { diff --git a/core/blockchain.go b/core/blockchain.go index 7a7687b5b..1a904a9cd 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -37,6 +37,7 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/core/vm/evmtypes" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" ) @@ -87,7 +88,7 @@ func ExecuteBlockEphemerally( usedGas := new(uint64) gp := new(GasPool) - gp.AddGas(block.GasLimit()) + gp.AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) var ( rejectedTxs []*RejectedTx @@ -201,7 +202,7 @@ func ExecuteBlockEphemerallyBor( usedGas := new(uint64) gp := new(GasPool) - gp.AddGas(block.GasLimit()) + gp.AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) var ( rejectedTxs []*RejectedTx diff --git a/core/types/legacy_tx.go b/core/types/legacy_tx.go index 54f13b066..b9c1a2437 100644 --- a/core/types/legacy_tx.go +++ b/core/types/legacy_tx.go @@ -57,6 +57,10 @@ func (ct CommonTx) GetTo() *libcommon.Address { return ct.To } +func (ct CommonTx) GetDataGas() uint64 { + return 0 +} + func (ct CommonTx) GetGas() uint64 { return ct.Gas } diff --git a/core/types/transaction.go b/core/types/transaction.go index 1a45a0007..01f752263 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -67,6 +67,7 @@ type Transaction interface { Cost() *uint256.Int GetDataHashes() []libcommon.Hash GetGas() uint64 + GetDataGas() uint64 GetValue() *uint256.Int Time() time.Time GetTo() *libcommon.Address diff --git a/eth/tracers/internal/tracetest/calltrace_test.go b/eth/tracers/internal/tracetest/calltrace_test.go index 9c3c5ab00..50dfa0157 100644 --- a/eth/tracers/internal/tracetest/calltrace_test.go +++ b/eth/tracers/internal/tracetest/calltrace_test.go @@ -168,7 +168,7 @@ func testCallTracer(tracerName string, dirPath string, t *testing.T) { if err != nil { t.Fatalf("failed to prepare transaction for tracing: %v", err) } - vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.GetGas()), true /* refunds */, false /* gasBailout */) + vmRet, err := core.ApplyMessage(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas()), true /* refunds */, false /* gasBailout */) if err != nil { t.Fatalf("failed to execute transaction: %v", err) } @@ -273,7 +273,7 @@ func benchTracer(b *testing.B, tracerName string, test *callTracerTest) { } evm := vm.NewEVM(context, txContext, statedb, test.Genesis.Config, vm.Config{Debug: true, Tracer: tracer}) snap := statedb.Snapshot() - st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas())) + st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas())) if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil { b.Fatalf("failed to execute transaction: %v", err) } @@ -350,7 +350,7 @@ func TestZeroValueToNotExitCall(t *testing.T) { if err != nil { t.Fatalf("failed to prepare transaction for tracing: %v", err) } - st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas())) + st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas())) if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil { t.Fatalf("failed to execute transaction: %v", err) } diff --git a/eth/tracers/internal/tracetest/prestate_test.go b/eth/tracers/internal/tracetest/prestate_test.go index a56840fba..7eba7a124 100644 --- a/eth/tracers/internal/tracetest/prestate_test.go +++ b/eth/tracers/internal/tracetest/prestate_test.go @@ -131,7 +131,7 @@ func testPrestateDiffTracer(tracerName string, dirPath string, t *testing.T) { if err != nil { t.Fatalf("failed to prepare transaction for tracing: %v", err) } - st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas())) + st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(tx.GetGas()).AddDataGas(tx.GetDataGas())) if _, err = st.TransitionDb(true /* refunds */, false /* gasBailout */); err != nil { t.Fatalf("failed to execute transaction: %v", err) } diff --git a/eth/tracers/tracers_test.go b/eth/tracers/tracers_test.go index 3ec95a915..eb8fa167e 100644 --- a/eth/tracers/tracers_test.go +++ b/eth/tracers/tracers_test.go @@ -113,7 +113,7 @@ func TestPrestateTracerCreate2(t *testing.T) { if err != nil { t.Fatalf("failed to prepare transaction for tracing: %v", err) } - st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(txn.GetGas())) + st := core.NewStateTransition(evm, msg, new(core.GasPool).AddGas(txn.GetGas()).AddDataGas(txn.GetDataGas())) if _, err = st.TransitionDb(false, false); err != nil { t.Fatalf("failed to execute transaction: %v", err) } diff --git a/tests/state_test_util.go b/tests/state_test_util.go index c972b4b01..dec99bdcb 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -42,6 +42,7 @@ import ( "github.com/ledgerwatch/erigon/core/types" "github.com/ledgerwatch/erigon/core/vm" "github.com/ledgerwatch/erigon/crypto" + "github.com/ledgerwatch/erigon/params" "github.com/ledgerwatch/erigon/rlp" "github.com/ledgerwatch/erigon/turbo/trie" ) @@ -237,7 +238,7 @@ func (t *StateTest) RunNoVerify(tx kv.RwTx, subtest StateSubtest, vmconfig vm.Co // Execute the message. snapshot := statedb.Snapshot() gaspool := new(core.GasPool) - gaspool.AddGas(block.GasLimit()) + gaspool.AddGas(block.GasLimit()).AddDataGas(params.MaxDataGasPerBlock) if _, err = core.ApplyMessage(evm, msg, gaspool, true /* refunds */, false /* gasBailout */); err != nil { statedb.RevertToSnapshot(snapshot) } diff --git a/turbo/transactions/call.go b/turbo/transactions/call.go index f2399e8c5..b45414e88 100644 --- a/turbo/transactions/call.go +++ b/turbo/transactions/call.go @@ -94,7 +94,7 @@ func DoCall( evm.Cancel() }() - gp := new(core.GasPool).AddGas(msg.Gas()) + gp := new(core.GasPool).AddGas(msg.Gas()).AddDataGas(msg.DataGas()) result, err := core.ApplyMessage(evm, msg, gp, true /* refunds */, false /* gasBailout */) if err != nil { return nil, err @@ -172,7 +172,7 @@ func (r *ReusableCaller) DoCallWithNewGas( timedOut = true }() - gp := new(core.GasPool).AddGas(r.message.Gas()) + gp := new(core.GasPool).AddGas(r.message.Gas()).AddDataGas(r.message.DataGas()) result, err := core.ApplyMessage(r.evm, r.message, gp, true /* refunds */, false /* gasBailout */) if err != nil {