Skip to content
Snippets Groups Projects
Unverified Commit 0e09ad44 authored by Liu-Cheng Xu's avatar Liu-Cheng Xu Committed by GitHub
Browse files

Expose more syncing types to enable custom syncing strategy (#6163)

This PR exposes additional syncing types to facilitate the development
of a custom syncing strategy based on the existing Polkadot syncing
strategy. Specifically, my goal is to isolate the state sync and chain
sync components, allowing the state to be downloaded from the P2P
network without running a full regular Substrate node. I also need to
intercept the state responses during the state sync process.

The newly exposed types are necessary to implement this custom syncing
strategy.
parent c4e94d35
No related merge requests found
Pipeline #504801 waiting for manual action with stages
in 28 minutes and 47 seconds
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json
title: Expose more syncing types to enable custom syncing strategy
doc:
- audience: Node Dev
description: |
Exposes additional syncing types to facilitate the development of a custom syncing strategy.
crates:
- name: sc-network-sync
bump: patch
......@@ -18,6 +18,7 @@
//! Blockchain syncing implementation in Substrate.
pub use schema::v1::*;
pub use service::syncing_service::SyncingService;
pub use strategy::warp::{WarpSyncConfig, WarpSyncPhase, WarpSyncProgress};
pub use types::{SyncEvent, SyncEventStream, SyncState, SyncStatus, SyncStatusProvider};
......
......@@ -25,7 +25,7 @@
pub mod chain_sync;
mod disconnected_peers;
pub mod polkadot;
mod state;
pub mod state;
pub mod state_sync;
pub mod warp;
......@@ -177,7 +177,8 @@ pub enum SyncingAction<B: BlockT> {
}
impl<B: BlockT> SyncingAction<B> {
fn is_finished(&self) -> bool {
/// Returns `true` if the syncing action has completed.
pub fn is_finished(&self) -> bool {
matches!(self, SyncingAction::Finished)
}
......
......@@ -118,10 +118,11 @@ impl<B: BlockT> StateStrategy<B> {
}
}
// Create a new instance with a custom state sync provider.
// Used in tests.
#[cfg(test)]
fn new_with_provider(
/// Create a new instance with a custom state sync provider.
///
/// Note: In most cases, users should use [`StateStrategy::new`].
/// This method is intended for custom sync strategies and advanced use cases.
pub fn new_with_provider(
state_sync_provider: Box<dyn StateSyncProvider<B>>,
initial_peers: impl Iterator<Item = (PeerId, NumberFor<B>)>,
protocol_name: ProtocolName,
......@@ -348,7 +349,7 @@ impl<B: BlockT> StateStrategy<B> {
}
}
/// Get actions that should be performed by the owner on [`WarpSync`]'s behalf
/// Get actions that should be performed.
#[must_use]
pub fn actions(
&mut self,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment