@aztec/pxe 0.15.0 → 0.15.1
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/contract_data_oracle/index.d.ts.map +1 -1
- package/dest/contract_data_oracle/index.js +3 -4
- package/dest/contract_tree/index.d.ts +3 -4
- package/dest/contract_tree/index.d.ts.map +1 -1
- package/dest/contract_tree/index.js +10 -12
- package/dest/database/database.d.ts +12 -0
- package/dest/database/database.d.ts.map +1 -1
- package/dest/database/memory_db.d.ts +3 -0
- package/dest/database/memory_db.d.ts.map +1 -1
- package/dest/database/memory_db.js +15 -3
- package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
- package/dest/kernel_prover/kernel_prover.js +8 -4
- package/dest/note_processor/note_processor.d.ts.map +1 -1
- package/dest/note_processor/note_processor.js +6 -4
- package/dest/pxe_service/create_pxe_service.js +2 -2
- 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 +9 -4
- package/dest/pxe_service/test/pxe_test_suite.d.ts.map +1 -1
- package/dest/pxe_service/test/pxe_test_suite.js +8 -8
- package/dest/simulator_oracle/index.d.ts +1 -0
- package/dest/simulator_oracle/index.d.ts.map +1 -1
- package/dest/simulator_oracle/index.js +13 -4
- package/dest/synchronizer/synchronizer.d.ts.map +1 -1
- package/dest/synchronizer/synchronizer.js +7 -4
- package/package.json +10 -11
- package/src/contract_data_oracle/index.ts +2 -3
- package/src/contract_tree/index.ts +7 -10
- package/src/database/database.ts +14 -0
- package/src/database/memory_db.ts +19 -3
- package/src/kernel_prover/kernel_prover.ts +7 -5
- package/src/note_processor/note_processor.ts +7 -3
- package/src/pxe_service/create_pxe_service.ts +1 -1
- package/src/pxe_service/pxe_service.ts +11 -3
- package/src/pxe_service/test/pxe_test_suite.ts +7 -13
- package/src/simulator_oracle/index.ts +13 -2
- package/src/synchronizer/synchronizer.ts +9 -3
|
@@ -110,11 +110,13 @@ export class KernelProver {
|
|
|
110
110
|
// and fill the non-transient ones in with sibling paths via oracle.
|
|
111
111
|
const readRequestMembershipWitnesses = currentExecution.readRequestPartialWitnesses;
|
|
112
112
|
for (let rr = 0; rr < readRequestMembershipWitnesses.length; rr++) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
// Pretty sure this check was forever broken. I made some changes to Fr and this started triggering.
|
|
114
|
+
// The conditional makes no sense to me anyway.
|
|
115
|
+
// if (currentExecution.callStackItem.publicInputs.readRequests[rr] == Fr.ZERO) {
|
|
116
|
+
// throw new Error(
|
|
117
|
+
// 'Number of read requests output from Noir circuit does not match number of read request commitment indices output from simulator.',
|
|
118
|
+
// );
|
|
119
|
+
// }
|
|
118
120
|
const rrWitness = readRequestMembershipWitnesses[rr];
|
|
119
121
|
if (!rrWitness.isTransient) {
|
|
120
122
|
// Non-transient reads must contain full membership witness with sibling path from commitment to root.
|
|
@@ -94,7 +94,7 @@ export class NoteProcessor {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
const blocksAndNotes: ProcessedData[] = [];
|
|
97
|
-
const curve =
|
|
97
|
+
const curve = new Grumpkin();
|
|
98
98
|
|
|
99
99
|
// Iterate over both blocks and encrypted logs.
|
|
100
100
|
for (let blockIndex = 0; blockIndex < encryptedL2BlockLogs.length; ++blockIndex) {
|
|
@@ -203,10 +203,14 @@ export class NoteProcessor {
|
|
|
203
203
|
let uniqueSiloedNoteHash: Fr | undefined;
|
|
204
204
|
let innerNullifier: Fr | undefined;
|
|
205
205
|
for (; commitmentIndex < commitments.length; ++commitmentIndex) {
|
|
206
|
-
if (excludedIndices.has(commitmentIndex))
|
|
206
|
+
if (excludedIndices.has(commitmentIndex)) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
207
209
|
|
|
208
210
|
const commitment = commitments[commitmentIndex];
|
|
209
|
-
if (commitment.equals(Fr.ZERO))
|
|
211
|
+
if (commitment.equals(Fr.ZERO)) {
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
210
214
|
|
|
211
215
|
const expectedNonce = computeCommitmentNonce(firstNullifier, commitmentIndex);
|
|
212
216
|
({ innerNoteHash, siloedNoteHash, uniqueSiloedNoteHash, innerNullifier } =
|
|
@@ -43,7 +43,7 @@ export async function createPXEService(
|
|
|
43
43
|
: undefined
|
|
44
44
|
: useLogSuffix;
|
|
45
45
|
|
|
46
|
-
keyStore = keyStore || new TestKeyStore(
|
|
46
|
+
keyStore = keyStore || new TestKeyStore(new Grumpkin());
|
|
47
47
|
db = db || new MemoryDB(logSuffix);
|
|
48
48
|
|
|
49
49
|
const server = new PXEService(keyStore, aztecNode, db, config, logSuffix);
|
|
@@ -119,8 +119,12 @@ export class PXEService implements PXE {
|
|
|
119
119
|
return this.db.addAuthWitness(witness.requestHash, witness.witness);
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
public addCapsule(capsule: Fr[]) {
|
|
123
|
+
return this.db.addCapsule(capsule);
|
|
124
|
+
}
|
|
125
|
+
|
|
122
126
|
public async registerAccount(privKey: GrumpkinPrivateKey, partialAddress: PartialAddress): Promise<CompleteAddress> {
|
|
123
|
-
const completeAddress =
|
|
127
|
+
const completeAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(privKey, partialAddress);
|
|
124
128
|
const wasAdded = await this.db.addCompleteAddress(completeAddress);
|
|
125
129
|
if (wasAdded) {
|
|
126
130
|
const pubKey = this.keyStore.addAccount(privKey);
|
|
@@ -276,7 +280,9 @@ export class PXEService implements PXE {
|
|
|
276
280
|
const commitments = tx.newCommitments;
|
|
277
281
|
for (let i = 0; i < commitments.length; ++i) {
|
|
278
282
|
const commitment = commitments[i];
|
|
279
|
-
if (commitment.equals(Fr.ZERO))
|
|
283
|
+
if (commitment.equals(Fr.ZERO)) {
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
280
286
|
|
|
281
287
|
const nonce = computeCommitmentNonce(firstNullifier, i);
|
|
282
288
|
const { siloedNoteHash, uniqueSiloedNoteHash } = await this.simulator.computeNoteHashAndNullifier(
|
|
@@ -321,7 +327,9 @@ export class PXEService implements PXE {
|
|
|
321
327
|
const newContract = deployedContractAddress ? await this.db.getContract(deployedContractAddress) : undefined;
|
|
322
328
|
|
|
323
329
|
const tx = await this.#simulateAndProve(txRequest, newContract);
|
|
324
|
-
if (simulatePublic)
|
|
330
|
+
if (simulatePublic) {
|
|
331
|
+
await this.#simulatePublicCalls(tx);
|
|
332
|
+
}
|
|
325
333
|
this.log.info(`Executed local simulation for ${await tx.getTxHash()}`);
|
|
326
334
|
|
|
327
335
|
return tx;
|
|
@@ -12,13 +12,10 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
|
|
|
12
12
|
}, 120_000);
|
|
13
13
|
|
|
14
14
|
it('registers an account and returns it as an account only and not as a recipient', async () => {
|
|
15
|
-
const keyPair = ConstantKeyPair.random(
|
|
16
|
-
const completeAddress =
|
|
17
|
-
await keyPair.getPrivateKey(),
|
|
18
|
-
Fr.random(),
|
|
19
|
-
);
|
|
15
|
+
const keyPair = ConstantKeyPair.random(new Grumpkin());
|
|
16
|
+
const completeAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(keyPair.getPrivateKey(), Fr.random());
|
|
20
17
|
|
|
21
|
-
await pxe.registerAccount(
|
|
18
|
+
await pxe.registerAccount(keyPair.getPrivateKey(), completeAddress.partialAddress);
|
|
22
19
|
|
|
23
20
|
// Check that the account is correctly registered using the getAccounts and getRecipients methods
|
|
24
21
|
const accounts = await pxe.getRegisteredAccounts();
|
|
@@ -52,14 +49,11 @@ export const pxeTestSuite = (testName: string, pxeSetup: () => Promise<PXE>) =>
|
|
|
52
49
|
});
|
|
53
50
|
|
|
54
51
|
it('does not throw when registering the same account twice (just ignores the second attempt)', async () => {
|
|
55
|
-
const keyPair = ConstantKeyPair.random(
|
|
56
|
-
const completeAddress =
|
|
57
|
-
await keyPair.getPrivateKey(),
|
|
58
|
-
Fr.random(),
|
|
59
|
-
);
|
|
52
|
+
const keyPair = ConstantKeyPair.random(new Grumpkin());
|
|
53
|
+
const completeAddress = CompleteAddress.fromPrivateKeyAndPartialAddress(keyPair.getPrivateKey(), Fr.random());
|
|
60
54
|
|
|
61
|
-
await pxe.registerAccount(
|
|
62
|
-
await pxe.registerAccount(
|
|
55
|
+
await pxe.registerAccount(keyPair.getPrivateKey(), completeAddress.partialAddress);
|
|
56
|
+
await pxe.registerAccount(keyPair.getPrivateKey(), completeAddress.partialAddress);
|
|
63
57
|
});
|
|
64
58
|
|
|
65
59
|
it('cannot register a recipient with the same aztec address but different pub key or partial address', async () => {
|
|
@@ -31,19 +31,30 @@ export class SimulatorOracle implements DBOracle {
|
|
|
31
31
|
|
|
32
32
|
async getCompleteAddress(address: AztecAddress): Promise<CompleteAddress> {
|
|
33
33
|
const completeAddress = await this.db.getCompleteAddress(address);
|
|
34
|
-
if (!completeAddress)
|
|
34
|
+
if (!completeAddress) {
|
|
35
35
|
throw new Error(
|
|
36
36
|
`No public key registered for address ${address.toString()}. Register it by calling pxe.registerRecipient(...) or pxe.registerAccount(...).\nSee docs for context: https://docs.aztec.network/dev_docs/contracts/common_errors#no-public-key-registered-error`,
|
|
37
37
|
);
|
|
38
|
+
}
|
|
38
39
|
return completeAddress;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
async getAuthWitness(messageHash: Fr): Promise<Fr[]> {
|
|
42
43
|
const witness = await this.db.getAuthWitness(messageHash);
|
|
43
|
-
if (!witness)
|
|
44
|
+
if (!witness) {
|
|
45
|
+
throw new Error(`Unknown auth witness for message hash ${messageHash.toString()}`);
|
|
46
|
+
}
|
|
44
47
|
return witness;
|
|
45
48
|
}
|
|
46
49
|
|
|
50
|
+
async popCapsule(): Promise<Fr[]> {
|
|
51
|
+
const capsule = await this.db.popCapsule();
|
|
52
|
+
if (!capsule) {
|
|
53
|
+
throw new Error(`No capsules available`);
|
|
54
|
+
}
|
|
55
|
+
return capsule;
|
|
56
|
+
}
|
|
57
|
+
|
|
47
58
|
async getNotes(contractAddress: AztecAddress, storageSlot: Fr) {
|
|
48
59
|
const noteDaos = await this.db.getNotes({ contractAddress, storageSlot });
|
|
49
60
|
return noteDaos.map(({ contractAddress, storageSlot, nonce, note, innerNoteHash, siloedNullifier, index }) => ({
|
|
@@ -39,7 +39,9 @@ export class Synchronizer {
|
|
|
39
39
|
* @param retryInterval - The time interval (in ms) to wait before retrying if no data is available.
|
|
40
40
|
*/
|
|
41
41
|
public async start(from = INITIAL_L2_BLOCK_NUM, limit = 1, retryInterval = 1000) {
|
|
42
|
-
if (this.running)
|
|
42
|
+
if (this.running) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
43
45
|
this.running = true;
|
|
44
46
|
|
|
45
47
|
if (from < this.synchedToBlock + 1) {
|
|
@@ -197,7 +199,9 @@ export class Synchronizer {
|
|
|
197
199
|
|
|
198
200
|
private async setBlockDataFromBlock(latestBlock: L2BlockContext) {
|
|
199
201
|
const { block } = latestBlock;
|
|
200
|
-
if (block.number < this.initialSyncBlockNumber)
|
|
202
|
+
if (block.number < this.initialSyncBlockNumber) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
201
205
|
|
|
202
206
|
const globalsHash = computeGlobalsHash(latestBlock.block.globalVariables);
|
|
203
207
|
const blockData = new HistoricBlockData(
|
|
@@ -241,7 +245,9 @@ export class Synchronizer {
|
|
|
241
245
|
public addAccount(publicKey: PublicKey, keyStore: KeyStore, startingBlock: number) {
|
|
242
246
|
const predicate = (x: NoteProcessor) => x.publicKey.equals(publicKey);
|
|
243
247
|
const processor = this.noteProcessors.find(predicate) ?? this.noteProcessorsToCatchUp.find(predicate);
|
|
244
|
-
if (processor)
|
|
248
|
+
if (processor) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
245
251
|
|
|
246
252
|
this.noteProcessorsToCatchUp.push(new NoteProcessor(publicKey, keyStore, this.db, this.node, startingBlock));
|
|
247
253
|
}
|