From 95441f2a873d0fb0298f947b464fe77eb9563781 Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Mon, 2 Sep 2024 18:06:50 +0300 Subject: [PATCH 1/6] AA-408 deduct gas, pay coinbase --- core/rip7560_abi.go | 2 +- core/state_processor_rip7560.go | 148 +++++++++++++++++++++----------- core/types/tx_rip7560.go | 4 + 3 files changed, 102 insertions(+), 52 deletions(-) diff --git a/core/rip7560_abi.go b/core/rip7560_abi.go index a756b9204c59..eedcfbdf3262 100644 --- a/core/rip7560_abi.go +++ b/core/rip7560_abi.go @@ -10,7 +10,7 @@ import ( "strings" ) -var Rip7560Abi, err = abi.JSON(strings.NewReader(Rip7560AbiJson)) +var Rip7560Abi, _ = abi.JSON(strings.NewReader(Rip7560AbiJson)) type AcceptAccountData struct { ValidAfter *big.Int diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 96ff30296eb4..155edb7875a3 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -7,6 +7,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" + cmath "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" @@ -24,21 +25,23 @@ type EntryPointCall struct { } type ValidationPhaseResult struct { - TxIndex int - Tx *types.Transaction - TxHash common.Hash - PaymasterContext []byte - PreCharge *uint256.Int - EffectiveGasPrice *uint256.Int - CallDataUsedGas uint64 - NonceManagerUsedGas uint64 - DeploymentUsedGas uint64 - ValidationUsedGas uint64 - PmValidationUsedGas uint64 - SenderValidAfter uint64 - SenderValidUntil uint64 - PmValidAfter uint64 - PmValidUntil uint64 + TxIndex int + Tx *types.Transaction + TxHash common.Hash + PaymasterContext []byte + PreCharge *uint256.Int + EffectiveGasPrice *uint256.Int + TotalValidationGasUsed uint64 + ValidationRefund uint64 + CallDataUsedGas uint64 + NonceManagerUsedGas uint64 + DeploymentUsedGas uint64 + ValidationUsedGas uint64 + PmValidationUsedGas uint64 + SenderValidAfter uint64 + SenderValidUntil uint64 + PmValidAfter uint64 + PmValidUntil uint64 } // ValidationPhaseError is an API error that encompasses an EVM revert with JSON error @@ -119,9 +122,9 @@ func handleRip7560Transactions(transactions []*types.Transaction, index int, sta statedb.SetTxContext(tx.Hash(), index+i) - vpr, vpe := ApplyRip7560ValidationPhases(chainConfig, bc, coinbase, gp, statedb, header, tx, cfg) - if vpe != nil { - return nil, nil, nil, vpe + vpr, err := ApplyRip7560ValidationPhases(chainConfig, bc, coinbase, gp, statedb, header, tx, cfg) + if err != nil { + return nil, nil, nil, err } validationPhaseResults = append(validationPhaseResults, vpr) validatedTransactions = append(validatedTransactions, tx) @@ -155,11 +158,10 @@ func BuyGasRip7560Transaction(st *types.Rip7560AccountAbstractionTx, state vm.St //TODO: check gasLimit against block gasPool preCharge := new(uint256.Int).SetUint64(gasLimit) preCharge = preCharge.Mul(preCharge, gasPrice) - balanceCheck := new(uint256.Int).Set(preCharge) chargeFrom := st.GasPayer() - if have, want := state.GetBalance(*chargeFrom), balanceCheck; have.Cmp(want) < 0 { + if have, want := state.GetBalance(*chargeFrom), preCharge; have.Cmp(want) < 0 { return 0, nil, fmt.Errorf("%w: address %v have %v want %v", ErrInsufficientFunds, chargeFrom.Hex(), have, want) } @@ -234,7 +236,7 @@ func ptr(s string) *string { return &s } func ApplyRip7560ValidationPhases( chainConfig *params.ChainConfig, bc ChainContext, - author *common.Address, + coinbase *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, @@ -243,21 +245,17 @@ func ApplyRip7560ValidationPhases( ) (*ValidationPhaseResult, error) { aatx := tx.Rip7560TransactionData() - gasPrice := new(big.Int).Add(header.BaseFee, tx.GasTipCap()) - if gasPrice.Cmp(tx.GasFeeCap()) > 0 { - gasPrice = tx.GasFeeCap() - } - gasPriceUint256, _ := uint256.FromBig(gasPrice) - - gasLimit, preCharge, err := BuyGasRip7560Transaction(aatx, statedb, gasPriceUint256) + gasPrice := aatx.EffectiveGasPrice(header.BaseFee) + effectiveGasPrice := uint256.MustFromBig(gasPrice) + gasLimit, preCharge, err := BuyGasRip7560Transaction(aatx, statedb, effectiveGasPrice) if err != nil { return nil, newValidationPhaseError(err, nil, nil) } - blockContext := NewEVMBlockContext(header, bc, author) - sender := tx.Rip7560TransactionData().Sender + blockContext := NewEVMBlockContext(header, bc, coinbase) + sender := aatx.Sender txContext := vm.TxContext{ - Origin: *sender, + Origin: *aatx.Sender, GasPrice: gasPrice, } evm := vm.NewEVM(blockContext, txContext, statedb, chainConfig, cfg) @@ -359,24 +357,34 @@ func ApplyRip7560ValidationPhases( } callDataUsedGas, err := aatx.CallDataGasCost() + //this is the value to refund, but we refund at the end, after execution. + // we COULD refund here (and thus restore unused gas to the gaspool),and that would allow more TXs to be included in a block, + // but that would require a more complex refund mechanism: splitting evm refund from excessive prefund refund. + gasRefund := st.state.GetRefund() + + validationGasUsed := st.gasUsed() + callDataUsedGas if err != nil { return nil, err } vpr := &ValidationPhaseResult{ - Tx: tx, - TxHash: tx.Hash(), - PreCharge: preCharge, - EffectiveGasPrice: gasPriceUint256, - PaymasterContext: paymasterContext, + Tx: tx, + TxHash: tx.Hash(), + PreCharge: preCharge, + EffectiveGasPrice: effectiveGasPrice, + PaymasterContext: paymasterContext, + ValidationRefund: gasRefund, + TotalValidationGasUsed: validationGasUsed, + CallDataUsedGas: callDataUsedGas, DeploymentUsedGas: deploymentUsedGas, NonceManagerUsedGas: nonceManagerUsedGas, ValidationUsedGas: resultAccountValidation.UsedGas, PmValidationUsedGas: pmValidationUsedGas, - SenderValidAfter: aad.ValidAfter.Uint64(), - SenderValidUntil: aad.ValidUntil.Uint64(), - PmValidAfter: pmValidAfter, - PmValidUntil: pmValidUntil, + + SenderValidAfter: aad.ValidAfter.Uint64(), + SenderValidUntil: aad.ValidUntil.Uint64(), + PmValidAfter: pmValidAfter, + PmValidUntil: pmValidUntil, } statedb.Finalise(true) @@ -422,9 +430,17 @@ func applyPaymasterPostOpFrame(st *StateTransition, aatx *types.Rip7560AccountAb return paymasterPostOpResult } -func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhaseResult, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, cfg vm.Config) (*types.Receipt, error) { +func capRefund(getRefund uint64, gasUsed uint64) uint64 { + refund := gasUsed / params.RefundQuotientEIP3529 + if refund > getRefund { + return getRefund + } + return refund +} + +func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhaseResult, bc ChainContext, coinbase *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, cfg vm.Config) (*types.Receipt, error) { - blockContext := NewEVMBlockContext(header, bc, author) + blockContext := NewEVMBlockContext(header, bc, coinbase) aatx := vpr.Tx.Rip7560TransactionData() sender := aatx.Sender txContext := vm.TxContext{ @@ -440,39 +456,41 @@ func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhase accountExecutionMsg := prepareAccountExecutionMessage(vpr.Tx) beforeExecSnapshotId := statedb.Snapshot() executionResult := CallFrame(st, &AA_ENTRY_POINT, sender, accountExecutionMsg, aatx.Gas) + execRefund := capRefund(st.state.GetRefund(), executionResult.UsedGas) executionStatus := types.ReceiptStatusSuccessful if executionResult.Failed() { executionStatus = types.ReceiptStatusFailed } executionGasPenalty := (aatx.Gas - executionResult.UsedGas) * AA_GAS_PENALTY_PCT / 100 - gasUsed := vpr.ValidationUsedGas + - vpr.NonceManagerUsedGas + - vpr.DeploymentUsedGas + - vpr.PmValidationUsedGas + - vpr.CallDataUsedGas + + gasUsed := vpr.TotalValidationGasUsed + executionResult.UsedGas + executionGasPenalty + gasRefund := capRefund(execRefund+vpr.ValidationRefund, gasUsed) + var postOpGasUsed uint64 if len(vpr.PaymasterContext) != 0 { - paymasterPostOpResult := applyPaymasterPostOpFrame(st, aatx, vpr, !executionResult.Failed(), gasUsed) + paymasterPostOpResult := applyPaymasterPostOpFrame(st, aatx, vpr, !executionResult.Failed(), gasUsed-gasRefund) postOpGasUsed = paymasterPostOpResult.UsedGas + gasRefund += capRefund(paymasterPostOpResult.RefundedGas, postOpGasUsed) // PostOp failed, reverting execution changes if paymasterPostOpResult.Err != nil { statedb.RevertToSnapshot(beforeExecSnapshotId) executionStatus = types.ReceiptStatusFailed } postOpGasPenalty := (aatx.PostOpGas - postOpGasUsed) * AA_GAS_PENALTY_PCT / 100 - gasUsed += postOpGasUsed + postOpGasPenalty + postOpGasUsed += postOpGasPenalty + gasUsed += postOpGasUsed } + gasUsed -= gasRefund + refundPayer(vpr, statedb, gasUsed) + payCoinbase(st, aatx, gasUsed) receipt := &types.Receipt{Type: vpr.Tx.Type(), TxHash: vpr.Tx.Hash(), GasUsed: gasUsed, CumulativeGasUsed: gasUsed} receipt.Status = executionStatus - refundPayer(vpr, statedb, gasUsed) - // Set the receipt logs and create the bloom filter. blockNumber := header.Number receipt.Logs = statedb.GetLogs(vpr.TxHash, blockNumber.Uint64(), common.Hash{}) @@ -482,6 +500,34 @@ func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhase return receipt, nil } +// extracted from TransitionDb() +func payCoinbase(st *StateTransition, msg *types.Rip7560AccountAbstractionTx, gasUsed uint64) { + rules := st.evm.ChainConfig().Rules(st.evm.Context.BlockNumber, st.evm.Context.Random != nil, st.evm.Context.Time) + + effectiveTip := msg.GasTipCap + if rules.IsLondon { + effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) + } + + effectiveTipU256, _ := uint256.FromBig(effectiveTip) + + fmt.Printf("=== paying coinbase %v gasUsed %v effectiveTip %v\n", st.evm.Context.Coinbase.Hex(), gasUsed, effectiveTipU256) + + if st.evm.Config.NoBaseFee && msg.GasFeeCap.Sign() == 0 && msg.GasTipCap.Sign() == 0 { + // Skip fee payment when NoBaseFee is set and the fee fields + // are 0. This avoids a negative effectiveTip being applied to + // the coinbase when simulating calls. + } else { + fee := new(uint256.Int).SetUint64(gasUsed) + fee.Mul(fee, effectiveTipU256) + st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee) + // add the coinbase to the witness iff the fee is greater than 0 + if rules.IsEIP4762 && fee.Sign() != 0 { + st.evm.AccessEvents.BalanceGas(st.evm.Context.Coinbase, true) + } + } +} + func prepareAccountValidationMessage(tx *types.Rip7560AccountAbstractionTx, signingHash common.Hash) ([]byte, error) { return abiEncodeValidateTransaction(tx, signingHash) } diff --git a/core/types/tx_rip7560.go b/core/types/tx_rip7560.go index 7887292a017c..b563e606a1fe 100644 --- a/core/types/tx_rip7560.go +++ b/core/types/tx_rip7560.go @@ -160,6 +160,10 @@ func (tx *Rip7560AccountAbstractionTx) IsRip7712Nonce() bool { return tx.NonceKey != nil && tx.NonceKey.Cmp(big.NewInt(0)) == 1 } +func (tx *Rip7560AccountAbstractionTx) EffectiveGasPrice(baseFee *big.Int) *big.Int { + return tx.effectiveGasPrice(new(big.Int), baseFee) +} + func (tx *Rip7560AccountAbstractionTx) effectiveGasPrice(dst *big.Int, baseFee *big.Int) *big.Int { if baseFee == nil { return dst.Set(tx.GasFeeCap) From 35d1f4da0cf66bbb01530ed77898834456d8e274 Mon Sep 17 00:00:00 2001 From: Alex Forshtat Date: Sat, 14 Sep 2024 22:01:46 +0200 Subject: [PATCH 2/6] Fix 'CumulativeGasUsed' not being calculated correctly --- core/state_processor.go | 2 +- core/state_processor_rip7560.go | 26 ++++++++++++++++++++++---- miner/worker.go | 2 +- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/core/state_processor.go b/core/state_processor.go index 6be7f5009707..cb3e27f39624 100644 --- a/core/state_processor.go +++ b/core/state_processor.go @@ -85,7 +85,7 @@ func (p *StateProcessor) Process(block *types.Block, statedb *state.StateDB, cfg if tx.Type() == types.Rip7560Type { // HandleRip7560Transactions accepts a transaction array and in the future bundle handling will need this tmpTxs := [1]*types.Transaction{tx} - _, validatedTxsReceipts, _, validateTxsLogs, err := HandleRip7560Transactions(tmpTxs[:], 0, statedb, &context.Coinbase, header, gp, p.config, p.bc, cfg, false) + _, validatedTxsReceipts, _, validateTxsLogs, err := HandleRip7560Transactions(tmpTxs[:], 0, statedb, &context.Coinbase, header, gp, p.config, p.bc, cfg, false, usedGas) receipts = append(receipts, validatedTxsReceipts...) allLogs = append(allLogs, validateTxsLogs...) if err != nil { diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 59ed3504958c..40e21850bdb2 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -114,13 +114,14 @@ func HandleRip7560Transactions( bc ChainContext, cfg vm.Config, skipInvalid bool, + usedGas *uint64, ) ([]*types.Transaction, types.Receipts, []*types.Rip7560TransactionDebugInfo, []*types.Log, error) { validatedTransactions := make([]*types.Transaction, 0) receipts := make([]*types.Receipt, 0) allLogs := make([]*types.Log, 0) iTransactions, iReceipts, validationFailureReceipts, iLogs, err := handleRip7560Transactions( - transactions, index, statedb, coinbase, header, gp, chainConfig, bc, cfg, skipInvalid, + transactions, index, statedb, coinbase, header, gp, chainConfig, bc, cfg, skipInvalid, usedGas, ) if err != nil { return nil, nil, nil, nil, err @@ -142,6 +143,7 @@ func handleRip7560Transactions( bc ChainContext, cfg vm.Config, skipInvalid bool, + usedGas *uint64, ) ([]*types.Transaction, types.Receipts, []*types.Rip7560TransactionDebugInfo, []*types.Log, error) { validationPhaseResults := make([]*ValidationPhaseResult, 0) validatedTransactions := make([]*types.Transaction, 0) @@ -187,7 +189,7 @@ func handleRip7560Transactions( // TODO: this will miss all validation phase events - pass in 'vpr' // statedb.SetTxContext(vpr.Tx.Hash(), i) - receipt, err := ApplyRip7560ExecutionPhase(chainConfig, vpr, bc, coinbase, gp, statedb, header, cfg) + receipt, err := ApplyRip7560ExecutionPhase(chainConfig, vpr, bc, coinbase, gp, statedb, header, cfg, usedGas) if err != nil { return nil, nil, nil, nil, err @@ -480,7 +482,17 @@ func applyPaymasterPostOpFrame(st *StateTransition, aatx *types.Rip7560AccountAb return paymasterPostOpResult } -func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhaseResult, bc ChainContext, author *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, cfg vm.Config) (*types.Receipt, error) { +func ApplyRip7560ExecutionPhase( + config *params.ChainConfig, + vpr *ValidationPhaseResult, + bc ChainContext, + author *common.Address, + gp *GasPool, + statedb *state.StateDB, + header *types.Header, + cfg vm.Config, + usedGas *uint64, +) (*types.Receipt, error) { blockContext := NewEVMBlockContext(header, bc, author) aatx := vpr.Tx.Rip7560TransactionData() @@ -555,7 +567,13 @@ func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhase } } - receipt := &types.Receipt{Type: vpr.Tx.Type(), TxHash: vpr.Tx.Hash(), GasUsed: gasUsed, CumulativeGasUsed: gasUsed} + // TODO: naming convention hell!!! 'usedGas' is 'CumulativeGasUsed' in block processing + *usedGas += gasUsed + + receipt := &types.Receipt{Type: vpr.Tx.Type(), TxHash: vpr.Tx.Hash(), GasUsed: gasUsed, CumulativeGasUsed: *usedGas} + + println("ApplyRip7560ExecutionPhase GasUsed", receipt.GasUsed) + println("ApplyRip7560ExecutionPhase CumulativeGasUsed", receipt.CumulativeGasUsed) receipt.Status = receiptStatus diff --git a/miner/worker.go b/miner/worker.go index e299d5ef3741..caf415efccd4 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -381,7 +381,7 @@ func (miner *Miner) commitRip7560TransactionsBundle(env *environment, txs *types env.gasPool = new(core.GasPool).AddGas(gasLimit) } - validatedTxs, receipts, validationFailureInfos, _, err := core.HandleRip7560Transactions(txs.Transactions, 0, env.state, &env.coinbase, env.header, env.gasPool, miner.chainConfig, miner.chain, vm.Config{}, true) + validatedTxs, receipts, validationFailureInfos, _, err := core.HandleRip7560Transactions(txs.Transactions, 0, env.state, &env.coinbase, env.header, env.gasPool, miner.chainConfig, miner.chain, vm.Config{}, true, &env.header.GasUsed) miner.chain.SetRip7560TransactionDebugInfo(validationFailureInfos) if err != nil { return err From 1f217a08a7c8b74ebda19f6f1e5de2b79d1725f2 Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Sun, 15 Sep 2024 17:46:57 +0300 Subject: [PATCH 3/6] call Prepare to initialize warm addresses --- core/state_processor_rip7560.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 40e21850bdb2..436343793de6 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -318,6 +318,10 @@ func ApplyRip7560ValidationPhases( GasPrice: gasPrice, } evm := vm.NewEVM(blockContext, txContext, statedb, chainConfig, cfg) + rules := evm.ChainConfig().Rules(evm.Context.BlockNumber, evm.Context.Random != nil, evm.Context.Time) + + statedb.Prepare(rules, *sender, evm.Context.Coinbase, &AA_ENTRY_POINT, vm.ActivePrecompiles(rules), tx.AccessList()) + epc := &EntryPointCall{} if evm.Config.Tracer == nil { From 57b899ac7a406d778e8a72ebe4b982ff1fc9f7cd Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Sun, 15 Sep 2024 17:52:57 +0300 Subject: [PATCH 4/6] remove prints --- core/state_processor_rip7560.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 436343793de6..730ba6bbedb3 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -576,9 +576,6 @@ func ApplyRip7560ExecutionPhase( receipt := &types.Receipt{Type: vpr.Tx.Type(), TxHash: vpr.Tx.Hash(), GasUsed: gasUsed, CumulativeGasUsed: *usedGas} - println("ApplyRip7560ExecutionPhase GasUsed", receipt.GasUsed) - println("ApplyRip7560ExecutionPhase CumulativeGasUsed", receipt.CumulativeGasUsed) - receipt.Status = receiptStatus refundPayer(vpr, statedb, gasUsed) From a358078b3be0ad56fd77919cb6139712683a1c1c Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Sun, 15 Sep 2024 20:36:03 +0300 Subject: [PATCH 5/6] reformat --- core/state_processor_rip7560.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 933c5161fc88..95ca46e78ab3 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -496,9 +496,18 @@ func capRefund(getRefund uint64, gasUsed uint64) uint64 { return refund } -func ApplyRip7560ExecutionPhase(config *params.ChainConfig, vpr *ValidationPhaseResult, bc ChainContext, coinbase *common.Address, gp *GasPool, statedb *state.StateDB, header *types.Header, cfg vm.Config) (*types.Receipt, error) { +func ApplyRip7560ExecutionPhase( + config *params.ChainConfig, + vpr *ValidationPhaseResult, + bc ChainContext, + author *common.Address, + gp *GasPool, + statedb *state.StateDB, + header *types.Header, + cfg vm.Config, +) (*types.Receipt, error) { - blockContext := NewEVMBlockContext(header, bc, coinbase) + blockContext := NewEVMBlockContext(header, bc, author) aatx := vpr.Tx.Rip7560TransactionData() sender := aatx.Sender txContext := vm.TxContext{ From f3e4a59d485e861f1b2059658b2d0601c428640d Mon Sep 17 00:00:00 2001 From: Dror Tirosh Date: Mon, 16 Sep 2024 17:40:49 +0300 Subject: [PATCH 6/6] PR comments --- core/state_processor_rip7560.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/core/state_processor_rip7560.go b/core/state_processor_rip7560.go index 6091add6c02e..1e1fe01a0d0a 100644 --- a/core/state_processor_rip7560.go +++ b/core/state_processor_rip7560.go @@ -7,7 +7,6 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/math" - cmath "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/tracing" "github.com/ethereum/go-ethereum/core/types" @@ -434,9 +433,6 @@ func ApplyRip7560ValidationPhases( return nil, err } - //this is the value to refund, but we refund at the end, after execution. - // we COULD refund here (and thus restore unused gas to the gaspool),and that would allow more TXs to be included in a block, - // but that would require a more complex refund mechanism: splitting evm refund from excessive prefund refund. gasRefund := st.state.GetRefund() vpr := &ValidationPhaseResult{ @@ -704,13 +700,11 @@ func payCoinbase(st *StateTransition, msg *types.Rip7560AccountAbstractionTx, ga effectiveTip := msg.GasTipCap if rules.IsLondon { - effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) + effectiveTip = math.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) } effectiveTipU256, _ := uint256.FromBig(effectiveTip) - fmt.Printf("=== paying coinbase %v gasUsed %v effectiveTip %v\n", st.evm.Context.Coinbase.Hex(), gasUsed, effectiveTipU256) - if st.evm.Config.NoBaseFee && msg.GasFeeCap.Sign() == 0 && msg.GasTipCap.Sign() == 0 { // Skip fee payment when NoBaseFee is set and the fee fields // are 0. This avoids a negative effectiveTip being applied to