fix: remove gas estimation accuracy threshold (#2049)

This commit is contained in:
Dan Cline
2023-03-31 04:33:40 -04:00
committed by GitHub
parent 7c1bd7c5c5
commit ec7a565ef3

View File

@ -194,8 +194,6 @@ where
((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64,
);
let mut last_highest_gas_limit = highest_gas_limit;
// binary search
while (highest_gas_limit - lowest_gas_limit) > 1 {
let mut env = env.clone();
@ -205,16 +203,6 @@ where
ExecutionResult::Success { .. } => {
// cap the highest gas limit with succeeding gas limit
highest_gas_limit = mid_gas_limit;
// if last two successful estimations only vary by 10%, we consider this to be
// sufficiently accurate
const ACCURACY: u128 = 10;
if (last_highest_gas_limit - highest_gas_limit) as u128 * ACCURACY /
(last_highest_gas_limit as u128) <
1u128
{
return Ok(U256::from(highest_gas_limit))
}
last_highest_gas_limit = highest_gas_limit;
}
ExecutionResult::Revert { .. } => {
// increase the lowest gas limit