Skip to content

feat(pq): --pq-timing-output, the PQ devnets' shared timing export - #942

Open
pablodeymo wants to merge 1 commit into
pq/aggregation-timing-metricsfrom
pq/timing-output
Open

pablodeymo wants to merge 1 commit into
pq/aggregation-timing-metricsfrom
pq/timing-output

Conversation

@pablodeymo

Copy link
Copy Markdown
Collaborator

Stacked on #941 (step 1, the Prometheus metrics): this PR's base is that branch, so the diff here is step 2 alone. Merge #941 first, then retarget this one to pq-devnet-1.

🗒️ Description / Motivation

pq-devnet-1 asks every client to expose its aggregation timings "in a common format" (notes, Timings). Lighthouse, Prysm, Teku and Lodestar already write one: schema 1 of Lighthouse's scripts/pq-measurement, a run directory of run.json plus zstd-compressed JSON-lines chunks that its plot.py draws side by side. ethlambda wrote nothing, so it is missing from those comparisons.

This is step 2 of #938: ethlambda beacon --pq-timing-output <DIR>.

What Changed

The export (crates/common/telemetry/src/pq_timing.rs, pq_timing/)

A new module in ethlambda-telemetry, next to the ClickHouse block telemetry and built the same way: a process-wide sink, off unless installed, whose emitters build nothing when it is off.

  • recorder.rs: the run directory. Events go onto a bounded queue (16,384); a pq-timing-writer thread serializes, compresses and writes. Chunks are finished after 64 MiB of events or five minutes, and a run keeps at most 8 GiB, removing the oldest first. run.json is rewritten whole whenever a chunk is finished and every 10 seconds. These are the other clients' numbers.
  • pq_timing.rs: the typed events (message_received, validated, Job::{started, finished, ready, outcome}, proposal_snapshot), the manifest, and testing::capture(), which records into memory for tests of the emit sites (behind a test-utils feature).
  • hardware.rs: the hardware block of run.json, from /proc and the cgroup v2 tree, so a container reports the CPU quota and memory limit it was given.

The emit sites

Event Where When
message_received p2p/src/beacon/pq.rs (triage) A PQ attestation or aggregate decoded, stamped at gossipsub delivery
validated p2p/src/beacon/verdict.rs (report) Its verdict, through the one function every verdict passes
proof_started, proof_finished rpc/src/beacon/pq_aggregation.rs (prove_committee) Around the leanVM call for one committee of an aggregator seat
candidate_ready, job_outcome rpc/src/beacon/pq_aggregation.rs (prove_seat) The aggregate is in the pool; or the committee was already proven, or left unproved
proof_started, proof_finished, candidate_ready, job_outcome blockchain/src/pq_attestation_packing.rs A block-proof merge, the complete packing, or a merge skipped
proposal_snapshot rpc/src/beacon/pq_proposal.rs Block production took its attestations and proof

GossipId gains pq_vote, set by triage when a receipt was recorded, so report can name the vote in its validated event without decoding anything again. triage now takes the GossipId instead of its arrival instant.

How ethlambda's steps map onto the schema

  • work: a seat's committee proof is committee. The merge ahead of the slot is initial (round 1) and the one at production is improvement (round 2), which runs only when the first cannot be used. Teku maps its two merges the same way.
  • reference_slot: the committee's own slot, and two slots before the block for a merge, as in the other clients.
  • validated.outcome: accepted, rejected, ignored, duplicate (already seen, or covered by an accepted aggregate) and queue_dropped (no validation permit free).
  • job_outcome: already_proven and unproved for committees, skipped for a merge with no time or no permit. A failed or late proof is already a proof_finished event, so it gets no second one.
  • timing.initial_merge_ns is 20 s on a 12-second slot: a block's packing starts with its payload build, 8 s into the slot before it.

The binary

  • --pq-timing-output <DIR> on beacon (cli.rs). run_node installs the run after leanVM, since the manifest names the prover backend, and wait_for_shutdown closes it. On a network that does not schedule PQ the flag logs a warning and records nothing.
  • bin/ethlambda/src/pq_timing.rs builds what the run says about itself from the resolved network and Config.

Also

  • lean_beacon_pq_timing_dropped_events_total{class}, for a node whose export falls behind.
  • payload_attributes::lookahead_start is pub, so the manifest's initial_merge_ns is derived from the function the chain actor uses.
  • Docs: a new docs/pq_timing.md (running, reading, the directory, every event and field), and pointers from cli.md, metrics.md, beacon_pq.md and CLAUDE.md.

Dependencies

zstd 0.13.5 and zstd-safe 7.4.1, the safe wrappers over the zstd-sys RocksDB already builds. Both were resolved with the cooldown resolver: 0.13.6 and 7.4.2 were published three days ago and need a zstd-sys that is just as new.

Cargo.lock gains those two packages and the new edges of the workspace crates, 22 lines, and nothing else. A plain re-resolve also re-pointed packages this change has nothing to do with (quinn, quinn-udp and hyper-util from socket2 0.5.10 to 0.6.3, iana-time-zone to another windows-core). I left those where they were; cargo metadata --locked accepts the result.

