From 72577219c0cb2ed0af8d701e513ff5509a43b01a Mon Sep 17 00:00:00 2001 From: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> Date: Mon, 8 Jul 2024 17:08:22 +0800 Subject: [PATCH] fix fee logic in `TransitionDb` (#887) update fee_vault logic in TransitionDb --- core/state_transition.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index bce05cb99c..e7bf5dcf36 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -490,19 +490,19 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) } + // The L2 Fee is the same as the fee that is charged in the normal geth codepath. + fee := big.NewInt(0) 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 { - // The L2 Fee is the same as the fee that is charged in the normal geth - // codepath. Add the L1DataFee to the L2 fee for the total fee that is sent - // to the sequencer. - fee := new(big.Int).SetUint64(st.gasUsed()) + fee = new(big.Int).SetUint64(st.gasUsed()) fee.Mul(fee, effectiveTip) - fee.Add(fee, st.l1DataFee) - st.state.AddBalance(st.evm.Context.Coinbase, fee) // TODO: change to `st.evm.FeeRecipient()` } + //Add the L1DataFee to the L2 fee for the total fee that is sent to the sequencer. + totalFee := fee.Add(fee, st.l1DataFee) + st.state.AddBalance(st.evm.FeeRecipient(), totalFee) return &ExecutionResult{ L1DataFee: st.l1DataFee,