From e43b2f4829900fc34e5f3ffbde98ae2807119a2a Mon Sep 17 00:00:00 2001 From: Omid Chenane <155813094+ochenane@users.noreply.github.com> Date: Tue, 9 Apr 2024 17:13:58 +0330 Subject: [PATCH] fix: Remove extra return when init uses too much gas (#7521) --- crates/rpc/rpc/src/eth/api/call.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index e2f5558800..62be2612c4 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -344,7 +344,7 @@ where }; env.tx.gas_limit = mid_gas_limit; - let ethres = self.transact(&mut db, env); + let ethres = self.transact(&mut db, env.clone()); // Exceptional case: init used too much gas, we need to increase the gas limit and try // again @@ -354,21 +354,16 @@ where ) { // increase the lowest gas limit lowest_gas_limit = mid_gas_limit; - - // new midpoint - mid_gas_limit = ((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64; - (_, env) = ethres?; - continue + } else { + (res, env) = ethres?; + update_estimated_gas_range( + res.result, + mid_gas_limit, + &mut highest_gas_limit, + &mut lowest_gas_limit, + )?; } - (res, env) = ethres?; - update_estimated_gas_range( - res.result, - mid_gas_limit, - &mut highest_gas_limit, - &mut lowest_gas_limit, - )?; - // new midpoint mid_gas_limit = ((highest_gas_limit as u128 + lowest_gas_limit as u128) / 2) as u64; }