Repository navigation
feat(validator): make /health report whether the client can do its duties - #884
Merged
Merged
Conversation
…ot's duties The client asked whether its beacon node was syncing or optimistic once an epoch, at the top of refresh_epoch, and between refreshes left every duty to the node's 503. The Beacon API has none for a syncing node's head root or an optimistic node's payload attestation data, and with several nodes every request still started at the first one listed. beacon_node::health probes every node's /eth/v1/node/syncing once a slot, all at once, a sixth of a slot before the boundary (2 s on 12 s slots), on its own task. NodeHealth keeps each node's last probe (the full SyncStatus, head_slot and sync_distance included, or the error), shared through FallbackBeaconNode::health() with a cheap snapshot(). - The duty loop reads the probe at the boundary: a slot signs nothing when some node answered and every node that answered is syncing or optimistic. A node that did not answer does not count, so the 503 stays the backstop. Logged, and counted on ethlambda_validator_slots_skipped_syncing_total. Only the fee recipient re-send, which signs nothing, still runs in such a slot. - refresh_epoch drops its own check and runs only in a slot that passed, so the epoch refresh and the duties read one probe. - The fallback tries the nodes that passed first, then the rest, each in command-line order; Producer positions are unchanged. - The head root and the PTC data are never asked of a node whose last probe said syncing or optimistic, so no sync committee message is signed over a syncing node's head and no PTC vote over an optimistic one. - el_offline and each node's change of state are logged on change.
MegaRedHand
changed the base branch from
feat/validator-per-slot-sync-check
to
feat/validator-node-ranking
November 25, 2026 02:14
MegaRedHand
force-pushed
the
feat/validator-health-endpoint
branch
from
November 25, 2026 02:14
06ecf51 to
4134958
Compare
…s probe A synced node whose sync probe had not come back by the boundary counted as not answering, so one fast syncing answer withheld the slot while routing still ranked that node synced. A node still on the slot before's synced answer now holds the gate open. The probe task's end is logged: it loops for the client's life, so it ends only by panicking, and the duties then go on unchecked. The el_offline change logs compare against the last probe that answered, so a failed probe in between neither hides the execution client coming back nor reports it going offline twice.
MegaRedHand
force-pushed
the
feat/validator-health-endpoint
branch
from
November 25, 2026 14:13
4134958 to
a712b8b
Compare
Collaborator
Author
|
/review |
AI security review: 2 finding(s) to checkReviewed by Opus, GPT, Kimi, GLM. A judge model checked every one of the findings against the code.
DetailsM1. Expire schedules at epoch boundaries, not two epochs after refresh (medium, logic)
M2. Do not assume a successful refresh includes lookahead duties (medium, logic)
Cost of this review: ~$2.75 of a $30 budget (estimated from token counts). |
…ered synced The head root and the payload attestation data have no 503 behind them, yet a node whose sync probe failed was still asked for them: a syncing node with a slow or broken /node/syncing could hand out its stale head, or an optimistic one its unvalidated payload data, for this client to sign. For those two calls a node must have answered its last probe synced, or have no probe to read (a fallback no probe task runs for). With no node left to ask the answer stays BeaconNodeSyncing, which the sync committee and PTC services read as "do not sign".
…sages Requests walk the beacon nodes by tier, best first: synced and validated; optimistic or with the execution client offline; syncing or more than 8 slots behind by sync_distance; not probed yet; failing. Command-line order breaks ties, so one healthy node, or several, are asked as listed. A request that times out or cannot connect ranks its node failing until a later probe answers, so a hung node costs one request timeout per probe rather than one per request. `nodes` stays in command-line order, so a Producer still names the node that built a blinded block. `--broadcast attestations,blocks,sync-committee` sends those signed messages to every node at once, succeeding when any accepts. Nodes ranked failing are sent a broadcast only when no other node took it. A block reports the best answer (200 over 202 over refused). An envelope goes to its block's producer first, then the rest, or to the producer alone when sent without its blobs. A blinded block stays on its producer. None is broadcast by default.
…less envelope to its producer In a stall every node is past the sync tolerance and ranks Behind, so a syncing node listed first was asked ahead of a synced one. Inside a tier, a node reporting syncing now goes last, and an optimistic or el_offline one after the rest. An envelope without its blobs goes to its producer alone with or without --broadcast blocks: only the producer cached them, and a producer ranked failing for a timed-out block publish was otherwise asked last. Also: --broadcast accepts Lighthouse's `none` as a no-op, the request failures are recorded with inspect_err, and the dto.rs table says el_offline and sync_distance rank a node.
…e envelope's failover A broadcast waited for every node not ranked failing. A node hanging on publish_block for the first time held it past the proposal's deadline, which cut the whole publish: the proposal read as failed, the self-built envelope was skipped, and the hung node's timeout was never recorded, so the next proposal waited on it again. Once a node accepts, a broadcast now waits at most half a second more; a node still sending is cut off and ranked failing. An envelope without its blobs went to its producer alone. A block with no blobs can be revealed through any node, so a producer that does not take it is now followed by the walk, with or without --broadcast. A request failure is cleared only by a probe sent after it, not by one already on its way when the request failed.
…ties
The validator client's /health always answered 200 with a constant
body, so a client whose beacon nodes were all down or syncing, or whose
slashing-protection writes kept failing, looked healthy to every probe.
client_health::ClientHealth holds what the endpoint reads, all of it
state the client already keeps, and makes no beacon node request of its
own. /health now answers 200 when the client can do its duties and 503
when it cannot, with status, service and four checks:
- beacon_nodes {usable, configured}: usable counts the nodes whose
latest sync probe (beacon_node::health) answered neither syncing nor
optimistic and is at most two slots old. One is enough.
- validators {loaded, resolved}: reported, never failing. loaded is
read from the key store with try_read, falling back to the last count.
- slashing_protection {last_write_ok}: SharedProtection::last_write_ok,
two atomics beside the record's mutex. commit() sets the write flag
from file::write's outcome; blocking() sets the wait flag on a
RECORD_WAIT timeout and clears it when it reaches the record. A failed
write fails the check until a later write succeeds.
- started: the duty loop marks the first successful refresh_epoch.
status is healthy (200), starting (503: not started, nothing else
failed; a node not probed yet does not count against a client that has
not started) or unhealthy (503).
beacon_node_available is now set on every /metrics scrape from the same
report, as is the new ethlambda_validator_healthy gauge and
validators_loaded, so a gauge and the endpoint read one answer. Its old
writers in the duty loop and the sync gate are gone.
docs/cli.md documents the endpoint and docs/metrics.md the metric
changes.
A node can answer its sync probe synced and still fail every duty refresh. /health then stayed 200 for good after the first refresh, with no duties left to do once the held schedule ran out, and the failure paths that used to drop beacon_node_available are gone. /health gains a schedule_current check: the last successful refresh is at most two epochs old, so the schedule it fetched (its own epoch and the next) still covers now. healthy now also requires it.
…y held schedule_current allowed two epochs from the refresh's completion. A refresh late in its epoch then read current for most of an epoch past the schedule's end, and one whose lookahead fetch failed (which refresh_around shrugs off) read current through an epoch it held no attester duties for. The duty loop now passes the last epoch the attester schedule holds after a successful refresh: the lookahead epoch when its fetch went through, else the refresh's own (DutiesService::holds_attesters). ClientHealth compares it with the clock's epoch, so attach takes the SlotClock.
MegaRedHand
force-pushed
the
feat/validator-health-endpoint
branch
from
November 25, 2026 15:01
578c046 to
0256e84
Compare
…rent across boundaries A refresh that resolved no validator (no keys, or keys waiting for activation) fetches no attester schedule, so the schedule check counted it through its own epoch only, and /health read unhealthy at every epoch boundary until that slot's refresh returned. Such a refresh now counts through the next epoch: there is no schedule to run out.
…ot-sync-check Conflicts with the chain check from main (#854), resolved to keep both: - FallbackBeaconNode holds the probe records and the chain check's per-node states side by side. The walk follows the probe ranking and skips a node whose usable flag is down; try_each_synced answers BeaconNodeSyncing only when some node is on this client's chain, and the no-usable-node failure otherwise. - The per-slot probe and is_optimistic_or_syncing ask only the nodes on this client's chain, so a synced node on another chain cannot open the slot's gate. - The duty loop reads the gate before the readmission count, so a node let back in during a withheld slot is still sent what it missed at the next slot that passes. Both the probe task and the chain check are stopped when run returns. - docs/cli.md: the --beacon-nodes row and the per-slot section name the chain check.
…-node-ranking Brings in main through the base branch: the chain check (#854) and the keymanager token file (#867). Conflicts in fallback.rs, resolved to keep both: the broadcast topics and flag sit beside the chain check's per-node states, and the module doc keeps both sections. Beyond the conflicts, a node whose usable flag is down is now left out of a broadcast (`broadcast_to_all`), and an envelope whose producer left the chain is not sent to it but to the walk or the broadcast, as no other call goes to such a node. A broadcast with no node to send to names the chain check's no-usable-node reason. docs/cli.md says so.
pablodeymo
approved these changes
Nov 25, 2026
With an empty ValidatorStore the sync committee and PTC services sign nothing whichever node answers, so both tests still passed with head_block_root routed back through the plain try_each walk. Loading one key makes a stale or optimistic node's root produce a submitted message, which the existing asserts catch.
…ot-sync-check Brings in #869, #870 and #879. One conflict, in the duty loop's refresh block (lib.rs): main's ahead_of_block/settle_refresh restructure is kept, with this branch's comment fix (refresh_epoch no longer runs a sync check) carried over. Semantic fix: #869's a_refresh_that_finds_the_node_syncing_stops_the_proposals drove the node_syncing gate through refresh_epoch's is_optimistic_or_syncing check, which this branch removes in favour of the per-slot probe. The gate is still reachable through a duties fetch every node refuses with a 503 (read as BeaconNodeSyncing), so the test now feeds settle_refresh that outcome. The proposal gate's comment now names the per-slot check as the primary guard.
…ck' into stack/885
…-endpoint Brings in #876's and #885's latest, and through them main's #869, #870 and #879, which restructured the duty loop's refresh (ahead_of_block, settle_refresh, a refresh deferred past the block). Conflicts in lib.rs, resolved onto main's structure with this branch's intent ported: - health.epoch_refreshed now runs wherever settle_refresh reports a refresh that got through, both ahead of the block and deferred past it, through a new report_refreshed helper that keeps the covered_through rule. - The set_beacon_node_available writes #869 and #870 added (settle_refresh's two failure arms, the proposer-only fetch, spawn_subscriptions) are dropped, as this branch dropped the older ones: the gauge is set from the /health report on every scrape. duties.rs: #869 and this branch each added an identical holds_attesters; one is kept.
…-endpoint Brings in the base branch's merge of main, which carries #876 as one squashed commit.
MegaRedHand
added a commit
that referenced
this pull request
Nov 26, 2026
…ties (#884) The validator client's /health answered healthy whatever its state, and ethlambda_validator_beacon_node_available said little more. /health now answers 503 with the reasons when no beacon node is usable, when the duty schedule has run out, or when slashing-protection writes keep failing, and the metric is set from that same report rather than from scattered call sites. Applied as this PR's own change on top of #885, which it is stacked on. Resolved against #874, #877 and #880: - The deferred refresh reports to the health tracker before #869's owed sends. - The sync committee message step keeps #880's head-event trigger and drops the direct metric write, as this PR does everywhere. - The registrable filter keeps #877's whole-entry is_registrable. - #874's distributed subscription task no longer writes the metric either. - This PR's health test builds ValidatorEntry with #877's slashed: false.
MegaRedHand
added a commit
that referenced
this pull request
Nov 26, 2026
…de's (#886) The validator client timed every duty off its own wall clock and never checked it against anything, so a skewed clock got proposals refused or sent duties late while every series looked healthy. Each sync probe now also reads the node's Date header and answer time, and the client warns when its clock is off from the nodes' by half a second or more (ethlambda_validator_beacon_node_clock_offset_seconds). A step of the wall clock against the monotonic one is logged and counted too. Applied as this PR's own change on top of #884, which it is stacked on. Resolved against #874 and #880: the module list and the metrics keep #874's and #880's entries next to this PR's clock series.
… it off, and give the envelope's producer a head start - A node a broadcast stops waiting for 500 ms after the first acceptance is no longer ranked Failing. One that is only slower (to import a block, or to take a large envelope) was cut out of every broadcast until its next probe, slot after slot. A hung node still costs a broadcast at most the grace, and its probe ranks it failing. `NodeHealth::record_no_answer` is removed. - Under `--broadcast blocks` the envelope's producer gets a 500 ms head start (`PRODUCER_HEAD_START`) rather than an unbounded wait. A producer that holds the request open (one that answered the block 202 waits for a block it never imported) no longer keeps the envelope from every node until the proposal's deadline cuts the reveal; past the head start its answer is awaited with the others' (`Sent::Pending`). - An envelope without its blobs that the producer refused is not sent to it a second time by the walk (`Reach::EveryBut`). - `register_validators_in_batches` records failed batches against node health.
…anking # Conflicts: # bin/ethlambda/src/validator.rs
…anking # Conflicts: # bin/ethlambda/src/validator.rs # crates/validator/src/lib.rs
MegaRedHand
added a commit
that referenced
this pull request
Nov 26, 2026
…ties (#884) The validator client's /health answered healthy whatever its state, and ethlambda_validator_beacon_node_available said little more. /health now answers 503 with the reasons when no beacon node is usable, when the duty schedule has run out, or when slashing-protection writes keep failing, and the metric is set from that same report rather than from scattered call sites. Applied as this PR's own change on top of #885, which it is stacked on. Resolved against #874, #877 and #880: - The deferred refresh reports to the health tracker before #869's owed sends. - The sync committee message step keeps #880's head-event trigger and drops the direct metric write, as this PR does everywhere. - The registrable filter keeps #877's whole-entry is_registrable. - #874's distributed subscription task no longer writes the metric either. - This PR's health test builds ValidatorEntry with #877's slashed: false.
MegaRedHand
added a commit
that referenced
this pull request
Nov 26, 2026
…de's (#886) The validator client timed every duty off its own wall clock and never checked it against anything, so a skewed clock got proposals refused or sent duties late while every series looked healthy. Each sync probe now also reads the node's Date header and answer time, and the client warns when its clock is off from the nodes' by half a second or more (ethlambda_validator_beacon_node_clock_offset_seconds). A step of the wall clock against the monotonic one is logged and counted too. Applied as this PR's own change on top of #884, which it is stacked on. Resolved against #874 and #880: the module list and the metrics keep #874's and #880's entries next to this PR's clock series.
MegaRedHand
added a commit
that referenced
this pull request
Nov 26, 2026
Brings in main now that #885 and #884 have merged, with #868, #900, #901 and #911. #885 and #884 reached main as squash commits, so a plain merge saw both sides add the same files and conflicted throughout. The tree is main plus this branch's own diff against #884's merged head (42dcaa3), which applies to main without conflicts.
MegaRedHand
added a commit
that referenced
this pull request
Nov 27, 2026
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.
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.
Closes #833.
Problem
The validator client's
/health(metrics::router) answered200 {"status":"healthy","service":"ethlambda-validator"}whatever the client's state. A client whose beacon nodes were all down, syncing or optimistic, or whose slashing-protection writes kept failing on a full disk, answered the same way as one that was attesting. Kubernetes probes, load balancers and uptime checks reading it were told everything was fine while no duty was done.ethlambda_validator_beacon_node_availabledid not help either. Its help text said "1 when a beacon node answered the last duty refresh or attestation", but:1only at the end of a successfulrefresh_epoch, once an epoch;0until the next epoch's refresh;1.What this does
/healthanswers from state the client already keeps (crates/validator/src/client_health.rs).ClientHealth::reportasks no beacon node anything and waits on no lock. The answer is200when the client can do its duties and503when it cannot, with the body the issue sketches:{ "status": "unhealthy", "service": "ethlambda-validator", "checks": { "beacon_nodes": { "usable": 0, "configured": 2 }, "validators": { "loaded": 64, "resolved": 64 }, "slashing_protection": { "last_write_ok": true }, "started": true, "schedule_current": true } }The issue's four checks, plus one:
beacon_nodes:usablecounts the nodes whose latest probe from feat(validator): check each beacon node's sync status before every slot's duties #876 (NodeHealth::snapshot,Probe::standing) answered, neither syncing nor optimistic, and is at most two slots old. One usable node passes. The two-slot bound is the oneNodeHealth::rankeduses for routing; probes are a slot apart, so only a probe task that stopped leaves one that old. Neitherrankednor feat(validator): rank beacon nodes by health and broadcast signed messages #885'stiersis read.usableis the probe's own verdict, the one the slot's gate reads, so feat(validator): rank beacon nodes by health and broadcast signed messages #885's ranking inputs do not move it:sync_distance,el_offline, and a request the node did not answer.validators:loadedandresolved, reported.loadedis read from the key store withtry_read, falling back to the last count, since a keymanager import holds the store's write lock while it decrypts.resolvedis what the last successful refresh resolved.slashing_protection.last_write_ok(SharedProtection::last_write_ok): two atomics beside the record's mutex, so reading them never waits on the stuck write being reported.SlashingProtection::commitsets the write flag fromfile::write's outcome (Error::Unflushedincluded), next toinc_slashing_protection_write_failures.slashing_protection::blockingsets the wait flag when it gives up afterRECORD_WAIT, and clears it when it reaches the record.started: set byClientHealth::epoch_refreshed, which the duty loop calls inrefresh_epoch'sOkarm. That arm is also reached by a client with no keys, whererefresh_epochreturns early.refresh_epoch's signature is unchanged.schedule_current(not in the issue's sketch): the attester schedule the last successful refresh left held reaches the clock's epoch. The duty loop passesepoch_refreshedthe last epoch held: the lookahead epoch when its fetch went through (DutiesService::holds_attesters), else the refresh's own, sincerefresh_aroundshrugs a failed lookahead off.attachtakes theSlotClockto read the epoch. A node can answer its probe synced and still fail every refresh or every lookahead (duties or validator endpoints erroring); once the schedule runs out the client makes no attestation, and without this check/healthwould stay200.truebefore the first refresh, whichstartedreports, and before genesis. A refresh that resolved no validator (no keys, or keys waiting for activation) holds no schedule to run out and counts through the next epoch, so such a client does not read unhealthy at each epoch boundary while its refresh is under way.statusis one of three:healthy(200): started, at least one usable node, the last write went through, and the schedule is current.starting(503): not started, and nothing else has failed.unhealthy(503): anything else.Gauges from the same report. The
/metricshandler builds the report and sets three gauges from it before gathering (client_health::publish):ethlambda_validator_beacon_node_available:1when at least one node is usable by the definition above, with new help text.ethlambda_validator_healthy: new,1exactly when/healthwould answer200.ethlambda_validator_validators_loaded: the same count/healthreports, so it now follows keymanager imports and deletions.The old writers of
beacon_node_availableare removed: the refresh, subscription, attestation, sync committee and PTC failure paths and the end ofrefresh_epochinlib.rs, andhealth::slot_signs.metrics::set_beacon_node_availablestays public, now called only bypublish.Wiring in
lib.rs.ClientHealth::newruns before the metrics listener binds, with the configured node count and the store.metrics::routernow takes it.ClientHealth::attachhands it the nodes'NodeHealth, the slot duration and the record once they exist.epoch_refreshedis one line in the refresh'sOkarm.Decisions
starting(503) throughout, neverunhealthy. Before the nodes are attached at all (while fetching genesis and the spec), the same. A client that has not started isunhealthyinstead only when every node has been probed and none is usable, or a write failed. Once started, a node with no probe counts as unusable. Otherwise a probe task that never ran would leave the clienthealthywith nothing vouching for a node.statusvalue,starting. It keeps "still starting" from reading as "broken" in the body. The status code is503either way./healthcarries the checks.docs/cli.mdtells operators to point readiness checks, load balancers and uptime monitors at it, and not a Kubernetes liveness probe: it answers503while every beacon node is down or syncing, which a restart does not fix.200, with the counts in the body; no206.upcheckper signer is a network call, which/healthdoes not make.loaded = 0is reported and does not fail the check. A client started empty to wait for a keymanager import is idle on purpose, and neither a restart nor taking it out of rotation loads a key.resolved = 0does not fail it either, as the issue says.ethlambda_validator_doppelganger_detectingreports it.Docs.
docs/cli.md: the Metrics section documents/health, its body, the checks, the three statuses and the liveness-probe warning.docs/metrics.md: the newhealthyrow, and new text forbeacon_node_availableandvalidators_loaded.Tests
client_health.rs:status,serviceand the four checks, with exactly the fields named, plusschedule_current.E + 1ishealthyat the last slot ofE + 1andunhealthywithschedule_current: falseat the first slot ofE + 2, while the node still probes usable; one whose lookahead failed (held throughE) isunhealthyfromE + 1. The real-refresh test checks the lookahead epoch is held.starting(503) before the first probe and after it, thenhealthy(200) after a realrefresh_epochdriven throughMockBeaconNode. The test callsepoch_refreshedas the duty loop does, since the loop itself is not unit-testable.starting, notunhealthy, both unattached and attached. One node answering unusable while another is unprobed is stillstarting; every node answering unusable isunhealthy.unhealthy.unhealthy; one coming back synced ishealthy.loaded = 0and stayshealthy.loadedis the last count read; after the writer drops it, the new one.unhealthyuntil a later write succeeds.cfg(unix), skipped as root./healthand then/metrics, going down and coming back,healthyandbeacon_node_availableread what the endpoint answered. This is the only test that touches those process-wide gauges.slashing_protection/mod.rs:last_write_okoff, a read-only access leaves it off, and a later successful write turns it back on.cfg(unix), skipped as root.RECORD_WAITturns it off, and the next access that reaches the record turns it back on. This waits out the real 3 s, since the wait runs on a blocking thread's clock.Tests not run locally (CI runs them);
make fmtandmake lintclean.