From d38ae58ba59bf14c9193be735bbe8815ed6e5aef Mon Sep 17 00:00:00 2001 From: Eason Gao Date: Thu, 7 Dec 2023 14:32:15 +0800 Subject: [PATCH] refactor: change estimate gas calculation (#1626) * refactor: change estimate gas calculation * add annotation * cargo fmt --- core/executor/src/lib.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/executor/src/lib.rs b/core/executor/src/lib.rs index b5cf9d5e8..9c4a803d5 100644 --- a/core/executor/src/lib.rs +++ b/core/executor/src/lib.rs @@ -71,15 +71,10 @@ impl Executor for AxonExecutor { to: Option, value: U256, data: Vec, - estimate: bool, + is_estimate: bool, ) -> TxResp { self.init_local_system_contract_roots(backend); - let config = { - let mut config = self.config(); - // whether run the gasometer in estimate mode or not - config.estimate = estimate; - config - }; + let config = self.config(); let metadata = StackSubstateMetadata::new(gas_limit, &config); let state = MemoryStackState::new(metadata, backend); let precompiles = build_precompile_set(); @@ -99,6 +94,12 @@ impl Executor for AxonExecutor { }; let used_gas = executor.used_gas(); + let used_gas = if is_estimate { + // The estimate gas coef is 1.25 + (used_gas / 4) + used_gas + } else { + used_gas + }; TxResp { exit_reason: exit,