@aztec/pxe 0.0.1-commit.d431d1c → 0.0.1-commit.d939eb5aa

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 (269) hide show
  1. package/dest/bin/check_oracle_version.js +5 -5
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +9 -5
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +68 -16
  5. package/dest/config/index.d.ts +4 -2
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +12 -2
  8. package/dest/config/package_info.js +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts +63 -31
  10. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/contract_function_simulator.js +206 -78
  12. package/dest/contract_function_simulator/ephemeral_array_service.d.ts +28 -0
  13. package/dest/contract_function_simulator/ephemeral_array_service.d.ts.map +1 -0
  14. package/dest/contract_function_simulator/ephemeral_array_service.js +78 -0
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +7 -7
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/execution_tagging_index_cache.js +19 -11
  18. package/dest/contract_function_simulator/index.d.ts +2 -1
  19. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  20. package/dest/contract_function_simulator/index.js +1 -0
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +5 -7
  22. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +9 -11
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.js +1 -1
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  27. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  28. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +2 -4
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +5 -8
  30. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +7 -12
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts +65 -46
  33. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  34. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts +9 -0
  35. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.d.ts.map +1 -0
  36. package/dest/contract_function_simulator/oracle/legacy_oracle_mappings.js +47 -0
  37. package/dest/contract_function_simulator/oracle/oracle.d.ts +75 -42
  38. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/oracle.js +319 -112
  40. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -22
  41. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution.js +5 -40
  43. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +59 -77
  44. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +120 -86
  46. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +134 -67
  47. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +337 -151
  49. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  50. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  51. package/dest/contract_function_simulator/pick_notes.js +9 -2
  52. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  53. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/proxied_contract_data_source.js +3 -0
  55. package/dest/contract_logging.d.ts +27 -0
  56. package/dest/contract_logging.d.ts.map +1 -0
  57. package/dest/contract_logging.js +38 -0
  58. package/dest/contract_sync/contract_sync_service.d.ts +44 -0
  59. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  60. package/dest/contract_sync/contract_sync_service.js +116 -0
  61. package/dest/contract_sync/helpers.d.ts +28 -0
  62. package/dest/contract_sync/helpers.d.ts.map +1 -0
  63. package/dest/contract_sync/helpers.js +60 -0
  64. package/dest/debug/pxe_debug_utils.d.ts +24 -10
  65. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  66. package/dest/debug/pxe_debug_utils.js +28 -17
  67. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  68. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  69. package/dest/entrypoints/client/bundle/index.js +2 -0
  70. package/dest/entrypoints/client/bundle/utils.d.ts +2 -2
  71. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  72. package/dest/entrypoints/client/bundle/utils.js +23 -9
  73. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  74. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  75. package/dest/entrypoints/client/lazy/index.js +2 -0
  76. package/dest/entrypoints/client/lazy/utils.d.ts +3 -3
  77. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  78. package/dest/entrypoints/client/lazy/utils.js +24 -10
  79. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  80. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  81. package/dest/entrypoints/pxe_creation_options.js +3 -1
  82. package/dest/entrypoints/server/index.d.ts +4 -2
  83. package/dest/entrypoints/server/index.d.ts.map +1 -1
  84. package/dest/entrypoints/server/index.js +3 -1
  85. package/dest/entrypoints/server/utils.d.ts +2 -2
  86. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  87. package/dest/entrypoints/server/utils.js +30 -11
  88. package/dest/events/event_service.d.ts +6 -6
  89. package/dest/events/event_service.d.ts.map +1 -1
  90. package/dest/events/event_service.js +21 -10
  91. package/dest/events/private_event_filter_validator.d.ts +3 -2
  92. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  93. package/dest/events/private_event_filter_validator.js +15 -0
  94. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  95. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  96. package/dest/job_coordinator/job_coordinator.js +3 -2
  97. package/dest/logs/log_service.d.ts +10 -9
  98. package/dest/logs/log_service.d.ts.map +1 -1
  99. package/dest/logs/log_service.js +50 -64
  100. package/dest/messages/message_context_service.d.ts +17 -0
  101. package/dest/messages/message_context_service.d.ts.map +1 -0
  102. package/dest/messages/message_context_service.js +36 -0
  103. package/dest/notes/note_service.d.ts +8 -8
  104. package/dest/notes/note_service.d.ts.map +1 -1
  105. package/dest/notes/note_service.js +29 -19
  106. package/dest/notes_filter.d.ts +24 -0
  107. package/dest/notes_filter.d.ts.map +1 -0
  108. package/dest/notes_filter.js +4 -0
  109. package/dest/oracle_version.d.ts +4 -3
  110. package/dest/oracle_version.d.ts.map +1 -1
  111. package/dest/oracle_version.js +20 -9
  112. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts +4 -0
  113. package/dest/private_kernel/hints/compute_tx_expiration_timestamp.d.ts.map +1 -0
  114. package/dest/private_kernel/hints/{compute_tx_include_by_timestamp.js → compute_tx_expiration_timestamp.js} +12 -12
  115. package/dest/private_kernel/hints/index.d.ts +1 -1
  116. package/dest/private_kernel/hints/index.js +1 -1
  117. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +4 -3
  118. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -1
  119. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.js +129 -68
  120. package/dest/private_kernel/hints/test_utils.d.ts +122 -0
  121. package/dest/private_kernel/hints/test_utils.d.ts.map +1 -0
  122. package/dest/private_kernel/hints/test_utils.js +203 -0
  123. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  124. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  125. package/dest/private_kernel/private_kernel_execution_prover.js +20 -15
  126. package/dest/private_kernel/private_kernel_oracle.d.ts +8 -4
  127. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  128. package/dest/private_kernel/private_kernel_oracle.js +7 -3
  129. package/dest/pxe.d.ts +74 -24
  130. package/dest/pxe.d.ts.map +1 -1
  131. package/dest/pxe.js +142 -80
  132. package/dest/storage/address_store/address_store.d.ts +1 -1
  133. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  134. package/dest/storage/address_store/address_store.js +12 -11
  135. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  136. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  137. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  138. package/dest/storage/capsule_store/capsule_service.d.ts +21 -0
  139. package/dest/storage/capsule_store/capsule_service.d.ts.map +1 -0
  140. package/dest/storage/capsule_store/capsule_service.js +50 -0
  141. package/dest/storage/capsule_store/capsule_store.d.ts +9 -9
  142. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  143. package/dest/storage/capsule_store/capsule_store.js +39 -36
  144. package/dest/storage/capsule_store/index.d.ts +2 -1
  145. package/dest/storage/capsule_store/index.d.ts.map +1 -1
  146. package/dest/storage/capsule_store/index.js +1 -0
  147. package/dest/storage/contract_store/contract_store.d.ts +42 -16
  148. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  149. package/dest/storage/contract_store/contract_store.js +157 -84
  150. package/dest/storage/metadata.d.ts +1 -1
  151. package/dest/storage/metadata.js +1 -1
  152. package/dest/storage/note_store/note_store.d.ts +47 -49
  153. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  154. package/dest/storage/note_store/note_store.js +278 -252
  155. package/dest/storage/note_store/stored_note.d.ts +16 -0
  156. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  157. package/dest/storage/note_store/stored_note.js +43 -0
  158. package/dest/storage/private_event_store/private_event_store.d.ts +17 -4
  159. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  160. package/dest/storage/private_event_store/private_event_store.js +198 -147
  161. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  162. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  163. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  164. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +6 -6
  165. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  166. package/dest/storage/tagging_store/recipient_tagging_store.js +31 -19
  167. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  168. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  169. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  170. package/dest/storage/tagging_store/sender_tagging_store.d.ts +29 -28
  171. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  172. package/dest/storage/tagging_store/sender_tagging_store.js +233 -137
  173. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  174. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  175. package/dest/tagging/get_all_logs_by_tags.js +60 -0
  176. package/dest/tagging/index.d.ts +4 -3
  177. package/dest/tagging/index.d.ts.map +1 -1
  178. package/dest/tagging/index.js +2 -1
  179. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +5 -5
  180. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  181. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -21
  182. package/dest/tagging/recipient_sync/utils/find_highest_indexes.js +2 -2
  183. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +7 -7
  184. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  185. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +16 -12
  186. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +5 -8
  187. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  188. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +13 -7
  189. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +4 -3
  190. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  191. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +23 -16
  192. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +6 -7
  193. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  194. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +42 -27
  195. package/package.json +25 -16
  196. package/src/bin/check_oracle_version.ts +5 -4
  197. package/src/block_synchronizer/block_synchronizer.ts +82 -33
  198. package/src/config/index.ts +9 -1
  199. package/src/config/package_info.ts +1 -1
  200. package/src/contract_function_simulator/contract_function_simulator.ts +366 -142
  201. package/src/contract_function_simulator/ephemeral_array_service.ts +110 -0
  202. package/src/contract_function_simulator/execution_tagging_index_cache.ts +19 -14
  203. package/src/contract_function_simulator/index.ts +1 -0
  204. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +10 -10
  205. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  206. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -5
  207. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +5 -11
  208. package/src/contract_function_simulator/oracle/interfaces.ts +95 -58
  209. package/src/contract_function_simulator/oracle/legacy_oracle_mappings.ts +104 -0
  210. package/src/contract_function_simulator/oracle/oracle.ts +404 -150
  211. package/src/contract_function_simulator/oracle/private_execution.ts +5 -64
  212. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +160 -182
  213. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +564 -182
  214. package/src/contract_function_simulator/pick_notes.ts +9 -2
  215. package/src/contract_function_simulator/proxied_contract_data_source.ts +8 -1
  216. package/src/contract_logging.ts +52 -0
  217. package/src/contract_sync/contract_sync_service.ts +176 -0
  218. package/src/contract_sync/helpers.ts +98 -0
  219. package/src/debug/pxe_debug_utils.ts +63 -18
  220. package/src/entrypoints/client/bundle/index.ts +2 -0
  221. package/src/entrypoints/client/bundle/utils.ts +18 -18
  222. package/src/entrypoints/client/lazy/index.ts +2 -0
  223. package/src/entrypoints/client/lazy/utils.ts +19 -18
  224. package/src/entrypoints/pxe_creation_options.ts +9 -1
  225. package/src/entrypoints/server/index.ts +3 -1
  226. package/src/entrypoints/server/utils.ts +24 -29
  227. package/src/events/event_service.ts +22 -11
  228. package/src/events/private_event_filter_validator.ts +21 -1
  229. package/src/job_coordinator/job_coordinator.ts +4 -3
  230. package/src/logs/log_service.ts +93 -105
  231. package/src/messages/message_context_service.ts +44 -0
  232. package/src/notes/note_service.ts +38 -26
  233. package/src/notes_filter.ts +24 -0
  234. package/src/oracle_version.ts +20 -9
  235. package/src/private_kernel/hints/{compute_tx_include_by_timestamp.ts → compute_tx_expiration_timestamp.ts} +13 -13
  236. package/src/private_kernel/hints/index.ts +1 -1
  237. package/src/private_kernel/hints/private_kernel_reset_private_inputs_builder.ts +164 -117
  238. package/src/private_kernel/hints/test_utils.ts +325 -0
  239. package/src/private_kernel/private_kernel_execution_prover.ts +24 -19
  240. package/src/private_kernel/private_kernel_oracle.ts +9 -9
  241. package/src/pxe.ts +272 -126
  242. package/src/storage/address_store/address_store.ts +15 -15
  243. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  244. package/src/storage/capsule_store/capsule_service.ts +90 -0
  245. package/src/storage/capsule_store/capsule_store.ts +42 -34
  246. package/src/storage/capsule_store/index.ts +1 -0
  247. package/src/storage/contract_store/contract_store.ts +186 -96
  248. package/src/storage/metadata.ts +1 -1
  249. package/src/storage/note_store/note_store.ts +318 -318
  250. package/src/storage/note_store/stored_note.ts +48 -0
  251. package/src/storage/private_event_store/private_event_store.ts +250 -190
  252. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  253. package/src/storage/tagging_store/recipient_tagging_store.ts +38 -24
  254. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  255. package/src/storage/tagging_store/sender_tagging_store.ts +287 -156
  256. package/src/tagging/get_all_logs_by_tags.ts +92 -0
  257. package/src/tagging/index.ts +3 -2
  258. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +19 -24
  259. package/src/tagging/recipient_sync/utils/find_highest_indexes.ts +2 -2
  260. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +17 -16
  261. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +25 -10
  262. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +29 -26
  263. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +39 -29
  264. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +0 -4
  265. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts.map +0 -1
  266. package/dest/tree_membership/tree_membership_service.d.ts +0 -50
  267. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  268. package/dest/tree_membership/tree_membership_service.js +0 -75
  269. package/src/tree_membership/tree_membership_service.ts +0 -97
