fix: cap request gas limit in eth estimate (#12970)

This commit is contained in:
Matthias Seitz
2024-11-28 17:34:41 +01:00
committed by GitHub
parent ca72d45662
commit 8e1945592b

View File

@ -57,7 +57,7 @@ pub trait EstimateCall: Call {
request.nonce = None;
// Keep a copy of gas related request values
let tx_request_gas_limit = request.gas;
let tx_request_gas_limit = request.gas.map(U256::from);
let tx_request_gas_price = request.gas_price;
// the gas limit of the corresponding block
let block_env_gas_limit = block.gas_limit;
@ -65,7 +65,13 @@ pub trait EstimateCall: Call {
// Determine the highest possible gas limit, considering both the request's specified limit
// and the block's limit.
let mut highest_gas_limit = tx_request_gas_limit
.map(|tx_gas_limit| U256::from(tx_gas_limit).max(block_env_gas_limit))
.map(|mut tx_gas_limit| {
if block_env_gas_limit < tx_gas_limit {
// requested gas limit is higher than the allowed gas limit, capping
tx_gas_limit = block_env_gas_limit;
}
tx_gas_limit
})
.unwrap_or(block_env_gas_limit);
// Configure the evm env