@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
@@ -2,7 +2,7 @@ import type { SecretValue } from '@aztec/foundation/config';
2
2
  import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import type { EthAddress } from '@aztec/foundation/eth-address';
4
4
  import type { Signature } from '@aztec/foundation/eth-signature';
5
- import { type ZodFor, schemas } from '@aztec/foundation/schemas';
5
+ import { schemas, zodFor } 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
8
  import type { Tx } from '@aztec/stdlib/tx';
@@ -56,23 +56,27 @@ export type ValidatorClientFullConfig = ValidatorClientConfig &
56
56
  disableTransactions?: boolean;
57
57
  };
58
58
 
59
- export const ValidatorClientConfigSchema = z.object({
60
- validatorAddresses: z.array(schemas.EthAddress).optional(),
61
- disableValidator: z.boolean(),
62
- disabledValidators: z.array(schemas.EthAddress),
63
- attestationPollingIntervalMs: z.number().min(0),
64
- validatorReexecute: z.boolean(),
65
- validatorReexecuteDeadlineMs: z.number().min(0),
66
- alwaysReexecuteBlockProposals: z.boolean().optional(),
67
- fishermanMode: z.boolean().optional(),
68
- }) satisfies ZodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>;
69
-
70
- export const ValidatorClientFullConfigSchema = ValidatorClientConfigSchema.extend({
71
- txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
72
- broadcastInvalidBlockProposal: z.boolean().optional(),
73
- slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
74
- disableTransactions: z.boolean().optional(),
75
- }) satisfies ZodFor<Omit<ValidatorClientFullConfig, 'validatorPrivateKeys'>>;
59
+ export const ValidatorClientConfigSchema = zodFor<Omit<ValidatorClientConfig, 'validatorPrivateKeys'>>()(
60
+ z.object({
61
+ validatorAddresses: z.array(schemas.EthAddress).optional(),
62
+ disableValidator: z.boolean(),
63
+ disabledValidators: z.array(schemas.EthAddress),
64
+ attestationPollingIntervalMs: z.number().min(0),
65
+ validatorReexecute: z.boolean(),
66
+ validatorReexecuteDeadlineMs: z.number().min(0),
67
+ alwaysReexecuteBlockProposals: z.boolean().optional(),
68
+ fishermanMode: z.boolean().optional(),
69
+ }),
70
+ );
71
+
72
+ export const ValidatorClientFullConfigSchema = zodFor<Omit<ValidatorClientFullConfig, 'validatorPrivateKeys'>>()(
73
+ ValidatorClientConfigSchema.extend({
74
+ txPublicSetupAllowList: z.array(AllowedElementSchema).optional(),
75
+ broadcastInvalidBlockProposal: z.boolean().optional(),
76
+ slashBroadcastedInvalidBlockPenalty: schemas.BigInt,
77
+ disableTransactions: z.boolean().optional(),
78
+ }),
79
+ );
76
80
 
