@aztec/pxe 0.47.1 → 0.49.2

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 (67) hide show
  1. package/dest/config/index.d.ts +18 -0
  2. package/dest/config/index.d.ts.map +1 -1
  3. package/dest/config/index.js +72 -8
  4. package/dest/database/incoming_note_dao.d.ts +4 -4
  5. package/dest/database/incoming_note_dao.d.ts.map +1 -1
  6. package/dest/database/incoming_note_dao.js +7 -7
  7. package/dest/database/kv_pxe_database.d.ts +3 -3
  8. package/dest/database/kv_pxe_database.d.ts.map +1 -1
  9. package/dest/database/kv_pxe_database.js +64 -31
  10. package/dest/database/outgoing_note_dao.d.ts +6 -6
  11. package/dest/database/outgoing_note_dao.d.ts.map +1 -1
  12. package/dest/database/outgoing_note_dao.js +8 -8
  13. package/dest/database/pxe_database.d.ts +6 -2
  14. package/dest/database/pxe_database.d.ts.map +1 -1
  15. package/dest/database/pxe_database_test_suite.d.ts.map +1 -1
  16. package/dest/database/pxe_database_test_suite.js +43 -4
  17. package/dest/kernel_prover/{private_inputs_builders → hints}/build_private_kernel_reset_hints.d.ts +1 -1
  18. package/dest/kernel_prover/hints/build_private_kernel_reset_hints.d.ts.map +1 -0
  19. package/dest/kernel_prover/hints/build_private_kernel_reset_hints.js +90 -0
  20. package/dest/kernel_prover/hints/index.d.ts +3 -0
  21. package/dest/kernel_prover/hints/index.d.ts.map +1 -0
  22. package/dest/kernel_prover/hints/index.js +3 -0
  23. package/dest/kernel_prover/hints/needs_reset.d.ts +5 -0
  24. package/dest/kernel_prover/hints/needs_reset.d.ts.map +1 -0
  25. package/dest/kernel_prover/hints/needs_reset.js +38 -0
  26. package/dest/kernel_prover/kernel_prover.d.ts +0 -2
  27. package/dest/kernel_prover/kernel_prover.d.ts.map +1 -1
  28. package/dest/kernel_prover/kernel_prover.js +14 -38
  29. package/dest/note_processor/note_processor.js +2 -2
  30. package/dest/note_processor/produce_note_dao.js +15 -15
  31. package/dest/pxe_http/pxe_http_server.d.ts.map +1 -1
  32. package/dest/pxe_http/pxe_http_server.js +5 -2
  33. package/dest/pxe_service/create_pxe_service.d.ts.map +1 -1
  34. package/dest/pxe_service/create_pxe_service.js +4 -4
  35. package/dest/pxe_service/pxe_service.d.ts +8 -15
  36. package/dest/pxe_service/pxe_service.d.ts.map +1 -1
  37. package/dest/pxe_service/pxe_service.js +66 -66
  38. package/dest/simulator_oracle/index.d.ts +2 -2
  39. package/dest/simulator_oracle/index.d.ts.map +1 -1
  40. package/dest/simulator_oracle/index.js +5 -4
  41. package/dest/synchronizer/synchronizer.d.ts +1 -1
  42. package/dest/synchronizer/synchronizer.d.ts.map +1 -1
  43. package/dest/synchronizer/synchronizer.js +8 -10
  44. package/package.json +14 -14
  45. package/src/config/index.ts +90 -14
  46. package/src/database/incoming_note_dao.ts +5 -5
  47. package/src/database/kv_pxe_database.ts +86 -31
  48. package/src/database/outgoing_note_dao.ts +6 -6
  49. package/src/database/pxe_database.ts +6 -2
  50. package/src/database/pxe_database_test_suite.ts +70 -3
  51. package/src/kernel_prover/{private_inputs_builders → hints}/build_private_kernel_reset_hints.ts +31 -7
  52. package/src/kernel_prover/hints/index.ts +2 -0
  53. package/src/kernel_prover/hints/needs_reset.ts +54 -0
  54. package/src/kernel_prover/kernel_prover.ts +24 -48
  55. package/src/note_processor/note_processor.ts +1 -1
  56. package/src/note_processor/produce_note_dao.ts +14 -14
  57. package/src/pxe_http/pxe_http_server.ts +4 -0
  58. package/src/pxe_service/create_pxe_service.ts +3 -2
  59. package/src/pxe_service/pxe_service.ts +76 -61
  60. package/src/simulator_oracle/index.ts +4 -3
  61. package/src/synchronizer/synchronizer.ts +19 -19
  62. package/dest/kernel_prover/private_inputs_builders/build_private_kernel_reset_hints.d.ts.map +0 -1
  63. package/dest/kernel_prover/private_inputs_builders/build_private_kernel_reset_hints.js +0 -77
  64. package/dest/kernel_prover/private_inputs_builders/index.d.ts +0 -2
  65. package/dest/kernel_prover/private_inputs_builders/index.d.ts.map +0 -1
  66. package/dest/kernel_prover/private_inputs_builders/index.js +0 -2
  67. package/src/kernel_prover/private_inputs_builders/index.ts +0 -1
@@ -130,14 +130,19 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
130
130
 
131
131
  it.each(filteringTests)('stores notes in bulk and retrieves notes', async (getFilter, getExpected) => {
132
132
  await database.addNotes(notes, []);
133
- await expect(database.getIncomingNotes(getFilter())).resolves.toEqual(getExpected());
133
+ const returnedNotes = await database.getIncomingNotes(getFilter());
134
+
135
+ expect(returnedNotes.sort()).toEqual(getExpected().sort());
134
136
  });
135
137
 
136
138
  it.each(filteringTests)('stores notes one by one and retrieves notes', async (getFilter, getExpected) => {
137
139
  for (const note of notes) {
138
140
  await database.addNote(note);
139
141
  }
140
- await expect(database.getIncomingNotes(getFilter())).resolves.toEqual(getExpected());
142
+
143
+ const returnedNotes = await database.getIncomingNotes(getFilter());
144
+
145
+ expect(returnedNotes.sort()).toEqual(getExpected().sort());
141
146
  });
142
147
 
143
148
  it.each(filteringTests)('retrieves nullified notes', async (getFilter, getExpected) => {
@@ -196,6 +201,68 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
196
201
  // inserted combining active and nullified results.
197
202
  expect(result.sort()).toEqual([...notes].sort());
198
203
  });
204
+
205
+ it('stores notes one by one and retrieves notes with siloed account', async () => {
206
+ for (const note of notes.slice(0, 5)) {
207
+ await database.addNote(note, owners[0].address);
208
+ }
209
+
210
+ for (const note of notes.slice(5)) {
211
+ await database.addNote(note, owners[1].address);
212
+ }
213
+
214
+ const owner0IncomingNotes = await database.getIncomingNotes({
215
+ scopes: [owners[0].address],
216
+ });
217
+
218
+ expect(owner0IncomingNotes.sort()).toEqual(notes.slice(0, 5).sort());
219
+
220
+ const owner1IncomingNotes = await database.getIncomingNotes({
221
+ scopes: [owners[1].address],
222
+ });
223
+
224
+ expect(owner1IncomingNotes.sort()).toEqual(notes.slice(5).sort());
225
+
226
+ const bothOwnerIncomingNotes = await database.getIncomingNotes({
227
+ scopes: [owners[0].address, owners[1].address],
228
+ });
229
+
230
+ expect(bothOwnerIncomingNotes.sort()).toEqual(notes.sort());
231
+ });
232
+
233
+ it('a nullified note removes notes from all accounts in the pxe', async () => {
234
+ await database.addNote(notes[0], owners[0].address);
235
+ await database.addNote(notes[0], owners[1].address);
236
+
237
+ await expect(
238
+ database.getIncomingNotes({
239
+ scopes: [owners[0].address],
240
+ }),
241
+ ).resolves.toEqual([notes[0]]);
242
+ await expect(
243
+ database.getIncomingNotes({
244
+ scopes: [owners[1].address],
245
+ }),
246
+ ).resolves.toEqual([notes[0]]);
247
+
248
+ await expect(
249
+ database.removeNullifiedNotes(
250
+ [notes[0].siloedNullifier],
251
+ owners[0].publicKeys.masterIncomingViewingPublicKey,
252
+ ),
253
+ ).resolves.toEqual([notes[0]]);
254
+
255
+ await expect(
256
+ database.getIncomingNotes({
257
+ scopes: [owners[0].address],
258
+ }),
259
+ ).resolves.toEqual([]);
260
+ await expect(
261
+ database.getIncomingNotes({
262
+ scopes: [owners[1].address],
263
+ }),
264
+ ).resolves.toEqual([]);
265
+ });
199
266
  });
200
267
 
