Skip to content

fix: wire attestation-committee-count CLI flag through to ChainOptions#678

Merged
ch4r10t33r merged 3 commits intomainfrom
fix/attestation-committee-count
Mar 18, 2026
Merged

fix: wire attestation-committee-count CLI flag through to ChainOptions#678
ch4r10t33r merged 3 commits intomainfrom
fix/attestation-committee-count

Conversation

@zclawz
Copy link
Copy Markdown
Contributor

@zclawz zclawz commented Mar 18, 2026

Problem

NodeCommand was missing the @"attestation-committee-count" field, so simargs silently discarded the flag. The value always fell through to the hardcoded default of 1 inside ChainConfig.init. With committee_count = 1 every node computes validator_id % 1 = 0 and all validators end up on the same single subnet, breaking the subnet-sharding design entirely.

Fix

pkgs/cli/src/main.zig

  • Add @"attestation-committee-count": ?u64 = null to NodeCommand so simargs now parses and exposes the flag.
  • Add a __messages__ entry for the new field.

pkgs/cli/src/node.zig

  • Add attestation_committee_count: ?u64 = null to NodeOptions.
  • Add attestationCommitteeCountFromYAML() helper that reads ATTESTATION_COMMITTEE_COUNT from config.yaml as a fallback when the CLI flag is absent.
  • In buildStartOptions: CLI flag takes precedence; falls back to config.yaml; leaves null if neither is present (ChainConfig still defaults to 1 for backward compat).
  • In Node.init: apply options.attestation_committee_count to chain_options before constructing ChainConfig, so the correct count propagates to EthLibp2p and the subnet-assignment logic (validator_id % attestation_committee_count).

pkgs/cli/test/fixtures/config.yaml

  • Add ATTESTATION_COMMITTEE_COUNT: 4 to the test fixture.

New tests

  • attestationCommitteeCountFromYAML reads ATTESTATION_COMMITTEE_COUNT from config.yaml — asserts value 4 is read correctly.
  • attestationCommitteeCountFromYAML returns null when field is absent — asserts null for a YAML file without the field.

Usage

Via CLI flag (overrides config.yaml):

zeam node --attestation-committee-count 8 ...

Via config.yaml (new fallback, no flag needed):

ATTESTATION_COMMITTEE_COUNT: 8

NodeCommand was missing the @"attestation-committee-count" field, so
simargs silently ignored the flag and the value always fell through to
the hardcoded default of 1 in ChainConfig.init.  With every node using
committee_count=1, all validators compute validator_id % 1 = 0 and end
up subscribed to the same single subnet.

Changes:
- Add @"attestation-committee-count": ?u64 = null to NodeCommand so
  simargs parses and exposes the flag.
- Add attestation_committee_count: ?u64 = null to NodeOptions.
- Add attestationCommitteeCountFromYAML() helper that reads
  ATTESTATION_COMMITTEE_COUNT from config.yaml as a fallback.
- In buildStartOptions: CLI flag takes precedence; falls back to
  config.yaml value; leaves null if neither is present (ChainConfig
  still defaults to 1 in that case for backward compat).
- In Node.init: apply options.attestation_committee_count to
  chain_options before constructing ChainConfig so the correct value
  reaches EthLibp2p.attestation_committee_count and the subnet
  assignment logic.
- Add ATTESTATION_COMMITTEE_COUNT: 4 to test fixture config.yaml.
- Add two unit tests for attestationCommitteeCountFromYAML.
@ch4r10t33r ch4r10t33r self-requested a review March 18, 2026 08:10
ch4r10t33r
ch4r10t33r previously approved these changes Mar 18, 2026
Copy link
Copy Markdown
Contributor

@ch4r10t33r ch4r10t33r left a comment

Choose a reason for hiding this comment

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

Looks good.

@ch4r10t33r ch4r10t33r merged commit 9340749 into main Mar 18, 2026
12 checks passed
@ch4r10t33r ch4r10t33r deleted the fix/attestation-committee-count branch March 18, 2026 10:18
GrapeBaBa pushed a commit that referenced this pull request Apr 2, 2026
#678)

* fix: wire attestation-committee-count CLI flag through to ChainOptions

NodeCommand was missing the @"attestation-committee-count" field, so
simargs silently ignored the flag and the value always fell through to
the hardcoded default of 1 in ChainConfig.init.  With every node using
committee_count=1, all validators compute validator_id % 1 = 0 and end
up subscribed to the same single subnet.

Changes:
- Add @"attestation-committee-count": ?u64 = null to NodeCommand so
  simargs parses and exposes the flag.
- Add attestation_committee_count: ?u64 = null to NodeOptions.
- Add attestationCommitteeCountFromYAML() helper that reads
  ATTESTATION_COMMITTEE_COUNT from config.yaml as a fallback.
- In buildStartOptions: CLI flag takes precedence; falls back to
  config.yaml value; leaves null if neither is present (ChainConfig
  still defaults to 1 in that case for backward compat).
- In Node.init: apply options.attestation_committee_count to
  chain_options before constructing ChainConfig so the correct value
  reaches EthLibp2p.attestation_committee_count and the subnet
  assignment logic.
- Add ATTESTATION_COMMITTEE_COUNT: 4 to test fixture config.yaml.
- Add two unit tests for attestationCommitteeCountFromYAML.

* fix: validate attestation-committee-count >= 1, default to 1 with warning

* build: add minimum_zig_version = "0.15.0" to build.zig.zon

---------

Co-authored-by: zclawz <zclawz@blockblaz.io>
Co-authored-by: zclawz <zclawz@openclaw.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants