Skip to content

feat(pq): expose aggregation timings as Prometheus metrics - #941

Open
pablodeymo wants to merge 1 commit into
pq-devnet-1from
pq/aggregation-timing-metrics
Open

pablodeymo wants to merge 1 commit into
pq-devnet-1from
pq/aggregation-timing-metrics

Conversation

@pablodeymo

Copy link
Copy Markdown
Collaborator

🗒️ Description / Motivation

pq-devnet-1 asks every client to expose its aggregation timings: committee proof, recursive merge and aggregate arrival (notes, "Client requirements", Timings), and ethPandaOps asked for them again during the run. ethlambda measured the first two but only wrote them to the log, and nothing recorded where in the slot a vote arrived. A dashboard had nothing to plot for ethlambda, and comparing it with another client meant scraping logs.

This is step 1 of #938: Prometheus metrics on the node. Steps 2 and 3 (the --pq-timing-output export the other clients share, and the observer mode) are not in this PR.

What Changed

Eleven series on the node's /metrics, each defined in the crate that measures it. All are registered on first use, so a network that does not schedule PQ shows none of them.

Metric Labels Measures
lean_beacon_pq_committee_proof_seconds position leanVM time to prove one committee's aggregate
lean_beacon_pq_committee_proof_ready_offset_seconds position how far into its slot the proof was ready
lean_beacon_pq_committee_proof_signatures signatures the proof proves
lean_beacon_pq_committee_proof_size_bytes proof size
lean_beacon_pq_committee_proofs_total position, outcome committees a seat was due to prove: proved, late, failed, already_proven, unproved
lean_beacon_pq_merge_seconds phase leanVM time to merge a block's attestation proofs
lean_beacon_pq_merge_children child proofs the merge folded
lean_beacon_pq_merged_proof_size_bytes merged proof size
lean_beacon_pq_merges_total phase, outcome packings with several proofs to merge: merged, failed, late, skipped
lean_beacon_pq_proof_verification_seconds kind verifying one aggregate's proof or one block's merged proof
lean_beacon_pq_gossip_arrival_offset_seconds kind how far into its vote's slot an attestation or aggregate arrived

By area:

  • Committee proofs (crates/net/rpc/src/beacon/pq_aggregation.rs, crates/net/rpc/src/metrics.rs). prove_seat observes every proof it makes, late ones included, under the aggregator seat's position, and counts the seat's committees by outcome once its pass ends. These are the numbers the Finished proving this seat's PQ aggregates log line already carried.
  • Merges (crates/blockchain/src/pq_attestation_packing.rs, crates/blockchain/src/metrics.rs). pack_attestations observes a merge when it ends, in time or not, under phase: ahead for the packing started ahead of the slot, production for one block production runs itself. The outcome counter is incremented where the packing already decided between the merged proof and the one-committee fallback.
  • Verification (crates/blockchain/state_transition/src/beacon/gossip/pq.rs, stf/pq.rs, metrics.rs). Times stark.VerifyAggregates at its two call sites: an aggregate's proof in the gossip rules (gossip, and a validator client's own aggregates through the Beacon API), and a block's merged proof in process_stark. A block without attestations is not a sample.
  • Arrival (crates/net/p2p/src/beacon/pq.rs, crates/net/p2p/src/metrics.rs). triage observes every PQ attestation and aggregate that decodes, from the start of the vote's own slot, at the instant gossipsub delivered it. The kind values are the ones lean_beacon_gossip_validation_seconds uses (beacon_attestation, beacon_aggregate_and_proof).
  • Docs. A "PQ Aggregation Timing" section in docs/metrics.md with the table, the buckets and how to read each group, and a pointer from docs/beacon_pq.md.
  • Test helper. ethlambda_metrics::series_value reads one series from the default registry by its exposition name.

Differences from the names #938 suggested

  • The merge label is phase, not round: ethlambda's two merges are "ahead of the slot" and "at production", not two rounds of one job.
  • Verification is lean_beacon_pq_proof_verification_seconds{kind} rather than lean_beacon_pq_aggregate_verify_seconds, so it also covers a block's merged proof, which nothing timed before (process_stark is outside the STF phases).
  • Proof size is two metrics, committee and merged: the two are measured in different crates, and one name cannot be registered twice.
  • lean_beacon_pq_merges_total is new. The duration alone cannot show a merge that missed its budget and left the block with one committee's attestation.

Correctness / Behavior Guarantees

  • No behaviour changes. prove_committee returns a Duration where it returned milliseconds, and the packing's fall_back closure takes the merge outcome it counts. Whether a proof is on time is decided before its metrics are recorded, as before.
  • The cost is a handful of histogram observations per proof, merge, verification or received vote. Arrival is the only one on a hot path: one observation per decoded PQ attestation or aggregate, in the p2p actor.
  • Label sets are bounded: position is 0 to 3, the rest are fixed strings.

Things a reader of the dashboards should know:

  • Proving time includes waiting. leanVM makes one proof at a time and the wait happens inside it, so committee_proof_seconds includes any wait for a merge or another proof already running.
  • Bucket bounds follow a 12-second slot. The offset histograms use the seat cutoffs (4.8 to 6.6 s) and broadcast times (7.2 to 9.0 s). A shorter slot gets coarser resolution.
  • Arrival covers every vote that decodes, whatever validation then makes of it, and none of this node's own (gossip never hands a node its messages back).
  • A seat that wakes after its broadcast time still only logs No time left to prove this seat's PQ aggregates. Its committees are not counted as unproved, because counting them needs the head state that path does not read.

Tests Added / Run

Added, each checked to fail when its metric call is removed:

  • a_seats_proving_pass_is_timed_and_counted (rpc): drives prove_seat for seats 0 and 1 on a PQ state with collected signatures. Seat 0 proves one committee: proved is 1, the proof is timed once, ready between 5.0 and 7.2 s into the slot, with the committee's signature count. Seat 1 finds it already_proven and times nothing.
  • a_merge_with_no_time_left_is_counted_as_skipped_by_phase (blockchain): two aggregates to merge and a slot long past, under both phases.
  • a_decoded_votes_arrival_is_recorded_under_its_topic_kind and a_votes_arrival_is_measured_from_its_own_slot (p2p): one sample per decoded attestation and aggregate, none for a slashing or an undecodable message; the offset is from the vote's own slot and zero for a vote ahead of it.
  • process_stark_checks_the_attesters_signatures and a_pq_aggregate_needs_an_aggregator_its_signature_and_its_proof (state transition) now also assert their verifications were timed, the refused proofs' too.
  • a_series_is_read_by_its_exposition_name (metrics): the helper.

Not covered by a test:

  • The merge duration, children and size histograms, and the merged, failed and late outcomes. A test that runs a real merge takes the global merge permit, and an_abandoned_packing_does_not_take_the_merge_permit asserts that permit is free, so the two would race.
  • Nothing here ran against real leanVM or a live devnet: the tests prove with the reference backend, so the durations they record are not realistic. The first devnet run on this branch is what will show whether the buckets sit where the values fall.

Run on the final tree: make lint clean; make test 4,204 passed, 0 failed, 97 ignored.

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 (committee
proof, recursive merge, aggregate arrival). The node measured the first
two but only wrote them to the log, and nothing recorded where in the
slot a vote arrived, so a dashboard had nothing to plot for ethlambda.
Step 1 of #938.

On /metrics, all lazily registered, so a network without PQ shows none:

- Committee proofs, by aggregator seat (rpc's seat prover): leanVM's
  proving time, how far into the slot the proof was ready, its
  signatures and size, and lean_beacon_pq_committee_proofs_total by
  outcome (proved, late, failed, already_proven, unproved).
- Block-proof merges, by phase (ahead of the slot, at production):
  duration, children and merged size when the merge ends, in time or
  not, and lean_beacon_pq_merges_total by outcome (merged, failed, late,
  skipped).
- lean_beacon_pq_proof_verification_seconds, by kind: an aggregate's
  proof in the gossip rules, a block's merged proof in process_stark.
- lean_beacon_pq_gossip_arrival_offset_seconds, by topic kind: every
  attestation and aggregate that decodes, from the start of its own
  slot.

No behaviour changes: prove_committee returns a Duration where it
returned milliseconds, and the packing's fall_back closure takes the
merge outcome it counts.

ethlambda_metrics::series_value reads one series from the default
registry by its exposition name, for the tests that check a path left
its metrics behind.

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