@aztec/pxe 0.0.1-commit.cd76b27 → 0.0.1-commit.ce4f8c4f2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. package/dest/config/index.d.ts +2 -2
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +1 -1
  4. package/dest/contract_function_simulator/contract_function_simulator.d.ts +9 -3
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +33 -11
  7. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  8. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  10. package/dest/contract_function_simulator/index.d.ts +2 -1
  11. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/index.js +1 -0
  13. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -3
  14. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  15. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -4
  16. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +1 -1
  17. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -3
  19. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts +16 -0
  20. package/dest/contract_function_simulator/noir-structs/message_tx_context.d.ts.map +1 -0
  21. package/dest/contract_function_simulator/noir-structs/message_tx_context.js +57 -0
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -4
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +3 -5
  25. package/dest/contract_function_simulator/oracle/interfaces.d.ts +50 -45
  26. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  28. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  29. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +42 -0
  30. package/dest/contract_function_simulator/oracle/oracle.d.ts +45 -44
  31. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/oracle.js +163 -94
  33. package/dest/contract_function_simulator/oracle/private_execution.js +5 -3
  34. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +22 -47
  35. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +40 -80
  37. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +57 -39
  38. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +138 -63
  40. package/dest/contract_logging.d.ts +22 -0
  41. package/dest/contract_logging.d.ts.map +1 -0
  42. package/dest/contract_logging.js +23 -0
  43. package/dest/contract_sync/contract_sync_service.d.ts +5 -3
  44. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  45. package/dest/contract_sync/contract_sync_service.js +47 -30
  46. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  47. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  48. package/dest/entrypoints/client/bundle/index.js +1 -0
  49. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  50. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  51. package/dest/entrypoints/client/lazy/index.js +1 -0
  52. package/dest/logs/log_service.d.ts +1 -1
  53. package/dest/logs/log_service.d.ts.map +1 -1
  54. package/dest/logs/log_service.js +4 -4
  55. package/dest/messages/message_context_service.d.ts +17 -0
  56. package/dest/messages/message_context_service.d.ts.map +1 -0
  57. package/dest/messages/message_context_service.js +36 -0
  58. package/dest/oracle_version.d.ts +2 -2
  59. package/dest/oracle_version.js +3 -3
  60. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  61. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  62. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +125 -64
  63. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  64. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  65. package/dest/private_kernel/hints/test_utils.js +203 -0
  66. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  67. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  68. package/dest/private_kernel/private_kernel_execution_prover.js +13 -5
  69. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  70. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  71. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  72. package/dest/pxe.d.ts +8 -4
  73. package/dest/pxe.d.ts.map +1 -1
  74. package/dest/pxe.js +55 -33
  75. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  76. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  77. package/dest/storage/contract_store/contract_store.js +140 -64
  78. package/dest/storage/metadata.d.ts +1 -1
  79. package/dest/storage/metadata.js +1 -1
  80. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  81. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  82. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  83. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  84. package/dest/storage/tagging_store/sender_tagging_store.js +141 -115
  85. package/dest/tagging/index.d.ts +3 -3
  86. package/dest/tagging/index.d.ts.map +1 -1
  87. package/dest/tagging/index.js +1 -1
  88. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  89. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  90. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +3 -3
  91. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  92. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  93. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  94. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  95. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  96. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  97. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  98. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  99. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +20 -10
  100. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -7
  101. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  102. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -24
  103. package/package.json +16 -16
  104. package/src/config/index.ts +1 -1
  105. package/src/contract_function_simulator/contract_function_simulator.ts +51 -20
  106. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  107. package/src/contract_function_simulator/index.ts +1 -0
  108. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +8 -5
  109. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -4
  110. package/src/contract_function_simulator/noir-structs/message_tx_context.ts +55 -0
  111. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +3 -6
  112. package/src/contract_function_simulator/oracle/interfaces.ts +54 -54
  113. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +135 -0
  114. package/src/contract_function_simulator/oracle/oracle.ts +176 -138
  115. package/src/contract_function_simulator/oracle/private_execution.ts +4 -4
  116. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +45 -99
  117. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +200 -80
  118. package/src/contract_logging.ts +39 -0
  119. package/src/contract_sync/contract_sync_service.ts +67 -38
  120. package/src/entrypoints/client/bundle/index.ts +1 -0
  121. package/src/entrypoints/client/lazy/index.ts +1 -0
  122. package/src/logs/log_service.ts +10 -5
  123. package/src/messages/message_context_service.ts +45 -0
  124. package/src/oracle_version.ts +3 -3
  125. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +157 -110
  126. package/src/private_kernel/hints/test_utils.ts +325 -0
  127. package/src/private_kernel/private_kernel_execution_prover.ts +13 -6
  128. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  129. package/src/pxe.ts +74 -34
  130. package/src/storage/contract_store/contract_store.ts +170 -71
  131. package/src/storage/metadata.ts +1 -1
  132. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  133. package/src/storage/tagging_store/sender_tagging_store.ts +185 -138
  134. package/src/tagging/index.ts +2 -2
  135. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +3 -6
  136. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  137. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +23 -10
  138. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +26 -11
  139. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +27 -26
