Skip to content

Finish a deleted key's PQ signatures before the delete answers - #1011

Open
tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-delete-waits
Open

tcoratger wants to merge 1 commit into
lambdaclass:pq-devnet-2from
tcoratger:fix/pq-delete-waits

Conversation

@tcoratger

Copy link
Copy Markdown

Description / Motivation

A PQ signature takes its key from the registry, claims its leaf, then signs for up to seconds, outside the store's lock.
DELETE /eth/v1/keystores could answer while such a signature was still being made.
The operator was then told the key was gone while this process still produced a signature with it.

What Changed

  • pq.rs: each signature is counted from its key's lookup until it exists.
    • The lookup and the count happen under the registry's read lock, so a later removal from the registry cannot miss a counted signature.
    • wait_for_signatures blocks until the signatures counted for a key exist; finish_signatures runs it on the blocking pool.
  • keystores.rs: a delete waits for the signatures counted for each key that left the store, before the export and the response.
  • The leaves those signatures claimed stay in the leaf record.

Interaction with open PRs

  • Stop a PQ key signing once its import fails or it is deleted #1009 removes a deleted key from the PQ registry in judge_delete, so no signature of it starts after the delete.
    This PR covers the signatures that started before; together, no signature of a deleted key exists after the delete answers.
    Both edit delete's neighbourhood in keystores.rs and pq.rs, so whichever lands second may need a rebase.

For reviewers

  • The wait has no time limit and holds definitions_lock.
    A bound would answer with a signature still being made, which is what this removes; one signature takes at most a bottom-tree build.

Tests Added / Run

  • a_delete_waits_for_the_pq_signature_under_way: a delete with a signature held answers only after it is released.
  • a_wait_returns_once_the_keys_signatures_under_way_end: two signatures of one key; the wait returns only after both; the claimed leaf stays spent.
  • a_wait_ignores_another_keys_signatures and a_batch_counts_its_signature_until_it_exists (through sign_batch).
  • Removing the wait from delete, ending the count before the signature, or dropping a key's whole count on one signature each make a test fail.
  • cargo test --locked --profile release-fast -p ethlambda-validator: 777 passed; the lib binary passed 10 runs in a row.
  • cargo fmt --all -- --check and cargo clippy --locked --profile release-fast -p ethlambda-validator --all-targets -- -D warnings: clean.

🤖 Generated with Claude Code

A PQ signature takes its key from the registry, claims its leaf, then signs for up to seconds, without the store's lock.
A keystore delete could answer while such a signature was still being made, so a signature of the key appeared after the response.
Each signature is now counted from its key's lookup until it exists.
The lookup and the count happen under the registry's read lock, so a later removal from the registry cannot miss a counted signature.
The delete waits, on the blocking pool, for the signatures counted for each key that left the store.
The leaves those signatures claimed stay in the leaf record.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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