Repository navigation
feat(pq): pq-devnet-2 — ERC-8517 PQ keys, X_COMMITTEE_COUNTS rotation, eth.telemetry/0.4 events - #961
Open
pablodeymo wants to merge 8 commits into
Open
pablodeymo wants to merge 8 commits into
pablodeymo wants to merge 8 commits into
Conversation
… eth.telemetry/0.3 events pq-devnet-2 (notes.ethereum.org/@ethpandaops/pq-devnet-2) relaunches pq-devnet-1 with three changes every client has to carry. ERC-8517 key derivation. PQ keys no longer derive from the BLS signing key. Each account's seed comes from a BIP-39 seed at the all-hardened path m/5326/3600/<chain_id>/<role>/<account> (HMAC-SHA512 under "Ethereum PQ seed", then HKDF-Expand-SHA256 with "leanXMSS key" and, for validators, "VRF key"). Out-of-range seeds, chain ids, roles and accounts are refused, never reduced into range. The validator client loads seeds from ERC-8519 v5 "leanxmss" keystores, from --pq-mnemonic with an account range, or from --pq-seeds-file, and refuses any whose chain id disagrees with the beacon node's DEPOSIT_CHAIN_ID. `ethlambda pq-keys` takes --chain-id and --role and can write the leanXMSS tree caches. The devnet's check values for accounts 0 and 1 are pinned as tests. X_COMMITTEE_COUNTS (consensus-specs #5879). The PQ committee count per slot rotates through the configured list, eight epochs a stage. The list is a Config field stored in a Metadata row of its own, so DB_VERSION stays 10; a resume refuses a changed list. A PQ-at-genesis network is checked at startup for enough validators to fill every stage, and gossipsub's expected aggregators follow the active stage. PQ measurement telemetry. --telemetry-events=pq on `beacon` and `validator` exports the pq.* events of eth.telemetry/0.3 over OTLP Logs (grpc or http/protobuf, configured through OTEL_* variables), with pq_measurement_* exporter-health counters on /metrics.
…istry 0.9.0) The measurement spec moved its wire from eth.telemetry/0.3 to 0.4 on Dec 2 and xatu's sentry takes both (ethpandaops/xatu#1021). 0.4 separates a duty's nominal publication target from the cutoff at which a client gives the duty up: - pq.duty_scheduled names its target as scheduled_publish_unix_ns, for both kinds (was broadcast_unix_ns and proposal_unix_ns). - pq.duty_completed has no `late` flag. Whether a publication was late is the analysis's subtraction, not the client's. - outcome=missed_deadline carries deadline_unix_ns, the cutoff the abandoning path ran against, and no other outcome does. The beacon node's is a committee seat's broadcast time, where it stops proving and discards a proof finished later. The validator client's is the slot's attestation time, where a block not yet handed to the node is abandoned; it is recorded where the budget is set (`propose`), since the proposal service holds only a monotonic deadline. `duty::missed_deadline(key, cutoff)` is now the one way to record an abandonment, so the cutoff cannot be left out. pq.context documents each role's cutoff policy, as the spec asks. The lifecycle test fed hand-written schedules and workloads in shapes no call site builds (and the spec's schema refuses), so it could not notice a record drifting from the contract. It now announces the context a beacon node does (`context_data`, split out of `start`) and uses each call site's shapes, covers an abandoned duty, and with PQ_EVENTS_DUMP writes its records as normalized JSON for the spec's schema and tools.
…tes/*/validators (#971) ## Motivation `validators_response` (`GET` / `POST /eth/v1/beacon/states/{state_id}/validators`) filtered the state's validator registry with `ids.iter().any(...)`, an $O(N \times M)$ linear scan. On `pq-devnet-2` (65,536 validators, ~3,200 validator keys per host), every PQ validator pubkey in memory shares the same 16-byte `[0u8; 16]` prefix, and `HttpBeaconNode::validator_indices` sends two `POST` requests (`6,400` 48-byte IDs and `3,200` 32-byte IDs). A single `validator_indices` call (used during VRF startup, doppelganger checks, and duty resolution) performed ~629 million 48-byte comparisons synchronously on an Axum worker thread. ## Changes - Index `request.ids` into `HashSet<ValidatorIndex>` and `HashSet<BlsPubkey>` up front, reducing filtering from $O(N \times M)$ to $O(N + M)$ while preserving exact `400 Bad Request` validation, deduplication, and registry-order output (with zero heap allocation when `ids` is empty). - Add unit test `pq_registry::post_deduplicates_mixed_id_forms_and_keeps_registry_order` covering mixed 32-byte, 48-byte, index, duplicate, and unknown IDs over `POST`.
…state file (#970) Port of #939 (`84e36a7f`) onto `pq-devnet-2` (refs #936). ## Motivation On `pq-devnet-2` (65,536 validators, ~3,200 keys per host), giving up on `--vrf-state-url` after 2 minutes (`REGISTRY_ATTEMPTS = 60` × `2s`) or after a single transient read error on the first `.vrf` record forces every validator key on the host to hash its full VRF tree sequentially (~100s per key = tens of hours of missed proposals on a fresh start). ## Changes - **Index lookup (`resolve_indices`):** retries every `REGISTRY_RETRY` (2s) without a 2-minute cap until the beacon node answers and knows at least one of the validator's keys (runs on the dedicated `pq-vrf-trees` thread, so it never blocks attestations, aggregations, or PTC votes). - **Record reads (`read_vrf_state`):** retries each `.vrf` record read up to 5 times with doubling backoff (~30s total) before falling back to hashing. - **Logging:** collapses per-key warnings into a single summary `warn!` counting misses by reason (`no_index`, `no_record`, `unreadable`, `refused`, plus `first_refusal`). - **Docs & tests:** updates `docs/beacon_pq.md` and ports the 4 unit tests from #939.
…istry 0.10.0) (#972) ## Summary Upgrades PQ telemetry (`--telemetry-events=pq`) on **`pq-devnet-2`** from `eth.telemetry/0.4` (registry `0.9.0`) to **`eth.telemetry/0.5` (registry `0.10.0`)** per [`ethDreamer/pq-measurement-spec` `guides/migrating-to-wire-0.5.md`](https://github.com/ethDreamer/pq-measurement-spec/blob/main/guides/migrating-to-wire-0.5.md): - **Envelope & OTLP mapping (`crates/common/telemetry/src/pq_events/{mod.rs,otlp.rs}`):** - `schema_version` bumped to `"eth.telemetry/0.5"` and `InstrumentationScope` version to `"0.10.0"`. - Updated `error.type` projection to match wire `0.5`'s `tools/otlp.py` rules (`pq.aggregate_publication` checks `result.outcome == "failed"`; `pq.aggregate_processed` checks `pool_outcome == "error"` -> `pool_reason`, `outcome` in `{"rejected", "error", "dropped", "decode_error"}` -> `reason`, and `admission.outcome == "rejected"` -> `admission.reason`; ordinary cancellation and late-discard outcomes omit `error.type`). - `decode_records_request` accepts an optional display-only string `body` while rejecting structured `body` values. - Updated `pq.context` `implementation` string and `publish` hook description (`result.stage = "network"`). - **`pq.aggregate_publication` (`crates/common/telemetry/src/pq_events/gossip.rs`, `crates/net/p2p/src/swarm_adapter.rs`):** - Renamed from `pq.aggregate_published`; emits `invoked`, `result: { stage: "network", outcome, at, reason }`, and `closed: { at, cause: "resolved" }`. - Maps `PublishError::Duplicate` to `outcome = "duplicate_suppressed", reason = "duplicate"`, `PublishError::NoPeersSubscribedToTopic` to `outcome = "failed", reason = "no_peers"`, and `MessageTooLarge | SigningError | TransformFailed` to `outcome = "failed", reason = "encode_error"`. - **`pq.aggregate_processed` (`crates/common/telemetry/src/pq_events/gossip.rs`, `crates/net/p2p/src/beacon/pq.rs`):** - Replaced `queued` / `validation_outcome` / `terminal_stage` with `submitted`, `admission: { outcome, at?, reason? }`, `outcome`, `decision_stage` (omitted when `outcome == "not_reached"` on rejected queue admission), optional `pool_reason`, and `closed: { at, cause: "resolved" }`. - Mapped `OutsideEpochWindow | Finalized` gossip ignores to `("ignored", "deadline")` (`"expired"` was removed from `pq.aggregate_processed`'s `0.5` `outcome` enum). ## Verification - Validated all 29 normalized records and all 9 raw HTTP OTLP protobuf batches from `crates/common/telemetry/tests/pq_lifecycle.rs` directly against `ethDreamer/pq-measurement-spec@efdd060`: - `schemas/pq.schema.json` + `schemas/envelope.schema.json` - `tools/metadata.py` (`check_metadata` + `check_metadata_sequence`, 0 unresolved receipts/contexts) - `tools/otlp.py` (`decode()` on raw Rust `ExportLogsServiceRequest` protobuf bytes) - `cargo fmt --check` - `cargo clippy --workspace --all-targets -- -D warnings` - `cargo test -p ethlambda-telemetry` & `cargo test -p ethlambda-p2p --lib beacon::pq`
## Motivation
pq-devnet-2's spec sheet names leanVM `bindings-v0.19.2` (`17cb5cc6`).
`pq-devnet-2` still pins `bindings-v0.19.0` (`351f7ae4`).
## Changes
- `leanvm_prover`, `leanvm_claims` and `leanvm_lean_xmss` move to
`17cb5cc6bb9af2321cfff3a50ccbeaf612e0113b`, with `leanvm-revision`
(which the Dockerfile reads to fetch `scripts/tier-rustc`) and
`stark::leanvm::LEANVM_REV`.
- `Cargo.lock` changes by that revision only: no crates.io package
moves.
- No source change was needed: the `lean_vm`, `claims` and `lean_xmss`
APIs the node uses are the same.
- Comments and docs name v0.19.2.
## This is not a compatibility break
v0.19.0 and v0.19.2 verify each other's proofs, so a node on either
release interoperates with the other:
- leanVM's `PROTOCOL_VERSION` ("bumped when old proofs or signatures
stop verifying") is `1` at both tags, and its
`protocol_version_pins_the_guest` test pins the same guest Fiat-Shamir
IV (`48e6b446…`) at both.
- Checked directly, with a throwaway test built once against each
revision (not in this PR), each side reading the other's bytes:
| Made by → checked by | v0.19.0 → v0.19.2 | v0.19.2 → v0.19.0 |
|---|---|---|
| Public keys from one seed are equal | yes | yes |
| leanXMSS signature verifies | yes | yes |
| Leaf proofs (2 signatures, 1 signature) verify | yes | yes |
| Merged proof verifies, and not against other claims | yes | yes |
| Merge of two of the other release's proofs, then verify | yes | yes |
| Merge of one proof from each release, then verify | yes | yes |
What v0.19.1 and v0.19.2 change in the crates the node builds:
`zkdsl_compiler` fixes (the compiled guest is unchanged, per the IV
above), the PCS prover reading the verifier's WHIR table (a refactor),
and `lean_vrf` batching, which the node does not use.
So the docs that said a proof from any other leanVM revision does not
verify now say it is `PROTOCOL_VERSION` that has to match.
## Testing
- `cargo test --profile release-fast -p ethlambda-crypto -p
ethlambda-telemetry -p ethlambda-validator -p ethlambda`: all pass,
including the leanXMSS known answers
(`consensus_specs_known_answer_{signs,verifies,rejections}`,
`lean_vm_known_answer`, `the_port_signs_and_verifies_as_leanvm_does`),
`pq_keys::erc8517_test_vectors`, `vrf::known_answers` and
`the_leanvm_pin_is_the_same_everywhere`.
- `leanvm_proofs_merge_and_verify` (the end-to-end prover test `make
test-consensus` runs by name): passes.
- `make lint` and `cargo fmt --all --check`: clean.
Not run: the Docker image build with the CPU tiers, and a devnet.
## Summary Ports #941 (step 1 of #938) onto **`pq-devnet-2`**, exposing the eleven PQ aggregation, merge, verification, and vote-arrival Prometheus series on `/metrics` alongside `pq-devnet-2`'s OTLP PQ telemetry hooks: | 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 | ### Conflict resolutions on `pq-devnet-2` - **`crates/net/rpc/src/beacon/pq_aggregation.rs`:** `prove_committee` returns `(Arc<PooledPqAggregate>, Duration, Option<proof::Plan>)`, feeding both `metrics::observe_pq_committee_proof` / `inc_pq_committee_proofs` and `pq_events` duty/operation hooks. - **`crates/blockchain/src/pq_attestation_packing.rs`:** `pack_attestations` records both `metrics::observe_pq_merge` / `inc_pq_merges` and the `pq_events::proof::Plan` / `duty::remember_result` lifecycle. - **`crates/blockchain/state_transition/src/beacon/gossip/pq.rs`:** Uses a single `Instant::now()` timer around `verify_aggregates` for both `observe_pq_proof_verification("aggregate", elapsed)` and `pq_events::gossip::record_current_proof_verify_ns`. - **`docs/metrics.md`:** Appends `### PQ Aggregation Timing` cleanly alongside `### PQ Measurement Exporter Health` without overlapping #972. ## Related Issues / PRs - Port of #941 onto `pq-devnet-2` - Part of #938 ## Verification - [x] `cargo fmt --check` - [x] `cargo clippy --workspace --all-targets -- -D warnings` - [x] Unit tests across `ethlambda-metrics`, `ethlambda-state-transition`, `ethlambda-p2p`, `ethlambda-rpc`, and `ethlambda-blockchain`
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🗒️ Description / Motivation
What ethlambda needs for pq-devnet-2 (spec, target launch 08.12.2026). It relaunches pq-devnet-1 at 65,536 validators with three changes every client has to carry:
X_COMMITTEE_COUNTS, consensus-specs#5879). The devnet runs[16, 8, 4, 2, 1], eight epochs a stage.pq.*events of the PQ measurement spec over OTLP Logs, behind--telemetry-events=pq. It is a launch requirement this time. This PR emits wireeth.telemetry/0.4, the spec's current version.Stacked on
pq-devnet-1(#896), the same way that one is stacked onpq-devnet-0.What Changed
1. ERC-8517 PQ keys
Derivation (
ethlambda_crypto::pq_keys):m/5326/3600/<chain_id>/<role>/<account>:HMAC-SHA512("Ethereum PQ seed", seed), then hardened child steps.HKDF-Expand-SHA256(account_seed, "leanXMSS key"), and the VRF seed uses"VRF key".0is a validator and role1a builder. A builder derives no VRF seed.chain_idoutside[1, 2^31), an unsupported role, or an account at or above2^31is refused, never reduced into range.Validator client (
crates/validator,bin/ethlambda/src/validator.rs). It loads account seeds from three sources:"leanxmss"keystores, found in--validators-diror imported throughPOST /eth/v1/keystores.--pq-mnemonicwith--pq-account-min/--pq-account-max, and optionally--pq-passphrase,--pq-chain-idand--pq-role.--pq-seeds-file, which readseth2-val-tools pq-seedsoutput or one hex seed per line.Any entry whose
chain_iddisagrees with the beacon node'sDEPOSIT_CHAIN_IDis refused.--secrets-dirnow defaults to<validators-dir>/secrets. The stored leanXMSS trees are named by XMSS public key instead of BLS public key.ethlambda pq-keys: takes--chain-idand--role, and--write-xmss-cachealso writes the.xmsstree caches. The default file stem now includes the chain id, since the path does.Known answers: the spec's check values for accounts 0 and 1 (chain id
3151908: account seed, leanXMSS seed, VRF seed and public key) are pinned as tests inpq_keys.rs.2.
X_COMMITTEE_COUNTScrates/common/types/src/beacon/config.rs):CommitteeCountsis a list of distinct positive powers of two, kept in file order. The count at an epoch isX_COMMITTEE_COUNTS[(epoch // 8) % len]. An empty or missing list falls back toX_MAX_COMMITTEE_COUNT_PER_SLOT.Metadatarow of its own (config_x_committee_counts), likeGAS_LIMIT_SCHEDULE, soDB_VERSIONstays 10. A resume refuses a changed list.committee_count_per_slot_at_epoch), and the PQ epoch processing and gossip rules use it.genesis.ssz'saggregation_committee_windowmatches the first epochs' counts./eth/v1/config/specserves the list as decimal strings when it is not empty.3.
--telemetry-events=pqethlambda_telemetry::pq_events: the event records, an OTLP Logs exporter overgrpcandhttp/protobufconfigured through the standardOTEL_*variables (OTEL_RESOURCE_ATTRIBUTESmust carryeth.node.id), and thepq_measurement_*exporter-health counters on/metrics.beaconandvalidatortake the flag. The beacon node starts the exporter only on a network that schedules PQ, and flushes it at shutdown.p2p/src/beacon/pq.rs,gossipsub/handler.rs,swarm_adapter.rs), proving (crypto/src/stark.rs,stark/leanvm.rs), the node's aggregation duties (rpc/src/beacon/pq_aggregation.rs) and proposal-time proof merging (pq_attestation_packing.rs).pq.validation_batchis never emitted. The node validates aggregates one by one, andpq.contextdeclaresvalidation_batching: individual.fcbf6a87). The devnet note says 0.3, but the spec moved to 0.4 on Dec 2 and xatu's sentry accepts both (feat(otlp): support measurement wire 0.4 duty timing ethpandaops/xatu#1021), so this emits 0.4:pq.duty_schedulednames its nominal target asscheduled_publish_unix_nsfor both duty kinds.pq.duty_completedhas nolateflag.missed_deadline) carries that cutoff asdeadline_unix_ns. The beacon node's cutoff for a committee seat is the seat's broadcast time. The validator client's cutoff for a proposal is the slot's attestation time.--pq-timing-output) pq-devnet-1 asked for. It is not in this branch, and pq-devnet-2 asks for the OTLP events instead.Docs
docs/beacon_pq.md,docs/cli.md(new flags and apq-keyssection),docs/metrics.md(the exporter-health counters) andCLAUDE.md.Open points
ethereum/consensus-specs@66f143ec. The module headers anddocs/beacon_pq.mdstill name pq-devnet-1's4c296784, and this PR adds only #5879 on top of it. Any other consensus change between the two commits has not been audited here.351f7ae4)."leanxmss"shape here may need to change once clients agree on one.Testing
make fmtandmake lintpass on the first commit. On the second,cargo fmt --checkpasses and clippy passes with-D warningson the crates it touches.cargo test --profile release-fast -p ethlambda-telemetry -p ethlambda-crypto -p ethlambda-types -p ethlambda-validator -p ethlambda-rpcpasses (the crates'#[ignore]d tests were not run).3b9eb6b, wire 0.4):schema.jsonandtools/metadata.py.tools/otlp.py) into the same records.make testand the beacon spec suites (make test-beacon) have not been run.