Change request-response protocol names to include genesis hash & fork id (#5870)

This commit is contained in:
Dmitry Markin
2022-08-12 15:07:13 +03:00
committed by GitHub
parent 596b5df747
commit 4def0da0dc
17 changed files with 206 additions and 72 deletions
+16 -14
View File
@@ -46,6 +46,7 @@ use {
self as chain_selection_subsystem, Config as ChainSelectionConfig,
},
polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig,
polkadot_node_network_protocol::request_response::ReqProtocolNames,
polkadot_overseer::BlockInfo,
sc_client_api::{BlockBackend, ExecutorProvider},
sp_core::traits::SpawnNamed,
@@ -831,22 +832,19 @@ where
let shared_voter_state = rpc_setup;
let auth_disc_publish_non_global_ips = config.network.allow_non_globals_in_dht;
let genesis_hash = client.block_hash(0).ok().flatten().expect("Genesis block exists; qed");
// Note: GrandPa is pushed before the Polkadot-specific protocols. This doesn't change
// anything in terms of behaviour, but makes the logs more consistent with the other
// Substrate nodes.
let grandpa_protocol_name = grandpa::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);
let grandpa_protocol_name = grandpa::protocol_standard_name(&genesis_hash, &config.chain_spec);
config
.network
.extra_sets
.push(grandpa::grandpa_peers_set_config(grandpa_protocol_name.clone()));
let beefy_protocol_name = beefy_gadget::protocol_standard_name(
&client.block_hash(0).ok().flatten().expect("Genesis block exists; qed"),
&config.chain_spec,
);
let beefy_protocol_name =
beefy_gadget::protocol_standard_name(&genesis_hash, &config.chain_spec);
if enable_beefy {
config
.network
@@ -860,17 +858,20 @@ where
config.network.extra_sets.extend(peer_sets_info(is_authority));
}
let (pov_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let req_protocol_names = ReqProtocolNames::new(&genesis_hash, config.chain_spec.fork_id());
let (pov_req_receiver, cfg) = IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let (chunk_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let (chunk_req_receiver, cfg) = IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let (collation_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let (collation_req_receiver, cfg) = IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let (available_data_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let (available_data_req_receiver, cfg) =
IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let (statement_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let (statement_req_receiver, cfg) = IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let (dispute_req_receiver, cfg) = IncomingRequest::get_config_receiver();
let (dispute_req_receiver, cfg) = IncomingRequest::get_config_receiver(&req_protocol_names);
config.network.request_response_protocols.push(cfg);
let grandpa_hard_forks = if config.chain_spec.is_kusama() {
@@ -1061,6 +1062,7 @@ where
dispute_coordinator_config,
pvf_checker_enabled,
overseer_message_channel_capacity_override,
req_protocol_names,
},
)
.map_err(|e| {
+8 -1
View File
@@ -24,7 +24,9 @@ use polkadot_node_core_av_store::Config as AvailabilityConfig;
use polkadot_node_core_candidate_validation::Config as CandidateValidationConfig;
use polkadot_node_core_chain_selection::Config as ChainSelectionConfig;
use polkadot_node_core_dispute_coordinator::Config as DisputeCoordinatorConfig;
use polkadot_node_network_protocol::request_response::{v1 as request_v1, IncomingRequestReceiver};
use polkadot_node_network_protocol::request_response::{
v1 as request_v1, IncomingRequestReceiver, ReqProtocolNames,
};
#[cfg(any(feature = "malus", test))]
pub use polkadot_overseer::{
dummy::{dummy_overseer_builder, DummySubsystem},
@@ -118,6 +120,8 @@ where
pub pvf_checker_enabled: bool,
/// Overseer channel capacity override.
pub overseer_message_channel_capacity_override: Option<usize>,
/// Request-response protocol names source.
pub req_protocol_names: ReqProtocolNames,
}
/// Obtain a prepared `OverseerBuilder`, that is initialized
@@ -146,6 +150,7 @@ pub fn prepared_overseer_builder<'a, Spawner, RuntimeClient>(
dispute_coordinator_config,
pvf_checker_enabled,
overseer_message_channel_capacity_override,
req_protocol_names,
}: OverseerGenArgs<'a, Spawner, RuntimeClient>,
) -> Result<
InitializedOverseerBuilder<
@@ -194,11 +199,13 @@ where
let spawner = SpawnGlue(spawner);
let network_bridge_metrics: NetworkBridgeMetrics = Metrics::register(registry)?;
let builder = Overseer::builder()
.network_bridge_tx(NetworkBridgeTxSubsystem::new(
network_service.clone(),
authority_discovery_service.clone(),
network_bridge_metrics.clone(),
req_protocol_names,
))
.network_bridge_rx(NetworkBridgeRxSubsystem::new(
network_service.clone(),