Skip to content

Commit

Permalink
Enable validation/collation v2 protocols (#1542)
Browse files Browse the repository at this point in the history
Removes the `network-protocol-staging` feature. This is needed for the
first release of async backing capable nodes.
Renames `VStaging` to `V2`
on top of #1543

---------

Signed-off-by: Andrei Sandu <[email protected]>
  • Loading branch information
sandreim authored Sep 15, 2023
1 parent b8b8121 commit 4cb5e35
Show file tree
Hide file tree
Showing 50 changed files with 469 additions and 596 deletions.
3 changes: 0 additions & 3 deletions cumulus/client/relay-chain-inprocess-interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,3 @@ metered = { package = "prioritized-metered-channel", version = "0.5.1", default-

# Cumulus
cumulus-test-service = { path = "../../test/service" }

[features]
network-protocol-staging = [ "polkadot-service/network-protocol-staging" ]
4 changes: 0 additions & 4 deletions cumulus/client/relay-chain-minimal-node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,3 @@ tracing = "0.1.37"
async-trait = "0.1.73"
futures = "0.3.28"

[features]
network-protocol-staging = [
"polkadot-node-network-protocol/network-protocol-staging",
]
11 changes: 5 additions & 6 deletions cumulus/client/relay-chain-minimal-node/src/collator_overseer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
request_response::{
v1::{self, AvailableDataFetchingRequest},
vstaging, IncomingRequestReceiver, ReqProtocolNames,
v2, IncomingRequestReceiver, ReqProtocolNames,
},
};
use polkadot_node_subsystem_util::metrics::{prometheus::Registry, Metrics};
Expand Down Expand Up @@ -63,9 +63,8 @@ pub(crate) struct CollatorOverseerGenArgs<'a> {
pub authority_discovery_service: AuthorityDiscoveryService,
/// Receiver for collation request protocol v1.
pub collation_req_receiver_v1: IncomingRequestReceiver<v1::CollationFetchingRequest>,
/// Receiver for collation request protocol vstaging.
pub collation_req_receiver_vstaging:
IncomingRequestReceiver<vstaging::CollationFetchingRequest>,
/// Receiver for collation request protocol v2.
pub collation_req_receiver_v2: IncomingRequestReceiver<v2::CollationFetchingRequest>,
/// Receiver for availability request protocol
pub available_data_req_receiver: IncomingRequestReceiver<AvailableDataFetchingRequest>,
/// Prometheus registry, commonly used for production systems, less so for test.
Expand All @@ -88,7 +87,7 @@ fn build_overseer(
sync_oracle,
authority_discovery_service,
collation_req_receiver_v1,
collation_req_receiver_vstaging,
collation_req_receiver_v2,
available_data_req_receiver,
registry,
spawner,
Expand Down Expand Up @@ -121,7 +120,7 @@ fn build_overseer(
peer_id: network_service.local_peer_id(),
collator_pair,
request_receiver_v1: collation_req_receiver_v1,
request_receiver_vstaging: collation_req_receiver_vstaging,
request_receiver_v2: collation_req_receiver_v2,
metrics: Metrics::register(registry)?,
};
CollatorProtocolSubsystem::new(side)
Expand Down
12 changes: 6 additions & 6 deletions cumulus/client/relay-chain-minimal-node/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use polkadot_network_bridge::{peer_sets_info, IsAuthority};
use polkadot_node_network_protocol::{
peer_set::PeerSetProtocolNames,
request_response::{
v1, vstaging, IncomingRequest, IncomingRequestReceiver, Protocol, ReqProtocolNames,
v1, v2, IncomingRequest, IncomingRequestReceiver, Protocol, ReqProtocolNames,
},
};

Expand Down Expand Up @@ -182,7 +182,7 @@ async fn new_minimal_relay_chain(
}

let request_protocol_names = ReqProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
let (collation_req_receiver_v1, collation_req_receiver_vstaging, available_data_req_receiver) =
let (collation_req_receiver_v1, collation_req_receiver_v2, available_data_req_receiver) =
build_request_response_protocol_receivers(&request_protocol_names, &mut net_config);

let best_header = relay_chain_rpc_client
Expand Down Expand Up @@ -212,7 +212,7 @@ async fn new_minimal_relay_chain(
sync_oracle,
authority_discovery_service,
collation_req_receiver_v1,
collation_req_receiver_vstaging,
collation_req_receiver_v2,
available_data_req_receiver,
registry: prometheus_registry.as_ref(),
spawner: task_manager.spawn_handle(),
Expand All @@ -234,19 +234,19 @@ fn build_request_response_protocol_receivers(
config: &mut FullNetworkConfiguration,
) -> (
IncomingRequestReceiver<v1::CollationFetchingRequest>,
IncomingRequestReceiver<vstaging::CollationFetchingRequest>,
IncomingRequestReceiver<v2::CollationFetchingRequest>,
IncomingRequestReceiver<v1::AvailableDataFetchingRequest>,
) {
let (collation_req_receiver_v1, cfg) =
IncomingRequest::get_config_receiver(request_protocol_names);
config.add_request_response_protocol(cfg);
let (collation_req_receiver_vstaging, cfg) =
let (collation_req_receiver_v2, cfg) =
IncomingRequest::get_config_receiver(request_protocol_names);
config.add_request_response_protocol(cfg);
let (available_data_req_receiver, cfg) =
IncomingRequest::get_config_receiver(request_protocol_names);
config.add_request_response_protocol(cfg);
let cfg = Protocol::ChunkFetchingV1.get_outbound_only_config(request_protocol_names);
config.add_request_response_protocol(cfg);
(collation_req_receiver_v1, collation_req_receiver_vstaging, available_data_req_receiver)
(collation_req_receiver_v1, collation_req_receiver_v2, available_data_req_receiver)
}
5 changes: 0 additions & 5 deletions cumulus/client/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,3 @@ cumulus-relay-chain-interface = { path = "../relay-chain-interface" }
cumulus-relay-chain-inprocess-interface = { path = "../relay-chain-inprocess-interface" }
cumulus-relay-chain-minimal-node = { path = "../relay-chain-minimal-node" }

[features]
network-protocol-staging = [
"cumulus-relay-chain-inprocess-interface/network-protocol-staging",
"cumulus-relay-chain-minimal-node/network-protocol-staging",
]
5 changes: 1 addition & 4 deletions cumulus/parachain-template/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,4 @@ try-runtime = [
"polkadot-cli/try-runtime",
"sp-runtime/try-runtime",
]
network-protocol-staging = [
"cumulus-client-service/network-protocol-staging",
"polkadot-cli/network-protocol-staging",
]

1 change: 0 additions & 1 deletion polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ jemalloc-allocator = [
# Enables timeout-based tests supposed to be run only in CI environment as they may be flaky
# when run locally depending on system load
ci-only-tests = [ "polkadot-node-core-pvf/ci-only-tests" ]
network-protocol-staging = [ "polkadot-cli/network-protocol-staging" ]

# Configuration for building a .deb package - for use with `cargo-deb`
[package.metadata.deb]
Expand Down
1 change: 0 additions & 1 deletion polkadot/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,3 @@ runtime-metrics = [
"polkadot-node-metrics/runtime-metrics",
"service/runtime-metrics",
]
network-protocol-staging = [ "service/network-protocol-staging" ]
48 changes: 22 additions & 26 deletions polkadot/node/network/approval-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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;
}
Expand Down Expand Up @@ -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),
)),
}
}
Expand All @@ -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),
)),
}
}
Expand Down
16 changes: 8 additions & 8 deletions polkadot/node/network/approval-distribution/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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,
Expand Down Expand Up @@ -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]);
Expand Down
19 changes: 9 additions & 10 deletions polkadot/node/network/bitfield-distribution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(),
)),
Expand Down Expand Up @@ -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(
Expand All @@ -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
}
Expand All @@ -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),
Expand Down
Loading

0 comments on commit 4cb5e35

Please sign in to comment.