Skip to content

feat(validator): --network, to hold every beacon node to a named network - #902

Open
MegaRedHand wants to merge 5 commits into
mainfrom
feat/validator-network
Open

MegaRedHand wants to merge 5 commits into
mainfrom
feat/validator-network

Conversation

@MegaRedHand

@MegaRedHand MegaRedHand commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

🗒️ Description / Motivation

The validator client has no network config of its own. It runs on whatever chain the first beacon node to answer is on, and checks the other nodes against that one. That leaves two gaps:

  • First start. The slashing-protection record pins genesis_validators_root once it exists, but it is created on whatever chain the first answering node reports.
  • Outdated beacon nodes. When every node agrees on the genesis but serves an old fork schedule (one built before a network rescheduled a fork, as Hoodi's Glamsterdam just was), the client follows that schedule without a word.

Lighthouse, Lodestar and Prysm let the validator client name its network; Teku defaults to auto (take it from the node), and Nimbus has no flag. This adds an optional --network, in the style of Teku's named mode and Lighthouse's check: it holds the identity of the chain to the named network, and only warns about the fork schedule.

No open PR adds this. The closest is #873 (GAS_LIMIT_SCHEDULE), which touches chain_check.rs, the spec parsing and lib.rs; it is a likely merge conflict, not something to build on. This PR keeps its edits to those files additive.

What Changed

ethlambda validator --network <name|dir>

  • Optional, with no default: absent keeps today's behaviour exactly.
  • Takes what ethlambda beacon --network takes: mainnet, sepolia, hoodi, plataberget, or a directory of published network files. It is resolved by the same network module (NetworkSpec::parse + NetworkSource::resolve), so the client and the node read a network's config the same way.
  • Resolved first thing in validator::run. Resolving selects the network's preset, which is fine for require_unread_preset(): that only fails when a read froze a preset before any select.

What the network is compared on (chain_check)

Refused Warned
PRESET_BASE, genesis_time, genesis_validators_root, slot duration, GENESIS_FORK_VERSION ✅ (first_identity_difference)
Fork epochs and versions ✅ once an epoch (schedule_differences, warn_if_schedule_differs)
  • first_identity_difference is the prefix first_chain_difference already checked, pulled out into its own function; first_chain_difference calls it, so node-vs-node checking is unchanged.
  • Why the schedule only warns: either side can be stale. If this binary predates a reschedule and the beacon nodes are upgraded, refusing on the schedule would take every validator offline at the fork. Lighthouse makes the same choice (it warns on a mismatched fork epoch and refuses only on genesis fork version and preset).
  • The warning compares the schedule the client actually follows (after the merge across nodes) with the network's, names both values (GLOAS_FORK_EPOCH (beacon nodes unscheduled, network config 143616)), and says one side is out of date without guessing which.
  • The named network is only ever compared against. It never goes into SharedConfig or the schedule merge; the client still runs on the reference node's config.

Startup (FallbackBeaconNode::establish_on)

establish now delegates to a new establish_on(network, with_reference), so the existing call sites are untouched. With a network:

  • The reference is the first node that answers and has no identity difference from the network. A node on another network is never the reference, so with_reference never adopts its chain or its preset.
  • The network's fork schedule does not pick the reference among nodes on the network that disagree on a fork: list order does, as without the flag. Preferring the node that matches the network's config would, when this binary is the stale side, follow the stale schedule and drop the upgraded node at the old epoch.
  • Other nodes are judged against the reference as before, which leaves a node on another network unusable.
  • A node that answered on another network is a final answer, like an unreadable spec or an unsupported preset. When every node has answered with one of those, startup fails at once, naming the network and why each node is off it (node 0: not on sepolia: genesis_time (ours 1655733600, theirs 1742213400)). Otherwise it keeps waiting for a node on the network, as it waits today.

After startup nothing changes: every node compatible with the reference has the network's identity.

Docs

docs/cli.md (flag row and the chain-check section), README flag table, CLAUDE.md's validator paragraph, and the doc comments on adopt_preset, the chain_check module, establish_on and validator.rs's module doc.

Correctness / Behavior Guarantees

  • No flag, no change. establish(f) is establish_on(None, f), and with None every Ok answer can be the reference, as before. The only user-visible differences are the wording of the "waiting for a node" log line and a network field on the startup log line.
  • A directory network goes through NetworkSource::resolve unchanged, so it decodes the directory's genesis.ssz and runs check_constants. A directory whose constants this binary refuses as a beacon node is refused here too, even though a validator client does not use those constants.
  • Out of scope: ethlambda voluntary-exit takes no --network.

Tests Added / Run

Added (not run locally; CI runs them):

  • chain_check: the_identity_leaves_the_forks_out, a_schedule_differs_from_the_network_by_epoch_or_scheduled_version, an_unscheduled_forks_version_is_no_schedule_difference.
  • chain_check, through the fallback with mock nodes: a_node_off_the_named_network_is_never_the_reference (also checks with_reference sees only the network's chain and the off-network node gets no duty call), without_a_named_network_the_first_answer_is_the_reference, the_named_networks_schedule_does_not_pick_the_reference, every_node_off_the_named_network_fails_at_once (under a 1 s timeout, shorter than a startup retry), startup_waits_for_a_node_on_the_named_network.
  • bin/ethlambda/src/validator.rs: the_network_is_optional, a_built_in_network_resolves_to_its_genesis_and_config (Hoodi), a_network_directory_resolves_to_its_genesis_and_config, a_network_directory_without_a_config_name_is_named_by_its_path, an_unknown_network_name_is_refused_at_startup.

Run:

make fmt
make lint   # clippy --all-targets, so the new tests compile

End to end, the release-fast binary against a local server replaying the /eth/v1/beacon/genesis and /eth/v1/config/spec answers recorded from our Hoodi and Sepolia beacon nodes (no validators loaded):

Node Flag Result
Hoodi --network hoodi starts, network="hoodi"
Hoodi --network sepolia fails at once: node 0: not on sepolia: genesis_time (ours 1655733600, theirs 1742213400)
Sepolia --network sepolia starts
Hoodi none starts as before, network="any, taken from the beacon nodes"
Hoodi, spec edited to GLOAS_FORK_EPOCH: 143616 --network hoodi (run before #901 merged, when this branch's Hoodi config had Gloas unscheduled) starts, then at the first slot round: differences=GLOAS_FORK_EPOCH (beacon nodes 143616, network config unscheduled)

So a real node's spec and the built-in configs agree on every identity field (PRESET_BASE, SLOT_DURATION_MS, GENESIS_FORK_VERSION, genesis).

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt
  • Ran make lint (clippy with -D warnings)
  • Ran make test: left to CI

Brings in #868, #872, #880, #884, #885 and #886, among others.

Each side added a flag next to --beacon-nodes, a ValidatorConfig field
and a row in the README and docs/cli.md flag tables. --network and
main's --broadcast both stay, --network first, and the --beacon-nodes
rows take main's text, which describes #885's ranking. The config is
built before run (#872), so network joins main's broadcast and
event_stream fields there.
…agreeing nodes

Review round 1 on #902:

- With --network, the reference was the first node on the network
  whatever schedule it served, so with one node stale on a rescheduled
  fork listed ahead of an upgraded one, the client followed the stale
  schedule and later dropped the node that agreed with the network. The
  first node on the network that also serves the network's schedule is
  now the reference, and the first on the network when none does.
- The help text and the flag row said startup fails when every node
  that answered is off the network. It fails once every configured node
  has answered and none is on it, and waits while one has not answered.
- The schedule warning told the operator to upgrade the beacon nodes or
  this client. For a directory the stale side can be its config.yaml, so
  the warning now names --network's config (this binary's for a
  built-in network, the directory's config.yaml otherwise), and the help
  text agrees with it.
- The help text and docs/cli.md say a directory is resolved whole, as
  for beacon: its genesis.ssz decoded and its bootnodes file read.
- Tests: the reference preference, a network directory resolving to its
  genesis and config, and a directory without CONFIG_NAME named by the
  flag's value. network::dir's complete_dir fixture is now reachable
  from the crate's other tests.
… schedule says

Review round 2 on #902 found round 1's tie-break wrong in the other half
of the case it was for. When the validator binary is the stale side (a
fork postponed from X to Y, the binary still at X), preferring the node
that matches --network's schedule made the stale node the reference: the
client followed X, the upgraded node was dropped at X, and the schedule
warning stayed quiet since the followed schedule equalled the network's.
That is the outage the PR's design rules out by only ever comparing
against the network's config.

The reference is the first node on the network again, as without
--network. The test now pins that a later node matching the network's
schedule does not take its place, and the docs and help text say why:
the network's config may be the stale side, and the once-an-epoch
warning names the difference in either case.
MegaRedHand added a commit that referenced this pull request Nov 27, 2026
…ork (#902)

The validator client had no network config of its own: it ran on whatever
chain the first beacon node to answer was on, created its slashing
protection record on that chain, and followed an outdated fork schedule
without a word when every node served one. ethlambda validator now takes
an optional --network (mainnet, sepolia, hoodi, plataberget, or a
directory of published network files), resolved by the same network
module ethlambda beacon uses. With no flag nothing changes.

The network holds the chain's identity: a node whose preset, genesis time,
genesis validators root, slot duration or genesis fork version differs
from it is never the reference and is skipped like any incompatible node,
and startup fails once every configured node has answered and none is on
the network (it waits while one has not answered). The fork schedule only
warns, once an epoch, naming both values, since either side can be the
stale one: the beacon nodes, or --network's config (this binary's for a
built-in network, the directory's config.yaml otherwise). The named
network is only compared against; the client still runs on the reference
node's config, and list order still picks the reference among the nodes
on the network.

Applied as the PR's own diff against its merge base with main
(4989419), since its branch carries main merges, on top of #899.

Resolved against #871, #873, #874 and #877: ValidatorConfig and its
construction keep #874's distributed and #877's shut_down_when_slashed
next to this PR's network, with --broadcast where nightly has it; the
imports keep #871's GraffitiFile, and drop DEFAULT_GAS_LIMIT as #873 did;
chain_check::run takes #873's settings and this PR's network, and each
round hands over the gas limit schedule before the schedule warning.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant