From c7621b9bbfc30c9aefd039c43365a4fb355b3c20 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Mon, 4 Dec 2017 15:29:23 +0100 Subject: [PATCH] Merge pull request #7075 from miyao-gmo/feature/estimate_gas_limit escape inifinite loop in estimte_gas --- ethcore/src/client/client.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 785d9782f..8bd9851b3 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1230,12 +1230,12 @@ impl BlockChainClient for Client { } fn estimate_gas(&self, t: &SignedTransaction, block: BlockId) -> Result { - const UPPER_CEILING: u64 = 1_000_000_000_000u64; - let (mut upper, env_info) = { + let (mut upper, max_upper, env_info) = { let mut env_info = self.env_info(block).ok_or(CallError::StatePruned)?; - let initial_upper = env_info.gas_limit; - env_info.gas_limit = UPPER_CEILING.into(); - (initial_upper, env_info) + let init = env_info.gas_limit; + let max = init * U256::from(10); + env_info.gas_limit = max; + (init, max, env_info) }; // that's just a copy of the state. @@ -1256,9 +1256,7 @@ impl BlockChainClient for Client { }; if !cond(upper)? { - // impossible at block gas limit - try `UPPER_CEILING` instead. - // TODO: consider raising limit by powers of two. - upper = UPPER_CEILING.into(); + upper = max_upper; if !cond(upper)? { trace!(target: "estimate_gas", "estimate_gas failed with {}", upper); let err = ExecutionError::Internal(format!("Requires higher than upper limit of {}", upper));