Merge branch 'master' into sfedgecase

This commit is contained in:
Gav Wood 2016-06-23 14:43:42 +02:00
commit bca9e1f31a
17 changed files with 48 additions and 32 deletions

20
Cargo.lock generated
View File

@ -3,7 +3,7 @@ name = "parity"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)", "docopt 0.6.80 (registry+https://github.com/rust-lang/crates.io-index)",
@ -129,15 +129,15 @@ dependencies = [
[[package]] [[package]]
name = "clippy" name = "clippy"
version = "0.0.76" version = "0.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"clippy_lints 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy_lints 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]] [[package]]
name = "clippy_lints" name = "clippy_lints"
version = "0.0.76" version = "0.0.77"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -250,7 +250,7 @@ name = "ethcore"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "bloomchain 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
@ -275,7 +275,7 @@ dependencies = [
name = "ethcore-dapps" name = "ethcore-dapps"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
"hyper 0.9.3 (git+https://github.com/ethcore/hyper)", "hyper 0.9.3 (git+https://github.com/ethcore/hyper)",
@ -337,7 +337,7 @@ dependencies = [
name = "ethcore-rpc" name = "ethcore-rpc"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"ethash 1.2.0", "ethash 1.2.0",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-devtools 1.2.0", "ethcore-devtools 1.2.0",
@ -360,7 +360,7 @@ dependencies = [
name = "ethcore-signer" name = "ethcore-signer"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore-rpc 1.2.0", "ethcore-rpc 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",
@ -379,7 +379,7 @@ dependencies = [
"arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
"bigint 0.1.0", "bigint 0.1.0",
"chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", "chrono 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "crossbeam 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
"elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "elastic-array 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
@ -451,7 +451,7 @@ dependencies = [
name = "ethsync" name = "ethsync"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"clippy 0.0.76 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.77 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"ethcore 1.2.0", "ethcore 1.2.0",
"ethcore-util 1.2.0", "ethcore-util 1.2.0",

View File

@ -22,7 +22,7 @@ fdlimit = { path = "util/fdlimit" }
num_cpus = "0.2" num_cpus = "0.2"
number_prefix = "0.2" number_prefix = "0.2"
rpassword = "0.2.1" rpassword = "0.2.1"
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
ethcore = { path = "ethcore" } ethcore = { path = "ethcore" }
ethcore-util = { path = "util" } ethcore-util = { path = "util" }
ethsync = { path = "sync" } ethsync = { path = "sync" }

View File

@ -28,7 +28,7 @@ parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true } parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true }
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true } parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true }
mime_guess = { version = "1.6.1" } mime_guess = { version = "1.6.1" }
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -12,7 +12,7 @@ syntex = "*"
ethcore-ipc-codegen = { path = "../ipc/codegen" } ethcore-ipc-codegen = { path = "../ipc/codegen" }
[dependencies] [dependencies]
clippy = { version = "0.0.67", optional = true} clippy = { version = "0.0.77", optional = true}
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }
ethcore-ipc = { path = "../ipc/rpc" } ethcore-ipc = { path = "../ipc/rpc" }
rocksdb = { git = "https://github.com/ethcore/rust-rocksdb" } rocksdb = { git = "https://github.com/ethcore/rust-rocksdb" }

View File

