Skip to content

Fix: Load snapshot store from snapshot path in replay (#3900)#3912

Merged
jolestar merged 1 commit into
mainfrom
fix_3900
Jan 7, 2026
Merged

Fix: Load snapshot store from snapshot path in replay (#3900)#3912
jolestar merged 1 commit into
mainfrom
fix_3900

Conversation

@jolestar

@jolestar jolestar commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR fixes issue #3900 where the replay function was ignoring snapshot contents and using the live MoveOSStore instead.

Problem

The load_snapshot_store function in IncrementalReplayer was ignoring the snapshot_path parameter and returning the live MoveOSStore. This caused replay operations to read and write against the live database rather than the snapshot, making it impossible to perform a true replay from a snapshot.

Solution

Modified the load_snapshot_store function to:

  • Load the actual snapshot from snapshot_path/snapshot.db
  • Validate that the snapshot database exists and is a valid directory
  • Create a new MoveOSStore instance from the snapshot database path
  • Provide clear error messages for troubleshooting

Changes

  • crates/rooch-pruner/src/state_prune/incremental_replayer.rs:

    • Fixed load_snapshot_store to load from the actual snapshot path
    • Removed unused moveos_store field from IncrementalReplayer struct
    • Added two regression tests:
      • test_load_snapshot_store_uses_snapshot_path_not_live_db: Verifies snapshot is loaded from correct path
      • test_load_snapshot_store_validates_path: Tests error handling for invalid paths
  • crates/rooch-pruner/Cargo.toml:

    • Moved prometheus from dev-dependencies to dependencies (required for MoveOSStore::new)

Acceptance Criteria

load_snapshot_store uses snapshot data from disk
✅ Replay runs against snapshot content, not current DB
✅ Regression tests added that verify the fix

Test Results

  • All 104 tests in rooch-pruner package pass
  • Binary compiles successfully
  • No clippy warnings

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings January 7, 2026 03:33
@jolestar jolestar requested a review from baichuan3 as a code owner January 7, 2026 03:33
@vercel

vercel Bot commented Jan 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview, Comment Jan 7, 2026 3:45am
test-portal Ready Ready Preview, Comment Jan 7, 2026 3:45am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
rooch Ignored Ignored Preview Jan 7, 2026 3:45am

@github-actions

github-actions Bot commented Jan 7, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 fixes issue #3900 where the replay function was incorrectly using the live MoveOSStore instead of loading data from the snapshot path. The fix ensures that replay operations now properly load and use the snapshot database, making it possible to perform true replays from snapshots.

Key Changes

  • Modified load_snapshot_store to load the actual snapshot database from snapshot_path/snapshot.db instead of returning the live store
  • Removed the unused moveos_store field from IncrementalReplayer struct since the snapshot store is now loaded on-demand
  • Added comprehensive regression tests to verify the fix and validate error handling

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/rooch-pruner/src/state_prune/incremental_replayer.rs Fixed load_snapshot_store implementation to load from snapshot path, removed unused struct field, added two regression tests
crates/rooch-pruner/Cargo.toml Moved prometheus from dev-dependencies to dependencies (required for MoveOSStore::new with Registry)

impl IncrementalReplayer {
/// Create new incremental replayer
pub fn new(config: ReplayConfig, moveos_store: MoveOSStore) -> Result<Self> {
pub fn new(config: ReplayConfig, _moveos_store: MoveOSStore) -> Result<Self> {

Copilot AI Jan 7, 2026

Copy link

Choose a reason for hiding this comment

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

The _moveos_store parameter is no longer used after the fix but is still required by the API. This could be misleading for callers who might assume it's being used for replay operations. Consider removing this parameter entirely and updating all callers to pass only the ReplayConfig. This would make the API clearer and prevent confusion about which store is actually used during replay.

Copilot uses AI. Check for mistakes.
Previously, the replay function ignored the snapshot contents and
used the live MoveOSStore, causing replay operations to read/write
against the live DB instead of the snapshot.

Changes:
- Fix load_snapshot_store to load from snapshot_path/snapshot.db
- Add validation for snapshot database path
- Add regression tests to verify snapshot isolation
- Move prometheus to dependencies (required for MoveOSStore::new)

This ensures replay runs against snapshot content, not current DB.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jolestar jolestar merged commit bb05ccd into main Jan 7, 2026
17 checks passed
@jolestar jolestar deleted the fix_3900 branch January 7, 2026 06:24
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.

2 participants