Skip to content

feat(pq): follow consensus-specs pq at 66f143ec (pq-devnet-2) - #975

Open
pablodeymo wants to merge 3 commits into
pq-devnet-2from
feat/pq-devnet-2-specs-66f143ec
Open

pablodeymo wants to merge 3 commits into
pq-devnet-2from
feat/pq-devnet-2-specs-66f143ec

Conversation

@pablodeymo

Copy link
Copy Markdown
Collaborator

Motivation

pq-devnet-2's spec sheet names consensus-specs pq at 66f143ec. pq-devnet-2 is at 4c296784 plus X_COMMITTEE_COUNTS. Two things in between change the state a node computes:

  • Preregistrations (f21ace42..c8608e56): a record now stores expiry_epoch, not expiry_slot, so the state root differs from the first preregistration on.
  • EIP-8483 registrations (4e25f53a, a0d94fdc): who may register, what must be unique, and removal on exit.

Changes

PQ state transition

  • ValidatorPreregistration and BuilderPreregistration carry expiry_epoch = get_current_epoch(state) + PREREGISTRATION_EXPIRY_EPOCHS. The preset is 8192 epochs on mainnet and 8 on minimal (it was PREREGISTRATION_EXPIRY_SLOTS, 262144 and 64).
  • A preregistration request is a no-op when the list already holds PREREGISTRATIONS_LIMIT records or one for the key. Both used to count only unexpired records, and an expired record was replaced in place. Now only the sweep frees either.
  • is_active_*_preregistration and get_active_*_preregistration are gone. Deposits and builder deposits look the record up with get_{validator,builder}_preregistration, which does not check expiry.
  • process_preregistration_expiry keeps a record while compute_epoch_at_slot(state.latest_execution_payload_bid.slot) < expiry_epoch.

EIP-8483 state transition

  • A validator registers only with compounding (0x02) credentials and only before it has initiated an exit. Only the first 32 bytes of its PQ data must be unregistered (both halves had to be).
  • A builder registers only before it has initiated an exit.
  • initiate_validator_exit, initiate_validator_consolidation and initiate_builder_exit remove the registration. The removal is a no-op on every other fork, PQ included, whose state has no such list.
  • process_parent_execution_payload verifies a full parent from before EIP8483_FORK_EPOCH against gloas's ExecutionRequests root, and requires it to carry no PQ registration.

