@aztec/pxe 0.0.1-commit.3100065 → 0.0.1-commit.330febf

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 (207) hide show
  1. package/dest/bin/check_oracle_version.js +5 -46
  2. package/dest/bin/index.d.ts +2 -2
  3. package/dest/bin/index.d.ts.map +1 -1
  4. package/dest/bin/index.js +1 -1
  5. package/dest/bin/oracle_version_helpers.d.ts +8 -39
  6. package/dest/bin/oracle_version_helpers.d.ts.map +1 -1
  7. package/dest/bin/oracle_version_helpers.js +10 -239
  8. package/dest/block_synchronizer/block_synchronizer.d.ts +3 -5
  9. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  10. package/dest/block_synchronizer/block_synchronizer.js +5 -18
  11. package/dest/config/package_info.js +1 -1
  12. package/dest/contract/contract_class_service.d.ts +1 -8
  13. package/dest/contract/contract_class_service.d.ts.map +1 -1
  14. package/dest/contract/contract_class_service.js +8 -40
  15. package/dest/contract/helpers.d.ts +1 -1
  16. package/dest/contract/helpers.d.ts.map +1 -1
  17. package/dest/contract/helpers.js +3 -3
  18. package/dest/contract/skip_sync_contracts.d.ts +11 -0
  19. package/dest/contract/skip_sync_contracts.d.ts.map +1 -0
  20. package/dest/contract/skip_sync_contracts.js +18 -0
  21. package/dest/contract_function_simulator/contract_function_simulator.d.ts +1 -8
  22. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/contract_function_simulator.js +5 -20
  24. package/dest/contract_function_simulator/index.d.ts +3 -3
  25. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/index.js +1 -2
  27. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts +7 -9
  28. package/dest/contract_function_simulator/noir-structs/resolved_tx.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/resolved_tx.js +3 -44
  30. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts +5 -4
  31. package/dest/contract_function_simulator/noir-structs/tx_effect_data.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/noir-structs/tx_effect_data.js +2 -2
  33. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts +4 -3
  34. package/dest/contract_function_simulator/oracle/oracle_registry.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/oracle_registry.js +15 -6
  36. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts +87 -35
  37. package/dest/contract_function_simulator/oracle/oracle_type_mappings.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/oracle_type_mappings.js +297 -287
  39. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +1 -1
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +11 -8
  42. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +15 -4
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +168 -53
  45. package/dest/entrypoints/client/bundle/index.d.ts +2 -1
  46. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  47. package/dest/entrypoints/client/bundle/index.js +1 -0
  48. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  49. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  50. package/dest/entrypoints/client/bundle/utils.js +10 -4
  51. package/dest/entrypoints/client/lazy/index.d.ts +2 -1
  52. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  53. package/dest/entrypoints/client/lazy/index.js +1 -0
  54. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  55. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  56. package/dest/entrypoints/client/lazy/utils.js +10 -4
  57. package/dest/entrypoints/client/store.d.ts +14 -0
  58. package/dest/entrypoints/client/store.d.ts.map +1 -0
  59. package/dest/entrypoints/client/store.js +42 -0
  60. package/dest/entrypoints/server/index.d.ts +2 -1
  61. package/dest/entrypoints/server/index.d.ts.map +1 -1
  62. package/dest/entrypoints/server/index.js +1 -0
  63. package/dest/entrypoints/server/store.d.ts +18 -0
  64. package/dest/entrypoints/server/store.d.ts.map +1 -0
  65. package/dest/entrypoints/server/store.js +28 -0
  66. package/dest/entrypoints/server/utils.d.ts +1 -1
  67. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  68. package/dest/entrypoints/server/utils.js +8 -2
  69. package/dest/events/event_service.d.ts +13 -6
  70. package/dest/events/event_service.d.ts.map +1 -1
  71. package/dest/events/event_service.js +13 -13
  72. package/dest/logs/log_service.d.ts +15 -6
  73. package/dest/logs/log_service.d.ts.map +1 -1
  74. package/dest/logs/log_service.js +25 -32
  75. package/dest/messages/tx_resolver_service.d.ts +18 -7
  76. package/dest/messages/tx_resolver_service.d.ts.map +1 -1
  77. package/dest/messages/tx_resolver_service.js +13 -7
  78. package/dest/node/benchmarked_node.d.ts +20 -0
  79. package/dest/node/benchmarked_node.d.ts.map +1 -0
  80. package/dest/node/benchmarked_node.js +94 -0
  81. package/dest/node/caching_aztec_node.d.ts +24 -0
  82. package/dest/node/caching_aztec_node.d.ts.map +1 -0
  83. package/dest/node/caching_aztec_node.js +267 -0
  84. package/dest/notes/note_service.d.ts +13 -7
  85. package/dest/notes/note_service.d.ts.map +1 -1
  86. package/dest/notes/note_service.js +10 -10
  87. package/dest/oracle_version.d.ts +2 -2
  88. package/dest/oracle_version.js +5 -5
  89. package/dest/private_kernel/batch_planner.d.ts +1 -1
  90. package/dest/private_kernel/batch_planner.d.ts.map +1 -1
  91. package/dest/private_kernel/batch_planner.js +1 -1
  92. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  93. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  94. package/dest/private_kernel/private_kernel_execution_prover.js +45 -5
  95. package/dest/pxe.d.ts +1 -1
  96. package/dest/pxe.d.ts.map +1 -1
  97. package/dest/pxe.js +39 -19
  98. package/dest/storage/contract_store/contract_store.d.ts +1 -1
  99. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  100. package/dest/storage/contract_store/contract_store.js +2 -2
  101. package/dest/storage/fact_store/fact_store.d.ts +1 -1
  102. package/dest/storage/fact_store/fact_store.js +1 -1
  103. package/dest/storage/fact_store/index.d.ts +2 -2
  104. package/dest/storage/fact_store/index.d.ts.map +1 -1
  105. package/dest/storage/fact_store/index.js +1 -1
  106. package/dest/storage/fact_store/origin_state.d.ts +4 -2
  107. package/dest/storage/fact_store/origin_state.d.ts.map +1 -1
  108. package/dest/storage/fact_store/origin_state.js +8 -1
  109. package/dest/storage/store_identity.d.ts +35 -0
  110. package/dest/storage/store_identity.d.ts.map +1 -0
  111. package/dest/storage/store_identity.js +44 -0
  112. package/dest/storage/tagging_store/sender_tagging_store.d.ts +41 -10
  113. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  114. package/dest/storage/tagging_store/sender_tagging_store.js +81 -29
  115. package/dest/tagging/constants.d.ts +10 -1
  116. package/dest/tagging/constants.d.ts.map +1 -1
  117. package/dest/tagging/constants.js +19 -0
  118. package/dest/tagging/get_all_logs_by_tags.d.ts +29 -8
  119. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -1
  120. package/dest/tagging/get_all_logs_by_tags.js +29 -10
  121. package/dest/tagging/index.d.ts +3 -3
  122. package/dest/tagging/index.d.ts.map +1 -1
  123. package/dest/tagging/index.js +2 -2
  124. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts +10 -5
  125. package/dest/tagging/recipient_sync/sync_tagged_private_logs.d.ts.map +1 -1
  126. package/dest/tagging/recipient_sync/sync_tagged_private_logs.js +69 -38
  127. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +6 -3
  128. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  129. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +23 -38
  130. package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts +22 -0
  131. package/dest/tagging/sender_sync/utils/classify_pending_txs.d.ts.map +1 -0
  132. package/dest/tagging/sender_sync/utils/classify_pending_txs.js +61 -0
  133. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +15 -5
  134. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  135. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +36 -35
  136. package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts +29 -0
  137. package/dest/tagging/sender_sync/utils/resolve_pending_txs.d.ts.map +1 -0
  138. package/dest/tagging/sender_sync/utils/resolve_pending_txs.js +41 -0
  139. package/dest/tagging/sender_sync/utils/test_utils.d.ts +16 -0
  140. package/dest/tagging/sender_sync/utils/test_utils.d.ts.map +1 -0
  141. package/dest/tagging/sender_sync/utils/test_utils.js +24 -0
  142. package/dest/tagging/testing/tag_query_test_utils.d.ts +6 -0
  143. package/dest/tagging/testing/tag_query_test_utils.d.ts.map +1 -0
  144. package/dest/tagging/testing/tag_query_test_utils.js +10 -0
  145. package/package.json +17 -17
  146. package/src/bin/check_oracle_version.ts +5 -56
  147. package/src/bin/index.ts +1 -5
  148. package/src/bin/oracle_version_helpers.ts +11 -292
  149. package/src/block_synchronizer/block_synchronizer.ts +6 -23
  150. package/src/config/package_info.ts +1 -1
  151. package/src/contract/contract_class_service.ts +8 -46
  152. package/src/contract/helpers.ts +3 -3
  153. package/src/contract/skip_sync_contracts.ts +23 -0
  154. package/src/contract_function_simulator/contract_function_simulator.ts +5 -20
  155. package/src/contract_function_simulator/index.ts +23 -3
  156. package/src/contract_function_simulator/noir-structs/resolved_tx.ts +11 -45
  157. package/src/contract_function_simulator/noir-structs/tx_effect_data.ts +4 -3
  158. package/src/contract_function_simulator/oracle/oracle_registry.ts +12 -8
  159. package/src/contract_function_simulator/oracle/oracle_type_mappings.ts +301 -198
  160. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +19 -9
  161. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +184 -56
  162. package/src/entrypoints/client/bundle/index.ts +1 -0
  163. package/src/entrypoints/client/bundle/utils.ts +15 -3
  164. package/src/entrypoints/client/lazy/index.ts +1 -0
  165. package/src/entrypoints/client/lazy/utils.ts +15 -3
  166. package/src/entrypoints/client/store.ts +54 -0
  167. package/src/entrypoints/server/index.ts +1 -0
  168. package/src/entrypoints/server/store.ts +47 -0
  169. package/src/entrypoints/server/utils.ts +21 -7
  170. package/src/events/event_service.ts +24 -14
  171. package/src/logs/log_service.ts +41 -39
  172. package/src/messages/tx_resolver_service.ts +26 -15
  173. package/src/node/benchmarked_node.ts +140 -0
  174. package/src/node/caching_aztec_node.ts +406 -0
  175. package/src/notes/note_service.ts +20 -14
  176. package/src/oracle_version.ts +5 -5
  177. package/src/private_kernel/batch_planner.ts +0 -1
  178. package/src/private_kernel/private_kernel_execution_prover.ts +90 -4
  179. package/src/pxe.ts +40 -21
  180. package/src/storage/contract_store/contract_store.ts +2 -1
  181. package/src/storage/fact_store/fact_store.ts +1 -1
  182. package/src/storage/fact_store/index.ts +1 -0
  183. package/src/storage/fact_store/origin_state.ts +10 -1
  184. package/src/storage/store_identity.ts +72 -0
  185. package/src/storage/tagging_store/sender_tagging_store.ts +113 -41
  186. package/src/tagging/constants.ts +22 -0
  187. package/src/tagging/get_all_logs_by_tags.ts +47 -11
  188. package/src/tagging/index.ts +7 -2
  189. package/src/tagging/recipient_sync/sync_tagged_private_logs.ts +116 -62
  190. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +27 -57
  191. package/src/tagging/sender_sync/utils/classify_pending_txs.ts +91 -0
  192. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +46 -40
  193. package/src/tagging/sender_sync/utils/resolve_pending_txs.ts +64 -0
  194. package/src/tagging/sender_sync/utils/test_utils.ts +46 -0
  195. package/src/tagging/testing/tag_query_test_utils.ts +11 -0
  196. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts +0 -39
  197. package/dest/contract_function_simulator/aztec_node_read_cache.d.ts.map +0 -1
  198. package/dest/contract_function_simulator/aztec_node_read_cache.js +0 -60
  199. package/dest/contract_function_simulator/benchmarked_node.d.ts +0 -9
  200. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +0 -1
  201. package/dest/contract_function_simulator/benchmarked_node.js +0 -77
  202. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +0 -17
  203. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +0 -1
  204. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +0 -60
  205. package/src/contract_function_simulator/aztec_node_read_cache.ts +0 -89
  206. package/src/contract_function_simulator/benchmarked_node.ts +0 -103
  207. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +0 -66
