@aztec/pxe 0.0.1-commit.d6f2b3f94 → 0.0.1-commit.dbf9cec

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 (159) hide show
  1. package/dest/access_scopes.d.ts +9 -0
  2. package/dest/access_scopes.d.ts.map +1 -0
  3. package/dest/access_scopes.js +6 -0
  4. package/dest/config/package_info.js +1 -1
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts +53 -29
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.js +172 -68
  8. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +5 -5
  9. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/execution_tagging_index_cache.js +3 -3
  11. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  12. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +2 -2
  13. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  15. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  16. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
  18. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/oracle/oracle.js +2 -2
  20. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -36
  21. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +71 -26
  23. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +30 -12
  24. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +36 -36
  26. package/dest/contract_logging.d.ts +22 -0
  27. package/dest/contract_logging.d.ts.map +1 -0
  28. package/dest/contract_logging.js +23 -0
  29. package/dest/contract_sync/contract_sync_service.d.ts +4 -2
  30. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  31. package/dest/contract_sync/contract_sync_service.js +34 -19
  32. package/dest/contract_sync/helpers.d.ts +3 -2
  33. package/dest/contract_sync/helpers.d.ts.map +1 -1
  34. package/dest/contract_sync/helpers.js +3 -3
  35. package/dest/debug/pxe_debug_utils.d.ts +5 -4
  36. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  37. package/dest/debug/pxe_debug_utils.js +4 -4
  38. package/dest/entrypoints/client/bundle/index.d.ts +4 -1
  39. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  40. package/dest/entrypoints/client/bundle/index.js +3 -0
  41. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  42. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  43. package/dest/entrypoints/client/bundle/utils.js +9 -1
  44. package/dest/entrypoints/client/lazy/index.d.ts +4 -1
  45. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  46. package/dest/entrypoints/client/lazy/index.js +3 -0
  47. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  48. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  49. package/dest/entrypoints/client/lazy/utils.js +9 -1
  50. package/dest/entrypoints/server/index.d.ts +3 -1
  51. package/dest/entrypoints/server/index.d.ts.map +1 -1
  52. package/dest/entrypoints/server/index.js +2 -0
  53. package/dest/entrypoints/server/utils.js +9 -1
  54. package/dest/logs/log_service.d.ts +3 -2
  55. package/dest/logs/log_service.d.ts.map +1 -1
  56. package/dest/logs/log_service.js +9 -14
  57. package/dest/notes/note_service.d.ts +4 -3
  58. package/dest/notes/note_service.d.ts.map +1 -1
  59. package/dest/notes/note_service.js +3 -2
  60. package/dest/notes_filter.d.ts +25 -0
  61. package/dest/notes_filter.d.ts.map +1 -0
  62. package/dest/notes_filter.js +4 -0
  63. package/dest/oracle_version.d.ts +2 -2
  64. package/dest/oracle_version.js +2 -2
  65. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  66. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  67. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  68. package/dest/private_kernel/hints/index.d.ts +1 -1
  69. package/dest/private_kernel/hints/index.js +1 -1
  70. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  71. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  72. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  73. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  74. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  75. package/dest/private_kernel/hints/test_utils.js +203 -0
  76. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  77. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  78. package/dest/private_kernel/private_kernel_execution_prover.js +19 -11
  79. package/dest/private_kernel/private_kernel_oracle.d.ts +6 -2
  80. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  81. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  82. package/dest/pxe.d.ts +58 -23
  83. package/dest/pxe.d.ts.map +1 -1
  84. package/dest/pxe.js +65 -53
  85. package/dest/storage/contract_store/contract_store.d.ts +42 -15
  86. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  87. package/dest/storage/contract_store/contract_store.js +140 -64
  88. package/dest/storage/note_store/note_store.d.ts +3 -3
  89. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  90. package/dest/storage/note_store/note_store.js +3 -4
  91. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  92. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  93. package/dest/storage/tagging_store/sender_tagging_store.d.ts +5 -5
  94. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  95. package/dest/storage/tagging_store/sender_tagging_store.js +4 -4
  96. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  97. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  98. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  99. package/dest/tagging/index.d.ts +2 -2
  100. package/dest/tagging/index.d.ts.map +1 -1
  101. package/dest/tagging/index.js +1 -1
  102. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +4 -5
  103. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  104. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  105. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  106. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +6 -7
  107. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  108. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +12 -11
  109. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +4 -8
  110. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  111. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +3 -6
  112. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -7
  113. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  114. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +14 -15
  115. package/package.json +16 -16
  116. package/src/access_scopes.ts +9 -0
  117. package/src/config/package_info.ts +1 -1
  118. package/src/contract_function_simulator/contract_function_simulator.ts +320 -128
  119. package/src/contract_function_simulator/execution_tagging_index_cache.ts +5 -5
  120. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  121. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  122. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  123. package/src/contract_function_simulator/oracle/oracle.ts +2 -2
  124. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +95 -102
  125. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +77 -33
  126. package/src/contract_logging.ts +39 -0
  127. package/src/contract_sync/contract_sync_service.ts +49 -26
  128. package/src/contract_sync/helpers.ts +7 -2
  129. package/src/debug/pxe_debug_utils.ts +11 -9
  130. package/src/entrypoints/client/bundle/index.ts +3 -0
  131. package/src/entrypoints/client/bundle/utils.ts +9 -1
  132. package/src/entrypoints/client/lazy/index.ts +3 -0
  133. package/src/entrypoints/client/lazy/utils.ts +9 -1
  134. package/src/entrypoints/server/index.ts +2 -0
  135. package/src/entrypoints/server/utils.ts +7 -7
  136. package/src/logs/log_service.ts +17 -24
  137. package/src/notes/note_service.ts +4 -3
  138. package/src/notes_filter.ts +26 -0
  139. package/src/oracle_version.ts +2 -2
  140. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  141. package/src/private_kernel/hints/index.ts +1 -1
  142. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  143. package/src/private_kernel/hints/test_utils.ts +325 -0
  144. package/src/private_kernel/private_kernel_execution_prover.ts +19 -12
  145. package/src/private_kernel/private_kernel_oracle.ts +7 -7
  146. package/src/pxe.ts +132 -98
  147. package/src/storage/contract_store/contract_store.ts +170 -71
  148. package/src/storage/note_store/note_store.ts +8 -5
  149. package/src/storage/tagging_store/recipient_tagging_store.ts +9 -5
  150. package/src/storage/tagging_store/sender_tagging_store.ts +8 -8
  151. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  152. package/src/tagging/index.ts +1 -1
  153. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +7 -10
  154. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  155. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +10 -15
  156. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +4 -9
  157. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +11 -20
  158. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  159. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -1,8 +1,7 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
2
  import type { BlockHash } from '@aztec/stdlib/block';
4
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
- import type { DirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
6
5
 
7
6
  import type { RecipientTaggingStore } from '../../storage/tagging_store/recipient_tagging_store.js';
8
7
  import { UNFINALIZED_TAGGING_INDEXES_WINDOW_LEN } from '../constants.js';
@@ -10,15 +9,14 @@ import { findHighestIndexes } from './utils/find_highest_indexes.js';
10
9
  import { loadLogsForRange } from './utils/load_logs_for_range.js';
11
10
 
12
11
  /**
13
- * Loads private logs for `app` and sender-recipient pair defined by `secret` and updates the highest aged and
12
+ * Loads private logs for the app-sender-recipient triplet defined by `secret` and updates the highest aged and
14
13
  * finalized indexes in the db. At most load logs from blocks up to and including `anchorBlockNumber`.
15
14
  *
16
15
  * @dev This function can be safely executed "in parallel" for other sender-recipient pairs because the data in
17
16
  * in the tagging data provider is indexed by the secret and hence completely disjoint.
18
17
  */
19
18
  export async function loadPrivateLogsForSenderRecipientPair(
20
- secret: DirectionalAppTaggingSecret,
21
- app: AztecAddress,
19
+ secret: ExtendedDirectionalAppTaggingSecret,
22
20
  aztecNode: AztecNode,
23
21
  taggingStore: RecipientTaggingStore,
24
22
  anchorBlockNumber: BlockNumber,
@@ -30,7 +28,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
30
28
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
31
29
  //
32
30
  // highestAgedIndex is the highest index that was used in a tx that is included in a block at least
33
- // `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds ago.
31
+ // `MAX_TX_LIFETIME` seconds ago.
34
32
  // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
35
33
  //
36
34
  // "(" denotes an open end of the range - the index is not included in the range.
@@ -42,19 +40,19 @@ export async function loadPrivateLogsForSenderRecipientPair(
42
40
  // ever appear.
43
41
  //
44
42
  // This relies on the "maximum inclusion timestamp" rule enforced by the kernel and rollup circuits:
45
- // - a transaction's maximum inclusion timestamp is at most `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds after
43
+ // - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
46
44
  // the timestamp of its anchor block; and
47
45
  // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
48
46
  //
49
47
  // Suppose some device used index `I` in a transaction anchored to block `B_N` at time `N`, and that block is now at
50
- // least `MAX_INCLUDE_BY_TIMESTAMP_DURATION` seconds in the past. Then there is no possibility of any *other* device
48
+ // least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
51
49
  // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
52
50
  // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
53
51
  // chosen a larger index.
54
52
  // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
55
53
  // because it would already have been expired.
56
54
  //
57
- // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
55
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
58
56
  // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
59
57
  //
60
58
  // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
@@ -96,7 +94,6 @@ export async function loadPrivateLogsForSenderRecipientPair(
96
94
  // Get private logs with their block timestamps and corresponding tagging indexes
97
95
  const privateLogsWithIndexes = await loadLogsForRange(
98
96
  secret,
99
- app,
100
97
  aztecNode,
101
98
  start,
102
99
  end,
@@ -1,4 +1,4 @@
1
- import { MAX_INCLUDE_BY_TIMESTAMP_DURATION } from '@aztec/constants';
1
+ import { MAX_TX_LIFETIME } from '@aztec/constants';
2
2
  import type { TxScopedL2Log } from '@aztec/stdlib/logs';
3
3
 
4
4
  /**
@@ -16,7 +16,7 @@ export function findHighestIndexes(
16
16
  const ageInSeconds = currentTimestamp - log.blockTimestamp;
17
17
 
18
18
  if (
19
- ageInSeconds >= BigInt(MAX_INCLUDE_BY_TIMESTAMP_DURATION) &&
19
+ ageInSeconds >= BigInt(MAX_TX_LIFETIME) &&
20
20
  (highestAgedIndex === undefined || taggingIndex > highestAgedIndex)
21
21
  ) {
22
22
  highestAgedIndex = taggingIndex;
@@ -1,32 +1,27 @@
1
1
  import type { BlockNumber } from '@aztec/foundation/branded-types';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
2
  import type { BlockHash } from '@aztec/stdlib/block';
4
3
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
- import type { DirectionalAppTaggingSecret, PreTag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
- import { SiloedTag, Tag } from '@aztec/stdlib/logs';
4
+ import type { ExtendedDirectionalAppTaggingSecret, TxScopedL2Log } from '@aztec/stdlib/logs';
5
+ import { SiloedTag } from '@aztec/stdlib/logs';
7
6
 
8
7
  import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
9
8
 
10
9
  /**
11
- * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range, `app` and
12
- * `secret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and `end` is
13
- * exclusive.
10
+ * Gets private logs with their corresponding block timestamps and tagging indexes for the given index range and
11
+ * `extendedSecret`. At most load logs from blocks up to and including `anchorBlockNumber`. `start` is inclusive and
12
+ * `end` is exclusive.
14
13
  */
15
14
  export async function loadLogsForRange(
16
- secret: DirectionalAppTaggingSecret,
17
- app: AztecAddress,
15
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
18
16
  aztecNode: AztecNode,
19
17
  start: number,
20
18
  end: number,
21
19
  anchorBlockNumber: BlockNumber,
22
20
  anchorBlockHash: BlockHash,
23
21
  ): Promise<Array<{ log: TxScopedL2Log; taggingIndex: number }>> {
24
- // Derive tags for the window
25
- const preTags: PreTag[] = Array(end - start)
26
- .fill(0)
27
- .map((_, i) => ({ secret, index: start + i }));
28
- const siloedTags = await Promise.all(preTags.map(preTag => Tag.compute(preTag))).then(tags =>
29
- Promise.all(tags.map(tag => SiloedTag.compute(tag, app))),
22
+ // Derive siloed tags for the window
23
+ const siloedTags = await Promise.all(
24
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
30
25
  );
31
26
 
32
27
  // We use the utility function below to retrieve all logs for the tags across all pages, so we don't need to handle
@@ -37,7 +32,7 @@ export async function loadLogsForRange(
37
32
  const logsWithIndexes: Array<{ log: TxScopedL2Log; taggingIndex: number }> = [];
38
33
  for (let i = 0; i < logs.length; i++) {
39
34
  const logsForTag = logs[i];
40
- const taggingIndex = preTags[i].index;
35
+ const taggingIndex = start + i;
41
36
  for (const log of logsForTag) {
42
37
  if (log.blockNumber <= anchorBlockNumber) {
43
38
  logsWithIndexes.push({ log, taggingIndex });
@@ -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);
@@ -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,9 +11,7 @@ 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.
@@ -23,8 +20,7 @@ import { getAllPrivateLogsByTags } from '../../get_all_logs_by_tags.js';
23
20
  * preserving way.
24
21
  */
25
22
  export async function loadAndStoreNewTaggingIndexes(
26
- secret: DirectionalAppTaggingSecret,
27
- app: AztecAddress,
23
+ extendedSecret: ExtendedDirectionalAppTaggingSecret,
28
24
  start: number,
29
25
  end: number,
30
26
  aztecNode: AztecNode,
@@ -33,20 +29,17 @@ export async function loadAndStoreNewTaggingIndexes(
33
29
  jobId: string,
34
30
  ) {
35
31
  // 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
32
  const siloedTagsForWindow = await Promise.all(
40
- preTagsForWindow.map(async preTag => SiloedTag.compute(await Tag.compute(preTag), app)),
33
+ Array.from({ length: end - start }, (_, i) => SiloedTag.compute({ extendedSecret, index: start + i })),
41
34
  );
42
35
 
43
36
  const txsForTags = await getTxsContainingTags(siloedTagsForWindow, aztecNode, anchorBlockHash);
44
- const highestIndexMap = getTxHighestIndexMap(txsForTags, preTagsForWindow);
37
+ const highestIndexMap = getTxHighestIndexMap(txsForTags, start, siloedTagsForWindow.length);
45
38
 
46
39
  // Now we iterate over the map, reconstruct the preTags and tx hash and store them in the db.
47
40
  for (const [txHashStr, highestIndex] of highestIndexMap.entries()) {
48
41
  const txHash = TxHash.fromString(txHashStr);
49
- await taggingStore.storePendingIndexes([{ secret, index: highestIndex }], txHash, jobId);
42
+ await taggingStore.storePendingIndexes([{ extendedSecret, index: highestIndex }], txHash, jobId);
50
43
  }
51
44
  }
52
45
 
@@ -64,16 +57,14 @@ async function getTxsContainingTags(
64
57
  }
65
58
 
66
59
  // 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
- );
60
+ function getTxHighestIndexMap(txHashesForTags: TxHash[][], start: number, count: number): Map<string, number> {
61
+ if (txHashesForTags.length !== count) {
62
+ throw new Error(`Number of tx hashes arrays does not match number of tags. ${txHashesForTags.length} !== ${count}`);
72
63
  }
73
64
 
74
65
  const highestIndexMap = new Map<string, number>();
75
66
  for (let i = 0; i < txHashesForTags.length; i++) {
76
- const taggingIndex = preTagsForWindow[i].index;
67
+ const taggingIndex = start + i;
77
68
  const txHashesForTag = txHashesForTags[i];
78
69
  for (const txHash of txHashesForTag) {
79
70
  const key = txHash.toString();
@@ -1,4 +0,0 @@
1
- import type { PrivateKernelCircuitPublicInputs } from '@aztec/stdlib/kernel';
2
- import type { UInt64 } from '@aztec/stdlib/types';
3
- export declare function computeTxIncludeByTimestamp(previousKernel: PrivateKernelCircuitPublicInputs, maxDuration?: number): UInt64;
4
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tcHV0ZV90eF9pbmNsdWRlX2J5X3RpbWVzdGFtcC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3ByaXZhdGVfa2VybmVsL2hpbnRzL2NvbXB1dGVfdHhfaW5jbHVkZV9ieV90aW1lc3RhbXAudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0NBQWdDLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUM3RSxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQXFCbEQsd0JBQWdCLDJCQUEyQixDQUN6QyxjQUFjLEVBQUUsZ0NBQWdDLEVBQ2hELFdBQVcsU0FBb0MsR0FDOUMsTUFBTSxDQStCUiJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"compute_tx_include_by_timestamp.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/compute_tx_include_by_timestamp.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAqBlD,wBAAgB,2BAA2B,CACzC,cAAc,EAAE,gCAAgC,EAChD,WAAW,SAAoC,GAC9C,MAAM,CA+BR"}