@@ -2,7 +2,6 @@ import { PRIVATE_CIRCUIT_PUBLIC_INPUTS_LENGTH, PRIVATE_CONTEXT_INPUTS_LENGTH } f
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { createLogger } from '@aztec/foundation/log';
4
4
  import { Timer } from '@aztec/foundation/timer';
5
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
5
  import {
7
6
  type ACVMWitness,
8
7
  type CircuitSimulator,
@@ -18,15 +17,10 @@ import {
18
17
  countArgumentsSize,
19
18
  } from '@aztec/stdlib/abi';
20
19
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
21
- import { L2BlockHash } from '@aztec/stdlib/block';
22
- import type { ContractInstance } from '@aztec/stdlib/contract';
23
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
24
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
25
20
  import { PrivateCircuitPublicInputs } from '@aztec/stdlib/kernel';
26
21
  import type { CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
27
- import { BlockHeader, PrivateCallExecutionResult } from '@aztec/stdlib/tx';
22
+ import { PrivateCallExecutionResult } from '@aztec/stdlib/tx';
28
23
 
29
- import { ContractStore } from '../../storage/contract_store/index.js';
30
24
  import { Oracle } from './oracle.js';
31
25
  import type { PrivateExecutionOracle } from './private_execution_oracle.js';
32
26
 
@@ -82,12 +76,12 @@ export async function executePrivateFunction(
82
76
 
83
77
  const contractClassLogs = privateExecutionOracle.getContractClassLogs();
84
78
 
85
- const rawReturnValues = await privateExecutionOracle.privateLoadFromExecutionCache(publicInputs.returnsHash);
79
+ const rawReturnValues = await privateExecutionOracle.getHashPreimage(publicInputs.returnsHash);
86
80
 
87
81
  const newNotes = privateExecutionOracle.getNewNotes();
88
82
  const noteHashNullifierCounterMap = privateExecutionOracle.getNoteHashNullifierCounterMap();
89
83
  const offchainEffects = privateExecutionOracle.getOffchainEffects();
90
- const preTags = privateExecutionOracle.getUsedPreTags();
84
+ const taggingIndexRanges = privateExecutionOracle.getUsedTaggingIndexRanges();
91
85
  const nestedExecutionResults = privateExecutionOracle.getNestedExecutionResults();
92
86
 
93
87
  let timerSubtractionList = nestedExecutionResults;
@@ -109,8 +103,8 @@ export async function executePrivateFunction(
109
103
  newNotes,
110
104
  noteHashNullifierCounterMap,
111
105
  rawReturnValues,
112
- offchainEffects,
113
- preTags,
106
+ offchainEffects.map(e => ({ data: e.data })),
107
+ taggingIndexRanges,
114
108
  nestedExecutionResults,
115
109
  contractClassLogs,
116
110
  {
@@ -145,56 +139,3 @@ export function extractPrivateCircuitPublicInputs(
145
139
  }
146
140
  return PrivateCircuitPublicInputs.fromFields(returnData);
147
141
  }
148
-
149
- /**
150
- * Read the current class id of a contract from the execution data provider or AztecNode. If not found, class id
151
- * from the instance is used.
152
- * @param contractAddress - The address of the contract to read the class id for.
153
- * @param instance - The instance of the contract.
154
- * @param aztecNode - The Aztec node to query for storage.
155
- * @param header - The header of the block at which to load the DelayedPublicMutable storing the class id.
156
- * @returns The current class id.
157
- */
158
- export async function readCurrentClassId(
159
- contractAddress: AztecAddress,
160
- instance: ContractInstance,
161
- aztecNode: AztecNode,
162
- header: BlockHeader,
163
- ) {
164
- const blockHashFr = await header.hash();
165
- const blockHash = L2BlockHash.fromField(blockHashFr);
166
- const timestamp = header.globalVariables.timestamp;
167
- const { delayedPublicMutableSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
168
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, slot =>
169
- aztecNode.getPublicStorageAt(blockHash, ProtocolContractAddress.ContractInstanceRegistry, slot),
170
- );
171
- let currentClassId = delayedPublicMutableValues.svc.getCurrentAt(timestamp)[0];
172
- if (currentClassId.isZero()) {
173
- currentClassId = instance.originalContractClassId;
174
- }
175
- return currentClassId;
176
- }
177
-
178
- /**
179
- * Verify that the current class id of a contract obtained from AztecNode is the same as the one in contract data
180
- * provider (i.e. PXE's own storage).
181
- * @param header - The header of the block at which to verify the current class id.
182
- */
183
- export async function verifyCurrentClassId(
184
- contractAddress: AztecAddress,
185
- aztecNode: AztecNode,
186
- contractStore: ContractStore,
187
- header: BlockHeader,
188
- ) {
189
- const instance = await contractStore.getContractInstance(contractAddress);
190
- if (!instance) {
191
- throw new Error(`No contract instance found for address ${contractAddress.toString()}`);
192
- }
193
-
194
- const currentClassId = await readCurrentClassId(contractAddress, instance, aztecNode, header);
195
- if (!instance.currentContractClassId.equals(currentClassId)) {
196
- throw new Error(
197
- `Contract ${contractAddress} is outdated, current class id is ${currentClassId}, local class id is ${instance.currentContractClassId}`,
198
- );
199
- }
200
- }