@aztec/stdlib 3.0.0-nightly.20251128 → 3.0.0-nightly.20251201.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) 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/l2_block.d.ts +3 -2
  8. package/dest/block/l2_block.d.ts.map +1 -1
  9. package/dest/block/l2_block_code_to_purge.d.ts +1 -1
  10. package/dest/block/l2_block_code_to_purge.d.ts.map +1 -1
  11. package/dest/block/l2_block_code_to_purge.js +3 -2
  12. package/dest/block/l2_block_header.d.ts +4 -3
  13. package/dest/block/l2_block_header.d.ts.map +1 -1
  14. package/dest/block/l2_block_header.js +1 -1
  15. package/dest/block/l2_block_source.d.ts +4 -4
  16. package/dest/block/l2_block_source.d.ts.map +1 -1
  17. package/dest/epoch-helpers/index.d.ts +7 -7
  18. package/dest/epoch-helpers/index.d.ts.map +1 -1
  19. package/dest/epoch-helpers/index.js +9 -9
  20. package/dest/interfaces/archiver.js +1 -1
  21. package/dest/interfaces/aztec-node.d.ts +8 -2
  22. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  23. package/dest/interfaces/aztec-node.js +2 -1
  24. package/dest/interfaces/p2p.d.ts +3 -2
  25. package/dest/interfaces/p2p.d.ts.map +1 -1
  26. package/dest/interfaces/p2p.js +1 -1
  27. package/dest/interfaces/proving-job.d.ts +9 -5
  28. package/dest/interfaces/proving-job.d.ts.map +1 -1
  29. package/dest/interfaces/validator.d.ts +3 -3
  30. package/dest/interfaces/validator.d.ts.map +1 -1
  31. package/dest/kernel/private_call_data.d.ts +62 -5
  32. package/dest/kernel/private_call_data.d.ts.map +1 -1
  33. package/dest/kernel/private_call_data.js +105 -4
  34. package/dest/p2p/block_attestation.d.ts +4 -9
  35. package/dest/p2p/block_attestation.d.ts.map +1 -1
  36. package/dest/p2p/block_proposal.d.ts +3 -2
  37. package/dest/p2p/block_proposal.d.ts.map +1 -1
  38. package/dest/p2p/block_proposal.js +1 -1
  39. package/dest/p2p/consensus_payload.d.ts +4 -182
  40. package/dest/p2p/consensus_payload.d.ts.map +1 -1
  41. package/dest/p2p/consensus_payload.js +14 -25
  42. package/dest/rollup/checkpoint_constant_data.d.ts +11 -5
  43. package/dest/rollup/checkpoint_constant_data.d.ts.map +1 -1
  44. package/dest/rollup/checkpoint_constant_data.js +11 -4
  45. package/dest/rollup/checkpoint_header.d.ts +11 -5
  46. package/dest/rollup/checkpoint_header.d.ts.map +1 -1
  47. package/dest/rollup/checkpoint_header.js +18 -11
  48. package/dest/schemas/schemas.d.ts +6 -1
  49. package/dest/schemas/schemas.d.ts.map +1 -1
  50. package/dest/schemas/schemas.js +2 -0
  51. package/dest/slashing/empire.js +2 -2
  52. package/dest/slashing/helpers.d.ts +5 -5
  53. package/dest/slashing/helpers.d.ts.map +1 -1
  54. package/dest/slashing/helpers.js +7 -6
  55. package/dest/slashing/interfaces.d.ts +3 -2
  56. package/dest/slashing/interfaces.d.ts.map +1 -1
  57. package/dest/tests/factories.d.ts +1 -1
  58. package/dest/tests/factories.d.ts.map +1 -1
  59. package/dest/tests/factories.js +5 -4
  60. package/dest/tests/mocks.d.ts +2 -3
  61. package/dest/tests/mocks.d.ts.map +1 -1
  62. package/dest/tests/mocks.js +6 -12
  63. package/dest/trees/append_only_tree_snapshot.d.ts +1 -4
  64. package/dest/trees/append_only_tree_snapshot.d.ts.map +1 -1
  65. package/dest/trees/append_only_tree_snapshot.js +0 -9
  66. package/dest/tx/block_header.d.ts +4 -3
  67. package/dest/tx/block_header.d.ts.map +1 -1
  68. package/dest/tx/block_header.js +1 -1
  69. package/dest/tx/global_variable_builder.d.ts +3 -2
  70. package/dest/tx/global_variable_builder.d.ts.map +1 -1
  71. package/dest/tx/global_variables.d.ts +26 -8
  72. package/dest/tx/global_variables.d.ts.map +1 -1
  73. package/dest/tx/global_variables.js +27 -10
  74. package/dest/tx/partial_state_reference.d.ts +1 -4
  75. package/dest/tx/partial_state_reference.d.ts.map +1 -1
  76. package/dest/tx/partial_state_reference.js +0 -10
  77. package/dest/tx/state_reference.d.ts +1 -4
  78. package/dest/tx/state_reference.d.ts.map +1 -1
  79. package/dest/tx/state_reference.js +0 -9
  80. package/dest/tx/tx.d.ts +2 -2
  81. package/dest/tx/tx.d.ts.map +1 -1
  82. package/dest/tx/tx.js +1 -0
  83. package/dest/validators/errors.d.ts +6 -7
  84. package/dest/validators/errors.d.ts.map +1 -1
  85. package/dest/validators/errors.js +2 -4
  86. package/dest/validators/schemas.d.ts +102 -48
  87. package/dest/validators/schemas.d.ts.map +1 -1
  88. package/dest/validators/schemas.js +6 -6
  89. package/dest/validators/types.d.ts +9 -9
  90. package/dest/validators/types.d.ts.map +1 -1
  91. package/package.json +8 -8
  92. package/src/block/l2_block.ts +2 -1
  93. package/src/block/l2_block_code_to_purge.ts +3 -2
  94. package/src/block/l2_block_header.ts +3 -2
  95. package/src/block/l2_block_source.ts +3 -3
  96. package/src/epoch-helpers/index.ts +19 -14
  97. package/src/interfaces/archiver.ts +1 -1
  98. package/src/interfaces/aztec-node.ts +12 -3
  99. package/src/interfaces/p2p.ts +4 -2
  100. package/src/interfaces/validator.ts +1 -2
  101. package/src/kernel/private_call_data.ts +130 -3
  102. package/src/p2p/block_attestation.ts +2 -1
  103. package/src/p2p/block_proposal.ts +3 -2
  104. package/src/p2p/consensus_payload.ts +12 -28
  105. package/src/rollup/checkpoint_constant_data.ts +24 -5
  106. package/src/rollup/checkpoint_header.ts +21 -12
  107. package/src/schemas/schemas.ts +7 -0
  108. package/src/slashing/empire.ts +2 -2
  109. package/src/slashing/helpers.ts +12 -9
  110. package/src/slashing/interfaces.ts +3 -1
  111. package/src/tests/factories.ts +5 -4
  112. package/src/tests/mocks.ts +2 -16
  113. package/src/trees/append_only_tree_snapshot.ts +0 -12
  114. package/src/tx/block_header.ts +3 -2
  115. package/src/tx/global_variable_builder.ts +2 -1
  116. package/src/tx/global_variables.ts +30 -11
  117. package/src/tx/partial_state_reference.ts +0 -17
  118. package/src/tx/state_reference.ts +0 -15
  119. package/src/tx/tx.ts +2 -1
  120. package/src/validators/errors.ts +3 -4
  121. package/src/validators/schemas.ts +6 -6
  122. package/src/validators/types.ts +8 -8
