@aztec/stdlib 3.0.0-nightly.20251216 → 3.0.0-nightly.20251218

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 (126) hide show
  1. package/dest/abi/abi.d.ts +602 -4
  2. package/dest/abi/abi.d.ts.map +1 -1
  3. package/dest/abi/abi.js +7 -7
  4. package/dest/abi/function_selector.d.ts +2 -1
  5. package/dest/abi/function_selector.d.ts.map +1 -1
  6. package/dest/abi/function_selector.js +7 -0
  7. package/dest/avm/avm.js +1 -1
  8. package/dest/block/checkpointed_l2_block.d.ts +267 -0
  9. package/dest/block/checkpointed_l2_block.d.ts.map +1 -0
  10. package/dest/block/{published_l2_block.js → checkpointed_l2_block.js} +40 -4
  11. package/dest/block/index.d.ts +2 -2
  12. package/dest/block/index.d.ts.map +1 -1
  13. package/dest/block/index.js +1 -1
  14. package/dest/block/l2_block_source.d.ts +62 -45
  15. package/dest/block/l2_block_source.d.ts.map +1 -1
  16. package/dest/block/l2_block_stream/interfaces.d.ts +2 -2
  17. package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
  18. package/dest/block/l2_block_stream/l2_block_stream.d.ts +6 -1
  19. package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
  20. package/dest/block/l2_block_stream/l2_block_stream.js +9 -1
  21. package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
  22. package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
  23. package/dest/block/test/l2_tips_store_test_suite.js +2 -5
  24. package/dest/checkpoint/checkpoint.d.ts +3 -2
  25. package/dest/checkpoint/checkpoint.d.ts.map +1 -1
  26. package/dest/checkpoint/checkpoint.js +16 -4
  27. package/dest/checkpoint/published_checkpoint.d.ts +14 -8
  28. package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
  29. package/dest/checkpoint/published_checkpoint.js +11 -1
  30. package/dest/contract/interfaces/contract_class.d.ts +11 -13
  31. package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
  32. package/dest/contract/interfaces/contract_class.js +18 -18
  33. package/dest/contract/interfaces/contract_instance.d.ts +12 -13
  34. package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
  35. package/dest/contract/interfaces/contract_instance.js +5 -5
  36. package/dest/contract/interfaces/contract_instance_update.d.ts +6 -7
  37. package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
  38. package/dest/contract/interfaces/contract_instance_update.js +5 -5
  39. package/dest/epoch-helpers/index.d.ts +1 -1
  40. package/dest/epoch-helpers/index.d.ts.map +1 -1
  41. package/dest/epoch-helpers/index.js +3 -3
  42. package/dest/interfaces/allowed_element.d.ts +7 -8
  43. package/dest/interfaces/allowed_element.d.ts.map +1 -1
  44. package/dest/interfaces/allowed_element.js +3 -3
  45. package/dest/interfaces/archiver.d.ts +1 -1
  46. package/dest/interfaces/archiver.d.ts.map +1 -1
  47. package/dest/interfaces/archiver.js +2 -2
  48. package/dest/interfaces/aztec-node-admin.d.ts +7 -1
  49. package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
  50. package/dest/interfaces/aztec-node.d.ts +1 -1
  51. package/dest/interfaces/aztec-node.d.ts.map +1 -1
  52. package/dest/interfaces/aztec-node.js +1 -1
  53. package/dest/interfaces/configs.d.ts +13 -11
  54. package/dest/interfaces/configs.d.ts.map +1 -1
  55. package/dest/interfaces/configs.js +4 -3
  56. package/dest/interfaces/get_logs_response.d.ts +12 -4
  57. package/dest/interfaces/get_logs_response.d.ts.map +1 -1
  58. package/dest/interfaces/get_logs_response.js +5 -4
  59. package/dest/interfaces/prover-client.d.ts +5 -3
  60. package/dest/interfaces/prover-client.d.ts.map +1 -1
  61. package/dest/interfaces/prover-client.js +5 -4
  62. package/dest/interfaces/slasher.d.ts +1 -1
  63. package/dest/interfaces/slasher.d.ts.map +1 -1
  64. package/dest/interfaces/slasher.js +3 -3
  65. package/dest/interfaces/validator.d.ts +7 -8
  66. package/dest/interfaces/validator.d.ts.map +1 -1
  67. package/dest/interfaces/validator.js +5 -5
  68. package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +1 -1
  69. package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
  70. package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +1 -3
  71. package/dest/schemas/schemas.d.ts +2 -2
  72. package/dest/schemas/schemas.d.ts.map +1 -1
  73. package/dest/schemas/schemas.js +1 -1
  74. package/dest/slashing/types.d.ts +4 -5
  75. package/dest/slashing/types.d.ts.map +1 -1
  76. package/dest/slashing/types.js +5 -5
  77. package/dest/snapshots/types.d.ts +1 -1
  78. package/dest/snapshots/types.d.ts.map +1 -1
  79. package/dest/snapshots/types.js +5 -5
  80. package/dest/tests/mocks.d.ts +5 -4
  81. package/dest/tests/mocks.d.ts.map +1 -1
  82. package/dest/tests/mocks.js +18 -5
  83. package/dest/tx/private_execution_result.d.ts +1 -1
  84. package/dest/tx/private_execution_result.js +1 -1
  85. package/dest/tx/simulated_tx.d.ts +1031 -7
  86. package/dest/tx/simulated_tx.d.ts.map +1 -1
  87. package/dest/tx/validator/tx_validator.d.ts +1 -4
  88. package/dest/tx/validator/tx_validator.d.ts.map +1 -1
  89. package/dest/tx/validator/tx_validator.js +4 -4
  90. package/dest/validators/schemas.d.ts +1 -1
  91. package/dest/validators/schemas.d.ts.map +1 -1
  92. package/dest/validators/schemas.js +13 -13
  93. package/package.json +8 -8
  94. package/src/abi/abi.ts +39 -33
  95. package/src/abi/function_selector.ts +8 -0
  96. package/src/avm/avm.ts +1 -1
  97. package/src/block/{published_l2_block.ts → checkpointed_l2_block.ts} +58 -3
  98. package/src/block/index.ts +1 -1
  99. package/src/block/l2_block_source.ts +70 -50
  100. package/src/block/l2_block_stream/interfaces.ts +1 -1
  101. package/src/block/l2_block_stream/l2_block_stream.ts +9 -0
  102. package/src/block/test/l2_tips_store_test_suite.ts +2 -1
  103. package/src/checkpoint/checkpoint.ts +19 -4
  104. package/src/checkpoint/published_checkpoint.ts +19 -5
  105. package/src/contract/interfaces/contract_class.ts +59 -46
  106. package/src/contract/interfaces/contract_instance.ts +15 -13
  107. package/src/contract/interfaces/contract_instance_update.ts +11 -9
  108. package/src/epoch-helpers/index.ts +11 -9
  109. package/src/interfaces/allowed_element.ts +9 -7
  110. package/src/interfaces/archiver.ts +2 -2
  111. package/src/interfaces/aztec-node.ts +1 -1
  112. package/src/interfaces/configs.ts +30 -27
  113. package/src/interfaces/get_logs_response.ts +13 -9
  114. package/src/interfaces/prover-client.ts +13 -10
  115. package/src/interfaces/slasher.ts +24 -22
  116. package/src/interfaces/validator.ts +22 -18
  117. package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +2 -4
  118. package/src/schemas/schemas.ts +1 -0
  119. package/src/slashing/types.ts +24 -20
  120. package/src/snapshots/types.ts +33 -29
  121. package/src/tests/mocks.ts +15 -3
  122. package/src/tx/private_execution_result.ts +1 -1
  123. package/src/tx/validator/tx_validator.ts +8 -6
  124. package/src/validators/schemas.ts +54 -48
  125. package/dest/block/published_l2_block.d.ts +0 -130
  126. package/dest/block/published_l2_block.d.ts.map +0 -1
@@ -73,15 +73,30 @@ export class Checkpoint {
73
73
  {
74
74
  numBlocks = 1,
75
75
  startBlockNumber = 1,
76
+ previousArchive,
76
77
  ...options
77
- }: { numBlocks?: number; startBlockNumber?: number } & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
78
+ }: {
79
+ numBlocks?: number;
80
+ startBlockNumber?: number;
81
+ previousArchive?: AppendOnlyTreeSnapshot;
82
+ } & Partial<Parameters<typeof CheckpointHeader.random>[0]> &
78
83
  Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
79
84
  ) {
80
85
  const header = CheckpointHeader.random(options);
81
86
 
82
- const blocks = await Promise.all(
83
- Array.from({ length: numBlocks }, (_, i) => L2BlockNew.random(BlockNumber(startBlockNumber + i), options)),
84
- );
87
+ // Create blocks sequentially to chain archive roots properly.
88
+ // Each block's header.lastArchive must equal the previous block's archive.
89
+ const blocks: L2BlockNew[] = [];
90
+ let lastArchive = previousArchive;
91
+ for (let i = 0; i < numBlocks; i++) {
92
+ const block = await L2BlockNew.random(BlockNumber(startBlockNumber + i), {
93
+ indexWithinCheckpoint: i,
94
+ ...options,
95
+ ...(lastArchive ? { lastArchive } : {}),
96
+ });
97
+ lastArchive = block.archive;
98
+ blocks.push(block);
99
+ }
85
100
 
86
101
  return new Checkpoint(AppendOnlyTreeSnapshot.random(), header, blocks, checkpointNumber);
87
102
  }
@@ -18,11 +18,13 @@ export class L1PublishedData {
18
18
  ) {}
19
19
 
20
20
  static get schema() {
21
- return z.object({
22
- blockNumber: schemas.BigInt,
23
- timestamp: schemas.BigInt,
24
- blockHash: z.string(),
25
- });
21
+ return z
22
+ .object({
23
+ blockNumber: schemas.BigInt,
24
+ timestamp: schemas.BigInt,
25
+ blockHash: z.string(),
26
+ })
27
+ .transform(obj => L1PublishedData.fromFields(obj));
26
28
  }
27
29
 
28
30
  static random() {
@@ -36,6 +38,18 @@ export class L1PublishedData {
36
38
  static fromFields(fields: FieldsOf<L1PublishedData>) {
37
39
  return new L1PublishedData(fields.blockNumber, fields.timestamp, fields.blockHash);
38
40
  }
41
+
42
+ static fromBuffer(bufferOrReader: Buffer | BufferReader): L1PublishedData {
43
+ const reader = BufferReader.asReader(bufferOrReader);
44
+ const l1BlockNumber = reader.readBigInt();
45
+ const l1BlockHash = reader.readString();
46
+ const l1Timestamp = reader.readBigInt();
47
+ return new L1PublishedData(l1BlockNumber, l1Timestamp, l1BlockHash);
48
+ }
49
+
50
+ public toBuffer(): Buffer {
51
+ return serializeToBuffer(this.blockNumber, this.blockHash, this.timestamp);
52
+ }
39
53
  }
40
54
 
41
55
  export class PublishedCheckpoint {
@@ -1,5 +1,5 @@
1
1
  import { Fr } from '@aztec/foundation/curves/bn254';
2
- import { type ZodFor, schemas } from '@aztec/foundation/schemas';
2
+ import { schemas, zodFor } from '@aztec/foundation/schemas';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
@@ -35,10 +35,12 @@ export interface PrivateFunction {
35
35
  vkHash: Fr;
36
36
  }
37
37
 
38
- const PrivateFunctionSchema = z.object({
39
- selector: FunctionSelector.schema,
40
- vkHash: schemas.Fr,
41
- }) satisfies ZodFor<PrivateFunction>;
38
+ const PrivateFunctionSchema = zodFor<PrivateFunction>()(
39
+ z.object({
40
+ selector: FunctionSelector.schema,
41
+ vkHash: schemas.Fr,
42
+ }),
43
+ );
42
44
 
43
45
  /** Private function definition with executable bytecode. */
44
46
  export interface ExecutablePrivateFunction extends PrivateFunction {
@@ -46,9 +48,9 @@ export interface ExecutablePrivateFunction extends PrivateFunction {
46
48
  bytecode: Buffer;
47
49
  }
48
50
 
49
- const ExecutablePrivateFunctionSchema = PrivateFunctionSchema.and(
50
- z.object({ bytecode: schemas.Buffer }),
51
- ) satisfies ZodFor<ExecutablePrivateFunction>;
51
+ const ExecutablePrivateFunctionSchema = zodFor<ExecutablePrivateFunction>()(
52
+ PrivateFunctionSchema.and(z.object({ bytecode: schemas.Buffer })),
53
+ );
52
54
 
53
55
  /** Utility function definition. */
54
56
  export interface UtilityFunction {
@@ -58,11 +60,12 @@ export interface UtilityFunction {
58
60
  bytecode: Buffer;
59
61
  }
60
62
 
61
- const UtilityFunctionSchema = z.object({
62
- /** lala */
63
- selector: FunctionSelector.schema,
64
- bytecode: schemas.Buffer,
65
- }) satisfies ZodFor<UtilityFunction>;
63
+ const UtilityFunctionSchema = zodFor<UtilityFunction>()(
64
+ z.object({
65
+ selector: FunctionSelector.schema,
66
+ bytecode: schemas.Buffer,
67
+ }),
68
+ );
66
69
 
67
70
  /** Sibling paths and sibling commitments for proving membership of a private function within a contract class. */
68
71
  export type PrivateFunctionMembershipProof = {
@@ -75,15 +78,17 @@ export type PrivateFunctionMembershipProof = {
75
78
  artifactTreeLeafIndex: number;
76
79
  };
77
80
 
78
- const PrivateFunctionMembershipProofSchema = z.object({
79
- artifactMetadataHash: schemas.Fr,
80
- functionMetadataHash: schemas.Fr,
81
- utilityFunctionsTreeRoot: schemas.Fr,
82
- privateFunctionTreeSiblingPath: z.array(schemas.Fr),
83
- privateFunctionTreeLeafIndex: schemas.Integer,
84
- artifactTreeSiblingPath: z.array(schemas.Fr),
85
- artifactTreeLeafIndex: schemas.Integer,
86
- }) satisfies ZodFor<PrivateFunctionMembershipProof>;
81
+ const PrivateFunctionMembershipProofSchema = zodFor<PrivateFunctionMembershipProof>()(
82
+ z.object({
83
+ artifactMetadataHash: schemas.Fr,
84
+ functionMetadataHash: schemas.Fr,
85
+ utilityFunctionsTreeRoot: schemas.Fr,
86
+ privateFunctionTreeSiblingPath: z.array(schemas.Fr),
87
+ privateFunctionTreeLeafIndex: schemas.Integer,
88
+ artifactTreeSiblingPath: z.array(schemas.Fr),
89
+ artifactTreeLeafIndex: schemas.Integer,
90
+ }),
91
+ );
87
92
 
88
93
  /** A private function with a membership proof. */
89
94
  export type ExecutablePrivateFunctionWithMembershipProof = ExecutablePrivateFunction & PrivateFunctionMembershipProof;
@@ -97,23 +102,27 @@ export type UtilityFunctionMembershipProof = {
97
102
  artifactTreeLeafIndex: number;
98
103
  };
99
104
 
100
- const UtilityFunctionMembershipProofSchema = z.object({
101
- artifactMetadataHash: schemas.Fr,
102
- functionMetadataHash: schemas.Fr,
103
- privateFunctionsArtifactTreeRoot: schemas.Fr,
104
- artifactTreeSiblingPath: z.array(schemas.Fr),
105
- artifactTreeLeafIndex: schemas.Integer,
106
- }) satisfies ZodFor<UtilityFunctionMembershipProof>;
105
+ const UtilityFunctionMembershipProofSchema = zodFor<UtilityFunctionMembershipProof>()(
106
+ z.object({
107
+ artifactMetadataHash: schemas.Fr,
108
+ functionMetadataHash: schemas.Fr,
109
+ privateFunctionsArtifactTreeRoot: schemas.Fr,
110
+ artifactTreeSiblingPath: z.array(schemas.Fr),
111
+ artifactTreeLeafIndex: schemas.Integer,
112
+ }),
113
+ );
107
114
 
108
115
  /** A utility function with a membership proof. */
109
116
  export type UtilityFunctionWithMembershipProof = UtilityFunction & UtilityFunctionMembershipProof;
110
117
 
111
- export const ContractClassSchema = z.object({
112
- version: z.literal(VERSION),
113
- artifactHash: schemas.Fr,
114
- privateFunctions: z.array(PrivateFunctionSchema),
115
- packedBytecode: schemas.Buffer,
116
- }) satisfies ZodFor<ContractClass>;
118
+ export const ContractClassSchema = zodFor<ContractClass>()(
119
+ z.object({
120
+ version: z.literal(VERSION),
121
+ artifactHash: schemas.Fr,
122
+ privateFunctions: z.array(PrivateFunctionSchema),
123
+ packedBytecode: schemas.Buffer,
124
+ }),
125
+ );
117
126
 
118
127
  /** Commitments to fields of a contract class. */
119
128
  interface ContractClassCommitments {
@@ -128,9 +137,11 @@ interface ContractClassCommitments {
128
137
  /** A contract class with its precomputed id. */
129
138
  export type ContractClassWithId = ContractClass & Pick<ContractClassCommitments, 'id'>;
130
139
 
131
- export const ContractClassWithIdSchema = ContractClassSchema.extend({
132
- id: schemas.Fr,
133
- }) satisfies ZodFor<ContractClassWithId>;
140
+ export const ContractClassWithIdSchema = zodFor<ContractClassWithId>()(
141
+ ContractClassSchema.extend({
142
+ id: schemas.Fr,
143
+ }),
144
+ );
134
145
 
135
146
  /** A contract class with public bytecode information, and optional private and utility functions. */
136
147
  export type ContractClassPublic = {
@@ -142,14 +153,16 @@ export type ContractClassPublic = {
142
153
  export type ContractClassPublicWithCommitment = ContractClassPublic &
143
154
  Pick<ContractClassCommitments, 'publicBytecodeCommitment'>;
144
155
 
145
- export const ContractClassPublicSchema = z
146
- .object({
147
- id: schemas.Fr,
148
- privateFunctionsRoot: schemas.Fr,
149
- privateFunctions: z.array(ExecutablePrivateFunctionSchema.and(PrivateFunctionMembershipProofSchema)),
150
- utilityFunctions: z.array(UtilityFunctionSchema.and(UtilityFunctionMembershipProofSchema)),
151
- })
152
- .and(ContractClassSchema.omit({ privateFunctions: true })) satisfies ZodFor<ContractClassPublic>;
156
+ export const ContractClassPublicSchema = zodFor<ContractClassPublic>()(
157
+ z
158
+ .object({
159
+ id: schemas.Fr,
160
+ privateFunctionsRoot: schemas.Fr,
161
+ privateFunctions: z.array(ExecutablePrivateFunctionSchema.and(PrivateFunctionMembershipProofSchema)),
162
+ utilityFunctions: z.array(UtilityFunctionSchema.and(UtilityFunctionMembershipProofSchema)),
163
+ })
164
+ .and(ContractClassSchema.omit({ privateFunctions: true })),
165
+ );
153
166
 
154
167
  /** The contract class with the block it was initially deployed at */
155
168
  export type ContractClassPublicWithBlockNumber = { l2BlockNumber: number } & ContractClassPublic;
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
 
5
5
  import { AztecAddress } from '../../aztec-address/index.js';
6
6
  import { PublicKeys } from '../../keys/public_keys.js';
7
- import { type ZodFor, schemas } from '../../schemas/index.js';
7
+ import { schemas, zodFor } from '../../schemas/index.js';
8
8
 
9
9
  const VERSION = 1 as const;
10
10
 
@@ -32,19 +32,21 @@ export interface ContractInstance {
32
32
 
33
33
  export type ContractInstanceWithAddress = ContractInstance & { address: AztecAddress };
34
34
 
35
- export const ContractInstanceSchema = z.object({
36
- version: z.literal(VERSION),
37
- salt: schemas.Fr,
38
- deployer: schemas.AztecAddress,
39
- currentContractClassId: schemas.Fr,
40
- originalContractClassId: schemas.Fr,
41
- initializationHash: schemas.Fr,
42
- publicKeys: PublicKeys.schema,
43
- }) satisfies ZodFor<ContractInstance>;
35
+ export const ContractInstanceSchema = zodFor<ContractInstance>()(
36
+ z.object({
37
+ version: z.literal(VERSION),
38
+ salt: schemas.Fr,
39
+ deployer: schemas.AztecAddress,
40
+ currentContractClassId: schemas.Fr,
41
+ originalContractClassId: schemas.Fr,
42
+ initializationHash: schemas.Fr,
43
+ publicKeys: PublicKeys.schema,
44
+ }),
45
+ );
44
46
 
45
- export const ContractInstanceWithAddressSchema = ContractInstanceSchema.and(
46
- z.object({ address: schemas.AztecAddress }),
47
- ) satisfies ZodFor<ContractInstanceWithAddress>;
47
+ export const ContractInstanceWithAddressSchema = zodFor<ContractInstanceWithAddress>()(
48
+ ContractInstanceSchema.and(z.object({ address: schemas.AztecAddress })),
49
+ );
48
50
 
49
51
  /**
50
52
  * Creates a ContractInstance from a plain object without Zod validation.
@@ -3,7 +3,7 @@ import type { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { z } from 'zod';
4
4
 
5
5
  import type { AztecAddress } from '../../aztec-address/index.js';
6
- import { type ZodFor, schemas } from '../../schemas/index.js';
6
+ import { schemas, zodFor } from '../../schemas/index.js';
7
7
  import type { UInt64 } from '../../types/shared.js';
8
8
 
9
9
  /**
@@ -20,12 +20,14 @@ export interface ContractInstanceUpdate {
20
20
 
21
21
  export type ContractInstanceUpdateWithAddress = ContractInstanceUpdate & { address: AztecAddress };
22
22
 
23
- export const ContractInstanceUpdateSchema = z.object({
24
- prevContractClassId: schemas.Fr,
25
- newContractClassId: schemas.Fr,
26
- timestampOfChange: schemas.BigInt,
27
- }) satisfies ZodFor<ContractInstanceUpdate>;
23
+ export const ContractInstanceUpdateSchema = zodFor<ContractInstanceUpdate>()(
24
+ z.object({
25
+ prevContractClassId: schemas.Fr,
26
+ newContractClassId: schemas.Fr,
27
+ timestampOfChange: schemas.BigInt,
28
+ }),
29
+ );
28
30
 
29
- export const ContractInstanceUpdateWithAddressSchema = ContractInstanceUpdateSchema.and(
30
- z.object({ address: schemas.AztecAddress }),
31
- ) satisfies ZodFor<ContractInstanceUpdateWithAddress>;
31
+ export const ContractInstanceUpdateWithAddressSchema = zodFor<ContractInstanceUpdateWithAddress>()(
32
+ ContractInstanceUpdateSchema.and(z.object({ address: schemas.AztecAddress })),
33
+ );
@@ -2,7 +2,7 @@ import { EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
5
- import { type ZodFor, schemas } from '../schemas/index.js';
5
+ import { schemas, zodFor } from '../schemas/index.js';
6
6
 
7
7
  export type L1RollupConstants = {
8
8
  l1StartBlock: bigint;
@@ -22,14 +22,16 @@ export const EmptyL1RollupConstants: L1RollupConstants = {
22
22
  proofSubmissionEpochs: 1,
23
23
  };
24
24
 
25
- export const L1RollupConstantsSchema = z.object({
26
- l1StartBlock: schemas.BigInt,
27
- l1GenesisTime: schemas.BigInt,
28
- slotDuration: z.number(),
29
- epochDuration: z.number(),
30
- ethereumSlotDuration: z.number(),
31
- proofSubmissionEpochs: z.number(),
32
- }) satisfies ZodFor<L1RollupConstants>;
25
+ export const L1RollupConstantsSchema = zodFor<L1RollupConstants>()(
26
+ z.object({
27
+ l1StartBlock: schemas.BigInt,
28
+ l1GenesisTime: schemas.BigInt,
29
+ slotDuration: z.number(),
30
+ epochDuration: z.number(),
31
+ ethereumSlotDuration: z.number(),
32
+ proofSubmissionEpochs: z.number(),
33
+ }),
34
+ );
33
35
 
34
36
  /** Returns the timestamp for a given L2 slot. */
35
37
  export function getTimestampForSlot(
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
 
5
5
  import type { FunctionSelector } from '../abi/function_selector.js';
6
6
  import type { AztecAddress } from '../aztec-address/index.js';
7
- import { type ZodFor, schemas } from '../schemas/index.js';
7
+ import { schemas, zodFor } from '../schemas/index.js';
8
8
 
9
9
  type AllowedInstance = { address: AztecAddress };
10
10
  type AllowedInstanceFunction = { address: AztecAddress; selector: FunctionSelector };
@@ -13,9 +13,11 @@ type AllowedClassFunction = { classId: Fr; selector: FunctionSelector };
13
13
 
14
14
  export type AllowedElement = AllowedInstance | AllowedInstanceFunction | AllowedClass | AllowedClassFunction;
15
15
 
16
- export const AllowedElementSchema = z.union([
17
- z.object({ address: schemas.AztecAddress, selector: schemas.FunctionSelector }),
18
- z.object({ address: schemas.AztecAddress }),
19
- z.object({ classId: schemas.Fr, selector: schemas.FunctionSelector }),
20
- z.object({ classId: schemas.Fr }),
21
- ]) satisfies ZodFor<AllowedElement>;
16
+ export const AllowedElementSchema = zodFor<AllowedElement>()(
17
+ z.union([
18
+ z.object({ address: schemas.AztecAddress, selector: schemas.FunctionSelector }),
19
+ z.object({ address: schemas.AztecAddress }),
20
+ z.object({ classId: schemas.Fr, selector: schemas.FunctionSelector }),
21
+ z.object({ classId: schemas.Fr }),
22
+ ]),
23
+ );
@@ -4,9 +4,9 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
4
4
 
5
5
  import { z } from 'zod';
6
6
 
7
+ import { CheckpointedL2Block, PublishedL2Block } from '../block/checkpointed_l2_block.js';
7
8
  import { L2Block } from '../block/l2_block.js';
8
9
  import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
9
- import { PublishedL2Block } from '../block/published_l2_block.js';
10
10
  import { ValidateBlockResultSchema } from '../block/validate_block_result.js';
11
11
  import { Checkpoint } from '../checkpoint/checkpoint.js';
12
12
  import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
@@ -85,6 +85,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
85
85
  .function()
86
86
  .args(z.union([BlockNumberSchema, z.literal('latest')]))
87
87
  .returns(BlockHeader.schema.optional()),
88
+ getCheckpointedBlock: z.function().args(BlockNumberSchema).returns(CheckpointedL2Block.schema.optional()),
88
89
  getBlocks: z
89
90
  .function()
90
91
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
@@ -93,7 +94,6 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
93
94
  .function()
94
95
  .args(CheckpointNumberSchema, schemas.Integer)
95
96
  .returns(z.array(PublishedCheckpoint.schema)),
96
- getCheckpointByArchive: z.function().args(schemas.Fr).returns(Checkpoint.schema.optional()),
97
97
  getPublishedBlocks: z
98
98
  .function()
99
99
  .args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
@@ -21,10 +21,10 @@ import { z } from 'zod';
21
21
 
22
22
  import type { AztecAddress } from '../aztec-address/index.js';
23
23
  import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
24
+ import { PublishedL2Block } from '../block/checkpointed_l2_block.js';
24
25
  import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
25
26
  import { L2Block } from '../block/l2_block.js';
26
27
  import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
27
- import { PublishedL2Block } from '../block/published_l2_block.js';
28
28
  import {
29
29
  type ContractClassPublic,
30
30
  ContractClassPublicSchema,
@@ -3,7 +3,7 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { z } from 'zod';
4
4
 
5
5
  import type { AztecAddress } from '../aztec-address/index.js';
6
- import { type ZodFor, schemas } from '../schemas/index.js';
6
+ import { schemas, zodFor } from '../schemas/index.js';
7
7
  import { type AllowedElement, AllowedElementSchema } from './allowed_element.js';
8
8
 
9
9
  /**
@@ -62,29 +62,32 @@ export interface SequencerConfig {
62
62
  shuffleAttestationOrdering?: boolean;
63
63
  }
64
64
 
65
- export const SequencerConfigSchema = z.object({
66
- transactionPollingIntervalMS: z.number().optional(),
67
- maxTxsPerBlock: z.number().optional(),
68
- minTxsPerBlock: z.number().optional(),
69
- maxL2BlockGas: z.number().optional(),
70
- publishTxsWithProposals: z.boolean().optional(),
71
- maxDABlockGas: z.number().optional(),
72
- coinbase: schemas.EthAddress.optional(),
73
- feeRecipient: schemas.AztecAddress.optional(),
74
- acvmWorkingDirectory: z.string().optional(),
75
- acvmBinaryPath: z.string().optional(),
76
- txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
77
- maxBlockSizeInBytes: z.number().optional(),
78
- governanceProposerPayload: schemas.EthAddress.optional(),
79
- maxL1TxInclusionTimeIntoSlot: z.number().optional(),
80
- enforceTimeTable: z.boolean().optional(),
81
- fakeProcessingDelayPerTxMs: z.number().optional(),
82
- attestationPropagationTime: z.number().optional(),
83
- skipCollectingAttestations: z.boolean().optional(),
84
- secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
85
- secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
86
- broadcastInvalidBlockProposal: z.boolean().optional(),
87
- injectFakeAttestation: z.boolean().optional(),
88
- fishermanMode: z.boolean().optional(),
89
- shuffleAttestationOrdering: z.boolean().optional(),
90
- }) satisfies ZodFor<SequencerConfig>;
65
+ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
66
+ z.object({
67
+ transactionPollingIntervalMS: z.number().optional(),
68
+ maxTxsPerBlock: z.number().optional(),
69
+ minTxsPerBlock: z.number().optional(),
70
+ maxL2BlockGas: z.number().optional(),
71
+ publishTxsWithProposals: z.boolean().optional(),
72
+ maxDABlockGas: z.number().optional(),
73
+ coinbase: schemas.EthAddress.optional(),
74
+ feeRecipient: schemas.AztecAddress.optional(),
75
+ acvmWorkingDirectory: z.string().optional(),
76
+ acvmBinaryPath: z.string().optional(),
77
+ txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
78
+ maxBlockSizeInBytes: z.number().optional(),
79
+ governanceProposerPayload: schemas.EthAddress.optional(),
80
+ maxL1TxInclusionTimeIntoSlot: z.number().optional(),
81
+ enforceTimeTable: z.boolean().optional(),
82
+ fakeProcessingDelayPerTxMs: z.number().optional(),
83
+ attestationPropagationTime: z.number().optional(),
84
+ skipCollectingAttestations: z.boolean().optional(),
85
+ skipInvalidateBlockAsProposer: z.boolean().optional(),
86
+ secondsBeforeInvalidatingBlockAsCommitteeMember: z.number(),
87
+ secondsBeforeInvalidatingBlockAsNonCommitteeMember: z.number(),
88
+ broadcastInvalidBlockProposal: z.boolean().optional(),
89
+ injectFakeAttestation: z.boolean().optional(),
90
+ fishermanMode: z.boolean().optional(),
91
+ shuffleAttestationOrdering: z.boolean().optional(),
92
+ }),
93
+ );
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
 
3
3
  import { ExtendedContractClassLog } from '../logs/extended_contract_class_log.js';
4
4
  import { ExtendedPublicLog } from '../logs/extended_public_log.js';
5
- import type { ZodFor } from '../schemas/index.js';
5
+ import { zodFor } from '../schemas/index.js';
6
6
 
7
7
  /** Response for the getContractClassLogs archiver call. */
8
8
  export type GetContractClassLogsResponse = {
@@ -12,10 +12,12 @@ export type GetContractClassLogsResponse = {
12
12
  maxLogsHit: boolean;
13
13
  };
14
14
 
15
- export const GetContractClassLogsResponseSchema: ZodFor<GetContractClassLogsResponse> = z.object({
16
- logs: z.array(ExtendedContractClassLog.schema),
17
- maxLogsHit: z.boolean(),
18
- });
15
+ export const GetContractClassLogsResponseSchema = zodFor<GetContractClassLogsResponse>()(
16
+ z.object({
17
+ logs: z.array(ExtendedContractClassLog.schema),
18
+ maxLogsHit: z.boolean(),
19
+ }),
20
+ );
19
21
 
20
22
  /** Response for the getPublicLogs archiver call. */
21
23
  export type GetPublicLogsResponse = {
@@ -25,7 +27,9 @@ export type GetPublicLogsResponse = {
25
27
  maxLogsHit: boolean;
26
28
  };
27
29
 
28
- export const GetPublicLogsResponseSchema = z.object({
29
- logs: z.array(ExtendedPublicLog.schema),
30
- maxLogsHit: z.boolean(),
31
- }) satisfies ZodFor<GetPublicLogsResponse>;
30
+ export const GetPublicLogsResponseSchema = zodFor<GetPublicLogsResponse>()(
31
+ z.object({
32
+ logs: z.array(ExtendedPublicLog.schema),
33
+ maxLogsHit: z.boolean(),
34
+ }),
35
+ );
@@ -3,7 +3,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
6
- import { type ZodFor, schemas } from '../schemas/index.js';
6
+ import { schemas, zodFor } from '../schemas/index.js';
7
7
  import type { TxHash } from '../tx/tx_hash.js';
8
8
  import type { EpochProver } from './epoch-prover.js';
9
9
  import type { ProvingJobConsumer } from './prover-broker.js';
@@ -33,15 +33,18 @@ export type ProverConfig = ActualProverConfig & {
33
33
  failedProofStore?: string;
34
34
  };
35
35
 
36
- export const ProverConfigSchema = z.object({
37
- nodeUrl: z.string().optional(),
38
- realProofs: z.boolean(),
39
- proverId: schemas.EthAddress.optional(),
40
- proverTestDelayType: z.enum(['fixed', 'realistic']),
41
- proverTestDelayMs: z.number(),
42
- proverTestDelayFactor: z.number(),
43
- proverAgentCount: z.number(),
44
- }) satisfies ZodFor<ProverConfig>;
36
+ export const ProverConfigSchema = zodFor<ProverConfig>()(
37
+ z.object({
38
+ nodeUrl: z.string().optional(),
39
+ realProofs: z.boolean(),
40
+ proverId: schemas.EthAddress.optional(),
41
+ proverTestDelayType: z.enum(['fixed', 'realistic']),
42
+ proverTestDelayMs: z.number(),
43
+ proverTestDelayFactor: z.number(),
44
+ proverAgentCount: z.number(),
45
+ failedProofStore: z.string().optional(),
46
+ }),
47
+ );
45
48
 
46
49
  export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
47
50
  nodeUrl: {
@@ -1,5 +1,5 @@
1
1
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
- import { type ZodFor, schemas } from '@aztec/foundation/schemas';
2
+ import { schemas, zodFor } from '@aztec/foundation/schemas';
3
3
 
4
4
  import { z } from 'zod';
5
5
 
@@ -27,24 +27,26 @@ export interface SlasherConfig {
27
27
  slashExecuteRoundsLookBack: number; // How many rounds to look back when searching for a round to execute
28
28
  }
29
29
 
30
- export const SlasherConfigSchema = z.object({
31
- slashOverridePayload: schemas.EthAddress.optional(),
32
- slashMinPenaltyPercentage: z.number(),
33
- slashMaxPenaltyPercentage: z.number(),
34
- slashValidatorsAlways: z.array(schemas.EthAddress),
35
- slashValidatorsNever: z.array(schemas.EthAddress),
36
- slashPrunePenalty: schemas.BigInt,
37
- slashDataWithholdingPenalty: schemas.BigInt,
38
- slashInactivityTargetPercentage: z.number(),
39
- slashInactivityConsecutiveEpochThreshold: z.number(),
40
- slashInactivityPenalty: schemas.BigInt,
41
- slashProposeInvalidAttestationsPenalty: schemas.BigInt,
42
- slashAttestDescendantOfInvalidPenalty: schemas.BigInt,
43
- slashUnknownPenalty: schemas.BigInt,
44
- slashOffenseExpirationRounds: z.number(),
45
- slashMaxPayloadSize: z.number(),
46
- slashGracePeriodL2Slots: z.number(),
47
- slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
48
- slashExecuteRoundsLookBack: z.number(),
49
- slashSelfAllowed: z.boolean().optional(),
50
- }) satisfies ZodFor<SlasherConfig>;
30
+ export const SlasherConfigSchema = zodFor<SlasherConfig>()(
31
+ z.object({
32
+ slashOverridePayload: schemas.EthAddress.optional(),
33
+ slashMinPenaltyPercentage: z.number(),
34
+ slashMaxPenaltyPercentage: z.number(),
35
+ slashValidatorsAlways: z.array(schemas.EthAddress),
36
+ slashValidatorsNever: z.array(schemas.EthAddress),
37
+ slashPrunePenalty: schemas.BigInt,
38
+ slashDataWithholdingPenalty: schemas.BigInt,
39
+ slashInactivityTargetPercentage: z.number(),
40
+ slashInactivityConsecutiveEpochThreshold: z.number(),
41
+ slashInactivityPenalty: schemas.BigInt,
42
+ slashProposeInvalidAttestationsPenalty: schemas.BigInt,
43
+ slashAttestDescendantOfInvalidPenalty: schemas.BigInt,
44
+ slashUnknownPenalty: schemas.BigInt,
45
+ slashOffenseExpirationRounds: z.number(),
46
+ slashMaxPayloadSize: z.number(),
47
+ slashGracePeriodL2Slots: z.number(),
48
+ slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
49
+ slashExecuteRoundsLookBack: z.number(),
50
+ slashSelfAllowed: z.boolean().optional(),
51
+ }),
52
+ );