mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-11 13:30:05 +00:00
eip-4844: adding data_gas to gaspool (#7428)
Adding `data_gas` to gas pool. EIP-4844 gas pool includes data_gas which is used to fee blob transactions.
This commit is contained in:
parent
9644e6d220
commit
40947f6c98
accounts/abi/bind/backends
cmd
rpcdaemon/commands
eth_block.goeth_call.goeth_callMany.goeth_receipts.gootterscan_api.gootterscan_generic_tracer.gootterscan_search_trace.gotrace_adhoc.gotrace_filtering.gotracing.go
state/commands
core
eth/tracers
tests
turbo/transactions
@ -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 */)
|
||||
}
|
||||
|
@ -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{}{}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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 */)
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user