Skip to content

perf(validator): fetch the next epoch's payload committee after the slot's duties - #908

Merged
MegaRedHand merged 1 commit into
pq-devnet-0from
pq/ptc-lookahead-after-duties
Nov 26, 2026
Merged

MegaRedHand merged 1 commit into
pq-devnet-0from
pq/ptc-lookahead-after-duties

Conversation

@MegaRedHand

@MegaRedHand MegaRedHand commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

🗒️ Description / Motivation

On pq-devnet-0, every epoch's first slot publishes its attestations at 3.2–4.2 s, about 1.5 s later than other slots. The client's log shows why:

slot 23744 (first of epoch 742)  +0.09s  Attester duties updated epoch=743
                                 +2.15s  Payload timeliness committee duties updated epoch=743
                                 +3.98s  Published attestations slot=23744

The same ~2 s gap shows in every epoch of the 40 minutes sampled.

The request itself is slow. The epoch refresh runs at the first slot, before its duties and normally before the epoch's first block arrives. It asks for the next epoch's PTC duties (E+1) while the node's head state is still in E−1.

  • A gloas state holds the committees of its own epoch and the two around it (ptc_window), so E+1 is out of its reach.
  • rpc/src/beacon/ptc.rs therefore clones the head state and runs process_slots through two epoch transitions.
  • Sampled per thread on geth-1 at slot 23808, one beacon blocking thread used 2.05 s of CPU in the slot's first 2.2 s. The validator client sat idle until +2.2 s and published at +3.77 s.

What Changed

  • crates/validator/src/lib.rs
    • refresh_ptc fetches its own epoch's schedule only. At the first slot the head is in E−1, so E is in its window, and the node reads it straight from the head state.
    • New fetch_ptc_lookahead fetches E+1 after the slot's duties, next to retry_missing_ptc and bounded by the slot's end like it.
      • By then the head has normally entered E, and the node reads E+1 off its state.
      • Once held, later slots ask nothing. A failed fetch is tried again next slot. If every attempt fails, E+1's own refresh still fetches it, as before.
      • The gloas fork epoch's committee is still fetched by its own refresh, since no node knows it before the fork.

Correctness / Behavior Guarantees

Tests Added / Run

  • the_next_epochs_committee_is_fetched_after_the_slots_duties: asked until held, then never again. Never the fork epoch's, and nothing before gloas.
  • the_committee_schedule_is_fetched_for_gloas_epochs_only updated: the fork epoch's refresh asks for its own epoch only.
  • make fmt, make lint clean.
  • Local A/B devnet: see below.

Related Issues / PRs

Local devnet (all four PRs together, A/B)

Run with ethereum-package pq (7a29d69e), PQ at genesis, on an arm64 Mac:

Five epochs ran, and the three nodes justified and finalized together (just=3 fin=2 at slot 132, one head). Justification needs more than 107 of the 160 votes, so the new client's streamed votes counted. There were no warnings on any node beyond startup notices, and zero signing, attestation, PTC or envelope failures on either client.

new baseline
vote delay (per vote) p50 / p90 0.49 s / 0.88 s 0.70 s / 1.05 s
submissions per slot (median) 2 1
first PTC publish minus last attestation, p50 (min) +0.29 s (+0.03 s) +0.01 s (−0.61 s)
envelope after its block, p50 / mean / max 0.05 / 0.11 / 0.41 s (44 proposals) 0.15 / 0.21 / 0.69 s (55)
next epoch's PTC duties fetched after the slot's duties, +6.2–6.5 s at the refresh, +0.14–0.18 s

On this small network each client signs only about two votes per slot, so the streaming gain is smaller than on pq-devnet-0's twenty. The node there answers the early PTC request in 0.15 s, so the 2 s state advance only shows at pq-devnet-0's 10,000 validators. Both effects are expected to be larger on the real devnet.

…lot's duties

The epoch refresh asked for the next epoch's payload committee duties at the
epoch's first slot, before its duties and normally before its first block,
while the node's head state was still in the previous epoch. A gloas state
holds the committees of its own epoch and its neighbours (ptc_window), so
the epoch after next is out of reach and the node advanced a copy of the
head state through two epoch transitions to answer: about 2 s of a core on
pq-devnet-0 (measured at slot 23808: one blocking thread busy for 2.05 s,
the validator client idle until +2.2 s). Every epoch's first slot published
its attestations at 3.2-4.2 s.

The refresh now fetches its own epoch's schedule only, and the lookahead is
fetched after the slot's duties, bounded by the slot's end, when the head
has normally entered the epoch and the node reads it off its state. Held
once fetched; a failed fetch is tried again next slot. The gloas fork
epoch's committee is still fetched by its own refresh.
@MegaRedHand
MegaRedHand merged commit c798cb6 into pq-devnet-0 Nov 26, 2026
11 checks passed
@MegaRedHand
MegaRedHand deleted the pq/ptc-lookahead-after-duties branch November 26, 2026 22:46
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