Skip to content

Commit

Permalink
temporary margin error in gas estimation (to not cherry-pick)
Browse files Browse the repository at this point in the history
  • Loading branch information
librelois committed Aug 18, 2023
1 parent 688ad3b commit f8a810f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions client/rpc/src/eth/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,8 @@ where
// Start close to the used gas for faster binary search
let mut mid = std::cmp::min(used_gas * 3, (highest + lowest) / 2);

const MARGIN_ERROR: U256 = 200;

// Execute the binary search and hone in on an executable gas limit.
let mut previous_highest = highest;
while (highest - lowest) > U256::one() {
Expand All @@ -853,7 +855,7 @@ where
// If the variation in the estimate is less than 10%,
// then the estimate is considered sufficiently accurate.
if (previous_highest - highest) * 10 / previous_highest < U256::one() {
return Ok(highest);
return Ok(highest + MARGIN_ERROR);
}
previous_highest = highest;
}
Expand All @@ -867,7 +869,7 @@ where
mid = (highest + lowest) / 2;
}

Ok(highest)
Ok(highest + MARGIN_ERROR)
}
}

Expand Down

0 comments on commit f8a810f

Please sign in to comment.