@aztec/pxe 3.0.0-devnet.6 → 3.0.0-devnet.6-patch.1

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 (193) hide show
  1. package/dest/bin/check_oracle_version.d.ts +1 -1
  2. package/dest/bin/check_oracle_version.js +105 -15
  3. package/dest/config/index.d.ts +2 -10
  4. package/dest/config/index.d.ts.map +1 -1
  5. package/dest/config/index.js +7 -13
  6. package/dest/config/package_info.d.ts +1 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts +6 -6
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  9. package/dest/contract_function_simulator/contract_function_simulator.js +15 -16
  10. package/dest/contract_function_simulator/execution_data_provider.d.ts +13 -19
  11. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  12. package/dest/contract_function_simulator/execution_note_cache.d.ts +9 -7
  13. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  14. package/dest/contract_function_simulator/execution_note_cache.js +21 -13
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  17. package/dest/contract_function_simulator/hashed_values_cache.d.ts +2 -2
  18. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.d.ts +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +2 -2
  21. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +2 -2
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +3 -3
  25. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +1 -1
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +6 -4
  28. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +12 -3
  30. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +2 -2
  31. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/noir-structs/utility_context.js +1 -1
  33. package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
  34. package/dest/contract_function_simulator/oracle/interfaces.d.ts +17 -10
  35. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +2 -4
  37. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.js +1 -1
  39. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +10 -4
  40. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  41. package/dest/contract_function_simulator/oracle/note_packing_utils.js +10 -5
  42. package/dest/contract_function_simulator/oracle/oracle.d.ts +5 -4
  43. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/oracle/oracle.js +31 -14
  45. package/dest/contract_function_simulator/oracle/private_execution.d.ts +4 -3
  46. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/oracle/private_execution.js +1 -1
  48. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -12
  49. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  50. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +20 -7
  51. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +13 -11
  52. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  53. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +5 -4
  54. package/dest/contract_function_simulator/pick_notes.d.ts +2 -2
  55. package/dest/contract_function_simulator/pick_notes.d.ts.map +1 -1
  56. package/dest/contract_function_simulator/pick_notes.js +1 -1
  57. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  58. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  59. package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
  60. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
  61. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +15 -13
  62. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  63. package/dest/contract_function_simulator/pxe_oracle_interface.js +50 -25
  64. package/dest/entrypoints/client/bundle/index.d.ts +1 -1
  65. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  66. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  67. package/dest/entrypoints/client/bundle/utils.js +13 -4
  68. package/dest/entrypoints/client/lazy/index.d.ts +1 -1
  69. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  70. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  71. package/dest/entrypoints/client/lazy/utils.js +13 -4
  72. package/dest/entrypoints/pxe_creation_options.d.ts +5 -2
  73. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  74. package/dest/entrypoints/server/index.d.ts +1 -1
  75. package/dest/entrypoints/server/utils.d.ts +1 -1
  76. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  77. package/dest/entrypoints/server/utils.js +13 -20
  78. package/dest/error_enriching.d.ts +1 -1
  79. package/dest/events/index.d.ts +2 -0
  80. package/dest/events/index.d.ts.map +1 -0
  81. package/dest/events/index.js +1 -0
  82. package/dest/events/private_event_filter_validator.d.ts +8 -0
  83. package/dest/events/private_event_filter_validator.d.ts.map +1 -0
  84. package/dest/events/private_event_filter_validator.js +39 -0
  85. package/dest/oracle_version.d.ts +3 -3
  86. package/dest/oracle_version.js +2 -2
  87. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
  88. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  89. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
  90. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  91. package/dest/private_kernel/hints/index.d.ts +1 -1
  92. package/dest/private_kernel/index.d.ts +1 -1
  93. package/dest/private_kernel/private_kernel_execution_prover.d.ts +4 -4
  94. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  95. package/dest/private_kernel/private_kernel_execution_prover.js +26 -25
  96. package/dest/private_kernel/private_kernel_oracle.d.ts +3 -2
  97. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  98. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +6 -5
  99. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  100. package/dest/pxe.d.ts +26 -19
  101. package/dest/pxe.d.ts.map +1 -1
  102. package/dest/pxe.js +35 -50
  103. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -1
  104. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  105. package/dest/storage/address_data_provider/index.d.ts +1 -1
  106. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +2 -2
  107. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  108. package/dest/storage/capsule_data_provider/capsule_data_provider.js +1 -1
  109. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  110. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -13
  111. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  112. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -12
  113. package/dest/storage/contract_data_provider/index.d.ts +1 -1
  114. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
  115. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  116. package/dest/storage/contract_data_provider/private_functions_tree.js +1 -1
  117. package/dest/storage/index.d.ts +1 -1
  118. package/dest/storage/metadata.d.ts +1 -1
  119. package/dest/storage/note_data_provider/index.d.ts +2 -2
  120. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  121. package/dest/storage/note_data_provider/index.js +1 -1
  122. package/dest/storage/note_data_provider/note_data_provider.d.ts +8 -7
  123. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  124. package/dest/storage/note_data_provider/note_data_provider.js +27 -13
  125. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +30 -14
  126. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
  127. package/dest/storage/private_event_data_provider/private_event_data_provider.js +47 -25
  128. package/dest/storage/sync_data_provider/index.d.ts +1 -1
  129. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +3 -2
  130. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  131. package/dest/storage/tagging_data_provider/index.d.ts +1 -1
  132. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +1 -1
  133. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  134. package/dest/synchronizer/index.d.ts +1 -1
  135. package/dest/synchronizer/synchronizer.d.ts +3 -2
  136. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  137. package/dest/synchronizer/synchronizer.js +2 -1
  138. package/dest/tagging/constants.d.ts +1 -1
  139. package/dest/tagging/index.d.ts +1 -1
  140. package/dest/tagging/siloed_tag.d.ts +2 -2
  141. package/dest/tagging/siloed_tag.d.ts.map +1 -1
  142. package/dest/tagging/siloed_tag.js +1 -1
  143. package/dest/tagging/tag.d.ts +2 -2
  144. package/dest/tagging/tag.d.ts.map +1 -1
  145. package/dest/tagging/tag.js +1 -1
  146. package/dest/tagging/utils.d.ts +1 -1
  147. package/package.json +20 -19
  148. package/src/bin/check_oracle_version.ts +130 -20
  149. package/src/config/index.ts +8 -23
  150. package/src/contract_function_simulator/contract_function_simulator.ts +23 -18
  151. package/src/contract_function_simulator/execution_data_provider.ts +18 -18
  152. package/src/contract_function_simulator/execution_note_cache.ts +22 -11
  153. package/src/contract_function_simulator/hashed_values_cache.ts +1 -1
  154. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +1 -1
  155. package/src/contract_function_simulator/noir-structs/log_retrieval_request.ts +1 -1
  156. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +2 -2
  157. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +14 -2
  158. package/src/contract_function_simulator/noir-structs/utility_context.ts +1 -1
  159. package/src/contract_function_simulator/oracle/interfaces.ts +24 -8
  160. package/src/contract_function_simulator/oracle/message_load_oracle_inputs.ts +1 -1
  161. package/src/contract_function_simulator/oracle/note_packing_utils.ts +21 -5
  162. package/src/contract_function_simulator/oracle/oracle.ts +40 -10
  163. package/src/contract_function_simulator/oracle/private_execution.ts +3 -2
  164. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +17 -4
  165. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +22 -9
  166. package/src/contract_function_simulator/pick_notes.ts +1 -1
  167. package/src/contract_function_simulator/pxe_oracle_interface.ts +98 -59
  168. package/src/entrypoints/client/bundle/utils.ts +10 -4
  169. package/src/entrypoints/client/lazy/utils.ts +10 -5
  170. package/src/entrypoints/pxe_creation_options.ts +4 -1
  171. package/src/entrypoints/server/utils.ts +13 -31
  172. package/src/events/index.ts +1 -0
  173. package/src/events/private_event_filter_validator.ts +47 -0
  174. package/src/oracle_version.ts +2 -2
  175. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +5 -9
  176. package/src/private_kernel/private_kernel_execution_prover.ts +27 -31
  177. package/src/private_kernel/private_kernel_oracle.ts +2 -1
  178. package/src/private_kernel/private_kernel_oracle_impl.ts +4 -3
  179. package/src/pxe.ts +50 -75
  180. package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -1
  181. package/src/storage/contract_data_provider/contract_data_provider.ts +1 -18
  182. package/src/storage/contract_data_provider/private_functions_tree.ts +1 -1
  183. package/src/storage/note_data_provider/index.ts +1 -1
  184. package/src/storage/note_data_provider/note_data_provider.ts +34 -15
  185. package/src/storage/private_event_data_provider/private_event_data_provider.ts +69 -35
  186. package/src/storage/sync_data_provider/sync_data_provider.ts +2 -1
  187. package/src/synchronizer/synchronizer.ts +2 -1
  188. package/src/tagging/siloed_tag.ts +2 -2
  189. package/src/tagging/tag.ts +2 -2
  190. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  191. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  192. package/dest/storage/note_data_provider/note_dao.js +0 -102
  193. package/src/storage/note_data_provider/note_dao.ts +0 -154
@@ -1,16 +1,35 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
3
  import { createLogger } from '@aztec/foundation/log';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
  import type { AztecAsyncArray, AztecAsyncKVStore, AztecAsyncMap } from '@aztec/kv-store';
5
6
  import type { EventSelector } from '@aztec/stdlib/abi';
6
7
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import type { TxHash } from '@aztec/stdlib/tx';
8
+ import { L2BlockHash } from '@aztec/stdlib/block';
9
+ import { type InTx, TxHash } from '@aztec/stdlib/tx';
8
10
 
9
- interface PrivateEventEntry {
11
+ import type { PackedPrivateEvent } from '../../pxe.js';
12
+
13
+ export type PrivateEventDataProviderFilter = {
14
+ contractAddress: AztecAddress;
15
+ fromBlock: number;
16
+ toBlock: number;
17
+ scopes: AztecAddress[];
18
+ txHash?: TxHash;
19
+ };
20
+
21
+ type PrivateEventEntry = {
10
22
  msgContent: Buffer;
11
- blockNumber: number;
12
23
  eventCommitmentIndex: number;
13
- }
24
+ l2BlockNumber: number;
25
+ l2BlockHash: Buffer;
26
+ txHash: Buffer;
27
+ };
28
+
29
+ type PrivateEventMetadata = InTx & {
30
+ contractAddress: AztecAddress;
31
+ scope: AztecAddress;
32
+ };
14
33
 
15
34
  /**
16
35
  * Stores decrypted private event logs.
@@ -19,7 +38,7 @@ export class PrivateEventDataProvider {
19
38
  #store: AztecAsyncKVStore;
20
39
  /** Array storing the actual private event log entries containing the log content and block number */
21
40
  #eventLogs: AztecAsyncArray<PrivateEventEntry>;
22
- /** Map from contract_address_recipient_eventSelector to array of indices into #eventLogs for efficient lookup */
41
+ /** Map from contract_address_scope_eventSelector to array of indices into #eventLogs for efficient lookup */
23
42
  #eventLogIndex: AztecAsyncMap<string, number[]>;
24
43
  /** Map from eventCommitmentIndex to boolean indicating if log has been seen. */
25
44
  #seenLogs: AztecAsyncMap<number, boolean>;
@@ -33,27 +52,31 @@ export class PrivateEventDataProvider {
33
52
  this.#seenLogs = this.#store.openMap('seen_logs');
34
53
  }
35
54
 
55
+ #keyFor(contractAddress: AztecAddress, scope: AztecAddress, eventSelector: EventSelector): string {
56
+ return `${contractAddress.toString()}_${scope.toString()}_${eventSelector.toString()}`;
57
+ }
58
+
36
59
  /**
37
60
  * Store a private event log.
38
- * @param contractAddress - The address of the contract that emitted the event.
39
- * @param recipient - The recipient of the event.
40
61
  * @param eventSelector - The event selector of the event.
41
62
  * @param msgContent - The content of the event.
42
- * @param txHash - The transaction hash of the event log.
43
63
  * @param eventCommitmentIndex - The index of the event commitment in the nullifier tree.
44
- * @param blockNumber - The block number in which the event was emitted.
64
+ * @param metadata
65
+ * contractAddress - The address of the contract that emitted the event.
66
+ * scope - The address to which the event is scoped.
67
+ * txHash - The transaction hash of the event log.
68
+ * blockNumber - The block number in which the event was emitted.
45
69
  */
46
70
  storePrivateEventLog(
47
- contractAddress: AztecAddress,
48
- recipient: AztecAddress,
49
71
  eventSelector: EventSelector,
50
72
  msgContent: Fr[],
51
- txHash: TxHash,
52
73
  eventCommitmentIndex: number,
53
- blockNumber: number,
74
+ metadata: PrivateEventMetadata,
54
75
  ): Promise<void> {
76
+ const { contractAddress, scope, txHash, l2BlockNumber, l2BlockHash } = metadata;
77
+
55
78
  return this.#store.transactionAsync(async () => {
56
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
79
+ const key = this.#keyFor(contractAddress, scope, eventSelector);
57
80
 
58
81
  // Check if this exact log has already been stored using eventCommitmentIndex as unique identifier
59
82
  const hasBeenSeen = await this.#seenLogs.getAsync(eventCommitmentIndex);
@@ -62,13 +85,15 @@ export class PrivateEventDataProvider {
62
85
  return;
63
86
  }
64
87
 
65
- this.logger.verbose('storing private event log', { contractAddress, recipient, msgContent, blockNumber });
88
+ this.logger.verbose('storing private event log', { contractAddress, scope, msgContent, l2BlockNumber });
66
89
 
67
90
  const index = await this.#eventLogs.lengthAsync();
68
91
  await this.#eventLogs.push({
69
92
  msgContent: serializeToBuffer(msgContent),
70
- blockNumber,
93
+ l2BlockNumber,
94
+ l2BlockHash: l2BlockHash.toBuffer(),
71
95
  eventCommitmentIndex,
96
+ txHash: txHash.toBuffer(),
72
97
  });
73
98
 
74
99
  const existingIndices = (await this.#eventLogIndex.getAsync(key)) || [];
@@ -81,29 +106,28 @@ export class PrivateEventDataProvider {
81
106
 
82
107
  /**
83
108
  * Returns the private events given search parameters.
84
- * @param contractAddress - The address of the contract to get events from.
85
- * @param from - The block number to search from.
86
- * @param numBlocks - The amount of blocks to search.
87
- * @param recipients - The addresses that decrypted the logs.
88
109
  * @param eventSelector - The event selector to filter by.
89
- * @returns - The event log contents.
110
+ * @param filter - Filtering criteria:
111
+ * contractAddress: The address of the contract to get events from.
112
+ * fromBlock: The block number to search from (inclusive).
113
+ * toBlock: The block number to search upto (exclusive).
114
+ * scope: - The addresses that decrypted the logs.
115
+ * @returns - The event log contents, augmented with metadata about
116
+ * the transaction and block it the event was included in .
90
117
  */
91
118
  public async getPrivateEvents(
92
- contractAddress: AztecAddress,
93
- from: number,
94
- numBlocks: number,
95
- recipients: AztecAddress[],
96
119
  eventSelector: EventSelector,
97
- ): Promise<Fr[][]> {
98
- const events: Array<{ msgContent: Fr[]; blockNumber: number; eventCommitmentIndex: number }> = [];
120
+ filter: PrivateEventDataProviderFilter,
121
+ ): Promise<PackedPrivateEvent[]> {
122
+ const events: Array<{ eventCommitmentIndex: number; event: PackedPrivateEvent }> = [];
99
123
 
100
- for (const recipient of recipients) {
101
- const key = `${contractAddress.toString()}_${recipient.toString()}_${eventSelector.toString()}`;
124
+ for (const scope of filter.scopes) {
125
+ const key = this.#keyFor(filter.contractAddress, scope, eventSelector);
102
126
  const indices = (await this.#eventLogIndex.getAsync(key)) || [];
103
127
 
104
128
  for (const index of indices) {
105
129
  const entry = await this.#eventLogs.atAsync(index);
106
- if (!entry || entry.blockNumber < from || entry.blockNumber >= from + numBlocks) {
130
+ if (!entry || entry.l2BlockNumber < filter.fromBlock || entry.l2BlockNumber >= filter.toBlock) {
107
131
  continue;
108
132
  }
109
133
 
@@ -111,18 +135,28 @@ export class PrivateEventDataProvider {
111
135
  const reader = BufferReader.asReader(entry.msgContent);
112
136
  const numFields = entry.msgContent.length / Fr.SIZE_IN_BYTES;
113
137
  const msgContent = reader.readArray(numFields, Fr);
138
+ const txHash = TxHash.fromBuffer(entry.txHash);
139
+ const l2BlockHash = L2BlockHash.fromBuffer(entry.l2BlockHash);
140
+
141
+ if (filter.txHash && !txHash.equals(filter.txHash)) {
142
+ continue;
143
+ }
114
144
 
115
145
  events.push({
116
- msgContent,
117
- blockNumber: entry.blockNumber,
118
146
  eventCommitmentIndex: entry.eventCommitmentIndex,
147
+ event: {
148
+ packedEvent: msgContent,
149
+ l2BlockNumber: BlockNumber(entry.l2BlockNumber),
150
+ txHash,
151
+ l2BlockHash,
152
+ eventSelector,
153
+ },
119
154
  });
120
155
  }
121
156
  }
122
157
 
123
158
  // Sort by eventCommitmentIndex only
124
159
  events.sort((a, b) => a.eventCommitmentIndex - b.eventCommitmentIndex);
125
-
126
- return events.map(e => e.msgContent);
160
+ return events.map(ev => ev.event);
127
161
  }
128
162
  }
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import type { AztecAsyncKVStore, AztecAsyncSingleton } from '@aztec/kv-store';
2
3
  import { BlockHeader } from '@aztec/stdlib/tx';
3
4
 
@@ -14,7 +15,7 @@ export class SyncDataProvider {
14
15
  await this.#synchronizedHeader.set(header.toBuffer());
15
16
  }
16
17
 
17
- async getBlockNumber(): Promise<number> {
18
+ async getBlockNumber(): Promise<BlockNumber> {
18
19
  const headerBuffer = await this.#synchronizedHeader.getAsync();
19
20
  if (!headerBuffer) {
20
21
  throw new Error(`Trying to get block number with a not-yet-synchronized PXE - this should never happen`);
@@ -1,3 +1,4 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { type Logger, createLogger } from '@aztec/foundation/log';
2
3
  import type { L2TipsKVStore } from '@aztec/kv-store/stores';
3
4
  import { L2BlockStream, type L2BlockStreamEvent, type L2BlockStreamEventHandler } from '@aztec/stdlib/block';
@@ -109,7 +110,7 @@ export class Synchronizer implements L2BlockStreamEventHandler {
109
110
  }
110
111
  if (!currentHeader) {
111
112
  // REFACTOR: We should know the header of the genesis block without having to request it from the node.
112
- await this.syncDataProvider.setHeader((await this.node.getBlockHeader(0))!);
113
+ await this.syncDataProvider.setHeader((await this.node.getBlockHeader(BlockNumber.ZERO))!);
113
114
  }
114
115
  await this.blockStream.sync();
115
116
  }
@@ -1,5 +1,5 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto';
2
- import type { Fr } from '@aztec/foundation/fields';
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
 
5
5
  import type { Tag } from './tag.js';
@@ -1,5 +1,5 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto';
2
- import type { Fr } from '@aztec/foundation/fields';
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { PreTag } from '@aztec/stdlib/logs';
4
4
 
5
5
  /**
@@ -1,100 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { Note } from '@aztec/stdlib/note';
5
- import { TxHash } from '@aztec/stdlib/tx';
6
- import type { NoteData } from '../../contract_function_simulator/oracle/interfaces.js';
7
- /**
8
- * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
9
- * information required to use it during execution and manage its state.
10
- */
11
- export declare class NoteDao implements NoteData {
12
- /** The packed content of the note, as will be returned in the getNotes oracle. */
13
- note: Note;
14
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
15
- contractAddress: AztecAddress;
16
- /**
17
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
18
- * since contracts typically make queries based on it.
19
- */
20
- storageSlot: Fr;
21
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
22
- noteNonce: Fr;
23
- /**
24
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
25
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
26
- */
27
- noteHash: Fr;
28
- /**
29
- * The nullifier of the note, siloed by contract address.
30
- * Note: Might be set as 0 if the note was added to PXE as nullified.
31
- */
32
- siloedNullifier: Fr;
33
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
34
- * when searching for txEffects.
35
- */
36
- txHash: TxHash;
37
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
38
- * reorgs.*/
39
- l2BlockNumber: number;
40
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
41
- * reorgs.*/
42
- l2BlockHash: string;
43
- /** The index of the leaf in the global note hash tree the note is stored at */
44
- index: bigint;
45
- /**
46
- * The address whose public key was used to encrypt the note log during delivery.
47
- * (This is the x-coordinate of the public key.)
48
- */
49
- recipient: AztecAddress;
50
- constructor(
51
- /** The packed content of the note, as will be returned in the getNotes oracle. */
52
- note: Note,
53
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
54
- contractAddress: AztecAddress,
55
- /**
56
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
57
- * since contracts typically make queries based on it.
58
- */
59
- storageSlot: Fr,
60
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
61
- noteNonce: Fr,
62
- /**
63
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
64
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
65
- */
66
- noteHash: Fr,
67
- /**
68
- * The nullifier of the note, siloed by contract address.
69
- * Note: Might be set as 0 if the note was added to PXE as nullified.
70
- */
71
- siloedNullifier: Fr,
72
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
73
- * when searching for txEffects.
74
- */
75
- txHash: TxHash,
76
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
77
- * reorgs.*/
78
- l2BlockNumber: number,
79
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
80
- * reorgs.*/
81
- l2BlockHash: string,
82
- /** The index of the leaf in the global note hash tree the note is stored at */
83
- index: bigint,
84
- /**
85
- * The address whose public key was used to encrypt the note log during delivery.
86
- * (This is the x-coordinate of the public key.)
87
- */
88
- recipient: AztecAddress);
89
- toBuffer(): Buffer;
90
- static fromBuffer(buffer: Buffer | BufferReader): NoteDao;
91
- toString(): string;
92
- static fromString(str: string): NoteDao;
93
- /**
94
- * Returns the size in bytes of the Note Dao.
95
- * @returns - Its size in bytes.
96
- */
97
- getSize(): number;
98
- static random({ note, contractAddress, storageSlot, noteNonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient, }?: Partial<NoteDao>): Promise<NoteDao>;
99
- }
100
- //# sourceMappingURL=note_dao.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"note_dao.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_dao.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAS,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wDAAwD,CAAC;AAEvF;;;GAGG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IAIpC,kFAAkF;IAC3E,IAAI,EAAE,IAAI;IACjB,8GAA8G;IACvG,eAAe,EAAE,YAAY;IACpC;;;OAGG;IACI,WAAW,EAAE,EAAE;IACtB,gGAAgG;IACzF,SAAS,EAAE,EAAE;IAGpB;;;OAGG;IACI,QAAQ,EAAE,EAAE;IACnB;;;OAGG;IACI,eAAe,EAAE,EAAE;IAG1B;;OAEG;IACI,MAAM,EAAE,MAAM;IACrB;gBACY;IACL,aAAa,EAAE,MAAM;IAC5B;gBACY;IACL,WAAW,EAAE,MAAM;IAC1B,+EAA+E;IACxE,KAAK,EAAE,MAAM;IACpB;;;OAGG;IACI,SAAS,EAAE,YAAY;;IAzC9B,kFAAkF;IAC3E,IAAI,EAAE,IAAI;IACjB,8GAA8G;IACvG,eAAe,EAAE,YAAY;IACpC;;;OAGG;IACI,WAAW,EAAE,EAAE;IACtB,gGAAgG;IACzF,SAAS,EAAE,EAAE;IAGpB;;;OAGG;IACI,QAAQ,EAAE,EAAE;IACnB;;;OAGG;IACI,eAAe,EAAE,EAAE;IAG1B;;OAEG;IACI,MAAM,EAAE,MAAM;IACrB;gBACY;IACL,aAAa,EAAE,MAAM;IAC5B;gBACY;IACL,WAAW,EAAE,MAAM;IAC1B,+EAA+E;IACxE,KAAK,EAAE,MAAM;IACpB;;;OAGG;IACI,SAAS,EAAE,YAAY;IAGhC,QAAQ,IAAI,MAAM;IAgBlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IA8B/C,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM;IAK7B;;;OAGG;IACI,OAAO;WAMD,MAAM,CAAC,EAClB,IAAoB,EACpB,eAA2B,EAC3B,WAAyB,EACzB,SAAuB,EACvB,QAAsB,EACtB,eAA6B,EAC7B,MAAwB,EACxB,aAAgD,EAChD,WAAoC,EACpC,KAA8B,EAC9B,SAAqB,GACtB,GAAE,OAAO,CAAC,OAAO,CAAM;CAezB"}
@@ -1,102 +0,0 @@
1
- import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
- import { Fr, Point } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { Note } from '@aztec/stdlib/note';
6
- import { TxHash } from '@aztec/stdlib/tx';
7
- /**
8
- * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
9
- * information required to use it during execution and manage its state.
10
- */ export class NoteDao {
11
- note;
12
- contractAddress;
13
- storageSlot;
14
- noteNonce;
15
- noteHash;
16
- siloedNullifier;
17
- txHash;
18
- l2BlockNumber;
19
- l2BlockHash;
20
- index;
21
- recipient;
22
- constructor(// Note information
23
- /** The packed content of the note, as will be returned in the getNotes oracle. */ note, /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */ contractAddress, /**
24
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
25
- * since contracts typically make queries based on it.
26
- */ storageSlot, /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */ noteNonce, // Computed values
27
- /**
28
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
29
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
30
- */ noteHash, /**
31
- * The nullifier of the note, siloed by contract address.
32
- * Note: Might be set as 0 if the note was added to PXE as nullified.
33
- */ siloedNullifier, // Metadata
34
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
35
- * when searching for txEffects.
36
- */ txHash, /** The L2 block number in which the tx with this note was included. Used for note management while processing
37
- * reorgs.*/ l2BlockNumber, /** The L2 block hash in which the tx with this note was included. Used for note management while processing
38
- * reorgs.*/ l2BlockHash, /** The index of the leaf in the global note hash tree the note is stored at */ index, /**
39
- * The address whose public key was used to encrypt the note log during delivery.
40
- * (This is the x-coordinate of the public key.)
41
- */ recipient){
42
- this.note = note;
43
- this.contractAddress = contractAddress;
44
- this.storageSlot = storageSlot;
45
- this.noteNonce = noteNonce;
46
- this.noteHash = noteHash;
47
- this.siloedNullifier = siloedNullifier;
48
- this.txHash = txHash;
49
- this.l2BlockNumber = l2BlockNumber;
50
- this.l2BlockHash = l2BlockHash;
51
- this.index = index;
52
- this.recipient = recipient;
53
- }
54
- toBuffer() {
55
- return serializeToBuffer([
56
- this.note,
57
- this.contractAddress,
58
- this.storageSlot,
59
- this.noteNonce,
60
- this.noteHash,
61
- this.siloedNullifier,
62
- this.txHash,
63
- this.l2BlockNumber,
64
- Fr.fromHexString(this.l2BlockHash),
65
- this.index,
66
- this.recipient
67
- ]);
68
- }
69
- static fromBuffer(buffer) {
70
- const reader = BufferReader.asReader(buffer);
71
- const note = Note.fromBuffer(reader);
72
- const contractAddress = AztecAddress.fromBuffer(reader);
73
- const storageSlot = Fr.fromBuffer(reader);
74
- const noteNonce = Fr.fromBuffer(reader);
75
- const noteHash = Fr.fromBuffer(reader);
76
- const siloedNullifier = Fr.fromBuffer(reader);
77
- const txHash = reader.readObject(TxHash);
78
- const l2BlockNumber = reader.readNumber();
79
- const l2BlockHash = Fr.fromBuffer(reader).toString();
80
- const index = toBigIntBE(reader.readBytes(32));
81
- const recipient = AztecAddress.fromBuffer(reader);
82
- return new NoteDao(note, contractAddress, storageSlot, noteNonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient);
83
- }
84
- toString() {
85
- return '0x' + this.toBuffer().toString('hex');
86
- }
87
- static fromString(str) {
88
- const hex = str.replace(/^0x/, '');
89
- return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
90
- }
91
- /**
92
- * Returns the size in bytes of the Note Dao.
93
- * @returns - Its size in bytes.
94
- */ getSize() {
95
- const indexSize = Math.ceil(Math.log2(Number(this.index)));
96
- const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
97
- return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
98
- }
99
- static async random({ note = Note.random(), contractAddress = undefined, storageSlot = Fr.random(), noteNonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(), recipient = undefined } = {}) {
100
- return new NoteDao(note, contractAddress ?? await AztecAddress.random(), storageSlot, noteNonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient ?? await AztecAddress.random());
101
- }
102
- }
@@ -1,154 +0,0 @@
1
- import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
- import { Fr, Point } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { Note } from '@aztec/stdlib/note';
6
- import { TxHash } from '@aztec/stdlib/tx';
7
-
8
- import type { NoteData } from '../../contract_function_simulator/oracle/interfaces.js';
9
-
10
- /**
11
- * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
12
- * information required to use it during execution and manage its state.
13
- */
14
- export class NoteDao implements NoteData {
15
- constructor(
16
- // Note information
17
-
18
- /** The packed content of the note, as will be returned in the getNotes oracle. */
19
- public note: Note,
20
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
21
- public contractAddress: AztecAddress,
22
- /**
23
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
24
- * since contracts typically make queries based on it.
25
- */
26
- public storageSlot: Fr,
27
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
28
- public noteNonce: Fr,
29
-
30
- // Computed values
31
- /**
32
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
33
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
34
- */
35
- public noteHash: Fr,
36
- /**
37
- * The nullifier of the note, siloed by contract address.
38
- * Note: Might be set as 0 if the note was added to PXE as nullified.
39
- */
40
- public siloedNullifier: Fr,
41
-
42
- // Metadata
43
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
44
- * when searching for txEffects.
45
- */
46
- public txHash: TxHash,
47
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
48
- * reorgs.*/
49
- public l2BlockNumber: number,
50
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
51
- * reorgs.*/
52
- public l2BlockHash: string,
53
- /** The index of the leaf in the global note hash tree the note is stored at */
54
- public index: bigint,
55
- /**
56
- * The address whose public key was used to encrypt the note log during delivery.
57
- * (This is the x-coordinate of the public key.)
58
- */
59
- public recipient: AztecAddress,
60
- ) {}
61
-
62
- toBuffer(): Buffer {
63
- return serializeToBuffer([
64
- this.note,
65
- this.contractAddress,
66
- this.storageSlot,
67
- this.noteNonce,
68
- this.noteHash,
69
- this.siloedNullifier,
70
- this.txHash,
71
- this.l2BlockNumber,
72
- Fr.fromHexString(this.l2BlockHash),
73
- this.index,
74
- this.recipient,
75
- ]);
76
- }
77
-
78
- static fromBuffer(buffer: Buffer | BufferReader) {
79
- const reader = BufferReader.asReader(buffer);
80
-
81
- const note = Note.fromBuffer(reader);
82
- const contractAddress = AztecAddress.fromBuffer(reader);
83
- const storageSlot = Fr.fromBuffer(reader);
84
- const noteNonce = Fr.fromBuffer(reader);
85
- const noteHash = Fr.fromBuffer(reader);
86
- const siloedNullifier = Fr.fromBuffer(reader);
87
- const txHash = reader.readObject(TxHash);
88
- const l2BlockNumber = reader.readNumber();
89
- const l2BlockHash = Fr.fromBuffer(reader).toString();
90
- const index = toBigIntBE(reader.readBytes(32));
91
- const recipient = AztecAddress.fromBuffer(reader);
92
-
93
- return new NoteDao(
94
- note,
95
- contractAddress,
96
- storageSlot,
97
- noteNonce,
98
- noteHash,
99
- siloedNullifier,
100
- txHash,
101
- l2BlockNumber,
102
- l2BlockHash,
103
- index,
104
- recipient,
105
- );
106
- }
107
-
108
- toString() {
109
- return '0x' + this.toBuffer().toString('hex');
110
- }
111
-
112
- static fromString(str: string) {
113
- const hex = str.replace(/^0x/, '');
114
- return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
115
- }
116
-
117
- /**
118
- * Returns the size in bytes of the Note Dao.
119
- * @returns - Its size in bytes.
120
- */
121
- public getSize() {
122
- const indexSize = Math.ceil(Math.log2(Number(this.index)));
123
- const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
124
- return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
125
- }
126
-
127
- static async random({
128
- note = Note.random(),
129
- contractAddress = undefined,
130
- storageSlot = Fr.random(),
131
- noteNonce = Fr.random(),
132
- noteHash = Fr.random(),
133
- siloedNullifier = Fr.random(),
134
- txHash = TxHash.random(),
135
- l2BlockNumber = Math.floor(Math.random() * 1000),
136
- l2BlockHash = Fr.random().toString(),
137
- index = Fr.random().toBigInt(),
138
- recipient = undefined,
139
- }: Partial<NoteDao> = {}) {
140
- return new NoteDao(
141
- note,
142
- contractAddress ?? (await AztecAddress.random()),
143
- storageSlot,
144
- noteNonce,
145
- noteHash,
146
- siloedNullifier,
147
- txHash,
148
- l2BlockNumber,
149
- l2BlockHash,
150
- index,
151
- recipient ?? (await AztecAddress.random()),
152
- );
153
- }
154
- }