Skip to content

Introduce rooch db gc command to clear state#3824

Merged
jolestar merged 22 commits into
mainfrom
refactor_pruner_store
Nov 30, 2025
Merged

Introduce rooch db gc command to clear state#3824
jolestar merged 22 commits into
mainfrom
refactor_pruner_store

Conversation

@jolestar

Copy link
Copy Markdown
Contributor

Summary

Summary about this PR

  • Closes #issue

@vercel

vercel Bot commented Nov 25, 2025

Copy link
Copy Markdown

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

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Nov 29, 2025 3:51pm
test-portal Ready Ready Preview Comment Nov 29, 2025 3:51pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Nov 29, 2025 3:51pm

@github-actions

github-actions Bot commented Nov 25, 2025

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 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 StoreKeyH256 type for storage-optimized H256 serialization (32 bytes vs 67 bytes)
  • Changed write_stale_indices to accept tx_order parameter instead of using timestamps internally
  • Modified get_node_refcount to return Option<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_before function continues iterating through all entries even after finding entries with order_h256 >= cutoff. Since the stale_index_store keys are ordered lexicographically and tx_orders increase monotonically, once we encounter the first entry with order_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 add else { 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.

Comment thread moveos/moveos-types/src/h256.rs Outdated
Comment thread frameworks/moveos-stdlib/src/natives/moveos_stdlib/object/mod.rs Outdated
Comment thread moveos/moveos-store/src/tests/test_prune_store.rs Outdated
Comment thread moveos/moveos-types/src/h256.rs Outdated
Comment thread crates/rooch-pruner/src/tests/test_pruner.rs Outdated

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

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.

@jolestar jolestar merged commit 18f69da into main Nov 30, 2025
19 checks passed
@jolestar jolestar deleted the refactor_pruner_store branch November 30, 2025 00:30
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