diff --git a/ethcore/src/client/client.rs b/ethcore/src/client/client.rs index 7141c7bdb..fdd201e68 100644 --- a/ethcore/src/client/client.rs +++ b/ethcore/src/client/client.rs @@ -1112,20 +1112,9 @@ impl Client { }.fake_sign(from) } - fn do_call(&self, env_info: &EnvInfo, state: &mut State, increase_balance: bool, t: &SignedTransaction, analytics: CallAnalytics) -> Result { + fn do_call(&self, env_info: &EnvInfo, state: &mut State, t: &SignedTransaction, analytics: CallAnalytics) -> Result { let original_state = if analytics.state_diffing { Some(state.clone()) } else { None }; - // give the sender a sufficient balance (if calling in pending block) - if increase_balance { - let sender = t.sender(); - let balance = state.balance(&sender).map_err(ExecutionError::from)?; - let needed_balance = t.value + t.gas * t.gas_price; - if balance < needed_balance { - state.add_balance(&sender, &(needed_balance - balance), state::CleanupMode::NoEmpty) - .map_err(ExecutionError::from)?; - } - } - let options = TransactOptions { tracing: analytics.transaction_tracing, vm_tracing: analytics.vm_tracing, check_nonce: false }; let mut ret = Executive::new(state, env_info, &*self.engine).transact_virtual(t, options)?; @@ -1167,7 +1156,7 @@ impl BlockChainClient for Client { // that's just a copy of the state. let mut state = self.state_at(block).ok_or(CallError::StatePruned)?; - self.do_call(&env_info, &mut state, block == BlockId::Pending, transaction, analytics) + self.do_call(&env_info, &mut state, transaction, analytics) } fn call_many(&self, transactions: &[(SignedTransaction, CallAnalytics)], block: BlockId) -> Result, CallError> { @@ -1179,7 +1168,7 @@ impl BlockChainClient for Client { let mut results = Vec::with_capacity(transactions.len()); for &(ref t, analytics) in transactions { - let ret = self.do_call(&env_info, &mut state, block == BlockId::Pending, t, analytics)?; + let ret = self.do_call(&env_info, &mut state, t, analytics)?; env_info.gas_used = ret.cumulative_gas_used; results.push(ret); } diff --git a/ethcore/src/executive.rs b/ethcore/src/executive.rs index bd7cf28c1..8f2fb06f2 100644 --- a/ethcore/src/executive.rs +++ b/ethcore/src/executive.rs @@ -157,7 +157,7 @@ impl<'a, B: 'a + StateBackend, E: Engine + ?Sized> Executive<'a, B, E> { pub fn transact_virtual(&'a mut self, t: &SignedTransaction, options: TransactOptions) -> Result { let sender = t.sender(); let balance = self.state.balance(&sender)?; - let needed_balance = t.value + t.gas * t.gas_price; + let needed_balance = t.value.saturating_add(t.gas.saturating_mul(t.gas_price)); if balance < needed_balance { // give the sender a sufficient balance self.state.add_balance(&sender, &(needed_balance - balance), CleanupMode::NoEmpty)?; diff --git a/rpc/src/v1/helpers/fake_sign.rs b/rpc/src/v1/helpers/fake_sign.rs index e5d2c905d..b9be422c5 100644 --- a/rpc/src/v1/helpers/fake_sign.rs +++ b/rpc/src/v1/helpers/fake_sign.rs @@ -34,6 +34,7 @@ pub fn sign_call( Ok(Transaction { nonce: request.nonce.unwrap_or_else(|| client.latest_nonce(&from)), action: request.to.map_or(Action::Create, Action::Call), + // gas: request.gas.unwrap_or(U256::one() << 100), gas: request.gas.unwrap_or(U256::max_value()), gas_price: request.gas_price.unwrap_or_else(|| default_gas_price(&**client, &**miner)), value: request.value.unwrap_or(0.into()),