@aztec/pxe 0.79.0 → 0.81.0

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 (26) hide show
  1. package/dest/config/index.d.ts.map +1 -1
  2. package/dest/config/index.js +2 -1
  3. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -6
  4. package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
  5. package/dest/pxe_oracle_interface/pxe_oracle_interface.js +44 -80
  6. package/dest/pxe_service/pxe_service.d.ts +1 -0
  7. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  8. package/dest/pxe_service/pxe_service.js +135 -100
  9. package/dest/storage/note_data_provider/note_dao.d.ts +9 -13
  10. package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
  11. package/dest/storage/note_data_provider/note_dao.js +11 -15
  12. package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
  13. package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
  14. package/dest/storage/note_data_provider/note_data_provider.js +18 -19
  15. package/dest/synchronizer/synchronizer.js +1 -1
  16. package/package.json +15 -15
  17. package/src/config/index.ts +1 -0
  18. package/src/pxe_oracle_interface/pxe_oracle_interface.ts +55 -117
  19. package/src/pxe_service/pxe_service.ts +180 -134
  20. package/src/storage/note_data_provider/note_dao.ts +9 -18
  21. package/src/storage/note_data_provider/note_data_provider.ts +22 -28
  22. package/src/synchronizer/synchronizer.ts +1 -1
  23. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
  24. package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
  25. package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
  26. package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
@@ -1,5 +1,6 @@
1
1
  import { Fr } from '@aztec/foundation/fields';
2
2
  import { createLogger } from '@aztec/foundation/log';
3
+ import { SerialQueue } from '@aztec/foundation/queue';
3
4
  import { Timer } from '@aztec/foundation/timer';
4
5
  import { KeyStore } from '@aztec/key-store';
5
6
  import { L2TipsStore } from '@aztec/kv-store/stores';
@@ -48,7 +49,8 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
48
49
  proofCreator;
49
50
  protocolContractsProvider;
50
51
  log;
51
- constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log){
52
+ jobQueue;
53
+ constructor(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue){
52
54
  this.node = node;
53
55
  this.synchronizer = synchronizer;
54
56
  this.keyStore = keyStore;
@@ -65,6 +67,7 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
65
67
  this.proofCreator = proofCreator;
66
68
  this.protocolContractsProvider = protocolContractsProvider;
67
69
  this.log = log;
70
+ this.jobQueue = jobQueue;
68
71
  }
69
72
  /**
70
73
  * Creates an instance of a PXE Service by instantiating all the necessary data providers and services.
@@ -88,12 +91,26 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
88
91
  const synchronizer = new Synchronizer(node, syncDataProvider, noteDataProvider, taggingDataProvider, tipsStore, config, loggerOrSuffix);
89
92
  const pxeOracleInterface = new PXEOracleInterface(node, keyStore, simulationProvider, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, log);
90
93
  const simulator = new AcirSimulator(pxeOracleInterface, simulationProvider);
91
- const pxeService = new PXEService(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log);
94
+ const jobQueue = new SerialQueue();
95
+ const pxeService = new PXEService(node, synchronizer, keyStore, contractDataProvider, noteDataProvider, capsuleDataProvider, syncDataProvider, taggingDataProvider, addressDataProvider, authWitnessDataProvider, simulator, packageVersion, proverEnabled, proofCreator, protocolContractsProvider, log, jobQueue);
96
+ pxeService.jobQueue.start();
92
97
  await pxeService.#registerProtocolContracts();
93
98
  const info = await pxeService.getNodeInfo();
94
99
  log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
95
100
  return pxeService;
96
101
  }
102
+ /**
103
+ * Enqueues a job for execution once no other jobs are running. Returns a promise that will resolve once the job is
104
+ * complete.
105
+ *
106
+ * Useful for tasks that cannot run concurrently, such as contract function simulation.
107
+ */ #putInJobQueue(fn) {
108
+ // TODO(#12636): relax the conditions under which we forbid concurrency.
109
+ if (this.jobQueue.length() != 0) {
110
+ this.log.warn(`PXE is already processing ${this.jobQueue.length()} jobs, concurrent execution is not supported. Will run once those are complete.`);
111
+ }
112
+ return this.jobQueue.put(fn);
113
+ }
97
114
  isL1ToL2MessageSynced(l1ToL2Message) {
98
115
  return this.node.isL1ToL2MessageSynced(l1ToL2Message);
99
116
  }
