@aztec/sequencer-client 0.32.1 → 0.34.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 (62) hide show
  1. package/dest/global_variable_builder/global_builder.js +2 -2
  2. package/dest/publisher/l1-publisher.js +10 -10
  3. package/dest/publisher/viem-tx-sender.js +2 -2
  4. package/dest/sequencer/abstract_phase_manager.d.ts +16 -4
  5. package/dest/sequencer/abstract_phase_manager.d.ts.map +1 -1
  6. package/dest/sequencer/abstract_phase_manager.js +38 -39
  7. package/dest/sequencer/app_logic_phase_manager.d.ts +1 -0
  8. package/dest/sequencer/app_logic_phase_manager.d.ts.map +1 -1
  9. package/dest/sequencer/app_logic_phase_manager.js +4 -4
  10. package/dest/sequencer/hints_builder.d.ts +7 -3
  11. package/dest/sequencer/hints_builder.d.ts.map +1 -1
  12. package/dest/sequencer/hints_builder.js +24 -4
  13. package/dest/sequencer/phase_manager_factory.d.ts.map +1 -1
  14. package/dest/sequencer/phase_manager_factory.js +5 -4
  15. package/dest/sequencer/public_processor.d.ts +6 -3
  16. package/dest/sequencer/public_processor.d.ts.map +1 -1
  17. package/dest/sequencer/public_processor.js +65 -27
  18. package/dest/sequencer/sequencer.d.ts +2 -12
  19. package/dest/sequencer/sequencer.d.ts.map +1 -1
  20. package/dest/sequencer/sequencer.js +43 -49
  21. package/dest/sequencer/setup_phase_manager.d.ts +1 -0
  22. package/dest/sequencer/setup_phase_manager.d.ts.map +1 -1
  23. package/dest/sequencer/setup_phase_manager.js +3 -3
  24. package/dest/sequencer/tail_phase_manager.d.ts +6 -1
  25. package/dest/sequencer/tail_phase_manager.d.ts.map +1 -1
  26. package/dest/sequencer/tail_phase_manager.js +29 -4
  27. package/dest/sequencer/teardown_phase_manager.d.ts +1 -0
  28. package/dest/sequencer/teardown_phase_manager.d.ts.map +1 -1
  29. package/dest/sequencer/teardown_phase_manager.js +3 -3
  30. package/dest/sequencer/tx_validator.d.ts +2 -1
  31. package/dest/sequencer/tx_validator.d.ts.map +1 -1
  32. package/dest/sequencer/tx_validator.js +8 -7
  33. package/dest/sequencer/utils.d.ts.map +1 -1
  34. package/dest/sequencer/utils.js +8 -7
  35. package/dest/simulator/index.d.ts +2 -2
  36. package/dest/simulator/index.d.ts.map +1 -1
  37. package/dest/simulator/public_executor.js +3 -3
  38. package/dest/simulator/public_kernel.d.ts +2 -2
  39. package/dest/simulator/public_kernel.d.ts.map +1 -1
  40. package/dest/simulator/public_kernel.js +5 -5
  41. package/package.json +32 -15
  42. package/src/global_variable_builder/global_builder.ts +1 -1
  43. package/src/publisher/l1-publisher.ts +9 -9
  44. package/src/publisher/viem-tx-sender.ts +1 -1
  45. package/src/sequencer/abstract_phase_manager.ts +74 -63
  46. package/src/sequencer/app_logic_phase_manager.ts +3 -3
  47. package/src/sequencer/hints_builder.ts +42 -9
  48. package/src/sequencer/phase_manager_factory.ts +4 -3
  49. package/src/sequencer/public_processor.ts +97 -51
  50. package/src/sequencer/sequencer.ts +51 -61
  51. package/src/sequencer/setup_phase_manager.ts +2 -2
  52. package/src/sequencer/tail_phase_manager.ts +67 -3
  53. package/src/sequencer/teardown_phase_manager.ts +2 -2
  54. package/src/sequencer/tx_validator.ts +8 -6
  55. package/src/sequencer/utils.ts +7 -6
  56. package/src/simulator/index.ts +2 -1
  57. package/src/simulator/public_executor.ts +2 -2
  58. package/src/simulator/public_kernel.ts +6 -5
  59. package/dest/utils.d.ts +0 -12
  60. package/dest/utils.d.ts.map +0 -1
  61. package/dest/utils.js +0 -16
  62. package/src/utils.ts +0 -16
@@ -1,7 +1,7 @@
1
1
  import { type L1ToL2MessageSource, type L2Block, type L2BlockSource, type ProcessedTx, Tx } from '@aztec/circuit-types';
2
2
  import { type BlockProver, PROVING_STATUS } from '@aztec/circuit-types/interfaces';
3
3
  import { type L2BlockBuiltStats } from '@aztec/circuit-types/stats';
4
- import { AztecAddress, EthAddress, type GlobalVariables } from '@aztec/circuits.js';
4
+ import { AztecAddress, EthAddress } from '@aztec/circuits.js';
5
5
  import { Fr } from '@aztec/foundation/fields';
6
6
  import { createDebugLogger } from '@aztec/foundation/log';
7
7
  import { RunningPromise } from '@aztec/foundation/running-promise';
@@ -52,7 +52,7 @@ export class Sequencer {
52
52
  private log = createDebugLogger('aztec:sequencer'),
53
53
  ) {
54
54
  this.updateConfig(config);
55
- this.log(`Initialized sequencer with ${this.minTxsPerBLock}-${this.maxTxsPerBlock} txs per block.`);
55
+ this.log.verbose(`Initialized sequencer with ${this.minTxsPerBLock}-${this.maxTxsPerBlock} txs per block.`);
56
56
  }
57
57
 
58
58
  /**
@@ -92,25 +92,25 @@ export class Sequencer {
92
92
  this.runningPromise = new RunningPromise(this.work.bind(this), this.pollingIntervalMs);
93
93
  this.runningPromise.start();
94
94
  this.state = SequencerState.IDLE;
95
- this.log('Sequencer started');
95
+ this.log.info('Sequencer started');
96
96
  }
97
97
 
98
98
  /**
99
99
  * Stops the sequencer from processing txs and moves to STOPPED state.
100
100
  */
101
101
  public async stop(): Promise<void> {
102
- this.log(`Stopping sequencer`);
102
+ this.log.debug(`Stopping sequencer`);
103
103
  await this.runningPromise?.stop();
104
104
  this.publisher.interrupt();
105
105
  this.state = SequencerState.STOPPED;
106
- this.log('Stopped sequencer');
106
+ this.log.info('Stopped sequencer');
107
107
  }
108
108
 
109
109
  /**
110
110
  * Starts a previously stopped sequencer.
111
111
  */
112
112
  public restart() {
113
- this.log('Restarting sequencer');
113
+ this.log.info('Restarting sequencer');
114
114
  this.publisher.restart();
115
115
  this.runningPromise!.start();
116
116
  this.state = SequencerState.IDLE;
@@ -137,7 +137,7 @@ export class Sequencer {
137
137
  // Update state when the previous block has been synced
138
138
  const prevBlockSynced = await this.isBlockSynced();
139
139
  if (prevBlockSynced && this.state === SequencerState.PUBLISHING_BLOCK) {
140
- this.log(`Block has been synced`);
140
+ this.log.debug(`Block has been synced`);
141
141
  this.state = SequencerState.IDLE;
142
142
  }
143
143
 
@@ -193,57 +193,75 @@ export class Sequencer {
193
193
  this.log.info(`Building block ${newBlockNumber} with ${validTxs.length} transactions`);
194
194
  this.state = SequencerState.CREATING_BLOCK;
195
195
 
196
+ // Get l1 to l2 messages from the contract
197
+ this.log.debug('Requesting L1 to L2 messages from contract');
198
+ const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(BigInt(newBlockNumber));
199
+ this.log.verbose(`Retrieved ${l1ToL2Messages.length} L1 to L2 messages for block ${newBlockNumber}`);
200
+
196
201
  // We create a fresh processor each time to reset any cached state (eg storage writes)
197
202
  const processor = await this.publicProcessorFactory.create(historicalHeader, newGlobalVariables);
198
- const [publicProcessorDuration, [processedTxs, failedTxs]] = await elapsed(() => processor.process(validTxs));
203
+
204
+ const emptyTx = processor.makeEmptyProcessedTx();
205
+
206
+ const blockBuildingTimer = new Timer();
207
+
208
+ // We must initialise the block to be a power of 2 in size
209
+ const numRealTxs = validTxs.length;
210
+ const pow2 = Math.log2(numRealTxs);
211
+ const totalTxs = 2 ** Math.ceil(pow2);
212
+ const blockSize = Math.max(2, totalTxs);
213
+ const blockTicket = await this.prover.startNewBlock(blockSize, newGlobalVariables, l1ToL2Messages, emptyTx);
214
+
215
+ const [publicProcessorDuration, [processedTxs, failedTxs]] = await elapsed(() =>
216
+ processor.process(validTxs, blockSize, this.prover, txValidator),
217
+ );
199
218
  if (failedTxs.length > 0) {
200
219
  const failedTxData = failedTxs.map(fail => fail.tx);
201
- this.log(`Dropping failed txs ${Tx.getHashes(failedTxData).join(', ')}`);
220
+ this.log.debug(`Dropping failed txs ${Tx.getHashes(failedTxData).join(', ')}`);
202
221
  await this.p2pClient.deleteTxs(Tx.getHashes(failedTxData));
203
222
  }
204
223
 
205
- // Only accept processed transactions that are not double-spends,
206
- // public functions emitting nullifiers would pass earlier check but fail here.
207
- // Note that we're checking all nullifiers generated in the private execution twice,
208
- // we could store the ones already checked and skip them here as an optimization.
209
- const processedValidTxs = await this.takeValidTxs(processedTxs, txValidator);
210
-
211
- if (processedValidTxs.length === 0) {
212
- this.log('No txs processed correctly to build block. Exiting');
224
+ if (processedTxs.length === 0) {
225
+ this.log.verbose('No txs processed correctly to build block. Exiting');
226
+ this.prover.cancelBlock();
213
227
  return;
214
228
  }
215
229
 
216
230
  await assertBlockHeight();
217
231
 
218
- // Get l1 to l2 messages from the contract
219
- this.log('Requesting L1 to L2 messages from contract');
220
- const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(BigInt(newBlockNumber));
221
- this.log(`Retrieved ${l1ToL2Messages.length} L1 to L2 messages for block ${newBlockNumber}`);
232
+ // All real transactions have been added, set the block as full and complete the proving.
233
+ await this.prover.setBlockCompleted();
222
234
 
223
- // Build the new block by running the rollup circuits
224
- this.log(`Assembling block with txs ${processedValidTxs.map(tx => tx.hash).join(', ')}`);
235
+ // Here we are now waiting for the block to be proven.
236
+ // TODO(@PhilWindle) We should probably periodically check for things like another
237
+ // block being published before ours instead of just waiting on our block
238
+ const result = await blockTicket.provingPromise;
239
+ if (result.status === PROVING_STATUS.FAILURE) {
240
+ throw new Error(`Block proving failed, reason: ${result.reason}`);
241
+ }
225
242
 
226
243
  await assertBlockHeight();
227
244
 
228
- const emptyTx = processor.makeEmptyProcessedTx();
229
- const [rollupCircuitsDuration, block] = await elapsed(() =>
230
- this.buildBlock(processedValidTxs, l1ToL2Messages, emptyTx, newGlobalVariables),
231
- );
245
+ // Block is proven, now finalise and publish!
246
+ const blockResult = await this.prover.finaliseBlock();
247
+ const block = blockResult.block;
248
+
249
+ await assertBlockHeight();
232
250
 
233
- this.log(`Assembled block ${block.number}`, {
251
+ this.log.verbose(`Assembled block ${block.number}`, {
234
252
  eventName: 'l2-block-built',
235
253
  duration: workTimer.ms(),
236
254
  publicProcessDuration: publicProcessorDuration,
237
- rollupCircuitsDuration: rollupCircuitsDuration,
255
+ rollupCircuitsDuration: blockBuildingTimer.ms(),
238
256
  ...block.getStats(),
239
257
  } satisfies L2BlockBuiltStats);
240
258
 
241
- await assertBlockHeight();
242
-
243
259
  await this.publishL2Block(block);
244
- this.log.info(`Submitted rollup block ${block.number} with ${processedValidTxs.length} transactions`);
260
+ this.log.info(`Submitted rollup block ${block.number} with ${processedTxs.length} transactions`);
245
261
  } catch (err) {
246
262
  this.log.error(`Rolling back world state DB due to error assembling block`, (err as any).stack);
263
+ // Cancel any further proving on the block
264
+ this.prover?.cancelBlock();
247
265
  await this.worldState.getLatest().rollback();
248
266
  }
249
267
  }
@@ -257,7 +275,6 @@ export class Sequencer {
257
275
  this.state = SequencerState.PUBLISHING_BLOCK;
258
276
  const publishedL2Block = await this.publisher.processL2Block(block);
259
277
  if (publishedL2Block) {
260
- this.log(`Successfully published block ${block.number}`);
261
278
  this.lastPublishedBlock = block.number;
262
279
  } else {
263
280
  throw new Error(`Failed to publish block`);
@@ -267,7 +284,7 @@ export class Sequencer {
267
284
  protected async takeValidTxs<T extends Tx | ProcessedTx>(txs: T[], validator: TxValidator): Promise<T[]> {
268
285
  const [valid, invalid] = await validator.validateTxs(txs);
269
286
  if (invalid.length > 0) {
270
- this.log(`Dropping invalid txs from the p2p pool ${Tx.getHashes(invalid).join(', ')}`);
287
+ this.log.debug(`Dropping invalid txs from the p2p pool ${Tx.getHashes(invalid).join(', ')}`);
271
288
  await this.p2pClient.deleteTxs(Tx.getHashes(invalid));
272
289
  }
273
290
 
@@ -289,33 +306,6 @@ export class Sequencer {
289
306
  return min >= this.lastPublishedBlock;
290
307
  }
291
308
 
292
- /**
293
- * Pads the set of txs to a power of two and assembles a block by calling the block builder.
294
- * @param txs - Processed txs to include in the next block.
295
- * @param l1ToL2Messages - L1 to L2 messages to be part of the block.
296
- * @param emptyTx - Empty tx to repeat at the end of the block to pad to a power of two.
297
- * @param globalVariables - Global variables to use in the block.
298
- * @returns The new block.
299
- */
300
- protected async buildBlock(
301
- txs: ProcessedTx[],
302
- l1ToL2Messages: Fr[],
303
- emptyTx: ProcessedTx,
304
- globalVariables: GlobalVariables,
305
- ) {
306
- const blockTicket = await this.prover.startNewBlock(txs.length, globalVariables, l1ToL2Messages, emptyTx);
307
-
308
- for (const tx of txs) {
309
- await this.prover.addNewTx(tx);
310
- }
311
-
312
- const result = await blockTicket.provingPromise;
313
- if (result.status === PROVING_STATUS.FAILURE) {
314
- throw new Error(`Block proving failed, reason: ${result.reason}`);
315
- }
316
- return result.block;
317
- }
318
-
319
309
  get coinbase(): EthAddress {
320
310
  return this._coinbase;
321
311
  }
@@ -34,7 +34,7 @@ export class SetupPhaseManager extends AbstractPhaseManager {
34
34
  previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
35
35
  previousPublicKernelProof: Proof,
36
36
  ) {
37
- this.log(`Processing tx ${tx.getTxHash()}`);
37
+ this.log.verbose(`Processing tx ${tx.getTxHash()}`);
38
38
  const [publicKernelOutput, publicKernelProof, newUnencryptedFunctionLogs, revertReason] =
39
39
  await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousPublicKernelProof).catch(
40
40
  // the abstract phase manager throws if simulation gives error in a non-revertible phase
@@ -45,6 +45,6 @@ export class SetupPhaseManager extends AbstractPhaseManager {
45
45
  );
46
46
  tx.unencryptedLogs.addFunctionLogs(newUnencryptedFunctionLogs);
47
47
  await this.publicStateDB.checkpoint();
48
- return { publicKernelOutput, publicKernelProof, revertReason };
48
+ return { publicKernelOutput, publicKernelProof, revertReason, returnValues: undefined };
49
49
  }
50
50
  }
@@ -1,10 +1,19 @@
1
1
  import { type Tx } from '@aztec/circuit-types';
2
2
  import {
3
+ type Fr,
3
4
  type GlobalVariables,
4
5
  type Header,
6
+ type KernelCircuitPublicInputs,
7
+ MAX_NEW_NOTE_HASHES_PER_TX,
5
8
  type Proof,
6
9
  type PublicKernelCircuitPublicInputs,
10
+ PublicKernelTailCircuitPrivateInputs,
11
+ type SideEffect,
12
+ makeEmptyProof,
13
+ mergeAccumulatedData,
14
+ sortByCounter,
7
15
  } from '@aztec/circuits.js';
16
+ import { type Tuple } from '@aztec/foundation/serialize';
8
17
  import { type PublicExecutor, type PublicStateDB } from '@aztec/simulator';
9
18
  import { type MerkleTreeOperations } from '@aztec/world-state';
10
19
 
@@ -27,8 +36,8 @@ export class TailPhaseManager extends AbstractPhaseManager {
27
36
  }
28
37
 
29
38
  async handle(tx: Tx, previousPublicKernelOutput: PublicKernelCircuitPublicInputs, previousPublicKernelProof: Proof) {
30
- this.log(`Processing tx ${tx.getTxHash()}`);
31
- const [publicKernelOutput, publicKernelProof] = await this.runKernelCircuit(
39
+ this.log.verbose(`Processing tx ${tx.getTxHash()}`);
40
+ const [finalKernelOutput, publicKernelProof] = await this.runTailKernelCircuit(
32
41
  previousPublicKernelOutput,
33
42
  previousPublicKernelProof,
34
43
  ).catch(
@@ -42,6 +51,61 @@ export class TailPhaseManager extends AbstractPhaseManager {
42
51
  // commit the state updates from this transaction
43
52
  await this.publicStateDB.commit();
44
53
 
45
- return { publicKernelOutput, publicKernelProof, revertReason: undefined };
54
+ return {
55
+ publicKernelOutput: previousPublicKernelOutput,
56
+ finalKernelOutput,
57
+ publicKernelProof,
58
+ revertReason: undefined,
59
+ returnValues: undefined,
60
+ };
61
+ }
62
+
63
+ private async runTailKernelCircuit(
64
+ previousOutput: PublicKernelCircuitPublicInputs,
65
+ previousProof: Proof,
66
+ ): Promise<[KernelCircuitPublicInputs, Proof]> {
67
+ const output = await this.simulate(previousOutput, previousProof);
68
+
69
+ // Temporary hack. Should sort them in the tail circuit.
70
+ const noteHashes = mergeAccumulatedData(
71
+ MAX_NEW_NOTE_HASHES_PER_TX,
72
+ previousOutput.endNonRevertibleData.newNoteHashes,
73
+ previousOutput.end.newNoteHashes,
74
+ );
75
+ output.end.newNoteHashes = this.sortNoteHashes<typeof MAX_NEW_NOTE_HASHES_PER_TX>(noteHashes);
76
+
77
+ return [output, makeEmptyProof()];
78
+ }
79
+
80
+ private async simulate(
81
+ previousOutput: PublicKernelCircuitPublicInputs,
82
+ previousProof: Proof,
83
+ ): Promise<KernelCircuitPublicInputs> {
84
+ const previousKernel = this.getPreviousKernelData(previousOutput, previousProof);
85
+
86
+ const { validationRequests, endNonRevertibleData, end } = previousOutput;
87
+ const nullifierReadRequestHints = await this.hintsBuilder.getNullifierReadRequestHints(
88
+ validationRequests.nullifierReadRequests,
89
+ endNonRevertibleData.newNullifiers,
90
+ end.newNullifiers,
91
+ );
92
+ const nullifierNonExistentReadRequestHints = await this.hintsBuilder.getNullifierNonExistentReadRequestHints(
93
+ validationRequests.nullifierNonExistentReadRequests,
94
+ endNonRevertibleData.newNullifiers,
95
+ end.newNullifiers,
96
+ );
97
+ const inputs = new PublicKernelTailCircuitPrivateInputs(
98
+ previousKernel,
99
+ nullifierReadRequestHints,
100
+ nullifierNonExistentReadRequestHints,
101
+ );
102
+ return this.publicKernel.publicKernelCircuitTail(inputs);
103
+ }
104
+
105
+ private sortNoteHashes<N extends number>(noteHashes: Tuple<SideEffect, N>): Tuple<Fr, N> {
106
+ return sortByCounter(noteHashes.map(n => ({ ...n, counter: n.counter.toNumber() }))).map(n => n.value) as Tuple<
107
+ Fr,
108
+ N
109
+ >;
46
110
  }
47
111
  }
@@ -34,7 +34,7 @@ export class TeardownPhaseManager extends AbstractPhaseManager {
34
34
  previousPublicKernelOutput: PublicKernelCircuitPublicInputs,
35
35
  previousPublicKernelProof: Proof,
36
36
  ) {
37
- this.log(`Processing tx ${tx.getTxHash()}`);
37
+ this.log.verbose(`Processing tx ${tx.getTxHash()}`);
38
38
  const [publicKernelOutput, publicKernelProof, newUnencryptedFunctionLogs, revertReason] =
39
39
  await this.processEnqueuedPublicCalls(tx, previousPublicKernelOutput, previousPublicKernelProof).catch(
40
40
  // the abstract phase manager throws if simulation gives error in a non-revertible phase
@@ -45,6 +45,6 @@ export class TeardownPhaseManager extends AbstractPhaseManager {
45
45
  );
46
46
  tx.unencryptedLogs.addFunctionLogs(newUnencryptedFunctionLogs);
47
47
  await this.publicStateDB.checkpoint();
48
- return { publicKernelOutput, publicKernelProof, revertReason };
48
+ return { publicKernelOutput, publicKernelProof, revertReason, returnValues: undefined };
49
49
  }
50
50
  }
@@ -138,9 +138,7 @@ export class TxValidator {
138
138
  * @returns Whether this is a problematic double spend that the L1 contract would reject.
139
139
  */
140
140
  async #validateNullifiers(tx: Tx | ProcessedTx, thisBlockNullifiers: Set<bigint>): Promise<TxValidationStatus> {
141
- const newNullifiers = [...tx.data.endNonRevertibleData.newNullifiers, ...tx.data.end.newNullifiers]
142
- .filter(x => !x.isEmpty())
143
- .map(x => x.value.toBigInt());
141
+ const newNullifiers = tx.data.getNonEmptyNullifiers().map(x => x.toBigInt());
144
142
 
145
143
  // Ditch this tx if it has repeated nullifiers
146
144
  const uniqueNullifiers = new Set(newNullifiers);
@@ -172,7 +170,7 @@ export class TxValidator {
172
170
  }
173
171
 
174
172
  async #validateGasBalance(tx: Tx): Promise<TxValidationStatus> {
175
- if (!tx.data.needsTeardown) {
173
+ if (!tx.data.forPublic || !tx.data.forPublic.needsTeardown) {
176
174
  return VALID_TX;
177
175
  }
178
176
 
@@ -200,7 +198,11 @@ export class TxValidator {
200
198
  }
201
199
 
202
200
  #validateMaxBlockNumber(tx: Tx | ProcessedTx): TxValidationStatus {
203
- const maxBlockNumber = tx.data.rollupValidationRequests.maxBlockNumber;
201
+ const target =
202
+ tx instanceof Tx
203
+ ? tx.data.forRollup?.rollupValidationRequests || tx.data.forPublic!.validationRequests.forRollup
204
+ : tx.data.rollupValidationRequests;
205
+ const maxBlockNumber = target.maxBlockNumber;
204
206
 
205
207
  if (maxBlockNumber.isSome && maxBlockNumber.value < this.#globalVariables.blockNumber) {
206
208
  this.#log.warn(`Rejecting tx ${Tx.getHash(tx)} for low max block number`);
@@ -211,7 +213,7 @@ export class TxValidator {
211
213
  }
212
214
 
213
215
  async #validateFee(tx: Tx): Promise<TxValidationStatus> {
214
- if (!tx.data.needsTeardown) {
216
+ if (!tx.data.forPublic || !tx.data.forPublic.needsTeardown) {
215
217
  // TODO check if fees are mandatory and reject this tx
216
218
  this.#log.debug(`Tx ${Tx.getHash(tx)} doesn't pay for gas`);
217
219
  return VALID_TX;
@@ -7,13 +7,14 @@ import { CallRequest } from '@aztec/circuits.js';
7
7
  * @returns The highest side effect counter in the transaction so far
8
8
  */
9
9
  export function lastSideEffectCounter(tx: Tx): number {
10
+ const data = tx.data.forPublic!;
10
11
  const sideEffectCounters = [
11
- ...tx.data.endNonRevertibleData.newNoteHashes,
12
- ...tx.data.endNonRevertibleData.newNullifiers,
13
- ...tx.data.endNonRevertibleData.publicCallStack,
14
- ...tx.data.end.newNoteHashes,
15
- ...tx.data.end.newNullifiers,
16
- ...tx.data.end.publicCallStack,
12
+ ...data.endNonRevertibleData.newNoteHashes,
13
+ ...data.endNonRevertibleData.newNullifiers,
14
+ ...data.endNonRevertibleData.publicCallStack,
15
+ ...data.end.newNoteHashes,
16
+ ...data.end.newNullifiers,
17
+ ...data.end.publicCallStack,
17
18
  ];
18
19
 
19
20
  let max = 0;
@@ -1,4 +1,5 @@
1
1
  import {
2
+ type KernelCircuitPublicInputs,
2
3
  type PublicKernelCircuitPrivateInputs,
3
4
  type PublicKernelCircuitPublicInputs,
4
5
  type PublicKernelTailCircuitPrivateInputs,
@@ -31,5 +32,5 @@ export interface PublicKernelCircuitSimulator {
31
32
  * @param inputs - Inputs to the circuit.
32
33
  * @returns The public inputs as outputs of the simulation.
33
34
  */
34
- publicKernelCircuitTail(inputs: PublicKernelTailCircuitPrivateInputs): Promise<PublicKernelCircuitPublicInputs>;
35
+ publicKernelCircuitTail(inputs: PublicKernelTailCircuitPrivateInputs): Promise<KernelCircuitPublicInputs>;
35
36
  }
@@ -47,11 +47,11 @@ export class ContractsDataSourcePublicDB implements PublicContractsDB {
47
47
  // Extract contract class and instance data from logs and add to cache for this block
48
48
  const logs = tx.unencryptedLogs.unrollLogs();
49
49
  ContractClassRegisteredEvent.fromLogs(logs, getCanonicalClassRegistererAddress()).forEach(e => {
50
- this.log(`Adding class ${e.contractClassId.toString()} to public execution contract cache`);
50
+ this.log.debug(`Adding class ${e.contractClassId.toString()} to public execution contract cache`);
51
51
  this.classCache.set(e.contractClassId.toString(), e.toContractClassPublic());
52
52
  });
53
53
  ContractInstanceDeployedEvent.fromLogs(logs).forEach(e => {
54
- this.log(
54
+ this.log.debug(
55
55
  `Adding instance ${e.address.toString()} with class ${e.contractClassId.toString()} to public execution contract cache`,
56
56
  );
57
57
  this.instanceCache.set(e.address.toString(), e.toContractInstance());
@@ -1,5 +1,6 @@
1
1
  import { type CircuitSimulationStats } from '@aztec/circuit-types/stats';
2
2
  import {
3
+ type KernelCircuitPublicInputs,
3
4
  type PublicKernelCircuitPrivateInputs,
4
5
  type PublicKernelCircuitPublicInputs,
5
6
  type PublicKernelTailCircuitPrivateInputs,
@@ -51,7 +52,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
51
52
  this.wasmSimulator.simulateCircuit(inputWitness, PublicKernelSetupArtifact),
52
53
  );
53
54
  const result = convertPublicSetupRollupOutputFromWitnessMap(witness);
54
- this.log(`Simulated public kernel setup circuit`, {
55
+ this.log.debug(`Simulated public kernel setup circuit`, {
55
56
  eventName: 'circuit-simulation',
56
57
  circuitName: 'public-kernel-setup',
57
58
  duration,
@@ -77,7 +78,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
77
78
  this.wasmSimulator.simulateCircuit(inputWitness, PublicKernelAppLogicArtifact),
78
79
  );
79
80
  const result = convertPublicInnerRollupOutputFromWitnessMap(witness);
80
- this.log(`Simulated public kernel app logic circuit`, {
81
+ this.log.debug(`Simulated public kernel app logic circuit`, {
81
82
  eventName: 'circuit-simulation',
82
83
  circuitName: 'public-kernel-app-logic',
83
84
  duration,
@@ -103,7 +104,7 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
103
104
  this.wasmSimulator.simulateCircuit(inputWitness, PublicKernelTeardownArtifact),
104
105
  );
105
106
  const result = convertPublicTeardownRollupOutputFromWitnessMap(witness);
106
- this.log(`Simulated public kernel teardown circuit`, {
107
+ this.log.debug(`Simulated public kernel teardown circuit`, {
107
108
  eventName: 'circuit-simulation',
108
109
  circuitName: 'public-kernel-teardown',
109
110
  duration,
@@ -120,13 +121,13 @@ export class RealPublicKernelCircuitSimulator implements PublicKernelCircuitSimu
120
121
  */
121
122
  public async publicKernelCircuitTail(
122
123
  input: PublicKernelTailCircuitPrivateInputs,
123
- ): Promise<PublicKernelCircuitPublicInputs> {
124
+ ): Promise<KernelCircuitPublicInputs> {
124
125
  const inputWitness = convertPublicTailInputsToWitnessMap(input);
125
126
  const [duration, witness] = await elapsed(() =>
126
127
  this.wasmSimulator.simulateCircuit(inputWitness, PublicKernelTailArtifact),
127
128
  );
128
129
  const result = convertPublicTailOutputFromWitnessMap(witness);
129
- this.log(`Simulated public kernel tail circuit`, {
130
+ this.log.debug(`Simulated public kernel tail circuit`, {
130
131
  eventName: 'circuit-simulation',
131
132
  circuitName: 'public-kernel-tail',
132
133
  duration,
package/dest/utils.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Returns a promise that resolves after ms milliseconds, returning "returnValue".
3
- * @param ms - How many milliseconds to sleep.
4
- * @param returnValue - The return value of the promise.
5
- */
6
- export declare function sleep<T>(ms: number, returnValue: T): Promise<T>;
7
- /**
8
- * Returns the lowest power of two that is greater of equal to the input.
9
- * @param num - The input.
10
- */
11
- export declare function ceilPowerOfTwo(num: number): number;
12
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE/D;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAElD"}
package/dest/utils.js DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns a promise that resolves after ms milliseconds, returning "returnValue".
3
- * @param ms - How many milliseconds to sleep.
4
- * @param returnValue - The return value of the promise.
5
- */
6
- export function sleep(ms, returnValue) {
7
- return new Promise(resolve => setTimeout(() => resolve(returnValue), ms));
8
- }
9
- /**
10
- * Returns the lowest power of two that is greater of equal to the input.
11
- * @param num - The input.
12
- */
13
- export function ceilPowerOfTwo(num) {
14
- return 2 ** Math.ceil(Math.log2(num));
15
- }
16
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7R0FJRztBQUNILE1BQU0sVUFBVSxLQUFLLENBQUksRUFBVSxFQUFFLFdBQWM7SUFDakQsT0FBTyxJQUFJLE9BQU8sQ0FBQyxPQUFPLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxHQUFHLEVBQUUsQ0FBQyxPQUFPLENBQUMsV0FBVyxDQUFDLEVBQUUsRUFBRSxDQUFDLENBQUMsQ0FBQztBQUM1RSxDQUFDO0FBRUQ7OztHQUdHO0FBQ0gsTUFBTSxVQUFVLGNBQWMsQ0FBQyxHQUFXO0lBQ3hDLE9BQU8sQ0FBQyxJQUFJLElBQUksQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLElBQUksQ0FBQyxHQUFHLENBQUMsQ0FBQyxDQUFDO0FBQ3hDLENBQUMifQ==
package/src/utils.ts DELETED
@@ -1,16 +0,0 @@
1
- /**
2
- * Returns a promise that resolves after ms milliseconds, returning "returnValue".
3
- * @param ms - How many milliseconds to sleep.
4
- * @param returnValue - The return value of the promise.
5
- */
6
- export function sleep<T>(ms: number, returnValue: T): Promise<T> {
7
- return new Promise(resolve => setTimeout(() => resolve(returnValue), ms));
8
- }
9
-
10
- /**
11
- * Returns the lowest power of two that is greater of equal to the input.
12
- * @param num - The input.
13
- */
14
- export function ceilPowerOfTwo(num: number): number {
15
- return 2 ** Math.ceil(Math.log2(num));
16
- }