Migrate polkadot-primitives to v6 (#1543)

- Async-backing related primitives are stable `primitives::v6`
- Async-backing API is now part of `api_version(7)`
- It's enabled on Rococo and Westend runtimes

---------

Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
Co-authored-by: Andrei Sandu <54316454+sandreim@users.noreply.github.com>
This commit is contained in:
Chris Sosnin
2023-09-27 13:32:02 +03:00
committed by GitHub
parent 5a2833cceb
commit 7cbe0c76ef
107 changed files with 2410 additions and 2792 deletions
@@ -21,8 +21,7 @@ use polkadot_node_network_protocol::{
grid_topology::{GridNeighbors, RequiredRouting, SessionBoundGridTopologyStorage},
peer_set::{IsAuthority, PeerSet, ValidationVersion},
v1::{self as protocol_v1, StatementMetadata},
vstaging as protocol_vstaging, IfDisconnected, PeerId, UnifiedReputationChange as Rep,
Versioned, View,
v2 as protocol_v2, IfDisconnected, PeerId, UnifiedReputationChange as Rep, Versioned, View,
};
use polkadot_node_primitives::{
SignedFullStatement, Statement, StatementWithPVD, UncheckedSignedFullStatement,
@@ -1062,7 +1061,7 @@ async fn circulate_statement<'a, Context>(
"We filter out duplicates above. qed.",
);
let (v1_peers_to_send, vstaging_peers_to_send) = peers_to_send
let (v1_peers_to_send, v2_peers_to_send) = peers_to_send
.into_iter()
.map(|peer_id| {
let peer_data =
@@ -1074,7 +1073,7 @@ async fn circulate_statement<'a, Context>(
})
.partition::<Vec<_>, _>(|(_, _, version)| match version {
ValidationVersion::V1 => true,
ValidationVersion::VStaging => false,
ValidationVersion::V2 => false,
}); // partition is handy here but not if we add more protocol versions
let payload = v1_statement_message(relay_parent, stored.statement.clone(), metrics);
@@ -1094,24 +1093,24 @@ async fn circulate_statement<'a, Context>(
))
.await;
}
if !vstaging_peers_to_send.is_empty() {
if !v2_peers_to_send.is_empty() {
gum::trace!(
target: LOG_TARGET,
?vstaging_peers_to_send,
?v2_peers_to_send,
?relay_parent,
statement = ?stored.statement,
"Sending statement to vstaging peers",
"Sending statement to v2 peers",
);
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
vstaging_peers_to_send.iter().map(|(p, _, _)| *p).collect(),
compatible_v1_message(ValidationVersion::VStaging, payload.clone()).into(),
v2_peers_to_send.iter().map(|(p, _, _)| *p).collect(),
compatible_v1_message(ValidationVersion::V2, payload.clone()).into(),
))
.await;
}
v1_peers_to_send
.into_iter()
.chain(vstaging_peers_to_send)
.chain(v2_peers_to_send)
.filter_map(|(peer, needs_dependent, _)| if needs_dependent { Some(peer) } else { None })
.collect()
}
@@ -1443,10 +1442,8 @@ async fn handle_incoming_message<'a, Context>(
let message = match message {
Versioned::V1(m) => m,
Versioned::VStaging(protocol_vstaging::StatementDistributionMessage::V1Compatibility(
m,
)) => m,
Versioned::VStaging(_) => {
Versioned::V2(protocol_v2::StatementDistributionMessage::V1Compatibility(m)) => m,
Versioned::V2(_) => {
// The higher-level subsystem code is supposed to filter out
// all non v1 messages.
gum::debug!(
@@ -2170,8 +2167,7 @@ fn compatible_v1_message(
) -> net_protocol::StatementDistributionMessage {
match version {
ValidationVersion::V1 => Versioned::V1(message),
ValidationVersion::VStaging => Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::V1Compatibility(message),
),
ValidationVersion::V2 =>
Versioned::V2(protocol_v2::StatementDistributionMessage::V1Compatibility(message)),
}
}
@@ -793,7 +793,7 @@ fn receiving_from_one_sends_to_another_and_to_candidate_backing() {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == hash_a
=> {
@@ -1033,7 +1033,7 @@ fn receiving_large_statement_from_one_sends_to_another_and_to_candidate_backing(
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == hash_a
=> {
@@ -1563,7 +1563,7 @@ fn delay_reputation_changes() {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == hash_a
=> {
@@ -2043,7 +2043,7 @@ fn share_prioritizes_backing_group() {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == hash_a
=> {
@@ -2365,7 +2365,7 @@ fn peer_cant_flood_with_large_statements() {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == hash_a
=> {
@@ -2590,7 +2590,7 @@ fn handle_multiple_seconded_statements() {
assert_matches!(
handle.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(r, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(r, RuntimeApiRequest::AsyncBackingParams(tx))
)
if r == relay_parent_hash
=> {
@@ -26,10 +26,8 @@ use error::{log_error, FatalResult};
use std::time::Duration;
use polkadot_node_network_protocol::{
request_response::{
v1 as request_v1, vstaging::AttestedCandidateRequest, IncomingRequestReceiver,
},
vstaging as protocol_vstaging, Versioned,
request_response::{v1 as request_v1, v2::AttestedCandidateRequest, IncomingRequestReceiver},
v2 as protocol_v2, Versioned,
};
use polkadot_node_primitives::StatementWithPVD;
use polkadot_node_subsystem::{
@@ -60,7 +58,7 @@ use legacy_v1::{
ResponderMessage as V1ResponderMessage,
};
mod vstaging;
mod v2;
const LOG_TARGET: &str = "parachain::statement-distribution";
@@ -104,9 +102,9 @@ enum MuxedMessage {
/// Messages from spawned v1 (legacy) responder background task.
V1Responder(Option<V1ResponderMessage>),
/// Messages from candidate responder background task.
Responder(Option<vstaging::ResponderMessage>),
Responder(Option<v2::ResponderMessage>),
/// Messages from answered requests.
Response(vstaging::UnhandledResponse),
Response(v2::UnhandledResponse),
/// Message that a request is ready to be retried. This just acts as a signal that we should
/// dispatch all pending requests again.
RetryRequest(()),
@@ -116,10 +114,10 @@ enum MuxedMessage {
impl MuxedMessage {
async fn receive<Context>(
ctx: &mut Context,
state: &mut vstaging::State,
state: &mut v2::State,
from_v1_requester: &mut mpsc::Receiver<V1RequesterMessage>,
from_v1_responder: &mut mpsc::Receiver<V1ResponderMessage>,
from_responder: &mut mpsc::Receiver<vstaging::ResponderMessage>,
from_responder: &mut mpsc::Receiver<v2::ResponderMessage>,
) -> MuxedMessage {
let (request_manager, response_manager) = state.request_and_response_managers();
// We are only fusing here to make `select` happy, in reality we will quit if one of those
@@ -128,8 +126,8 @@ impl MuxedMessage {
let from_v1_requester = from_v1_requester.next();
let from_v1_responder = from_v1_responder.next();
let from_responder = from_responder.next();
let receive_response = vstaging::receive_response(response_manager).fuse();
let retry_request = vstaging::next_retry(request_manager).fuse();
let receive_response = v2::receive_response(response_manager).fuse();
let retry_request = v2::next_retry(request_manager).fuse();
futures::pin_mut!(
from_orchestra,
from_v1_requester,
@@ -182,7 +180,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
let mut reputation_delay = new_reputation_delay();
let mut legacy_v1_state = crate::legacy_v1::State::new(self.keystore.clone());
let mut state = crate::vstaging::State::new(self.keystore.clone());
let mut state = crate::v2::State::new(self.keystore.clone());
// Sender/Receiver for getting news from our statement fetching tasks.
let (v1_req_sender, mut v1_req_receiver) = mpsc::channel(1);
@@ -206,7 +204,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
ctx.spawn(
"candidate-responder",
vstaging::respond_task(
v2::respond_task(
self.req_receiver.take().expect("Mandatory argument to new. qed"),
res_sender.clone(),
)
@@ -280,14 +278,13 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
)?;
},
MuxedMessage::Responder(result) => {
vstaging::answer_request(
v2::answer_request(
&mut state,
result.ok_or(FatalError::RequesterReceiverFinished)?,
);
},
MuxedMessage::Response(result) => {
vstaging::handle_response(&mut ctx, &mut state, result, &mut self.reputation)
.await;
v2::handle_response(&mut ctx, &mut state, result, &mut self.reputation).await;
},
MuxedMessage::RetryRequest(()) => {
// A pending request is ready to retry. This is only a signal to call
@@ -296,7 +293,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
},
};
vstaging::dispatch_requests(&mut ctx, &mut state).await;
v2::dispatch_requests(&mut ctx, &mut state).await;
}
Ok(())
}
@@ -304,7 +301,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
async fn handle_subsystem_message<Context>(
&mut self,
ctx: &mut Context,
state: &mut vstaging::State,
state: &mut v2::State,
legacy_v1_state: &mut legacy_v1::State,
v1_req_sender: &mpsc::Sender<V1RequesterMessage>,
message: FromOrchestra<StatementDistributionMessage>,
@@ -318,11 +315,11 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
})) => {
let _timer = metrics.time_active_leaves_update();
// vstaging should handle activated first because of implicit view.
// v2 should handle activated first because of implicit view.
if let Some(ref activated) = activated {
let mode = prospective_parachains_mode(ctx.sender(), activated.hash).await?;
if let ProspectiveParachainsMode::Enabled { .. } = mode {
vstaging::handle_active_leaves_update(ctx, state, activated, mode).await?;
v2::handle_active_leaves_update(ctx, state, activated, mode).await?;
} else if let ProspectiveParachainsMode::Disabled = mode {
for deactivated in &deactivated {
crate::legacy_v1::handle_deactivate_leaf(legacy_v1_state, *deactivated);
@@ -339,7 +336,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
for deactivated in &deactivated {
crate::legacy_v1::handle_deactivate_leaf(legacy_v1_state, *deactivated);
}
vstaging::handle_deactivate_leaves(state, &deactivated);
v2::handle_deactivate_leaves(state, &deactivated);
}
},
FromOrchestra::Signal(OverseerSignal::BlockFinalized(..)) => {
@@ -362,7 +359,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
)
.await?;
} else {
vstaging::share_local_statement(
v2::share_local_statement(
ctx,
state,
relay_parent,
@@ -399,11 +396,11 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
let target = match &event {
NetworkBridgeEvent::PeerMessage(_, message) => match message {
Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::V1Compatibility(_),
Versioned::V2(
protocol_v2::StatementDistributionMessage::V1Compatibility(_),
) => VersionTarget::Legacy,
Versioned::V1(_) => VersionTarget::Legacy,
Versioned::VStaging(_) => VersionTarget::Current,
Versioned::V2(_) => VersionTarget::Current,
},
_ => VersionTarget::Both,
};
@@ -422,14 +419,12 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
}
if target.targets_current() {
// pass to vstaging.
vstaging::handle_network_update(ctx, state, event, &mut self.reputation)
.await;
// pass to v2.
v2::handle_network_update(ctx, state, event, &mut self.reputation).await;
}
},
StatementDistributionMessage::Backed(candidate_hash) => {
crate::vstaging::handle_backed_candidate_message(ctx, state, candidate_hash)
.await;
crate::v2::handle_backed_candidate_message(ctx, state, candidate_hash).await;
},
},
}
@@ -27,7 +27,7 @@
use polkadot_node_network_protocol::PeerId;
use polkadot_node_subsystem::messages::HypotheticalCandidate;
use polkadot_primitives::vstaging::{
use polkadot_primitives::{
CandidateHash, CommittedCandidateReceipt, GroupIndex, Hash, Id as ParaId,
PersistedValidationData,
};
@@ -55,7 +55,7 @@
//! and to keep track of what we have sent to other validators in the group and what we may
//! continue to send them.
use polkadot_primitives::vstaging::{CandidateHash, CompactStatement, ValidatorIndex};
use polkadot_primitives::{CandidateHash, CompactStatement, ValidatorIndex};
use std::collections::{HashMap, HashSet};
@@ -459,7 +459,7 @@ pub enum RejectOutgoing {
#[cfg(test)]
mod tests {
use super::*;
use polkadot_primitives::vstaging::Hash;
use polkadot_primitives::Hash;
#[test]
fn rejects_incoming_outside_of_group() {
@@ -60,12 +60,8 @@
//! - which has sent a `BackedCandidateAcknowledgement`
//! - 1st-hop nodes do the same thing
use polkadot_node_network_protocol::{
grid_topology::SessionGridTopology, vstaging::StatementFilter,
};
use polkadot_primitives::vstaging::{
CandidateHash, CompactStatement, GroupIndex, Hash, ValidatorIndex,
};
use polkadot_node_network_protocol::{grid_topology::SessionGridTopology, v2::StatementFilter};
use polkadot_primitives::{CandidateHash, CompactStatement, GroupIndex, Hash, ValidatorIndex};
use std::collections::{
hash_map::{Entry, HashMap},
@@ -17,8 +17,7 @@
//! A utility for tracking groups and their members within a session.
use polkadot_primitives::{
effective_minimum_backing_votes,
vstaging::{GroupIndex, IndexedVec, ValidatorIndex},
effective_minimum_backing_votes, GroupIndex, IndexedVec, ValidatorIndex,
};
use std::collections::HashMap;
@@ -23,11 +23,11 @@ use polkadot_node_network_protocol::{
peer_set::ValidationVersion,
request_response::{
incoming::OutgoingResponse,
vstaging::{AttestedCandidateRequest, AttestedCandidateResponse},
v2::{AttestedCandidateRequest, AttestedCandidateResponse},
IncomingRequest, IncomingRequestReceiver, Requests,
MAX_PARALLEL_ATTESTED_CANDIDATE_REQUESTS,
},
vstaging::{self as protocol_vstaging, StatementFilter},
v2::{self as protocol_v2, StatementFilter},
IfDisconnected, PeerId, UnifiedReputationChange as Rep, Versioned, View,
};
use polkadot_node_primitives::{
@@ -45,7 +45,7 @@ use polkadot_node_subsystem_util::{
reputation::ReputationAggregator,
runtime::{request_min_backing_votes, ProspectiveParachainsMode},
};
use polkadot_primitives::vstaging::{
use polkadot_primitives::{
AuthorityDiscoveryId, CandidateHash, CompactStatement, CoreIndex, CoreState, GroupIndex,
GroupRotationInfo, Hash, Id as ParaId, IndexedVec, SessionIndex, SessionInfo, SignedStatement,
SigningContext, UncheckedSignedStatement, ValidatorId, ValidatorIndex,
@@ -323,7 +323,7 @@ pub(crate) async fn handle_network_update<Context>(
NetworkBridgeEvent::PeerConnected(peer_id, role, protocol_version, mut authority_ids) => {
gum::trace!(target: LOG_TARGET, ?peer_id, ?role, ?protocol_version, "Peer connected");
if protocol_version != ValidationVersion::VStaging.into() {
if protocol_version != ValidationVersion::V2.into() {
return
}
@@ -381,19 +381,19 @@ pub(crate) async fn handle_network_update<Context>(
},
NetworkBridgeEvent::PeerMessage(peer_id, message) => match message {
net_protocol::StatementDistributionMessage::V1(_) => return,
net_protocol::StatementDistributionMessage::VStaging(
protocol_vstaging::StatementDistributionMessage::V1Compatibility(_),
net_protocol::StatementDistributionMessage::V2(
protocol_v2::StatementDistributionMessage::V1Compatibility(_),
) => return,
net_protocol::StatementDistributionMessage::VStaging(
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
net_protocol::StatementDistributionMessage::V2(
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
) =>
handle_incoming_statement(ctx, state, peer_id, relay_parent, statement, reputation)
.await,
net_protocol::StatementDistributionMessage::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(inner),
net_protocol::StatementDistributionMessage::V2(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(inner),
) => handle_incoming_manifest(ctx, state, peer_id, inner, reputation).await,
net_protocol::StatementDistributionMessage::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(inner),
net_protocol::StatementDistributionMessage::V2(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(inner),
) => handle_incoming_acknowledgement(ctx, state, peer_id, inner, reputation).await,
},
NetworkBridgeEvent::PeerViewChange(peer_id, view) =>
@@ -727,10 +727,8 @@ fn pending_statement_network_message(
statement_store
.validator_statement(originator, compact)
.map(|s| s.as_unchecked().clone())
.map(|signed| {
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, signed)
})
.map(|msg| (vec![*peer], Versioned::VStaging(msg).into()))
.map(|signed| protocol_v2::StatementDistributionMessage::Statement(relay_parent, signed))
.map(|msg| (vec![*peer], Versioned::V2(msg).into()))
}
/// Send a peer all pending cluster statements for a relay parent.
@@ -823,7 +821,7 @@ async fn send_pending_grid_messages<Context>(
match kind {
grid::ManifestKind::Full => {
let manifest = protocol_vstaging::BackedCandidateManifest {
let manifest = protocol_v2::BackedCandidateManifest {
relay_parent,
candidate_hash,
group_index,
@@ -847,8 +845,8 @@ async fn send_pending_grid_messages<Context>(
messages.push((
vec![*peer_id],
Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
Versioned::V2(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest,
),
)
@@ -1192,7 +1190,7 @@ async fn circulate_statement<Context>(
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
statement_to,
Versioned::VStaging(protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::StatementDistributionMessage::Statement(
relay_parent,
statement.as_unchecked().clone(),
))
@@ -1672,7 +1670,7 @@ async fn provide_candidate_to_grid<Context>(
filter.clone(),
);
let manifest = protocol_vstaging::BackedCandidateManifest {
let manifest = protocol_v2::BackedCandidateManifest {
relay_parent,
candidate_hash,
group_index,
@@ -1680,16 +1678,15 @@ async fn provide_candidate_to_grid<Context>(
parent_head_data_hash: confirmed_candidate.parent_head_data_hash(),
statement_knowledge: filter.clone(),
};
let acknowledgement = protocol_vstaging::BackedCandidateAcknowledgement {
let acknowledgement = protocol_v2::BackedCandidateAcknowledgement {
candidate_hash,
statement_knowledge: filter.clone(),
};
let manifest_message = Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
);
let ack_message = Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(acknowledgement),
let manifest_message =
Versioned::V2(protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest));
let ack_message = Versioned::V2(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(acknowledgement),
);
let mut manifest_peers = Vec::new();
@@ -2062,8 +2059,8 @@ fn post_acknowledgement_statement_messages(
statement.payload(),
);
messages.push(Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::Statement(
messages.push(Versioned::V2(
protocol_v2::StatementDistributionMessage::Statement(
relay_parent,
statement.as_unchecked().clone(),
)
@@ -2079,7 +2076,7 @@ async fn handle_incoming_manifest<Context>(
ctx: &mut Context,
state: &mut State,
peer: PeerId,
manifest: net_protocol::vstaging::BackedCandidateManifest,
manifest: net_protocol::v2::BackedCandidateManifest,
reputation: &mut ReputationAggregator,
) {
gum::debug!(
@@ -2183,14 +2180,14 @@ fn acknowledgement_and_statement_messages(
Some(l) => l,
};
let acknowledgement = protocol_vstaging::BackedCandidateAcknowledgement {
let acknowledgement = protocol_v2::BackedCandidateAcknowledgement {
candidate_hash,
statement_knowledge: local_knowledge.clone(),
};
let msg = Versioned::VStaging(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(acknowledgement),
);
let msg = Versioned::V2(protocol_v2::StatementDistributionMessage::BackedCandidateKnown(
acknowledgement,
));
let mut messages = vec![(vec![peer], msg.into())];
@@ -2221,7 +2218,7 @@ async fn handle_incoming_acknowledgement<Context>(
ctx: &mut Context,
state: &mut State,
peer: PeerId,
acknowledgement: net_protocol::vstaging::BackedCandidateAcknowledgement,
acknowledgement: net_protocol::v2::BackedCandidateAcknowledgement,
reputation: &mut ReputationAggregator,
) {
// The key difference between acknowledgments and full manifests is that only
@@ -2521,7 +2518,7 @@ pub(crate) async fn dispatch_requests<Context>(ctx: &mut Context, state: &mut St
) {
// Peer is supposedly connected.
ctx.send_message(NetworkBridgeTxMessage::SendRequests(
vec![Requests::AttestedCandidateVStaging(request)],
vec![Requests::AttestedCandidateV2(request)],
IfDisconnected::ImmediateError,
))
.await;
@@ -39,14 +39,14 @@ use crate::LOG_TARGET;
use polkadot_node_network_protocol::{
request_response::{
outgoing::{Recipient as RequestRecipient, RequestError},
vstaging::{AttestedCandidateRequest, AttestedCandidateResponse},
v2::{AttestedCandidateRequest, AttestedCandidateResponse},
OutgoingRequest, OutgoingResult, MAX_PARALLEL_ATTESTED_CANDIDATE_REQUESTS,
},
vstaging::StatementFilter,
v2::StatementFilter,
PeerId, UnifiedReputationChange as Rep,
};
use polkadot_primitives::vstaging::{
CandidateHash, CommittedCandidateReceipt, CompactStatement, GroupIndex, Hash, ParaId,
use polkadot_primitives::{
CandidateHash, CommittedCandidateReceipt, CompactStatement, GroupIndex, Hash, Id as ParaId,
PersistedValidationData, SessionIndex, SignedStatement, SigningContext, ValidatorId,
ValidatorIndex,
};
@@ -24,8 +24,8 @@
//! groups, and views based on the validators themselves.
use bitvec::{order::Lsb0 as BitOrderLsb0, vec::BitVec};
use polkadot_node_network_protocol::vstaging::StatementFilter;
use polkadot_primitives::vstaging::{
use polkadot_node_network_protocol::v2::StatementFilter;
use polkadot_primitives::{
CandidateHash, CompactStatement, GroupIndex, SignedStatement, ValidatorIndex,
};
use std::collections::hash_map::{Entry as HEntry, HashMap};
@@ -103,8 +103,8 @@ fn share_seconded_circulated_to_cluster() {
overseer.recv().await,
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -173,7 +173,7 @@ fn cluster_valid_statement_before_seconded_ignored() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
protocol_v2::StatementDistributionMessage::Statement(
relay_parent,
signed_valid.as_unchecked().clone(),
),
@@ -252,7 +252,7 @@ fn cluster_statement_bad_signature() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
protocol_v2::StatementDistributionMessage::Statement(
relay_parent,
statement.clone(),
),
@@ -327,7 +327,7 @@ fn useful_cluster_statement_from_non_cluster_peer_rejected() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -388,7 +388,7 @@ fn statement_from_non_cluster_originator_unexpected() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -465,7 +465,7 @@ fn seconded_statement_leads_to_request() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -593,8 +593,8 @@ fn cluster_statements_shared_seconded_first() {
assert_matches!(
&messages[0].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -604,8 +604,8 @@ fn cluster_statements_shared_seconded_first() {
assert_matches!(
&messages[1].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -699,8 +699,8 @@ fn cluster_accounts_for_implicit_view() {
overseer.recv().await,
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -749,8 +749,8 @@ fn cluster_accounts_for_implicit_view() {
&messages[0],
(
peers,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -836,10 +836,7 @@ fn cluster_messages_imported_after_confirmed_candidate_importable_check() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -971,10 +968,7 @@ fn cluster_messages_imported_after_new_leaf_importable_check() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -1191,7 +1185,7 @@ fn ensure_seconding_limit_is_respected() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1216,7 +1210,7 @@ fn ensure_seconding_limit_is_respected() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1241,7 +1235,7 @@ fn ensure_seconding_limit_is_respected() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -17,9 +17,7 @@
use super::*;
use bitvec::order::Lsb0;
use polkadot_node_network_protocol::vstaging::{
BackedCandidateAcknowledgement, BackedCandidateManifest,
};
use polkadot_node_network_protocol::v2::{BackedCandidateAcknowledgement, BackedCandidateManifest};
use polkadot_node_subsystem::messages::CandidateBackingMessage;
use polkadot_primitives_test_helpers::make_candidate;
@@ -156,7 +154,7 @@ fn backed_candidate_leads_to_advertisement() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -181,7 +179,7 @@ fn backed_candidate_leads_to_advertisement() {
send_peer_message(
&mut overseer,
peer_b.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -210,9 +208,9 @@ fn backed_candidate_leads_to_advertisement() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
),
),
)
@@ -349,7 +347,7 @@ fn received_advertisement_before_confirmation_leads_to_request() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
)
.await;
@@ -534,7 +532,7 @@ fn received_advertisement_after_backing_leads_to_acknowledgement() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -603,9 +601,9 @@ fn received_advertisement_after_backing_leads_to_acknowledgement() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(ack),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(ack),
),
),
)
@@ -629,7 +627,7 @@ fn received_advertisement_after_backing_leads_to_acknowledgement() {
send_peer_message(
&mut overseer,
peer_d.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -654,8 +652,8 @@ fn received_advertisement_after_backing_leads_to_acknowledgement() {
assert_matches!(
&messages[0].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(ack)
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(ack)
)) if *ack == expected_ack
);
}
@@ -782,7 +780,7 @@ fn received_advertisement_after_confirmation_before_backing() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -842,7 +840,7 @@ fn received_advertisement_after_confirmation_before_backing() {
send_peer_message(
&mut overseer,
peer_d.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -951,7 +949,7 @@ fn additional_statements_are_shared_after_manifest_exchange() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -1066,9 +1064,9 @@ fn additional_statements_are_shared_after_manifest_exchange() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(ack),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(ack),
),
),
)
@@ -1104,7 +1102,7 @@ fn additional_statements_are_shared_after_manifest_exchange() {
send_peer_message(
&mut overseer,
peer_d.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -1130,15 +1128,15 @@ fn additional_statements_are_shared_after_manifest_exchange() {
assert_matches!(
&messages[0].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateKnown(ack)
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateKnown(ack)
)) if *ack == expected_ack
);
assert_matches!(
&messages[1].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(r, s)
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(r, s)
)) if *r == relay_parent && s.unchecked_payload() == &CompactStatement::Seconded(candidate_hash) && s.unchecked_validator_index() == v_e
);
}
@@ -1281,7 +1279,7 @@ fn advertisement_sent_when_peer_enters_relay_parent_view() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1306,7 +1304,7 @@ fn advertisement_sent_when_peer_enters_relay_parent_view() {
send_peer_message(
&mut overseer,
peer_b.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1357,8 +1355,8 @@ fn advertisement_sent_when_peer_enters_relay_parent_view() {
assert_matches!(
&messages[0].1,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest)
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest)
)) => {
assert_eq!(*manifest, expected_manifest);
}
@@ -1504,7 +1502,7 @@ fn advertisement_not_re_sent_when_peer_re_enters_view() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1529,7 +1527,7 @@ fn advertisement_not_re_sent_when_peer_re_enters_view() {
send_peer_message(
&mut overseer,
peer_b.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1558,9 +1556,9 @@ fn advertisement_not_re_sent_when_peer_re_enters_view() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
),
),
)
@@ -1692,7 +1690,7 @@ fn grid_statements_imported_to_backing() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -1907,7 +1905,7 @@ fn advertisements_rejected_from_incorrect_peers() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -1925,7 +1923,7 @@ fn advertisements_rejected_from_incorrect_peers() {
send_peer_message(
&mut overseer,
peer_b.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
)
.await;
@@ -2029,7 +2027,7 @@ fn manifest_rejected_with_unknown_relay_parent() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -2131,7 +2129,7 @@ fn manifest_rejected_when_not_a_validator() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -2238,7 +2236,7 @@ fn manifest_rejected_when_group_does_not_match_para() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -2370,7 +2368,7 @@ fn peer_reported_for_advertisement_conflicting_with_confirmed_candidate() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -2439,7 +2437,7 @@ fn peer_reported_for_advertisement_conflicting_with_confirmed_candidate() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
)
.await;
@@ -31,7 +31,7 @@ use polkadot_node_subsystem::messages::{
};
use polkadot_node_subsystem_test_helpers as test_helpers;
use polkadot_node_subsystem_util::TimeoutExt;
use polkadot_primitives::vstaging::{
use polkadot_primitives::{
AssignmentPair, AsyncBackingParams, BlockNumber, CommittedCandidateReceipt, CoreState,
GroupRotationInfo, HeadData, Header, IndexedVec, PersistedValidationData, ScheduledCore,
SessionIndex, SessionInfo, ValidatorPair,
@@ -380,7 +380,7 @@ async fn handle_leaf_activation(
assert_matches!(
virtual_overseer.recv().await,
AllMessages::RuntimeApi(
RuntimeApiMessage::Request(parent, RuntimeApiRequest::StagingAsyncBackingParams(tx))
RuntimeApiMessage::Request(parent, RuntimeApiRequest::AsyncBackingParams(tx))
) if parent == *hash => {
tx.send(Ok(test_state.config.async_backing_params.unwrap_or(DEFAULT_ASYNC_BACKING_PARAMETERS))).unwrap();
}
@@ -479,7 +479,7 @@ async fn handle_sent_request(
assert_eq!(requests.len(), 1);
assert_matches!(
requests.pop().unwrap(),
Requests::AttestedCandidateVStaging(outgoing) => {
Requests::AttestedCandidateV2(outgoing) => {
assert_eq!(outgoing.peer, Recipient::Peer(peer));
assert_eq!(outgoing.payload.candidate_hash, candidate_hash);
assert_eq!(outgoing.payload.mask, mask);
@@ -537,7 +537,7 @@ async fn connect_peer(
NetworkBridgeEvent::PeerConnected(
peer,
ObservedRole::Authority,
ValidationVersion::VStaging.into(),
ValidationVersion::V2.into(),
authority_ids,
),
),
@@ -570,12 +570,12 @@ async fn send_peer_view_change(virtual_overseer: &mut VirtualOverseer, peer: Pee
async fn send_peer_message(
virtual_overseer: &mut VirtualOverseer,
peer: PeerId,
message: protocol_vstaging::StatementDistributionMessage,
message: protocol_v2::StatementDistributionMessage,
) {
virtual_overseer
.send(FromOrchestra::Communication {
msg: StatementDistributionMessage::NetworkBridgeUpdate(
NetworkBridgeEvent::PeerMessage(peer, Versioned::VStaging(message)),
NetworkBridgeEvent::PeerMessage(peer, Versioned::V2(message)),
),
})
.await;
@@ -19,7 +19,7 @@ use super::*;
use bitvec::order::Lsb0;
use parity_scale_codec::{Decode, Encode};
use polkadot_node_network_protocol::{
request_response::vstaging as request_vstaging, vstaging::BackedCandidateManifest,
request_response::v2 as request_v2, v2::BackedCandidateManifest,
};
use polkadot_primitives_test_helpers::make_candidate;
use sc_network::config::{
@@ -109,10 +109,7 @@ fn cluster_peer_allowed_to_send_incomplete_statements() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -164,9 +161,9 @@ fn cluster_peer_allowed_to_send_incomplete_statements() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(hash, statement),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(hash, statement),
),
),
)
@@ -304,7 +301,7 @@ fn peer_reported_for_providing_statements_meant_to_be_masked_out() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -376,7 +373,7 @@ fn peer_reported_for_providing_statements_meant_to_be_masked_out() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -453,7 +450,7 @@ fn peer_reported_for_providing_statements_meant_to_be_masked_out() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -568,9 +565,7 @@ fn peer_reported_for_not_enough_statements() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest.clone()),
)
.await;
@@ -752,10 +747,7 @@ fn peer_reported_for_duplicate_statements() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -812,9 +804,9 @@ fn peer_reported_for_duplicate_statements() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(hash, statement),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(hash, statement),
),
),
)
@@ -916,10 +908,7 @@ fn peer_reported_for_providing_statements_with_invalid_signatures() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -1058,10 +1047,7 @@ fn peer_reported_for_providing_statements_with_wrong_validator_id() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
relay_parent,
a_seconded,
),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, a_seconded),
)
.await;
@@ -1191,7 +1177,7 @@ fn local_node_sanity_checks_incoming_requests() {
.send(RawIncomingRequest {
// Request from peer that received manifest.
peer: peer_c,
payload: request_vstaging::AttestedCandidateRequest {
payload: request_v2::AttestedCandidateRequest {
candidate_hash: candidate.hash(),
mask: mask.clone(),
}
@@ -1225,8 +1211,8 @@ fn local_node_sanity_checks_incoming_requests() {
overseer.recv().await,
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::Statement(
Versioned::V2(protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::Statement(
r,
s,
)
@@ -1250,7 +1236,7 @@ fn local_node_sanity_checks_incoming_requests() {
.send(RawIncomingRequest {
// Request from peer that received manifest.
peer: peer_d,
payload: request_vstaging::AttestedCandidateRequest {
payload: request_v2::AttestedCandidateRequest {
candidate_hash: candidate.hash(),
mask: mask.clone(),
}
@@ -1269,10 +1255,7 @@ fn local_node_sanity_checks_incoming_requests() {
let response = state
.send_request(
peer_c,
request_vstaging::AttestedCandidateRequest {
candidate_hash: candidate.hash(),
mask,
},
request_v2::AttestedCandidateRequest { candidate_hash: candidate.hash(), mask },
)
.await
.await;
@@ -1296,7 +1279,7 @@ fn local_node_sanity_checks_incoming_requests() {
let response = state
.send_request(
peer_c,
request_vstaging::AttestedCandidateRequest {
request_v2::AttestedCandidateRequest {
candidate_hash: candidate.hash(),
mask: mask.clone(),
},
@@ -1455,7 +1438,7 @@ fn local_node_respects_statement_mask() {
send_peer_message(
&mut overseer,
peer_a.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(relay_parent, statement),
protocol_v2::StatementDistributionMessage::Statement(relay_parent, statement),
)
.await;
@@ -1479,7 +1462,7 @@ fn local_node_respects_statement_mask() {
send_peer_message(
&mut overseer,
peer_b.clone(),
protocol_vstaging::StatementDistributionMessage::Statement(
protocol_v2::StatementDistributionMessage::Statement(
relay_parent,
statement_b.clone(),
),
@@ -1511,9 +1494,9 @@ fn local_node_respects_statement_mask() {
AllMessages:: NetworkBridgeTx(
NetworkBridgeTxMessage::SendValidationMessage(
peers,
Versioned::VStaging(
protocol_vstaging::ValidationProtocol::StatementDistribution(
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(manifest),
Versioned::V2(
protocol_v2::ValidationProtocol::StatementDistribution(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(manifest),
),
),
)
@@ -1547,19 +1530,16 @@ fn local_node_respects_statement_mask() {
let response = state
.send_request(
peer_c,
request_vstaging::AttestedCandidateRequest {
candidate_hash: candidate.hash(),
mask,
},
request_v2::AttestedCandidateRequest { candidate_hash: candidate.hash(), mask },
)
.await
.await;
let expected_statements = vec![statement_b];
assert_matches!(response, full_response => {
// Response is the same for vstaging.
let request_vstaging::AttestedCandidateResponse { candidate_receipt, persisted_validation_data, statements } =
request_vstaging::AttestedCandidateResponse::decode(
// Response is the same for v2.
let request_v2::AttestedCandidateResponse { candidate_receipt, persisted_validation_data, statements } =
request_v2::AttestedCandidateResponse::decode(
&mut full_response.result.expect("We should have a proper answer").as_ref(),
).expect("Decoding should work");
assert_eq!(candidate_receipt, candidate);
@@ -1683,7 +1663,7 @@ fn should_delay_before_retrying_dropped_requests() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)
@@ -1696,7 +1676,7 @@ fn should_delay_before_retrying_dropped_requests() {
assert_eq!(requests.len(), 1);
assert_matches!(
requests.pop().unwrap(),
Requests::AttestedCandidateVStaging(outgoing) => {
Requests::AttestedCandidateV2(outgoing) => {
assert_eq!(outgoing.peer, Recipient::Peer(peer_c));
assert_eq!(outgoing.payload.candidate_hash, candidate_hash_1);
assert_eq!(outgoing.payload.mask, mask);
@@ -1729,7 +1709,7 @@ fn should_delay_before_retrying_dropped_requests() {
send_peer_message(
&mut overseer,
peer_c.clone(),
protocol_vstaging::StatementDistributionMessage::BackedCandidateManifest(
protocol_v2::StatementDistributionMessage::BackedCandidateManifest(
manifest.clone(),
),
)