@aztec/pxe 3.0.0-canary.a9708bd → 3.0.0-devnet.20251212

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 (264) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.d.ts +1 -1
  3. package/dest/bin/check_oracle_version.js +110 -10
  4. package/dest/config/index.d.ts +9 -17
  5. package/dest/config/index.d.ts.map +1 -1
  6. package/dest/config/index.js +10 -16
  7. package/dest/config/package_info.d.ts +1 -1
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -6
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +97 -42
  12. package/dest/contract_function_simulator/execution_data_provider.d.ts +40 -57
  13. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_note_cache.d.ts +11 -9
  15. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/execution_note_cache.js +28 -17
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  18. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  19. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  20. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  21. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/index.d.ts +4 -2
  23. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/index.js +2 -1
  25. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
  26. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +2 -2
  28. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  30. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +8 -4
  32. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -3
  33. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
  35. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  36. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  37. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  38. package/dest/contract_function_simulator/oracle/index.d.ts +2 -2
  39. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/index.js +1 -1
  41. package/dest/contract_function_simulator/oracle/interfaces.d.ts +104 -0
  42. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  43. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  44. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
  45. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  46. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  47. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
  48. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  49. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
  50. package/dest/contract_function_simulator/oracle/oracle.d.ts +17 -15
  51. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/oracle/oracle.js +101 -81
  53. package/dest/contract_function_simulator/oracle/private_execution.d.ts +6 -5
  54. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  55. package/dest/contract_function_simulator/oracle/private_execution.js +7 -16
  56. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +34 -22
  57. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  58. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +89 -25
  59. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +23 -33
  60. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  61. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +38 -42
  62. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  63. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  64. package/dest/contract_function_simulator/pick_notes.js +1 -1
  65. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  66. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  67. package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
  68. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
  69. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +34 -68
  70. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  71. package/dest/contract_function_simulator/pxe_oracle_interface.js +220 -208
  72. package/dest/entrypoints/client/bundle/index.d.ts +4 -2
  73. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  74. package/dest/entrypoints/client/bundle/index.js +2 -1
  75. package/dest/entrypoints/client/bundle/utils.d.ts +9 -9
  76. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  77. package/dest/entrypoints/client/bundle/utils.js +12 -12
  78. package/dest/entrypoints/client/lazy/index.d.ts +4 -2
  79. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  80. package/dest/entrypoints/client/lazy/index.js +2 -1
  81. package/dest/entrypoints/client/lazy/utils.d.ts +8 -8
  82. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  83. package/dest/entrypoints/client/lazy/utils.js +11 -11
  84. package/dest/entrypoints/pxe_creation_options.d.ts +3 -1
  85. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  86. package/dest/entrypoints/server/index.d.ts +4 -2
  87. package/dest/entrypoints/server/index.d.ts.map +1 -1
  88. package/dest/entrypoints/server/index.js +2 -1
  89. package/dest/entrypoints/server/utils.d.ts +5 -24
  90. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  91. package/dest/entrypoints/server/utils.js +9 -41
  92. package/dest/error_enriching.d.ts +11 -0
  93. package/dest/error_enriching.d.ts.map +1 -0
  94. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
  95. package/dest/events/index.d.ts +2 -0
  96. package/dest/events/index.d.ts.map +1 -0
  97. package/dest/events/index.js +1 -0
  98. package/dest/events/private_event_filter_validator.d.ts +8 -0
  99. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  100. package/dest/events/private_event_filter_validator.js +39 -0
  101. package/dest/oracle_version.d.ts +3 -3
  102. package/dest/oracle_version.js +2 -2
  103. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
  104. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  105. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
  106. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  107. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
  108. package/dest/private_kernel/hints/index.d.ts +1 -1
  109. package/dest/private_kernel/index.d.ts +1 -1
  110. package/dest/private_kernel/private_kernel_execution_prover.d.ts +9 -2
  111. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  112. package/dest/private_kernel/private_kernel_execution_prover.js +38 -32
  113. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
  114. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  115. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +8 -7
  116. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  117. package/dest/pxe.d.ts +240 -0
  118. package/dest/pxe.d.ts.map +1 -0
  119. package/dest/{pxe_service/pxe_service.js → pxe.js} +227 -241
  120. package/dest/storage/address_data_provider/address_data_provider.d.ts +2 -4
  121. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  122. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  123. package/dest/storage/address_data_provider/index.d.ts +1 -1
  124. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +3 -5
  125. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  126. package/dest/storage/capsule_data_provider/capsule_data_provider.js +1 -5
  127. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  128. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +6 -17
  129. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  130. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -15
  131. package/dest/storage/contract_data_provider/index.d.ts +1 -1
  132. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
  133. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  134. package/dest/storage/contract_data_provider/private_functions_tree.js +1 -1
  135. package/dest/storage/index.d.ts +1 -2
  136. package/dest/storage/index.d.ts.map +1 -1
  137. package/dest/storage/index.js +0 -1
  138. package/dest/storage/metadata.d.ts +1 -1
  139. package/dest/storage/note_data_provider/index.d.ts +2 -2
  140. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  141. package/dest/storage/note_data_provider/index.js +1 -1
  142. package/dest/storage/note_data_provider/note_data_provider.d.ts +75 -11
  143. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  144. package/dest/storage/note_data_provider/note_data_provider.js +143 -81
  145. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +31 -17
  146. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
  147. package/dest/storage/private_event_data_provider/private_event_data_provider.js +47 -28
  148. package/dest/storage/sync_data_provider/index.d.ts +1 -1
  149. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +4 -5
  150. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  151. package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
  152. package/dest/storage/tagging_data_provider/index.d.ts +1 -1
  153. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +29 -7
  154. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  155. package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
  156. package/dest/synchronizer/index.d.ts +1 -1
  157. package/dest/synchronizer/synchronizer.d.ts +3 -2
  158. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  159. package/dest/synchronizer/synchronizer.js +4 -4
  160. package/dest/tagging/constants.d.ts +2 -0
  161. package/dest/tagging/constants.d.ts.map +1 -0
  162. package/dest/tagging/constants.js +2 -0
  163. package/dest/tagging/index.d.ts +7 -0
  164. package/dest/tagging/index.d.ts.map +1 -0
  165. package/dest/tagging/index.js +5 -0
  166. package/dest/tagging/siloed_tag.d.ts +14 -0
  167. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  168. package/dest/tagging/siloed_tag.js +20 -0
  169. package/dest/tagging/tag.d.ts +12 -0
  170. package/dest/tagging/tag.d.ts.map +1 -0
  171. package/dest/tagging/tag.js +17 -0
  172. package/dest/tagging/utils.d.ts +18 -0
  173. package/dest/tagging/utils.d.ts.map +1 -0
  174. package/dest/tagging/utils.js +24 -0
  175. package/package.json +22 -24
  176. package/src/bin/check_oracle_version.ts +134 -10
  177. package/src/config/index.ts +18 -32
  178. package/src/config/package_info.ts +1 -1
  179. package/src/contract_function_simulator/contract_function_simulator.ts +151 -62
  180. package/src/contract_function_simulator/execution_data_provider.ts +47 -65
  181. package/src/contract_function_simulator/execution_note_cache.ts +33 -17
  182. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  183. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  184. package/src/contract_function_simulator/index.ts +3 -1
  185. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  186. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  187. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +10 -5
  188. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
  189. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  190. package/src/contract_function_simulator/oracle/index.ts +1 -1
  191. package/src/contract_function_simulator/oracle/interfaces.ts +176 -0
  192. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  193. package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
  194. package/src/contract_function_simulator/oracle/oracle.ts +135 -80
  195. package/src/contract_function_simulator/oracle/private_execution.ts +10 -17
  196. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +123 -49
  197. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +68 -80
  198. package/src/contract_function_simulator/pick_notes.ts +1 -1
  199. package/src/contract_function_simulator/pxe_oracle_interface.ts +291 -271
  200. package/src/entrypoints/client/bundle/index.ts +3 -1
  201. package/src/entrypoints/client/bundle/utils.ts +15 -23
  202. package/src/entrypoints/client/lazy/index.ts +3 -1
  203. package/src/entrypoints/client/lazy/utils.ts +14 -22
  204. package/src/entrypoints/pxe_creation_options.ts +2 -0
  205. package/src/entrypoints/server/index.ts +3 -1
  206. package/src/entrypoints/server/utils.ts +12 -56
  207. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
  208. package/src/events/index.ts +1 -0
  209. package/src/events/private_event_filter_validator.ts +47 -0
  210. package/src/oracle_version.ts +2 -2
  211. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
  212. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
  213. package/src/private_kernel/private_kernel_execution_prover.ts +51 -43
  214. package/src/private_kernel/private_kernel_oracle.ts +2 -1
  215. package/src/private_kernel/private_kernel_oracle_impl.ts +4 -3
  216. package/src/{pxe_service/pxe_service.ts → pxe.ts} +256 -308
  217. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  218. package/src/storage/capsule_data_provider/capsule_data_provider.ts +2 -12
  219. package/src/storage/contract_data_provider/contract_data_provider.ts +4 -27
  220. package/src/storage/contract_data_provider/private_functions_tree.ts +1 -1
  221. package/src/storage/index.ts +0 -1
  222. package/src/storage/note_data_provider/index.ts +1 -1
  223. package/src/storage/note_data_provider/note_data_provider.ts +171 -109
  224. package/src/storage/private_event_data_provider/private_event_data_provider.ts +69 -41
  225. package/src/storage/sync_data_provider/sync_data_provider.ts +3 -8
  226. package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
  227. package/src/synchronizer/synchronizer.ts +4 -4
  228. package/src/tagging/constants.ts +2 -0
  229. package/src/tagging/index.ts +6 -0
  230. package/src/tagging/siloed_tag.ts +22 -0
  231. package/src/tagging/tag.ts +16 -0
  232. package/src/tagging/utils.ts +31 -0
  233. package/dest/bin/index.d.ts +0 -3
  234. package/dest/bin/index.d.ts.map +0 -1
  235. package/dest/bin/index.js +0 -48
  236. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  237. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  238. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  239. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  240. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  241. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  242. package/dest/pxe_service/error_enriching.d.ts +0 -11
  243. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  244. package/dest/pxe_service/index.d.ts +0 -3
  245. package/dest/pxe_service/index.d.ts.map +0 -1
  246. package/dest/pxe_service/index.js +0 -2
  247. package/dest/pxe_service/pxe_service.d.ts +0 -100
  248. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  249. package/dest/storage/data_provider.d.ts +0 -4
  250. package/dest/storage/data_provider.d.ts.map +0 -1
  251. package/dest/storage/data_provider.js +0 -1
  252. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  253. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  254. package/dest/storage/note_data_provider/note_dao.js +0 -102
  255. package/dest/test/pxe_test_suite.d.ts +0 -3
  256. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  257. package/dest/test/pxe_test_suite.js +0 -97
  258. package/src/bin/index.ts +0 -62
  259. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  260. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  261. package/src/pxe_service/index.ts +0 -2
  262. package/src/storage/data_provider.ts +0 -3
  263. package/src/storage/note_data_provider/note_dao.ts +0 -154
  264. package/src/test/pxe_test_suite.ts +0 -113
