feat(cli): default --attestation-committee-count from validator-config.yaml#337
feat(cli): default --attestation-committee-count from validator-config.yaml#337MegaRedHand wants to merge 4 commits intomainfrom
Conversation
…yaml Make `--attestation-committee-count` optional and fall back to the `config.attestation_committee_count` field in `validator-config.yaml`, then to `1`. Lets multi-subnet networks (e.g. lean-quickstart's 2-subnet ansible devnet) drop the per-client flag and rely on the shared genesis bundle.
Verify the CLI/file/default precedence and that the new fields parse against snippets from both the ansible-devnet (with the field set) and the local-devnet (with the field absent).
🤖 Claude Code ReviewNow I have everything I need. Here is the review: PR #337 —
|
Greptile SummaryThis PR makes
Confidence Score: 4/5Safe to merge after addressing the missing lower-bound validation for the YAML-sourced committee count. One P1 finding: YAML path silently accepts
|
| Filename | Overview |
|---|---|
| bin/ethlambda/src/main.rs | Makes --attestation-committee-count optional with a three-level resolution (CLI > YAML > 1); introduces typed deserialization structs and 5 unit tests. One issue: the YAML path bypasses the range(1..) lower-bound enforced by clap. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Startup] --> B{CLI --attestation-committee-count set?}
B -- Yes --> C[Use CLI value\nclap enforces range >= 1]
B -- No --> D{validator-config.yaml\nconfig.attestation_committee_count present?}
D -- Yes --> E[Use YAML value\n⚠️ no lower-bound check]
D -- No --> F[Use default: 1]
C --> G[set_attestation_committee_count]
E --> G
F --> G
G --> H[SwarmConfig.attestation_committee_count]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
bin/ethlambda/src/main.rs:266-270
**YAML path bypasses the `range(1..)` lower-bound validator**
When `attestation_committee_count` is supplied via the CLI, clap rejects any value below 1. When it comes from `validator-config.yaml`, there is no equivalent guard. A YAML entry of `attestation_committee_count: 0` is silently accepted, reaches `set_attestation_committee_count(0)`, and is forwarded into `SwarmConfig` — producing the same invalid state that the CLI validator was added to prevent.
Consider adding an `assert!(val >= 1)` (or returning an error) after resolving the value, so the invariant is enforced regardless of the source.
Reviews (1): Last reviewed commit: "refactor: simplify code a bit" | Re-trigger Greptile
| fn populate_name_registry(file: &ValidatorConfigFile) { | ||
| let names_and_privkeys = file | ||
| .validators | ||
| .into_iter() | ||
| .map(|v| (v.name, v.privkey)) | ||
| .iter() | ||
| .map(|v| (v.name.clone(), v.privkey)) |
There was a problem hiding this comment.
YAML path bypasses the
range(1..) lower-bound validator
When attestation_committee_count is supplied via the CLI, clap rejects any value below 1. When it comes from validator-config.yaml, there is no equivalent guard. A YAML entry of attestation_committee_count: 0 is silently accepted, reaches set_attestation_committee_count(0), and is forwarded into SwarmConfig — producing the same invalid state that the CLI validator was added to prevent.
Consider adding an assert!(val >= 1) (or returning an error) after resolving the value, so the invariant is enforced regardless of the source.
Prompt To Fix With AI
This is a comment left during a code review.
Path: bin/ethlambda/src/main.rs
Line: 266-270
Comment:
**YAML path bypasses the `range(1..)` lower-bound validator**
When `attestation_committee_count` is supplied via the CLI, clap rejects any value below 1. When it comes from `validator-config.yaml`, there is no equivalent guard. A YAML entry of `attestation_committee_count: 0` is silently accepted, reaches `set_attestation_committee_count(0)`, and is forwarded into `SwarmConfig` — producing the same invalid state that the CLI validator was added to prevent.
Consider adding an `assert!(val >= 1)` (or returning an error) after resolving the value, so the invariant is enforced regardless of the source.
How can I resolve this? If you propose a fix, please make it concise.
🤖 Kimi Code ReviewThe changes are well-structured and improve configuration management for the consensus-critical Consensus Safety Note Code Quality
Minor Suggestions
Acknowledgment Automated review by Kimi (Moonshot AI) · kimi-k2.5 · custom prompt |
🤖 Codex Code Review
Otherwise this looks fine. The PR is limited to startup config resolution and metrics wiring; I did not see changes touching fork choice, attestation validation, justification/finalization, state transition, XMSS, or SSZ logic. I could not run Automated review by OpenAI Codex · gpt-5.4 · custom prompt |
🗒️ Description / Motivation
Make
--attestation-committee-countoptional and let it default to theconfig.attestation_committee_countfield already defined invalidator-config.yaml(the shared genesis bundle every Lean clientreads). Falls back to
1when the field is also absent.This lets multi-subnet networks like lean-quickstart's ansible-devnet
(which sets
attestation_committee_count: 2in the bundle) drop theper-client wrapper flag and rely on a single source of truth.
What Changed
bin/ethlambda/src/main.rs--attestation-committee-countis nowOption<u64>with no default.ValidatorConfigFile/ValidatorConfigBlockstructs read theoptional
config.attestation_committee_countwhile parsing the filewe already read for the metrics name registry.
the field).
Correctness / Behavior Guarantees
--attestation-committee-countis supplied: same value, same metric, same swarm config.
1) still enforced via clap's value parser.SwarmConfigAPI or downstream callers; only thebinding site in
mainswitches from a CLI default to the resolvedvalue.
Tests Added / Run
cargo test -p ethlambda --release— 23 pass, including 5 newtests::*covering: file parses the field, defaults toNonewhenabsent, CLI overrides file, file fallback when CLI absent, default
fallback when neither is set.
cargo clippy -p ethlambda --tests -- -D warnings— clean.cargo fmt --all— clean.three resolution paths fired and logged correctly:
272lean-quickstartdevnet4branch withthe branch's image: 8/10 multi-client nodes up, ethlambda elected as
subnet-0 aggregator, blocks produced/imported,
justified_slot=12 vote_count=7 threshold=7.Related Issues / PRs
attestationCommitteeCountenv wiring inlean-quickstart/client-cmds/ethlambda-cmd.sh; once this lands, theflag forwarding there can be retired in a follow-up.