@@ -234,27 +251,31 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
234
251
  await this.contractDataProvider.addContractInstance(instance);
235
252
  this.log.info(`Added contract ${artifact.name} at ${instance.address.toString()} with class ${instance.currentContractClassId}`);
236
253
  }
237
- async updateContract(contractAddress, artifact) {
238
- const currentInstance = await this.contractDataProvider.getContractInstance(contractAddress);
239
- const contractClass = await getContractClassFromArtifact(artifact);
240
- await this.synchronizer.sync();
241
- const header = await this.syncDataProvider.getBlockHeader();
242
- const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header.globalVariables.blockNumber.toNumber());
243
- if (!contractClass.id.equals(currentClassId)) {
244
- throw new Error('Could not update contract to a class different from the current one.');
245
- }
246
- await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
247
- const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
248
- await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
249
- // TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
250
- await this.node.addContractClass({
251
- ...contractClass,
252
- privateFunctions: [],
253
- unconstrainedFunctions: []
254
+ updateContract(contractAddress, artifact) {
255
+ // We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
256
+ // class while we're simulating it.
257
+ return this.#putInJobQueue(async ()=>{
258
+ const currentInstance = await this.contractDataProvider.getContractInstance(contractAddress);
259
+ const contractClass = await getContractClassFromArtifact(artifact);
260
+ await this.synchronizer.sync();
261
+ const header = await this.syncDataProvider.getBlockHeader();
262
+ const currentClassId = await readCurrentClassId(contractAddress, currentInstance, this.node, header.globalVariables.blockNumber.toNumber());
263
+ if (!contractClass.id.equals(currentClassId)) {
264
+ throw new Error('Could not update contract to a class different from the current one.');
265
+ }
266
+ await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
267
+ const publicFunctionSignatures = artifact.functions.filter((fn)=>fn.functionType === FunctionType.PUBLIC).map((fn)=>decodeFunctionSignature(fn.name, fn.parameters));
268
+ await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
269
+ // TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
270
+ await this.node.addContractClass({
271
+ ...contractClass,
272
+ privateFunctions: [],
273
+ unconstrainedFunctions: []
274
+ });
275
+ currentInstance.currentContractClassId = contractClass.id;
276
+ await this.contractDataProvider.addContractInstance(currentInstance);
277
+ this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
254
278
  });
255
- currentInstance.currentContractClassId = contractClass.id;
256
- await this.contractDataProvider.addContractInstance(currentInstance);
257
- this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
258
279
  }
259
280
  getContracts() {
260
281
  return this.contractDataProvider.getContractsAddresses();
@@ -265,17 +286,17 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
265
286
  async getNotes(filter) {
266
287
  const noteDaos = await this.noteDataProvider.getNotes(filter);
267
288
  const extendedNotes = noteDaos.map(async (dao)=>{
268
- let owner = filter.owner;
269
- if (owner === undefined) {
289
+ let recipient = filter.recipient;
290
+ if (recipient === undefined) {
270
291
  const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
271
- const completeAddressIndex = (await Promise.all(completeAddresses.map((completeAddresses)=>completeAddresses.address.toAddressPoint()))).findIndex((addressPoint)=>addressPoint.equals(dao.addressPoint));
292
+ const completeAddressIndex = completeAddresses.findIndex((completeAddress)=>completeAddress.address.equals(dao.recipient));
272
293
  const completeAddress = completeAddresses[completeAddressIndex];
273
294
  if (completeAddress === undefined) {
274
- throw new Error(`Cannot find complete address for addressPoint ${dao.addressPoint.toString()}`);
295
+ throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
275
296
  }
276
- owner = completeAddress.address;
297
+ recipient = completeAddress.address;
277
298
  }
278
- return new UniqueNote(dao.note, owner, dao.contractAddress, dao.storageSlot, dao.noteTypeId, dao.txHash, dao.nonce);
299
+ return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.nonce);
279
300
  });
280
301
  return Promise.all(extendedNotes);
281
302
  }
@@ -295,71 +316,80 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
295
316
  async getCurrentBaseFees() {
296
317
  return await this.node.getCurrentBaseFees();
297
318
  }
298
- async proveTx(txRequest, privateExecutionResult) {
299
- try {
300
- const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
301
- simulate: false,
302
- skipFeeEnforcement: false,
303
- profile: false
304
- });
305
- return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof);
306
- } catch (err) {
307
- throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
308
- }
319
+ proveTx(txRequest, privateExecutionResult) {
320
+ // We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
321
+ // computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
322
+ return this.#putInJobQueue(async ()=>{
323
+ try {
324
+ const { publicInputs, clientIvcProof } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
325
+ simulate: false,
326
+ skipFeeEnforcement: false,
327
+ profile: false
328
+ });
329
+ return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof);
330
+ } catch (err) {
331
+ throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
332
+ }
333
+ });
309
334
  }
310
335
  // TODO(#7456) Prevent msgSender being defined here for the first call
311
- async simulateTx(txRequest, simulatePublic, msgSender = undefined, skipTxValidation = false, skipFeeEnforcement = false, profile = false, scopes) {
312
- try {
313
- const txInfo = {
314
- origin: txRequest.origin,
315
- functionSelector: txRequest.functionSelector,
316
- simulatePublic,
317
- msgSender,
318
- chainId: txRequest.txContext.chainId,
319
- version: txRequest.txContext.version,
320
- authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
321
- };
322
- this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
323
- const timer = new Timer();
324
- await this.synchronizer.sync();
325
- const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
326
- const { publicInputs, profileResult } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
327
- simulate: !profile,
328
- skipFeeEnforcement,
329
- profile
330
- });
331
- const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
332
- const simulatedTx = privateSimulationResult.toSimulatedTx();
333
- let publicOutput;
334
- if (simulatePublic && publicInputs.forPublic) {
335
- publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
336
- }
337
- if (!skipTxValidation) {
338
- const validationResult = await this.node.isValidTx(simulatedTx, {
339
- isSimulation: true,
340
- skipFeeEnforcement
336
+ simulateTx(txRequest, simulatePublic, msgSender = undefined, skipTxValidation = false, skipFeeEnforcement = false, profile = false, scopes) {
337
+ // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
338
+ // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
339
+ // delete the same read value, or reading values that another simulation is currently modifying).
340
+ return this.#putInJobQueue(async ()=>{
341
+ try {
342
+ const txInfo = {
343
+ origin: txRequest.origin,
344
+ functionSelector: txRequest.functionSelector,
345
+ simulatePublic,
346
+ msgSender,
347
+ chainId: txRequest.txContext.chainId,
348
+ version: txRequest.txContext.version,
349
+ authWitnesses: txRequest.authWitnesses.map((w)=>w.requestHash)
350
+ };
351
+ this.log.info(`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`, txInfo);
352
+ const timer = new Timer();
353
+ await this.synchronizer.sync();
354
+ const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
355
+ const { publicInputs, profileResult } = await this.#prove(txRequest, this.proofCreator, privateExecutionResult, {
356
+ simulate: !profile,
357
+ skipFeeEnforcement,
358
+ profile
341
359
  });
342
- if (validationResult.result === 'invalid') {
343
- throw new Error('The simulated transaction is unable to be added to state and is invalid.');
360
+ const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
361
+ const simulatedTx = privateSimulationResult.toSimulatedTx();
362
+ let publicOutput;
363
+ if (simulatePublic && publicInputs.forPublic) {
364
+ publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
365
+ }
366
+ if (!skipTxValidation) {
367
+ const validationResult = await this.node.isValidTx(simulatedTx, {
368
+ isSimulation: true,
369
+ skipFeeEnforcement
370
+ });
371
+ if (validationResult.result === 'invalid') {
372
+ throw new Error('The simulated transaction is unable to be added to state and is invalid.');
373
+ }
344
374
  }
375
+ const txHash = await simulatedTx.getTxHash();
376
+ this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
377
+ txHash,
378
+ ...txInfo,
379
+ ...profileResult ? {
380
+ gateCounts: profileResult.gateCounts
381
+ } : {},
382
+ ...publicOutput ? {
383
+ gasUsed: publicOutput.gasUsed,
384
+ revertCode: publicOutput.txEffect.revertCode.getCode(),
385
+ revertReason: publicOutput.revertReason
386
+ } : {}
387
+ });
388
+ return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, profileResult);
389
+ } catch (err) {
390
+ throw this.contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`, `skipTxValidation=${skipTxValidation}`, `profile=${profile}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
345
391
  }
