@aztec/stdlib 3.0.0-nightly.20251203 → 3.0.0-nightly.20251205

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 (131) hide show
  1. package/dest/avm/avm.d.ts +17 -9
  2. package/dest/avm/avm.d.ts.map +1 -1
  3. package/dest/avm/avm_circuit_public_inputs.d.ts +5 -3
  4. package/dest/avm/avm_circuit_public_inputs.d.ts.map +1 -1
  5. package/dest/avm/avm_proving_request.d.ts +9 -5
  6. package/dest/avm/avm_proving_request.d.ts.map +1 -1
  7. package/dest/block/block_parameter.d.ts +5 -0
  8. package/dest/block/block_parameter.d.ts.map +1 -0
  9. package/dest/block/block_parameter.js +6 -0
  10. package/dest/block/in_block.d.ts +6 -5
  11. package/dest/block/in_block.d.ts.map +1 -1
  12. package/dest/block/in_block.js +3 -3
  13. package/dest/block/index.d.ts +1 -1
  14. package/dest/block/index.js +1 -1
  15. package/dest/block/l2_block.d.ts +5 -5
  16. package/dest/block/l2_block.d.ts.map +1 -1
  17. package/dest/block/l2_block.js +1 -1
  18. package/dest/block/l2_block_code_to_purge.js +3 -3
  19. package/dest/block/l2_block_header.d.ts +3 -3
  20. package/dest/block/l2_block_header.d.ts.map +1 -1
  21. package/dest/block/l2_block_info.d.ts +15 -10
  22. package/dest/block/l2_block_info.d.ts.map +1 -1
  23. package/dest/block/l2_block_info.js +7 -6
  24. package/dest/block/l2_block_new.d.ts +5 -4
  25. package/dest/block/l2_block_new.d.ts.map +1 -1
  26. package/dest/block/l2_block_new.js +1 -1
  27. package/dest/block/l2_block_source.d.ts +47 -97
  28. package/dest/block/l2_block_source.d.ts.map +1 -1
  29. package/dest/block/l2_block_source.js +5 -11
  30. package/dest/block/l2_block_stream/l2_block_stream.d.ts +1 -1
  31. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  32. package/dest/block/l2_block_stream/l2_block_stream.js +4 -3
  33. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts +3 -2
  34. package/dest/block/l2_block_stream/l2_tips_memory_store.d.ts.map +1 -1
  35. package/dest/block/l2_block_stream/l2_tips_memory_store.js +4 -2
  36. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  37. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  38. package/dest/block/test/l2_tips_store_test_suite.js +6 -4
  39. package/dest/checkpoint/checkpoint.d.ts +1 -1
  40. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  41. package/dest/checkpoint/checkpoint.js +2 -2
  42. package/dest/contract/interfaces/contract_data_source.d.ts +3 -2
  43. package/dest/contract/interfaces/contract_data_source.d.ts.map +1 -1
  44. package/dest/interfaces/archiver.js +9 -9
  45. package/dest/interfaces/aztec-node.d.ts +23 -23
  46. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  47. package/dest/interfaces/aztec-node.js +24 -23
  48. package/dest/interfaces/block-builder.d.ts +3 -2
  49. package/dest/interfaces/block-builder.d.ts.map +1 -1
  50. package/dest/interfaces/epoch-prover.d.ts +4 -4
  51. package/dest/interfaces/epoch-prover.d.ts.map +1 -1
  52. package/dest/interfaces/get_logs_response.d.ts +5 -3
  53. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  54. package/dest/interfaces/l2_logs_source.d.ts +4 -3
  55. package/dest/interfaces/l2_logs_source.d.ts.map +1 -1
  56. package/dest/interfaces/merkle_tree_operations.d.ts +3 -2
  57. package/dest/interfaces/merkle_tree_operations.d.ts.map +1 -1
  58. package/dest/interfaces/proving-job.d.ts +9 -5
  59. package/dest/interfaces/proving-job.d.ts.map +1 -1
  60. package/dest/interfaces/world_state.d.ts +9 -26
  61. package/dest/interfaces/world_state.d.ts.map +1 -1
  62. package/dest/interfaces/world_state.js +4 -3
  63. package/dest/logs/extended_public_log.d.ts +5 -3
  64. package/dest/logs/extended_public_log.d.ts.map +1 -1
  65. package/dest/logs/log_id.d.ts +8 -5
  66. package/dest/logs/log_id.d.ts.map +1 -1
  67. package/dest/logs/log_id.js +5 -4
  68. package/dest/logs/tx_scoped_l2_log.d.ts +10 -7
  69. package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
  70. package/dest/logs/tx_scoped_l2_log.js +4 -3
  71. package/dest/messaging/l1_to_l2_message_source.d.ts +4 -4
  72. package/dest/messaging/l1_to_l2_message_source.d.ts.map +1 -1
  73. package/dest/messaging/l2_to_l1_membership.d.ts +4 -3
  74. package/dest/messaging/l2_to_l1_membership.d.ts.map +1 -1
  75. package/dest/note/note_dao.d.ts +4 -3
  76. package/dest/note/note_dao.d.ts.map +1 -1
  77. package/dest/note/note_dao.js +3 -2
  78. package/dest/tests/factories.js +5 -5
  79. package/dest/tests/mocks.d.ts +1 -1
  80. package/dest/tests/mocks.d.ts.map +1 -1
  81. package/dest/tests/mocks.js +2 -1
  82. package/dest/tx/block_header.d.ts +4 -4
  83. package/dest/tx/block_header.d.ts.map +1 -1
  84. package/dest/tx/global_variables.d.ts +13 -11
  85. package/dest/tx/global_variables.d.ts.map +1 -1
  86. package/dest/tx/global_variables.js +6 -6
  87. package/dest/tx/indexed_tx_effect.d.ts +6 -3
  88. package/dest/tx/indexed_tx_effect.d.ts.map +1 -1
  89. package/dest/tx/indexed_tx_effect.js +2 -1
  90. package/dest/tx/private_execution_result.d.ts +3 -3
  91. package/dest/tx/private_execution_result.d.ts.map +1 -1
  92. package/dest/tx/tx_receipt.d.ts +4 -3
  93. package/dest/tx/tx_receipt.d.ts.map +1 -1
  94. package/dest/tx/tx_receipt.js +2 -1
  95. package/package.json +9 -9
  96. package/src/block/block_parameter.ts +8 -0
  97. package/src/block/in_block.ts +5 -4
  98. package/src/block/index.ts +1 -1
  99. package/src/block/l2_block.ts +4 -4
  100. package/src/block/l2_block_code_to_purge.ts +3 -3
  101. package/src/block/l2_block_info.ts +10 -9
  102. package/src/block/l2_block_new.ts +4 -3
  103. package/src/block/l2_block_source.ts +15 -22
  104. package/src/block/l2_block_stream/l2_block_stream.ts +10 -5
  105. package/src/block/l2_block_stream/l2_tips_memory_store.ts +5 -2
  106. package/src/block/test/l2_tips_store_test_suite.ts +8 -3
  107. package/src/checkpoint/checkpoint.ts +2 -2
  108. package/src/contract/interfaces/contract_data_source.ts +2 -1
  109. package/src/interfaces/archiver.ts +9 -9
  110. package/src/interfaces/aztec-node.ts +51 -44
  111. package/src/interfaces/block-builder.ts +2 -1
  112. package/src/interfaces/epoch-prover.ts +3 -3
  113. package/src/interfaces/l2_logs_source.ts +3 -2
  114. package/src/interfaces/merkle_tree_operations.ts +2 -1
  115. package/src/interfaces/world_state.ts +12 -11
  116. package/src/logs/log_id.ts +6 -5
  117. package/src/logs/tx_scoped_l2_log.ts +5 -4
  118. package/src/messaging/l1_to_l2_message_source.ts +3 -3
  119. package/src/messaging/l2_to_l1_membership.ts +3 -2
  120. package/src/note/note_dao.ts +4 -3
  121. package/src/tests/factories.ts +4 -4
  122. package/src/tests/mocks.ts +2 -1
  123. package/src/tx/block_header.ts +2 -2
  124. package/src/tx/global_variables.ts +8 -8
  125. package/src/tx/indexed_tx_effect.ts +2 -1
  126. package/src/tx/private_execution_result.ts +2 -2
  127. package/src/tx/tx_receipt.ts +3 -2
  128. package/dest/block/l2_block_number.d.ts +0 -5
  129. package/dest/block/l2_block_number.d.ts.map +0 -1
  130. package/dest/block/l2_block_number.js +0 -6
  131. package/src/block/l2_block_number.ts +0 -8
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import type { Fr } from '@aztec/foundation/fields';
2
3
 
3
4
  import type { LogFilter } from '../logs/log_filter.js';
@@ -15,7 +16,7 @@ export interface L2LogsSource {
15
16
  * @param limit - The maximum number of blocks to retrieve logs from.
16
17
  * @returns An array of private logs from the specified range of blocks.
17
18
  */
18
- getPrivateLogs(from: number, limit: number): Promise<PrivateLog[]>;
19
+ getPrivateLogs(from: BlockNumber, limit: number): Promise<PrivateLog[]>;
19
20
 
20
21
  /**
21
22
  * Gets all logs that match any of the received tags (i.e. logs with their first field equal to a tag).
@@ -44,5 +45,5 @@ export interface L2LogsSource {
44
45
  * Gets the number of the latest L2 block processed by the implementation.
45
46
  * @returns The number of the latest L2 block processed by the implementation.
46
47
  */
47
- getBlockNumber(): Promise<number>;
48
+ getBlockNumber(): Promise<BlockNumber>;
48
49
  }
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import type { Fr } from '@aztec/foundation/fields';
2
3
  import { createLogger } from '@aztec/foundation/log';
3
4
  import { type IndexedTreeLeafPreimage, SiblingPath } from '@aztec/foundation/trees';
@@ -220,7 +221,7 @@ export interface MerkleTreeReadOperations {
220
221
  getBlockNumbersForLeafIndices<ID extends MerkleTreeId>(
221
222
  treeId: ID,
222
223
  leafIndices: bigint[],
223
- ): Promise<(bigint | undefined)[]>;
224
+ ): Promise<(BlockNumber | undefined)[]>;
224
225
  }
