Skip to content

feat: implement CLAIM note nullifier tracking#2610

Open
partylikeits1983 wants to merge 3 commits intoajl-reorient-claim-note-flowfrom
ajl-claim-note-nullifier-tracking
Open

feat: implement CLAIM note nullifier tracking#2610
partylikeits1983 wants to merge 3 commits intoajl-reorient-claim-note-flowfrom
ajl-claim-note-nullifier-tracking

Conversation

@partylikeits1983
Copy link
Contributor

@partylikeits1983 partylikeits1983 commented Mar 16, 2026

This PR implements CLAIM note nullifier tracking inside the agglayer bridge account. Additionally, this PR adds a test which attempts to consume two different CLAIM notes with the same PROOF_DATA.

The nullifier of the CLAIM note is defined as the RPO hash of leaf_index (last 32 bits of global_index) and source_bridge_network. Will update to use poseidon2 once the latest VM version is used in the protocol agglayer branch.

Resolves: #2594

Note: Wait until #2528 is merged since this PR is based on ajl-reorient-claim-note-flow branch.

@partylikeits1983 partylikeits1983 self-assigned this Mar 16, 2026
@partylikeits1983 partylikeits1983 added no changelog This PR does not require an entry in the `CHANGELOG.md` file agglayer PRs or issues related to AggLayer bridging integration pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority labels Mar 16, 2026
Comment on lines +376 to +377
#! This is analogous to the multisig's `assert_new_tx` procedure which tracks executed
#! transactions. Here we track consumed CLAIM notes via their PROOF_DATA_KEY.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can remove this comment since it might not make sense to someone not familiar with the multisig.

@partylikeits1983 partylikeits1983 marked this pull request as ready for review March 16, 2026 15:30
@partylikeits1983 partylikeits1983 marked this pull request as draft March 16, 2026 15:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Implements replay protection for CLAIM notes in the AggLayer bridge account by tracking spent claims via a nullifier map keyed by PROOF_DATA_KEY, and adds an integration test to ensure duplicate claims are rejected.

Changes:

  • Added a new bridge storage slot (claim_nullifiers) to persist spent CLAIM nullifiers.
  • Updated bridge_in.masm to check-and-set the nullifier (mirroring the multisig assert_new_tx pattern) and introduced a dedicated MASM error.
  • Added a test that executes a CLAIM twice with identical PROOF_DATA and asserts the second execution fails with the expected error code.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
crates/miden-testing/tests/agglayer/bridge_in.rs Adds a regression test to ensure a second CLAIM with the same PROOF_DATA_KEY is rejected.
crates/miden-agglayer/src/errors/agglayer.rs Adds generated error constant for “claim note has already been spent”.
crates/miden-agglayer/src/bridge.rs Introduces the new claim_nullifiers storage slot in the bridge component layout and exposes its slot name.
crates/miden-agglayer/asm/agglayer/bridge/bridge_in.masm Adds nullifier tracking logic via native_account::set_map_item and a new error constant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@partylikeits1983 partylikeits1983 marked this pull request as ready for review March 16, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agglayer PRs or issues related to AggLayer bridging integration no changelog This PR does not require an entry in the `CHANGELOG.md` file pr-from-maintainers PRs that come from internal contributors or integration partners. They should be given priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants