@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,63 +1,22 @@
1
1
  import { keccak256String } from '@aztec/foundation/crypto/keccak';
2
- import { dirname, join } from 'path';
3
- import { fileURLToPath } from 'url';
4
- import { ORACLE_INTERFACE_HASH, ORACLE_VERSION_MAJOR } from '../oracle_version.js';
5
- import { getOracleRegistrySignature, readNumericGlobal } from './oracle_version_helpers.js';
2
+ import { ORACLE_REGISTRY } from '../contract_function_simulator/index.js';
3
+ import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
4
+ import { getOracleRegistrySignature } from './oracle_version_helpers.js';
6
5
  /**
7
6
  * Verifies that the Oracle interface matches the expected interface hash.
8
7
  *
9
8
  * The Oracle interface needs to be versioned to ensure compatibility between Aztec.nr and PXE. This function computes
10
- * a hash of the `ORACLE_REGISTRY` declaration (where each oracle's parameter names, parameter types, and return type
9
+ * a hash of `ORACLE_REGISTRY` (where each oracle's parameter names, parameter types, and return type
11
10
  * live) and compares it against a known hash. If they don't match, it means the interface has changed and the oracle
12
11
  * version needs to be bumped:
13
12
  * - If the change is backward-breaking (e.g. removing/renaming an oracle, or changing its params/return), bump
14
13
  * ORACLE_VERSION_MAJOR.
15
14
  * - If the change is an oracle addition (non-breaking), bump ORACLE_VERSION_MINOR.
16
15
  */ function assertOracleInterfaceMatches() {
17
- // The script runs from dest/bin/ after compilation, so we go up to the package root then into src/ to find
18
- // the source file.
19
- const currentDir = dirname(fileURLToPath(import.meta.url));
20
- const packageRoot = dirname(dirname(currentDir)); // Go up from bin/ to pxe/
21
- const registrySourcePath = join(packageRoot, 'src/contract_function_simulator/oracle/oracle_registry.ts');
22
- const oracleInterfaceSignature = getOracleRegistrySignature(registrySourcePath, 'ORACLE_REGISTRY');
23
16
  // We use keccak256 here just because we already have it in the dependencies.
24
- const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
17
+ const oracleInterfaceHash = keccak256String(getOracleRegistrySignature(ORACLE_REGISTRY));
25
18
  if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
26
19
  throw new Error(`The Oracle interface has changed. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} in pxe/src/oracle_version.ts and bump the oracle version (ORACLE_VERSION_MAJOR for breaking changes, ORACLE_VERSION_MINOR for oracle additions).`);
27
20
  }
28
21
  }
29
- /**
30
- * Verifies that `ORACLE_VERSION_MAJOR` is identical across all of its hand-maintained copies.
31
- *
32
- * The major version is duplicated across the PXE TypeScript constant and two Noir constants (Aztec.nr and the protocol
33
- * contracts' `aztec_sublib`) because those layers can't import each other. This static check fails fast at build time,
34
- * naming each file and its value.
35
- *
36
- * Only the major version is checked: the minor version legitimately diverges under the "environment minor >= contract
37
- * minor" tolerance, so asserting minor equality would false-positive.
38
- */ function assertContractOracleVersionMajorInSync() {
39
- const currentDir = dirname(fileURLToPath(import.meta.url));
40
- // Go up from dest/bin/ or src/bin/ to the package root (pxe/), then up two more to the git root.
41
- const packageRoot = dirname(dirname(currentDir));
42
- const gitRoot = join(packageRoot, '..', '..');
43
- const copies = [
44
- {
45
- label: 'pxe/src/oracle_version.ts',
46
- value: ORACLE_VERSION_MAJOR
47
- },
48
- {
49
- label: 'aztec-nr/aztec/src/oracle/version.nr',
50
- value: readNumericGlobal(join(gitRoot, 'noir-projects/aztec-nr/aztec/src/oracle/version.nr'), 'ORACLE_VERSION_MAJOR')
51
- },
52
- {
53
- label: 'aztec_sublib/src/oracle/version.nr',
54
- value: readNumericGlobal(join(gitRoot, 'noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/oracle/version.nr'), 'ORACLE_VERSION_MAJOR')
55
- }
56
- ];
57
- if (new Set(copies.map((copy)=>copy.value)).size > 1) {
58
- const details = copies.map((copy)=>`${copy.label}=${copy.value}`).join(', ');
59
- throw new Error(`ORACLE_VERSION_MAJOR is out of sync: ${details}. Bump all copies together.`);
60
- }
61
- }
62
22
  assertOracleInterfaceMatches();
63
- assertContractOracleVersionMajorInSync();
@@ -1,2 +1,2 @@
1
- export { getOracleInterfaceSignature, getOracleRegistrySignature, readNumericGlobal, } from './oracle_version_helpers.js';
2
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUNMLDJCQUEyQixFQUMzQiwwQkFBMEIsRUFDMUIsaUJBQWlCLEdBQ2xCLE1BQU0sNkJBQTZCLENBQUMifQ==
1
+ export { getOracleRegistrySignature } from './oracle_version_helpers.js';
2
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9iaW4vaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLDBCQUEwQixFQUFFLE1BQU0sNkJBQTZCLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC1B,iBAAiB,GAClB,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC"}
package/dest/bin/index.js CHANGED
@@ -1 +1 @@
1
- export { getOracleInterfaceSignature, getOracleRegistrySignature, readNumericGlobal } from './oracle_version_helpers.js';
1
+ export { getOracleRegistrySignature } from './oracle_version_helpers.js';
@@ -1,24 +1,10 @@
1
+ import type { OracleRegistryEntry } from '../contract_function_simulator/index.js';
1
2
  /**
2
- * Extracts method signatures from TypeScript classes or interfaces and returns a deterministic string representation.
3
+ * Extracts a deterministic signature string from an oracle registry (e.g. PXE's `ORACLE_REGISTRY`).
3
4
  *
4
- * This is used to detect when an oracle interface changes so that the oracle version can be bumped. It works with both
5
- * class declarations (e.g. PXE's `Oracle` class) and interface declarations (e.g. TXE's `IAvmExecutionOracle`).
6
- *
7
- * @param sourcePath - Absolute path to the TypeScript source file to parse.
8
- * @param targets - Names of classes or interfaces to extract methods from.
9
- * @param excludedMembers - Method names to skip (e.g. non-oracle helpers like `constructor`).
10
- */
11
- export declare function getOracleInterfaceSignature(sourcePath: string, targets: string[], excludedMembers: string[]): string;
12
- /**
13
- * Extracts a deterministic signature string from an oracle registry object literal (e.g. PXE's `ORACLE_REGISTRY`).
14
- *
15
- * Reads the registry declaration where each oracle's wire ABI lives: the ordered parameter names with their
16
- * `TypeMapping` expressions and the return type. The resulting hash is sensitive to parameter, type, and return
17
- * changes, not just oracle additions and removals.
18
- *
19
- * Type expressions are captured as their source text (e.g. `OPTION(AZTEC_ADDRESS)`, `BOUNDED_VEC(NOTE)`), so the
20
- * signature tracks the composition of types. However, if the internal serialization logic of a `TypeMapping` constant
21
- * (e.g. `FIELD`) changes without the constant being renamed, the hash will not change.
5
+ * Reads the registry where each oracle's wire ABI lives: the ordered parameter names with their `TypeMapping` labels
6
+ * and the return type. The resulting hash is sensitive to parameter, type, and return changes, not just oracle
7
+ * additions and removals.
22
8
  *
23
9
  * @example
24
10
  * // Given a registry like:
@@ -28,24 +14,7 @@ export declare function getOracleInterfaceSignature(sourcePath: string, targets:
28
14
  * // } satisfies Record<string, OracleRegistryEntry>;
29
15
  * //
30
16
  * // Returns (sorted, newline-joined):
31
- * // "aztec_prv_bar(): void\naztec_utl_foo(a: U32): BOOL"
32
- *
33
- * @param sourcePath - Absolute path to the TypeScript source file declaring the registry.
34
- * @param registryName - Name of the registry constant to read (e.g. `ORACLE_REGISTRY`).
35
- */
36
- export declare function getOracleRegistrySignature(sourcePath: string, registryName: string): string;
37
- /**
38
- * Reads an integer-valued global constant from a Noir or TypeScript source file.
39
- *
40
- * Matches both the Noir form (`pub global NAME: Field = N;`) and the TypeScript form (`export const NAME = N;`). This
41
- * lets us compare a version constant that is hand-duplicated across the TS and Noir layers (which can't import each
42
- * other) without depending on either compiler. Only the assignment form `NAME = N` matches, so later usages of the
43
- * constant are ignored regardless of their order in the file.
44
- *
45
- * @param sourcePath - Absolute path to the source file to read.
46
- * @param name - Name of the global constant whose integer value should be extracted.
47
- * @returns The integer value assigned to the constant.
48
- * @throws If the constant's declaration is not found in the file.
17
+ * // "aztec_prv_bar(): void\naztec_utl_foo(a: u32): bool"
49
18
  */
