Remove legacy network code (#860)

* expunge legacy code from polkadot-network

* mostly rip out old legacy protocol from service

* ensure validation work is spawned by incoming messages

* decouple availabliity store from network logic; clean up data flow

* av_store: test helpers and use futures-abort

* update polkadot-validation to pass n_validators when submitting chunks

* fallible erasure-chunk fetching

* implement `ErasureNetworking` for new network prot

* API for registering availability store in network

* fully integrate new network service into service

* fix validation tests

* scaffolding for porting collator over to new network

* track connected validators' peer IDs and distribute collators' collations

* helper in network for fetching all checked statements

* fix adder-collator

* actually register notifications protocol

* Update service/src/lib.rs

* merge with master
This commit is contained in:
Robert Habermeier
2020-03-05 10:11:21 -08:00
committed by GitHub
parent b49bf9d5b0
commit 7931380825
19 changed files with 863 additions and 3120 deletions
+20 -16
View File
@@ -369,6 +369,7 @@ impl<Fetch, F, Err> PrimedParachainWork<Fetch, F>
).await?;
self.inner.availability_store.add_erasure_chunks(
candidate,
full_output.n_validators as _,
full_output.erasure_chunks,
).await?;
@@ -593,7 +594,7 @@ mod tests {
BlockData, ErasureChunk, AvailableData,
};
use polkadot_erasure_coding::{self as erasure};
use availability_store::ProvideGossipMessages;
use availability_store::ErasureNetworking;
use futures::future;
use futures::executor::block_on;
use std::pin::Pin;
@@ -605,21 +606,22 @@ mod tests {
}
#[derive(Clone)]
struct DummyGossipMessages;
struct DummyErasureNetworking;
impl ProvideGossipMessages for DummyGossipMessages {
fn gossip_messages_for(
impl ErasureNetworking for DummyErasureNetworking {
type Error = String;
fn fetch_erasure_chunk(
&self,
_topic: Hash
) -> Pin<Box<dyn futures::Stream<Item = (Hash, Hash, ErasureChunk)> + Send>> {
futures::stream::empty().boxed()
_candidate_hash: &Hash,
_index: u32,
) -> Pin<Box<dyn Future<Output = Result<ErasureChunk, Self::Error>> + Send>> {
future::pending().boxed()
}
fn gossip_erasure_chunk(
fn distribute_erasure_chunk(
&self,
_relay_parent: Hash,
_candidate_hash: Hash,
_erasure_root: Hash,
_chunk: ErasureChunk,
) {}
}
@@ -668,7 +670,7 @@ mod tests {
groups,
Some(local_key.clone()),
parent_hash,
AvailabilityStore::new_in_memory(DummyGossipMessages),
AvailabilityStore::new_in_memory(DummyErasureNetworking),
None,
);
@@ -716,7 +718,7 @@ mod tests {
groups,
Some(local_key.clone()),
parent_hash,
AvailabilityStore::new_in_memory(DummyGossipMessages),
AvailabilityStore::new_in_memory(DummyErasureNetworking),
None,
);
@@ -741,7 +743,7 @@ mod tests {
#[test]
fn evaluate_makes_block_data_available() {
let store = AvailabilityStore::new_in_memory(DummyGossipMessages);
let store = AvailabilityStore::new_in_memory(DummyErasureNetworking);
let relay_parent = [0; 32].into();
let para_id = 5.into();
let pov_block = pov_block_with_data(vec![1, 2, 3]);
@@ -789,6 +791,7 @@ mod tests {
proof: vec![],
}).collect(),
commitments: Default::default(),
n_validators,
}
)).validate()).unwrap();
@@ -802,7 +805,7 @@ mod tests {
#[test]
fn full_availability() {
let store = AvailabilityStore::new_in_memory(DummyGossipMessages);
let store = AvailabilityStore::new_in_memory(DummyErasureNetworking);
let relay_parent = [0; 32].into();
let para_id = 5.into();
let pov_block = pov_block_with_data(vec![1, 2, 3]);
@@ -853,6 +856,7 @@ mod tests {
proof: vec![],
}).collect(),
commitments: Default::default(),
n_validators,
}
)).validate()).unwrap();
@@ -886,7 +890,7 @@ mod tests {
groups,
Some(local_key.clone()),
parent_hash,
AvailabilityStore::new_in_memory(DummyGossipMessages),
AvailabilityStore::new_in_memory(DummyErasureNetworking),
None,
);
@@ -945,7 +949,7 @@ mod tests {
groups,
Some(local_key.clone()),
parent_hash,
AvailabilityStore::new_in_memory(DummyGossipMessages),
AvailabilityStore::new_in_memory(DummyErasureNetworking),
None,
);