@ -22,7 +22,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 = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
crossbeam = "0.2.9" crossbeam = "0.2.9"
lazy_static = "0.2" lazy_static = "0.2"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -490,6 +490,7 @@ pub fn enact(
} }
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
#[cfg_attr(feature="dev", allow(too_many_arguments))]
pub fn enact_bytes( pub fn enact_bytes(
block_bytes: &[u8], block_bytes: &[u8],
engine: &Engine, engine: &Engine,
@ -506,6 +507,7 @@ pub fn enact_bytes(
} }
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header
#[cfg_attr(feature="dev", allow(too_many_arguments))]
pub fn enact_verified( pub fn enact_verified(
block: &PreverifiedBlock, block: &PreverifiedBlock,
engine: &Engine, engine: &Engine,
@ -521,6 +523,7 @@ pub fn enact_verified(
} }
/// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards /// Enact the block given by `block_bytes` using `engine` on the database `db` with given `parent` block header. Seal the block aferwards
#[cfg_attr(feature="dev", allow(too_many_arguments))]
pub fn enact_and_seal( pub fn enact_and_seal(
block_bytes: &[u8], block_bytes: &[u8],
engine: &Engine, engine: &Engine,

View File

@ -228,7 +228,7 @@ pub enum Error {
/// The value of the nonce or mishash is invalid. /// The value of the nonce or mishash is invalid.
PowInvalid, PowInvalid,
/// Error concerning TrieDBs /// Error concerning TrieDBs
TrieError(TrieError), Trie(TrieError),
} }
impl fmt::Display for Error { impl fmt::Display for Error {
@ -244,7 +244,7 @@ impl fmt::Display for Error {
f.write_fmt(format_args!("Unknown engine name ({})", name)), f.write_fmt(format_args!("Unknown engine name ({})", name)),
Error::PowHashInvalid => f.write_str("Invalid or out of date PoW hash."), Error::PowHashInvalid => f.write_str("Invalid or out of date PoW hash."),
Error::PowInvalid => f.write_str("Invalid nonce or mishash"), Error::PowInvalid => f.write_str("Invalid nonce or mishash"),
Error::TrieError(ref err) => f.write_fmt(format_args!("{}", err)), Error::Trie(ref err) => f.write_fmt(format_args!("{}", err)),
} }
} }
} }
@ -308,7 +308,7 @@ impl From<IoError> for Error {
impl From<TrieError> for Error { impl From<TrieError> for Error {
fn from(err: TrieError) -> Error { fn from(err: TrieError) -> Error {
Error::TrieError(err) Error::Trie(err)
} }
} }

View File

@ -106,7 +106,7 @@ impl Engine for Ethash {
} else { } else {
let mut s = Schedule::new_homestead(); let mut s = Schedule::new_homestead();
if self.ethash_params.dao_rescue_soft_fork { if self.ethash_params.dao_rescue_soft_fork {
s.reject_dao_transactions = env_info.dao_rescue_block_gas_limit.map(|x| x <= 4_000_000.into()).unwrap_or(false); s.reject_dao_transactions = env_info.dao_rescue_block_gas_limit.map_or(false, |x| x <= 4_000_000.into());
} }
s s
} }

View File

