mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 19:17:58 +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:
@@ -26,10 +26,11 @@ use error::{log_error, FatalResult, JfyiErrorResult};
|
||||
use parity_scale_codec::Encode;
|
||||
|
||||
use polkadot_node_network_protocol::{
|
||||
self as net_protocol,
|
||||
peer_set::{IsAuthority, PeerSet},
|
||||
request_response::{v1 as request_v1, IncomingRequestReceiver},
|
||||
v1::{self as protocol_v1, StatementMetadata},
|
||||
IfDisconnected, PeerId, UnifiedReputationChange as Rep, View,
|
||||
IfDisconnected, PeerId, UnifiedReputationChange as Rep, Versioned, View,
|
||||
};
|
||||
use polkadot_node_primitives::{SignedFullStatement, Statement, UncheckedSignedFullStatement};
|
||||
use polkadot_node_subsystem_util::{self as util, rand, MIN_GOSSIP_PEERS};
|
||||
@@ -961,7 +962,7 @@ fn statement_message(
|
||||
relay_parent: Hash,
|
||||
statement: SignedFullStatement,
|
||||
metrics: &Metrics,
|
||||
) -> protocol_v1::ValidationProtocol {
|
||||
) -> net_protocol::VersionedValidationProtocol {
|
||||
let (is_large, size) = is_statement_large(&statement);
|
||||
if let Some(size) = size {
|
||||
metrics.on_created_message(size);
|
||||
@@ -978,7 +979,7 @@ fn statement_message(
|
||||
protocol_v1::StatementDistributionMessage::Statement(relay_parent, statement.into())
|
||||
};
|
||||
|
||||
protocol_v1::ValidationProtocol::StatementDistribution(msg)
|
||||
protocol_v1::ValidationProtocol::StatementDistribution(msg).into()
|
||||
}
|
||||
|
||||
/// Check whether a statement should be treated as large statement.
|
||||
@@ -1603,12 +1604,12 @@ async fn handle_network_update(
|
||||
recent_outdated_heads: &RecentOutdatedHeads,
|
||||
ctx: &mut (impl SubsystemContext + overseer::SubsystemContext),
|
||||
req_sender: &mpsc::Sender<RequesterMessage>,
|
||||
update: NetworkBridgeEvent<protocol_v1::StatementDistributionMessage>,
|
||||
update: NetworkBridgeEvent<net_protocol::StatementDistributionMessage>,
|
||||
metrics: &Metrics,
|
||||
rng: &mut impl rand::Rng,
|
||||
) {
|
||||
match update {
|
||||
NetworkBridgeEvent::PeerConnected(peer, role, maybe_authority) => {
|
||||
NetworkBridgeEvent::PeerConnected(peer, role, _, maybe_authority) => {
|
||||
gum::trace!(target: LOG_TARGET, ?peer, ?role, "Peer connected");
|
||||
peers.insert(
|
||||
peer,
|
||||
@@ -1660,7 +1661,7 @@ async fn handle_network_update(
|
||||
}
|
||||
}
|
||||
},
|
||||
NetworkBridgeEvent::PeerMessage(peer, message) => {
|
||||
NetworkBridgeEvent::PeerMessage(peer, Versioned::V1(message)) => {
|
||||
handle_incoming_message_and_circulate(
|
||||
peer,
|
||||
gossip_peers,
|
||||
@@ -2056,7 +2057,7 @@ impl<R: rand::Rng> StatementDistributionSubsystem<R> {
|
||||
)
|
||||
.await;
|
||||
},
|
||||
StatementDistributionMessage::NetworkBridgeUpdateV1(event) => {
|
||||
StatementDistributionMessage::NetworkBridgeUpdate(event) => {
|
||||
handle_network_update(
|
||||
peers,
|
||||
gossip_peers,
|
||||
|
||||
Reference in New Issue
Block a user