Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add domain snap sync algorithm #3027

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 146 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/sc-consensus-subspace/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ACKNOWLEDGEMENT_TIMEOUT: Duration = Duration::from_mins(2);
/// Ideally, we'd decouple pruning from finalization, but it may require invasive changes in
/// Substrate and is not worth it right now.
/// https://github.com/paritytech/substrate/discussions/14359
pub(crate) const FINALIZATION_DEPTH_IN_SEGMENTS: SegmentIndex = SegmentIndex::new(5);
pub const FINALIZATION_DEPTH_IN_SEGMENTS: SegmentIndex = SegmentIndex::new(5);

#[derive(Debug)]
struct SegmentHeadersStoreInner<AS> {
Expand Down
31 changes: 30 additions & 1 deletion crates/subspace-service/src/domains.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Remove after adding domain snap-sync
#![allow(dead_code)]
pub mod snap_sync_orchestrator;

use crate::domains::request_handler::{
generate_protocol_name, LastConfirmedBlockRequest, LastConfirmedBlockResponse,
};
use crate::domains::snap_sync_orchestrator::SnapSyncOrchestrator;
use crate::FullBackend;
use async_trait::async_trait;
use domain_runtime_primitives::Balance;
use futures::channel::oneshot;
use parity_scale_codec::{Decode, Encode};
use sc_client_api::AuxStore;
use sc_consensus_subspace::archiver::SegmentHeadersStore;
use sc_network::{IfDisconnected, NetworkRequest, PeerId, RequestFailure};
use sc_network_sync::SyncingService;
use sp_blockchain::HeaderBackend;
Expand All @@ -22,7 +27,31 @@ pub(crate) mod request_handler;

const REQUEST_PAUSE: Duration = Duration::from_secs(5);

/// Last confirmed domain block info error
/// Provides parameters for domain snap sync synchronization with the consensus chain snap sync.
pub struct ConsensusChainSyncParams<Block, CBlock, CNR, AS>
where
Block: BlockT,
CBlock: BlockT,
CNR: NetworkRequest + Sync + Send,
AS: AuxStore,
{
/// Synchronizes consensus snap sync stages.
pub snap_sync_orchestrator: Arc<SnapSyncOrchestrator>,
/// Provides execution receipts for the last confirmed domain block.
pub execution_receipt_provider: Box<dyn LastDomainBlockReceiptProvider<Block, CBlock>>,
/// Consensus chain fork ID
pub fork_id: Option<String>,
/// Consensus chain network service
pub network_service: CNR,
/// Consensus chain sync service
pub sync_service: Arc<SyncingService<CBlock>>,
/// Consensus chain backend (for obtaining offchain storage)
pub backend: Arc<FullBackend>,
/// Provides segment headers.
pub segment_headers_store: SegmentHeadersStore<AS>,
}

/// Last confirmed domain block info error.
#[derive(Debug, thiserror::Error)]
pub enum LastConfirmedDomainBlockResponseError {
#[error("Last confirmed domain block info request failed: {0}")]
Expand Down
Loading
Loading