From 92315c333e2a724e55296921206cb656b7da0804 Mon Sep 17 00:00:00 2001 From: Bharath Date: Wed, 29 May 2024 14:50:06 +0530 Subject: [PATCH] collect the base fee instead of burning it (#5) EIP-1559 burns the base fee. This doesn't make sense for rollups. The set fee recipient should collect it. --- core/state_transition.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index ea8eae2b1..5db6b71b3 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -467,16 +467,22 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { if rules.IsLondon { effectiveTip = cmath.BigMin(msg.GasTipCap, new(big.Int).Sub(msg.GasFeeCap, st.evm.Context.BaseFee)) } - effectiveTipU256, _ := uint256.FromBig(effectiveTip) 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(st.gasUsed()) - fee.Mul(fee, effectiveTipU256) - st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee) + fee := new(big.Int).SetUint64(st.gasUsed()) + fee.Mul(fee, effectiveTip) + st.state.AddBalance(st.evm.Context.Coinbase, uint256.MustFromBig(fee), tracing.BalanceIncreaseRewardTransactionFee) + + // collect base fee instead of burn + if rules.IsLondon && st.evm.Context.Coinbase.Cmp(common.Address{}) != 0 { + baseFee := new(big.Int).SetUint64(st.gasUsed()) + baseFee.Mul(baseFee, st.evm.Context.BaseFee) + st.state.AddBalance(st.evm.Context.Coinbase, uint256.MustFromBig(baseFee), tracing.BalanceIncreaseRewardTransactionFee) + } } return &ExecutionResult{