Repository navigation
feat(beacon): select the preset at runtime from PRESET_BASE - #851
Open
MegaRedHand wants to merge 2 commits into
Open
MegaRedHand wants to merge 2 commits into
MegaRedHand wants to merge 2 commits into
Conversation
One binary now runs mainnet and minimal-preset networks alike, the way
Lighthouse and Teku do, so ethereum-package can run ethlambda on a minimal
devnet from the same image.
- `ethlambda beacon` selects its network's PRESET_BASE while resolving
--network, before anything is decoded; the validator client and
voluntary-exit adopt the preset their beacon node reports. The choice is
process-wide and frozen by its first read.
- Preset values both presets share stay constants, compile-asserted equal;
the 29 they disagree on are accessor functions (`preset::slots_per_epoch()`).
- Containers bounded by a differing value take a `Length` marker:
`preset_sized::{PresetList, PresetVector, PresetBitlist, PresetBitvector}`
and ssz-tree's new `ListOf`/`VectorOf` (`List`/`Vector` are aliases over
`Const<N>`).
- /eth/v1/config/spec reports the active preset's values.
- The spec-test binary selects its preset from BEACON_SPEC_PRESET, so both
suites run off one build; `preset-minimal` now only sets the default of a
process that never selects one (unit tests).
…-catmull # Conflicts: # crates/blockchain/state_transition/src/beacon/helpers/gloas.rs # crates/common/ssz-tree/src/lib.rs # crates/storage/src/beacon_state_delta.rs
Collaborator
Author
|
/review |
AI security review: 0 finding(s) to checkReviewed by Opus, GPT, Kimi, GLM, DeepSeek. A judge model checked every one of the findings against the code. No findings to check. Pre-existing (real, but already on the base branch): 2
Housekeeping (not security): 10Stale docs, missing tests, leftovers and inconsistencies, from a separate cheap model. Not checked by the judge.
Leads from a script (not checked): 1Found without a model, from the lines this PR adds. Some can be wrong, e.g. a path created at runtime or a name used through reflection.
Cost of this review: ~$11.78 of a $30 budget (estimated from token counts). |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description / Motivation
ethlambda could only run the mainnet preset: every SSZ container bound was a
{ preset::X }const generic, and thepreset-minimalfeature that switched them never reached the binary. ethereum-package therefore refused ethlambda onpreset: minimaldevnets, and the only alternatives were a second-minimalimage (Prysm/Nimbus/Grandine style) or shipping two binaries.This makes the preset a runtime choice, the way Lighthouse and Teku pick theirs: one binary and one image run mainnet and a minimal-preset network alike.
ethlambda beaconselects the preset its network'sconfig.yamlnames inPRESET_BASE, while resolving--networkand before anything is decoded against it.ethlambda validatorandvoluntary-exitadopt the preset their beacon node reports in/eth/v1/config/spec.What Changed
beacon::preset).Preset::selectstores it in a process-wide atomic. The first read freezes it, so a later select of the other preset fails instead of mixing container shapes, and a startup path that reads a preset value before selecting one fails loudly.preset::MAX_ATTESTATIONS, ...), each compile-asserted equal inmainnetandminimal. If a spec release ever moves one, the build breaks there.preset::slots_per_epoch()isSLOTS_PER_EPOCH.preset::mainnet::*andpreset::minimal::*keep every literal.Lengthmarker type (preset::SyncCommitteeSize, ...) instead of a const generic:beacon::preset_sized::{PresetList, PresetVector, PresetBitlist, PresetBitvector}: libssz's four collections withNread at runtime. Same encoding and merkleization, and inline bitfield storage like libssz's.ethlambda_ssz_tree::{ListOf, VectorOf}: ssz-tree's persistent trees take aLength.List<T, N>andVector<T, N>stay as aliases overConst<N>, so existing users are untouched.max_aggregates_per_slot(),sync_subcommittee_size(), ...). This is a mechanical rename across about 100 files.select_preset(inbin/ethlambda/src/network) replacescheck_preset, andadopt_presetis added to the validator crate. Both the beacon node and the validator client log the preset they run./eth/v1/config/specreports the active preset's values.BEACON_SPEC_PRESET, somake test-beacon-minimalruns off the same build as mainnet. CI's minimal job and the cache key are updated to match.preset-minimalfeature now only setsPreset::DEFAULT, the preset of a process that never selects one (unit tests). The binary never enables it.CLAUDE.md,docs/beacon_stf.md,docs/cli.md,docs/data_storage.mdanddocs/rpc.mdno longer describe the preset as compile-time.Correctness / Behavior Guarantees
PRESET_BASE: mainnet, and the mainnet spec suite passes as before.PRESET_BASEis a hard startup error. That includesgnosis, whose values are not carried.Tests Added / Run
crates/common/types/tests/runtime_preset.rs, an integration test binary that selects minimal at runtime and checks container shapes. Also addedpreset_sizedunit tests comparing each type against its libssz counterpart, plus tests of the select/freeze rule.make fmtandmake lint: clean.make test-beacon-mainnet: 7,493 fixture cases passed, 0 failed.make test-beacon-minimal: 49,577 fixture cases passed, 0 failed, the preset selected at runtime from the same build. That includes 43,297ssz_staticcases, which check every container's encoding and root under minimal. Re-run after merging main.make test: not run locally; CI runs it. The new tests and the machine-edited test files have not been executed yet.preset: minimal. Four pairs: lighthouse BN + lighthouse VC, ethlambda BN + ethlambda VC, lighthouse BN + ethlambda VC, ethlambda BN + lighthouse VC. Package:lambdaclass/ethereum-packagebranchethlambda-minimal-preset./eth/v1/config/specmatches lighthouse's on all 190 shared keys.Related Issues / PRs
lambdaclass/ethereum-packagebranchethlambda-minimal-preset(no PR yet). It drops the mainnet-only guard for ethlambda and adds it to the minimal default images. It is based onadd-ethlambda, which passes--bootnodesas a list and so also needs feat(cli): take beacon --bootnodes as a list of ENRs and multiaddrs #825.✅ Verification Checklist
make fmt— cleanmake lint(clippy with-D warnings) — cleanmake test(test-consensusplustest-node, atrelease-fast) — all passing