Merge branch 'master' of github.com:gavofyork/ethcore into client

This commit is contained in:
arkpar 2016-01-15 01:54:48 +01:00
commit 5ce3275f04

View File

@ -22,7 +22,7 @@ pub struct Substate {
/// Refund counter of SSTORE nonzero->zero. /// Refund counter of SSTORE nonzero->zero.
refunds_count: U256, refunds_count: U256,
/// True if transaction, or one of its subcalls runs out of gas. /// True if transaction, or one of its subcalls runs out of gas.
out_of_gas: bool, excepted: bool,
/// Created contracts. /// Created contracts.
contracts_created: Vec<Address> contracts_created: Vec<Address>
} }
@ -34,7 +34,7 @@ impl Substate {
suicides: HashSet::new(), suicides: HashSet::new(),
logs: vec![], logs: vec![],
refunds_count: U256::zero(), refunds_count: U256::zero(),
out_of_gas: false, excepted: false,
contracts_created: vec![] contracts_created: vec![]
} }
} }
@ -43,11 +43,11 @@ impl Substate {
self.suicides.extend(s.suicides.into_iter()); self.suicides.extend(s.suicides.into_iter());
self.logs.extend(s.logs.into_iter()); self.logs.extend(s.logs.into_iter());
self.refunds_count = self.refunds_count + s.refunds_count; self.refunds_count = self.refunds_count + s.refunds_count;
self.out_of_gas |= s.out_of_gas; self.excepted |= s.excepted;
self.contracts_created.extend(s.contracts_created.into_iter()); self.contracts_created.extend(s.contracts_created.into_iter());
} }
pub fn out_of_gas(&self) -> bool { self.out_of_gas } pub fn excepted(&self) -> bool { self.excepted }
} }
/// Transaction execution receipt. /// Transaction execution receipt.
@ -69,7 +69,7 @@ pub struct Executed {
/// Vector of logs generated by transaction. /// Vector of logs generated by transaction.
pub logs: Vec<LogEntry>, pub logs: Vec<LogEntry>,
/// Execution ended running out of gas. /// Execution ended running out of gas.
pub out_of_gas: bool, pub excepted: bool,
/// Addresses of contracts created during execution of transaction. /// Addresses of contracts created during execution of transaction.
/// Ordered from earliest creation. /// Ordered from earliest creation.
/// ///
@ -293,7 +293,7 @@ impl<'a> Executive<'a> {
refunded: refund, refunded: refund,
cumulative_gas_used: self.info.gas_used + gas_used, cumulative_gas_used: self.info.gas_used + gas_used,
logs: substate.logs, logs: substate.logs,
out_of_gas: substate.out_of_gas, excepted: substate.excepted,
contracts_created: substate.contracts_created contracts_created: substate.contracts_created
}) })
}, },
@ -304,7 +304,7 @@ impl<'a> Executive<'a> {
refunded: U256::zero(), refunded: U256::zero(),
cumulative_gas_used: self.info.gas_used + t.gas, cumulative_gas_used: self.info.gas_used + t.gas,
logs: vec![], logs: vec![],
out_of_gas: true, excepted: true,
contracts_created: vec![] contracts_created: vec![]
}) })
} }
@ -315,7 +315,7 @@ impl<'a> Executive<'a> {
// TODO: handle other evm::Errors same as OutOfGas once they are implemented // TODO: handle other evm::Errors same as OutOfGas once they are implemented
match result { match result {
&Err(evm::Error::OutOfGas) => { &Err(evm::Error::OutOfGas) => {
substate.out_of_gas = true; substate.excepted = true;
self.state.revert(backup); self.state.revert(backup);
}, },
&Ok(_) | &Err(evm::Error::Internal) => substate.accrue(un_substate) &Ok(_) | &Err(evm::Error::Internal) => substate.accrue(un_substate)
@ -899,7 +899,7 @@ mod tests {
assert_eq!(executed.refunded, U256::from(58_699)); assert_eq!(executed.refunded, U256::from(58_699));
assert_eq!(executed.cumulative_gas_used, U256::from(41_301)); assert_eq!(executed.cumulative_gas_used, U256::from(41_301));
assert_eq!(executed.logs.len(), 0); assert_eq!(executed.logs.len(), 0);
assert_eq!(executed.out_of_gas, false); assert_eq!(executed.excepted, false);
assert_eq!(executed.contracts_created.len(), 0); assert_eq!(executed.contracts_created.len(), 0);
assert_eq!(state.balance(&sender), U256::from(1)); assert_eq!(state.balance(&sender), U256::from(1));
assert_eq!(state.balance(&contract), U256::from(17)); assert_eq!(state.balance(&contract), U256::from(17));