225
226
 
226
227
  export interface MerkleTreeCheckpointOperations {
@@ -1,3 +1,4 @@
1
+ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
1
2
  import type { PromiseWithResolvers } from '@aztec/foundation/promise';
2
3
 
3
4
  import { z } from 'zod';
@@ -18,10 +19,10 @@ export enum WorldStateRunningState {
18
19
  }
19
20
 
20
21
  export interface WorldStateSyncStatus {
21
- latestBlockNumber: number;
22
+ latestBlockNumber: BlockNumber;
22
23
  latestBlockHash: string;
23
- finalizedBlockNumber: number;
24
- oldestHistoricBlockNumber: number;
24
+ finalizedBlockNumber: BlockNumber;
25
+ oldestHistoricBlockNumber: BlockNumber;
25
26
  treesAreSynched: boolean;
26
27
  }
27
28
 
@@ -42,10 +43,10 @@ export interface WorldStateSynchronizerStatus {
42
43
  /** Provides writeable forks of the world state at a given block number. */
43
44
  export interface ForkMerkleTreeOperations {
44
45
  /** Forks the world state at the given block number, defaulting to the latest one. */
45
- fork(block?: number): Promise<MerkleTreeWriteOperations>;
46
+ fork(block?: BlockNumber): Promise<MerkleTreeWriteOperations>;
46
47
 
47
48
  /** Gets a handle that allows reading the state as it was at the given block number. */
48
- getSnapshot(blockNumber: number): MerkleTreeReadOperations;
49
+ getSnapshot(blockNumber: BlockNumber): MerkleTreeReadOperations;
49
50
 
50
51
  /** Backups the db to the target path. */
51
52
  backupTo(dstPath: string, compact?: boolean): Promise<Record<Exclude<SnapshotDataKeys, 'archiver'>, string>>;
@@ -74,7 +75,7 @@ export interface WorldStateSynchronizer extends ForkMerkleTreeOperations {
74
75
  * @param skipThrowIfTargetNotReached - Whether to skip throwing if the target block number is not reached.
75
76
  * @returns A promise that resolves with the block number the world state was synced to
76
77
  */
77
- syncImmediate(minBlockNumber?: number, skipThrowIfTargetNotReached?: boolean): Promise<number>;
78
+ syncImmediate(minBlockNumber?: BlockNumber, skipThrowIfTargetNotReached?: boolean): Promise<BlockNumber>;
78
79
 
79
80
  /** Returns an instance of MerkleTreeAdminOperations that will not include uncommitted data. */
80
81
  getCommitted(): MerkleTreeReadOperations;
@@ -83,10 +84,10 @@ export interface WorldStateSynchronizer extends ForkMerkleTreeOperations {
83
84
  clear(): Promise<void>;
84
85
  }
85
86
 
86
- export const WorldStateSyncStatusSchema = z.object({
87
- finalizedBlockNumber: z.number().int().nonnegative(),
88
- latestBlockNumber: z.number().int().nonnegative(),
87
+ export const WorldStateSyncStatusSchema: z.ZodType<WorldStateSyncStatus, z.ZodTypeDef, any> = z.object({
88
+ finalizedBlockNumber: BlockNumberSchema,
89
+ latestBlockNumber: BlockNumberSchema,
89
90
  latestBlockHash: z.string(),
90
- oldestHistoricBlockNumber: z.number().int().nonnegative(),
91
+ oldestHistoricBlockNumber: BlockNumberSchema,
91
92
  treesAreSynched: z.boolean(),
92
- }) satisfies z.ZodType<WorldStateSyncStatus>;
93
+ });
@@ -1,5 +1,6 @@
1
1
  import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
2
2
  import { toBufferBE } from '@aztec/foundation/bigint-buffer';
3
+ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
3
4
  import { BufferReader } from '@aztec/foundation/serialize';
4
5
 
5
6
  import { z } from 'zod';
@@ -16,7 +17,7 @@ export class LogId {
16
17
  */
17
18
  constructor(
18
19
  /** The block number the log was emitted in. */
19
- public readonly blockNumber: number,
20
+ public readonly blockNumber: BlockNumber,
20
21
  /** The index of a tx in a block the log was emitted in. */
21
22
  public readonly txIndex: number,
22
23
  /** The index of a log the tx was emitted in. */
@@ -35,7 +36,7 @@ export class LogId {
35
36
 
36
37
  static random() {
37
38
  return new LogId(
38
- Math.floor(Math.random() * 1000) + 1,
39
+ BlockNumber(Math.floor(Math.random() * 1000) + 1),
39
40
  Math.floor(Math.random() * 1000),
40
41
  Math.floor(Math.random() * 100),
41
42
  );
@@ -44,7 +45,7 @@ export class LogId {
44
45
  static get schema() {
45
46
  return z
46
47
  .object({
47
- blockNumber: schemas.Integer,
48
+ blockNumber: BlockNumberSchema,
48
49
  txIndex: schemas.Integer,
49
50
  logIndex: schemas.Integer,
50
51
  })
@@ -71,7 +72,7 @@ export class LogId {
71
72
  static fromBuffer(buffer: Buffer | BufferReader): LogId {
72
73
  const reader = BufferReader.asReader(buffer);
73
74
 
74
- const blockNumber = reader.readNumber();
75
+ const blockNumber = BlockNumber(reader.readNumber());
75
76
  const txIndex = reader.readNumber();
76
77
  const logIndex = reader.readNumber();
77
78
 
@@ -93,7 +94,7 @@ export class LogId {
93
94
  */
94
95
  static fromString(data: string): LogId {
95
96
  const [rawBlockNumber, rawTxIndex, rawLogIndex] = data.split('-');
96
- const blockNumber = Number(rawBlockNumber);
97
+ const blockNumber = BlockNumber(Number(rawBlockNumber));
97
98
  const txIndex = Number(rawTxIndex);
98
99
  const logIndex = Number(rawLogIndex);
99
100
 
@@ -1,3 +1,4 @@
1
+ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
1
2
  import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/serialize';
2
3
 
3
4
  import { z } from 'zod';
@@ -26,7 +27,7 @@ export class TxScopedL2Log {
26
27
  /*
27
28
  * The block this log is included in
28
29
  */
29
- public blockNumber: number,
30
+ public blockNumber: BlockNumber,
30
31
  /*
31
32
  * The log data as either a PrivateLog or PublicLog
32
33
  */
@@ -43,7 +44,7 @@ export class TxScopedL2Log {
43
44
  txHash: TxHash.schema,
44
45
  dataStartIndexForTx: z.number(),
45
46
  logIndexInTx: z.number(),
46
- blockNumber: z.number(),
47
+ blockNumber: BlockNumberSchema,
47
48
  log: z.union([PrivateLog.schema, PublicLog.schema]),
48
49
  })
49
50
  .transform(
@@ -69,7 +70,7 @@ export class TxScopedL2Log {
69
70
  const txHash = reader.readObject(TxHash);
70
71
  const dataStartIndexForTx = reader.readNumber();
71
72
  const logIndexInTx = reader.readNumber();
72
- const blockNumber = reader.readNumber();
73
+ const blockNumber = BlockNumber(reader.readNumber());
73
74
  const isFromPublic = reader.readBoolean();
74
75
  const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
75
76
 
@@ -78,7 +79,7 @@ export class TxScopedL2Log {
78
79
 
79
80
  static async random(isFromPublic = Math.random() < 0.5) {
80
81
  const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
81
- return new TxScopedL2Log(TxHash.random(), 1, 1, 1, log);
82
+ return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), log);
82
83
  }
83
84
 
84
85
  equals(other: TxScopedL2Log) {
@@ -1,4 +1,4 @@
1
- import type { CheckpointNumber } from '@aztec/foundation/branded-types';
1
+ import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
2
  import type { Fr } from '@aztec/foundation/fields';
3
3
 
4
4
  import type { L2Tips } from '../block/l2_block_source.js';
@@ -19,7 +19,7 @@ export interface L1ToL2MessageSource {
19
19
  * @param blockNumber - L2 block number to get messages for.
20
20
  * @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
21
21
  */
22
- getL1ToL2Messages(blockNumber: number): Promise<Fr[]>;
22
+ getL1ToL2Messages(blockNumber: BlockNumber): Promise<Fr[]>;
23
23
 
24
24
  /**
25
25
  * Gets the L1 to L2 message index in the L1 to L2 message tree.
@@ -32,7 +32,7 @@ export interface L1ToL2MessageSource {
32
32
  * Gets the number of the latest L2 block processed by the implementation.
33
33
  * @returns The number of the latest L2 block processed by the implementation.
34
34
  */
35
- getBlockNumber(): Promise<number>;
35
+ getBlockNumber(): Promise<BlockNumber>;
36
36
 
37
37
  /**
38
38
  * Returns the tips of the L2 chain.
@@ -1,8 +1,9 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
3
  import { SiblingPath, UnbalancedMerkleTreeCalculator, computeUnbalancedShaRoot } from '@aztec/foundation/trees';
3
4
 
4
5
  export interface MessageRetrieval {
5
- getL2ToL1Messages(l2BlockNumber: number): Promise<Fr[][] | undefined>;
6
+ getL2ToL1Messages(l2BlockNumber: BlockNumber): Promise<Fr[][] | undefined>;
6
7
  }
7
8
 
8
9
  export type L2ToL1MembershipWitness = {
@@ -13,7 +14,7 @@ export type L2ToL1MembershipWitness = {
13
14
 
14
15
  export async function computeL2ToL1MembershipWitness(
15
16
  messageRetriever: MessageRetrieval,
16
- l2BlockNumber: number,
17
+ l2BlockNumber: BlockNumber,
17
18
  message: Fr,
18
19
  ): Promise<L2ToL1MembershipWitness | undefined> {
19
20
  const messagesForAllTxs = await messageRetriever.getL2ToL1Messages(l2BlockNumber);
@@ -1,4 +1,5 @@
1
1
  import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
2
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
3
  import { Fr, Point } from '@aztec/foundation/fields';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
4
5
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -50,7 +51,7 @@ export class NoteDao {
50
51
  public txHash: TxHash,
51
52
  /** The L2 block number in which the tx with this note was included. Used for note management while processing
52
53
  * reorgs.*/
53
- public l2BlockNumber: number,
54
+ public l2BlockNumber: BlockNumber,
54
55
  /** The L2 block hash in which the tx with this note was included. Used for note management while processing
55
56
  * reorgs.*/
56
57
  public l2BlockHash: string,
@@ -87,7 +88,7 @@ export class NoteDao {
87
88
  const noteHash = Fr.fromBuffer(reader);
88
89
  const siloedNullifier = Fr.fromBuffer(reader);
89
90
  const txHash = reader.readObject(TxHash);
90
- const l2BlockNumber = reader.readNumber();
91
+ const l2BlockNumber = BlockNumber(reader.readNumber());
91
92
  const l2BlockHash = Fr.fromBuffer(reader).toString();
92
93
  const index = toBigIntBE(reader.readBytes(32));
93
94
 
@@ -138,7 +139,7 @@ export class NoteDao {
138
139
  noteHash = Fr.random(),
139
140
  siloedNullifier = Fr.random(),
140
141
  txHash = TxHash.random(),
141
- l2BlockNumber = Math.floor(Math.random() * 1000),
142
+ l2BlockNumber = BlockNumber(Math.floor(Math.random() * 1000)),
142
143
  l2BlockHash = Fr.random().toString(),
143
144
  index = Fr.random().toBigInt(),
144
145
  }: Partial<NoteDao> = {}) {
@@ -43,7 +43,7 @@ import {
43
43
  VK_TREE_HEIGHT,
44
44
  } from '@aztec/constants';
45
45
  import { type FieldsOf, makeTuple } from '@aztec/foundation/array';
46
- import { SlotNumber } from '@aztec/foundation/branded-types';
46
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
47
47
  import { compact } from '@aztec/foundation/collection';
48
48
  import { Grumpkin, SchnorrSignature, poseidon2HashWithSeparator, sha256 } from '@aztec/foundation/crypto';
49
49
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -694,7 +694,7 @@ export function makeGlobalVariables(seed = 1, overrides: Partial<FieldsOf<Global
694
694
  return GlobalVariables.from({
695
695
  chainId: new Fr(seed),
696
696
  version: new Fr(seed + 1),
697
- blockNumber: seed + 2,
697
+ blockNumber: BlockNumber(seed + 2),
698
698
  slotNumber: SlotNumber(seed + 3),
699
699
  timestamp: BigInt(seed + 4),
700
700
  coinbase: EthAddress.fromField(new Fr(seed + 5)),
@@ -916,8 +916,8 @@ export function makeL2BlockHeader(
916
916
  overrides?.contentCommitment ?? makeContentCommitment(seed + 0x200),
917
917
  overrides?.state ?? makeStateReference(seed + 0x600),
918
918
  makeGlobalVariables((seed += 0x700), {
919
- ...(blockNumber ? { blockNumber } : {}),
920
- ...(slotNumber ? { slotNumber: SlotNumber(slotNumber) } : {}),
919
+ ...(blockNumber !== undefined ? { blockNumber: BlockNumber(blockNumber) } : {}),
920
+ ...(slotNumber !== undefined ? { slotNumber: SlotNumber(slotNumber) } : {}),
921
921
  }),
922
922
  new Fr(seed + 0x800),
923
923
  new Fr(seed + 0x900),
@@ -7,6 +7,7 @@ import {
7
7
  MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
8
8
  } from '@aztec/constants';
9
9
  import { makeTuple } from '@aztec/foundation/array';
10
+ import { BlockNumber } from '@aztec/foundation/branded-types';
10
11
  import { Buffer32 } from '@aztec/foundation/buffer';
11
12
  import { padArrayEnd, times } from '@aztec/foundation/collection';
12
13
  import { Secp256k1Signer, randomBytes } from '@aztec/foundation/crypto';
@@ -513,7 +514,7 @@ export async function randomPublishedL2Block(
513
514
  l2BlockNumber: number,
514
515
  opts: { signers?: Secp256k1Signer[] } = {},
515
516
  ): Promise<PublishedL2Block> {
516
- const block = await L2Block.random(l2BlockNumber);
517
+ const block = await L2Block.random(BlockNumber(l2BlockNumber));
517
518
  const l1 = L1PublishedData.fromFields({
518
519
  blockNumber: BigInt(block.number),
519
520
  timestamp: block.header.globalVariables.timestamp,
@@ -1,5 +1,5 @@
1
1
  import { BLOCK_HEADER_LENGTH, GeneratorIndex } from '@aztec/constants';
2
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { poseidon2HashWithSeparator, randomInt } from '@aztec/foundation/crypto';
4
4
  import { Fr } from '@aztec/foundation/fields';
5
5
  import { type ZodFor, schemas } from '@aztec/foundation/schemas';
@@ -66,7 +66,7 @@ export class BlockHeader {
66
66
  return this.globalVariables.slotNumber;
67
67
  }
68
68
 
69
- getBlockNumber() {
69
+ getBlockNumber(): BlockNumber {
70
70
  return this.globalVariables.blockNumber;
71
71
  }
72
72
 
@@ -1,5 +1,5 @@
1
1
  import { GLOBAL_VARIABLES_LENGTH } from '@aztec/constants';
2
- import { SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { BlockNumber, BlockNumberSchema, SlotNumber } from '@aztec/foundation/branded-types';
3
3
  import { randomInt } from '@aztec/foundation/crypto';
4
4
  import { EthAddress } from '@aztec/foundation/eth-address';
5
5
  import { Fr } from '@aztec/foundation/fields';
@@ -19,7 +19,7 @@ import { z } from 'zod';
19
19
  import { AztecAddress } from '../aztec-address/index.js';
20
20
  import { GasFees } from '../gas/gas_fees.js';
21
21
  import { schemas } from '../schemas/index.js';
22
- import type { UInt32, UInt64 } from '../types/index.js';
22
+ import type { UInt64 } from '../types/index.js';
23
23
 
24
24
  /**
25
25
  * Global variables of the L2 block.
@@ -31,7 +31,7 @@ export class GlobalVariables {
31
31
  /** Version for the L2 block. */
32
32
  public version: Fr,
33
33
  /** Block number of the L2 block. */
34
- public blockNumber: UInt32,
34
+ public blockNumber: BlockNumber,
35
35
  /** Slot number of the L2 block */
36
36
  public slotNumber: SlotNumber,
37
37
  /** Timestamp of the L2 block. */
@@ -49,7 +49,7 @@ export class GlobalVariables {
49
49
  .object({
50
50
  chainId: schemas.Fr,
51
51
  version: schemas.Fr,
52
- blockNumber: schemas.UInt32,
52
+ blockNumber: BlockNumberSchema,
53
53
  slotNumber: schemas.SlotNumber,
54
54
  timestamp: schemas.BigInt,
55
55
  coinbase: schemas.EthAddress,
@@ -89,7 +89,7 @@ export class GlobalVariables {
89
89
 
90
90
  static empty(fields: Partial<FieldsOf<GlobalVariables>> = {}): GlobalVariables {
91
91
  return GlobalVariables.from({
92
- blockNumber: 0,
92
+ blockNumber: BlockNumber.ZERO,
93
93
  slotNumber: SlotNumber.ZERO,
94
94
  timestamp: 0n,
95
95
  chainId: Fr.ZERO,
@@ -106,7 +106,7 @@ export class GlobalVariables {
106
106
  return new GlobalVariables(
107
107
  Fr.fromBuffer(reader),
108
108
  Fr.fromBuffer(reader),
109
- reader.readNumber(),
109
+ BlockNumber(reader.readNumber()),
110
110
  SlotNumber(reader.readNumber()),
111
111
  reader.readUInt64(),
112
112
  reader.readObject(EthAddress),
@@ -121,7 +121,7 @@ export class GlobalVariables {
121
121
  return new GlobalVariables(
122
122
  reader.readField(),
123
123
  reader.readField(),
124
- reader.readU32(),
124
+ BlockNumber(reader.readU32()),
125
125
  SlotNumber(reader.readU32()),
126
126
  reader.readField().toBigInt(),
127
127
  EthAddress.fromField(reader.readField()),
@@ -219,7 +219,7 @@ export class GlobalVariables {
219
219
  return GlobalVariables.from({
220
220
  chainId: new Fr(randomInt(100_000)),
221
221
  version: new Fr(randomInt(100_000)),
222
- blockNumber: randomInt(100_000),
222
+ blockNumber: BlockNumber(randomInt(100_000)),
223
223
  slotNumber: SlotNumber(randomInt(100_000)),
224
224
  coinbase: EthAddress.random(),
225
225
  feeRecipient: AztecAddress.fromField(Fr.random()),
@@ -1,3 +1,4 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { schemas } from '@aztec/foundation/schemas';
2
3
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
3
4
 
@@ -26,7 +27,7 @@ export function deserializeIndexedTxEffect(buffer: Buffer): IndexedTxEffect {
26
27
  const reader = BufferReader.asReader(buffer);
27
28
 
28
29
  const l2BlockHash = reader.readObject(L2BlockHash);
29
- const l2BlockNumber = reader.readNumber();
30
+ const l2BlockNumber = BlockNumber(reader.readNumber());
30
31
  const txIndexInBlock = reader.readNumber();
31
32
  const data = reader.readObject(TxEffect);
32
33
 
@@ -1,3 +1,4 @@
1
+ import type { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { timesParallel } from '@aztec/foundation/collection';
2
3
  import { randomBytes, randomInt } from '@aztec/foundation/crypto';
3
4
  import { Fr } from '@aztec/foundation/fields';
@@ -13,7 +14,6 @@ import { ContractClassLog, ContractClassLogFields } from '../logs/contract_class
13
14
  import { type PreTag, PreTagSchema } from '../logs/pre_tag.js';
14
15
  import { Note } from '../note/note.js';
15
16
  import { type ZodFor, mapSchema, schemas } from '../schemas/index.js';
16
- import type { UInt32 } from '../types/index.js';
17
17
  import { HashedValues } from './hashed_values.js';
18
18
  import type { OffchainEffect } from './offchain_effect.js';
19
19
 
@@ -109,7 +109,7 @@ export class PrivateExecutionResult {
109
109
  /**
110
110
  * The anchor block number that this execution was simulated with.
111
111
  */
112
- getSimulationAnchorBlockNumber(): UInt32 {
112
+ getSimulationAnchorBlockNumber(): BlockNumber {
113
113
  return this.entrypoint.publicInputs.anchorBlockHeader.globalVariables.blockNumber;
114
114
  }
115
115
  }
@@ -1,3 +1,4 @@
1
+ import { BlockNumber, BlockNumberSchema } from '@aztec/foundation/branded-types';
1
2
  import type { FieldsOf } from '@aztec/foundation/types';
2
3
 
3
4
  import { z } from 'zod';
@@ -38,7 +39,7 @@ export class TxReceipt {
38
39
  /** The hash of the block containing the transaction. */
39
40
  public blockHash?: L2BlockHash,
40
41
  /** The block number in which the transaction was included. */
41
- public blockNumber?: number,
42
+ public blockNumber?: BlockNumber,
42
43
  ) {}
43
44
 
44
45
  static empty() {
@@ -52,7 +53,7 @@ export class TxReceipt {
52
53
  status: z.nativeEnum(TxStatus),
53
54
  error: z.string(),
54
55
  blockHash: L2BlockHash.schema.optional(),
55
- blockNumber: z.number().int().nonnegative().optional(),
56
+ blockNumber: BlockNumberSchema.optional(),
56
57
  transactionFee: schemas.BigInt.optional(),
57
58
  })
58
59
  .transform(TxReceipt.from);
@@ -1,5 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const L2BlockNumberSchema: z.ZodUnion<[z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>, z.ZodLiteral<"latest">]>;
3
- /** Helper type for a specific L2 block number or the latest block number */
4
- export type L2BlockNumber = z.infer<typeof L2BlockNumberSchema>;
5
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibDJfYmxvY2tfbnVtYmVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2svbDJfYmxvY2tfbnVtYmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxDQUFDLEVBQUUsTUFBTSxLQUFLLENBQUM7QUFJeEIsZUFBTyxNQUFNLG1CQUFtQix1SEFBa0QsQ0FBQztBQUVuRiw0RUFBNEU7QUFDNUUsTUFBTSxNQUFNLGFBQWEsR0FBRyxDQUFDLENBQUMsS0FBSyxDQUFDLE9BQU8sbUJBQW1CLENBQUMsQ0FBQyJ9
@@ -1 +0,0 @@
1
- {"version":3,"file":"l2_block_number.d.ts","sourceRoot":"","sources":["../../src/block/l2_block_number.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB,uHAAkD,CAAC;AAEnF,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC"}
@@ -1,6 +0,0 @@
1
- import { z } from 'zod';
2
- import { schemas } from '../schemas/index.js';
3
- export const L2BlockNumberSchema = z.union([
4
- schemas.Integer,
5
- z.literal('latest')
6
- ]);
@@ -1,8 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- import { schemas } from '../schemas/index.js';
4
-
5
- export const L2BlockNumberSchema = z.union([schemas.Integer, z.literal('latest')]);
6
-
7
- /** Helper type for a specific L2 block number or the latest block number */
8
- export type L2BlockNumber = z.infer<typeof L2BlockNumberSchema>;