From a4190a0c63ed2e84b15ab9bf04aef406ce8d83b8 Mon Sep 17 00:00:00 2001 From: Daniel Liu Date: Fri, 14 Nov 2025 19:02:21 +0800 Subject: [PATCH] core: skip AddBalance for special-tx, close XFN-67 (#1629) --- core/state_transition.go | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 3c829f7983..6349be5abd 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -384,19 +384,22 @@ func (st *StateTransition) TransitionDb(owner common.Address) (*ExecutionResult, st.refundGas(params.RefundQuotientEIP3529) } - if st.evm.Context.BlockNumber.Cmp(common.TIPTRC21Fee) > 0 { - if (owner != common.Address{}) { - st.state.AddBalance(owner, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice)) - } - } else { - effectiveTip := st.gasPrice - if st.evm.ChainConfig().IsEIP1559(st.evm.Context.BlockNumber) { - effectiveTip = new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee) - if effectiveTip.Cmp(st.gasTipCap) > 0 { - effectiveTip = st.gasTipCap + // GasPrice of special tx is always 0, so we can skip AddBalance + if !types.IsSpecialTx(msg.To()) { + if st.evm.Context.BlockNumber.Cmp(common.TIPTRC21Fee) > 0 { + if (owner != common.Address{}) { + st.state.AddBalance(owner, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), st.gasPrice)) } + } else { + effectiveTip := st.gasPrice + if rules.IsEIP1559 { + effectiveTip = new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee) + if effectiveTip.Cmp(st.gasTipCap) > 0 { + effectiveTip = st.gasTipCap + } + } + st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip)) } - st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip)) } return &ExecutionResult{