feat: integrate legacy migrate tool into bin/tools crate#196
Merged
louisliu2048 merged 6 commits intomainfrom Mar 16, 2026
Merged
feat: integrate legacy migrate tool into bin/tools crate#196louisliu2048 merged 6 commits intomainfrom
louisliu2048 merged 6 commits intomainfrom
Conversation
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
commented
Mar 13, 2026
- 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)
- 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>
JimmyShi22
reviewed
Mar 16, 2026
…_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
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
JimmyShi22
approved these changes
Mar 16, 2026
louisliu2048
approved these changes
Mar 16, 2026
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.
Description
Ports the legacy data migration tool from PR #137 (which targeted the
devbranch) into themainbranch by integrating it as a newlegacy-migratesubcommand in the existingbin/toolscrate.Key differences from the original PR #137:
okx/rethgit deps at9359e21f...xlayer-chainspeccrate instead of duplicating chainspec/parser/genesis modulesbin/toolsas a subcommand rather than a standalonebin/legacy-migratecrateStorageSettingsto use the upstreamStorageSettings::v2()API (see review note below)Usage:
xlayer-reth-tools legacy-migrate --chain xlayer-mainnet --datadir /path/to/dataType of Change
Code Guidelines
StorageSettings::v2()vs granular settings: The original PR feat: legacy data migration tool #137 used fine-grained builder methods (with_receipts_in_static_files(bool),with_transaction_senders_in_static_files(bool), etc.) that don't exist in upstream reth v1.11.0. This PR usesStorageSettings::v2()which unconditionally enables all v2 features. If receipts can't be migrated (due to pruning) or senders have no data, the storage settings will still report v2-enabled for those segments. Please verify this is acceptable for your use case.num-traitsdependency: Added tobin/tools/Cargo.tomlbutu64::is_multiple_of()may already be stable in Rust 1.92. This dep might be unnecessary — please verify.reth-cli-commandswithoutedgefeature: The original PR usedfeatures = ["edge"]onreth-cli-commands. This was dropped since we explicitly useStorageSettings::v2(). Verify no other behavior depends onedge.No unit tests for the migration logic (same as original PR feat: legacy data migration tool #137).
Checklist
docs/folderTesting
cargo check -p xlayer-reth-toolspasses locally with Rust 1.92Additional Notes
reth-static-file-typesas a new workspace dependency in the rootCargo.tomlreth-db,reth-node-builder,reth-primitives-traits,reth-static-file-typestobin/tools/Cargo.toml; enablesrocksdbfeature onreth-provider