Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ describe('buildNullifierNonExistentReadRequestHints', () => {

nonExistentReadRequests[0] = makeReadRequest(innerNullifier(2));

await expect(() => buildHints()).rejects.toThrow('Nullifier exists in the pending set.');
await expect(() => buildHints()).rejects.toThrow(
'Nullifier DOES exists in the pending set at the time of reading, but there is a NonExistentReadRequest for it.',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ export async function buildNullifierNonExistentReadRequestHints(
let nextPendingValueIndex = sortedValues.findIndex(v => !v.value.lt(siloedValue));
if (nextPendingValueIndex == -1) {
nextPendingValueIndex = numPendingNullifiers;
} else if (sortedValues[nextPendingValueIndex].value.equals(siloedValue)) {
throw new Error('Nullifier exists in the pending set.');
} else if (
sortedValues[nextPendingValueIndex].value.equals(siloedValue) &&
sortedValues[nextPendingValueIndex].counter < readRequest.counter
) {
throw new Error(
'Nullifier DOES exists in the pending set at the time of reading, but there is a NonExistentReadRequest for it.',
);
}

builder.addHint(membershipWitness, leafPreimage, nextPendingValueIndex);
Expand Down