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 @@
.wasm-binaries
polkadot/runtime/wasm/target/
**/._*
.idea
.vscode
polkadot.*
.DS_Store
......@@ -2204,35 +2204,6 @@ dependencies = [
"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]]
name = "polkadot-erasure-coding"
version = "0.1.0"
......@@ -2264,8 +2235,8 @@ dependencies = [
"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)",
"polkadot-availability-store 0.1.0",
"polkadot-consensus 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)",
"sr-primitives 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 = [
"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)",
"polkadot-availability-store 0.1.0",
"polkadot-consensus 0.1.0",
"polkadot-executor 0.1.0",
"polkadot-network 0.1.0",
"polkadot-primitives 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)",
"sr-io 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 = [
"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]]
name = "pretty_assertions"
version = "0.5.1"
......
......@@ -22,7 +22,6 @@ members = [
"availability-store",
"cli",
"collator",
"consensus",
"erasure-coding",
"executor",
"network",
......@@ -31,6 +30,7 @@ members = [
"service",
"statement-table",
"service",
"validation",
"test-parachains/adder",
"test-parachains/adder/collator",
......
......@@ -8,7 +8,7 @@ description = "Polkadot-specific networking protocol"
arrayvec = "0.4"
parking_lot = "0.7.1"
polkadot-availability-store = { path = "../availability-store" }
polkadot-consensus = { path = "../consensus" }
polkadot-validation = { path = "../validation" }
polkadot-primitives = { path = "../primitives" }
parity-codec = "3.0"
parity-codec-derive = "3.0"
......
......@@ -24,7 +24,7 @@ extern crate substrate_network;
extern crate substrate_primitives;
extern crate sr_primitives;
extern crate polkadot_consensus;
extern crate polkadot_validation;
extern crate polkadot_availability_store as av_store;
extern crate polkadot_primitives;
......@@ -49,7 +49,7 @@ extern crate substrate_keyring;
mod collator_pool;
mod local_collations;
mod router;
pub mod consensus;
pub mod validation;
use codec::{Decode, Encode};
use futures::sync::oneshot;
......@@ -59,7 +59,7 @@ use substrate_network::{NodeIndex, RequestId, Context, Severity};
use substrate_network::{message, generic_message};
use substrate_network::specialization::NetworkSpecialization as Specialization;
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::local_collations::LocalCollations;
......@@ -85,7 +85,7 @@ pub struct Status {
struct BlockDataRequest {
attempted_peers: HashSet<SessionKey>,
consensus_parent: Hash,
validation_session_parent: Hash,
candidate_hash: Hash,
block_data_hash: Hash,
sender: oneshot::Sender<BlockData>,
......@@ -168,7 +168,7 @@ pub struct PolkadotProtocol {
collators: CollatorPool,
validators: HashMap<SessionKey, NodeIndex>,
local_collations: LocalCollations<Collation>,
live_consensus: LiveConsensusInstances,
live_validation_sessions: LiveValidationSessions,
in_flight: HashMap<(RequestId, NodeIndex), BlockDataRequest>,
pending: Vec<BlockDataRequest>,
extrinsic_store: Option<::av_store::Store>,
......@@ -184,7 +184,7 @@ impl PolkadotProtocol {
collating_for,
validators: HashMap::new(),
local_collations: LocalCollations::new(),
live_consensus: LiveConsensusInstances::new(),
live_validation_sessions: LiveValidationSessions::new(),
in_flight: HashMap::new(),
pending: Vec::new(),
extrinsic_store: None,
......@@ -198,7 +198,7 @@ impl PolkadotProtocol {
self.pending.push(BlockDataRequest {
attempted_peers: Default::default(),
consensus_parent: relay_parent,
validation_session_parent: relay_parent,
candidate_hash: candidate.hash(),
block_data_hash: candidate.block_data_hash,
sender: tx,
......@@ -208,14 +208,14 @@ impl PolkadotProtocol {
rx
}
/// Note new consensus session.
fn new_consensus(
/// Note new validation session.
fn new_validation_session(
&mut self,
ctx: &mut Context<Block>,
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()
.filter(|&(_, ref info)| info.should_send_key())
{
......@@ -228,8 +228,8 @@ impl PolkadotProtocol {
}
}
fn remove_consensus(&mut self, parent_hash: &Hash) {
self.live_consensus.remove(parent_hash);
fn remove_validation_session(&mut self, parent_hash: &Hash) {
self.live_validation_sessions.remove(parent_hash);
}
fn dispatch_pending_requests(&mut self, ctx: &mut Context<Block>) {
......@@ -239,10 +239,10 @@ impl PolkadotProtocol {
let in_flight = &mut self.in_flight;
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 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 @ &_) => {
// answer locally.
let _ = pending.sender.send(data.clone());
......@@ -272,7 +272,7 @@ impl PolkadotProtocol {
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 {
......@@ -288,7 +288,7 @@ impl PolkadotProtocol {
match msg {
Message::SessionKey(key) => self.on_session_key(ctx, who, key),
Message::RequestBlockData(req_id, relay_parent, candidate_hash) => {
let block_data = self.live_consensus
let block_data = self.live_validation_sessions
.with_block_data(
&relay_parent,
&candidate_hash,
......@@ -440,7 +440,7 @@ impl Specialization<Block> for PolkadotProtocol {
// send session keys.
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(
ctx,
who,
......@@ -481,7 +481,7 @@ impl Specialization<Block> for PolkadotProtocol {
let (sender, _) = oneshot::channel();
pending.push(::std::mem::replace(val, BlockDataRequest {
attempted_peers: Default::default(),
consensus_parent: Default::default(),
validation_session_parent: Default::default(),
candidate_hash: Default::default(),
block_data_hash: Default::default(),
sender,
......
......@@ -19,11 +19,11 @@
//! During the consensus process, validators exchange statements on validity and availability
//! of parachain candidates.
//! 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.
use sr_primitives::traits::{ProvideRuntimeApi, BlakeTwo256, Hash as HashT};
use polkadot_consensus::{
use polkadot_validation::{
SharedTable, TableRouter, SignedStatement, GenericStatement, ParachainWork, Incoming,
Validated, Outgoing,
};
......@@ -41,7 +41,7 @@ use std::collections::{hash_map::{Entry, HashMap}, HashSet};
use std::{io, mem};
use std::sync::Arc;
use consensus::{NetworkService, Knowledge, Executor};
use validation::{NetworkService, Knowledge, Executor};
type IngressPair = (ParaId, Vec<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
impl<P, E, N: NetworkService, T> Drop for Router<P, E, N, T> {
fn drop(&mut self) {
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);
{
......@@ -481,7 +481,7 @@ impl<S> Future for ComputeIngress<S> where S: Stream<Item=IngressPair> {
Entry::Occupied(occupied) => {
let canon_root = occupied.get().clone();
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;
}
......@@ -572,7 +572,7 @@ mod tests {
let roots: HashMap<_, _> = actual_messages.iter()
.map(|&(para_id, ref messages)| (
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();
......
......@@ -14,13 +14,13 @@
// You should have received a copy of the GNU General Public License
// 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 consensus::{CurrentConsensus, Knowledge};
use validation::{ValidationSession, Knowledge};
use parking_lot::Mutex;
use polkadot_consensus::GenericStatement;
use polkadot_validation::GenericStatement;
use polkadot_primitives::{Block, SessionKey};
use polkadot_primitives::parachain::{CandidateReceipt, HeadData, BlockData};
use substrate_primitives::H512;
......@@ -34,7 +34,7 @@ use substrate_network::{
use std::sync::Arc;
use futures::Future;
mod consensus;
mod validation;
#[derive(Default)]
struct TestContext {
......@@ -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 c = CurrentConsensus::new(knowledge.clone(), local_key);
let c = ValidationSession::new(knowledge.clone(), local_key);
(c, knowledge)
}
......@@ -119,8 +119,8 @@ fn sends_session_key() {
{
let mut ctx = TestContext::default();
let (consensus, _knowledge) = make_consensus(local_key);
protocol.new_consensus(&mut ctx, parent_hash, consensus);
let (session, _knowledge) = make_validation_session(local_key);
protocol.new_validation_session(&mut ctx, parent_hash, session);
assert!(ctx.has_message(peer_a, Message::SessionKey(local_key)));
}
......@@ -159,8 +159,8 @@ fn fetches_from_those_with_knowledge() {
let status = Status { collating_for: None };
let (consensus, knowledge) = make_consensus(local_key);
protocol.new_consensus(&mut TestContext::default(), parent_hash, consensus);
let (session, knowledge) = make_validation_session(local_key);
protocol.new_validation_session(&mut TestContext::default(), parent_hash, session);
knowledge.lock().note_statement(a_key, &GenericStatement::Valid(candidate_hash));
let recv = protocol.fetch_block_data(&mut TestContext::default(), &candidate_receipt, parent_hash);
......@@ -289,13 +289,13 @@ fn many_session_keys() {
let local_key_a = [3; 32].into();
let local_key_b = [4; 32].into();
let (consensus_a, _knowledge_a) = make_consensus(local_key_a);
let (consensus_b, _knowledge_b) = make_consensus(local_key_b);
let (session_a, _knowledge_a) = make_validation_session(local_key_a);
let (session_b, _knowledge_b) = make_validation_session(local_key_b);
protocol.new_consensus(&mut TestContext::default(), parent_a, consensus_a);
protocol.new_consensus(&mut TestContext::default(), parent_b, consensus_b);
protocol.new_validation_session(&mut TestContext::default(), parent_a, session_a);
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;
......@@ -312,7 +312,7 @@ fn many_session_keys() {
let peer_b = 2;
protocol.remove_consensus(&parent_a);
protocol.remove_validation_session(&parent_a);
{
let mut ctx = TestContext::default();
......
......@@ -14,15 +14,15 @@
// You should have received a copy of the GNU General Public License
// 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_primitives::{Ed25519AuthorityId, NativeOrEncoded};
use substrate_keyring::Keyring;
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::parachain::{Id as ParaId, Chain, DutyRoster, ParachainHost, OutgoingMessage};
use parking_lot::Mutex;
......@@ -298,7 +298,7 @@ impl ParachainHost<Block> for RuntimeApi {
}
}
type TestConsensusNetwork = ::consensus::ConsensusNetwork<
type TestValidationNetwork = ::validation::ValidationNetwork<
TestApi,
NeverExit,
TestNetwork,
......@@ -308,7 +308,7 @@ type TestConsensusNetwork = ::consensus::ConsensusNetwork<
struct Built {
gossip: GossipRouter,
api_handle: Arc<Mutex<ApiData>>,
networks: Vec<TestConsensusNetwork>,
networks: Vec<TestValidationNetwork>,
}
fn build_network(n: usize, executor: TaskExecutor) -> Built {
......@@ -322,7 +322,7 @@ fn build_network(n: usize, executor: TaskExecutor) -> Built {
gossip: gossip_handle.clone(),
});
TestConsensusNetwork::new(
TestValidationNetwork::new(
net,
NeverExit,
runtime_api.clone(),
......@@ -356,7 +356,7 @@ impl IngressBuilder {
let mut map = HashMap::new();
for ((source, target), messages) in self.egress {
map.entry(target).or_insert_with(Vec::new)
.push((source, polkadot_consensus::message_queue_root(&messages)));
.push((source, polkadot_validation::message_queue_root(&messages)));
}
for roots in map.values_mut() {
......@@ -372,7 +372,7 @@ fn make_table(data: &ApiData, local_key: &Keyring, parent_hash: Hash) -> Arc<Sha
let store = Store::new_in_memory();
let authorities: Vec<_> = data.validators.iter().map(|v| v.to_fixed_bytes().into()).collect();
let (group_info, _) = ::polkadot_consensus::make_group_info(
let (group_info, _) = ::polkadot_validation::make_group_info(
DutyRoster { validator_duty: data.duties.clone() },
&authorities,
local_key.to_raw_public().into()
......
......@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
//! The "consensus" networking code built on top of the base network service.
//! The "validation session" networking code built on top of the base network service.
//!
//! This fulfills the `polkadot_consensus::Network` trait, providing a hook to be called
//! each time consensus begins on a new chain head.
//! This fulfills the `polkadot_validation::Network` trait, providing a hook to be called
//! each time a validation session begins on a new chain head.
use sr_primitives::traits::ProvideRuntimeApi;
use substrate_network::{consensus_gossip::ConsensusMessage, Context as NetContext};
use polkadot_consensus::{Network as ParachainNetwork, SharedTable, Collators, Statement, GenericStatement};
use polkadot_validation::{Network as ParachainNetwork, SharedTable, Collators, Statement, GenericStatement};
use polkadot_primitives::{AccountId, Block, Hash, SessionKey};
use polkadot_primitives::parachain::{Id as ParaId, Collation, Extrinsic, ParachainHost, BlockData};
use codec::Decode;
......@@ -53,7 +53,7 @@ impl<T> Executor for WrappedExecutor<T>
{
fn spawn<F: Future<Item=(),Error=()> + Send + 'static>(&self, f: F) {
if let Err(e) = self.0.execute(Box::new(f)) {
warn!(target: "consensus", "could not spawn consensus task: {:?}", e);
warn!(target: "validation", "could not spawn consensus task: {:?}", e);
}
}
}
......@@ -128,11 +128,11 @@ impl<P, E, N, T> MessageProcessTask<P, E, N, T> where
T: Clone + Executor + Send + 'static,
{
fn process_message(&self, msg: ConsensusMessage) -> Option<Async<()>> {
use polkadot_consensus::SignedStatement;
use polkadot_validation::SignedStatement;
debug!(target: "consensus", "Processing consensus statement for live consensus");
debug!(target: "validation", "Processing validation statement for live session");
if let Some(statement) = SignedStatement::decode(&mut msg.as_slice()) {
if ::polkadot_consensus::check_statement(
if ::polkadot_validation::check_statement(
&statement.statement,
&statement.signature,
statement.sender,
......@@ -171,23 +171,23 @@ impl<P, E, N, T> Future for MessageProcessTask<P, E, N, T> where
}
/// Wrapper around the network service
pub struct ConsensusNetwork<P, E, N, T> {
pub struct ValidationNetwork<P, E, N, T> {
network: Arc<N>,
api: Arc<P>,
executor: T,
exit: E,
}
impl<P, E, N, T> ConsensusNetwork<P, E, N, T> {
/// Create a new consensus networking object.
impl<P, E, N, T> ValidationNetwork<P, E, N, T> {
/// Create a new validation session networking object.
pub fn new(network: Arc<N>, exit: E, api: Arc<P>, executor: T) -> Self {
ConsensusNetwork { network, exit, api, executor }
ValidationNetwork { network, exit, api, executor }
}
}
impl<P, E: Clone, N, T: Clone> Clone for ConsensusNetwork<P, E, N, T> {
impl<P, E: Clone, N, T: Clone> Clone for ValidationNetwork<P, E, N, T> {
fn clone(&self) -> Self {
ConsensusNetwork {
ValidationNetwork {
network: self.network.clone(),
exit: self.exit.clone(),
api: self.api.clone(),
......@@ -197,7 +197,7 @@ impl<P, E: Clone, N, T: Clone> Clone for ConsensusNetwork<P, E, N, T> {
}
/// A long-lived network which can create parachain statement routing processes on demand.
impl<P, E, N, T> ParachainNetwork for ConsensusNetwork<P, E, N, T> where
impl<P, E, N, T> ParachainNetwork for ValidationNetwork<P, E, N, T> where
P: ProvideRuntimeApi + Send + Sync + 'static,
P::Api: ParachainHost<Block>,
E: Clone + Future<Item=(),Error=()> + Send + 'static,
......@@ -209,7 +209,7 @@ impl<P, E, N, T> ParachainNetwork for ConsensusNetwork<P, E, N, T> where
fn communication_for(
&self,
table: Arc<SharedTable>,
outgoing: polkadot_consensus::Outgoing,
outgoing: polkadot_validation::Outgoing,
) -> Self::TableRouter {
let parent_hash = table.consensus_parent_hash().clone();
......@@ -238,7 +238,7 @@ impl<P, E, N, T> ParachainNetwork for ConsensusNetwork<P, E, N, T> where
let inner_stream = self.network.gossip_messages_for(attestation_topic);
self.network
.with_spec(move |spec, ctx| {
spec.new_consensus(ctx, parent_hash, CurrentConsensus {
spec.new_validation_session(ctx, parent_hash, ValidationSession {
knowledge,
local_session_key,
});
......@@ -284,7 +284,7 @@ impl Future for AwaitingCollation {
}
}
impl<P, E: Clone, N, T: Clone> Collators for ConsensusNetwork<P, E, N, T> where
impl<P, E: Clone, N, T: Clone> Collators for ValidationNetwork<P, E, N, T> where
P: ProvideRuntimeApi + Send + Sync + 'static,
P::Api: ParachainHost<Block>,
N: NetworkService,
......@@ -359,16 +359,16 @@ impl Knowledge {
}
}
/// A current consensus instance.
pub(crate) struct CurrentConsensus {
/// A current validation session instance.
pub(crate) struct ValidationSession {
knowledge: Arc<Mutex<Knowledge>>,
local_session_key: SessionKey,
}
impl CurrentConsensus {
impl ValidationSession {
#[cfg(test)]
pub(crate) fn new(knowledge: Arc<Mutex<Knowledge>>, local_session_key: SessionKey) -> Self {
CurrentConsensus {
ValidationSession {
knowledge,
local_session_key
}
......@@ -434,50 +434,50 @@ impl RecentSessionKeys {
}
}
/// Manages requests and session keys for live consensus instances.
pub(crate) struct LiveConsensusInstances {
/// Manages requests and keys for live validation session instances.
pub(crate) struct LiveValidationSessions {
// recent local session keys.
recent: RecentSessionKeys,
// live consensus instances, on `parent_hash`.
live_instances: HashMap<Hash, CurrentConsensus>,
// live validation session instances, on `parent_hash`.
live_instances: HashMap<Hash, ValidationSession>,
}
impl LiveConsensusInstances {
/// Create a new `LiveConsensusInstances`
impl LiveValidationSessions {
/// Create a new `LiveValidationSessions`
pub(crate) fn new() -> Self {
LiveConsensusInstances {
LiveValidationSessions {
recent: Default::default(),
live_instances: HashMap::new(),
}