@aztec/pxe 0.76.2 → 0.76.4-devnet-test
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/database/kv_pxe_database.d.ts +4 -4
- package/dest/database/kv_pxe_database.d.ts.map +1 -1
- package/dest/database/kv_pxe_database.js +17 -17
- package/dest/database/pxe_database.d.ts +14 -11
- package/dest/database/pxe_database.d.ts.map +1 -1
- package/dest/database/pxe_database_test_suite.js +51 -51
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +7 -9
- package/dest/pxe_service/pxe_service.d.ts +1 -1
- package/dest/pxe_service/pxe_service.d.ts.map +1 -1
- package/dest/pxe_service/pxe_service.js +3 -3
- package/dest/simulator_oracle/index.d.ts +4 -4
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +9 -9
- package/package.json +14 -14
- package/src/database/kv_pxe_database.ts +14 -17
- package/src/database/pxe_database.ts +14 -11
- package/src/database/pxe_database_test_suite.ts +50 -50
- package/src/kernel_prover/kernel_prover.ts +6 -12
- package/src/pxe_service/pxe_service.ts +2 -2
- package/src/simulator_oracle/index.ts +8 -8
|
@@ -410,8 +410,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
410
410
|
const slot = new Fr(1);
|
|
411
411
|
const values = [new Fr(42)];
|
|
412
412
|
|
|
413
|
-
await database.
|
|
414
|
-
const result = await database.
|
|
413
|
+
await database.storeCapsule(contract, slot, values);
|
|
414
|
+
const result = await database.loadCapsule(contract, slot);
|
|
415
415
|
expect(result).toEqual(values);
|
|
416
416
|
});
|
|
417
417
|
|
|
@@ -419,8 +419,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
419
419
|
const slot = new Fr(1);
|
|
420
420
|
const values = [new Fr(42), new Fr(43), new Fr(44)];
|
|
421
421
|
|
|
422
|
-
await database.
|
|
423
|
-
const result = await database.
|
|
422
|
+
await database.storeCapsule(contract, slot, values);
|
|
423
|
+
const result = await database.loadCapsule(contract, slot);
|
|
424
424
|
expect(result).toEqual(values);
|
|
425
425
|
});
|
|
426
426
|
|
|
@@ -429,10 +429,10 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
429
429
|
const initialValues = [new Fr(42)];
|
|
430
430
|
const newValues = [new Fr(100)];
|
|
431
431
|
|
|
432
|
-
await database.
|
|
433
|
-
await database.
|
|
432
|
+
await database.storeCapsule(contract, slot, initialValues);
|
|
433
|
+
await database.storeCapsule(contract, slot, newValues);
|
|
434
434
|
|
|
435
|
-
const result = await database.
|
|
435
|
+
const result = await database.loadCapsule(contract, slot);
|
|
436
436
|
expect(result).toEqual(newValues);
|
|
437
437
|
});
|
|
438
438
|
|
|
@@ -442,11 +442,11 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
442
442
|
const values1 = [new Fr(42)];
|
|
443
443
|
const values2 = [new Fr(100)];
|
|
444
444
|
|
|
445
|
-
await database.
|
|
446
|
-
await database.
|
|
445
|
+
await database.storeCapsule(contract, slot, values1);
|
|
446
|
+
await database.storeCapsule(anotherContract, slot, values2);
|
|
447
447
|
|
|
448
|
-
const result1 = await database.
|
|
449
|
-
const result2 = await database.
|
|
448
|
+
const result1 = await database.loadCapsule(contract, slot);
|
|
449
|
+
const result2 = await database.loadCapsule(anotherContract, slot);
|
|
450
450
|
|
|
451
451
|
expect(result1).toEqual(values1);
|
|
452
452
|
expect(result2).toEqual(values2);
|
|
@@ -454,7 +454,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
454
454
|
|
|
455
455
|
it('returns null for non-existent slots', async () => {
|
|
456
456
|
const slot = Fr.random();
|
|
457
|
-
const result = await database.
|
|
457
|
+
const result = await database.loadCapsule(contract, slot);
|
|
458
458
|
expect(result).toBeNull();
|
|
459
459
|
});
|
|
460
460
|
|
|
@@ -462,99 +462,99 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
|
|
|
462
462
|
const slot = new Fr(1);
|
|
463
463
|
const values = [new Fr(42)];
|
|
464
464
|
|
|
465
|
-
await database.
|
|
466
|
-
await database.
|
|
465
|
+
await database.storeCapsule(contract, slot, values);
|
|
466
|
+
await database.deleteCapsule(contract, slot);
|
|
467
467
|
|
|
468
|
-
expect(await database.
|
|
468
|
+
expect(await database.loadCapsule(contract, slot)).toBeNull();
|
|
469
469
|
});
|
|
470
470
|
|
|
471
471
|
it('deletes an empty slot', async () => {
|
|
472
472
|
const slot = new Fr(1);
|
|
473
|
-
await database.
|
|
473
|
+
await database.deleteCapsule(contract, slot);
|
|
474
474
|
|
|
475
|
-
expect(await database.
|
|
475
|
+
expect(await database.loadCapsule(contract, slot)).toBeNull();
|
|
476
476
|
});
|
|
477
477
|
|
|
478
478
|
it('copies a single value', async () => {
|
|
479
479
|
const slot = new Fr(1);
|
|
480
480
|
const values = [new Fr(42)];
|
|
481
481
|
|
|
482
|
-
await database.
|
|
482
|
+
await database.storeCapsule(contract, slot, values);
|
|
483
483
|
|
|
484
484
|
const dstSlot = new Fr(5);
|
|
485
|
-
await database.
|
|
485
|
+
await database.copyCapsule(contract, slot, dstSlot, 1);
|
|
486
486
|
|
|
487
|
-
expect(await database.
|
|
487
|
+
expect(await database.loadCapsule(contract, dstSlot)).toEqual(values);
|
|
488
488
|
});
|
|
489
489
|
|
|
490
490
|
it('copies multiple non-overlapping values', async () => {
|
|
491
491
|
const src = new Fr(1);
|
|
492
492
|
const valuesArray = [[new Fr(42)], [new Fr(1337)], [new Fr(13)]];
|
|
493
493
|
|
|
494
|
-
await database.
|
|
495
|
-
await database.
|
|
496
|
-
await database.
|
|
494
|
+
await database.storeCapsule(contract, src, valuesArray[0]);
|
|
495
|
+
await database.storeCapsule(contract, src.add(new Fr(1)), valuesArray[1]);
|
|
496
|
+
await database.storeCapsule(contract, src.add(new Fr(2)), valuesArray[2]);
|
|
497
497
|
|
|
498
498
|
const dst = new Fr(5);
|
|
499
|
-
await database.
|
|
499
|
+
await database.copyCapsule(contract, src, dst, 3);
|
|
500
500
|
|
|
501
|
-
expect(await database.
|
|
502
|
-
expect(await database.
|
|
503
|
-
expect(await database.
|
|
501
|
+
expect(await database.loadCapsule(contract, dst)).toEqual(valuesArray[0]);
|
|
502
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(1)))).toEqual(valuesArray[1]);
|
|
503
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(2)))).toEqual(valuesArray[2]);
|
|
504
504
|
});
|
|
505
505
|
|
|
506
506
|
it('copies overlapping values with src ahead', async () => {
|
|
507
507
|
const src = new Fr(1);
|
|
508
508
|
const valuesArray = [[new Fr(42)], [new Fr(1337)], [new Fr(13)]];
|
|
509
509
|
|
|
510
|
-
await database.
|
|
511
|
-
await database.
|
|
512
|
-
await database.
|
|
510
|
+
await database.storeCapsule(contract, src, valuesArray[0]);
|
|
511
|
+
await database.storeCapsule(contract, src.add(new Fr(1)), valuesArray[1]);
|
|
512
|
+
await database.storeCapsule(contract, src.add(new Fr(2)), valuesArray[2]);
|
|
513
513
|
|
|
514
514
|
const dst = new Fr(2);
|
|
515
|
-
await database.
|
|
515
|
+
await database.copyCapsule(contract, src, dst, 3);
|
|
516
516
|
|
|
517
|
-
expect(await database.
|
|
518
|
-
expect(await database.
|
|
519
|
-
expect(await database.
|
|
517
|
+
expect(await database.loadCapsule(contract, dst)).toEqual(valuesArray[0]);
|
|
518
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(1)))).toEqual(valuesArray[1]);
|
|
519
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(2)))).toEqual(valuesArray[2]);
|
|
520
520
|
|
|
521
521
|
// Slots 2 and 3 (src[1] and src[2]) should have been overwritten since they are also dst[0] and dst[1]
|
|
522
|
-
expect(await database.
|
|
523
|
-
expect(await database.
|
|
524
|
-
expect(await database.
|
|
522
|
+
expect(await database.loadCapsule(contract, src)).toEqual(valuesArray[0]); // src[0] (unchanged)
|
|
523
|
+
expect(await database.loadCapsule(contract, src.add(new Fr(1)))).toEqual(valuesArray[0]); // dst[0]
|
|
524
|
+
expect(await database.loadCapsule(contract, src.add(new Fr(2)))).toEqual(valuesArray[1]); // dst[1]
|
|
525
525
|
});
|
|
526
526
|
|
|
527
527
|
it('copies overlapping values with dst ahead', async () => {
|
|
528
528
|
const src = new Fr(5);
|
|
529
529
|
const valuesArray = [[new Fr(42)], [new Fr(1337)], [new Fr(13)]];
|
|
530
530
|
|
|
531
|
-
await database.
|
|
532
|
-
await database.
|
|
533
|
-
await database.
|
|
531
|
+
await database.storeCapsule(contract, src, valuesArray[0]);
|
|
532
|
+
await database.storeCapsule(contract, src.add(new Fr(1)), valuesArray[1]);
|
|
533
|
+
await database.storeCapsule(contract, src.add(new Fr(2)), valuesArray[2]);
|
|
534
534
|
|
|
535
535
|
const dst = new Fr(4);
|
|
536
|
-
await database.
|
|
536
|
+
await database.copyCapsule(contract, src, dst, 3);
|
|
537
537
|
|
|
538
|
-
expect(await database.
|
|
539
|
-
expect(await database.
|
|
540
|
-
expect(await database.
|
|
538
|
+
expect(await database.loadCapsule(contract, dst)).toEqual(valuesArray[0]);
|
|
539
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(1)))).toEqual(valuesArray[1]);
|
|
540
|
+
expect(await database.loadCapsule(contract, dst.add(new Fr(2)))).toEqual(valuesArray[2]);
|
|
541
541
|
|
|
542
542
|
// Slots 5 and 6 (src[0] and src[1]) should have been overwritten since they are also dst[1] and dst[2]
|
|
543
|
-
expect(await database.
|
|
544
|
-
expect(await database.
|
|
545
|
-
expect(await database.
|
|
543
|
+
expect(await database.loadCapsule(contract, src)).toEqual(valuesArray[1]); // dst[1]
|
|
544
|
+
expect(await database.loadCapsule(contract, src.add(new Fr(1)))).toEqual(valuesArray[2]); // dst[2]
|
|
545
|
+
expect(await database.loadCapsule(contract, src.add(new Fr(2)))).toEqual(valuesArray[2]); // src[2] (unchanged)
|
|
546
546
|
});
|
|
547
547
|
|
|
548
548
|
it('copying fails if any value is empty', async () => {
|
|
549
549
|
const src = new Fr(1);
|
|
550
550
|
const valuesArray = [[new Fr(42)], [new Fr(1337)], [new Fr(13)]];
|
|
551
551
|
|
|
552
|
-
await database.
|
|
552
|
+
await database.storeCapsule(contract, src, valuesArray[0]);
|
|
553
553
|
// We skip src[1]
|
|
554
|
-
await database.
|
|
554
|
+
await database.storeCapsule(contract, src.add(new Fr(2)), valuesArray[2]);
|
|
555
555
|
|
|
556
556
|
const dst = new Fr(5);
|
|
557
|
-
await expect(database.
|
|
557
|
+
await expect(database.copyCapsule(contract, src, dst, 3)).rejects.toThrow('Attempted to copy empty slot');
|
|
558
558
|
});
|
|
559
559
|
});
|
|
560
560
|
});
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
CLIENT_IVC_VERIFICATION_KEY_LENGTH_IN_FIELDS,
|
|
14
14
|
ClientIvcProof,
|
|
15
15
|
Fr,
|
|
16
|
-
PROTOCOL_CONTRACT_TREE_HEIGHT,
|
|
17
16
|
PrivateCallData,
|
|
18
17
|
PrivateKernelCircuitPublicInputs,
|
|
19
18
|
PrivateKernelData,
|
|
@@ -28,18 +27,13 @@ import {
|
|
|
28
27
|
VerificationKeyAsFields,
|
|
29
28
|
} from '@aztec/circuits.js';
|
|
30
29
|
import { hashVK } from '@aztec/circuits.js/hash';
|
|
31
|
-
import { makeTuple } from '@aztec/foundation/array';
|
|
32
30
|
import { vkAsFieldsMegaHonk } from '@aztec/foundation/crypto';
|
|
33
31
|
import { createLogger } from '@aztec/foundation/log';
|
|
34
32
|
import { assertLength } from '@aztec/foundation/serialize';
|
|
35
33
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
36
34
|
import { Timer } from '@aztec/foundation/timer';
|
|
37
35
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
|
|
38
|
-
import {
|
|
39
|
-
getProtocolContractSiblingPath,
|
|
40
|
-
isProtocolContract,
|
|
41
|
-
protocolContractTreeRoot,
|
|
42
|
-
} from '@aztec/protocol-contracts';
|
|
36
|
+
import { getProtocolContractLeafAndMembershipWitness, protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
43
37
|
|
|
44
38
|
import { type WitnessMap } from '@noir-lang/types';
|
|
45
39
|
import { strict as assert } from 'assert';
|
|
@@ -330,7 +324,7 @@ export class KernelProver {
|
|
|
330
324
|
const ivcProof = await this.proofCreator.createClientIvcProof(acirs, witnessStack);
|
|
331
325
|
tailOutput.clientIvcProof = ivcProof;
|
|
332
326
|
} else {
|
|
333
|
-
tailOutput.clientIvcProof = ClientIvcProof.
|
|
327
|
+
tailOutput.clientIvcProof = ClientIvcProof.random();
|
|
334
328
|
}
|
|
335
329
|
|
|
336
330
|
return tailOutput;
|
|
@@ -356,9 +350,8 @@ export class KernelProver {
|
|
|
356
350
|
// const acirHash = keccak256(Buffer.from(bytecode, 'hex'));
|
|
357
351
|
const acirHash = Fr.fromBuffer(Buffer.alloc(32, 0));
|
|
358
352
|
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
: makeTuple(PROTOCOL_CONTRACT_TREE_HEIGHT, Fr.zero);
|
|
353
|
+
const { lowLeaf: protocolContractLeaf, witness: protocolContractMembershipWitness } =
|
|
354
|
+
await getProtocolContractLeafAndMembershipWitness(contractAddress);
|
|
362
355
|
|
|
363
356
|
return PrivateCallData.from({
|
|
364
357
|
publicInputs,
|
|
@@ -368,7 +361,8 @@ export class KernelProver {
|
|
|
368
361
|
contractClassPublicBytecodeCommitment,
|
|
369
362
|
saltedInitializationHash,
|
|
370
363
|
functionLeafMembershipWitness,
|
|
371
|
-
|
|
364
|
+
protocolContractMembershipWitness,
|
|
365
|
+
protocolContractLeaf,
|
|
372
366
|
acirHash,
|
|
373
367
|
});
|
|
374
368
|
}
|
|
@@ -137,8 +137,8 @@ export class PXEService implements PXE {
|
|
|
137
137
|
return this.db.getAuthWitness(messageHash);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
public
|
|
141
|
-
return this.db.
|
|
140
|
+
public storeCapsule(contract: AztecAddress, storageSlot: Fr, capsule: Fr[]) {
|
|
141
|
+
return this.db.storeCapsule(contract, storageSlot, capsule);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
public getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined> {
|
|
@@ -825,20 +825,20 @@ export class SimulatorOracle implements DBOracle {
|
|
|
825
825
|
);
|
|
826
826
|
}
|
|
827
827
|
|
|
828
|
-
|
|
829
|
-
return this.db.
|
|
828
|
+
storeCapsule(contractAddress: AztecAddress, slot: Fr, capsule: Fr[]): Promise<void> {
|
|
829
|
+
return this.db.storeCapsule(contractAddress, slot, capsule);
|
|
830
830
|
}
|
|
831
831
|
|
|
832
|
-
|
|
833
|
-
return this.db.
|
|
832
|
+
loadCapsule(contractAddress: AztecAddress, slot: Fr): Promise<Fr[] | null> {
|
|
833
|
+
return this.db.loadCapsule(contractAddress, slot);
|
|
834
834
|
}
|
|
835
835
|
|
|
836
|
-
|
|
837
|
-
return this.db.
|
|
836
|
+
deleteCapsule(contractAddress: AztecAddress, slot: Fr): Promise<void> {
|
|
837
|
+
return this.db.deleteCapsule(contractAddress, slot);
|
|
838
838
|
}
|
|
839
839
|
|
|
840
|
-
|
|
841
|
-
return this.db.
|
|
840
|
+
copyCapsule(contractAddress: AztecAddress, srcSlot: Fr, dstSlot: Fr, numEntries: number): Promise<void> {
|
|
841
|
+
return this.db.copyCapsule(contractAddress, srcSlot, dstSlot, numEntries);
|
|
842
842
|
}
|
|
843
843
|
}
|
|
844
844
|
|