@aztec/validator-client 0.0.1-commit.d3ec352c → 0.0.1-commit.d58ff9d0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +327 -0
  2. package/dest/checkpoint_builder.d.ts +81 -0
  3. package/dest/checkpoint_builder.d.ts.map +1 -0
  4. package/dest/checkpoint_builder.js +259 -0
  5. package/dest/config.d.ts +9 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +56 -14
  8. package/dest/duties/validation_service.d.ts +44 -16
  9. package/dest/duties/validation_service.d.ts.map +1 -1
  10. package/dest/duties/validation_service.js +102 -31
  11. package/dest/factory.d.ts +22 -11
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +19 -6
  14. package/dest/index.d.ts +3 -2
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +2 -1
  17. package/dest/key_store/ha_key_store.d.ts +99 -0
  18. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  19. package/dest/key_store/ha_key_store.js +208 -0
  20. package/dest/key_store/index.d.ts +2 -1
  21. package/dest/key_store/index.d.ts.map +1 -1
  22. package/dest/key_store/index.js +1 -0
  23. package/dest/key_store/interface.d.ts +36 -6
  24. package/dest/key_store/interface.d.ts.map +1 -1
  25. package/dest/key_store/local_key_store.d.ts +10 -5
  26. package/dest/key_store/local_key_store.d.ts.map +1 -1
  27. package/dest/key_store/local_key_store.js +9 -5
  28. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  29. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  30. package/dest/key_store/node_keystore_adapter.js +18 -4
  31. package/dest/key_store/web3signer_key_store.d.ts +19 -6
  32. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  33. package/dest/key_store/web3signer_key_store.js +41 -46
  34. package/dest/metrics.d.ts +16 -3
  35. package/dest/metrics.d.ts.map +1 -1
  36. package/dest/metrics.js +58 -30
  37. package/dest/proposal_handler.d.ts +165 -0
  38. package/dest/proposal_handler.d.ts.map +1 -0
  39. package/dest/proposal_handler.js +1207 -0
  40. package/dest/validator.d.ts +93 -25
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +491 -89
  43. package/package.json +21 -11
  44. package/src/checkpoint_builder.ts +426 -0
  45. package/src/config.ts +63 -15
  46. package/src/duties/validation_service.ts +168 -41
  47. package/src/factory.ts +46 -12
  48. package/src/index.ts +2 -1
  49. package/src/key_store/ha_key_store.ts +269 -0
  50. package/src/key_store/index.ts +1 -0
  51. package/src/key_store/interface.ts +44 -5
  52. package/src/key_store/local_key_store.ts +14 -5
  53. package/src/key_store/node_keystore_adapter.ts +28 -5
  54. package/src/key_store/web3signer_key_store.ts +61 -64
  55. package/src/metrics.ts +81 -33
  56. package/src/proposal_handler.ts +1314 -0
  57. package/src/validator.ts +721 -139
  58. package/dest/block_proposal_handler.d.ts +0 -53
  59. package/dest/block_proposal_handler.d.ts.map +0 -1
  60. package/dest/block_proposal_handler.js +0 -290
  61. package/src/block_proposal_handler.ts +0 -344
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/validator-client",
3
- "version": "0.0.1-commit.d3ec352c",
3
+ "version": "0.0.1-commit.d58ff9d0",
4
4
  "main": "dest/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,25 +64,35 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/constants": "0.0.1-commit.d3ec352c",