@@ -1,14 +1,12 @@
1
- import { keccak256String } from '@aztec/foundation/crypto';
1
+ import { keccak256String } from '@aztec/foundation/crypto/keccak';
2
2
 
3
- import deterministicStringify from 'json-stringify-deterministic';
3
+ import { readFileSync } from 'fs';
4
+ import { dirname, join } from 'path';
5
+ import ts from 'typescript';
6
+ import { fileURLToPath } from 'url';
4
7
 
5
- import { Oracle } from '../contract_function_simulator/oracle/oracle.js';
6
- import { TypedOracle } from '../contract_function_simulator/oracle/typed_oracle.js';
7
8
  import { ORACLE_INTERFACE_HASH } from '../oracle_version.js';
8
9
 
9
- // Create a minimal mock implementation of TypedOracle to instantiate the Oracle class for interface verification.
10
- class OracleMock extends TypedOracle {}
11
-
12
10
  /**
13
11
  * Verifies that the Oracle interface matches the expected interface hash.
14
12
  *
@@ -22,15 +20,141 @@ class OracleMock extends TypedOracle {}
22
20
  * oracle interface like we do in PXE (i.e., there is no single Oracle class that contains only the oracles).
23
21
  */
24
22
  function assertOracleInterfaceMatches(): void {
25
- const oracle = new Oracle(new OracleMock());
23
+ const oracleInterfaceSignature = getOracleInterfaceSignature();
24
+
26
25
  // We use keccak256 here just because we already have it in the dependencies.
27
- const oracleInterfaceHash = keccak256String(deterministicStringify(oracle.toACIRCallback()));
26
+ const oracleInterfaceHash = keccak256String(oracleInterfaceSignature);
28
27
  if (oracleInterfaceHash !== ORACLE_INTERFACE_HASH) {
29
28
  // This check exists only to notify you when you need to update the ORACLE_VERSION constant.
30
29
  throw new Error(
31
- `The TypedOracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`,
30
+ `The Oracle interface has changed, which implies a breaking change in the aztec.nr/PXE oracle interface. Update ORACLE_INTERFACE_HASH to ${oracleInterfaceHash} and bump ORACLE_VERSION in pxe/src/oracle_version.ts.`,
32
31
  );
33
32
  }
34
33
  }
