@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.
- package/dest/abi/abi.d.ts +602 -4
- package/dest/abi/abi.d.ts.map +1 -1
- package/dest/abi/abi.js +7 -7
- package/dest/abi/function_selector.d.ts +2 -1
- package/dest/abi/function_selector.d.ts.map +1 -1
- package/dest/abi/function_selector.js +7 -0
- package/dest/avm/avm.js +1 -1
- package/dest/block/checkpointed_l2_block.d.ts +267 -0
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -0
- package/dest/block/{published_l2_block.js → checkpointed_l2_block.js} +40 -4
- package/dest/block/index.d.ts +2 -2
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +1 -1
- package/dest/block/l2_block_source.d.ts +62 -45
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/block/l2_block_stream/interfaces.d.ts +2 -2
- package/dest/block/l2_block_stream/interfaces.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts +6 -1
- package/dest/block/l2_block_stream/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_stream/l2_block_stream.js +9 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts +1 -1
- package/dest/block/test/l2_tips_store_test_suite.d.ts.map +1 -1
- package/dest/block/test/l2_tips_store_test_suite.js +2 -5
- package/dest/checkpoint/checkpoint.d.ts +3 -2
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +16 -4
- package/dest/checkpoint/published_checkpoint.d.ts +14 -8
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/published_checkpoint.js +11 -1
- package/dest/contract/interfaces/contract_class.d.ts +11 -13
- package/dest/contract/interfaces/contract_class.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_class.js +18 -18
- package/dest/contract/interfaces/contract_instance.d.ts +12 -13
- package/dest/contract/interfaces/contract_instance.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance.js +5 -5
- package/dest/contract/interfaces/contract_instance_update.d.ts +6 -7
- package/dest/contract/interfaces/contract_instance_update.d.ts.map +1 -1
- package/dest/contract/interfaces/contract_instance_update.js +5 -5
- package/dest/epoch-helpers/index.d.ts +1 -1
- package/dest/epoch-helpers/index.d.ts.map +1 -1
- package/dest/epoch-helpers/index.js +3 -3
- package/dest/interfaces/allowed_element.d.ts +7 -8
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +3 -3
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +2 -2
- package/dest/interfaces/aztec-node-admin.d.ts +7 -1
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +1 -1
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +1 -1
- package/dest/interfaces/configs.d.ts +13 -11
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +4 -3
- package/dest/interfaces/get_logs_response.d.ts +12 -4
- package/dest/interfaces/get_logs_response.d.ts.map +1 -1
- package/dest/interfaces/get_logs_response.js +5 -4
- package/dest/interfaces/prover-client.d.ts +5 -3
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +5 -4
- package/dest/interfaces/slasher.d.ts +1 -1
- package/dest/interfaces/slasher.d.ts.map +1 -1
- package/dest/interfaces/slasher.js +3 -3
- package/dest/interfaces/validator.d.ts +7 -8
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +5 -5
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.d.ts.map +1 -1
- package/dest/kernel/hints/find_private_kernel_reset_dimensions.js +1 -3
- package/dest/schemas/schemas.d.ts +2 -2
- package/dest/schemas/schemas.d.ts.map +1 -1
- package/dest/schemas/schemas.js +1 -1
- package/dest/slashing/types.d.ts +4 -5
- package/dest/slashing/types.d.ts.map +1 -1
- package/dest/slashing/types.js +5 -5
- package/dest/snapshots/types.d.ts +1 -1
- package/dest/snapshots/types.d.ts.map +1 -1
- package/dest/snapshots/types.js +5 -5
- package/dest/tests/mocks.d.ts +5 -4
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +18 -5
- package/dest/tx/private_execution_result.d.ts +1 -1
- package/dest/tx/private_execution_result.js +1 -1
- package/dest/tx/simulated_tx.d.ts +1031 -7
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.d.ts +1 -4
- package/dest/tx/validator/tx_validator.d.ts.map +1 -1
- package/dest/tx/validator/tx_validator.js +4 -4
- package/dest/validators/schemas.d.ts +1 -1
- package/dest/validators/schemas.d.ts.map +1 -1
- package/dest/validators/schemas.js +13 -13
- package/package.json +8 -8
- package/src/abi/abi.ts +39 -33
- package/src/abi/function_selector.ts +8 -0
- package/src/avm/avm.ts +1 -1
- package/src/block/{published_l2_block.ts → checkpointed_l2_block.ts} +58 -3
- package/src/block/index.ts +1 -1
- package/src/block/l2_block_source.ts +70 -50
- package/src/block/l2_block_stream/interfaces.ts +1 -1
- package/src/block/l2_block_stream/l2_block_stream.ts +9 -0
- package/src/block/test/l2_tips_store_test_suite.ts +2 -1
- package/src/checkpoint/checkpoint.ts +19 -4
- package/src/checkpoint/published_checkpoint.ts +19 -5
- package/src/contract/interfaces/contract_class.ts +59 -46
- package/src/contract/interfaces/contract_instance.ts +15 -13
- package/src/contract/interfaces/contract_instance_update.ts +11 -9
- package/src/epoch-helpers/index.ts +11 -9
- package/src/interfaces/allowed_element.ts +9 -7
- package/src/interfaces/archiver.ts +2 -2
- package/src/interfaces/aztec-node.ts +1 -1
- package/src/interfaces/configs.ts +30 -27
- package/src/interfaces/get_logs_response.ts +13 -9
- package/src/interfaces/prover-client.ts +13 -10
- package/src/interfaces/slasher.ts +24 -22
- package/src/interfaces/validator.ts +22 -18
- package/src/kernel/hints/find_private_kernel_reset_dimensions.ts +2 -4
- package/src/schemas/schemas.ts +1 -0
- package/src/slashing/types.ts +24 -20
- package/src/snapshots/types.ts +33 -29
- package/src/tests/mocks.ts +15 -3
- package/src/tx/private_execution_result.ts +1 -1
- package/src/tx/validator/tx_validator.ts +8 -6
- package/src/validators/schemas.ts +54 -48
- package/dest/block/published_l2_block.d.ts +0 -130
- 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 {
|
|
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 =
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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,
|
package/src/schemas/schemas.ts
CHANGED
package/src/slashing/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
2
2
|
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
import {
|
|
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 =
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
z.
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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;
|
package/src/snapshots/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
|
-
import {
|
|
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 =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
z.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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 =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
+
);
|
package/src/tests/mocks.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
28
|
-
z.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 {
|
|
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 =
|
|
15
|
-
'block-mined',
|
|
16
|
-
|
|
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 =
|
|
23
|
-
z.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
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 =
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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 =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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 =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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 =
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
z.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
//# sourceMapp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