@aztec/pxe 0.0.1-commit.7d4e6cd → 0.0.1-commit.87a0206

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 (230) hide show
  1. package/dest/bin/check_oracle_version.js +1 -1
  2. package/dest/block_synchronizer/block_synchronizer.d.ts +11 -5
  3. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  4. package/dest/block_synchronizer/block_synchronizer.js +72 -21
  5. package/dest/config/index.d.ts +3 -1
  6. package/dest/config/index.d.ts.map +1 -1
  7. package/dest/config/index.js +17 -0
  8. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  9. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  10. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  11. package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -10
  12. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/contract_function_simulator.js +36 -26
  14. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -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 +45 -28
  17. package/dest/contract_function_simulator/index.d.ts +2 -2
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +1 -1
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -1
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  24. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  25. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  27. package/dest/contract_function_simulator/oracle/interfaces.d.ts +16 -12
  28. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  30. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  31. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +6 -6
  32. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/note_packing_utils.js +8 -8
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +11 -9
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +64 -41
  37. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -26
  38. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/private_execution.js +0 -35
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +13 -3
  41. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +23 -11
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +37 -24
  44. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  45. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +88 -84
  46. package/dest/contract_sync/contract_sync_service.d.ts +41 -0
  47. package/dest/contract_sync/contract_sync_service.d.ts.map +1 -0
  48. package/dest/contract_sync/contract_sync_service.js +82 -0
  49. package/dest/contract_sync/helpers.d.ts +28 -0
  50. package/dest/contract_sync/helpers.d.ts.map +1 -0
  51. package/dest/contract_sync/helpers.js +55 -0
  52. package/dest/debug/pxe_debug_utils.d.ts +22 -9
  53. package/dest/debug/pxe_debug_utils.d.ts.map +1 -1
  54. package/dest/debug/pxe_debug_utils.js +28 -17
  55. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  56. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  57. package/dest/entrypoints/client/bundle/utils.js +12 -6
  58. package/dest/entrypoints/client/lazy/utils.d.ts +2 -2
  59. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  60. package/dest/entrypoints/client/lazy/utils.js +13 -7
  61. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  62. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  63. package/dest/entrypoints/server/index.d.ts +3 -1
  64. package/dest/entrypoints/server/index.d.ts.map +1 -1
  65. package/dest/entrypoints/server/index.js +2 -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 +19 -8
  69. package/dest/events/event_service.d.ts +6 -6
  70. package/dest/events/event_service.d.ts.map +1 -1
  71. package/dest/events/event_service.js +19 -22
  72. package/dest/events/private_event_filter_validator.d.ts +5 -5
  73. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  74. package/dest/events/private_event_filter_validator.js +5 -6
  75. package/dest/job_coordinator/job_coordinator.d.ts +3 -2
  76. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -1
  77. package/dest/job_coordinator/job_coordinator.js +3 -2
  78. package/dest/logs/log_service.d.ts +7 -5
  79. package/dest/logs/log_service.d.ts.map +1 -1
  80. package/dest/logs/log_service.js +23 -20
  81. package/dest/notes/note_service.d.ts +7 -7
  82. package/dest/notes/note_service.d.ts.map +1 -1
  83. package/dest/notes/note_service.js +31 -36
  84. package/dest/oracle_version.d.ts +3 -3
  85. package/dest/oracle_version.d.ts.map +1 -1
  86. package/dest/oracle_version.js +4 -3
  87. package/dest/private_kernel/hints/index.d.ts +2 -2
  88. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  89. package/dest/private_kernel/hints/index.js +1 -1
  90. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  91. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  92. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +12 -6
  93. package/dest/private_kernel/private_kernel_execution_prover.d.ts +3 -2
  94. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  95. package/dest/private_kernel/private_kernel_execution_prover.js +3 -3
  96. package/dest/private_kernel/private_kernel_oracle.d.ts +23 -28
  97. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  98. package/dest/private_kernel/private_kernel_oracle.js +90 -2
  99. package/dest/pxe.d.ts +19 -37
  100. package/dest/pxe.d.ts.map +1 -1
  101. package/dest/pxe.js +67 -86
  102. package/dest/storage/address_store/address_store.d.ts +1 -1
  103. package/dest/storage/address_store/address_store.d.ts.map +1 -1
  104. package/dest/storage/address_store/address_store.js +12 -11
  105. package/dest/storage/anchor_block_store/anchor_block_store.d.ts +9 -1
  106. package/dest/storage/anchor_block_store/anchor_block_store.d.ts.map +1 -1
  107. package/dest/storage/anchor_block_store/anchor_block_store.js +8 -1
  108. package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
  109. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  110. package/dest/storage/capsule_store/capsule_store.js +130 -23
  111. package/dest/storage/contract_store/contract_store.d.ts +1 -2
  112. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  113. package/dest/storage/contract_store/contract_store.js +27 -30
  114. package/dest/storage/metadata.d.ts +1 -1
  115. package/dest/storage/metadata.js +1 -1
  116. package/dest/storage/note_store/note_store.d.ts +51 -52
  117. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  118. package/dest/storage/note_store/note_store.js +285 -263
  119. package/dest/storage/note_store/stored_note.d.ts +16 -0
  120. package/dest/storage/note_store/stored_note.d.ts.map +1 -0
  121. package/dest/storage/note_store/stored_note.js +43 -0
  122. package/dest/storage/private_event_store/private_event_store.d.ts +43 -8
  123. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  124. package/dest/storage/private_event_store/private_event_store.js +226 -111
  125. package/dest/storage/private_event_store/stored_private_event.d.ts +23 -0
  126. package/dest/storage/private_event_store/stored_private_event.d.ts.map +1 -0
  127. package/dest/storage/private_event_store/stored_private_event.js +56 -0
  128. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
  129. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  130. package/dest/storage/tagging_store/recipient_tagging_store.js +88 -19
  131. package/dest/storage/tagging_store/sender_address_book_store.d.ts +1 -1
  132. package/dest/storage/tagging_store/sender_address_book_store.d.ts.map +1 -1
  133. package/dest/storage/tagging_store/sender_address_book_store.js +20 -14
  134. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
  135. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  136. package/dest/storage/tagging_store/sender_tagging_store.js +252 -100
  137. package/dest/tagging/get_all_logs_by_tags.d.ts +24 -0
  138. package/dest/tagging/get_all_logs_by_tags.d.ts.map +1 -0
  139. package/dest/tagging/get_all_logs_by_tags.js +46 -0
  140. package/dest/tagging/index.d.ts +2 -1
  141. package/dest/tagging/index.d.ts.map +1 -1
  142. package/dest/tagging/index.js +1 -0
  143. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +3 -2
  144. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  145. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +6 -6
  146. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts +3 -2
  147. package/dest/tagging/recipient_sync/utils/load_logs_for_range.d.ts.map +1 -1
  148. package/dest/tagging/recipient_sync/utils/load_logs_for_range.js +5 -2
  149. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +3 -2
  150. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  151. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +7 -7
  152. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  153. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  154. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +5 -8
  155. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +5 -2
  156. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  157. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +10 -5
  158. package/package.json +27 -18
  159. package/src/bin/check_oracle_version.ts +1 -0
  160. package/src/block_synchronizer/block_synchronizer.ts +91 -33
  161. package/src/config/index.ts +14 -0
  162. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  163. package/src/contract_function_simulator/contract_function_simulator.ts +39 -30
  164. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  165. package/src/contract_function_simulator/index.ts +1 -1
  166. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  167. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  168. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  169. package/src/contract_function_simulator/oracle/interfaces.ts +21 -11
  170. package/src/contract_function_simulator/oracle/note_packing_utils.ts +10 -10
  171. package/src/contract_function_simulator/oracle/oracle.ts +76 -44
  172. package/src/contract_function_simulator/oracle/private_execution.ts +1 -67
  173. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +37 -13
  174. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +112 -91
  175. package/src/contract_sync/contract_sync_service.ts +129 -0
  176. package/src/contract_sync/helpers.ts +93 -0
  177. package/src/debug/pxe_debug_utils.ts +60 -17
  178. package/src/entrypoints/client/bundle/utils.ts +7 -14
  179. package/src/entrypoints/client/lazy/utils.ts +8 -14
  180. package/src/entrypoints/pxe_creation_options.ts +2 -1
  181. package/src/entrypoints/server/index.ts +2 -0
  182. package/src/entrypoints/server/utils.ts +15 -19
  183. package/src/events/event_service.ts +17 -25
  184. package/src/events/private_event_filter_validator.ts +3 -5
  185. package/src/job_coordinator/job_coordinator.ts +4 -3
  186. package/src/logs/log_service.ts +34 -16
  187. package/src/notes/note_service.ts +38 -43
  188. package/src/oracle_version.ts +4 -3
  189. package/src/private_kernel/hints/index.ts +1 -1
  190. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +32 -20
  191. package/src/private_kernel/private_kernel_execution_prover.ts +7 -4
  192. package/src/private_kernel/private_kernel_oracle.ts +116 -37
  193. package/src/pxe.ts +111 -118
  194. package/src/storage/address_store/address_store.ts +15 -15
  195. package/src/storage/anchor_block_store/anchor_block_store.ts +8 -0
  196. package/src/storage/capsule_store/capsule_store.ts +159 -23
  197. package/src/storage/contract_store/contract_store.ts +26 -35
  198. package/src/storage/metadata.ts +1 -1
  199. package/src/storage/note_store/note_store.ts +321 -318
  200. package/src/storage/note_store/stored_note.ts +48 -0
  201. package/src/storage/private_event_store/private_event_store.ts +292 -124
  202. package/src/storage/private_event_store/stored_private_event.ts +73 -0
  203. package/src/storage/tagging_store/recipient_tagging_store.ts +106 -20
  204. package/src/storage/tagging_store/sender_address_book_store.ts +20 -14
  205. package/src/storage/tagging_store/sender_tagging_store.ts +293 -108
  206. package/src/tagging/get_all_logs_by_tags.ts +68 -0
  207. package/src/tagging/index.ts +1 -0
  208. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +16 -5
  209. package/src/tagging/recipient_sync/utils/load_logs_for_range.ts +7 -1
  210. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +9 -6
  211. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +5 -17
  212. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +16 -4
  213. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  214. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  215. package/dest/contract_function_simulator/proxied_node.js +0 -27
  216. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  217. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  218. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  219. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  220. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -85
  221. package/dest/public_storage/public_storage_service.d.ts +0 -24
  222. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  223. package/dest/public_storage/public_storage_service.js +0 -26
  224. package/dest/tree_membership/tree_membership_service.d.ts +0 -52
  225. package/dest/tree_membership/tree_membership_service.d.ts.map +0 -1
  226. package/dest/tree_membership/tree_membership_service.js +0 -84
  227. package/src/contract_function_simulator/proxied_node.ts +0 -33
  228. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -127
  229. package/src/public_storage/public_storage_service.ts +0 -33
  230. package/src/tree_membership/tree_membership_service.ts +0 -112
@@ -1,32 +1,40 @@
1
1
  import type { Fr } from '@aztec/foundation/curves/bn254';
2
- import { createLogger } from '@aztec/foundation/log';
2
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
3
3
  import type { KeyStore } from '@aztec/key-store';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { CompleteAddress } from '@aztec/stdlib/contract';
6
6
  import type { AztecNode } from '@aztec/stdlib/interfaces/server';
7
7
  import { DirectionalAppTaggingSecret, PendingTaggedLog, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
8
+ import type { BlockHeader } from '@aztec/stdlib/tx';
8
9
 
9
10
  import type { LogRetrievalRequest } from '../contract_function_simulator/noir-structs/log_retrieval_request.js';
10
11
  import { LogRetrievalResponse } from '../contract_function_simulator/noir-structs/log_retrieval_response.js';
11
12
  import { AddressStore } from '../storage/address_store/address_store.js';
12
- import { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
13
13
  import { CapsuleStore } from '../storage/capsule_store/capsule_store.js';
14
14
  import type { RecipientTaggingStore } from '../storage/tagging_store/recipient_tagging_store.js';
15
15
  import type { SenderAddressBookStore } from '../storage/tagging_store/sender_address_book_store.js';
16
- import { loadPrivateLogsForSenderRecipientPair } from '../tagging/index.js';
16
+ import {
17
+ getAllPrivateLogsByTags,
18
+ getAllPublicLogsByTagsFromContract,
19
+ loadPrivateLogsForSenderRecipientPair,
20
+ } from '../tagging/index.js';
17
21
 
18
22
  export class LogService {
19
- private log = createLogger('log_service');
23
+ private log: Logger;
20
24
 
21
25
  constructor(
22
26
  private readonly aztecNode: AztecNode,
23
- private readonly anchorBlockStore: AnchorBlockStore,
27
+ private readonly anchorBlockHeader: BlockHeader,
24
28
  private readonly keyStore: KeyStore,
25
29
  private readonly capsuleStore: CapsuleStore,
26
30
  private readonly recipientTaggingStore: RecipientTaggingStore,
27
31
  private readonly senderAddressBookStore: SenderAddressBookStore,
28
32
  private readonly addressStore: AddressStore,
29
- ) {}
33
+ private readonly jobId: string,
34
+ bindings?: LoggerBindings,
35
+ ) {
36
+ this.log = createLogger('pxe:log_service', bindings);
37
+ }
30
38
 
31
39
  public async bulkRetrieveLogs(logRetrievalRequests: LogRetrievalRequest[]): Promise<(LogRetrievalResponse | null)[]> {
32
40
  return await Promise.all(
@@ -48,10 +56,16 @@ export class LogService {
48
56
  }
49
57
 
50
58
  async #getPublicLogByTag(tag: Tag, contractAddress: AztecAddress): Promise<LogRetrievalResponse | null> {
51
- const logs = await this.aztecNode.getPublicLogsByTagsFromContract(contractAddress, [tag]);
52
- const logsForTag = logs[0];
59
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
60
+ const allLogsPerTag = await getAllPublicLogsByTagsFromContract(
61
+ this.aztecNode,
62
+ contractAddress,
63
+ [tag],
64
+ anchorBlockHash,
65
+ );
66
+ const logsForTag = allLogsPerTag[0];
53
67
 
54
- if (logsForTag.length == 0) {
68
+ if (logsForTag.length === 0) {
55
69
  return null;
56
70
  } else if (logsForTag.length > 1) {
57
71
  // TODO(#11627): handle this case
@@ -71,10 +85,11 @@ export class LogService {
71
85
  }
72
86
 
73
87
  async #getPrivateLogByTag(siloedTag: SiloedTag): Promise<LogRetrievalResponse | null> {
74
- const logs = await this.aztecNode.getPrivateLogsByTags([siloedTag]);
75
- const logsForTag = logs[0];
88
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
89
+ const allLogsPerTag = await getAllPrivateLogsByTags(this.aztecNode, [siloedTag], anchorBlockHash);
90
+ const logsForTag = allLogsPerTag[0];
76
91
 
77
- if (logsForTag.length == 0) {
92
+ if (logsForTag.length === 0) {
78
93
  return null;
79
94
  } else if (logsForTag.length > 1) {
80
95
  // TODO(#11627): handle this case
@@ -93,15 +108,16 @@ export class LogService {
93
108
  );
94
109
  }
95
110
 
96
- public async syncTaggedLogs(
111
+ public async fetchTaggedLogs(
97
112
  contractAddress: AztecAddress,
98
113
  pendingTaggedLogArrayBaseSlot: Fr,
99
114
  scopes?: AztecAddress[],
100
115
  ) {
101
- this.log.verbose('Searching for tagged logs', { contract: contractAddress });
116
+ this.log.verbose(`Fetching tagged logs for ${contractAddress.toString()}`);
102
117
 
103
118
  // We only load logs from block up to and including the anchor block number
104
- const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
119
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
120
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
105
121
 
106
122
  // Determine recipients: use scopes if provided, otherwise get all accounts
107
123
  const recipients = scopes && scopes.length > 0 ? scopes : await this.keyStore.getAccounts();
@@ -122,6 +138,8 @@ export class LogService {
122
138
  this.aztecNode,
123
139
  this.recipientTaggingStore,
124
140
  anchorBlockNumber,
141
+ anchorBlockHash,
142
+ this.jobId,
125
143
  ),
126
144
  ),
127
145
  );
@@ -186,7 +204,7 @@ export class LogService {
186
204
  });
187
205
 
188
206
  // TODO: This looks like it could belong more at the oracle interface level
189
- return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs);
207
+ return this.capsuleStore.appendToCapsuleArray(contractAddress, capsuleArrayBaseSlot, pendingTaggedLogs, this.jobId);
190
208
  }
191
209
 
192
210
  async #getCompleteAddress(account: AztecAddress): Promise<CompleteAddress> {
@@ -5,16 +5,16 @@ import { computeUniqueNoteHash, siloNoteHash, siloNullifier } from '@aztec/stdli
5
5
  import { type AztecNode, MAX_RPC_LEN } from '@aztec/stdlib/interfaces/client';
6
6
  import { Note, NoteDao, NoteStatus } from '@aztec/stdlib/note';
7
7
  import { MerkleTreeId } from '@aztec/stdlib/trees';
8
- import type { TxHash } from '@aztec/stdlib/tx';
8
+ import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
9
9
 
10
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
11
10
  import type { NoteStore } from '../storage/note_store/note_store.js';
12
11
 
13
12
  export class NoteService {
14
13
  constructor(
15
14
  private readonly noteStore: NoteStore,
16
15
  private readonly aztecNode: AztecNode,
17
- private readonly anchorBlockStore: AnchorBlockStore,
16
+ private readonly anchorBlockHeader: BlockHeader,
17
+ private readonly jobId: string,
18
18
  ) {}
19
19
 
20
20
  /**
@@ -33,15 +33,18 @@ export class NoteService {
33
33
  status: NoteStatus,
34
34
  scopes?: AztecAddress[],
35
35
  ) {
36
- const noteDaos = await this.noteStore.getNotes({
37
- contractAddress,
38
- owner,
39
- storageSlot,
40
- status,
41
- scopes,
42
- });
36
+ const noteDaos = await this.noteStore.getNotes(
37
+ {
38
+ contractAddress,
39
+ owner,
40
+ storageSlot,
41
+ status,
42
+ scopes,
43
+ },
44
+ this.jobId,
45
+ );
43
46
  return noteDaos.map(
44
- ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier, index }) => ({
47
+ ({ contractAddress, owner, storageSlot, randomness, noteNonce, note, noteHash, siloedNullifier }) => ({
45
48
  contractAddress,
46
49
  owner,
47
50
  storageSlot,
@@ -49,9 +52,8 @@ export class NoteService {
49
52
  noteNonce,
50
53
  note,
51
54
  noteHash,
55
+ isPending: false, // Note service deals only with settled notes
52
56
  siloedNullifier,
53
- // PXE can use this index to get full MembershipWitness
54
- index,
55
57
  }),
56
58
  );
57
59
  }
@@ -69,9 +71,9 @@ export class NoteService {
69
71
  * @param contractAddress - The contract whose notes should be checked and nullified.
70
72
  */
71
73
  public async syncNoteNullifiers(contractAddress: AztecAddress): Promise<void> {
72
- const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
74
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
73
75
 
74
- const contractNotes = await this.noteStore.getNotes({ contractAddress });
76
+ const contractNotes = await this.noteStore.getNotes({ contractAddress }, this.jobId);
75
77
 
76
78
  if (contractNotes.length === 0) {
77
79
  return;
@@ -92,7 +94,7 @@ export class NoteService {
92
94
  const nullifierIndexes = (
93
95
  await Promise.all(
94
96
  nullifierBatches.map(batch =>
95
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, batch),
97
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, batch),
96
98
  ),
97
99
  )
98
100
  ).flat();
@@ -105,10 +107,10 @@ export class NoteService {
105
107
  })
106
108
  .filter(nullifier => nullifier !== undefined) as DataInBlock<Fr>[];
107
109
 
108
- await this.noteStore.applyNullifiers(foundNullifiers);
110
+ await this.noteStore.applyNullifiers(foundNullifiers, this.jobId);
109
111
  }
110
112
 
111
- public async deliverNote(
113
+ public async validateAndStoreNote(
112
114
  contractAddress: AztecAddress,
113
115
  owner: AztecAddress,
114
116
  storageSlot: Fr,
@@ -139,41 +141,32 @@ export class NoteService {
139
141
  // number which *should* be recent enough to be available, even for non-archive nodes.
140
142
  // Also note that the note should never be ahead of the synced block here since `fetchTaggedLogs` only processes
141
143
  // logs up to the synced block making this only an additional safety check.
142
- const syncedBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
144
+ const anchorBlockNumber = this.anchorBlockHeader.getBlockNumber();
145
+ const anchorBlockHash = await this.anchorBlockHeader.hash();
143
146
 
144
147
  // By computing siloed and unique note hashes ourselves we prevent contracts from interfering with the note storage
145
148
  // of other contracts, which would constitute a security breach.
146
149
  const uniqueNoteHash = await computeUniqueNoteHash(noteNonce, await siloNoteHash(contractAddress, noteHash));
147
150
  const siloedNullifier = await siloNullifier(contractAddress, nullifier);
148
151
 
149
- const txEffect = await this.aztecNode.getTxEffect(txHash);
152
+ const [txEffect, [nullifierIndex]] = await Promise.all([
153
+ this.aztecNode.getTxEffect(txHash),
154
+ this.aztecNode.findLeavesIndexes(anchorBlockHash, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
155
+ ]);
150
156
  if (!txEffect) {
151
157
  throw new Error(`Could not find tx effect for tx hash ${txHash}`);
152
158
  }
153
159
 
154
- if (txEffect.l2BlockNumber > syncedBlockNumber) {
155
- throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${syncedBlockNumber}`);
160
+ if (txEffect.l2BlockNumber > anchorBlockNumber) {
161
+ throw new Error(`Could not find tx effect for tx hash ${txHash} as of block number ${anchorBlockNumber}`);
156
162
  }
157
163
 
158
- const noteInTx = txEffect.data.noteHashes.some(nh => nh.equals(uniqueNoteHash));
159
- if (!noteInTx) {
164
+ // Find the index of the note hash in the noteHashes array to determine note ordering within the tx
165
+ const noteIndexInTx = txEffect.data.noteHashes.findIndex(nh => nh.equals(uniqueNoteHash));
166
+ if (noteIndexInTx === -1) {
160
167
  throw new Error(`Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present in tx ${txHash}`);
161
168
  }
162
169
 
163
- // We store notes by their index in the global note hash tree, which has the convenient side effect of validating
164
- // note existence in said tree. We concurrently also check if the note's nullifier exists, performing all node
165
- // queries in a single round-trip.
166
- const [[uniqueNoteHashTreeIndexInBlock], [nullifierIndex]] = await Promise.all([
167
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NOTE_HASH_TREE, [uniqueNoteHash]),
168
- this.aztecNode.findLeavesIndexes(syncedBlockNumber, MerkleTreeId.NULLIFIER_TREE, [siloedNullifier]),
169
- ]);
170
-
171
- if (uniqueNoteHashTreeIndexInBlock === undefined) {
172
- throw new Error(
173
- `Note hash ${noteHash} (uniqued as ${uniqueNoteHash}) is not present on the tree at block ${syncedBlockNumber} (from tx ${txHash})`,
174
- );
175
- }
176
-
177
170
  const noteDao = new NoteDao(
178
171
  new Note(content),
179
172
  contractAddress,
@@ -184,17 +177,19 @@ export class NoteService {
184
177
  noteHash,
185
178
  siloedNullifier,
186
179
  txHash,
187
- uniqueNoteHashTreeIndexInBlock.l2BlockNumber,
188
- uniqueNoteHashTreeIndexInBlock.l2BlockHash.toString(),
189
- uniqueNoteHashTreeIndexInBlock.data,
180
+ txEffect.l2BlockNumber,
181
+ txEffect.l2BlockHash.toString(),
182
+ txEffect.txIndexInBlock,
183
+ noteIndexInTx,
190
184
  );
191
185
 
192
186
  // The note was found by `recipient`, so we use that as the scope when storing the note.
193
- await this.noteStore.addNotes([noteDao], recipient);
187
+ await this.noteStore.addNotes([noteDao], recipient, this.jobId);
194
188
 
195
189
  if (nullifierIndex !== undefined) {
190
+ // We found nullifier index which implies that the note has already been nullified.
196
191
  const { data: _, ...blockHashAndNum } = nullifierIndex;
197
- await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }]);
192
+ await this.noteStore.applyNullifiers([{ data: siloedNullifier, ...blockHashAndNum }], this.jobId);
198
193
  }
199
194
  }
200
195
  }
@@ -4,8 +4,9 @@
4
4
  ///
5
5
  /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 5;
7
+ export const ORACLE_VERSION = 11;
8
8
 
9
9
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
10
- /// which in turn implies that you need to update the ORACLE_VERSION constant.
11
- export const ORACLE_INTERFACE_HASH = 'd603c17a97034d978ca453d2bce3aacae139539dee28bbc46e8f8c7177a348ec';
10
+ /// which in turn implies that you need to update the ORACLE_VERSION constant in this file and in
11
+ /// `noir-projects/aztec-nr/aztec/src/oracle/version.nr`.
12
+ export const ORACLE_INTERFACE_HASH = '20c4d02d8cd5e448c11001a5f72ea2e0927630aeda75e537550872a9627bf40b';
@@ -1,2 +1,2 @@
1
- export * from './build_private_kernel_reset_private_inputs.js';
1
+ export * from './private_kernel_reset_private_inputs_builder.js';
2
2
  export * from './compute_tx_include_by_timestamp.js';
@@ -157,16 +157,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
157
157
  allowRemainder,
158
158
  );
159
159
 
160
- const previousVkMembershipWitness = await oracle.getVkMembershipWitness(
161
- this.previousKernelOutput.verificationKey.keyAsFields,
162
- );
163
- const vkData = new VkData(
164
- this.previousKernelOutput.verificationKey,
165
- Number(previousVkMembershipWitness.leafIndex),
166
- previousVkMembershipWitness.siblingPath,
167
- );
168
- const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
169
-
170
160
  this.reduceReadRequestActions(
171
161
  this.noteHashResetActions,
172
162
  dimensions.NOTE_HASH_PENDING_READ,
@@ -178,29 +168,51 @@ export class PrivateKernelResetPrivateInputsBuilder {
178
168
  dimensions.NULLIFIER_SETTLED_READ,
179
169
  );
180
170
 
181
- // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
182
- const paddedSideEffects = PaddedSideEffects.empty();
183
-
184
- return new PrivateKernelResetCircuitPrivateInputs(
185
- previousKernelData,
186
- paddedSideEffects,
187
- new PrivateKernelResetHints(
188
- await buildNoteHashReadRequestHintsFromResetActions(
171
+ // Execute all the expensive node querying operations in parallel.
172
+ const [previousVkMembershipWitness, noteHashReadRequestHints, nullifierReadRequestHints, keyValidationHints] =
173
+ await Promise.all([
174
+ oracle.getVkMembershipWitness(this.previousKernelOutput.verificationKey.keyAsFields),
175
+ buildNoteHashReadRequestHintsFromResetActions<
176
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
177
+ typeof MAX_NOTE_HASH_READ_REQUESTS_PER_TX
178
+ >(
189
179
  oracle,
190
180
  this.previousKernel.validationRequests.noteHashReadRequests,
191
181
  this.previousKernel.end.noteHashes,
192
182
  this.noteHashResetActions,
193
183
  ),
194
- await buildNullifierReadRequestHintsFromResetActions(
184
+ buildNullifierReadRequestHintsFromResetActions<
185
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX,
186
+ typeof MAX_NULLIFIER_READ_REQUESTS_PER_TX
187
+ >(
195
188
  { getNullifierMembershipWitness: getNullifierMembershipWitnessResolver(oracle) },
196
189
  this.previousKernel.validationRequests.nullifierReadRequests,
197
190
  this.nullifierResetActions,
198
191
  ),
199
- await getMasterSecretKeysAndAppKeyGenerators(
192
+ getMasterSecretKeysAndAppKeyGenerators(
200
193
  this.previousKernel.validationRequests.scopedKeyValidationRequestsAndGenerators,
201
194
  dimensions.KEY_VALIDATION,
202
195
  oracle,
203
196
  ),
197
+ ]);
198
+
199
+ const vkData = new VkData(
200
+ this.previousKernelOutput.verificationKey,
201
+ Number(previousVkMembershipWitness.leafIndex),
202
+ previousVkMembershipWitness.siblingPath,
203
+ );
204
+ const previousKernelData = new PrivateKernelData(this.previousKernelOutput.publicInputs, vkData);
205
+
206
+ // TODO: Enable padding when we have a better idea what are the final amounts we should pad to.
207
+ const paddedSideEffects = PaddedSideEffects.empty();
208
+
209
+ return new PrivateKernelResetCircuitPrivateInputs(
210
+ previousKernelData,
211
+ paddedSideEffects,
212
+ new PrivateKernelResetHints(
213
+ noteHashReadRequestHints,
214
+ nullifierReadRequestHints,
215
+ keyValidationHints,
204
216
  this.transientDataSquashingHints,
205
217
  ),
206
218
  dimensions,
@@ -1,6 +1,6 @@
1
1
  import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto/keys';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
- import { createLogger } from '@aztec/foundation/log';
3
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
4
4
  import { pushTestData } from '@aztec/foundation/testing';
5
5
  import { Timer } from '@aztec/foundation/timer';
6
6
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
@@ -33,7 +33,7 @@ import {
33
33
  } from '@aztec/stdlib/tx';
34
34
  import { VerificationKeyAsFields, VerificationKeyData, VkData } from '@aztec/stdlib/vks';
35
35
 
36
- import { PrivateKernelResetPrivateInputsBuilder } from './hints/build_private_kernel_reset_private_inputs.js';
36
+ import { PrivateKernelResetPrivateInputsBuilder } from './hints/private_kernel_reset_private_inputs_builder.js';
37
37
  import type { PrivateKernelOracle } from './private_kernel_oracle.js';
38
38
 
39
39
  const NULL_SIMULATE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
@@ -56,13 +56,16 @@ export interface PrivateKernelExecutionProverConfig {
56
56
  * inform state tree updates.
57
57
  */
58
58
  export class PrivateKernelExecutionProver {
59
- private log = createLogger('pxe:private-kernel-execution-prover');
59
+ private log: Logger;
60
60
 
61
61
  constructor(
62
62
  private oracle: PrivateKernelOracle,
63
63
  private proofCreator: PrivateKernelProver,
64
64
  private fakeProofs = false,
65
- ) {}
65
+ bindings?: LoggerBindings,
66
+ ) {
67
+ this.log = createLogger('pxe:private-kernel-execution-prover', bindings);
68
+ }
66
69
 
67
70
  /**
68
71
  * Generate a proof for a given transaction request and execution result.
@@ -1,73 +1,152 @@
1
- import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
1
+ import { FUNCTION_TREE_HEIGHT, NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
2
  import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
4
4
  import { MembershipWitness } from '@aztec/foundation/trees';
5
+ import type { KeyStore } from '@aztec/key-store';
6
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
7
+ import { ProtocolContractAddress } from '@aztec/protocol-contracts';
5
8
  import type { FunctionSelector } from '@aztec/stdlib/abi';
6
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
10
+ import { BlockHash } from '@aztec/stdlib/block';
11
+ import {
12
+ type ContractInstanceWithAddress,
13
+ computeContractClassIdPreimage,
14
+ computeSaltedInitializationHash,
15
+ } from '@aztec/stdlib/contract';
16
+ import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
17
+ import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
18
+ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
7
19
  import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
8
- import type { PublicKeys } from '@aztec/stdlib/keys';
9
20
  import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
10
21
  import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
11
22
 
23
+ import type { ContractStore } from '../storage/contract_store/contract_store.js';
24
+
12
25
  /**
13
26
  * Provides functionality needed by the private kernel for interacting with our state trees.
14
- * This is either PrivateKernelOracleImpl, or a mocked test implementation.
15
27
  */
16
- export interface PrivateKernelOracle {
28
+ export class PrivateKernelOracle {
29
+ constructor(
30
+ private contractStore: ContractStore,
31
+ private keyStore: KeyStore,
32
+ private node: AztecNode,
33
+ private blockHash: BlockHash,
34
+ ) {}
35
+
17
36
  /** Retrieves the preimage of a contract address from the registered contract instances db. */
18
- getContractAddressPreimage(address: AztecAddress): Promise<{
19
- saltedInitializationHash: Fr;
20
- publicKeys: PublicKeys;
21
- currentContractClassId: Fr;
22
- originalContractClassId: Fr;
23
- }>;
37
+ public async getContractAddressPreimage(
38
+ address: AztecAddress,
39
+ ): Promise<ContractInstanceWithAddress & { saltedInitializationHash: Fr }> {
40
+ const instance = await this.contractStore.getContractInstance(address);
41
+ if (!instance) {
42
+ throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
43
+ }
44
+ return {
45
+ saltedInitializationHash: await computeSaltedInitializationHash(instance),
46
+ ...instance,
47
+ };
48
+ }
24
49
 
25
50
  /** Retrieves the preimage of a contract class id from the contract classes db. */
26
- getContractClassIdPreimage(
27
- contractClassId: Fr,
28
- ): Promise<{ artifactHash: Fr; publicBytecodeCommitment: Fr; privateFunctionsRoot: Fr }>;
51
+ public async getContractClassIdPreimage(contractClassId: Fr) {
52
+ const contractClass = await this.contractStore.getContractClass(contractClassId);
53
+ if (!contractClass) {
54
+ throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
55
+ }
56
+ return computeContractClassIdPreimage(contractClass);
57
+ }
29
58
 
30
- /**
31
- * Returns a membership witness with the sibling path and leaf index in our private functions tree.
32
- */
33
- getFunctionMembershipWitness(
59
+ /** Returns a membership witness with the sibling path and leaf index in our private functions tree. */
60
+ public async getFunctionMembershipWitness(
34
61
  contractClassId: Fr,
35
62
  selector: FunctionSelector,
36
- ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>>;
63
+ ): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT>> {
64
+ const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
65
+ if (!membershipWitness) {
66
+ throw new Error(
67
+ `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
68
+ );
69
+ }
70
+ return membershipWitness;
71
+ }
37
72
 
38
73
  /**
39
74
  * Returns a membership witness with the sibling path and leaf index in our protocol VK indexed merkle tree.
40
75
  * Used to validate the previous kernel's verification key.
41
76
  */
42
- getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>>;
77
+ public getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<typeof VK_TREE_HEIGHT>> {
78
+ const leafIndex = getVKIndex(vk);
79
+ return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
80
+ }
43
81
 
44
- /**
45
- * Returns a membership witness with the sibling path and leaf index in our private function indexed merkle tree.
46
- */
47
- getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
82
+ /** Returns a membership witness with the sibling path and leaf index in our note hash tree. */
83
+ getNoteHashMembershipWitness(noteHash: Fr): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
84
+ return this.node.getNoteHashMembershipWitness(this.blockHash, noteHash);
85
+ }
48
86
 
49
- /**
50
- * Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree.
51
- */
52
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
53
- /**
54
- * Returns the root of our note hash merkle tree.
55
- */
56
- getNoteHashTreeRoot(): Promise<Fr>;
87
+ /** Returns a membership witness with the sibling path and leaf index in our nullifier indexed merkle tree. */
88
+ getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
89
+ return this.node.getNullifierMembershipWitness(this.blockHash, nullifier);
90
+ }
91
+
92
+ /** Returns the root of our note hash merkle tree. */
93
+ async getNoteHashTreeRoot(): Promise<Fr> {
94
+ const header = await this.node.getBlockHeader(this.blockHash);
95
+ if (!header) {
96
+ throw new Error(`No block header found for block hash ${this.blockHash}`);
97
+ }
98
+ return header.state.partial.noteHashTree.root;
99
+ }
57
100
 
58
101
  /**
59
102
  * Retrieves the sk_m corresponding to the pk_m.
60
103
  * @throws If the provided public key is not associated with any of the registered accounts.
61
- * @param pkM - The master public key to get secret key for.
104
+ * @param masterPublicKey - The master public key to get secret key for.
62
105
  * @returns A Promise that resolves to sk_m.
63
106
  * @dev Used when feeding the sk_m to the kernel circuit for keys verification.
64
107
  */
65
- getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
108
+ public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
109
+ return this.keyStore.getMasterSecretKey(masterPublicKey);
110
+ }
66
111
 
67
112
  /** Use debug data to get the function name corresponding to a selector. */
68
- getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined>;
113
+ public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string | undefined> {
114
+ return this.contractStore.getDebugFunctionName(contractAddress, selector);
115
+ }
116
+
117
+ /**
118
+ * Returns a membership witness and leaf index to our public data indexed merkle tree,
119
+ * along with an associated DelayedPublicMutable containing the class ID to update.
120
+ */
121
+ public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
122
+ const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
123
+ await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
124
+
125
+ const hashLeafSlot = await computePublicDataTreeLeafSlot(
126
+ ProtocolContractAddress.ContractInstanceRegistry,
127
+ delayedPublicMutableHashSlot,
128
+ );
129
+ const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockHash, hashLeafSlot);
130
+
131
+ if (!updatedClassIdWitness) {
132
+ throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
133
+ }
134
+
135
+ const readStorage = (storageSlot: Fr) =>
136
+ this.node.getPublicStorageAt(this.blockHash, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
137
+ const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
138
+ delayedPublicMutableSlot,
139
+ readStorage,
140
+ );
69
141
 
70
- /** Returns a membership witness and leaf index to our public data indexed merkle tree,
71
- * along with an associated DelayedPublicMutable containing the class ID to update. */
72
- getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
142
+ return new UpdatedClassIdHints(
143
+ new MembershipWitness(
144
+ PUBLIC_DATA_TREE_HEIGHT,
145
+ updatedClassIdWitness.index,
146
+ updatedClassIdWitness.siblingPath.toTuple(),
147
+ ),
148
+ updatedClassIdWitness.leafPreimage,
149
+ delayedPublicMutableValues,
150
+ );
151
+ }
73
152
  }