@@ -1,7 +1,6 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
1
  import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
5
4
 
6
5
  import type { SenderTaggingStore } from '../../storage/tagging_store/sender_tagging_store.js';
7
6
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -11,11 +10,8 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
11
10
  /**
12
11
  * Syncs tagging indexes. This function needs to be called whenever a private log is being sent.
13
12
  *
14
- * @param secret - The secret that's unique for (sender, recipient, contract) tuple while the direction of
13
+ * @param secret - The secret that's unique for (sender, recipient, app) tuple while the direction of
15
14
  * sender -> recipient matters.
16
- * @param app - The address of the contract that the logs are tagged for. Needs to be provided because we perform
17
- * second round of siloing in this function which is necessary because kernels do it as well (they silo first field
18
- * of the private log which corresponds to the tag).
19
15
  * @remarks When syncing the indexes as sender we don't care about the log contents - we only care about the highest
20
16
  * pending and highest finalized indexes as that guides the next index choice when sending a log. The next index choice
21
17
  * is simply the highest pending index plus one (or finalized if pending is undefined).
@@ -23,8 +19,7 @@ import { loadAndStoreNewTaggingIndexes } from './utils/load_and_store_new_taggin
23
19
  * updates its status accordingly.
24
20
  */
25
21
  export async function syncSenderTaggingIndexes(
26
- secret: DirectionalAppTaggingSecret,
27
- app: AztecAddress,
22
+ secret: ExtendedDirectionalAppTaggingSecret,
28
23
  aztecNode: AztecNode,
29
24
  taggingStore: SenderTaggingStore,
30
25
  anchorBlockHash: BlockHash,
@@ -59,7 +54,7 @@ export async function syncSenderTaggingIndexes(
59
54
  while (true) {
60
55
  // Load and store indexes for the current window. These indexes may already exist in the database if txs using
61
56
  // them were previously sent from this PXE. Any duplicates are handled by the tagging data provider.
62
- await loadAndStoreNewTaggingIndexes(secret, app, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
57
+ await loadAndStoreNewTaggingIndexes(secret, start, end, aztecNode, taggingStore, anchorBlockHash, jobId);
63
58
 
64
59
  // Retrieve all indexes within the current window from storage and update their status accordingly.
65
60
  const pendingTxHashes = await taggingStore.getTxHashesOfPendingIndexes(secret, start, end, jobId);
@@ -67,11 +62,29 @@ export async function syncSenderTaggingIndexes(
67
62
  break;
68
63
  }
69
64
 
70
- const { txHashesToFinalize, txHashesToDrop } = await getStatusChangeOfPending(pendingTxHashes, aztecNode);
65
+ const { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted } = await getStatusChangeOfPending(
66
+ pendingTxHashes,
67
+ aztecNode,
68
+ );
71
69
 
72
70
  await taggingStore.dropPendingIndexes(txHashesToDrop, jobId);
73
71
  await taggingStore.finalizePendingIndexes(txHashesToFinalize, jobId);
74
72
 
73
+ if (txHashesWithExecutionReverted.length > 0) {
74
+ const indexedTxEffects = await Promise.all(
75
+ txHashesWithExecutionReverted.map(txHash => aztecNode.getTxEffect(txHash)),
76
+ );
77
+ for (const indexedTxEffect of indexedTxEffects) {
78
+ if (indexedTxEffect === undefined) {
79
+ throw new Error(
80
+ 'TxEffect not found for execution-reverted tx. This is either a bug or a reorg has occurred.',
81
+ );
82
+ }
83
+
84
+ await taggingStore.finalizePendingIndexesOfAPartiallyRevertedTx(indexedTxEffect.data, jobId);
85
+ }
86
+ }
87
+
75
88
  // We check if the finalized index has been updated.
76
89
  newFinalizedIndex = await taggingStore.getLastFinalizedIndex(secret, jobId);
77
90
  if (previousFinalizedIndex !== newFinalizedIndex) {
@@ -2,35 +2,50 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/server';
2
2
  import { TxHash, TxStatus } from '@aztec/stdlib/tx';
3
3
 
4
4
  /**
5
- * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized or
6
- * dropped.
5
+ * Based on receipts obtained from `aztecNode` returns which pending transactions changed their status to finalized,
6
+ * dropped, or execution-reverted (but mined).
7
7
  */
8
8
  export async function getStatusChangeOfPending(
9
9
  pending: TxHash[],
10
10
  aztecNode: AztecNode,
11
- ): Promise<{ txHashesToFinalize: TxHash[]; txHashesToDrop: TxHash[] }> {
11
+ ): Promise<{
12
+ txHashesToFinalize: TxHash[];
13
+ txHashesToDrop: TxHash[];
14
+ txHashesWithExecutionReverted: TxHash[];
15
+ }> {
12
16
  // Get receipts for all pending tx hashes.
13
17
  const receipts = await Promise.all(pending.map(pendingTxHash => aztecNode.getTxReceipt(pendingTxHash)));
14
18
 
15
19
  const txHashesToFinalize: TxHash[] = [];
16
20
  const txHashesToDrop: TxHash[] = [];
21
+ const txHashesWithExecutionReverted: TxHash[] = [];
17
22
 
18
23
  for (let i = 0; i < receipts.length; i++) {
19
24
  const receipt = receipts[i];
20
25
  const txHash = pending[i];
21
26
 
22
- if (receipt.status === TxStatus.FINALIZED && receipt.hasExecutionSucceeded()) {
23
- // Tx has been included in a block and the corresponding block is finalized --> we mark the indexes as
24
- // finalized.
25
- txHashesToFinalize.push(txHash);
26
- } else if (receipt.isDropped() || receipt.hasExecutionReverted()) {
27
- // Tx was dropped or reverted --> we drop the corresponding pending indexes.
28
- // TODO(#17615): Don't drop pending indexes corresponding to non-revertible phases.
27
+ if (receipt.status === TxStatus.FINALIZED) {
28
+ // Tx has been included in a block and the corresponding block is finalized
29
+ if (receipt.hasExecutionSucceeded()) {
30
+ // No part of execution reverted - we just finalize all the indexes.
31
+ txHashesToFinalize.push(txHash);
32
+ } else if (receipt.hasExecutionReverted()) {
33
+ // Tx was mined but execution reverted (app logic, teardown, or both). Some logs from the non-revertible
34
+ // phase may still be onchain. We check which tags made it onchain and finalize those; drop the rest.
35
+ txHashesWithExecutionReverted.push(txHash);
36
+ } else {
37
+ // Defensive check - this branch should never be triggered
38
+ throw new Error(
39
+ 'Both hasExecutionSucceeded and hasExecutionReverted on the receipt returned false. This should never happen and it implies a bug. Please open an issue.',
40
+ );
41
+ }
42
+ } else if (receipt.isDropped()) {
43
+ // Tx was dropped from the mempool --> we drop the corresponding pending indexes.
29
44
  txHashesToDrop.push(txHash);
30
45
  } else {
31
46
  // Tx is still pending, not yet finalized, or was mined successfully but not yet finalized --> we don't do anything.
32
47
  }
33
48
  }
34
49
 
35
- return { txHashesToFinalize, txHashesToDrop };
50
+ return { txHashesToFinalize, txHashesToDrop, txHashesWithExecutionReverted };
36
51
  }
@@ -1,8 +1,7 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
1
  import type { BlockHash } from '@aztec/stdlib/block';
3
2
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
4
- import type { DirectionalAppTaggingSecret, PreTag } from '@aztec/stdlib/logs';
5
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
3
+ import type { ExtendedDirectionalAppTaggingSecret } from '@aztec/stdlib/logs';
4
+ import { SiloedTag } from '@aztec/stdlib/logs';
6
5
  import { TxHash } from '@aztec/stdlib/tx';
7
6
 
8
7
  import type { SenderTaggingStore } from '../../../storage/tagging_store/sender_tagging_store.js';
@@ -12,19 +11,17 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
12
11
  * Loads tagging indexes from the Aztec node and stores them in the tagging data provider.
13
12
  * @remarks This function is one of two places by which a pending index can get to the tagging data provider. The other
14
13
  * place is when a tx is being sent from this PXE.
15
- * @param secret - The directional app tagging secret that's unique for (sender, recipient, contract) tuple.
16
- * @param app - The address of the contract that the logs are tagged for. Used for siloing tags to match
17
- * kernel circuit behavior.
14
+ * @param extendedSecret - The extended directional app tagging secret that's unique for (sender, recipient, app) tuple.
18
15
  * @param start - The starting index (inclusive) of the window to process.
19
16
  * @param end - The ending index (exclusive) of the window to process.
20
17
  * @param aztecNode - The Aztec node instance to query for logs.
21
18
  * @param taggingStore - The data provider to store pending indexes.
19
+ * @param anchorBlockHash - Hash of a block to use as reference block when querying node.
22
20
  * @param jobId - Job identifier, used to keep writes in-memory until they can be persisted in a data integrity
23
21
  * preserving way.
24
22
  */
25
23
  export async function loadAndStoreNewTaggingIndexes(
26
- secret: DirectionalAppTaggingSecret,
27
- app: AztecAddress,
24
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
28
25
  start: number,
29
26
  end: number,
30
27
  aztecNode: AztecNode,
@@ -33,20 +30,18 @@ export async function loadAndStoreNewTaggingIndexes(
33
30
  jobId: string,
34
31
  ) {
35
32
  // We compute the tags for the current window of indexes
36
- const preTagsForWindow: PreTag[] = Array(end - start)
37
- .fill(0)
38
- .map((_, i) => ({ secret, index: start + i }));
39
33
  const siloedTagsForWindow = await Promise.all(
40
- preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
34
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
41
35
  );
42
36
 
43
37
  const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
44
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
38
+ const txIndexesMap = getTxIndexesMap(txsForTags, start, siloedTagsForWindow.length);
45
39
 
46
- // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
47
- for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
40
+ // Now we iterate over the map, construct the tagging index ranges and store them in the db.
41
+ for (const [txHashStr, indexes] of txIndexesMap.entries()) {
48
42
  const txHash = TxHash.fromString(txHashStr);
49
- await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash, jobId);
43
+ const ranges = [{ extendedSecret, lowestIndex: Math.min(...indexes), highestIndex: Math.max(...indexes) }];
44
+ await taggingStore.storePendingIndexes(ranges, txHash, jobId);
50
45
  }
51
46
  }
52
47
 
@@ -63,22 +58,28 @@ async function getTxsContainingTags(
63
58
  return allLogs.map(logs => logs.map(log => log.txHash));
64
59
  }
65
60
 
66
- // Returns a map of txHash to the highest index for that txHash.
67
- function getTxHighestIndexMap(txHashesForTags: TxHash[][], preTagsForWindow: PreTag[]): Map<string, number> {
68
- if (txHashesForTags.length !== preTagsForWindow.length) {
69
- throw new Error(
70
- `Number of tx hashes arrays does not match number of pre-tags. ${txHashesForTags.length} !== ${preTagsForWindow.length}`,
71
- );
61
+ // Returns a map of txHash to all indexes for that txHash.
62
+ function getTxIndexesMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number[]> {
63
+ if (txHashesForTags.length !== count) {
64
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
72
65
  }
73
66
 
74
- const highestIndexMap = new Map<string, number>();
67
+ const indexesMap = new Map<string, number[]>();
68
+ // Iterate over indexes
75
69
  for (let i = 0; i < txHashesForTags.length; i++) {
76
- const taggingIndex = preTagsForWindow[i].index;
70
+ const taggingIndex = start + i;
77
71
  const txHashesForTag = txHashesForTags[i];
72
+ // iterate over tx hashes that used that index (tag)
78
73
  for (const txHash of txHashesForTag) {
79
74
  const key = txHash.toString();
80
- highestIndexMap.set(key, Math.max(highestIndexMap.get(key) ?? 0, taggingIndex));
75
+ const existing = indexesMap.get(key);
76
+ // Add the index to the tx's indexes
77
+ if (existing) {
78
+ existing.push(taggingIndex);
79
+ } else {
80
+ indexesMap.set(key, [taggingIndex]);
81
+ }
81
82
  }
82
83
  }
83
- return highestIndexMap;
84
+ return indexesMap;
84
85
  }