Skip to content

Commit

Permalink
Merge pull request #2927 from subspace/optimize-archiving-during-sync
Browse files Browse the repository at this point in the history
Optimize archiving during sync
  • Loading branch information
nazar-pc authored Jul 18, 2024
2 parents 47a7f34 + 742af99 commit 047f17a
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions crates/sc-consensus-subspace/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ use subspace_archiving::archiver::{Archiver, NewArchivedSegment};
use subspace_core_primitives::crypto::kzg::Kzg;
use subspace_core_primitives::objects::BlockObjectMapping;
use subspace_core_primitives::{BlockNumber, RecordedHistorySegment, SegmentHeader, SegmentIndex};
use tracing::{debug, info, warn};
use tracing::{debug, info, trace, warn};

/// Number of WASM instances is 8, this is a bit lower to avoid warnings exceeding number of
/// instances
Expand Down Expand Up @@ -830,8 +830,31 @@ where
}
};

if best_archived_block_number >= block_number_to_archive {
let last_archived_block_number = NumberFor::<Block>::from(
segment_headers_store
.last_segment_header()
.expect("Exists after archiver initialization; qed")
.last_archived_block()
.number,
);
trace!(
%importing_block_number,
%block_number_to_archive,
%best_archived_block_number,
%last_archived_block_number,
"Checking if block needs to be skipped"
);
if best_archived_block_number >= block_number_to_archive
|| last_archived_block_number > block_number_to_archive
{
// This block was already archived, skip
debug!(
%importing_block_number,
%block_number_to_archive,
%best_archived_block_number,
%last_archived_block_number,
"Skipping already archived block",
);
continue;
}

Expand Down

0 comments on commit 047f17a

Please sign in to comment.