@aztec/stdlib 3.0.0-nightly.20251222 → 3.0.0-nightly.20251224

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 (87) hide show
  1. package/dest/checkpoint/checkpoint.d.ts +15 -1
  2. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  3. package/dest/checkpoint/checkpoint.js +26 -0
  4. package/dest/checkpoint/checkpoint_info.d.ts +9 -0
  5. package/dest/checkpoint/checkpoint_info.d.ts.map +1 -0
  6. package/dest/checkpoint/checkpoint_info.js +1 -0
  7. package/dest/contract/contract_class_id.js +1 -1
  8. package/dest/hash/hash.d.ts +1 -9
  9. package/dest/hash/hash.d.ts.map +1 -1
  10. package/dest/hash/hash.js +0 -12
  11. package/dest/interfaces/archiver.d.ts +1 -1
  12. package/dest/interfaces/archiver.d.ts.map +1 -1
  13. package/dest/interfaces/archiver.js +4 -1
  14. package/dest/interfaces/aztec-node-admin.d.ts +19 -7
  15. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  16. package/dest/interfaces/aztec-node.d.ts +10 -10
  17. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  18. package/dest/interfaces/aztec-node.js +3 -3
  19. package/dest/interfaces/block-builder.d.ts +3 -2
  20. package/dest/interfaces/block-builder.d.ts.map +1 -1
  21. package/dest/interfaces/block-builder.js +9 -1
  22. package/dest/interfaces/configs.d.ts +35 -13
  23. package/dest/interfaces/configs.d.ts.map +1 -1
  24. package/dest/interfaces/configs.js +7 -3
  25. package/dest/interfaces/l2_logs_source.d.ts +12 -8
  26. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  27. package/dest/interfaces/merkle_tree_operations.d.ts +2 -2
  28. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  29. package/dest/interfaces/proving-job.d.ts +166 -166
  30. package/dest/interfaces/world_state.d.ts +10 -3
  31. package/dest/interfaces/world_state.d.ts.map +1 -1
  32. package/dest/kernel/private_circuit_public_inputs.d.ts +47 -47
  33. package/dest/kernel/private_circuit_public_inputs.d.ts.map +1 -1
  34. package/dest/kernel/private_circuit_public_inputs.js +59 -59
  35. package/dest/logs/index.d.ts +3 -1
  36. package/dest/logs/index.d.ts.map +1 -1
  37. package/dest/logs/index.js +2 -0
  38. package/dest/logs/siloed_tag.d.ts +23 -0
  39. package/dest/logs/siloed_tag.d.ts.map +1 -0
  40. package/dest/logs/siloed_tag.js +30 -0
  41. package/dest/logs/tag.d.ts +21 -0
  42. package/dest/logs/tag.d.ts.map +1 -0
  43. package/dest/logs/tag.js +30 -0
  44. package/dest/logs/tx_scoped_l2_log.d.ts +8 -2
  45. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  46. package/dest/logs/tx_scoped_l2_log.js +13 -5
  47. package/dest/messaging/l1_to_l2_message.d.ts +1 -1
  48. package/dest/messaging/l1_to_l2_message.d.ts.map +1 -1
  49. package/dest/rollup/checkpoint_constant_data.d.ts +2 -1
  50. package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
  51. package/dest/rollup/checkpoint_constant_data.js +1 -0
  52. package/dest/rollup/checkpoint_header.d.ts +5 -1
  53. package/dest/rollup/checkpoint_header.d.ts.map +1 -1
  54. package/dest/rollup/checkpoint_header.js +4 -1
  55. package/dest/schemas/schemas.d.ts +3 -1
  56. package/dest/schemas/schemas.d.ts.map +1 -1
  57. package/dest/schemas/schemas.js +1 -0
  58. package/dest/stats/stats.d.ts +10 -6
  59. package/dest/stats/stats.d.ts.map +1 -1
  60. package/dest/tx/global_variable_builder.d.ts +4 -2
  61. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  62. package/dest/tx/global_variables.d.ts +6 -1
  63. package/dest/tx/global_variables.d.ts.map +1 -1
  64. package/package.json +8 -8
  65. package/src/checkpoint/checkpoint.ts +32 -0
  66. package/src/checkpoint/checkpoint_info.ts +9 -0
  67. package/src/contract/contract_class_id.ts +1 -1
  68. package/src/hash/hash.ts +0 -11
  69. package/src/interfaces/archiver.ts +8 -2
  70. package/src/interfaces/aztec-node.ts +17 -14
  71. package/src/interfaces/block-builder.ts +11 -1
  72. package/src/interfaces/configs.ts +36 -8
  73. package/src/interfaces/l2_logs_source.ts +12 -7
  74. package/src/interfaces/merkle_tree_operations.ts +4 -1
  75. package/src/interfaces/world_state.ts +7 -2
  76. package/src/kernel/private_circuit_public_inputs.ts +85 -85
  77. package/src/logs/index.ts +2 -0
  78. package/src/logs/siloed_tag.ts +44 -0
  79. package/src/logs/tag.ts +42 -0
  80. package/src/logs/tx_scoped_l2_log.ts +15 -5
  81. package/src/messaging/l1_to_l2_message.ts +1 -0
  82. package/src/rollup/checkpoint_constant_data.ts +1 -0
  83. package/src/rollup/checkpoint_header.ts +4 -0
  84. package/src/schemas/schemas.ts +3 -0
  85. package/src/stats/stats.ts +10 -5
  86. package/src/tx/global_variable_builder.ts +8 -1
  87. package/src/tx/global_variables.ts +6 -0
@@ -0,0 +1,42 @@
1
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
2
+ import type { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { ZodFor } from '@aztec/foundation/schemas';
4
+
5
+ import { schemas } from '../schemas/schemas.js';
6
+ import type { PreTag } from './pre_tag.js';
7
+
8
+ /* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
9
+
10
+ export interface Tag {
11
+ /** Brand. */
12
+ _branding: 'Tag';
13
+ }
14
+
15
+ /**
16
+ * Represents a tag of a private log. This is not the tag that "appears" on the chain as this tag is first siloed
17
+ * with a contract address by kernels before being included in the final log.
18
+ */
19
+ export class Tag {
20
+ constructor(public readonly value: Fr) {}
21
+
22
+ static async compute(preTag: PreTag): Promise<Tag> {
23
+ const tag = await poseidon2Hash([preTag.secret.value, preTag.index]);
24
+ return new Tag(tag);
25
+ }
26
+
27
+ toString(): string {
28
+ return this.value.toString();
29
+ }
30
+
31
+ toJSON(): string {
32
+ return this.value.toString();
33
+ }
34
+
35
+ equals(other: Tag): boolean {
36
+ return this.value.equals(other.value);
37
+ }
38
+
39
+ static get schema(): ZodFor<Tag> {
40
+ return schemas.Fr.transform((fr: Fr) => new Tag(fr));
41
+ }
42
+ }
@@ -1,10 +1,12 @@
1
1
  import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
2
- import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
2
+ import { BufferReader, bigintToUInt64BE, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
6
  import { L2BlockHash } from '../block/block_hash.js';
7
+ import { schemas } from '../schemas/schemas.js';
7
8
  import { TxHash } from '../tx/tx_hash.js';
9
+ import type { UInt64 } from '../types/shared.js';
8
10
  import { PrivateLog } from './private_log.js';
9
11
  import { PublicLog } from './public_log.js';
10
12
 
@@ -33,6 +35,10 @@ export class TxScopedL2Log {
33
35
  * The block this log is included in
34
36
  */
35
37
  public blockHash: L2BlockHash,
38
+ /*
39
+ * The timestamp of the block this log is included in
40
+ */
41
+ public blockTimestamp: UInt64,
36
42
  /*
37
43
  * The log data as either a PrivateLog or PublicLog
38
44
  */
@@ -51,11 +57,12 @@ export class TxScopedL2Log {
51
57
  logIndexInTx: z.number(),
52
58
  blockNumber: BlockNumberSchema,
53
59
  blockHash: L2BlockHash.schema,
60
+ blockTimestamp: schemas.UInt64,
54
61
  log: z.union([PrivateLog.schema, PublicLog.schema]),
55
62
  })
56
63
  .transform(
57
- ({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log }) =>
58
- new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log),
64
+ ({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log }) =>
65
+ new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log),
59
66
  );
