Skip to content

Commit

Permalink
Allow importing older blocks in DSN/Snap sync if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jul 18, 2024
1 parent 742af99 commit acbc2ff
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 4 additions & 1 deletion crates/sc-consensus-subspace/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,9 @@ where
);

let best_number = self.client.info().best_number;
// Reject block below archiving point, but only if we received it from the network
if *block.header.number() + self.chain_constants.confirmation_depth_k().into() < best_number
&& matches!(block.origin, BlockOrigin::NetworkBroadcast)
{
debug!(
header = ?block.header,
Expand Down Expand Up @@ -579,7 +581,8 @@ where
} = checked_header;

let slot = pre_digest.slot();
// Estimate what the "current" slot is according to sync target since we don't have other way to know it
// Estimate what the "current" slot is according to sync target since we don't have other
// way to know it
let diff_in_blocks = self
.sync_target_block_number
.load(Ordering::Relaxed)
Expand Down
3 changes: 2 additions & 1 deletion crates/subspace-service/src/sync_from_dsn/import_blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ where
import_queue_service
.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
// This will notify Substrate's sync mechanism and allow regular Substrate sync to continue gracefully
import_queue_service.import_blocks(BlockOrigin::NetworkBroadcast, vec![last_block]);
import_queue_service
.import_blocks(BlockOrigin::ConsensusBroadcast, vec![last_block]);
} else {
import_queue_service
.import_blocks(BlockOrigin::NetworkInitialSync, blocks_to_import);
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-service/src/sync_from_dsn/snap_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ where
);

import_queue_service
.import_blocks(BlockOrigin::NetworkBroadcast, vec![last_block_to_import]);
.import_blocks(BlockOrigin::ConsensusBroadcast, vec![last_block_to_import]);
}

// Wait for blocks to be imported
Expand Down

0 comments on commit acbc2ff

Please sign in to comment.