diff --git a/ethcore/res/parity-import-tests b/ethcore/res/parity-import-tests new file mode 160000 index 00000000000..c5fd3862aa7 --- /dev/null +++ b/ethcore/res/parity-import-tests @@ -0,0 +1 @@ +Subproject commit c5fd3862aa7902a202d5054e0124981e8e12f4ab diff --git a/ethcore/src/snapshot/service.rs b/ethcore/src/snapshot/service.rs index fd4c2cc1ee8..25fa28b5d5c 100644 --- a/ethcore/src/snapshot/service.rs +++ b/ethcore/src/snapshot/service.rs @@ -558,9 +558,9 @@ impl SnapshotService for Service { self.reader.read().as_ref().map(|r| r.manifest().clone()) } - fn min_supported_version(&self) -> Option { + fn supported_versions(&self) -> Option<(u64, u64)> { self.engine.snapshot_components() - .map(|c| c.min_supported_version()) + .map(|c| (c.min_supported_version(), c.current_version())) } fn chunk(&self, hash: H256) -> Option { diff --git a/ethcore/src/snapshot/snapshot_service_trait.rs b/ethcore/src/snapshot/snapshot_service_trait.rs index e57b39da1ae..9df36625070 100644 --- a/ethcore/src/snapshot/snapshot_service_trait.rs +++ b/ethcore/src/snapshot/snapshot_service_trait.rs @@ -27,9 +27,9 @@ pub trait SnapshotService : Sync + Send { /// Query the most recent manifest data. fn manifest(&self) -> Option; - /// Get the minimum supported snapshot version number. + /// Get the supported range of snapshot version numbers. /// `None` indicates warp sync isn't supported by the consensus engine. - fn min_supported_version(&self) -> Option; + fn supported_versions(&self) -> Option<(u64, u64)>; /// Get raw chunk for a given hash. fn chunk(&self, hash: H256) -> Option; diff --git a/sync/src/chain.rs b/sync/src/chain.rs index 1b31f91696c..b3ca25328c8 100644 --- a/sync/src/chain.rs +++ b/sync/src/chain.rs @@ -504,7 +504,7 @@ impl ChainSync { } fn maybe_start_snapshot_sync(&mut self, io: &mut SyncIo) { - if !self.enable_warp_sync || io.snapshot_service().min_supported_version().is_none() { + if !self.enable_warp_sync || io.snapshot_service().supported_versions().is_none() { return; } if self.state != SyncState::WaitingPeers && self.state != SyncState::Blocks && self.state != SyncState::Waiting { @@ -1044,11 +1044,11 @@ impl ChainSync { Ok(manifest) => manifest, }; - let is_supported_version = io.snapshot_service().min_supported_version() - .map_or(false, |v| manifest.version >= v); + let is_supported_version = io.snapshot_service().supported_versions() + .map_or(false, |(l, h)| manifest.version >= l && manifest.version <= h); if !is_supported_version { - trace!(target: "sync", "{}: Snapshot manifest version too low: {}", peer_id, manifest.version); + trace!(target: "sync", "{}: Snapshot manifest version not supported: {}", peer_id, manifest.version); io.disable_peer(peer_id); self.continue_sync(io); return Ok(());