60
67
  }
61
68
 
@@ -66,6 +73,7 @@ export class TxScopedL2Log {
66
73
  numToUInt32BE(this.logIndexInTx),
67
74
  numToUInt32BE(this.blockNumber),
68
75
  this.blockHash.toBuffer(),
76
+ bigintToUInt64BE(this.blockTimestamp),
69
77
  boolToBuffer(this.isFromPublic),
70
78
  this.log.toBuffer(),
71
79
  ]);
@@ -78,15 +86,16 @@ export class TxScopedL2Log {
78
86
  const logIndexInTx = reader.readNumber();
79
87
  const blockNumber = BlockNumber(reader.readNumber());
80
88
  const blockHash = reader.readObject(L2BlockHash);
89
+ const blockTimestamp = reader.readUInt64();
81
90
  const isFromPublic = reader.readBoolean();
82
91
  const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
83
92
 
84
- return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log);
93
+ return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, blockTimestamp, log);
85
94
  }
86
95
 
87
96
  static async random(isFromPublic = Math.random() < 0.5) {
88
97
  const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
89
- return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), log);
98
+ return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), 1n, log);
90
99
  }
91
100
 
92
101
  equals(other: TxScopedL2Log) {
@@ -96,6 +105,7 @@ export class TxScopedL2Log {
96
105
  this.logIndexInTx === other.logIndexInTx &&
97
106
  this.blockNumber === other.blockNumber &&
98
107
  this.blockHash.equals(other.blockHash) &&
108
+ this.blockTimestamp === other.blockTimestamp &&
99
109
  ((this.log instanceof PublicLog && other.log instanceof PublicLog) ||
100
110
  (this.log instanceof PrivateLog && other.log instanceof PrivateLog)) &&
101
111
  this.log.equals(other.log as any)
@@ -84,6 +84,7 @@ export async function getNonNullifiedL1ToL2MessageWitness(
84
84
  if (!response) {
85
85
  throw new Error(`No L1 to L2 message found for message hash ${messageHash.toString()}`);
86
86
  }
87
+
87
88
  const [messageIndex, siblingPath] = response;
88
89
 
89
90
  const messageNullifier = await computeL1ToL2MessageNullifier(contractAddress, messageHash, secret);
@@ -11,6 +11,7 @@ import { GasFees } from '../gas/gas_fees.js';
11
11
 
12
12
  /**
13
13
  * Constants that are the same for the entire checkpoint.
14
+ * Used in circuits during rollup proving.
14
15
  */
15
16
  export class CheckpointConstantData {
16
17
  constructor(
@@ -17,6 +17,10 @@ import { schemas } from '../schemas/index.js';
17
17
  import { ContentCommitment } from '../tx/content_commitment.js';
18
18
  import type { UInt64 } from '../types/shared.js';
19
19
 
20
+ /**
21
+ * Header of a checkpoint. A checkpoint is a collection of blocks submitted to L1 all within the same slot.
22
+ * TODO(palla/mbps): Should this include chainId and version as well? Is this used just in circuits?
23
+ */
20
24
  export class CheckpointHeader {
21
25
  constructor(
22
26
  /** Root of the archive tree before this block is added. */
@@ -40,6 +40,9 @@ export const schemas = {
40
40
  /** Coerces input to UInt32. */
41
41
  UInt32: foundationSchemas.UInt32,
42
42
 
43
+ /** Coerces input to UInt64. */
44
+ UInt64: foundationSchemas.UInt64,
45
+
43
46
  /** Accepts a hex string as a Buffer32 type. */
44
47
  Buffer32: foundationSchemas.Buffer32 as ZodFor<Buffer32>,
45
48
 
@@ -20,6 +20,13 @@ export type L2BlockStats = {
20
20
  publicLogCount?: number;
21
21
  };
22
22
 
23
+ export type CheckpointStats = {
24
+ /** Number of transactions in the checkpoint */
25
+ txCount: number;
26
+ /** Number of blocks in the checkpoint */
27
+ blockCount: number;
28
+ };
29
+
23
30
  /** Stats logged for each L1 publish tx.*/
24
31
  export type L1PublishStats = {
25
32
  /** Address of the sender. */
@@ -45,11 +52,11 @@ export type L1PublishStats = {
45
52
  };
46
53
 
47
54
  /** Stats logged for each L1 rollup publish tx.*/
48
- export type L1PublishBlockStats = {
55
+ export type L1PublishCheckpointStats = {
49
56
  /** Name of the event for metrics purposes */
50
57
  eventName: 'rollup-published-to-l1';
51
58
  } & L1PublishStats &
52
- L2BlockStats;
59
+ CheckpointStats;
53
60
 
54
61
  /** Stats logged for each L1 rollup publish tx.*/
55
62
  export type L1PublishProofStats = {
@@ -189,8 +196,6 @@ export type CircuitVerificationStats = {
189
196
 
190
197
  /** Stats for an L2 block built by a sequencer. */
191
198
  export type L2BlockBuiltStats = {
192
- /** The creator of the block */
193
- creator: string;
194
199
  /** Name of the event. */
195
200
  eventName: 'l2-block-built';
196
201
  /** Total duration in ms. */
@@ -272,7 +277,7 @@ export type Stats =
272
277
  | CircuitSimulationStats
273
278
  | CircuitWitnessGenerationStats
274
279
  | PublicDBAccessStats
275
- | L1PublishBlockStats
280
+ | L1PublishCheckpointStats
276
281
  | L1PublishProofStats
277
282
  | L2BlockBuiltStats
278
283
  | L2BlockHandledStats
@@ -4,7 +4,7 @@ import type { SlotNumber } from '@aztec/foundation/schemas';
4
4
  import type { AztecAddress } from '../aztec-address/index.js';
5
5
  import type { GasFees } from '../gas/gas_fees.js';
6
6
  import type { UInt32 } from '../types/index.js';
7
- import type { GlobalVariables } from './global_variables.js';
7
+ import type { CheckpointGlobalVariables, GlobalVariables } from './global_variables.js';
8
8
 
9
9
  /**
10
10
  * Interface for building global variables for Aztec blocks.
@@ -26,4 +26,11 @@ export interface GlobalVariableBuilder {
26
26
  feeRecipient: AztecAddress,
27
27
  slotNumber?: SlotNumber,
28
28
  ): Promise<GlobalVariables>;
29
+
30
+ /** Builds global variables that are constant throughout a checkpoint. */
31
+ buildCheckpointGlobalVariables(
32
+ coinbase: EthAddress,
33
+ feeRecipient: AztecAddress,
34
+ slotNumber: SlotNumber,
35
+ ): Promise<CheckpointGlobalVariables>;
29
36
  }
@@ -21,6 +21,12 @@ import { GasFees } from '../gas/gas_fees.js';
21
21
  import { schemas } from '../schemas/index.js';
22
22
  import type { UInt64 } from '../types/index.js';
23
23
 
24
+ /**
25
+ * Global variables that are constant across the entire slot.
26
+ * TODO(palla/mbps): Should timestamp be included here as well?
27
+ */
28
+ export type CheckpointGlobalVariables = Omit<FieldsOf<GlobalVariables>, 'blockNumber' | 'timestamp'>;
29
+
24
30
  /**
25
31
  * Global variables of the L2 block.
26
32
  */