mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 10:27:59 +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:
@@ -31,7 +31,7 @@ use std::{
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use futures::{future::BoxFuture, prelude::*};
|
||||
use futures::{channel::oneshot, future::BoxFuture, prelude::*};
|
||||
use libp2p::{build_multiaddr, PeerId};
|
||||
use log::trace;
|
||||
use parking_lot::Mutex;
|
||||
@@ -56,7 +56,9 @@ use sc_network_common::{
|
||||
},
|
||||
protocol::{role::Roles, ProtocolName},
|
||||
service::{NetworkBlock, NetworkStateInfo, NetworkSyncForkRequest},
|
||||
sync::warp::{AuthorityList, EncodedProof, SetId, VerificationResult, WarpSyncProvider},
|
||||
sync::warp::{
|
||||
AuthorityList, EncodedProof, SetId, VerificationResult, WarpSyncParams, WarpSyncProvider,
|
||||
},
|
||||
};
|
||||
use sc_network_light::light_client_requests::handler::LightClientRequestHandler;
|
||||
use sc_network_sync::{
|
||||
@@ -722,6 +724,8 @@ pub struct FullPeerConfig {
|
||||
pub extra_storage: Option<sp_core::storage::Storage>,
|
||||
/// Enable transaction indexing.
|
||||
pub storage_chain: bool,
|
||||
/// Optional target block header to sync to
|
||||
pub target_block: Option<<Block as BlockT>::Header>,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -867,6 +871,15 @@ where
|
||||
|
||||
let warp_sync = Arc::new(TestWarpSyncProvider(client.clone()));
|
||||
|
||||
let warp_sync_params = match config.target_block {
|
||||
Some(target_block) => {
|
||||
let (sender, receiver) = oneshot::channel::<<Block as BlockT>::Header>();
|
||||
let _ = sender.send(target_block);
|
||||
WarpSyncParams::WaitForTarget(receiver)
|
||||
},
|
||||
_ => WarpSyncParams::WithProvider(warp_sync.clone()),
|
||||
};
|
||||
|
||||
let warp_protocol_config = {
|
||||
let (handler, protocol_config) = warp_request_handler::RequestHandler::new(
|
||||
protocol_id.clone(),
|
||||
@@ -887,6 +900,7 @@ where
|
||||
.unwrap_or_else(|| Box::new(DefaultBlockAnnounceValidator));
|
||||
let (chain_sync_network_provider, chain_sync_network_handle) =
|
||||
NetworkServiceProvider::new();
|
||||
|
||||
let (chain_sync, chain_sync_service, block_announce_config) = ChainSync::new(
|
||||
match network_config.sync_mode {
|
||||
SyncMode::Full => sc_network_common::sync::SyncMode::Full,
|
||||
@@ -903,7 +917,7 @@ where
|
||||
Roles::from(if config.is_authority { &Role::Authority } else { &Role::Full }),
|
||||
block_announce_validator,
|
||||
network_config.max_parallel_downloads,
|
||||
Some(warp_sync),
|
||||
Some(warp_sync_params),
|
||||
None,
|
||||
chain_sync_network_handle,
|
||||
import_queue.service(),
|
||||
|
||||
Reference in New Issue
Block a user