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

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 (194) hide show
  1. package/README.md +5 -5
  2. package/dest/bin/check_oracle_version.js +18 -8
  3. package/dest/config/index.d.ts +8 -8
  4. package/dest/config/index.d.ts.map +1 -1
  5. package/dest/config/index.js +3 -3
  6. package/dest/config/package_info.js +1 -1
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +82 -26
  9. package/dest/contract_function_simulator/execution_data_provider.d.ts +27 -38
  10. package/dest/contract_function_simulator/execution_data_provider.d.ts.map +1 -1
  11. package/dest/contract_function_simulator/execution_note_cache.d.ts +2 -2
  12. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/execution_note_cache.js +7 -4
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +16 -0
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -0
  16. package/dest/contract_function_simulator/execution_tagging_index_cache.js +26 -0
  17. package/dest/contract_function_simulator/index.d.ts +3 -1
  18. package/dest/contract_function_simulator/index.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/index.js +2 -1
  20. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.js +7 -3
  22. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +1 -0
  23. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +1 -1
  25. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +22 -0
  26. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -0
  27. package/dest/contract_function_simulator/noir-structs/utility_context.js +33 -0
  28. package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
  29. package/dest/contract_function_simulator/oracle/index.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/index.js +1 -1
  31. package/dest/contract_function_simulator/oracle/interfaces.d.ts +97 -0
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -0
  33. package/dest/contract_function_simulator/oracle/interfaces.js +4 -0
  34. package/dest/contract_function_simulator/oracle/oracle.d.ts +12 -11
  35. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  36. package/dest/contract_function_simulator/oracle/oracle.js +79 -76
  37. package/dest/contract_function_simulator/oracle/private_execution.d.ts +2 -2
  38. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  39. package/dest/contract_function_simulator/oracle/private_execution.js +6 -15
  40. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +26 -10
  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 +69 -18
  43. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +10 -22
  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 +33 -38
  46. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +19 -55
  47. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  48. package/dest/contract_function_simulator/pxe_oracle_interface.js +174 -187
  49. package/dest/entrypoints/client/bundle/index.d.ts +3 -1
  50. package/dest/entrypoints/client/bundle/index.d.ts.map +1 -1
  51. package/dest/entrypoints/client/bundle/index.js +2 -1
  52. package/dest/entrypoints/client/bundle/utils.d.ts +8 -8
  53. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  54. package/dest/entrypoints/client/bundle/utils.js +8 -8
  55. package/dest/entrypoints/client/lazy/index.d.ts +3 -1
  56. package/dest/entrypoints/client/lazy/index.d.ts.map +1 -1
  57. package/dest/entrypoints/client/lazy/index.js +2 -1
  58. package/dest/entrypoints/client/lazy/utils.d.ts +7 -7
  59. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  60. package/dest/entrypoints/client/lazy/utils.js +7 -7
  61. package/dest/entrypoints/server/index.d.ts +3 -1
  62. package/dest/entrypoints/server/index.d.ts.map +1 -1
  63. package/dest/entrypoints/server/index.js +2 -1
  64. package/dest/entrypoints/server/utils.d.ts +4 -23
  65. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  66. package/dest/entrypoints/server/utils.js +4 -25
  67. package/dest/{pxe_service/error_enriching.d.ts → error_enriching.d.ts} +1 -1
  68. package/dest/error_enriching.d.ts.map +1 -0
  69. package/dest/{pxe_service/error_enriching.js → error_enriching.js} +3 -0
  70. package/dest/oracle_version.d.ts +2 -2
  71. package/dest/oracle_version.js +2 -2
  72. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.js +6 -6
  73. package/dest/private_kernel/private_kernel_execution_prover.d.ts +7 -0
  74. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  75. package/dest/private_kernel/private_kernel_execution_prover.js +23 -18
  76. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
  77. package/dest/pxe.d.ts +233 -0
  78. package/dest/pxe.d.ts.map +1 -0
  79. package/dest/{pxe_service/pxe_service.js → pxe.js} +215 -214
  80. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -3
  81. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  82. package/dest/storage/address_data_provider/address_data_provider.js +0 -3
  83. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +1 -3
  84. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  85. package/dest/storage/capsule_data_provider/capsule_data_provider.js +0 -4
  86. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +3 -4
  87. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  88. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -3
  89. package/dest/storage/index.d.ts +0 -1
  90. package/dest/storage/index.d.ts.map +1 -1
  91. package/dest/storage/index.js +0 -1
  92. package/dest/storage/note_data_provider/note_dao.d.ts +1 -1
  93. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  94. package/dest/storage/note_data_provider/note_data_provider.d.ts +70 -7
  95. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  96. package/dest/storage/note_data_provider/note_data_provider.js +120 -72
  97. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +1 -3
  98. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
  99. package/dest/storage/private_event_data_provider/private_event_data_provider.js +0 -3
  100. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -3
  101. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  102. package/dest/storage/sync_data_provider/sync_data_provider.js +0 -3
  103. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +28 -6
  104. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  105. package/dest/storage/tagging_data_provider/tagging_data_provider.js +46 -39
  106. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  107. package/dest/synchronizer/synchronizer.js +2 -3
  108. package/dest/tagging/constants.d.ts +2 -0
  109. package/dest/tagging/constants.d.ts.map +1 -0
  110. package/dest/tagging/constants.js +2 -0
  111. package/dest/tagging/index.d.ts +7 -0
  112. package/dest/tagging/index.d.ts.map +1 -0
  113. package/dest/tagging/index.js +5 -0
  114. package/dest/tagging/siloed_tag.d.ts +14 -0
  115. package/dest/tagging/siloed_tag.d.ts.map +1 -0
  116. package/dest/tagging/siloed_tag.js +20 -0
  117. package/dest/tagging/tag.d.ts +12 -0
  118. package/dest/tagging/tag.d.ts.map +1 -0
  119. package/dest/tagging/tag.js +17 -0
  120. package/dest/tagging/utils.d.ts +18 -0
  121. package/dest/tagging/utils.d.ts.map +1 -0
  122. package/dest/tagging/utils.js +24 -0
  123. package/package.json +19 -22
  124. package/src/bin/check_oracle_version.ts +23 -9
  125. package/src/config/index.ts +11 -10
  126. package/src/config/package_info.ts +1 -1
  127. package/src/contract_function_simulator/contract_function_simulator.ts +128 -44
  128. package/src/contract_function_simulator/execution_data_provider.ts +29 -47
  129. package/src/contract_function_simulator/execution_note_cache.ts +11 -6
  130. package/src/contract_function_simulator/execution_tagging_index_cache.ts +32 -0
  131. package/src/contract_function_simulator/index.ts +3 -1
  132. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +8 -3
  133. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +1 -1
  134. package/src/contract_function_simulator/noir-structs/utility_context.ts +42 -0
  135. package/src/contract_function_simulator/oracle/index.ts +1 -1
  136. package/src/contract_function_simulator/oracle/interfaces.ts +160 -0
  137. package/src/contract_function_simulator/oracle/oracle.ts +102 -77
  138. package/src/contract_function_simulator/oracle/private_execution.ts +7 -15
  139. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +106 -45
  140. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +51 -76
  141. package/src/contract_function_simulator/pxe_oracle_interface.ts +199 -218
  142. package/src/entrypoints/client/bundle/index.ts +3 -1
  143. package/src/entrypoints/client/bundle/utils.ts +11 -19
  144. package/src/entrypoints/client/lazy/index.ts +3 -1
  145. package/src/entrypoints/client/lazy/utils.ts +10 -18
  146. package/src/entrypoints/server/index.ts +3 -1
  147. package/src/entrypoints/server/utils.ts +9 -39
  148. package/src/{pxe_service/error_enriching.ts → error_enriching.ts} +5 -1
  149. package/src/oracle_version.ts +2 -2
  150. package/src/private_kernel/hints/compute_tx_include_by_timestamp.ts +6 -6
  151. package/src/private_kernel/private_kernel_execution_prover.ts +35 -23
  152. package/src/{pxe_service/pxe_service.ts → pxe.ts} +230 -257
  153. package/src/storage/address_data_provider/address_data_provider.ts +1 -7
  154. package/src/storage/capsule_data_provider/capsule_data_provider.ts +1 -11
  155. package/src/storage/contract_data_provider/contract_data_provider.ts +3 -9
  156. package/src/storage/index.ts +0 -1
  157. package/src/storage/note_data_provider/note_dao.ts +1 -1
  158. package/src/storage/note_data_provider/note_data_provider.ts +142 -99
  159. package/src/storage/private_event_data_provider/private_event_data_provider.ts +1 -7
  160. package/src/storage/sync_data_provider/sync_data_provider.ts +1 -7
  161. package/src/storage/tagging_data_provider/tagging_data_provider.ts +52 -55
  162. package/src/synchronizer/synchronizer.ts +2 -3
  163. package/src/tagging/constants.ts +2 -0
  164. package/src/tagging/index.ts +6 -0
  165. package/src/tagging/siloed_tag.ts +22 -0
  166. package/src/tagging/tag.ts +16 -0
  167. package/src/tagging/utils.ts +31 -0
  168. package/dest/bin/index.d.ts +0 -3
  169. package/dest/bin/index.d.ts.map +0 -1
  170. package/dest/bin/index.js +0 -48
  171. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts +0 -87
  172. package/dest/contract_function_simulator/oracle/typed_oracle.d.ts.map +0 -1
  173. package/dest/contract_function_simulator/oracle/typed_oracle.js +0 -146
  174. package/dest/contract_function_simulator/tagging_utils.d.ts +0 -17
  175. package/dest/contract_function_simulator/tagging_utils.d.ts.map +0 -1
  176. package/dest/contract_function_simulator/tagging_utils.js +0 -23
  177. package/dest/pxe_service/error_enriching.d.ts.map +0 -1
  178. package/dest/pxe_service/index.d.ts +0 -3
  179. package/dest/pxe_service/index.d.ts.map +0 -1
  180. package/dest/pxe_service/index.js +0 -2
  181. package/dest/pxe_service/pxe_service.d.ts +0 -100
  182. package/dest/pxe_service/pxe_service.d.ts.map +0 -1
  183. package/dest/storage/data_provider.d.ts +0 -4
  184. package/dest/storage/data_provider.d.ts.map +0 -1
  185. package/dest/storage/data_provider.js +0 -1
  186. package/dest/test/pxe_test_suite.d.ts +0 -3
  187. package/dest/test/pxe_test_suite.d.ts.map +0 -1
  188. package/dest/test/pxe_test_suite.js +0 -97
  189. package/src/bin/index.ts +0 -62
  190. package/src/contract_function_simulator/oracle/typed_oracle.ts +0 -289
  191. package/src/contract_function_simulator/tagging_utils.ts +0 -32
  192. package/src/pxe_service/index.ts +0 -2
  193. package/src/storage/data_provider.ts +0 -3
  194. package/src/test/pxe_test_suite.ts +0 -113
@@ -1 +1 @@
1
- {"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,mBAAoB,YAAW,YAAY;;gBAK1C,KAAK,EAAE,iBAAiB;IAOpC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCtE,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIzE,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;IAMlD,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAGjC"}
1
+ {"version":3,"file":"address_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/address_data_provider/address_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,qBAAa,mBAAmB;;gBAKlB,KAAK,EAAE,iBAAiB;IAOpC,kBAAkB,CAAC,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IAsCtE,kBAAkB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,GAAG,SAAS,CAAC;IAIzE,oBAAoB,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;CAKzD"}
@@ -44,7 +44,4 @@ export class AddressDataProvider {
44
44
  async getCompleteAddresses() {
45
45
  return await Promise.all((await toArray(this.#completeAddresses.valuesAsync())).map((v)=>CompleteAddress.fromBuffer(v)));
46
46
  }
47
- async getSize() {
48
- return await this.#completeAddresses.lengthAsync() * CompleteAddress.SIZE_IN_BYTES;
49
- }
50
47
  }
@@ -2,8 +2,7 @@ import { Fr } from '@aztec/foundation/fields';
2
2
  import { type Logger } from '@aztec/foundation/log';
3
3
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { DataProvider } from '../data_provider.js';
6
- export declare class CapsuleDataProvider implements DataProvider {
5
+ export declare class CapsuleDataProvider {
7
6
  #private;
8
7
  logger: Logger;
9
8
  constructor(store: AztecAsyncKVStore);
@@ -22,6 +21,5 @@ export declare class CapsuleDataProvider implements DataProvider {
22
21
  appendToCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
23
22
  readCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr): Promise<Fr[][]>;
24
23
  setCapsuleArray(contractAddress: AztecAddress, baseSlot: Fr, content: Fr[][]): Promise<void>;
25
- getSize(): Promise<number>;
26
24
  }
27
25
  //# sourceMappingURL=capsule_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capsule_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/capsule_data_provider/capsule_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,YAAY,EA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ACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,qBAAa,mBAAmB;;IAM9B,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,iBAAiB;IAQ9B,YAAY,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInF,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC;IAa1E,aAAa,CAAC,eAAe,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAI3E,WAAW,CAAC,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BvG;;;;;;;OAOG;IACH,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAkBjG,gBAAgB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;IAwB9E,eAAe,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE;CAoB7E"}
@@ -1,5 +1,4 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
- import { toArray } from '@aztec/foundation/iterable';
3
2
  import { createLogger } from '@aztec/foundation/log';
4
3
  export class CapsuleDataProvider {
5
4
  #store;
@@ -110,9 +109,6 @@ export class CapsuleDataProvider {
110
109
  }
111
110
  });
112
111
  }
113
- async getSize() {
114
- return (await toArray(this.#capsules.valuesAsync())).reduce((sum, value)=>sum + value.length * Fr.SIZE_IN_BYTES, 0);
115
- }
116
112
  }
117
113
  function dbSlotToKey(contractAddress, slot) {
118
114
  return `${contractAddress.toString()}:${slot.toString()}`;
@@ -1,10 +1,10 @@
1
+ import type { FUNCTION_TREE_HEIGHT } from '@aztec/constants';
1
2
  import type { Fr } from '@aztec/foundation/fields';
2
3
  import type { MembershipWitness } from '@aztec/foundation/trees';
3
4
  import type { AztecAsyncKVStore } from '@aztec/kv-store';
4
5
  import { type ContractArtifact, type FunctionAbi, type FunctionArtifact, type FunctionArtifactWithContractName, type FunctionDebugMetadata, FunctionSelector } from '@aztec/stdlib/abi';
5
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
7
  import { type ContractClass, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
7
- import type { DataProvider } from '../data_provider.js';
8
8
  /**
9
9
  * ContractDataProvider serves as a data manager and retriever for Aztec.nr contracts.
10
10
  * It provides methods to obtain contract addresses, function ABI, bytecode, and membership witnesses
@@ -12,7 +12,7 @@ import type { DataProvider } from '../data_provider.js';
12
12
  * to efficiently serve the requested data. It interacts with the ContractDatabase and AztecNode to fetch
13
13
  * the required information and facilitate cryptographic proof generation.
14
14
  */
15
- export declare class ContractDataProvider implements DataProvider {
15
+ export declare class ContractDataProvider {
16
16
  #private;
17
17
  constructor(store: AztecAsyncKVStore);
18
18
  addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void>;
@@ -67,9 +67,8 @@ export declare class ContractDataProvider implements DataProvider {
67
67
  * @param selector - The function selector.
68
68
  * @returns A promise that resolves with the MembershipWitness instance for the specified contract's function.
69
69
  */
70
- getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<5> | undefined>;
70
+ getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<typeof FUNCTION_TREE_HEIGHT> | undefined>;
71
71
  getDebugContractName(contractAddress: AztecAddress): Promise<string | undefined>;
72
72
  getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
73
- getSize(): Promise<number>;
74
73
  }
75
74
  //# sourceMappingURL=contract_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACxE,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,gCAAgC,EACrC,KAAK,qBAAqB,EAC1B,gBAAgB,EAKjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,2BAA2B,EAGjC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;;;;GAMG;AACH,qBAAa,oBAAqB,YAAW,YAAY;;gBAW3C,KAAK,EAAE,iBAAiB;IAOvB,mBAAmB,CAAC,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB7E,mBAAmB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDzE,qBAAqB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAKtD,4EAA4E;IAC/D,mBAAmB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,2BAA2B,GAAG,SAAS,CAAC;IAKpG,mBAAmB,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAM5F,0EAA0E;IAC7D,gBAAgB,CAAC,eAAe,EAAE,EAAE,GAAG,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAKzE,WAAW,CACtB,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,CAAC,2BAA2B,GAAG,gBAAgB,CAAC,GAAG,SAAS,CAAC;IAYxE;;;;;;;;OAQG;IACU,mBAAmB,CAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAM3C,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAMxD;;;;;;;;OAQG;IACU,yBAAyB,CACpC,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAK3B,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAKnC;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAMhC,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAM7C;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAK/B,oBAAoB,CAAC,eAAe,EAAE,YAAY;IAKlD,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB;IAM9E,OAAO;CAiCrB"}
1
+ {"version":3,"file":"contract_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/contract_data_provider/contract_data_provider.ts"],"names":[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QG;IACU,mBAAmB,CAC9B,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAM3C,yBAAyB,CACpC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,gCAAgC,GAAG,SAAS,CAAC;IAMxD;;;;;;;;OAQG;IACU,yBAAyB,CACpC,eAAe,EAAE,YAAY,EAC7B,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC;IAK3B,cAAc,CACzB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAKnC;;;;;;;;;OASG;IACU,wBAAwB,CACnC,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAMhC,8BAA8B,CACzC,eAAe,EAAE,YAAY,GAC5B,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IAM7C;;;;;;;;OAQG;IACU,4BAA4B,CACvC,eAAe,EAAE,EAAE,EACnB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC,OAAO,oBAAoB,CAAC,GAAG,SAAS,CAAC;IAKzD,oBAAoB,CAAC,eAAe,EAAE,YAAY;IAKlD,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB;CAiC5F"}
@@ -179,9 +179,6 @@ import { PrivateFunctionsTree } from './private_functions_tree.js';
179
179
  const fnArtifact = artifact && await this.#findFunctionAbiBySelector(artifact, selector);
180
180
  return `${artifact?.name ?? contractAddress}:${fnArtifact?.name ?? selector}`;
181
181
  }
182
- async getSize() {
183
- return (await toArray(this.#contractInstances.valuesAsync())).concat(await toArray(this.#contractArtifacts.valuesAsync())).reduce((sum, value)=>sum + value.length, 0);
184
- }
185
182
  async #findFunctionArtifactBySelector(artifact, selector) {
186
183
  const functions = artifact.functions;
187
184
  for(let i = 0; i < functions.length; i++){
@@ -4,7 +4,6 @@ export * from './contract_data_provider/index.js';
4
4
  export * from './note_data_provider/index.js';
5
5
  export * from './sync_data_provider/index.js';
6
6
  export * from './tagging_data_provider/index.js';
7
- export * from './data_provider.js';
8
7
  export * from './metadata.js';
9
8
  export * from './private_event_data_provider/private_event_data_provider.js';
10
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC;AAC9B,cAAc,8DAA8D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AAAA,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,kCAAkC,CAAC;AACjD,cAAc,eAAe,CAAC;AAC9B,cAAc,8DAA8D,CAAC"}
@@ -4,6 +4,5 @@ export * from './contract_data_provider/index.js';
4
4
  export * from './note_data_provider/index.js';
5
5
  export * from './sync_data_provider/index.js';
6
6
  export * from './tagging_data_provider/index.js';
7
- export * from './data_provider.js';
8
7
  export * from './metadata.js';
9
8
  export * from './private_event_data_provider/private_event_data_provider.js';
@@ -3,7 +3,7 @@ import { BufferReader } from '@aztec/foundation/serialize';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { Note } from '@aztec/stdlib/note';
5
5
  import { TxHash } from '@aztec/stdlib/tx';
6
- import type { NoteData } from '../../contract_function_simulator/oracle/typed_oracle.js';
6
+ import type { NoteData } from '../../contract_function_simulator/oracle/interfaces.js';
7
7
  /**
8
8
  * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
9
9
  * information required to use it during execution and manage its state.
@@ -1 +1 @@
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,0DAA0D,CAAC;AAEzF;;;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,Q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AAE;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"}
@@ -3,18 +3,81 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { InBlock } from '@aztec/stdlib/block';
5
5
  import { type NotesFilter } from '@aztec/stdlib/note';
6
- import type { DataProvider } from '../data_provider.js';
7
6
  import { NoteDao } from './note_dao.js';
8
- export declare class NoteDataProvider implements DataProvider {
7
+ /**
8
+ * NoteDataProvider manages the storage and retrieval of notes.
9
+ *
10
+ * Notes can be active or nullified. This class processes new notes, nullifications,
11
+ * and performs rollback handling in the case of a reorg.
12
+ **/
13
+ export declare class NoteDataProvider {
9
14
  #private;
10
15
  private constructor();
16
+ /**
17
+ * Creates and initializes a new NoteDataProvider instance.
18
+ *
19
+ * This factory method creates a NoteDataProvider and restores any existing
20
+ * scope-specific indexes from the database.
21
+ *
22
+ * @param store - The key-value store to use for persistence
23
+ * @returns Promise resolving to a fully initialized NoteDataProvider instance
24
+ */
11
25
  static create(store: AztecAsyncKVStore): Promise<NoteDataProvider>;
26
+ /**
27
+ * Adds a new scope to the note data provider.
28
+ *
29
+ * Scopes provide privacy isolation by creating separate indexes for each user.
30
+ * Each scope gets its own set of indexes for efficient note retrieval by various criteria.
31
+ *
32
+ * @param scope - The AztecAddress representing the scope/user to add
33
+ * @returns Promise resolving to true if scope was added, false if it already existed
34
+ */
12
35
  addScope(scope: AztecAddress): Promise<boolean>;
13
- addNotes(notes: NoteDao[], scope?: AztecAddress): Promise<void>;
14
- removeNotesAfter(blockNumber: number): Promise<void>;
15
- unnullifyNotesAfter(blockNumber: number, synchedBlockNumber?: number): Promise<void>;
36
+ /**
37
+ * Adds multiple notes to the data provider under the specified scope.
38
+ *
39
+ * Notes are stored using their index from the notes hash tree as the key, which provides
40
+ * uniqueness and maintains creation order. Each note is indexed by multiple criteria
41
+ * for efficient retrieval.
42
+ *
43
+ * @param notes - Notes to store
44
+ * @param scope - The scope (user/account) under which to store the notes
45
+ */
46
+ addNotes(notes: NoteDao[], scope: AztecAddress): Promise<void>;
47
+ /**
48
+ * Synchronizes notes and nullifiers to a specific block number.
49
+ *
50
+ * This method ensures that the state of notes and nullifiers is consistent with the
51
+ * specified block number. It restores any notes that were nullified after the given block
52
+ * and deletes any active notes created after that block.
53
+ *
54
+ * @param blockNumber - The new chain tip after a reorg
55
+ * @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
56
+ */
57
+ rollbackNotesAndNullifiers(blockNumber: number, synchedBlockNumber: number): Promise<void>;
58
+ /**
59
+ * Retrieves notes based on the provided filter criteria.
60
+ *
61
+ * This method queries both active and optionally nullified notes based on the filter
62
+ * parameters.
63
+ *
64
+ * @param filter - Filter criteria including contractAddress (required), and optional
65
+ * storageSlot, status, scopes and siloedNullifier.
66
+ * @returns Promise resolving to array of NoteDao objects matching the filter
67
+ * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
68
+ */
16
69
  getNotes(filter: NotesFilter): Promise<NoteDao[]>;
17
- removeNullifiedNotes(nullifiers: InBlock<Fr>[], recipient: AztecAddress): Promise<NoteDao[]>;
18
- getSize(): Promise<number>;
70
+ /**
71
+ * Transitions notes from "active" to "nullified" state.
72
+ *
73
+ * This operation processes a batch of nullifiers to mark the corresponding notes
74
+ * as spent/nullified. The operation is atomic - if any nullifier is not found,
75
+ * the entire operation fails and no notes are modified.
76
+ *
77
+ * @param nullifiers - Array of nullifiers with their block numbers to process
78
+ * @returns Promise resolving to array of nullified NoteDao objects
79
+ * @throws Error if any nullifier is not found in the active notes
80
+ */
81
+ applyNullifiers(nullifiers: InBlock<Fr>[]): Promise<NoteDao[]>;
19
82
  }
20
83
  //# sourceMappingURL=note_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"note_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_data_provider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnD,OAAO,KAAK,EAAE,iBAAiB,EAAqC,MAAM,iBAAiB,CAAC;AAC5F,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnD,OA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AE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC;;;;;IAKI;AACJ,qBAAa,gBAAgB;;IAiB3B,OAAO;IAkBP;;;;;;;;OAQG;WACiB,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAS/E;;;;;;;;OAQG;IACU,QAAQ,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAc5D;;;;;;;;;OASG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAkB9D;;;;;;;;;OASG;IACU,0BAA0B,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAwFvG;;;;;;;;;;OAUG;IACG,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IA8FvD;;;;;;;;;;OAUG;IACH,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CA0D/D"}
@@ -3,7 +3,12 @@ import { toArray } from '@aztec/foundation/iterable';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { NoteStatus } from '@aztec/stdlib/note';
5
5
  import { NoteDao } from './note_dao.js';
6
- export class NoteDataProvider {
6
+ /**
7
+ * NoteDataProvider manages the storage and retrieval of notes.
8
+ *
9
+ * Notes can be active or nullified. This class processes new notes, nullifications,
10
+ * and performs rollback handling in the case of a reorg.
11
+ **/ export class NoteDataProvider {
7
12
  #store;
8
13
  #notes;
9
14
  #nullifiedNotes;
@@ -12,15 +17,11 @@ export class NoteDataProvider {
12
17
  #nullifiedNotesToScope;
13
18
  #nullifiedNotesByContract;
14
19
  #nullifiedNotesByStorageSlot;
15
- #nullifiedNotesByTxHash;
16
- #nullifiedNotesByRecipient;
17
20
  #nullifiedNotesByNullifier;
18
21
  #scopes;
19
22
  #notesToScope;
20
23
  #notesByContractAndScope;
21
24
  #notesByStorageSlotAndScope;
22
- #notesByTxHashAndScope;
23
- #notesByRecipientAndScope;
24
25
  constructor(store){
25
26
  this.#store = store;
26
27
  this.#notes = store.openMap('notes');
@@ -30,27 +31,37 @@ export class NoteDataProvider {
30
31
  this.#nullifiedNotesToScope = store.openMultiMap('nullified_notes_to_scope');
31
32
  this.#nullifiedNotesByContract = store.openMultiMap('nullified_notes_by_contract');
32
33
  this.#nullifiedNotesByStorageSlot = store.openMultiMap('nullified_notes_by_storage_slot');
33
- this.#nullifiedNotesByTxHash = store.openMultiMap('nullified_notes_by_tx_hash');
34
- this.#nullifiedNotesByRecipient = store.openMultiMap('nullified_notes_by_recipient');
35
34
  this.#nullifiedNotesByNullifier = store.openMap('nullified_notes_by_nullifier');
36
35
  this.#scopes = store.openMap('scopes');
37
36
  this.#notesToScope = store.openMultiMap('notes_to_scope');
38
37
  this.#notesByContractAndScope = new Map();
39
38
  this.#notesByStorageSlotAndScope = new Map();
40
- this.#notesByTxHashAndScope = new Map();
41
- this.#notesByRecipientAndScope = new Map();
42
39
  }
43
- static async create(store) {
40
+ /**
41
+ * Creates and initializes a new NoteDataProvider instance.
42
+ *
43
+ * This factory method creates a NoteDataProvider and restores any existing
44
+ * scope-specific indexes from the database.
45
+ *
46
+ * @param store - The key-value store to use for persistence
47
+ * @returns Promise resolving to a fully initialized NoteDataProvider instance
48
+ */ static async create(store) {
44
49
  const pxeDB = new NoteDataProvider(store);
45
50
  for await (const scope of pxeDB.#scopes.keysAsync()){
46
51
  pxeDB.#notesByContractAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_contract`));
47
52
  pxeDB.#notesByStorageSlotAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_storage_slot`));
48
- pxeDB.#notesByTxHashAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_tx_hash`));
49
- pxeDB.#notesByRecipientAndScope.set(scope, store.openMultiMap(`${scope}:notes_by_recipient`));
50
53
  }
51
54
  return pxeDB;
52
55
  }
53
- async addScope(scope) {
56
+ /**
57
+ * Adds a new scope to the note data provider.
58
+ *
59
+ * Scopes provide privacy isolation by creating separate indexes for each user.
60
+ * Each scope gets its own set of indexes for efficient note retrieval by various criteria.
61
+ *
62
+ * @param scope - The AztecAddress representing the scope/user to add
63
+ * @returns Promise resolving to true if scope was added, false if it already existed
64
+ */ async addScope(scope) {
54
65
  const scopeString = scope.toString();
55
66
  if (await this.#scopes.hasAsync(scopeString)) {
56
67
  return false;
@@ -58,32 +69,53 @@ export class NoteDataProvider {
58
69
  await this.#scopes.set(scopeString, true);
59
70
  this.#notesByContractAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_contract`));
60
71
  this.#notesByStorageSlotAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_storage_slot`));
61
- this.#notesByTxHashAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_tx_hash`));
62
- this.#notesByRecipientAndScope.set(scopeString, this.#store.openMultiMap(`${scopeString}:notes_by_recipient`));
63
72
  return true;
64
73
  }
65
- addNotes(notes, scope = AztecAddress.ZERO) {
74
+ /**
75
+ * Adds multiple notes to the data provider under the specified scope.
76
+ *
77
+ * Notes are stored using their index from the notes hash tree as the key, which provides
78
+ * uniqueness and maintains creation order. Each note is indexed by multiple criteria
79
+ * for efficient retrieval.
80
+ *
81
+ * @param notes - Notes to store
82
+ * @param scope - The scope (user/account) under which to store the notes
83
+ */ addNotes(notes, scope) {
66
84
  return this.#store.transactionAsync(async ()=>{
67
85
  if (!await this.#scopes.hasAsync(scope.toString())) {
68
86
  await this.addScope(scope);
69
87
  }
70
88
  for (const dao of notes){
71
- // store notes by their index in the notes hash tree
72
- // this provides the uniqueness we need to store individual notes
73
- // and should also return notes in the order that they were created.
74
- // Had we stored them by their nullifier, they would be returned in random order
75
89
  const noteIndex = toBufferBE(dao.index, 32).toString('hex');
76
90
  await this.#notes.set(noteIndex, dao.toBuffer());
77
91
  await this.#notesToScope.set(noteIndex, scope.toString());
78
92
  await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
79
93
  await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
80
94
  await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
81
- await this.#notesByTxHashAndScope.get(scope.toString()).set(dao.txHash.toString(), noteIndex);
82
- await this.#notesByRecipientAndScope.get(scope.toString()).set(dao.recipient.toString(), noteIndex);
83
95
  }
84
96
  });
85
97
  }
86
- removeNotesAfter(blockNumber) {
98
+ /**
99
+ * Synchronizes notes and nullifiers to a specific block number.
100
+ *
101
+ * This method ensures that the state of notes and nullifiers is consistent with the
102
+ * specified block number. It restores any notes that were nullified after the given block
103
+ * and deletes any active notes created after that block.
104
+ *
105
+ * @param blockNumber - The new chain tip after a reorg
106
+ * @param synchedBlockNumber - The block number up to which PXE managed to sync before the reorg happened.
107
+ */ async rollbackNotesAndNullifiers(blockNumber, synchedBlockNumber) {
108
+ await this.#rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber);
109
+ await this.#deleteActiveNotesAfterBlock(blockNumber);
110
+ }
111
+ /**
112
+ * Deletes (removes) all active notes created after the specified block number.
113
+ *
114
+ * Permanently delete notes from the active notes store, e.g. during a reorg.
115
+ * Note: This only affects #notes (active notes), not #nullifiedNotes.
116
+ *
117
+ * @param blockNumber - Notes created after this block number will be deleted
118
+ */ #deleteActiveNotesAfterBlock(blockNumber) {
87
119
  return this.#store.transactionAsync(async ()=>{
88
120
  const notes = await toArray(this.#notes.valuesAsync());
89
121
  for (const note of notes){
@@ -95,8 +127,6 @@ export class NoteDataProvider {
95
127
  await this.#nullifierToNoteId.delete(noteDao.siloedNullifier.toString());
96
128
  const scopes = await toArray(this.#scopes.keysAsync());
97
129
  for (const scope of scopes){
98
- await this.#notesByRecipientAndScope.get(scope).deleteValue(noteDao.recipient.toString(), noteIndex);
99
- await this.#notesByTxHashAndScope.get(scope).deleteValue(noteDao.txHash.toString(), noteIndex);
100
130
  await this.#notesByContractAndScope.get(scope).deleteValue(noteDao.contractAddress.toString(), noteIndex);
101
131
  await this.#notesByStorageSlotAndScope.get(scope).deleteValue(noteDao.storageSlot.toString(), noteIndex);
102
132
  }
@@ -104,12 +134,20 @@ export class NoteDataProvider {
104
134
  }
105
135
  });
106
136
  }
107
- async unnullifyNotesAfter(blockNumber, synchedBlockNumber) {
137
+ /**
138
+ * Rewinds nullifications after a given block number.
139
+ *
140
+ * This operation "unnullifies" notes, rolling back nullifications that occurred
141
+ * in orphaned blocks, e.g. during a reorg. The notes are restored to the
142
+ * active notes store and removed from the nullified store.
143
+ *
144
+ * @param blockNumber - Revert nullifications that occurred after this block
145
+ * @param synchedBlockNumber - Upper bound for the block range to process
146
+ */ async #rewindNullifiersAfterBlock(blockNumber, synchedBlockNumber) {
108
147
  await this.#store.transactionAsync(async ()=>{
109
148
  const nullifiersToUndo = [];
110
149
  const currentBlockNumber = blockNumber + 1;
111
- const maxBlockNumber = synchedBlockNumber ?? currentBlockNumber;
112
- for(let i = currentBlockNumber; i <= maxBlockNumber; i++){
150
+ for(let i = currentBlockNumber; i <= synchedBlockNumber; i++){
113
151
  nullifiersToUndo.push(...await toArray(this.#nullifiersByBlockNumber.getValuesAsync(i)));
114
152
  }
115
153
  const notesIndexesToReinsert = await Promise.all(nullifiersToUndo.map((nullifier)=>this.#nullifiedNotesByNullifier.getAsync(nullifier)));
@@ -129,8 +167,6 @@ export class NoteDataProvider {
129
167
  for (const scope of scopes){
130
168
  await this.#notesByContractAndScope.get(scope.toString()).set(dao.contractAddress.toString(), noteIndex);
131
169
  await this.#notesByStorageSlotAndScope.get(scope.toString()).set(dao.storageSlot.toString(), noteIndex);
132
- await this.#notesByTxHashAndScope.get(scope.toString()).set(dao.txHash.toString(), noteIndex);
133
- await this.#notesByRecipientAndScope.get(scope.toString()).set(dao.recipient.toString(), noteIndex);
134
170
  await this.#notesToScope.set(noteIndex, scope);
135
171
  }
136
172
  await this.#nullifiedNotes.delete(noteIndex);
@@ -138,33 +174,57 @@ export class NoteDataProvider {
138
174
  await this.#nullifiersByBlockNumber.deleteValue(dao.l2BlockNumber, dao.siloedNullifier.toString());
139
175
  await this.#nullifiedNotesByContract.deleteValue(dao.contractAddress.toString(), noteIndex);
140
176
  await this.#nullifiedNotesByStorageSlot.deleteValue(dao.storageSlot.toString(), noteIndex);
141
- await this.#nullifiedNotesByTxHash.deleteValue(dao.txHash.toString(), noteIndex);
142
- await this.#nullifiedNotesByRecipient.deleteValue(dao.recipient.toString(), noteIndex);
143
177
  await this.#nullifiedNotesByNullifier.delete(dao.siloedNullifier.toString());
144
178
  }
145
179
  });
146
180
  }
147
- async getNotes(filter) {
181
+ /**
182
+ * Retrieves notes based on the provided filter criteria.
183
+ *
184
+ * This method queries both active and optionally nullified notes based on the filter
185
+ * parameters.
186
+ *
187
+ * @param filter - Filter criteria including contractAddress (required), and optional
188
+ * storageSlot, status, scopes and siloedNullifier.
189
+ * @returns Promise resolving to array of NoteDao objects matching the filter
190
+ * @throws If filtering by an empty scopes array. Scopes have to be set to undefined or to a non-empty array.
191
+ */ async getNotes(filter) {
148
192
  filter.status = filter.status ?? NoteStatus.ACTIVE;
193
+ // throw early if scopes is an empty array
194
+ if (filter.scopes !== undefined && filter.scopes.length === 0) {
195
+ throw new Error('Trying to get notes with an empty scopes array. Scopes have to be set to undefined if intending on not filtering by scopes.');
196
+ }
149
197
  const candidateNoteSources = [];
150
198
  filter.scopes ??= (await toArray(this.#scopes.keysAsync())).map((addressString)=>AztecAddress.fromString(addressString));
151
199
  const activeNoteIdsPerScope = [];
152
200
  for (const scope of new Set(filter.scopes)){
153
201
  const formattedScopeString = scope.toString();
154
202
  if (!await this.#scopes.hasAsync(formattedScopeString)) {
155
- throw new Error('Trying to get incoming notes of an scope that is not in the PXE database');
203
+ throw new Error('Trying to get incoming notes of a scope that is not in the PXE database');
156
204
  }
157
- activeNoteIdsPerScope.push(filter.recipient ? await toArray(this.#notesByRecipientAndScope.get(formattedScopeString).getValuesAsync(filter.recipient.toString())) : filter.txHash ? await toArray(this.#notesByTxHashAndScope.get(formattedScopeString).getValuesAsync(filter.txHash.toString())) : filter.storageSlot ? await toArray(this.#notesByStorageSlotAndScope.get(formattedScopeString).getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#notesByContractAndScope.get(formattedScopeString).getValuesAsync(filter.contractAddress.toString())));
205
+ activeNoteIdsPerScope.push(filter.storageSlot ? await toArray(this.#notesByStorageSlotAndScope.get(formattedScopeString).getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#notesByContractAndScope.get(formattedScopeString).getValuesAsync(filter.contractAddress.toString())));
158
206
  }
159
207
  candidateNoteSources.push({
160
208
  ids: new Set(activeNoteIdsPerScope.flat()),
161
209
  notes: this.#notes
162
210
  });
163
- if (filter.status == NoteStatus.ACTIVE_OR_NULLIFIED) {
164
- candidateNoteSources.push({
165
- ids: filter.recipient ? await toArray(this.#nullifiedNotesByRecipient.getValuesAsync(filter.recipient.toString())) : filter.txHash ? await toArray(this.#nullifiedNotesByTxHash.getValuesAsync(filter.txHash.toString())) : filter.storageSlot ? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString())),
166
- notes: this.#nullifiedNotes
167
- });
211
+ // If status is ACTIVE_OR_NULLIFIED we add nullified notes as candidates on top of the default active ones.
212
+ if (filter.status === NoteStatus.ACTIVE_OR_NULLIFIED) {
213
+ const nullifiedIds = filter.storageSlot ? await toArray(this.#nullifiedNotesByStorageSlot.getValuesAsync(filter.storageSlot.toString())) : await toArray(this.#nullifiedNotesByContract.getValuesAsync(filter.contractAddress.toString()));
214
+ const setOfScopes = new Set(filter.scopes.map((s)=>s.toString()));
215
+ const filteredNullifiedIds = new Set();
216
+ for (const noteId of nullifiedIds){
217
+ const scopeList = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteId));
218
+ if (scopeList.some((scope)=>setOfScopes.has(scope))) {
219
+ filteredNullifiedIds.add(noteId);
220
+ }
221
+ }
222
+ if (filteredNullifiedIds.size > 0) {
223
+ candidateNoteSources.push({
224
+ ids: filteredNullifiedIds,
225
+ notes: this.#nullifiedNotes
226
+ });
227
+ }
168
228
  }
169
229
  const result = [];
170
230
  for (const { ids, notes } of candidateNoteSources){
@@ -177,15 +237,9 @@ export class NoteDataProvider {
177
237
  if (!note.contractAddress.equals(filter.contractAddress)) {
178
238
  continue;
179
239
  }
180
- if (filter.txHash && !note.txHash.equals(filter.txHash)) {
181
- continue;
182
- }
183
240
  if (filter.storageSlot && !note.storageSlot.equals(filter.storageSlot)) {
184
241
  continue;
185
242
  }
186
- if (filter.recipient && !note.recipient.equals(filter.recipient)) {
187
- continue;
188
- }
189
243
  if (filter.siloedNullifier && !note.siloedNullifier.equals(filter.siloedNullifier)) {
190
244
  continue;
191
245
  }
@@ -194,7 +248,17 @@ export class NoteDataProvider {
194
248
  }
195
249
  return result;
196
250
  }
197
- removeNullifiedNotes(nullifiers, recipient) {
251
+ /**
252
+ * Transitions notes from "active" to "nullified" state.
253
+ *
254
+ * This operation processes a batch of nullifiers to mark the corresponding notes
255
+ * as spent/nullified. The operation is atomic - if any nullifier is not found,
256
+ * the entire operation fails and no notes are modified.
257
+ *
258
+ * @param nullifiers - Array of nullifiers with their block numbers to process
259
+ * @returns Promise resolving to array of nullified NoteDao objects
260
+ * @throws Error if any nullifier is not found in the active notes
261
+ */ applyNullifiers(nullifiers) {
198
262
  if (nullifiers.length === 0) {
199
263
  return Promise.resolve([]);
200
264
  }
@@ -202,26 +266,27 @@ export class NoteDataProvider {
202
266
  const nullifiedNotes = [];
203
267
  for (const blockScopedNullifier of nullifiers){
204
268
  const { data: nullifier, l2BlockNumber: blockNumber } = blockScopedNullifier;
205
- const noteIndex = await this.#nullifierToNoteId.getAsync(nullifier.toString());
269
+ const nullifierKey = nullifier.toString();
270
+ const noteIndex = await this.#nullifierToNoteId.getAsync(nullifierKey);
206
271
  if (!noteIndex) {
207
- throw new Error('Nullifier not found in removeNullifiedNotes');
272
+ // Check if already nullified?
273
+ const alreadyNullified = await this.#nullifiedNotesByNullifier.getAsync(nullifierKey);
274
+ if (alreadyNullified) {
275
+ throw new Error(`Nullifier already applied in applyNullifiers`);
276
+ }
277
+ throw new Error('Nullifier not found in applyNullifiers');
208
278
  }
209
279
  const noteBuffer = noteIndex ? await this.#notes.getAsync(noteIndex) : undefined;
210
280
  if (!noteBuffer) {
211
- throw new Error('Note not found in removeNullifiedNotes');
281
+ throw new Error('Note not found in applyNullifiers');
212
282
  }
213
283
  const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex)) ?? [];
214
284
  const note = NoteDao.fromBuffer(noteBuffer);
215
- if (!note.recipient.equals(recipient)) {
216
- throw new Error("Tried to nullify someone else's note");
217
- }
218
285
  nullifiedNotes.push(note);
219
286
  await this.#notes.delete(noteIndex);
220
287
  await this.#notesToScope.delete(noteIndex);
221
288
  const scopes = await toArray(this.#scopes.keysAsync());
222
289
  for (const scope of scopes){
223
- await this.#notesByRecipientAndScope.get(scope).deleteValue(note.recipient.toString(), noteIndex);
224
- await this.#notesByTxHashAndScope.get(scope).deleteValue(note.txHash.toString(), noteIndex);
225
290
  await this.#notesByContractAndScope.get(scope).deleteValue(note.contractAddress.toString(), noteIndex);
226
291
  await this.#notesByStorageSlotAndScope.get(scope).deleteValue(note.storageSlot.toString(), noteIndex);
227
292
  }
@@ -234,27 +299,10 @@ export class NoteDataProvider {
234
299
  await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
235
300
  await this.#nullifiedNotesByContract.set(note.contractAddress.toString(), noteIndex);
236
301
  await this.#nullifiedNotesByStorageSlot.set(note.storageSlot.toString(), noteIndex);
237
- await this.#nullifiedNotesByTxHash.set(note.txHash.toString(), noteIndex);
238
- await this.#nullifiedNotesByRecipient.set(note.recipient.toString(), noteIndex);
239
302
  await this.#nullifiedNotesByNullifier.set(nullifier.toString(), noteIndex);
240
303
  await this.#nullifierToNoteId.delete(nullifier.toString());
241
304
  }
242
305
  return nullifiedNotes;
243
306
  });
244
307
  }
245
- async getSize() {
246
- const scopes = await toArray(this.#scopes.keysAsync());
247
- const contractAddresses = new Set();
248
- // Collect all unique contract addresses across all scopes
249
- for (const scope of scopes){
250
- const addresses = await toArray(this.#notesByContractAndScope.get(scope).keysAsync());
251
- addresses.forEach((addr)=>contractAddresses.add(addr));
252
- }
253
- // Get all notes for each contract address
254
- const allNotes = await Promise.all(Array.from(contractAddresses).map((addr)=>this.getNotes({
255
- contractAddress: AztecAddress.fromString(addr)
256
- })));
257
- // Reduce all notes to get total size
258
- return allNotes.flat().reduce((sum, note)=>sum + note.getSize(), 0);
259
- }
260
308
  }
@@ -3,11 +3,10 @@ import type { AztecAsyncKVStore } from '@aztec/kv-store';
3
3
  import type { EventSelector } from '@aztec/stdlib/abi';
4
4
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { TxHash } from '@aztec/stdlib/tx';
6
- import type { DataProvider } from '../data_provider.js';
7
6
  /**
8
7
  * Stores decrypted private event logs.
9
8
  */
10
- export declare class PrivateEventDataProvider implements DataProvider {
9
+ export declare class PrivateEventDataProvider {
11
10
  #private;
12
11
  logger: import("@aztec/foundation/log").Logger;
13
12
  constructor(store: AztecAsyncKVStore);
@@ -32,6 +31,5 @@ export declare class PrivateEventDataProvider implements DataProvider {
32
31
  * @returns - The event log contents.
33
32
  */
34
33
  getPrivateEvents(contractAddress: AztecAddress, from: number, numBlocks: number, recipients: AztecAddress[], eventSelector: EventSelector): Promise<Fr[][]>;
35
- getSize(): Promise<number>;
36
34
  }
37
35
  //# sourceMappingURL=private_event_data_provider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"private_event_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_data_provider/private_event_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD;;GAEG;AACH,qBAAa,wBAAyB,YAAW,YAAY;;IAS3D,MAAM,yCAA+C;gBAEzC,KAAK,EAAE,iBAAiB;IAOpC;;;;;;;;;OASG;IACH,oBAAoB,CAClB,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,EAAE,EAAE,EAChB,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IA4BhB;;;;;;;;OAQG;IACU,gBAAgB,CAC3B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,YAAY,EAAE,EAC1B,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;IAgClB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;CAG3B"}
1
+ {"version":3,"file":"private_event_data_provider.d.ts","sourceRoot":"","sources":["../../../src/storage/private_event_data_provider/private_event_data_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,KAAK,EAAmB,iBAAiB,EAAiB,MAAM,iBAAiB,CAAC;AACzF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAQ/C;;GAEG;AACH,qBAAa,wBAAwB;;IASnC,MAAM,yCAA+C;gBAEzC,KAAK,EAAE,iBAAiB;IAOpC;;;;;;;;;OASG;IACH,oBAAoB,CAClB,eAAe,EAAE,YAAY,EAC7B,SAAS,EAAE,YAAY,EACvB,aAAa,EAAE,aAAa,EAC5B,UAAU,EAAE,EAAE,EAAE,EAChB,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,IAAI,CAAC;IA4BhB;;;;;;;;OAQG;IACU,gBAAgB,CAC3B,eAAe,EAAE,YAAY,EAC7B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,YAAY,EAAE,EAC1B,aAAa,EAAE,aAAa,GAC3B,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;CA+BnB"}