@aztec/pxe 0.0.1-commit.87a0206 → 0.0.1-commit.8f9871590

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 (100) 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/contract_function_simulator/contract_function_simulator.d.ts +53 -29
  5. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.js +168 -64
  7. package/dest/contract_function_simulator/oracle/interfaces.d.ts +2 -2
  8. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/oracle/oracle.d.ts +2 -2
  10. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/oracle/oracle.js +3 -3
  12. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +35 -36
  13. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +71 -18
  15. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +31 -11
  16. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +49 -31
  18. package/dest/contract_sync/contract_sync_service.d.ts +4 -2
  19. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -1
  20. package/dest/contract_sync/contract_sync_service.js +34 -19
  21. package/dest/contract_sync/helpers.d.ts +3 -2
  22. package/dest/contract_sync/helpers.d.ts.map +1 -1
  23. package/dest/contract_sync/helpers.js +3 -3
  24. package/dest/debug/pxe_debug_utils.d.ts +5 -4
  25. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  26. package/dest/debug/pxe_debug_utils.js +1 -1
  27. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  28. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  29. package/dest/entrypoints/client/bundle/index.js +2 -0
  30. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  31. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  32. package/dest/entrypoints/client/bundle/utils.js +9 -1
  33. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  34. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  35. package/dest/entrypoints/client/lazy/index.js +2 -0
  36. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  37. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  38. package/dest/entrypoints/client/lazy/utils.js +9 -1
  39. package/dest/entrypoints/server/index.d.ts +3 -1
  40. package/dest/entrypoints/server/index.d.ts.map +1 -1
  41. package/dest/entrypoints/server/index.js +2 -0
  42. package/dest/entrypoints/server/utils.js +9 -1
  43. package/dest/logs/log_service.d.ts +3 -2
  44. package/dest/logs/log_service.d.ts.map +1 -1
  45. package/dest/logs/log_service.js +5 -10
  46. package/dest/notes/note_service.d.ts +4 -3
  47. package/dest/notes/note_service.d.ts.map +1 -1
  48. package/dest/notes/note_service.js +3 -2
  49. package/dest/notes_filter.d.ts +25 -0
  50. package/dest/notes_filter.d.ts.map +1 -0
  51. package/dest/notes_filter.js +4 -0
  52. package/dest/oracle_version.d.ts +2 -2
  53. package/dest/oracle_version.js +2 -2
  54. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  55. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  56. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  57. package/dest/private_kernel/hints/index.d.ts +1 -1
  58. package/dest/private_kernel/hints/index.js +1 -1
  59. package/dest/private_kernel/private_kernel_execution_prover.js +6 -6
  60. package/dest/pxe.d.ts +57 -22
  61. package/dest/pxe.d.ts.map +1 -1
  62. package/dest/pxe.js +42 -35
  63. package/dest/storage/note_store/note_store.d.ts +3 -3
  64. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  65. package/dest/storage/note_store/note_store.js +3 -4
  66. package/dest/tagging/get_all_logs_by_tags.d.ts +1 -1
  67. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  68. package/dest/tagging/get_all_logs_by_tags.js +17 -3
  69. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +4 -4
  70. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  71. package/package.json +16 -16
  72. package/src/access_scopes.ts +9 -0
  73. package/src/contract_function_simulator/contract_function_simulator.ts +315 -121
  74. package/src/contract_function_simulator/oracle/interfaces.ts +1 -1
  75. package/src/contract_function_simulator/oracle/oracle.ts +3 -3
  76. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +92 -93
  77. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +89 -30
  78. package/src/contract_sync/contract_sync_service.ts +49 -26
  79. package/src/contract_sync/helpers.ts +7 -2
  80. package/src/debug/pxe_debug_utils.ts +8 -6
  81. package/src/entrypoints/client/bundle/index.ts +2 -0
  82. package/src/entrypoints/client/bundle/utils.ts +9 -1
  83. package/src/entrypoints/client/lazy/index.ts +2 -0
  84. package/src/entrypoints/client/lazy/utils.ts +9 -1
  85. package/src/entrypoints/server/index.ts +2 -0
  86. package/src/entrypoints/server/utils.ts +7 -7
  87. package/src/logs/log_service.ts +7 -19
  88. package/src/notes/note_service.ts +4 -3
  89. package/src/notes_filter.ts +26 -0
  90. package/src/oracle_version.ts +2 -2
  91. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  92. package/src/private_kernel/hints/index.ts +1 -1
  93. package/src/private_kernel/private_kernel_execution_prover.ts +6 -6
  94. package/src/pxe.ts +104 -74
  95. package/src/storage/note_store/note_store.ts +8 -5
  96. package/src/tagging/get_all_logs_by_tags.ts +28 -4
  97. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +4 -4
  98. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  99. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  100. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
