mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
add warp to target block for parachains (#12761)
* add warp to target block for parachains * fix for failing tests * format using `Cargo +nightly fmt` * Remove blocking based on PR comments and create new `WarpSync` on poll * remove method from trait * add tests for wait for target * Update client/network/common/src/sync/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/common/src/sync/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * code refactor based on pr comments * Second round of PR comments * Third round of pr comments * add comments to explain logic * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * code refactor based on last PR comments * move warp sync polling before `process_outbound_requests` Add error message if target block fails to be retreived * Update client/network/sync/src/warp.rs Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> * Update client/network/sync/src/lib.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fmt after code suggestions * rebase changes * Bring down the node if the target block fails to return * Revert "Bring down the node if the target block fails to return" This reverts commit c0ecb220d66dd8e7b1a5ee29831b776f4f18d024. * Update client/network/common/src/sync/warp.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * Update client/network/common/src/sync/warp.rs Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> * use matching on polling to avoid calling poll more than once * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/sync/src/warp.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fix typo on comment * update snapshot with new folder structure * Upload snapshot * Bump zombienet * bump zombienet again * Improve test * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update client/network/test/src/sync.rs Co-authored-by: Bastian Köcher <git@kchr.de> * fix tests * dummy commit to restart builds * Converted the target block to an optional value that is set to `None` when an error occurs * dummy commit to restart builds --------- Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Arkadiy Paronyan <arkady.paronyan@gmail.com> Co-authored-by: Michal Kucharczyk <1728078+michalkucharczyk@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
@@ -43,7 +43,7 @@ use sc_network_bitswap::BitswapRequestHandler;
|
||||
use sc_network_common::{
|
||||
protocol::role::Roles,
|
||||
service::{NetworkStateInfo, NetworkStatusProvider},
|
||||
sync::warp::WarpSyncProvider,
|
||||
sync::warp::WarpSyncParams,
|
||||
};
|
||||
use sc_network_light::light_client_requests::handler::LightClientRequestHandler;
|
||||
use sc_network_sync::{
|
||||
@@ -759,8 +759,8 @@ pub struct BuildNetworkParams<'a, TBl: BlockT, TExPool, TImpQu, TCl> {
|
||||
/// A block announce validator builder.
|
||||
pub block_announce_validator_builder:
|
||||
Option<Box<dyn FnOnce(Arc<TCl>) -> Box<dyn BlockAnnounceValidator<TBl> + Send> + Send>>,
|
||||
/// An optional warp sync provider.
|
||||
pub warp_sync: Option<Arc<dyn WarpSyncProvider<TBl>>>,
|
||||
/// Optional warp sync params.
|
||||
pub warp_sync_params: Option<WarpSyncParams<TBl>>,
|
||||
}
|
||||
/// Build the network service, the network status sinks and an RPC sender.
|
||||
pub fn build_network<TBl, TExPool, TImpQu, TCl>(
|
||||
@@ -795,12 +795,12 @@ where
|
||||
spawn_handle,
|
||||
import_queue,
|
||||
block_announce_validator_builder,
|
||||
warp_sync,
|
||||
warp_sync_params,
|
||||
} = params;
|
||||
|
||||
let mut request_response_protocol_configs = Vec::new();
|
||||
|
||||
if warp_sync.is_none() && config.network.sync_mode.is_warp() {
|
||||
if warp_sync_params.is_none() && config.network.sync_mode.is_warp() {
|
||||
return Err("Warp sync enabled, but no warp sync provider configured.".into())
|
||||
}
|
||||
|
||||
@@ -845,8 +845,8 @@ where
|
||||
protocol_config
|
||||
};
|
||||
|
||||
let (warp_sync_provider, warp_sync_protocol_config) = warp_sync
|
||||
.map(|provider| {
|
||||
let warp_sync_protocol_config = match warp_sync_params.as_ref() {
|
||||
Some(WarpSyncParams::WithProvider(warp_with_provider)) => {
|
||||
// Allow both outgoing and incoming requests.
|
||||
let (handler, protocol_config) = WarpSyncRequestHandler::new(
|
||||
protocol_id.clone(),
|
||||
@@ -856,12 +856,13 @@ where
|
||||
.flatten()
|
||||
.expect("Genesis block exists; qed"),
|
||||
config.chain_spec.fork_id(),
|
||||
provider.clone(),
|
||||
warp_with_provider.clone(),
|
||||
);
|
||||
spawn_handle.spawn("warp-sync-request-handler", Some("networking"), handler.run());
|
||||
(Some(provider), Some(protocol_config))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
Some(protocol_config)
|
||||
},
|
||||
_ => None,
|
||||
};
|
||||
|
||||
let light_client_request_protocol_config = {
|
||||
// Allow both outgoing and incoming requests.
|
||||
@@ -888,7 +889,7 @@ where
|
||||
Roles::from(&config.role),
|
||||
block_announce_validator,
|
||||
config.network.max_parallel_downloads,
|
||||
warp_sync_provider,
|
||||
warp_sync_params,
|
||||
config.prometheus_config.as_ref().map(|config| config.registry.clone()).as_ref(),
|
||||
chain_sync_network_handle,
|
||||
import_queue.service(),
|
||||
|
||||
Reference in New Issue
Block a user