@ -239,6 +239,7 @@ impl TransactionSet {
if let Some(ref old_order) = r { if let Some(ref old_order) = r {
self.by_priority.remove(old_order); self.by_priority.remove(old_order);
} }
assert_eq!(self.by_priority.len(), self.by_address.len());
r r
} }
@ -279,8 +280,10 @@ impl TransactionSet {
fn drop(&mut self, sender: &Address, nonce: &U256) -> Option<TransactionOrder> { fn drop(&mut self, sender: &Address, nonce: &U256) -> Option<TransactionOrder> {
if let Some(tx_order) = self.by_address.remove(sender, nonce) { if let Some(tx_order) = self.by_address.remove(sender, nonce) {
self.by_priority.remove(&tx_order); self.by_priority.remove(&tx_order);
assert_eq!(self.by_priority.len(), self.by_address.len());
return Some(tx_order); return Some(tx_order);
} }
assert_eq!(self.by_priority.len(), self.by_address.len());
None None
} }
@ -468,7 +471,9 @@ impl TransactionQueue {
})); }));
} }
self.import_tx(vtx, client_account.nonce).map_err(Error::Transaction) let r = self.import_tx(vtx, client_account.nonce).map_err(Error::Transaction);
assert_eq!(self.future.by_priority.len() + self.current.by_priority.len(), self.by_hash.len());
r
} }
/// Removes all transactions from particular sender up to (excluding) given client (state) nonce. /// Removes all transactions from particular sender up to (excluding) given client (state) nonce.
@ -484,6 +489,7 @@ impl TransactionQueue {
// And now lets check if there is some batch of transactions in future // And now lets check if there is some batch of transactions in future
// that should be placed in current. It should also update last_nonces. // that should be placed in current. It should also update last_nonces.
self.move_matching_future_to_current(sender, client_nonce, client_nonce); self.move_matching_future_to_current(sender, client_nonce, client_nonce);
assert_eq!(self.future.by_priority.len() + self.current.by_priority.len(), self.by_hash.len());
} }
/// Removes invalid transaction identified by hash from queue. /// Removes invalid transaction identified by hash from queue.
@ -493,6 +499,8 @@ impl TransactionQueue {
/// If gap is introduced marks subsequent transactions as future /// If gap is introduced marks subsequent transactions as future
pub fn remove_invalid<T>(&mut self, transaction_hash: &H256, fetch_account: &T) pub fn remove_invalid<T>(&mut self, transaction_hash: &H256, fetch_account: &T)
where T: Fn(&Address) -> AccountDetails { where T: Fn(&Address) -> AccountDetails {
assert_eq!(self.future.by_priority.len() + self.current.by_priority.len(), self.by_hash.len());
let transaction = self.by_hash.remove(transaction_hash); let transaction = self.by_hash.remove(transaction_hash);
if transaction.is_none() { if transaction.is_none() {
// We don't know this transaction // We don't know this transaction
@ -511,6 +519,7 @@ impl TransactionQueue {
// And now lets check if there is some chain of transactions in future // And now lets check if there is some chain of transactions in future
// that should be placed in current // that should be placed in current
self.move_matching_future_to_current(sender, current_nonce, current_nonce); self.move_matching_future_to_current(sender, current_nonce, current_nonce);
assert_eq!(self.future.by_priority.len() + self.current.by_priority.len(), self.by_hash.len());
return; return;
} }
@ -520,6 +529,7 @@ impl TransactionQueue {
// This will keep consistency in queue // This will keep consistency in queue
// Moves all to future and then promotes a batch from current: // Moves all to future and then promotes a batch from current:
self.remove_all(sender, current_nonce); self.remove_all(sender, current_nonce);
assert_eq!(self.future.by_priority.len() + self.current.by_priority.len(), self.by_hash.len());
return; return;
} }
} }
@ -538,7 +548,7 @@ impl TransactionQueue {
} else { } else {
trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce); trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce);
// Remove the transaction completely // Remove the transaction completely
self.by_hash.remove(&order.hash); self.by_hash.remove(&order.hash).expect("All transactions in `future` are also in `by_hash`");
} }
} }
} }
@ -558,7 +568,7 @@ impl TransactionQueue {
self.future.insert(*sender, k, order.update_height(k, current_nonce)); self.future.insert(*sender, k, order.update_height(k, current_nonce));
} else { } else {
trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce); trace!(target: "miner", "Removing old transaction: {:?} (nonce: {} < {})", order.hash, k, current_nonce);
self.by_hash.remove(&order.hash); self.by_hash.remove(&order.hash).expect("All transactions in `future` are also in `by_hash`");
} }
} }
self.future.enforce_limit(&mut self.by_hash); self.future.enforce_limit(&mut self.by_hash);
@ -686,7 +696,7 @@ impl TransactionQueue {
// same (sender, nonce), but above function would not move it. // same (sender, nonce), but above function would not move it.
if let Some(order) = self.future.drop(&address, &nonce) { if let Some(order) = self.future.drop(&address, &nonce) {
// Let's insert that transaction to current (if it has higher gas_price) // Let's insert that transaction to current (if it has higher gas_price)
let future_tx = self.by_hash.remove(&order.hash).unwrap(); let future_tx = self.by_hash.remove(&order.hash).expect("All transactions in `future` are always in `by_hash`.");
// if transaction in `current` (then one we are importing) is replaced it means that it has to low gas_price // if transaction in `current` (then one we are importing) is replaced it means that it has to low gas_price
try!(check_too_cheap(!Self::replace_transaction(future_tx, state_nonce, &mut self.current, &mut self.by_hash))); try!(check_too_cheap(!Self::replace_transaction(future_tx, state_nonce, &mut self.current, &mut self.by_hash)));
} }
@ -728,7 +738,9 @@ impl TransactionQueue {
let address = tx.sender(); let address = tx.sender();
let nonce = tx.nonce(); let nonce = tx.nonce();
by_hash.insert(hash, tx); let old_hash = by_hash.insert(hash, tx);
assert!(old_hash.is_none(), "Each hash has to be inserted exactly once.");
if let Some(old) = set.insert(address, nonce, order.clone()) { if let Some(old) = set.insert(address, nonce, order.clone()) {
// There was already transaction in queue. Let's check which one should stay // There was already transaction in queue. Let's check which one should stay
@ -738,11 +750,11 @@ impl TransactionQueue {
// Put back old transaction since it has greater priority (higher gas_price) // Put back old transaction since it has greater priority (higher gas_price)
set.insert(address, nonce, old); set.insert(address, nonce, old);
// and remove new one // and remove new one
by_hash.remove(&hash); by_hash.remove(&hash).expect("The hash has been just inserted and no other line is altering `by_hash`.");
false false
} else { } else {
// Make sure we remove old transaction entirely // Make sure we remove old transaction entirely
by_hash.remove(&old.hash); by_hash.remove(&old.hash).expect("The hash is coming from `future` so it has to be in `by_hash`.");
true true
} }
} else { } else {

View File

@ -10,7 +10,7 @@ rustc-serialize = "0.3"
serde = "0.7.0" serde = "0.7.0"
serde_json = "0.7.0" serde_json = "0.7.0"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
[build-dependencies] [build-dependencies]
serde_codegen = { version = "0.7.0", optional = true } serde_codegen = { version = "0.7.0", optional = true }

View File

@ -547,7 +547,7 @@ fn execute_account_cli(conf: Configuration) {
} }
fn execute_wallet_cli(conf: Configuration) { fn execute_wallet_cli(conf: Configuration) {
use ethcore::ethstore::{PresaleWallet, SecretStore, EthStore}; use ethcore::ethstore::{PresaleWallet, EthStore};
use ethcore::ethstore::dir::DiskDirectory; use ethcore::ethstore::dir::DiskDirectory;
use ethcore::account_provider::AccountProvider; use ethcore::account_provider::AccountProvider;

View File

@ -23,7 +23,7 @@ ethcore-devtools = { path = "../devtools" }
rustc-serialize = "0.3" rustc-serialize = "0.3"
transient-hashmap = "0.1" transient-hashmap = "0.1"
serde_macros = { version = "0.7.0", optional = true } serde_macros = { version = "0.7.0", optional = true }
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
[build-dependencies] [build-dependencies]

View File

@ -20,7 +20,7 @@ ethcore-util = { path = "../util" }
ethcore-rpc = { path = "../rpc" } ethcore-rpc = { path = "../rpc" }
parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" } parity-minimal-sysui = { git = "https://github.com/ethcore/parity-dapps-minimal-sysui-rs.git" }
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
[features] [features]
dev = ["clippy"] dev = ["clippy"]

View File

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

View File

@ -946,7 +946,7 @@ impl ChainSync {
let tx = try!(r.at(i)).as_raw().to_vec(); let tx = try!(r.at(i)).as_raw().to_vec();
transactions.push(tx); transactions.push(tx);
} }
let _ = io.chain().queue_transactions(transactions); io.chain().queue_transactions(transactions);
Ok(()) Ok(())
} }

View File

@ -28,7 +28,7 @@ crossbeam = "0.2"
slab = "0.2" slab = "0.2"
sha3 = { path = "sha3" } sha3 = { path = "sha3" }
serde = "0.7.0" serde = "0.7.0"
clippy = { version = "0.0.76", optional = true} clippy = { version = "0.0.77", optional = true}
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
igd = "0.4.2" igd = "0.4.2"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }

View File

@ -735,6 +735,7 @@ impl<Message> Host<Message> where Message: Send + Sync + Clone {
self.kill_connection(token, io, true); self.kill_connection(token, io, true);
} }
#[cfg_attr(feature="dev", allow(collapsible_if))]
fn session_readable(&self, token: StreamToken, io: &IoContext<NetworkIoMessage<Message>>) { fn session_readable(&self, token: StreamToken, io: &IoContext<NetworkIoMessage<Message>>) {
let mut ready_data: Vec<ProtocolId> = Vec::new(); let mut ready_data: Vec<ProtocolId> = Vec::new();
let mut packet_data: Vec<(ProtocolId, PacketId, Vec<u8>)> = Vec::new(); let mut packet_data: Vec<(ProtocolId, PacketId, Vec<u8>)> = Vec::new();