@aztec/pxe 0.0.1-commit.b655e406 → 0.0.1-commit.fce3e4f

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 (149) hide show
  1. package/dest/bin/check_oracle_version.d.ts +1 -1
  2. package/dest/config/index.d.ts +2 -10
  3. package/dest/config/index.d.ts.map +1 -1
  4. package/dest/config/index.js +7 -13
  5. package/dest/config/package_info.d.ts +1 -1
  6. package/dest/contract_function_simulator/contract_function_simulator.d.ts +4 -4
  7. package/dest/contract_function_simulator/contract_function_simulator.d.ts.map +1 -1
  8. package/dest/contract_function_simulator/contract_function_simulator.js +9 -10
  9. package/dest/contract_function_simulator/execution_data_provider.d.ts +2 -11
  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 +6 -5
  12. package/dest/contract_function_simulator/execution_note_cache.d.ts.map +1 -1
  13. package/dest/contract_function_simulator/execution_note_cache.js +17 -10
  14. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts +1 -1
  15. package/dest/contract_function_simulator/execution_tagging_index_cache.d.ts.map +1 -1
  16. package/dest/contract_function_simulator/hashed_values_cache.d.ts +1 -1
  17. package/dest/contract_function_simulator/hashed_values_cache.d.ts.map +1 -1
  18. package/dest/contract_function_simulator/index.d.ts +1 -1
  19. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts +1 -1
  20. package/dest/contract_function_simulator/noir-structs/event_validation_request.d.ts.map +1 -1
  21. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts +1 -1
  22. package/dest/contract_function_simulator/noir-structs/log_retrieval_request.d.ts.map +1 -1
  23. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts +2 -2
  24. package/dest/contract_function_simulator/noir-structs/log_retrieval_response.d.ts.map +1 -1
  25. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts +4 -3
  26. package/dest/contract_function_simulator/noir-structs/note_validation_request.d.ts.map +1 -1
  27. package/dest/contract_function_simulator/noir-structs/note_validation_request.js +9 -3
  28. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts +1 -1
  29. package/dest/contract_function_simulator/noir-structs/utility_context.d.ts.map +1 -1
  30. package/dest/contract_function_simulator/oracle/index.d.ts +1 -1
  31. package/dest/contract_function_simulator/oracle/interfaces.d.ts +5 -2
  32. package/dest/contract_function_simulator/oracle/interfaces.d.ts.map +1 -1
  33. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts +1 -3
  34. package/dest/contract_function_simulator/oracle/message_load_oracle_inputs.d.ts.map +1 -1
  35. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts +5 -3
  36. package/dest/contract_function_simulator/oracle/note_packing_utils.d.ts.map +1 -1
  37. package/dest/contract_function_simulator/oracle/note_packing_utils.js +4 -3
  38. package/dest/contract_function_simulator/oracle/oracle.d.ts +4 -3
  39. package/dest/contract_function_simulator/oracle/oracle.d.ts.map +1 -1
  40. package/dest/contract_function_simulator/oracle/oracle.js +9 -4
  41. package/dest/contract_function_simulator/oracle/private_execution.d.ts +1 -1
  42. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts +4 -9
  43. package/dest/contract_function_simulator/oracle/private_execution_oracle.d.ts.map +1 -1
  44. package/dest/contract_function_simulator/oracle/private_execution_oracle.js +13 -2
  45. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts +2 -3
  46. package/dest/contract_function_simulator/oracle/utility_execution_oracle.d.ts.map +1 -1
  47. package/dest/contract_function_simulator/pick_notes.d.ts +1 -1
  48. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts +1 -1
  49. package/dest/contract_function_simulator/proxied_contract_data_source.d.ts.map +1 -1
  50. package/dest/contract_function_simulator/proxied_node.d.ts +1 -1
  51. package/dest/contract_function_simulator/proxied_node.d.ts.map +1 -1
  52. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts +3 -3
  53. package/dest/contract_function_simulator/pxe_oracle_interface.d.ts.map +1 -1
  54. package/dest/contract_function_simulator/pxe_oracle_interface.js +8 -15
  55. package/dest/entrypoints/client/bundle/index.d.ts +1 -1
  56. package/dest/entrypoints/client/bundle/utils.d.ts +1 -1
  57. package/dest/entrypoints/client/bundle/utils.js +2 -2
  58. package/dest/entrypoints/client/lazy/index.d.ts +1 -1
  59. package/dest/entrypoints/client/lazy/utils.d.ts +1 -1
  60. package/dest/entrypoints/client/lazy/utils.js +2 -2
  61. package/dest/entrypoints/pxe_creation_options.d.ts +1 -1
  62. package/dest/entrypoints/server/index.d.ts +1 -1
  63. package/dest/entrypoints/server/utils.d.ts +1 -1
  64. package/dest/entrypoints/server/utils.d.ts.map +1 -1
  65. package/dest/entrypoints/server/utils.js +4 -15
  66. package/dest/error_enriching.d.ts +1 -1
  67. package/dest/oracle_version.d.ts +3 -3
  68. package/dest/oracle_version.js +2 -2
  69. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts +3 -3
  70. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.d.ts.map +1 -1
  71. package/dest/private_kernel/hints/build_private_kernel_reset_private_inputs.js +7 -7
  72. package/dest/private_kernel/hints/compute_tx_include_by_timestamp.d.ts +1 -1
  73. package/dest/private_kernel/hints/index.d.ts +1 -1
  74. package/dest/private_kernel/index.d.ts +1 -1
  75. package/dest/private_kernel/private_kernel_execution_prover.d.ts +1 -1
  76. package/dest/private_kernel/private_kernel_execution_prover.d.ts.map +1 -1
  77. package/dest/private_kernel/private_kernel_execution_prover.js +7 -6
  78. package/dest/private_kernel/private_kernel_oracle.d.ts +1 -1
  79. package/dest/private_kernel/private_kernel_oracle_impl.d.ts +2 -2
  80. package/dest/private_kernel/private_kernel_oracle_impl.d.ts.map +1 -1
  81. package/dest/pxe.d.ts +20 -13
  82. package/dest/pxe.d.ts.map +1 -1
  83. package/dest/pxe.js +19 -37
  84. package/dest/storage/address_data_provider/address_data_provider.d.ts +1 -1
  85. package/dest/storage/address_data_provider/address_data_provider.d.ts.map +1 -1
  86. package/dest/storage/address_data_provider/index.d.ts +1 -1
  87. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts +1 -1
  88. package/dest/storage/capsule_data_provider/capsule_data_provider.d.ts.map +1 -1
  89. package/dest/storage/capsule_data_provider/index.d.ts +1 -1
  90. package/dest/storage/contract_data_provider/contract_data_provider.d.ts +2 -12
  91. package/dest/storage/contract_data_provider/contract_data_provider.d.ts.map +1 -1
  92. package/dest/storage/contract_data_provider/contract_data_provider.js +0 -12
  93. package/dest/storage/contract_data_provider/index.d.ts +1 -1
  94. package/dest/storage/contract_data_provider/private_functions_tree.d.ts +1 -1
  95. package/dest/storage/contract_data_provider/private_functions_tree.d.ts.map +1 -1
  96. package/dest/storage/index.d.ts +1 -1
  97. package/dest/storage/metadata.d.ts +1 -1
  98. package/dest/storage/note_data_provider/index.d.ts +2 -2
  99. package/dest/storage/note_data_provider/index.d.ts.map +1 -1
  100. package/dest/storage/note_data_provider/index.js +1 -1
  101. package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
  102. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  103. package/dest/storage/note_data_provider/note_data_provider.js +13 -10
  104. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts +2 -8
  105. package/dest/storage/private_event_data_provider/private_event_data_provider.d.ts.map +1 -1
  106. package/dest/storage/private_event_data_provider/private_event_data_provider.js +3 -2
  107. package/dest/storage/sync_data_provider/index.d.ts +1 -1
  108. package/dest/storage/sync_data_provider/sync_data_provider.d.ts +1 -1
  109. package/dest/storage/sync_data_provider/sync_data_provider.d.ts.map +1 -1
  110. package/dest/storage/tagging_data_provider/index.d.ts +1 -1
  111. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts +1 -1
  112. package/dest/storage/tagging_data_provider/tagging_data_provider.d.ts.map +1 -1
  113. package/dest/synchronizer/index.d.ts +1 -1
  114. package/dest/synchronizer/synchronizer.d.ts +1 -1
  115. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  116. package/dest/tagging/constants.d.ts +1 -1
  117. package/dest/tagging/index.d.ts +1 -1
  118. package/dest/tagging/siloed_tag.d.ts +1 -1
  119. package/dest/tagging/siloed_tag.d.ts.map +1 -1
  120. package/dest/tagging/tag.d.ts +1 -1
  121. package/dest/tagging/tag.d.ts.map +1 -1
  122. package/dest/tagging/utils.d.ts +1 -1
  123. package/package.json +20 -19
  124. package/src/config/index.ts +8 -23
  125. package/src/contract_function_simulator/contract_function_simulator.ts +17 -12
  126. package/src/contract_function_simulator/execution_data_provider.ts +1 -11
  127. package/src/contract_function_simulator/execution_note_cache.ts +15 -8
  128. package/src/contract_function_simulator/noir-structs/log_retrieval_response.ts +1 -1
  129. package/src/contract_function_simulator/noir-structs/note_validation_request.ts +10 -1
  130. package/src/contract_function_simulator/oracle/interfaces.ts +11 -1
  131. package/src/contract_function_simulator/oracle/note_packing_utils.ts +5 -3
  132. package/src/contract_function_simulator/oracle/oracle.ts +10 -2
  133. package/src/contract_function_simulator/oracle/private_execution_oracle.ts +9 -1
  134. package/src/contract_function_simulator/pxe_oracle_interface.ts +20 -31
  135. package/src/entrypoints/client/bundle/utils.ts +2 -2
  136. package/src/entrypoints/client/lazy/utils.ts +2 -2
  137. package/src/entrypoints/server/utils.ts +4 -18
  138. package/src/oracle_version.ts +2 -2
  139. package/src/private_kernel/hints/build_private_kernel_reset_private_inputs.ts +4 -8
  140. package/src/private_kernel/private_kernel_execution_prover.ts +7 -12
  141. package/src/pxe.ts +36 -64
  142. package/src/storage/contract_data_provider/contract_data_provider.ts +0 -17
  143. package/src/storage/note_data_provider/index.ts +1 -1
  144. package/src/storage/note_data_provider/note_data_provider.ts +15 -9
  145. package/src/storage/private_event_data_provider/private_event_data_provider.ts +4 -9
  146. package/dest/storage/note_data_provider/note_dao.d.ts +0 -100
  147. package/dest/storage/note_data_provider/note_dao.d.ts.map +0 -1
  148. package/dest/storage/note_data_provider/note_dao.js +0 -102
  149. package/src/storage/note_data_provider/note_dao.ts +0 -154
