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)); |
|
} |
getL1ToL2MessageAndIndexcurrently 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?
aztec-packages/yarn-project/aztec-node/src/aztec-node/server.ts
Lines 374 to 379 in f3ee0b9