Introduce rooch db gc command to clear state#3824
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 refactors the pruner store implementation to optimize database storage and improve the pruning system's reliability. The main purpose is to reduce storage overhead for H256 keys from 67 bytes to 32 bytes by introducing a StoreKeyH256 wrapper type that ensures raw binary serialization. Additionally, the PR enhances the pruning system by tracking transaction order explicitly and improving error handling throughout.
Key Changes
- Introduced
StoreKeyH256type for storage-optimized H256 serialization (32 bytes vs 67 bytes) - Changed
write_stale_indicesto accepttx_orderparameter instead of using timestamps internally - Modified
get_node_refcountto returnOption<u32>to distinguish between missing entries and zero-count entries
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| moveos/moveos-types/src/h256.rs | Added StoreKeyH256 wrapper type with raw 32-byte serialization for database keys and comprehensive tests |
| moveos/moveos-store/src/prune/mod.rs | Refactored pruner store to use StoreKeyH256, changed stale index tracking from timestamps to tx_order, and improved refcount API to return Option<u32> |
| moveos/moveos-store/src/tests/test_prune_store.rs | Replaced comprehensive pruner tests with focused serialization validation test for StoreKeyH256 |
| moveos/moveos-store/src/tests/test_incremental_sweep.rs | Updated refcount assertions and stale index writing to match new API semantics |
| moveos/moveos-store/src/lib.rs | Added tx_order parameter to handle_tx_output and improved error propagation for pruning operations |
| moveos/moveos-object-runtime/src/runtime_object.rs | Enhanced error messages with detailed context (object_id, state_root, field_key) to diagnose pruner issues |
| frameworks/moveos-stdlib/src/natives/moveos_stdlib/object/mod.rs | Made error logging unconditional (removed debug gate) and added more diagnostic details |
| crates/rooch-executor/src/actor/executor.rs | Threaded tx_order parameter through transaction execution pipeline |
| crates/rooch-executor/src/actor/messages.rs | Added tx_order field to ExecuteTransactionMessage |
| crates/rooch-executor/src/proxy/mod.rs | Updated execute_transaction signature to accept tx_order parameter |
| crates/rooch-pipeline-processor/src/actor/processor.rs | Passed transaction order from sequence info to executor |
| crates/rooch-integration-test-runner/src/lib.rs | Added next_tx_order tracking to test runner with genesis at order 0 |
| crates/rooch-genesis/src/lib.rs | Explicitly set genesis transaction order to 0 |
| crates/rooch/src/commands/da/commands/exec.rs | Passed tx_order to transaction execution |
| crates/rooch-pruner/src/incremental_sweep.rs | Updated to handle new Option<u32> refcount API and use tx_order-based cutoffs |
| crates/rooch-pruner/src/pruner.rs | Added bloom filter reset at BuildReach phase start and updated sweep calls to use tx_order |
| crates/rooch-pruner/src/sweep_expired.rs | Updated refcount check to handle Option<u32> return type |
| crates/rooch-pruner/src/tests/test_pruner.rs | Updated test assertions to expect Some(0) instead of raw 0 for refcounts |
Comments suppressed due to low confidence (1)
moveos/moveos-store/src/prune/mod.rs:184
- The
list_beforefunction continues iterating through all entries even after finding entries withorder_h256 >= cutoff. Since the stale_index_store keys are ordered lexicographically and tx_orders increase monotonically, once we encounter the first entry withorder_h256 >= cutoff, all subsequent entries will also be >= cutoff. The function should break early when this condition is met to avoid unnecessary iterations. Change line 177-183 to:if order_h256 < cutoff { ... } else { break; }or addelse { break; }after line 183.
if order_h256 < cutoff {
let node_h256: H256 = store_node_key.into();
out.push((order_h256, node_h256));
if out.len() >= limit {
break;
}
}
}
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 75 out of 76 changed files in this pull request and generated no new comments.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Summary
Summary about this PR