Commit 6088360f authored by Andrew Jones's avatar Andrew Jones Committed by asynchronous rob
Browse files

Rename polkadot-consensus -> polkadot-validation (#151)

* Initial rename of consensus -> validation

* Rename crate imports

* network: rename consensus to validation

* network: rename consensus in comments and logs

* Grumbles

* Rename tests consensus -> validation
parent f0d8daf1
Pipeline #31383 passed with stages
in 15 minutes and 37 seconds
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
.wasm-binaries .wasm-binaries
polkadot/runtime/wasm/target/ polkadot/runtime/wasm/target/
**/._* **/._*
.idea
.vscode .vscode
polkadot.* polkadot.*
.DS_Store .DS_Store
...@@ -2204,35 +2204,6 @@ dependencies = [ ...@@ -2204,35 +2204,6 @@ dependencies = [
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", "tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "polkadot-consensus"
version = "0.1.0"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-availability-store 0.1.0",
"polkadot-parachain 0.1.0",
"polkadot-primitives 0.1.0",
"polkadot-runtime 0.1.0",
"polkadot-statement-table 0.1.0",
"sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"srml-aura 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-client 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-consensus-aura 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-consensus-common 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-finality-grandpa 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-inherents 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-keyring 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-transaction-pool 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-trie 0.4.0 (git+https://github.com/paritytech/substrate)",
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "polkadot-erasure-coding" name = "polkadot-erasure-coding"
version = "0.1.0" version = "0.1.0"
...@@ -2264,8 +2235,8 @@ dependencies = [ ...@@ -2264,8 +2235,8 @@ dependencies = [
"parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "parity-codec-derive 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-availability-store 0.1.0", "polkadot-availability-store 0.1.0",
"polkadot-consensus 0.1.0",
"polkadot-primitives 0.1.0", "polkadot-primitives 0.1.0",
"polkadot-validation 0.1.0",
"slice-group-by 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "slice-group-by 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)", "sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-client 0.1.0 (git+https://github.com/paritytech/substrate)", "substrate-client 0.1.0 (git+https://github.com/paritytech/substrate)",
...@@ -2361,11 +2332,11 @@ dependencies = [ ...@@ -2361,11 +2332,11 @@ dependencies = [
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-availability-store 0.1.0", "polkadot-availability-store 0.1.0",
"polkadot-consensus 0.1.0",
"polkadot-executor 0.1.0", "polkadot-executor 0.1.0",
"polkadot-network 0.1.0", "polkadot-network 0.1.0",
"polkadot-primitives 0.1.0", "polkadot-primitives 0.1.0",
"polkadot-runtime 0.1.0", "polkadot-runtime 0.1.0",
"polkadot-validation 0.1.0",
"slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "slog 2.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"sr-io 0.1.0 (git+https://github.com/paritytech/substrate)", "sr-io 0.1.0 (git+https://github.com/paritytech/substrate)",
"sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)", "sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
...@@ -2390,6 +2361,35 @@ dependencies = [ ...@@ -2390,6 +2361,35 @@ dependencies = [
"substrate-primitives 0.1.0 (git+https://github.com/paritytech/substrate)", "substrate-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
] ]
[[package]]
name = "polkadot-validation"
version = "0.1.0"
dependencies = [
"error-chain 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)",
"exit-future 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.25 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"parity-codec 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
"parking_lot 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)",
"polkadot-availability-store 0.1.0",
"polkadot-parachain 0.1.0",
"polkadot-primitives 0.1.0",
"polkadot-runtime 0.1.0",
"polkadot-statement-table 0.1.0",
"sr-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"srml-aura 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-client 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-consensus-aura 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-consensus-common 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-finality-grandpa 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-inherents 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-keyring 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-primitives 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-transaction-pool 0.1.0 (git+https://github.com/paritytech/substrate)",
"substrate-trie 0.4.0 (git+https://github.com/paritytech/substrate)",
"tokio 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "pretty_assertions" name = "pretty_assertions"
version = "0.5.1" version = "0.5.1"
......
...@@ -22,7 +22,6 @@ members = [ ...@@ -22,7 +22,6 @@ members = [
"availability-store", "availability-store",
"cli", "cli",
"collator", "collator",
"consensus",
"erasure-coding", "erasure-coding",
"executor", "executor",
"network", "network",
...@@ -31,6 +30,7 @@ members = [ ...@@ -31,6 +30,7 @@ members = [
"service", "service",
"statement-table", "statement-table",
"service", "service",
"validation",
"test-parachains/adder", "test-parachains/adder",
"test-parachains/adder/collator", "test-parachains/adder/collator",
......
...@@ -8,7 +8,7 @@ description = "Polkadot-specific networking protocol" ...@@ -8,7 +8,7 @@ description = "Polkadot-specific networking protocol"
arrayvec = "0.4" arrayvec = "0.4"
parking_lot = "0.7.1" parking_lot = "0.7.1"
polkadot-availability-store = { path = "../availability-store" } polkadot-availability-store = { path = "../availability-store" }
polkadot-consensus = { path = "../consensus" } polkadot-validation = { path = "../validation" }
polkadot-primitives = { path = "../primitives" } polkadot-primitives = { path = "../primitives" }
parity-codec = "3.0" parity-codec = "3.0"
parity-codec-derive = "3.0" parity-codec-derive = "3.0"
......
...@@ -24,7 +24,7 @@ extern crate substrate_network; ...@@ -24,7 +24,7 @@ extern crate substrate_network;
extern crate substrate_primitives; extern crate substrate_primitives;
extern crate sr_primitives; extern crate sr_primitives;
extern crate polkadot_consensus; extern crate polkadot_validation;
extern crate polkadot_availability_store as av_store; extern crate polkadot_availability_store as av_store;
extern crate polkadot_primitives; extern crate polkadot_primitives;
...@@ -49,7 +49,7 @@ extern crate substrate_keyring; ...@@ -49,7 +49,7 @@ extern crate substrate_keyring;
mod collator_pool; mod collator_pool;
mod local_collations; mod local_collations;
mod router; mod router;
pub mod consensus; pub mod validation;
use codec::{Decode, Encode}; use codec::{Decode, Encode};
use futures::sync::oneshot; use futures::sync::oneshot;
...@@ -59,7 +59,7 @@ use substrate_network::{NodeIndex, RequestId, Context, Severity}; ...@@ -59,7 +59,7 @@ use substrate_network::{NodeIndex, RequestId, Context, Severity};
use substrate_network::{message, generic_message}; use substrate_network::{message, generic_message};
use substrate_network::specialization::NetworkSpecialization as Specialization; use substrate_network::specialization::NetworkSpecialization as Specialization;
use substrate_network::StatusMessage as GenericFullStatus; use substrate_network::StatusMessage as GenericFullStatus;
use self::consensus::{LiveConsensusInstances, RecentSessionKeys, InsertedRecentKey}; use self::validation::{LiveValidationSessions, RecentSessionKeys, InsertedRecentKey};
use self::collator_pool::{CollatorPool, Role, Action}; use self::collator_pool::{CollatorPool, Role, Action};
use self::local_collations::LocalCollations; use self::local_collations::LocalCollations;
...@@ -85,7 +85,7 @@ pub struct Status { ...@@ -85,7 +85,7 @@ pub struct Status {
struct BlockDataRequest { struct BlockDataRequest {
attempted_peers: HashSet<SessionKey>, attempted_peers: HashSet<SessionKey>,
consensus_parent: Hash, validation_session_parent: Hash,
candidate_hash: Hash, candidate_hash: Hash,
block_data_hash: Hash, block_data_hash: Hash,
sender: oneshot::Sender<BlockData>, sender: oneshot::Sender<BlockData>,
...@@ -168,7 +168,7 @@ pub struct PolkadotProtocol { ...@@ -168,7 +168,7 @@ pub struct PolkadotProtocol {
collators: CollatorPool, collators: CollatorPool,
validators: HashMap<SessionKey, NodeIndex>, validators: HashMap<SessionKey, NodeIndex>,
local_collations: LocalCollations<Collation>, local_collations: LocalCollations<Collation>,
live_consensus: LiveConsensusInstances, live_validation_sessions: LiveValidationSessions,
in_flight: HashMap<(RequestId, NodeIndex), BlockDataRequest>, in_flight: HashMap<(RequestId, NodeIndex), BlockDataRequest>,
pending: Vec<BlockDataRequest>, pending: Vec<BlockDataRequest>,
extrinsic_store: Option<::av_store::Store>, extrinsic_store: Option<::av_store::Store>,
...@@ -184,7 +184,7 @@ impl PolkadotProtocol { ...@@ -184,7 +184,7 @@ impl PolkadotProtocol {
collating_for, collating_for,
validators: HashMap::new(), validators: HashMap::new(),
local_collations: LocalCollations::new(), local_collations: LocalCollations::new(),
live_consensus: LiveConsensusInstances::new(), live_validation_sessions: LiveValidationSessions::new(),
in_flight: HashMap::new(), in_flight: HashMap::new(),
pending: Vec::new(), pending: Vec::new(),
extrinsic_store: None, extrinsic_store: None,
...@@ -198,7 +198,7 @@ impl PolkadotProtocol { ...@@ -198,7 +198,7 @@ impl PolkadotProtocol {
self.pending.push(BlockDataRequest { self.pending.push(BlockDataRequest {
attempted_peers: Default::default(), attempted_peers: Default::default(),
consensus_parent: relay_parent, validation_session_parent: relay_parent,
candidate_hash: candidate.hash(), candidate_hash: candidate.hash(),
block_data_hash: candidate.block_data_hash, block_data_hash: candidate.block_data_hash,
sender: tx, sender: tx,
...@@ -208,14 +208,14 @@ impl PolkadotProtocol { ...@@ -208,14 +208,14 @@ impl PolkadotProtocol {
rx rx
} }
/// Note new consensus session. /// Note new validation session.
fn new_consensus( fn new_validation_session(
&mut self, &mut self,
ctx: &mut Context<Block>, ctx: &mut Context<Block>,
parent_hash: Hash, parent_hash: Hash,
consensus: consensus::CurrentConsensus, session: validation::ValidationSession,
) { ) {
if let Some(new_local) = self.live_consensus.new_consensus(parent_hash, consensus) { if let Some(new_local) = self.live_validation_sessions.new_validation_session(parent_hash, session) {
for (id, peer_data) in self.peers.iter_mut() for (id, peer_data) in self.peers.iter_mut()
.filter(|&(_, ref info)| info.should_send_key()) .filter(|&(_, ref info)| info.should_send_key())
{ {
...@@ -228,8 +228,8 @@ impl PolkadotProtocol { ...@@ -228,8 +228,8 @@ impl PolkadotProtocol {
} }
} }
fn remove_consensus(&mut self, parent_hash: &Hash) { fn remove_validation_session(&mut self, parent_hash: &Hash) {
self.live_consensus.remove(parent_hash); self.live_validation_sessions.remove(parent_hash);
} }
fn dispatch_pending_requests(&mut self, ctx: &mut Context<Block>) { fn dispatch_pending_requests(&mut self, ctx: &mut Context<Block>) {
...@@ -239,10 +239,10 @@ impl PolkadotProtocol { ...@@ -239,10 +239,10 @@ impl PolkadotProtocol {
let in_flight = &mut self.in_flight; let in_flight = &mut self.in_flight;
for mut pending in ::std::mem::replace(&mut self.pending, Vec::new()) { for mut pending in ::std::mem::replace(&mut self.pending, Vec::new()) {
let parent = pending.consensus_parent; let parent = pending.validation_session_parent;
let c_hash = pending.candidate_hash; let c_hash = pending.candidate_hash;
let still_pending = self.live_consensus.with_block_data(&parent, &c_hash, |x| match x { let still_pending = self.live_validation_sessions.with_block_data(&parent, &c_hash, |x| match x {
Ok(data @ &_) => { Ok(data @ &_) => {
// answer locally. // answer locally.
let _ = pending.sender.send(data.clone()); let _ = pending.sender.send(data.clone());
...@@ -272,7 +272,7 @@ impl PolkadotProtocol { ...@@ -272,7 +272,7 @@ impl PolkadotProtocol {
Some(pending) Some(pending)
} }
} }
Err(None) => None, // no such known consensus session. prune out. Err(None) => None, // no such known validation session. prune out.
}); });
if let Some(pending) = still_pending { if let Some(pending) = still_pending {
...@@ -288,7 +288,7 @@ impl PolkadotProtocol { ...@@ -288,7 +288,7 @@ impl PolkadotProtocol {
match msg { match msg {
Message::SessionKey(key) => self.on_session_key(ctx, who, key), Message::SessionKey(key) => self.on_session_key(ctx, who, key),
Message::RequestBlockData(req_id, relay_parent, candidate_hash) => { Message::RequestBlockData(req_id, relay_parent, candidate_hash) => {
let block_data = self.live_consensus let block_data = self.live_validation_sessions
.with_block_data( .with_block_data(
&relay_parent, &relay_parent,
&candidate_hash, &candidate_hash,
...@@ -440,7 +440,7 @@ impl Specialization<Block> for PolkadotProtocol { ...@@ -440,7 +440,7 @@ impl Specialization<Block> for PolkadotProtocol {
// send session keys. // send session keys.
if peer_info.should_send_key() { if peer_info.should_send_key() {
for local_session_key in self.live_consensus.recent_keys() { for local_session_key in self.live_validation_sessions.recent_keys() {
peer_info.collator_state.send_key(*local_session_key, |msg| send_polkadot_message( peer_info.collator_state.send_key(*local_session_key, |msg| send_polkadot_message(
ctx, ctx,
who, who,
...@@ -481,7 +481,7 @@ impl Specialization<Block> for PolkadotProtocol { ...@@ -481,7 +481,7 @@ impl Specialization<Block> for PolkadotProtocol {
let (sender, _) = oneshot::channel(); let (sender, _) = oneshot::channel();
pending.push(::std::mem::replace(val, BlockDataRequest { pending.push(::std::mem::replace(val, BlockDataRequest {
attempted_peers: Default::default(), attempted_peers: Default::default(),
consensus_parent: Default::default(), validation_session_parent: Default::default(),
candidate_hash: Default::default(), candidate_hash: Default::default(),
block_data_hash: Default::default(), block_data_hash: Default::default(),
sender, sender,
......
...@@ -19,11 +19,11 @@ ...@@ -19,11 +19,11 @@
//! During the consensus process, validators exchange statements on validity and availability //! During the consensus process, validators exchange statements on validity and availability
//! of parachain candidates. //! of parachain candidates.
//! The `Router` in this file hooks into the underlying network to fulfill //! The `Router` in this file hooks into the underlying network to fulfill
//! the `TableRouter` trait from `polkadot-consensus`, which is expected to call into a shared statement table //! the `TableRouter` trait from `polkadot-validation`, which is expected to call into a shared statement table
//! and dispatch evaluation work as necessary when new statements come in. //! and dispatch evaluation work as necessary when new statements come in.
use sr_primitives::traits::{ProvideRuntimeApi, BlakeTwo256, Hash as HashT}; use sr_primitives::traits::{ProvideRuntimeApi, BlakeTwo256, Hash as HashT};
use polkadot_consensus::{ use polkadot_validation::{
SharedTable, TableRouter, SignedStatement, GenericStatement, ParachainWork, Incoming, SharedTable, TableRouter, SignedStatement, GenericStatement, ParachainWork, Incoming,
Validated, Outgoing, Validated, Outgoing,
}; };
...@@ -41,7 +41,7 @@ use std::collections::{hash_map::{Entry, HashMap}, HashSet}; ...@@ -41,7 +41,7 @@ use std::collections::{hash_map::{Entry, HashMap}, HashSet};
use std::{io, mem}; use std::{io, mem};
use std::sync::Arc; use std::sync::Arc;
use consensus::{NetworkService, Knowledge, Executor}; use validation::{NetworkService, Knowledge, Executor};
type IngressPair = (ParaId, Vec<Message>); type IngressPair = (ParaId, Vec<Message>);
type IngressPairRef<'a> = (ParaId, &'a [Message]); type IngressPairRef<'a> = (ParaId, &'a [Message]);
...@@ -380,7 +380,7 @@ impl<P: ProvideRuntimeApi + Send, E, N, T> TableRouter for Router<P, E, N, T> wh ...@@ -380,7 +380,7 @@ impl<P: ProvideRuntimeApi + Send, E, N, T> TableRouter for Router<P, E, N, T> wh
impl<P, E, N: NetworkService, T> Drop for Router<P, E, N, T> { impl<P, E, N: NetworkService, T> Drop for Router<P, E, N, T> {
fn drop(&mut self) { fn drop(&mut self) {
let parent_hash = self.parent_hash.clone(); let parent_hash = self.parent_hash.clone();
self.network.with_spec(move |spec, _| spec.remove_consensus(&parent_hash)); self.network.with_spec(move |spec, _| spec.remove_validation_session(&parent_hash));
self.network.drop_gossip(self.attestation_topic); self.network.drop_gossip(self.attestation_topic);
{ {
...@@ -481,7 +481,7 @@ impl<S> Future for ComputeIngress<S> where S: Stream<Item=IngressPair> { ...@@ -481,7 +481,7 @@ impl<S> Future for ComputeIngress<S> where S: Stream<Item=IngressPair> {
Entry::Occupied(occupied) => { Entry::Occupied(occupied) => {
let canon_root = occupied.get().clone(); let canon_root = occupied.get().clone();
let messages = messages.iter().map(|m| &m.0[..]); let messages = messages.iter().map(|m| &m.0[..]);
if ::polkadot_consensus::message_queue_root(messages) != canon_root { if ::polkadot_validation::message_queue_root(messages) != canon_root {
continue; continue;
} }
...@@ -572,7 +572,7 @@ mod tests { ...@@ -572,7 +572,7 @@ mod tests {
let roots: HashMap<_, _> = actual_messages.iter() let roots: HashMap<_, _> = actual_messages.iter()
.map(|&(para_id, ref messages)| ( .map(|&(para_id, ref messages)| (
para_id, para_id,
::polkadot_consensus::message_queue_root(messages.iter().map(|m| &m.0)), ::polkadot_validation::message_queue_root(messages.iter().map(|m| &m.0)),
)) ))
.collect(); .collect();
......
...@@ -14,13 +14,13 @@ ...@@ -14,13 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Tests for polkadot and consensus network. //! Tests for polkadot and validation network.
use super::{PolkadotProtocol, Status, Message, FullStatus}; use super::{PolkadotProtocol, Status, Message, FullStatus};
use consensus::{CurrentConsensus, Knowledge}; use validation::{ValidationSession, Knowledge};
use parking_lot::Mutex; use parking_lot::Mutex;
use polkadot_consensus::GenericStatement; use polkadot_validation::GenericStatement;
use polkadot_primitives::{Block, SessionKey}; use polkadot_primitives::{Block, SessionKey};
use polkadot_primitives::parachain::{CandidateReceipt, HeadData, BlockData}; use polkadot_primitives::parachain::{CandidateReceipt, HeadData, BlockData};
use substrate_primitives::H512; use substrate_primitives::H512;
...@@ -34,7 +34,7 @@ use substrate_network::{ ...@@ -34,7 +34,7 @@ use substrate_network::{
use std::sync::Arc; use std::sync::Arc;
use futures::Future; use futures::Future;
mod consensus; mod validation;
#[derive(Default)] #[derive(Default)]
struct TestContext { struct TestContext {
...@@ -87,9 +87,9 @@ fn make_status(status: &Status, roles: Roles) -> FullStatus { ...@@ -87,9 +87,9 @@ fn make_status(status: &Status, roles: Roles) -> FullStatus {
} }
} }
fn make_consensus(local_key: SessionKey) -> (CurrentConsensus, Arc<Mutex<Knowledge>>) { fn make_validation_session(local_key: SessionKey) -> (ValidationSession, Arc<Mutex<Knowledge>>) {
let knowledge = Arc::new(Mutex::new(Knowledge::new())); let knowledge = Arc::new(Mutex::new(Knowledge::new()));
let c = CurrentConsensus::new(knowledge.clone(), local_key); let c = ValidationSession::new(knowledge.clone(), local_key);
(c, knowledge) (c, knowledge)
} }
...@@ -119,8 +119,8 @@ fn sends_session_key() { ...@@ -119,8 +119,8 @@ fn sends_session_key() {
{ {
let mut ctx = TestContext::default(); let mut ctx = TestContext::default();
let (consensus, _knowledge) = make_consensus(local_key); let (session, _knowledge) = make_validation_session(local_key);
protocol.new_consensus(&mut ctx, parent_hash, consensus); protocol.new_validation_session(&mut ctx, parent_hash, session);
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key))); assert!(ctx.has_message(peer_a, Message::SessionKey(local_key)));
} }
...@@ -159,8 +159,8 @@ fn fetches_from_those_with_knowledge() { ...@@ -159,8 +159,8 @@ fn fetches_from_those_with_knowledge() {
let status = Status { collating_for: None }; let status = Status { collating_for: None };
let (consensus, knowledge) = make_consensus(local_key); let (session, knowledge) = make_validation_session(local_key);
protocol.new_consensus(&mut TestContext::default(), parent_hash, consensus); protocol.new_validation_session(&mut TestContext::default(), parent_hash, session);
knowledge.lock().note_statement(a_key, &GenericStatement::Valid(candidate_hash)); knowledge.lock().note_statement(a_key, &GenericStatement::Valid(candidate_hash));
let recv = protocol.fetch_block_data(&mut TestContext::default(), &candidate_receipt, parent_hash); let recv = protocol.fetch_block_data(&mut TestContext::default(), &candidate_receipt, parent_hash);
...@@ -289,13 +289,13 @@ fn many_session_keys() { ...@@ -289,13 +289,13 @@ fn many_session_keys() {
let local_key_a = [3; 32].into(); let local_key_a = [3; 32].into();
let local_key_b = [4; 32].into(); let local_key_b = [4; 32].into();
let (consensus_a, _knowledge_a) = make_consensus(local_key_a); let (session_a, _knowledge_a) = make_validation_session(local_key_a);
let (consensus_b, _knowledge_b) = make_consensus(local_key_b); let (session_b, _knowledge_b) = make_validation_session(local_key_b);
protocol.new_consensus(&mut TestContext::default(), parent_a, consensus_a); protocol.new_validation_session(&mut TestContext::default(), parent_a, session_a);
protocol.new_consensus(&mut TestContext::default(), parent_b, consensus_b); protocol.new_validation_session(&mut TestContext::default(), parent_b, session_b);
assert_eq!(protocol.live_consensus.recent_keys(), &[local_key_a, local_key_b]); assert_eq!(protocol.live_validation_sessions.recent_keys(), &[local_key_a, local_key_b]);
let peer_a = 1; let peer_a = 1;
...@@ -312,7 +312,7 @@ fn many_session_keys() { ...@@ -312,7 +312,7 @@ fn many_session_keys() {
let peer_b = 2; let peer_b = 2;
protocol.remove_consensus(&parent_a); protocol.remove_validation_session(&parent_a);
{ {
let mut ctx = TestContext::default(); let mut ctx = TestContext::default();
......
...@@ -14,15 +14,15 @@ ...@@ -14,15 +14,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>. // along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! Tests and helpers for consensus networking. //! Tests and helpers for validation networking.
use consensus::NetworkService; use validation::NetworkService;
use substrate_network::{consensus_gossip::ConsensusMessage, Context as NetContext}; use substrate_network::{consensus_gossip::ConsensusMessage, Context as NetContext};
use substrate_primitives::{Ed25519AuthorityId, NativeOrEncoded}; use substrate_primitives::{Ed25519AuthorityId, NativeOrEncoded};
use substrate_keyring::Keyring; use substrate_keyring::Keyring;
use {PolkadotProtocol}; use {PolkadotProtocol};
use polkadot_consensus::{SharedTable, MessagesFrom, Network, TableRouter}; use polkadot_validation::{SharedTable, MessagesFrom, Network, TableRouter};
use polkadot_primitives::{AccountId, Block, Hash, Header, BlockId}; use polkadot_primitives::{AccountId, Block, Hash, Header, BlockId};
use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, ParachainHost, OutgoingMessage}; use polkadot_primitives::parachain::{Id as ParaId, Chain, DutyRoster, ParachainHost, OutgoingMessage};
use parking_lot::Mutex; use parking_lot::Mutex;
...@@ -298,7 +298,7 @@ impl ParachainHost<Block> for RuntimeApi { ...@@ -298,7 +298,7 @@ impl ParachainHost<Block> for RuntimeApi {
} }
} }
type TestConsensusNetwork = ::consensus::ConsensusNetwork< type TestValidationNetwork = ::validation::ValidationNetwork<
TestApi, TestApi,
NeverExit, NeverExit,
TestNetwork,