chore(el): derive reth chainspecs from base-alloy-chains vs. duplicating configs#1592
chore(el): derive reth chainspecs from base-alloy-chains vs. duplicating configs#1592danyalprout wants to merge 5 commits intomainfrom
Conversation
🟡 Heimdall Review Status
|
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
| } | ||
|
|
||
| /// Looks up a chain config by CLI name. | ||
| pub fn by_name(name: &str) -> Option<&'static Self> { |
There was a problem hiding this comment.
by_name does a linear scan with contains on each config's cli_names slice. With only 4 configs this is fine, but the &str parameter requires exact equality — consider documenting that this is case-sensitive. No functional issue, just noting for API clarity.
| "base-devnet-0-sepolia-dev-0" => Some(BASE_DEVNET_0_SEPOLIA_DEV_0.clone()), | ||
| _ => None, | ||
| } | ||
| BaseChainConfig::by_name(s).map(|cfg| Arc::new(Self::from(cfg))) |
There was a problem hiding this comment.
parse_chain now constructs a fresh OpChainSpec (including deserializing the embedded genesis JSON) on every call. The old implementation returned Arc::clone() of LazyLock statics, which was essentially free after first access.
This is called from CLI parsing so it's unlikely to be a hot path, but if anything else calls parse_chain repeatedly (e.g., in tests or validation loops), the repeated deserialization is wasteful. Consider caching the result per chain, or documenting that callers should cache the Arc themselves.
|
|
||
| bootnodes: &[], | ||
|
|
||
| prune_delete_limit: 0, |
There was a problem hiding this comment.
Behavioral change for dev chain base fee params. The deleted dev.rs used BaseFeeParamsKind::Constant(BaseFeeParams::ethereum()) which is { denominator: 8, elasticity: 2 }. The new From<&BaseChainConfig> impl derives params from these config values, producing BaseFeeParamsKind::Variable([(London, {50, 6}), (Canyon, {250, 6})]) because eip1559_denominator (50) != eip1559_denominator_canyon (250).
This changes the dev chain from Ethereum-style constant base fee params to OP-style variable params. If this is intentional (aligning devnet with production behavior), it's fine — but if the old Ethereum-style params were needed for dev/test compatibility, this is a regression.
There was a problem hiding this comment.
This is a correct change
Add base-alloy-chains to udeps ignore list (used in doc-test but undetectable by cargo-udeps). Improve genesis deserialization panic message to include chain_id.
Consolidate chain configuration so adding a new chain only requires touching config.rs. Add cli_names field to BaseChainConfig, derive by_name/by_chain_id lookups from all(), simplify parse_chain(), and remove the 4 LazyLock statics from chainspec.
Add base-alloy-chains to udeps ignore list (used in doc-test but undetectable by cargo-udeps). Improve genesis deserialization panic message to include chain_id.
fece2c1 to
354facd
Compare
|
|
||
| /// All supported chain names for the CLI. | ||
| pub const SUPPORTED_CHAINS: &[&str] = | ||
| &["base", "base_sepolia", "base-sepolia", "base-devnet-0-sepolia-dev-0", "dev"]; |
There was a problem hiding this comment.
SUPPORTED_CHAINS duplicates data already embedded in each config's cli_names. The test at the bottom catches drift, but this const could be derived at compile-time or as a function to eliminate the maintenance hazard entirely:
pub fn supported_chains() -> impl Iterator<Item = &'static str> {
BaseChainConfig::all().into_iter().flat_map(|cfg| cfg.cli_names.iter().copied())
}This would also remove the need for the sync test. If the const form is needed for CLI help strings (e.g., clap's possible_values), consider generating it from cli_names via a const fn or LazyLock instead of manually maintaining the list.
354facd to
57e8e61
Compare
Review SummaryThis PR consolidates four per-chain What looks good
Findings (inline comments posted)All findings were posted as inline comments on this and prior review passes:
No blocking issues found. The main item requiring explicit confirmation is the dev chain base fee parameter change (#1 above). |
| /// All supported chain names for the CLI. | ||
| pub const SUPPORTED_CHAINS: &[&str] = | ||
| &["base", "base_sepolia", "base-sepolia", "base-devnet-0-sepolia-dev-0", "dev"]; |
There was a problem hiding this comment.
I think these could be placed on BaseChainConfig i.e. BaseChainConfig::ALL
| hardforks, | ||
| base_fee_params, | ||
| prune_delete_limit: cfg.prune_delete_limit, | ||
| ..Default::default() |
There was a problem hiding this comment.
Are we sure about this ..Default::default()? I think we ought to list everything out here so it's very explicit about what's made default.
|
|
||
| mod spec; | ||
| pub use spec::{OpChainSpec, OpGenesisInfo, SUPPORTED_CHAINS}; | ||
| pub use spec::{OpChainSpec, OpGenesisInfo}; |
There was a problem hiding this comment.
Would be nice to rename this to BaseChainSpec and BaseGenesisInfo while we're in here. If there are too many call sites, fine to leave it for later
| // Re-export base-alloy-upgrades types. | ||
| pub use base_alloy_chains::BaseChainUpgrades; | ||
| pub use chain::{BASE_MAINNET_HARDFORKS, BaseChainUpgradesExt}; |
Description
Part one of deduplicating chain configurations and settings. Creates
base-alloy-chainswhich has the chain configurations defined in Rust.Upstream consumers will map this generic type into CL/EL specific types via a
TryFrom/Fromimpl.