Skip to content

fix(chainspec): make --chain required on stage/db subcommands#231

Merged
fridrik01 merged 3 commits intomainfrom
fix/chain-spec-parser-default
Apr 9, 2026
Merged

fix(chainspec): make --chain required on stage/db subcommands#231
fridrik01 merged 3 commits intomainfrom
fix/chain-spec-parser-default

Conversation

@camembera
Copy link
Copy Markdown
Collaborator

@camembera camembera commented Apr 1, 2026

Summary

Removes all supported built-in chains from bera-reth, and makes the --chain <path> option work.

Details

The --chain parameter advertises ethereum chains, but not Bera's. This is not useful. It's not possible to bake in bera-mainnet because the spec is 48mb. And only bepolia would be silly. So that's the reason why there should be no --chain builtins.

The bug regarding --chain <path> manifested in rewinds. For various reasons, I have to sometimes rewind state (see paradigmxyz/reth#23234).

So to "unwind", I have to provide a --chain parameter. Because of a flaw in this function, passing "--chain /path/to/genesis.json" does not work. The workaround to accomplish an unwind was: make a hardlink or symlink ./mainnet (in the directory where bera-reth is being invoked) pointing to genesis.json

n.b. reth node does not use this path to evaluate --chain

Fix

Two changes to BerachainChainSpecParser:

  1. Override default_value() to return None — makes --chain a required argument on all EnvironmentArgs-based subcommands (stage unwind, stage run, db, prune, …). Omitting it now fails with a clear "required argument missing" rather than a file-not-found on "mainnet".

  2. Replace the borrowed SUPPORTED_CHAINS from reth_ethereum_cli with &[] — stops advertising mainnet, sepolia, etc. as valid --chain values when they cannot be resolved.

The node subcommand is unaffected — it uses NodeCommand's own chain argument wiring, not EnvironmentArgs.

Testing

  • cargo check clean
  • 48 existing chainspec unit tests pass (cargo test -p bera-reth -- chainspec)
  • No existing tests invoke stage/db subcommands without --chain

Summary by CodeRabbit

  • Bug Fixes
    • The --chain CLI parameter is now required for subcommands instead of being optional with a default fallback.

BerachainChainSpecParser had no default_value() override, so Clap
defaulted --chain to "mainnet". parse() calls parse_genesis(s)
unconditionally with no named-chain match arms, so parse_genesis("mainnet")
tried to open a file named "mainnet", failing with ENOENT.

Override default_value() to return None (makes --chain required) and
drop the borrowed SUPPORTED_CHAINS from reth_ethereum_cli (stops
advertising Ethereum chain names as valid values).
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 1, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b192ce9c-bf1a-49ec-aaa7-658bbdeaf8b5

📥 Commits

Reviewing files that changed from the base of the PR and between 23b13a2 and e69caaf.

📒 Files selected for processing (1)
  • src/chainspec/mod.rs

📝 Walkthrough

Walkthrough

The pull request removes Ethereum's supported chains list delegation from Berachain's chainspec parser and replaces it with an empty list, while making the --chain CLI argument required by returning None from the default_value() method instead of allowing implicit defaults.

Changes

Cohort / File(s) Summary
Berachain Chainspec Configuration
src/chainspec/mod.rs
Removed Ethereum SUPPORTED_CHAINS import. Updated BerachainChainSpecParser to use empty SUPPORTED_CHAINS list and added default_value() method returning None, making --chain a required parameter.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 No more borrowing chains from the east,
Berachain stands independent, at least!
The --chain flag now demands to be seen,
No defaults allowed—requirements are keen.
A simpler directive, explicit and clean! 🌿

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: making --chain required on stage/db subcommands by removing default values and unsupported chains.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/chain-spec-parser-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@camembera camembera marked this pull request as ready for review April 1, 2026 21:38
Copilot AI review requested due to automatic review settings April 1, 2026 21:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR makes the --chain parameter required on Berachain's EnvironmentArgs-based subcommands (like stage, db, prune) by fixing two bugs in the BerachainChainSpecParser implementation. The changes address issues where:

  1. Berachain doesn't have built-in named chain specs to advertise (genesis allocation is too large to embed)
  2. Omitting --chain would incorrectly fall back to "mainnet" and fail with file-not-found errors

Changes:

  • Removed the import of SUPPORTED_CHAINS from reth_ethereum_cli::chainspec and replaced it with an empty slice &[] to prevent advertising Ethereum chain names that cannot actually be resolved
  • Added a default_value() method override returning None to make --chain a required argument on EnvironmentArgs-based subcommands, eliminating the previous broken fallback behavior
  • Added comprehensive comments explaining the changes and their rationale

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@calbera calbera left a comment

Choose a reason for hiding this comment

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

I'm okay with this, but would ideally prefer the default be bera-mainnet, as was done in bera-geth. This would require embedding the genesis into the code/binary however. And obv update tooling docs accordingly

@camembera
Copy link
Copy Markdown
Collaborator Author

@calbera I'd be cool with that too, but was cautious about embedding such a colossal genesis. I'll rework. bepolia too?

@calbera
Copy link
Copy Markdown
Contributor

calbera commented Apr 7, 2026

@camembera yes worth doing bepolia too

Copy link
Copy Markdown
Contributor

@fridrik01 fridrik01 left a comment

Choose a reason for hiding this comment

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

LGTM, fine with bundling beramainnet/bepolia genesis in a separate commit

@calbera
Copy link
Copy Markdown
Contributor

calbera commented Apr 9, 2026

lgtm lets merge this, just filed a ticket for the future work @camembera, we should try to get this in sooner than later

@fridrik01 fridrik01 enabled auto-merge (squash) April 9, 2026 18:20
@fridrik01 fridrik01 merged commit f7916df into main Apr 9, 2026
10 checks passed
@fridrik01 fridrik01 deleted the fix/chain-spec-parser-default branch April 9, 2026 18:34
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.

4 participants