Skip to content

Commit

Permalink
collect the base fee instead of burning it (#5)
Browse files Browse the repository at this point in the history
EIP-1559 burns the base fee. This doesn't make sense for rollups. The
set fee recipient should collect it.
  • Loading branch information
bharath-123 committed May 29, 2024
1 parent d66918d commit 92315c3
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit 92315c3

Please sign in to comment.