@aztec/pxe 0.71.0 → 0.73.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 (43) hide show
  1. package/dest/bin/index.js +1 -3
  2. package/dest/contract_data_oracle/index.js +4 -4
  3. package/dest/contract_data_oracle/private_functions_tree.d.ts +7 -6
  4. package/dest/contract_data_oracle/private_functions_tree.d.ts.map +1 -1
  5. package/dest/contract_data_oracle/private_functions_tree.js +25 -14
  6. package/dest/database/kv_pxe_database.d.ts +3 -3
  7. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  8. package/dest/database/kv_pxe_database.js +8 -9
  9. package/dest/database/note_dao.d.ts +4 -4
  10. package/dest/database/note_dao.d.ts.map +1 -1
  11. package/dest/database/note_dao.js +5 -5
  12. package/dest/database/outgoing_note_dao.d.ts +1 -1
  13. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  14. package/dest/database/outgoing_note_dao.js +3 -3
  15. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  16. package/dest/database/pxe_database_test_suite.js +70 -48
  17. package/dest/kernel_oracle/index.d.ts.map +1 -1
  18. package/dest/kernel_oracle/index.js +5 -5
  19. package/dest/kernel_prover/kernel_prover.js +5 -5
  20. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  21. package/dest/pxe_http/pxe_http_server.js +2 -1
  22. package/dest/pxe_service/error_enriching.js +4 -4
  23. package/dest/pxe_service/pxe_service.d.ts +16 -11
  24. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  25. package/dest/pxe_service/pxe_service.js +62 -53
  26. package/dest/pxe_service/test/pxe_test_suite.js +13 -13
  27. package/dest/simulator_oracle/index.d.ts.map +1 -1
  28. package/dest/simulator_oracle/index.js +36 -21
  29. package/package.json +15 -15
  30. package/src/bin/index.ts +0 -3
  31. package/src/contract_data_oracle/index.ts +3 -3
  32. package/src/contract_data_oracle/private_functions_tree.ts +28 -20
  33. package/src/database/kv_pxe_database.ts +19 -14
  34. package/src/database/note_dao.ts +7 -7
  35. package/src/database/outgoing_note_dao.ts +5 -5
  36. package/src/database/pxe_database_test_suite.ts +71 -56
  37. package/src/kernel_oracle/index.ts +4 -4
  38. package/src/kernel_prover/kernel_prover.ts +4 -4
  39. package/src/pxe_http/pxe_http_server.ts +1 -0
  40. package/src/pxe_service/error_enriching.ts +3 -3
  41. package/src/pxe_service/pxe_service.ts +86 -64
  42. package/src/pxe_service/test/pxe_test_suite.ts +12 -12
  43. package/src/simulator_oracle/index.ts +52 -23
@@ -10,7 +10,7 @@ import {
10
10
  } from '@aztec/circuits.js';
11
11
  import { type ContractArtifact, FunctionSelector, FunctionType } from '@aztec/foundation/abi';
12
12
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
13
- import { Fr } from '@aztec/foundation/fields';
13
+ import { Fr, type Point } from '@aztec/foundation/fields';
14
14
  import { toArray } from '@aztec/foundation/iterable';
15
15
  import { type LogFn, createDebugOnlyLogger } from '@aztec/foundation/log';