@@ -1,5 +1,4 @@
1
- import { BBNativePrivateKernelProver } from '@aztec/bb-prover/client/native';
2
- import { BBWASMBundlePrivateKernelProver } from '@aztec/bb-prover/client/wasm/bundle';
1
+ import { BBBundlePrivateKernelProver } from '@aztec/bb-prover/client/bundle';
3
2
  import { randomBytes } from '@aztec/foundation/crypto';
4
3
  import { type Logger, createLogger } from '@aztec/foundation/log';
5
4
  import { BundledProtocolContractsProvider } from '@aztec/protocol-contracts/providers/bundle';
@@ -59,7 +58,7 @@ export async function createPXE(
59
58
  ? loggers.prover
60
59
  : createLogger('pxe:bb:native' + (logSuffix ? `:${logSuffix}` : ''));
61
60
 
62
- const prover = options.prover ?? (await createProver(config, simulator, proverLogger));
61
+ const prover = options.prover ?? createProver(simulator, proverLogger);
63
62
  const protocolContractsProvider = new BundledProtocolContractsProvider();
64
63
 
65
64
  const pxeLogger = loggers.pxe ? loggers.pxe : createLogger('pxe:service' + (logSuffix ? `:${logSuffix}` : ''));
@@ -75,19 +74,6 @@ export async function createPXE(
75
74
  return pxe;
76
75
  }
77
76
 
78
- function createProver(
79
- config: Pick<PXEConfig, 'bbBinaryPath' | 'bbWorkingDirectory'>,
80
- simulator: CircuitSimulator,
81
- logger?: Logger,
82
- ) {
83
- if (!config.bbBinaryPath || !config.bbWorkingDirectory) {
84
- return new BBWASMBundlePrivateKernelProver(simulator, 16, logger);
85
- } else {
86
- const bbConfig = config as Required<Pick<PXEConfig, 'bbBinaryPath' | 'bbWorkingDirectory'>> & PXEConfig;
87
- return BBNativePrivateKernelProver.new(
88
- { bbSkipCleanup: false, numConcurrentIVCVerifiers: 1, bbIVCConcurrency: 1, ...bbConfig },
89
- simulator,
90
- logger,
91
- );
92
- }
77
+ function createProver(simulator: CircuitSimulator, logger?: Logger) {
78
+ return new BBBundlePrivateKernelProver(simulator, logger);
93
79
  }
@@ -4,8 +4,8 @@
4
4
  ///
5
5
  /// @dev Whenever a contract function or Noir test is run, the `utilityAssertCompatibleOracleVersion` oracle is called
6
6
  /// and if the oracle version is incompatible an error is thrown.
7
- export const ORACLE_VERSION = 3;
7
+ export const ORACLE_VERSION = 4;
8
8
 
9
9
  /// This hash is computed as by hashing the Oracle interface and it is used to detect when the Oracle interface changes,
10
10
  /// which in turn implies that you need to update the ORACLE_VERSION constant.
11
- export const ORACLE_INTERFACE_HASH = 'f9168ceb5a2227c148c5021ebffd4e2ca0da99885b87c5be3ee5ac0d8dd3d67c';
11
+ export const ORACLE_INTERFACE_HASH = 'd1496df59c0b51a481d5ef93f218b5c35ddfce6242da28d60bb5c66386940eac';
@@ -24,7 +24,6 @@ import {
24
24
  PrivateKernelResetDimensions,
25
25
  PrivateKernelResetHints,
26
26
  type PrivateKernelSimulateOutput,
27
- type ReadRequest,
28
27
  ReadRequestActionEnum,
29
28
  ReadRequestResetActions,
30
29
  type ScopedKeyValidationRequestAndGenerator,
@@ -47,12 +46,10 @@ import type { PrivateKernelOracle } from '../private_kernel_oracle.js';
47
46
 
48
47
  function collectNestedReadRequests<N extends number>(
49
48
  executionStack: PrivateCallExecutionResult[],
50
- extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<ReadRequest, N>,
49
+ extractReadRequests: (execution: PrivateCallExecutionResult) => ClaimedLengthArray<ScopedReadRequest, N>,
51
50
  ): ScopedReadRequest[] {
52
51
  return collectNested(executionStack, executionResult => {
53
- return extractReadRequests(executionResult)
54
- .getActiveItems()
55
- .map(readRequest => new ScopedReadRequest(readRequest, executionResult.publicInputs.callContext.contractAddress));
52
+ return extractReadRequests(executionResult).getActiveItems();
56
53
  });
57
54
  }
58
55
 
@@ -104,7 +101,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
104
101
  private previousKernelOutput: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>,
105
102
  private executionStack: PrivateCallExecutionResult[],
106
103
  private noteHashNullifierCounterMap: Map<number, number>,
107
- private validationRequestsSplitCounter: number,
104
+ private splitCounter: number,
108
105
  ) {
109
106
  this.previousKernel = previousKernelOutput.publicInputs;
110
107
  this.requestedDimensions = PrivateKernelResetDimensions.empty();
@@ -206,7 +203,6 @@ export class PrivateKernelResetPrivateInputsBuilder {
206
203
  oracle,
207
204
  ),
208
205
  this.transientDataSquashingHints,
209
- this.validationRequestsSplitCounter,
210
206
  ),
211
207
  dimensions,
212
208
  );
@@ -403,7 +399,7 @@ export class PrivateKernelResetPrivateInputsBuilder {
403
399
  futureNoteHashReads,
404
400
  futureNullifierReads,
405
401
  this.noteHashNullifierCounterMap,
406
- this.validationRequestsSplitCounter,
402
+ this.splitCounter,
407
403
  );
408
404
 
409
405
  if (this.nextIteration && !numTransientData) {
@@ -103,9 +103,8 @@ export class PrivateKernelExecutionProver {
103
103
 
104
104
  const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
105
105
  const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
106
- const validationRequestsSplitCounter = isPrivateOnlyTx
107
- ? 0
108
- : getFinalMinRevertibleSideEffectCounter(executionResult);
106
+ const minRevertibleSideEffectCounter = getFinalMinRevertibleSideEffectCounter(executionResult);
107
+ const splitCounter = isPrivateOnlyTx ? 0 : minRevertibleSideEffectCounter;
109
108
 
110
109
  while (executionStack.length) {
111
110
  if (!firstIteration) {
@@ -113,7 +112,7 @@ export class PrivateKernelExecutionProver {
113
112
  output,
114
113
  executionStack,
115
114
  noteHashNullifierCounterMap,
116
- validationRequestsSplitCounter,
115
+ splitCounter,
117
116
  );
118
117
  while (resetBuilder.needsReset()) {
119
118
  const witgenTimer = new Timer();
@@ -134,7 +133,7 @@ export class PrivateKernelExecutionProver {
134
133
  output,
135
134
  executionStack,
136
135
  noteHashNullifierCounterMap,
137
- validationRequestsSplitCounter,
136
+ splitCounter,
138
137
  );
139
138
  }
140
139
  }
@@ -171,6 +170,7 @@ export class PrivateKernelExecutionProver {
171
170
  privateCallData,
172
171
  isPrivateOnlyTx,
173
172
  executionResult.firstNullifier,
173
+ minRevertibleSideEffectCounter,
174
174
  );
175
175
  this.log.debug(
176
176
  `Calling private kernel init with isPrivateOnly ${isPrivateOnlyTx} and firstNullifierHint ${proofInput.firstNullifierHint}`,
@@ -220,7 +220,7 @@ export class PrivateKernelExecutionProver {
220
220
  output,
221
221
  [],
222
222
  noteHashNullifierCounterMap,
223
- validationRequestsSplitCounter,
223
+ splitCounter,
224
224
  );
225
225
  while (resetBuilder.needsReset()) {
226
226
  const witgenTimer = new Timer();
@@ -239,12 +239,7 @@ export class PrivateKernelExecutionProver {
239
239
  },
240
240
  });
241
241
 
242
- resetBuilder = new PrivateKernelResetPrivateInputsBuilder(
243
- output,
244
- [],
245
- noteHashNullifierCounterMap,
246
- validationRequestsSplitCounter,
247
- );
242
+ resetBuilder = new PrivateKernelResetPrivateInputsBuilder(output, [], noteHashNullifierCounterMap, splitCounter);
248
243
  }
249
244
 
250
245
  if (output.publicInputs.feePayer.isZero() && skipFeeEnforcement) {
package/src/pxe.ts CHANGED
@@ -9,16 +9,16 @@ import { type ProtocolContractsProvider, protocolContractNames } from '@aztec/pr
9
9
  import type { CircuitSimulator } from '@aztec/simulator/client';
10
10
  import {
11
11
  type ContractArtifact,
12
- type EventMetadataDefinition,
12
+ EventSelector,
13
13
  FunctionCall,
14
14
  FunctionSelector,
15
15
  FunctionType,
16
- decodeFromAbi,
17
16
  decodeFunctionSignature,
18
17
  encodeArguments,
19
18
  } from '@aztec/stdlib/abi';
20
19
  import type { AuthWitness } from '@aztec/stdlib/auth-witness';
21
20
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
21
+ import type { L2BlockHash } from '@aztec/stdlib/block';
22
22
  import {
23
23
  CompleteAddress,
24
24
  type ContractClassWithId,
@@ -28,14 +28,15 @@ import {
28
28
  getContractClassFromArtifact,
29
29
  } from '@aztec/stdlib/contract';
30
30
  import { SimulationError } from '@aztec/stdlib/errors';
31
- import { siloNullifier } from '@aztec/stdlib/hash';
31
+ import { computeProtocolNullifier, siloNullifier } from '@aztec/stdlib/hash';
32
32
  import type { AztecNode, PrivateKernelProver } from '@aztec/stdlib/interfaces/client';
33
33
  import type {
34
34
  PrivateExecutionStep,
35
35
  PrivateKernelExecutionProofOutput,
36
36
  PrivateKernelTailCircuitPublicInputs,
37
37
  } from '@aztec/stdlib/kernel';
38
- import { type NotesFilter, UniqueNote } from '@aztec/stdlib/note';
38
+ import type { NotesFilter } from '@aztec/stdlib/note';
39
+ import { NoteDao } from '@aztec/stdlib/note';
39
40
  import {
40
41
  type ContractOverrides,
41
42
  PrivateExecutionResult,
@@ -46,6 +47,7 @@ import {
46
47
  type SimulationTimings,
47
48
  Tx,
48
49
  TxExecutionRequest,
50
+ TxHash,
49
51
  TxProfileResult,
50
52
  TxProvingResult,
51
53
  TxSimulationResult,
@@ -73,14 +75,20 @@ import { AddressDataProvider } from './storage/address_data_provider/address_dat
73
75
  import { CapsuleDataProvider } from './storage/capsule_data_provider/capsule_data_provider.js';
74
76
  import { ContractDataProvider } from './storage/contract_data_provider/contract_data_provider.js';
75
77
  import { NoteDataProvider } from './storage/note_data_provider/note_data_provider.js';
76
- import {
77
- type PrivateEvent,
78
- PrivateEventDataProvider,
79
- } from './storage/private_event_data_provider/private_event_data_provider.js';
78
+ import { PrivateEventDataProvider } from './storage/private_event_data_provider/private_event_data_provider.js';
80
79
  import { SyncDataProvider } from './storage/sync_data_provider/sync_data_provider.js';
81
80
  import { TaggingDataProvider } from './storage/tagging_data_provider/tagging_data_provider.js';
82
81
  import { Synchronizer } from './synchronizer/index.js';
83
82
 
83
+ export type PrivateEvent = {
84
+ packedEvent: Fr[];
85
+ blockNumber: number;
86
+ blockHash: L2BlockHash;
87
+ txHash: TxHash;
88
+ recipient: AztecAddress;
89
+ eventSelector: EventSelector;
90
+ };
91
+
84
92
  /**
85
93
  * Private eXecution Environment (PXE) is a library used by wallets to simulate private phase of transactions and to
86
94
  * manage private state of users.
@@ -665,25 +673,12 @@ export class PXE {
665
673
  * @param filter - The filter to apply to the notes.
666
674
  * @returns The requested notes.
667
675
  */
668
- public async getNotes(filter: NotesFilter): Promise<UniqueNote[]> {
676
+ public async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
669
677
  // We need to manually trigger private state sync to have a guarantee that all the notes are available.
670
- await this.simulateUtility('sync_private_state', [], filter.contractAddress);
671
-
672
- const noteDaos = await this.noteDataProvider.getNotes(filter);
678
+ const call = await this.#getFunctionCall('sync_private_state', [], filter.contractAddress);
679
+ await this.simulateUtility(call);
673
680
 
674
- const uniqueNotes = noteDaos.map(async dao => {
675
- const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
676
- const completeAddressIndex = completeAddresses.findIndex(completeAddress =>
677
- completeAddress.address.equals(dao.recipient),
678
- );
679
- const completeAddress = completeAddresses[completeAddressIndex];
680
- if (completeAddress === undefined) {
681
- throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
682
- }
683
- const recipient = completeAddress.address;
684
- return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.noteNonce);
685
- });
686
- return Promise.all(uniqueNotes);
681
+ return this.noteDataProvider.getNotes(filter);
687
682
  }
688
683
 
689
684
  /**
@@ -908,10 +903,9 @@ export class PXE {
908
903
 
909
904
  if (skipKernels) {
910
905
  // According to the protocol rules, the nonce generator for the note hashes
911
- // can either be the first nullifier in the tx or the hash of the initial tx request
912
- // if there are none.
906
+ // can either be the first nullifier in the tx or the protocol nullifier if there are none.
913
907
  const nonceGenerator = privateExecutionResult.firstNullifier.equals(Fr.ZERO)
914
- ? await txRequest.toTxRequest().hash()
908
+ ? await computeProtocolNullifier(await txRequest.toTxRequest().hash())
915
909
  : privateExecutionResult.firstNullifier;
916
910
  ({ publicInputs, executionSteps } = await generateSimulatedProvingResult(
917
911
  privateExecutionResult,
@@ -1003,21 +997,15 @@ export class PXE {
1003
997
  /**
1004
998
  * Simulate the execution of a contract utility function.
1005
999
  *
1006
- * @param functionName - The name of the utility contract function to be called.
1007
- * @param args - The arguments to be provided to the function.
1008
- * @param to - The address of the contract to be called.
1000
+ * @param call - The function call containing the function details, arguments, and target contract address.
1009
1001
  * @param authwits - (Optional) The authentication witnesses required for the function call.
1010
- * @param from - (Optional) The msg sender to set for the call.
1011
1002
  * @param scopes - (Optional) The accounts whose notes we can access in this call. Currently optional and will
1012
1003
  * default to all.
1013
1004
  * @returns The result of the utility function call, structured based on the function ABI.
1014
1005
  */
1015
1006
  public simulateUtility(
1016
- functionName: string,
1017
- args: any[],
1018
- to: AztecAddress,
1007
+ call: FunctionCall,
1019
1008
  authwits?: AuthWitness[],
1020
- _from?: AztecAddress,
1021
1009
  scopes?: AztecAddress[],
1022
1010
  ): Promise<UtilitySimulationResult> {
1023
1011
  // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
@@ -1029,20 +1017,14 @@ export class PXE {
1029
1017
  const syncTimer = new Timer();
1030
1018
  await this.synchronizer.sync();
1031
1019
  const syncTime = syncTimer.ms();
1032
- const functionCall = await this.#getFunctionCall(functionName, args, to);
1033
1020
  const functionTimer = new Timer();
1034
1021
  const contractFunctionSimulator = this.#getSimulatorForTx();
1035
- const executionResult = await this.#simulateUtility(
1036
- contractFunctionSimulator,
1037
- functionCall,
1038
- authwits ?? [],
1039
- scopes,
1040
- );
1022
+ const executionResult = await this.#simulateUtility(contractFunctionSimulator, call, authwits ?? [], scopes);
1041
1023
  const functionTime = functionTimer.ms();
1042
1024
 
1043
1025
  const totalTime = totalTimer.ms();
1044
1026
 
1045
- const perFunction = [{ functionName, time: functionTime }];
1027
+ const perFunction = [{ functionName: call.name, time: functionTime }];
1046
1028
 
1047
1029
  const timings: SimulationTimings = {
1048
1030
  total: totalTime,
@@ -1054,10 +1036,11 @@ export class PXE {
1054
1036
  const simulationStats = contractFunctionSimulator.getStats();
1055
1037
  return { result: executionResult, stats: { timings, nodeRPCCalls: simulationStats.nodeRPCCalls } };
1056
1038
  } catch (err: any) {
1039
+ const { to, name, args } = call;
1057
1040
  const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
1058
1041
  throw this.#contextualizeError(
1059
1042
  err,
1060
- `simulateUtility ${to}:${functionName}(${stringifiedArgs})`,
1043
+ `simulateUtility ${to}:${name}(${stringifiedArgs})`,
1061
1044
  `scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
1062
1045
  );
1063
1046
  }
@@ -1067,19 +1050,19 @@ export class PXE {
1067
1050
  /**
1068
1051
  * Returns the private events given search parameters.
1069
1052
  * @param contractAddress - The address of the contract to get events from.
1070
- * @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
1053
+ * @param eventSelector - Event selector to search for.
1071
1054
  * @param from - The block number to search from.
1072
1055
  * @param numBlocks - The amount of blocks to search.
1073
1056
  * @param recipients - The addresses that decrypted the logs.
1074
- * @returns - The deserialized events.
1057
+ * @returns - The packed events with block and tx metadata.
1075
1058
  */
1076
- public async getPrivateEvents<T>(
1059
+ public async getPrivateEvents(
1077
1060
  contractAddress: AztecAddress,
1078
- eventMetadataDef: EventMetadataDefinition,
1061
+ eventSelector: EventSelector,
1079
1062
  from: number,
1080
1063
  numBlocks: number,
1081
1064
  recipients: AztecAddress[],
1082
- ): Promise<T[]> {
1065
+ ): Promise<PrivateEvent[]> {
1083
1066
  if (recipients.length === 0) {
1084
1067
  throw new Error('Recipients are required to get private events');
1085
1068
  }
@@ -1087,21 +1070,10 @@ export class PXE {
1087
1070
  this.log.verbose(`Getting private events for ${contractAddress.toString()} from ${from} to ${from + numBlocks}`);
1088
1071
 
1089
1072
  // We need to manually trigger private state sync to have a guarantee that all the events are available.
1090
- await this.simulateUtility('sync_private_state', [], contractAddress);
1091
-
1092
- const events = await this.privateEventDataProvider.getPrivateEvents(
1093
- contractAddress,
1094
- from,
1095
- numBlocks,
1096
- recipients,
1097
- eventMetadataDef.eventSelector,
1098
- );
1099
-
1100
- const decodedEvents = events.map(
1101
- (event: PrivateEvent): T => decodeFromAbi([eventMetadataDef.abiType], event.msgContent) as T,
1102
- );
1073
+ const call = await this.#getFunctionCall('sync_private_state', [], contractAddress);
1074
+ await this.simulateUtility(call);
1103
1075
 
1104
- return decodedEvents;
1076
+ return this.privateEventDataProvider.getPrivateEvents(contractAddress, from, numBlocks, recipients, eventSelector);
1105
1077
  }
1106
1078
 
1107
1079
  /**
@@ -184,23 +184,6 @@ export class ContractDataProvider {
184
184
  return fnArtifact && { ...fnArtifact, contractName: artifact.name };
185
185
  }
186
186
 
187
- /**
188
- * Retrieves the artifact of a specified function within a given contract.
189
- * The function is identified by its name, which is unique within a contract.
190
- * Throws if the contract has not been added to the database.
191
- *
192
- * @param contractAddress - The AztecAddress representing the contract containing the function.
193
- * @param functionName - The name of the function.
194
- * @returns The corresponding function's artifact as an object
195
- */
196
- public async getFunctionArtifactByName(
197
- contractAddress: AztecAddress,
198
- functionName: string,
199
- ): Promise<FunctionArtifact | undefined> {
200
- const artifact = await this.#getContractArtifactByAddress(contractAddress);
201
- return artifact?.functions.find(fn => fn.name === functionName);
202
- }
203
-
204
187
  public async getFunctionAbi(
205
188
  contractAddress: AztecAddress,
206
189
  selector: FunctionSelector,
@@ -1,2 +1,2 @@
1
- export { NoteDao } from './note_dao.js';
1
+ export { NoteDao } from '@aztec/stdlib/note';
2
2
  export { NoteDataProvider } from './note_data_provider.js';
@@ -5,8 +5,7 @@ import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncMultiMap } from '@azte
5
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
6
  import type { InBlock } from '@aztec/stdlib/block';
7
7
  import { NoteStatus, type NotesFilter } from '@aztec/stdlib/note';
8
-
9
- import { NoteDao } from './note_dao.js';
8
+ import { NoteDao } from '@aztec/stdlib/note';
10
9
 
11
10
  /**
12
11
  * NoteDataProvider manages the storage and retrieval of notes.
@@ -194,10 +193,12 @@ export class NoteDataProvider {
194
193
  await this.#notes.set(noteIndex, dao.toBuffer());
195
194
  await this.#nullifierToNoteId.set(dao.siloedNullifier.toString(), noteIndex);
196
195
 
197
- let scopes = (await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex))) ?? [];
196
+ const scopes = await toArray(this.#nullifiedNotesToScope.getValuesAsync(noteIndex));
198
197
 
199
198
  if (scopes.length === 0) {
200
- scopes = [dao.recipient.toString()];
199
+ // We should never run into this error because notes always have a scope assigned to them - either on initial
200
+ // insertion via `addNotes` or when removing their nullifiers.
201
+ throw new Error(`No scopes found for nullified note with index ${noteIndex}`);
201
202
  }
202
203
 
203
204
  for (const scope of scopes) {
@@ -359,7 +360,14 @@ export class NoteDataProvider {
359
360
  if (!noteBuffer) {
360
361
  throw new Error('Note not found in applyNullifiers');
361
362
  }
362
- const noteScopes = (await toArray(this.#notesToScope.getValuesAsync(noteIndex))) ?? [];
363
+
364
+ const noteScopes = await toArray(this.#notesToScope.getValuesAsync(noteIndex));
365
+ if (noteScopes.length === 0) {
366
+ // We should never run into this error because notes always have a scope assigned to them - either on initial
367
+ // insertion via `addNotes` or when removing their nullifiers.
368
+ throw new Error('Note scopes are missing in applyNullifiers');
369
+ }
370
+
363
371
  const note = NoteDao.fromBuffer(noteBuffer);
364
372
 
365
373
  nullifiedNotes.push(note);
@@ -374,10 +382,8 @@ export class NoteDataProvider {
374
382
  await this.#notesByStorageSlotAndScope.get(scope)!.deleteValue(note.storageSlot.toString(), noteIndex);
375
383
  }
376
384
 
377
- if (noteScopes !== undefined) {
378
- for (const scope of noteScopes) {
379
- await this.#nullifiedNotesToScope.set(noteIndex, scope);
380
- }
385
+ for (const scope of noteScopes) {
386
+ await this.#nullifiedNotesToScope.set(noteIndex, scope);
381
387
  }
382
388
  await this.#nullifiedNotes.set(noteIndex, note.toBuffer());
383
389
  await this.#nullifiersByBlockNumber.set(blockNumber, nullifier.toString());
@@ -7,6 +7,8 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
7
7
  import { L2BlockHash } from '@aztec/stdlib/block';
8
8
  import { TxHash } from '@aztec/stdlib/tx';
9
9
 
10
+ import type { PrivateEvent } from '../../pxe.js';
11
+
10
12
  interface PrivateEventEntry {
11
13
  msgContent: Buffer;
12
14
  blockNumber: number;
@@ -15,14 +17,6 @@ interface PrivateEventEntry {
15
17
  txHash: Buffer;
16
18
  }
17
19
 
18
- export type PrivateEvent = {
19
- msgContent: Fr[];
20
- blockNumber: number;
21
- blockHash: L2BlockHash;
22
- txHash: TxHash;
23
- recipient: AztecAddress;
24
- };
25
-
26
20
  /**
27
21
  * Stores decrypted private event logs.
28
22
  */
@@ -131,11 +125,12 @@ export class PrivateEventDataProvider {
131
125
  events.push({
132
126
  eventCommitmentIndex: entry.eventCommitmentIndex,
133
127
  event: {
134
- msgContent,
128
+ packedEvent: msgContent,
135
129
  blockNumber: entry.blockNumber,
136
130
  recipient,
137
131
  txHash,
138
132
  blockHash,
133
+ eventSelector,
139
134
  },
140
135
  });
141
136
  }
@@ -1,100 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { Note } from '@aztec/stdlib/note';
5
- import { TxHash } from '@aztec/stdlib/tx';
6
- import type { NoteData } from '../../contract_function_simulator/oracle/interfaces.js';
7
- /**
8
- * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
9
- * information required to use it during execution and manage its state.
10
- */
11
- export declare class NoteDao implements NoteData {
12
- /** The packed content of the note, as will be returned in the getNotes oracle. */
13
- note: Note;
14
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
15
- contractAddress: AztecAddress;
16
- /**
17
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
18
- * since contracts typically make queries based on it.
19
- */
20
- storageSlot: Fr;
21
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
22
- noteNonce: Fr;
23
- /**
24
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
25
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
26
- */
27
- noteHash: Fr;
28
- /**
29
- * The nullifier of the note, siloed by contract address.
30
- * Note: Might be set as 0 if the note was added to PXE as nullified.
31
- */
32
- siloedNullifier: Fr;
33
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
34
- * when searching for txEffects.
35
- */
36
- txHash: TxHash;
37
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
38
- * reorgs.*/
39
- l2BlockNumber: number;
40
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
41
- * reorgs.*/
42
- l2BlockHash: string;
43
- /** The index of the leaf in the global note hash tree the note is stored at */
44
- index: bigint;
45
- /**
46
- * The address whose public key was used to encrypt the note log during delivery.
47
- * (This is the x-coordinate of the public key.)
48
- */
49
- recipient: AztecAddress;
50
- constructor(
51
- /** The packed content of the note, as will be returned in the getNotes oracle. */
52
- note: Note,
53
- /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
54
- contractAddress: AztecAddress,
55
- /**
56
- * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
57
- * since contracts typically make queries based on it.
58
- */
59
- storageSlot: Fr,
60
- /** The nonce that was injected into the note hash preimage in order to guarantee uniqueness. */
61
- noteNonce: Fr,
62
- /**
63
- * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note is hashed. Can
64
- * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
65
- */
66
- noteHash: Fr,
67
- /**
68
- * The nullifier of the note, siloed by contract address.
69
- * Note: Might be set as 0 if the note was added to PXE as nullified.
70
- */
71
- siloedNullifier: Fr,
72
- /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
73
- * when searching for txEffects.
74
- */
75
- txHash: TxHash,
76
- /** The L2 block number in which the tx with this note was included. Used for note management while processing
77
- * reorgs.*/
78
- l2BlockNumber: number,
79
- /** The L2 block hash in which the tx with this note was included. Used for note management while processing
80
- * reorgs.*/
81
- l2BlockHash: string,
82
- /** The index of the leaf in the global note hash tree the note is stored at */
83
- index: bigint,
84
- /**
85
- * The address whose public key was used to encrypt the note log during delivery.
86
- * (This is the x-coordinate of the public key.)
87
- */
88
- recipient: AztecAddress);
89
- toBuffer(): Buffer;
90
- static fromBuffer(buffer: Buffer | BufferReader): NoteDao;
91
- toString(): string;
92
- static fromString(str: string): NoteDao;
93
- /**
94
- * Returns the size in bytes of the Note Dao.
95
- * @returns - Its size in bytes.
96
- */
97
- getSize(): number;
98
- static random({ note, contractAddress, storageSlot, noteNonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient, }?: Partial<NoteDao>): Promise<NoteDao>;
99
- }
100
- //# sourceMappingURL=note_dao.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"note_dao.d.ts","sourceRoot":"","sources":["../../../src/storage/note_data_provider/note_dao.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAS,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,YAAY,EAAqB,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wDAAwD,CAAC;AAEvF;;;GAGG;AACH,qBAAa,OAAQ,YAAW,QAAQ;IAIpC,kFAAkF;IAC3E,IAAI,EAAE,IAAI;IACjB,8GAA8G;IACvG,eAAe,EAAE,YAAY;IACpC;;;OAGG;IACI,WAAW,EAAE,EAAE;IACtB,gGAAgG;IACzF,SAAS,EAAE,EAAE;IAGpB;;;OAGG;IACI,QAAQ,EAAE,EAAE;IACnB;;;OAGG;IACI,eAAe,EAAE,EAAE;IAG1B;;OAEG;IACI,MAAM,EAAE,MAAM;IACrB;gBACY;IACL,aAAa,EAAE,MAAM;IAC5B;gBACY;IACL,WAAW,EAAE,MAAM;IAC1B,+EAA+E;IACxE,KAAK,EAAE,MAAM;IACpB;;;OAGG;IACI,SAAS,EAAE,YAAY;;IAzC9B,kFAAkF;IAC3E,IAAI,EAAE,IAAI;IACjB,8GAA8G;IACvG,eAAe,EAAE,YAAY;IACpC;;;OAGG;IACI,WAAW,EAAE,EAAE;IACtB,gGAAgG;IACzF,SAAS,EAAE,EAAE;IAGpB;;;OAGG;IACI,QAAQ,EAAE,EAAE;IACnB;;;OAGG;IACI,eAAe,EAAE,EAAE;IAG1B;;OAEG;IACI,MAAM,EAAE,MAAM;IACrB;gBACY;IACL,aAAa,EAAE,MAAM;IAC5B;gBACY;IACL,WAAW,EAAE,MAAM;IAC1B,+EAA+E;IACxE,KAAK,EAAE,MAAM;IACpB;;;OAGG;IACI,SAAS,EAAE,YAAY;IAGhC,QAAQ,IAAI,MAAM;IAgBlB,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IA8B/C,QAAQ;IAIR,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM;IAK7B;;;OAGG;IACI,OAAO;WAMD,MAAM,CAAC,EAClB,IAAoB,EACpB,eAA2B,EAC3B,WAAyB,EACzB,SAAuB,EACvB,QAAsB,EACtB,eAA6B,EAC7B,MAAwB,EACxB,aAAgD,EAChD,WAAoC,EACpC,KAA8B,EAC9B,SAAqB,GACtB,GAAE,OAAO,CAAC,OAAO,CAAM;CAezB"}