diff --git a/Cargo.lock b/Cargo.lock index e579a996c..90112d209 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ [root] name = "parity" -version = "1.4.5" +version = "1.4.6" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.96 (registry+https://github.com/rust-lang/crates.io-index)", @@ -21,7 +21,7 @@ dependencies = [ "ethcore-rpc 1.4.0", "ethcore-signer 1.4.0", "ethcore-stratum 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "ethsync 1.4.0", "fdlimit 0.1.0", "hyper 0.9.10 (registry+https://github.com/rust-lang/crates.io-index)", @@ -289,7 +289,7 @@ dependencies = [ "ethcore-ipc 1.4.0", "ethcore-ipc-codegen 1.4.0", "ethcore-ipc-nano 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "ethjson 0.1.0", "ethkey 0.2.0", "ethstore 0.1.0", @@ -336,7 +336,7 @@ dependencies = [ "ethabi 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-rpc 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "fetch 0.1.0", "hyper 0.9.4 (git+https://github.com/ethcore/hyper)", "jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -381,7 +381,7 @@ name = "ethcore-ipc" version = "1.4.0" dependencies = [ "ethcore-devtools 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -428,7 +428,7 @@ dependencies = [ "ethcore-ipc 1.4.0", "ethcore-ipc-codegen 1.4.0", "ethcore-ipc-nano 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "nanomsg 0.5.1 (git+https://github.com/ethcore/nanomsg.rs.git)", "semver 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -439,7 +439,7 @@ name = "ethcore-logger" version = "1.4.0" dependencies = [ "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "isatty 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -455,7 +455,7 @@ dependencies = [ "bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "ethcrypto 0.1.0", "ethkey 0.2.0", "igd 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -482,7 +482,7 @@ dependencies = [ "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", "ethcore-ipc 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "ethcrypto 0.1.0", "ethjson 0.1.0", "ethkey 0.2.0", @@ -511,7 +511,7 @@ dependencies = [ "ethcore-devtools 1.4.0", "ethcore-io 1.4.0", "ethcore-rpc 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parity-dapps-glue 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -530,7 +530,7 @@ dependencies = [ "ethcore-ipc 1.4.0", "ethcore-ipc-codegen 1.4.0", "ethcore-ipc-nano 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "json-tcp-server 0.1.0 (git+https://github.com/ethcore/json-tcp-server)", "jsonrpc-core 3.0.2 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -541,7 +541,7 @@ dependencies = [ [[package]] name = "ethcore-util" -version = "1.4.5" +version = "1.4.6" dependencies = [ "ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "arrayvec 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", @@ -590,7 +590,7 @@ dependencies = [ name = "ethjson" version = "0.1.0" dependencies = [ - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)", "serde 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", "serde_codegen 0.8.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -643,7 +643,7 @@ dependencies = [ "ethcore-ipc-codegen 1.4.0", "ethcore-ipc-nano 1.4.0", "ethcore-network 1.4.0", - "ethcore-util 1.4.5", + "ethcore-util 1.4.6", "heapsize 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index 3e8277d8d..4b11484de 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] description = "Ethcore client." name = "parity" -version = "1.4.5" +version = "1.4.6" license = "GPL-3.0" authors = ["Ethcore "] build = "build.rs" diff --git a/mac/Parity.pkgproj b/mac/Parity.pkgproj index 7746139a1..43e29565b 100755 --- a/mac/Parity.pkgproj +++ b/mac/Parity.pkgproj @@ -578,7 +578,7 @@ OVERWRITE_PERMISSIONS VERSION - 1.4.5 + 1.4.6 UUID 2DCD5B81-7BAF-4DA1-9251-6274B089FD36 diff --git a/nsis/installer.nsi b/nsis/installer.nsi index 4372213e3..647ffe6c4 100644 --- a/nsis/installer.nsi +++ b/nsis/installer.nsi @@ -10,7 +10,7 @@ !define DESCRIPTION "Fast, light, robust Ethereum implementation" !define VERSIONMAJOR 1 !define VERSIONMINOR 4 -!define VERSIONBUILD 5 +!define VERSIONBUILD 6 !define ARGS "--warp" !define FIRST_START_ARGS "ui --warp --mode=passive" diff --git a/sync/src/block_sync.rs b/sync/src/block_sync.rs index ff5411140..eea977906 100644 --- a/sync/src/block_sync.rs +++ b/sync/src/block_sync.rs @@ -258,6 +258,12 @@ impl BlockDownloader { self.blocks.reset_to(hashes); self.state = State::Blocks; return Ok(DownloadAction::Reset); + } else { + let best = io.chain().chain_info().best_block_number; + if best > self.last_imported_block && best - self.last_imported_block > MAX_REORG_BLOCKS { + trace!(target: "sync", "No common block, disabling peer"); + return Err(BlockDownloaderImportError::Invalid); + } } }, State::Blocks => { diff --git a/sync/src/tests/chain.rs b/sync/src/tests/chain.rs index 5fe34428e..7705215f5 100644 --- a/sync/src/tests/chain.rs +++ b/sync/src/tests/chain.rs @@ -250,3 +250,14 @@ fn high_td_attach() { assert_eq!(net.peer(0).chain.chain_info().best_block_number, 5); } + +#[test] +fn disconnect_on_unrelated_chain() { + ::env_logger::init().ok(); + let mut net = TestNet::new(2); + net.peer_mut(0).chain.add_blocks(200, EachBlockWith::Uncle); + net.peer_mut(1).chain.add_blocks(100, EachBlockWith::Nothing); + net.sync(); + assert_eq!(net.disconnect_events, vec![(0, 0)]); +} + diff --git a/sync/src/tests/helpers.rs b/sync/src/tests/helpers.rs index d5e07a936..b1c04f84e 100644 --- a/sync/src/tests/helpers.rs +++ b/sync/src/tests/helpers.rs @@ -123,6 +123,7 @@ pub struct TestPeer { pub struct TestNet { pub peers: Vec, pub started: bool, + pub disconnect_events: Vec<(PeerId, PeerId)>, //disconnected (initiated by, to) } impl TestNet { @@ -140,6 +141,7 @@ impl TestNet { let mut net = TestNet { peers: Vec::new(), started: false, + disconnect_events: Vec::new(), }; for _ in 0..n { let chain = TestBlockChainClient::new(); @@ -190,6 +192,7 @@ impl TestNet { // notify this that disconnecting peers are disconnecting let mut io = TestIo::new(&mut p.chain, &p.snapshot_service, &mut p.queue, Some(*d)); p.sync.write().on_peer_aborting(&mut io, *d); + self.disconnect_events.push((peer, *d)); } to_disconnect }; diff --git a/util/Cargo.toml b/util/Cargo.toml index f8e5a0f59..aa9cf4610 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -3,7 +3,7 @@ description = "Ethcore utility library" homepage = "http://ethcore.io" license = "GPL-3.0" name = "ethcore-util" -version = "1.4.5" +version = "1.4.6" authors = ["Ethcore "] build = "build.rs"