@@ -1,4 +1,4 @@
1
- import { EpochNumber } from '@aztec/foundation/branded-types';
1
+ import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
@@ -33,15 +33,20 @@ export const L1RollupConstantsSchema = z.object({
33
33
 
34
34
  /** Returns the timestamp for a given L2 slot. */
35
35
  export function getTimestampForSlot(
36
- slot: bigint,
36
+ slot: SlotNumber,
37
37
  constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>,
38
38
  ) {
39
- return constants.l1GenesisTime + slot * BigInt(constants.slotDuration);
39
+ return constants.l1GenesisTime + BigInt(slot) * BigInt(constants.slotDuration);
40
40
  }
41
41
 
42
42
  /** Returns the slot number for a given timestamp. */
43
- export function getSlotAtTimestamp(ts: bigint, constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>) {
44
- return ts < constants.l1GenesisTime ? 0n : (ts - constants.l1GenesisTime) / BigInt(constants.slotDuration);
43
+ export function getSlotAtTimestamp(
44
+ ts: bigint,
45
+ constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>,
46
+ ): SlotNumber {
47
+ return ts < constants.l1GenesisTime
48
+ ? SlotNumber.ZERO
49
+ : SlotNumber.fromBigInt((ts - constants.l1GenesisTime) / BigInt(constants.slotDuration));
45
50
  }
46
51
 
47
52
  /** Returns the epoch number for a given timestamp. */
@@ -53,17 +58,17 @@ export function getEpochNumberAtTimestamp(
53
58
  }
54
59
 
55
60
  /** Returns the epoch number for a given slot. */
56
- export function getEpochAtSlot(slot: bigint, constants: Pick<L1RollupConstants, 'epochDuration'>): EpochNumber {
57
- return EpochNumber.fromBigInt(slot / BigInt(constants.epochDuration));
61
+ export function getEpochAtSlot(slot: SlotNumber, constants: Pick<L1RollupConstants, 'epochDuration'>): EpochNumber {
62
+ return EpochNumber.fromBigInt(BigInt(slot) / BigInt(constants.epochDuration));
58
63
  }
59
64
 
60
65
  /** Returns the range of L2 slots (inclusive) for a given epoch number. */
61
66
  export function getSlotRangeForEpoch(
62
67
  epochNumber: EpochNumber,
63
68
  constants: Pick<L1RollupConstants, 'epochDuration'>,
64
- ): [bigint, bigint] {
65
- const startSlot = BigInt(epochNumber) * BigInt(constants.epochDuration);
66
- return [startSlot, startSlot + BigInt(constants.epochDuration) - 1n];
69
+ ): [SlotNumber, SlotNumber] {
70
+ const startSlot = SlotNumber(epochNumber * constants.epochDuration);
71
+ return [startSlot, SlotNumber(startSlot + constants.epochDuration - 1)];
67
72
  }
68
73
 
69
74
  /**
@@ -77,9 +82,9 @@ export function getTimestampRangeForEpoch(
77
82
  const [startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, constants);
78
83
  const ethereumSlotsPerL2Slot = constants.slotDuration / constants.ethereumSlotDuration;
79
84
  return [
80
- constants.l1GenesisTime + startSlot * BigInt(constants.slotDuration),
85
+ constants.l1GenesisTime + BigInt(startSlot) * BigInt(constants.slotDuration),
81
86
  constants.l1GenesisTime +
82
- endSlot * BigInt(constants.slotDuration) +
87
+ BigInt(endSlot) * BigInt(constants.slotDuration) +
83
88
  BigInt((ethereumSlotsPerL2Slot - 1) * constants.ethereumSlotDuration),
84
89
  ];
85
90
  }
@@ -123,8 +128,8 @@ export function getProofSubmissionDeadlineTimestamp(
123
128
 
124
129
  /** Returns the timestamp to start building a block for a given L2 slot. Computed as the start timestamp of the slot minus one L1 slot duration. */
125
130
  export function getSlotStartBuildTimestamp(
126
- slotNumber: number | bigint,
131
+ slotNumber: SlotNumber,
127
132
  constants: Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration' | 'ethereumSlotDuration'>,
128
133
  ): number {
129
- return Number(constants.l1GenesisTime) + Number(slotNumber) * constants.slotDuration - constants.ethereumSlotDuration;
134
+ return Number(constants.l1GenesisTime) + slotNumber * constants.slotDuration - constants.ethereumSlotDuration;
130
135
  }
@@ -94,7 +94,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
94
94
  getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
95
95
  getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
96
96
  getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
97
- getL2SlotNumber: z.function().args().returns(schemas.BigInt.optional()),
97
+ getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
98
98
  getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
99
99
  getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2Block.schema)),
100
100
  getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
@@ -7,6 +7,7 @@ import {
7
7
  PUBLIC_DATA_TREE_HEIGHT,
8
8
  } from '@aztec/constants';
9
9
  import { type L1ContractAddresses, L1ContractAddressesSchema } from '@aztec/ethereum/l1-contract-addresses';
10
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
10
11
  import type { EthAddress } from '@aztec/foundation/eth-address';
11
12
  import type { Fr } from '@aztec/foundation/fields';
12
13
  import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
@@ -278,6 +279,12 @@ export interface AztecNode
278
279
  */
279
280
  getCurrentBaseFees(): Promise<GasFees>;
280
281
 
282
+ /**
283
+ * Method to fetch the current max priority fee of txs in the mempool.
284
+ * @returns The current max priority fees.
285
+ */
286
+ getMaxPriorityFees(): Promise<GasFees>;
287
+
281
288
  /**
282
289
  * Method to fetch the version of the package.
283
290
  * @returns The node package version
@@ -434,8 +441,8 @@ export interface AztecNode
434
441
  /** Returns stats for a single validator if enabled. */
435
442
  getValidatorStats(
436
443
  validatorAddress: EthAddress,
437
- fromSlot?: bigint,
438
- toSlot?: bigint,
444
+ fromSlot?: SlotNumber,
445
+ toSlot?: SlotNumber,
439
446
  ): Promise<SingleValidatorStats | undefined>;
440
447
 
441
448
  /**
@@ -575,6 +582,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
575
582
 
576
583
  getCurrentBaseFees: z.function().returns(GasFees.schema),
577
584
 
585
+ getMaxPriorityFees: z.function().returns(GasFees.schema),
586
+
578
587
  getNodeVersion: z.function().returns(z.string()),
579
588
 
580
589
  getVersion: z.function().returns(z.number()),
@@ -636,7 +645,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
636
645
 
637
646
  getValidatorStats: z
638
647
  .function()
639
- .args(schemas.EthAddress, optional(schemas.BigInt), optional(schemas.BigInt))
648
+ .args(schemas.EthAddress, optional(schemas.SlotNumber), optional(schemas.SlotNumber))
640
649
  .returns(SingleValidatorStatsSchema.optional()),
641
650
 
642
651
  simulatePublicCalls: z.function().args(Tx.schema, optional(z.boolean())).returns(PublicSimulationOutput.schema),
@@ -1,3 +1,5 @@
1
+ import type { SlotNumber } from '@aztec/foundation/branded-types';
2
+
1
3
  import { z } from 'zod';
2
4
 
3
5
  import { BlockAttestation } from '../p2p/block_attestation.js';
@@ -56,7 +58,7 @@ export interface P2PApiWithAttestations extends P2PApiWithoutAttestations {
56
58
  * @param proposalId - the proposal id to query, or undefined to query all proposals for the slot
57
59
  * @returns BlockAttestations
58
60
  */
59
- getAttestationsForSlot(slot: bigint, proposalId?: string): Promise<BlockAttestation[]>;
61
+ getAttestationsForSlot(slot: SlotNumber, proposalId?: string): Promise<BlockAttestation[]>;
60
62
 
61
63
  /** Deletes a given attestation manually from the p2p client attestation pool. */
62
64
  deleteAttestation(attestation: BlockAttestation): Promise<void>;
@@ -78,7 +80,7 @@ export type P2PApiFull<T extends P2PClientType = P2PClientType.Full> = T extends
78
80
  export const P2PApiSchema: ApiSchemaFor<P2PApi> = {
79
81
  getAttestationsForSlot: z
80
82
  .function()
81
- .args(schemas.BigInt, optional(z.string()))
83
+ .args(schemas.SlotNumber, optional(z.string()))
82
84
  .returns(z.array(BlockAttestation.schema)),
83
85
  getPendingTxs: z
84
86
  .function()
@@ -5,7 +5,7 @@ import { Fr } from '@aztec/foundation/fields';
5
5
  import { type ZodFor, schemas } from '@aztec/foundation/schemas';
6
6
  import type { SequencerConfig, SlasherConfig } from '@aztec/stdlib/interfaces/server';
7
7
  import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
8
- import type { StateReference, Tx } from '@aztec/stdlib/tx';
8
+ import type { Tx } from '@aztec/stdlib/tx';
9
9
 
10
10
  import type { PeerId } from '@libp2p/interface';
11
11
  import { z } from 'zod';
@@ -83,7 +83,6 @@ export interface Validator {
83
83
  blockNumber: number,
84
84
  header: CheckpointHeader,
85
85
  archive: Fr,
86
- stateReference: StateReference,
87
86
  txs: Tx[],
88
87
  proposerAddress: EthAddress | undefined,
89
88
  options: BlockProposalOptions,
@@ -1,12 +1,27 @@
1
- import { FUNCTION_TREE_HEIGHT, PUBLIC_DATA_TREE_HEIGHT, UPDATES_VALUE_SIZE } from '@aztec/constants';
1
+ import {
2
+ FUNCTION_TREE_HEIGHT,
3
+ MAX_CONTRACT_CLASS_LOGS_PER_CALL,
4
+ MAX_ENQUEUED_CALLS_PER_CALL,
5
+ MAX_L2_TO_L1_MSGS_PER_CALL,
6
+ MAX_NOTE_HASHES_PER_CALL,
7
+ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
8
+ MAX_NULLIFIERS_PER_CALL,
9
+ MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
10
+ MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL,
11
+ MAX_PRIVATE_LOGS_PER_CALL,
12
+ PUBLIC_DATA_TREE_HEIGHT,
13
+ TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL,
14
+ UPDATES_VALUE_SIZE,
15
+ } from '@aztec/constants';
2
16
  import { Fr } from '@aztec/foundation/fields';
3
- import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
17
+ import { BufferReader, type Tuple, serializeToBuffer } from '@aztec/foundation/serialize';
4
18
  import { MembershipWitness } from '@aztec/foundation/trees';
5
19
  import type { FieldsOf } from '@aztec/foundation/types';
6
20
 
7
21
  import { DelayedPublicMutableValues } from '../delayed_public_mutable/delayed_public_mutable_values.js';
8
22
  import { PublicKeys } from '../keys/public_keys.js';
9
23
  import { PublicDataTreeLeafPreimage } from '../trees/index.js';
24
+ import type { UInt32 } from '../types/shared.js';
10
25
  import { VerificationKeyAsFields } from '../vks/verification_key.js';
11
26
  import { PrivateCircuitPublicInputs } from './private_circuit_public_inputs.js';
12
27
 
@@ -29,6 +44,11 @@ export class PrivateCallData {
29
44
  * Hints for the validation of the vk
30
45
  */
31
46
  public verificationKeyHints: PrivateVerificationKeyHints,
47
+
48
+ /**
49
+ * Hints for validating the uniqueness of the side effects.
50
+ */
51
+ public sideEffectUniquenessHints: SideEffectUniquenessHints,
32
52
  ) {}
33
53
 
34
54
  /**
@@ -37,7 +57,7 @@ export class PrivateCallData {
37
57
  * @returns The array.
38
58
  */
39
59
  static getFields(fields: FieldsOf<PrivateCallData>) {
40
- return [fields.publicInputs, fields.vk, fields.verificationKeyHints] as const;
60
+ return [fields.publicInputs, fields.vk, fields.verificationKeyHints, fields.sideEffectUniquenessHints] as const;
41
61
  }
42
62
 
43
63
  static from(fields: FieldsOf<PrivateCallData>): PrivateCallData {
@@ -63,6 +83,7 @@ export class PrivateCallData {
63
83
  reader.readObject(PrivateCircuitPublicInputs),
64
84
  reader.readObject(VerificationKeyAsFields),
65
85
  reader.readObject(PrivateVerificationKeyHints),
86
+ reader.readObject(SideEffectUniquenessHints),
66
87
  );
67
88
  }
68
89
  }
@@ -180,3 +201,109 @@ export class UpdatedClassIdHints {
180
201
  );
181
202
  }
182
203
  }
204
+
205
+ export class SideEffectUniquenessHints {
206
+ constructor(
207
+ public sideEffectRanges: Tuple<SideEffectCounterRange, typeof TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL>,
208
+ public noteHashReadRequestIndices: Tuple<UInt32, typeof MAX_NOTE_HASH_READ_REQUESTS_PER_CALL>,
209
+ public nullifierReadRequestIndices: Tuple<UInt32, typeof MAX_NULLIFIER_READ_REQUESTS_PER_CALL>,
210
+ public noteHashesIndices: Tuple<UInt32, typeof MAX_NOTE_HASHES_PER_CALL>,
211
+ public nullifiersIndices: Tuple<UInt32, typeof MAX_NULLIFIERS_PER_CALL>,
212
+ public privateCallRequestsIndices: Tuple<UInt32, typeof MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL>,
213
+ public publicCallRequestsIndices: Tuple<UInt32, typeof MAX_ENQUEUED_CALLS_PER_CALL>,
214
+ public l2ToL1MsgsIndices: Tuple<UInt32, typeof MAX_L2_TO_L1_MSGS_PER_CALL>,
215
+ public privateLogsIndices: Tuple<UInt32, typeof MAX_PRIVATE_LOGS_PER_CALL>,
216
+ public contractClassLogsHashesIndices: Tuple<UInt32, typeof MAX_CONTRACT_CLASS_LOGS_PER_CALL>,
217
+ ) {}
218
+
219
+ /**
220
+ * Serialize into a field array. Low-level utility.
221
+ * @param fields - Object with fields.
222
+ * @returns The array.
223
+ */
224
+ static getFields(fields: FieldsOf<SideEffectUniquenessHints>) {
225
+ return [
226
+ fields.sideEffectRanges,
227
+ fields.noteHashReadRequestIndices,
228
+ fields.nullifierReadRequestIndices,
229
+ fields.noteHashesIndices,
230
+ fields.nullifiersIndices,
231
+ fields.privateCallRequestsIndices,
232
+ fields.publicCallRequestsIndices,
233
+ fields.l2ToL1MsgsIndices,
234
+ fields.privateLogsIndices,
235
+ fields.contractClassLogsHashesIndices,
236
+ ] as const;
237
+ }
238
+
239
+ static from(fields: FieldsOf<SideEffectUniquenessHints>): SideEffectUniquenessHints {
240
+ return new SideEffectUniquenessHints(...SideEffectUniquenessHints.getFields(fields));
241
+ }
242
+
243
+ /**
244
+ * Serialize this as a buffer.
245
+ * @returns The buffer.
246
+ */
247
+ toBuffer(): Buffer {
248
+ return serializeToBuffer(...SideEffectUniquenessHints.getFields(this));
249
+ }
250
+
251
+ /**
252
+ * Deserializes from a buffer or reader.
253
+ * @param buffer - Buffer or reader to read from.
254
+ * @returns The deserialized instance.
255
+ */
256
+ static fromBuffer(buffer: Buffer | BufferReader): SideEffectUniquenessHints {
257
+ const reader = BufferReader.asReader(buffer);
258
+ return new SideEffectUniquenessHints(
259
+ reader.readArray(TOTAL_COUNTED_SIDE_EFFECTS_PER_CALL, SideEffectCounterRange),
260
+ reader.readNumbers(MAX_NOTE_HASH_READ_REQUESTS_PER_CALL),
261
+ reader.readNumbers(MAX_NULLIFIER_READ_REQUESTS_PER_CALL),
262
+ reader.readNumbers(MAX_NOTE_HASHES_PER_CALL),
263
+ reader.readNumbers(MAX_NULLIFIERS_PER_CALL),
264
+ reader.readNumbers(MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL),
265
+ reader.readNumbers(MAX_ENQUEUED_CALLS_PER_CALL),
266
+ reader.readNumbers(MAX_L2_TO_L1_MSGS_PER_CALL),
267
+ reader.readNumbers(MAX_PRIVATE_LOGS_PER_CALL),
268
+ reader.readNumbers(MAX_CONTRACT_CLASS_LOGS_PER_CALL),
269
+ );
270
+ }
271
+ }
272
+
273
+ export class SideEffectCounterRange {
274
+ constructor(
275
+ public start: UInt32,
276
+ public end: UInt32,
277
+ public sideEffectGlobalIndex: UInt32,
278
+ ) {}
279
+
280
+ static getFields(fields: FieldsOf<SideEffectCounterRange>) {
281
+ return [fields.start, fields.end, fields.sideEffectGlobalIndex] as const;
282
+ }
283
+
284
+ static from(fields: FieldsOf<SideEffectCounterRange>): SideEffectCounterRange {
285
+ return new SideEffectCounterRange(...SideEffectCounterRange.getFields(fields));
286
+ }
287
+
288
+ static empty(): SideEffectCounterRange {
289
+ return new SideEffectCounterRange(0, 0, 0);
290
+ }
291
+
292
+ /**
293
+ * Serialize this as a buffer.
294
+ * @returns The buffer.
295
+ */
296
+ toBuffer(): Buffer {
297
+ return serializeToBuffer(...SideEffectCounterRange.getFields(this));
298
+ }
299
+
300
+ /**
301
+ * Deserializes from a buffer or reader.
302
+ * @param buffer - Buffer or reader to read from.
303
+ * @returns The deserialized instance.
304
+ */
305
+ static fromBuffer(buffer: Buffer | BufferReader): SideEffectCounterRange {
306
+ const reader = BufferReader.asReader(buffer);
307
+ return new SideEffectCounterRange(reader.readNumber(), reader.readNumber(), reader.readNumber());
308
+ }
309
+ }
@@ -1,3 +1,4 @@
1
+ import { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import { Buffer32 } from '@aztec/foundation/buffer';
2
3
  import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
3
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
@@ -62,7 +63,7 @@ export class BlockAttestation extends Gossipable {
62
63
  return this.payload.archive;
63
64
  }
64
65
 
65
- get slotNumber(): Fr {
66
+ get slotNumber(): SlotNumber {
66
67
  return this.payload.header.slotNumber;
67
68
  }
68
69
 
@@ -1,3 +1,4 @@
1
+ import { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import { Buffer32 } from '@aztec/foundation/buffer';
2
3
  import { keccak256, tryRecoverAddress } from '@aztec/foundation/crypto';
3
4
  import type { EthAddress } from '@aztec/foundation/eth-address';
@@ -65,13 +66,13 @@ export class BlockProposal extends Gossipable {
65
66
  return this.payload.archive;
66
67
  }
67
68
 
68
- get slotNumber(): Fr {
69
+ get slotNumber(): SlotNumber {
69
70
  return this.payload.header.slotNumber;
70
71
  }
71
72
 
72
73
  toBlockInfo(): Omit<L2BlockInfo, 'blockNumber'> {
73
74
  return {
74
- slotNumber: this.slotNumber.toNumber(),
75
+ slotNumber: this.slotNumber,
75
76
  lastArchive: this.payload.header.lastArchiveRoot,
76
77
  timestamp: this.payload.header.timestamp,
77
78
  archive: this.archive,
@@ -10,7 +10,6 @@ import { z } from 'zod';
10
10
  import type { L2Block } from '../block/l2_block.js';
11
11
  import type { Checkpoint } from '../checkpoint/checkpoint.js';
12
12
  import { CheckpointHeader } from '../rollup/checkpoint_header.js';
13
- import { StateReference } from '../tx/state_reference.js';
14
13
  import type { Signable, SignatureDomainSeparator } from './signature_utils.js';
15
14
 
16
15
  export class ConsensusPayload implements Signable {
@@ -21,8 +20,6 @@ export class ConsensusPayload implements Signable {
21
20
  public readonly header: CheckpointHeader,
22
21
  /** The archive root after the block is added */
23
22
  public readonly archive: Fr,
24
- /** The state reference after the block is added */
25
- public readonly stateReference: StateReference,
26
23
  ) {}
27
24
 
28
25
  static get schema() {
@@ -30,13 +27,12 @@ export class ConsensusPayload implements Signable {
30
27
  .object({
31
28
  header: CheckpointHeader.schema,
32
29
  archive: schemas.Fr,
33
- stateReference: StateReference.schema,
34
30
  })
35
- .transform(obj => new ConsensusPayload(obj.header, obj.archive, obj.stateReference));
31
+ .transform(obj => new ConsensusPayload(obj.header, obj.archive));
36
32
  }
37
33
 
38
34
  static getFields(fields: FieldsOf<ConsensusPayload>) {
39
- return [fields.header, fields.archive, fields.stateReference] as const;
35
+ return [fields.header, fields.archive] as const;
40
36
  }
41
37
 
42
38
  getPayloadToSign(domainSeparator: SignatureDomainSeparator): Buffer {
@@ -44,64 +40,53 @@ export class ConsensusPayload implements Signable {
44
40
  'uint8, ' + //domainSeperator
45
41
  '(' +
46
42
  'bytes32, ' + // archive
47
- '((bytes32,uint32),((bytes32,uint32),(bytes32,uint32),(bytes32,uint32))), ' + // stateReference
48
43
  '(int256), ' + // oracleInput
49
44
  'bytes32' + // headerHash
50
45
  ')',
51
46
  );
52
47
  const archiveRoot = this.archive.toString();
53
- const stateReference = this.stateReference.toAbi();
54
48
 
55
49
  const headerHash = this.header.hash().toString();
56
50
  const encodedData = encodeAbiParameters(abi, [
57
51
  domainSeparator,
58
- [archiveRoot, stateReference, [0n] /* @todo See #9963 */, headerHash],
52
+ [archiveRoot, [0n] /* @todo See #9963 */, headerHash],
59
53
  ] as const);
60
54
 
61
55
  return hexToBuffer(encodedData);
62
56
  }
63
57
 
64
58
  toBuffer(): Buffer {
65
- return serializeToBuffer([this.header, this.archive, this.stateReference]);
59
+ return serializeToBuffer([this.header, this.archive]);
66
60
  }
67
61
 
68
62
  public equals(other: ConsensusPayload): boolean {
69
- return (
70
- this.header.equals(other.header) &&
71
- this.archive.equals(other.archive) &&
72
- this.stateReference.equals(other.stateReference)
73
- );
63
+ return this.header.equals(other.header) && this.archive.equals(other.archive);
74
64
  }
75
65
 
76
66
  static fromBuffer(buf: Buffer | BufferReader): ConsensusPayload {
77
67
  const reader = BufferReader.asReader(buf);
78
- const payload = new ConsensusPayload(
79
- reader.readObject(CheckpointHeader),
80
- reader.readObject(Fr),
81
- reader.readObject(StateReference),
82
- );
68
+ const payload = new ConsensusPayload(reader.readObject(CheckpointHeader), reader.readObject(Fr));
83
69
  return payload;
84
70
  }
85
71
 
86
72
  static fromFields(fields: FieldsOf<ConsensusPayload>): ConsensusPayload {
87
- return new ConsensusPayload(fields.header, fields.archive, fields.stateReference);
73
+ return new ConsensusPayload(fields.header, fields.archive);
88
74
  }
89
75
 
90
76
  static fromBlock(block: L2Block): ConsensusPayload {
91
- return new ConsensusPayload(block.header.toCheckpointHeader(), block.archive.root, block.header.state);
77
+ return new ConsensusPayload(block.header.toCheckpointHeader(), block.archive.root);
92
78
  }
93
79
 
94
80
  static fromCheckpoint(checkpoint: Checkpoint): ConsensusPayload {
95
- const lastBlock = checkpoint.blocks.at(-1)!;
96
- return new ConsensusPayload(checkpoint.header, checkpoint.archive.root, lastBlock.header.state);
81
+ return new ConsensusPayload(checkpoint.header, checkpoint.archive.root);
97
82
  }
98
83
 
99
84
  static empty(): ConsensusPayload {
100
- return new ConsensusPayload(CheckpointHeader.empty(), Fr.ZERO, StateReference.empty());
85
+ return new ConsensusPayload(CheckpointHeader.empty(), Fr.ZERO);
101
86
  }
102
87
 
103
88
  static random(): ConsensusPayload {
104
- return new ConsensusPayload(CheckpointHeader.random(), Fr.random(), StateReference.random());
89
+ return new ConsensusPayload(CheckpointHeader.random(), Fr.random());
105
90
  }
106
91
 
107
92
  /**
@@ -121,11 +106,10 @@ export class ConsensusPayload implements Signable {
121
106
  return {
122
107
  header: this.header.toInspect(),
123
108
  archive: this.archive.toString(),
124
- stateReference: this.stateReference.toInspect(),
125
109
  };
126
110
  }
127
111
 
128
112
  toString() {
129
- return `header: ${this.header.toString()}, archive: ${this.archive.toString()}, stateReference: ${this.stateReference.l1ToL2MessageTree.root.toString()}`;
113
+ return `header: ${this.header.toString()}, archive: ${this.archive.toString()}}`;
130
114
  }
131
115
  }
@@ -1,3 +1,4 @@
1
+ import { SlotNumber } from '@aztec/foundation/branded-types';
1
2
  import { EthAddress } from '@aztec/foundation/eth-address';
2
3
  import { Fr } from '@aztec/foundation/fields';
3
4
  import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
@@ -24,7 +25,7 @@ export class CheckpointConstantData {
24
25
  /** Identifier of the prover. */
25
26
  public proverId: Fr,
26
27
  /** Slot number of the checkpoint. */
27
- public slotNumber: Fr,
28
+ public slotNumber: SlotNumber,
28
29
  /** Coinbase address of the rollup. */
29
30
  public coinbase: EthAddress,
30
31
  /** Address to receive fees. */
@@ -58,7 +59,7 @@ export class CheckpointConstantData {
58
59
  Fr.ZERO,
59
60
  Fr.ZERO,
60
61
  Fr.ZERO,
61
- Fr.ZERO,
62
+ SlotNumber.ZERO,
62
63
  EthAddress.ZERO,
63
64
  AztecAddress.ZERO,
64
65
  GasFees.empty(),
@@ -66,7 +67,17 @@ export class CheckpointConstantData {
66
67
  }
67
68
 
68
69
  toBuffer() {
69
- return serializeToBuffer(...CheckpointConstantData.getFields(this));
70
+ return serializeToBuffer(
71
+ this.chainId,
72
+ this.version,
73
+ this.vkTreeRoot,
74
+ this.protocolContractsHash,
75
+ this.proverId,
76
+ new Fr(this.slotNumber),
77
+ this.coinbase,
78
+ this.feeRecipient,
79
+ this.gasFees,
80
+ );
70
81
  }
71
82
 
72
83
  static fromBuffer(buffer: Buffer | BufferReader) {
@@ -77,13 +88,21 @@ export class CheckpointConstantData {
77
88
  Fr.fromBuffer(reader),
78
89
  Fr.fromBuffer(reader),
79
90
  Fr.fromBuffer(reader),
80
- Fr.fromBuffer(reader),
91
+ SlotNumber(Fr.fromBuffer(reader).toNumber()),
81
92
  reader.readObject(EthAddress),
82
93
  reader.readObject(AztecAddress),
83
94
  reader.readObject(GasFees),
84
95
  );
85
96
  }
86
97
 
98
+ /**
99
+ * Returns the slot number as a SlotNumber branded type.
100
+ * @deprecated Use slotNumber directly instead.
101
+ */
102
+ getSlotNumber(): SlotNumber {
103
+ return this.slotNumber;
104
+ }
105
+
87
106
  toInspect() {
88
107
  return {
89
108
  chainId: this.chainId.toNumber(),
@@ -91,7 +110,7 @@ export class CheckpointConstantData {
91
110
  vkTreeRoot: this.vkTreeRoot.toString(),
92
111
  protocolContractsHash: this.protocolContractsHash.toString(),
93
112
  proverId: this.proverId.toString(),
94
- slotNumber: this.slotNumber.toNumber(),
113
+ slotNumber: this.slotNumber,
95
114
  coinbase: this.coinbase.toString(),
96
115
  feeRecipient: this.feeRecipient.toString(),
97
116
  gasFees: this.gasFees.toInspect(),