Skip to content

fix(beacon): give the gloas fork epoch's PTC duties their own dependent root - #849

Open
MegaRedHand wants to merge 3 commits into
mainfrom
fix/ptc-fork-epoch-dependent-root
Open

MegaRedHand wants to merge 3 commits into
mainfrom
fix/ptc-fork-epoch-dependent-root

Conversation

@MegaRedHand

@MegaRedHand MegaRedHand commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

🗒️ Description / Motivation

At the gloas fork epoch F, the validator client can keep a stale payload timeliness committee (PTC) schedule for all of F. Some validators then vote in a slot where they are not on the committee and miss the slot where they are. This happens once per network, at the fork, so it still matters for Hoodi and mainnet.

The spec treats this epoch specially. F's PTC is computed at the fork, from the effective balances the last pre-gloas epoch ends with, so it can change until the last slot before the fork. beacon-APIs (apis/validator/duties/ptc.yaml) therefore says:

  • for epoch == GLOAS_FORK_EPOCH, dependent_root is the block root at compute_start_slot_at_epoch(epoch) - 1, or the genesis block root on underflow;
  • "Duties for this epoch are not available before the fork."

What we did instead:

  1. Node: used the generic rule, compute_start_slot_at_epoch(epoch - 1) - 1, for F too. Asked about F during F-1, it advanced a copy of the pre-gloas head to F and served a committee computed without any of F-1's later blocks.
  2. Client: fetched F's duties as lookahead at slot 0 of F-1, and fetched them again at slot 0 of F. DutiesService::refresh_ptc keeps a held schedule while its dependent root is unchanged, and the wrong root never changed, so the early committee stayed in use for the whole epoch.

Lighthouse (unstable @ 11813cfb) already follows the spec:

  • beacon_node/http_api/src/ptc_duties.rs:44-50 refuses F with a 400 until the tolerant current epoch reaches it;
  • beacon_node/beacon_chain/src/beacon_chain.rs:1782-1793 takes F's dependent root from the block at start_slot(F) - 1.

Against a Lighthouse node, our client's lookahead fetch got that 400 and logged a misleading "Payload committee duties fetch failed; this client may miss its votes".

What Changed

  • crates/net/rpc/src/beacon/ptc.rs
    • F's dependent slot is now compute_start_slot_at_epoch(F).saturating_sub(1). When gloas starts at genesis, that saturates to the genesis block. Every other epoch keeps the generic rule.
    • F is refused with a 400 ("PTC duties for the gloas fork epoch are not available until the fork") until its first slot starts by the wall clock, with MAXIMUM_GOSSIP_CLOCK_DISPARITY (500 ms) of tolerance. This reuses gossip::is_future_slot, and only applies while the head is still before the fork.
    • The handler reads the clock once and passes now_ms to ptc_duties, so the 500 ms edge is testable.
    • Pre-gloas epochs still answer 200 with no duties, now with a comment saying why.
    • Four new tests, and shared fulu_state() and everyone() test helpers.
  • crates/validator/src/lib.rs: refresh_ptc skips the fork epoch while epoch < target, so F is fetched at its own first slot, with F+1 as the lookahead. the_committee_schedule_is_fetched_for_gloas_epochs_only asserted the old behaviour and is rewritten.
  • crates/validator/src/lib.rs, duties.rs (second commit): retry_missing_ptc runs after each slot's duties, and DutiesService::holds_ptc reports whether a schedule is held.
  • crates/validator/src/beacon_node/mock.rs: the mock records which epochs were requested (ptc_requested_epochs()). ptc_call_count() is kept.
  • crates/validator/src/duties.rs: doc comments only.
  • docs/rpc.md, docs/cli.md: the fork epoch's 400, its dependent root, and when the client fetches it.