68
- "@aztec/epoch-cache": "0.0.1-commit.d3ec352c",
69
- "@aztec/ethereum": "0.0.1-commit.d3ec352c",
70
- "@aztec/foundation": "0.0.1-commit.d3ec352c",
71
- "@aztec/node-keystore": "0.0.1-commit.d3ec352c",
72
- "@aztec/p2p": "0.0.1-commit.d3ec352c",
73
- "@aztec/slasher": "0.0.1-commit.d3ec352c",
74
- "@aztec/stdlib": "0.0.1-commit.d3ec352c",
75
- "@aztec/telemetry-client": "0.0.1-commit.d3ec352c",
67
+ "@aztec/blob-client": "0.0.1-commit.d58ff9d0",
68
+ "@aztec/blob-lib": "0.0.1-commit.d58ff9d0",
69
+ "@aztec/constants": "0.0.1-commit.d58ff9d0",
70
+ "@aztec/epoch-cache": "0.0.1-commit.d58ff9d0",
71
+ "@aztec/ethereum": "0.0.1-commit.d58ff9d0",
72
+ "@aztec/foundation": "0.0.1-commit.d58ff9d0",
73
+ "@aztec/node-keystore": "0.0.1-commit.d58ff9d0",
74
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.d58ff9d0",
75
+ "@aztec/p2p": "0.0.1-commit.d58ff9d0",
76
+ "@aztec/protocol-contracts": "0.0.1-commit.d58ff9d0",
77
+ "@aztec/prover-client": "0.0.1-commit.d58ff9d0",
78
+ "@aztec/simulator": "0.0.1-commit.d58ff9d0",
79
+ "@aztec/slasher": "0.0.1-commit.d58ff9d0",
80
+ "@aztec/stdlib": "0.0.1-commit.d58ff9d0",
81
+ "@aztec/telemetry-client": "0.0.1-commit.d58ff9d0",
82
+ "@aztec/validator-ha-signer": "0.0.1-commit.d58ff9d0",
76
83
  "koa": "^2.16.1",
77
84
  "koa-router": "^13.1.1",
78
85
  "tslib": "^2.4.0",
79
86
  "viem": "npm:@aztec/viem@2.38.2"
80
87
  },
