mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
fix: estimateGas edge case (#11764)
This commit is contained in:
@@ -888,7 +888,11 @@ pub trait Call: LoadState + SpawnBlocking {
|
||||
// Execute transaction and handle potential gas errors, adjusting limits accordingly.
|
||||
match self.transact(&mut db, env.clone()) {
|
||||
Err(err) if err.is_gas_too_high() => {
|
||||
// Increase the lowest gas limit if gas is too high
|
||||
// Decrease the highest gas limit if gas is too high
|
||||
highest_gas_limit = mid_gas_limit;
|
||||
}
|
||||
Err(err) if err.is_gas_too_low() => {
|
||||
// Increase the lowest gas limit if gas is too low
|
||||
lowest_gas_limit = mid_gas_limit;
|
||||
}
|
||||
// Handle other cases, including successful transactions.
|
||||
|
||||
@@ -59,6 +59,16 @@ pub trait AsEthApiError {
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
/// Returns `true` if error is
|
||||
/// [`RpcInvalidTransactionError::GasTooLow`](reth_rpc_eth_types::RpcInvalidTransactionError::GasTooLow).
|
||||
fn is_gas_too_low(&self) -> bool {
|
||||
if let Some(err) = self.as_err() {
|
||||
return err.is_gas_too_low()
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl AsEthApiError for EthApiError {
|
||||
|
||||
@@ -151,6 +151,11 @@ impl EthApiError {
|
||||
pub const fn is_gas_too_high(&self) -> bool {
|
||||
matches!(self, Self::InvalidTransaction(RpcInvalidTransactionError::GasTooHigh))
|
||||
}
|
||||
|
||||
/// Returns `true` if error is [`RpcInvalidTransactionError::GasTooLow`]
|
||||
pub const fn is_gas_too_low(&self) -> bool {
|
||||
matches!(self, Self::InvalidTransaction(RpcInvalidTransactionError::GasTooLow))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<EthApiError> for jsonrpsee_types::error::ErrorObject<'static> {
|
||||
|
||||
Reference in New Issue
Block a user