nightly fixes

This commit is contained in:
debris
2016-02-14 12:54:27 +01:00
parent e1cd5186c6
commit f1b39ee1e5
14 changed files with 35 additions and 42 deletions

View File

@@ -72,14 +72,14 @@ impl AccountDiff {
pub fn diff_pod(pre: Option<&PodAccount>, post: Option<&PodAccount>) -> Option<AccountDiff> {
match (pre, post) {
(None, Some(x)) => Some(AccountDiff {
balance: Diff::Born(x.balance.clone()),
nonce: Diff::Born(x.nonce.clone()),
balance: Diff::Born(x.balance),
nonce: Diff::Born(x.nonce),
code: Diff::Born(x.code.clone()),
storage: x.storage.iter().map(|(k, v)| (k.clone(), Diff::Born(v.clone()))).collect(),
}),
(Some(x), None) => Some(AccountDiff {
balance: Diff::Died(x.balance.clone()),
nonce: Diff::Died(x.nonce.clone()),
balance: Diff::Died(x.balance),
nonce: Diff::Died(x.nonce),
code: Diff::Died(x.code.clone()),
storage: x.storage.iter().map(|(k, v)| (k.clone(), Diff::Died(v.clone()))).collect(),
}),
@@ -88,8 +88,8 @@ impl AccountDiff {
.filter(|k| pre.storage.get(k).unwrap_or(&H256::new()) != post.storage.get(k).unwrap_or(&H256::new()))
.collect();
let r = AccountDiff {
balance: Diff::new(pre.balance.clone(), post.balance.clone()),
nonce: Diff::new(pre.nonce.clone(), post.nonce.clone()),
balance: Diff::new(pre.balance, post.balance),
nonce: Diff::new(pre.nonce, post.nonce),
code: Diff::new(pre.code.clone(), post.code.clone()),
storage: storage.into_iter().map(|k|
(k.clone(), Diff::new(

View File

@@ -274,7 +274,7 @@ mod tests {
use block::*;
use engine::*;
use tests::helpers::*;
use super::*;
use super::{Ethash};
use super::super::new_morden;
#[test]

View File

@@ -391,10 +391,7 @@ impl Interpreter {
instructions::SLOAD => {
InstructionCost::Gas(U256::from(schedule.sload_gas))
},
instructions::MSTORE => {
InstructionCost::GasMem(default_gas, try!(self.mem_needed_const(stack.peek(0), 32)))
},
instructions::MLOAD => {
instructions::MSTORE | instructions::MLOAD => {
InstructionCost::GasMem(default_gas, try!(self.mem_needed_const(stack.peek(0), 32)))
},
instructions::MSTORE8 => {
@@ -736,8 +733,7 @@ impl Interpreter {
},
instructions::CALLVALUE => {
stack.push(match params.value {
ActionValue::Transfer(val) => val,
ActionValue::Apparent(val) => val,
ActionValue::Transfer(val) | ActionValue::Apparent(val) => val
});
},
instructions::CALLDATALOAD => {

View File

@@ -84,7 +84,7 @@ impl Ext for FakeExt {
}
fn balance(&self, address: &Address) -> U256 {
self.balances.get(address).unwrap().clone()
*self.balances.get(address).unwrap()
}
fn blockhash(&self, number: &U256) -> H256 {
@@ -94,10 +94,10 @@ impl Ext for FakeExt {
fn create(&mut self, gas: &U256, value: &U256, code: &[u8]) -> ContractCreateResult {
self.calls.insert(FakeCall {
call_type: FakeCallType::CREATE,
gas: gas.clone(),
gas: *gas,
sender_address: None,
receive_address: None,
value: Some(value.clone()),
value: Some(*value),
data: code.to_vec(),
code_address: None
});
@@ -115,14 +115,14 @@ impl Ext for FakeExt {
self.calls.insert(FakeCall {
call_type: FakeCallType::CALL,
gas: gas.clone(),
gas: *gas,
sender_address: Some(sender_address.clone()),
receive_address: Some(receive_address.clone()),
value: value,
data: data.to_vec(),
code_address: Some(code_address.clone())
});
MessageCallResult::Success(gas.clone())
MessageCallResult::Success(*gas)
}
fn extcode(&self, address: &Address) -> Bytes {
@@ -898,7 +898,7 @@ fn test_calls(factory: super::Factory) {
let mut ext = FakeExt::new();
ext.balances = {
let mut s = HashMap::new();
s.insert(params.address.clone(), params.gas.clone());
s.insert(params.address.clone(), params.gas);
s
};

View File

@@ -45,10 +45,9 @@ impl OriginInfo {
OriginInfo {
address: params.address.clone(),
origin: params.origin.clone(),
gas_price: params.gas_price.clone(),
gas_price: params.gas_price,
value: match params.value {
ActionValue::Transfer(val) => val,
ActionValue::Apparent(val) => val,
ActionValue::Transfer(val) | ActionValue::Apparent(val) => val
}
}
}
@@ -133,8 +132,8 @@ impl<'a> Ext for Externalities<'a> {
sender: self.origin_info.address.clone(),
origin: self.origin_info.origin.clone(),
gas: *gas,
gas_price: self.origin_info.gas_price.clone(),
value: ActionValue::Transfer(value.clone()),
gas_price: self.origin_info.gas_price,
value: ActionValue::Transfer(*value),
code: Some(code.to_vec()),
data: None,
};
@@ -164,11 +163,11 @@ impl<'a> Ext for Externalities<'a> {
let mut params = ActionParams {
sender: sender_address.clone(),
address: receive_address.clone(),
value: ActionValue::Apparent(self.origin_info.value.clone()),
value: ActionValue::Apparent(self.origin_info.value),
code_address: code_address.clone(),
origin: self.origin_info.origin.clone(),
gas: *gas,
gas_price: self.origin_info.gas_price.clone(),
gas_price: self.origin_info.gas_price,
code: self.state.code(code_address),
data: Some(data.to_vec()),
};

View File

@@ -43,8 +43,8 @@ impl PodAccount {
/// NOTE: This will silently fail unless the account is fully cached.
pub fn from_account(acc: &Account) -> PodAccount {
PodAccount {
balance: acc.balance().clone(),
nonce: acc.nonce().clone(),
balance: *acc.balance(),
nonce: *acc.nonce(),
storage: acc.storage_overlay().iter().fold(BTreeMap::new(), |mut m, (k, &(_, ref v))| {m.insert(k.clone(), v.clone()); m}),
code: acc.code().unwrap().to_vec(),
}

View File

@@ -153,12 +153,12 @@ impl State {
/// Get the balance of account `a`.
pub fn balance(&self, a: &Address) -> U256 {
self.get(a, false).as_ref().map_or(U256::zero(), |account| account.balance().clone())
self.get(a, false).as_ref().map_or(U256::zero(), |account| *account.balance())
}
/// Get the nonce of account `a`.
pub fn nonce(&self, a: &Address) -> U256 {
self.get(a, false).as_ref().map_or(U256::zero(), |account| account.nonce().clone())
self.get(a, false).as_ref().map_or(U256::zero(), |account| *account.nonce())
}
/// Mutate storage of account `address` so that it is `value` for `key`.