201
268
  describe('outgoing notes', () => {
@@ -264,7 +331,7 @@ export function describePxeDatabase(getDatabase: () => PxeDatabase) {
264
331
 
265
332
  describe('block header', () => {
266
333
  it('stores and retrieves the block header', async () => {
267
- const header = makeHeader(randomInt(1000), INITIAL_L2_BLOCK_NUM);
334
+ const header = makeHeader(randomInt(1000), INITIAL_L2_BLOCK_NUM, 0 /** slot number */);
268
335
 
269
336
  await database.setHeader(header);
270
337
  expect(database.getHeader()).toEqual(header);
@@ -21,6 +21,7 @@ import {
21
21
  buildNoteHashReadRequestHints,
22
22
  buildNullifierReadRequestHints,
23
23
  buildTransientDataHints,
24
+ countAccumulatedItems,
24
25
  getNonEmptyItems,
25
26
  } from '@aztec/circuits.js';
26
27
  import { makeTuple } from '@aztec/foundation/array';
@@ -68,7 +69,9 @@ async function getMasterSecretKeysAndAppKeyGenerators(
68
69
  keyValidationRequests: Tuple<ScopedKeyValidationRequestAndGenerator, typeof MAX_KEY_VALIDATION_REQUESTS_PER_TX>,
69
70
  oracle: ProvingDataOracle,
70
71
  ) {
71
- const keysHints = makeTuple(MAX_KEY_VALIDATION_REQUESTS_PER_TX, KeyValidationHint.empty);
72
+ const keysHints = makeTuple(MAX_KEY_VALIDATION_REQUESTS_PER_TX, () =>
73
+ KeyValidationHint.nada(MAX_KEY_VALIDATION_REQUESTS_PER_TX),
74
+ );
72
75
 
73
76
  let keyIndex = 0;
74
77
  for (let i = 0; i < keyValidationRequests.length; ++i) {
@@ -91,6 +94,8 @@ export async function buildPrivateKernelResetInputs(
91
94
  previousKernelData: PrivateKernelData,
92
95
  noteHashLeafIndexMap: Map<bigint, bigint>,
93
96
  noteHashNullifierCounterMap: Map<number, number>,
97
+ validationRequestsSplitCounter: number,
98
+ shouldSilo: boolean,
94
99
  oracle: ProvingDataOracle,
95
100
  ) {
96
101
  const publicInputs = previousKernelData.publicInputs;
@@ -153,9 +158,11 @@ export async function buildPrivateKernelResetInputs(
153
158
  executionResult => executionResult.callStackItem.publicInputs.nullifierReadRequests,
154
159
  );
155
160
 
156
- const [transientNullifierIndexesForNoteHashes, transientNoteHashIndexesForNullifiers] = buildTransientDataHints(
157
- publicInputs.end.noteHashes,
158
- publicInputs.end.nullifiers,
161
+ const noteHashes = publicInputs.end.noteHashes;
162
+ const nullifiers = publicInputs.end.nullifiers;
163
+ const { numTransientData, hints: transientDataIndexHints } = buildTransientDataHints(
164
+ noteHashes,
165
+ nullifiers,
159
166
  futureNoteHashReads,
160
167
  futureNullifierReads,
161
168
  noteHashNullifierCounterMap,
@@ -163,30 +170,47 @@ export async function buildPrivateKernelResetInputs(
163
170
  MAX_NULLIFIERS_PER_TX,
164
171
  );
165
172
 
173
+ const remainingNoteHashes = countAccumulatedItems(noteHashes) - numTransientData;
174
+
175
+ const remainingNullifiers = countAccumulatedItems(nullifiers) - numTransientData;
176
+
177
+ const numEncryptedLogHashes = countAccumulatedItems(publicInputs.end.encryptedLogsHashes);
178
+
166
179
  let privateInputs;
167
180
 
168
181
  for (const [sizeTag, hintSizes] of Object.entries(PRIVATE_RESET_VARIANTS)) {
182
+ const noSiloing =
183
+ !hintSizes.NOTE_HASH_SILOING_AMOUNT &&
184
+ !hintSizes.NULLIFIER_SILOING_AMOUNT &&
185
+ !hintSizes.ENCRYPTED_LOG_SILOING_AMOUNT;
186
+ const enoughSiloing =
187
+ hintSizes.NOTE_HASH_SILOING_AMOUNT >= remainingNoteHashes &&
188
+ hintSizes.NULLIFIER_SILOING_AMOUNT >= remainingNullifiers &&
189
+ hintSizes.ENCRYPTED_LOG_SILOING_AMOUNT >= numEncryptedLogHashes;
169
190
  if (
170
191
  hintSizes.NOTE_HASH_PENDING_AMOUNT >= noteHashPendingReadHints &&
171
192
  hintSizes.NOTE_HASH_SETTLED_AMOUNT >= noteHashSettledReadHints &&
172
193
  hintSizes.NULLIFIER_PENDING_AMOUNT >= nullifierPendingReadHints &&
173
194
  hintSizes.NULLIFIER_SETTLED_AMOUNT >= nullifierSettledReadHints &&
174
- hintSizes.NULLIFIER_KEYS >= keysCount
195
+ hintSizes.NULLIFIER_KEYS >= keysCount &&
196
+ hintSizes.TRANSIENT_DATA_AMOUNT >= numTransientData &&
197
+ ((!shouldSilo && noSiloing) || (shouldSilo && enoughSiloing))
175
198
  ) {
176
199
  privateInputs = new PrivateKernelResetCircuitPrivateInputs(
177
200
  previousKernelData,
178
201
  new PrivateKernelResetHints(
179
- transientNullifierIndexesForNoteHashes,
180
- transientNoteHashIndexesForNullifiers,
181
202
  noteHashReadRequestHints,
182
203
  nullifierReadRequestHints,
183
204
  keysHints,
205
+ transientDataIndexHints,
206
+ validationRequestsSplitCounter,
184
207
  ).trimToSizes(
185
208
  hintSizes.NOTE_HASH_PENDING_AMOUNT,
186
209
  hintSizes.NOTE_HASH_SETTLED_AMOUNT,
187
210
  hintSizes.NULLIFIER_PENDING_AMOUNT,
188
211
  hintSizes.NULLIFIER_SETTLED_AMOUNT,
189
212
  hintSizes.NULLIFIER_KEYS,
213
+ hintSizes.TRANSIENT_DATA_AMOUNT,
190
214
  ),
191
215
  sizeTag,
192
216
  );
@@ -0,0 +1,2 @@
1
+ export * from './build_private_kernel_reset_hints.js';
2
+ export * from './needs_reset.js';
@@ -0,0 +1,54 @@
1
+ import {
2
+ MAX_KEY_VALIDATION_REQUESTS_PER_TX,
3
+ MAX_NOTE_ENCRYPTED_LOGS_PER_TX,
4
+ MAX_NOTE_HASHES_PER_TX,
5
+ MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
6
+ MAX_NULLIFIERS_PER_TX,
7
+ MAX_NULLIFIER_READ_REQUESTS_PER_TX,
8
+ type PrivateKernelCircuitPublicInputs,
9
+ countAccumulatedItems,
10
+ } from '@aztec/circuits.js';
11
+ import { type ExecutionResult } from '@aztec/simulator';
12
+
13
+ export function needsReset(publicInputs: PrivateKernelCircuitPublicInputs, executionStack: ExecutionResult[]) {
14
+ const nextIteration = executionStack[executionStack.length - 1];
15
+ return (
16
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.noteHashes) +
17
+ countAccumulatedItems(publicInputs.end.noteHashes) >
18
+ MAX_NOTE_HASHES_PER_TX ||
19
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.nullifiers) +
20
+ countAccumulatedItems(publicInputs.end.nullifiers) >
21
+ MAX_NULLIFIERS_PER_TX ||
22
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.noteEncryptedLogsHashes) +
23
+ countAccumulatedItems(publicInputs.end.noteEncryptedLogsHashes) >
24
+ MAX_NOTE_ENCRYPTED_LOGS_PER_TX ||
25
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.noteHashReadRequests) +
26
+ countAccumulatedItems(publicInputs.validationRequests.noteHashReadRequests) >
27
+ MAX_NOTE_HASH_READ_REQUESTS_PER_TX ||
28
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.nullifierReadRequests) +
29
+ countAccumulatedItems(publicInputs.validationRequests.nullifierReadRequests) >
30
+ MAX_NULLIFIER_READ_REQUESTS_PER_TX ||
31
+ countAccumulatedItems(nextIteration.callStackItem.publicInputs.keyValidationRequestsAndGenerators) +
32
+ countAccumulatedItems(publicInputs.validationRequests.scopedKeyValidationRequestsAndGenerators) >
33
+ MAX_KEY_VALIDATION_REQUESTS_PER_TX
34
+ );
35
+ }
36
+
37
+ function hasTransientNullifier(publicInputs: PrivateKernelCircuitPublicInputs) {
38
+ const noteHashSet = new Set();
39
+ publicInputs.end.noteHashes.forEach(n => noteHashSet.add(n.noteHash.value.toBigInt()));
40
+ noteHashSet.delete(0n);
41
+ return publicInputs.end.nullifiers.some(n => noteHashSet.has(n.nullifiedNoteHash.toBigInt()));
42
+ }
43
+
44
+ export function needsFinalReset(publicInputs: PrivateKernelCircuitPublicInputs) {
45
+ return (
46
+ countAccumulatedItems(publicInputs.end.noteHashes) > 0 ||
47
+ countAccumulatedItems(publicInputs.end.nullifiers) > 0 ||
48
+ countAccumulatedItems(publicInputs.end.encryptedLogsHashes) > 0 ||
49
+ countAccumulatedItems(publicInputs.validationRequests.noteHashReadRequests) > 0 ||
50
+ countAccumulatedItems(publicInputs.validationRequests.nullifierReadRequests) > 0 ||
51
+ countAccumulatedItems(publicInputs.validationRequests.scopedKeyValidationRequestsAndGenerators) > 0 ||
52
+ hasTransientNullifier(publicInputs)
53
+ );
54
+ }
@@ -1,12 +1,6 @@
1
1
  import { type PrivateKernelProver, type PrivateKernelSimulateOutput } from '@aztec/circuit-types';
2
2
  import {
3
3
  Fr,
4
- MAX_KEY_VALIDATION_REQUESTS_PER_TX,
5
- MAX_NOTE_ENCRYPTED_LOGS_PER_TX,
6
- MAX_NOTE_HASHES_PER_TX,
7
- MAX_NOTE_HASH_READ_REQUESTS_PER_TX,
8
- MAX_NULLIFIERS_PER_TX,
9
- MAX_NULLIFIER_READ_REQUESTS_PER_TX,
10
4
  PrivateCallData,
11
5
  PrivateKernelCircuitPublicInputs,
12
6
  PrivateKernelData,
@@ -17,7 +11,6 @@ import {
17
11
  type TxRequest,
18
12
  VK_TREE_HEIGHT,
19
13
  VerificationKeyAsFields,
20
- getNonEmptyItems,
21
14
  } from '@aztec/circuits.js';
22
15
  import { createDebugLogger } from '@aztec/foundation/log';
23
16
  import { assertLength } from '@aztec/foundation/serialize';
@@ -27,11 +20,18 @@ import {
27
20
  PrivateResetTagToArtifactName,
28
21
  getVKTreeRoot,
29
22
  } from '@aztec/noir-protocol-circuits-types';
30
- import { type ExecutionResult, collectNoteHashLeafIndexMap, collectNullifiedNoteHashCounters } from '@aztec/simulator';
23
+ import {
24
+ type ExecutionResult,
25
+ collectEnqueuedPublicFunctionCalls,
26
+ collectNoteHashLeafIndexMap,
27
+ collectNoteHashNullifierCounterMap,
28
+ collectPublicTeardownFunctionCall,
29
+ getFinalMinRevertibleSideEffectCounter,
30
+ } from '@aztec/simulator';
31
31
 
32
32
  import { type WitnessMap } from '@noir-lang/types';
33
33
 
34
- import { buildPrivateKernelResetInputs } from './private_inputs_builders/index.js';
34
+ import { buildPrivateKernelResetInputs, needsFinalReset, needsReset } from './hints/index.js';
35
35
  import { type ProvingDataOracle } from './proving_data_oracle.js';
36
36
 
37
37
  const NULL_PROVE_OUTPUT: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs> = {
@@ -71,18 +71,24 @@ export class KernelProver {
71
71
  let output = NULL_PROVE_OUTPUT;
72
72
 
73
73
  const noteHashLeafIndexMap = collectNoteHashLeafIndexMap(executionResult);
74
- const noteHashNullifierCounterMap = collectNullifiedNoteHashCounters(executionResult);
74
+ const noteHashNullifierCounterMap = collectNoteHashNullifierCounterMap(executionResult);
75
+ const enqueuedPublicFunctions = collectEnqueuedPublicFunctionCalls(executionResult);
76
+ const hasPublicCalls =
77
+ enqueuedPublicFunctions.length > 0 || !collectPublicTeardownFunctionCall(executionResult).isEmpty();
78
+ const validationRequestsSplitCounter = hasPublicCalls ? getFinalMinRevertibleSideEffectCounter(executionResult) : 0;
75
79
  // vector of gzipped bincode acirs
76
80
  const acirs: Buffer[] = [];
77
81
  const witnessStack: WitnessMap[] = [];
78
82
 
79
83
  while (executionStack.length) {
80
- if (!firstIteration && this.needsReset(executionStack, output)) {
84
+ if (!firstIteration && needsReset(output.publicInputs, executionStack)) {
81
85
  const resetInputs = await this.getPrivateKernelResetInputs(
82
86
  executionStack,
83
87
  output,
84
88
  noteHashLeafIndexMap,
85
89
  noteHashNullifierCounterMap,
90
+ validationRequestsSplitCounter,
91
+ false,
86
92
  );
87
93
  output = await this.proofCreator.simulateProofReset(resetInputs);
88
94
  // TODO(#7368) consider refactoring this redundant bytecode pushing
@@ -130,12 +136,14 @@ export class KernelProver {
130
136
  firstIteration = false;
131
137
  }
132
138
 
133
- if (this.somethingToReset(output)) {
139
+ if (needsFinalReset(output.publicInputs)) {
134
140
  const resetInputs = await this.getPrivateKernelResetInputs(
135
141
  executionStack,
136
142
  output,
137
143
  noteHashLeafIndexMap,
138
144
  noteHashNullifierCounterMap,
145
+ validationRequestsSplitCounter,
146
+ true,
139
147
  );
140
148
  output = await this.proofCreator.simulateProofReset(resetInputs);
141
149
  // TODO(#7368) consider refactoring this redundant bytecode pushing
@@ -176,47 +184,13 @@ export class KernelProver {
176
184
  return tailOutput;
177
185
  }
178
186
 
179
- private needsReset(
180
- executionStack: ExecutionResult[],
181
- output: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>,
182
- ) {
183
- const nextIteration = executionStack[executionStack.length - 1];
184
- return (
185
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.noteHashes).length +
186
- getNonEmptyItems(output.publicInputs.end.noteHashes).length >
187
- MAX_NOTE_HASHES_PER_TX ||
188
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.nullifiers).length +
189
- getNonEmptyItems(output.publicInputs.end.nullifiers).length >
190
- MAX_NULLIFIERS_PER_TX ||
191
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.noteEncryptedLogsHashes).length +
192
- getNonEmptyItems(output.publicInputs.end.noteEncryptedLogsHashes).length >
193
- MAX_NOTE_ENCRYPTED_LOGS_PER_TX ||
194
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.noteHashReadRequests).length +
195
- getNonEmptyItems(output.publicInputs.validationRequests.noteHashReadRequests).length >
196
- MAX_NOTE_HASH_READ_REQUESTS_PER_TX ||
197
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.nullifierReadRequests).length +
198
- getNonEmptyItems(output.publicInputs.validationRequests.nullifierReadRequests).length >
199
- MAX_NULLIFIER_READ_REQUESTS_PER_TX ||
200
- getNonEmptyItems(nextIteration.callStackItem.publicInputs.keyValidationRequestsAndGenerators).length +
201
- getNonEmptyItems(output.publicInputs.validationRequests.scopedKeyValidationRequestsAndGenerators).length >
202
- MAX_KEY_VALIDATION_REQUESTS_PER_TX
203
- );
204
- }
205
-
206
- private somethingToReset(output: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>) {
207
- return (
208
- getNonEmptyItems(output.publicInputs.validationRequests.noteHashReadRequests).length > 0 ||
209
- getNonEmptyItems(output.publicInputs.validationRequests.nullifierReadRequests).length > 0 ||
210
- getNonEmptyItems(output.publicInputs.validationRequests.scopedKeyValidationRequestsAndGenerators).length > 0 ||
211
- output.publicInputs.end.nullifiers.find(nullifier => !nullifier.nullifiedNoteHash.equals(Fr.zero()))
212
- );
213
- }
214
-
215
187
  private async getPrivateKernelResetInputs(
216
188
  executionStack: ExecutionResult[],
217
189
  output: PrivateKernelSimulateOutput<PrivateKernelCircuitPublicInputs>,
218
190
  noteHashLeafIndexMap: Map<bigint, bigint>,
219
191
  noteHashNullifierCounterMap: Map<number, number>,
192
+ validationRequestsSplitCounter: number,
193
+ shouldSilo: boolean,
220
194
  ) {
221
195
  const previousVkMembershipWitness = await this.oracle.getVkMembershipWitness(output.verificationKey);
222
196
  const previousKernelData = new PrivateKernelData(
@@ -231,6 +205,8 @@ export class KernelProver {
231
205
  previousKernelData,
232
206
  noteHashLeafIndexMap,
233
207
  noteHashNullifierCounterMap,
208
+ validationRequestsSplitCounter,
209
+ shouldSilo,
234
210
  this.oracle,
235
211
  );
236
212
  }
@@ -227,7 +227,7 @@ export class NoteProcessor {
227
227
  const incomingNotes = blocksAndNotes.flatMap(b => b.incomingNotes);
228
228
  const outgoingNotes = blocksAndNotes.flatMap(b => b.outgoingNotes);
229
229
  if (incomingNotes.length || outgoingNotes.length) {
230
- await this.db.addNotes(incomingNotes, outgoingNotes);
230
+ await this.db.addNotes(incomingNotes, outgoingNotes, this.account);
231
231
  incomingNotes.forEach(noteDao => {
232
232
  this.log.verbose(
233
233
  `Added incoming note for contract ${noteDao.contractAddress} at slot ${
@@ -51,7 +51,7 @@ export async function produceNoteDaos(
51
51
 
52
52
  try {
53
53
  if (ivpkM) {
54
- const { noteHashIndex, nonce, innerNoteHash, siloedNullifier } = await findNoteIndexAndNullifier(
54
+ const { noteHashIndex, nonce, noteHash, siloedNullifier } = await findNoteIndexAndNullifier(
55
55
  simulator,
56
56
  noteHashes,
57
57
  txHash,
@@ -69,7 +69,7 @@ export async function produceNoteDaos(
69
69
  payload.noteTypeId,
70
70
  txHash,
71
71
  nonce,
72
- innerNoteHash,
72
+ noteHash,
73
73
  siloedNullifier,
74
74
  index,
75
75
  ivpkM,
@@ -108,12 +108,12 @@ export async function produceNoteDaos(
108
108
  payload.noteTypeId,
109
109
  txHash,
110
110
  incomingNote.nonce,
111
- incomingNote.innerNoteHash,
111
+ incomingNote.noteHash,
112
112
  incomingNote.index,
113
113
  ovpkM,
114
114
  );
115
115
  } else {
116
- const { noteHashIndex, nonce, innerNoteHash } = await findNoteIndexAndNullifier(
116
+ const { noteHashIndex, nonce, noteHash } = await findNoteIndexAndNullifier(
117
117
  simulator,
118
118
  noteHashes,
119
119
  txHash,
@@ -130,7 +130,7 @@ export async function produceNoteDaos(
130
130
  payload.noteTypeId,
131
131
  txHash,
132
132
  nonce,
133
- innerNoteHash,
133
+ noteHash,
134
134
  index,
135
135
  ovpkM,
136
136
  );
@@ -170,7 +170,7 @@ export async function produceNoteDaos(
170
170
  * @dev Finds the index in the note hash tree by computing the note hash with different nonce and see which hash for
171
171
  * the current tx matches this value.
172
172
  * @remarks This method assists in identifying spent notes in the note hash tree.
173
- * @param noteHashes - Note hashes in the tx. One of them should correspond to the note we are looking for
173
+ * @param siloedNoteHashes - Note hashes in the tx. One of them should correspond to the note we are looking for
174
174
  * @param txHash - Hash of a tx the note was emitted in.
175
175
  * @param l1NotePayload - The note payload.
176
176
  * @param excludedIndices - Indices that have been assigned a note in the same tx. Notes in a tx can have the same
@@ -181,7 +181,7 @@ export async function produceNoteDaos(
181
181
  */
182
182
  async function findNoteIndexAndNullifier(
183
183
  simulator: AcirSimulator,
184
- noteHashes: Fr[],
184
+ siloedNoteHashes: Fr[],
185
185
  txHash: TxHash,
186
186
  { contractAddress, storageSlot, noteTypeId, note }: L1NotePayload,
187
187
  excludedIndices: Set<number>,
@@ -189,23 +189,23 @@ async function findNoteIndexAndNullifier(
189
189
  ) {
190
190
  let noteHashIndex = 0;
191
191
  let nonce: Fr | undefined;
192
- let innerNoteHash: Fr | undefined;
192
+ let noteHash: Fr | undefined;
193
193
  let siloedNoteHash: Fr | undefined;
194
194
  let innerNullifier: Fr | undefined;
195
195
  const firstNullifier = Fr.fromBuffer(txHash.toBuffer());
196
196
 
197
- for (; noteHashIndex < noteHashes.length; ++noteHashIndex) {
197
+ for (; noteHashIndex < siloedNoteHashes.length; ++noteHashIndex) {
198
198
  if (excludedIndices.has(noteHashIndex)) {
199
199
  continue;
200
200
  }
201
201
 
202
- const noteHash = noteHashes[noteHashIndex];
203
- if (noteHash.equals(Fr.ZERO)) {
202
+ const siloedNoteHashFromTxEffect = siloedNoteHashes[noteHashIndex];
203
+ if (siloedNoteHashFromTxEffect.equals(Fr.ZERO)) {
204
204
  break;
205
205
  }
206
206
 
207
207
  const expectedNonce = computeNoteHashNonce(firstNullifier, noteHashIndex);
208
- ({ innerNoteHash, siloedNoteHash, innerNullifier } = await simulator.computeNoteHashAndOptionallyANullifier(
208
+ ({ noteHash, siloedNoteHash, innerNullifier } = await simulator.computeNoteHashAndOptionallyANullifier(
209
209
  contractAddress,
210
210
  expectedNonce,
211
211
  storageSlot,
@@ -214,7 +214,7 @@ async function findNoteIndexAndNullifier(
214
214
  note,
215
215
  ));
216
216
 
217
- if (noteHash.equals(siloedNoteHash)) {
217
+ if (siloedNoteHashFromTxEffect.equals(siloedNoteHash)) {
218
218
  nonce = expectedNonce;
219
219
  break;
220
220
  }
@@ -229,7 +229,7 @@ async function findNoteIndexAndNullifier(
229
229
  return {
230
230
  noteHashIndex,
231
231
  nonce,
232
- innerNoteHash: innerNoteHash!,
232
+ noteHash: noteHash!,
233
233
  siloedNullifier: siloNullifier(contractAddress, innerNullifier!),
234
234
  };
235
235
  }
@@ -16,12 +16,14 @@ import {
16
16
  TxHash,
17
17
  TxReceipt,
18
18
  UnencryptedL2BlockL2Logs,
19
+ UniqueNote,
19
20
  } from '@aztec/circuit-types';
20
21
  import { FunctionSelector } from '@aztec/circuits.js';
21
22
  import { NoteSelector } from '@aztec/foundation/abi';
22
23
  import { AztecAddress } from '@aztec/foundation/aztec-address';
23
24
  import { EthAddress } from '@aztec/foundation/eth-address';
24
25
  import { Fr, GrumpkinScalar, Point } from '@aztec/foundation/fields';
26
+ import { BaseHashType } from '@aztec/foundation/hash';
25
27
  import { JsonRpcServer, createNamespacedJsonRpcServer } from '@aztec/foundation/json-rpc/server';
26
28
 
27
29
  import http from 'http';
@@ -40,12 +42,14 @@ export function createPXERpcServer(pxeService: PXE): JsonRpcServer {
40
42
  ExtendedUnencryptedL2Log,
41
43
  FunctionSelector,
42
44
  TxHash,
45
+ BaseHashType,
43
46
  EthAddress,
44
47
  Point,
45
48
  Fr,
46
49
  GrumpkinScalar,
47
50
  Note,
48
51
  ExtendedNote,
52
+ UniqueNote,
49
53
  AuthWitness,
50
54
  L2Block,
51
55
  TxEffect,
@@ -7,7 +7,7 @@ import { AztecLmdbStore } from '@aztec/kv-store/lmdb';
7
7
  import { initStoreForRollup } from '@aztec/kv-store/utils';
8
8
  import { getCanonicalAuthRegistry } from '@aztec/protocol-contracts/auth-registry';
9
9
  import { getCanonicalClassRegisterer } from '@aztec/protocol-contracts/class-registerer';
10
- import { getCanonicalGasToken } from '@aztec/protocol-contracts/gas-token';
10
+ import { getCanonicalFeeJuice } from '@aztec/protocol-contracts/fee-juice';
11
11
  import { getCanonicalInstanceDeployer } from '@aztec/protocol-contracts/instance-deployer';
12
12
  import { getCanonicalKeyRegistry } from '@aztec/protocol-contracts/key-registry';
13
13
  import { getCanonicalMultiCallEntrypointContract } from '@aztec/protocol-contracts/multi-call-entrypoint';
@@ -57,6 +57,7 @@ export async function createPXEService(
57
57
  : new BBNativePrivateKernelProver(
58
58
  config.bbBinaryPath!,
59
59
  config.bbWorkingDirectory!,
60
+ !!config.bbSkipCleanup,
60
61
  createDebugLogger('aztec:pxe:bb-native-prover' + (logSuffix ? `:${logSuffix}` : '')),
61
62
  );
62
63
  }
@@ -66,7 +67,7 @@ export async function createPXEService(
66
67
  getCanonicalClassRegisterer(),
67
68
  getCanonicalInstanceDeployer(),
68
69
  getCanonicalMultiCallEntrypointContract(),
69
- getCanonicalGasToken(),
70
+ getCanonicalFeeJuice(),
70
71
  getCanonicalKeyRegistry(),
71
72
  getCanonicalAuthRegistry(),
72
73
  ]) {