From b311de91cf532b6bb6586ccb8f8fcbbaeed217ce Mon Sep 17 00:00:00 2001 From: Thomas Coratger <60488569+tcoratger@users.noreply.github.com> Date: Sat, 1 Jun 2024 18:24:34 +0200 Subject: [PATCH] small fix in `estimate_gas_with` gas used (#8541) --- crates/rpc/rpc/src/eth/api/call.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/rpc/rpc/src/eth/api/call.rs b/crates/rpc/rpc/src/eth/api/call.rs index 4143f11ba6..7024fa35cb 100644 --- a/crates/rpc/rpc/src/eth/api/call.rs +++ b/crates/rpc/rpc/src/eth/api/call.rs @@ -296,7 +296,7 @@ where // // NOTE: this is the gas the transaction used, which is less than the // transaction requires to succeed. - let gas_used = res.result.gas_used(); + let mut gas_used = res.result.gas_used(); // the lowest value is capped by the gas used by the unconstrained transaction let mut lowest_gas_limit = gas_used.saturating_sub(1); @@ -313,6 +313,8 @@ where // Re-execute the transaction with the new gas limit and update the result and // environment. (res, env) = self.transact(&mut db, env)?; + // Update the gas used based on the new result. + gas_used = res.result.gas_used(); // Update the gas limit estimates (highest and lowest) based on the execution result. update_estimated_gas_range( res.result,