mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 07:11:03 +00:00
Generic request/response infrastructure for Polkadot (#2352)
* Move NetworkBridgeEvent to subsystem::messages. It is not protocol related at all, it is in fact only part of the subsystem communication as it gets wrapped into messages of each subsystem. * Request/response infrastructure is taking shape. WIP: Does not compile. * Multiplexer variant not supported by Rusts type system. * request_response::request type checks. * Cleanup. * Minor fixes for request_response. * Implement request sending + move multiplexer. Request multiplexer is moved to bridge, as there the implementation is more straight forward as we can specialize on `AllMessages` for the multiplexing target. Sending of requests is mostly complete, apart from a few `From` instances. Receiving is also almost done, initializtion needs to be fixed and the multiplexer needs to be invoked. * Remove obsolete multiplexer. * Initialize bridge with multiplexer. * Finish generic request sending/receiving. Subsystems are now able to receive and send requests and responses via the overseer. * Doc update. * Fixes. * Link issue for not yet implemented code. * Fixes suggested by @ordian - thanks! - start encoding at 0 - don't crash on zero protocols - don't panic on not yet implemented request handling * Update node/network/protocol/src/request_response/v1.rs Use index 0 instead of 1. Co-authored-by: Andronik Ordian <write@reusable.software> * Update node/network/protocol/src/request_response.rs Co-authored-by: Andronik Ordian <write@reusable.software> * Fix existing tests. * Better avoidance of division by zoro errors. * Doc fixes. * send_request -> start_request. * Fix missing renamings. * Update substrate. * Pass TryConnect instead of true. * Actually import `IfDisconnected`. * Fix wrong import. * Update node/network/bridge/src/lib.rs typo Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * Update node/network/bridge/src/multiplexer.rs Remove redundant import. Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> * Stop doing tracing from within `From` instance. Thanks for the catch @tomaka! * Get rid of redundant import. * Formatting cleanup. * Fix tests. * Add link to issue. * Clarify comments some more. * Fix tests. * Formatting fix. * tabs * Fix link Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * Use map_err. Co-authored-by: Bernhard Schuster <bernhard@ahoi.io> * Improvements inspired by suggestions by @drahnr. - Channel size is now determined by function. - Explicitely scope NetworkService::start_request. Co-authored-by: Andronik Ordian <write@reusable.software> Co-authored-by: Pierre Krieger <pierre.krieger1708@gmail.com> Co-authored-by: Bernhard Schuster <bernhard@ahoi.io>
This commit is contained in:
@@ -39,6 +39,8 @@ use {
|
||||
sp_trie::PrefixedMemoryDB,
|
||||
sc_client_api::ExecutorProvider,
|
||||
};
|
||||
#[cfg(feature = "real-overseer")]
|
||||
use polkadot_network_bridge::RequestMultiplexer;
|
||||
|
||||
use sp_core::traits::SpawnNamed;
|
||||
|
||||
@@ -347,6 +349,7 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
_: AvailabilityConfig,
|
||||
_: Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
_: AuthorityDiscoveryService,
|
||||
request_multiplexer: (),
|
||||
registry: Option<&Registry>,
|
||||
spawner: Spawner,
|
||||
_: IsCollator,
|
||||
@@ -373,6 +376,7 @@ fn real_overseer<Spawner, RuntimeClient>(
|
||||
availability_config: AvailabilityConfig,
|
||||
network_service: Arc<sc_network::NetworkService<Block, Hash>>,
|
||||
authority_discovery: AuthorityDiscoveryService,
|
||||
request_multiplexer: RequestMultiplexer,
|
||||
registry: Option<&Registry>,
|
||||
spawner: Spawner,
|
||||
is_collator: IsCollator,
|
||||
@@ -456,6 +460,7 @@ where
|
||||
network_bridge: NetworkBridgeSubsystem::new(
|
||||
network_service,
|
||||
authority_discovery,
|
||||
request_multiplexer,
|
||||
),
|
||||
pov_distribution: PoVDistributionSubsystem::new(
|
||||
Metrics::register(registry)?,
|
||||
@@ -597,6 +602,15 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
config.network.request_response_protocols.push(sc_finality_grandpa_warp_sync::request_response_config_for_chain(
|
||||
&config, task_manager.spawn_handle(), backend.clone(),
|
||||
));
|
||||
#[cfg(feature = "real-overseer")]
|
||||
fn register_request_response(config: &mut sc_network::config::NetworkConfiguration) -> RequestMultiplexer {
|
||||
let (multiplexer, configs) = RequestMultiplexer::new();
|
||||
config.request_response_protocols.extend(configs);
|
||||
multiplexer
|
||||
}
|
||||
#[cfg(not(feature = "real-overseer"))]
|
||||
fn register_request_response(_: &mut sc_network::config::NetworkConfiguration) {}
|
||||
let request_multiplexer = register_request_response(&mut config.network);
|
||||
|
||||
let (network, network_status_sinks, system_rpc_tx, network_starter) =
|
||||
service::build_network(service::BuildNetworkParams {
|
||||
@@ -693,6 +707,7 @@ pub fn new_full<RuntimeApi, Executor>(
|
||||
availability_config,
|
||||
network.clone(),
|
||||
authority_discovery_service,
|
||||
request_multiplexer,
|
||||
prometheus_registry.as_ref(),
|
||||
spawner,
|
||||
is_collator,
|
||||
|
||||
Reference in New Issue
Block a user