Skip to content

fix(contracts): drop the unreachable vault membership check - #283

Merged
lolaaimar merged 2 commits into
fix/240-registry-double-init-testfrom
fix/attestation-unreachable-vault-check
Nov 25, 2026
Merged

lolaaimar merged 2 commits into
fix/240-registry-double-init-testfrom
fix/attestation-unreachable-vault-check

Conversation

@nicolasLuduena

@nicolasLuduena nicolasLuduena commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #285 (stack: #291 → #292 → #293 → #294 → #285 → #283 → #282); it shares no files with them.

verifyAttestation checked the vault for the claim's id right after the replay check. That second assert can never fire, so this PR removes it:

 verifyAttestation
   assert(!nullifiers.member(nullifier), "Observation replay")
   nullifiers.insert(nullifier)
   id = persistentCommit(claim, rand)
-  assert(!claimsVault.member(id), "Claim already accepted")
   claimsVault.insert(id, entry)

If the vault already held id, the replay check would have rejected the call first:

  1. Only verifyAttestation writes to claimsVault and nullifiers, and it inserts into both in the same call. A failed assert aborts the call, so every vault entry has its claim's nullifier.
  2. persistentCommit is binding, so an equal id means the same claim, barring a SHA-256 collision.
  3. nullifierOf depends only on the claim's fields (ADR 0006, ADR 0012), so the same claim gives the same nullifier.

Concurrent transactions run the same checks in the same order against the ledger, so they end the same way.

The argument breaks for an app that embeds the module and writes to A_nullifiers or A_claimsVault from its own circuits. Such an app also breaks the module's replay protection, and no app in the repo does it.

The contracts README's guarantees no longer name "Claim already accepted"; they say the replay check also covers a resubmission under the same vault randomness. A patch changeset for @txpipe/thoth-contracts records the change.

Evidence

The new test resubmits an identical claim with the same vault randomness, the only case the removed assert was meant to catch:

observation replay > rejects the same claim with the same vault randomness
  • Before: with the assert still in attestation.compact, the test passes and the call fails with Observation replay, so the vault check is never reached.
    After: with the assert removed, the test passes with the same error.

On the full stack, all four mocks compile with npm run compact:no-zk. Build, npm run types and npm run check (Biome and compact format -c) pass. The full suite passes: 776 passed, 4 skipped (the opt-in live checks).

No verification skill in this repo.

Merge Danger

Door: two-way

Blast Radius: contracts consumers

A circuit that embeds attestation.compact loses one assert and gets slightly smaller. No input that used to pass now fails, and no input that used to fail now passes. A deployed contract keeps its old circuit until you redeploy it.

@nicolasLuduena
nicolasLuduena force-pushed the fix/attestation-unreachable-vault-check branch from aedf87b to 4287db3 Compare November 25, 2026 02:12
@nicolasLuduena
nicolasLuduena changed the base branch from main to fix/240-registry-double-init-test November 25, 2026 02:12

@nicolasLuduena nicolasLuduena left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lolaaimar lolaaimar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@lolaaimar
lolaaimar force-pushed the fix/attestation-unreachable-vault-check branch from b910721 to 7c05c80 Compare November 25, 2026 19:49
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2c18033a-04b5-4ab5-a0cb-b7cbb188478a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

An equal vault id commits to the same claim, whose nullifier the replay
check has already rejected, so "Claim already accepted" could never fire.
@lolaaimar
lolaaimar force-pushed the fix/attestation-unreachable-vault-check branch from 7c05c80 to d600820 Compare November 25, 2026 20:47
@lolaaimar
lolaaimar merged commit 84750ee into main Nov 25, 2026
3 checks passed
@lolaaimar
lolaaimar deleted the fix/attestation-unreachable-vault-check branch November 25, 2026 20:50
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.

2 participants