Merge branch 'net' into discovery

This commit is contained in:
arkpar 2016-02-14 18:27:31 +01:00
commit 986448ce7a
24 changed files with 46 additions and 52 deletions

View File

@ -12,7 +12,7 @@ rustc-serialize = "0.3"
docopt = "0.6" docopt = "0.6"
docopt_macros = "0.6" docopt_macros = "0.6"
ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" } ctrlc = { git = "https://github.com/tomusdrw/rust-ctrlc.git" }
clippy = "0.0.37" clippy = "0.0.41"
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethsync = { path = "sync" } ethsync = { path = "sync" }

View File

@ -18,7 +18,7 @@ ethcore-util = { path = "../util" }
evmjit = { path = "../evmjit", optional = true } evmjit = { path = "../evmjit", optional = true }
ethash = { path = "../ethash" } ethash = { path = "../ethash" }
num_cpus = "0.2" num_cpus = "0.2"
clippy = "0.0.37" clippy = "0.0.41"
crossbeam = "0.1.5" crossbeam = "0.1.5"
lazy_static = "0.1" lazy_static = "0.1"

View File

@ -3,7 +3,7 @@
"engineName": "Ethash", "engineName": "Ethash",
"params": { "params": {
"accountStartNonce": "0x00", "accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0x10c8e0", "frontierCompatibilityModeLimit": "0xf4240fff",
"maximumExtraDataSize": "0x20", "maximumExtraDataSize": "0x20",
"tieBreakingGas": false, "tieBreakingGas": false,
"minGasLimit": "0x1388", "minGasLimit": "0x1388",

View File

@ -3,7 +3,7 @@
"engineName": "Ethash", "engineName": "Ethash",
"params": { "params": {
"accountStartNonce": "0x00", "accountStartNonce": "0x00",
"frontierCompatibilityModeLimit": "0xf4240", "frontierCompatibilityModeLimit": "0xf4240fff",
"maximumExtraDataSize": "0x20", "maximumExtraDataSize": "0x20",
"tieBreakingGas": false, "tieBreakingGas": false,
"minGasLimit": "0x1388", "minGasLimit": "0x1388",

View File

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

View File

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

View File

@ -24,7 +24,7 @@ pub mod ethash;
/// Export the denominations module. /// Export the denominations module.
pub mod denominations; pub mod denominations;
pub use self::ethash::*; pub use self::ethash::{Ethash};
pub use self::denominations::*; pub use self::denominations::*;
use super::spec::*; use super::spec::*;

View File

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

View File

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

View File

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

View File

@ -115,7 +115,7 @@ declare_test!{StateTests_stSolidityTest, "StateTests/stSolidityTest"}
declare_test!{StateTests_stSpecialTest, "StateTests/stSpecialTest"} declare_test!{StateTests_stSpecialTest, "StateTests/stSpecialTest"}
declare_test!{StateTests_stSystemOperationsTest, "StateTests/stSystemOperationsTest"} declare_test!{StateTests_stSystemOperationsTest, "StateTests/stSystemOperationsTest"}
declare_test!{StateTests_stTransactionTest, "StateTests/stTransactionTest"} declare_test!{StateTests_stTransactionTest, "StateTests/stTransactionTest"}
declare_test!{StateTests_stTransitionTest, "StateTests/stTransitionTest"} //declare_test!{StateTests_stTransitionTest, "StateTests/stTransitionTest"}
declare_test!{StateTests_stWalletTest, "StateTests/stWalletTest"} declare_test!{StateTests_stWalletTest, "StateTests/stWalletTest"}

View File

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

View File

@ -153,12 +153,12 @@ impl State {
/// Get the balance of account `a`. /// Get the balance of account `a`.
pub fn balance(&self, a: &Address) -> U256 { 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`. /// Get the nonce of account `a`.
pub fn nonce(&self, a: &Address) -> U256 { 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`. /// Mutate storage of account `address` so that it is `value` for `key`.

View File

@ -9,13 +9,13 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies] [dependencies]
serde = "0.6.7" serde = "0.6.7"
serde_macros = "0.6.10" serde_macros = { git = "https://github.com/debris/serde", path = "serde_macros" }
serde_json = "0.6.0" serde_json = "0.6.0"
jsonrpc-core = "1.1" jsonrpc-core = { git = "https://github.com/debris/jsonrpc-core" }
jsonrpc-http-server = "1.1" jsonrpc-http-server = { git = "https://github.com/debris/jsonrpc-http-server" }
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = "../ethcore" } ethcore = { path = "../ethcore" }
ethsync = { path = "../sync" } ethsync = { path = "../sync" }
clippy = "0.0.37" clippy = "0.0.41"
target_info = "0.1.0" target_info = "0.1.0"
rustc-serialize = "0.3" rustc-serialize = "0.3"

View File

@ -10,7 +10,7 @@ authors = ["Ethcore <admin@ethcore.io"]
[dependencies] [dependencies]
ethcore-util = { path = "../util" } ethcore-util = { path = "../util" }
ethcore = { path = ".." } ethcore = { path = ".." }
clippy = "0.0.37" clippy = "0.0.41"
log = "0.3" log = "0.3"
env_logger = "0.3" env_logger = "0.3"
time = "0.1.34" time = "0.1.34"

View File

@ -466,6 +466,7 @@ impl ChainSync {
trace!(target: "sync", "New block already queued {:?}", h); trace!(target: "sync", "New block already queued {:?}", h);
}, },
Ok(_) => { Ok(_) => {
self.last_imported_block = Some(header.number);
trace!(target: "sync", "New block queued {:?}", h); trace!(target: "sync", "New block queued {:?}", h);
}, },
Err(ImportError::UnknownParent) => { Err(ImportError::UnknownParent) => {

View File

@ -168,6 +168,7 @@ impl<K, V> RangeCollection<K, V> for Vec<(K, Vec<V>)> where K: Ord + PartialEq +
fn insert_item(&mut self, key: K, value: V) { fn insert_item(&mut self, key: K, value: V) {
assert!(!self.have_item(&key)); assert!(!self.have_item(&key));
// todo: fix warning
let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) { let lower = match self.binary_search_by(|&(k, _)| k.cmp(&key).reverse()) {
Ok(index) => index, Ok(index) => index,
Err(index) => index, Err(index) => index,

View File

@ -26,7 +26,7 @@ crossbeam = "0.2"
slab = { git = "https://github.com/arkpar/slab.git" } slab = { git = "https://github.com/arkpar/slab.git" }
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
serde = "0.6.7" serde = "0.6.7"
clippy = "0.0.37" clippy = "0.0.41"
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
target_info = "0.1.0" target_info = "0.1.0"
igd = "0.4.2" igd = "0.4.2"

View File

@ -17,7 +17,6 @@
#![feature(test)] #![feature(test)]
extern crate test; extern crate test;
extern crate rand;
extern crate ethcore_util; extern crate ethcore_util;
#[macro_use] #[macro_use]
extern crate log; extern crate log;

View File

@ -74,7 +74,6 @@ impl From<::secp256k1::Error> for CryptoError {
match e { match e {
::secp256k1::Error::InvalidMessage => CryptoError::InvalidMessage, ::secp256k1::Error::InvalidMessage => CryptoError::InvalidMessage,
::secp256k1::Error::InvalidPublicKey => CryptoError::InvalidPublic, ::secp256k1::Error::InvalidPublicKey => CryptoError::InvalidPublic,
::secp256k1::Error::InvalidSignature => CryptoError::InvalidSignature,
::secp256k1::Error::InvalidSecretKey => CryptoError::InvalidSecret, ::secp256k1::Error::InvalidSecretKey => CryptoError::InvalidSecret,
_ => CryptoError::InvalidSignature, _ => CryptoError::InvalidSignature,
} }

View File

@ -290,7 +290,7 @@ macro_rules! impl_hash {
try!(write!(f, "{:02x}", i)); try!(write!(f, "{:02x}", i));
} }
try!(write!(f, "")); try!(write!(f, ""));
for i in &self.0[$size - 4..$size] { for i in &self.0[$size - 2..$size] {
try!(write!(f, "{:02x}", i)); try!(write!(f, "{:02x}", i));
} }
Ok(()) Ok(())
@ -641,7 +641,7 @@ mod tests {
fn hash() { fn hash() {
let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]); let h = H64([0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef]);
assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h); assert_eq!(H64::from_str("0123456789abcdef").unwrap(), h);
assert_eq!(format!("{}", h), "0123…89abcdef"); assert_eq!(format!("{}", h), "0123…cdef");
assert_eq!(format!("{:?}", h), "0123456789abcdef"); assert_eq!(format!("{:?}", h), "0123456789abcdef");
assert_eq!(h.hex(), "0123456789abcdef"); assert_eq!(h.hex(), "0123456789abcdef");
assert!(h == h); assert!(h == h);

View File

@ -335,7 +335,7 @@ impl Session {
let mut rlp = RlpStream::new(); let mut rlp = RlpStream::new();
rlp.append(&(PACKET_DISCONNECT as u32)); rlp.append(&(PACKET_DISCONNECT as u32));
rlp.begin_list(1); rlp.begin_list(1);
rlp.append(&(reason.clone() as u32)); rlp.append(&(reason as u32));
self.connection.send_packet(&rlp.out()).ok(); self.connection.send_packet(&rlp.out()).ok();
NetworkError::Disconnect(reason) NetworkError::Disconnect(reason)
} }

View File

@ -408,7 +408,7 @@ impl Decodable for Vec<u8> {
fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder { fn decode<D>(decoder: &D) -> Result<Self, DecoderError> where D: Decoder {
decoder.read_value(| bytes | { decoder.read_value(| bytes | {
let mut res = vec![]; let mut res = vec![];
res.extend(bytes); res.extend_from_slice(bytes);
Ok(res) Ok(res)
}) })
} }

View File

@ -293,7 +293,7 @@ impl<'a> Iterator for TrieDBIterator<'a> {
fn next(&mut self) -> Option<Self::Item> { fn next(&mut self) -> Option<Self::Item> {
let b = match self.trail.last_mut() { let b = match self.trail.last_mut() {
Some(ref mut b) => { b.increment(); b.clone() }, Some(mut b) => { b.increment(); b.clone() },
None => return None None => return None
}; };
match (b.status, b.node) { match (b.status, b.node) {
@ -309,9 +309,8 @@ impl<'a> Iterator for TrieDBIterator<'a> {
self.trail.pop(); self.trail.pop();
self.next() self.next()
}, },
(Status::At, Node::Leaf(_, v)) => Some((self.key(), v)), (Status::At, Node::Leaf(_, v)) | (Status::At, Node::Branch(_, Some(v))) => Some((self.key(), v)),
(Status::At, Node::Extension(_, d)) => self.descend_next(d), (Status::At, Node::Extension(_, d)) => self.descend_next(d),
(Status::At, Node::Branch(_, Some(v))) => Some((self.key(), v)),
(Status::At, Node::Branch(_, _)) => self.next(), (Status::At, Node::Branch(_, _)) => self.next(),
(Status::AtChild(i), Node::Branch(children, _)) if children[i].len() > 0 => { (Status::AtChild(i), Node::Branch(children, _)) if children[i].len() > 0 => {
match i { match i {