@@ -1,75 +1,11 @@
1
- /* eslint-disable import-x/no-named-as-default-member */
2
- import { readFileSync } from 'fs';
3
- import ts from 'typescript';
1
+ import type { OracleRegistryEntry } from '../contract_function_simulator/index.js';
4
2
 
5
3
  /**
6
- * Extracts method signatures from TypeScript classes or interfaces and returns a deterministic string representation.
4
+ * Extracts a deterministic signature string from an oracle registry (e.g. PXE's `ORACLE_REGISTRY`).
7
5
  *
8
- * This is used to detect when an oracle interface changes so that the oracle version can be bumped. It works with both
9
- * class declarations (e.g. PXE's `Oracle` class) and interface declarations (e.g. TXE's `IAvmExecutionOracle`).
10
- *
11
- * @param sourcePath - Absolute path to the TypeScript source file to parse.
12
- * @param targets - Names of classes or interfaces to extract methods from.
13
- * @param excludedMembers - Method names to skip (e.g. non-oracle helpers like `constructor`).
14
- */
15
- export function getOracleInterfaceSignature(sourcePath: string, targets: string[], excludedMembers: string[]): string {
16
- const sourceCode = readFileSync(sourcePath, 'utf-8');
17
- const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
18
-
19
- const methodSignatures: string[] = [];
20
-
21
- function visit(node: ts.Node) {
22
- const isTarget =
23
- (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) && targets.includes(node.name?.text ?? '');
24
-
25
- if (isTarget) {
26
- node.members.forEach(member => {
27
- if (
28
- (ts.isMethodDeclaration(member) || ts.isMethodSignature(member)) &&
29
- member.name &&
30
- ts.isIdentifier(member.name)
31
- ) {
32
- const methodName = member.name.text;
33
-
34
- if (excludedMembers.includes(methodName)) {
35
- return;
36
- }
37
-
38
- const paramSignatures: string[] = [];
39
- member.parameters.forEach(param => {
40
- const paramName = extractParameterName(param, sourceFile);
41
- const paramType = extractTypeString(param.type, sourceFile);
42
- paramSignatures.push(`${paramName}: ${paramType}`);
43
- });
44
-
45
- const returnType = extractTypeString(member.type, sourceFile);
46
-
47
- const signature = `${methodName}(${paramSignatures.join(', ')}): ${returnType}`;
48
- methodSignatures.push(signature);
49
- }
50
- });
51
- }
52
-
53
- ts.forEachChild(node, visit);
54
- }
55
-
56
- visit(sourceFile);
57
-
58
- methodSignatures.sort();
59
-
60
- return methodSignatures.join('');
61
- }
62
-
63
- /**
64
- * Extracts a deterministic signature string from an oracle registry object literal (e.g. PXE's `ORACLE_REGISTRY`).
65
- *
66
- * Reads the registry declaration where each oracle's wire ABI lives: the ordered parameter names with their
67
- * `TypeMapping` expressions and the return type. The resulting hash is sensitive to parameter, type, and return
68
- * changes, not just oracle additions and removals.
69
- *
70
- * Type expressions are captured as their source text (e.g. `OPTION(AZTEC_ADDRESS)`, `BOUNDED_VEC(NOTE)`), so the
71
- * signature tracks the composition of types. However, if the internal serialization logic of a `TypeMapping` constant
72
- * (e.g. `FIELD`) changes without the constant being renamed, the hash will not change.
6
+ * Reads the registry where each oracle's wire ABI lives: the ordered parameter names with their `TypeMapping` labels
7
+ * and the return type. The resulting hash is sensitive to parameter, type, and return changes, not just oracle
8
+ * additions and removals.
73
9
  *
74
10
  * @example
75
11
  * // Given a registry like:
@@ -79,233 +15,16 @@ export function getOracleInterfaceSignature(sourcePath: string, targets: string[
79
15
  * // } satisfies Record<string, OracleRegistryEntry>;
80
16
  * //
81
17
  * // Returns (sorted, newline-joined):
82
- * // "aztec_prv_bar(): void\naztec_utl_foo(a: U32): BOOL"
83
- *
84
- * @param sourcePath - Absolute path to the TypeScript source file declaring the registry.
85
- * @param registryName - Name of the registry constant to read (e.g. `ORACLE_REGISTRY`).
18
+ * // "aztec_prv_bar(): void\naztec_utl_foo(a: u32): bool"
86
19
  */
