Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Backporting to beta (#3718)
Browse files Browse the repository at this point in the history
* Disaable peer if no common block found

* v1.4.6
  • Loading branch information
arkpar authored Dec 5, 2016
1 parent 38bd0aa commit 5feccf1
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 18 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
description = "Ethcore client."
name = "parity"
version = "1.4.5"
version = "1.4.6"
license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io>"]
build = "build.rs"
Expand Down
2 changes: 1 addition & 1 deletion mac/Parity.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@
<key>OVERWRITE_PERMISSIONS</key>
<false/>
<key>VERSION</key>
<string>1.4.5</string>
<string>1.4.6</string>
</dict>
<key>UUID</key>
<string>2DCD5B81-7BAF-4DA1-9251-6274B089FD36</string>
Expand Down
2 changes: 1 addition & 1 deletion nsis/installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 6 additions & 0 deletions sync/src/block_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
11 changes: 11 additions & 0 deletions sync/src/tests/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]);
}

3 changes: 3 additions & 0 deletions sync/src/tests/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub struct TestPeer {
pub struct TestNet {
pub peers: Vec<TestPeer>,
pub started: bool,
pub disconnect_events: Vec<(PeerId, PeerId)>, //disconnected (initiated by, to)
}

impl TestNet {
Expand All @@ -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();
Expand Down Expand Up @@ -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
};
Expand Down
2 changes: 1 addition & 1 deletion util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <admin@ethcore.io>"]
build = "build.rs"

Expand Down

0 comments on commit 5feccf1

Please sign in to comment.