@aztec/pxe 0.69.0-devnet → 0.69.1-devnet

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 (59) hide show
  1. package/dest/database/kv_pxe_database.d.ts +11 -7
  2. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  3. package/dest/database/kv_pxe_database.js +36 -13
  4. package/dest/database/note_dao.d.ts +105 -0
  5. package/dest/database/note_dao.d.ts.map +1 -0
  6. package/dest/database/note_dao.js +123 -0
  7. package/dest/database/outgoing_note_dao.js +3 -3
  8. package/dest/database/pxe_database.d.ts +25 -9
  9. package/dest/database/pxe_database.d.ts.map +1 -1
  10. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  11. package/dest/database/pxe_database_test_suite.js +68 -21
  12. package/dest/kernel_oracle/index.js +2 -2
  13. package/dest/kernel_prover/hints/build_private_kernel_reset_private_inputs.js +2 -2
  14. package/dest/kernel_prover/index.d.ts +0 -1
  15. package/dest/kernel_prover/index.d.ts.map +1 -1
  16. package/dest/kernel_prover/index.js +1 -2
  17. package/dest/kernel_prover/kernel_prover.d.ts +8 -2
  18. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  19. package/dest/kernel_prover/kernel_prover.js +32 -12
  20. package/dest/note_decryption_utils/brute_force_note_info.d.ts +1 -1
  21. package/dest/note_decryption_utils/brute_force_note_info.d.ts.map +1 -1
  22. package/dest/note_decryption_utils/brute_force_note_info.js +2 -3
  23. package/dest/note_decryption_utils/produce_note_daos.d.ts +3 -3
  24. package/dest/note_decryption_utils/produce_note_daos.d.ts.map +1 -1
  25. package/dest/note_decryption_utils/produce_note_daos.js +6 -6
  26. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts +1 -1
  27. package/dest/note_decryption_utils/produce_note_daos_for_key.d.ts.map +1 -1
  28. package/dest/note_decryption_utils/produce_note_daos_for_key.js +3 -3
  29. package/dest/pxe_service/pxe_service.d.ts +3 -2
  30. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  31. package/dest/pxe_service/pxe_service.js +34 -42
  32. package/dest/simulator_oracle/index.d.ts +18 -3
  33. package/dest/simulator_oracle/index.d.ts.map +1 -1
  34. package/dest/simulator_oracle/index.js +63 -37
  35. package/dest/utils/create_pxe_service.d.ts.map +1 -1
  36. package/dest/utils/create_pxe_service.js +3 -8
  37. package/package.json +14 -15
  38. package/src/database/kv_pxe_database.ts +46 -16
  39. package/src/database/{incoming_note_dao.ts → note_dao.ts} +65 -48
  40. package/src/database/outgoing_note_dao.ts +2 -2
  41. package/src/database/pxe_database.ts +27 -9
  42. package/src/database/pxe_database_test_suite.ts +86 -25
  43. package/src/kernel_oracle/index.ts +1 -1
  44. package/src/kernel_prover/hints/build_private_kernel_reset_private_inputs.ts +1 -1
  45. package/src/kernel_prover/index.ts +0 -2
  46. package/src/kernel_prover/kernel_prover.ts +41 -11
  47. package/src/note_decryption_utils/brute_force_note_info.ts +1 -1
  48. package/src/note_decryption_utils/produce_note_daos.ts +8 -6
  49. package/src/note_decryption_utils/produce_note_daos_for_key.ts +2 -0
  50. package/src/pxe_service/pxe_service.ts +42 -63
  51. package/src/simulator_oracle/index.ts +54 -24
  52. package/src/utils/create_pxe_service.ts +2 -8
  53. package/dest/database/incoming_note_dao.d.ts +0 -86
  54. package/dest/database/incoming_note_dao.d.ts.map +0 -1
  55. package/dest/database/incoming_note_dao.js +0 -110
  56. package/dest/kernel_prover/test/test_circuit_prover.d.ts +0 -20
  57. package/dest/kernel_prover/test/test_circuit_prover.d.ts.map +0 -1
  58. package/dest/kernel_prover/test/test_circuit_prover.js +0 -75
  59. package/src/kernel_prover/test/test_circuit_prover.ts +0 -122
@@ -8,40 +8,57 @@ import { type NoteData } from '@aztec/simulator/acvm';
8
8
  import { type NoteInfo } from '../note_decryption_utils/index.js';
