Skip to content

Commit

Permalink
Merge pull request #2934 from subspace/clear-block-gap-after-dsn-sync
Browse files Browse the repository at this point in the history
Clear block gap proactively after DSN sync as well
  • Loading branch information
nazar-pc authored Jul 22, 2024
2 parents 9a20564 + 3dcea8e commit abfb713
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions crates/subspace-service/src/sync_from_dsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use sc_client_api::{AuxStore, BlockBackend, BlockchainEvents};
use sc_consensus::import_queue::ImportQueueService;
use sc_consensus_subspace::archiver::SegmentHeadersStore;
use sc_network::service::traits::NetworkService;
use sc_service::ClientExt;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi};
Expand Down Expand Up @@ -84,7 +85,7 @@ enum NotificationReason {
/// Create node observer that will track node state and send notifications to worker to start sync
/// from DSN.
#[allow(clippy::too_many_arguments)]
pub(super) fn create_observer_and_worker<Block, AS, Client, PG>(
pub(super) fn create_observer_and_worker<Block, Backend, AS, Client, PG>(
segment_headers_store: SegmentHeadersStore<AS>,
network_service: Arc<dyn NetworkService>,
node: Node,
Expand All @@ -99,11 +100,13 @@ pub(super) fn create_observer_and_worker<Block, AS, Client, PG>(
)
where
Block: BlockT,
Backend: sc_client_api::Backend<Block>,
AS: AuxStore + Send + Sync + 'static,
Client: HeaderBackend<Block>
+ BlockBackend<Block>
+ BlockchainEvents<Block>
+ ProvideRuntimeApi<Block>
+ ClientExt<Block, Backend>
+ Send
+ Sync
+ 'static,
Expand Down Expand Up @@ -247,7 +250,7 @@ async fn create_substrate_network_observer(
}

#[allow(clippy::too_many_arguments)]
async fn create_worker<Block, AS, IQS, Client, PG>(
async fn create_worker<Block, Backend, AS, IQS, Client, PG>(
segment_headers_store: SegmentHeadersStore<AS>,
node: &Node,
client: &Client,
Expand All @@ -259,10 +262,12 @@ async fn create_worker<Block, AS, IQS, Client, PG>(
) -> Result<(), sc_service::Error>
where
Block: BlockT,
Backend: sc_client_api::Backend<Block>,
AS: AuxStore + Send + Sync + 'static,
Client: HeaderBackend<Block>
+ BlockBackend<Block>
+ ProvideRuntimeApi<Block>
+ ClientExt<Block, Backend>
+ Send
+ Sync
+ 'static,
Expand Down Expand Up @@ -329,6 +334,11 @@ where
}
}

// Clear the block gap that arises from first block import with a much higher number than
// previously (resulting in a gap)
// TODO: This is a hack and better solution is needed: https://github.com/paritytech/polkadot-sdk/issues/4407
client.clear_block_gap()?;

debug!("Finished DSN sync");

pause_sync.store(false, Ordering::Release);
Expand Down

0 comments on commit abfb713

Please sign in to comment.