validator: re-fetch duties when their dependent root changes between epoch refreshes
Maintainer antworten meist innerhalb von 6 Tagen
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Start with crates/validator/src/lib.rs:400-452 and the duty fetch logic in crates/validator/src/duties.rs; the issue also points to preferences.rs:30-37 and slot_clock.rs:1-6. Compare the event driven and per-slot polling options, including reconnect handling and the fork-epoch PTC root decision, before choosing an approach. Done means changed dependent roots refresh affected duties and subscriptions in time, with the listed mock-node, head-event, reconnect, and lookahead tests passing.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
The validator client fetches its duties at the first slot of each epoch and compares each schedule's dependent_root only then. Between two refreshes, nothing notices a reorg that changes a held schedule. The client reads no beacon node events, neither head nor chain_reorg.
Code references are at main @ 5d8628e9.
What happens today
refresh_epochruns at an epoch's first slot (crates/validator/src/lib.rs:400-452). Each of its fetches compares the dependent root it gets with the one held, and replaces the schedule when it moved:- attester duties for this epoch and the next (
duties.rs:124-136); - proposer duties for this epoch (
duties.rs:174-180); - PTC duties for this epoch and the next (
duties.rs:235-244).
- attester duties for this epoch and the next (
- The next comparison happens at the next epoch's first slot, or at the next slot when the refresh failed.
- Sync committee duties carry no dependent root (
duties.rs:64-67): the endpoint sends none, and the committee is fixed a period ahead. They are out of scope here. PreferencesServicealready polls v2 proposer duties every slot, from the epoch before gloas. It follows a changed dependent root within a slot for the preferences it signs (preferences.rs:30-37). The duty loop's own proposer schedule does not, so the two can disagree until the next refresh.
Which reorgs this misses
beacon-APIs defines the dependent roots (ethereum/beacon-APIs master @ 6bc8c7bd, apis/validator/duties/{attester,ptc,proposer,proposer.v2}.yaml). ethlambda's node follows the same definitions (docs/rpc.md:304-308).
| Schedule | When the client fetches it | Depends on | What changes it after the fetch |
|---|---|---|---|
| Attester and PTC duties for the current epoch E | Slot 0 of E-1, as lookahead, and again at slot 0 of E | The last block of epoch E-2 | A reorg that replaces a block at least 33 slots back |
| Proposer duties for E (v1) | Slot 0 of E | The v1 root is the last block of E-1. Since fulu, the proposers themselves come from the lookahead fixed by the end of E-2 | Since fulu, the same deep reorg. Before fulu, a reorg of the boundary block |
| Attester and PTC duties for E+1, the lookahead | Slot 0 of E | The last block of E-1 | A one-slot reorg at the boundary. Examples: a late block in E-1's last slot that the next proposer re-orgs, or one that arrives after the refresh |
beacon-APIs says this of the current epoch's duties: "Duties should only need to be checked once per epoch, however a chain reorganization (of > MIN_SEED_LOOKAHEAD epochs) could occur, resulting in a change of duties. For full safety, you should monitor head_v2 events and confirm the dependent root in this response matches" (attester.yaml, ptc.yaml, proposer.v2.yaml).
So:
- This epoch's schedules go stale only on a reorg deeper than an epoch. That is rare on a finalizing chain. It is expected during long non-finality, when competing forks more than an epoch long switch places.
- The next epoch's attester and PTC schedules go stale on a one-slot reorg at the boundary, which is ordinary. The next refresh replaces them before any vote uses them. Two things act on them before that:
- The subnet subscriptions the refresh leaves owing are computed from them (
lib.rs:488-500). The corrected ones go out only after the next epoch's first proposal, so an aggregator in the first slots of E+1 may have joined the wrong subnet. - If the refresh at slot 0 of E+1 fails, the loop keeps the previous schedule (
lib.rs:436-439) and attests from the stale lookahead.
- The subnet subscriptions the refresh leaves owing are computed from them (
- The PTC of the gloas fork epoch. Per
ptc.yaml, that PTC "is computed at the fork from effective balances that are updated at the end of the previous epoch, so its duties can change until the last slot before the fork". For that epoch alone, beacon-APIs moves the dependent root to the last block before the fork epoch, and adds: "Duties for this epoch are not available before the fork."- ethlambda's node answers the fork epoch's PTC before the fork by advancing a copy of its pre-gloas head to the fork epoch (
crates/net/rpc/src/beacon/ptc.rs:194-204). It reports the root of the last block before the previous epoch, as for every other epoch (ptc.rs:115-118,:170-176). The duties can move during the last pre-gloas epoch while the root stays put. - The client fetches the fork epoch's PTC at the start of the last pre-gloas epoch (
lib.rs:1258-1269). At the fork's first slot it keeps that schedule, because the root did not move (duties.rs:235-238). - It can hold a stale PTC schedule through the first gloas epoch, and per-slot re-polling would not catch it either. Hoodi and mainnet have not forked yet. The node half belongs in an issue of its own.
- ethlambda's node answers the fork epoch's PTC before the fork by advancing a copy of its pre-gloas head to the fork epoch (
Why it matters
- A stale attester schedule costs the epoch's vote. The client attests in the wrong slot or committee. Gossip rejects an attester who is not in the committee, so the vote is lost. Slashing protection has already recorded the target epoch, so the validator's real duty later in the epoch is refused too.
- A stale proposer schedule costs a block. The client asks for a block in a slot that is not its own, which the node or gossip rejects for its proposer index, and misses the slot that is.
- A stale PTC schedule votes in the wrong slot and misses the right one.
- Stale subscriptions leave an aggregator without its committee's votes.
What other clients do
| Client | How held duties follow a reorg | Read at |
|---|---|---|
| Lighthouse | Polls attester and proposer duties every slot, each in its own loop (duties_service.rs:727, :759). For attesters it asks for a few validators first, and fetches everything only for validators whose stored dependent_root differs (duties_service.rs:1240-1266). It fetches proposers for the current and the next epoch every slot, with v2 by default (duties_service.rs:1882, :1940-1946). Head events are not used for duties |
unstable @ 11813cfb |
| Teku | Loads each epoch's duties once. On every head event (head_v2 from gloas) it compares the event's dependent roots with the held ones, and recalculates on a mismatch (AbstractDutyScheduler.java:72-84, PendingDuties.java:166-171). previous_duty_dependent_root is checked against the head's epoch and current_duty_dependent_root against the next (AttestationDutyScheduler.java:76-83). A missed-events signal, such as a reconnect, recalculates everything (AbstractDutyScheduler.java:96-100) |
master @ 62a54b96 |
| Prysm | Runs checkDependentRoots on every head_v2 (or head) event, and calls UpdateDuties when a root differs (duties.go:765-812). --disable-duties-polling turns it off |
develop @ 0c1e3d24 |
| Nimbus | With the default --block-monitor-type=event, each duty loop polls once an epoch, and again when a head event's dependent root differs from the stored one (common.nim:1623-1625, duties_service.nim:834-840). A stream (re)connect invalidates everything (block_service.nim:864-868) |
unstable @ 9bed158a |
| Lodestar | Polls attester duties every epoch. On each head event it checks previousDutyDependentRoot against the current epoch and currentDutyDependentRoot against the next, and refetches on a mismatch (attestationDuties.ts:351-367). Proposers get the same check (blockDuties.ts:216-218) |
unstable @ 77088eb7 |
| Vouch | On each head event for the current slot, compares its dependent roots with the previous head event's (events.go:80). A changed previous root refreshes this epoch's attester and PTC duties. A changed current root refreshes this epoch's proposers and the next epoch's attester and PTC duties (events.go:226-249) |
master @ 691f3652 |
| Vero | Subscribes to head_v2 and chain_reorg on every node (event_consumer.py:238-244). A head_v2 whose dependent roots differ from the held duties' triggers a refetch (attestation.py:155-165, block_proposal.py:205-215, ptc.py:116-126). A chain_reorg refetches attester, proposer and sync duties (validator_duty_service.py:106-110) |
master @ 9d110c1d |
File names are relative to each client's validator client directory.
All seven follow a changed dependent root within a slot or a head event. Lighthouse polls. The other six compare the dependent roots in head events. Only Vero also listens to chain_reorg.
Proposal
Two ways, not exclusive:
- Head events. Subscribe to
head(head_v2once nodes serve it).- On each event, compare
previous_duty_dependent_rootwith the held current-epoch attester and PTC roots, andcurrent_duty_dependent_rootwith the next epoch's. Refetch what differs, and resubscribe when the attester schedule moved. - On a stream (re)connect, refetch everything, as Teku and Nimbus do, since events can be lost.
- The epoch refresh and the slot clock stay.
slot_clock.rs:1-6explains why a dropped event must never cost a duty. - ethlambda's node emits
headwith both dependent roots (docs/rpc.md:1023). It acceptshead_v2but never emits it (crates/blockchain/src/events.rs:296-311). It sends noheadwhile more than 32 slots behind the wall clock (docs/rpc.md:1023).
- On each event, compare
- Per-slot polling, as Lighthouse does. Re-request the current and next epoch's attester and PTC duties every slot, and compare roots. Lighthouse keeps the cost down by asking for a few validators first and fetching the rest only when the root moved (
duties_service.rs:1240-1266).
To decide
- Events, polling or both. Events cost nothing per slot, but they need an SSE client, reconnect handling and a choice of node. Polling needs nothing new. On an ethlambda node, though, each attester duties request "walk[s] every committee of the epoch, a full shuffle per request on mainnet" (
docs/rpc.md:308-309), so polling two epochs every slot costs the node two shuffles a slot per client. - Which node's events, with several configured. The first node, every node as Vero does, or the node that serves the duties.
- Which proposer root to track. The loop keeps v1 proposer duties. Their root moves on a boundary reorg that, since fulu, cannot change the proposers. Tracking the v2 root (
previous_duty_dependent_rootfor the head's epoch) avoids refetching for nothing. This ties in with #826, which proposes prefetching the next epoch's proposers. chain_reorg. Vero refetches on it. Once head events are compared it adds little, since every reorg that changes duties moves a dependent root.- The fork-epoch PTC root. Fix the node's dependent root for
GLOAS_FORK_EPOCHfirst; nothing on the client side can see the change without it.
Tests
- A mock node whose attester duties' dependent root changes between two slots of one epoch: assert the second slot attests from the new schedule.
- A head event carrying a new
previous_duty_dependent_root: assert this epoch's attester and PTC duties are fetched again, and that matching roots fetch nothing. - A stream that drops and reconnects: assert a full refetch.
- A changed lookahead schedule: assert the subnet subscriptions are sent again within the slot.
- Vorherrschende Sprache
- Rust
- Sterne
- 86
- Forks
- 34
- Ø Merge
- 9 T. 20 Std.
- Gemergte PRs (30 T.)
- 77
Entwicklungsumgebung
- Enthält ein Dockerfile oder eine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus lambdaclass/ethlambda
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
lambdaclass/ethlambda#850 ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
lambdaclass/ethlambda#777 · 1 Reaktion ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Run all gossip validation testsEvtl. wieder frei @dicethedev hat das vor 9 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
lambdaclass/ethlambda#725 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Handle malformed DB dataEvtl. wieder frei @dicethedev hat das vor 115 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
lambdaclass/ethlambda#529 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 6 Tagen
-
Document architectural choicesEvtl. wieder frei @dicethedev hat das vor 115 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
lambdaclass/ethlambda#521 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 6 Tagen
Alle Issues in lambdaclass/ethlambda
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
antithesishq/bombadil#473 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
bench/api.sh exec test fails with curl exit 52, and --ignore-failure still records the timingsOffenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
libracoder/kiri#669 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 5 Tagen
-
autofixer: follow-up
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
tursodatabase/turso#12217 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Declare the CMS schema library in the optional recipients extraEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offenarea:python in-progress
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
yhay81/pyropdf#1005 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag