From 5c0f9f1c40c265cf4abfa151f0bd7204465c73b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Thu, 24 Aug 2017 13:13:01 +0200 Subject: [PATCH] Fix eth_call. (#6365) * Fix eth_call. * Fix warning spam. --- rpc/src/v1/helpers/fake_sign.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rpc/src/v1/helpers/fake_sign.rs b/rpc/src/v1/helpers/fake_sign.rs index c5b95f6a4..551bf5d35 100644 --- a/rpc/src/v1/helpers/fake_sign.rs +++ b/rpc/src/v1/helpers/fake_sign.rs @@ -30,15 +30,17 @@ pub fn sign_call( request: CallRequest, gas_cap: bool, ) -> Result { - let from = request.from.unwrap_or(0.into()); - let mut gas = request.gas.unwrap_or(U256::max_value()); - if gas_cap { - let max_gas = 50_000_000.into(); - if gas > max_gas { + let max_gas = 50_000_000.into(); + let gas = match request.gas { + Some(gas) if gas_cap && gas > max_gas => { warn!("Gas limit capped to {} (from {})", max_gas, gas); - gas = max_gas + max_gas } - } + Some(gas) => gas, + None if gas_cap => max_gas, + None => U256::from(2) << 50, + }; + let from = request.from.unwrap_or(0.into()); Ok(Transaction { nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)),