Correctness / Behavior Guarantees

  • Off by default, and free when off. Every emitter returns after one atomic load, before building its fields.
  • Never blocks. A full queue drops the event and counts it, in run.json's recorder_status.dropped and in the new counter. The gossip path, the seat prover and the merge never wait on the disk.
  • A write failure stops the export, not the node. It is logged, recorded in run.json when that is still possible, and later events are discarded.
  • A killed node loses little. The open chunk is flushed every 10 seconds, so its .partial decodes up to the last flush. A normal stop finishes and lists it.
  • No proof or signature is exported: a proof is named by its SHA-256.

One behaviour change outside the export: the seat prover's loop now also logs The PQ aggregate deadline passed with committees left to prove when a proof that ran past the deadline leaves other committees unproved. It used to log that only when the deadline had passed before a proof started.

Not ported: the other clients' --pq-measurement observer mode (step 3 of #938). A node with no aggregators or proposers records receipts and verdicts and no proof events. ethlambda's own attestations and aggregates are not in the export, since gossip never hands a node its messages back.

Tests Added / Run

  • Recorder (5): a closed run's chunk is listed and readable; a full queue drops and counts without waiting; chunks rotate by size and the oldest are evicted; the open chunk is flushed with every status; an existing run directory is refused.
  • Events (6): nothing is built when no run is recorded; the manifest carries what a report reads; a receipt is stamped at arrival and tied to its verdict; a job's events share its fields; a run on disk reads back from its listed chunk; a proof's id is its SHA-256.
  • Hardware (3), including the tightest cgroup limit among a cgroup's ancestors.
  • Emit sites, each through an in-memory capture:
    • p2p: a vote's receipt and verdict, for an attestation and an aggregate, and nothing for a slashing; nothing noted when no run is recorded.
    • rpc: seat 0's proof_started, proof_finished, candidate_ready and seat 1's already_proven, in the test that already drives both seats.
    • blockchain: a skipped merge's job_outcome under each round.
  • Binary (2): the slot's timing on a 12-second slot; the flag parses and is off by default.

The step-1 vote tests in p2p now run one at a time: they assert exact sample counts, which a second test triaging votes in parallel would break.

Run on the final tree: make lint clean, make cooldown-check clean, cargo metadata --locked accepted, make test 4,222 passed, 0 failed, 97 ignored.

Compatibility with Lighthouse's plot.py

  • Parsing: checked. I wrote an eight-slot run through the public API (receipts, verdicts, committee proofs, merges, snapshots) and ran the unmodified script's read_records and summarize on it. It built the production cohort, placed committee proofs and merge R1 at the offsets they were emitted at, counted the snapshots by outcome, and matched every receipt to its verdict.
  • Drawing: not checked. The chart step needs matplotlib 3.10 and so Python 3.10 or newer, which the machine this was developed on does not have. From the script's source, it reads only the cohorts above plus manifest keys this export writes (timing, hardware, prover_cpu_profile, prover_threads, recorder_status). Running it is the first item below.

Not verified

  • plot.py renders an ethlambda run, next to a Lighthouse run from the same devnet.
  • A live node: the startup and shutdown wiring in main.rs is compiled and its parts are tested, but no node has been run with the flag, against real leanVM or a devnet.

Related Issues / PRs

✅ Verification Checklist

  • Ran make fmt — clean
  • Ran make lint (clippy with -D warnings) — clean
  • Ran make test (test-consensus plus test-node, at release-fast) — all passing

pq-devnet-1 asks every client for its aggregation timings in a common
format. Lighthouse, Prysm, Teku and Lodestar write one: schema 1 of
Lighthouse's scripts/pq-measurement, a run directory holding run.json and
zstd-compressed JSON-lines chunks, which its plot.py draws side by side.
ethlambda wrote nothing. Step 2 of #938.

`ethlambda beacon --pq-timing-output <DIR>` records, on a network that
schedules PQ:

- message_received and validated: every PQ attestation and aggregate
  that decodes, stamped at gossipsub delivery, and the verdict it got
  (p2p's beacon::pq::triage and verdict::report).
- proof_started, proof_finished, candidate_ready, job_outcome: each
  committee proof of an aggregator seat (rpc's seat prover), and each
  merge of a block's attestation proofs, `initial` ahead of the slot and
  `improvement` at production (pq_attestation_packing).
- proposal_snapshot: what block production built the block with.

The export is ethlambda_telemetry::pq_timing: a process-wide session
whose emitters return after one atomic load when no run is recorded. An
event goes onto a bounded queue; a writer thread serializes, compresses
and rotates chunks (64 MiB or five minutes, 8 GiB kept), and a full queue
drops the event and counts it in run.json and in
lean_beacon_pq_timing_dropped_events_total. The open chunk is flushed
every ten seconds, so a killed node's .partial still decodes.

run.json describes the run: client and leanVM revision, prover threads,
hardware (from /proc and the cgroup tree), and where in a slot this node
does each step. The node closes the run at shutdown.

Adds zstd 0.13.5 and zstd-safe 7.4.1, resolved under the publish-age
cooldown, over the zstd-sys RocksDB already builds. Cargo.lock gains
those two packages and telemetry's edges, nothing else: a plain
re-resolve would also have moved quinn and hyper-util to another socket2.

Not ported: the other clients' --pq-measurement observer mode.

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