77
81
  export interface Validator {
78
82
  start(): Promise<void>;
@@ -1,3 +1,5 @@
1
+ import { isDefined } from '@aztec/foundation/types';
2
+
1
3
  import {
2
4
  PrivateKernelResetDimensions,
3
5
  type PrivateKernelResetDimensionsConfig,
@@ -10,10 +12,6 @@ interface DimensionOption {
10
12
  remainder?: PrivateKernelResetDimensions;
11
13
  }
12
14
 
13
- function isDefined<T>(value: T | undefined): value is T {
14
- return value !== undefined;
15
- }
16
-
17
15
  function computeCost(dimensions: PrivateKernelResetDimensions, config: PrivateKernelResetDimensionsConfig) {
18
16
  return privateKernelResetDimensionNames.reduce(
19
17
  (accum, name) => accum + dimensions[name] * config.dimensions[name].cost,
@@ -94,6 +94,7 @@ export const NullishToUndefined = (schema: ZodFor<any>) => schema.nullish().tran
94
94
 
95
95
  export {
96
96
  type ZodFor,
97
+ zodFor,
97
98
  bufferSchema,
98
99
  hexSchema,
99
100
  hexSchemaFor,
@@ -2,7 +2,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
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 enum OffenseType {
8
8
  UNKNOWN = 0,
@@ -90,12 +90,14 @@ export type Offense = {
90
90
 
91
91
  export type OffenseIdentifier = Pick<Offense, 'validator' | 'offenseType' | 'epochOrSlot'>;
92
92
 
93
- export const OffenseSchema = z.object({
94
- validator: schemas.EthAddress,
95
- amount: schemas.BigInt,
96
- offenseType: OffenseTypeSchema,
97
- epochOrSlot: schemas.BigInt,
98
- }) satisfies ZodFor<Offense>;
93
+ export const OffenseSchema = zodFor<Offense>()(
94
+ z.object({
95
+ validator: schemas.EthAddress,
96
+ amount: schemas.BigInt,
97
+ offenseType: OffenseTypeSchema,
98
+ epochOrSlot: schemas.BigInt,
99
+ }),
100
+ );
99
101
 
100
102
  /** Offense by a validator in the context of a slash payload */
101
103
  export type ValidatorSlashOffense = {
@@ -120,19 +122,21 @@ export type SlashPayload = {
120
122
  /** Slash payload with round information from empire slash proposer */
121
123
  export type SlashPayloadRound = SlashPayload & { votes: bigint; round: bigint };
122
124
 
123
- export const SlashPayloadRoundSchema = z.object({
124
- address: schemas.EthAddress,
125
- timestamp: schemas.BigInt,
126
- votes: schemas.BigInt,
127
- round: schemas.BigInt,
128
- slashes: z.array(
129
- z.object({
130
- validator: schemas.EthAddress,
131
- amount: schemas.BigInt,
132
- offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
133
- }),
134
- ),
135
- }) satisfies ZodFor<SlashPayloadRound>;
125
+ export const SlashPayloadRoundSchema = zodFor<SlashPayloadRound>()(
126
+ z.object({
127
+ address: schemas.EthAddress,
128
+ timestamp: schemas.BigInt,
129
+ votes: schemas.BigInt,
130
+ round: schemas.BigInt,
131
+ slashes: z.array(
132
+ z.object({
133
+ validator: schemas.EthAddress,
134
+ amount: schemas.BigInt,
135
+ offenses: z.array(z.object({ offenseType: OffenseTypeSchema, epochOrSlot: schemas.BigInt })),
136
+ }),
137
+ ),
138
+ }),
139
+ );
136
140
 
137
141
  /** Votes for a validator slash in the consensus slash proposer */
138
142
  export type ValidatorSlashVote = number;
@@ -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
 
@@ -38,33 +38,37 @@ export type SnapshotsIndex = SnapshotsIndexMetadata & {
38
38
  export type UploadSnapshotMetadata = Pick<SnapshotMetadata, 'l2BlockNumber' | 'l2BlockHash' | 'l1BlockNumber'> &
39
39
  Pick<SnapshotsIndex, 'l1ChainId' | 'rollupVersion' | 'rollupAddress'>;
40
40
 
41
- export const SnapshotsIndexSchema = z.object({
42
- l1ChainId: z.number(),
43
- rollupVersion: z.number(),
44
- rollupAddress: schemas.EthAddress,
45
- snapshots: z.array(
46
- z.object({
47
- l2BlockNumber: z.number(),
48
- l2BlockHash: z.string(),
49
- l1BlockNumber: z.number(),
50
- timestamp: z.number(),
51
- schemaVersions: z.object({
52
- archiver: z.number(),
53
- worldState: z.number(),
41
+ export const SnapshotsIndexSchema = zodFor<SnapshotsIndex>()(
42
+ z.object({
43
+ l1ChainId: z.number(),
44
+ rollupVersion: z.number(),
45
+ rollupAddress: schemas.EthAddress,
46
+ snapshots: z.array(
47
+ z.object({
48
+ l2BlockNumber: z.number(),
49
+ l2BlockHash: z.string(),
50
+ l1BlockNumber: z.number(),
51
+ timestamp: z.number(),
52
+ schemaVersions: z.object({
53
+ archiver: z.number(),
54
+ worldState: z.number(),
55
+ }),
56
+ dataUrls: z
57
+ .record(z.enum(SnapshotDataKeys), z.string())
58
+ // See https://stackoverflow.com/questions/77958464/zod-record-with-required-keys
59
+ .refine((obj): obj is Required<typeof obj> => SnapshotDataKeys.every(key => !!obj[key])),
54
60
  }),
55
- dataUrls: z
56
- .record(z.enum(SnapshotDataKeys), z.string())
57
- // See https://stackoverflow.com/questions/77958464/zod-record-with-required-keys
58
- .refine((obj): obj is Required<typeof obj> => SnapshotDataKeys.every(key => !!obj[key])),
59
- }),
60
- ),
61
- }) satisfies ZodFor<SnapshotsIndex>;
61
+ ),
62
+ }),
63
+ );
62
64
 
63
- export const UploadSnapshotMetadataSchema = z.object({
64
- l2BlockNumber: z.number(),
65
- l2BlockHash: z.string(),
66
- l1BlockNumber: z.number(),
67
- l1ChainId: z.number(),
68
- rollupVersion: z.number(),
69
- rollupAddress: schemas.EthAddress,
70
- }) satisfies ZodFor<UploadSnapshotMetadata>;
65
+ export const UploadSnapshotMetadataSchema = zodFor<UploadSnapshotMetadata>()(
66
+ z.object({
67
+ l2BlockNumber: z.number(),
68
+ l2BlockHash: z.string(),
69
+ l1BlockNumber: z.number(),
70
+ l1ChainId: z.number(),
71
+ rollupVersion: z.number(),
72
+ rollupAddress: schemas.EthAddress,
73
+ }),
74
+ );
@@ -20,10 +20,9 @@ import { AvmCircuitPublicInputs } from '../avm/avm_circuit_public_inputs.js';
20
20
  import { PublicDataWrite } from '../avm/public_data_write.js';
21
21
  import { RevertCode } from '../avm/revert_code.js';
22
22
  import { AztecAddress } from '../aztec-address/index.js';
23
- import { CommitteeAttestation, L2BlockHeader, L2BlockNew } from '../block/index.js';
23
+ import { CommitteeAttestation, L2BlockHeader, L2BlockNew, PublishedL2Block } from '../block/index.js';
24
24
  import { L2Block } from '../block/l2_block.js';
25
25
  import type { CommitteeAttestationsAndSigners } from '../block/proposal/attestations_and_signers.js';
26
- import { PublishedL2Block } from '../block/published_l2_block.js';
27
26
  import { Checkpoint } from '../checkpoint/checkpoint.js';
28
27
  import { L1PublishedData } from '../checkpoint/published_checkpoint.js';
29
28
  import { computeContractAddressFromInstance } from '../contract/contract_address.js';
@@ -396,6 +395,7 @@ export async function mockCheckpointAndMessages(
396
395
  numTxsPerBlock = 1,
397
396
  numL1ToL2Messages = 1,
398
397
  makeBlockOptions = () => ({}),
398
+ previousArchive,
399
399
  ...options
400
400
  }: {
401
401
  startBlockNumber?: BlockNumber;
@@ -403,11 +403,15 @@ export async function mockCheckpointAndMessages(
403
403
  numTxsPerBlock?: number;
404
404
  numL1ToL2Messages?: number;
405
405
  makeBlockOptions?: (blockNumber: BlockNumber) => Partial<Parameters<typeof L2BlockNew.random>[1]>;
406
+ previousArchive?: AppendOnlyTreeSnapshot;
406
407
  } & Partial<Parameters<typeof Checkpoint.random>[1]> &
407
408
  Partial<Parameters<typeof L2BlockNew.random>[1]> = {},
408
409
  ) {
409
410
  const slotNumber = options.slotNumber ?? SlotNumber(checkpointNumber * 10);
410
411
  const blocksAndMessages = [];
412
+ // Track the previous block's archive to ensure consecutive blocks have consistent archive roots.
413
+ // The current block's header.lastArchive must equal the previous block's archive.
414
+ let lastArchive: AppendOnlyTreeSnapshot | undefined = previousArchive;
411
415
  for (let i = 0; i < numBlocks; i++) {
412
416
  const blockNumber = BlockNumber(startBlockNumber + i);
413
417
  const { block, messages } = {
@@ -418,9 +422,12 @@ export async function mockCheckpointAndMessages(
418
422
  slotNumber,
419
423
  ...options,
420
424
  ...makeBlockOptions(blockNumber),
425
+ ...(lastArchive ? { lastArchive } : {}),
421
426
  }),
422
427
  messages: mockL1ToL2Messages(numL1ToL2Messages),
423
428
  };
429
+ // Update lastArchive for the next block
430
+ lastArchive = block.archive;
424
431
  blocksAndMessages.push({ block, messages });
425
432
  }
426
433
 
@@ -428,8 +435,13 @@ export async function mockCheckpointAndMessages(
428
435
  const inHash = computeInHashFromL1ToL2Messages(messages);
429
436
  const checkpoint = await Checkpoint.random(checkpointNumber, { numBlocks: 0, slotNumber, inHash, ...options });
430
437
  checkpoint.blocks = blocksAndMessages.map(({ block }) => block);
438
+ // Set the checkpoint's archive to match the last block's archive for proper chaining.
439
+ // When the archiver reconstructs checkpoints from L1, it uses the checkpoint's archive root
440
+ // from the L1 event to set the last block's archive. Without this, the archive chain breaks.
441
+ checkpoint.archive = lastArchive!;
431
442
 
432
- return { checkpoint, messages };
443
+ // Return lastArchive so callers can chain it across multiple checkpoints
444
+ return { checkpoint, messages, lastArchive };
433
445
  }
434
446
 
435
447
  export const randomContractArtifact = (): ContractArtifact => ({
@@ -139,7 +139,7 @@ export class PrivateCallExecutionResult {
139
139
  public returnValues: Fr[],
140
140
  /** The offchain effects emitted during execution of this function call via the `emit_offchain_effect` oracle. */
141
141
  public offchainEffects: { data: Fr[] }[],
142
- /** The pre tags used in this tx to compute tags for private logs */
142
+ /** The pre-tags used in this tx to compute tags for private logs */
143
143
  public preTags: PreTag[],
144
144
  /** The nested executions. */
145
145
  public nestedExecutionResults: PrivateCallExecutionResult[],
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- import type { ZodFor } from '../../schemas/schemas.js';
3
+ import { zodFor } from '../../schemas/schemas.js';
4
4
  import type { ProcessedTx } from '../processed_tx.js';
5
5
  import type { Tx } from '../tx.js';
6
6
  import type { TxHash } from '../tx_hash.js';
@@ -24,8 +24,10 @@ export interface TxValidator<T extends AnyTx = AnyTx> {
24
24
  validateTx(tx: T): Promise<TxValidationResult>;
25
25
  }
26
26
 
27
- export const TxValidationResultSchema = z.discriminatedUnion('result', [
28
- z.object({ result: z.literal('valid'), reason: z.array(z.string()).optional() }),
29
- z.object({ result: z.literal('invalid'), reason: z.array(z.string()) }),
30
- z.object({ result: z.literal('skipped'), reason: z.array(z.string()) }),
31
- ]) satisfies ZodFor<TxValidationResult>;
27
+ export const TxValidationResultSchema = zodFor<TxValidationResult>()(
28
+ z.discriminatedUnion('result', [
29
+ z.object({ result: z.literal('valid') }),
30
+ z.object({ result: z.literal('invalid'), reason: z.array(z.string()) }),
31
+ z.object({ result: z.literal('skipped'), reason: z.array(z.string()) }),
32
+ ]),
33
+ );
@@ -1,4 +1,4 @@
1
- import { type ZodFor, schemas } from '@aztec/foundation/schemas';
1
+ import { schemas, zodFor } from '@aztec/foundation/schemas';
2
2
 
3
3
  import { z } from 'zod';
4
4
 
@@ -11,20 +11,18 @@ import type {
11
11
  ValidatorsStats,
12
12
  } from './types.js';
13
13
 
14
- export const ValidatorStatusInSlotSchema = z.enum([
15
- 'block-mined',
16
- 'block-proposed',
17
- 'block-missed',
18
- 'attestation-sent',
19
- 'attestation-missed',
20
- ]) satisfies ZodFor<ValidatorStatusInSlot>;
14
+ export const ValidatorStatusInSlotSchema = zodFor<ValidatorStatusInSlot>()(
15
+ z.enum(['block-mined', 'block-proposed', 'block-missed', 'attestation-sent', 'attestation-missed']),
16
+ );
21
17
 
22
- export const ValidatorStatusHistorySchema = z.array(
23
- z.object({
24
- slot: schemas.SlotNumber,
25
- status: ValidatorStatusInSlotSchema,
26
- }),
27
- ) satisfies ZodFor<ValidatorStatusHistory>;
18
+ export const ValidatorStatusHistorySchema = zodFor<ValidatorStatusHistory>()(
19
+ z.array(
20
+ z.object({
21
+ slot: schemas.SlotNumber,
22
+ status: ValidatorStatusInSlotSchema,
23
+ }),
24
+ ),
25
+ );
28
26
 
29
27
  export const ValidatorStatusHistorySchemaArray = z.array(ValidatorStatusHistorySchema);
30
28
 
@@ -36,40 +34,48 @@ const ValidatorTimeStatSchema = z.object({
36
34
  date: z.string(),
37
35
  });
38
36
 
39
- const ValidatorMissedStatsSchema = z.object({
40
- currentStreak: schemas.Integer,
41
- rate: z.number().optional(),
42
- count: schemas.Integer,
43
- total: schemas.Integer,
44
- }) satisfies ZodFor<ValidatorMissedStats>;
37
+ const ValidatorMissedStatsSchema = zodFor<ValidatorMissedStats>()(
38
+ z.object({
39
+ currentStreak: schemas.Integer,
40
+ rate: z.number().optional(),
41
+ count: schemas.Integer,
42
+ total: schemas.Integer,
43
+ }),
44
+ );
45
45
 
46
- export const ValidatorStatsSchema = z.object({
47
- address: schemas.EthAddress,
48
- lastProposal: ValidatorTimeStatSchema.optional(),
49
- lastAttestation: ValidatorTimeStatSchema.optional(),
50
- totalSlots: schemas.Integer,
51
- missedProposals: ValidatorMissedStatsSchema,
52
- missedAttestations: ValidatorMissedStatsSchema,
53
- history: ValidatorStatusHistorySchema,
54
- }) satisfies ZodFor<ValidatorStats>;
46
+ export const ValidatorStatsSchema = zodFor<ValidatorStats>()(
47
+ z.object({
48
+ address: schemas.EthAddress,
49
+ lastProposal: ValidatorTimeStatSchema.optional(),
50
+ lastAttestation: ValidatorTimeStatSchema.optional(),
51
+ totalSlots: schemas.Integer,
52
+ missedProposals: ValidatorMissedStatsSchema,
53
+ missedAttestations: ValidatorMissedStatsSchema,
54
+ history: ValidatorStatusHistorySchema,
55
+ }),
56
+ );
55
57
 
56
- export const ValidatorsStatsSchema = z.object({
57
- stats: z.record(ValidatorStatsSchema),
58
- lastProcessedSlot: schemas.SlotNumber.optional(),
59
- initialSlot: schemas.SlotNumber.optional(),
60
- slotWindow: schemas.Integer,
61
- }) satisfies ZodFor<ValidatorsStats>;
58
+ export const ValidatorsStatsSchema = zodFor<ValidatorsStats>()(
59
+ z.object({
60
+ stats: z.record(ValidatorStatsSchema),
61
+ lastProcessedSlot: schemas.SlotNumber.optional(),
62
+ initialSlot: schemas.SlotNumber.optional(),
63
+ slotWindow: schemas.Integer,
64
+ }),
65
+ );
62
66
 
63
- export const SingleValidatorStatsSchema = z.object({
64
- validator: ValidatorStatsSchema,
65
- allTimeProvenPerformance: z.array(
66
- z.object({
67
- missed: schemas.Integer,
68
- total: schemas.Integer,
69
- epoch: schemas.EpochNumber,
70
- }),
71
- ),
72
- lastProcessedSlot: schemas.SlotNumber.optional(),
73
- initialSlot: schemas.SlotNumber.optional(),
74
- slotWindow: schemas.Integer,
75
- }) satisfies ZodFor<SingleValidatorStats>;
67
+ export const SingleValidatorStatsSchema = zodFor<SingleValidatorStats>()(
68
+ z.object({
69
+ validator: ValidatorStatsSchema,
70
+ allTimeProvenPerformance: z.array(
71
+ z.object({
72
+ missed: schemas.Integer,
73
+ total: schemas.Integer,
74
+ epoch: schemas.EpochNumber,
75
+ }),
76
+ ),
77
+ lastProcessedSlot: schemas.SlotNumber.optional(),
78
+ initialSlot: schemas.SlotNumber.optional(),
79
+ slotWindow: schemas.Integer,
80
+ }),
81
+ );
@@ -1,130 +0,0 @@
1
- import { BufferReader } from '@aztec/foundation/serialize';
2
- import type { FieldsOf } from '@aztec/foundation/types';
3
- import { z } from 'zod';
4
- import { L1PublishedData, PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
5
- import { L2Block } from './l2_block.js';
6
- import { CommitteeAttestation } from './proposal/committee_attestation.js';
7
- /**
8
- * @deprecated `PublishedCheckpoint` is what will be retrieved from L1.
9
- * L2 blocks do not need to link to L1PublishedData directly.
10
- * TODO: Create another type (AttestedL2Block?) for an L2 block and its attestations.
11
- */
12
- export declare class PublishedL2Block {
13
- block: L2Block;
14
- l1: L1PublishedData;
15
- attestations: CommitteeAttestation[];
16
- constructor(block: L2Block, l1: L1PublishedData, attestations: CommitteeAttestation[]);
17
- static get schema(): z.ZodEffects<z.ZodObject<{
18
- block: z.ZodEffects<z.ZodObject<{
19
- archive: z.ZodEffects<z.ZodObject<{
20
- root: z.ZodType<import("../../../foundation/dest/schemas/schemas.js").Fr, any, string>;
21
- nextAvailableLeafIndex: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodNumber>;
22
- }, "strip", z.ZodTypeAny, {
23
- root: import("../../../foundation/dest/schemas/schemas.js").Fr;
24
- nextAvailableLeafIndex: number;
25
- }, {
26
- root: string;
27
- nextAvailableLeafIndex: string | number | bigint;
28
- }>, import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot, {
29
- root: string;
30
- nextAvailableLeafIndex: string | number | bigint;
31
- }>;
32
- header: import("../schemas/schemas.js").ZodFor<import("./l2_block_header.js").L2BlockHeader>;
33
- body: import("../schemas/schemas.js").ZodFor<import("./body.js").Body>;
34
- }, "strip", z.ZodTypeAny, {
35
- archive: import("../trees/append_only_tree_snapshot.js").AppendOnlyTreeSnapshot;
36
- header: import("./l2_block_header.js").L2BlockHeader;
37
- body: import("./body.js").Body;
38
- }, {
39
- archive: {
40
- root: string;
41
- nextAvailableLeafIndex: string | number | bigint;
42
- };
43
- header?: any;
44
- body?: any;
45
- }>, L2Block, {
46
- archive: {
47
- root: string;
48
- nextAvailableLeafIndex: string | number | bigint;
49
- };
50
- header?: any;
51
- body?: any;
52
- }>;
53
- l1: z.ZodObject<{
54
- blockNumber: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
55
- timestamp: z.ZodPipeline<z.ZodUnion<[z.ZodBigInt, z.ZodNumber, z.ZodString]>, z.ZodBigInt>;
56
- blockHash: z.ZodString;
57
- }, "strip", z.ZodTypeAny, {
58
- blockNumber: bigint;
59
- timestamp: bigint;
60
- blockHash: string;
61
- }, {
62
- blockNumber: string | number | bigint;
63
- timestamp: string | number | bigint;
64
- blockHash: string;
65
- }>;
66
- attestations: z.ZodArray<z.ZodEffects<z.ZodObject<{
67
- address: z.ZodType<import("./proposal/committee_attestation.js").EthAddress, any, string>;
68
- signature: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, `0x${string}`, string>, `0x${string}`, string>, import("./proposal/committee_attestation.js").Signature, string>;
69
- }, "strip", z.ZodTypeAny, {
70
- address: import("./proposal/committee_attestation.js").EthAddress;
71
- signature: import("./proposal/committee_attestation.js").Signature;
72
- }, {
73
- address: string;
74
- signature: string;
75
- }>, CommitteeAttestation, {
76
- address: string;
77
- signature: string;
78
- }>, "many">;
79
- }, "strip", z.ZodTypeAny, {
80
- block: L2Block;
81
- l1: {
82
- blockNumber: bigint;
83
- timestamp: bigint;
84
- blockHash: string;
85
- };
86
- attestations: CommitteeAttestation[];
87
- }, {
88
- block: {
89
- archive: {
90
- root: string;
91
- nextAvailableLeafIndex: string | number | bigint;
92
- };
93
- header?: any;
94
- body?: any;
95
- };
96
- l1: {
97
- blockNumber: string | number | bigint;
98
- timestamp: string | number | bigint;
99
- blockHash: string;
100
- };
101
- attestations: {
102
- address: string;
103
- signature: string;
104
- }[];
105
- }>, PublishedL2Block, {
106
- block: {
107
- archive: {
108
- root: string;
109
- nextAvailableLeafIndex: string | number | bigint;
110
- };
111
- header?: any;
112
- body?: any;
113
- };
114
- l1: {
115
- blockNumber: string | number | bigint;
116
- timestamp: string | number | bigint;
117
- blockHash: string;
118
- };
119
- attestations: {
120
- address: string;
121
- signature: string;
122
- }[];
123
- }>;
124
- static fromBuffer(bufferOrReader: Buffer | BufferReader): PublishedL2Block;
125
- static fromFields(fields: FieldsOf<PublishedL2Block>): PublishedL2Block;
126
- toBuffer(): Buffer;
127
- toPublishedCheckpoint(): PublishedCheckpoint;
128
- static fromPublishedCheckpoint(checkpoint: PublishedCheckpoint): PublishedL2Block;
129
- }
130
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGlzaGVkX2wyX2Jsb2NrLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYmxvY2svcHVibGlzaGVkX2wyX2Jsb2NrLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUNBLE9BQU8sRUFBRSxZQUFZLEVBQXF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