mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 02:10:46 +00:00
core: refactor fee payment guard in state transition
This commit is contained in:
parent
98b13f342f
commit
a1d9d0f9f9
1 changed files with 12 additions and 10 deletions
|
|
@ -563,17 +563,19 @@ func (st *stateTransition) execute() (*ExecutionResult, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
effectiveTip := msg.GasPrice
|
|
||||||
if rules.IsLondon {
|
|
||||||
effectiveTip = new(big.Int).Sub(msg.GasPrice, st.evm.Context.BaseFee)
|
|
||||||
}
|
|
||||||
effectiveTipU256, _ := uint256.FromBig(effectiveTip)
|
|
||||||
|
|
||||||
if st.evm.Config.NoBaseFee && msg.GasFeeCap.Sign() == 0 && msg.GasTipCap.Sign() == 0 {
|
skipFeePayment := 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
|
// Skip fee payment when NoBaseFee is set and the fee fields
|
||||||
// the coinbase when simulating calls.
|
// are 0. This avoids a negative effectiveTip being applied to
|
||||||
} else {
|
// the coinbase when simulating calls.
|
||||||
|
if !skipFeePayment {
|
||||||
|
effectiveTip := msg.GasPrice
|
||||||
|
if rules.IsLondon {
|
||||||
|
effectiveTip = new(big.Int).Sub(msg.GasPrice, st.evm.Context.BaseFee)
|
||||||
|
}
|
||||||
|
effectiveTipU256, _ := uint256.FromBig(effectiveTip)
|
||||||
|
|
||||||
fee := new(uint256.Int).SetUint64(st.gasUsed())
|
fee := new(uint256.Int).SetUint64(st.gasUsed())
|
||||||
fee.Mul(fee, effectiveTipU256)
|
fee.Mul(fee, effectiveTipU256)
|
||||||
st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee)
|
st.state.AddBalance(st.evm.Context.Coinbase, fee, tracing.BalanceIncreaseRewardTransactionFee)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue