@@ -206,13 +206,13 @@ describe('PXEOracleInterface', () => {
206206 ) ,
207207 ) ;
208208
209- // First sender should have 2 logs, but keep index 1 since they were built using the same tag
210- // Next 4 senders should also have index 1 = offset + 1
211- // Last 5 senders should have index 2 = offset + 2
212- const indexes = await taggingDataProvider . getNextIndexesAsRecipient ( secrets ) ;
209+ // First sender should have 2 logs, but keep index 0 since they were built using the same tag
210+ // Next 4 senders should also have index 0 = offset + 0
211+ // Last 5 senders should have index 1 = offset + 1
212+ const indexes = await taggingDataProvider . getLastUsedIndexesAsRecipient ( secrets ) ;
213213
214214 expect ( indexes ) . toHaveLength ( NUM_SENDERS ) ;
215- expect ( indexes ) . toEqual ( [ 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 ] ) ;
215+ expect ( indexes ) . toEqual ( [ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 ] ) ;
216216
217217 // We should have called the node 2 times:
218218 // 2 times: first time during initial request, second time after pushing the edge of the window once
@@ -244,10 +244,21 @@ describe('PXEOracleInterface', () => {
244244 ) ;
245245
246246 const getTaggingSecretsIndexesAsSenderForSenders = ( ) =>
247- Promise . all ( secrets . map ( secret => taggingDataProvider . getNextIndexAsSender ( secret ) ) ) ;
247+ Promise . all ( secrets . map ( secret => taggingDataProvider . getLastUsedIndexesAsSender ( secret ) ) ) ;
248248
249249 const indexesAsSender = await getTaggingSecretsIndexesAsSenderForSenders ( ) ;
250- expect ( indexesAsSender ) . toStrictEqual ( [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ;
250+ expect ( indexesAsSender ) . toStrictEqual ( [
251+ undefined ,
252+ undefined ,
253+ undefined ,
254+ undefined ,
255+ undefined ,
256+ undefined ,
257+ undefined ,
258+ undefined ,
259+ undefined ,
260+ undefined ,
261+ ] ) ;
251262
252263 expect ( aztecNode . getLogsByTags . mock . calls . length ) . toBe ( 0 ) ;
253264
@@ -263,7 +274,7 @@ describe('PXEOracleInterface', () => {
263274 }
264275
265276 let indexesAsSenderAfterSync = await getTaggingSecretsIndexesAsSenderForSenders ( ) ;
266- expect ( indexesAsSenderAfterSync ) . toStrictEqual ( [ 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 ] ) ;
277+ expect ( indexesAsSenderAfterSync ) . toStrictEqual ( [ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 ] ) ;
267278
268279 // Only 1 window is obtained for each sender
269280 expect ( aztecNode . getLogsByTags . mock . calls . length ) . toBe ( NUM_SENDERS ) ;
@@ -285,7 +296,7 @@ describe('PXEOracleInterface', () => {
285296 }
286297
287298 indexesAsSenderAfterSync = await getTaggingSecretsIndexesAsSenderForSenders ( ) ;
288- expect ( indexesAsSenderAfterSync ) . toStrictEqual ( [ 12 , 12 , 12 , 12 , 12 , 13 , 13 , 13 , 13 , 13 ] ) ;
299+ expect ( indexesAsSenderAfterSync ) . toStrictEqual ( [ 10 , 10 , 10 , 10 , 10 , 11 , 11 , 11 , 11 , 11 ] ) ;
289300
290301 expect ( aztecNode . getLogsByTags . mock . calls . length ) . toBe ( NUM_SENDERS * 2 ) ;
291302 } ) ;
@@ -313,13 +324,13 @@ describe('PXEOracleInterface', () => {
313324 ) ,
314325 ) ;
315326
316- // First sender should have 2 logs, but keep index 6 since they were built using the same tag
317- // Next 4 senders should also have index 6 = offset + 1
318- // Last 5 senders should have index 7 = offset + 2
319- const indexes = await taggingDataProvider . getNextIndexesAsRecipient ( secrets ) ;
327+ // First sender should have 2 logs, but keep index 5 since they were built using the same tag
328+ // Next 4 senders should also have index 5 = offset
329+ // Last 5 senders should have index 6 = offset + 1
330+ const indexes = await taggingDataProvider . getLastUsedIndexesAsRecipient ( secrets ) ;
320331
321332 expect ( indexes ) . toHaveLength ( NUM_SENDERS ) ;
322- expect ( indexes ) . toEqual ( [ 6 , 6 , 6 , 6 , 6 , 7 , 7 , 7 , 7 , 7 ] ) ;
333+ expect ( indexes ) . toEqual ( [ 5 , 5 , 5 , 5 , 5 , 6 , 6 , 6 , 6 , 6 ] ) ;
323334
324335 // We should have called the node 2 times:
325336 // 2 times: first time during initial request, second time after pushing the edge of the window once
@@ -344,22 +355,22 @@ describe('PXEOracleInterface', () => {
344355 ) ,
345356 ) ;
346357
347- // Increase our indexes to 2
348- await taggingDataProvider . setNextIndexesAsRecipient ( secrets . map ( secret => ( { secret, index : 2 } ) ) ) ;
358+ // Set last used indexes to 1 (so next scan starts at 2)
359+ await taggingDataProvider . setLastUsedIndexesAsRecipient ( secrets . map ( secret => ( { secret, index : 1 } ) ) ) ;
349360
350361 await pxeOracleInterface . syncTaggedLogs ( contractAddress , PENDING_TAGGED_LOG_ARRAY_BASE_SLOT ) ;
351362
352363 // Even if our index as recipient is higher than what the sender sent, we should be able to find the logs
353364 // since the window starts at Math.max(0, 2 - window_size) = 0
354365 await expectPendingTaggedLogArrayLengthToBe ( contractAddress , NUM_SENDERS + 1 + NUM_SENDERS / 2 ) ;
355366
356- // First sender should have 2 logs, but keep index 2 since they were built using the same tag
357- // Next 4 senders should also have index 2 = tagIndex + 1
358- // Last 5 senders should have index 3 = tagIndex + 2
359- const indexes = await taggingDataProvider . getNextIndexesAsRecipient ( secrets ) ;
367+ // First sender should have 2 logs, but keep index 1 since they were built using the same tag
368+ // Next 4 senders should also have index 1 = tagIndex
369+ // Last 5 senders should have index 2 = tagIndex + 1
370+ const indexes = await taggingDataProvider . getLastUsedIndexesAsRecipient ( secrets ) ;
360371
361372 expect ( indexes ) . toHaveLength ( NUM_SENDERS ) ;
362- expect ( indexes ) . toEqual ( [ 2 , 2 , 2 , 2 , 2 , 3 , 3 , 3 , 3 , 3 ] ) ;
373+ expect ( indexes ) . toEqual ( [ 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 ] ) ;
363374
364375 // We should have called the node 2 times:
365376 // first time during initial request, second time after pushing the edge of the window once
@@ -384,19 +395,19 @@ describe('PXEOracleInterface', () => {
384395 ) ,
385396 ) ;
386397
387- // We set the indexes to WINDOW_HALF_SIZE + 1 so that it's outside the window and for this reason no updates
388- // should be triggered.
398+ // We set the last used indexes to WINDOW_HALF_SIZE so that next scan starts at WINDOW_HALF_SIZE + 1,
399+ // which is outside the window, and for this reason no updates should be triggered.
389400 const index = WINDOW_HALF_SIZE + 1 ;
390- await taggingDataProvider . setNextIndexesAsRecipient ( secrets . map ( secret => ( { secret, index } ) ) ) ;
401+ await taggingDataProvider . setLastUsedIndexesAsRecipient ( secrets . map ( secret => ( { secret, index } ) ) ) ;
391402
392403 await pxeOracleInterface . syncTaggedLogs ( contractAddress , PENDING_TAGGED_LOG_ARRAY_BASE_SLOT ) ;
393404
394405 // Only half of the logs should be synced since we start from index 1 = (11 - window_size), the other half should
395406 // be skipped
396407 await expectPendingTaggedLogArrayLengthToBe ( contractAddress , NUM_SENDERS / 2 ) ;
397408
398- // Indexes should remain where we set them (window_size + 1 )
399- const indexes = await taggingDataProvider . getNextIndexesAsRecipient ( secrets ) ;
409+ // Indexes should remain where we set them (window_size)
410+ const indexes = await taggingDataProvider . getLastUsedIndexesAsRecipient ( secrets ) ;
400411
401412 expect ( indexes ) . toHaveLength ( NUM_SENDERS ) ;
402413 expect ( indexes ) . toEqual ( [ index , index , index , index , index , index , index , index , index , index ] ) ;
@@ -423,7 +434,7 @@ describe('PXEOracleInterface', () => {
423434 ) ,
424435 ) ;
425436
426- await taggingDataProvider . setNextIndexesAsRecipient (
437+ await taggingDataProvider . setLastUsedIndexesAsRecipient (
427438 secrets . map ( secret => ( { secret, index : WINDOW_HALF_SIZE + 2 } ) ) ,
428439 ) ;
429440
@@ -443,13 +454,13 @@ describe('PXEOracleInterface', () => {
443454
444455 await pxeOracleInterface . syncTaggedLogs ( contractAddress , PENDING_TAGGED_LOG_ARRAY_BASE_SLOT ) ;
445456
446- // First sender should have 2 logs, but keep index 1 since they were built using the same tag
447- // Next 4 senders should also have index 1 = offset + 1
448- // Last 5 senders should have index 2 = offset + 2
449- const indexes = await taggingDataProvider . getNextIndexesAsRecipient ( secrets ) ;
457+ // First sender should have 2 logs, but keep index 0 since they were built using the same tag
458+ // Next 4 senders should also have index 0 = offset
459+ // Last 5 senders should have index 1 = offset + 1
460+ const indexes = await taggingDataProvider . getLastUsedIndexesAsRecipient ( secrets ) ;
450461
451462 expect ( indexes ) . toHaveLength ( NUM_SENDERS ) ;
452- expect ( indexes ) . toEqual ( [ 1 , 1 , 1 , 1 , 1 , 2 , 2 , 2 , 2 , 2 ] ) ;
463+ expect ( indexes ) . toEqual ( [ 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 ] ) ;
453464
454465 // We should have called the node 2 times:
455466 // first time during initial request, second time after pushing the edge of the window once
0 commit comments