35
34
 
35
+ /**
36
+ * Constructs a signature of the Oracle interface while ignoring methods that are not foreign call handlers.
37
+ */
38
+ function getOracleInterfaceSignature(): string {
39
+ const excludedProps = [
40
+ 'handler',
41
+ 'constructor',
42
+ 'toACIRCallback',
43
+ 'handlerAsMisc',
44
+ 'handlerAsUtility',
45
+ 'handlerAsPrivate',
46
+ ] as const;
47
+
48
+ // Get the path to Oracle.ts source file
49
+ // The script runs from dest/bin/ after compilation, so we need to go up to the package root
50
+ // then into src/ to find the source file
51
+ const currentDir = dirname(fileURLToPath(import.meta.url));
52
+ // Go up from dest/bin/ or src/bin/ to the package root (pxe/), then into src/
53
+ const packageRoot = dirname(dirname(currentDir)); // Go up from bin/ to pxe/
54
+ const oracleSourcePath = join(packageRoot, 'src/contract_function_simulator/oracle/oracle.ts');
55
+
56
+ // Read and parse the TypeScript source file
57
+ const sourceCode = readFileSync(oracleSourcePath, 'utf-8');
58
+ const sourceFile = ts.createSourceFile('oracle.ts', sourceCode, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
59
+
60
+ // Extract method signatures from the Oracle class
61
+ const methodSignatures: string[] = [];
62
+
63
+ function visit(node: ts.Node) {
64
+ // Look for class declaration named "Oracle"
65
+ if (ts.isClassDeclaration(node) && node.name?.text === 'Oracle') {
66
+ // Visit all members of the class
67
+ node.members.forEach(member => {
68
+ if (ts.isMethodDeclaration(member) && member.name && ts.isIdentifier(member.name)) {
69
+ const methodName = member.name.text;
70
+
71
+ // Skip excluded methods
72
+ if (excludedProps.includes(methodName as (typeof excludedProps)[number])) {
73
+ return;
74
+ }
75
+
76
+ // Extract parameter signatures
77
+ const paramSignatures: string[] = [];
78
+ member.parameters.forEach(param => {
79
+ const paramName = extractParameterName(param, sourceFile);
80
+ const paramType = extractTypeString(param.type, sourceFile);
81
+ paramSignatures.push(`${paramName}: ${paramType}`);
82
+ });
83
+
84
+ // Extract return type
85
+ const returnType = extractTypeString(member.type, sourceFile);
86
+
87
+ // Build full signature: methodName(param1: Type1, param2: Type2): ReturnType
88
+ const signature = `${methodName}(${paramSignatures.join(', ')}): ${returnType}`;
89
+ methodSignatures.push(signature);
90
+ }
91
+ });
92
+ }
93
+
94
+ ts.forEachChild(node, visit);
95
+ }
96
+
97
+ visit(sourceFile);
98
+
99
+ // Sort signatures alphabetically for consistent hashing
100
+ methodSignatures.sort();
101
+
102
+ // Create a hashable representation by concatenating all signatures
103
+ return methodSignatures.join('');
104
+ }
105
+
106
+ /**
107
+ * Extracts the parameter name from a parameter node, handling destructured parameters.
108
+ */
109
+ function extractParameterName(param: ts.ParameterDeclaration, sourceFile: ts.SourceFile): string {
110
+ const name = param.name;
111
+
112
+ if (ts.isIdentifier(name)) {
113
+ return name.text;
114
+ }
115
+
116
+ if (ts.isArrayBindingPattern(name)) {
117
+ // Handle destructured parameters like [blockNumber]: ACVMField[]
118
+ // Extract the first element name
119
+ if (name.elements.length > 0) {
120
+ const element = name.elements[0];
121
+ if (ts.isBindingElement(element)) {
122
+ const elementName = element.name;
123
+ if (ts.isIdentifier(elementName)) {
124
+ return elementName.text;
125
+ }
126
+ // Nested destructuring - use text representation
127
+ if (ts.isArrayBindingPattern(elementName) || ts.isObjectBindingPattern(elementName)) {
128
+ return elementName.getText(sourceFile);
129
+ }
130
+ }
131
+ }
132
+ // Fallback: return the text representation
133
+ return name.getText(sourceFile);
134
+ }
135
+
136
+ if (ts.isObjectBindingPattern(name)) {
137
+ // Handle object destructuring
138
+ return name.getText(sourceFile);
139
+ }
140
+
141
+ // Fallback for any other case - this should never happen but TypeScript needs it
142
+ return (name as ts.Node).getText(sourceFile);
143
+ }
144
+
145
+ /**
146
+ * Extracts the type string from a type node, normalizing whitespace.
147
+ */
148
+ function extractTypeString(typeNode: ts.TypeNode | undefined, sourceFile: ts.SourceFile): string {
149
+ if (!typeNode) {
150
+ return 'void';
151
+ }
152
+
153
+ // Get the type text and normalize whitespace
154
+ let typeText = typeNode.getText(sourceFile);
155
+ // Normalize whitespace: remove extra spaces, newlines, and tabs
156
+ typeText = typeText.replace(/\s+/g, ' ').trim();
157
+ return typeText;
158
+ }
159
+
36
160
  assertOracleInterfaceMatches();
@@ -10,15 +10,6 @@ import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
10
10
 
11
11
  export { getPackageInfo } from './package_info.js';
12
12
 
13
- /**
14
- * Temporary configuration until WASM can be used instead of native
15
- */
16
- export interface BBProverConfig {
17
- bbWorkingDirectory?: string;
18
- bbBinaryPath?: string;
19
- bbSkipCleanup?: boolean;
20
- }
21
-
22
13
  /**
23
14
  * Configuration settings for the prover factory
24
15
  */
@@ -26,22 +17,23 @@ export interface KernelProverConfig {
26
17
  /** Whether we are running with real proofs */
27
18
  proverEnabled?: boolean;
28
19
  }
20
+
29
21
  /**
30
- * Configuration settings for the PXE.
22
+ * Configuration settings for the synchronizer.
31
23
  */
32
- export interface PXEConfig {
24
+ export interface SynchronizerConfig {
33
25
  /** Maximum amount of blocks to pull from the stream in one request when synchronizing */
34
26
  l2BlockBatchSize: number;
35
27
  }
36
28
 
37
- export type PXEServiceConfig = PXEConfig & KernelProverConfig & BBProverConfig & DataStoreConfig & ChainConfig;
29
+ export type PXEConfig = KernelProverConfig & DataStoreConfig & ChainConfig & SynchronizerConfig;
38
30
 
39
31
  export type CliPXEOptions = {
40
32
  /** Custom Aztec Node URL to connect to */
41
33
  nodeUrl?: string;
42
34
  };
43
35
 
44
- export const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig> = {
36
+ export const pxeConfigMappings: ConfigMappingsType<PXEConfig> = {
45
37
  ...dataConfigMappings,
46
38
  ...chainConfigMappings,
47
39
  l2BlockBatchSize: {
@@ -49,19 +41,13 @@ export const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig> = {
49
41
  ...numberConfigHelper(50),
50
42
  description: 'Maximum amount of blocks to pull from the stream in one request when synchronizing',
51
43
  },
52
- bbBinaryPath: {
53
- env: 'BB_BINARY_PATH',
54
- description: 'Path to the BB binary',
55
- },
56
- bbWorkingDirectory: {
57
- env: 'BB_WORKING_DIRECTORY',
58
- description: 'Working directory for the BB binary',
59
- },
60
- bbSkipCleanup: {
61
- env: 'BB_SKIP_CLEANUP',
62
- description: 'True to skip cleanup of temporary files for debugging purposes',
63
- ...booleanConfigHelper(),
64
- },
44
+ // TODO: We're losing this feature in moving to bb.js api.
45
+ // Reimplement it as a setting that dumps the msgpack data on the bb.js backend if needed.
46
+ // bbSkipCleanup: {
47
+ // env: 'BB_SKIP_CLEANUP',
48
+ // description: 'True to skip cleanup of temporary files for debugging purposes',
49
+ // ...booleanConfigHelper(),
50
+ // },
65
51
  proverEnabled: {
66
52
  env: 'PXE_PROVER_ENABLED',
67
53
  description: 'Enable real proofs',
@@ -70,10 +56,10 @@ export const pxeConfigMappings: ConfigMappingsType<PXEServiceConfig> = {
70
56
  };
71
57
 
72
58
  /**
73
- * Creates an instance of PXEServiceConfig out of environment variables using sensible defaults for integration testing if not set.
59
+ * Creates an instance of PXEConfig out of environment variables using sensible defaults for integration testing if not set.
74
60
  */
75
- export function getPXEServiceConfig(): PXEServiceConfig {
76
- return getConfigFromMappings<PXEServiceConfig>(pxeConfigMappings);
61
+ export function getPXEConfig(): PXEConfig {
62
+ return getConfigFromMappings<PXEConfig>(pxeConfigMappings);
77
63
  }
78
64
 
79
65
  export const pxeCliConfigMappings: ConfigMappingsType<CliPXEOptions> = {
@@ -83,7 +69,7 @@ export const pxeCliConfigMappings: ConfigMappingsType<CliPXEOptions> = {
83
69
  },
84
70
  };
85
71
 
86
- export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEServiceConfig> = {
72
+ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEConfig> = {
87
73
  ...pxeConfigMappings,
88
74
  ...pxeCliConfigMappings,
89
75
  ...dataConfigMappings,
@@ -99,8 +85,8 @@ export const allPxeConfigMappings: ConfigMappingsType<CliPXEOptions & PXEService
99
85
  /**
100
86
  * Creates an instance of CliPxeOptions out of environment variables
101
87
  */
102
- export function getCliPXEOptions(): CliPXEOptions & PXEServiceConfig {
103
- const pxeConfig = getPXEServiceConfig();
88
+ export function getCliPXEOptions(): CliPXEOptions & PXEConfig {
89
+ const pxeConfig = getPXEConfig();
104
90
  const cliOptions = getConfigFromMappings<CliPXEOptions>(pxeCliConfigMappings);
105
91
  return {
106
92
  ...pxeConfig,
@@ -1,3 +1,3 @@
1
1
  export function getPackageInfo() {
2
- return { version: '2.0.0', name: '@aztec/pxe' };
2
+ return { version: '3.0.0', name: '@aztec/pxe' };
3
3
  }
@@ -1,4 +1,14 @@
1
1
  import {
2
+ AVM_EMITNOTEHASH_BASE_L2_GAS,
3
+ AVM_EMITNULLIFIER_BASE_L2_GAS,
4
+ AVM_SENDL2TOL1MSG_BASE_L2_GAS,
5
+ DA_BYTES_PER_FIELD,
6
+ DA_GAS_PER_BYTE,
7
+ FIXED_AVM_STARTUP_L2_GAS,
8
+ FIXED_DA_GAS,
9
+ FIXED_L2_GAS,
10
+ L2_GAS_PER_CONTRACT_CLASS_LOG,
11
+ L2_GAS_PER_PRIVATE_LOG,
2
12
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
3
13
  MAX_ENQUEUED_CALLS_PER_TX,
4
14
  MAX_L2_TO_L1_MSGS_PER_TX,
@@ -6,13 +16,13 @@ import {
6
16
  MAX_NULLIFIERS_PER_TX,
7
17
  MAX_PRIVATE_LOGS_PER_TX,
8
18
  } from '@aztec/constants';
9
- import { padArrayEnd } from '@aztec/foundation/collection';
10
- import { poseidon2Hash } from '@aztec/foundation/crypto';
11
- import { Fr } from '@aztec/foundation/fields';
19
+ import { arrayNonEmptyLength, padArrayEnd } from '@aztec/foundation/collection';
20
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
21
+ import { Fr } from '@aztec/foundation/curves/bn254';
12
22
  import { type Logger, createLogger } from '@aztec/foundation/log';
13
23
  import { Timer } from '@aztec/foundation/timer';
14
24
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
15
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
25
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
16
26
  import {
17
27
  type CircuitSimulator,
18
28
  ExecutionError,
@@ -22,12 +32,18 @@ import {
22
32
  toACVMWitness,
23
33
  witnessMapToFields,
24
34
  } from '@aztec/simulator/client';
25
- import type { AbiDecoded, FunctionCall } from '@aztec/stdlib/abi';
26
- import { FunctionSelector, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
35
+ import type { FunctionCall } from '@aztec/stdlib/abi';
36
+ import { FunctionSelector, FunctionType } from '@aztec/stdlib/abi';
27
37
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
28
38
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
29
39
  import { Gas } from '@aztec/stdlib/gas';
30
- import { computeNoteHashNonce, computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdlib/hash';
40
+ import {
41
+ computeNoteHashNonce,
42
+ computeProtocolNullifier,
43
+ computeUniqueNoteHash,
44
+ siloNoteHash,
45
+ siloNullifier,
46
+ } from '@aztec/stdlib/hash';
31
47
  import {
32
48
  PartialPrivateTailPublicInputsForPublic,
33
49
  PartialPrivateTailPublicInputsForRollup,
@@ -41,7 +57,7 @@ import {
41
57
  } from '@aztec/stdlib/kernel';
42
58
  import { PrivateLog } from '@aztec/stdlib/logs';
43
59
  import { ScopedL2ToL1Message } from '@aztec/stdlib/messaging';
44
- import { ClientIvcProof } from '@aztec/stdlib/proofs';
60
+ import { ChonkProof } from '@aztec/stdlib/proofs';
45
61
  import {
46
62
  CallContext,
47
63
  HashedValues,
@@ -49,11 +65,13 @@ import {
49
65
  TxConstantData,
50
66
  TxExecutionRequest,
51
67
  collectNested,
68
+ getFinalMinRevertibleSideEffectCounter,
52
69
  } from '@aztec/stdlib/tx';
53
70
 
54
71
  import type { ContractDataProvider } from '../storage/index.js';
55
72
  import type { ExecutionDataProvider } from './execution_data_provider.js';
56
73
  import { ExecutionNoteCache } from './execution_note_cache.js';
74
+ import { ExecutionTaggingIndexCache } from './execution_tagging_index_cache.js';
57
75
  import { HashedValuesCache } from './hashed_values_cache.js';
58
76
  import { Oracle } from './oracle/oracle.js';
59
77
  import { executePrivateFunction, verifyCurrentClassId } from './oracle/private_execution.js';
@@ -94,7 +112,7 @@ export class ContractFunctionSimulator {
94
112
  scopes?: AztecAddress[],
95
113
  ): Promise<PrivateExecutionResult> {
96
114
  const simulatorSetupTimer = new Timer();
97
- const header = await this.executionDataProvider.getBlockHeader();
115
+ const anchorBlockHeader = await this.executionDataProvider.getAnchorBlockHeader();
98
116
 
99
117
  await verifyCurrentClassId(contractAddress, this.executionDataProvider);
100
118
 
@@ -111,7 +129,7 @@ export class ContractFunctionSimulator {
111
129
  }
112
130
 
113
131
  // reserve the first side effect for the tx hash (inserted by the private kernel)
114
- const startSideEffectCounter = 1;
132
+ const startSideEffectCounter = 2;
115
133
 
116
134
  const callContext = new CallContext(
117
135
  msgSender,
@@ -120,25 +138,27 @@ export class ContractFunctionSimulator {
120
138
  entryPointArtifact.isStatic,
121
139
  );
122
140
 
123
- const txRequestHash = await request.toTxRequest().hash();
124
- const noteCache = new ExecutionNoteCache(txRequestHash);
141
+ const protocolNullifier = await computeProtocolNullifier(await request.toTxRequest().hash());
142
+ const noteCache = new ExecutionNoteCache(protocolNullifier);
143
+ const taggingIndexCache = new ExecutionTaggingIndexCache();
125
144
 
126
145
  const privateExecutionOracle = new PrivateExecutionOracle(
127
146
  request.firstCallArgsHash,
128
147
  request.txContext,
129
148
  callContext,
130
- header,
149
+ anchorBlockHeader,
131
150
  request.authWitnesses,
132
151
  request.capsules,
133
152
  HashedValuesCache.create(request.argsOfCalls),
134
153
  noteCache,
154
+ taggingIndexCache,
135
155
  this.executionDataProvider,
136
- this.simulator,
137
156
  0, // totalPublicArgsCount
138
157
  startSideEffectCounter,
139
158
  undefined, // log
140
159
  scopes,
141
160
  senderForTags,
161
+ this.simulator,
142
162
  );
143
163
 
144
164
  const setupTime = simulatorSetupTimer.ms();
@@ -156,8 +176,8 @@ export class ContractFunctionSimulator {
156
176
  request.functionSelector,
157
177
  );
158
178
  const simulatorTeardownTimer = new Timer();
159
- const { usedTxRequestHashForNonces } = noteCache.finish();
160
- const firstNullifierHint = usedTxRequestHashForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
179
+ const { usedProtocolNullifierForNonces } = noteCache.finish();
180
+ const firstNullifierHint = usedProtocolNullifierForNonces ? Fr.ZERO : noteCache.getAllNullifiers()[0];
161
181
 
162
182
  const publicCallRequests = collectNested([executionResult], r =>
163
183
  r.publicInputs.publicCallRequests
@@ -195,9 +215,9 @@ export class ContractFunctionSimulator {
195
215
  * @param authwits - Authentication witnesses required for the function call.
196
216
  * @param scopes - Optional array of account addresses whose notes can be accessed in this call. Defaults to all
197
217
  * accounts if not specified.
198
- * @returns A decoded ABI value containing the function's return data.
218
+ * @returns A return value of the utility function in a form as returned by the simulator (Noir fields)
199
219
  */
200
- public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<AbiDecoded> {
220
+ public async runUtility(call: FunctionCall, authwits: AuthWitness[], scopes?: AztecAddress[]): Promise<Fr[]> {
201
221
  await verifyCurrentClassId(call.to, this.executionDataProvider);
202
222
 
203
223
  const entryPointArtifact = await this.executionDataProvider.getFunctionArtifact(call.to, call.selector);
@@ -230,9 +250,8 @@ export class ContractFunctionSimulator {
230
250
  );
231
251
  });
232
252
 
233
- const returnWitness = witnessMapToFields(acirExecutionResult.returnWitness);
234
253
  this.log.verbose(`Utility simulation for ${call.to}.${call.selector} completed`);
235
- return decodeFromAbi(entryPointArtifact.returnTypes, returnWitness);
254
+ return witnessMapToFields(acirExecutionResult.returnWitness);
236
255
  } catch (err) {
237
256
  throw createSimulationError(err instanceof Error ? err : new Error('Unknown error during private execution'));
238
257
  }
@@ -255,7 +274,7 @@ class OrderedSideEffect<T> {
255
274
  }
256
275
 
257
276
  /**
258
- * Generates the final public inputs of the tail kernel circuit, an empty ClientIVC proof
277
+ * Generates the final public inputs of the tail kernel circuit, an empty Chonk proof
259
278
  * and the execution steps for a `PrivateExecutionResult` as if it had been
260
279
  * processed by the private kernel prover. This skips many of the checks performed by the kernels
261
280
  * (allowing state overrides) and is much faster, while still generating a valid
@@ -358,30 +377,35 @@ export async function generateSimulatedProvingResult(
358
377
  }
359
378
 
360
379
  const constantData = new TxConstantData(
361
- privateExecutionResult.entrypoint.publicInputs.historicalHeader,
380
+ privateExecutionResult.entrypoint.publicInputs.anchorBlockHeader,
362
381
  privateExecutionResult.entrypoint.publicInputs.txContext,
363
382
  getVKTreeRoot(),
364
- protocolContractTreeRoot,
383
+ protocolContractsHash,
365
384
  );
366
385
 
367
386
  const hasPublicCalls = privateExecutionResult.publicFunctionCalldata.length !== 0;
368
387
  let inputsForRollup;
369
388
  let inputsForPublic;
389
+ let gasUsed;
370
390
 
371
391
  const sortByCounter = <T>(a: OrderedSideEffect<T>, b: OrderedSideEffect<T>) => a.counter - b.counter;
372
392
  const getEffect = <T>(orderedSideEffect: OrderedSideEffect<T>) => orderedSideEffect.sideEffect;
373
393
 
374
- const sortedNullifiers = nullifiers.sort(sortByCounter).map(getEffect);
394
+ const isPrivateOnlyTx = privateExecutionResult.publicFunctionCalldata.length === 0;
395
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(privateExecutionResult);
375
396
 
376
- // If the tx generated no nullifiers, the nonce generator (txRequest hash)
377
- // is injected as the first nullifier as per protocol rules.
378
- if (sortedNullifiers.length === 0) {
379
- sortedNullifiers.push(nonceGenerator);
397
+ const [nonRevertibleNullifiers, revertibleNullifiers] = splitOrderedSideEffects(
398
+ nullifiers.sort(sortByCounter),
399
+ minRevertibleSideEffectCounter,
400
+ );
401
+ if (nonRevertibleNullifiers.length > 0 && !nonRevertibleNullifiers[0].equals(nonceGenerator)) {
402
+ throw new Error('The first non revertible nullifier should be equal to the nonce generator. This is a bug!');
403
+ } else {
404
+ nonRevertibleNullifiers.unshift(nonceGenerator);
380
405
  }
381
406
 
382
- // Private only
383
- if (privateExecutionResult.publicFunctionCalldata.length === 0) {
384
- // In case the tx only contains private functions, we must make the note hashes unique by using the
407
+ if (isPrivateOnlyTx) {
408
+ // We must make the note hashes unique by using the
385
409
  // nonce generator and their index in the tx.
386
410
  const uniqueNoteHashes = await Promise.all(
387
411
  siloedNoteHashes.sort(sortByCounter).map(async (orderedSideEffect, i) => {
@@ -393,7 +417,7 @@ export async function generateSimulatedProvingResult(
393
417
  );
394
418
  const accumulatedDataForRollup = new PrivateToRollupAccumulatedData(
395
419
  padArrayEnd(uniqueNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
396
- padArrayEnd(sortedNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
420
+ padArrayEnd(nonRevertibleNullifiers.concat(revertibleNullifiers), Fr.ZERO, MAX_NULLIFIERS_PER_TX),
397
421
  padArrayEnd(
398
422
  l2ToL1Messages.sort(sortByCounter).map(getEffect),
399
423
  ScopedL2ToL1Message.empty(),
@@ -406,39 +430,51 @@ export async function generateSimulatedProvingResult(
406
430
  MAX_CONTRACT_CLASS_LOGS_PER_TX,
407
431
  ),
408
432
  );
409
-
433
+ gasUsed = meterGasUsed(accumulatedDataForRollup);
410
434
  inputsForRollup = new PartialPrivateTailPublicInputsForRollup(accumulatedDataForRollup);
411
435
  } else {
412
- const nonRevertibleData = PrivateToPublicAccumulatedData.empty();
436
+ const [nonRevertibleNoteHashes, revertibleNoteHashes] = splitOrderedSideEffects(
437
+ siloedNoteHashes.sort(sortByCounter),
438
+ minRevertibleSideEffectCounter,
439
+ );
440
+ const [nonRevertibleL2ToL1Messages, revertibleL2ToL1Messages] = splitOrderedSideEffects(
441
+ l2ToL1Messages.sort(sortByCounter),
442
+ minRevertibleSideEffectCounter,
443
+ );
444
+ const [nonRevertibleTaggedPrivateLogs, revertibleTaggedPrivateLogs] = splitOrderedSideEffects(
445
+ taggedPrivateLogs,
446
+ minRevertibleSideEffectCounter,
447
+ );
448
+ const [nonRevertibleContractClassLogHashes, revertibleContractClassLogHashes] = splitOrderedSideEffects(
449
+ contractClassLogsHashes.sort(sortByCounter),
450
+ minRevertibleSideEffectCounter,
451
+ );
452
+ const [nonRevertiblePublicCallRequests, revertiblePublicCallRequests] = splitOrderedSideEffects(
453
+ publicCallRequests.sort(sortByCounter),
454
+ minRevertibleSideEffectCounter,
455
+ );
413
456
 
414
- // The nullifier array contains the nonce generator in position 0
415
- // Here we remove it from the revertible data and
416
- // add it as the first non-revertible nullifier (we can't have dupes!)
417
- // This is because public processor will use that first non-revertible nullifier
418
- // as the nonce generator for the note hashes in the revertible part of the tx.
419
- const [firstNullifier] = sortedNullifiers.splice(0, 1);
420
- nonRevertibleData.nullifiers[0] = firstNullifier;
457
+ const nonRevertibleData = new PrivateToPublicAccumulatedData(
458
+ padArrayEnd(nonRevertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
459
+ padArrayEnd(nonRevertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
460
+ padArrayEnd(nonRevertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
461
+ padArrayEnd(nonRevertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
462
+ padArrayEnd(nonRevertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
463
+ padArrayEnd(nonRevertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
464
+ );
421
465
 
422
466
  const revertibleData = new PrivateToPublicAccumulatedData(
423
- padArrayEnd(siloedNoteHashes.sort(sortByCounter).map(getEffect), Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
424
- padArrayEnd(sortedNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
425
- padArrayEnd(
426
- l2ToL1Messages.sort(sortByCounter).map(getEffect),
427
- ScopedL2ToL1Message.empty(),
428
- MAX_L2_TO_L1_MSGS_PER_TX,
429
- ),
430
- padArrayEnd(taggedPrivateLogs.sort(sortByCounter).map(getEffect), PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
431
- padArrayEnd(
432
- contractClassLogsHashes.sort(sortByCounter).map(getEffect),
433
- ScopedLogHash.empty(),
434
- MAX_CONTRACT_CLASS_LOGS_PER_TX,
435
- ),
436
- padArrayEnd(
437
- publicCallRequests.sort(sortByCounter).map(getEffect),
438
- PublicCallRequest.empty(),
439
- MAX_ENQUEUED_CALLS_PER_TX,
440
- ),
467
+ padArrayEnd(revertibleNoteHashes, Fr.ZERO, MAX_NOTE_HASHES_PER_TX),
468
+ padArrayEnd(revertibleNullifiers, Fr.ZERO, MAX_NULLIFIERS_PER_TX),
469
+ padArrayEnd(revertibleL2ToL1Messages, ScopedL2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_TX),
470
+ padArrayEnd(revertibleTaggedPrivateLogs, PrivateLog.empty(), MAX_PRIVATE_LOGS_PER_TX),
471
+ padArrayEnd(revertibleContractClassLogHashes, ScopedLogHash.empty(), MAX_CONTRACT_CLASS_LOGS_PER_TX),
472
+ padArrayEnd(revertiblePublicCallRequests, PublicCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_TX),
441
473
  );
474
+ gasUsed = meterGasUsed(revertibleData).add(meterGasUsed(nonRevertibleData));
475
+ if (publicTeardownCallRequest) {
476
+ gasUsed.add(privateExecutionResult.entrypoint.publicInputs.txContext.gasSettings.teardownGasLimits);
477
+ }
442
478
 
443
479
  inputsForPublic = new PartialPrivateTailPublicInputsForPublic(
444
480
  nonRevertibleData,
@@ -449,7 +485,7 @@ export async function generateSimulatedProvingResult(
449
485
 
450
486
  const publicInputs = new PrivateKernelTailCircuitPublicInputs(
451
487
  constantData,
452
- /*gasUsed=*/ new Gas(0, 0),
488
+ /*gasUsed=*/ gasUsed.add(Gas.from({ l2Gas: FIXED_L2_GAS, daGas: FIXED_DA_GAS })),
453
489
  /*feePayer=*/ AztecAddress.zero(),
454
490
  /*includeByTimestamp=*/ 0n,
455
491
  hasPublicCalls ? inputsForPublic : undefined,
@@ -458,7 +494,60 @@ export async function generateSimulatedProvingResult(
458
494
 
459
495
  return {
460
496
  publicInputs,
461
- clientIvcProof: ClientIvcProof.empty(),
462
- executionSteps: executionSteps,
497
+ chonkProof: ChonkProof.empty(),
498
+ executionSteps,
463
499
  };
464
500
  }
501
+
502
+ function splitOrderedSideEffects<T>(effects: OrderedSideEffect<T>[], minRevertibleSideEffectCounter: number) {
503
+ const revertibleSideEffects: T[] = [];
504
+ const nonRevertibleSideEffects: T[] = [];
505
+ effects.forEach(effect => {
506
+ if (effect.counter < minRevertibleSideEffectCounter) {
507
+ nonRevertibleSideEffects.push(effect.sideEffect);
508
+ } else {
509
+ revertibleSideEffects.push(effect.sideEffect);
510
+ }
511
+ });
512
+ return [nonRevertibleSideEffects, revertibleSideEffects];
513
+ }
514
+
515
+ function meterGasUsed(data: PrivateToRollupAccumulatedData | PrivateToPublicAccumulatedData) {
516
+ let meteredDAFields = 0;
517
+ let meteredL2Gas = 0;
518
+
519
+ const numNoteHashes = arrayNonEmptyLength(data.noteHashes, hash => hash.isEmpty());
520
+ meteredDAFields += numNoteHashes;
521
+ meteredL2Gas += numNoteHashes * AVM_EMITNOTEHASH_BASE_L2_GAS;
522
+
523
+ const numNullifiers = arrayNonEmptyLength(data.nullifiers, nullifier => nullifier.isEmpty());
524
+ meteredDAFields += numNullifiers;
525
+ meteredL2Gas += numNullifiers * AVM_EMITNULLIFIER_BASE_L2_GAS;
526
+
527
+ const numL2toL1Messages = arrayNonEmptyLength(data.l2ToL1Msgs, msg => msg.isEmpty());
528
+ meteredDAFields += numL2toL1Messages;
529
+ meteredL2Gas += numL2toL1Messages * AVM_SENDL2TOL1MSG_BASE_L2_GAS;
530
+
531
+ const numPrivatelogs = arrayNonEmptyLength(data.privateLogs, log => log.isEmpty());
532
+ // Every private log emits its length as an additional field
533
+ meteredDAFields += data.privateLogs.reduce((acc, log) => (!log.isEmpty() ? acc + log.emittedLength + 1 : acc), 0);
534
+ meteredL2Gas += numPrivatelogs * L2_GAS_PER_PRIVATE_LOG;
535
+
536
+ const numContractClassLogs = arrayNonEmptyLength(data.contractClassLogsHashes, log => log.isEmpty());
537
+ // Every contract class log emits its length and contract address as additional fields
538
+ meteredDAFields += data.contractClassLogsHashes.reduce(
539
+ (acc, log) => (!log.isEmpty() ? acc + log.logHash.length + 2 : acc),
540
+ 0,
541
+ );
542
+ meteredL2Gas += numContractClassLogs * L2_GAS_PER_CONTRACT_CLASS_LOG;
543
+
544
+ const meteredDAGas = meteredDAFields * DA_BYTES_PER_FIELD * DA_GAS_PER_BYTE;
545
+
546
+ if ((data as PrivateToPublicAccumulatedData).publicCallRequests) {
547
+ const dataForPublic = data as PrivateToPublicAccumulatedData;
548
+
549
+ const numPublicCallRequests = arrayNonEmptyLength(dataForPublic.publicCallRequests, req => req.isEmpty());
550
+ meteredL2Gas += numPublicCallRequests * FIXED_AVM_STARTUP_L2_GAS;
551
+ }
552
+ return Gas.from({ l2Gas: meteredL2Gas, daGas: meteredDAGas });
553
+ }