Skip to content

refactor(chainspec): use stock alloy_genesis::Genesis in ChainSpec#358

Merged
samlaf merged 6 commits intoseismicfrom
refactor--use-stock-alloy-genesis-in-chainspec
Apr 7, 2026
Merged

refactor(chainspec): use stock alloy_genesis::Genesis in ChainSpec#358
samlaf merged 6 commits intoseismicfrom
refactor--use-stock-alloy-genesis-in-chainspec

Conversation

@samlaf
Copy link
Copy Markdown
Contributor

@samlaf samlaf commented Apr 2, 2026

Replace seismic_alloy_genesis::Genesis with upstream alloy_genesis::Genesis in ChainSpec.genesis. This reduces our fork diff in core upstream crates (chainspec, optimism, cli) by keeping the genesis type stock.

Why: seismic_alloy_genesis::Genesis uses FlaggedStorage for storage values (carrying an is_private flag), but our genesis JSON files don't use private storage — all storage values are plain hex strings, which alloy_genesis handles identically. Using the stock type removes seismic-specific imports from upstream crates that don't need them.

What changed:

  • ChainSpec.genesis and EthChainSpec::genesis() now return &alloy_genesis::Genesis
  • parse_genesis() in CLI now returns alloy_genesis::Genesis (zero diff from upstream)
  • DB layer still uses seismic_alloy_genesis::GenesisAccount for its codec
    (FlaggedStorage encoding). The conversion boundary is in init_genesis() where
    alloy_genesis::GenesisAccount is converted to seismic_alloy_genesis::GenesisAccount
    via the existing lossless From impl (marks all storage as public).
  • Same conversion added in stage/drop.rs for the stage reset path.
  • Account::from now has impls for both genesis account types.
  • Optimism chainspec updated to use alloy_genesis types directly.

Future compatibility: If private genesis storage is ever needed, only the DB boundary code (init.rs) and seismic chainspec construction would need to change. ChainSpec stays stock.

Diff Explained

Our diff wrt upstream (main branch) has increased overall, but the conceptual diff has been reduced and is better organized.

Conceptual wins:

  • ChainSpec.genesis is now stock — this is the most important one. It's the type that flows through the entire codebase. Every upstream crate that touches chain.genesis() now sees
    a stock type.
  • cli/cli/src/chainspec.rs — zero diff, fully stock
  • optimism/chainspec/ — closer to stock, fewer seismic concepts bleeding in

Conceptual losses:

  • init.rs now has an explicit conversion boundary (alloy_genesis → seismic_alloy_genesis) that didn't exist before. But this is the right place for it — it's the DB boundary where
    B256 becomes FlaggedStorage. Previously the conversion was hidden in the genesis deserialization (JSON → seismic type), scattered across every callsite that parsed a genesis file.
  • drop.rs has the same conversion — annoying but same pattern, same boundary
  • account.rs has two From impls — duplication, but both are trivial 3-liners

The concentrated boundary: All the seismic-specific complexity now lives in two spots:

  1. The DB boundary (init.rs, drop.rs) — "stock genesis goes in, FlaggedStorage comes out for DB"
  2. SeismicHardforks impl in chainspec/spec.rs — forced by orphan rule

@samlaf samlaf requested a review from cdrappi as a code owner April 2, 2026 20:56
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 2, 2026

Adds conversions from standard alloy-genesis to seismic-alloy-genesis across multiple crates to reduce dependency usage.

Phase 1

  • crates/cli/commands/src/stage/drop.rs:117, 163.into() calls attempt to convert alloy_genesis::GenesisAccount to seismic_alloy_genesis::GenesisAccount, but no From trait implementation exists. This will fail to compile.
  • crates/storage/db-common/src/init.rs:141 — Same issue: account.clone().into() where account is &alloy_genesis::GenesisAccount but target type is seismic_alloy_genesis::GenesisAccount. Missing From implementation.

The fundamental issue is that seismic_alloy_genesis::GenesisAccount has additional fields (like is_private for flagged storage) that alloy_genesis::GenesisAccount lacks. The conversion needs to default these seismic-specific fields appropriately (genesis storage should be public).

Phase 2

  • crates/primitives-traits/src/account.rs:208-216 — Added conversion from SeismicGenesisAccount to Account but the reverse conversion (standard to seismic genesis account) is missing, which is what the .into() calls expect.

The PR needs a From<alloy_genesis::GenesisAccount> for seismic_alloy_genesis::GenesisAccount implementation that defaults is_private: false for all storage entries, similar to how the comment in init.rs:139 explains the conversion should be "lossless: all genesis storage is marked as public."

Copy link
Copy Markdown
Contributor

@ameya-deshmukh ameya-deshmukh left a comment

Choose a reason for hiding this comment

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

LGTM. The Claude PR review comments are a bit of a false negative since everything it mentions to be missing already exists in external crates like seismic-alloy. Fixing this in the review prompt (.claude/prompts/claude-pr-review.md) in another PR.

@samlaf samlaf merged commit dc70304 into seismic Apr 7, 2026
7 checks passed
@samlaf samlaf deleted the refactor--use-stock-alloy-genesis-in-chainspec branch April 7, 2026 15:52
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