346
- const txHash = await simulatedTx.getTxHash();
347
- this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
348
- txHash,
349
- ...txInfo,
350
- ...profileResult ? {
351
- gateCounts: profileResult.gateCounts
352
- } : {},
353
- ...publicOutput ? {
354
- gasUsed: publicOutput.gasUsed,
355
- revertCode: publicOutput.txEffect.revertCode.getCode(),
356
- revertReason: publicOutput.revertReason
357
- } : {}
358
- });
359
- return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(privateSimulationResult, publicOutput, profileResult);
360
- } catch (err) {
361
- throw this.contextualizeError(err, inspect(txRequest), `simulatePublic=${simulatePublic}`, `msgSender=${msgSender?.toString() ?? 'undefined'}`, `skipTxValidation=${skipTxValidation}`, `profile=${profile}`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
362
- }
392
+ });
363
393
  }
364
394
  async sendTx(tx) {
365
395
  const txHash = await tx.getTxHash();
@@ -373,18 +403,23 @@ import { enrichPublicSimulationError, enrichSimulationError } from './error_enri
373
403
  this.log.info(`Sent transaction ${txHash}`);
374
404
  return txHash;
375
405
  }
376
- async simulateUnconstrained(functionName, args, to, _from, scopes) {
377
- try {
378
- await this.synchronizer.sync();
379
- // TODO - Should check if `from` has the permission to call the view function.
380
- const functionCall = await this.#getFunctionCall(functionName, args, to);
381
- const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
382
- // TODO - Return typed result based on the function artifact.
383
- return executionResult;
384
- } catch (err) {
385
- const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
386
- throw this.contextualizeError(err, `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
387
- }
406
+ simulateUnconstrained(functionName, args, to, _from, scopes) {
407
+ // We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
408
+ // to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
409
+ // delete the same read value, or reading values that another simulation is currently modifying).
410
+ return this.#putInJobQueue(async ()=>{
411
+ try {
412
+ await this.synchronizer.sync();
413
+ // TODO - Should check if `from` has the permission to call the view function.
414
+ const functionCall = await this.#getFunctionCall(functionName, args, to);
415
+ const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
416
+ // TODO - Return typed result based on the function artifact.
417
+ return executionResult;
418
+ } catch (err) {
419
+ const stringifiedArgs = args.map((arg)=>arg.toString()).join(', ');
420
+ throw this.contextualizeError(err, `simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`, `scopes=${scopes?.map((s)=>s.toString()).join(', ') ?? 'undefined'}`);
421
+ }
422
+ });
388
423
  }
389
424
  getTxReceipt(txHash) {
390
425
  return this.node.getTxReceipt(txHash);
@@ -3,9 +3,7 @@
3
3
  import { Fr } from '@aztec/foundation/fields';
4
4
  import { BufferReader } from '@aztec/foundation/serialize';
5
5
  import type { NoteData } from '@aztec/simulator/client';
6
- import { NoteSelector } from '@aztec/stdlib/abi';
7
6
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
8
- import type { PublicKey } from '@aztec/stdlib/keys';
9
7
  import { Note } from '@aztec/stdlib/note';
10
8
  import { TxHash } from '@aztec/stdlib/tx';
11
9
  /**
@@ -46,12 +44,11 @@ export declare class NoteDao implements NoteData {
46
44
  l2BlockHash: string;
47
45
  /** The index of the leaf in the global note hash tree the note is stored at */
48
46
  index: bigint;
49
- /** The public key with which the note log was encrypted during delivery. */
50
- addressPoint: PublicKey;
51
- /** The note type identifier for the contract.
52
- * TODO(#12013): remove
47
+ /**
48
+ * The address whose public key was used to encrypt the note log during delivery.
49
+ * (This is the x-coordinate of the public key.)
53
50
  */
54
- noteTypeId: NoteSelector;
51
+ recipient: AztecAddress;
55
52
  constructor(
56
53
  /** The packed content of the note, as will be returned in the getNotes oracle. */
57
54
  note: Note,
@@ -86,12 +83,11 @@ export declare class NoteDao implements NoteData {
86
83
  l2BlockHash: string,
87
84
  /** The index of the leaf in the global note hash tree the note is stored at */
88
85
  index: bigint,
89
- /** The public key with which the note log was encrypted during delivery. */
90
- addressPoint: PublicKey,
91
- /** The note type identifier for the contract.
92
- * TODO(#12013): remove
86
+ /**
87
+ * The address whose public key was used to encrypt the note log during delivery.
88
+ * (This is the x-coordinate of the public key.)
93
89
  */
94
- noteTypeId: NoteSelector);
90
+ recipient: AztecAddress);
95
91
  toBuffer(): Buffer;
96
92
  static fromBuffer(buffer: Buffer | BufferReader): NoteDao;
97
93
  toString(): string;
@@ -101,6 +97,6 @@ export declare class NoteDao implements NoteData {
101
97
  * @returns - Its size in bytes.
102
98
  */
103
99
  getSize(): number;
104
- static random({ note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, addressPoint, noteTypeId, }?: Partial<NoteDao>): Promise<NoteDao>;
100
+ static random({ note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient, }?: Partial<NoteDao>): Promise<NoteDao>;
105
101
  }
106
102
  //# sourceMappingURL=note_dao.d.ts.map
@@ -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,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AAa,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;;;SAGK;IACE,WAAW,EAAE,EAAE;IACtB,qFAAqF;IAC9E,KAAK,EAAE,EAAE;IAGhB;;;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,KAAmB,EACnB,QAAsB,EACtB,eAA6B,EAC7B,MAAwB,EACxB,aAAgD,EAChD,WAAoC,EACpC,KAA8B,EAC9B,SAAqB,GACtB,GAAE,OAAO,CAAC,OAAO,CAAM;CAezB"}
@@ -1,7 +1,6 @@
1
1
  import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
2
  import { Fr, Point } from '@aztec/foundation/fields';
3
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
- import { NoteSelector } from '@aztec/stdlib/abi';
5
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
5
  import { Note } from '@aztec/stdlib/note';
7
6
  import { TxHash } from '@aztec/stdlib/tx';
@@ -19,8 +18,7 @@ import { TxHash } from '@aztec/stdlib/tx';
19
18
  l2BlockNumber;
20
19
  l2BlockHash;
21
20
  index;
22
- addressPoint;
23
- noteTypeId;
21
+ recipient;
24
22
  constructor(// Note information
25
23
  /** The packed content of the note, as will be returned in the getNotes oracle. */ note, /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */ contractAddress, /**
26
24
  * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
@@ -37,9 +35,10 @@ import { TxHash } from '@aztec/stdlib/tx';
37
35
  * when searching for txEffects.
38
36
  */ txHash, /** The L2 block number in which the tx with this note was included. Used for note management while processing
39
37
  * reorgs.*/ l2BlockNumber, /** The L2 block hash in which the tx with this note was included. Used for note management while processing
40
- * reorgs.*/ l2BlockHash, /** The index of the leaf in the global note hash tree the note is stored at */ index, /** The public key with which the note log was encrypted during delivery. */ addressPoint, /** The note type identifier for the contract.
41
- * TODO(#12013): remove
42
- */ noteTypeId){
38
+ * reorgs.*/ l2BlockHash, /** The index of the leaf in the global note hash tree the note is stored at */ index, /**
39
+ * The address whose public key was used to encrypt the note log during delivery.
40
+ * (This is the x-coordinate of the public key.)
41
+ */ recipient){
43
42
  this.note = note;
44
43
  this.contractAddress = contractAddress;
45
44
  this.storageSlot = storageSlot;
@@ -50,8 +49,7 @@ import { TxHash } from '@aztec/stdlib/tx';
50
49
  this.l2BlockNumber = l2BlockNumber;
51
50
  this.l2BlockHash = l2BlockHash;
52
51
  this.index = index;
53
- this.addressPoint = addressPoint;
54
- this.noteTypeId = noteTypeId;
52
+ this.recipient = recipient;
55
53
  }
56
54
  toBuffer() {
57
55
  return serializeToBuffer([
@@ -65,8 +63,7 @@ import { TxHash } from '@aztec/stdlib/tx';
65
63
  this.l2BlockNumber,
66
64
  Fr.fromHexString(this.l2BlockHash),
67
65
  this.index,
68
- this.addressPoint,
69
- this.noteTypeId
66
+ this.recipient
70
67
  ]);
71
68
  }
72
69
  static fromBuffer(buffer) {
@@ -81,9 +78,8 @@ import { TxHash } from '@aztec/stdlib/tx';
81
78
  const l2BlockNumber = reader.readNumber();
82
79
  const l2BlockHash = Fr.fromBuffer(reader).toString();
83
80
  const index = toBigIntBE(reader.readBytes(32));
84
- const publicKey = Point.fromBuffer(reader);
85
- const noteTypeId = reader.readObject(NoteSelector);
86
- return new NoteDao(note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, publicKey, noteTypeId);
81
+ const recipient = AztecAddress.fromBuffer(reader);
82
+ return new NoteDao(note, contractAddress, storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient);
87
83
  }
88
84
  toString() {
89
85
  return '0x' + this.toBuffer().toString('hex');
@@ -100,7 +96,7 @@ import { TxHash } from '@aztec/stdlib/tx';
100
96
  const noteSize = 4 + this.note.items.length * Fr.SIZE_IN_BYTES;
101
97
  return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
102
98
  }
103
- static async random({ note = Note.random(), contractAddress = undefined, storageSlot = Fr.random(), nonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(), addressPoint = undefined, noteTypeId = NoteSelector.random() } = {}) {
104
- return new NoteDao(note, contractAddress ?? await AztecAddress.random(), storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, addressPoint ?? await Point.random(), noteTypeId);
99
+ static async random({ note = Note.random(), contractAddress = undefined, storageSlot = Fr.random(), nonce = Fr.random(), noteHash = Fr.random(), siloedNullifier = Fr.random(), txHash = TxHash.random(), l2BlockNumber = Math.floor(Math.random() * 1000), l2BlockHash = Fr.random().toString(), index = Fr.random().toBigInt(), recipient = undefined } = {}) {
100
+ return new NoteDao(note, contractAddress ?? await AztecAddress.random(), storageSlot, nonce, noteHash, siloedNullifier, txHash, l2BlockNumber, l2BlockHash, index, recipient ?? await AztecAddress.random());
105
101
  }
106
102
  }
@@ -1,4 +1,4 @@
1
- import type { Fr, Point } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/fields';
2
2
  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';
@@ -14,7 +14,7 @@ export declare class NoteDataProvider implements DataProvider {
14
14
  removeNotesAfter(blockNumber: number): Promise<void>;
15
15
  unnullifyNotesAfter(blockNumber: number, synchedBlockNumber?: number): Promise<void>;
16
16
  getNotes(filter: NotesFilter): Promise<NoteDao[]>;
17
- removeNullifiedNotes(nullifiers: InBlock<Fr>[], accountAddressPoint: Point): Promise<NoteDao[]>;
17
+ removeNullifiedNotes(nullifiers: InBlock<Fr>[], recipient: AztecAddress): Promise<NoteDao[]>;
18
18
  getSize(): Promise<number>;
19
19
  }
20
20
  //# 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,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAE1D,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;AAEnD,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,qBAAa,gBAAiB,YAAW,YAAY;;IAsBnD,OAAO;WAsBa,MAAM,CAAC,K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