9
9
 
10
10
  /**
11
- * A note with contextual data which was decrypted as incoming.
11
+ * A Note Data Access Object, representing a note that was comitted to the note hash tree, holding all of the
12
+ * information required to use it during execution and manage its state.
12
13
  */
13
- export class IncomingNoteDao implements NoteData {
14
+ export class NoteDao implements NoteData {
14
15
  constructor(
15
- /** The note as emitted from the Noir contract. */
16
+ // Note information
17
+
18
+ /** The serialized content of the note, as will be returned in the getNotes oracle. */
16
19
  public note: Note,
17
- /** The contract address this note is created in. */
20
+ /** The address of the contract that created the note (i.e. the address used by the kernel during siloing). */
18
21
  public contractAddress: AztecAddress,
19
- /** The specific storage location of the note on the contract. */
22
+ /**
23
+ * The storage location of the note. This value is not used for anything in PXE, but we do index by storage slot
24
+ * since contracts typically make queries based on it.
25
+ * */
20
26
  public storageSlot: Fr,
21
- /** The note type identifier for the contract. */
22
- public noteTypeId: NoteSelector,
23
- /** The hash of the tx the note was created in. */
24
- public txHash: TxHash,
25
- /** The L2 block number in which the tx with this note was included. */
26
- public l2BlockNumber: number,
27
- /** The L2 block hash in which the tx with this note was included. */
28
- public l2BlockHash: string,
29
- /** The nonce of the note. */
27
+ /** The kernel-provided nonce of the note, required to compute the uniqueNoteHash. */
30
28
  public nonce: Fr,
29
+
30
+ // Computed values
31
31
  /**
32
- * A hash of the note. This is customizable by the app circuit.
33
- * We can use this value to compute siloedNoteHash and uniqueSiloedNoteHash.
32
+ * The inner hash (non-unique, non-siloed) of the note. Each contract determines how the note content is hashed. Can
33
+ * be used alongside contractAddress and nonce to compute the uniqueNoteHash and the siloedNoteHash.
34
34
  */
35
35
  public noteHash: Fr,
36
36
  /**
37
- * The nullifier of the note (siloed by contract address).
37
+ * The nullifier of the note, siloed by contract address.
38
38
  * Note: Might be set as 0 if the note was added to PXE as nullified.
39
39
  */
40
40
  public siloedNullifier: Fr,
41
- /** The location of the relevant note in the note hash tree. */
41
+
42
+ // Metadata
43
+ /** The hash of the tx in which this note was created. Knowing the tx hash allows for efficient node queries e.g.
44
+ * when searching for txEffects.
45
+ */
46
+ public txHash: TxHash,
47
+ /** The L2 block number in which the tx with this note was included. Used for note management while processing
48
+ * reorgs.*/
49
+ public l2BlockNumber: number,
50
+ /** The L2 block hash in which the tx with this note was included. Used for note management while processing
51
+ * reorgs.*/
52
+ public l2BlockHash: string,
53
+ /** The index of the leaf in the global note hash tree the note is stored at */
42
54
  public index: bigint,
43
- /** The public key with which the note was encrypted. */
55
+ /** The public key with which the note content was encrypted during delivery. */
44
56
  public addressPoint: PublicKey,
57
+
58
+ /** The note type identifier for the contract.
59
+ * TODO: remove
60
+ */
61
+ public noteTypeId: NoteSelector,
45
62
  ) {}
46
63
 
47
64
  static fromPayloadAndNoteInfo(
@@ -54,19 +71,19 @@ export class IncomingNoteDao implements NoteData {
54
71
  addressPoint: PublicKey,
55
72
  ) {
56
73
  const noteHashIndexInTheWholeTree = BigInt(dataStartIndexForTx + noteInfo.noteHashIndex);
57
- return new IncomingNoteDao(
74
+ return new NoteDao(
58
75
  note,
59
76
  payload.contractAddress,
60
77
  payload.storageSlot,
61
- payload.noteTypeId,
62
- noteInfo.txHash,
63
- l2BlockNumber,
64
- l2BlockHash,
65
78
  noteInfo.nonce,
66
79
  noteInfo.noteHash,
67
80
  noteInfo.siloedNullifier,
81
+ noteInfo.txHash,
82
+ l2BlockNumber,
83
+ l2BlockHash,
68
84
  noteHashIndexInTheWholeTree,
69
85
  addressPoint,
86
+ payload.noteTypeId,
70
87
  );
71
88
  }
72
89
 
@@ -75,15 +92,15 @@ export class IncomingNoteDao implements NoteData {
75
92
  this.note,
76
93
  this.contractAddress,
77
94
  this.storageSlot,
78
- this.noteTypeId,
79
- this.txHash.buffer,
80
- this.l2BlockNumber,
81
- Fr.fromHexString(this.l2BlockHash),
82
95
  this.nonce,
83
96
  this.noteHash,
84
97
  this.siloedNullifier,
98
+ this.txHash,
99
+ this.l2BlockNumber,
100
+ Fr.fromHexString(this.l2BlockHash),
85
101
  this.index,
86
102
  this.addressPoint,
103
+ this.noteTypeId,
87
104
  ]);
88
105
  }
89
106
 
@@ -93,29 +110,29 @@ export class IncomingNoteDao implements NoteData {
93
110
  const note = Note.fromBuffer(reader);
94
111
  const contractAddress = AztecAddress.fromBuffer(reader);
95
112
  const storageSlot = Fr.fromBuffer(reader);
96
- const noteTypeId = reader.readObject(NoteSelector);
97
- const txHash = reader.readObject(TxHash);
98
- const l2BlockNumber = reader.readNumber();
99
- const l2BlockHash = Fr.fromBuffer(reader).toString();
100
113
  const nonce = Fr.fromBuffer(reader);
101
114
  const noteHash = Fr.fromBuffer(reader);
102
115
  const siloedNullifier = Fr.fromBuffer(reader);
116
+ const txHash = reader.readObject(TxHash);
117
+ const l2BlockNumber = reader.readNumber();
118
+ const l2BlockHash = Fr.fromBuffer(reader).toString();
103
119
  const index = toBigIntBE(reader.readBytes(32));
104
120
  const publicKey = Point.fromBuffer(reader);
121
+ const noteTypeId = reader.readObject(NoteSelector);
105
122
 
106
- return new IncomingNoteDao(
123
+ return new NoteDao(
107
124
  note,
108
125
  contractAddress,
109
126
  storageSlot,
110
- noteTypeId,
111
- txHash,
112
- l2BlockNumber,
113
- l2BlockHash,
114
127
  nonce,
115
128
  noteHash,
116
129
  siloedNullifier,
130
+ txHash,
131
+ l2BlockNumber,
132
+ l2BlockHash,
117
133
  index,
118
134
  publicKey,
135
+ noteTypeId,
119
136
  );
120
137
  }
121
138
 
@@ -125,7 +142,7 @@ export class IncomingNoteDao implements NoteData {
125
142
 
126
143
  static fromString(str: string) {
127
144
  const hex = str.replace(/^0x/, '');
128
- return IncomingNoteDao.fromBuffer(Buffer.from(hex, 'hex'));
145
+ return NoteDao.fromBuffer(Buffer.from(hex, 'hex'));
129
146
  }
130
147
 
131
148
  /**
@@ -141,30 +158,30 @@ export class IncomingNoteDao implements NoteData {
141
158
  static random({
142
159
  note = Note.random(),
143
160
  contractAddress = AztecAddress.random(),
144
- txHash = randomTxHash(),
145
161
  storageSlot = Fr.random(),
146
- noteTypeId = NoteSelector.random(),
147
162
  nonce = Fr.random(),
148
- l2BlockNumber = Math.floor(Math.random() * 1000),
149
- l2BlockHash = Fr.random().toString(),
150
163
  noteHash = Fr.random(),
151
164
  siloedNullifier = Fr.random(),
165
+ txHash = randomTxHash(),
166
+ l2BlockNumber = Math.floor(Math.random() * 1000),
167
+ l2BlockHash = Fr.random().toString(),
152
168
  index = Fr.random().toBigInt(),
153
169
  addressPoint = Point.random(),
154
- }: Partial<IncomingNoteDao> = {}) {
155
- return new IncomingNoteDao(
170
+ noteTypeId = NoteSelector.random(),
171
+ }: Partial<NoteDao> = {}) {
172
+ return new NoteDao(
156
173
  note,
157
174
  contractAddress,
158
175
  storageSlot,
159
- noteTypeId,
160
- txHash,
161
- l2BlockNumber,
162
- l2BlockHash,
163
176
  nonce,
164
177
  noteHash,
165
178
  siloedNullifier,
179
+ txHash,
180
+ l2BlockNumber,
181
+ l2BlockHash,
166
182
  index,
167
183
  addressPoint,
184
+ noteTypeId,
168
185
  );
169
186
  }
170
187
  }
@@ -69,7 +69,7 @@ export class OutgoingNoteDao {
69
69
  this.contractAddress,
70
70
  this.storageSlot,
71
71
  this.noteTypeId,
72
- this.txHash.buffer,
72
+ this.txHash,
73
73
  this.l2BlockNumber,
74
74
  Fr.fromHexString(this.l2BlockHash),
75
75
  this.nonce,
@@ -85,7 +85,7 @@ export class OutgoingNoteDao {
85
85
  const contractAddress = AztecAddress.fromBuffer(reader);
86
86
  const storageSlot = Fr.fromBuffer(reader);
87
87
  const noteTypeId = reader.readObject(NoteSelector);
88
- const txHash = new TxHash(reader.readBytes(TxHash.SIZE));
88
+ const txHash = reader.readObject(TxHash);
89
89
  const l2BlockNumber = reader.readNumber();
90
90
  const l2BlockHash = Fr.fromBuffer(reader).toString();
91
91
  const nonce = Fr.fromBuffer(reader);
@@ -1,4 +1,4 @@
1
- import { type InBlock, type IncomingNotesFilter } from '@aztec/circuit-types';
1
+ import { type InBlock, type NotesFilter } from '@aztec/circuit-types';
2
2
  import {
3
3
  type BlockHeader,
4
4
  type CompleteAddress,
@@ -12,7 +12,7 @@ import { type Fr } from '@aztec/foundation/fields';
12
12
 
13
13
  import { type ContractArtifactDatabase } from './contracts/contract_artifact_db.js';
14
14
  import { type ContractInstanceDatabase } from './contracts/contract_instance_db.js';
15
- import { type IncomingNoteDao } from './incoming_note_dao.js';
15
+ import { type NoteDao } from './note_dao.js';
16
16
 
17
17
  /**
18
18
  * A database interface that provides methods for retrieving, adding, and removing transactional data related to Aztec
@@ -50,11 +50,11 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
50
50
  popCapsule(): Promise<Fr[] | undefined>;
51
51
 
52
52
  /**
53
- * Gets incoming notes based on the provided filter.
53
+ * Gets notes based on the provided filter.
54
54
  * @param filter - The filter to apply to the notes.
55
55
  * @returns The requested notes.
56
56
  */
57
- getIncomingNotes(filter: IncomingNotesFilter): Promise<IncomingNoteDao[]>;
57
+ getNotes(filter: NotesFilter): Promise<NoteDao[]>;
58
58
 
59
59
  /**
60
60
  * Adds a note to DB.
@@ -62,24 +62,24 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
62
62
  * @param scope - The scope to add the note under. Currently optional.
63
63
  * @remark - Will create a database for the scope if it does not already exist.
64
64
  */
65
- addNote(note: IncomingNoteDao, scope?: AztecAddress): Promise<void>;
65
+ addNote(note: NoteDao, scope?: AztecAddress): Promise<void>;
66
66
 
67
67
  /**
68
68
  * Adds a nullified note to DB.
69
69
  * @param note - The note to add.
70
70
  */
71
- addNullifiedNote(note: IncomingNoteDao): Promise<void>;
71
+ addNullifiedNote(note: NoteDao): Promise<void>;
72
72
 
73
73
  /**
74
74
  * Adds an array of notes to DB.
75
75
  * This function is used to insert multiple notes to the database at once,
76
76
  * which can improve performance when dealing with large numbers of transactions.
77
77
  *
78
- * @param incomingNotes - An array of notes which were decrypted as incoming.
78
+ * @param notes - An array of notes.
79
79
  * @param scope - The scope to add the notes under. Currently optional.
80
80
  * @remark - Will create a database for the scope if it does not already exist.
81
81
  */
82
- addNotes(incomingNotes: IncomingNoteDao[], scope?: AztecAddress): Promise<void>;
82
+ addNotes(notes: NoteDao[], scope?: AztecAddress): Promise<void>;
83
83
 
84
84
  /**
85
85
  * Remove nullified notes associated with the given account and nullifiers.
@@ -88,7 +88,7 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
88
88
  * @param account - A PublicKey instance representing the account for which the records are being removed.
89
89
  * @returns Removed notes.
90
90
  */
91
- removeNullifiedNotes(nullifiers: InBlock<Fr>[], account: PublicKey): Promise<IncomingNoteDao[]>;
91
+ removeNullifiedNotes(nullifiers: InBlock<Fr>[], account: PublicKey): Promise<NoteDao[]>;
92
92
 
93
93
  /**
94
94
  * Gets the most recently processed block number.
@@ -213,4 +213,22 @@ export interface PxeDatabase extends ContractArtifactDatabase, ContractInstanceD
213
213
  * is also required to deal with chain reorgs.
214
214
  */
215
215
  resetNoteSyncData(): Promise<void>;
216
+
217
+ /**
218
+ * Used by contracts during execution to store arbitrary data in the local PXE database. The data is siloed/scoped
219
+ * to a specific `contract`.
220
+ * @param contract - An address of a contract that is requesting to store the data.
221
+ * @param key - A field element representing the key to store the data under.
222
+ * @param values - An array of field elements representing the data to store.
223
+ */
224
+ store(contract: AztecAddress, key: Fr, values: Fr[]): Promise<void>;
225
+
226
+ /**
227
+ * Used by contracts during execution to load arbitrary data from the local PXE database. The data is siloed/scoped
228
+ * to a specific `contract`.
229
+ * @param contract - An address of a contract that is requesting to load the data.
230
+ * @param key - A field element representing the key under which to load the data..
231
+ * @returns An array of field elements representing the stored data or `null` if no data is stored under the key.
232
+ */
233
+ load(contract: AztecAddress, key: Fr): Promise<Fr[] | null>;
216
234
  }
@@ -1,4 +1,4 @@
1
- import { type IncomingNotesFilter, NoteStatus, randomTxHash } from '@aztec/circuit-types';
1
+ import { NoteStatus, type NotesFilter, randomTxHash } from '@aztec/circuit-types';
2
2
  import {
3
3
  AztecAddress,
4
4
  CompleteAddress,
@@ -13,7 +13,7 @@ import { Fr, Point } from '@aztec/foundation/fields';
13
13
  import { BenchmarkingContractArtifact } from '@aztec/noir-contracts.js/Benchmarking';
14
14
  import { TestContractArtifact } from '@aztec/noir-contracts.js/Test';
15
15
 
16
- import { IncomingNoteDao } from './incoming_note_dao.js';
16
+ import { NoteDao } from './note_dao.js';
17
17
  import { type PxeDatabase } from './pxe_database.js';
18
18
 
19
19
  /**
@@ -78,9 +78,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
78
78
  let owners: CompleteAddress[];
79
79
  let contractAddresses: AztecAddress[];
80
80
  let storageSlots: Fr[];
81
- let notes: IncomingNoteDao[];
81
+ let notes: NoteDao[];
82
82
 
83
- const filteringTests: [() => IncomingNotesFilter, () => IncomingNoteDao[]][] = [
83
+ const filteringTests: [() => NotesFilter, () => NoteDao[]][] = [
84
84
  [() => ({}), () => notes],
85
85
 
86
86
  [
@@ -119,7 +119,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
119
119
  storageSlots = Array.from({ length: 2 }).map(() => Fr.random());
120
120
 
121
121
  notes = Array.from({ length: 10 }).map((_, i) =>
122
- IncomingNoteDao.random({
122
+ NoteDao.random({
123
123
  contractAddress: contractAddresses[i % contractAddresses.length],
124
124
  storageSlot: storageSlots[i % storageSlots.length],
125
125
  addressPoint: owners[i % owners.length].address.toAddressPoint(),
@@ -135,7 +135,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
135
135
 
136
136
  it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
137
137
  await database.addNotes(notes);
138
- const returnedNotes = await database.getIncomingNotes(getFilter());
138
+ const returnedNotes = await database.getNotes(getFilter());
139
139
 
140
140
  expect(returnedNotes.sort()).toEqual(getExpected().sort());
141
141
  });
@@ -145,7 +145,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
145
145
  await database.addNote(note);
146
146
  }
147
147
 
148
- const returnedNotes = await database.getIncomingNotes(getFilter());
148
+ const returnedNotes = await database.getNotes(getFilter());
149
149
 
150
150
  expect(returnedNotes.sort()).toEqual(getExpected().sort());
151
151
  });
@@ -166,9 +166,9 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
166
166
  );
167
167
  }
168
168
 
169
- await expect(
170
- database.getIncomingNotes({ ...getFilter(), status: NoteStatus.ACTIVE_OR_NULLIFIED }),
171
- ).resolves.toEqual(getExpected());
169
+ await expect(database.getNotes({ ...getFilter(), status: NoteStatus.ACTIVE_OR_NULLIFIED })).resolves.toEqual(
170
+ getExpected(),
171
+ );
172
172
  });
173
173
 
174
174
  it('skips nullified notes by default or when requesting active', async () => {
@@ -184,8 +184,8 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
184
184
  notesToNullify,
185
185
  );
186
186
 
187
- const actualNotesWithDefault = await database.getIncomingNotes({});
188
- const actualNotesWithActive = await database.getIncomingNotes({ status: NoteStatus.ACTIVE });
187
+ const actualNotesWithDefault = await database.getNotes({});
188
+ const actualNotesWithActive = await database.getNotes({ status: NoteStatus.ACTIVE });
189
189
 
190
190
  expect(actualNotesWithDefault).toEqual(actualNotesWithActive);
191
191
  expect(actualNotesWithActive).toEqual(notes.filter(note => !notesToNullify.includes(note)));
@@ -206,7 +206,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
206
206
  );
207
207
  await expect(database.unnullifyNotesAfter(98)).resolves.toEqual(undefined);
208
208
 
209
- const result = await database.getIncomingNotes({ status: NoteStatus.ACTIVE, owner: owners[0].address });
209
+ const result = await database.getNotes({ status: NoteStatus.ACTIVE, owner: owners[0].address });
210
210
 
211
211
  expect(result.sort()).toEqual([...notesToNullify].sort());
212
212
  });
@@ -224,7 +224,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
224
224
  notesToNullify,
225
225
  );
226
226
 
227
- const result = await database.getIncomingNotes({
227
+ const result = await database.getNotes({
228
228
  status: NoteStatus.ACTIVE_OR_NULLIFIED,
229
229
  });
230
230
 
@@ -242,23 +242,23 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
242
242
  await database.addNote(note, owners[1].address);
243
243
  }
244
244
 
245
- const owner0IncomingNotes = await database.getIncomingNotes({
245
+ const owner0Notes = await database.getNotes({
246
246
  scopes: [owners[0].address],
247
247
  });
248
248
 
249
- expect(owner0IncomingNotes.sort()).toEqual(notes.slice(0, 5).sort());
249
+ expect(owner0Notes.sort()).toEqual(notes.slice(0, 5).sort());
250
250
 
251
- const owner1IncomingNotes = await database.getIncomingNotes({
251
+ const owner1Notes = await database.getNotes({
252
252
  scopes: [owners[1].address],
253
253
  });
254
254
 
255
- expect(owner1IncomingNotes.sort()).toEqual(notes.slice(5).sort());
255
+ expect(owner1Notes.sort()).toEqual(notes.slice(5).sort());
256
256
 
257
- const bothOwnerIncomingNotes = await database.getIncomingNotes({
257
+ const bothOwnerNotes = await database.getNotes({
258
258
  scopes: [owners[0].address, owners[1].address],
259
259
  });
260
260
 
261
- expect(bothOwnerIncomingNotes.sort()).toEqual(notes.sort());
261
+ expect(bothOwnerNotes.sort()).toEqual(notes.sort());
262
262
  });
263
263
 
264
264
  it('a nullified note removes notes from all accounts in the pxe', async () => {
@@ -266,12 +266,12 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
266
266
  await database.addNote(notes[0], owners[1].address);
267
267
 
268
268
  await expect(
269
- database.getIncomingNotes({
269
+ database.getNotes({
270
270
  scopes: [owners[0].address],
271
271
  }),
272
272
  ).resolves.toEqual([notes[0]]);
273
273
  await expect(
274
- database.getIncomingNotes({
274
+ database.getNotes({
275
275
  scopes: [owners[1].address],
276
276
  }),
277
277
  ).resolves.toEqual([notes[0]]);
@@ -290,12 +290,12 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
290
290
  ).resolves.toEqual([notes[0]]);
291
291
 
292
292
  await expect(
293
- database.getIncomingNotes({
293
+ database.getNotes({
294
294
  scopes: [owners[0].address],
295
295
  }),
296
296
  ).resolves.toEqual([]);
297
297
  await expect(
298
- database.getIncomingNotes({
298
+ database.getNotes({
299
299
  scopes: [owners[1].address],
300
300
  }),
301
301
  ).resolves.toEqual([]);
@@ -305,7 +305,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
305
305
  await database.addNotes(notes, owners[0].address);
306
306
 
307
307
  await database.removeNotesAfter(5);
308
- const result = await database.getIncomingNotes({ scopes: [owners[0].address] });
308
+ const result = await database.getNotes({ scopes: [owners[0].address] });
309
309
  expect(new Set(result)).toEqual(new Set(notes.slice(0, 6)));
310
310
  });
311
311
  });
@@ -405,5 +405,66 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
405
405
  await expect(database.getContractInstance(address)).resolves.toEqual(instance);
406
406
  });
407
407
  });
408
+
409
+ describe('contract store', () => {
410
+ let contract: AztecAddress;
411
+
412
+ beforeEach(() => {
413
+ // Setup mock contract address
414
+ contract = AztecAddress.random();
415
+ });
416
+
417
+ it('stores and loads a single value', async () => {
418
+ const key = new Fr(1);
419
+ const values = [new Fr(42)];
420
+
421
+ await database.store(contract, key, values);
422
+ const result = await database.load(contract, key);
423
+ expect(result).toEqual(values);
424
+ });
425
+
426
+ it('stores and loads multiple values', async () => {
427
+ const key = new Fr(1);
428
+ const values = [new Fr(42), new Fr(43), new Fr(44)];
429
+
430
+ await database.store(contract, key, values);
431
+ const result = await database.load(contract, key);
432
+ expect(result).toEqual(values);
433
+ });
434
+
435
+ it('overwrites existing values', async () => {
436
+ const key = new Fr(1);
437
+ const initialValues = [new Fr(42)];
438
+ const newValues = [new Fr(100)];
439
+
440
+ await database.store(contract, key, initialValues);
441
+ await database.store(contract, key, newValues);
442
+
443
+ const result = await database.load(contract, key);
444
+ expect(result).toEqual(newValues);
445
+ });
446
+
447
+ it('stores values for different contracts independently', async () => {
448
+ const anotherContract = AztecAddress.random();
449
+ const key = new Fr(1);
450
+ const values1 = [new Fr(42)];
451
+ const values2 = [new Fr(100)];
452
+
453
+ await database.store(contract, key, values1);
454
+ await database.store(anotherContract, key, values2);
455
+
456
+ const result1 = await database.load(contract, key);
457
+ const result2 = await database.load(anotherContract, key);
458
+
459
+ expect(result1).toEqual(values1);
460
+ expect(result2).toEqual(values2);
461
+ });
462
+
463
+ it('returns null for non-existent keys', async () => {
464
+ const key = Fr.random();
465
+ const result = await database.load(contract, key);
466
+ expect(result).toBeNull();
467
+ });
468
+ });
408
469
  });
409
470
  }
@@ -15,7 +15,7 @@ import {
15
15
  import { createLogger } from '@aztec/foundation/log';
16
16
  import { type Tuple } from '@aztec/foundation/serialize';
17
17
  import { type KeyStore } from '@aztec/key-store';
18
- import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/client';
18
+ import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vks';
19
19
 
20
20
  import { type ContractDataOracle } from '../contract_data_oracle/index.js';
21
21
  import { type ProvingDataOracle } from './../kernel_prover/proving_data_oracle.js';
@@ -57,7 +57,7 @@ function getNullifierMembershipWitnessResolver(oracle: ProvingDataOracle) {
57
57
  return async (nullifier: Fr) => {
58
58
  const res = await oracle.getNullifierMembershipWitness(nullifier);
59
59
  if (!res) {
60
- throw new Error(`Cannot find the leaf for nullifier ${nullifier.toBigInt()}.`);
60
+ throw new Error(`Cannot find the leaf for nullifier ${nullifier}.`);
61
61
  }
62
62
 
63
63
  const { index, siblingPath, leafPreimage } = res;
@@ -1,4 +1,2 @@
1
- export { TestPrivateKernelProver } from './test/test_circuit_prover.js';
2
-
3
1
  export * from './kernel_prover.js';
4
2
  export * from './proving_data_oracle.js';