diff --git a/cmd/evm/internal/t8ntool/transaction.go b/cmd/evm/internal/t8ntool/transaction.go index 4a347f9344..91b19f575f 100644 --- a/cmd/evm/internal/t8ntool/transaction.go +++ b/cmd/evm/internal/t8ntool/transaction.go @@ -141,7 +141,7 @@ func Transaction(ctx *cli.Context) error { // Check intrinsic gas // TODO(pl): Adapt fee currency if gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, - chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0), nil, 0); err != nil { + chainConfig.IsHomestead(new(big.Int)), chainConfig.IsIstanbul(new(big.Int)), chainConfig.IsShanghai(new(big.Int), 0), nil); err != nil { r.Error = err results = append(results, r) continue diff --git a/core/bench_test.go b/core/bench_test.go index f6c70388b5..5fc65f5cd0 100644 --- a/core/bench_test.go +++ b/core/bench_test.go @@ -83,7 +83,7 @@ func genValueTx(nbytes int) func(int, *BlockGen) { return func(i int, gen *BlockGen) { toaddr := common.Address{} data := make([]byte, nbytes) - gas, _ := IntrinsicGas(data, nil, false, false, false, false, nil, 0) + gas, _ := IntrinsicGas(data, nil, false, false, false, false, nil) signer := types.MakeSigner(gen.config, big.NewInt(int64(i)), gen.header.Time) gasPrice := big.NewInt(0) if gen.header.BaseFee != nil { diff --git a/core/state_transition.go b/core/state_transition.go index 50eccd19e2..f9c5c9ee37 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -68,7 +68,7 @@ func (result *ExecutionResult) Revert() []byte { } // IntrinsicGas computes the 'intrinsic gas' for a message with the given data. -func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool, isEIP3860 bool, feeCurrency *common.Address, gasForAlternativeCurrency uint64) (uint64, error) { +func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation bool, isHomestead, isEIP2028 bool, isEIP3860 bool, feeCurrency *common.Address) (uint64, error) { // Set the starting gas for the raw transaction var gas uint64 if isContractCreation && isHomestead { @@ -126,10 +126,10 @@ func IntrinsicGas(data []byte, accessList types.AccessList, isContractCreation b // In this case, however, the user always ends up paying `maxGasForDebitAndCreditTransactions` // keeping it consistent. if feeCurrency != nil { - if (math.MaxUint64 - gas) < gasForAlternativeCurrency { + if (math.MaxUint64 - gas) < fee_currencies.IntrinsicGasForAlternativeFeeCurrency { return 0, ErrGasUintOverflow } - gas += gasForAlternativeCurrency + gas += fee_currencies.IntrinsicGasForAlternativeFeeCurrency } if accessList != nil { @@ -545,13 +545,8 @@ func (st *StateTransition) innerTransitionDb() (*ExecutionResult, error) { contractCreation = msg.To == nil ) - // If the fee currency is nil, do not retrieve the intrinsic gas adjustment from the chain state, as it will not be used. - gasForAlternativeCurrency := uint64(0) - if msg.FeeCurrency != nil { - gasForAlternativeCurrency = fee_currencies.IntrinsicGasForAlternativeFeeCurrency - } // Check clauses 4-5, subtract intrinsic gas if everything is correct - gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai, msg.FeeCurrency, gasForAlternativeCurrency) + gas, err := IntrinsicGas(msg.Data, msg.AccessList, contractCreation, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai, msg.FeeCurrency) if err != nil { return nil, err } diff --git a/core/txpool/validation.go b/core/txpool/validation.go index c88f3fd166..33cc1df78b 100644 --- a/core/txpool/validation.go +++ b/core/txpool/validation.go @@ -119,9 +119,7 @@ func ValidateTransaction(tx *types.Transaction, head *types.Header, signer types } // Ensure the transaction has more gas than the bare minimum needed to cover // the transaction metadata - gasForAlternativeCurrency := uint64(0) - // TODO(pl): Adapt gas for fee currency - intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time), tx.FeeCurrency(), gasForAlternativeCurrency) + intrGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, opts.Config.IsIstanbul(head.Number), opts.Config.IsShanghai(head.Number, head.Time), tx.FeeCurrency()) if err != nil { return err } diff --git a/light/txpool.go b/light/txpool.go index 7ab06bfb5e..936f361a70 100644 --- a/light/txpool.go +++ b/light/txpool.go @@ -385,10 +385,8 @@ func (pool *TxPool) validateTx(ctx context.Context, tx *types.Transaction) error return core.ErrInsufficientFunds } - // TODO(pl): Add correct intrinsic gas // Should supply enough intrinsic gas - gasForAlternativeCurrency := uint64(0) - gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.shanghai, tx.FeeCurrency(), gasForAlternativeCurrency) + gas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, true, pool.istanbul, pool.shanghai, tx.FeeCurrency()) if err != nil { return err } diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index f927f3ad3e..8f8c07ea53 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -55,7 +55,7 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error { return nil, nil, err } // Intrinsic gas - requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, false, nil, 0) + requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.To() == nil, isHomestead, isIstanbul, false, nil) if err != nil { return nil, nil, err }