@@ -3,9 +3,10 @@ import type { Fr } from '@aztec/foundation/schemas';
3
3
  import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@aztec/kv-store';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { DataInBlock } from '@aztec/stdlib/block';
6
- import { NoteDao, NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
6
+ import { NoteDao, NoteStatus } from '@aztec/stdlib/note';
7
7
 
8
8
  import type { StagedStore } from '../../job_coordinator/job_coordinator.js';
9
+ import type { NotesFilter } from '../../notes_filter.js';
9
10
  import { StoredNote } from './stored_note.js';
10
11
 
11
12
  /**
@@ -103,11 +104,10 @@ export class NoteStore implements StagedStore {
103
104
  * @params jobId - the job context to read from.
104
105
  * @returns Filtered and deduplicated notes (a note might be present in multiple scopes - we ensure it is only
105
106
  * returned once if this is the case)
106
- * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
107
107
  */
108
108
  getNotes(filter: NotesFilter, jobId: string): Promise<NoteDao[]> {
109
- if (filter.scopes !== undefined && filter.scopes.length === 0) {
110
- return Promise.reject(new Error('Trying to get notes with an empty scopes array'));
109
+ if (filter.scopes !== 'ALL_SCOPES' && filter.scopes.length === 0) {
110
+ return Promise.resolve([]);
111
111
  }
112
112
 
113
113
  return this.#store.transactionAsync(async () => {
@@ -180,7 +180,10 @@ export class NoteStore implements StagedStore {
180
180
  continue;
181
181
  }
182
182
 
183
- if (filter.scopes && note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0) {
183
+ if (
184
+ filter.scopes !== 'ALL_SCOPES' &&
185
+ note.scopes.intersection(new Set(filter.scopes.map(s => s.toString()))).size === 0
186
+ ) {
184
187
  continue;
185
188
  }
186
189
 
@@ -1,6 +1,6 @@
1
1
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
2
  import type { BlockHash } from '@aztec/stdlib/block';
3
- import { MAX_LOGS_PER_TAG } from '@aztec/stdlib/interfaces/api-limit';
3
+ import { MAX_LOGS_PER_TAG, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/api-limit';
4
4
  import type { AztecNode } from '@aztec/stdlib/interfaces/client';
5
5
  import type { SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
6
6
 
@@ -31,6 +31,26 @@ async function getAllPages<T>(numTags: number, fetchPage: (page: number) => Prom
31
31
  return allResultsPerTag;
32
32
  }
33
33
 
34
+ /**
35
+ * Splits tags into chunks of MAX_RPC_LEN, fetches logs for each chunk using getAllPages, then stitches the results
36
+ * back into a single array preserving the original tag order.
37
+ */
38
+ async function getAllPagesInBatches<Tag, T>(
39
+ tags: Tag[],
40
+ fetchAllPagesForBatch: (batch: Tag[]) => Promise<T[][]>,
41
+ ): Promise<T[][]> {
42
+ if (tags.length <= MAX_RPC_LEN) {
43
+ return fetchAllPagesForBatch(tags);
44
+ }
45
+
46
+ const batches: Tag[][] = [];
47
+ for (let i = 0; i < tags.length; i += MAX_RPC_LEN) {
48
+ batches.push(tags.slice(i, i + MAX_RPC_LEN));
49
+ }
50
+ const batchResults = await Promise.all(batches.map(fetchAllPagesForBatch));
51
+ return batchResults.flat();
52
+ }
53
+
34
54
  /**
35
55
  * Fetches all private logs for the given tags, automatically paginating through all pages.
36
56
  * @param aztecNode - The Aztec node to query.
@@ -44,7 +64,9 @@ export function getAllPrivateLogsByTags(
44
64
  tags: SiloedTag[],
45
65
  anchorBlockHash: BlockHash,
46
66
  ): Promise<TxScopedL2Log[][]> {
47
- return getAllPages(tags.length, page => aztecNode.getPrivateLogsByTags(tags, page, anchorBlockHash));
67
+ return getAllPagesInBatches(tags, batch =>
68
+ getAllPages(batch.length, page => aztecNode.getPrivateLogsByTags(batch, page, anchorBlockHash)),
69
+ );
48
70
  }
49
71
 
50
72
  /**
@@ -62,7 +84,9 @@ export function getAllPublicLogsByTagsFromContract(
62
84
  tags: Tag[],
63
85
  anchorBlockHash: BlockHash,
64
86
  ): Promise<TxScopedL2Log[][]> {
65
- return getAllPages(tags.length, page =>
66
- aztecNode.getPublicLogsByTagsFromContract(contractAddress, tags, page, anchorBlockHash),
87
+ return getAllPagesInBatches(tags, batch =>
88
+ getAllPages(batch.length, page =>
89
+ aztecNode.getPublicLogsByTagsFromContract(contractAddress, batch, page, anchorBlockHash),
90
+ ),
67
91
  );
68
92
  }
@@ -30,7 +30,7 @@ export async function loadPrivateLogsForSenderRecipientPair(
30
30
  // (highestAgedIndex, highestFinalizedIndex + WINDOW_LEN]
31
31
  //
32
32
  // 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.
33
+ // `MAX_TX_LIFETIME` seconds ago.
34
34
  // highestFinalizedIndex is the highest index that was used in a tx that is included in a finalized block.
35
35
  //
36
36
  // "(" denotes an open end of the range - the index is not included in the range.
@@ -42,19 +42,19 @@ export async function loadPrivateLogsForSenderRecipientPair(
42
42
  // ever appear.
43
43
  //
44
44
  // 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
45
+ // - a transaction's maximum inclusion timestamp is at most `MAX_TX_LIFETIME` seconds after
46
46
  // the timestamp of its anchor block; and
47
47
  // - a rollup only includes transactions whose inclusion timestamp is >= the L2 block's timestamp.
48
48
  //
49
49
  // 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
50
+ // least `MAX_TX_LIFETIME` seconds in the past. Then there is no possibility of any *other* device
51
51
  // trying to use an index <= `I` while anchoring to a *newer* block than `B_N` because if we were anchoring to
52
52
  // a newer block than `B_N` then we would already have seen the log with index `I` and hence the device would have
53
53
  // chosen a larger index.
54
54
  // If that *other* device would anchor to a block older than `B_N` then that tx could never be included in a block
55
55
  // because it would already have been expired.
56
56
  //
57
- // Therefore, once we see that index `I` has been used in a block that is at least `MAX_INCLUDE_BY_TIMESTAMP_DURATION`
57
+ // Therefore, once we see that index `I` has been used in a block that is at least `MAX_TX_LIFETIME`
58
58
  // seconds old, we can safely stop syncing logs for all indexes <= `I` and set highestAgedIndex = `I`.
59
59
  //
60
60
  // ## Explanation of the upper bound `highestFinalizedIndex + WINDOW_LEN`
@@ -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,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"}