Not changed

  • Gossip. The range also changes five gossip rules: the envelope's transaction-count bound (#5802) and block-hash check (#5770), the bid's timing, bid limit net of pending withdrawals (#5843) and head-compatibility reorg condition (#5803). None is taken here. All are gloas rules that PQ inherits, four of them first released in v1.7.0-beta.5, while this repository's gloas is pinned at beta.2; docs/spec_deviations.md ("PQ gossip is gloas's rules with the PQ lines applied") already records that PQ gossip follows the pinned gloas rules, and now lists these. They are IGNOREs, or REJECTs of payloads the execution client refuses anyway, so an honest network sees no difference. A wrong block-hash computation would refuse every valid payload, and nothing in the repository can check one yet.
  • Far-future slots (#5895) and malformed KZG inputs (#5904) need no change: slot times saturate and a KZG error is already a failed verdict. A test now pins the first.
  • BLS and sync-committee changes in the range (#5838, #5903, #5905, #5906) do not reach a PQ chain.
  • EIP-8483's proposer note (converting a pre-fork parent's requests when proposing): the node does not follow or propose on EIP-8483.

Docs

The pin moves to 66f143ec in module docs, CLAUDE.md, docs/beacon_pq.md and docs/spec_deviations.md. docs/beacon_pq.md also notes that the pyspec now signs fixtures with real leanXMSS keys (c3e76688), which the spec-test binary, with verification off, cannot judge yet.

Compatibility

The PQ state's SSZ shape is unchanged (one uint64 field renamed), so DB_VERSION stays. A data directory that already holds preregistrations would read their slot deadline as an epoch; this only matters to a network that stored one under the old rule.

Testing

New unit tests:

  • PQ: the stored expiry_epoch mid-epoch; a second request for a stored key, expired or not, changes nothing; a full list admits nothing and one below the limit does; the sweep follows the latest payload's epoch across empty epochs, keeps order, and frees the key.
  • EIP-8483: the credential and exit conditions; first-half-only uniqueness; removal on exit, on consolidation and on builder exit, with re-registration refused; a pre-fork parent's requests against the gloas root, and a post-fork parent's against the extended one.
  • Gossip: a far-future slot is future, and neither current nor past.

They match the cases of the pyspec's own tests for these functions at 66f143ec, read by hand (test_process_preregistration_expiry.py, test_process_validator_preregistration_request.py, the EIP-8483 block_processing tests).

Run locally, all green:

  • cargo test --locked --profile release-fast over the consensus crates (ethlambda-types, ethlambda-fork-choice, ethlambda-state-transition, ethlambda-blockchain, ethlambda-crypto, ethlambda-ssz-tree), default preset.
  • cargo test --profile release-fast --lib --features preset-minimal for ethlambda-types and ethlambda-state-transition.
  • cargo check --features beacon-spec-tests --tests for ethlambda-state-transition and ethlambda-blockchain (the spec-test targets compile).
  • make lint, cargo fmt --all --check.

Not run: the pyspec's reference fixtures. No release ships PQ or EIP-8483 fixtures, and generating them needs the pyspec toolchain. To check this PR against them:

git clone https://github.com/ethereum/consensus-specs && cd consensus-specs
git checkout 66f143ec87da07452e3059b0954584014043125e
make test reftests=true fork=pq preset=minimal k="preregistration or deposit_request"
make test reftests=true fork=eip8483 preset=minimal k="pq_registration or parent_execution_payload or exit_request or consolidation_request or withdrawal_request"

then unpack reftests/tests/minimal/{pq,eip8483} under consensus-spec-tests/tests/minimal/ and run make test-beacon-minimal.

PQ preregistrations store expiry_epoch (current epoch plus
PREREGISTRATION_EXPIRY_EPOCHS) instead of expiry_slot. A request is a
no-op when the list is full or already holds a record for the key,
expired or not: only the epoch sweep frees either, and the sweep
compares against the latest payload bid's epoch.

EIP-8483: a validator registers only with compounding credentials and
before initiating an exit, only the first 32 bytes of its PQ data must
be new, an exiting builder cannot register, and an exit, a
consolidation or a builder exit removes the registration. A full parent
from before the fork is checked against gloas's ExecutionRequests root.

The gloas gossip rules that changed in the same range are not taken:
PQ gossip follows the pinned gloas rules (docs/spec_deviations.md).
@pablodeymo

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

AI security review: 1 finding(s) to check

Reviewed by Opus, GPT, Kimi, DeepSeek. A judge model checked every one of the findings against the code.
GLM (error, see the run log) did not finish; Opus, GPT, Kimi, DeepSeek reviewed the whole PR. Comment /review continue to retry, with a new budget; reviewers that finished are reused.

# Finding Severity Status Found by Where
M2 upgrade_to_eip8483 doc still says a full pre-fork parent is left unhandled low Bug Opus (1/4) crates/blockchain/state_transition/src/beacon/upgrade.rs:1258
Details

M2. upgrade_to_eip8483 doc still says a full pre-fork parent is left unhandled (low, docs)

  • Trigger: Someone reads the upgrade's doc to understand how the first post-fork block handles a full gloas parent.
  • Mechanism: This PR changes eip8483::process_parent_execution_payload to check a pre-fork parent against gloas::ExecutionRequests and to require empty registration lists. The comment on upgrade_to_eip8483 still says the specification leaves this case open and that the code applies no special handling. That is no longer true.
  • Impact: Misleading documentation about a consensus-relevant boundary rule. It could lead someone to remove or duplicate the new handling.
  • Judge: The documentation is newly stale: it still describes full pre-fork parent validation as left to a coordinated upgrade, while this PR implements explicit handling in EIP-8483 block processing. The bid-copy description remains accurate, but the explanation of how its old commitment is handled needs updating.
Pre-existing (real, but already on the base branch): 1
# Finding Category Severity (reported → judged) Found by Where Judge's reason
M1 PQ fork transition rejects a full pre-fork parent because it hashes the new PQ requests type against the old fork's root consensus/state high Opus, DeepSeek (2/4) crates/blockchain/state_transition/src/beacon/stf/pq.rs:483 The full-parent root mismatch is real, but the same comparison, incompatible request layouts, and unchanged parent-bid copy already exist at base 1eaea68. This PR fixes the analogous EIP-8483 boundary without introducing the PQ defect. The unconditional chain-stall claim is overstated: an EMPTY-parent block bypasses the comparison, although it does not apply the old payload.
Housekeeping (not security): 1

Stale docs, missing tests, leftovers and inconsistencies, from a separate cheap model. Not checked by the judge.

Kind Item Where Fix
stale-docs Interop target still references pq-devnet-1 docs/beacon_pq.md:724 Update the item to reference pq-devnet-2 and the new pin: "Interop at pq-devnet-2's spec (66f143ec)."

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

Addresses the security review of PR #975.

M2: `upgrade_to_eip8483`'s doc still said the specification leaves a
full pre-fork parent to the coordinated upgrade and that nothing handles
it. This PR's `eip8483::process_parent_execution_payload` does: such a
parent's requests are verified against gloas's `ExecutionRequests` and
must carry no PQ registration. The doc now says so.

Pre-existing M1 (PQ rejects a full pre-fork parent): not a change of
rule. consensus-specs `pq` at `66f143ec` says in a note that every full
parent's requests are verified against the PQ type, and gives PQ no
branch like EIP-8483's, so the code is the specification as written, and
accepting such a parent here alone would follow a chain no other client
does. `pq::process_parent_execution_payload` and `upgrade_to_pq` now
record that, and that the first PQ block can take a pre-fork parent only
as EMPTY. A network that is PQ from genesis never meets the case.

Housekeeping: the "Interop at pq-devnet-1's spec" item under "What
remains" names pq-devnet-2 and `66f143ec`, and no longer calls the
genesis and key derivation TBD: the pq-devnet-2 notes settle both.
Conflict in docs/beacon_pq.md, "Running a devnet": both this branch and
#974 rewrote the paragraph naming the devnet's pins. Kept this branch's
text (pq-devnet-2, consensus-specs `pq` at `66f143ec`, leanVM bindings
v0.19.2), which #974 landing makes true.
@pablodeymo

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown

AI security review: 1 finding(s) to check

Reviewed by Opus, GPT, Kimi, DeepSeek. A judge model checked every one of the findings against the code.
GLM (error, see the run log) did not finish; Opus, GPT, Kimi, DeepSeek reviewed the whole PR. Comment /review continue to retry, with a new budget; reviewers that finished are reused.

# Finding Severity Status Found by Where
M1 Reject incompatible PQ snapshots before interpreting slot deadlines as epochs low Bug GPT (1/4) crates/common/types/src/beacon/containers/pq.rs:432
Details

M1. Reject incompatible PQ snapshots before interpreting slot deadlines as epochs (low, consensus/state)

  • Trigger: An operator upgrades an existing PQ node whose persisted state contains validator or builder preregistrations, then resumes using the same genesis and configuration.
  • Mechanism: Both preregistration records replace a slot-valued uint64 with an epoch-valued uint64 without changing their encoding, fork selector, or DB_VERSION (still 10). Store::from_db_state therefore accepts the old directory, and state_codec::decode_state_value directly decodes its old expiry_slot bytes into expiry_epoch. Startup's genesis and configuration comparisons do not distinguish these protocol revisions. The new expiry sweep then compares the payload epoch against the old slot deadline, retaining the binding for roughly SLOTS_PER_EPOCH times its intended lifetime.
  • Impact: The node silently resumes incompatible protocol state rather than requiring a fresh checkpoint. Preregistrations can remain binding far beyond their intended expiry, and subsequent transitions can disagree with nodes initialized under the new rules, preventing synchronization. Reject or explicitly rebootstrap affected old PQ directories.
  • Judge: Confirmed against the base revision: both expiry_slot fields become expiry_epoch without changing their uint64 SSZ representation, PQ selector, or DB_VERSION. An existing PQ directory with unchanged genesis and configuration passes startup checks, and its old deadlines decode unchanged as epochs. The expiry sweep consequently retains those bindings far beyond their original deadlines, allowing sub

Cost of this review: ~$4.50 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