Fix: feat(snapshot): honor --tx_order and fill SnapshotMeta#3926
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes issue #3904 by implementing proper support for the --tx_order flag in the snapshot CLI command. Previously, the flag was accepted but ignored, resulting in SnapshotMeta always having tx_order=0 and global_size=0.
Changes:
- Enhanced CLI flag documentation to clarify precedence:
--state-root>--tx_order>startup_info(latest) - Implemented tx_order resolution logic that looks up
StateChangeSetExtfrom the state store to extractstate_rootandglobal_size - Updated
SnapshotBuilder.build_snapshot()method signature to accepttx_orderandglobal_sizeparameters, which are now properly stored inSnapshotMeta
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/rooch/src/commands/db/commands/state_prune/snapshot.rs | Added tx_order resolution logic and enhanced flag documentation; implements precedence hierarchy for determining state_root, tx_order, and global_size |
| crates/rooch-pruner/src/state_prune/snapshot_builder.rs | Updated build_snapshot method signature to accept tx_order and global_size parameters; updated metadata initialization to use provided values instead of hardcoded 0 |
| crates/rooch-pruner/src/tests/scalable_dedup_test.rs | Updated test call to build_snapshot with new signature parameters (0, 0) |
|
@holonbot Please ensure make lint passed |
PR #3926 - Fix Lint Issues SummaryOverviewFixed code formatting issues in PR #3926 to ensure Issue IdentifiedThe CI check "Rust Lint" was failing due to incorrect code formatting in Changes MadeFile:
|
|
Holon completed successfully. Run: https://github.com/rooch-network/rooch/actions/runs/20876650415 |
Fixes #3904
Summary of Changes for Issue #3904
Overview
Implemented support for the
--tx_orderflag in the snapshot CLI command. Previously, the flag was accepted but ignored, andSnapshotMetaalways hadtx_order=0andglobal_size=0.Changes Made
1. CLI Command (
crates/rooch/src/commands/db/commands/state_prune/snapshot.rs)Enhanced flag documentation:
--tx_orderexplaining that it providesstate_rootandglobal_sizefrom the specified transaction--state-rootexplaining it takes precedence over--tx_order--tx-orderas an optionImplemented tx_order resolution logic:
StateChangeSetExtfrom the state store usingtx_orderstate_rootandglobal_sizefrom theStateChangeSet--state-root>--tx_order>startup_info(latest)--tx_orderis used, validates that the transaction existstx_orderandglobal_sizetoSnapshotBuilder2. Snapshot Builder (
crates/rooch-pruner/src/state_prune/snapshot_builder.rs)Updated method signature:
build_snapshot()to accepttx_order: u64andglobal_size: u64parameterstx_orderandglobal_sizeSnapshotMetacreation to use the provided values instead of hardcoded03. Test Fix (
crates/rooch-pruner/src/tests/scalable_dedup_test.rs)build_snapshot()to include the newtx_orderandglobal_sizeparametersBehavior
Before
rooch db state-prune snapshot --tx-order 1000 -o /tmp/snapshot # Result: tx_order=0, global_size=0, state_root from startup_infoAfter
rooch db state-prune snapshot --tx-order 1000 -o /tmp/snapshot # Result: tx_order=1000, global_size=<from tx 1000>, state_root=<from tx 1000>Flag Precedence
--state-root- Takes precedence, notx_orderorglobal_sizeavailable (set to 0)--tx-order- Looks up state_root and global_size from state changesetstartup_info(notx_orderorglobal_size)Acceptance Criteria Met
--tx_orderpath producesSnapshotMetawithtx_ordersetstate_rootmatches the chosentx_orderBuild Verification
cargo check -p roochcargo build --bin roochFiles Modified
crates/rooch/src/commands/db/commands/state_prune/snapshot.rs- CLI command implementationcrates/rooch-pruner/src/state_prune/snapshot_builder.rs- Snapshot builder implementationcrates/rooch-pruner/src/tests/scalable_dedup_test.rs- Test fix for new signature