Skip to content

feat: legacy data migration tool#137

Closed
Vui-Chee wants to merge 23 commits intodevfrom
vui-chee/legacy-data-migration
Closed

feat: legacy data migration tool#137
Vui-Chee wants to merge 23 commits intodevfrom
vui-chee/legacy-data-migration

Conversation

@Vui-Chee
Copy link
Contributor

@Vui-Chee Vui-Chee commented Feb 2, 2026

No description provided.

@Vui-Chee Vui-Chee changed the base branch from main to dev February 2, 2026 09:23
@Vui-Chee Vui-Chee requested a review from JimmyShi22 February 11, 2026 10:20
JimmyShi22

This comment was marked as outdated.

JimmyShi22

This comment was marked as outdated.

JimmyShi22

This comment was marked as outdated.

JimmyShi22

This comment was marked as outdated.

Copy link
Contributor

@JimmyShi22 JimmyShi22 left a comment

Choose a reason for hiding this comment

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

Code review of current HEAD.

Vui-Chee added a commit that referenced this pull request Mar 5, 2026
Port legacy data migration tool from PR #137 into existing bin/tools
as a new 'migrate' subcommand. Migrates data from MDBX to RocksDB +
static files for TransactionSenders, AccountChangeSets, Receipts,
TransactionHashNumbers, AccountsHistory, and StoragesHistory tables.

Key changes:
- Add migrate.rs: core migration logic for static files and RocksDB
- Add migrate_command.rs: CLI command with options (batch-size,
  skip-static-files, skip-rocksdb, keep-mdbx)
- Add progress.rs: progress logging utilities
- Update main.rs: add Migrate variant to Commands enum
- Update Cargo.toml: add reth-provider/rocksdb, reth-stages/rocksdb,
  reth-static-file-types, reth-storage-api dependencies
- Update .reth-dev.toml: add reth-stages and reth-static-file-types
  entries for local dev builds

Co-Authored-By: vuicheesiew@gmail.com <vuicheesiew@gmail.com>
Vui-Chee added a commit that referenced this pull request Mar 13, 2026
Port the legacy data migration tool from PR #137 into the existing
bin/tools crate as a new 'legacy-migrate' subcommand. Key changes:

- Use workspace reth deps (paradigmxyz/reth v1.11.0) instead of pinned
  okx/reth git deps
- Import chain spec from xlayer-chainspec crate instead of duplicating
- Add reth-static-file-types to workspace dependencies
- Adapt StorageSettings to use v2() API from upstream reth
- Add reth-db, reth-node-builder, reth-primitives-traits deps to tools
@Vui-Chee
Copy link
Contributor Author

Closing in favor of #196.

@Vui-Chee Vui-Chee closed this Mar 16, 2026
louisliu2048 pushed a commit that referenced this pull request Mar 16, 2026
* feat: integrate legacy migrate tool into bin/tools crate

Port the legacy data migration tool from PR #137 into the existing
bin/tools crate as a new 'legacy-migrate' subcommand. Key changes:

- Use workspace reth deps (paradigmxyz/reth v1.11.0) instead of pinned
  okx/reth git deps
- Import chain spec from xlayer-chainspec crate instead of duplicating
- Add reth-static-file-types to workspace dependencies
- Adapt StorageSettings to use v2() API from upstream reth
- Add reth-db, reth-node-builder, reth-primitives-traits deps to tools

* fix: add batch_size validation and remove unused num-traits dep

- Add clap value_parser range(1..) to prevent batch_size=0 panic
- Remove unnecessary num-traits dependency (u64::is_multiple_of is
  stable in Rust 1.92)

* chore: update Cargo.lock after removing num-traits

* fix: resolve legacy migrate tool PR review issues

- Check prune_modes.receipts.is_none() in addition to receipts_log_filter
  to prevent migrating incomplete receipt data when general pruning is active
- Remove is_some() guard on ensure_at_block in changeset arms to fill leading
  gap (genesis → first block with data), and add ensure_at_block(to_block)
  after each changeset loop to fill the trailing gap
- Gate StorageSettings::v2() write on both migrations completing; skip it
  with a warning when --skip-static-files or --skip-rocksdb is passed so
  the node keeps reading from MDBX until migration is fully finalized

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(tools): gate v2 storage settings and MDBX clearing on can_migrate_receipts

StorageSettings::v2() is all-or-nothing: it routes all static-file segment
queries (including Receipts) to static files. Writing it when receipts were
not migrated (due to pruning) would cause the node to look for receipt data
in static files that contain nothing, while the Receipts MDBX table (which
was not cleared) becomes unreachable via v1 routing.

Two related changes:
1. Add !can_migrate_receipts to the v2-write skip condition so we keep v1
   settings when receipts could not be migrated.
2. Guard MDBX static-file table clearing on can_migrate_receipts for the
   same reason: if v2 was not written, the node reads these tables via v1
   routing and they must remain intact.

Fixes: JimmyShi22 review comment on mod.rs:151

* fix(tools): add segment context to static file writer init errors

get_writer() and latest_writer() failures were propagated bare, making it
hard to know which segment caused the error. Wraps both call sites with
wrap_err_with so the error chain includes the segment name.

Addresses: JimmyShi22 nit on migrate.rs:70

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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