From 00aad34194ea266bb34682d931ffadc619ad58cb Mon Sep 17 00:00:00 2001 From: Aayush Date: Tue, 10 Oct 2023 11:20:26 -0400 Subject: [PATCH] messagepool: refactor CapGasFee logic to be cleaner --- chain/messagepool/messagepool.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 14db88f91..f0037de09 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -225,17 +225,11 @@ func CapGasFee(mff dtypes.DefaultMaxFeeFunc, msg *types.Message, sendSpec *api.M } gaslimit := types.NewInt(uint64(msg.GasLimit)) - - if !maximizeFeeCap { - totalFee := types.BigMul(msg.GasFeeCap, gaslimit) - - if totalFee.LessThanEqual(maxFee) { - msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap - return - } + totalFee := types.BigMul(msg.GasFeeCap, gaslimit) + if !maximizeFeeCap && totalFee.GreaterThan(maxFee) { + msg.GasFeeCap = big.Div(maxFee, gaslimit) } - msg.GasFeeCap = big.Div(maxFee, gaslimit) msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap }