Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@danlaine
Copy link
Collaborator

@danlaine danlaine commented Jul 14, 2025

This PR addresses #1213 by allowing for the re-use of existing persisted data when entering state sync.

danlaine added 30 commits July 11, 2025 15:31
.await
.unwrap();

// Verify database state
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved from below to be more consistent with other tests

@danlaine danlaine marked this pull request as ready for review July 14, 2025 21:16
@danlaine danlaine requested a review from Copilot July 14, 2025 21:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the ability to reuse existing persisted data during state synchronization in ADB, addressing issue #1213. The changes enable the sync process to detect and leverage previously stored operations and MMR data that fall within the sync boundaries, rather than always starting from scratch.

Key changes include:

  • Modified init_sync functions in both MMR and Journal to handle three scenarios: fresh start, prune and reuse, and prune and rewind
  • Updated sync client to detect when existing data matches sync targets and skip network operations
  • Enhanced configuration structures to use boundary-based parameters instead of single pruning positions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
storage/src/mmr/mod.rs Added InvalidSize error variant for MMR validation
storage/src/mmr/journaled.rs Replaced init_pruned with init_sync to handle data reuse scenarios and updated configuration
storage/src/journal/fixed.rs Replaced init_pruned with init_sync to support boundary-based initialization and data reuse
storage/src/adb/any/sync/resolver.rs Added test helper FailResolver for testing scenarios where no network operations should occur
storage/src/adb/any/sync/mod.rs Modified sync function to handle cases where sync is already complete
storage/src/adb/any/sync/client.rs Enhanced client to detect complete sync scenarios and avoid unnecessary network operations
storage/src/adb/any/mod.rs Updated init_synced to handle existing data scenarios and renamed configuration parameters

@danlaine danlaine changed the title [WIP] [adb] [sync] Re-use existing persisted data during state sync [adb] [sync] Re-use existing persisted data during state sync Jul 14, 2025
Copy link
Contributor

@patrick-ogrady patrick-ogrady left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty close! Just comments on naming really.

}

// Install pinned nodes on first successful batch.
if log_size == config.lower_bound_ops {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this was the "nuance" you referred to lol?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more referring to this:

        if cfg.lower_bound < journal_size {
            // We need to add the pinned nodes required for proving at the given pruning boundary.
            let mut additional_pinned_nodes = HashMap::new();
            for pos in Proof::<H::Digest>::nodes_to_pin(cfg.lower_bound) {
                let digest =
                    Mmr::<E, H>::get_from_metadata_or_journal(&metadata, &journal, pos).await?;
                additional_pinned_nodes.insert(pos, digest);
            }
            mem_mmr.add_pinned_nodes(additional_pinned_nodes);
        }

@danlaine danlaine requested a review from patrick-ogrady July 15, 2025 16:33
@patrick-ogrady patrick-ogrady merged commit 64aa8de into main Jul 15, 2025
31 checks passed
@patrick-ogrady patrick-ogrady deleted the danlaine/sync-start branch July 15, 2025 16:57
@patrick-ogrady patrick-ogrady linked an issue Jul 15, 2025 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jul 15, 2025

Codecov Report

Attention: Patch coverage is 97.72118% with 17 lines in your changes missing coverage. Please review.

Project coverage is 91.09%. Comparing base (685aa3d) to head (3babacc).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/adb/any/sync/resolver.rs 46.66% 8 Missing ⚠️
storage/src/journal/fixed.rs 97.85% 6 Missing ⚠️
storage/src/adb/any/sync/client.rs 98.61% 2 Missing ⚠️
storage/src/adb/any/mod.rs 99.43% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1275      +/-   ##
==========================================
+ Coverage   91.06%   91.09%   +0.03%     
==========================================
  Files         246      246              
  Lines       60120    60489     +369     
==========================================
+ Hits        54748    55103     +355     
- Misses       5372     5386      +14     
Files with missing lines Coverage Δ
storage/src/adb/any/sync/mod.rs 100.00% <100.00%> (ø)
storage/src/mmr/journaled.rs 98.65% <100.00%> (+0.04%) ⬆️
storage/src/adb/any/mod.rs 99.05% <99.43%> (+<0.01%) ⬆️
storage/src/adb/any/sync/client.rs 90.63% <98.61%> (+3.09%) ⬆️
storage/src/journal/fixed.rs 97.77% <97.85%> (+0.12%) ⬆️
storage/src/adb/any/sync/resolver.rs 73.33% <46.66%> (-26.67%) ⬇️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 685aa3d...3babacc. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[storage] [sync] Add handling for existing database

2 participants