@aztec/stdlib 5.0.0-nightly.20260305 → 5.0.0-nightly.20260307
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/decoder.d.ts +2 -2
- package/dest/abi/decoder.d.ts.map +1 -1
- package/dest/abi/decoder.js +6 -1
- package/dest/abi/encoder.d.ts +1 -1
- package/dest/abi/encoder.d.ts.map +1 -1
- package/dest/abi/encoder.js +28 -1
- package/dest/abi/event_metadata_definition.d.ts +3 -1
- package/dest/abi/event_metadata_definition.d.ts.map +1 -1
- package/dest/abi/event_metadata_definition.js +1 -1
- package/dest/abi/utils.d.ts +14 -1
- package/dest/abi/utils.d.ts.map +1 -1
- package/dest/abi/utils.js +15 -0
- package/dest/block/l2_block.d.ts +9 -1
- package/dest/block/l2_block.d.ts.map +1 -1
- package/dest/block/l2_block.js +12 -2
- package/dest/block/l2_block_source.d.ts +6 -1
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.d.ts +2 -1
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +9 -4
- package/dest/checkpoint/index.d.ts +2 -1
- package/dest/checkpoint/index.d.ts.map +1 -1
- package/dest/checkpoint/index.js +1 -0
- package/dest/checkpoint/validate.d.ts +36 -0
- package/dest/checkpoint/validate.d.ts.map +1 -0
- package/dest/checkpoint/validate.js +120 -0
- package/dest/config/sequencer-config.d.ts +2 -2
- package/dest/config/sequencer-config.d.ts.map +1 -1
- package/dest/config/sequencer-config.js +1 -2
- package/dest/ha-signing/config.d.ts +49 -14
- package/dest/ha-signing/config.d.ts.map +1 -1
- package/dest/ha-signing/config.js +20 -15
- package/dest/ha-signing/index.d.ts +3 -2
- package/dest/ha-signing/index.d.ts.map +1 -1
- package/dest/ha-signing/index.js +2 -1
- package/dest/ha-signing/local_config.d.ts +63 -0
- package/dest/ha-signing/local_config.d.ts.map +1 -0
- package/dest/ha-signing/local_config.js +24 -0
- package/dest/interfaces/allowed_element.d.ts +25 -1
- package/dest/interfaces/allowed_element.d.ts.map +1 -1
- package/dest/interfaces/allowed_element.js +8 -2
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +1 -0
- package/dest/interfaces/aztec-node-admin.d.ts +64 -10
- package/dest/interfaces/aztec-node-admin.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.d.ts +10 -5
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +3 -2
- package/dest/interfaces/block-builder.d.ts +11 -5
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/block-builder.js +6 -1
- package/dest/interfaces/configs.d.ts +42 -7
- package/dest/interfaces/configs.d.ts.map +1 -1
- package/dest/interfaces/configs.js +2 -1
- package/dest/interfaces/validator.d.ts +100 -21
- package/dest/interfaces/validator.d.ts.map +1 -1
- package/dest/interfaces/validator.js +7 -4
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts +2 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.d.ts.map +1 -1
- package/dest/kernel/private_kernel_tail_circuit_public_inputs.js +4 -0
- package/dest/kv-store/config.d.ts +17 -0
- package/dest/kv-store/config.d.ts.map +1 -0
- package/dest/kv-store/config.js +26 -0
- package/dest/kv-store/index.d.ts +2 -0
- package/dest/kv-store/index.d.ts.map +1 -0
- package/dest/kv-store/index.js +1 -0
- package/dest/logs/public_log.d.ts +4 -3
- package/dest/logs/public_log.d.ts.map +1 -1
- package/dest/logs/public_log.js +2 -1
- package/dest/p2p/checkpoint_proposal.d.ts +1 -6
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +0 -12
- package/dest/p2p/peer_error.d.ts +3 -1
- package/dest/p2p/peer_error.d.ts.map +1 -1
- package/dest/p2p/peer_error.js +5 -0
- package/dest/slashing/tally.d.ts +5 -6
- package/dest/slashing/tally.d.ts.map +1 -1
- package/dest/slashing/tally.js +19 -10
- package/dest/tests/mocks.d.ts +4 -2
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +13 -8
- package/dest/tx/block_header.d.ts +3 -1
- package/dest/tx/block_header.d.ts.map +1 -1
- package/dest/tx/block_header.js +4 -0
- package/dest/tx/simulated_tx.d.ts +5 -2
- package/dest/tx/simulated_tx.d.ts.map +1 -1
- package/dest/tx/simulated_tx.js +4 -1
- package/dest/tx/tx.d.ts +6 -5
- package/dest/tx/tx.d.ts.map +1 -1
- package/dest/tx/tx.js +18 -6
- package/dest/tx/validator/error_texts.d.ts +4 -1
- package/dest/tx/validator/error_texts.d.ts.map +1 -1
- package/dest/tx/validator/error_texts.js +3 -0
- package/dest/update-checker/index.d.ts +3 -2
- package/dest/update-checker/index.d.ts.map +1 -1
- package/dest/update-checker/index.js +2 -1
- package/dest/update-checker/package_version.d.ts +3 -0
- package/dest/update-checker/package_version.d.ts.map +1 -0
- package/dest/update-checker/package_version.js +11 -0
- package/dest/update-checker/version_checker.d.ts +25 -0
- package/dest/update-checker/version_checker.d.ts.map +1 -0
- package/dest/update-checker/version_checker.js +50 -0
- package/package.json +10 -9
- package/src/abi/decoder.ts +14 -2
- package/src/abi/encoder.ts +41 -1
- package/src/abi/event_metadata_definition.ts +2 -0
- package/src/abi/utils.ts +25 -0
- package/src/block/l2_block.ts +13 -1
- package/src/block/l2_block_source.ts +6 -0
- package/src/checkpoint/checkpoint.ts +12 -3
- package/src/checkpoint/index.ts +1 -0
- package/src/checkpoint/validate.ts +230 -0
- package/src/config/sequencer-config.ts +2 -2
- package/src/ha-signing/config.ts +45 -38
- package/src/ha-signing/index.ts +9 -0
- package/src/ha-signing/local_config.ts +46 -0
- package/src/interfaces/allowed_element.ts +28 -4
- package/src/interfaces/archiver.ts +1 -0
- package/src/interfaces/aztec-node.ts +14 -4
- package/src/interfaces/block-builder.ts +22 -5
- package/src/interfaces/configs.ts +12 -4
- package/src/interfaces/validator.ts +49 -28
- package/src/kernel/private_kernel_tail_circuit_public_inputs.ts +9 -0
- package/src/kv-store/config.ts +36 -0
- package/src/kv-store/index.ts +1 -0
- package/src/logs/public_log.ts +4 -2
- package/src/p2p/checkpoint_proposal.ts +0 -17
- package/src/p2p/peer_error.ts +7 -0
- package/src/slashing/tally.ts +22 -4
- package/src/tests/mocks.ts +18 -7
- package/src/tx/block_header.ts +6 -0
- package/src/tx/simulated_tx.ts +8 -1
- package/src/tx/tx.ts +20 -11
- package/src/tx/validator/error_texts.ts +3 -0
- package/src/update-checker/index.ts +2 -1
- package/src/update-checker/package_version.ts +17 -0
- package/src/update-checker/version_checker.ts +65 -0
- package/dest/update-checker/update-checker.d.ts +0 -49
- package/dest/update-checker/update-checker.d.ts.map +0 -1
- package/dest/update-checker/update-checker.js +0 -130
- package/src/update-checker/update-checker.ts +0 -166
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
|
|
2
|
+
import type { CheckpointNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import { sum } from '@aztec/foundation/collection';
|
|
4
|
+
|
|
5
|
+
import { MAX_BLOCKS_PER_CHECKPOINT } from '../deserialization/index.js';
|
|
6
|
+
import type { Checkpoint } from './checkpoint.js';
|
|
7
|
+
|
|
8
|
+
export class CheckpointValidationError extends Error {
|
|
9
|
+
constructor(
|
|
10
|
+
message: string,
|
|
11
|
+
public readonly checkpointNumber: CheckpointNumber,
|
|
12
|
+
public readonly slot: SlotNumber,
|
|
13
|
+
) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'CheckpointValidationError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Validates a checkpoint. Throws a CheckpointValidationError if any validation fails.
|
|
21
|
+
* - Validates structural integrity (non-empty, block count, sequential numbers, archive chaining, slot consistency)
|
|
22
|
+
* - Validates checkpoint blob field count against maxBlobFields limit
|
|
23
|
+
* - Validates total L2 gas used by checkpoint blocks against the Rollup contract mana limit
|
|
24
|
+
* - Validates total DA gas used by checkpoint blocks against MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT
|
|
25
|
+
* - Validates individual block L2 gas and DA gas against maxL2BlockGas and maxDABlockGas limits
|
|
26
|
+
*/
|
|
27
|
+
export function validateCheckpoint(
|
|
28
|
+
checkpoint: Checkpoint,
|
|
29
|
+
opts: {
|
|
30
|
+
rollupManaLimit?: number;
|
|
31
|
+
maxL2BlockGas?: number;
|
|
32
|
+
maxDABlockGas?: number;
|
|
33
|
+
maxTxsPerCheckpoint?: number;
|
|
34
|
+
maxTxsPerBlock?: number;
|
|
35
|
+
},
|
|
36
|
+
): void {
|
|
37
|
+
validateCheckpointStructure(checkpoint);
|
|
38
|
+
validateCheckpointLimits(checkpoint, opts);
|
|
39
|
+
validateCheckpointBlocksGasLimits(checkpoint, opts);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Validates structural integrity of a checkpoint.
|
|
44
|
+
* - Non-empty block list
|
|
45
|
+
* - Block count within MAX_BLOCKS_PER_CHECKPOINT
|
|
46
|
+
* - Checkpoint slot matches the first block's slot
|
|
47
|
+
* - Checkpoint lastArchiveRoot matches the first block's lastArchive root
|
|
48
|
+
* - Sequential block numbers without gaps
|
|
49
|
+
* - Sequential indexWithinCheckpoint starting at 0
|
|
50
|
+
* - Archive root chaining between consecutive blocks
|
|
51
|
+
* - Consistent slot number across all blocks
|
|
52
|
+
* - Global variables (slot, timestamp, coinbase, feeRecipient, gasFees) match checkpoint header for each block
|
|
53
|
+
*/
|
|
54
|
+
export function validateCheckpointStructure(checkpoint: Checkpoint): void {
|
|
55
|
+
const { blocks, number, slot } = checkpoint;
|
|
56
|
+
|
|
57
|
+
if (blocks.length === 0) {
|
|
58
|
+
throw new CheckpointValidationError('Checkpoint has no blocks', number, slot);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (blocks.length > MAX_BLOCKS_PER_CHECKPOINT) {
|
|
62
|
+
throw new CheckpointValidationError(
|
|
63
|
+
`Checkpoint has ${blocks.length} blocks, exceeding limit of ${MAX_BLOCKS_PER_CHECKPOINT}`,
|
|
64
|
+
number,
|
|
65
|
+
slot,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const firstBlock = blocks[0];
|
|
70
|
+
|
|
71
|
+
if (!checkpoint.header.lastArchiveRoot.equals(firstBlock.header.lastArchive.root)) {
|
|
72
|
+
throw new CheckpointValidationError(
|
|
73
|
+
`Checkpoint lastArchiveRoot does not match first block's lastArchive root`,
|
|
74
|
+
number,
|
|
75
|
+
slot,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
80
|
+
const block = blocks[i];
|
|
81
|
+
|
|
82
|
+
if (block.indexWithinCheckpoint !== i) {
|
|
83
|
+
throw new CheckpointValidationError(
|
|
84
|
+
`Block at index ${i} has indexWithinCheckpoint ${block.indexWithinCheckpoint}, expected ${i}`,
|
|
85
|
+
number,
|
|
86
|
+
slot,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (block.slot !== slot) {
|
|
91
|
+
throw new CheckpointValidationError(
|
|
92
|
+
`Block ${block.number} has slot ${block.slot}, expected ${slot} (all blocks must share the same slot)`,
|
|
93
|
+
number,
|
|
94
|
+
slot,
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (!checkpoint.header.matchesGlobalVariables(block.header.globalVariables)) {
|
|
99
|
+
throw new CheckpointValidationError(
|
|
100
|
+
`Block ${block.number} global variables (slot, timestamp, coinbase, feeRecipient, gasFees) do not match checkpoint header`,
|
|
101
|
+
number,
|
|
102
|
+
slot,
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if (i > 0) {
|
|
107
|
+
const prev = blocks[i - 1];
|
|
108
|
+
if (block.number !== prev.number + 1) {
|
|
109
|
+
throw new CheckpointValidationError(
|
|
110
|
+
`Block numbers are not sequential: block at index ${i - 1} has number ${prev.number}, block at index ${i} has number ${block.number}`,
|
|
111
|
+
number,
|
|
112
|
+
slot,
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (!block.header.lastArchive.root.equals(prev.archive.root)) {
|
|
117
|
+
throw new CheckpointValidationError(
|
|
118
|
+
`Block ${block.number} lastArchive root does not match archive root of block ${prev.number}`,
|
|
119
|
+
number,
|
|
120
|
+
slot,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Validates checkpoint blocks gas limits */
|
|
128
|
+
function validateCheckpointBlocksGasLimits(
|
|
129
|
+
checkpoint: Checkpoint,
|
|
130
|
+
opts: {
|
|
131
|
+
maxL2BlockGas?: number;
|
|
132
|
+
maxDABlockGas?: number;
|
|
133
|
+
maxTxsPerBlock?: number;
|
|
134
|
+
},
|
|
135
|
+
): void {
|
|
136
|
+
const { maxL2BlockGas, maxDABlockGas, maxTxsPerBlock } = opts;
|
|
137
|
+
|
|
138
|
+
if (maxL2BlockGas !== undefined) {
|
|
139
|
+
for (const block of checkpoint.blocks) {
|
|
140
|
+
const blockL2Gas = block.header.totalManaUsed.toNumber();
|
|
141
|
+
if (blockL2Gas > maxL2BlockGas) {
|
|
142
|
+
throw new CheckpointValidationError(
|
|
143
|
+
`Block ${block.number} in checkpoint has L2 gas used ${blockL2Gas} exceeding limit of ${maxL2BlockGas}`,
|
|
144
|
+
checkpoint.number,
|
|
145
|
+
checkpoint.slot,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (maxDABlockGas !== undefined) {
|
|
152
|
+
for (const block of checkpoint.blocks) {
|
|
153
|
+
const blockDAGas = block.computeDAGasUsed();
|
|
154
|
+
if (blockDAGas > maxDABlockGas) {
|
|
155
|
+
throw new CheckpointValidationError(
|
|
156
|
+
`Block ${block.number} in checkpoint has DA gas used ${blockDAGas} exceeding limit of ${maxDABlockGas}`,
|
|
157
|
+
checkpoint.number,
|
|
158
|
+
checkpoint.slot,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (maxTxsPerBlock !== undefined) {
|
|
165
|
+
for (const block of checkpoint.blocks) {
|
|
166
|
+
const blockTxCount = block.body.txEffects.length;
|
|
167
|
+
if (blockTxCount > maxTxsPerBlock) {
|
|
168
|
+
throw new CheckpointValidationError(
|
|
169
|
+
`Block ${block.number} in checkpoint has ${blockTxCount} txs exceeding limit of ${maxTxsPerBlock}`,
|
|
170
|
+
checkpoint.number,
|
|
171
|
+
checkpoint.slot,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/** Validates checkpoint max blob fields, gas limits, and tx limits */
|
|
179
|
+
function validateCheckpointLimits(
|
|
180
|
+
checkpoint: Checkpoint,
|
|
181
|
+
opts: {
|
|
182
|
+
rollupManaLimit?: number;
|
|
183
|
+
maxTxsPerCheckpoint?: number;
|
|
184
|
+
},
|
|
185
|
+
): void {
|
|
186
|
+
const { rollupManaLimit, maxTxsPerCheckpoint } = opts;
|
|
187
|
+
|
|
188
|
+
const maxBlobFields = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB;
|
|
189
|
+
const maxDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT;
|
|
190
|
+
|
|
191
|
+
if (rollupManaLimit !== undefined) {
|
|
192
|
+
const checkpointMana = sum(checkpoint.blocks.map(block => block.header.totalManaUsed.toNumber()));
|
|
193
|
+
if (checkpointMana > rollupManaLimit) {
|
|
194
|
+
throw new CheckpointValidationError(
|
|
195
|
+
`Checkpoint mana cost ${checkpointMana} exceeds rollup limit of ${rollupManaLimit}`,
|
|
196
|
+
checkpoint.number,
|
|
197
|
+
checkpoint.slot,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const checkpointDAGas = sum(checkpoint.blocks.map(block => block.computeDAGasUsed()));
|
|
203
|
+
if (checkpointDAGas > maxDAGas) {
|
|
204
|
+
throw new CheckpointValidationError(
|
|
205
|
+
`Checkpoint DA gas cost ${checkpointDAGas} exceeds limit of ${maxDAGas}`,
|
|
206
|
+
checkpoint.number,
|
|
207
|
+
checkpoint.slot,
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const checkpointBlobFields = checkpoint.toBlobFields().length;
|
|
212
|
+
if (checkpointBlobFields > maxBlobFields) {
|
|
213
|
+
throw new CheckpointValidationError(
|
|
214
|
+
`Checkpoint blob field count ${checkpointBlobFields} exceeds limit of ${maxBlobFields}`,
|
|
215
|
+
checkpoint.number,
|
|
216
|
+
checkpoint.slot,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (maxTxsPerCheckpoint !== undefined) {
|
|
221
|
+
const checkpointTxCount = sum(checkpoint.blocks.map(block => block.body.txEffects.length));
|
|
222
|
+
if (checkpointTxCount > maxTxsPerCheckpoint) {
|
|
223
|
+
throw new CheckpointValidationError(
|
|
224
|
+
`Checkpoint tx count ${checkpointTxCount} exceeds limit of ${maxTxsPerCheckpoint}`,
|
|
225
|
+
checkpoint.number,
|
|
226
|
+
checkpoint.slot,
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
2
2
|
|
|
3
3
|
import type { SequencerConfig } from '../interfaces/configs.js';
|
|
4
4
|
|
|
@@ -32,6 +32,6 @@ export const sharedSequencerConfigMappings: ConfigMappingsType<
|
|
|
32
32
|
maxTxsPerBlock: {
|
|
33
33
|
env: 'SEQ_MAX_TX_PER_BLOCK',
|
|
34
34
|
description: 'The maximum number of txs to include in a block.',
|
|
35
|
-
|
|
35
|
+
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
|
|
36
36
|
},
|
|
37
37
|
};
|
package/src/ha-signing/config.ts
CHANGED
|
@@ -13,14 +13,9 @@ import type { ZodFor } from '@aztec/foundation/schemas';
|
|
|
13
13
|
import { z } from 'zod';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* This config is used for distributed locking and slashing protection
|
|
19
|
-
* when running multiple validator nodes in a high-availability setup.
|
|
16
|
+
* Base signing protection configuration shared by both HA (Postgres) and local (LMDB) signers.
|
|
20
17
|
*/
|
|
21
|
-
export interface
|
|
22
|
-
/** Whether HA signing / slashing protection is enabled */
|
|
23
|
-
haSigningEnabled: boolean;
|
|
18
|
+
export interface BaseSignerConfig {
|
|
24
19
|
/** L1 contract addresses (rollup address required) */
|
|
25
20
|
l1Contracts: Pick<L1ContractAddresses, 'rollupAddress'>;
|
|
26
21
|
/** Unique identifier for this node */
|
|
@@ -33,30 +28,9 @@ export interface ValidatorHASignerConfig {
|
|
|
33
28
|
maxStuckDutiesAgeMs?: number;
|
|
34
29
|
/** Optional: clean up old duties after this many hours (disabled if not set) */
|
|
35
30
|
cleanupOldDutiesAfterHours?: number;
|
|
36
|
-
/**
|
|
37
|
-
* PostgreSQL connection string
|
|
38
|
-
* Format: postgresql://user:password@host:port/database
|
|
39
|
-
*/
|
|
40
|
-
databaseUrl?: string;
|
|
41
|
-
/**
|
|
42
|
-
* PostgreSQL connection pool configuration
|
|
43
|
-
*/
|
|
44
|
-
/** Maximum number of clients in the pool (default: 10) */
|
|
45
|
-
poolMaxCount?: number;
|
|
46
|
-
/** Minimum number of clients in the pool (default: 0) */
|
|
47
|
-
poolMinCount?: number;
|
|
48
|
-
/** Idle timeout in milliseconds (default: 10000) */
|
|
49
|
-
poolIdleTimeoutMs?: number;
|
|
50
|
-
/** Connection timeout in milliseconds (default: 0, no timeout) */
|
|
51
|
-
poolConnectionTimeoutMs?: number;
|
|
52
31
|
}
|
|
53
32
|
|
|
54
|
-
export const
|
|
55
|
-
haSigningEnabled: {
|
|
56
|
-
env: 'VALIDATOR_HA_SIGNING_ENABLED',
|
|
57
|
-
description: 'Whether HA signing / slashing protection is enabled',
|
|
58
|
-
...booleanConfigHelper(false),
|
|
59
|
-
},
|
|
33
|
+
export const baseSignerConfigMappings: ConfigMappingsType<BaseSignerConfig> = {
|
|
60
34
|
l1Contracts: {
|
|
61
35
|
description: 'L1 contract addresses (rollup address required)',
|
|
62
36
|
nested: {
|
|
@@ -91,6 +65,47 @@ export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASign
|
|
|
91
65
|
description: 'Optional: clean up old duties after this many hours (disabled if not set)',
|
|
92
66
|
...optionalNumberConfigHelper(),
|
|
93
67
|
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const BaseSignerConfigSchema = z.object({
|
|
71
|
+
l1Contracts: z.object({ rollupAddress: z.instanceof(EthAddress) }),
|
|
72
|
+
nodeId: z.string(),
|
|
73
|
+
pollingIntervalMs: z.number().min(0),
|
|
74
|
+
signingTimeoutMs: z.number().min(0),
|
|
75
|
+
maxStuckDutiesAgeMs: z.number().min(0).optional(),
|
|
76
|
+
cleanupOldDutiesAfterHours: z.number().min(0).optional(),
|
|
77
|
+
}) satisfies ZodFor<BaseSignerConfig>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Configuration for the Validator HA Signer.
|
|
81
|
+
*
|
|
82
|
+
* Extends BaseSignerConfig with a flag to enable HA mode and Postgres connection settings.
|
|
83
|
+
*/
|
|
84
|
+
export interface ValidatorHASignerConfig extends BaseSignerConfig {
|
|
85
|
+
/** Whether HA signing / slashing protection is enabled */
|
|
86
|
+
haSigningEnabled: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* PostgreSQL connection string
|
|
89
|
+
* Format: postgresql://user:password@host:port/database
|
|
90
|
+
*/
|
|
91
|
+
databaseUrl?: string;
|
|
92
|
+
/** Maximum number of clients in the pool (default: 10) */
|
|
93
|
+
poolMaxCount?: number;
|
|
94
|
+
/** Minimum number of clients in the pool (default: 0) */
|
|
95
|
+
poolMinCount?: number;
|
|
96
|
+
/** Idle timeout in milliseconds (default: 10000) */
|
|
97
|
+
poolIdleTimeoutMs?: number;
|
|
98
|
+
/** Connection timeout in milliseconds (default: 0, no timeout) */
|
|
99
|
+
poolConnectionTimeoutMs?: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const validatorHASignerConfigMappings: ConfigMappingsType<ValidatorHASignerConfig> = {
|
|
103
|
+
...baseSignerConfigMappings,
|
|
104
|
+
haSigningEnabled: {
|
|
105
|
+
env: 'VALIDATOR_HA_SIGNING_ENABLED',
|
|
106
|
+
description: 'Whether HA signing / slashing protection is enabled',
|
|
107
|
+
...booleanConfigHelper(false),
|
|
108
|
+
},
|
|
94
109
|
databaseUrl: {
|
|
95
110
|
env: 'VALIDATOR_HA_DATABASE_URL',
|
|
96
111
|
description:
|
|
@@ -131,16 +146,8 @@ export function getConfigEnvVars(): ValidatorHASignerConfig {
|
|
|
131
146
|
return getConfigFromMappings<ValidatorHASignerConfig>(validatorHASignerConfigMappings);
|
|
132
147
|
}
|
|
133
148
|
|
|
134
|
-
export const ValidatorHASignerConfigSchema =
|
|
149
|
+
export const ValidatorHASignerConfigSchema = BaseSignerConfigSchema.extend({
|
|
135
150
|
haSigningEnabled: z.boolean(),
|
|
136
|
-
l1Contracts: z.object({
|
|
137
|
-
rollupAddress: z.instanceof(EthAddress),
|
|
138
|
-
}),
|
|
139
|
-
nodeId: z.string(),
|
|
140
|
-
pollingIntervalMs: z.number().min(0),
|
|
141
|
-
signingTimeoutMs: z.number().min(0),
|
|
142
|
-
maxStuckDutiesAgeMs: z.number().min(0).optional(),
|
|
143
|
-
cleanupOldDutiesAfterHours: z.number().min(0).optional(),
|
|
144
151
|
databaseUrl: z.string().optional(),
|
|
145
152
|
poolMaxCount: z.number().min(0).optional(),
|
|
146
153
|
poolMinCount: z.number().min(0).optional(),
|
package/src/ha-signing/index.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
export {
|
|
2
|
+
type BaseSignerConfig,
|
|
3
|
+
BaseSignerConfigSchema,
|
|
4
|
+
baseSignerConfigMappings,
|
|
2
5
|
type ValidatorHASignerConfig,
|
|
3
6
|
ValidatorHASignerConfigSchema,
|
|
4
7
|
defaultValidatorHASignerConfig,
|
|
5
8
|
getConfigEnvVars,
|
|
6
9
|
validatorHASignerConfigMappings,
|
|
7
10
|
} from './config.js';
|
|
11
|
+
export {
|
|
12
|
+
type LocalSignerConfig,
|
|
13
|
+
LocalSignerConfigSchema,
|
|
14
|
+
getLocalSignerConfigEnvVars,
|
|
15
|
+
localSignerConfigMappings,
|
|
16
|
+
} from './local_config.js';
|
|
8
17
|
export {
|
|
9
18
|
DutyType,
|
|
10
19
|
type BlockProposalSigningContext,
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type ConfigMappingsType, getConfigFromMappings } from '@aztec/foundation/config';
|
|
2
|
+
import { zodFor } from '@aztec/foundation/schemas';
|
|
3
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
|
|
7
|
+
import { type BaseSignerConfig, BaseSignerConfigSchema, baseSignerConfigMappings } from './config.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for local (single-node) slashing protection.
|
|
11
|
+
*
|
|
12
|
+
* Combines the base signing protection fields (shared with HA mode) with
|
|
13
|
+
* DataStoreConfig for the local LMDB backing store, plus a per-store map-size
|
|
14
|
+
* override. Used when HA signing is disabled.
|
|
15
|
+
*/
|
|
16
|
+
export type LocalSignerConfig = BaseSignerConfig &
|
|
17
|
+
DataStoreConfig & {
|
|
18
|
+
/** Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb. */
|
|
19
|
+
signingProtectionMapSizeKb?: number;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const localSignerConfigMappings: ConfigMappingsType<LocalSignerConfig> = {
|
|
23
|
+
...baseSignerConfigMappings,
|
|
24
|
+
...dataConfigMappings,
|
|
25
|
+
signingProtectionMapSizeKb: {
|
|
26
|
+
env: 'SIGNING_PROTECTION_MAP_SIZE_KB',
|
|
27
|
+
description:
|
|
28
|
+
'Maximum size of the local signing-protection LMDB store in KB. Overwrites the general dataStoreMapSizeKb.',
|
|
29
|
+
parseEnv: (val: string | undefined) => (val ? +val : undefined),
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const LocalSignerConfigSchema = zodFor<LocalSignerConfig>()(
|
|
34
|
+
BaseSignerConfigSchema.extend({
|
|
35
|
+
dataDirectory: z.string().optional(),
|
|
36
|
+
dataStoreMapSizeKb: z.number(),
|
|
37
|
+
signingProtectionMapSizeKb: z.number().optional(),
|
|
38
|
+
}),
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Returns the local signer configuration from environment variables.
|
|
43
|
+
*/
|
|
44
|
+
export function getLocalSignerConfigEnvVars(): LocalSignerConfig {
|
|
45
|
+
return getConfigFromMappings<LocalSignerConfig>(localSignerConfigMappings);
|
|
46
|
+
}
|
|
@@ -6,14 +6,38 @@ import type { FunctionSelector } from '../abi/function_selector.js';
|
|
|
6
6
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
7
7
|
import { schemas, zodFor } from '../schemas/index.js';
|
|
8
8
|
|
|
9
|
-
type AllowedInstanceFunction = {
|
|
10
|
-
|
|
9
|
+
type AllowedInstanceFunction = {
|
|
10
|
+
address: AztecAddress;
|
|
11
|
+
selector: FunctionSelector;
|
|
12
|
+
onlySelf?: boolean;
|
|
13
|
+
rejectNullMsgSender?: boolean;
|
|
14
|
+
calldataLength?: number;
|
|
15
|
+
};
|
|
16
|
+
type AllowedClassFunction = {
|
|
17
|
+
classId: Fr;
|
|
18
|
+
selector: FunctionSelector;
|
|
19
|
+
onlySelf?: boolean;
|
|
20
|
+
rejectNullMsgSender?: boolean;
|
|
21
|
+
calldataLength?: number;
|
|
22
|
+
};
|
|
11
23
|
|
|
12
24
|
export type AllowedElement = AllowedInstanceFunction | AllowedClassFunction;
|
|
13
25
|
|
|
14
26
|
export const AllowedElementSchema = zodFor<AllowedElement>()(
|
|
15
27
|
z.union([
|
|
16
|
-
z.object({
|
|
17
|
-
|
|
28
|
+
z.object({
|
|
29
|
+
address: schemas.AztecAddress,
|
|
30
|
+
selector: schemas.FunctionSelector,
|
|
31
|
+
onlySelf: z.boolean().optional(),
|
|
32
|
+
rejectNullMsgSender: z.boolean().optional(),
|
|
33
|
+
calldataLength: z.number().optional(),
|
|
34
|
+
}),
|
|
35
|
+
z.object({
|
|
36
|
+
classId: schemas.Fr,
|
|
37
|
+
selector: schemas.FunctionSelector,
|
|
38
|
+
onlySelf: z.boolean().optional(),
|
|
39
|
+
rejectNullMsgSender: z.boolean().optional(),
|
|
40
|
+
calldataLength: z.number().optional(),
|
|
41
|
+
}),
|
|
18
42
|
]),
|
|
19
43
|
);
|
|
@@ -86,6 +86,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
86
86
|
getBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
87
87
|
getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
88
88
|
getCheckpointedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
89
|
+
getCheckpointNumber: z.function().args().returns(CheckpointNumberSchema),
|
|
89
90
|
getFinalizedL2BlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
90
91
|
getBlock: z.function().args(BlockNumberSchema).returns(L2Block.schema.optional()),
|
|
91
92
|
getBlockHeader: z
|
|
@@ -4,7 +4,9 @@ import {
|
|
|
4
4
|
BlockNumber,
|
|
5
5
|
BlockNumberPositiveSchema,
|
|
6
6
|
BlockNumberSchema,
|
|
7
|
+
CheckpointNumber,
|
|
7
8
|
CheckpointNumberPositiveSchema,
|
|
9
|
+
CheckpointNumberSchema,
|
|
8
10
|
EpochNumber,
|
|
9
11
|
EpochNumberSchema,
|
|
10
12
|
type SlotNumber,
|
|
@@ -172,14 +174,14 @@ export interface AztecNode
|
|
|
172
174
|
l1ToL2Message: Fr,
|
|
173
175
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
|
|
174
176
|
|
|
175
|
-
/** Returns the L2
|
|
176
|
-
|
|
177
|
+
/** Returns the L2 checkpoint number in which this L1 to L2 message becomes available, or undefined if not found. */
|
|
178
|
+
getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined>;
|
|
177
179
|
|
|
178
180
|
/**
|
|
179
181
|
* Returns whether an L1 to L2 message is synced by archiver.
|
|
180
182
|
* @param l1ToL2Message - The L1 to L2 message to check.
|
|
181
183
|
* @returns Whether the message is synced.
|
|
182
|
-
* @deprecated Use `
|
|
184
|
+
* @deprecated Use `getL1ToL2MessageCheckpoint` instead. This method may return true even if the message is not ready to use.
|
|
183
185
|
*/
|
|
184
186
|
isL1ToL2MessageSynced(l1ToL2Message: Fr): Promise<boolean>;
|
|
185
187
|
|
|
@@ -230,6 +232,12 @@ export interface AztecNode
|
|
|
230
232
|
*/
|
|
231
233
|
getCheckpointedBlockNumber(): Promise<BlockNumber>;
|
|
232
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Method to fetch the latest checkpoint number synchronized by the node.
|
|
237
|
+
* @returns The checkpoint number.
|
|
238
|
+
*/
|
|
239
|
+
getCheckpointNumber(): Promise<CheckpointNumber>;
|
|
240
|
+
|
|
233
241
|
/**
|
|
234
242
|
* Method to determine if the node is ready to accept transactions.
|
|
235
243
|
* @returns - Flag indicating the readiness for tx submission.
|
|
@@ -517,7 +525,7 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
517
525
|
.args(BlockParameterSchema, schemas.Fr)
|
|
518
526
|
.returns(z.tuple([schemas.BigInt, SiblingPath.schemaFor(L1_TO_L2_MSG_TREE_HEIGHT)]).optional()),
|
|
519
527
|
|
|
520
|
-
|
|
528
|
+
getL1ToL2MessageCheckpoint: z.function().args(schemas.Fr).returns(CheckpointNumberSchema.optional()),
|
|
521
529
|
|
|
522
530
|
isL1ToL2MessageSynced: z.function().args(schemas.Fr).returns(z.boolean()),
|
|
523
531
|
|
|
@@ -534,6 +542,8 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
534
542
|
|
|
535
543
|
getBlockNumber: z.function().returns(BlockNumberSchema),
|
|
536
544
|
|
|
545
|
+
getCheckpointNumber: z.function().returns(CheckpointNumberSchema),
|
|
546
|
+
|
|
537
547
|
getProvenBlockNumber: z.function().returns(BlockNumberSchema),
|
|
538
548
|
|
|
539
549
|
getCheckpointedBlockNumber: z.function().returns(BlockNumberSchema),
|
|
@@ -36,11 +36,16 @@ export interface IBlockFactory extends ProcessedTxHandler {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export interface PublicProcessorLimits {
|
|
39
|
+
/** Maximum number of txs to process. */
|
|
39
40
|
maxTransactions?: number;
|
|
40
|
-
|
|
41
|
+
/** L2 and DA gas limits. */
|
|
41
42
|
maxBlockGas?: Gas;
|
|
43
|
+
/** Maximum number of blob fields allowed. */
|
|
42
44
|
maxBlobFields?: number;
|
|
45
|
+
/** Deadline for processing the txs. Processor will stop as soon as it hits this time. */
|
|
43
46
|
deadline?: Date;
|
|
47
|
+
/** Whether this processor is building a proposal (as opposed to re-executing one). Skipping txs due to gas or blob limits is only done during proposal building. */
|
|
48
|
+
isBuildingProposal?: boolean;
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
export interface PublicProcessorValidator {
|
|
@@ -52,8 +57,17 @@ export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime'
|
|
|
52
57
|
Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
|
|
53
58
|
Pick<
|
|
54
59
|
SequencerConfig,
|
|
55
|
-
|
|
56
|
-
|
|
60
|
+
| 'txPublicSetupAllowListExtend'
|
|
61
|
+
| 'fakeProcessingDelayPerTxMs'
|
|
62
|
+
| 'fakeThrowAfterProcessingTxCount'
|
|
63
|
+
| 'maxTxsPerBlock'
|
|
64
|
+
| 'maxTxsPerCheckpoint'
|
|
65
|
+
| 'maxL2BlockGas'
|
|
66
|
+
| 'maxDABlockGas'
|
|
67
|
+
> & {
|
|
68
|
+
/** Total L2 gas (mana) allowed per checkpoint. Fetched from L1 getManaLimit(). */
|
|
69
|
+
rollupManaLimit: number;
|
|
70
|
+
};
|
|
57
71
|
|
|
58
72
|
export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[] = [
|
|
59
73
|
'l1GenesisTime',
|
|
@@ -63,6 +77,11 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
|
|
|
63
77
|
'txPublicSetupAllowListExtend',
|
|
64
78
|
'fakeProcessingDelayPerTxMs',
|
|
65
79
|
'fakeThrowAfterProcessingTxCount',
|
|
80
|
+
'maxTxsPerBlock',
|
|
81
|
+
'maxTxsPerCheckpoint',
|
|
82
|
+
'maxL2BlockGas',
|
|
83
|
+
'maxDABlockGas',
|
|
84
|
+
'rollupManaLimit',
|
|
66
85
|
] as const;
|
|
67
86
|
|
|
68
87
|
/** Thrown when no valid transactions are available to include in a block after processing, and this is not the first block in a checkpoint. */
|
|
@@ -76,12 +95,10 @@ export class NoValidTxsError extends Error {
|
|
|
76
95
|
/** Result of building a block within a checkpoint. */
|
|
77
96
|
export type BuildBlockInCheckpointResult = {
|
|
78
97
|
block: L2Block;
|
|
79
|
-
publicGas: Gas;
|
|
80
98
|
publicProcessorDuration: number;
|
|
81
99
|
numTxs: number;
|
|
82
100
|
failedTxs: FailedTx[];
|
|
83
101
|
usedTxs: Tx[];
|
|
84
|
-
usedTxBlobFields: number;
|
|
85
102
|
};
|
|
86
103
|
|
|
87
104
|
/** Interface for building blocks within a checkpoint context. */
|
|
@@ -13,6 +13,8 @@ export interface SequencerConfig {
|
|
|
13
13
|
sequencerPollingIntervalMS?: number;
|
|
14
14
|
/** The maximum number of txs to include in a block. */
|
|
15
15
|
maxTxsPerBlock?: number;
|
|
16
|
+
/** The maximum number of txs across all blocks in a checkpoint. */
|
|
17
|
+
maxTxsPerCheckpoint?: number;
|
|
16
18
|
/** The minimum number of txs to include in a block. */
|
|
17
19
|
minTxsPerBlock?: number;
|
|
18
20
|
/** The minimum number of valid txs (after execution) to include in a block. If not set, falls back to minTxsPerBlock. */
|
|
@@ -23,6 +25,8 @@ export interface SequencerConfig {
|
|
|
23
25
|
maxL2BlockGas?: number;
|
|
24
26
|
/** The maximum DA block gas. */
|
|
25
27
|
maxDABlockGas?: number;
|
|
28
|
+
/** Per-block gas budget multiplier for both L2 and DA gas. Budget = (checkpointLimit / maxBlocks) * multiplier. */
|
|
29
|
+
perBlockAllocationMultiplier?: number;
|
|
26
30
|
/** Recipient of block reward. */
|
|
27
31
|
coinbase?: EthAddress;
|
|
28
32
|
/** Address to receive fees. */
|
|
@@ -33,8 +37,6 @@ export interface SequencerConfig {
|
|
|
33
37
|
acvmBinaryPath?: string;
|
|
34
38
|
/** Additional entries to extend the default setup allow list. */
|
|
35
39
|
txPublicSetupAllowListExtend?: AllowedElement[];
|
|
36
|
-
/** Max block size */
|
|
37
|
-
maxBlockSizeInBytes?: number;
|
|
38
40
|
/** Payload address to vote for */
|
|
39
41
|
governanceProposerPayload?: EthAddress;
|
|
40
42
|
/** Whether to enforce the time table when building blocks */
|
|
@@ -85,17 +87,18 @@ export const SequencerConfigSchema = zodFor<SequencerConfig>()(
|
|
|
85
87
|
z.object({
|
|
86
88
|
sequencerPollingIntervalMS: z.number().optional(),
|
|
87
89
|
maxTxsPerBlock: z.number().optional(),
|
|
90
|
+
maxTxsPerCheckpoint: z.number().optional(),
|
|
88
91
|
minValidTxsPerBlock: z.number().optional(),
|
|
89
92
|
minTxsPerBlock: z.number().optional(),
|
|
90
93
|
maxL2BlockGas: z.number().optional(),
|
|
91
94
|
publishTxsWithProposals: z.boolean().optional(),
|
|
92
95
|
maxDABlockGas: z.number().optional(),
|
|
96
|
+
perBlockAllocationMultiplier: z.number().optional(),
|
|
93
97
|
coinbase: schemas.EthAddress.optional(),
|
|
94
98
|
feeRecipient: schemas.AztecAddress.optional(),
|
|
95
99
|
acvmWorkingDirectory: z.string().optional(),
|
|
96
100
|
acvmBinaryPath: z.string().optional(),
|
|
97
101
|
txPublicSetupAllowListExtend: z.array(AllowedElementSchema).optional(),
|
|
98
|
-
maxBlockSizeInBytes: z.number().optional(),
|
|
99
102
|
governanceProposerPayload: schemas.EthAddress.optional(),
|
|
100
103
|
l1PublishingTime: z.number().optional(),
|
|
101
104
|
enforceTimeTable: z.boolean().optional(),
|
|
@@ -134,7 +137,12 @@ type SequencerConfigOptionalKeys =
|
|
|
134
137
|
| 'l1PublishingTime'
|
|
135
138
|
| 'txPublicSetupAllowListExtend'
|
|
136
139
|
| 'minValidTxsPerBlock'
|
|
137
|
-
| 'minBlocksForCheckpoint'
|
|
140
|
+
| 'minBlocksForCheckpoint'
|
|
141
|
+
| 'maxTxsPerBlock'
|
|
142
|
+
| 'maxTxsPerCheckpoint'
|
|
143
|
+
| 'maxL2BlockGas'
|
|
144
|
+
| 'maxDABlockGas'
|
|
145
|
+
| 'perBlockAllocationMultiplier';
|
|
138
146
|
|
|
139
147
|
export type ResolvedSequencerConfig = Prettify<
|
|
140
148
|
Required<Omit<SequencerConfig, SequencerConfigOptionalKeys>> & Pick<SequencerConfig, SequencerConfigOptionalKeys>
|