Skip to content

Fix: sync sequencer info after state-prune replay#3941

Merged
jolestar merged 5 commits into
mainfrom
fix/replay-sequencer-consistency
Jan 27, 2026
Merged

Fix: sync sequencer info after state-prune replay#3941
jolestar merged 5 commits into
mainfrom
fix/replay-sequencer-consistency

Conversation

@jolestar

Copy link
Copy Markdown
Contributor

Summary

  • always refresh sequencer_info to to_order after replay, even when no trim is needed
  • add post-replay consistency check between startup_info and sequencer_info
  • keep trim logic but eliminate the early-return gap that left last_order stale (could be 0)

Testing

  • cargo fmt
  • cargo test -q --package rooch-pruner --lib --test state_prune_tests --test snapshot_replay_e2e_test # timed out at 120s in local env; no compile errors before timeout

@vercel

vercel Bot commented Jan 26, 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 26, 2026 6:51pm
test-portal Ready Ready Preview, Comment Jan 26, 2026 6:51pm
1 Skipped Deployment
Project Deployment Review Updated (UTC)
rooch Ignored Ignored Preview Jan 26, 2026 6:51pm

Request Review

Copilot AI review requested due to automatic review settings January 26, 2026 16:45
@github-actions

github-actions Bot commented Jan 26, 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 a critical issue where sequencer_info.last_order could remain stale (potentially 0) after state-prune replay when no trimming was needed. The fix ensures sequencer_info is always synchronized to the target order, and adds a consistency verification between startup_info and sequencer_info.

Changes:

  • Refactored trim_output_store to always refresh sequencer_info before checking if trimming is needed, eliminating the gap that left last_order stale
  • Added verify_startup_sequencer_consistency function to validate that sequencer_info.last_order matches the expected order after replay
  • Positioned the consistency check after trim/refresh operations to catch any synchronization issues

output_store: &MoveOSStore,
expected_order: u64,
) -> Result<()> {
let output_rooch_store = self.load_output_rooch_store(output_store)?;

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

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

The verify_startup_sequencer_consistency function loads output_rooch_store again, but this is already loaded in trim_output_store at line 480. Consider passing output_rooch_store as a parameter to avoid redundant database initialization, which can be expensive.

Copilot uses AI. Check for mistakes.
sequencer_info.last_order
));
}

Copilot AI Jan 26, 2026

Copy link

Choose a reason for hiding this comment

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

The verification function only checks that sequencer_info.last_order matches expected_order, but doesn't verify consistency between startup_info and sequencer_info state roots or transaction accumulator info. Consider adding a check to ensure the state_root in startup_info corresponds to the transaction at sequencer_info.last_order, to provide more comprehensive consistency verification.

Suggested change
// Verify that the startup state root is consistent with the sequencer progress.
// For genesis (order 0), the startup state root must be the canonical genesis state root.
if sequencer_info.last_order == 0 {
if startup_info.state_root != GENESIS_STATE_ROOT {
return Err(anyhow::anyhow!(
"Startup info inconsistency: expected genesis state_root for order 0, got {:x}",
startup_info.state_root
));
}
} else {
// For non-genesis orders, the startup state root must not be the genesis state root.
if startup_info.state_root == GENESIS_STATE_ROOT {
return Err(anyhow::anyhow!(
"Startup info inconsistency: non-zero order {} has genesis state_root {:x}",
sequencer_info.last_order,
startup_info.state_root
));
}
}

Copilot uses AI. Check for mistakes.
@github-actions

Copy link
Copy Markdown

Docker images for this PR are available:

  • ghcr.io/rooch-network/rooch:pr-3941
  • ghcr.io/rooch-network/rooch:pr-3941-90c4d25

Pull commands:

  • docker pull ghcr.io/rooch-network/rooch:pr-3941
  • docker pull ghcr.io/rooch-network/rooch:pr-3941-90c4d25

@jolestar jolestar merged commit 4ea9133 into main Jan 27, 2026
29 checks passed
@jolestar jolestar deleted the fix/replay-sequencer-consistency branch January 27, 2026 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants