From 4ebd59eba11d693393a3beea399f8878998ea823 Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Fri, 21 Nov 2025 16:18:52 +0800 Subject: [PATCH 1/3] skip refundIsthmusOperatorCost for estimate_gas --- core/state_transition.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/state_transition.go b/core/state_transition.go index 5620d7da5d..80354563fe 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -967,8 +967,9 @@ func (st *stateTransition) innerExecute() (*ExecutionResult, error) { st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee) } - if rules.IsOptimismIsthmus { + if rules.IsOptimismIsthmus && shouldCheckGasFormula { // Operator Fee refunds are only applied if Isthmus is active and the transaction is *not* a deposit. + // Skip during gas estimation (when shouldCheckGasFormula is false) since operator cost wasn't pre-charged. st.refundIsthmusOperatorCost() operatorFeeCost := st.evm.Context.OperatorCostFunc(st.gasUsed(), st.evm.Context.Time) From f3c63f359206e8dd3dd674469335d87c703e6fad Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Fri, 21 Nov 2025 16:52:50 +0800 Subject: [PATCH 2/3] also fix l1cost --- core/state_transition.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 80354563fe..4aa77c2d9b 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -954,17 +954,17 @@ func (st *stateTransition) innerExecute() (*ExecutionResult, error) { amtU256 = st.collectNativeBalance(amtU256) st.state.AddBalance(params.OptimismBaseFeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee) - if l1Cost := st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time); l1Cost != nil { - amtU256, overflow = uint256.FromBig(l1Cost) - if overflow { - return nil, fmt.Errorf("optimism l1 cost overflows U256: %d", l1Cost) - } - if shouldCheckGasFormula { + if shouldCheckGasFormula { + if l1Cost := st.evm.Context.L1CostFunc(st.msg.RollupCostData, st.evm.Context.Time); l1Cost != nil { + amtU256, overflow = uint256.FromBig(l1Cost) + if overflow { + return nil, fmt.Errorf("optimism l1 cost overflows U256: %d", l1Cost) + } st.l1Fee = amtU256.Clone() - } - amtU256 = st.collectNativeBalance(amtU256) - st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee) + amtU256 = st.collectNativeBalance(amtU256) + st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee) + } } if rules.IsOptimismIsthmus && shouldCheckGasFormula { From cd1326866804a76d641a795ed13eb1543649aca5 Mon Sep 17 00:00:00 2001 From: blockchaindevsh Date: Tue, 25 Nov 2025 13:50:42 +0800 Subject: [PATCH 3/3] move under the same "if shouldCheckGasFormula" check --- core/state_transition.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 4aa77c2d9b..6f93c34d9e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -965,20 +965,18 @@ func (st *stateTransition) innerExecute() (*ExecutionResult, error) { amtU256 = st.collectNativeBalance(amtU256) st.state.AddBalance(params.OptimismL1FeeRecipient, amtU256, tracing.BalanceIncreaseRewardTransactionFee) } - } - if rules.IsOptimismIsthmus && shouldCheckGasFormula { - // Operator Fee refunds are only applied if Isthmus is active and the transaction is *not* a deposit. - // Skip during gas estimation (when shouldCheckGasFormula is false) since operator cost wasn't pre-charged. - st.refundIsthmusOperatorCost() + if rules.IsOptimismIsthmus { + // Operator Fee refunds are only applied if Isthmus is active and the transaction is *not* a deposit. + // Skip during gas estimation (when shouldCheckGasFormula is false) since operator cost wasn't pre-charged. + st.refundIsthmusOperatorCost() - operatorFeeCost := st.evm.Context.OperatorCostFunc(st.gasUsed(), st.evm.Context.Time) - st.operatorFee = operatorFeeCost.Clone() - operatorFeeCost = st.collectNativeBalance(operatorFeeCost) - st.state.AddBalance(params.OptimismOperatorFeeRecipient, operatorFeeCost, tracing.BalanceIncreaseRewardTransactionFee) - } + operatorFeeCost := st.evm.Context.OperatorCostFunc(st.gasUsed(), st.evm.Context.Time) + st.operatorFee = operatorFeeCost.Clone() + operatorFeeCost = st.collectNativeBalance(operatorFeeCost) + st.state.AddBalance(params.OptimismOperatorFeeRecipient, operatorFeeCost, tracing.BalanceIncreaseRewardTransactionFee) + } - if shouldCheckGasFormula { if st.l1Fee == nil { st.l1Fee = new(uint256.Int) }