@aztec/stdlib 0.84.0-alpha-testnet.1 → 0.84.0-nightly.20250406

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 (36) hide show
  1. package/dest/avm/avm.d.ts +1691 -123
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm.js +110 -17
  4. package/dest/avm/avm_proving_request.d.ts +740 -23
  5. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  6. package/dest/epoch-helpers/index.d.ts +9 -0
  7. package/dest/epoch-helpers/index.d.ts.map +1 -1
  8. package/dest/epoch-helpers/index.js +15 -2
  9. package/dest/interfaces/proving-job.d.ts +740 -23
  10. package/dest/interfaces/proving-job.d.ts.map +1 -1
  11. package/dest/logs/log_with_tx_data.d.ts +3 -2
  12. package/dest/logs/log_with_tx_data.d.ts.map +1 -1
  13. package/dest/logs/log_with_tx_data.js +3 -2
  14. package/dest/logs/pending_tagged_log.d.ts +3 -2
  15. package/dest/logs/pending_tagged_log.d.ts.map +1 -1
  16. package/dest/logs/pending_tagged_log.js +1 -1
  17. package/dest/messaging/l1_to_l2_message_source.d.ts +5 -0
  18. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  19. package/dest/tests/factories.d.ts +5 -1
  20. package/dest/tests/factories.d.ts.map +1 -1
  21. package/dest/tests/factories.js +22 -7
  22. package/dest/tx/index.d.ts +1 -0
  23. package/dest/tx/index.d.ts.map +1 -1
  24. package/dest/tx/index.js +1 -0
  25. package/dest/tx/validator/error_texts.d.ts +19 -0
  26. package/dest/tx/validator/error_texts.d.ts.map +1 -0
  27. package/dest/tx/validator/error_texts.js +26 -0
  28. package/package.json +6 -6
  29. package/src/avm/avm.ts +171 -29
  30. package/src/epoch-helpers/index.ts +19 -0
  31. package/src/logs/log_with_tx_data.ts +4 -3
  32. package/src/logs/pending_tagged_log.ts +3 -2
  33. package/src/messaging/l1_to_l2_message_source.ts +7 -0
  34. package/src/tests/factories.ts +51 -4
  35. package/src/tx/index.ts +1 -0
  36. package/src/tx/validator/error_texts.ts +33 -0
package/src/avm/avm.ts CHANGED
@@ -10,7 +10,7 @@ import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
10
10
  import { MerkleTreeId } from '../trees/merkle_tree_id.js';
