@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.
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +2 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts +7 -6
- package/dest/pxe_oracle_interface/pxe_oracle_interface.d.ts.map +1 -1
- package/dest/pxe_oracle_interface/pxe_oracle_interface.js +44 -80
- package/dest/pxe_service/pxe_service.d.ts +1 -0
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +135 -100
- package/dest/storage/note_data_provider/note_dao.d.ts +9 -13
- package/dest/storage/note_data_provider/note_dao.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_dao.js +11 -15
- package/dest/storage/note_data_provider/note_data_provider.d.ts +2 -2
- package/dest/storage/note_data_provider/note_data_provider.d.ts.map +1 -1
- package/dest/storage/note_data_provider/note_data_provider.js +18 -19
- package/dest/synchronizer/synchronizer.js +1 -1
- package/package.json +15 -15
- package/src/config/index.ts +1 -0
- package/src/pxe_oracle_interface/pxe_oracle_interface.ts +55 -117
- package/src/pxe_service/pxe_service.ts +180 -134
- package/src/storage/note_data_provider/note_dao.ts +9 -18
- package/src/storage/note_data_provider/note_data_provider.ts +22 -28
- package/src/synchronizer/synchronizer.ts +1 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts +0 -11
- package/dest/note_decryption_utils/add_public_values_to_payload.d.ts.map +0 -1
- package/dest/note_decryption_utils/add_public_values_to_payload.js +0 -47
- package/src/note_decryption_utils/add_public_values_to_payload.ts +0 -64
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
2
|
import { Fr, type Point } from '@aztec/foundation/fields';
|
|
3
3
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
4
5
|
import { Timer } from '@aztec/foundation/timer';
|
|
5
6
|
import type { SiblingPath } from '@aztec/foundation/trees';
|
|
6
7
|
import { KeyStore } from '@aztec/key-store';
|
|
@@ -31,8 +32,9 @@ import {
|
|
|
31
32
|
type ContractInstanceWithAddress,
|
|
32
33
|
type NodeInfo,
|
|
33
34
|
type PartialAddress,
|
|
35
|
+
computeContractAddressFromInstance,
|
|
36
|
+
getContractClassFromArtifact,
|
|
34
37
|
} from '@aztec/stdlib/contract';
|
|
35
|
-
import { computeContractAddressFromInstance, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
36
38
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
37
39
|
import { EventMetadata, L1EventPayload } from '@aztec/stdlib/event';
|
|
38
40
|
import type { GasFees } from '@aztec/stdlib/gas';
|
|
@@ -103,6 +105,7 @@ export class PXEService implements PXE {
|
|
|
103
105
|
private proofCreator: PrivateKernelProver,
|
|
104
106
|
private protocolContractsProvider: ProtocolContractsProvider,
|
|
105
107
|
private log: Logger,
|
|
108
|
+
private jobQueue: SerialQueue,
|
|
106
109
|
) {}
|
|
107
110
|
|
|
108
111
|
/**
|
|
@@ -160,6 +163,8 @@ export class PXEService implements PXE {
|
|
|
160
163
|
log,
|
|
161
164
|
);
|
|
162
165
|
const simulator = new AcirSimulator(pxeOracleInterface, simulationProvider);
|
|
166
|
+
const jobQueue = new SerialQueue();
|
|
167
|
+
|
|
163
168
|
const pxeService = new PXEService(
|
|
164
169
|
node,
|
|
165
170
|
synchronizer,
|
|
@@ -177,13 +182,34 @@ export class PXEService implements PXE {
|
|
|
177
182
|
proofCreator,
|
|
178
183
|
protocolContractsProvider,
|
|
179
184
|
log,
|
|
185
|
+
jobQueue,
|
|
180
186
|
);
|
|
187
|
+
|
|
188
|
+
pxeService.jobQueue.start();
|
|
189
|
+
|
|
181
190
|
await pxeService.#registerProtocolContracts();
|
|
182
191
|
const info = await pxeService.getNodeInfo();
|
|
183
192
|
log.info(`Started PXE connected to chain ${info.l1ChainId} version ${info.protocolVersion}`);
|
|
184
193
|
return pxeService;
|
|
185
194
|
}
|
|
186
195
|
|
|
196
|
+
/**
|
|
197
|
+
* Enqueues a job for execution once no other jobs are running. Returns a promise that will resolve once the job is
|
|
198
|
+
* complete.
|
|
199
|
+
*
|
|
200
|
+
* Useful for tasks that cannot run concurrently, such as contract function simulation.
|
|
201
|
+
*/
|
|
202
|
+
#putInJobQueue<T>(fn: () => Promise<T>): Promise<T> {
|
|
203
|
+
// TODO(#12636): relax the conditions under which we forbid concurrency.
|
|
204
|
+
if (this.jobQueue.length() != 0) {
|
|
205
|
+
this.log.warn(
|
|
206
|
+
`PXE is already processing ${this.jobQueue.length()} jobs, concurrent execution is not supported. Will run once those are complete.`,
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return this.jobQueue.put(fn);
|
|
211
|
+
}
|
|
212
|
+
|
|
187
213
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean> {
|
|
188
214
|
return this.node.isL1ToL2MessageSynced(l1ToL2Message);
|
|
189
215
|
}
|
|
@@ -364,35 +390,39 @@ export class PXEService implements PXE {
|
|
|
364
390
|
);
|
|
365
391
|
}
|
|
366
392
|
|
|
367
|
-
public
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
393
|
+
public updateContract(contractAddress: AztecAddress, artifact: ContractArtifact): Promise<void> {
|
|
394
|
+
// We disable concurrently updating contracts to avoid concurrently syncing with the node, or changing a contract's
|
|
395
|
+
// class while we're simulating it.
|
|
396
|
+
return this.#putInJobQueue(async () => {
|
|
397
|
+
const currentInstance = await this.contractDataProvider.getContractInstance(contractAddress);
|
|
398
|
+
const contractClass = await getContractClassFromArtifact(artifact);
|
|
399
|
+
await this.synchronizer.sync();
|
|
371
400
|
|
|
372
|
-
|
|
401
|
+
const header = await this.syncDataProvider.getBlockHeader();
|
|
373
402
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
403
|
+
const currentClassId = await readCurrentClassId(
|
|
404
|
+
contractAddress,
|
|
405
|
+
currentInstance,
|
|
406
|
+
this.node,
|
|
407
|
+
header.globalVariables.blockNumber.toNumber(),
|
|
408
|
+
);
|
|
409
|
+
if (!contractClass.id.equals(currentClassId)) {
|
|
410
|
+
throw new Error('Could not update contract to a class different from the current one.');
|
|
411
|
+
}
|
|
383
412
|
|
|
384
|
-
|
|
413
|
+
await this.contractDataProvider.addContractArtifact(contractClass.id, artifact);
|
|
385
414
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
415
|
+
const publicFunctionSignatures = artifact.functions
|
|
416
|
+
.filter(fn => fn.functionType === FunctionType.PUBLIC)
|
|
417
|
+
.map(fn => decodeFunctionSignature(fn.name, fn.parameters));
|
|
418
|
+
await this.node.registerContractFunctionSignatures(contractAddress, publicFunctionSignatures);
|
|
390
419
|
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
420
|
+
// TODO(#10007): Node should get public contract class from the registration event, not from PXE registration
|
|
421
|
+
await this.node.addContractClass({ ...contractClass, privateFunctions: [], unconstrainedFunctions: [] });
|
|
422
|
+
currentInstance.currentContractClassId = contractClass.id;
|
|
423
|
+
await this.contractDataProvider.addContractInstance(currentInstance);
|
|
424
|
+
this.log.info(`Updated contract ${artifact.name} at ${contractAddress.toString()} to class ${contractClass.id}`);
|
|
425
|
+
});
|
|
396
426
|
}
|
|
397
427
|
|
|
398
428
|
public getContracts(): Promise<AztecAddress[]> {
|
|
@@ -407,27 +437,19 @@ export class PXEService implements PXE {
|
|
|
407
437
|
const noteDaos = await this.noteDataProvider.getNotes(filter);
|
|
408
438
|
|
|
409
439
|
const extendedNotes = noteDaos.map(async dao => {
|
|
410
|
-
let
|
|
411
|
-
if (
|
|
440
|
+
let recipient = filter.recipient;
|
|
441
|
+
if (recipient === undefined) {
|
|
412
442
|
const completeAddresses = await this.addressDataProvider.getCompleteAddresses();
|
|
413
|
-
const completeAddressIndex = (
|
|
414
|
-
|
|
415
|
-
)
|
|
443
|
+
const completeAddressIndex = completeAddresses.findIndex(completeAddress =>
|
|
444
|
+
completeAddress.address.equals(dao.recipient),
|
|
445
|
+
);
|
|
416
446
|
const completeAddress = completeAddresses[completeAddressIndex];
|
|
417
447
|
if (completeAddress === undefined) {
|
|
418
|
-
throw new Error(`Cannot find complete address for
|
|
448
|
+
throw new Error(`Cannot find complete address for recipient ${dao.recipient.toString()}`);
|
|
419
449
|
}
|
|
420
|
-
|
|
450
|
+
recipient = completeAddress.address;
|
|
421
451
|
}
|
|
422
|
-
return new UniqueNote(
|
|
423
|
-
dao.note,
|
|
424
|
-
owner,
|
|
425
|
-
dao.contractAddress,
|
|
426
|
-
dao.storageSlot,
|
|
427
|
-
dao.noteTypeId,
|
|
428
|
-
dao.txHash,
|
|
429
|
-
dao.nonce,
|
|
430
|
-
);
|
|
452
|
+
return new UniqueNote(dao.note, recipient, dao.contractAddress, dao.storageSlot, dao.txHash, dao.nonce);
|
|
431
453
|
});
|
|
432
454
|
return Promise.all(extendedNotes);
|
|
433
455
|
}
|
|
@@ -456,24 +478,33 @@ export class PXEService implements PXE {
|
|
|
456
478
|
return await this.node.getCurrentBaseFees();
|
|
457
479
|
}
|
|
458
480
|
|
|
459
|
-
public
|
|
481
|
+
public proveTx(
|
|
460
482
|
txRequest: TxExecutionRequest,
|
|
461
483
|
privateExecutionResult: PrivateExecutionResult,
|
|
462
484
|
): Promise<TxProvingResult> {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
485
|
+
// We disable proving concurrently mostly out of caution, since it accesses some of our stores. Proving is so
|
|
486
|
+
// computationally demanding that it'd be rare for someone to try to do it concurrently regardless.
|
|
487
|
+
return this.#putInJobQueue(async () => {
|
|
488
|
+
try {
|
|
489
|
+
const { publicInputs, clientIvcProof } = await this.#prove(
|
|
490
|
+
txRequest,
|
|
491
|
+
this.proofCreator,
|
|
492
|
+
privateExecutionResult,
|
|
493
|
+
{
|
|
494
|
+
simulate: false,
|
|
495
|
+
skipFeeEnforcement: false,
|
|
496
|
+
profile: false,
|
|
497
|
+
},
|
|
498
|
+
);
|
|
499
|
+
return new TxProvingResult(privateExecutionResult, publicInputs, clientIvcProof!);
|
|
500
|
+
} catch (err: any) {
|
|
501
|
+
throw this.contextualizeError(err, inspect(txRequest), inspect(privateExecutionResult));
|
|
502
|
+
}
|
|
503
|
+
});
|
|
473
504
|
}
|
|
474
505
|
|
|
475
506
|
// TODO(#7456) Prevent msgSender being defined here for the first call
|
|
476
|
-
public
|
|
507
|
+
public simulateTx(
|
|
477
508
|
txRequest: TxExecutionRequest,
|
|
478
509
|
simulatePublic: boolean,
|
|
479
510
|
msgSender: AztecAddress | undefined = undefined,
|
|
@@ -482,74 +513,84 @@ export class PXEService implements PXE {
|
|
|
482
513
|
profile: boolean = false,
|
|
483
514
|
scopes?: AztecAddress[],
|
|
484
515
|
): Promise<TxSimulationResult> {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
516
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
517
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
518
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
519
|
+
return this.#putInJobQueue(async () => {
|
|
520
|
+
try {
|
|
521
|
+
const txInfo = {
|
|
522
|
+
origin: txRequest.origin,
|
|
523
|
+
functionSelector: txRequest.functionSelector,
|
|
524
|
+
simulatePublic,
|
|
525
|
+
msgSender,
|
|
526
|
+
chainId: txRequest.txContext.chainId,
|
|
527
|
+
version: txRequest.txContext.version,
|
|
528
|
+
authWitnesses: txRequest.authWitnesses.map(w => w.requestHash),
|
|
529
|
+
};
|
|
530
|
+
this.log.info(
|
|
531
|
+
`Simulating transaction execution request to ${txRequest.functionSelector} at ${txRequest.origin}`,
|
|
532
|
+
txInfo,
|
|
533
|
+
);
|
|
534
|
+
const timer = new Timer();
|
|
535
|
+
await this.synchronizer.sync();
|
|
536
|
+
const privateExecutionResult = await this.#executePrivate(txRequest, msgSender, scopes);
|
|
537
|
+
|
|
538
|
+
const { publicInputs, profileResult } = await this.#prove(
|
|
539
|
+
txRequest,
|
|
540
|
+
this.proofCreator,
|
|
541
|
+
privateExecutionResult,
|
|
542
|
+
{
|
|
543
|
+
simulate: !profile,
|
|
544
|
+
skipFeeEnforcement,
|
|
545
|
+
profile,
|
|
546
|
+
},
|
|
547
|
+
);
|
|
515
548
|
|
|
516
|
-
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
|
|
549
|
+
const privateSimulationResult = new PrivateSimulationResult(privateExecutionResult, publicInputs);
|
|
550
|
+
const simulatedTx = privateSimulationResult.toSimulatedTx();
|
|
551
|
+
let publicOutput: PublicSimulationOutput | undefined;
|
|
552
|
+
if (simulatePublic && publicInputs.forPublic) {
|
|
553
|
+
publicOutput = await this.#simulatePublicCalls(simulatedTx, skipFeeEnforcement);
|
|
520
554
|
}
|
|
521
|
-
}
|
|
522
555
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
? {
|
|
530
|
-
gasUsed: publicOutput.gasUsed,
|
|
531
|
-
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
532
|
-
revertReason: publicOutput.revertReason,
|
|
533
|
-
}
|
|
534
|
-
: {}),
|
|
535
|
-
});
|
|
556
|
+
if (!skipTxValidation) {
|
|
557
|
+
const validationResult = await this.node.isValidTx(simulatedTx, { isSimulation: true, skipFeeEnforcement });
|
|
558
|
+
if (validationResult.result === 'invalid') {
|
|
559
|
+
throw new Error('The simulated transaction is unable to be added to state and is invalid.');
|
|
560
|
+
}
|
|
561
|
+
}
|
|
536
562
|
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
563
|
+
const txHash = await simulatedTx.getTxHash();
|
|
564
|
+
this.log.info(`Simulation completed for ${txHash.toString()} in ${timer.ms()}ms`, {
|
|
565
|
+
txHash,
|
|
566
|
+
...txInfo,
|
|
567
|
+
...(profileResult ? { gateCounts: profileResult.gateCounts } : {}),
|
|
568
|
+
...(publicOutput
|
|
569
|
+
? {
|
|
570
|
+
gasUsed: publicOutput.gasUsed,
|
|
571
|
+
revertCode: publicOutput.txEffect.revertCode.getCode(),
|
|
572
|
+
revertReason: publicOutput.revertReason,
|
|
573
|
+
}
|
|
574
|
+
: {}),
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
return TxSimulationResult.fromPrivateSimulationResultAndPublicOutput(
|
|
578
|
+
privateSimulationResult,
|
|
579
|
+
publicOutput,
|
|
580
|
+
profileResult,
|
|
581
|
+
);
|
|
582
|
+
} catch (err: any) {
|
|
583
|
+
throw this.contextualizeError(
|
|
584
|
+
err,
|
|
585
|
+
inspect(txRequest),
|
|
586
|
+
`simulatePublic=${simulatePublic}`,
|
|
587
|
+
`msgSender=${msgSender?.toString() ?? 'undefined'}`,
|
|
588
|
+
`skipTxValidation=${skipTxValidation}`,
|
|
589
|
+
`profile=${profile}`,
|
|
590
|
+
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
553
594
|
}
|
|
554
595
|
|
|
555
596
|
public async sendTx(tx: Tx): Promise<TxHash> {
|
|
@@ -565,29 +606,34 @@ export class PXEService implements PXE {
|
|
|
565
606
|
return txHash;
|
|
566
607
|
}
|
|
567
608
|
|
|
568
|
-
public
|
|
609
|
+
public simulateUnconstrained(
|
|
569
610
|
functionName: string,
|
|
570
611
|
args: any[],
|
|
571
612
|
to: AztecAddress,
|
|
572
613
|
_from?: AztecAddress,
|
|
573
614
|
scopes?: AztecAddress[],
|
|
574
615
|
): Promise<AbiDecoded> {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
616
|
+
// We disable concurrent simulations since those might execute oracles which read and write to the PXE stores (e.g.
|
|
617
|
+
// to the capsules), and we need to prevent concurrent runs from interfering with one another (e.g. attempting to
|
|
618
|
+
// delete the same read value, or reading values that another simulation is currently modifying).
|
|
619
|
+
return this.#putInJobQueue(async () => {
|
|
620
|
+
try {
|
|
621
|
+
await this.synchronizer.sync();
|
|
622
|
+
// TODO - Should check if `from` has the permission to call the view function.
|
|
623
|
+
const functionCall = await this.#getFunctionCall(functionName, args, to);
|
|
624
|
+
const executionResult = await this.#simulateUnconstrained(functionCall, scopes);
|
|
625
|
+
|
|
626
|
+
// TODO - Return typed result based on the function artifact.
|
|
627
|
+
return executionResult;
|
|
628
|
+
} catch (err: any) {
|
|
629
|
+
const stringifiedArgs = args.map(arg => arg.toString()).join(', ');
|
|
630
|
+
throw this.contextualizeError(
|
|
631
|
+
err,
|
|
632
|
+
`simulateUnconstrained ${to}:${functionName}(${stringifiedArgs})`,
|
|
633
|
+
`scopes=${scopes?.map(s => s.toString()).join(', ') ?? 'undefined'}`,
|
|
634
|
+
);
|
|
635
|
+
}
|
|
636
|
+
});
|
|
591
637
|
}
|
|
592
638
|
|
|
593
639
|
public getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
|
|
@@ -2,9 +2,7 @@ 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
4
|
import type { NoteData } from '@aztec/simulator/client';
|
|
5
|
-
import { NoteSelector } from '@aztec/stdlib/abi';
|
|
6
5
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
8
6
|
import { Note } from '@aztec/stdlib/note';
|
|
9
7
|
import { TxHash } from '@aztec/stdlib/tx';
|
|
10
8
|
|
|
@@ -53,13 +51,11 @@ export class NoteDao implements NoteData {
|
|
|
53
51
|
public l2BlockHash: string,
|
|
54
52
|
/** The index of the leaf in the global note hash tree the note is stored at */
|
|
55
53
|
public index: bigint,
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
/** The note type identifier for the contract.
|
|
60
|
-
* TODO(#12013): remove
|
|
54
|
+
/**
|
|
55
|
+
* The address whose public key was used to encrypt the note log during delivery.
|
|
56
|
+
* (This is the x-coordinate of the public key.)
|
|
61
57
|
*/
|
|
62
|
-
public
|
|
58
|
+
public recipient: AztecAddress,
|
|
63
59
|
) {}
|
|
64
60
|
|
|
65
61
|
toBuffer(): Buffer {
|
|
@@ -74,8 +70,7 @@ export class NoteDao implements NoteData {
|
|
|
74
70
|
this.l2BlockNumber,
|
|
75
71
|
Fr.fromHexString(this.l2BlockHash),
|
|
76
72
|
this.index,
|
|
77
|
-
this.
|
|
78
|
-
this.noteTypeId,
|
|
73
|
+
this.recipient,
|
|
79
74
|
]);
|
|
80
75
|
}
|
|
81
76
|
|
|
@@ -92,8 +87,7 @@ export class NoteDao implements NoteData {
|
|
|
92
87
|
const l2BlockNumber = reader.readNumber();
|
|
93
88
|
const l2BlockHash = Fr.fromBuffer(reader).toString();
|
|
94
89
|
const index = toBigIntBE(reader.readBytes(32));
|
|
95
|
-
const
|
|
96
|
-
const noteTypeId = reader.readObject(NoteSelector);
|
|
90
|
+
const recipient = AztecAddress.fromBuffer(reader);
|
|
97
91
|
|
|
98
92
|
return new NoteDao(
|
|
99
93
|
note,
|
|
@@ -106,8 +100,7 @@ export class NoteDao implements NoteData {
|
|
|
106
100
|
l2BlockNumber,
|
|
107
101
|
l2BlockHash,
|
|
108
102
|
index,
|
|
109
|
-
|
|
110
|
-
noteTypeId,
|
|
103
|
+
recipient,
|
|
111
104
|
);
|
|
112
105
|
}
|
|
113
106
|
|
|
@@ -141,8 +134,7 @@ export class NoteDao implements NoteData {
|
|
|
141
134
|
l2BlockNumber = Math.floor(Math.random() * 1000),
|
|
142
135
|
l2BlockHash = Fr.random().toString(),
|
|
143
136
|
index = Fr.random().toBigInt(),
|
|
144
|
-
|
|
145
|
-
noteTypeId = NoteSelector.random(),
|
|
137
|
+
recipient = undefined,
|
|
146
138
|
}: Partial<NoteDao> = {}) {
|
|
147
139
|
return new NoteDao(
|
|
148
140
|
note,
|
|
@@ -155,8 +147,7 @@ export class NoteDao implements NoteData {
|
|
|
155
147
|
l2BlockNumber,
|
|
156
148
|
l2BlockHash,
|
|
157
149
|
index,
|
|
158
|
-
|
|
159
|
-
noteTypeId,
|
|
150
|
+
recipient ?? (await AztecAddress.random()),
|
|
160
151
|
);
|
|
161
152
|
}
|
|
162
153
|
}
|