feat(statedb): add active-state rebase pipeline#3971
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an “active-state rebase” pipeline for Rooch statedb operations, adding operator-facing CLI commands to export a recursive logical object tree and rebuild a slimmed database, along with several mainnet ops/design rollout documents to guide the reset + rebase sequence.
Changes:
- Added
statedb rebase-exportandstatedb rebase-buildcommands (with a roundtrip unit test) to export recursive object records and rebuild state + indexer. - Added a consolidated set of dev-guide documents covering snapshot limitations, state slimming scope, rebase redesign, and GCP cost reduction.
- Wired the new rebase commands into the
statedbcommand module.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/dev-guide/mainnet_state_slimming_master_plan_20260316.md | Consolidated execution plan tying together snapshot, slimming, rebase, and cost goals. |
| docs/dev-guide/mainnet_snapshot_resume_plan.md | Snapshot resume runbook (draft) for operational continuity. |
| docs/dev-guide/mainnet_snapshot_refactor_handoff_20260312.md | Handoff note describing snapshot bottlenecks and refactor starting points. |
| docs/dev-guide/mainnet_snapshot_ops_log_20260227.md | Ops log documenting the snapshot migration steps and disk decommission. |
| docs/dev-guide/mainnet_header_only_state_slimming_plan_20260312.md | Defines the header-only “slim node” scope and what state domains can be dropped. |
| docs/dev-guide/mainnet_active_state_rebase_redesign_20260313.md | Redesign notes on why export/import must be recursive + metadata/boot constraints. |
| docs/dev-guide/mainnet_active_state_rebase_plan_20260313.md | Original rebase plan describing the high-level approach and tradeoffs. |
| docs/dev-guide/gcp_cost_reduction_plan_20260316.md | Cost analysis and execution plan targeting major storage-driven reductions. |
| crates/rooch/src/commands/statedb/mod.rs | Registers new RebaseExport/RebaseBuild subcommands for the CLI. |
| crates/rooch/src/commands/statedb/commands/rebase.rs | Implements recursive export, rebuild flow, checkpointing, and indexer rebuild + test. |
| crates/rooch/src/commands/statedb/commands/mod.rs | Exposes the new rebase command module. |
You can also share your feedback on Copilot code review. Take the survey.
| let end = H256::from_slice(&[0xFFu8; 32]); | ||
|
|
||
| node_store.delete_range_nodes(start, end, true)?; | ||
| node_store.delete_nodes_with_flush(vec![end], true)?; |
Comment on lines
+335
to
+341
| let rebuilt_indexer_tx_order = std::cmp::max(1, manifest.cutover_tx_order); | ||
| let rebuilt_indexer_objects = rebuild_indexer_from_state( | ||
| &rooch_db.moveos_store, | ||
| &rooch_db.indexer_store, | ||
| ObjectMeta::root_metadata(rebuilt_root, rebuilt_global_size), | ||
| rebuilt_indexer_tx_order, | ||
| self.indexer_batch_size, |
Comment on lines
+441
to
+491
| let object_id = object_state.metadata.id.clone(); | ||
| let mut cursor = None; | ||
| let mut fields = Vec::new(); | ||
|
|
||
| loop { | ||
| let page = resolver.list_fields(&object_id, cursor, page_size)?; | ||
| if page.is_empty() { | ||
| break; | ||
| } | ||
|
|
||
| for (field_key, mut child_state) in page.iter().cloned() { | ||
| if child_state.metadata.has_fields() { | ||
| let child_has_fields = export_object_record_recursive( | ||
| resolver, | ||
| &child_state, | ||
| page_size, | ||
| writer, | ||
| stats, | ||
| )?; | ||
| if !child_has_fields { | ||
| child_state.metadata.size = 0; | ||
| child_state.metadata.state_root = None; | ||
| } | ||
| } | ||
|
|
||
| fields.push(RebaseFieldRecord { | ||
| field_key: field_key.to_string(), | ||
| object_state: child_state.to_string(), | ||
| }); | ||
| } | ||
|
|
||
| cursor = page.last().map(|(field_key, _)| *field_key); | ||
| if page.len() < page_size { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if fields.is_empty() { | ||
| return Ok(false); | ||
| } | ||
|
|
||
| let record = RebaseObjectRecord { | ||
| object_id: object_id.to_string(), | ||
| fields, | ||
| }; | ||
| serde_json::to_writer(&mut *writer, &record)?; | ||
| writer.write_all(b"\n")?; | ||
|
|
||
| stats.object_records += 1; | ||
| stats.field_entries += record.fields.len() as u64; | ||
| Ok(true) |
Comment on lines
+364
to
+369
| (Some(store_dir), None, chain_id) => { | ||
| let (root, moveos_store, rooch_store) = | ||
| open_stores_from_store_dir(&store_dir, readonly)?; | ||
| let chain_id = chain_id.unwrap_or_else(|| BuiltinChainID::Local.into()); | ||
| Ok((root, moveos_store, rooch_store, chain_id)) | ||
| } |
Comment on lines
+232
to
+241
| let manifest: RebaseManifest = serde_json::from_reader(File::open(&manifest_path)?)?; | ||
| ensure!( | ||
| manifest.artifact_version == REBASE_ARTIFACT_VERSION, | ||
| "unsupported artifact version: {}", | ||
| manifest.artifact_version | ||
| ); | ||
|
|
||
| let (output_store_dir, output_indexer_dir) = | ||
| derive_output_paths(&self.output_data_dir, &self.chain_id); | ||
| ensure!( |
Comment on lines
+301
to
+302
| 4. boot slim read node | ||
| 5. validate account / asset / module / object reads |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
statedb rebase-exportandstatedb rebase-buildcommands for active-state rebaseTesting