Skip to content

Reth celo state import storage layouts v1+v2#437

Open
piersy wants to merge 17 commits intocelo-rebase-17from
piersy/reth-import-rebase-17
Open

Reth celo state import storage layouts v1+v2#437
piersy wants to merge 17 commits intocelo-rebase-17from
piersy/reth-import-rebase-17

Conversation

@piersy
Copy link
Copy Markdown

@piersy piersy commented Apr 23, 2026

Provides the tooling to import a state dump from celo into reth, with either the v1 or v2 storage layout.

Includes the changes in #435

Relies on a fork of reth with this additional commit on top of the v1.11 branch

The rust-deny failures match those coming from the base branch, so are not related to these changes.

palango and others added 17 commits April 21, 2026 16:43
Add a script to append L2 allocs (OP Stack predeploys injected at
migration time) to the Celo L1 state dump for use with reth's
init-state --without-ovm command. Also add migration documentation
describing the full import workflow.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The L1 state dump omits the address field for the zero address,
replacing it with the keccak256 hash as a key field. Add a script
to fix this in place and document it as a required step.

Also clarify that --update-state-root is required (not optional)
and resolve open questions about decimal balances and nonce formats.
Remove --update-state-root flag from append_l2_allocs.py since the
state root update is required for reth import. Add before/after
output to fix_dump_zero_address.sh. Document ulimit requirement for
dummy chain creation.
sed -i has incompatible syntax between macOS and Linux, and GNU sed
fails with "regex input buffer length larger than INT_MAX" on the
50GB dump file. Switch to perl -i which works on both platforms.
…aration

The append_l2_allocs.py script was naively appending L2 allocs to the L1
dump, causing a state root mismatch. Rewrite it to apply the same merge
rules as the Go migration (applyAllocsToState + setupUnreleasedTreasury):
allowlist-based account merging, treasury balance computation, and the
zero address fix (absorbing fix_dump_zero_address.sh).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Log each alloc merge decision (case 2/3/5) and treasury handling so
the output can be reviewed for correctness.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
With --storage.v2, genesis init creates changeset segments at block 0
(block_end=0), so next_block_number() returns 1. When importing at a
non-zero migration block, this causes "trying to append data to
StorageChangeSets as block #31056500 but expected block #1". Fix by
advancing the changeset segments through the dummy blocks using
increment_block, which properly creates segment files as needed.
The fix prevents the block being incremented for each inserted batch of
changesets. Insetad the block is now incremented when the init-state
requests a new block.
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 160824069d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread scripts/prepare_celo_import.sh Outdated
@piersy piersy requested a review from palango April 23, 2026 11:05
@piersy piersy marked this pull request as draft April 23, 2026 11:24
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 11.53846% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.0%. Comparing base (ea9dcf5) to head (91c0032).

Files with missing lines Patch % Lines
rust/op-reth/crates/cli/src/commands/init_state.rs 0.0% 23 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           celo-rebase-17    #437     +/-   ##
================================================
- Coverage            76.2%   76.0%   -0.2%     
================================================
  Files                 591     592      +1     
  Lines               74215   75003    +788     
================================================
+ Hits                56564   57037    +473     
- Misses              17507   17822    +315     
  Partials              144     144             
Flag Coverage Δ
cannon-go-tests-64 65.6% <ø> (-0.8%) ⬇️
unit 76.7% <11.5%> (-0.1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
rust/op-reth/crates/primitives/src/celo.rs 100.0% <100.0%> (ø)
rust/op-reth/crates/cli/src/commands/init_state.rs 0.0% <0.0%> (ø)

... and 53 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@piersy piersy marked this pull request as ready for review April 23, 2026 11:59
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.

3 participants