50
- export declare function readNumericGlobal(sourcePath: string, name: string): number;
51
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb25faGVscGVycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Jpbi9vcmFjbGVfdmVyc2lvbl9oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBOzs7Ozs7Ozs7R0FTRztBQUNILHdCQUFnQiwyQkFBMkIsQ0FBQyxVQUFVLEVBQUUsTUFBTSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUUsRUFBRSxlQUFlLEVBQUUsTUFBTSxFQUFFLEdBQUcsTUFBTSxDQThDcEg7QUFFRDs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0F1Qkc7QUFDSCx3QkFBZ0IsMEJBQTBCLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxZQUFZLEVBQUUsTUFBTSxHQUFHLE1BQU0sQ0EwQjNGO0FBRUQ7Ozs7Ozs7Ozs7OztHQVlHO0FBQ0gsd0JBQWdCLGlCQUFpQixDQUFDLFVBQVUsRUFBRSxNQUFNLEVBQUUsSUFBSSxFQUFFLE1BQU0sR0FBRyxNQUFNLENBTzFFIn0=
19
+ export declare function getOracleRegistrySignature(registry: Record<string, OracleRegistryEntry>): string;
20
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3JhY2xlX3ZlcnNpb25faGVscGVycy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2Jpbi9vcmFjbGVfdmVyc2lvbl9oZWxwZXJzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0seUNBQXlDLENBQUM7QUFFbkY7Ozs7Ozs7Ozs7Ozs7Ozs7R0FnQkc7QUFDSCx3QkFBZ0IsMEJBQTBCLENBQUMsUUFBUSxFQUFFLE1BQU0sQ0FBQyxNQUFNLEVBQUUsbUJBQW1CLENBQUMsR0FBRyxNQUFNLENBVWhHIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"oracle_version_helpers.d.ts","sourceRoot":"","sources":["../../src/bin/oracle_version_helpers.ts"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,eAAe,EAAE,MAAM,EAAE,GAAG,MAAM,CA8CpH;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CA0B3F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAO1E"}
1
+ {"version":3,"file":"oracle_version_helpers.d.ts","sourceRoot":"","sources":["../../src/bin/oracle_version_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,GAAG,MAAM,CAUhG"}
@@ -1,55 +1,9 @@
1
- /* eslint-disable import-x/no-named-as-default-member */ import { readFileSync } from 'fs';
2
- import ts from 'typescript';
3
1
  /**
4
- * Extracts method signatures from TypeScript classes or interfaces and returns a deterministic string representation.
2
+ * Extracts a deterministic signature string from an oracle registry (e.g. PXE's `ORACLE_REGISTRY`).
5
3
  *
6
- * This is used to detect when an oracle interface changes so that the oracle version can be bumped. It works with both
7
- * class declarations (e.g. PXE's `Oracle` class) and interface declarations (e.g. TXE's `IAvmExecutionOracle`).
8
- *
9
- * @param sourcePath - Absolute path to the TypeScript source file to parse.
10
- * @param targets - Names of classes or interfaces to extract methods from.
11
- * @param excludedMembers - Method names to skip (e.g. non-oracle helpers like `constructor`).
12
- */ export function getOracleInterfaceSignature(sourcePath, targets, excludedMembers) {
13
- const sourceCode = readFileSync(sourcePath, 'utf-8');
14
- const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
15
- const methodSignatures = [];
16
- function visit(node) {
17
- const isTarget = (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node)) && targets.includes(node.name?.text ?? '');
18
- if (isTarget) {
19
- node.members.forEach((member)=>{
20
- if ((ts.isMethodDeclaration(member) || ts.isMethodSignature(member)) && member.name && ts.isIdentifier(member.name)) {
21
- const methodName = member.name.text;
22
- if (excludedMembers.includes(methodName)) {
23
- return;
24
- }
25
- const paramSignatures = [];
26
- member.parameters.forEach((param)=>{
27
- const paramName = extractParameterName(param, sourceFile);
28
- const paramType = extractTypeString(param.type, sourceFile);
29
- paramSignatures.push(`${paramName}: ${paramType}`);
30
- });
31
- const returnType = extractTypeString(member.type, sourceFile);
32
- const signature = `${methodName}(${paramSignatures.join(', ')}): ${returnType}`;
33
- methodSignatures.push(signature);
34
- }
35
- });
36
- }
37
- ts.forEachChild(node, visit);
38
- }
39
- visit(sourceFile);
40
- methodSignatures.sort();
41
- return methodSignatures.join('');
42
- }
43
- /**
44
- * Extracts a deterministic signature string from an oracle registry object literal (e.g. PXE's `ORACLE_REGISTRY`).
45
- *
46
- * Reads the registry declaration where each oracle's wire ABI lives: the ordered parameter names with their
47
- * `TypeMapping` expressions and the return type. The resulting hash is sensitive to parameter, type, and return
48
- * changes, not just oracle additions and removals.
49
- *
50
- * Type expressions are captured as their source text (e.g. `OPTION(AZTEC_ADDRESS)`, `BOUNDED_VEC(NOTE)`), so the
51
- * signature tracks the composition of types. However, if the internal serialization logic of a `TypeMapping` constant
52
- * (e.g. `FIELD`) changes without the constant being renamed, the hash will not change.
4
+ * Reads the registry where each oracle's wire ABI lives: the ordered parameter names with their `TypeMapping` labels
5
+ * and the return type. The resulting hash is sensitive to parameter, type, and return changes, not just oracle
6
+ * additions and removals.
53
7
  *
54
8
  * @example
55
9
  * // Given a registry like:
@@ -59,196 +13,13 @@ import ts from 'typescript';
59
13
  * // } satisfies Record<string, OracleRegistryEntry>;
60
14
  * //
61
15
  * // Returns (sorted, newline-joined):
62
- * // "aztec_prv_bar(): void\naztec_utl_foo(a: U32): BOOL"
63
- *
64
- * @param sourcePath - Absolute path to the TypeScript source file declaring the registry.
65
- * @param registryName - Name of the registry constant to read (e.g. `ORACLE_REGISTRY`).
66
- */ export function getOracleRegistrySignature(sourcePath, registryName) {
67
- const sourceCode = readFileSync(sourcePath, 'utf-8');
68
- const sourceFile = ts.createSourceFile(sourcePath, sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
69
- const registry = findObjectLiteral(sourceFile, registryName);
70
- if (!registry) {
71
- throw new Error(`Could not find oracle registry '${registryName}' in ${sourcePath}.`);
72
- }
73
- const oracleSignatures = registry.properties.map((property)=>{
74
- if (!ts.isPropertyAssignment(property)) {
75
- throw new Error(`Unexpected member in oracle registry '${registryName}': ${property.getText(sourceFile)}. Spread elements ` + `are not supported.`);
76
- }
77
- const oracleName = getPropertyName(property.name, sourceFile);
78
- const { params, returnType } = extractRegistryEntry(property.initializer, sourceFile);
79
- const paramSignatures = params.map((param)=>`${param.name}: ${param.type}`);
80
- return `${oracleName}(${paramSignatures.join(', ')}): ${returnType}`;
16
+ * // "aztec_prv_bar(): void\naztec_utl_foo(a: u32): bool"
17
+ */ export function getOracleRegistrySignature(registry) {
18
+ const oracleSignatures = Object.entries(registry).map(([name, entry])=>{
19
+ const paramSignatures = entry.params.map((p)=>`${p.name}: ${p.type.label}`);
20
+ const returnType = entry.returnType === undefined ? 'void' : entry.returnType.label;
21
+ return `${name}(${paramSignatures.join(', ')}): ${returnType}`;
81
22
  });
82
23
  oracleSignatures.sort();
83
24
  return oracleSignatures.join('\n');
84
25
  }
85
- /**
86
- * Reads an integer-valued global constant from a Noir or TypeScript source file.
87
- *
88
- * Matches both the Noir form (`pub global NAME: Field = N;`) and the TypeScript form (`export const NAME = N;`). This
89
- * lets us compare a version constant that is hand-duplicated across the TS and Noir layers (which can't import each
90
- * other) without depending on either compiler. Only the assignment form `NAME = N` matches, so later usages of the
91
- * constant are ignored regardless of their order in the file.
92
- *
93
- * @param sourcePath - Absolute path to the source file to read.
94
- * @param name - Name of the global constant whose integer value should be extracted.
95
- * @returns The integer value assigned to the constant.
96
- * @throws If the constant's declaration is not found in the file.
97
- */ export function readNumericGlobal(sourcePath, name) {
98
- const sourceCode = readFileSync(sourcePath, 'utf-8');
99
- const match = sourceCode.match(new RegExp(`\\b${name}\\s*(?::\\s*\\w+\\s*)?=\\s*(\\d+)`));
100
- if (!match) {
101
- throw new Error(`Could not find numeric global '${name}' in ${sourcePath}.`);
102
- }
103
- return Number(match[1]);
104
- }
105
- function extractParameterName(param, sourceFile) {
106
- const name = param.name;
107
- if (ts.isIdentifier(name)) {
108
- return name.text;
109
- }
110
- if (ts.isArrayBindingPattern(name)) {
111
- if (name.elements.length > 0) {
112
- const element = name.elements[0];
113
- if (ts.isBindingElement(element)) {
114
- const elementName = element.name;
115
- if (ts.isIdentifier(elementName)) {
116
- return elementName.text;
117
- }
118
- if (ts.isArrayBindingPattern(elementName) || ts.isObjectBindingPattern(elementName)) {
119
- return elementName.getText(sourceFile);
120
- }
121
- }
122
- }
123
- return name.getText(sourceFile);
124
- }
125
- if (ts.isObjectBindingPattern(name)) {
126
- return name.getText(sourceFile);
127
- }
128
- return name.getText(sourceFile);
129
- }
130
- /** Returns the source text of a type annotation, or `'void'` if absent. */ function extractTypeString(typeNode, sourceFile) {
131
- if (!typeNode) {
132
- return 'void';
133
- }
134
- return typeNode.getText(sourceFile).replace(/\s+/g, ' ').trim();
135
- }
136
- /**
137
- * Finds a top-level object-literal-valued constant by name, unwrapping `satisfies`/`as`/parenthesized wrappers.
138
- *
139
- * @example
140
- * // `const REGISTRY = { ... } satisfies Record<string, Entry>` => the `{ ... }` ObjectLiteralExpression
141
- */ function findObjectLiteral(sourceFile, name) {
142
- let result;
143
- function visit(node) {
144
- if (ts.isVariableDeclaration(node) && ts.isIdentifier(node.name) && node.name.text === name && node.initializer) {
145
- result = unwrapObjectLiteral(node.initializer);
146
- }
147
- ts.forEachChild(node, visit);
148
- }
149
- visit(sourceFile);
150
- return result;
151
- }
152
- /** Peels `satisfies`, `as`, and parenthesized wrappers off an expression to reach the underlying object literal. */ function unwrapObjectLiteral(node) {
153
- let current = node;
154
- while(ts.isSatisfiesExpression(current) || ts.isAsExpression(current) || ts.isParenthesizedExpression(current)){
155
- current = current.expression;
156
- }
157
- return ts.isObjectLiteralExpression(current) ? current : undefined;
158
- }
159
- /**
160
- * Extracts the ordered `params` (names + type expressions) and `returnType` from a `makeEntry({ ... })` call.
161
- *
162
- * @example
163
- * // makeEntry({ params: [{ name: 'a', type: OPTION(FIELD) }], returnType: BOOL })
164
- * // => { params: [{ name: 'a', type: 'OPTION(FIELD)' }], returnType: 'BOOL' }
165
- * //
166
- * // makeEntry()
167
- * // => { params: [], returnType: 'void' }
168
- */ function extractRegistryEntry(initializer, sourceFile) {
169
- if (!ts.isCallExpression(initializer)) {
170
- throw new Error(`Expected a makeEntry(...) call but got: ${initializer.getText(sourceFile)}`);
171
- }
172
- const [arg] = initializer.arguments;
173
- if (arg === undefined) {
174
- return {
175
- params: [],
176
- returnType: 'void'
177
- };
178
- }
179
- if (!ts.isObjectLiteralExpression(arg)) {
180
- throw new Error(`Expected a makeEntry object argument but got: ${arg.getText(sourceFile)}`);
181
- }
182
- let params = [];
183
- let returnType = 'void';
184
- arg.properties.forEach((property)=>{
185
- if (!ts.isPropertyAssignment(property)) {
186
- throw new Error(`Unexpected makeEntry property: ${property.getText(sourceFile)}`);
187
- }
188
- const key = getPropertyName(property.name, sourceFile);
189
- if (key === 'params') {
190
- params = extractRegistryParams(property.initializer, sourceFile);
191
- } else if (key === 'returnType') {
192
- returnType = normalizeExpressionText(property.initializer, sourceFile);
193
- } else {
194
- throw new Error(`Unexpected makeEntry property '${key}'.`);
195
- }
196
- });
197
- return {
198
- params,
199
- returnType
200
- };
201
- }
202
- /**
203
- * Extracts `{ name, type }` pairs from the `params` array literal inside a `makeEntry` call.
204
- */ function extractRegistryParams(initializer, sourceFile) {
205
- if (!ts.isArrayLiteralExpression(initializer)) {
206
- throw new Error(`Expected a params array but got: ${initializer.getText(sourceFile)}`);
207
- }
208
- return initializer.elements.map((element)=>{
209
- if (!ts.isObjectLiteralExpression(element)) {
210
- throw new Error(`Expected a param object but got: ${element.getText(sourceFile)}`);
211
- }
212
- let name;
213
- let type;
214
- element.properties.forEach((property)=>{
215
- if (!ts.isPropertyAssignment(property)) {
216
- throw new Error(`Unexpected param property: ${property.getText(sourceFile)}`);
217
- }
218
- const key = getPropertyName(property.name, sourceFile);
219
- if (key === 'name') {
220
- if (!ts.isStringLiteralLike(property.initializer)) {
221
- throw new Error(`Expected a string literal param name but got: ${property.initializer.getText(sourceFile)}`);
222
- }
223
- name = property.initializer.text;
224
- } else if (key === 'type') {
225
- type = normalizeExpressionText(property.initializer, sourceFile);
226
- } else {
227
- throw new Error(`Unexpected param property '${key}'.`);
228
- }
229
- });
230
- if (name === undefined || type === undefined) {
231
- throw new Error(`Param missing 'name' or 'type': ${element.getText(sourceFile)}`);
232
- }
233
- return {
234
- name,
235
- type
236
- };
237
- });
238
- }
239
- /** Returns the text of an identifier or string-literal property name, throwing on computed or numeric names. */ function getPropertyName(name, sourceFile) {
240
- if (ts.isIdentifier(name) || ts.isStringLiteralLike(name)) {
241
- return name.text;
242
- }
243
- throw new Error(`Unsupported property name: ${name.getText(sourceFile)}`);
244
- }
245
- /**
246
- * Returns the source text of an expression with all whitespace stripped for format-insensitive comparison.
247
- *
248
- * @example
249
- * // `OPTION(\n AZTEC_ADDRESS\n)` => `"OPTION(AZTEC_ADDRESS)"`
250
- */ function normalizeExpressionText(node, sourceFile) {
251
- // Type expressions are TypeMapping references and calls (identifiers, parentheses, commas, numbers) with no
252
- // meaningful whitespace, so we strip it entirely to keep the signature stable across reformatting.
253
- return node.getText(sourceFile).replace(/\s+/g, '');
254
- }
@@ -2,10 +2,9 @@ import { type LoggerBindings } from '@aztec/foundation/log';
2
2
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
3
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
4
4
  import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
5
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
6
5
  import type { BlockSynchronizerConfig } from '../config/index.js';
7
- import type { ContractClassService } from '../contract/contract_class_service.js';
8
6
  import type { ContractSyncService } from '../contract/contract_sync_service.js';
7
+ import type { CachingAztecNode } from '../node/caching_aztec_node.js';
9
8
  import type { AnchorBlockStore } from '../storage/anchor_block_store/index.js';
10
9
  import type { FactStore } from '../storage/fact_store/fact_store.js';
11
10
  import type { NoteStore } from '../storage/note_store/index.js';
@@ -24,13 +23,12 @@ export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
24
23
  private readonly factStore;
25
24
  private readonly l2TipsStore;
26
25
  private readonly contractSyncService;
27
- private readonly contractClassService;
28
26
  private readonly config;
29
27
  private log;
30
28
  private isSyncing;
31
29
  private readonly eventQueue;
32
30
  protected readonly blockStream: L2BlockStream;
33
- constructor(node: AztecNode, store: AztecAsyncKVStore, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, privateEventStore: PrivateEventStore, factStore: FactStore, l2TipsStore: L2TipsKVStore, contractSyncService: ContractSyncService, contractClassService: ContractClassService, config?: Partial<BlockSynchronizerConfig>, bindings?: LoggerBindings);
31
+ constructor(node: CachingAztecNode, store: AztecAsyncKVStore, anchorBlockStore: AnchorBlockStore, noteStore: NoteStore, privateEventStore: PrivateEventStore, factStore: FactStore, l2TipsStore: L2TipsKVStore, contractSyncService: ContractSyncService, config?: Partial<BlockSynchronizerConfig>, bindings?: LoggerBindings);
34
32
  protected createBlockStream(): L2BlockStream;
35
33
  /** Handle events emitted by the block stream. Serialized to prevent concurrent mutations to anchor state. */
36
34
  handleBlockStreamEvent(event: L2BlockStreamEvent): Promise<void>;
@@ -50,4 +48,4 @@ export declare class BlockSynchronizer implements L2BlockStreamEventHandler {
50
48
  stop(): Promise<void>;
51
49
  private doSync;
52
50
  }
53
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJz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OAAO,CAAC,QAAQ,CAAC,MAAM;IAdzB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,SAAS,CAA4B;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAChD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,aAAa,CAAC;IAE9C,YACmB,IAAI,EAAE,gBAAgB,EACtB,KAAK,EAAE,iBAAiB,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACpB,iBAAiB,EAAE,iBAAiB,EACpC,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,aAAa,EAC1B,mBAAmB,EAAE,mBAAmB,EACxC,MAAM,GAAE,OAAO,CAAC,uBAAuB,CAAM,EAC9D,QAAQ,CAAC,EAAE,cAAc,EAK1B;IAED,SAAS,CAAC,iBAAiB,IAAI,aAAa,CAY3C;IAED,6GAA6G;IACtG,sBAAsB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtE;YAEa,wBAAwB;YAgGxB,uBAAuB;IAcrC;;;;;;;;OAQG;IACU,IAAI,kBAiBhB;IAED,oGAAoG;IACvF,IAAI,kBAIhB;YAEa,MAAM;CAcrB"}
@@ -16,13 +16,12 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
16
16
  factStore;
17
17
  l2TipsStore;
18
18
  contractSyncService;
19
- contractClassService;
20
19
  config;
21
20
  log;
22
21
  isSyncing;
23
22
  eventQueue;
24
23
  blockStream;
25
- constructor(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, contractClassService, config = {}, bindings){
24
+ constructor(node, store, anchorBlockStore, noteStore, privateEventStore, factStore, l2TipsStore, contractSyncService, config = {}, bindings){
26
25
  this.node = node;
27
26
  this.store = store;
28
27
  this.anchorBlockStore = anchorBlockStore;
@@ -31,7 +30,6 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
31
30
  this.factStore = factStore;
32
31
  this.l2TipsStore = l2TipsStore;
33
32
  this.contractSyncService = contractSyncService;
34
- this.contractClassService = contractClassService;
35
33
  this.config = config;
36
34
  this.eventQueue = new SerialQueue();
37
35
  this.log = createLogger('pxe:block_synchronizer', bindings);
@@ -53,17 +51,7 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
53
51
  case 'chain-proposed':
54
52
  {
55
53
  if (this.config.syncChainTip === undefined || this.config.syncChainTip === 'proposed') {
56
- // Fetch the proposed tip header by hash. By-hash is safer than by-number against a same-height reorg.
57
- const block = await this.node.getBlockData(BlockHash.fromString(event.block.hash));
58
- if (!block) {
59
- // The node served a proposed tip whose block data it cannot return — a node inconsistency, since the
60
- // stream events and the block data come from the same node (same reasoning as the chain-pruned throw
61
- // below). Throwing here propagates before the tips-store cursor advances, so the cursor stays put and the
62
- // next sync re-emits chain-proposed (at-least-once). Were we to warn-and-skip, the cursor would advance and
63
- // a quiet chain would never re-emit, leaving the anchor stale indefinitely.
64
- throw new Error(`Block header for proposed block ${event.block.number} and hash ${event.block.hash} not found. This ` + `likely indicates a bug in the node, as we receive block stream events and fetch block headers from ` + `the same node.`);
65
- }
66
- await this.updateAnchorBlockHeader(block.header);
54
+ await this.updateAnchorBlockHeader(event.header);
67
55
  }
68
56
  break;
69
57
  }
@@ -156,10 +144,9 @@ import { blockStreamSourceFromAztecNode } from './block_stream_source.js';
156
144
  // Therefore, we clear the contract synchronization cache here such that the sync is re-triggered upon new
157
145
  // execution.
158
146
  this.contractSyncService.wipe();
159
- // The contract class service keeps a per-block cache - since updating our anchor means it is very unlikely we'd
160
- // ever re-simulate at past anchors, we wipe its cache to prevent runaway memory growth on very long-lived PXE
161
- // instances.
162
- this.contractClassService.wipe();
147
+ // Cached node reads stay correct indefinitely, so this wipe is only about bounding memory growth. An anchor
148
+ // update is the recurring trigger PXE already has.
149
+ this.node.wipeCache();
163
150
  this.log.verbose(`Updated pxe last block to ${blockHeader.getBlockNumber()}`, blockHeader.toInspect());
164
151
  await this.anchorBlockStore.setHeader(blockHeader);
165
152
  }
@@ -1,6 +1,6 @@
1
1
  export function getPackageInfo() {
2
2
  return {
3
- version: '5.0.0',
3
+ version: '6.0.0',
4
4
  name: '@aztec/pxe'
5
5
  };
6
6
  }
@@ -11,7 +11,6 @@ import type { ContractStore } from '../storage/contract_store/contract_store.js'
11
11
  * falling back to a local instance if no upgrades were scheduled.
12
12
  */
13
13
  export declare class ContractClassService {
14
- #private;
15
14
  private node;
16
15
  private contractStore;
17
16
  constructor(node: AztecNode, contractStore: ContractStore);
@@ -21,11 +20,5 @@ export declare class ContractClassService {
21
20
  * failures (e.g. the node being unreachable) still throw.
22
21
  */
23
22
  getCurrentClassId(address: AztecAddress, anchorBlockHeader: BlockHeader): Promise<Fr | undefined>;
24
- /**
25
- * Clears the cache.
26
- *
27
- * This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
28
- * reorgs etc. as it is based on block hashes, not block numbers. */
29
- wipe(): void;
30
23
  }
31
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJhY3RfY2xhc3Nfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbnRyYWN0L2NvbnRyYWN0X2NsYXNzX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFFekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakUsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFcEQsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sNkNBQTZDLENBQUM7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UUsU0FBUyxFQUNmLGFBQWEsRUFBRSxhQUFhLEVBQ2xDO0lBRUo7Ozs7T0FJRztJQUNHLGlCQUFpQixDQUFDLE9BQU8sRUFBRSxZQUFZLEVBQUUsaUJBQWlCLEVBQUUsV0FBVyxHQUFHLE9BQU8sQ0FBQyxFQUFFLEdBQUcsU0FBUyxDQUFDLENBaUJ0RztDQUNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"contract_class_service.d.ts","sourceRoot":"","sources":["../../src/contract/contract_class_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;GAMG;AACH,qBAAa,oBAAoB;;IAU7B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,aAAa;IAFvB,YACU,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,aAAa,EAClC;IAEJ;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAsCtG;IAED;;;;wEAIoE;IACpE,IAAI,IAAI,IAAI,CAEX;CACF"}
1
+ {"version":3,"file":"contract_class_service.d.ts","sourceRoot":"","sources":["../../src/contract/contract_class_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6CAA6C,CAAC;AAEjF;;;;;;GAMG;AACH,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,IAAI;IACZ,OAAO,CAAC,aAAa;IAFvB,YACU,IAAI,EAAE,SAAS,EACf,aAAa,EAAE,aAAa,EAClC;IAEJ;;;;OAIG;IACG,iBAAiB,CAAC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,GAAG,SAAS,CAAC,CAiBtG;CACF"}
@@ -8,16 +8,9 @@ import { isProtocolContract } from '@aztec/protocol-contracts';
8
8
  */ export class ContractClassService {
9
9
  node;
10
10
  contractStore;
11
- /**
12
- * Class ids are cached per `(address, anchorHash)`. This avoid unnecessary network roundtrips in scenarios where
13
- * multiple executions are done on the same anchor block (e.g. simulation followed by witgen), or when the same
14
- * contract is invoked multiple times in an execution (e.g. authwit checks).
15
- * It also means the callers don't need to worry about caching this service's return values, simplifying callsites.
16
- */ #cache;
17
11
  constructor(node, contractStore){
18
12
  this.node = node;
19
13
  this.contractStore = contractStore;
20
- this.#cache = new Map();
21
14
  }
22
15
  /**
23
16
  * Returns the class id that corresponds to `address` as of `anchorBlockHeader`, or `undefined` if no instance is
@@ -30,39 +23,14 @@ import { isProtocolContract } from '@aztec/protocol-contracts';
30
23
  const instance = await this.contractStore.getContractInstance(address);
31
24
  return instance?.originalContractClassId;
32
25
  }
33
- const key = `${address.toString()}:${(await anchorBlockHeader.hash()).toString()}`;
34
- let promise = this.#cache.get(key);
35
- if (!promise) {
36
- promise = (async ()=>{
37
- // The node resolves the current class from the same scheduled value change the AVM enforces against the public
38
- // data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means
39
- // no upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original
40
- // class is current.
41
- const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
42
- if (nodeInstance) {
43
- return nodeInstance.currentContractClassId;
44
- } else {
45
- return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
46
- }
47
- })().catch((err)=>{
48
- this.#cache.delete(key);
49
- throw err;
50
- });
51
- this.#cache.set(key, promise);
52
- }
53
- const classId = await promise;
54
- if (classId === undefined) {
55
- // Don't memoize a missing instance: it may be registered later in this PXE (e.g. via contract sync
56
- // mid-execution), and a cached miss would then hide it. Only successful resolutions stay cached.
57
- this.#cache.delete(key);
26
+ // The node resolves the current class from the same scheduled value change the AVM enforces against the public
27
+ // data tree. If the contract was upgraded the node returns a non-undefined instance; an undefined result means no
28
+ // upgrade happened (or the node has no record of it, e.g. it was never publicly deployed), so the original class
29
+ // is current.
30
+ const nodeInstance = await this.node.getContract(address, await anchorBlockHeader.hash());
31
+ if (nodeInstance) {
32
+ return nodeInstance.currentContractClassId;
58
33
  }
59
- return classId;
60
- }
61
- /**
62
- * Clears the cache.
63
- *
64
- * This is not required for correctness, only to limit how much memory the cache uses. The cache is resilient against
65
- * reorgs etc. as it is based on block hashes, not block numbers. */ wipe() {
66
- this.#cache.clear();
34
+ return (await this.contractStore.getContractInstance(address))?.originalContractClassId;
67
35
  }
68
36
  }