Skip to content

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

@alexghr

Description

@alexghr

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));
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions