mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Prepare for network protocol version upgrades (#5084)
* explicitly tag network requests with version * fmt * make PeerSet more aware of versioning * some generalization of the network bridge to support upgrades * walk back some renaming * walk back some version stuff * extract version from fallback * remove V1 from NetworkBridgeUpdate * add accidentally-removed timer * implement focusing for versioned messages * fmt * fix up network bridge & tests * remove inaccurate version check in bridge * remove some TODO [now]s * fix fallout in statement distribution * fmt * fallout in gossip-support * fix fallout in collator-protocol * fix fallout in bitfield-distribution * fix fallout in approval-distribution * fmt * use never! * fmt
This commit is contained in:
@@ -25,7 +25,8 @@
|
||||
use futures::{channel::oneshot, FutureExt};
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
v1 as protocol_v1, OurView, PeerId, UnifiedReputationChange as Rep, View,
|
||||
self as net_protocol, v1 as protocol_v1, OurView, PeerId, UnifiedReputationChange as Rep,
|
||||
Versioned, View,
|
||||
};
|
||||
use polkadot_node_subsystem_util::{self as util, MIN_GOSSIP_PEERS};
|
||||
use polkadot_primitives::v2::{Hash, SignedAvailabilityBitfield, SigningContext, ValidatorId};
|
||||
@@ -63,15 +64,15 @@ struct BitfieldGossipMessage {
|
||||
}
|
||||
|
||||
impl BitfieldGossipMessage {
|
||||
fn into_validation_protocol(self) -> protocol_v1::ValidationProtocol {
|
||||
protocol_v1::ValidationProtocol::BitfieldDistribution(self.into_network_message())
|
||||
fn into_validation_protocol(self) -> net_protocol::VersionedValidationProtocol {
|
||||
self.into_network_message().into()
|
||||
}
|
||||
|
||||
fn into_network_message(self) -> protocol_v1::BitfieldDistributionMessage {
|
||||
protocol_v1::BitfieldDistributionMessage::Bitfield(
|
||||
fn into_network_message(self) -> net_protocol::BitfieldDistributionMessage {
|
||||
Versioned::V1(protocol_v1::BitfieldDistributionMessage::Bitfield(
|
||||
self.relay_parent,
|
||||
self.signed_availability.into(),
|
||||
)
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ impl BitfieldDistribution {
|
||||
.await;
|
||||
},
|
||||
FromOverseer::Communication {
|
||||
msg: BitfieldDistributionMessage::NetworkBridgeUpdateV1(event),
|
||||
msg: BitfieldDistributionMessage::NetworkBridgeUpdate(event),
|
||||
} => {
|
||||
gum::trace!(target: LOG_TARGET, "Processing NetworkMessage");
|
||||
// a network message was received
|
||||
@@ -506,14 +507,14 @@ async fn handle_network_msg<Context>(
|
||||
ctx: &mut Context,
|
||||
state: &mut ProtocolState,
|
||||
metrics: &Metrics,
|
||||
bridge_message: NetworkBridgeEvent<protocol_v1::BitfieldDistributionMessage>,
|
||||
bridge_message: NetworkBridgeEvent<net_protocol::BitfieldDistributionMessage>,
|
||||
) where
|
||||
Context: SubsystemContext<Message = BitfieldDistributionMessage>,
|
||||
{
|
||||
let _timer = metrics.time_handle_network_msg();
|
||||
|
||||
match bridge_message {
|
||||
NetworkBridgeEvent::PeerConnected(peer, role, _) => {
|
||||
NetworkBridgeEvent::PeerConnected(peer, role, _, _) => {
|
||||
gum::trace!(target: LOG_TARGET, ?peer, ?role, "Peer connected");
|
||||
// insert if none already present
|
||||
state.peer_views.entry(peer).or_default();
|
||||
@@ -550,7 +551,7 @@ async fn handle_network_msg<Context>(
|
||||
gum::trace!(target: LOG_TARGET, ?new_view, "Our view change");
|
||||
handle_our_view_change(state, new_view);
|
||||
},
|
||||
NetworkBridgeEvent::PeerMessage(remote, message) =>
|
||||
NetworkBridgeEvent::PeerMessage(remote, Versioned::V1(message)) =>
|
||||
process_incoming_peer_message(ctx, state, metrics, remote, message).await,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ fn changing_view() {
|
||||
&mut ctx,
|
||||
&mut state,
|
||||
&Default::default(),
|
||||
NetworkBridgeEvent::PeerConnected(peer_b.clone(), ObservedRole::Full, None),
|
||||
NetworkBridgeEvent::PeerConnected(peer_b.clone(), ObservedRole::Full, 1, None),
|
||||
));
|
||||
|
||||
// make peer b interested
|
||||
|
||||
Reference in New Issue
Block a user