mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 21:41:12 +00:00
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:
@@ -26,8 +26,8 @@ use polkadot_node_network_protocol::{
|
||||
self as net_protocol,
|
||||
grid_topology::{RandomRouting, RequiredRouting, SessionGridTopologies, SessionGridTopology},
|
||||
peer_set::{ValidationVersion, MAX_NOTIFICATION_SIZE},
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, PeerId, UnifiedReputationChange as Rep,
|
||||
Versioned, VersionedValidationProtocol, View,
|
||||
v1 as protocol_v1, v2 as protocol_v2, PeerId, UnifiedReputationChange as Rep, Versioned,
|
||||
VersionedValidationProtocol, View,
|
||||
};
|
||||
use polkadot_node_primitives::approval::{
|
||||
AssignmentCert, BlockApprovalMeta, IndirectAssignmentCert, IndirectSignedApprovalVote,
|
||||
@@ -602,9 +602,7 @@ impl State {
|
||||
{
|
||||
match msg {
|
||||
Versioned::V1(protocol_v1::ApprovalDistributionMessage::Assignments(assignments)) |
|
||||
Versioned::VStaging(protocol_vstaging::ApprovalDistributionMessage::Assignments(
|
||||
assignments,
|
||||
)) => {
|
||||
Versioned::V2(protocol_v2::ApprovalDistributionMessage::Assignments(assignments)) => {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
@@ -644,9 +642,7 @@ impl State {
|
||||
}
|
||||
},
|
||||
Versioned::V1(protocol_v1::ApprovalDistributionMessage::Approvals(approvals)) |
|
||||
Versioned::VStaging(protocol_vstaging::ApprovalDistributionMessage::Approvals(
|
||||
approvals,
|
||||
)) => {
|
||||
Versioned::V2(protocol_v2::ApprovalDistributionMessage::Approvals(approvals)) => {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = %peer_id,
|
||||
@@ -1060,7 +1056,7 @@ impl State {
|
||||
route_random
|
||||
};
|
||||
|
||||
let (v1_peers, vstaging_peers) = {
|
||||
let (v1_peers, v2_peers) = {
|
||||
let peer_data = &self.peer_data;
|
||||
let peers = entry
|
||||
.known_by
|
||||
@@ -1090,9 +1086,9 @@ impl State {
|
||||
}
|
||||
|
||||
let v1_peers = filter_peers_by_version(&peers, ValidationVersion::V1);
|
||||
let vstaging_peers = filter_peers_by_version(&peers, ValidationVersion::VStaging);
|
||||
let v2_peers = filter_peers_by_version(&peers, ValidationVersion::V2);
|
||||
|
||||
(v1_peers, vstaging_peers)
|
||||
(v1_peers, v2_peers)
|
||||
};
|
||||
|
||||
if !v1_peers.is_empty() {
|
||||
@@ -1103,10 +1099,10 @@ impl State {
|
||||
.await;
|
||||
}
|
||||
|
||||
if !vstaging_peers.is_empty() {
|
||||
if !v2_peers.is_empty() {
|
||||
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
vstaging_peers,
|
||||
versioned_assignments_packet(ValidationVersion::VStaging, assignments.clone()),
|
||||
v2_peers,
|
||||
versioned_assignments_packet(ValidationVersion::V2, assignments.clone()),
|
||||
))
|
||||
.await;
|
||||
}
|
||||
@@ -1395,7 +1391,7 @@ impl State {
|
||||
in_topology || knowledge.sent.contains(message_subject, MessageKind::Assignment)
|
||||
};
|
||||
|
||||
let (v1_peers, vstaging_peers) = {
|
||||
let (v1_peers, v2_peers) = {
|
||||
let peer_data = &self.peer_data;
|
||||
let peers = entry
|
||||
.known_by
|
||||
@@ -1425,9 +1421,9 @@ impl State {
|
||||
}
|
||||
|
||||
let v1_peers = filter_peers_by_version(&peers, ValidationVersion::V1);
|
||||
let vstaging_peers = filter_peers_by_version(&peers, ValidationVersion::VStaging);
|
||||
let v2_peers = filter_peers_by_version(&peers, ValidationVersion::V2);
|
||||
|
||||
(v1_peers, vstaging_peers)
|
||||
(v1_peers, v2_peers)
|
||||
};
|
||||
|
||||
let approvals = vec![vote];
|
||||
@@ -1440,10 +1436,10 @@ impl State {
|
||||
.await;
|
||||
}
|
||||
|
||||
if !vstaging_peers.is_empty() {
|
||||
if !v2_peers.is_empty() {
|
||||
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
vstaging_peers,
|
||||
versioned_approvals_packet(ValidationVersion::VStaging, approvals),
|
||||
v2_peers,
|
||||
versioned_approvals_packet(ValidationVersion::V2, approvals),
|
||||
))
|
||||
.await;
|
||||
}
|
||||
@@ -2017,9 +2013,9 @@ fn versioned_approvals_packet(
|
||||
Versioned::V1(protocol_v1::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v1::ApprovalDistributionMessage::Approvals(approvals),
|
||||
)),
|
||||
ValidationVersion::VStaging =>
|
||||
Versioned::VStaging(protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_vstaging::ApprovalDistributionMessage::Approvals(approvals),
|
||||
ValidationVersion::V2 =>
|
||||
Versioned::V2(protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v2::ApprovalDistributionMessage::Approvals(approvals),
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -2033,9 +2029,9 @@ fn versioned_assignments_packet(
|
||||
Versioned::V1(protocol_v1::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v1::ApprovalDistributionMessage::Assignments(assignments),
|
||||
)),
|
||||
ValidationVersion::VStaging =>
|
||||
Versioned::VStaging(protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_vstaging::ApprovalDistributionMessage::Assignments(assignments),
|
||||
ValidationVersion::V2 =>
|
||||
Versioned::V2(protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v2::ApprovalDistributionMessage::Assignments(assignments),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2388,9 +2388,9 @@ fn import_versioned_approval() {
|
||||
let _ = test_harness(state, |mut virtual_overseer| async move {
|
||||
let overseer = &mut virtual_overseer;
|
||||
// All peers are aware of relay parent.
|
||||
setup_peer_with_view(overseer, &peer_a, ValidationVersion::VStaging, view![hash]).await;
|
||||
setup_peer_with_view(overseer, &peer_a, ValidationVersion::V2, view![hash]).await;
|
||||
setup_peer_with_view(overseer, &peer_b, ValidationVersion::V1, view![hash]).await;
|
||||
setup_peer_with_view(overseer, &peer_c, ValidationVersion::VStaging, view![hash]).await;
|
||||
setup_peer_with_view(overseer, &peer_c, ValidationVersion::V2, view![hash]).await;
|
||||
|
||||
// new block `hash_a` with 1 candidates
|
||||
let meta = BlockApprovalMeta {
|
||||
@@ -2431,8 +2431,8 @@ fn import_versioned_approval() {
|
||||
overseer_recv(overseer).await,
|
||||
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
peers,
|
||||
Versioned::VStaging(protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_vstaging::ApprovalDistributionMessage::Assignments(assignments)
|
||||
Versioned::V2(protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v2::ApprovalDistributionMessage::Assignments(assignments)
|
||||
))
|
||||
)) => {
|
||||
assert_eq!(peers.len(), 2);
|
||||
@@ -2450,8 +2450,8 @@ fn import_versioned_approval() {
|
||||
validator: validator_index,
|
||||
signature: dummy_signature(),
|
||||
};
|
||||
let msg = protocol_vstaging::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
|
||||
send_message_from_peer(overseer, &peer_a, Versioned::VStaging(msg)).await;
|
||||
let msg = protocol_v2::ApprovalDistributionMessage::Approvals(vec![approval.clone()]);
|
||||
send_message_from_peer(overseer, &peer_a, Versioned::V2(msg)).await;
|
||||
|
||||
assert_matches!(
|
||||
overseer_recv(overseer).await,
|
||||
@@ -2483,8 +2483,8 @@ fn import_versioned_approval() {
|
||||
overseer_recv(overseer).await,
|
||||
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
peers,
|
||||
Versioned::VStaging(protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_vstaging::ApprovalDistributionMessage::Approvals(approvals)
|
||||
Versioned::V2(protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
protocol_v2::ApprovalDistributionMessage::Approvals(approvals)
|
||||
))
|
||||
)) => {
|
||||
assert_eq!(peers, vec![peer_c]);
|
||||
|
||||
@@ -31,8 +31,8 @@ use polkadot_node_network_protocol::{
|
||||
GridNeighbors, RandomRouting, RequiredRouting, SessionBoundGridTopologyStorage,
|
||||
},
|
||||
peer_set::{ProtocolVersion, ValidationVersion},
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, OurView, PeerId,
|
||||
UnifiedReputationChange as Rep, Versioned, View,
|
||||
v1 as protocol_v1, v2 as protocol_v2, OurView, PeerId, UnifiedReputationChange as Rep,
|
||||
Versioned, View,
|
||||
};
|
||||
use polkadot_node_subsystem::{
|
||||
jaeger, messages::*, overseer, ActiveLeavesUpdate, FromOrchestra, OverseerSignal, PerLeafSpan,
|
||||
@@ -96,8 +96,8 @@ impl BitfieldGossipMessage {
|
||||
self.relay_parent,
|
||||
self.signed_availability.into(),
|
||||
)),
|
||||
Some(ValidationVersion::VStaging) =>
|
||||
Versioned::VStaging(protocol_vstaging::BitfieldDistributionMessage::Bitfield(
|
||||
Some(ValidationVersion::V2) =>
|
||||
Versioned::V2(protocol_v2::BitfieldDistributionMessage::Bitfield(
|
||||
self.relay_parent,
|
||||
self.signed_availability.into(),
|
||||
)),
|
||||
@@ -502,8 +502,7 @@ async fn relay_message<Context>(
|
||||
};
|
||||
|
||||
let v1_interested_peers = filter_by_version(&interested_peers, ValidationVersion::V1);
|
||||
let vstaging_interested_peers =
|
||||
filter_by_version(&interested_peers, ValidationVersion::VStaging);
|
||||
let v2_interested_peers = filter_by_version(&interested_peers, ValidationVersion::V2);
|
||||
|
||||
if !v1_interested_peers.is_empty() {
|
||||
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
@@ -513,10 +512,10 @@ async fn relay_message<Context>(
|
||||
.await;
|
||||
}
|
||||
|
||||
if !vstaging_interested_peers.is_empty() {
|
||||
if !v2_interested_peers.is_empty() {
|
||||
ctx.send_message(NetworkBridgeTxMessage::SendValidationMessage(
|
||||
vstaging_interested_peers,
|
||||
message.into_validation_protocol(ValidationVersion::VStaging.into()),
|
||||
v2_interested_peers,
|
||||
message.into_validation_protocol(ValidationVersion::V2.into()),
|
||||
))
|
||||
.await
|
||||
}
|
||||
@@ -538,7 +537,7 @@ async fn process_incoming_peer_message<Context>(
|
||||
relay_parent,
|
||||
bitfield,
|
||||
)) => (relay_parent, bitfield),
|
||||
Versioned::VStaging(protocol_vstaging::BitfieldDistributionMessage::Bitfield(
|
||||
Versioned::V2(protocol_v2::BitfieldDistributionMessage::Bitfield(
|
||||
relay_parent,
|
||||
bitfield,
|
||||
)) => (relay_parent, bitfield),
|
||||
|
||||
@@ -1111,9 +1111,9 @@ fn network_protocol_versioning() {
|
||||
let peer_c = PeerId::random();
|
||||
|
||||
let peers = [
|
||||
(peer_a, ValidationVersion::VStaging),
|
||||
(peer_a, ValidationVersion::V2),
|
||||
(peer_b, ValidationVersion::V1),
|
||||
(peer_c, ValidationVersion::VStaging),
|
||||
(peer_c, ValidationVersion::V2),
|
||||
];
|
||||
|
||||
// validator 0 key pair
|
||||
@@ -1173,7 +1173,7 @@ fn network_protocol_versioning() {
|
||||
&Default::default(),
|
||||
NetworkBridgeEvent::PeerMessage(
|
||||
peer_a,
|
||||
msg.clone().into_network_message(ValidationVersion::VStaging.into()),
|
||||
msg.clone().into_network_message(ValidationVersion::V2.into()),
|
||||
),
|
||||
&mut rng,
|
||||
));
|
||||
@@ -1201,14 +1201,14 @@ fn network_protocol_versioning() {
|
||||
}
|
||||
);
|
||||
|
||||
// vstaging gossip
|
||||
// v2 gossip
|
||||
assert_matches!(
|
||||
handle.recv().await,
|
||||
AllMessages::NetworkBridgeTx(
|
||||
NetworkBridgeTxMessage::SendValidationMessage(peers, send_msg),
|
||||
) => {
|
||||
assert_eq!(peers, vec![peer_c]);
|
||||
assert_eq!(send_msg, msg.clone().into_validation_protocol(ValidationVersion::VStaging.into()));
|
||||
assert_eq!(send_msg, msg.clone().into_validation_protocol(ValidationVersion::V2.into()));
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ use polkadot_node_network_protocol::{
|
||||
CollationVersion, PeerSet, PeerSetProtocolNames, PerPeerSet, ProtocolVersion,
|
||||
ValidationVersion,
|
||||
},
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, ObservedRole, OurView, PeerId,
|
||||
v1 as protocol_v1, v2 as protocol_v2, ObservedRole, OurView, PeerId,
|
||||
UnifiedReputationChange as Rep, View,
|
||||
};
|
||||
|
||||
@@ -262,13 +262,13 @@ where
|
||||
),
|
||||
&metrics,
|
||||
),
|
||||
ValidationVersion::VStaging => send_message(
|
||||
ValidationVersion::V2 => send_message(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Validation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_vstaging::ValidationProtocol>::ViewUpdate(
|
||||
WireMessage::<protocol_v2::ValidationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
),
|
||||
&metrics,
|
||||
@@ -304,13 +304,13 @@ where
|
||||
),
|
||||
&metrics,
|
||||
),
|
||||
CollationVersion::VStaging => send_message(
|
||||
CollationVersion::V2 => send_message(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Collation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_vstaging::CollationProtocol>::ViewUpdate(
|
||||
WireMessage::<protocol_v2::CollationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
),
|
||||
&metrics,
|
||||
@@ -465,9 +465,9 @@ where
|
||||
&metrics,
|
||||
)
|
||||
} else if expected_versions[PeerSet::Validation] ==
|
||||
Some(ValidationVersion::VStaging.into())
|
||||
Some(ValidationVersion::V2.into())
|
||||
{
|
||||
handle_peer_messages::<protocol_vstaging::ValidationProtocol, _>(
|
||||
handle_peer_messages::<protocol_v2::ValidationProtocol, _>(
|
||||
remote,
|
||||
PeerSet::Validation,
|
||||
&mut shared.0.lock().validation_peers,
|
||||
@@ -507,9 +507,9 @@ where
|
||||
&metrics,
|
||||
)
|
||||
} else if expected_versions[PeerSet::Collation] ==
|
||||
Some(CollationVersion::VStaging.into())
|
||||
Some(CollationVersion::V2.into())
|
||||
{
|
||||
handle_peer_messages::<protocol_vstaging::CollationProtocol, _>(
|
||||
handle_peer_messages::<protocol_v2::CollationProtocol, _>(
|
||||
remote,
|
||||
PeerSet::Collation,
|
||||
&mut shared.0.lock().collation_peers,
|
||||
@@ -813,10 +813,8 @@ fn update_our_view<Net, Context>(
|
||||
let v1_validation_peers = filter_by_version(&validation_peers, ValidationVersion::V1.into());
|
||||
let v1_collation_peers = filter_by_version(&collation_peers, CollationVersion::V1.into());
|
||||
|
||||
let vstaging_validation_peers =
|
||||
filter_by_version(&validation_peers, ValidationVersion::VStaging.into());
|
||||
let vstaging_collation_peers =
|
||||
filter_by_version(&collation_peers, ValidationVersion::VStaging.into());
|
||||
let v2_validation_peers = filter_by_version(&validation_peers, ValidationVersion::V2.into());
|
||||
let v2_collation_peers = filter_by_version(&collation_peers, ValidationVersion::V2.into());
|
||||
|
||||
send_validation_message_v1(
|
||||
net,
|
||||
@@ -834,17 +832,17 @@ fn update_our_view<Net, Context>(
|
||||
metrics,
|
||||
);
|
||||
|
||||
send_validation_message_vstaging(
|
||||
send_validation_message_v2(
|
||||
net,
|
||||
vstaging_validation_peers,
|
||||
v2_validation_peers,
|
||||
peerset_protocol_names,
|
||||
WireMessage::ViewUpdate(new_view.clone()),
|
||||
metrics,
|
||||
);
|
||||
|
||||
send_collation_message_vstaging(
|
||||
send_collation_message_v2(
|
||||
net,
|
||||
vstaging_collation_peers,
|
||||
v2_collation_peers,
|
||||
peerset_protocol_names,
|
||||
WireMessage::ViewUpdate(new_view),
|
||||
metrics,
|
||||
@@ -955,36 +953,36 @@ fn send_collation_message_v1(
|
||||
);
|
||||
}
|
||||
|
||||
fn send_validation_message_vstaging(
|
||||
fn send_validation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_vstaging::ValidationProtocol>,
|
||||
message: WireMessage<protocol_v2::ValidationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Validation,
|
||||
ValidationVersion::VStaging.into(),
|
||||
ValidationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
fn send_collation_message_vstaging(
|
||||
fn send_collation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_vstaging::CollationProtocol>,
|
||||
message: WireMessage<protocol_v2::CollationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Collation,
|
||||
CollationVersion::VStaging.into(),
|
||||
CollationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
|
||||
@@ -1216,10 +1216,10 @@ fn network_protocol_versioning_view_update() {
|
||||
|
||||
let peer_ids: Vec<_> = (0..4).map(|_| PeerId::random()).collect();
|
||||
let peers = [
|
||||
(peer_ids[0], PeerSet::Validation, ValidationVersion::VStaging),
|
||||
(peer_ids[0], PeerSet::Validation, ValidationVersion::V2),
|
||||
(peer_ids[1], PeerSet::Collation, ValidationVersion::V1),
|
||||
(peer_ids[2], PeerSet::Validation, ValidationVersion::V1),
|
||||
(peer_ids[3], PeerSet::Collation, ValidationVersion::VStaging),
|
||||
(peer_ids[3], PeerSet::Collation, ValidationVersion::V2),
|
||||
];
|
||||
|
||||
let head = Hash::repeat_byte(1);
|
||||
@@ -1245,8 +1245,8 @@ fn network_protocol_versioning_view_update() {
|
||||
ValidationVersion::V1 =>
|
||||
WireMessage::<protocol_v1::ValidationProtocol>::ViewUpdate(view.clone())
|
||||
.encode(),
|
||||
ValidationVersion::VStaging =>
|
||||
WireMessage::<protocol_vstaging::ValidationProtocol>::ViewUpdate(view.clone())
|
||||
ValidationVersion::V2 =>
|
||||
WireMessage::<protocol_v2::ValidationProtocol>::ViewUpdate(view.clone())
|
||||
.encode(),
|
||||
};
|
||||
assert_network_actions_contains(
|
||||
@@ -1268,12 +1268,7 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
let peer = PeerId::random();
|
||||
|
||||
network_handle
|
||||
.connect_peer(
|
||||
peer,
|
||||
ValidationVersion::VStaging,
|
||||
PeerSet::Validation,
|
||||
ObservedRole::Full,
|
||||
)
|
||||
.connect_peer(peer, ValidationVersion::V2, PeerSet::Validation, ObservedRole::Full)
|
||||
.await;
|
||||
|
||||
// bridge will inform about all connected peers.
|
||||
@@ -1282,7 +1277,7 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
NetworkBridgeEvent::PeerConnected(
|
||||
peer,
|
||||
ObservedRole::Full,
|
||||
ValidationVersion::VStaging.into(),
|
||||
ValidationVersion::V2.into(),
|
||||
None,
|
||||
),
|
||||
&mut virtual_overseer,
|
||||
@@ -1297,9 +1292,9 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
}
|
||||
|
||||
let approval_distribution_message =
|
||||
protocol_vstaging::ApprovalDistributionMessage::Approvals(Vec::new());
|
||||
protocol_v2::ApprovalDistributionMessage::Approvals(Vec::new());
|
||||
|
||||
let msg = protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
let msg = protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
approval_distribution_message.clone(),
|
||||
);
|
||||
|
||||
@@ -1315,7 +1310,7 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::ApprovalDistribution(
|
||||
ApprovalDistributionMessage::NetworkBridgeUpdate(
|
||||
NetworkBridgeEvent::PeerMessage(p, Versioned::VStaging(m))
|
||||
NetworkBridgeEvent::PeerMessage(p, Versioned::V2(m))
|
||||
)
|
||||
) => {
|
||||
assert_eq!(p, peer);
|
||||
@@ -1330,10 +1325,10 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
signature: sp_core::crypto::UncheckedFrom::unchecked_from([1u8; 64]),
|
||||
};
|
||||
let statement_distribution_message =
|
||||
protocol_vstaging::StatementDistributionMessage::V1Compatibility(
|
||||
protocol_v2::StatementDistributionMessage::V1Compatibility(
|
||||
protocol_v1::StatementDistributionMessage::LargeStatement(metadata),
|
||||
);
|
||||
let msg = protocol_vstaging::ValidationProtocol::StatementDistribution(
|
||||
let msg = protocol_v2::ValidationProtocol::StatementDistribution(
|
||||
statement_distribution_message.clone(),
|
||||
);
|
||||
|
||||
@@ -1349,7 +1344,7 @@ fn network_protocol_versioning_subsystem_msg() {
|
||||
virtual_overseer.recv().await,
|
||||
AllMessages::StatementDistribution(
|
||||
StatementDistributionMessage::NetworkBridgeUpdate(
|
||||
NetworkBridgeEvent::PeerMessage(p, Versioned::VStaging(m))
|
||||
NetworkBridgeEvent::PeerMessage(p, Versioned::V2(m))
|
||||
)
|
||||
) => {
|
||||
assert_eq!(p, peer);
|
||||
|
||||
@@ -20,7 +20,7 @@ use super::*;
|
||||
use polkadot_node_network_protocol::{
|
||||
peer_set::{CollationVersion, PeerSet, PeerSetProtocolNames, ValidationVersion},
|
||||
request_response::ReqProtocolNames,
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, PeerId, Versioned,
|
||||
v1 as protocol_v1, v2 as protocol_v2, PeerId, Versioned,
|
||||
};
|
||||
|
||||
use polkadot_node_subsystem::{
|
||||
@@ -198,7 +198,7 @@ where
|
||||
WireMessage::ProtocolMessage(msg),
|
||||
&metrics,
|
||||
),
|
||||
Versioned::VStaging(msg) => send_validation_message_vstaging(
|
||||
Versioned::V2(msg) => send_validation_message_v2(
|
||||
&mut network_service,
|
||||
peers,
|
||||
peerset_protocol_names,
|
||||
@@ -223,7 +223,7 @@ where
|
||||
WireMessage::ProtocolMessage(msg),
|
||||
&metrics,
|
||||
),
|
||||
Versioned::VStaging(msg) => send_validation_message_vstaging(
|
||||
Versioned::V2(msg) => send_validation_message_v2(
|
||||
&mut network_service,
|
||||
peers,
|
||||
peerset_protocol_names,
|
||||
@@ -248,7 +248,7 @@ where
|
||||
WireMessage::ProtocolMessage(msg),
|
||||
&metrics,
|
||||
),
|
||||
Versioned::VStaging(msg) => send_collation_message_vstaging(
|
||||
Versioned::V2(msg) => send_collation_message_v2(
|
||||
&mut network_service,
|
||||
peers,
|
||||
peerset_protocol_names,
|
||||
@@ -273,7 +273,7 @@ where
|
||||
WireMessage::ProtocolMessage(msg),
|
||||
&metrics,
|
||||
),
|
||||
Versioned::VStaging(msg) => send_collation_message_vstaging(
|
||||
Versioned::V2(msg) => send_collation_message_v2(
|
||||
&mut network_service,
|
||||
peers,
|
||||
peerset_protocol_names,
|
||||
@@ -296,13 +296,11 @@ where
|
||||
Requests::AvailableDataFetchingV1(_) =>
|
||||
metrics.on_message("available_data_fetching_v1"),
|
||||
Requests::CollationFetchingV1(_) => metrics.on_message("collation_fetching_v1"),
|
||||
Requests::CollationFetchingVStaging(_) =>
|
||||
metrics.on_message("collation_fetching_vstaging"),
|
||||
Requests::CollationFetchingV2(_) => metrics.on_message("collation_fetching_v2"),
|
||||
Requests::PoVFetchingV1(_) => metrics.on_message("pov_fetching_v1"),
|
||||
Requests::DisputeSendingV1(_) => metrics.on_message("dispute_sending_v1"),
|
||||
Requests::StatementFetchingV1(_) => metrics.on_message("statement_fetching_v1"),
|
||||
Requests::AttestedCandidateVStaging(_) =>
|
||||
metrics.on_message("attested_candidate_vstaging"),
|
||||
Requests::AttestedCandidateV2(_) => metrics.on_message("attested_candidate_v2"),
|
||||
}
|
||||
|
||||
network_service
|
||||
@@ -425,36 +423,36 @@ fn send_collation_message_v1(
|
||||
);
|
||||
}
|
||||
|
||||
fn send_validation_message_vstaging(
|
||||
fn send_validation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_vstaging::ValidationProtocol>,
|
||||
message: WireMessage<protocol_v2::ValidationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Validation,
|
||||
ValidationVersion::VStaging.into(),
|
||||
ValidationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
fn send_collation_message_vstaging(
|
||||
fn send_collation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_vstaging::CollationProtocol>,
|
||||
message: WireMessage<protocol_v2::CollationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Collation,
|
||||
CollationVersion::VStaging.into(),
|
||||
CollationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
|
||||
@@ -341,10 +341,10 @@ fn network_protocol_versioning_send() {
|
||||
|
||||
let peer_ids: Vec<_> = (0..4).map(|_| PeerId::random()).collect();
|
||||
let peers = [
|
||||
(peer_ids[0], PeerSet::Validation, ValidationVersion::VStaging),
|
||||
(peer_ids[0], PeerSet::Validation, ValidationVersion::V2),
|
||||
(peer_ids[1], PeerSet::Collation, ValidationVersion::V1),
|
||||
(peer_ids[2], PeerSet::Validation, ValidationVersion::V1),
|
||||
(peer_ids[3], PeerSet::Collation, ValidationVersion::VStaging),
|
||||
(peer_ids[3], PeerSet::Collation, ValidationVersion::V2),
|
||||
];
|
||||
|
||||
for &(peer_id, peer_set, version) in &peers {
|
||||
@@ -359,9 +359,9 @@ fn network_protocol_versioning_send() {
|
||||
|
||||
{
|
||||
let approval_distribution_message =
|
||||
protocol_vstaging::ApprovalDistributionMessage::Approvals(Vec::new());
|
||||
protocol_v2::ApprovalDistributionMessage::Approvals(Vec::new());
|
||||
|
||||
let msg = protocol_vstaging::ValidationProtocol::ApprovalDistribution(
|
||||
let msg = protocol_v2::ValidationProtocol::ApprovalDistribution(
|
||||
approval_distribution_message.clone(),
|
||||
);
|
||||
|
||||
@@ -372,7 +372,7 @@ fn network_protocol_versioning_send() {
|
||||
.send(FromOrchestra::Communication {
|
||||
msg: NetworkBridgeTxMessage::SendValidationMessage(
|
||||
receivers.clone(),
|
||||
Versioned::VStaging(msg.clone()),
|
||||
Versioned::V2(msg.clone()),
|
||||
),
|
||||
})
|
||||
.timeout(TIMEOUT)
|
||||
@@ -398,15 +398,14 @@ fn network_protocol_versioning_send() {
|
||||
// send a collation protocol message.
|
||||
|
||||
{
|
||||
let collator_protocol_message = protocol_vstaging::CollatorProtocolMessage::Declare(
|
||||
let collator_protocol_message = protocol_v2::CollatorProtocolMessage::Declare(
|
||||
Sr25519Keyring::Alice.public().into(),
|
||||
0_u32.into(),
|
||||
dummy_collator_signature(),
|
||||
);
|
||||
|
||||
let msg = protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
collator_protocol_message.clone(),
|
||||
);
|
||||
let msg =
|
||||
protocol_v2::CollationProtocol::CollatorProtocol(collator_protocol_message.clone());
|
||||
|
||||
let receivers = vec![peer_ids[1], peer_ids[2]];
|
||||
|
||||
@@ -414,7 +413,7 @@ fn network_protocol_versioning_send() {
|
||||
.send(FromOrchestra::Communication {
|
||||
msg: NetworkBridgeTxMessage::SendCollationMessages(vec![(
|
||||
receivers.clone(),
|
||||
Versioned::VStaging(msg.clone()),
|
||||
Versioned::V2(msg.clone()),
|
||||
)]),
|
||||
})
|
||||
.await;
|
||||
|
||||
@@ -22,8 +22,7 @@ use futures::{future::BoxFuture, stream::FuturesUnordered};
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
request_response::{
|
||||
incoming::OutgoingResponse, v1 as protocol_v1, vstaging as protocol_vstaging,
|
||||
IncomingRequest,
|
||||
incoming::OutgoingResponse, v1 as protocol_v1, v2 as protocol_v2, IncomingRequest,
|
||||
},
|
||||
PeerId,
|
||||
};
|
||||
@@ -89,7 +88,7 @@ pub struct WaitingCollationFetches {
|
||||
/// Backwards-compatible wrapper for incoming collations requests.
|
||||
pub enum VersionedCollationRequest {
|
||||
V1(IncomingRequest<protocol_v1::CollationFetchingRequest>),
|
||||
VStaging(IncomingRequest<protocol_vstaging::CollationFetchingRequest>),
|
||||
V2(IncomingRequest<protocol_v2::CollationFetchingRequest>),
|
||||
}
|
||||
|
||||
impl From<IncomingRequest<protocol_v1::CollationFetchingRequest>> for VersionedCollationRequest {
|
||||
@@ -98,11 +97,9 @@ impl From<IncomingRequest<protocol_v1::CollationFetchingRequest>> for VersionedC
|
||||
}
|
||||
}
|
||||
|
||||
impl From<IncomingRequest<protocol_vstaging::CollationFetchingRequest>>
|
||||
for VersionedCollationRequest
|
||||
{
|
||||
fn from(req: IncomingRequest<protocol_vstaging::CollationFetchingRequest>) -> Self {
|
||||
Self::VStaging(req)
|
||||
impl From<IncomingRequest<protocol_v2::CollationFetchingRequest>> for VersionedCollationRequest {
|
||||
fn from(req: IncomingRequest<protocol_v2::CollationFetchingRequest>) -> Self {
|
||||
Self::V2(req)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +108,7 @@ impl VersionedCollationRequest {
|
||||
pub fn para_id(&self) -> ParaId {
|
||||
match self {
|
||||
VersionedCollationRequest::V1(req) => req.payload.para_id,
|
||||
VersionedCollationRequest::VStaging(req) => req.payload.para_id,
|
||||
VersionedCollationRequest::V2(req) => req.payload.para_id,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +116,7 @@ impl VersionedCollationRequest {
|
||||
pub fn relay_parent(&self) -> Hash {
|
||||
match self {
|
||||
VersionedCollationRequest::V1(req) => req.payload.relay_parent,
|
||||
VersionedCollationRequest::VStaging(req) => req.payload.relay_parent,
|
||||
VersionedCollationRequest::V2(req) => req.payload.relay_parent,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +124,7 @@ impl VersionedCollationRequest {
|
||||
pub fn peer_id(&self) -> PeerId {
|
||||
match self {
|
||||
VersionedCollationRequest::V1(req) => req.peer,
|
||||
VersionedCollationRequest::VStaging(req) => req.peer,
|
||||
VersionedCollationRequest::V2(req) => req.peer,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +135,7 @@ impl VersionedCollationRequest {
|
||||
) -> Result<(), ()> {
|
||||
match self {
|
||||
VersionedCollationRequest::V1(req) => req.send_outgoing_response(response),
|
||||
VersionedCollationRequest::VStaging(req) => req.send_outgoing_response(response),
|
||||
VersionedCollationRequest::V2(req) => req.send_outgoing_response(response),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ use polkadot_node_network_protocol::{
|
||||
peer_set::{CollationVersion, PeerSet},
|
||||
request_response::{
|
||||
incoming::{self, OutgoingResponse},
|
||||
v1 as request_v1, vstaging as request_vstaging, IncomingRequestReceiver,
|
||||
v1 as request_v1, v2 as request_v2, IncomingRequestReceiver,
|
||||
},
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, OurView, PeerId,
|
||||
UnifiedReputationChange as Rep, Versioned, View,
|
||||
v1 as protocol_v1, v2 as protocol_v2, OurView, PeerId, UnifiedReputationChange as Rep,
|
||||
Versioned, View,
|
||||
};
|
||||
use polkadot_node_primitives::{CollationSecondedSignal, PoV, Statement};
|
||||
use polkadot_node_subsystem::{
|
||||
@@ -577,7 +577,7 @@ async fn determine_our_validators<Context>(
|
||||
fn declare_message(
|
||||
state: &mut State,
|
||||
version: CollationVersion,
|
||||
) -> Option<Versioned<protocol_v1::CollationProtocol, protocol_vstaging::CollationProtocol>> {
|
||||
) -> Option<Versioned<protocol_v1::CollationProtocol, protocol_v2::CollationProtocol>> {
|
||||
let para_id = state.collating_on?;
|
||||
Some(match version {
|
||||
CollationVersion::V1 => {
|
||||
@@ -590,17 +590,15 @@ fn declare_message(
|
||||
);
|
||||
Versioned::V1(protocol_v1::CollationProtocol::CollatorProtocol(wire_message))
|
||||
},
|
||||
CollationVersion::VStaging => {
|
||||
CollationVersion::V2 => {
|
||||
let declare_signature_payload =
|
||||
protocol_vstaging::declare_signature_payload(&state.local_peer_id);
|
||||
let wire_message = protocol_vstaging::CollatorProtocolMessage::Declare(
|
||||
protocol_v2::declare_signature_payload(&state.local_peer_id);
|
||||
let wire_message = protocol_v2::CollatorProtocolMessage::Declare(
|
||||
state.collator_pair.public(),
|
||||
para_id,
|
||||
state.collator_pair.sign(&declare_signature_payload),
|
||||
);
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
wire_message,
|
||||
))
|
||||
Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(wire_message))
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -706,15 +704,13 @@ async fn advertise_collation<Context>(
|
||||
collation.status.advance_to_advertised();
|
||||
|
||||
let collation_message = match protocol_version {
|
||||
CollationVersion::VStaging => {
|
||||
let wire_message = protocol_vstaging::CollatorProtocolMessage::AdvertiseCollation {
|
||||
CollationVersion::V2 => {
|
||||
let wire_message = protocol_v2::CollatorProtocolMessage::AdvertiseCollation {
|
||||
relay_parent,
|
||||
candidate_hash: *candidate_hash,
|
||||
parent_head_data_hash: collation.parent_head_data_hash,
|
||||
};
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
wire_message,
|
||||
))
|
||||
Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(wire_message))
|
||||
},
|
||||
CollationVersion::V1 => {
|
||||
let wire_message =
|
||||
@@ -837,7 +833,7 @@ async fn send_collation(
|
||||
let candidate_hash = receipt.hash();
|
||||
|
||||
// The response payload is the same for both versions of protocol
|
||||
// and doesn't have vstaging alias for simplicity.
|
||||
// and doesn't have v2 alias for simplicity.
|
||||
let response = OutgoingResponse {
|
||||
result: Ok(request_v1::CollationFetchingResponse::Collation(receipt, pov)),
|
||||
reputation_changes: Vec::new(),
|
||||
@@ -868,16 +864,13 @@ async fn handle_incoming_peer_message<Context>(
|
||||
runtime: &mut RuntimeInfo,
|
||||
state: &mut State,
|
||||
origin: PeerId,
|
||||
msg: Versioned<
|
||||
protocol_v1::CollatorProtocolMessage,
|
||||
protocol_vstaging::CollatorProtocolMessage,
|
||||
>,
|
||||
msg: Versioned<protocol_v1::CollatorProtocolMessage, protocol_v2::CollatorProtocolMessage>,
|
||||
) -> Result<()> {
|
||||
use protocol_v1::CollatorProtocolMessage as V1;
|
||||
use protocol_vstaging::CollatorProtocolMessage as VStaging;
|
||||
use protocol_v2::CollatorProtocolMessage as V2;
|
||||
|
||||
match msg {
|
||||
Versioned::V1(V1::Declare(..)) | Versioned::VStaging(VStaging::Declare(..)) => {
|
||||
Versioned::V1(V1::Declare(..)) | Versioned::V2(V2::Declare(..)) => {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?origin,
|
||||
@@ -888,8 +881,7 @@ async fn handle_incoming_peer_message<Context>(
|
||||
ctx.send_message(NetworkBridgeTxMessage::DisconnectPeer(origin, PeerSet::Collation))
|
||||
.await;
|
||||
},
|
||||
Versioned::V1(V1::AdvertiseCollation(_)) |
|
||||
Versioned::VStaging(VStaging::AdvertiseCollation { .. }) => {
|
||||
Versioned::V1(V1::AdvertiseCollation(_)) | Versioned::V2(V2::AdvertiseCollation { .. }) => {
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?origin,
|
||||
@@ -904,7 +896,7 @@ async fn handle_incoming_peer_message<Context>(
|
||||
.await;
|
||||
},
|
||||
Versioned::V1(V1::CollationSeconded(relay_parent, statement)) |
|
||||
Versioned::VStaging(VStaging::CollationSeconded(relay_parent, statement)) => {
|
||||
Versioned::V2(V2::CollationSeconded(relay_parent, statement)) => {
|
||||
if !matches!(statement.unchecked_payload(), Statement::Seconded(_)) {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -1006,7 +998,7 @@ async fn handle_incoming_request<Context>(
|
||||
let collation = match &req {
|
||||
VersionedCollationRequest::V1(_) if !mode.is_enabled() =>
|
||||
per_relay_parent.collations.values_mut().next(),
|
||||
VersionedCollationRequest::VStaging(req) =>
|
||||
VersionedCollationRequest::V2(req) =>
|
||||
per_relay_parent.collations.get_mut(&req.payload.candidate_hash),
|
||||
_ => {
|
||||
gum::warn!(
|
||||
@@ -1322,7 +1314,7 @@ pub(crate) async fn run<Context>(
|
||||
local_peer_id: PeerId,
|
||||
collator_pair: CollatorPair,
|
||||
req_v1_receiver: IncomingRequestReceiver<request_v1::CollationFetchingRequest>,
|
||||
req_v2_receiver: IncomingRequestReceiver<request_vstaging::CollationFetchingRequest>,
|
||||
req_v2_receiver: IncomingRequestReceiver<request_v2::CollationFetchingRequest>,
|
||||
metrics: Metrics,
|
||||
) -> std::result::Result<(), FatalError> {
|
||||
run_inner(
|
||||
@@ -1344,7 +1336,7 @@ async fn run_inner<Context>(
|
||||
local_peer_id: PeerId,
|
||||
collator_pair: CollatorPair,
|
||||
mut req_v1_receiver: IncomingRequestReceiver<request_v1::CollationFetchingRequest>,
|
||||
mut req_v2_receiver: IncomingRequestReceiver<request_vstaging::CollationFetchingRequest>,
|
||||
mut req_v2_receiver: IncomingRequestReceiver<request_v2::CollationFetchingRequest>,
|
||||
metrics: Metrics,
|
||||
reputation: ReputationAggregator,
|
||||
reputation_interval: Duration,
|
||||
@@ -1425,7 +1417,7 @@ async fn run_inner<Context>(
|
||||
(ProspectiveParachainsMode::Disabled, VersionedCollationRequest::V1(_)) => {
|
||||
per_relay_parent.collations.values().next()
|
||||
},
|
||||
(ProspectiveParachainsMode::Enabled { .. }, VersionedCollationRequest::VStaging(req)) => {
|
||||
(ProspectiveParachainsMode::Enabled { .. }, VersionedCollationRequest::V2(req)) => {
|
||||
per_relay_parent.collations.get(&req.payload.candidate_hash)
|
||||
},
|
||||
_ => {
|
||||
@@ -1476,7 +1468,7 @@ async fn run_inner<Context>(
|
||||
|
||||
log_error(
|
||||
handle_incoming_request(&mut ctx, &mut state, request).await,
|
||||
"Handling incoming collation fetch request VStaging"
|
||||
"Handling incoming collation fetch request V2"
|
||||
)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +198,7 @@ impl TestState {
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
RuntimeApiRequest::StagingAsyncBackingParams(tx)
|
||||
RuntimeApiRequest::AsyncBackingParams(tx)
|
||||
)) => {
|
||||
assert_eq!(relay_parent, self.relay_parent);
|
||||
tx.send(Err(ASYNC_BACKING_DISABLED_ERROR)).unwrap();
|
||||
@@ -212,7 +212,7 @@ type VirtualOverseer = test_helpers::TestSubsystemContextHandle<CollatorProtocol
|
||||
struct TestHarness {
|
||||
virtual_overseer: VirtualOverseer,
|
||||
req_v1_cfg: sc_network::config::RequestResponseConfig,
|
||||
req_vstaging_cfg: sc_network::config::RequestResponseConfig,
|
||||
req_v2_cfg: sc_network::config::RequestResponseConfig,
|
||||
}
|
||||
|
||||
fn test_harness<T: Future<Output = TestHarness>>(
|
||||
@@ -236,7 +236,7 @@ fn test_harness<T: Future<Output = TestHarness>>(
|
||||
|
||||
let (collation_req_receiver, req_v1_cfg) =
|
||||
IncomingRequest::get_config_receiver(&req_protocol_names);
|
||||
let (collation_req_vstaging_receiver, req_vstaging_cfg) =
|
||||
let (collation_req_v2_receiver, req_v2_cfg) =
|
||||
IncomingRequest::get_config_receiver(&req_protocol_names);
|
||||
let subsystem = async {
|
||||
run_inner(
|
||||
@@ -244,7 +244,7 @@ fn test_harness<T: Future<Output = TestHarness>>(
|
||||
local_peer_id,
|
||||
collator_pair,
|
||||
collation_req_receiver,
|
||||
collation_req_vstaging_receiver,
|
||||
collation_req_v2_receiver,
|
||||
Default::default(),
|
||||
reputation,
|
||||
REPUTATION_CHANGE_TEST_INTERVAL,
|
||||
@@ -253,7 +253,7 @@ fn test_harness<T: Future<Output = TestHarness>>(
|
||||
.unwrap();
|
||||
};
|
||||
|
||||
let test_fut = test(TestHarness { virtual_overseer, req_v1_cfg, req_vstaging_cfg });
|
||||
let test_fut = test(TestHarness { virtual_overseer, req_v1_cfg, req_v2_cfg });
|
||||
|
||||
futures::pin_mut!(test_fut);
|
||||
futures::pin_mut!(subsystem);
|
||||
@@ -330,7 +330,7 @@ async fn setup_system(virtual_overseer: &mut VirtualOverseer, test_state: &TestS
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
RuntimeApiRequest::StagingAsyncBackingParams(tx)
|
||||
RuntimeApiRequest::AsyncBackingParams(tx)
|
||||
)) => {
|
||||
assert_eq!(relay_parent, test_state.relay_parent);
|
||||
tx.send(Err(ASYNC_BACKING_DISABLED_ERROR)).unwrap();
|
||||
@@ -545,7 +545,7 @@ async fn expect_declare_msg(
|
||||
|
||||
/// Check that the next received message is a collation advertisement message.
|
||||
///
|
||||
/// Expects vstaging message if `expected_candidate_hashes` is `Some`, v1 otherwise.
|
||||
/// Expects v2 message if `expected_candidate_hashes` is `Some`, v1 otherwise.
|
||||
async fn expect_advertise_collation_msg(
|
||||
virtual_overseer: &mut VirtualOverseer,
|
||||
peer: &PeerId,
|
||||
@@ -579,13 +579,13 @@ async fn expect_advertise_collation_msg(
|
||||
},
|
||||
(
|
||||
Some(candidate_hashes),
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(
|
||||
wire_message,
|
||||
)),
|
||||
) => {
|
||||
assert_matches!(
|
||||
wire_message,
|
||||
protocol_vstaging::CollatorProtocolMessage::AdvertiseCollation {
|
||||
protocol_v2::CollatorProtocolMessage::AdvertiseCollation {
|
||||
relay_parent,
|
||||
candidate_hash,
|
||||
..
|
||||
@@ -634,7 +634,7 @@ fn advertise_and_send_collation() {
|
||||
|test_harness| async move {
|
||||
let mut virtual_overseer = test_harness.virtual_overseer;
|
||||
let mut req_v1_cfg = test_harness.req_v1_cfg;
|
||||
let req_vstaging_cfg = test_harness.req_vstaging_cfg;
|
||||
let req_v2_cfg = test_harness.req_v2_cfg;
|
||||
|
||||
setup_system(&mut virtual_overseer, &test_state).await;
|
||||
|
||||
@@ -789,7 +789,7 @@ fn advertise_and_send_collation() {
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_vstaging_cfg }
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_v2_cfg }
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -807,7 +807,7 @@ fn delay_reputation_change() {
|
||||
|test_harness| async move {
|
||||
let mut virtual_overseer = test_harness.virtual_overseer;
|
||||
let mut req_v1_cfg = test_harness.req_v1_cfg;
|
||||
let req_vstaging_cfg = test_harness.req_vstaging_cfg;
|
||||
let req_v2_cfg = test_harness.req_v2_cfg;
|
||||
|
||||
setup_system(&mut virtual_overseer, &test_state).await;
|
||||
|
||||
@@ -903,15 +903,15 @@ fn delay_reputation_change() {
|
||||
);
|
||||
}
|
||||
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_vstaging_cfg }
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_v2_cfg }
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// Tests that collator side works with vstaging network protocol
|
||||
/// Tests that collator side works with v2 network protocol
|
||||
/// before async backing is enabled.
|
||||
#[test]
|
||||
fn advertise_collation_vstaging_protocol() {
|
||||
fn advertise_collation_v2_protocol() {
|
||||
let test_state = TestState::default();
|
||||
let local_peer_id = test_state.local_peer_id;
|
||||
let collator_pair = test_state.collator_pair.clone();
|
||||
@@ -941,21 +941,16 @@ fn advertise_collation_vstaging_protocol() {
|
||||
Some(validators[0].clone()),
|
||||
)
|
||||
.await;
|
||||
// The rest with vstaging.
|
||||
// The rest with v2.
|
||||
for (val, peer) in validators.iter().zip(peer_ids.iter()).skip(1) {
|
||||
connect_peer(
|
||||
virtual_overseer,
|
||||
*peer,
|
||||
CollationVersion::VStaging,
|
||||
Some(val.clone()),
|
||||
)
|
||||
.await;
|
||||
connect_peer(virtual_overseer, *peer, CollationVersion::V2, Some(val.clone()))
|
||||
.await;
|
||||
}
|
||||
|
||||
// Declare messages.
|
||||
expect_declare_msg(virtual_overseer, &test_state, &peer_ids[0]).await;
|
||||
for peer_id in peer_ids.iter().skip(1) {
|
||||
prospective_parachains::expect_declare_msg_vstaging(
|
||||
prospective_parachains::expect_declare_msg_v2(
|
||||
virtual_overseer,
|
||||
&test_state,
|
||||
&peer_id,
|
||||
@@ -981,7 +976,7 @@ fn advertise_collation_vstaging_protocol() {
|
||||
virtual_overseer,
|
||||
peer_id,
|
||||
test_state.relay_parent,
|
||||
Some(vec![candidate.hash()]), // This is `Some`, advertisement is vstaging.
|
||||
Some(vec![candidate.hash()]), // This is `Some`, advertisement is v2.
|
||||
)
|
||||
.await;
|
||||
}
|
||||
@@ -1405,7 +1400,7 @@ fn connect_to_buffered_groups() {
|
||||
|test_harness| async move {
|
||||
let mut virtual_overseer = test_harness.virtual_overseer;
|
||||
let mut req_cfg = test_harness.req_v1_cfg;
|
||||
let req_vstaging_cfg = test_harness.req_vstaging_cfg;
|
||||
let req_v2_cfg = test_harness.req_v2_cfg;
|
||||
|
||||
setup_system(&mut virtual_overseer, &test_state).await;
|
||||
|
||||
@@ -1510,7 +1505,7 @@ fn connect_to_buffered_groups() {
|
||||
}
|
||||
);
|
||||
|
||||
TestHarness { virtual_overseer, req_v1_cfg: req_cfg, req_vstaging_cfg }
|
||||
TestHarness { virtual_overseer, req_v1_cfg: req_cfg, req_v2_cfg }
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
+19
-20
@@ -19,10 +19,10 @@
|
||||
use super::*;
|
||||
|
||||
use polkadot_node_subsystem::messages::{ChainApiMessage, ProspectiveParachainsMessage};
|
||||
use polkadot_primitives::{vstaging as vstaging_primitives, Header, OccupiedCore};
|
||||
use polkadot_primitives::{AsyncBackingParams, Header, OccupiedCore};
|
||||
|
||||
const ASYNC_BACKING_PARAMETERS: vstaging_primitives::AsyncBackingParams =
|
||||
vstaging_primitives::AsyncBackingParams { max_candidate_depth: 4, allowed_ancestry_len: 3 };
|
||||
const ASYNC_BACKING_PARAMETERS: AsyncBackingParams =
|
||||
AsyncBackingParams { max_candidate_depth: 4, allowed_ancestry_len: 3 };
|
||||
|
||||
fn get_parent_hash(hash: Hash) -> Hash {
|
||||
Hash::from_low_u64_be(hash.to_low_u64_be() + 1)
|
||||
@@ -52,7 +52,7 @@ async fn update_view(
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
parent,
|
||||
RuntimeApiRequest::StagingAsyncBackingParams(tx),
|
||||
RuntimeApiRequest::AsyncBackingParams(tx),
|
||||
)) => {
|
||||
tx.send(Ok(ASYNC_BACKING_PARAMETERS)).unwrap();
|
||||
(parent, new_view.get(&parent).copied().expect("Unknown parent requested"))
|
||||
@@ -124,7 +124,7 @@ async fn update_view(
|
||||
}
|
||||
|
||||
/// Check that the next received message is a `Declare` message.
|
||||
pub(super) async fn expect_declare_msg_vstaging(
|
||||
pub(super) async fn expect_declare_msg_v2(
|
||||
virtual_overseer: &mut VirtualOverseer,
|
||||
test_state: &TestState,
|
||||
peer: &PeerId,
|
||||
@@ -133,20 +133,20 @@ pub(super) async fn expect_declare_msg_vstaging(
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendCollationMessage(
|
||||
to,
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(
|
||||
wire_message,
|
||||
)),
|
||||
)) => {
|
||||
assert_eq!(to[0], *peer);
|
||||
assert_matches!(
|
||||
wire_message,
|
||||
protocol_vstaging::CollatorProtocolMessage::Declare(
|
||||
protocol_v2::CollatorProtocolMessage::Declare(
|
||||
collator_id,
|
||||
para_id,
|
||||
signature,
|
||||
) => {
|
||||
assert!(signature.verify(
|
||||
&*protocol_vstaging::declare_signature_payload(&test_state.local_peer_id),
|
||||
&*protocol_v2::declare_signature_payload(&test_state.local_peer_id),
|
||||
&collator_id),
|
||||
);
|
||||
assert_eq!(collator_id, test_state.collator_pair.public());
|
||||
@@ -203,13 +203,12 @@ fn distribute_collation_from_implicit_view() {
|
||||
.into_iter()
|
||||
.zip(validator_peer_ids.clone())
|
||||
{
|
||||
connect_peer(virtual_overseer, peer, CollationVersion::VStaging, Some(val.clone()))
|
||||
.await;
|
||||
connect_peer(virtual_overseer, peer, CollationVersion::V2, Some(val.clone())).await;
|
||||
}
|
||||
|
||||
// Collator declared itself to each peer.
|
||||
for peer_id in &validator_peer_ids {
|
||||
expect_declare_msg_vstaging(virtual_overseer, &test_state, peer_id).await;
|
||||
expect_declare_msg_v2(virtual_overseer, &test_state, peer_id).await;
|
||||
}
|
||||
|
||||
let pov = PoV { block_data: BlockData(vec![1, 2, 3]) };
|
||||
@@ -386,7 +385,7 @@ fn advertise_and_send_collation_by_hash() {
|
||||
|test_harness| async move {
|
||||
let mut virtual_overseer = test_harness.virtual_overseer;
|
||||
let req_v1_cfg = test_harness.req_v1_cfg;
|
||||
let mut req_vstaging_cfg = test_harness.req_vstaging_cfg;
|
||||
let mut req_v2_cfg = test_harness.req_v2_cfg;
|
||||
|
||||
let head_a = Hash::from_low_u64_be(128);
|
||||
let head_a_num: u32 = 64;
|
||||
@@ -435,11 +434,11 @@ fn advertise_and_send_collation_by_hash() {
|
||||
connect_peer(
|
||||
&mut virtual_overseer,
|
||||
peer,
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
Some(validator_id.clone()),
|
||||
)
|
||||
.await;
|
||||
expect_declare_msg_vstaging(&mut virtual_overseer, &test_state, &peer).await;
|
||||
expect_declare_msg_v2(&mut virtual_overseer, &test_state, &peer).await;
|
||||
|
||||
// Head `b` is not a leaf, but both advertisements are still relevant.
|
||||
send_peer_view_change(&mut virtual_overseer, &peer, vec![head_b]).await;
|
||||
@@ -449,13 +448,13 @@ fn advertise_and_send_collation_by_hash() {
|
||||
|
||||
for (candidate, pov_block) in candidates {
|
||||
let (pending_response, rx) = oneshot::channel();
|
||||
req_vstaging_cfg
|
||||
req_v2_cfg
|
||||
.inbound_queue
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.send(RawIncomingRequest {
|
||||
peer,
|
||||
payload: request_vstaging::CollationFetchingRequest {
|
||||
payload: request_v2::CollationFetchingRequest {
|
||||
relay_parent: head_b,
|
||||
para_id: test_state.para_id,
|
||||
candidate_hash: candidate.hash(),
|
||||
@@ -469,7 +468,7 @@ fn advertise_and_send_collation_by_hash() {
|
||||
assert_matches!(
|
||||
rx.await,
|
||||
Ok(full_response) => {
|
||||
// Response is the same for vstaging.
|
||||
// Response is the same for v2.
|
||||
let request_v1::CollationFetchingResponse::Collation(receipt, pov): request_v1::CollationFetchingResponse
|
||||
= request_v1::CollationFetchingResponse::decode(
|
||||
&mut full_response.result
|
||||
@@ -482,7 +481,7 @@ fn advertise_and_send_collation_by_hash() {
|
||||
);
|
||||
}
|
||||
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_vstaging_cfg }
|
||||
TestHarness { virtual_overseer, req_v1_cfg, req_v2_cfg }
|
||||
},
|
||||
)
|
||||
}
|
||||
@@ -552,11 +551,11 @@ fn advertise_core_occupied() {
|
||||
connect_peer(
|
||||
virtual_overseer,
|
||||
peer_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
Some(validators[0].clone()),
|
||||
)
|
||||
.await;
|
||||
expect_declare_msg_vstaging(virtual_overseer, &test_state, &peer_ids[0]).await;
|
||||
expect_declare_msg_v2(virtual_overseer, &test_state, &peer_ids[0]).await;
|
||||
// Peer is aware of the leaf.
|
||||
send_peer_view_change(virtual_overseer, &peer_ids[0], vec![head_a]).await;
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ use polkadot_node_subsystem_util::reputation::ReputationAggregator;
|
||||
use sp_keystore::KeystorePtr;
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
request_response::{v1 as request_v1, vstaging as protocol_vstaging, IncomingRequestReceiver},
|
||||
request_response::{v1 as request_v1, v2 as protocol_v2, IncomingRequestReceiver},
|
||||
PeerId, UnifiedReputationChange as Rep,
|
||||
};
|
||||
use polkadot_primitives::CollatorPair;
|
||||
@@ -83,9 +83,8 @@ pub enum ProtocolSide {
|
||||
collator_pair: CollatorPair,
|
||||
/// Receiver for v1 collation fetching requests.
|
||||
request_receiver_v1: IncomingRequestReceiver<request_v1::CollationFetchingRequest>,
|
||||
/// Receiver for vstaging collation fetching requests.
|
||||
request_receiver_vstaging:
|
||||
IncomingRequestReceiver<protocol_vstaging::CollationFetchingRequest>,
|
||||
/// Receiver for v2 collation fetching requests.
|
||||
request_receiver_v2: IncomingRequestReceiver<protocol_v2::CollationFetchingRequest>,
|
||||
/// Metrics.
|
||||
metrics: collator_side::Metrics,
|
||||
},
|
||||
@@ -121,14 +120,14 @@ impl<Context> CollatorProtocolSubsystem {
|
||||
peer_id,
|
||||
collator_pair,
|
||||
request_receiver_v1,
|
||||
request_receiver_vstaging,
|
||||
request_receiver_v2,
|
||||
metrics,
|
||||
} => collator_side::run(
|
||||
ctx,
|
||||
peer_id,
|
||||
collator_pair,
|
||||
request_receiver_v1,
|
||||
request_receiver_vstaging,
|
||||
request_receiver_v2,
|
||||
metrics,
|
||||
)
|
||||
.map_err(|e| SubsystemError::with_origin("collator-protocol", e))
|
||||
|
||||
@@ -119,7 +119,7 @@ impl PendingCollation {
|
||||
}
|
||||
}
|
||||
|
||||
/// vstaging advertisement that was rejected by the backing
|
||||
/// v2 advertisement that was rejected by the backing
|
||||
/// subsystem. Validator may fetch it later if its fragment
|
||||
/// membership gets recognized before relay parent goes out of view.
|
||||
#[derive(Debug, Clone)]
|
||||
|
||||
@@ -34,10 +34,10 @@ use polkadot_node_network_protocol::{
|
||||
peer_set::{CollationVersion, PeerSet},
|
||||
request_response::{
|
||||
outgoing::{Recipient, RequestError},
|
||||
v1 as request_v1, vstaging as request_vstaging, OutgoingRequest, Requests,
|
||||
v1 as request_v1, v2 as request_v2, OutgoingRequest, Requests,
|
||||
},
|
||||
v1 as protocol_v1, vstaging as protocol_vstaging, OurView, PeerId,
|
||||
UnifiedReputationChange as Rep, Versioned, View,
|
||||
v1 as protocol_v1, v2 as protocol_v2, OurView, PeerId, UnifiedReputationChange as Rep,
|
||||
Versioned, View,
|
||||
};
|
||||
use polkadot_node_primitives::{SignedFullStatement, Statement};
|
||||
use polkadot_node_subsystem::{
|
||||
@@ -624,13 +624,9 @@ async fn notify_collation_seconded(
|
||||
CollationVersion::V1 => Versioned::V1(protocol_v1::CollationProtocol::CollatorProtocol(
|
||||
protocol_v1::CollatorProtocolMessage::CollationSeconded(relay_parent, statement),
|
||||
)),
|
||||
CollationVersion::VStaging =>
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
protocol_vstaging::CollatorProtocolMessage::CollationSeconded(
|
||||
relay_parent,
|
||||
statement,
|
||||
),
|
||||
)),
|
||||
CollationVersion::V2 => Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(
|
||||
protocol_v2::CollatorProtocolMessage::CollationSeconded(relay_parent, statement),
|
||||
)),
|
||||
};
|
||||
sender
|
||||
.send_message(NetworkBridgeTxMessage::SendCollationMessage(vec![peer_id], wire_message))
|
||||
@@ -694,16 +690,12 @@ async fn request_collation(
|
||||
let requests = Requests::CollationFetchingV1(req);
|
||||
(requests, response_recv.boxed())
|
||||
},
|
||||
(CollationVersion::VStaging, Some(ProspectiveCandidate { candidate_hash, .. })) => {
|
||||
(CollationVersion::V2, Some(ProspectiveCandidate { candidate_hash, .. })) => {
|
||||
let (req, response_recv) = OutgoingRequest::new(
|
||||
Recipient::Peer(peer_id),
|
||||
request_vstaging::CollationFetchingRequest {
|
||||
relay_parent,
|
||||
para_id,
|
||||
candidate_hash,
|
||||
},
|
||||
request_v2::CollationFetchingRequest { relay_parent, para_id, candidate_hash },
|
||||
);
|
||||
let requests = Requests::CollationFetchingVStaging(req);
|
||||
let requests = Requests::CollationFetchingV2(req);
|
||||
(requests, response_recv.boxed())
|
||||
},
|
||||
_ => return Err(FetchError::ProtocolMismatch),
|
||||
@@ -758,18 +750,15 @@ async fn process_incoming_peer_message<Context>(
|
||||
ctx: &mut Context,
|
||||
state: &mut State,
|
||||
origin: PeerId,
|
||||
msg: Versioned<
|
||||
protocol_v1::CollatorProtocolMessage,
|
||||
protocol_vstaging::CollatorProtocolMessage,
|
||||
>,
|
||||
msg: Versioned<protocol_v1::CollatorProtocolMessage, protocol_v2::CollatorProtocolMessage>,
|
||||
) {
|
||||
use protocol_v1::CollatorProtocolMessage as V1;
|
||||
use protocol_vstaging::CollatorProtocolMessage as VStaging;
|
||||
use protocol_v2::CollatorProtocolMessage as V2;
|
||||
use sp_runtime::traits::AppVerify;
|
||||
|
||||
match msg {
|
||||
Versioned::V1(V1::Declare(collator_id, para_id, signature)) |
|
||||
Versioned::VStaging(VStaging::Declare(collator_id, para_id, signature)) => {
|
||||
Versioned::V2(V2::Declare(collator_id, para_id, signature)) => {
|
||||
if collator_peer_id(&state.peer_data, &collator_id).is_some() {
|
||||
modify_reputation(
|
||||
&mut state.reputation,
|
||||
@@ -881,7 +870,7 @@ async fn process_incoming_peer_message<Context>(
|
||||
modify_reputation(&mut state.reputation, ctx.sender(), origin, rep).await;
|
||||
}
|
||||
},
|
||||
Versioned::VStaging(VStaging::AdvertiseCollation {
|
||||
Versioned::V2(V2::AdvertiseCollation {
|
||||
relay_parent,
|
||||
candidate_hash,
|
||||
parent_head_data_hash,
|
||||
@@ -901,15 +890,14 @@ async fn process_incoming_peer_message<Context>(
|
||||
?relay_parent,
|
||||
?candidate_hash,
|
||||
error = ?err,
|
||||
"Rejected vstaging advertisement",
|
||||
"Rejected v2 advertisement",
|
||||
);
|
||||
|
||||
if let Some(rep) = err.reputation_changes() {
|
||||
modify_reputation(&mut state.reputation, ctx.sender(), origin, rep).await;
|
||||
}
|
||||
},
|
||||
Versioned::V1(V1::CollationSeconded(..)) |
|
||||
Versioned::VStaging(VStaging::CollationSeconded(..)) => {
|
||||
Versioned::V1(V1::CollationSeconded(..)) | Versioned::V2(V2::CollationSeconded(..)) => {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
peer_id = ?origin,
|
||||
@@ -1074,7 +1062,7 @@ where
|
||||
};
|
||||
|
||||
if relay_parent_mode.is_enabled() && prospective_candidate.is_none() {
|
||||
// Expected vstaging advertisement.
|
||||
// Expected v2 advertisement.
|
||||
return Err(AdvertisementError::ProtocolMismatch)
|
||||
}
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ async fn assert_fetch_collation_request(
|
||||
),
|
||||
Some(candidate_hash) => assert_matches!(
|
||||
req,
|
||||
Requests::CollationFetchingVStaging(req) => {
|
||||
Requests::CollationFetchingV2(req) => {
|
||||
let payload = req.payload;
|
||||
assert_eq!(payload.relay_parent, relay_parent);
|
||||
assert_eq!(payload.para_id, para_id);
|
||||
@@ -394,12 +394,11 @@ async fn connect_and_declare_collator(
|
||||
para_id,
|
||||
collator.sign(&protocol_v1::declare_signature_payload(&peer)),
|
||||
)),
|
||||
CollationVersion::VStaging =>
|
||||
Versioned::VStaging(protocol_vstaging::CollatorProtocolMessage::Declare(
|
||||
collator.public(),
|
||||
para_id,
|
||||
collator.sign(&protocol_v1::declare_signature_payload(&peer)),
|
||||
)),
|
||||
CollationVersion::V2 => Versioned::V2(protocol_v2::CollatorProtocolMessage::Declare(
|
||||
collator.public(),
|
||||
para_id,
|
||||
collator.sign(&protocol_v1::declare_signature_payload(&peer)),
|
||||
)),
|
||||
};
|
||||
|
||||
overseer_send(
|
||||
@@ -421,7 +420,7 @@ async fn advertise_collation(
|
||||
) {
|
||||
let wire_message = match candidate {
|
||||
Some((candidate_hash, parent_head_data_hash)) =>
|
||||
Versioned::VStaging(protocol_vstaging::CollatorProtocolMessage::AdvertiseCollation {
|
||||
Versioned::V2(protocol_v2::CollatorProtocolMessage::AdvertiseCollation {
|
||||
relay_parent,
|
||||
candidate_hash,
|
||||
parent_head_data_hash,
|
||||
@@ -444,7 +443,7 @@ async fn assert_async_backing_params_request(virtual_overseer: &mut VirtualOvers
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
relay_parent,
|
||||
RuntimeApiRequest::StagingAsyncBackingParams(tx)
|
||||
RuntimeApiRequest::AsyncBackingParams(tx)
|
||||
)) => {
|
||||
assert_eq!(relay_parent, hash);
|
||||
tx.send(Err(ASYNC_BACKING_DISABLED_ERROR)).unwrap();
|
||||
@@ -499,10 +498,10 @@ fn act_on_advertisement() {
|
||||
});
|
||||
}
|
||||
|
||||
/// Tests that validator side works with vstaging network protocol
|
||||
/// Tests that validator side works with v2 network protocol
|
||||
/// before async backing is enabled.
|
||||
#[test]
|
||||
fn act_on_advertisement_vstaging() {
|
||||
fn act_on_advertisement_v2() {
|
||||
let test_state = TestState::default();
|
||||
|
||||
test_harness(ReputationAggregator::new(|_| true), |test_harness| async move {
|
||||
@@ -529,13 +528,13 @@ fn act_on_advertisement_vstaging() {
|
||||
peer_b,
|
||||
pair.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
let candidate_hash = CandidateHash::default();
|
||||
let parent_head_data_hash = Hash::zero();
|
||||
// vstaging advertisement.
|
||||
// v2 advertisement.
|
||||
advertise_collation(
|
||||
&mut virtual_overseer,
|
||||
peer_b,
|
||||
|
||||
+18
-18
@@ -20,12 +20,12 @@ use super::*;
|
||||
|
||||
use polkadot_node_subsystem::messages::ChainApiMessage;
|
||||
use polkadot_primitives::{
|
||||
vstaging as vstaging_primitives, BlockNumber, CandidateCommitments, CommittedCandidateReceipt,
|
||||
Header, SigningContext, ValidatorId,
|
||||
AsyncBackingParams, BlockNumber, CandidateCommitments, CommittedCandidateReceipt, Header,
|
||||
SigningContext, ValidatorId,
|
||||
};
|
||||
|
||||
const ASYNC_BACKING_PARAMETERS: vstaging_primitives::AsyncBackingParams =
|
||||
vstaging_primitives::AsyncBackingParams { max_candidate_depth: 4, allowed_ancestry_len: 3 };
|
||||
const ASYNC_BACKING_PARAMETERS: AsyncBackingParams =
|
||||
AsyncBackingParams { max_candidate_depth: 4, allowed_ancestry_len: 3 };
|
||||
|
||||
fn get_parent_hash(hash: Hash) -> Hash {
|
||||
Hash::from_low_u64_be(hash.to_low_u64_be() + 1)
|
||||
@@ -97,7 +97,7 @@ async fn update_view(
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::RuntimeApi(RuntimeApiMessage::Request(
|
||||
parent,
|
||||
RuntimeApiRequest::StagingAsyncBackingParams(tx),
|
||||
RuntimeApiRequest::AsyncBackingParams(tx),
|
||||
)) => {
|
||||
tx.send(Ok(ASYNC_BACKING_PARAMETERS)).unwrap();
|
||||
(parent, new_view.get(&parent).copied().expect("Unknown parent requested"))
|
||||
@@ -226,8 +226,8 @@ async fn assert_collation_seconded(
|
||||
overseer_recv(virtual_overseer).await,
|
||||
AllMessages::NetworkBridgeTx(NetworkBridgeTxMessage::SendCollationMessage(
|
||||
peers,
|
||||
Versioned::VStaging(protocol_vstaging::CollationProtocol::CollatorProtocol(
|
||||
protocol_vstaging::CollatorProtocolMessage::CollationSeconded(
|
||||
Versioned::V2(protocol_v2::CollationProtocol::CollatorProtocol(
|
||||
protocol_v2::CollatorProtocolMessage::CollationSeconded(
|
||||
_relay_parent,
|
||||
..,
|
||||
),
|
||||
@@ -306,7 +306,7 @@ fn accept_advertisements_from_implicit_view() {
|
||||
peer_a,
|
||||
pair_a.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
connect_and_declare_collator(
|
||||
@@ -314,7 +314,7 @@ fn accept_advertisements_from_implicit_view() {
|
||||
peer_b,
|
||||
pair_b.clone(),
|
||||
test_state.chain_ids[1],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -406,7 +406,7 @@ fn second_multiple_candidates_per_relay_parent() {
|
||||
peer_a,
|
||||
pair.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -457,7 +457,7 @@ fn second_multiple_candidates_per_relay_parent() {
|
||||
let pov = PoV { block_data: BlockData(vec![1]) };
|
||||
|
||||
response_channel
|
||||
.send(Ok(request_vstaging::CollationFetchingResponse::Collation(
|
||||
.send(Ok(request_v2::CollationFetchingResponse::Collation(
|
||||
candidate.clone(),
|
||||
pov.clone(),
|
||||
)
|
||||
@@ -514,7 +514,7 @@ fn second_multiple_candidates_per_relay_parent() {
|
||||
peer_b,
|
||||
pair_b.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -562,7 +562,7 @@ fn fetched_collation_sanity_check() {
|
||||
peer_a,
|
||||
pair.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -611,7 +611,7 @@ fn fetched_collation_sanity_check() {
|
||||
let pov = PoV { block_data: BlockData(vec![1]) };
|
||||
|
||||
response_channel
|
||||
.send(Ok(request_vstaging::CollationFetchingResponse::Collation(
|
||||
.send(Ok(request_v2::CollationFetchingResponse::Collation(
|
||||
candidate.clone(),
|
||||
pov.clone(),
|
||||
)
|
||||
@@ -668,7 +668,7 @@ fn advertisement_spam_protection() {
|
||||
peer_a,
|
||||
pair_a.clone(),
|
||||
test_state.chain_ids[1],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -748,7 +748,7 @@ fn backed_candidate_unblocks_advertisements() {
|
||||
peer_a,
|
||||
pair_a.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
connect_and_declare_collator(
|
||||
@@ -756,7 +756,7 @@ fn backed_candidate_unblocks_advertisements() {
|
||||
peer_b,
|
||||
pair_b.clone(),
|
||||
test_state.chain_ids[1],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
|
||||
@@ -856,7 +856,7 @@ fn active_leave_unblocks_advertisements() {
|
||||
*peer_id,
|
||||
peer.clone(),
|
||||
test_state.chain_ids[0],
|
||||
CollationVersion::VStaging,
|
||||
CollationVersion::V2,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
@@ -452,7 +452,7 @@ where
|
||||
// match void -> LLVM unreachable
|
||||
match message {
|
||||
Versioned::V1(m) => match m {},
|
||||
Versioned::VStaging(m) => match m {},
|
||||
Versioned::V2(m) => match m {},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
@@ -27,6 +27,3 @@ bitvec = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
rand_chacha = "0.3.1"
|
||||
|
||||
[features]
|
||||
network-protocol-staging = []
|
||||
|
||||
@@ -253,26 +253,25 @@ impl View {
|
||||
|
||||
/// A protocol-versioned type.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Versioned<V1, VStaging> {
|
||||
pub enum Versioned<V1, V2> {
|
||||
/// V1 type.
|
||||
V1(V1),
|
||||
/// VStaging type.
|
||||
VStaging(VStaging),
|
||||
/// V2 type.
|
||||
V2(V2),
|
||||
}
|
||||
|
||||
impl<V1: Clone, VStaging: Clone> Versioned<&'_ V1, &'_ VStaging> {
|
||||
impl<V1: Clone, V2: Clone> Versioned<&'_ V1, &'_ V2> {
|
||||
/// Convert to a fully-owned version of the message.
|
||||
pub fn clone_inner(&self) -> Versioned<V1, VStaging> {
|
||||
pub fn clone_inner(&self) -> Versioned<V1, V2> {
|
||||
match *self {
|
||||
Versioned::V1(inner) => Versioned::V1(inner.clone()),
|
||||
Versioned::VStaging(inner) => Versioned::VStaging(inner.clone()),
|
||||
Versioned::V2(inner) => Versioned::V2(inner.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// All supported versions of the validation protocol message.
|
||||
pub type VersionedValidationProtocol =
|
||||
Versioned<v1::ValidationProtocol, vstaging::ValidationProtocol>;
|
||||
pub type VersionedValidationProtocol = Versioned<v1::ValidationProtocol, v2::ValidationProtocol>;
|
||||
|
||||
impl From<v1::ValidationProtocol> for VersionedValidationProtocol {
|
||||
fn from(v1: v1::ValidationProtocol) -> Self {
|
||||
@@ -280,14 +279,14 @@ impl From<v1::ValidationProtocol> for VersionedValidationProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<vstaging::ValidationProtocol> for VersionedValidationProtocol {
|
||||
fn from(vstaging: vstaging::ValidationProtocol) -> Self {
|
||||
VersionedValidationProtocol::VStaging(vstaging)
|
||||
impl From<v2::ValidationProtocol> for VersionedValidationProtocol {
|
||||
fn from(v2: v2::ValidationProtocol) -> Self {
|
||||
VersionedValidationProtocol::V2(v2)
|
||||
}
|
||||
}
|
||||
|
||||
/// All supported versions of the collation protocol message.
|
||||
pub type VersionedCollationProtocol = Versioned<v1::CollationProtocol, vstaging::CollationProtocol>;
|
||||
pub type VersionedCollationProtocol = Versioned<v1::CollationProtocol, v2::CollationProtocol>;
|
||||
|
||||
impl From<v1::CollationProtocol> for VersionedCollationProtocol {
|
||||
fn from(v1: v1::CollationProtocol) -> Self {
|
||||
@@ -295,9 +294,9 @@ impl From<v1::CollationProtocol> for VersionedCollationProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<vstaging::CollationProtocol> for VersionedCollationProtocol {
|
||||
fn from(vstaging: vstaging::CollationProtocol) -> Self {
|
||||
VersionedCollationProtocol::VStaging(vstaging)
|
||||
impl From<v2::CollationProtocol> for VersionedCollationProtocol {
|
||||
fn from(v2: v2::CollationProtocol) -> Self {
|
||||
VersionedCollationProtocol::V2(v2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,7 +306,7 @@ macro_rules! impl_versioned_full_protocol_from {
|
||||
fn from(versioned_from: $from) -> $out {
|
||||
match versioned_from {
|
||||
Versioned::V1(x) => Versioned::V1(x.into()),
|
||||
Versioned::VStaging(x) => Versioned::VStaging(x.into()),
|
||||
Versioned::V2(x) => Versioned::V2(x.into()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -321,7 +320,7 @@ macro_rules! impl_versioned_try_from {
|
||||
$from:ty,
|
||||
$out:ty,
|
||||
$v1_pat:pat => $v1_out:expr,
|
||||
$vstaging_pat:pat => $vstaging_out:expr
|
||||
$v2_pat:pat => $v2_out:expr
|
||||
) => {
|
||||
impl TryFrom<$from> for $out {
|
||||
type Error = crate::WrongVariant;
|
||||
@@ -330,7 +329,7 @@ macro_rules! impl_versioned_try_from {
|
||||
#[allow(unreachable_patterns)] // when there is only one variant
|
||||
match x {
|
||||
Versioned::V1($v1_pat) => Ok(Versioned::V1($v1_out)),
|
||||
Versioned::VStaging($vstaging_pat) => Ok(Versioned::VStaging($vstaging_out)),
|
||||
Versioned::V2($v2_pat) => Ok(Versioned::V2($v2_out)),
|
||||
_ => Err(crate::WrongVariant),
|
||||
}
|
||||
}
|
||||
@@ -343,8 +342,7 @@ macro_rules! impl_versioned_try_from {
|
||||
#[allow(unreachable_patterns)] // when there is only one variant
|
||||
match x {
|
||||
Versioned::V1($v1_pat) => Ok(Versioned::V1($v1_out.clone())),
|
||||
Versioned::VStaging($vstaging_pat) =>
|
||||
Ok(Versioned::VStaging($vstaging_out.clone())),
|
||||
Versioned::V2($v2_pat) => Ok(Versioned::V2($v2_out.clone())),
|
||||
_ => Err(crate::WrongVariant),
|
||||
}
|
||||
}
|
||||
@@ -354,7 +352,7 @@ macro_rules! impl_versioned_try_from {
|
||||
|
||||
/// Version-annotated messages used by the bitfield distribution subsystem.
|
||||
pub type BitfieldDistributionMessage =
|
||||
Versioned<v1::BitfieldDistributionMessage, vstaging::BitfieldDistributionMessage>;
|
||||
Versioned<v1::BitfieldDistributionMessage, v2::BitfieldDistributionMessage>;
|
||||
impl_versioned_full_protocol_from!(
|
||||
BitfieldDistributionMessage,
|
||||
VersionedValidationProtocol,
|
||||
@@ -364,12 +362,12 @@ impl_versioned_try_from!(
|
||||
VersionedValidationProtocol,
|
||||
BitfieldDistributionMessage,
|
||||
v1::ValidationProtocol::BitfieldDistribution(x) => x,
|
||||
vstaging::ValidationProtocol::BitfieldDistribution(x) => x
|
||||
v2::ValidationProtocol::BitfieldDistribution(x) => x
|
||||
);
|
||||
|
||||
/// Version-annotated messages used by the statement distribution subsystem.
|
||||
pub type StatementDistributionMessage =
|
||||
Versioned<v1::StatementDistributionMessage, vstaging::StatementDistributionMessage>;
|
||||
Versioned<v1::StatementDistributionMessage, v2::StatementDistributionMessage>;
|
||||
impl_versioned_full_protocol_from!(
|
||||
StatementDistributionMessage,
|
||||
VersionedValidationProtocol,
|
||||
@@ -379,12 +377,12 @@ impl_versioned_try_from!(
|
||||
VersionedValidationProtocol,
|
||||
StatementDistributionMessage,
|
||||
v1::ValidationProtocol::StatementDistribution(x) => x,
|
||||
vstaging::ValidationProtocol::StatementDistribution(x) => x
|
||||
v2::ValidationProtocol::StatementDistribution(x) => x
|
||||
);
|
||||
|
||||
/// Version-annotated messages used by the approval distribution subsystem.
|
||||
pub type ApprovalDistributionMessage =
|
||||
Versioned<v1::ApprovalDistributionMessage, vstaging::ApprovalDistributionMessage>;
|
||||
Versioned<v1::ApprovalDistributionMessage, v2::ApprovalDistributionMessage>;
|
||||
impl_versioned_full_protocol_from!(
|
||||
ApprovalDistributionMessage,
|
||||
VersionedValidationProtocol,
|
||||
@@ -394,13 +392,13 @@ impl_versioned_try_from!(
|
||||
VersionedValidationProtocol,
|
||||
ApprovalDistributionMessage,
|
||||
v1::ValidationProtocol::ApprovalDistribution(x) => x,
|
||||
vstaging::ValidationProtocol::ApprovalDistribution(x) => x
|
||||
v2::ValidationProtocol::ApprovalDistribution(x) => x
|
||||
|
||||
);
|
||||
|
||||
/// Version-annotated messages used by the gossip-support subsystem (this is void).
|
||||
pub type GossipSupportNetworkMessage =
|
||||
Versioned<v1::GossipSupportNetworkMessage, vstaging::GossipSupportNetworkMessage>;
|
||||
Versioned<v1::GossipSupportNetworkMessage, v2::GossipSupportNetworkMessage>;
|
||||
// This is a void enum placeholder, so never gets sent over the wire.
|
||||
impl TryFrom<VersionedValidationProtocol> for GossipSupportNetworkMessage {
|
||||
type Error = WrongVariant;
|
||||
@@ -418,7 +416,7 @@ impl<'a> TryFrom<&'a VersionedValidationProtocol> for GossipSupportNetworkMessag
|
||||
|
||||
/// Version-annotated messages used by the bitfield distribution subsystem.
|
||||
pub type CollatorProtocolMessage =
|
||||
Versioned<v1::CollatorProtocolMessage, vstaging::CollatorProtocolMessage>;
|
||||
Versioned<v1::CollatorProtocolMessage, v2::CollatorProtocolMessage>;
|
||||
impl_versioned_full_protocol_from!(
|
||||
CollatorProtocolMessage,
|
||||
VersionedCollationProtocol,
|
||||
@@ -428,7 +426,7 @@ impl_versioned_try_from!(
|
||||
VersionedCollationProtocol,
|
||||
CollatorProtocolMessage,
|
||||
v1::CollationProtocol::CollatorProtocol(x) => x,
|
||||
vstaging::CollationProtocol::CollatorProtocol(x) => x
|
||||
v2::CollationProtocol::CollatorProtocol(x) => x
|
||||
);
|
||||
|
||||
/// v1 notification protocol types.
|
||||
@@ -589,12 +587,12 @@ pub mod v1 {
|
||||
}
|
||||
}
|
||||
|
||||
/// vstaging network protocol types.
|
||||
pub mod vstaging {
|
||||
/// v2 network protocol types.
|
||||
pub mod v2 {
|
||||
use bitvec::{order::Lsb0, slice::BitSlice, vec::BitVec};
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
|
||||
use polkadot_primitives::vstaging::{
|
||||
use polkadot_primitives::{
|
||||
CandidateHash, CandidateIndex, CollatorId, CollatorSignature, GroupIndex, Hash,
|
||||
Id as ParaId, UncheckedSignedAvailabilityBitfield, UncheckedSignedStatement,
|
||||
};
|
||||
|
||||
@@ -118,16 +118,9 @@ impl PeerSet {
|
||||
/// Networking layer relies on `get_main_version()` being the version
|
||||
/// of the main protocol name reported by [`PeerSetProtocolNames::get_main_name()`].
|
||||
pub fn get_main_version(self) -> ProtocolVersion {
|
||||
#[cfg(not(feature = "network-protocol-staging"))]
|
||||
match self {
|
||||
PeerSet::Validation => ValidationVersion::V1.into(),
|
||||
PeerSet::Collation => CollationVersion::V1.into(),
|
||||
}
|
||||
|
||||
#[cfg(feature = "network-protocol-staging")]
|
||||
match self {
|
||||
PeerSet::Validation => ValidationVersion::VStaging.into(),
|
||||
PeerSet::Collation => CollationVersion::VStaging.into(),
|
||||
PeerSet::Validation => ValidationVersion::V2.into(),
|
||||
PeerSet::Collation => CollationVersion::V2.into(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +145,7 @@ impl PeerSet {
|
||||
PeerSet::Validation =>
|
||||
if version == ValidationVersion::V1.into() {
|
||||
Some("validation/1")
|
||||
} else if version == ValidationVersion::VStaging.into() {
|
||||
} else if version == ValidationVersion::V2.into() {
|
||||
Some("validation/2")
|
||||
} else {
|
||||
None
|
||||
@@ -160,7 +153,7 @@ impl PeerSet {
|
||||
PeerSet::Collation =>
|
||||
if version == CollationVersion::V1.into() {
|
||||
Some("collation/1")
|
||||
} else if version == CollationVersion::VStaging.into() {
|
||||
} else if version == CollationVersion::V2.into() {
|
||||
Some("collation/2")
|
||||
} else {
|
||||
None
|
||||
@@ -223,8 +216,8 @@ impl From<ProtocolVersion> for u32 {
|
||||
pub enum ValidationVersion {
|
||||
/// The first version.
|
||||
V1 = 1,
|
||||
/// The staging version.
|
||||
VStaging = 2,
|
||||
/// The second version.
|
||||
V2 = 2,
|
||||
}
|
||||
|
||||
/// Supported collation protocol versions. Only versions defined here must be used in the codebase.
|
||||
@@ -232,8 +225,8 @@ pub enum ValidationVersion {
|
||||
pub enum CollationVersion {
|
||||
/// The first version.
|
||||
V1 = 1,
|
||||
/// The staging version.
|
||||
VStaging = 2,
|
||||
/// The second version.
|
||||
V2 = 2,
|
||||
}
|
||||
|
||||
/// Marker indicating the version is unknown.
|
||||
|
||||
@@ -55,7 +55,7 @@ pub use outgoing::{OutgoingRequest, OutgoingResult, Recipient, Requests, Respons
|
||||
pub mod v1;
|
||||
|
||||
/// Actual versioned requests and responses that are sent over the wire.
|
||||
pub mod vstaging;
|
||||
pub mod v2;
|
||||
|
||||
/// A protocol per subsystem seems to make the most sense, this way we don't need any dispatching
|
||||
/// within protocols.
|
||||
@@ -66,7 +66,7 @@ pub enum Protocol {
|
||||
/// Protocol for fetching collations from collators.
|
||||
CollationFetchingV1,
|
||||
/// Protocol for fetching collations from collators when async backing is enabled.
|
||||
CollationFetchingVStaging,
|
||||
CollationFetchingV2,
|
||||
/// Protocol for fetching seconded PoVs from validators of the same group.
|
||||
PoVFetchingV1,
|
||||
/// Protocol for fetching available data.
|
||||
@@ -78,7 +78,7 @@ pub enum Protocol {
|
||||
|
||||
/// Protocol for requesting candidates with attestations in statement distribution
|
||||
/// when async backing is enabled.
|
||||
AttestedCandidateVStaging,
|
||||
AttestedCandidateV2,
|
||||
}
|
||||
|
||||
/// Minimum bandwidth we expect for validators - 500Mbit/s is the recommendation, so approximately
|
||||
@@ -147,7 +147,7 @@ const POV_RESPONSE_SIZE: u64 = MAX_POV_SIZE as u64 + 10_000;
|
||||
/// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead.
|
||||
const STATEMENT_RESPONSE_SIZE: u64 = MAX_CODE_SIZE as u64 + 10_000;
|
||||
|
||||
/// Maximum response sizes for `AttestedCandidateVStaging`.
|
||||
/// Maximum response sizes for `AttestedCandidateV2`.
|
||||
///
|
||||
/// This is `MAX_CODE_SIZE` plus some additional space for protocol overhead and
|
||||
/// additional backing statements.
|
||||
@@ -199,7 +199,7 @@ impl Protocol {
|
||||
request_timeout: CHUNK_REQUEST_TIMEOUT,
|
||||
inbound_queue: tx,
|
||||
},
|
||||
Protocol::CollationFetchingV1 | Protocol::CollationFetchingVStaging =>
|
||||
Protocol::CollationFetchingV1 | Protocol::CollationFetchingV2 =>
|
||||
RequestResponseConfig {
|
||||
name,
|
||||
fallback_names,
|
||||
@@ -254,7 +254,7 @@ impl Protocol {
|
||||
request_timeout: DISPUTE_REQUEST_TIMEOUT,
|
||||
inbound_queue: tx,
|
||||
},
|
||||
Protocol::AttestedCandidateVStaging => RequestResponseConfig {
|
||||
Protocol::AttestedCandidateV2 => RequestResponseConfig {
|
||||
name,
|
||||
fallback_names,
|
||||
max_request_size: 1_000,
|
||||
@@ -275,7 +275,7 @@ impl Protocol {
|
||||
// as well.
|
||||
Protocol::ChunkFetchingV1 => 100,
|
||||
// 10 seems reasonable, considering group sizes of max 10 validators.
|
||||
Protocol::CollationFetchingV1 | Protocol::CollationFetchingVStaging => 10,
|
||||
Protocol::CollationFetchingV1 | Protocol::CollationFetchingV2 => 10,
|
||||
// 10 seems reasonable, considering group sizes of max 10 validators.
|
||||
Protocol::PoVFetchingV1 => 10,
|
||||
// Validators are constantly self-selecting to request available data which may lead
|
||||
@@ -307,7 +307,7 @@ impl Protocol {
|
||||
// failure, so having a good value here is mostly about performance tuning.
|
||||
Protocol::DisputeSendingV1 => 100,
|
||||
|
||||
Protocol::AttestedCandidateVStaging => {
|
||||
Protocol::AttestedCandidateV2 => {
|
||||
// We assume we can utilize up to 70% of the available bandwidth for statements.
|
||||
// This is just a guess/estimate, with the following considerations: If we are
|
||||
// faster than that, queue size will stay low anyway, even if not - requesters will
|
||||
@@ -344,8 +344,8 @@ impl Protocol {
|
||||
Protocol::DisputeSendingV1 => Some("/polkadot/send_dispute/1"),
|
||||
|
||||
// Introduced after legacy names became legacy.
|
||||
Protocol::AttestedCandidateVStaging => None,
|
||||
Protocol::CollationFetchingVStaging => None,
|
||||
Protocol::AttestedCandidateV2 => None,
|
||||
Protocol::CollationFetchingV2 => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -402,8 +402,8 @@ impl ReqProtocolNames {
|
||||
Protocol::StatementFetchingV1 => "/req_statement/1",
|
||||
Protocol::DisputeSendingV1 => "/send_dispute/1",
|
||||
|
||||
Protocol::CollationFetchingVStaging => "/req_collation/2",
|
||||
Protocol::AttestedCandidateVStaging => "/req_attested_candidate/2",
|
||||
Protocol::CollationFetchingV2 => "/req_collation/2",
|
||||
Protocol::AttestedCandidateV2 => "/req_attested_candidate/2",
|
||||
};
|
||||
|
||||
format!("{}{}", prefix, short_name).into()
|
||||
|
||||
@@ -23,7 +23,7 @@ use sc_network::PeerId;
|
||||
|
||||
use polkadot_primitives::AuthorityDiscoveryId;
|
||||
|
||||
use super::{v1, vstaging, IsRequest, Protocol};
|
||||
use super::{v1, v2, IsRequest, Protocol};
|
||||
|
||||
/// All requests that can be sent to the network bridge via `NetworkBridgeTxMessage::SendRequest`.
|
||||
#[derive(Debug)]
|
||||
@@ -42,10 +42,10 @@ pub enum Requests {
|
||||
DisputeSendingV1(OutgoingRequest<v1::DisputeRequest>),
|
||||
|
||||
/// Request a candidate and attestations.
|
||||
AttestedCandidateVStaging(OutgoingRequest<vstaging::AttestedCandidateRequest>),
|
||||
AttestedCandidateV2(OutgoingRequest<v2::AttestedCandidateRequest>),
|
||||
/// Fetch a collation from a collator which previously announced it.
|
||||
/// Compared to V1 it requires specifying which candidate is requested by its hash.
|
||||
CollationFetchingVStaging(OutgoingRequest<vstaging::CollationFetchingRequest>),
|
||||
CollationFetchingV2(OutgoingRequest<v2::CollationFetchingRequest>),
|
||||
}
|
||||
|
||||
impl Requests {
|
||||
@@ -54,12 +54,12 @@ impl Requests {
|
||||
match self {
|
||||
Self::ChunkFetchingV1(_) => Protocol::ChunkFetchingV1,
|
||||
Self::CollationFetchingV1(_) => Protocol::CollationFetchingV1,
|
||||
Self::CollationFetchingVStaging(_) => Protocol::CollationFetchingVStaging,
|
||||
Self::CollationFetchingV2(_) => Protocol::CollationFetchingV2,
|
||||
Self::PoVFetchingV1(_) => Protocol::PoVFetchingV1,
|
||||
Self::AvailableDataFetchingV1(_) => Protocol::AvailableDataFetchingV1,
|
||||
Self::StatementFetchingV1(_) => Protocol::StatementFetchingV1,
|
||||
Self::DisputeSendingV1(_) => Protocol::DisputeSendingV1,
|
||||
Self::AttestedCandidateVStaging(_) => Protocol::AttestedCandidateVStaging,
|
||||
Self::AttestedCandidateV2(_) => Protocol::AttestedCandidateV2,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,12 +74,12 @@ impl Requests {
|
||||
match self {
|
||||
Self::ChunkFetchingV1(r) => r.encode_request(),
|
||||
Self::CollationFetchingV1(r) => r.encode_request(),
|
||||
Self::CollationFetchingVStaging(r) => r.encode_request(),
|
||||
Self::CollationFetchingV2(r) => r.encode_request(),
|
||||
Self::PoVFetchingV1(r) => r.encode_request(),
|
||||
Self::AvailableDataFetchingV1(r) => r.encode_request(),
|
||||
Self::StatementFetchingV1(r) => r.encode_request(),
|
||||
Self::DisputeSendingV1(r) => r.encode_request(),
|
||||
Self::AttestedCandidateVStaging(r) => r.encode_request(),
|
||||
Self::AttestedCandidateV2(r) => r.encode_request(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -18,13 +18,13 @@
|
||||
|
||||
use parity_scale_codec::{Decode, Encode};
|
||||
|
||||
use polkadot_primitives::vstaging::{
|
||||
use polkadot_primitives::{
|
||||
CandidateHash, CommittedCandidateReceipt, Hash, Id as ParaId, PersistedValidationData,
|
||||
UncheckedSignedStatement,
|
||||
};
|
||||
|
||||
use super::{IsRequest, Protocol};
|
||||
use crate::vstaging::StatementFilter;
|
||||
use crate::v2::StatementFilter;
|
||||
|
||||
/// Request a candidate with statements.
|
||||
#[derive(Debug, Clone, Encode, Decode)]
|
||||
@@ -56,7 +56,7 @@ pub struct AttestedCandidateResponse {
|
||||
|
||||
impl IsRequest for AttestedCandidateRequest {
|
||||
type Response = AttestedCandidateResponse;
|
||||
const PROTOCOL: Protocol = Protocol::AttestedCandidateVStaging;
|
||||
const PROTOCOL: Protocol = Protocol::AttestedCandidateV2;
|
||||
}
|
||||
|
||||
/// Responses as sent by collators.
|
||||
@@ -76,5 +76,5 @@ pub struct CollationFetchingRequest {
|
||||
impl IsRequest for CollationFetchingRequest {
|
||||
// The response is the same as for V1.
|
||||
type Response = CollationFetchingResponse;
|
||||
const PROTOCOL: Protocol = Protocol::CollationFetchingVStaging;
|
||||
const PROTOCOL: Protocol = Protocol::CollationFetchingV2;
|
||||
}
|
||||
@@ -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;
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
+1
-1
@@ -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,
|
||||
};
|
||||
+2
-2
@@ -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() {
|
||||
+2
-6
@@ -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},
|
||||
+1
-2
@@ -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;
|
||||
+33
-36
@@ -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;
|
||||
+4
-4
@@ -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,
|
||||
};
|
||||
+2
-2
@@ -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};
|
||||
+20
-26
@@ -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;
|
||||
|
||||
+42
-44
@@ -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;
|
||||
|
||||
+6
-6
@@ -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;
|
||||
+33
-53
@@ -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(),
|
||||
),
|
||||
)
|
||||
Reference in New Issue
Block a user