Skip to content

feat!: improve L2ToL1MessageWitness API#21231

Open
nventuro wants to merge 4 commits intomerge-train/fairiesfrom
nico/f-388-feature-support-unique-message-identifier-in
Open

feat!: improve L2ToL1MessageWitness API#21231
nventuro wants to merge 4 commits intomerge-train/fairiesfrom
nico/f-388-feature-support-unique-message-identifier-in

Conversation

@nventuro
Copy link
Contributor

@nventuro nventuro commented Mar 7, 2026

The old API had two issues:

  • it required knowledge of the epoch for the tx in which the message was included, which is hard to acquire
  • it did not support duplicate messages (i.e. same hash) in the epoch at all - it only found the first one

This changes things so that users no longer need to know the epoch, and instead query with (message, txHash). If more than one message is found in the tx matching message, we throw and request an additional optional param messageIndexInTx. If this is passed, then we assert that the message at that index indeed matches message.

Most users should not need to pass the index, but it is there in case it is needed. It is expected that apps would know the messages they're interested in, and can look at indices from the tx effects.

Doing this requires fetching the epoch as well as checkpoint, block and tx indices from the node. There was no API for checkpoint data, so I exposed getCheckpointsDataForEpoch so that we can find the checkpoint's index in the epoch. I also added the epoch number to the tx receipt.


I used Claude heavily here as I don't really know my way around the node and archiver code, but I think the result makes sense.

Closes #20874

nventuro and others added 3 commits March 6, 2026 23:32
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactors `computeL2ToL1MembershipWitness` to take a `txHash` instead of requiring the caller to pass the epoch number. The epoch, checkpoint index, block index, and tx index are now resolved internally via the node. Also adds `epochNumber` to `L2ToL1MembershipWitness` type, adds `getCheckpointsDataForEpoch` to `AztecNode`, and supports explicit `messageIndexInTx` for disambiguating duplicate messages.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@nventuro nventuro requested a review from spalladino March 7, 2026 01:29
@nventuro nventuro requested a review from a team as a code owner March 7, 2026 01:29
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