@aztec/pxe 0.0.1-commit.c7c42ec → 0.0.1-commit.f295ac2

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 (180) hide show
  1. package/dest/block_synchronizer/block_synchronizer.d.ts +6 -2
  2. package/dest/block_synchronizer/block_synchronizer.d.ts.map +1 -1
  3. package/dest/block_synchronizer/block_synchronizer.js +21 -13
  4. package/dest/config/package_info.js +1 -1
  5. package/dest/contract_function_simulator/benchmarked_node.d.ts +9 -0
  6. package/dest/contract_function_simulator/benchmarked_node.d.ts.map +1 -0
  7. package/dest/contract_function_simulator/benchmarked_node.js +77 -0
  8. package/dest/contract_function_simulator/contract_function_simulator.d.ts +8 -9
  9. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  10. package/dest/contract_function_simulator/contract_function_simulator.js +33 -16
  11. package/dest/contract_function_simulator/execution_note_cache.d.ts +18 -9
  12. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/execution_note_cache.js +45 -28
  14. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +3 -2
  15. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/noir-structs/event_validation_request.js +5 -2
  17. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +4 -10
  18. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  19. package/dest/contract_function_simulator/noir-structs/utility_context.js +7 -18
  20. package/dest/contract_function_simulator/oracle/interfaces.d.ts +9 -8
  21. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  22. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +3 -1
  23. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  24. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +4 -4
  25. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  26. package/dest/contract_function_simulator/oracle/note_packing_utils.js +5 -5
  27. package/dest/contract_function_simulator/oracle/oracle.d.ts +6 -6
  28. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  29. package/dest/contract_function_simulator/oracle/oracle.js +20 -19
  30. package/dest/contract_function_simulator/oracle/private_execution.d.ts +5 -9
  31. package/dest/contract_function_simulator/oracle/private_execution.d.ts.map +1 -1
  32. package/dest/contract_function_simulator/oracle/private_execution.js +11 -10
  33. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +8 -18
  34. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +10 -35
  36. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +14 -12
  37. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  38. package/dest/contract_function_simulator/oracle/utility_execution_oracle.js +54 -52
  39. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  40. package/dest/entrypoints/client/bundle/utils.d.ts.map +1 -1
  41. package/dest/entrypoints/client/bundle/utils.js +10 -1
  42. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  43. package/dest/entrypoints/client/lazy/utils.d.ts.map +1 -1
  44. package/dest/entrypoints/client/lazy/utils.js +10 -1
  45. package/dest/entrypoints/pxe_creation_options.d.ts +3 -2
  46. package/dest/entrypoints/pxe_creation_options.d.ts.map +1 -1
  47. package/dest/entrypoints/server/index.d.ts +2 -1
  48. package/dest/entrypoints/server/index.d.ts.map +1 -1
  49. package/dest/entrypoints/server/index.js +1 -0
  50. package/dest/entrypoints/server/utils.d.ts +1 -1
  51. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  52. package/dest/entrypoints/server/utils.js +11 -7
  53. package/dest/events/event_service.d.ts +4 -3
  54. package/dest/events/event_service.d.ts.map +1 -1
  55. package/dest/events/event_service.js +17 -19
  56. package/dest/events/private_event_filter_validator.d.ts +5 -5
  57. package/dest/events/private_event_filter_validator.d.ts.map +1 -1
  58. package/dest/events/private_event_filter_validator.js +5 -6
  59. package/dest/job_coordinator/job_coordinator.d.ts +74 -0
  60. package/dest/job_coordinator/job_coordinator.d.ts.map +1 -0
  61. package/dest/job_coordinator/job_coordinator.js +93 -0
  62. package/dest/logs/log_service.d.ts +3 -2
  63. package/dest/logs/log_service.d.ts.map +1 -1
  64. package/dest/logs/log_service.js +5 -3
  65. package/dest/notes/note_service.d.ts +3 -3
  66. package/dest/notes/note_service.d.ts.map +1 -1
  67. package/dest/notes/note_service.js +23 -28
  68. package/dest/oracle_version.d.ts +2 -2
  69. package/dest/oracle_version.js +2 -2
  70. package/dest/private_kernel/hints/index.d.ts +2 -2
  71. package/dest/private_kernel/hints/index.d.ts.map +1 -1
  72. package/dest/private_kernel/hints/index.js +1 -1
  73. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts +28 -0
  74. package/dest/private_kernel/hints/private_kernel_reset_private_inputs_builder.d.ts.map +1 -0
  75. package/dest/private_kernel/hints/{build_private_kernel_reset_private_inputs.js → private_kernel_reset_private_inputs_builder.js} +13 -7
  76. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  77. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  78. package/dest/private_kernel/private_kernel_execution_prover.js +4 -5
  79. package/dest/private_kernel/private_kernel_oracle.d.ts +24 -28
  80. package/dest/private_kernel/private_kernel_oracle.d.ts.map +1 -1
  81. package/dest/private_kernel/private_kernel_oracle.js +90 -2
  82. package/dest/pxe.d.ts +8 -36
  83. package/dest/pxe.d.ts.map +1 -1
  84. package/dest/pxe.js +65 -87
  85. package/dest/storage/capsule_store/capsule_store.d.ts +24 -9
  86. package/dest/storage/capsule_store/capsule_store.d.ts.map +1 -1
  87. package/dest/storage/capsule_store/capsule_store.js +132 -23
  88. package/dest/storage/contract_store/contract_store.d.ts +2 -1
  89. package/dest/storage/contract_store/contract_store.d.ts.map +1 -1
  90. package/dest/storage/contract_store/contract_store.js +12 -0
  91. package/dest/storage/note_store/note_store.d.ts +6 -5
  92. package/dest/storage/note_store/note_store.d.ts.map +1 -1
  93. package/dest/storage/note_store/note_store.js +89 -94
  94. package/dest/storage/private_event_store/private_event_store.d.ts +33 -6
  95. package/dest/storage/private_event_store/private_event_store.d.ts.map +1 -1
  96. package/dest/storage/private_event_store/private_event_store.js +139 -32
  97. package/dest/storage/tagging_store/recipient_tagging_store.d.ts +15 -8
  98. package/dest/storage/tagging_store/recipient_tagging_store.d.ts.map +1 -1
  99. package/dest/storage/tagging_store/recipient_tagging_store.js +69 -12
  100. package/dest/storage/tagging_store/sender_tagging_store.d.ts +19 -9
  101. package/dest/storage/tagging_store/sender_tagging_store.d.ts.map +1 -1
  102. package/dest/storage/tagging_store/sender_tagging_store.js +110 -28
  103. package/dest/tagging/constants.d.ts +2 -0
  104. package/dest/tagging/constants.d.ts.map +1 -0
  105. package/dest/tagging/constants.js +10 -0
  106. package/dest/tagging/index.d.ts +2 -2
  107. package/dest/tagging/index.d.ts.map +1 -1
  108. package/dest/tagging/index.js +1 -10
  109. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts +2 -2
  110. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.d.ts.map +1 -1
  111. package/dest/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.js +7 -7
  112. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts +2 -2
  113. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.d.ts.map +1 -1
  114. package/dest/tagging/sender_sync/sync_sender_tagging_indexes.js +8 -8
  115. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts +1 -1
  116. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.d.ts.map +1 -1
  117. package/dest/tagging/sender_sync/utils/get_status_change_of_pending.js +2 -2
  118. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts +4 -2
  119. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.d.ts.map +1 -1
  120. package/dest/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.js +4 -2
  121. package/dest/tree_membership/tree_membership_service.d.ts +9 -11
  122. package/dest/tree_membership/tree_membership_service.d.ts.map +1 -1
  123. package/dest/tree_membership/tree_membership_service.js +25 -34
  124. package/package.json +18 -18
  125. package/src/block_synchronizer/block_synchronizer.ts +30 -12
  126. package/src/config/package_info.ts +1 -1
  127. package/src/contract_function_simulator/benchmarked_node.ts +103 -0
  128. package/src/contract_function_simulator/contract_function_simulator.ts +42 -16
  129. package/src/contract_function_simulator/execution_note_cache.ts +44 -25
  130. package/src/contract_function_simulator/noir-structs/event_validation_request.ts +4 -0
  131. package/src/contract_function_simulator/noir-structs/utility_context.ts +6 -25
  132. package/src/contract_function_simulator/oracle/interfaces.ts +8 -7
  133. package/src/contract_function_simulator/oracle/note_packing_utils.ts +6 -6
  134. package/src/contract_function_simulator/oracle/oracle.ts +24 -22
  135. package/src/contract_function_simulator/oracle/private_execution.ts +10 -19
  136. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +13 -38
  137. package/src/contract_function_simulator/oracle/utility_execution_oracle.ts +56 -50
  138. package/src/entrypoints/client/bundle/utils.ts +7 -1
  139. package/src/entrypoints/client/lazy/utils.ts +7 -2
  140. package/src/entrypoints/pxe_creation_options.ts +2 -1
  141. package/src/entrypoints/server/index.ts +1 -0
  142. package/src/entrypoints/server/utils.ts +11 -15
  143. package/src/events/event_service.ts +17 -21
  144. package/src/events/private_event_filter_validator.ts +3 -5
  145. package/src/job_coordinator/job_coordinator.ts +149 -0
  146. package/src/logs/log_service.ts +3 -1
  147. package/src/notes/note_service.ts +23 -29
  148. package/src/oracle_version.ts +2 -2
  149. package/src/private_kernel/hints/index.ts +1 -1
  150. package/src/private_kernel/hints/{build_private_kernel_reset_private_inputs.ts → private_kernel_reset_private_inputs_builder.ts} +33 -22
  151. package/src/private_kernel/private_kernel_execution_prover.ts +3 -5
  152. package/src/private_kernel/private_kernel_oracle.ts +116 -36
  153. package/src/pxe.ts +98 -116
  154. package/src/storage/capsule_store/capsule_store.ts +159 -23
  155. package/src/storage/contract_store/contract_store.ts +20 -0
  156. package/src/storage/note_store/note_store.ts +98 -95
  157. package/src/storage/private_event_store/private_event_store.ts +199 -37
  158. package/src/storage/tagging_store/recipient_tagging_store.ts +89 -13
  159. package/src/storage/tagging_store/sender_tagging_store.ts +129 -28
  160. package/src/tagging/constants.ts +10 -0
  161. package/src/tagging/index.ts +1 -11
  162. package/src/tagging/recipient_sync/load_private_logs_for_sender_recipient_pair.ts +10 -6
  163. package/src/tagging/sender_sync/sync_sender_tagging_indexes.ts +8 -7
  164. package/src/tagging/sender_sync/utils/get_status_change_of_pending.ts +6 -2
  165. package/src/tagging/sender_sync/utils/load_and_store_new_tagging_indexes.ts +4 -1
  166. package/src/tree_membership/tree_membership_service.ts +27 -42
  167. package/dest/contract_function_simulator/proxied_node.d.ts +0 -9
  168. package/dest/contract_function_simulator/proxied_node.d.ts.map +0 -1
  169. package/dest/contract_function_simulator/proxied_node.js +0 -27
  170. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +0 -28
  171. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +0 -1
  172. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +0 -46
  173. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +0 -1
  174. package/dest/private_kernel/private_kernel_oracle_impl.js +0 -86
  175. package/dest/public_storage/public_storage_service.d.ts +0 -24
  176. package/dest/public_storage/public_storage_service.d.ts.map +0 -1
  177. package/dest/public_storage/public_storage_service.js +0 -26
  178. package/src/contract_function_simulator/proxied_node.ts +0 -33
  179. package/src/private_kernel/private_kernel_oracle_impl.ts +0 -133
  180. package/src/public_storage/public_storage_service.ts +0 -33
@@ -1,27 +0,0 @@
1
- import { Timer } from '@aztec/foundation/timer';
2
- export class ProxiedNodeFactory {
3
- static create(node) {
4
- const stats = {};
5
- return new Proxy(node, {
6
- get (target, prop) {
7
- if (prop === 'getStats') {
8
- return ()=>{
9
- return stats;
10
- };
11
- } else {
12
- return async function(...args) {
13
- if (!stats[prop]) {
14
- stats[prop] = {
15
- times: []
16
- };
17
- }
18
- const timer = new Timer();
19
- const result = await target[prop].apply(target, args);
20
- stats[prop].times.push(timer.ms());
21
- return result;
22
- };
23
- }
24
- }
25
- });
26
- }
27
- }
@@ -1,28 +0,0 @@
1
- import { type PrivateKernelCircuitPublicInputs, PrivateKernelResetCircuitPrivateInputs, type PrivateKernelSimulateOutput } from '@aztec/stdlib/kernel';
2
- import { type PrivateCallExecutionResult } from '@aztec/stdlib/tx';
3
- import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
4
- export declare class PrivateKernelResetPrivateInputsBuilder {
5
- private previousKernelOutput;
6
- private executionStack;
7
- private noteHashNullifierCounterMap;
8
- private splitCounter;
9
- private previousKernel;
10
- private nextIteration?;
11
- private noteHashResetActions;
12
- private nullifierResetActions;
13
- private numTransientData?;
14
- private transientDataSquashingHints;
15
- private requestedDimensions;
16
- constructor(previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>, executionStack: PrivateCallExecutionResult[], noteHashNullifierCounterMap: Map<number, number>, splitCounter: number);
17
- needsReset(): boolean;
18
- build(oracle: PrivateKernelOracle, noteHashLeafIndexMap: Map<bigint, bigint>): Promise<PrivateKernelResetCircuitPrivateInputs>;
19
- private reduceReadRequestActions;
20
- private needsResetNoteHashReadRequests;
21
- private needsResetNullifierReadRequests;
22
- private needsResetNullifierKeys;
23
- private needsResetTransientData;
24
- private needsSiloNoteHashes;
25
- private needsSiloNullifiers;
26
- private needsSiloPrivateLogs;
27
- }
28
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGRfcHJpdmF0ZV9rZXJuZWxfcmVzZXRfcHJpdmF0ZV9pbnB1dHMuZC50cyIsInNvdXJjZVJvb3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BQUksT0FBTyxDQXNCcEI7SUFFSyxLQUFLLENBQUMsTUFBTSxFQUFFLG1CQUFtQixFQUFFLG9CQUFvQixFQUFFLEdBQUcsQ0FBQyxNQUFNLEVBQUUsTUFBTSxDQUFDLG1EQW9FakY7SUFFRCxPQUFPLENBQUMsd0JBQXdCO0lBMkJoQyxPQUFPLENBQUMsOEJBQThCO0lBdUR0QyxPQUFPLENBQUMsK0JBQStCO0lBdUR2QyxPQUFPLENBQUMsdUJBQXVCO0lBYS9CLE9BQU8sQ0FBQyx1QkFBdUI7SUFzRS9CLE9BQU8sQ0FBQyxtQkFBbUI7SUFjM0IsT0FBTyxDQUFDLG1CQUFtQjtJQWtCM0IsT0FBTyxDQUFDLG9CQUFvQjtDQXFCN0IifQ==
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_private_kernel_reset_private_inputs.d.ts","sourceRoot":"","sources":["../../../src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts"],"names":[],"mappings":"AAeA,OAAO,EAKL,KAAK,gCAAgC,EAErC,sCAAsC,EAGtC,KAAK,2BAA2B,EAejC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,KAAK,0BAA0B,EAAiB,MAAM,kBAAkB,CAAC;AAGlF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AA4CvE,qBAAa,sCAAsC;IAY/C,OAAO,CAAC,oBAAoB;IAC5B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,2BAA2B;IACnC,OAAO,CAAC,YAAY;IAdtB,OAAO,CAAC,cAAc,CAAmC;IAEzD,OAAO,CAAC,aAAa,CAAC,CAA6B;IAEnD,OAAO,CAAC,oBAAoB,CAAqE;IACjG,OAAO,CAAC,qBAAqB,CAAqE;IAClG,OAAO,CAAC,gBAAgB,CAAC,CAAS;IAClC,OAAO,CAAC,2BAA2B,CAAkE;IACrG,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,YACU,oBAAoB,EAAE,2BAA2B,CAAC,gCAAgC,CAAC,EACnF,cAAc,EAAE,0BAA0B,EAAE,EAC5C,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAChD,YAAY,EAAE,MAAM,EAW7B;IAED,UAAU,IAAI,OAAO,CAsBpB;IAEK,KAAK,CAAC,MAAM,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,mDAoEjF;IAED,OAAO,CAAC,wBAAwB;IA2BhC,OAAO,CAAC,8BAA8B;IAuDtC,OAAO,CAAC,+BAA+B;IAuDvC,OAAO,CAAC,uBAAuB;IAa/B,OAAO,CAAC,uBAAuB;IAsE/B,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,mBAAmB;IAkB3B,OAAO,CAAC,oBAAoB;CAqB7B"}
@@ -1,46 +0,0 @@
1
- import { NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
4
- import { MembershipWitness } from '@aztec/foundation/trees';
5
- import type { KeyStore } from '@aztec/key-store';
6
- import type { FunctionSelector } from '@aztec/stdlib/abi';
7
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import type { BlockParameter } from '@aztec/stdlib/block';
9
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
10
- import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
11
- import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
12
- import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
13
- import type { ContractStore } from '../storage/contract_store/contract_store.js';
14
- import type { PrivateKernelOracle } from './private_kernel_oracle.js';
15
- /**
16
- * A data oracle that provides information needed for simulating a transaction.
17
- */
18
- export declare class PrivateKernelOracleImpl implements PrivateKernelOracle {
19
- private contractStore;
20
- private keyStore;
21
- private node;
22
- private blockNumber;
23
- private log;
24
- constructor(contractStore: ContractStore, keyStore: KeyStore, node: AztecNode, blockNumber?: BlockParameter, log?: import("@aztec/foundation/log").Logger);
25
- getContractAddressPreimage(address: AztecAddress): Promise<{
26
- version: 1;
27
- salt: Fr;
28
- deployer: AztecAddress;
29
- currentContractClassId: Fr;
30
- originalContractClassId: Fr;
31
- initializationHash: Fr;
32
- publicKeys: import("../../../stdlib/dest/keys/public_keys.js").PublicKeys;
33
- address: AztecAddress;
34
- saltedInitializationHash: Fr;
35
- }>;
36
- getContractClassIdPreimage(contractClassId: Fr): Promise<import("@aztec/stdlib/contract").ContractClassIdPreimage>;
37
- getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector): Promise<MembershipWitness<7>>;
38
- getVkMembershipWitness(vk: VerificationKeyAsFields): Promise<MembershipWitness<7>>;
39
- getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>>;
40
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
41
- getNoteHashTreeRoot(): Promise<Fr>;
42
- getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar>;
43
- getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string>;
44
- getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints>;
45
- }
46
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJpdmF0ZV9rZXJuZWxfb3JhY2xlX2ltcGwuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9wcml2YXRlX2tlcm5lbC9wcml2YXRlX2tlcm5lbF9vcmFjbGVfaW1wbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUscUJBQXFCLEVBQTJDLE1BQU0sa0JBQWtCLENBQUM7QUFDbEcsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7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AAgB,iCAQxF;IAEM,sBAAsB,CAAC,EAAE,EAAE,uBAAuB,iCAGxD;IAEK,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAO9G;IAED,6BAA6B,CAAC,SAAS,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,GAAG,SAAS,CAAC,CAE5F;IAEK,mBAAmB,IAAI,OAAO,CAAC,EAAE,CAAC,CAMvC;IAEM,kBAAkB,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,CAEzE;IAEM,oBAAoB,CAAC,eAAe,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,CAEtG;IAEY,sBAAsB,CAAC,eAAe,EAAE,YAAY,GAAG,OAAO,CAAC,mBAAmB,CAAC,CA8B/F;CACF"}
@@ -1,86 +0,0 @@
1
- import { PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
- import { createLogger } from '@aztec/foundation/log';
3
- import { MembershipWitness } from '@aztec/foundation/trees';
4
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
5
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
6
- import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
7
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
8
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
9
- import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
10
- // TODO: Block number should not be "latest".
11
- // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
12
- /**
13
- * A data oracle that provides information needed for simulating a transaction.
14
- */ export class PrivateKernelOracleImpl {
15
- contractStore;
16
- keyStore;
17
- node;
18
- blockNumber;
19
- log;
20
- constructor(contractStore, keyStore, node, blockNumber = 'latest', log = createLogger('pxe:kernel_oracle')){
21
- this.contractStore = contractStore;
22
- this.keyStore = keyStore;
23
- this.node = node;
24
- this.blockNumber = blockNumber;
25
- this.log = log;
26
- }
27
- async getContractAddressPreimage(address) {
28
- const instance = await this.contractStore.getContractInstance(address);
29
- if (!instance) {
30
- throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
31
- }
32
- return {
33
- saltedInitializationHash: await computeSaltedInitializationHash(instance),
34
- ...instance
35
- };
36
- }
37
- async getContractClassIdPreimage(contractClassId) {
38
- const contractClass = await this.contractStore.getContractClass(contractClassId);
39
- if (!contractClass) {
40
- throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
41
- }
42
- return computeContractClassIdPreimage(contractClass);
43
- }
44
- async getFunctionMembershipWitness(contractClassId, selector) {
45
- const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
46
- if (!membershipWitness) {
47
- throw new Error(`Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`);
48
- }
49
- return membershipWitness;
50
- }
51
- getVkMembershipWitness(vk) {
52
- const leafIndex = getVKIndex(vk);
53
- return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
54
- }
55
- async getNoteHashMembershipWitness(leafIndex) {
56
- const path = await this.node.getNoteHashSiblingPath(this.blockNumber, leafIndex);
57
- return new MembershipWitness(path.pathSize, leafIndex, path.toFields());
58
- }
59
- getNullifierMembershipWitness(nullifier) {
60
- return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
61
- }
62
- async getNoteHashTreeRoot() {
63
- const header = await this.node.getBlockHeader(this.blockNumber);
64
- if (!header) {
65
- throw new Error(`No block header found for block number ${this.blockNumber}`);
66
- }
67
- return header.state.partial.noteHashTree.root;
68
- }
69
- getMasterSecretKey(masterPublicKey) {
70
- return this.keyStore.getMasterSecretKey(masterPublicKey);
71
- }
72
- getDebugFunctionName(contractAddress, selector) {
73
- return this.contractStore.getDebugFunctionName(contractAddress, selector);
74
- }
75
- async getUpdatedClassIdHints(contractAddress) {
76
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } = await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
77
- const hashLeafSlot = await computePublicDataTreeLeafSlot(ProtocolContractAddress.ContractInstanceRegistry, delayedPublicMutableHashSlot);
78
- const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
79
- if (!updatedClassIdWitness) {
80
- throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
81
- }
82
- const readStorage = (storageSlot)=>this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
83
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(delayedPublicMutableSlot, readStorage);
84
- return new UpdatedClassIdHints(new MembershipWitness(PUBLIC_DATA_TREE_HEIGHT, updatedClassIdWitness.index, updatedClassIdWitness.siblingPath.toTuple()), updatedClassIdWitness.leafPreimage, delayedPublicMutableValues);
85
- }
86
- }
@@ -1,24 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { BlockParameter } from '@aztec/stdlib/block';
4
- import type { AztecNode } from '@aztec/stdlib/interfaces/server';
5
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
6
- export declare class PublicStorageService {
7
- private readonly anchorBlockStore;
8
- private readonly aztecNode;
9
- constructor(anchorBlockStore: AnchorBlockStore, aztecNode: AztecNode);
10
- /**
11
- * Gets the storage value at the given contract storage slot.
12
- *
13
- * @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
14
- * Aztec's version of `eth_getStorageAt`.
15
- *
16
- * @param blockNumber - The block number at which to get the data.
17
- * @param contract - Address of the contract to query.
18
- * @param slot - Slot to query.
19
- * @returns Storage value at the given contract slot.
20
- * @throws If the contract is not deployed.
21
- */
22
- getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
23
- }
24
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljX3N0b3JhZ2Vfc2VydmljZS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL3B1YmxpY19zdG9yYWdlL3B1YmxpY19zdG9yYWdlX3NlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDekQsT0FBTyxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsY0FBYyxFQUFFLE1BQU0scUJBQXFCLENBQUM7QUFDMUQsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxxREFBcUQsQ0FBQztBQUU1RixxQkFBYSxvQkFBb0I7SUFFN0IsT0FBTyxDQUFDLFFBQVEsQ0FBQyxnQkFBZ0I7SUFDakMsT0FBTyxDQUFDLFFBQVEsQ0FBQyxTQUFTO0lBRjVCLFlBQ21CLGdCQUFnQixFQUFFLGdCQUFnQixFQUNsQyxTQUFTLEVBQUUsU0FBUyxFQUNuQztJQUVKOzs7Ozs7Ozs7OztPQVdHO0lBQ1Usa0JBQWtCLENBQUMsV0FBVyxFQUFFLGNBQWMsRUFBRSxRQUFRLEVBQUUsWUFBWSxFQUFFLElBQUksRUFBRSxFQUFFLEdBQUcsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQU0xRztDQUNGIn0=
@@ -1 +0,0 @@
1
- {"version":3,"file":"public_storage_service.d.ts","sourceRoot":"","sources":["../../src/public_storage/public_storage_service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAE5F,qBAAa,oBAAoB;IAE7B,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAF5B,YACmB,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,SAAS,EACnC;IAEJ;;;;;;;;;;;OAWG;IACU,kBAAkB,CAAC,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,CAM1G;CACF"}
@@ -1,26 +0,0 @@
1
- export class PublicStorageService {
2
- anchorBlockStore;
3
- aztecNode;
4
- constructor(anchorBlockStore, aztecNode){
5
- this.anchorBlockStore = anchorBlockStore;
6
- this.aztecNode = aztecNode;
7
- }
8
- /**
9
- * Gets the storage value at the given contract storage slot.
10
- *
11
- * @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
12
- * Aztec's version of `eth_getStorageAt`.
13
- *
14
- * @param blockNumber - The block number at which to get the data.
15
- * @param contract - Address of the contract to query.
16
- * @param slot - Slot to query.
17
- * @returns Storage value at the given contract slot.
18
- * @throws If the contract is not deployed.
19
- */ async getPublicStorageAt(blockNumber, contract, slot) {
20
- const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
21
- if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
22
- throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
23
- }
24
- return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
25
- }
26
- }
@@ -1,33 +0,0 @@
1
- import { Timer } from '@aztec/foundation/timer';
2
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
3
- import type { NodeStats } from '@aztec/stdlib/tx';
4
-
5
- /*
6
- * Proxy generator for an AztecNode that tracks the time taken for each RPC call.
7
- */
8
- export type ProxiedNode = AztecNode & { getStats(): NodeStats };
9
-
10
- export class ProxiedNodeFactory {
11
- static create(node: AztecNode) {
12
- const stats: Partial<Record<keyof AztecNode, { times: number[] }>> = {};
13
- return new Proxy(node, {
14
- get(target, prop: keyof ProxiedNode) {
15
- if (prop === 'getStats') {
16
- return () => {
17
- return stats;
18
- };
19
- } else {
20
- return async function (...args: any[]) {
21
- if (!stats[prop]) {
22
- stats[prop] = { times: [] };
23
- }
24
- const timer = new Timer();
25
- const result = await (target[prop] as any).apply(target, args);
26
- stats[prop].times.push(timer.ms());
27
- return result;
28
- };
29
- }
30
- },
31
- }) as ProxiedNode;
32
- }
33
- }
@@ -1,133 +0,0 @@
1
- import { NOTE_HASH_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, VK_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/curves/bn254';
3
- import type { GrumpkinScalar, Point } from '@aztec/foundation/curves/grumpkin';
4
- import { createLogger } from '@aztec/foundation/log';
5
- import type { Tuple } from '@aztec/foundation/serialize';
6
- import { MembershipWitness } from '@aztec/foundation/trees';
7
- import type { KeyStore } from '@aztec/key-store';
8
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
9
- import { ProtocolContractAddress } from '@aztec/protocol-contracts';
10
- import type { FunctionSelector } from '@aztec/stdlib/abi';
11
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
12
- import type { BlockParameter } from '@aztec/stdlib/block';
13
- import { computeContractClassIdPreimage, computeSaltedInitializationHash } from '@aztec/stdlib/contract';
14
- import { DelayedPublicMutableValues, DelayedPublicMutableValuesWithHash } from '@aztec/stdlib/delayed-public-mutable';
15
- import { computePublicDataTreeLeafSlot } from '@aztec/stdlib/hash';
16
- import type { AztecNode } from '@aztec/stdlib/interfaces/client';
17
- import { UpdatedClassIdHints } from '@aztec/stdlib/kernel';
18
- import type { NullifierMembershipWitness } from '@aztec/stdlib/trees';
19
- import type { VerificationKeyAsFields } from '@aztec/stdlib/vks';
20
-
21
- import type { ContractStore } from '../storage/contract_store/contract_store.js';
22
- import type { PrivateKernelOracle } from './private_kernel_oracle.js';
23
-
24
- // TODO: Block number should not be "latest".
25
- // It should be fixed at the time the proof is being simulated. I.e., it should be the same as the value defined in the constant data.
26
-
27
- /**
28
- * A data oracle that provides information needed for simulating a transaction.
29
- */
30
- export class PrivateKernelOracleImpl implements PrivateKernelOracle {
31
- constructor(
32
- private contractStore: ContractStore,
33
- private keyStore: KeyStore,
34
- private node: AztecNode,
35
- private blockNumber: BlockParameter = 'latest',
36
- private log = createLogger('pxe:kernel_oracle'),
37
- ) {}
38
-
39
- public async getContractAddressPreimage(address: AztecAddress) {
40
- const instance = await this.contractStore.getContractInstance(address);
41
- if (!instance) {
42
- throw new Error(`Contract instance not found when getting address preimage. Contract address: ${address}.`);
43
- }
44
- return {
45
- saltedInitializationHash: await computeSaltedInitializationHash(instance),
46
- ...instance,
47
- };
48
- }
49
-
50
- public async getContractClassIdPreimage(contractClassId: Fr) {
51
- const contractClass = await this.contractStore.getContractClass(contractClassId);
52
- if (!contractClass) {
53
- throw new Error(`Contract class not found when getting class id preimage. Class id: ${contractClassId}.`);
54
- }
55
- return computeContractClassIdPreimage(contractClass);
56
- }
57
-
58
- public async getFunctionMembershipWitness(contractClassId: Fr, selector: FunctionSelector) {
59
- const membershipWitness = await this.contractStore.getFunctionMembershipWitness(contractClassId, selector);
60
- if (!membershipWitness) {
61
- throw new Error(
62
- `Membership witness not found for contract class id ${contractClassId} and selector ${selector}.`,
63
- );
64
- }
65
- return membershipWitness;
66
- }
67
-
68
- public getVkMembershipWitness(vk: VerificationKeyAsFields) {
69
- const leafIndex = getVKIndex(vk);
70
- return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
71
- }
72
-
73
- async getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>> {
74
- const path = await this.node.getNoteHashSiblingPath(this.blockNumber, leafIndex);
75
- return new MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>(
76
- path.pathSize,
77
- leafIndex,
78
- path.toFields() as Tuple<Fr, typeof NOTE_HASH_TREE_HEIGHT>,
79
- );
80
- }
81
-
82
- getNullifierMembershipWitness(nullifier: Fr): Promise<NullifierMembershipWitness | undefined> {
83
- return this.node.getNullifierMembershipWitness(this.blockNumber, nullifier);
84
- }
85
-
86
- async getNoteHashTreeRoot(): Promise<Fr> {
87
- const header = await this.node.getBlockHeader(this.blockNumber);
88
- if (!header) {
89
- throw new Error(`No block header found for block number ${this.blockNumber}`);
90
- }
91
- return header.state.partial.noteHashTree.root;
92
- }
93
-
94
- public getMasterSecretKey(masterPublicKey: Point): Promise<GrumpkinScalar> {
95
- return this.keyStore.getMasterSecretKey(masterPublicKey);
96
- }
97
-
98
- public getDebugFunctionName(contractAddress: AztecAddress, selector: FunctionSelector): Promise<string> {
99
- return this.contractStore.getDebugFunctionName(contractAddress, selector);
100
- }
101
-
102
- public async getUpdatedClassIdHints(contractAddress: AztecAddress): Promise<UpdatedClassIdHints> {
103
- const { delayedPublicMutableSlot, delayedPublicMutableHashSlot } =
104
- await DelayedPublicMutableValuesWithHash.getContractUpdateSlots(contractAddress);
105
-
106
- const hashLeafSlot = await computePublicDataTreeLeafSlot(
107
- ProtocolContractAddress.ContractInstanceRegistry,
108
- delayedPublicMutableHashSlot,
109
- );
110
- const updatedClassIdWitness = await this.node.getPublicDataWitness(this.blockNumber, hashLeafSlot);
111
-
112
- if (!updatedClassIdWitness) {
113
- throw new Error(`No public data tree witness found for ${hashLeafSlot}`);
114
- }
115
-
116
- const readStorage = (storageSlot: Fr) =>
117
- this.node.getPublicStorageAt(this.blockNumber, ProtocolContractAddress.ContractInstanceRegistry, storageSlot);
118
- const delayedPublicMutableValues = await DelayedPublicMutableValues.readFromTree(
119
- delayedPublicMutableSlot,
120
- readStorage,
121
- );
122
-
123
- return new UpdatedClassIdHints(
124
- new MembershipWitness(
125
- PUBLIC_DATA_TREE_HEIGHT,
126
- updatedClassIdWitness.index,
127
- updatedClassIdWitness.siblingPath.toTuple(),
128
- ),
129
- updatedClassIdWitness.leafPreimage,
130
- delayedPublicMutableValues,
131
- );
132
- }
133
- }
@@ -1,33 +0,0 @@
1
- import type { Fr } from '@aztec/foundation/curves/bn254';
2
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { BlockParameter } from '@aztec/stdlib/block';
4
- import type { AztecNode } from '@aztec/stdlib/interfaces/server';
5
-
6
- import type { AnchorBlockStore } from '../storage/anchor_block_store/anchor_block_store.js';
7
-
8
- export class PublicStorageService {
9
- constructor(
10
- private readonly anchorBlockStore: AnchorBlockStore,
11
- private readonly aztecNode: AztecNode,
12
- ) {}
13
-
14
- /**
15
- * Gets the storage value at the given contract storage slot.
16
- *
17
- * @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
18
- * Aztec's version of `eth_getStorageAt`.
19
- *
20
- * @param blockNumber - The block number at which to get the data.
21
- * @param contract - Address of the contract to query.
22
- * @param slot - Slot to query.
23
- * @returns Storage value at the given contract slot.
24
- * @throws If the contract is not deployed.
25
- */
26
- public async getPublicStorageAt(blockNumber: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
27
- const anchorBlockNumber = (await this.anchorBlockStore.getBlockHeader()).getBlockNumber();
28
- if (blockNumber !== 'latest' && blockNumber > anchorBlockNumber) {
29
- throw new Error(`Block number ${blockNumber} is higher than current block ${anchorBlockNumber}`);
30
- }
31
- return await this.aztecNode.getPublicStorageAt(blockNumber, contract, slot);
32
- }
33
- }