Fix GasPremium capping logic

Cap it just to FeeCap, there is no reason to cap it proportionally

Signed-off-by: Jakub Sztandera <kubuxu@protocol.ai>
This commit is contained in:
Jakub Sztandera 2020-09-04 15:42:12 +02:00
parent a081dc7674
commit 114c0ea85c
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -217,16 +217,11 @@ func capGasFee(msg *types.Message, maxFee abi.TokenAmount) {
gl := types.NewInt(uint64(msg.GasLimit))
totalFee := types.BigMul(msg.GasFeeCap, gl)
minerFee := types.BigMul(msg.GasPremium, gl)
if totalFee.LessThanEqual(maxFee) {
return
}
// scale chain/miner fee down proportionally to fit in our budget
// TODO: there are probably smarter things we can do here to optimize
// message inclusion latency
msg.GasFeeCap = big.Div(maxFee, gl)
msg.GasPremium = big.Div(big.Div(big.Mul(minerFee, maxFee), totalFee), gl)
msg.GasPremium = big.Min(msg.GasFeeCap, msg.GasPremium) // cap premium at FeeCap
}