mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +00:00
Companion for paritytech/substrate#14080 (#2526)
* Companion for paritytech/substrate#14080 * Update lockfile * Update Polkadot * Update Cargo.lock
This commit is contained in:
@@ -29,7 +29,7 @@ use polkadot_node_subsystem_util::metrics::prometheus::Registry;
|
||||
use polkadot_primitives::CollatorPair;
|
||||
|
||||
use sc_authority_discovery::Service as AuthorityDiscoveryService;
|
||||
use sc_network::{Event, NetworkEventStream, NetworkService};
|
||||
use sc_network::{config::FullNetworkConfiguration, Event, NetworkEventStream, NetworkService};
|
||||
use sc_service::{Configuration, TaskManager};
|
||||
use sp_runtime::{app_crypto::Pair, traits::Block as BlockT};
|
||||
|
||||
@@ -119,11 +119,12 @@ pub async fn build_minimal_relay_chain_node(
|
||||
/// - AvailabilityDistribution
|
||||
#[sc_tracing::logging::prefix_logs_with("Relaychain")]
|
||||
async fn new_minimal_relay_chain(
|
||||
mut config: Configuration,
|
||||
config: Configuration,
|
||||
collator_pair: CollatorPair,
|
||||
relay_chain_rpc_client: Arc<BlockChainRpcClient>,
|
||||
) -> Result<NewMinimalNode, RelayChainError> {
|
||||
let role = config.role.clone();
|
||||
let mut net_config = sc_network::config::FullNetworkConfiguration::new(&config.network);
|
||||
|
||||
let task_manager = {
|
||||
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
|
||||
@@ -141,22 +142,27 @@ async fn new_minimal_relay_chain(
|
||||
let peer_set_protocol_names =
|
||||
PeerSetProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
|
||||
let is_authority = if role.is_authority() { IsAuthority::Yes } else { IsAuthority::No };
|
||||
config
|
||||
.network
|
||||
.extra_sets
|
||||
.extend(peer_sets_info(is_authority, &peer_set_protocol_names));
|
||||
|
||||
for config in peer_sets_info(is_authority, &peer_set_protocol_names) {
|
||||
net_config.add_notification_protocol(config);
|
||||
}
|
||||
|
||||
let request_protocol_names = ReqProtocolNames::new(genesis_hash, config.chain_spec.fork_id());
|
||||
let (collation_req_receiver, available_data_req_receiver) =
|
||||
build_request_response_protocol_receivers(&request_protocol_names, &mut config);
|
||||
build_request_response_protocol_receivers(&request_protocol_names, &mut net_config);
|
||||
|
||||
let best_header = relay_chain_rpc_client
|
||||
.chain_get_header(None)
|
||||
.await?
|
||||
.ok_or_else(|| RelayChainError::RpcCallError("Unable to fetch best header".to_string()))?;
|
||||
let (network, network_starter, sync_oracle) =
|
||||
build_collator_network(&config, task_manager.spawn_handle(), genesis_hash, best_header)
|
||||
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
|
||||
let (network, network_starter, sync_oracle) = build_collator_network(
|
||||
&config,
|
||||
net_config,
|
||||
task_manager.spawn_handle(),
|
||||
genesis_hash,
|
||||
best_header,
|
||||
)
|
||||
.map_err(|e| RelayChainError::Application(Box::new(e) as Box<_>))?;
|
||||
|
||||
let authority_discovery_service = build_authority_discovery_service(
|
||||
&task_manager,
|
||||
@@ -190,18 +196,18 @@ async fn new_minimal_relay_chain(
|
||||
|
||||
fn build_request_response_protocol_receivers(
|
||||
request_protocol_names: &ReqProtocolNames,
|
||||
config: &mut Configuration,
|
||||
config: &mut FullNetworkConfiguration,
|
||||
) -> (
|
||||
IncomingRequestReceiver<v1::CollationFetchingRequest>,
|
||||
IncomingRequestReceiver<v1::AvailableDataFetchingRequest>,
|
||||
) {
|
||||
let (collation_req_receiver, cfg) =
|
||||
IncomingRequest::get_config_receiver(request_protocol_names);
|
||||
config.network.request_response_protocols.push(cfg);
|
||||
config.add_request_response_protocol(cfg);
|
||||
let (available_data_req_receiver, cfg) =
|
||||
IncomingRequest::get_config_receiver(request_protocol_names);
|
||||
config.network.request_response_protocols.push(cfg);
|
||||
config.add_request_response_protocol(cfg);
|
||||
let cfg = Protocol::ChunkFetchingV1.get_outbound_only_config(request_protocol_names);
|
||||
config.network.request_response_protocols.push(cfg);
|
||||
config.add_request_response_protocol(cfg);
|
||||
(collation_req_receiver, available_data_req_receiver)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user