Merge remote-tracking branch 'origin/master' into gav

This commit is contained in:
Gav Wood 2016-01-15 12:11:13 +01:00
commit bf4669eaff
2 changed files with 14 additions and 11 deletions

View File

@ -12,7 +12,7 @@ env_logger = "0.3"
ethcore-util = { path = "../ethcore-util" }
rustc-serialize = "0.3"
flate2 = "0.2"
rocksdb = "0.2"
rocksdb = "0.3"
heapsize = "0.2.0"
rust-crypto = "0.2.34"
time = "0.1"

View File

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