Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(Inbox): getL1ToL2MessageAndIndex should return the first non-nullified message, not the first message #3976

Closed
Tracked by #4492
alexghr opened this issue Jan 12, 2024 · 1 comment · Fixed by #5390
Assignees

Comments

@alexghr
Copy link
Contributor

alexghr commented Jan 12, 2024

getL1ToL2MessageAndIndex currently looks for the first leaf with the given message key in the message tree. This should probably return the first message with that message key that's not been nullified yet.

The risk here is that for messages that are emitted multiple times, the function would return a message that's already been consumed in the past instead of the most recent one. If the message's nullifier is siloed with the message's index in the tree then this would also emit a duplicate nullifier?

public async getL1ToL2MessageAndIndex(messageKey: Fr): Promise<L1ToL2MessageAndIndex> {
// todo: #697 - make this one lookup.
const index = (await this.findLeafIndex('latest', MerkleTreeId.L1_TO_L2_MESSAGE_TREE, messageKey))!;
const message = await this.l1ToL2MessageSource.getConfirmedL1ToL2Message(messageKey);
return Promise.resolve(new L1ToL2MessageAndIndex(index, message));
}

@github-project-automation github-project-automation bot moved this to Todo in A3 Jan 12, 2024
@LHerskind LHerskind changed the title getL1ToL2MessageAndIndex should return the first non-nullified message, not the first message refactor(Inbox): getL1ToL2MessageAndIndex should return the first non-nullified message, not the first message Mar 9, 2024
@LHerskind
Copy link
Contributor

For this, we can use the assumption that people are using the proposed mechanism to consuming messages, if they are using other mechanisms we cannot figure out the nullifier and cannot skip it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
3 participants