16
16
  import {
@@ -135,14 +135,17 @@ export class KVPxeDatabase implements PxeDatabase {
135
135
  }
136
136
 
137
137
  public async addContractArtifact(id: Fr, contract: ContractArtifact): Promise<void> {
138
- const privateSelectors = contract.functions
139
- .filter(functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE)
140
- .map(privateFunctionArtifact =>
141
- FunctionSelector.fromNameAndParameters(
142
- privateFunctionArtifact.name,
143
- privateFunctionArtifact.parameters,
138
+ const privateFunctions = contract.functions.filter(
139
+ functionArtifact => functionArtifact.functionType === FunctionType.PRIVATE,
140
+ );
141
+
142
+ const privateSelectors = await Promise.all(
143
+ privateFunctions.map(async privateFunctionArtifact =>
144
+ (
145
+ await FunctionSelector.fromNameAndParameters(privateFunctionArtifact.name, privateFunctionArtifact.parameters)
144
146
  ).toString(),
145
- );
147
+ ),
148
+ );
146
149
 
147
150
  if (privateSelectors.length !== new Set(privateSelectors).size) {
148
151
  throw new Error('Repeated function selectors of private functions');
@@ -297,7 +300,7 @@ export class KVPxeDatabase implements PxeDatabase {
297
300
  }
298
301
 
299
302
  async getNotes(filter: NotesFilter): Promise<NoteDao[]> {
300
- const publicKey: PublicKey | undefined = filter.owner ? filter.owner.toAddressPoint() : undefined;
303
+ const publicKey: PublicKey | undefined = filter.owner ? await filter.owner.toAddressPoint() : undefined;
301
304
 
302
305
  filter.status = filter.status ?? NoteStatus.ACTIVE;
303
306
 
@@ -311,7 +314,7 @@ export class KVPxeDatabase implements PxeDatabase {
311
314
 
312
315
  for (const scope of new Set(filter.scopes)) {
313
316
  const formattedScopeString = scope.toString();
314
- if (!this.#scopes.hasAsync(formattedScopeString)) {
317
+ if (!(await this.#scopes.hasAsync(formattedScopeString))) {
315
318
  throw new Error('Trying to get incoming notes of an scope that is not in the PXE database');
316
319
  }
317
320
 
@@ -394,7 +397,7 @@ export class KVPxeDatabase implements PxeDatabase {
394
397
  return result;
395
398
  }
396
399
 
397
- removeNullifiedNotes(nullifiers: InBlock<Fr>[], accountAddressPoint: PublicKey): Promise<NoteDao[]> {
400
+ removeNullifiedNotes(nullifiers: InBlock<Fr>[], accountAddressPoint: Point): Promise<NoteDao[]> {
398
401
  if (nullifiers.length === 0) {
399
402
  return Promise.resolve([]);
400
403
  }
@@ -537,7 +540,7 @@ export class KVPxeDatabase implements PxeDatabase {
537
540
  }
538
541
 
539
542
  const value = await this.#completeAddresses.atAsync(index);
540
- return value ? CompleteAddress.fromBuffer(value) : undefined;
543
+ return value ? await CompleteAddress.fromBuffer(value) : undefined;
541
544
  }
542
545
 
543
546
  getCompleteAddress(account: AztecAddress): Promise<CompleteAddress | undefined> {
@@ -545,7 +548,9 @@ export class KVPxeDatabase implements PxeDatabase {
545
548
  }
546
549
 
547
550
  async getCompleteAddresses(): Promise<CompleteAddress[]> {
548
- return (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v));
551
+ return await Promise.all(
552
+ (await toArray(this.#completeAddresses.valuesAsync())).map(v => CompleteAddress.fromBuffer(v)),
553
+ );
549
554
  }
550
555
 
551
556
  async addSenderAddress(address: AztecAddress): Promise<boolean> {
@@ -563,7 +568,7 @@ export class KVPxeDatabase implements PxeDatabase {
563
568
  }
564
569
 
565
570
  async removeSenderAddress(address: AztecAddress): Promise<boolean> {
566
- if (!this.#addressBook.hasAsync(address.toString())) {
571
+ if (!(await this.#addressBook.hasAsync(address.toString()))) {
567
572
  return false;
568
573
  }
569
574
 
@@ -6,14 +6,14 @@ import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
6
6
  import { type NoteData } from '@aztec/simulator/client';
7
7
 
8
8
  /**
9
- * A Note Data Access Object, representing a note that was comitted to the note hash tree, holding all of the
9
+ * A Note Data Access Object, representing a note that was committed to the note hash tree, holding all of the
10
10
  * information required to use it during execution and manage its state.
11
11
  */
12
12
  export class NoteDao implements NoteData {
13
13
  constructor(
14
14
  // Note information
15
15
 
16
- /** The serialized content of the note, as will be returned in the getNotes oracle. */
16
+ /** The packed content of the note, as will be returned in the getNotes oracle. */
17
17
  public note: Note,
18
18
  /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
19
19
  public contractAddress: AztecAddress,
@@ -127,9 +127,9 @@ export class NoteDao implements NoteData {
127
127
  return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 4 + TxHash.SIZE + Point.SIZE_IN_BYTES + indexSize;
128
128
  }
129
129
 
130
- static random({
130
+ static async random({
131
131
  note = Note.random(),
132
- contractAddress = AztecAddress.random(),
132
+ contractAddress = undefined,
133
133
  storageSlot = Fr.random(),
134
134
  nonce = Fr.random(),
135
135
  noteHash = Fr.random(),
@@ -138,12 +138,12 @@ export class NoteDao implements NoteData {
138
138
  l2BlockNumber = Math.floor(Math.random() * 1000),
139
139
  l2BlockHash = Fr.random().toString(),
140
140
  index = Fr.random().toBigInt(),
141
- addressPoint = Point.random(),
141
+ addressPoint = undefined,
142
142
  noteTypeId = NoteSelector.random(),
143
143
  }: Partial<NoteDao> = {}) {
144
144
  return new NoteDao(
145
145
  note,
146
- contractAddress,
146
+ contractAddress ?? (await AztecAddress.random()),
147
147
  storageSlot,
148
148
  nonce,
149
149
  noteHash,
@@ -152,7 +152,7 @@ export class NoteDao implements NoteData {
152
152
  l2BlockNumber,
153
153
  l2BlockHash,
154
154
  index,
155
- addressPoint,
155
+ addressPoint ?? (await Point.random()),
156
156
  noteTypeId,
157
157
  );
158
158
  }
@@ -99,9 +99,9 @@ export class OutgoingNoteDao {
99
99
  return noteSize + AztecAddress.SIZE_IN_BYTES + Fr.SIZE_IN_BYTES * 2 + TxHash.SIZE + Point.SIZE_IN_BYTES;
100
100
  }
101
101
 
102
- static random({
102
+ static async random({
103
103
  note = Note.random(),
104
- contractAddress = AztecAddress.random(),
104
+ contractAddress = undefined,
105
105
  txHash = randomTxHash(),
106
106
  storageSlot = Fr.random(),
107
107
  noteTypeId = NoteSelector.random(),
@@ -110,11 +110,11 @@ export class OutgoingNoteDao {
110
110
  l2BlockHash = Fr.random().toString(),
111
111
  noteHash = Fr.random(),
112
112
  index = Fr.random().toBigInt(),
113
- ovpkM = Point.random(),
113
+ ovpkM = undefined,
114
114
  }: Partial<OutgoingNoteDao> = {}) {
115
115
  return new OutgoingNoteDao(
116
116
  note,
117
- contractAddress,
117
+ contractAddress ?? (await AztecAddress.random()),
118
118
  storageSlot,
119
119
  noteTypeId,
120
120
  txHash,
@@ -123,7 +123,7 @@ export class OutgoingNoteDao {
123
123
  nonce,
124
124
  noteHash,
125
125
  index,
126
- ovpkM,
126
+ ovpkM ?? (await Point.random()),
127
127
  );
128
128
  }
129
129
  }
@@ -8,11 +8,14 @@ import {
8
8
  } from '@aztec/circuits.js';
9
9
  import { makeHeader } from '@aztec/circuits.js/testing';
10
10
  import { FunctionType } from '@aztec/foundation/abi';
11
+ import { timesParallel } from '@aztec/foundation/collection';
11
12
  import { randomInt } from '@aztec/foundation/crypto';
12
13
  import { Fr, Point } from '@aztec/foundation/fields';
13
14
  import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking';
14
15
  import { TestContractArtifact } from '@aztec/noir-contracts.js/Test';
15
16
 
17
+ import times from 'lodash.times';
18
+
16
19
  import { NoteDao } from './note_dao.js';
17
20
  import { type PxeDatabase } from './pxe_database.js';
18
21
 
@@ -80,53 +83,62 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
80
83
  let storageSlots: Fr[];
81
84
  let notes: NoteDao[];
82
85
 
83
- const filteringTests: [() => NotesFilter, () => NoteDao[]][] = [
84
- [() => ({}), () => notes],
86
+ const filteringTests: [() => Promise<NotesFilter>, () => Promise<NoteDao[]>][] = [
87
+ [() => Promise.resolve({}), () => Promise.resolve(notes)],
85
88
 
86
89
  [
87
- () => ({ contractAddress: contractAddresses[0] }),
88
- () => notes.filter(note => note.contractAddress.equals(contractAddresses[0])),
90
+ () => Promise.resolve({ contractAddress: contractAddresses[0] }),
91
+ () => Promise.resolve(notes.filter(note => note.contractAddress.equals(contractAddresses[0]))),
89
92
  ],
90
- [() => ({ contractAddress: AztecAddress.random() }), () => []],
93
+ [async () => ({ contractAddress: await AztecAddress.random() }), () => Promise.resolve([])],
91
94
 
92
95
  [
93
- () => ({ storageSlot: storageSlots[0] }),
94
- () => notes.filter(note => note.storageSlot.equals(storageSlots[0])),
96
+ () => Promise.resolve({ storageSlot: storageSlots[0] }),
97
+ () => Promise.resolve(notes.filter(note => note.storageSlot.equals(storageSlots[0]))),
95
98
  ],
96
- [() => ({ storageSlot: Fr.random() }), () => []],
99
+ [() => Promise.resolve({ storageSlot: Fr.random() }), () => Promise.resolve([])],
97
100
 
98
- [() => ({ txHash: notes[0].txHash }), () => [notes[0]]],
99
- [() => ({ txHash: randomTxHash() }), () => []],
101
+ [() => Promise.resolve({ txHash: notes[0].txHash }), () => Promise.resolve([notes[0]])],
102
+ [() => Promise.resolve({ txHash: randomTxHash() }), () => Promise.resolve([])],
100
103
 
101
104
  [
102
- () => ({ owner: owners[0].address }),
103
- () => notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint())),
105
+ () => Promise.resolve({ owner: owners[0].address }),
106
+ async () => {
107
+ const ownerAddressPoint = await owners[0].address.toAddressPoint();
108
+ return notes.filter(note => note.addressPoint.equals(ownerAddressPoint));
109
+ },
104
110
  ],
105
111
 
106
112
  [
107
- () => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[0] }),
113
+ () => Promise.resolve({ contractAddress: contractAddresses[0], storageSlot: storageSlots[0] }),
108
114
  () =>
109
- notes.filter(
110
- note => note.contractAddress.equals(contractAddresses[0]) && note.storageSlot.equals(storageSlots[0]),
115
+ Promise.resolve(
116
+ notes.filter(
117
+ note => note.contractAddress.equals(contractAddresses[0]) && note.storageSlot.equals(storageSlots[0]),
118
+ ),
111
119
  ),
112
120
  ],
113
- [() => ({ contractAddress: contractAddresses[0], storageSlot: storageSlots[1] }), () => []],
121
+ [
122
+ () => Promise.resolve({ contractAddress: contractAddresses[0], storageSlot: storageSlots[1] }),
123
+ () => Promise.resolve([]),
124
+ ],
114
125
  ];
115
126
 
116
127
  beforeEach(async () => {
117
- owners = Array.from({ length: 2 }).map(() => CompleteAddress.random());
118
- contractAddresses = Array.from({ length: 2 }).map(() => AztecAddress.random());
119
- storageSlots = Array.from({ length: 2 }).map(() => Fr.random());
128
+ owners = await timesParallel(2, () => CompleteAddress.random());
129
+ contractAddresses = await timesParallel(2, () => AztecAddress.random());
130
+ storageSlots = times(2, () => Fr.random());
120
131
 
121
- notes = Array.from({ length: 10 }).map((_, i) =>
122
- NoteDao.random({
132
+ notes = await timesParallel(10, async i => {
133
+ const addressPoint = await owners[i % owners.length].address.toAddressPoint();
134
+ return NoteDao.random({
123
135
  contractAddress: contractAddresses[i % contractAddresses.length],
124
136
  storageSlot: storageSlots[i % storageSlots.length],
125
- addressPoint: owners[i % owners.length].address.toAddressPoint(),
137
+ addressPoint,
126
138
  index: BigInt(i),
127
139
  l2BlockNumber: i,
128
- }),
129
- );
140
+ });
141
+ });
130
142
 
131
143
  for (const owner of owners) {
132
144
  await database.addCompleteAddress(owner);
@@ -135,9 +147,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
135
147
 
136
148
  it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
137
149
  await database.addNotes(notes);
138
- const returnedNotes = await database.getNotes(getFilter());
139
-
140
- expect(returnedNotes.sort()).toEqual(getExpected().sort());
150
+ const returnedNotes = await database.getNotes(await getFilter());
151
+ const expected = await getExpected();
152
+ expect(returnedNotes.sort()).toEqual(expected.sort());
141
153
  });
142
154
 
143
155
  it.each(filteringTests)('stores notes one by one and retrieves notes', async (getFilter, getExpected) => {
@@ -145,9 +157,10 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
145
157
  await database.addNote(note);
146
158
  }
147
159
 
148
- const returnedNotes = await database.getNotes(getFilter());
160
+ const returnedNotes = await database.getNotes(await getFilter());
149
161
 
150
- expect(returnedNotes.sort()).toEqual(getExpected().sort());
162
+ const expected = await getExpected();
163
+ expect(returnedNotes.sort()).toEqual(expected.sort());
151
164
  });
152
165
 
153
166
  it.each(filteringTests)('retrieves nullified notes', async (getFilter, getExpected) => {
@@ -155,26 +168,25 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
155
168
 
156
169
  // Nullify all notes and use the same filter as other test cases
157
170
  for (const owner of owners) {
158
- const notesToNullify = notes.filter(note => note.addressPoint.equals(owner.address.toAddressPoint()));
171
+ const ownerAddressPoint = await owner.address.toAddressPoint();
172
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(ownerAddressPoint));
159
173
  const nullifiers = notesToNullify.map(note => ({
160
174
  data: note.siloedNullifier,
161
175
  l2BlockNumber: note.l2BlockNumber,
162
176
  l2BlockHash: note.l2BlockHash,
163
177
  }));
164
- await expect(database.removeNullifiedNotes(nullifiers, owner.address.toAddressPoint())).resolves.toEqual(
165
- notesToNullify,
166
- );
178
+ await expect(database.removeNullifiedNotes(nullifiers, ownerAddressPoint)).resolves.toEqual(notesToNullify);
167
179
  }
168
-
169
- await expect(database.getNotes({ ...getFilter(), status: NoteStatus.ACTIVE_OR_NULLIFIED })).resolves.toEqual(
170
- getExpected(),
171
- );
180
+ const filter = await getFilter();
181
+ const returnedNotes = await database.getNotes({ ...filter, status: NoteStatus.ACTIVE_OR_NULLIFIED });
182
+ const expected = await getExpected();
183
+ expect(returnedNotes.sort()).toEqual(expected.sort());
172
184
  });
173
185
 
174
186
  it('skips nullified notes by default or when requesting active', async () => {
175
187
  await database.addNotes(notes);
176
-
177
- const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
188
+ const ownerAddressPoint = await owners[0].address.toAddressPoint();
189
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(ownerAddressPoint));
178
190
  const nullifiers = notesToNullify.map(note => ({
179
191
  data: note.siloedNullifier,
180
192
  l2BlockNumber: note.l2BlockNumber,
@@ -194,8 +206,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
194
206
  it('handles note unnullification', async () => {
195
207
  await database.setHeader(makeHeader(randomInt(1000), 100, 0 /** slot number */));
196
208
  await database.addNotes(notes);
209
+ const ownerAddressPoint = await owners[0].address.toAddressPoint();
197
210
 
198
- const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
211
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(ownerAddressPoint));
199
212
  const nullifiers = notesToNullify.map(note => ({
200
213
  data: note.siloedNullifier,
201
214
  l2BlockNumber: 99,
@@ -213,8 +226,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
213
226
 
214
227
  it('returns active and nullified notes when requesting either', async () => {
215
228
  await database.addNotes(notes);
229
+ const ownerAddressPoint = await owners[0].address.toAddressPoint();
216
230
 
217
- const notesToNullify = notes.filter(note => note.addressPoint.equals(owners[0].address.toAddressPoint()));
231
+ const notesToNullify = notes.filter(note => note.addressPoint.equals(ownerAddressPoint));
218
232
  const nullifiers = notesToNullify.map(note => ({
219
233
  data: note.siloedNullifier,
220
234
  l2BlockNumber: note.l2BlockNumber,
@@ -275,7 +289,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
275
289
  scopes: [owners[1].address],
276
290
  }),
277
291
  ).resolves.toEqual([notes[0]]);
278
-
292
+ const ownerAddressPoint = await owners[0].address.toAddressPoint();
279
293
  await expect(
280
294
  database.removeNullifiedNotes(
281
295
  [
@@ -285,7 +299,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
285
299
  l2BlockNumber: notes[0].l2BlockNumber,
286
300
  },
287
301
  ],
288
- owners[0].address.toAddressPoint(),
302
+ ownerAddressPoint,
289
303
  ),
290
304
  ).resolves.toEqual([notes[0]]);
291
305
 
@@ -325,22 +339,22 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
325
339
 
326
340
  describe('addresses', () => {
327
341
  it('stores and retrieves addresses', async () => {
328
- const address = CompleteAddress.random();
342
+ const address = await CompleteAddress.random();
329
343
  await expect(database.addCompleteAddress(address)).resolves.toBe(true);
330
344
  await expect(database.getCompleteAddress(address.address)).resolves.toEqual(address);
331
345
  });
332
346
 
333
347
  it('silently ignores an address it already knows about', async () => {
334
- const address = CompleteAddress.random();
348
+ const address = await CompleteAddress.random();
335
349
  await expect(database.addCompleteAddress(address)).resolves.toBe(true);
336
350
  await expect(database.addCompleteAddress(address)).resolves.toBe(false);
337
351
  });
338
352
 
339
353
  it.skip('refuses to overwrite an address with a different public key', async () => {
340
- const address = CompleteAddress.random();
341
- const otherAddress = new CompleteAddress(
354
+ const address = await CompleteAddress.random();
355
+ const otherAddress = await CompleteAddress.create(
342
356
  address.address,
343
- new PublicKeys(Point.random(), Point.random(), Point.random(), Point.random()),
357
+ new PublicKeys(await Point.random(), await Point.random(), await Point.random(), await Point.random()),
344
358
  address.partialAddress,
345
359
  );
346
360
 
@@ -349,7 +363,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
349
363
  });
350
364
 
351
365
  it('returns all addresses', async () => {
352
- const addresses = Array.from({ length: 10 }).map(() => CompleteAddress.random());
366
+ const addresses = await timesParallel(10, () => CompleteAddress.random());
353
367
  for (const address of addresses) {
354
368
  await database.addCompleteAddress(address);
355
369
  }
@@ -359,7 +373,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
359
373
  });
360
374
 
361
375
  it('returns a single address', async () => {
362
- const addresses = Array.from({ length: 10 }).map(() => CompleteAddress.random());
376
+ const addresses = await timesParallel(10, () => CompleteAddress.random());
363
377
  for (const address of addresses) {
364
378
  await database.addCompleteAddress(address);
365
379
  }
@@ -373,7 +387,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
373
387
  });
374
388
 
375
389
  it("returns undefined if it doesn't have an address", async () => {
376
- expect(await database.getCompleteAddress(CompleteAddress.random().address)).toBeUndefined();
390
+ const completeAddress = await CompleteAddress.random();
391
+ expect(await database.getCompleteAddress(completeAddress.address)).toBeUndefined();
377
392
  });
378
393
  });
379
394
 
@@ -399,8 +414,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
399
414
  });
400
415
 
401
416
  it('stores a contract instance', async () => {
402
- const address = AztecAddress.random();
403
- const instance = SerializableContractInstance.random().withAddress(address);
417
+ const address = await AztecAddress.random();
418
+ const instance = (await SerializableContractInstance.random()).withAddress(address);
404
419
  await database.addContractInstance(instance);
405
420
  await expect(database.getContractInstance(address)).resolves.toEqual(instance);
406
421
  });
@@ -409,9 +424,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
409
424
  describe('contract non-volatile database', () => {
410
425
  let contract: AztecAddress;
411
426
 
412
- beforeEach(() => {
427
+ beforeEach(async () => {
413
428
  // Setup mock contract address
414
- contract = AztecAddress.random();
429
+ contract = await AztecAddress.random();
415
430
  });
416
431
 
417
432
  it('stores and loads a single value', async () => {
@@ -445,7 +460,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
445
460
  });
446
461
 
447
462
  it('stores values for different contracts independently', async () => {
448
- const anotherContract = AztecAddress.random();
463
+ const anotherContract = await AztecAddress.random();
449
464
  const slot = new Fr(1);
450
465
  const values1 = [new Fr(42)];
451
466
  const values2 = [new Fr(100)];
@@ -37,7 +37,7 @@ export class KernelOracle implements ProvingDataOracle {
37
37
  public async getContractAddressPreimage(address: AztecAddress) {
38
38
  const instance = await this.contractDataOracle.getContractInstance(address);
39
39
  return {
40
- saltedInitializationHash: computeSaltedInitializationHash(instance),
40
+ saltedInitializationHash: await computeSaltedInitializationHash(instance),
41
41
  ...instance,
42
42
  };
43
43
  }
@@ -51,9 +51,9 @@ export class KernelOracle implements ProvingDataOracle {
51
51
  return await this.contractDataOracle.getFunctionMembershipWitness(contractAddress, selector);
52
52
  }
53
53
 
54
- public getVkMembershipWitness(vk: VerificationKeyAsFields) {
55
- const leafIndex = getVKIndex(vk);
56
- return Promise.resolve(new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)));
54
+ public async getVkMembershipWitness(vk: VerificationKeyAsFields) {
55
+ const leafIndex = await getVKIndex(vk);
56
+ return new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), await getVKSiblingPath(leafIndex));
57
57
  }
58
58
 
59
59
  async getNoteHashMembershipWitness(leafIndex: bigint): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT>> {
@@ -214,7 +214,7 @@ export class KernelProver {
214
214
  if (firstIteration) {
215
215
  const proofInput = new PrivateKernelInitCircuitPrivateInputs(
216
216
  txRequest,
217
- getVKTreeRoot(),
217
+ await getVKTreeRoot(),
218
218
  protocolContractTreeRoot,
219
219
  privateCallData,
220
220
  isPrivateOnlyTx,
@@ -339,8 +339,8 @@ export class KernelProver {
339
339
  private async createPrivateCallData({ publicInputs, vk: vkAsBuffer }: PrivateCallExecutionResult) {
340
340
  const { contractAddress, functionSelector } = publicInputs.callContext;
341
341
 
342
- const vkAsFields = vkAsFieldsMegaHonk(vkAsBuffer);
343
- const vk = new VerificationKeyAsFields(vkAsFields, hashVK(vkAsFields));
342
+ const vkAsFields = await vkAsFieldsMegaHonk(vkAsBuffer);
343
+ const vk = new VerificationKeyAsFields(vkAsFields, await hashVK(vkAsFields));
344
344
 
345
345
  const functionLeafMembershipWitness = await this.oracle.getFunctionMembershipWitness(
346
346
  contractAddress,
@@ -357,7 +357,7 @@ export class KernelProver {
357
357
  const acirHash = Fr.fromBuffer(Buffer.alloc(32, 0));
358
358
 
359
359
  const protocolContractSiblingPath = isProtocolContract(contractAddress)
360
- ? getProtocolContractSiblingPath(contractAddress)
360
+ ? await getProtocolContractSiblingPath(contractAddress)
361
361
  : makeTuple(PROTOCOL_CONTRACT_TREE_HEIGHT, Fr.zero);
362
362
 
363
363
  return PrivateCallData.from({
@@ -21,6 +21,7 @@ export function startPXEHttpServer(pxeService: PXE, port: string | number): http
21
21
  const rpcServer = createNamespacedSafeJsonRpcServer({ pxe: [pxeService, PXESchema] });
22
22
 
23
23
  const app = rpcServer.getApp();
24
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
24
25
  const httpServer = http.createServer(app.callback());
25
26
  httpServer.listen(port);
26
27
 
@@ -32,12 +32,12 @@ export async function enrichSimulationError(err: SimulationError, db: PxeDatabas
32
32
  const contract = await db.getContract(parsedContractAddress);
33
33
  if (contract) {
34
34
  err.enrichWithContractName(parsedContractAddress, contract.name);
35
- fnNames.forEach(fnName => {
35
+ for (const fnName of fnNames) {
36
36
  const functionArtifact = contract.functions.find(f => fnName === f.name);
37
37
  if (functionArtifact) {
38
38
  err.enrichWithFunctionName(
39
39
  parsedContractAddress,
40
- FunctionSelector.fromNameAndParameters(functionArtifact),
40
+ await FunctionSelector.fromNameAndParameters(functionArtifact),
41
41
  functionArtifact.name,
42
42
  );
43
43
  } else {
@@ -45,7 +45,7 @@ export async function enrichSimulationError(err: SimulationError, db: PxeDatabas
45
45
  `Could not find function artifact in contract ${contract.name} for function '${fnName}' when enriching error callstack`,
46
46
  );
47
47
  }
48
- });
48
+ }
49
49
  } else {
50
50
  logger.warn(
51
51
  `Could not find contract in database for address: ${parsedContractAddress} when enriching error callstack`,