fix(chainspec): make --chain required on stage/db subcommands#231
fix(chainspec): make --chain required on stage/db subcommands#231
Conversation
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).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request removes Ethereum's supported chains list delegation from Berachain's chainspec parser and replaces it with an empty list, while making the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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:
- Berachain doesn't have built-in named chain specs to advertise (genesis allocation is too large to embed)
- Omitting
--chainwould incorrectly fall back to "mainnet" and fail with file-not-found errors
Changes:
- Removed the import of
SUPPORTED_CHAINSfromreth_ethereum_cli::chainspecand replaced it with an empty slice&[]to prevent advertising Ethereum chain names that cannot actually be resolved - Added a
default_value()method override returningNoneto make--chaina required argument onEnvironmentArgs-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.
calbera
left a comment
There was a problem hiding this comment.
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
|
@calbera I'd be cool with that too, but was cautious about embedding such a colossal genesis. I'll rework. bepolia too? |
|
@camembera yes worth doing bepolia too |
fridrik01
left a comment
There was a problem hiding this comment.
LGTM, fine with bundling beramainnet/bepolia genesis in a separate commit
|
lgtm lets merge this, just filed a ticket for the future work @camembera, we should try to get this in sooner than later |
Summary
Removes all supported built-in chains from bera-reth, and makes the
--chain <path>option work.Details
The
--chainparameter 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--chainbuiltins.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 nodedoes not use this path to evaluate--chainFix
Two changes to
BerachainChainSpecParser:Override
default_value()to returnNone— makes--chaina required argument on allEnvironmentArgs-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".Replace the borrowed
SUPPORTED_CHAINSfromreth_ethereum_cliwith&[]— stops advertisingmainnet,sepolia, etc. as valid--chainvalues when they cannot be resolved.The
nodesubcommand is unaffected — it usesNodeCommand's own chain argument wiring, notEnvironmentArgs.Testing
cargo checkcleancargo test -p bera-reth -- chainspec)--chainSummary by CodeRabbit
--chainCLI parameter is now required for subcommands instead of being optional with a default fallback.