Correctness / Behavior Guarantees

  • Every epoch except F is unchanged on both the node and the client. That covers the dependent root, the duties served, and when they are fetched.
  • At slot 0 of F, the node reports the last block of F-1 as F's dependent root. That root differs from anything the client could have held, and the client no longer holds an early F schedule anyway.
  • Gloas at genesis: the refusal also requires the head to be before the fork. This differs from Lighthouse's clock-only check: with gloas at epoch 0, a clock-only check would refuse epoch 0 before genesis, although its committee is already in the genesis state. On a network that forks later the extra condition changes nothing.
  • Retry for a missing schedule: F's schedule comes from a single fetch at slot 0 of F, where every other epoch gets two chances (the lookahead and the current fetch). So after each slot's duties, the duty loop now fetches the current epoch's PTC schedule again when it is a gloas epoch and none is held. Each retry is bounded by the end of the slot, so it never delays a duty. It only runs once the epoch's refresh has succeeded, since a failed refresh is retried every slot anyway. An empty schedule counts as held. Failed retries log at debug, since refresh_ptc has already warned. Without this, a failed fetch at slot 0 of F (for example from a beacon node whose clock is more than 500 ms behind the client's) would have cost every PTC vote in F.

Tests Added / Run

  • Node:
    • F's dependent root is the block at start_slot(F) - 1, as is F+1's, while a pre-gloas epoch keeps the old rule.
    • At the boundary, F is a 400 with the clock in F-1's last slot and a 200 from F's first slot.
    • Exactly 500 ms before F starts is served; one millisecond earlier is a 400.
    • A chain with gloas at genesis is served.
  • Client: with gloas at epoch 4, the refresh at epoch 3 makes no PTC request, and the refresh at epoch 4 requests [4, 5].
  • Retry: a failed fetch is retried and then held, a held schedule (an empty one included) is not fetched again, and a pre-gloas epoch is never asked.
  • The tests catch the bug: with each part of the fix turned off in turn, the matching new test fails.
  • Commands:
    • cargo test -p ethlambda-rpc -p ethlambda-validator --profile release-fast: 504 rpc lib, 6 http_servers, 8 test_driver_e2e, 624 validator lib; 0 failed.
    • cargo clippy -p ethlambda-rpc -p ethlambda-validator --all-targets -- -D warnings: clean.

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt: clean
  • Ran make lint (clippy with -D warnings): ran for ethlambda-rpc and ethlambda-validator only, the two crates touched, and it is clean
  • Ran make test (test-consensus plus test-node, at release-fast): ran those two crates' tests only, all passing

…nt root

The payload timeliness committee of GLOAS_FORK_EPOCH is computed at the
fork, by upgrade_to_gloas, from the effective balances the last pre-gloas
epoch ends with. beacon-APIs (apis/validator/duties/ptc.yaml) therefore
gives that epoch its own dependent root, the block root at
compute_start_slot_at_epoch(epoch) - 1 (the genesis block root on
underflow), and says its duties are not available before the fork.

The node used the generic rule, compute_start_slot_at_epoch(epoch - 1) - 1,
for every epoch, and asked about the fork epoch during the epoch before it,
served a committee from the pre-gloas head advanced to the fork, missing
every block still to come in that epoch. The validator client fetched it
then as lookahead, and at the fork epoch's first slot fetched it again, but
DutiesService keeps a held schedule while its dependent root is unchanged.
The wrong root never changed, so the client kept the stale early committee
for the whole first gloas epoch.

Node: the fork epoch's dependent slot is now its start slot minus one, and
the epoch is refused with a 400 until its first slot has started by the
wall clock, allowing MAXIMUM_GOSSIP_CLOCK_DISPARITY, while the head is
still before it (so a chain with gloas at genesis is still served before
genesis). Pre-gloas epochs still answer 200 with no duties.

Validator client: the fork epoch's duties are no longer fetched as the
previous epoch's lookahead, which against Lighthouse drew a 400 and a
misleading "may miss its votes" warning. They are fetched at the fork
epoch's first slot, with the next epoch as the lookahead.

Lighthouse does the same: it refuses the fork epoch until the tolerant
current epoch reaches it, and takes its dependent root from the block at
the fork's start slot minus one.
…duties

The gloas fork epoch's payload timeliness committee is now fetched once,
at the fork epoch's first slot, since a node cannot know it before the
fork. refresh_ptc logs a failed fetch and moves on, and nothing retried
it within the epoch, so one failed request there left the client with no
PTC duties for the whole first gloas epoch. Every other epoch has two
chances, the lookahead and the current fetch.

After each slot's duties, the duty loop now fetches the current epoch's
schedule again when it is a gloas epoch and none is held, bounded by the
end of the slot so it never delays a duty. It runs only once the epoch's
refresh has succeeded, since a failed refresh is retried every slot
anyway. A schedule that came back empty counts as held. Failed retries
log at debug, as refresh_ptc has already warned.
@MegaRedHand

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

Copy link
Copy Markdown

AI security review: 0 finding(s) to check

Reviewed by Opus, GPT, Kimi, GLM, DeepSeek. A judge model checked every one of the findings against the code.

No findings to check.

Duplicates folded into another finding: 1
# Same as Finding Found by Where
M3 M2 Fork epoch's PTC schedule is fetched once at slot 0 of F and never re-checked, although its dependent block is the one j Opus crates/validator/src/lib.rs:1281
Pre-existing (real, but already on the base branch): 2
# Finding Category Severity (reported → judged) Found by Where Judge's reason
M2 Revalidate held fork-epoch duties after their dependency changes logic medium Opus, GPT, Kimi, DeepSeek (4/5) crates/validator/src/lib.rs:1311 Both the boundary-reorg claim and the other reports' late-block variant hold: successful schedules are not fetched again during F, so changed dependent roots are never compared. The late-head variant overlaps M1's server-side scenario, whereas the main issue here is missing client revalidation. Base already used epoch-only refreshes with no intra-epoch reorg-refresh path.
M1 Fork-epoch PTC duties can be computed and cached from a stale head consensus/state high → medium GLM (1/5) crates/net/rpc/src/beacon/ptc.rs:208 The stale-duty scenario is reachable, but base already advanced lagging pre-fork heads and cached successful responses without intra-epoch revalidation. The new wall-clock guard does not prevent this after F starts. Returning head_root is valid for genuinely skipped slots; the problem arises when subsequently imported blocks change committee inputs. Missed participation is supported, but broader f

Cost of this review: ~$2.98 of a $30 budget (estimated from token counts).

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