-
Notifications
You must be signed in to change notification settings - Fork 598
fix: tagging bug #13061
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
fix: tagging bug #13061
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,7 +181,7 @@ describe('PXEOracleInterface', () => { | |
| // First sender should have 2 logs, but keep index 1 since they were built using the same tag | ||
| // Next 4 senders should also have index 1 = offset + 1 | ||
| // Last 5 senders should have index 2 = offset + 2 | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets); | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets, recipient.address); | ||
|
|
||
| expect(indexes).toHaveLength(NUM_SENDERS); | ||
| expect(indexes).toEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]); | ||
|
|
@@ -202,14 +202,25 @@ describe('PXEOracleInterface', () => { | |
|
|
||
| // Recompute the secrets (as recipient) to ensure indexes are updated | ||
| const ivsk = await keyStore.getMasterIncomingViewingSecretKey(recipient.address); | ||
| // An array of direction-less secrets for each sender-recipient pair | ||
| const secrets = await Promise.all( | ||
| senders.map(sender => | ||
| computeAppTaggingSecret(recipient, ivsk, sender.completeAddress.address, contractAddress), | ||
| ), | ||
| ); | ||
|
|
||
| const indexesAsSender = await taggingDataProvider.getTaggingSecretsIndexesAsSender(secrets); | ||
| expect(indexesAsSender).toStrictEqual([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); | ||
| // We only get the tagging secret at index `index` for each sender because each sender only needs to track | ||
| // their own tagging secret with the recipient. The secrets array contains all sender-recipient pairs, so | ||
| // secrets[index] corresponds to the tagging secret between sender[index] and the recipient. | ||
| const getTaggingSecretsIndexesAsSenderForSenders = () => | ||
| Promise.all( | ||
| senders.map((sender, index) => | ||
| taggingDataProvider.getTaggingSecretsIndexesAsSender([secrets[index]], sender.completeAddress.address), | ||
| ), | ||
| ); | ||
|
|
||
| const indexesAsSender = await getTaggingSecretsIndexesAsSenderForSenders(); | ||
| expect(indexesAsSender).toStrictEqual([[0], [0], [0], [0], [0], [0], [0], [0], [0], [0]]); | ||
|
|
||
| expect(aztecNode.getLogsByTags.mock.calls.length).toBe(0); | ||
|
|
||
|
|
@@ -221,8 +232,8 @@ describe('PXEOracleInterface', () => { | |
| ); | ||
| } | ||
|
|
||
| let indexesAsSenderAfterSync = await taggingDataProvider.getTaggingSecretsIndexesAsSender(secrets); | ||
| expect(indexesAsSenderAfterSync).toStrictEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]); | ||
| let indexesAsSenderAfterSync = await getTaggingSecretsIndexesAsSenderForSenders(); | ||
| expect(indexesAsSenderAfterSync).toStrictEqual([[1], [1], [1], [1], [1], [2], [2], [2], [2], [2]]); | ||
|
|
||
| // Only 1 window is obtained for each sender | ||
| expect(aztecNode.getLogsByTags.mock.calls.length).toBe(NUM_SENDERS); | ||
|
|
@@ -240,8 +251,8 @@ describe('PXEOracleInterface', () => { | |
| ); | ||
| } | ||
|
|
||
| indexesAsSenderAfterSync = await taggingDataProvider.getTaggingSecretsIndexesAsSender(secrets); | ||
| expect(indexesAsSenderAfterSync).toStrictEqual([12, 12, 12, 12, 12, 13, 13, 13, 13, 13]); | ||
| indexesAsSenderAfterSync = await getTaggingSecretsIndexesAsSenderForSenders(); | ||
| expect(indexesAsSenderAfterSync).toStrictEqual([[12], [12], [12], [12], [12], [13], [13], [13], [13], [13]]); | ||
|
|
||
| expect(aztecNode.getLogsByTags.mock.calls.length).toBe(NUM_SENDERS * 2); | ||
| }); | ||
|
|
@@ -264,7 +275,7 @@ describe('PXEOracleInterface', () => { | |
| // First sender should have 2 logs, but keep index 1 since they were built using the same tag | ||
| // Next 4 senders should also have index 6 = offset + 1 | ||
| // Last 5 senders should have index 7 = offset + 2 | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets); | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets, recipient.address); | ||
|
|
||
| expect(indexes).toHaveLength(NUM_SENDERS); | ||
| expect(indexes).toEqual([6, 6, 6, 6, 6, 7, 7, 7, 7, 7]); | ||
|
|
@@ -289,6 +300,7 @@ describe('PXEOracleInterface', () => { | |
| // Increase our indexes to 2 | ||
| await taggingDataProvider.setTaggingSecretsIndexesAsRecipient( | ||
| secrets.map(secret => new IndexedTaggingSecret(secret, 2)), | ||
| recipient.address, | ||
| ); | ||
|
|
||
| const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); | ||
|
|
@@ -300,7 +312,7 @@ describe('PXEOracleInterface', () => { | |
| // First sender should have 2 logs, but keep index 2 since they were built using the same tag | ||
| // Next 4 senders should also have index 2 = tagIndex + 1 | ||
| // Last 5 senders should have index 3 = tagIndex + 2 | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets); | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets, recipient.address); | ||
|
|
||
| expect(indexes).toHaveLength(NUM_SENDERS); | ||
| expect(indexes).toEqual([2, 2, 2, 2, 2, 3, 3, 3, 3, 3]); | ||
|
|
@@ -324,8 +336,10 @@ describe('PXEOracleInterface', () => { | |
|
|
||
| // We set the indexes to WINDOW_HALF_SIZE + 1 so that it's outside the window and for this reason no updates | ||
| // should be triggered. | ||
| const index = WINDOW_HALF_SIZE + 1; | ||
| await taggingDataProvider.setTaggingSecretsIndexesAsRecipient( | ||
| secrets.map(secret => new IndexedTaggingSecret(secret, WINDOW_HALF_SIZE + 1)), | ||
| secrets.map(secret => new IndexedTaggingSecret(secret, index)), | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Introduced this change when I initially bumped the window size to 20 to fix the test. Then I reverted it back to 10 but decided to keep this change around as it improves the test (it makes it robust against window changes). |
||
| recipient.address, | ||
| ); | ||
|
|
||
| const syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); | ||
|
|
@@ -334,10 +348,10 @@ describe('PXEOracleInterface', () => { | |
| expect(syncedLogs.get(recipient.address.toString())).toHaveLength(NUM_SENDERS / 2); | ||
|
|
||
| // Indexes should remain where we set them (window_size + 1) | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets); | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets, recipient.address); | ||
|
|
||
| expect(indexes).toHaveLength(NUM_SENDERS); | ||
| expect(indexes).toEqual([11, 11, 11, 11, 11, 11, 11, 11, 11, 11]); | ||
| expect(indexes).toEqual([index, index, index, index, index, index, index, index, index, index]); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above comment. This is an unrelated change. |
||
|
|
||
| // We should have called the node once and that is only for the first window | ||
| expect(aztecNode.getLogsByTags.mock.calls.length).toBe(1); | ||
|
|
@@ -357,6 +371,7 @@ describe('PXEOracleInterface', () => { | |
|
|
||
| await taggingDataProvider.setTaggingSecretsIndexesAsRecipient( | ||
| secrets.map(secret => new IndexedTaggingSecret(secret, WINDOW_HALF_SIZE + 2)), | ||
| recipient.address, | ||
| ); | ||
|
|
||
| let syncedLogs = await pxeOracleInterface.syncTaggedLogs(contractAddress, 3); | ||
|
|
@@ -377,7 +392,7 @@ describe('PXEOracleInterface', () => { | |
| // First sender should have 2 logs, but keep index 1 since they were built using the same tag | ||
| // Next 4 senders should also have index 1 = offset + 1 | ||
| // Last 5 senders should have index 2 = offset + 2 | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets); | ||
| const indexes = await taggingDataProvider.getTaggingSecretsIndexesAsRecipient(secrets, recipient.address); | ||
|
|
||
| expect(indexes).toHaveLength(NUM_SENDERS); | ||
| expect(indexes).toEqual([1, 1, 1, 1, 1, 2, 2, 2, 2, 2]); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original workaround was to not send the txs "at once" but instead one by one.