81
88
  "devDependencies": {
89
+ "@aztec/archiver": "0.0.1-commit.d58ff9d0",
90
+ "@aztec/world-state": "0.0.1-commit.d58ff9d0",
91
+ "@electric-sql/pglite": "^0.3.14",
82
92
  "@jest/globals": "^30.0.0",
83
93
  "@types/jest": "^30.0.0",
84
94
  "@types/node": "^22.15.17",
85
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
95
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
86
96
  "jest": "^30.0.0",
87
97
  "jest-mock-extended": "^4.0.0",
88
98
  "ts-node": "^10.9.1",
@@ -0,0 +1,426 @@
1
+ import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
2
+ import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
3
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
4
+ import { merge, pick, sum } from '@aztec/foundation/collection';
5
+ import { Fr } from '@aztec/foundation/curves/bn254';
6
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
7
+ import { bufferToHex } from '@aztec/foundation/string';
8
+ import { DateProvider, elapsed } from '@aztec/foundation/timer';
9
+ import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
10
+ import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
11
+ import {
12
+ type AvmSimulator,
13
+ GuardedMerkleTreeOperations,
14
+ PublicContractsDB,
15
+ PublicProcessor,
16
+ createPublicTxSimulatorForBlockBuilding,
17
+ } from '@aztec/simulator/server';
18
+ import { L2Block } from '@aztec/stdlib/block';
19
+ import { Checkpoint } from '@aztec/stdlib/checkpoint';
20
+ import type { ContractDataSource } from '@aztec/stdlib/contract';
21
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
22
+ import { Gas } from '@aztec/stdlib/gas';
23
+ import {
24
+ type BlockBuilderOptions,
25
+ type BuildBlockInCheckpointResult,
26
+ type FullNodeBlockBuilderConfig,
27
+ FullNodeBlockBuilderConfigKeys,
28
+ type ICheckpointBlockBuilder,
29
+ type ICheckpointsBuilder,
30
+ InsufficientValidTxsError,
31
+ type MerkleTreeWriteOperations,
32
+ type PublicProcessorLimits,
33
+ type WorldStateSynchronizer,
34
+ } from '@aztec/stdlib/interfaces/server';
35
+ import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
36
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
37
+ import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
38
+ import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
39
+ import { ForkCheckpoint } from '@aztec/world-state';
40
+
41
+ // Re-export for backward compatibility
42
+ export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
43
+
44
+ /**
45
+ * Builder for a single checkpoint. Handles building blocks within the checkpoint
46
+ * and completing it.
47
+ */
48
+ export class CheckpointBuilder implements ICheckpointBlockBuilder {
49
+ private log: Logger;
50
+
51
+ /** Persistent contracts DB shared across all blocks in this checkpoint. */
52
+ protected contractsDB: PublicContractsDB;
53
+
54
+ constructor(
55
+ private checkpointBuilder: LightweightCheckpointBuilder,
56
+ private fork: MerkleTreeWriteOperations,
57
+ private config: FullNodeBlockBuilderConfig,
58
+ private contractDataSource: ContractDataSource,
59
+ private dateProvider: DateProvider,
60
+ private telemetryClient: TelemetryClient,
61
+ private avmSimulator: AvmSimulator,
62
+ bindings?: LoggerBindings,
63
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
64
+ ) {
65
+ this.log = createLogger('checkpoint-builder', {
66
+ ...bindings,
67
+ instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`,
68
+ });
69
+ this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
70
+ }
71
+
72
+ getConstantData(): CheckpointGlobalVariables {
73
+ return this.checkpointBuilder.constants;
74
+ }
75
+
76
+ /**
77
+ * Builds a single block within this checkpoint.
78
+ * Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
79
+ */
80
+ async buildBlock(
81
+ pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
82
+ blockNumber: BlockNumber,
83
+ timestamp: bigint,
84
+ opts: BlockBuilderOptions & { expectedEndState?: StateReference },
85
+ ): Promise<BuildBlockInCheckpointResult> {
86
+ const slot = this.checkpointBuilder.constants.slotNumber;
87
+
88
+ this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
89
+ slot,
90
+ blockNumber,
91
+ ...opts,
92
+ currentTime: new Date(this.dateProvider.now()),
93
+ });
94
+
95
+ const constants = this.checkpointBuilder.constants;
96
+ const globalVariables = GlobalVariables.from({
97
+ chainId: constants.chainId,
98
+ version: constants.version,
99
+ blockNumber,
100
+ slotNumber: constants.slotNumber,
101
+ timestamp,
102
+ coinbase: constants.coinbase,
103
+ feeRecipient: constants.feeRecipient,
104
+ gasFees: constants.gasFees,
105
+ });
106
+ const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
107
+
108
+ // Cap gas limits amd available blob fields by remaining checkpoint-level budgets
109
+ const cappedOpts: PublicProcessorLimits & { expectedEndState?: StateReference } = {
110
+ ...opts,
111
+ ...this.capLimitsByCheckpointBudgets(opts),
112
+ };
113
+
114
+ // Create a block-level checkpoint on the contracts DB so we can roll back on failure
115
+ this.contractsDB.createCheckpoint();
116
+ // We execute all merkle tree operations on a world state fork checkpoint
117
+ // This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
118
+ const forkCheckpoint = await ForkCheckpoint.new(this.fork);
119
+
120
+ try {
121
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
122
+ processor.process(pendingTxs, cappedOpts, validator),
123
+ );
124
+
125
+ // Throw before updating state if we don't have enough valid txs
126
+ const minValidTxs = opts.minValidTxs ?? 0;
127
+ if (processedTxs.length < minValidTxs) {
128
+ throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
129
+ }
130
+
131
+ // Commit the fork checkpoint
132
+ await forkCheckpoint.commit();
133
+
134
+ // Add block to checkpoint
135
+ const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
136
+ expectedEndState: opts.expectedEndState,
137
+ });
138
+
139
+ this.contractsDB.commitCheckpoint();
140
+
141
+ this.log.debug('Built block within checkpoint', {
142
+ header: block.header.toInspect(),
143
+ processedTxs: processedTxs.map(tx => tx.hash.toString()),
144
+ failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
145
+ });
146
+
147
+ return {
148
+ block,
149
+ publicProcessorDuration,
150
+ numTxs: processedTxs.length,
151
+ failedTxs,
152
+ usedTxs,
153
+ };
154
+ } catch (err) {
155
+ // Revert all changes to contracts db
156
+ this.contractsDB.revertCheckpoint();
157
+ // If we reached the point of committing the checkpoint, this does nothing
158
+ // Otherwise it reverts any changes made to the fork for this failed block
159
+ await forkCheckpoint.revert();
160
+ throw err;
161
+ }
162
+ }
163
+
164
+ /** Completes the checkpoint and returns it. */
165
+ async completeCheckpoint(): Promise<Checkpoint> {
166
+ const checkpoint = await this.checkpointBuilder.completeCheckpoint();
167
+
168
+ this.log.verbose(`Completed checkpoint ${checkpoint.number}`, {
169
+ checkpointNumber: checkpoint.number,
170
+ numBlocks: checkpoint.blocks.length,
171
+ archiveRoot: checkpoint.archive.root.toString(),
172
+ });
173
+
174
+ return checkpoint;
175
+ }
176
+
177
+ /** Gets the checkpoint currently in progress. */
178
+ getCheckpoint(): Promise<Checkpoint> {
179
+ return this.checkpointBuilder.clone().completeCheckpoint();
180
+ }
181
+
182
+ /**
183
+ * Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
184
+ * When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
185
+ * across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
186
+ * and remaining checkpoint budget (no redistribution or multiplier).
187
+ */
188
+ protected capLimitsByCheckpointBudgets(
189
+ opts: BlockBuilderOptions,
190
+ ): Pick<PublicProcessorLimits, 'maxBlockGas' | 'maxBlobFields' | 'maxTransactions'> {
191
+ const existingBlocks = this.checkpointBuilder.getBlocks();
192
+
193
+ // Remaining L2 gas (mana)
194
+ // IMPORTANT: This assumes mana is computed solely based on L2 gas used in transactions.
195
+ // This may change in the future.
196
+ const usedMana = sum(existingBlocks.map(b => b.header.totalManaUsed.toNumber()));
197
+ const remainingMana = this.config.rollupManaLimit - usedMana;
198
+
199
+ // Remaining DA gas
200
+ const usedDAGas = sum(existingBlocks.map(b => b.computeDAGasUsed())) ?? 0;
201
+ const remainingDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT - usedDAGas;
202
+
203
+ // Remaining blob fields (block blob fields include both tx data and block-end overhead)
204
+ const usedBlobFields = sum(existingBlocks.map(b => b.toBlobFields().length));
205
+ const totalBlobCapacity = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
206
+ const isFirstBlock = existingBlocks.length === 0;
207
+ const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
208
+ const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
209
+
210
+ // Remaining txs
211
+ const usedTxs = sum(existingBlocks.map(b => b.body.txEffects.length));
212
+ const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
213
+
214
+ // Cap by per-block limit + remaining checkpoint budget
215
+ let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
216
+ let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
217
+ let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
218
+ let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
219
+
220
+ // Proposer mode: further cap by fair share of remaining budget across remaining blocks
221
+ if (opts.isBuildingProposal) {
222
+ const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
223
+ const multiplier = opts.perBlockAllocationMultiplier;
224
+ // DA gas and blob fields use a higher multiplier so the largest contract class deploy fits a block.
225
+ const daMultiplier = opts.perBlockDAAllocationMultiplier ?? multiplier;
226
+
227
+ cappedL2Gas = Math.min(cappedL2Gas, Math.ceil((remainingMana / remainingBlocks) * multiplier));
228
+ cappedDAGas = Math.min(cappedDAGas, Math.ceil((remainingDAGas / remainingBlocks) * daMultiplier));
229
+ cappedBlobFields = Math.min(cappedBlobFields, Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * daMultiplier));
230
+ cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil((remainingTxs / remainingBlocks) * multiplier));
231
+ }
232
+
233
+ return {
234
+ maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
235
+ maxBlobFields: cappedBlobFields,
236
+ maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined,
237
+ };
238
+ }
239
+
240
+ protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
241
+ const txPublicSetupAllowList = [
242
+ ...(await getDefaultAllowedSetupFunctions()),
243
+ ...(this.config.txPublicSetupAllowListExtend ?? []),
244
+ ];
245
+ const contractsDB = this.contractsDB;
246
+ const guardedFork = new GuardedMerkleTreeOperations(fork);
247
+
248
+ const bindings = this.log.getBindings();
249
+ // Extract the WSDB fork ID so the C++ AVM can modify the same fork in-place; the simulator reads
250
+ // contract data from `contractsDB`, scoped to this fork for the duration of each simulation.
251
+ const wsdbForkId = fork.getRevision().forkId;
252
+ const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
253
+ this.avmSimulator,
254
+ globalVariables,
255
+ contractsDB,
256
+ wsdbForkId,
257
+ this.telemetryClient,
258
+ bindings,
259
+ this.debugLogStore?.isEnabled ?? false,
260
+ );
261
+
262
+ const processor = new PublicProcessor(
263
+ globalVariables,
264
+ guardedFork,
265
+ contractsDB,
266
+ publicTxSimulator,
267
+ this.dateProvider,
268
+ this.telemetryClient,
269
+ createLogger('simulator:public-processor', bindings),
270
+ this.config,
271
+ this.debugLogStore,
272
+ );
273
+
274
+ const validator = createTxValidatorForBlockBuilding(
275
+ fork,
276
+ this.contractDataSource,
277
+ globalVariables,
278
+ txPublicSetupAllowList,
279
+ this.log.getBindings(),
280
+ );
281
+
282
+ return {
283
+ processor,
284
+ validator,
285
+ };
286
+ }
287
+ }
288
+
289
+ /** Factory for creating checkpoint builders. */
290
+ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
291
+ private log: Logger;
292
+
293
+ constructor(
294
+ private config: FullNodeBlockBuilderConfig & Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>,
295
+ private worldState: WorldStateSynchronizer,
296
+ private contractDataSource: ContractDataSource,
297
+ private dateProvider: DateProvider,
298
+ private avmSimulator: AvmSimulator,
299
+ private telemetryClient: TelemetryClient = getTelemetryClient(),
300
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
301
+ ) {
302
+ this.log = createLogger('checkpoint-builder');
303
+ }
304
+
305
+ public getConfig(): FullNodeBlockBuilderConfig {
306
+ return this.config;
307
+ }
308
+
309
+ public updateConfig(config: Partial<FullNodeBlockBuilderConfig>) {
310
+ this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
311
+ }
312
+
313
+ /**
314
+ * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
315
+ */
316
+ async startCheckpoint(
317
+ checkpointNumber: CheckpointNumber,
318
+ constants: CheckpointGlobalVariables,
319
+ feeAssetPriceModifier: bigint,
320
+ l1ToL2Messages: Fr[],
321
+ previousCheckpointOutHashes: Fr[],
322
+ fork: MerkleTreeWriteOperations,
323
+ bindings?: LoggerBindings,
324
+ ): Promise<CheckpointBuilder> {
325
+ const stateReference = await fork.getStateReference();
326
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
327
+
328
+ this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
329
+ checkpointNumber,
330
+ msgCount: l1ToL2Messages.length,
331
+ initialStateReference: stateReference.toInspect(),
332
+ initialArchiveRoot: bufferToHex(archiveTree.root),
333
+ constants,
334
+ feeAssetPriceModifier,
335
+ });
336
+
337
+ const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
338
+ checkpointNumber,
339
+ constants,
340
+ l1ToL2Messages,
341
+ previousCheckpointOutHashes,
342
+ fork,
343
+ bindings,
344
+ feeAssetPriceModifier,
345
+ );
346
+
347
+ return new CheckpointBuilder(
348
+ lightweightBuilder,
349
+ fork,
350
+ this.config,
351
+ this.contractDataSource,
352
+ this.dateProvider,
353
+ this.telemetryClient,
354
+ this.avmSimulator,
355
+ bindings,
356
+ this.debugLogStore,
357
+ );
358
+ }
359
+
360
+ /**
361
+ * Opens a checkpoint, either starting fresh or resuming from existing blocks.
362
+ */
363
+ async openCheckpoint(
364
+ checkpointNumber: CheckpointNumber,
365
+ constants: CheckpointGlobalVariables,
366
+ feeAssetPriceModifier: bigint,
367
+ l1ToL2Messages: Fr[],
368
+ previousCheckpointOutHashes: Fr[],
369
+ fork: MerkleTreeWriteOperations,
370
+ existingBlocks: L2Block[] = [],
371
+ bindings?: LoggerBindings,
372
+ ): Promise<CheckpointBuilder> {
373
+ const stateReference = await fork.getStateReference();
374
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
375
+
376
+ if (existingBlocks.length === 0) {
377
+ return this.startCheckpoint(
378
+ checkpointNumber,
379
+ constants,
380
+ feeAssetPriceModifier,
381
+ l1ToL2Messages,
382
+ previousCheckpointOutHashes,
383
+ fork,
384
+ bindings,
385
+ );
386
+ }
387
+
388
+ this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
389
+ checkpointNumber,
390
+ msgCount: l1ToL2Messages.length,
391
+ existingBlockCount: existingBlocks.length,
392
+ initialStateReference: stateReference.toInspect(),
393
+ initialArchiveRoot: bufferToHex(archiveTree.root),
394
+ constants,
395
+ feeAssetPriceModifier,
396
+ });
397
+
398
+ const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
399
+ checkpointNumber,
400
+ constants,
401
+ feeAssetPriceModifier,
402
+ l1ToL2Messages,
403
+ previousCheckpointOutHashes,
404
+ fork,
405
+ existingBlocks,
406
+ bindings,
407
+ );
408
+
409
+ return new CheckpointBuilder(
410
+ lightweightBuilder,
411
+ fork,
412
+ this.config,
413
+ this.contractDataSource,
414
+ this.dateProvider,
415
+ this.telemetryClient,
416
+ this.avmSimulator,
417
+ bindings,
418
+ this.debugLogStore,
419
+ );
420
+ }
421
+
422
+ /** Returns a fork of the world state at the given block number. */
423
+ getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations> {
424
+ return this.worldState.fork(blockNumber);
425
+ }
426
+ }
package/src/config.ts CHANGED
@@ -3,14 +3,27 @@ import {
3
3
  booleanConfigHelper,
4
4
  getConfigFromMappings,
5
5
  numberConfigHelper,
6
+ optionalNumberConfigHelper,
7
+ pickConfigMappings,
6
8
  secretValueConfigHelper,
7
9
  } from '@aztec/foundation/config';
8
10
  import { EthAddress } from '@aztec/foundation/eth-address';
11
+ import { type SequencerConfig, sharedSequencerConfigMappings } from '@aztec/stdlib/config';
12
+ import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec/stdlib/ha-signing';
9
13
  import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
10
14
 
11
15
  export type { ValidatorClientConfig };
12
16
 
13
- export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientConfig> = {
17
+ /**
18
+ * Default clock-disparity tolerance (ms) for proposal/attestation receive windows, mirroring the p2p config
19
+ * default. Used by the validator-client validators when the merged node config does not carry the value.
20
+ */
21
+ export const DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS = 500;
22
+
23
+ export const validatorClientConfigMappings: ConfigMappingsType<
24
+ ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>
25
+ > = {
26
+ ...pickConfigMappings(sharedSequencerConfigMappings, ['blockDurationMs']),
14
27
  validatorPrivateKeys: {
15
28
  env: 'VALIDATOR_PRIVATE_KEYS',
16
29
  description: 'List of private keys of the validators participating in attestation duties',
@@ -29,6 +42,12 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
29
42
  .map(address => EthAddress.fromString(address.trim())),
30
43
  defaultValue: [],
31
44
  },
45
+ l1ChainId: {
46
+ env: 'L1_CHAIN_ID',
47
+ description: 'The chain ID of the ethereum host.',
48
+ parseEnv: (val: string) => +val,
49
+ defaultValue: 31337,
50
+ },
32
51
  disableValidator: {
33
52
  env: 'VALIDATOR_DISABLED',
34
53
  description: 'Do not run the validator',
@@ -48,21 +67,10 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
48
67
  description: 'Interval between polling for new attestations',
49
68
  ...numberConfigHelper(200),
50
69
  },
51
- validatorReexecute: {
52
- env: 'VALIDATOR_REEXECUTE',
53
- description: 'Re-execute transactions before attesting',
54
- ...booleanConfigHelper(true),
55
- },
56
- validatorReexecuteDeadlineMs: {
57
- env: 'VALIDATOR_REEXECUTE_DEADLINE_MS',
58
- description: 'Will re-execute until this many milliseconds are left in the slot',
59
- ...numberConfigHelper(6000),
60
- },
61
70
  alwaysReexecuteBlockProposals: {
62
- env: 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS',
63
71
  description:
64
72
  'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
65
- ...booleanConfigHelper(false),
73
+ defaultValue: true,
66
74
  },
67
75
  fishermanMode: {
68
76
  env: 'FISHERMAN_MODE',
@@ -70,6 +78,44 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
70
78
  'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
71
79
  ...booleanConfigHelper(false),
72
80
  },
81
+ skipCheckpointProposalValidation: {
82
+ description: 'Skip checkpoint proposal validation and always attest (default: false)',
83
+ defaultValue: false,
84
+ },
85
+ skipPushProposedBlocksToArchiver: {
86
+ description: 'Skip pushing re-executed blocks to archiver (default: false)',
87
+ defaultValue: false,
88
+ },
89
+ attestToEquivocatedProposals: {
90
+ description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
91
+ ...booleanConfigHelper(false),
92
+ },
93
+ skipProposalSlotValidation: {
94
+ description: 'Accept proposal validation regardless of slot timing (for testing only)',
95
+ ...booleanConfigHelper(false),
96
+ },
97
+ validateMaxL2BlockGas: {
98
+ env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
99
+ description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
100
+ ...optionalNumberConfigHelper(),
101
+ },
102
+ validateMaxDABlockGas: {
103
+ env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
104
+ description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
105
+ ...optionalNumberConfigHelper(),
106
+ },
107
+ validateMaxTxsPerBlock: {
108
+ env: 'VALIDATOR_MAX_TX_PER_BLOCK',
109
+ description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
110
+ ...optionalNumberConfigHelper(),
111
+ },
112
+ validateMaxTxsPerCheckpoint: {
113
+ env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
114
+ description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
115
+ ...optionalNumberConfigHelper(),
116
+ },
117
+ ...localSignerConfigMappings,
118
+ ...validatorHASignerConfigMappings,
73
119
  };
74
120
 
75
121
  /**
@@ -77,6 +123,8 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
77
123
  * Note: If an environment variable is not set, the default value is used.
78
124
  * @returns The validator configuration.
79
125
  */
80
- export function getProverEnvVars(): ValidatorClientConfig {
81
- return getConfigFromMappings<ValidatorClientConfig>(validatorClientConfigMappings);
126
+ export function getProverEnvVars(): ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'> {
127
+ return getConfigFromMappings<ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>>(
128
+ validatorClientConfigMappings,
129
+ );
82
130
  }