fix(nitro): pre-warm the CertManager cert chain before registerKey - #972
Merged
Conversation
`registerKey` reaches `NitroValidator.validateAttestationWithHints`, which re-walks the attestation's certificate bundle via `verifyCachedCertBundle` passing **empty** hint streams. That only succeeds on certificates already in the `CertManager` cache; an uncached cert falls through to signature verification against an empty hint stream and reverts with "inverse hint underflow" — regardless of how good `attestationSigHints` is. AWS rotates the enclave leaf certificate roughly every three hours, so the cache goes cold on its own and the pre-warm had to be re-run by hand inside that window. In practice it never was: the alphanet registry has emitted zero `SignerRegistered` events, and the worker crashlooped on this revert with a leaf cached ~19h earlier and one intermediate CA that had expired 11 minutes before the pod started. The worker now pre-warms its own chain. `prewarm::build_prewarm_plan` turns an attestation into the ordered `verifyCACertWithHints` / `verifyClientCertWithHints` calls needed, and `register_enclave_key` submits the uncached ones before `registerKey`. The CertManager address is discovered via `registry.verifier().certManager()`, so there is no second address to configure and drift. Details: - The pinned AWS root is written into the cache by the CertManager constructor, so it never needs a transaction — it only seeds the parent hash for the next cert in the chain. - Cache keys mirror `CertManager._certCacheKey`: keccak over the TBSCertificate element for every cert, and the pinned constant for the root. - A cert that is cached but expired cannot be re-verified (`_verifyCert` short-circuits on the cache and reverts "cert expired"), so that case fails with an explicit message pointing at the real fix rather than an opaque revert later. - A peer replica caching the same cert between the check and the submit is treated as success, not an error. Verified: 47 nitro tests pass (7 new); `cargo check` and `clippy -D warnings` clean for x86_64-unknown-linux-gnu with `--features enclave`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…rldcoin/world-chain into fix/nitro-worker-self-prewarm
0xOsiris
marked this pull request as ready for review
August 4, 2026 18:46
0xOsiris
requested review from
0xForerunner,
Dzejkop,
Kemperino,
alessandromazza98,
cichaczem,
karankurbur,
kilianglas,
murph and
piohei
as code owners
August 4, 2026 18:46
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
piohei
approved these changes
Aug 5, 2026
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.
Note
Medium Risk
Registration now submits extra L1 transactions and depends on correct cert-chain ordering and hint generation; failures affect enclave key onboarding but not unrelated runtime paths.
Overview
Fixes
registerKeyfailing when on-chainCertManagerlacks the attestation’s AWS cert chain (uncached certs cause"inverse hint underflow"during bundle re-verification with empty hints).Adds a
prewarmmodule that maps an attestation to an ordered list ofverifyCACertWithHints/verifyClientCertWithHintscalls: cache keys aligned withCertManager, P-384 signature hints per cert, and skipping the pinned root.register_enclave_keynow resolvesCertManagerviaregistry.verifier().certManager(), runs pre-warm beforeregisterKey, skips already-cached certs, fails clearly on cached-but-expired certs, and tolerates concurrent pre-warm races from peer workers.Refactors
leaf_cert_pubkey_xyto delegate to newcert_pubkey_xyfor reuse in the chain walk.Reviewed by Cursor Bugbot for commit bebc547. Configure here.