87
- export function getOracleRegistrySignature(sourcePath: string, registryName: string): string {
88
- const sourceCode = readFileSync(sourcePath, 'utf-8');
89
- const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
90
-
91
- const registry = findObjectLiteral(sourceFile, registryName);
92
- if (!registry) {
93
- throw new Error(`Could not find oracle registry '${registryName}' in ${sourcePath}.`);
94
- }
95
-
96
- const oracleSignatures = registry.properties.map(property => {
97
- if (!ts.isPropertyAssignment(property)) {
98
- throw new Error(
99
- `Unexpected member in oracle registry '${registryName}': ${property.getText(sourceFile)}. Spread elements ` +
100
- `are not supported.`,
101
- );
102
- }
103
-
104
- const oracleName = getPropertyName(property.name, sourceFile);
105
- const { params, returnType } = extractRegistryEntry(property.initializer, sourceFile);
106
- const paramSignatures = params.map(param => `${param.name}: ${param.type}`);
107
- return `${oracleName}(${paramSignatures.join(', ')}): ${returnType}`;
20
+ export function getOracleRegistrySignature(registry: Record<string, OracleRegistryEntry>): string {
21
+ const oracleSignatures = Object.entries(registry).map(([name, entry]) => {
22
+ const paramSignatures = entry.params.map(p => `${p.name}: ${p.type.label}`);
23
+ const returnType = entry.returnType === undefined ? 'void' : entry.returnType.label;
24
+ return `${name}(${paramSignatures.join(', ')}): ${returnType}`;
108
25
  });
109
26
 
110
27
  oracleSignatures.sort();
111
28
 
112
29
  return oracleSignatures.join('\n');
113
30
  }
114
-
115
- /**
116
- * Reads an integer-valued global constant from a Noir or TypeScript source file.
117
- *
118
- * Matches both the Noir form (`pub global NAME: Field = N;`) and the TypeScript form (`export const NAME = N;`). This
119
- * lets us compare a version constant that is hand-duplicated across the TS and Noir layers (which can't import each
120
- * other) without depending on either compiler. Only the assignment form `NAME = N` matches, so later usages of the
121
- * constant are ignored regardless of their order in the file.
122
- *
123
- * @param sourcePath - Absolute path to the source file to read.
124
- * @param name - Name of the global constant whose integer value should be extracted.
125
- * @returns The integer value assigned to the constant.
126
- * @throws If the constant's declaration is not found in the file.
127
- */
128
- export function readNumericGlobal(sourcePath: string, name: string): number {
129
- const sourceCode = readFileSync(sourcePath, 'utf-8');
130
- const match = sourceCode.match(new RegExp(`\\b${name}\\s*(?::\\s*\\w+\\s*)?=\\s*(\\d+)`));
131
- if (!match) {
132
- throw new Error(`Could not find numeric global '${name}' in ${sourcePath}.`);
133
- }
134
- return Number(match[1]);
135
- }
136
-
137
- function extractParameterName(param: ts.ParameterDeclaration, sourceFile: ts.SourceFile): string {
138
- const name = param.name;
139
-
140
- if (ts.isIdentifier(name)) {
141
- return name.text;
142
- }
143
-
144
- if (ts.isArrayBindingPattern(name)) {
145
- if (name.elements.length > 0) {
146
- const element = name.elements[0];
147
- if (ts.isBindingElement(element)) {
148
- const elementName = element.name;
149
- if (ts.isIdentifier(elementName)) {
150
- return elementName.text;
151
- }
152
- if (ts.isArrayBindingPattern(elementName) || ts.isObjectBindingPattern(elementName)) {
153
- return elementName.getText(sourceFile);
154
- }
155
- }
156
- }
157
- return name.getText(sourceFile);
158
- }
159
-
160
- if (ts.isObjectBindingPattern(name)) {
161
- return name.getText(sourceFile);
162
- }
163
-
164
- return (name as ts.Node).getText(sourceFile);
165
- }
166
-
167
- /** Returns the source text of a type annotation, or `'void'` if absent. */
168
- function extractTypeString(typeNode: ts.TypeNode | undefined, sourceFile: ts.SourceFile): string {
169
- if (!typeNode) {
170
- return 'void';
171
- }
172
-
173
- return typeNode.getText(sourceFile).replace(/\s+/g, ' ').trim();
174
- }
175
-
176
- /**
177
- * Finds a top-level object-literal-valued constant by name, unwrapping `satisfies`/`as`/parenthesized wrappers.
178
- *
179
- * @example
180
- * // `const REGISTRY = { ... } satisfies Record<string, Entry>` => the `{ ... }` ObjectLiteralExpression
181
- */
182
- function findObjectLiteral(sourceFile: ts.SourceFile, name: string): ts.ObjectLiteralExpression | undefined {
183
- let result: ts.ObjectLiteralExpression | undefined;
184
-
185
- function visit(node: ts.Node) {
186
- if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === name && node.initializer) {
187
- result = unwrapObjectLiteral(node.initializer);
188
- }
189
- ts.forEachChild(node, visit);
190
- }
191
-
192
- visit(sourceFile);
193
- return result;
194
- }
195
-
196
- /** Peels `satisfies`, `as`, and parenthesized wrappers off an expression to reach the underlying object literal. */
197
- function unwrapObjectLiteral(node: ts.Expression): ts.ObjectLiteralExpression | undefined {
198
- let current = node;
199
- while (ts.isSatisfiesExpression(current) || ts.isAsExpression(current) || ts.isParenthesizedExpression(current)) {
200
- current = current.expression;
201
- }
202
- return ts.isObjectLiteralExpression(current) ? current : undefined;
203
- }
204
-
205
- /**
206
- * Extracts the ordered `params` (names + type expressions) and `returnType` from a `makeEntry({ ... })` call.
207
- *
208
- * @example
209
- * // makeEntry({ params: [{ name: 'a', type: OPTION(FIELD) }], returnType: BOOL })
210
- * // => { params: [{ name: 'a', type: 'OPTION(FIELD)' }], returnType: 'BOOL' }
211
- * //
212
- * // makeEntry()
213
- * // => { params: [], returnType: 'void' }
214
- */
215
- function extractRegistryEntry(
216
- initializer: ts.Expression,
217
- sourceFile: ts.SourceFile,
218
- ): { params: { name: string; type: string }[]; returnType: string } {
219
- if (!ts.isCallExpression(initializer)) {
220
- throw new Error(`Expected a makeEntry(...) call but got: ${initializer.getText(sourceFile)}`);
221
- }
222
-
223
- const [arg] = initializer.arguments;
224
- if (arg === undefined) {
225
- return { params: [], returnType: 'void' };
226
- }
227
- if (!ts.isObjectLiteralExpression(arg)) {
228
- throw new Error(`Expected a makeEntry object argument but got: ${arg.getText(sourceFile)}`);
229
- }
230
-
231
- let params: { name: string; type: string }[] = [];
232
- let returnType = 'void';
233
-
234
- arg.properties.forEach(property => {
235
- if (!ts.isPropertyAssignment(property)) {
236
- throw new Error(`Unexpected makeEntry property: ${property.getText(sourceFile)}`);
237
- }
238
- const key = getPropertyName(property.name, sourceFile);
239
- if (key === 'params') {
240
- params = extractRegistryParams(property.initializer, sourceFile);
241
- } else if (key === 'returnType') {
242
- returnType = normalizeExpressionText(property.initializer, sourceFile);
243
- } else {
244
- throw new Error(`Unexpected makeEntry property '${key}'.`);
245
- }
246
- });
247
-
248
- return { params, returnType };
249
- }
250
-
251
- /**
252
- * Extracts `{ name, type }` pairs from the `params` array literal inside a `makeEntry` call.
253
- */
254
- function extractRegistryParams(
255
- initializer: ts.Expression,
256
- sourceFile: ts.SourceFile,
257
- ): { name: string; type: string }[] {
258
- if (!ts.isArrayLiteralExpression(initializer)) {
259
- throw new Error(`Expected a params array but got: ${initializer.getText(sourceFile)}`);
260
- }
261
-
262
- return initializer.elements.map(element => {
263
- if (!ts.isObjectLiteralExpression(element)) {
264
- throw new Error(`Expected a param object but got: ${element.getText(sourceFile)}`);
265
- }
266
-
267
- let name: string | undefined;
268
- let type: string | undefined;
269
- element.properties.forEach(property => {
270
- if (!ts.isPropertyAssignment(property)) {
271
- throw new Error(`Unexpected param property: ${property.getText(sourceFile)}`);
272
- }
273
- const key = getPropertyName(property.name, sourceFile);
274
- if (key === 'name') {
275
- if (!ts.isStringLiteralLike(property.initializer)) {
276
- throw new Error(`Expected a string literal param name but got: ${property.initializer.getText(sourceFile)}`);
277
- }
278
- name = property.initializer.text;
279
- } else if (key === 'type') {
280
- type = normalizeExpressionText(property.initializer, sourceFile);
281
- } else {
282
- throw new Error(`Unexpected param property '${key}'.`);
283
- }
284
- });
285
-
286
- if (name === undefined || type === undefined) {
287
- throw new Error(`Param missing 'name' or 'type': ${element.getText(sourceFile)}`);
288
- }
289
- return { name, type };
290
- });
291
- }
292
-
293
- /** Returns the text of an identifier or string-literal property name, throwing on computed or numeric names. */
294
- function getPropertyName(name: ts.PropertyName, sourceFile: ts.SourceFile): string {
295
- if (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) {
296
- return name.text;
297
- }
298
- throw new Error(`Unsupported property name: ${name.getText(sourceFile)}`);
299
- }
300
-
301
- /**
302
- * Returns the source text of an expression with all whitespace stripped for format-insensitive comparison.
303
- *
304
- * @example
305
- * // `OPTION(\n AZTEC_ADDRESS\n)` => `"OPTION(AZTEC_ADDRESS)"`
306
- */
307
- function normalizeExpressionText(node: ts.Expression, sourceFile: ts.SourceFile): string {
308
- // Type expressions are TypeMapping references and calls (identifiers, parentheses, commas, numbers) with no
309
- // meaningful whitespace, so we strip it entirely to keep the signature stable across reformatting.
310
- return node.getText(sourceFile).replace(/\s+/g, '');
311
- }
@@ -4,12 +4,11 @@ import { SerialQueue } from '@aztec/foundation/queue';
4
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
5
5
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
6
6
  import { BlockHash, L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
7
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
8
7
  import type { BlockHeader } from '@aztec/stdlib/tx';
9
8
 
10
9
  import type { BlockSynchronizerConfig } from '../config/index.js';
11
- import type { ContractClassService } from '../contract/contract_class_service.js';
12
10
  import type { ContractSyncService } from '../contract/contract_sync_service.js';
11
+ import type { CachingAztecNode } from '../node/caching_aztec_node.js';
13
12
  import type { AnchorBlockStore } from '../storage/anchor_block_store/index.js';
14
13
  import type { FactStore } from '../storage/fact_store/fact_store.js';
15
14
  import type { NoteStore } from '../storage/note_store/index.js';
@@ -28,7 +27,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
28
27
  protected readonly blockStream: L2BlockStream;
29
28
 
30
29
  constructor(
31
- private readonly node: AztecNode,
30
+ private readonly node: CachingAztecNode,
32
31
  private readonly store: AztecAsyncKVStore,
33
32
  private readonly anchorBlockStore: AnchorBlockStore,
34
33
  private readonly noteStore: NoteStore,
@@ -36,7 +35,6 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
36
35
  private readonly factStore: FactStore,
37
36
  private readonly l2TipsStore: L2TipsKVStore,
38
37
  private readonly contractSyncService: ContractSyncService,
39
- private readonly contractClassService: ContractClassService,
40
38
  private readonly config: Partial<BlockSynchronizerConfig> = {},
41
39
  bindings?: LoggerBindings,
42
40
  ) {
@@ -68,21 +66,7 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
68
66
  switch (event.type) {
69
67
  case 'chain-proposed': {
70
68
  if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
71
- // Fetch the proposed tip header by hash. By-hash is safer than by-number against a same-height reorg.
72
- const block = await this.node.getBlockData(BlockHash.fromString(event.block.hash));
73
- if (!block) {
74
- // The node served a proposed tip whose block data it cannot return — a node inconsistency, since the
75
- // stream events and the block data come from the same node (same reasoning as the chain-pruned throw
76
- // below). Throwing here propagates before the tips-store cursor advances, so the cursor stays put and the
77
- // next sync re-emits chain-proposed (at-least-once). Were we to warn-and-skip, the cursor would advance and
78
- // a quiet chain would never re-emit, leaving the anchor stale indefinitely.
79
- throw new Error(
80
- `Block header for proposed block ${event.block.number} and hash ${event.block.hash} not found. This ` +
81
- `likely indicates a bug in the node, as we receive block stream events and fetch block headers from ` +
82
- `the same node.`,
83
- );
84
- }
85
- await this.updateAnchorBlockHeader(block.header);
69
+ await this.updateAnchorBlockHeader(event.header);
86
70
  }
87
71
  break;
88
72
  }
@@ -180,10 +164,9 @@ export class BlockSynchronizer implements L2BlockStreamEventHandler {
180
164
  // execution.
181
165
  this.contractSyncService.wipe();
182
166
 
183
- // The contract class service keeps a per-block cache - since updating our anchor means it is very unlikely we'd
184
- // ever re-simulate at past anchors, we wipe its cache to prevent runaway memory growth on very long-lived PXE
185
- // instances.
186
- this.contractClassService.wipe();
167
+ // Cached node reads stay correct indefinitely, so this wipe is only about bounding memory growth. An anchor
168
+ // update is the recurring trigger PXE already has.
169
+ this.node.wipeCache();
187
170
 
188
171
  this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
189
172
  await this.anchorBlockStore.setHeader(blockHeader);
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '5.0.0', name: '@aztec/pxe' };
2
+ return { version: '6.0.0', name: '@aztec/pxe' };
3
3
  }
@@ -14,14 +14,6 @@ import type { ContractStore } from '../storage/contract_store/contract_store.js'
14
14
  * falling back to a local instance if no upgrades were scheduled.
15
15
  */
16
16
  export class ContractClassService {
17
- /**
18
- * Class ids are cached per `(address, anchorHash)`. This avoid unnecessary network roundtrips in scenarios where
19
- * multiple executions are done on the same anchor block (e.g. simulation followed by witgen), or when the same
20
- * contract is invoked multiple times in an execution (e.g. authwit checks).
21
- * It also means the callers don't need to worry about caching this service's return values, simplifying callsites.
22
- */
23
- #cache: Map<string, Promise<Fr | undefined>> = new Map();
24
-
25
17
  constructor(
26
18
  private node: AztecNode,
27
19
  private contractStore: ContractStore,
@@ -40,44 +32,14 @@ export class ContractClassService {
40
32
  return instance?.originalContractClassId;
41
33
  }
42
34
 
43
- const key = `${address.toString()}:${(await anchorBlockHeader.hash()).toString()}`;
44
- let promise = this.#cache.get(key);
45
- if (!promise) {
46
- promise = (async () => {
47
- // The node resolves the current class from the same scheduled value change the AVM enforces against the public
48
- // data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means
49
- // no upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original
50
- // class is current.
51
-
52
- const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
53
-
54
- if (nodeInstance) {
55
- return nodeInstance.currentContractClassId;
56
- } else {
57
- return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
58
- }
59
- })().catch(err => {
60
- this.#cache.delete(key);
61
- throw err;
62
- });
63
- this.#cache.set(key, promise);
64
- }
65
-
66
- const classId = await promise;
67
- if (classId === undefined) {
68
- // Don't memoize a missing instance: it may be registered later in this PXE (e.g. via contract sync
69
- // mid-execution), and a cached miss would then hide it. Only successful resolutions stay cached.
70
- this.#cache.delete(key);
35
+ // The node resolves the current class from the same scheduled value change the AVM enforces against the public
36
+ // data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means no
37
+ // upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original class
38
+ // is current.
39
+ const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
40
+ if (nodeInstance) {
41
+ return nodeInstance.currentContractClassId;
71
42
  }
72
- return classId;
73
- }
74
-
75
- /**
76
- * Clears the cache.
77
- *
78
- * This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
79
- * reorgs etc. as it is based on block hashes, not block numbers. */
80
- wipe(): void {
81
- this.#cache.clear();
43
+ return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
82
44
  }
83
45
  }
@@ -1,10 +1,10 @@
1
- import { isProtocolContract } from '@aztec/protocol-contracts';
2
1
  import type { FunctionCall, FunctionSelector } from '@aztec/stdlib/abi';
3
2
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
3
  import type { BlockHeader } from '@aztec/stdlib/tx';
5
4
 
6
5
  import type { ContractStore } from '../storage/contract_store/contract_store.js';
7
6
  import type { ContractClassService } from './contract_class_service.js';
7
+ import { isSkipSyncContract } from './skip_sync_contracts.js';
8
8
 
9
9
  export async function syncScope(
10
10
  contractAddress: AztecAddress,
@@ -15,8 +15,8 @@ export async function syncScope(
15
15
  utilityExecutor: (privateSyncCall: FunctionCall, scopes: AztecAddress[]) => Promise<any>,
16
16
  scope: AztecAddress,
17
17
  ) {
18
- // Protocol contracts don't have private state to sync
19
- if (isProtocolContract(contractAddress)) {
18
+ // Some canonical contracts hold no private state, so there is nothing to sync (see `skipSyncContracts`).
19
+ if (isSkipSyncContract(contractAddress)) {
20
20
  return;
21
21
  }
22
22
 
@@ -0,0 +1,23 @@
1
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
2
+ import { STANDARD_AUTH_REGISTRY_ADDRESS } from '@aztec/standard-contracts/auth-registry/constants';
3
+ import { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS } from '@aztec/standard-contracts/multi-call-entrypoint/constants';
4
+ import { STANDARD_PUBLIC_CHECKS_ADDRESS } from '@aztec/standard-contracts/public-checks/constants';
5
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ /**
8
+ * Canonical contracts that hold no private state and are therefore never synced.
9
+ *
10
+ * The protocol contracts (registries, fee juice) plus the standard AuthRegistry, MultiCallEntrypoint and PublicChecks
11
+ * declare no notes and no events, so their macro-generated `sync_state` has nothing to discover.
12
+ */
13
+ export const skipSyncContracts: AztecAddress[] = [
14
+ ...Object.values(ProtocolContractAddress),
15
+ STANDARD_AUTH_REGISTRY_ADDRESS,
16
+ STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
17
+ STANDARD_PUBLIC_CHECKS_ADDRESS,
18
+ ];
19
+
20
+ /** Returns whether the given contract should be skipped during private state synchronization. */
21
+ export function isSkipSyncContract(address: AztecAddress): boolean {
22
+ return skipSyncContracts.some(a => a.equals(address));
23
+ }
@@ -1,3 +1,4 @@
1
+ import { CircuitKind } from '@aztec/bb.js';
1
2
  import {
2
3
  AVM_EMITNOTEHASH_BASE_L2_GAS,
3
4
  AVM_EMITNULLIFIER_BASE_L2_GAS,
@@ -108,7 +109,6 @@ import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_t
108
109
  import type { SenderTaggingStore } from '../storage/tagging_store/sender_tagging_store.js';
109
110
  import type { TaggingSecretSourcesStore } from '../storage/tagging_store/tagging_secret_sources_store.js';
110
111
  import { AnchoredContractData } from './anchored_contract_data.js';
111
- import type { BenchmarkedNode } from './benchmarked_node.js';
112
112
  import { ExecutionNoteCache } from './execution_note_cache.js';
113
113
  import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
114
114
  import { HashedValuesCache } from './hashed_values_cache.js';
@@ -314,7 +314,7 @@ export class ContractFunctionSimulator {
314
314
  );
315
315
  const simulatorTeardownTimer = new Timer();
316
316
 
317
- const firstNullifier = noteCache.getNonceGenerator();
317
+ const firstNullifierHint = noteCache.getNonceGenerator();
318
318
 
319
319
  const publicCallRequests = collectNested([executionResult], r =>
320
320
  r.publicInputs.publicCallRequests
@@ -337,9 +337,9 @@ export class ContractFunctionSimulator {
337
337
  }
338
338
 
339
339
  // Not to be confused with a PrivateCallExecutionResult. This is a superset
340
- // of the PrivateCallExecutionResult, containing also firstNullifier
340
+ // of the PrivateCallExecutionResult, containing also firstNullifierHint
341
341
  // and publicFunctionsCalldata.
342
- return new PrivateExecutionResult(executionResult, firstNullifier, publicFunctionsCalldata);
342
+ return new PrivateExecutionResult(executionResult, firstNullifierHint, publicFunctionsCalldata);
343
343
  } catch (err) {
344
344
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
345
345
  }
@@ -443,22 +443,6 @@ export class ContractFunctionSimulator {
443
443
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
444
444
  }
445
445
  }
446
-
447
- /**
448
- * Returns the execution statistics collected during the simulator run.
449
- * @returns The execution statistics.
450
- */
451
- getStats() {
452
- const nodeRPCCalls =
453
- typeof (this.aztecNode as BenchmarkedNode).getStats === 'function'
454
- ? (this.aztecNode as BenchmarkedNode).getStats()
455
- : {
456
- perMethod: {},
457
- roundTrips: { roundTrips: 0, totalBlockingTime: 0, roundTripDurations: [], roundTripMethods: [] },
458
- };
459
-
460
- return { nodeRPCCalls };
461
- }
462
446
  }
463
447
 
464
448
  class OrderedSideEffect<T> {
@@ -587,6 +571,7 @@ export async function generateSimulatedProvingResult(
587
571
  execution.publicInputs.callContext.functionSelector,
588
572
  ),
589
573
  timings: execution.profileResult?.timings ?? { witgen: 0, oracles: {} },
574
+ kind: CircuitKind.App,
590
575
  bytecode: execution.acir,
591
576
  vk: execution.vk,
592
577
  witness: execution.partialWitness,
@@ -6,6 +6,7 @@ export {
6
6
  type ParamTypes,
7
7
  } from './oracle/oracle_registry.js';
8
8
  export {
9
+ ALIAS,
9
10
  ARRAY,
10
11
  AZTEC_ADDRESS,
11
12
  BIGINT,
@@ -13,8 +14,7 @@ export {
13
14
  BLOCK_NUMBER,
14
15
  BOOL,
15
16
  BOUNDED_VEC,
16
- BUFFER,
17
- BYTE,
17
+ U8,
18
18
  CONTRACT_INSTANCE,
19
19
  DELIVERY_MODE,
20
20
  EPHEMERAL_ARRAY,
@@ -23,6 +23,8 @@ export {
23
23
  FIELD,
24
24
  FIXED_ARRAY,
25
25
  FUNCTION_SELECTOR,
26
+ LEAF,
27
+ LEAF_INDEX,
26
28
  LOG_RETRIEVAL_REQUEST,
27
29
  LOG_RETRIEVAL_RESPONSE,
28
30
  MEMBERSHIP_WITNESS,
@@ -32,16 +34,34 @@ export {
32
34
  PENDING_TAGGED_LOG,
33
35
  POINT,
34
36
  PROVIDED_SECRET,
37
+ SCALAR,
35
38
  SLOT_NUMBER,
36
39
  STR,
37
40
  STRUCT,
38
41
  U32,
42
+ U64,
43
+ U128,
39
44
  tryFieldWidth,
45
+ isArrayMapping,
46
+ isBoundedVecMapping,
47
+ isEphemeralArrayMapping,
48
+ isFixedArrayMapping,
49
+ isFixedBoundedVecMapping,
50
+ isOptionMapping,
51
+ isStructMapping,
52
+ type ArrayMapping,
53
+ type BoundedVecMapping,
54
+ type CompositeMapping,
55
+ type EphemeralArrayMapping,
56
+ type FixedArrayMapping,
57
+ type FixedBoundedVecMapping,
40
58
  type InputSlot,
41
59
  type MaybePromise,
60
+ type OptionMapping,
42
61
  type OutputSlot,
43
62
  type SlotShape,
44
63
  type StructField,
64
+ type StructMapping,
45
65
  type TypeMapping,
46
66
  } from './oracle/oracle_type_mappings.js';
47
67
  export { ExecutionNoteCache } from './execution_note_cache.js';
@@ -74,5 +94,5 @@ export { NoteValidationRequest } from './noir-structs/note_validation_request.js
74
94
  export type { PendingTaggedLog } from './noir-structs/pending_tagged_log.js';
75
95
  export type { TxEffectData } from './noir-structs/tx_effect_data.js';
76
96
  export type { ProvidedSecret } from './noir-structs/provided_secret.js';
77
- export { ResolvedTx } from './noir-structs/resolved_tx.js';
97
+ export type { ResolvedTx } from './noir-structs/resolved_tx.js';
78
98
  export { TransientArrayService } from './transient_array_service.js';