fix: cap the message gas limit at the block gas limit (#10637)

Technically, if a message is near the block gas limit, this method could
over-estimate past the block gas limit. Instead, cap at the block gas
limit.
This commit is contained in:
Steven Allen 2023-04-08 14:57:28 -07:00 committed by GitHub
parent 9d44c88cbb
commit d1364caa84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -388,6 +388,10 @@ func (m *GasModule) GasEstimateMessageGas(ctx context.Context, msg *types.Messag
return nil, err
}
msg.GasLimit = int64(float64(gasLimit) * m.Mpool.GetConfig().GasLimitOverestimation)
// Gas overestimation can cause us to exceed the block gas limit, cap it.
if msg.GasLimit > build.BlockGasLimit {
msg.GasLimit = build.BlockGasLimit
}
}
if msg.GasPremium == types.EmptyInt || types.BigCmp(msg.GasPremium, types.NewInt(0)) == 0 {