mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 23:41:02 +00:00
approval-voting improvement: include all tranche0 assignments in one certificate (#1178)
**_PR migrated from https://github.com/paritytech/polkadot/pull/6782_** This PR will upgrade the network protocol to version 3 -> VStaging which will later be renamed to V3. This version introduces a new kind of assignment certificate that will be used for tranche0 assignments. Instead of issuing/importing one tranche0 assignment per candidate, there will be just one certificate per relay chain block per validator. However, we will not be sending out the new assignment certificates, yet. So everything should work exactly as before. Once the majority of the validators have been upgraded to the new protocol version we will enable the new certificates (starting at a specific relay chain block) with a new client update. There are still a few things that need to be done: - [x] Use bitfield instead of Vec<CandidateIndex>: https://github.com/paritytech/polkadot/pull/6802 - [x] Fix existing approval-distribution and approval-voting tests - [x] Fix bitfield-distribution and statement-distribution tests - [x] Fix network bridge tests - [x] Implement todos in the code - [x] Add tests to cover new code - [x] Update metrics - [x] Remove the approval distribution aggression levels: TBD PR - [x] Parachains DB migration - [x] Test network protocol upgrade on Versi - [x] Versi Load test - [x] Add Zombienet test - [x] Documentation updates - [x] Fix for sending DistributeAssignment for each candidate claimed by a v2 assignment (warning: Importing locally an already known assignment) - [x] Fix AcceptedDuplicate - [x] Fix DB migration so that we can still keep old data. - [x] Final Versi burn in --------- Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> Signed-off-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io> Co-authored-by: Alexandru Gheorghe <alexandru.gheorghe@parity.io>
This commit is contained in:
@@ -21,6 +21,7 @@ use super::*;
|
||||
use always_assert::never;
|
||||
use bytes::Bytes;
|
||||
use futures::stream::{BoxStream, StreamExt};
|
||||
use net_protocol::filter_by_peer_version;
|
||||
use parity_scale_codec::{Decode, DecodeAll};
|
||||
|
||||
use sc_network::Event as NetworkEvent;
|
||||
@@ -33,8 +34,8 @@ use polkadot_node_network_protocol::{
|
||||
CollationVersion, PeerSet, PeerSetProtocolNames, PerPeerSet, ProtocolVersion,
|
||||
ValidationVersion,
|
||||
},
|
||||
v1 as protocol_v1, v2 as protocol_v2, ObservedRole, OurView, PeerId,
|
||||
UnifiedReputationChange as Rep, View,
|
||||
v1 as protocol_v1, v2 as protocol_v2, vstaging as protocol_vstaging, ObservedRole, OurView,
|
||||
PeerId, UnifiedReputationChange as Rep, View,
|
||||
};
|
||||
|
||||
use polkadot_node_subsystem::{
|
||||
@@ -64,9 +65,11 @@ use super::validator_discovery;
|
||||
/// Actual interfacing to the network based on the `Network` trait.
|
||||
///
|
||||
/// Defines the `Network` trait with an implementation for an `Arc<NetworkService>`.
|
||||
use crate::network::{send_message, Network};
|
||||
|
||||
use crate::network::get_peer_id_by_authority_id;
|
||||
use crate::network::{
|
||||
send_collation_message_v1, send_collation_message_v2, send_validation_message_v1,
|
||||
send_validation_message_v2, send_validation_message_vstaging, Network,
|
||||
};
|
||||
use crate::{network::get_peer_id_by_authority_id, WireMessage};
|
||||
|
||||
use super::metrics::Metrics;
|
||||
|
||||
@@ -251,22 +254,27 @@ where
|
||||
match ValidationVersion::try_from(version)
|
||||
.expect("try_get_protocol has already checked version is known; qed")
|
||||
{
|
||||
ValidationVersion::V1 => send_message(
|
||||
ValidationVersion::V1 => send_validation_message_v1(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Validation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_v1::ValidationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
),
|
||||
&metrics,
|
||||
),
|
||||
ValidationVersion::V2 => send_message(
|
||||
ValidationVersion::VStaging => send_validation_message_vstaging(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_vstaging::ValidationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
),
|
||||
&metrics,
|
||||
),
|
||||
ValidationVersion::V2 => send_validation_message_v2(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Validation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_v2::ValidationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
@@ -293,22 +301,18 @@ where
|
||||
match CollationVersion::try_from(version)
|
||||
.expect("try_get_protocol has already checked version is known; qed")
|
||||
{
|
||||
CollationVersion::V1 => send_message(
|
||||
CollationVersion::V1 => send_collation_message_v1(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Collation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_v1::CollationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
),
|
||||
&metrics,
|
||||
),
|
||||
CollationVersion::V2 => send_message(
|
||||
CollationVersion::V2 => send_collation_message_v2(
|
||||
&mut network_service,
|
||||
vec![peer],
|
||||
PeerSet::Collation,
|
||||
version,
|
||||
&peerset_protocol_names,
|
||||
WireMessage::<protocol_v2::CollationProtocol>::ViewUpdate(
|
||||
local_view,
|
||||
@@ -386,8 +390,16 @@ where
|
||||
.filter_map(|(protocol, msg_bytes)| {
|
||||
// version doesn't matter because we always receive on the 'correct'
|
||||
// protocol name, not the negotiated fallback.
|
||||
let (peer_set, _version) =
|
||||
let (peer_set, version) =
|
||||
peerset_protocol_names.try_get_protocol(protocol)?;
|
||||
gum::trace!(
|
||||
target: LOG_TARGET,
|
||||
?peer_set,
|
||||
?protocol,
|
||||
?version,
|
||||
"Received notification"
|
||||
);
|
||||
|
||||
if peer_set == PeerSet::Validation {
|
||||
if expected_versions[PeerSet::Validation].is_none() {
|
||||
return Some(Err(UNCONNECTED_PEERSET_COST))
|
||||
@@ -474,6 +486,16 @@ where
|
||||
v_messages,
|
||||
&metrics,
|
||||
)
|
||||
} else if expected_versions[PeerSet::Validation] ==
|
||||
Some(ValidationVersion::VStaging.into())
|
||||
{
|
||||
handle_peer_messages::<protocol_vstaging::ValidationProtocol, _>(
|
||||
remote,
|
||||
PeerSet::Validation,
|
||||
&mut shared.0.lock().validation_peers,
|
||||
v_messages,
|
||||
&metrics,
|
||||
)
|
||||
} else {
|
||||
gum::warn!(
|
||||
target: LOG_TARGET,
|
||||
@@ -815,15 +837,16 @@ fn update_our_view<Net, Context>(
|
||||
)
|
||||
};
|
||||
|
||||
let filter_by_version = |peers: &[(PeerId, ProtocolVersion)], version| {
|
||||
peers.iter().filter(|(_, v)| v == &version).map(|(p, _)| *p).collect::<Vec<_>>()
|
||||
};
|
||||
let v1_validation_peers =
|
||||
filter_by_peer_version(&validation_peers, ValidationVersion::V1.into());
|
||||
let v1_collation_peers = filter_by_peer_version(&collation_peers, CollationVersion::V1.into());
|
||||
|
||||
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 v2_validation_peers =
|
||||
filter_by_peer_version(&validation_peers, ValidationVersion::V2.into());
|
||||
let v2_collation_peers = filter_by_peer_version(&collation_peers, CollationVersion::V2.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());
|
||||
let vstaging_validation_peers =
|
||||
filter_by_peer_version(&validation_peers, ValidationVersion::VStaging.into());
|
||||
|
||||
send_validation_message_v1(
|
||||
net,
|
||||
@@ -853,7 +876,15 @@ fn update_our_view<Net, Context>(
|
||||
net,
|
||||
v2_collation_peers,
|
||||
peerset_protocol_names,
|
||||
WireMessage::ViewUpdate(new_view),
|
||||
WireMessage::ViewUpdate(new_view.clone()),
|
||||
metrics,
|
||||
);
|
||||
|
||||
send_validation_message_vstaging(
|
||||
net,
|
||||
vstaging_validation_peers,
|
||||
peerset_protocol_names,
|
||||
WireMessage::ViewUpdate(new_view.clone()),
|
||||
metrics,
|
||||
);
|
||||
|
||||
@@ -926,78 +957,6 @@ fn handle_peer_messages<RawMessage: Decode, OutMessage: From<RawMessage>>(
|
||||
(outgoing_events, reports)
|
||||
}
|
||||
|
||||
fn send_validation_message_v1(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
peerset_protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_v1::ValidationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Validation,
|
||||
ValidationVersion::V1.into(),
|
||||
peerset_protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
fn send_collation_message_v1(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
peerset_protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_v1::CollationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Collation,
|
||||
CollationVersion::V1.into(),
|
||||
peerset_protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
fn send_validation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_v2::ValidationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Validation,
|
||||
ValidationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
fn send_collation_message_v2(
|
||||
net: &mut impl Network,
|
||||
peers: Vec<PeerId>,
|
||||
protocol_names: &PeerSetProtocolNames,
|
||||
message: WireMessage<protocol_v2::CollationProtocol>,
|
||||
metrics: &Metrics,
|
||||
) {
|
||||
send_message(
|
||||
net,
|
||||
peers,
|
||||
PeerSet::Collation,
|
||||
CollationVersion::V2.into(),
|
||||
protocol_names,
|
||||
message,
|
||||
metrics,
|
||||
);
|
||||
}
|
||||
|
||||
async fn dispatch_validation_event_to_all(
|
||||
event: NetworkBridgeEvent<net_protocol::VersionedValidationProtocol>,
|
||||
ctx: &mut impl overseer::NetworkBridgeRxSenderTrait,
|
||||
|
||||
Reference in New Issue
Block a user