Skip to content

Commit

Permalink
core: skip fee payment when NoBaseFee is set and feeCap is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
lightclient committed Jul 10, 2022
1 parent 86bda71 commit c24dec3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/state_transition.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) {
if rules.IsLondon {
effectiveTip = cmath.BigMin(st.gasTipCap, new(big.Int).Sub(st.gasFeeCap, st.evm.Context.BaseFee))
}
// effectiveTip may be negative during RPC calls such as eth_call and eth_estimateGas.
// In these circumstances, we don't want to subtract balance from the coinbase,
// which would otherwise result in a potentially negative balance.
if effectiveTip.Sign() > 0 {

if st.evm.Config.NoBaseFee && st.gasFeeCap.BitLen() == 0 && st.gasTipCap.BitLen() == 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 {
st.state.AddBalance(st.evm.Context.Coinbase, new(big.Int).Mul(new(big.Int).SetUint64(st.gasUsed()), effectiveTip))
}

Expand Down

0 comments on commit c24dec3

Please sign in to comment.