11
11
  import { NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
12
12
  import { PublicDataTreeLeafPreimage } from '../trees/public_data_leaf.js';
13
- import type { Tx } from '../tx/index.js';
13
+ import { TreeSnapshots, type Tx } from '../tx/index.js';
14
14
  import { AvmCircuitPublicInputs } from './avm_circuit_public_inputs.js';
15
15
  import { serializeWithMessagePack } from './message_pack.js';
16
16
 
@@ -262,6 +262,117 @@ function AvmSequentialInsertHintFactory(klass: IndexedTreeLeafPreimagesClasses)
262
262
  export class AvmSequentialInsertHintPublicDataTree extends AvmSequentialInsertHintFactory(PublicDataTreeLeafPreimage) {}
263
263
  export class AvmSequentialInsertHintNullifierTree extends AvmSequentialInsertHintFactory(NullifierLeafPreimage) {}
264
264
 
265
+ // Hint for MerkleTreeDB.appendLeaves.
266
+ // Note: only supported for NOTE_HASH_TREE and L1_TO_L2_MESSAGE_TREE.
267
+ export class AvmAppendLeavesHint {
268
+ constructor(
269
+ public readonly hintKey: AppendOnlyTreeSnapshot,
270
+ public readonly stateAfter: AppendOnlyTreeSnapshot,
271
+ // params
272
+ public readonly treeId: MerkleTreeId,
273
+ public readonly leaves: Fr[],
274
+ ) {}
275
+
276
+ static get schema() {
277
+ return z
278
+ .object({
279
+ hintKey: AppendOnlyTreeSnapshot.schema,
280
+ stateAfter: AppendOnlyTreeSnapshot.schema,
281
+ treeId: z.number().int().nonnegative(),
282
+ leaves: schemas.Fr.array(),
283
+ })
284
+ .transform(
285
+ ({ hintKey, stateAfter, treeId, leaves }) => new AvmAppendLeavesHint(hintKey, stateAfter, treeId, leaves),
286
+ );
287
+ }
288
+ }
289
+
290
+ // Hint for checkpoint actions that don't change the state.
291
+ class AvmCheckpointActionNoStateChangeHint {
292
+ constructor(
293
+ // key
294
+ public readonly actionCounter: number,
295
+ // current checkpoint evolution
296
+ public readonly oldCheckpointId: number,
297
+ public readonly newCheckpointId: number,
298
+ ) {}
299
+
300
+ static get schema() {
301
+ return z
302
+ .object({
303
+ actionCounter: z.number().int().nonnegative(),
304
+ oldCheckpointId: z.number().int().nonnegative(),
305
+ newCheckpointId: z.number().int().nonnegative(),
306
+ })
307
+ .transform(
308
+ ({ actionCounter, oldCheckpointId, newCheckpointId }) =>
309
+ new AvmCheckpointActionNoStateChangeHint(actionCounter, oldCheckpointId, newCheckpointId),
310
+ );
311
+ }
312
+ }
313
+
314
+ // Hint for MerkleTreeDB.createCheckpoint.
315
+ export class AvmCreateCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
316
+
317
+ // Hint for MerkleTreeDB.commitCheckpoint.
318
+ export class AvmCommitCheckpointHint extends AvmCheckpointActionNoStateChangeHint {}
319
+
320
+ // Hint for MerkleTreeDB.revertCheckpoint.
321
+ export class AvmRevertCheckpointHint {
322
+ // We use explicit fields for MessagePack.
323
+ constructor(
324
+ // key
325
+ public readonly actionCounter: number,
326
+ // current checkpoint evolution
327
+ public readonly oldCheckpointId: number,
328
+ public readonly newCheckpointId: number,
329
+ // state evolution
330
+ public readonly stateBefore: TreeSnapshots,
331
+ public readonly stateAfter: TreeSnapshots,
332
+ ) {}
333
+
334
+ static create(
335
+ actionCounter: number,
336
+ oldCheckpointId: number,
337
+ newCheckpointId: number,
338
+ stateBefore: Record<MerkleTreeId, AppendOnlyTreeSnapshot>,
339
+ stateAfter: Record<MerkleTreeId, AppendOnlyTreeSnapshot>,
340
+ ): AvmRevertCheckpointHint {
341
+ return new AvmRevertCheckpointHint(
342
+ actionCounter,
343
+ oldCheckpointId,
344
+ newCheckpointId,
345
+ new TreeSnapshots(
346
+ stateBefore[MerkleTreeId.L1_TO_L2_MESSAGE_TREE],
347
+ stateBefore[MerkleTreeId.NOTE_HASH_TREE],
348
+ stateBefore[MerkleTreeId.NULLIFIER_TREE],
349
+ stateBefore[MerkleTreeId.PUBLIC_DATA_TREE],
350
+ ),
351
+ new TreeSnapshots(
352
+ stateAfter[MerkleTreeId.L1_TO_L2_MESSAGE_TREE],
353
+ stateAfter[MerkleTreeId.NOTE_HASH_TREE],
354
+ stateAfter[MerkleTreeId.NULLIFIER_TREE],
355
+ stateAfter[MerkleTreeId.PUBLIC_DATA_TREE],
356
+ ),
357
+ );
358
+ }
359
+
360
+ static get schema() {
361
+ return z
362
+ .object({
363
+ actionCounter: z.number().int().nonnegative(),
364
+ oldCheckpointId: z.number().int().nonnegative(),
365
+ newCheckpointId: z.number().int().nonnegative(),
366
+ stateBefore: TreeSnapshots.schema,
367
+ stateAfter: TreeSnapshots.schema,
368
+ })
369
+ .transform(
370
+ ({ actionCounter, oldCheckpointId, newCheckpointId, stateBefore, stateAfter }) =>
371
+ new AvmRevertCheckpointHint(actionCounter, oldCheckpointId, newCheckpointId, stateBefore, stateAfter),
372
+ );
373
+ }
374
+ }
375
+
265
376
  ////////////////////////////////////////////////////////////////////////////
266
377
  // Hints (other)
267
378
  ////////////////////////////////////////////////////////////////////////////
@@ -290,6 +401,7 @@ export class AvmEnqueuedCallHint {
290
401
 
291
402
  export class AvmTxHint {
292
403
  constructor(
404
+ public readonly hash: string,
293
405
  public readonly nonRevertibleAccumulatedData: {
294
406
  noteHashes: Fr[];
295
407
  nullifiers: Fr[];
@@ -307,12 +419,16 @@ export class AvmTxHint {
307
419
  public readonly teardownEnqueuedCall: AvmEnqueuedCallHint | null,
308
420
  ) {}
309
421
 
310
- static fromTx(tx: Tx): AvmTxHint {
422
+ static async fromTx(tx: Tx): Promise<AvmTxHint> {
311
423
  const setupCallRequests = tx.getNonRevertiblePublicCallRequestsWithCalldata();
312
424
  const appLogicCallRequests = tx.getRevertiblePublicCallRequestsWithCalldata();
313
425
  const teardownCallRequest = tx.getTeardownPublicCallRequestWithCalldata();
314
426
 
427
+ // For informational purposes. Assumed quick because it should be cached.
428
+ const txHash = await tx.getTxHash();
429
+
315
430
  return new AvmTxHint(
431
+ txHash.hash.toString(),
316
432
  {
317
433
  noteHashes: tx.data.forPublic!.nonRevertibleAccumulatedData.noteHashes.filter(x => !x.isZero()),
318
434
  nullifiers: tx.data.forPublic!.nonRevertibleAccumulatedData.nullifiers.filter(x => !x.isZero()),
@@ -351,23 +467,43 @@ export class AvmTxHint {
351
467
  }
352
468
 
353
469
  static empty() {
354
- return new AvmTxHint({ noteHashes: [], nullifiers: [] }, { noteHashes: [], nullifiers: [] }, [], [], null);
470
+ return new AvmTxHint('', { noteHashes: [], nullifiers: [] }, { noteHashes: [], nullifiers: [] }, [], [], null);
355
471
  }
356
472
 
357
473
  static get schema() {
358
- return z.object({
359
- nonRevertibleAccumulatedData: z.object({
360
- noteHashes: schemas.Fr.array(),
361
- nullifiers: schemas.Fr.array(),
362
- }),
363
- revertibleAccumulatedData: z.object({
364
- noteHashes: schemas.Fr.array(),
365
- nullifiers: schemas.Fr.array(),
366
- }),
367
- setupEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
368
- appLogicEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
369
- teardownEnqueuedCall: AvmEnqueuedCallHint.schema.nullable(),
370
- });
474
+ return z
475
+ .object({
476
+ hash: z.string(),
477
+ nonRevertibleAccumulatedData: z.object({
478
+ noteHashes: schemas.Fr.array(),
479
+ nullifiers: schemas.Fr.array(),
480
+ }),
481
+ revertibleAccumulatedData: z.object({
482
+ noteHashes: schemas.Fr.array(),
483
+ nullifiers: schemas.Fr.array(),
484
+ }),
485
+ setupEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
486
+ appLogicEnqueuedCalls: AvmEnqueuedCallHint.schema.array(),
487
+ teardownEnqueuedCall: AvmEnqueuedCallHint.schema.nullable(),
488
+ })
489
+ .transform(
490
+ ({
491
+ hash,
492
+ nonRevertibleAccumulatedData,
493
+ revertibleAccumulatedData,
494
+ setupEnqueuedCalls,
495
+ appLogicEnqueuedCalls,
496
+ teardownEnqueuedCall,
497
+ }) =>
498
+ new AvmTxHint(
499
+ hash,
500
+ nonRevertibleAccumulatedData,
501
+ revertibleAccumulatedData,
502
+ setupEnqueuedCalls,
503
+ appLogicEnqueuedCalls,
504
+ teardownEnqueuedCall,
505
+ ),
506
+ );
371
507
  }
372
508
  }
373
509
 
@@ -386,6 +522,10 @@ export class AvmExecutionHints {
386
522
  public readonly getLeafValueHints: AvmGetLeafValueHint[] = [],
387
523
  public readonly sequentialInsertHintsPublicDataTree: AvmSequentialInsertHintPublicDataTree[] = [],
388
524
  public readonly sequentialInsertHintsNullifierTree: AvmSequentialInsertHintNullifierTree[] = [],
525
+ public readonly appendLeavesHints: AvmAppendLeavesHint[] = [],
526
+ public readonly createCheckpointHints: AvmCreateCheckpointHint[] = [],
527
+ public readonly commitCheckpointHints: AvmCommitCheckpointHint[] = [],
528
+ public readonly revertCheckpointHints: AvmRevertCheckpointHint[] = [],
389
529
  ) {}
390
530
 
391
531
  static empty() {
@@ -406,6 +546,10 @@ export class AvmExecutionHints {
406
546
  getLeafValueHints: AvmGetLeafValueHint.schema.array(),
407
547
  sequentialInsertHintsPublicDataTree: AvmSequentialInsertHintPublicDataTree.schema.array(),
408
548
  sequentialInsertHintsNullifierTree: AvmSequentialInsertHintNullifierTree.schema.array(),
549
+ appendLeavesHints: AvmAppendLeavesHint.schema.array(),
550
+ createCheckpointHints: AvmCreateCheckpointHint.schema.array(),
551
+ commitCheckpointHints: AvmCommitCheckpointHint.schema.array(),
552
+ revertCheckpointHints: AvmRevertCheckpointHint.schema.array(),
409
553
  })
410
554
  .transform(
411
555
  ({
@@ -420,6 +564,10 @@ export class AvmExecutionHints {
420
564
  getLeafValueHints,
421
565
  sequentialInsertHintsPublicDataTree,
422
566
  sequentialInsertHintsNullifierTree,
567
+ appendLeavesHints,
568
+ createCheckpointHints,
569
+ commitCheckpointHints,
570
+ revertCheckpointHints,
423
571
  }) =>
424
572
  new AvmExecutionHints(
425
573
  tx,
@@ -433,35 +581,29 @@ export class AvmExecutionHints {
433
581
  getLeafValueHints,
434
582
  sequentialInsertHintsPublicDataTree,
435
583
  sequentialInsertHintsNullifierTree,
584
+ appendLeavesHints,
585
+ createCheckpointHints,
586
+ commitCheckpointHints,
587
+ revertCheckpointHints,
436
588
  ),
437
589
  );
438
590
  }
439
591
  }
440
592
 
441
593
  export class AvmCircuitInputs {
442
- constructor(
443
- public readonly functionName: string, // only informational
444
- public readonly calldata: Fr[],
445
- public readonly hints: AvmExecutionHints,
446
- public publicInputs: AvmCircuitPublicInputs,
447
- ) {}
594
+ constructor(public readonly hints: AvmExecutionHints, public publicInputs: AvmCircuitPublicInputs) {}
448
595
 
449
596
  static empty() {
450
- return new AvmCircuitInputs('', [], AvmExecutionHints.empty(), AvmCircuitPublicInputs.empty());
597
+ return new AvmCircuitInputs(AvmExecutionHints.empty(), AvmCircuitPublicInputs.empty());
451
598
  }
452
599
 
453
600
  static get schema() {
454
601
  return z
455
602
  .object({
456
- functionName: z.string(),
457
- calldata: schemas.Fr.array(),
458
603
  hints: AvmExecutionHints.schema,
459
604
  publicInputs: AvmCircuitPublicInputs.schema,
460
605
  })
461
- .transform(
462
- ({ functionName, calldata, hints, publicInputs }) =>
463
- new AvmCircuitInputs(functionName, calldata, hints, publicInputs),
464
- );
606
+ .transform(({ hints, publicInputs }) => new AvmCircuitInputs(hints, publicInputs));
465
607
  }
466
608
 
467
609
  public serializeWithMessagePack(): Buffer {
@@ -8,6 +8,7 @@ export type L1RollupConstants = {
8
8
  slotDuration: number;
9
9
  epochDuration: number;
10
10
  ethereumSlotDuration: number;
11
+ proofSubmissionWindow: number;
11
12
  };
12
13
 
13
14
  export const EmptyL1RollupConstants: L1RollupConstants = {
@@ -16,6 +17,7 @@ export const EmptyL1RollupConstants: L1RollupConstants = {
16
17
  epochDuration: 1, // Not 0 to pervent division by zero
17
18
  slotDuration: 1,
18
19
  ethereumSlotDuration: 1,
20
+ proofSubmissionWindow: 2,
19
21
  };
20
22
 
21
23
  export const L1RollupConstantsSchema = z.object({
@@ -24,6 +26,7 @@ export const L1RollupConstantsSchema = z.object({
24
26
  slotDuration: z.number(),
25
27
  epochDuration: z.number(),
26
28
  ethereumSlotDuration: z.number(),
29
+ proofSubmissionWindow: z.number(),
27
30
  }) satisfies ZodFor<L1RollupConstants>;
28
31
 
29
32
  /** Returns the timestamp for a given L2 slot. */
@@ -75,3 +78,19 @@ export function getTimestampRangeForEpoch(
75
78
  BigInt((ethereumSlotsPerL2Slot - 1) * constants.ethereumSlotDuration),
76
79
  ];
77
80
  }
81
+
82
+ /**
83
+ * Returns the deadline timestamp (in seconds) for submitting a proof for a given epoch.
84
+ * Computed as the start of the given epoch plus the proof submission window.
85
+ */
86
+ export function getProofSubmissionDeadlineTimestamp(
87
+ epochNumber: bigint,
88
+ constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'epochDuration' | 'proofSubmissionWindow'>,
89
+ ) {
90
+ // See l1-contracts/src/core/libraries/rollup/EpochProofLib.sol:
91
+ // Slot deadline = startEpoch.toSlots() + Slot.wrap(rollupStore.config.proofSubmissionWindow);
92
+ const [startSlot] = getSlotRangeForEpoch(epochNumber, constants);
93
+ const deadlineSlot = startSlot + BigInt(constants.proofSubmissionWindow);
94
+ const deadlineTimestamp = getTimestampForSlot(deadlineSlot, constants);
95
+ return deadlineTimestamp;
96
+ }
@@ -1,12 +1,13 @@
1
1
  import { MAX_NOTE_HASHES_PER_TX, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
2
2
  import { Fr } from '@aztec/foundation/fields';
3
+ import { TxHash } from '@aztec/stdlib/tx';
3
4
 
4
5
  // TypeScript representation of the Noir aztec::oracle::message_discovery::LogWithTxData struct. This is used as a
5
6
  // response for PXE's custom getLogByTag oracle.
6
7
  export class LogWithTxData {
7
8
  constructor(
8
9
  public logContent: Fr[],
9
- public txHash: Fr,
10
+ public txHash: TxHash,
10
11
  public uniqueNoteHashesInTx: Fr[],
11
12
  public firstNullifierInTx: Fr,
12
13
  ) {}
@@ -14,14 +15,14 @@ export class LogWithTxData {
14
15
  toNoirSerialization(): (Fr | Fr[])[] {
15
16
  return [
16
17
  ...toBoundedVecSerialization(this.logContent, PUBLIC_LOG_DATA_SIZE_IN_FIELDS),
17
- this.txHash,
18
+ this.txHash.hash,
18
19
  ...toBoundedVecSerialization(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
19
20
  this.firstNullifierInTx,
20
21
  ];
21
22
  }
22
23
 
23
24
  static noirSerializationOfEmpty(): (Fr | Fr[])[] {
24
- return new LogWithTxData([], new Fr(0), [], new Fr(0)).toNoirSerialization();
25
+ return new LogWithTxData([], TxHash.zero(), [], new Fr(0)).toNoirSerialization();
25
26
  }
26
27
  }
27
28
 
@@ -2,6 +2,7 @@ import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/const
2
2
  import { Fr } from '@aztec/foundation/fields';
3
3
 
4
4
  import type { AztecAddress } from '../aztec-address/index.js';
5
+ import type { TxHash } from '../tx/tx_hash.js';
5
6
 
6
7
  /**
7
8
  * Represents a pending tagged log as it is stored in the pending tagged log array to which the syncNotes oracle
@@ -10,7 +11,7 @@ import type { AztecAddress } from '../aztec-address/index.js';
10
11
  export class PendingTaggedLog {
11
12
  constructor(
12
13
  public log: Fr[],
13
- public txHash: Fr,
14
+ public txHash: TxHash,
14
15
  public uniqueNoteHashesInTx: Fr[],
15
16
  public firstNullifierInTx: Fr,
16
17
  public recipient: AztecAddress,
@@ -20,7 +21,7 @@ export class PendingTaggedLog {
20
21
  toFields(): Fr[] {
21
22
  return [
22
23
  ...serializeBoundedVec(this.log, PRIVATE_LOG_SIZE_IN_FIELDS),
23
- this.txHash,
24
+ this.txHash.hash,
24
25
  ...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
25
26
  this.firstNullifierInTx,
26
27
  this.recipient.toField(),
@@ -1,5 +1,7 @@
1
1
  import type { Fr } from '@aztec/foundation/fields';
2
2
 
3
+ import type { L2Tips } from '../block/l2_block_source.js';
4
+
3
5
  /**
4
6
  * Interface of classes allowing for the retrieval of L1 to L2 messages.
5
7
  */
@@ -23,4 +25,9 @@ export interface L1ToL2MessageSource {
23
25
  * @returns The number of the latest L2 block processed by the implementation.
24
26
  */
25
27
  getBlockNumber(): Promise<number>;
28
+
29
+ /**
30
+ * Returns the tips of the L2 chain.
31
+ */
32
+ getL2Tips(): Promise<L2Tips>;
26
33
  }
@@ -55,11 +55,14 @@ import { ContractStorageRead } from '../avm/contract_storage_read.js';
55
55
  import { ContractStorageUpdateRequest } from '../avm/contract_storage_update_request.js';
56
56
  import {
57
57
  AvmAccumulatedData,
58
+ AvmAppendLeavesHint,
58
59
  AvmBytecodeCommitmentHint,
59
60
  AvmCircuitInputs,
60
61
  AvmCircuitPublicInputs,
62
+ AvmCommitCheckpointHint,
61
63
  AvmContractClassHint,
62
64
  AvmContractInstanceHint,
65
+ AvmCreateCheckpointHint,
63
66
  AvmEnqueuedCallHint,
64
67
  AvmExecutionHints,
65
68
  AvmGetLeafPreimageHintNullifierTree,
@@ -67,6 +70,7 @@ import {
67
70
  AvmGetLeafValueHint,
68
71
  AvmGetPreviousValueIndexHint,
69
72
  AvmGetSiblingPathHint,
73
+ AvmRevertCheckpointHint,
70
74
  AvmSequentialInsertHintNullifierTree,
71
75
  AvmSequentialInsertHintPublicDataTree,
72
76
  AvmTxHint,
@@ -1382,6 +1386,42 @@ export function makeAvmSequentialInsertHintNullifierTree(seed = 0): AvmSequentia
1382
1386
  );
1383
1387
  }
1384
1388
 
1389
+ export function makeAvmAppendLeavesHint(seed = 0): AvmAppendLeavesHint {
1390
+ return new AvmAppendLeavesHint(
1391
+ makeAppendOnlyTreeSnapshot(seed),
1392
+ makeAppendOnlyTreeSnapshot(seed + 1),
1393
+ // Use NOTE_HASH_TREE or L1_TO_L2_MESSAGE_TREE as mentioned in the comment on AvmAppendLeavesHint
1394
+ seed % 2 === 0 ? MerkleTreeId.NOTE_HASH_TREE : MerkleTreeId.L1_TO_L2_MESSAGE_TREE,
1395
+ makeArray((seed % 5) + 1, i => new Fr(seed + i + 2), 0),
1396
+ );
1397
+ }
1398
+
1399
+ export function makeAvmCheckpointActionCreateCheckpointHint(seed = 0): AvmCreateCheckpointHint {
1400
+ return new AvmCreateCheckpointHint(
1401
+ /*actionCounter=*/ seed,
1402
+ /*oldCheckpointId=*/ seed + 1,
1403
+ /*newCheckpointId=*/ seed + 2,
1404
+ );
1405
+ }
1406
+
1407
+ export function makeAvmCheckpointActionCommitCheckpointHint(seed = 0): AvmCommitCheckpointHint {
1408
+ return new AvmCommitCheckpointHint(
1409
+ /*actionCounter=*/ seed,
1410
+ /*oldCheckpointId=*/ seed + 1,
1411
+ /*newCheckpointId=*/ seed + 2,
1412
+ );
1413
+ }
1414
+
1415
+ export function makeAvmCheckpointActionRevertCheckpointHint(seed = 0): AvmRevertCheckpointHint {
1416
+ return new AvmRevertCheckpointHint(
1417
+ /*actionCounter=*/ seed,
1418
+ /*oldCheckpointId=*/ seed + 1,
1419
+ /*newCheckpointId=*/ seed + 2,
1420
+ /*beforeState=*/ makeTreeSnapshots(seed + 3),
1421
+ /*afterState=*/ makeTreeSnapshots(seed + 7),
1422
+ );
1423
+ }
1424
+
1385
1425
  /**
1386
1426
  * Makes arbitrary AvmContractInstanceHint.
1387
1427
  * @param seed - The seed to use for generating the state reference.
@@ -1430,6 +1470,7 @@ export function makeAvmEnqueuedCallHint(seed = 0): AvmEnqueuedCallHint {
1430
1470
 
1431
1471
  export function makeAvmTxHint(seed = 0): AvmTxHint {
1432
1472
  return new AvmTxHint(
1473
+ `txhash-${seed}`,
1433
1474
  {
1434
1475
  noteHashes: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x1000),
1435
1476
  nullifiers: makeArray((seed % 20) + 4, i => new Fr(i), seed + 0x2000),
@@ -1481,6 +1522,10 @@ export async function makeAvmExecutionHints(
1481
1522
  makeAvmSequentialInsertHintNullifierTree,
1482
1523
  seed + 0x5700,
1483
1524
  ),
1525
+ appendLeavesHints: makeArray(baseLength + 5, makeAvmAppendLeavesHint, seed + 0x5800),
1526
+ createCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionCreateCheckpointHint, seed + 0x5900),
1527
+ commitCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionCommitCheckpointHint, seed + 0x5b00),
1528
+ revertCheckpointHints: makeArray(baseLength + 5, makeAvmCheckpointActionRevertCheckpointHint, seed + 0x5d00),
1484
1529
  ...overrides,
1485
1530
  };
1486
1531
 
@@ -1496,6 +1541,10 @@ export async function makeAvmExecutionHints(
1496
1541
  fields.getLeafValueHints,
1497
1542
  fields.sequentialInsertHintsPublicDataTree,
1498
1543
  fields.sequentialInsertHintsNullifierTree,
1544
+ fields.appendLeavesHints,
1545
+ fields.createCheckpointHints,
1546
+ fields.commitCheckpointHints,
1547
+ fields.revertCheckpointHints,
1499
1548
  );
1500
1549
  }
1501
1550
 
@@ -1509,14 +1558,12 @@ export async function makeAvmCircuitInputs(
1509
1558
  overrides: Partial<FieldsOf<AvmCircuitInputs>> = {},
1510
1559
  ): Promise<AvmCircuitInputs> {
1511
1560
  const fields = {
1512
- functionName: `function${seed}`,
1513
- calldata: makeArray((seed % 100) + 10, i => new Fr(i), seed + 0x1000),
1514
- avmHints: await makeAvmExecutionHints(seed + 0x3000),
1561
+ hints: await makeAvmExecutionHints(seed + 0x3000),
1515
1562
  publicInputs: makeAvmCircuitPublicInputs(seed + 0x4000),
1516
1563
  ...overrides,
1517
1564
  };
1518
1565
 
1519
- return new AvmCircuitInputs(fields.functionName, fields.calldata, fields.avmHints, fields.publicInputs);
1566
+ return new AvmCircuitInputs(fields.hints, fields.publicInputs);
1520
1567
  }
1521
1568
 
1522
1569
  /**
package/src/tx/index.ts CHANGED
@@ -24,6 +24,7 @@ export * from './public_simulation_output.js';
24
24
  export * from './tx_execution_request.js';
25
25
  export * from './validator/tx_validator.js';
26
26
  export * from './validator/empty_validator.js';
27
+ export * from './validator/error_texts.js';
27
28
  export * from './capsule.js';
28
29
  export * from './global_variable_builder.js';
29
30
  export * from './hashed_values.js';
@@ -0,0 +1,33 @@
1
+ // Gas and fees
2
+ export const TX_ERROR_INSUFFICIENT_FEE_PER_GAS = 'Insufficient fee per gas';
3
+ export const TX_ERROR_INSUFFICIENT_FEE_PAYER_BALANCE = 'Insufficient fee payer balance';
4
+
5
+ // Phases
6
+ export const TX_ERROR_SETUP_FUNCTION_NOT_ALLOWED = 'Setup function not on allow list';
7
+
8
+ // Nullifiers
9
+ export const TX_ERROR_DUPLICATE_NULLIFIER_IN_TX = 'Duplicate nullifier in tx';
10
+ export const TX_ERROR_EXISTING_NULLIFIER = 'Existing nullifier';
11
+
12
+ // Metadata
13
+ export const TX_ERROR_INVALID_BLOCK_NUMBER = 'Invalid block number';
14
+ export const TX_ERROR_INCORRECT_CHAIN_ID = 'Incorrect chain id';
15
+ export const TX_ERROR_INCORRECT_ROLLUP_VERSION = 'Incorrect rollup version';
16
+
17
+ // Proof
18
+ export const TX_ERROR_INVALID_PROOF = 'Invalid proof';
19
+
20
+ //Data
21
+ export const TX_ERROR_INCORRECT_CALLDATA = 'Incorrect calldata for public call';
22
+ export const TX_ERROR_CALLDATA_COUNT_MISMATCH = 'Wrong number of calldata for public calls';
23
+ export const TX_ERROR_CALLDATA_COUNT_TOO_LARGE = 'Total calldata too large for enqueued public calls';
24
+ export const TX_ERROR_CONTRACT_CLASS_LOG_COUNT = 'Mismatched number of contract class logs';
25
+ export const TX_ERROR_CONTRACT_CLASS_LOG_LENGTH = 'Mismatched contract class logs length';
26
+ export const TX_ERROR_CONTRACT_CLASS_LOGS = 'Mismatched contract class logs';
27
+ export const TX_ERROR_CONTRACT_CLASS_LOG_SORTING = 'Incorrectly sorted contract class logs';
28
+
29
+ // Block header
30
+ export const TX_ERROR_BLOCK_HEADER = 'Block header not found';
31
+
32
+ // General
33
+ export const TX_ERROR_DURING_VALIDATION = 'Unexpected error during validation';