@aztec/stdlib 3.0.0-nightly.20251214 → 3.0.0-nightly.20251217
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 +19 -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/logs/extended_public_log.d.ts +7 -1
- package/dest/logs/extended_public_log.d.ts.map +1 -1
- package/dest/logs/log_id.d.ts +9 -1
- package/dest/logs/log_id.d.ts.map +1 -1
- package/dest/logs/log_id.js +15 -8
- package/dest/logs/tx_scoped_l2_log.d.ts +8 -2
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +13 -6
- 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/logs/log_id.ts +16 -6
- package/src/logs/tx_scoped_l2_log.ts +14 -6
- 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/logs/log_id.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { BufferReader } from '@aztec/foundation/serialize';
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
|
|
8
|
+
import { L2BlockHash } from '../block/block_hash.js';
|
|
8
9
|
import { schemas } from '../schemas/index.js';
|
|
9
10
|
|
|
10
11
|
/** A globally unique log id. */
|
|
@@ -18,6 +19,8 @@ export class LogId {
|
|
|
18
19
|
constructor(
|
|
19
20
|
/** The block number the log was emitted in. */
|
|
20
21
|
public readonly blockNumber: BlockNumber,
|
|
22
|
+
/** The hash of the block the log was emitted in. */
|
|
23
|
+
public readonly blockHash: L2BlockHash,
|
|
21
24
|
/** The index of a tx in a block the log was emitted in. */
|
|
22
25
|
public readonly txIndex: number,
|
|
23
26
|
/** The index of a log the tx was emitted in. */
|
|
@@ -37,6 +40,7 @@ export class LogId {
|
|
|
37
40
|
static random() {
|
|
38
41
|
return new LogId(
|
|
39
42
|
BlockNumber(Math.floor(Math.random() * 1000) + 1),
|
|
43
|
+
L2BlockHash.random(),
|
|
40
44
|
Math.floor(Math.random() * 1000),
|
|
41
45
|
Math.floor(Math.random() * 100),
|
|
42
46
|
);
|
|
@@ -46,10 +50,13 @@ export class LogId {
|
|
|
46
50
|
return z
|
|
47
51
|
.object({
|
|
48
52
|
blockNumber: BlockNumberSchema,
|
|
53
|
+
blockHash: L2BlockHash.schema,
|
|
49
54
|
txIndex: schemas.Integer,
|
|
50
55
|
logIndex: schemas.Integer,
|
|
51
56
|
})
|
|
52
|
-
.transform(
|
|
57
|
+
.transform(
|
|
58
|
+
({ blockNumber, blockHash, txIndex, logIndex }) => new LogId(blockNumber, blockHash, txIndex, logIndex),
|
|
59
|
+
);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
/**
|
|
@@ -59,6 +66,7 @@ export class LogId {
|
|
|
59
66
|
public toBuffer(): Buffer {
|
|
60
67
|
return Buffer.concat([
|
|
61
68
|
toBufferBE(BigInt(this.blockNumber), 4),
|
|
69
|
+
this.blockHash.toBuffer(),
|
|
62
70
|
toBufferBE(BigInt(this.txIndex), 4),
|
|
63
71
|
toBufferBE(BigInt(this.logIndex), 4),
|
|
64
72
|
]);
|
|
@@ -73,10 +81,11 @@ export class LogId {
|
|
|
73
81
|
const reader = BufferReader.asReader(buffer);
|
|
74
82
|
|
|
75
83
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
84
|
+
const blockHash = reader.readObject(L2BlockHash);
|
|
76
85
|
const txIndex = reader.readNumber();
|
|
77
86
|
const logIndex = reader.readNumber();
|
|
78
87
|
|
|
79
|
-
return new LogId(blockNumber, txIndex, logIndex);
|
|
88
|
+
return new LogId(blockNumber, blockHash, txIndex, logIndex);
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
/**
|
|
@@ -84,7 +93,7 @@ export class LogId {
|
|
|
84
93
|
* @returns A string representation of the log id.
|
|
85
94
|
*/
|
|
86
95
|
public toString(): string {
|
|
87
|
-
return `${this.blockNumber}-${this.txIndex}-${this.logIndex}`;
|
|
96
|
+
return `${this.blockNumber}-${this.txIndex}-${this.logIndex}-${this.blockHash.toString()}`;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
/**
|
|
@@ -93,12 +102,13 @@ export class LogId {
|
|
|
93
102
|
* @returns A log id.
|
|
94
103
|
*/
|
|
95
104
|
static fromString(data: string): LogId {
|
|
96
|
-
const [rawBlockNumber, rawTxIndex, rawLogIndex] = data.split('-');
|
|
105
|
+
const [rawBlockNumber, rawTxIndex, rawLogIndex, rawBlockHash] = data.split('-');
|
|
97
106
|
const blockNumber = BlockNumber(Number(rawBlockNumber));
|
|
107
|
+
const blockHash = L2BlockHash.fromString(rawBlockHash);
|
|
98
108
|
const txIndex = Number(rawTxIndex);
|
|
99
109
|
const logIndex = Number(rawLogIndex);
|
|
100
110
|
|
|
101
|
-
return new LogId(blockNumber, txIndex, logIndex);
|
|
111
|
+
return new LogId(blockNumber, blockHash, txIndex, logIndex);
|
|
102
112
|
}
|
|
103
113
|
|
|
104
114
|
/**
|
|
@@ -106,6 +116,6 @@ export class LogId {
|
|
|
106
116
|
* @returns A human readable representation of the log id.
|
|
107
117
|
*/
|
|
108
118
|
public toHumanReadable(): string {
|
|
109
|
-
return `logId: (blockNumber: ${this.blockNumber}, txIndex: ${this.txIndex}, logIndex: ${this.logIndex})`;
|
|
119
|
+
return `logId: (blockNumber: ${this.blockNumber}, blockHash: ${this.blockHash.toString()}, txIndex: ${this.txIndex}, logIndex: ${this.logIndex})`;
|
|
110
120
|
}
|
|
111
121
|
}
|
|
@@ -3,6 +3,7 @@ import { BufferReader, boolToBuffer, numToUInt32BE } from '@aztec/foundation/ser
|
|
|
3
3
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
|
|
6
|
+
import { L2BlockHash } from '../block/block_hash.js';
|
|
6
7
|
import { TxHash } from '../tx/tx_hash.js';
|
|
7
8
|
import { PrivateLog } from './private_log.js';
|
|
8
9
|
import { PublicLog } from './public_log.js';
|
|
@@ -28,6 +29,10 @@ export class TxScopedL2Log {
|
|
|
28
29
|
* The block this log is included in
|
|
29
30
|
*/
|
|
30
31
|
public blockNumber: BlockNumber,
|
|
32
|
+
/*
|
|
33
|
+
* The block this log is included in
|
|
34
|
+
*/
|
|
35
|
+
public blockHash: L2BlockHash,
|
|
31
36
|
/*
|
|
32
37
|
* The log data as either a PrivateLog or PublicLog
|
|
33
38
|
*/
|
|
@@ -45,22 +50,23 @@ export class TxScopedL2Log {
|
|
|
45
50
|
dataStartIndexForTx: z.number(),
|
|
46
51
|
logIndexInTx: z.number(),
|
|
47
52
|
blockNumber: BlockNumberSchema,
|
|
53
|
+
blockHash: L2BlockHash.schema,
|
|
48
54
|
log: z.union([PrivateLog.schema, PublicLog.schema]),
|
|
49
55
|
})
|
|
50
56
|
.transform(
|
|
51
|
-
({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, log }) =>
|
|
52
|
-
new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, log),
|
|
57
|
+
({ txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log }) =>
|
|
58
|
+
new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log),
|
|
53
59
|
);
|
|
54
60
|
}
|
|
55
61
|
|
|
56
62
|
toBuffer() {
|
|
57
|
-
const isFromPublic = this.log instanceof PublicLog;
|
|
58
63
|
return Buffer.concat([
|
|
59
64
|
this.txHash.toBuffer(),
|
|
60
65
|
numToUInt32BE(this.dataStartIndexForTx),
|
|
61
66
|
numToUInt32BE(this.logIndexInTx),
|
|
62
67
|
numToUInt32BE(this.blockNumber),
|
|
63
|
-
|
|
68
|
+
this.blockHash.toBuffer(),
|
|
69
|
+
boolToBuffer(this.isFromPublic),
|
|
64
70
|
this.log.toBuffer(),
|
|
65
71
|
]);
|
|
66
72
|
}
|
|
@@ -71,15 +77,16 @@ export class TxScopedL2Log {
|
|
|
71
77
|
const dataStartIndexForTx = reader.readNumber();
|
|
72
78
|
const logIndexInTx = reader.readNumber();
|
|
73
79
|
const blockNumber = BlockNumber(reader.readNumber());
|
|
80
|
+
const blockHash = reader.readObject(L2BlockHash);
|
|
74
81
|
const isFromPublic = reader.readBoolean();
|
|
75
82
|
const log = isFromPublic ? PublicLog.fromBuffer(reader) : PrivateLog.fromBuffer(reader);
|
|
76
83
|
|
|
77
|
-
return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, log);
|
|
84
|
+
return new TxScopedL2Log(txHash, dataStartIndexForTx, logIndexInTx, blockNumber, blockHash, log);
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
static async random(isFromPublic = Math.random() < 0.5) {
|
|
81
88
|
const log = isFromPublic ? await PublicLog.random() : PrivateLog.random();
|
|
82
|
-
return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), log);
|
|
89
|
+
return new TxScopedL2Log(TxHash.random(), 1, 1, BlockNumber(1), L2BlockHash.random(), log);
|
|
83
90
|
}
|
|
84
91
|
|
|
85
92
|
equals(other: TxScopedL2Log) {
|
|
@@ -88,6 +95,7 @@ export class TxScopedL2Log {
|
|
|
88
95
|
this.dataStartIndexForTx === other.dataStartIndexForTx &&
|
|
89
96
|
this.logIndexInTx === other.logIndexInTx &&
|
|
90
97
|
this.blockNumber === other.blockNumber &&
|
|
98
|
+
this.blockHash.equals(other.blockHash) &&
|
|
91
99
|
((this.log instanceof PublicLog && other.log instanceof PublicLog) ||
|
|
92
100
|
(this.log instanceof PrivateLog && other.log instanceof PrivateLog)) &&
|
|
93
101
|
this.log.equals(other.log as any)
|
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
|
+
);
|