mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix: remove gas estimation accuracy threshold (#2049)
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user