mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 09:17:58 +00:00
Extract warp sync strategy from ChainSync (#2467)
Extract `WarpSync` (and `StateSync` as part of warp sync) from `ChainSync` as independent syncing strategy called by `SyncingEngine`. Introduce `SyncingStrategy` enum as a proxy between `SyncingEngine` and specific syncing strategies. ## Limitations Gap sync is kept in `ChainSync` for now because it shares the same set of peers as block syncing implementation in `ChainSync`. Extraction of a common context responsible for peer management in syncing strategies able to run in parallel is planned for a follow-up PR. ## Further improvements A possibility of conversion of `SyncingStartegy` into a trait should be evaluated. The main stopper for this is that different strategies need to communicate different actions to `SyncingEngine` and respond to different events / provide different APIs (e.g., requesting justifications is only possible via `ChainSync` and not through `WarpSync`; `SendWarpProofRequest` action is only relevant to `WarpSync`, etc.) --------- Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com>
This commit is contained in:
@@ -66,7 +66,7 @@ use sc_network_sync::{
|
||||
block_request_handler::BlockRequestHandler,
|
||||
service::{network::NetworkServiceProvider, syncing_service::SyncingService},
|
||||
state_request_handler::StateRequestHandler,
|
||||
warp::{
|
||||
strategy::warp::{
|
||||
AuthorityList, EncodedProof, SetId, VerificationResult, WarpSyncParams, WarpSyncProvider,
|
||||
},
|
||||
warp_request_handler,
|
||||
@@ -699,6 +699,8 @@ pub struct FullPeerConfig {
|
||||
pub storage_chain: bool,
|
||||
/// Optional target block header to sync to
|
||||
pub target_block: Option<<Block as BlockT>::Header>,
|
||||
/// Force genesis even in case of warp & light state sync.
|
||||
pub force_genesis: bool,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -758,7 +760,9 @@ pub trait TestNetFactory: Default + Sized + Send {
|
||||
*genesis_extra_storage = storage;
|
||||
}
|
||||
|
||||
if matches!(config.sync_mode, SyncMode::LightState { .. } | SyncMode::Warp) {
|
||||
if !config.force_genesis &&
|
||||
matches!(config.sync_mode, SyncMode::LightState { .. } | SyncMode::Warp)
|
||||
{
|
||||
test_client_builder = test_client_builder.set_no_genesis();
|
||||
}
|
||||
let backend = test_client_builder.backend();
|
||||
|
||||
Reference in New Issue
Block a user