diff --git a/src/evm/executive.rs b/src/evm/executive.rs index 7b4b7da59..f39273870 100644 --- a/src/evm/executive.rs +++ b/src/evm/executive.rs @@ -69,18 +69,6 @@ pub struct Executed { pub logs: Vec } -impl Executed { - fn new() -> Executed { - Executed { - gas: U256::zero(), - gas_used: U256::zero(), - refunded: U256::zero(), - cumulative_gas_used: U256::zero(), - logs: vec![] - } - } -} - /// Result of executing the transaction. #[derive(PartialEq, Debug)] pub enum ExecutionError { @@ -94,6 +82,8 @@ pub enum ExecutionError { /// Returned when cost of transaction (value + gas_price * gas) exceeds /// current sender balance. NotEnoughCash { required: U256, is: U256 }, + /// Returned when transaction execution runs out of gas. + OutOfGas, /// Returned when internal evm error occurs. Internal } @@ -248,13 +238,10 @@ impl<'a> Executive<'a> { match result { Err(EvmError::Internal) => Err(ExecutionError::Internal), Err(EvmError::OutOfGas) => { - let executed = Executed::new(); *self.state = backup; - Ok(executed) + Err(ExecutionError::OutOfGas) }, Ok(gas_left) => { - let executed = Executed::new(); - let schedule = self.engine.evm_schedule(self.info); // refunds from SSTORE nonzero -> zero @@ -277,7 +264,14 @@ impl<'a> Executive<'a> { self.state.kill_account(address); } - Ok(executed) + let gas_used = t.gas - gas_left; + Ok(Executed { + gas: t.gas, + gas_used: gas_used, + refunded: refund, + cumulative_gas_used: self.info.gas_used + gas_used, + logs: substate.logs + }) } } } @@ -477,12 +471,8 @@ mod tests { use util::hash::*; use util::uint::*; use evm::*; - use transaction::*; use env_info::*; use state::*; - use spec::*; - use engine::*; - use evm_schedule::*; use super::contract_address; use ethereum; use null_engine::*; diff --git a/src/evm/jit.rs b/src/evm/jit.rs index d397ee77d..d5268b78c 100644 --- a/src/evm/jit.rs +++ b/src/evm/jit.rs @@ -241,7 +241,7 @@ impl<'a> evmjit::Ext for ExtAdapter<'a> { value: *const evmjit::I256, in_beg: *const u8, in_size: u64, - mut out_beg: *mut u8, + out_beg: *mut u8, out_size: u64, code_address: *const evmjit::H256) -> bool { unsafe {