@aztec/validator-client 0.0.1-commit.1142ef1 → 0.0.1-commit.125b3452

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 (69) hide show
  1. package/README.md +96 -24
  2. package/dest/block_proposal_handler.d.ts +12 -11
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +132 -77
  5. package/dest/checkpoint_builder.d.ts +32 -25
  6. package/dest/checkpoint_builder.d.ts.map +1 -1
  7. package/dest/checkpoint_builder.js +144 -49
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +33 -14
  11. package/dest/duties/validation_service.d.ts +20 -7
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +69 -22
  14. package/dest/factory.d.ts +2 -2
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +3 -2
  17. package/dest/index.d.ts +1 -2
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +0 -1
  20. package/dest/key_store/ha_key_store.d.ts +99 -0
  21. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  22. package/dest/key_store/ha_key_store.js +208 -0
  23. package/dest/key_store/index.d.ts +2 -1
  24. package/dest/key_store/index.d.ts.map +1 -1
  25. package/dest/key_store/index.js +1 -0
  26. package/dest/key_store/interface.d.ts +36 -6
  27. package/dest/key_store/interface.d.ts.map +1 -1
  28. package/dest/key_store/local_key_store.d.ts +10 -5
  29. package/dest/key_store/local_key_store.d.ts.map +1 -1
  30. package/dest/key_store/local_key_store.js +8 -4
  31. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  32. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  33. package/dest/key_store/node_keystore_adapter.js +18 -4
  34. package/dest/key_store/web3signer_key_store.d.ts +10 -5
  35. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  36. package/dest/key_store/web3signer_key_store.js +8 -4
  37. package/dest/metrics.d.ts +12 -3
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +46 -5
  40. package/dest/validator.d.ts +45 -18
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +263 -99
  43. package/package.json +21 -17
  44. package/src/block_proposal_handler.ts +163 -95
  45. package/src/checkpoint_builder.ts +206 -61
  46. package/src/config.ts +32 -13
  47. package/src/duties/validation_service.ts +94 -25
  48. package/src/factory.ts +2 -0
  49. package/src/index.ts +0 -1
  50. package/src/key_store/ha_key_store.ts +269 -0
  51. package/src/key_store/index.ts +1 -0
  52. package/src/key_store/interface.ts +44 -5
  53. package/src/key_store/local_key_store.ts +13 -4
  54. package/src/key_store/node_keystore_adapter.ts +27 -4
  55. package/src/key_store/web3signer_key_store.ts +17 -4
  56. package/src/metrics.ts +63 -6
  57. package/src/validator.ts +329 -118
  58. package/dest/tx_validator/index.d.ts +0 -3
  59. package/dest/tx_validator/index.d.ts.map +0 -1
  60. package/dest/tx_validator/index.js +0 -2
  61. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  62. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  63. package/dest/tx_validator/nullifier_cache.js +0 -24
  64. package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
  65. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  66. package/dest/tx_validator/tx_validator_factory.js +0 -53
  67. package/src/tx_validator/index.ts +0 -2
  68. package/src/tx_validator/nullifier_cache.ts +0 -30
  69. package/src/tx_validator/tx_validator_factory.ts +0 -133
@@ -1,10 +1,12 @@
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';
1
3
  import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
- import { merge, pick } from '@aztec/foundation/collection';
4
+ import { merge, pick, sum } from '@aztec/foundation/collection';
3
5
  import { Fr } from '@aztec/foundation/curves/bn254';
4
- import { createLogger } from '@aztec/foundation/log';
6
+ import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
5
7
  import { bufferToHex } from '@aztec/foundation/string';
6
- import { DateProvider, Timer, elapsed } from '@aztec/foundation/timer';
7
- import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
8
+ import { DateProvider, elapsed } from '@aztec/foundation/timer';
9
+ import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
8
10
  import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
9
11
  import {
10
12
  GuardedMerkleTreeOperations,
@@ -12,39 +14,38 @@ import {
12
14
  PublicProcessor,
13
15
  createPublicTxSimulatorForBlockBuilding,
14
16
  } from '@aztec/simulator/server';
15
- import { L2BlockNew } from '@aztec/stdlib/block';
17
+ import { L2Block } from '@aztec/stdlib/block';
16
18
  import { Checkpoint } from '@aztec/stdlib/checkpoint';
17
19
  import type { ContractDataSource } from '@aztec/stdlib/contract';
20
+ import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
18
21
  import { Gas } from '@aztec/stdlib/gas';
19
22
  import {
23
+ type BuildBlockInCheckpointResult,
20
24
  type FullNodeBlockBuilderConfig,
21
25
  FullNodeBlockBuilderConfigKeys,
26
+ type ICheckpointBlockBuilder,
27
+ type ICheckpointsBuilder,
28
+ InsufficientValidTxsError,
22
29
  type MerkleTreeWriteOperations,
23
30
  type PublicProcessorLimits,
31
+ type WorldStateSynchronizer,
24
32
  } from '@aztec/stdlib/interfaces/server';
33
+ import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
25
34
  import { MerkleTreeId } from '@aztec/stdlib/trees';
26
- import { type CheckpointGlobalVariables, type FailedTx, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
35
+ import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
27
36
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
37
+ import { ForkCheckpoint } from '@aztec/world-state';
28
38
 
29
- import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
30
-
31
- const log = createLogger('checkpoint-builder');
32
-
33
- export interface BuildBlockInCheckpointResult {
34
- block: L2BlockNew;
35
- publicGas: Gas;
36
- publicProcessorDuration: number;
37
- numTxs: number;
38
- failedTxs: FailedTx[];
39
- blockBuildingTimer: Timer;
40
- usedTxs: Tx[];
41
- }
39
+ // Re-export for backward compatibility
40
+ export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
42
41
 
43
42
  /**
44
43
  * Builder for a single checkpoint. Handles building blocks within the checkpoint
45
44
  * and completing it.
46
45
  */
47
- export class CheckpointBuilder {
46
+ export class CheckpointBuilder implements ICheckpointBlockBuilder {
47
+ private log: Logger;
48
+
48
49
  constructor(
49
50
  private checkpointBuilder: LightweightCheckpointBuilder,
50
51
  private fork: MerkleTreeWriteOperations,
@@ -52,7 +53,14 @@ export class CheckpointBuilder {
52
53
  private contractDataSource: ContractDataSource,
53
54
  private dateProvider: DateProvider,
54
55
  private telemetryClient: TelemetryClient,
55
- ) {}
56
+ bindings?: LoggerBindings,
57
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
58
+ ) {
59
+ this.log = createLogger('checkpoint-builder', {
60
+ ...bindings,
61
+ instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`,
62
+ });
63
+ }
56
64
 
57
65
  getConstantData(): CheckpointGlobalVariables {
58
66
  return this.checkpointBuilder.constants;
@@ -60,17 +68,22 @@ export class CheckpointBuilder {
60
68
 
61
69
  /**
62
70
  * Builds a single block within this checkpoint.
71
+ * Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
63
72
  */
64
73
  async buildBlock(
65
74
  pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
66
75
  blockNumber: BlockNumber,
67
76
  timestamp: bigint,
68
- opts: PublicProcessorLimits & { expectedEndState?: StateReference },
77
+ opts: PublicProcessorLimits & { expectedEndState?: StateReference; minValidTxs?: number } = {},
69
78
  ): Promise<BuildBlockInCheckpointResult> {
70
- const blockBuildingTimer = new Timer();
71
79
  const slot = this.checkpointBuilder.constants.slotNumber;
72
80
 
73
- log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, { slot, blockNumber, ...opts });
81
+ this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
82
+ slot,
83
+ blockNumber,
84
+ ...opts,
85
+ currentTime: new Date(this.dateProvider.now()),
86
+ });
74
87
 
75
88
  const constants = this.checkpointBuilder.constants;
76
89
  const globalVariables = GlobalVariables.from({
@@ -85,36 +98,60 @@ export class CheckpointBuilder {
85
98
  });
86
99
  const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
87
100
 
88
- const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
89
- processor.process(pendingTxs, opts, validator),
90
- );
91
-
92
- // Add block to checkpoint
93
- const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
94
- expectedEndState: opts.expectedEndState,
95
- });
96
-
97
- // How much public gas was processed
98
- const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
99
-
100
- const res = {
101
- block,
102
- publicGas,
103
- publicProcessorDuration,
104
- numTxs: processedTxs.length,
105
- failedTxs,
106
- blockBuildingTimer,
107
- usedTxs,
101
+ // Cap gas limits amd available blob fields by remaining checkpoint-level budgets
102
+ const cappedOpts: PublicProcessorLimits & { expectedEndState?: StateReference } = {
103
+ ...opts,
104
+ ...this.capLimitsByCheckpointBudgets(opts),
108
105
  };
109
- log.debug('Built block within checkpoint', res.block.header);
110
- return res;
106
+
107
+ // We execute all merkle tree operations on a world state fork checkpoint
108
+ // This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
109
+ const forkCheckpoint = await ForkCheckpoint.new(this.fork);
110
+
111
+ try {
112
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
113
+ processor.process(pendingTxs, cappedOpts, validator),
114
+ );
115
+ // Throw before updating state if we don't have enough valid txs
116
+ const minValidTxs = opts.minValidTxs ?? 0;
117
+ if (processedTxs.length < minValidTxs) {
118
+ throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
119
+ }
120
+
121
+ // Commit the fork checkpoint
122
+ await forkCheckpoint.commit();
123
+
124
+ // Add block to checkpoint
125
+ const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
126
+ expectedEndState: opts.expectedEndState,
127
+ });
128
+
129
+ this.log.debug('Built block within checkpoint', {
130
+ header: block.header.toInspect(),
131
+ processedTxs: processedTxs.map(tx => tx.hash.toString()),
132
+ failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
133
+ });
134
+
135
+ return {
136
+ block,
137
+ publicProcessorDuration,
138
+ numTxs: processedTxs.length,
139
+ failedTxs,
140
+ usedTxs,
141
+ };
142
+ } catch (err) {
143
+ // If we reached the point of committing the checkpoint, this does nothing
144
+ // Otherwise it reverts any changes made to the fork for this failed block
145
+ await forkCheckpoint.revert();
146
+ throw err;
147
+ }
111
148
  }
112
149
 
113
150
  /** Completes the checkpoint and returns it. */
114
151
  async completeCheckpoint(): Promise<Checkpoint> {
115
152
  const checkpoint = await this.checkpointBuilder.completeCheckpoint();
116
153
 
117
- log.verbose(`Completed checkpoint ${checkpoint.number}`, {
154
+ this.log.verbose(`Completed checkpoint ${checkpoint.number}`, {
118
155
  checkpointNumber: checkpoint.number,
119
156
  numBlocks: checkpoint.blocks.length,
120
157
  archiveRoot: checkpoint.archive.root.toString(),
@@ -128,16 +165,87 @@ export class CheckpointBuilder {
128
165
  return this.checkpointBuilder.clone().completeCheckpoint();
129
166
  }
130
167
 
168
+ /**
169
+ * Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
170
+ * Computes remaining L2 gas (mana), DA gas, and blob fields from blocks already added to the checkpoint,
171
+ * then returns opts with maxBlockGas and maxBlobFields capped accordingly.
172
+ */
173
+ protected capLimitsByCheckpointBudgets(
174
+ opts: PublicProcessorLimits,
175
+ ): Pick<PublicProcessorLimits, 'maxBlockGas' | 'maxBlobFields' | 'maxTransactions'> {
176
+ const existingBlocks = this.checkpointBuilder.getBlocks();
177
+
178
+ // Remaining L2 gas (mana)
179
+ // IMPORTANT: This assumes mana is computed solely based on L2 gas used in transactions.
180
+ // This may change in the future.
181
+ const usedMana = sum(existingBlocks.map(b => b.header.totalManaUsed.toNumber()));
182
+ const remainingMana = this.config.rollupManaLimit - usedMana;
183
+
184
+ // Remaining DA gas
185
+ const usedDAGas = sum(existingBlocks.map(b => b.computeDAGasUsed())) ?? 0;
186
+ const remainingDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT - usedDAGas;
187
+
188
+ // Remaining blob fields (block blob fields include both tx data and block-end overhead)
189
+ const usedBlobFields = sum(existingBlocks.map(b => b.toBlobFields().length));
190
+ const totalBlobCapacity = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
191
+ const isFirstBlock = existingBlocks.length === 0;
192
+ const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
193
+ const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
194
+
195
+ // When redistributeCheckpointBudget is enabled (default), compute a fair share of remaining budget
196
+ // across remaining blocks scaled by the multiplier, instead of letting one block consume it all.
197
+ const redistribute = this.config.redistributeCheckpointBudget !== false;
198
+ const remainingBlocks = Math.max(1, (this.config.maxBlocksPerCheckpoint ?? 1) - existingBlocks.length);
199
+ const multiplier = this.config.perBlockAllocationMultiplier ?? 1.2;
200
+
201
+ // Cap L2 gas by remaining checkpoint mana (with fair share when redistributing)
202
+ const fairShareL2 = redistribute ? Math.ceil((remainingMana / remainingBlocks) * multiplier) : Infinity;
203
+ const cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, fairShareL2, remainingMana);
204
+
205
+ // Cap DA gas by remaining checkpoint DA gas budget (with fair share when redistributing)
206
+ const fairShareDA = redistribute ? Math.ceil((remainingDAGas / remainingBlocks) * multiplier) : Infinity;
207
+ const cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? remainingDAGas, fairShareDA, remainingDAGas);
208
+
209
+ // Cap blob fields by remaining checkpoint blob capacity (with fair share when redistributing)
210
+ const fairShareBlobs = redistribute ? Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * multiplier) : Infinity;
211
+ const cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, fairShareBlobs, maxBlobFieldsForTxs);
212
+
213
+ // Cap transaction count by remaining checkpoint tx budget (with fair share when redistributing)
214
+ let cappedMaxTransactions: number | undefined;
215
+ if (this.config.maxTxsPerCheckpoint !== undefined) {
216
+ const usedTxs = sum(existingBlocks.map(b => b.body.txEffects.length));
217
+ const remainingTxs = Math.max(0, this.config.maxTxsPerCheckpoint - usedTxs);
218
+ const fairShareTxs = redistribute ? Math.ceil((remainingTxs / remainingBlocks) * multiplier) : Infinity;
219
+ cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, fairShareTxs, remainingTxs);
220
+ } else {
221
+ cappedMaxTransactions = opts.maxTransactions;
222
+ }
223
+
224
+ return {
225
+ maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
226
+ maxBlobFields: cappedBlobFields,
227
+ maxTransactions: cappedMaxTransactions,
228
+ };
229
+ }
230
+
131
231
  protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
132
- const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
133
- const contractsDB = new PublicContractsDB(this.contractDataSource);
232
+ const txPublicSetupAllowList = [
233
+ ...(await getDefaultAllowedSetupFunctions()),
234
+ ...(this.config.txPublicSetupAllowListExtend ?? []),
235
+ ];
236
+ const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
134
237
  const guardedFork = new GuardedMerkleTreeOperations(fork);
135
238
 
239
+ const collectDebugLogs = this.debugLogStore.isEnabled;
240
+
241
+ const bindings = this.log.getBindings();
136
242
  const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
137
243
  guardedFork,
138
244
  contractsDB,
139
245
  globalVariables,
140
246
  this.telemetryClient,
247
+ bindings,
248
+ collectDebugLogs,
141
249
  );
142
250
 
143
251
  const processor = new PublicProcessor(
@@ -147,15 +255,17 @@ export class CheckpointBuilder {
147
255
  publicTxSimulator,
148
256
  this.dateProvider,
149
257
  this.telemetryClient,
150
- undefined,
258
+ createLogger('simulator:public-processor', bindings),
151
259
  this.config,
260
+ this.debugLogStore,
152
261
  );
153
262
 
154
- const validator = createValidatorForBlockBuilding(
263
+ const validator = createTxValidatorForBlockBuilding(
155
264
  fork,
156
265
  this.contractDataSource,
157
266
  globalVariables,
158
267
  txPublicSetupAllowList,
268
+ this.log.getBindings(),
159
269
  );
160
270
 
161
271
  return {
@@ -165,16 +275,20 @@ export class CheckpointBuilder {
165
275
  }
166
276
  }
167
277
 
168
- /**
169
- * Factory for creating checkpoint builders.
170
- */
171
- export class FullNodeCheckpointsBuilder {
278
+ /** Factory for creating checkpoint builders. */
279
+ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
280
+ private log: Logger;
281
+
172
282
  constructor(
173
- private config: FullNodeBlockBuilderConfig,
283
+ private config: FullNodeBlockBuilderConfig & Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>,
284
+ private worldState: WorldStateSynchronizer,
174
285
  private contractDataSource: ContractDataSource,
175
286
  private dateProvider: DateProvider,
176
287
  private telemetryClient: TelemetryClient = getTelemetryClient(),
177
- ) {}
288
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
289
+ ) {
290
+ this.log = createLogger('checkpoint-builder');
291
+ }
178
292
 
179
293
  public getConfig(): FullNodeBlockBuilderConfig {
180
294
  return this.config;
@@ -190,25 +304,32 @@ export class FullNodeCheckpointsBuilder {
190
304
  async startCheckpoint(
191
305
  checkpointNumber: CheckpointNumber,
192
306
  constants: CheckpointGlobalVariables,
307
+ feeAssetPriceModifier: bigint,
193
308
  l1ToL2Messages: Fr[],
309
+ previousCheckpointOutHashes: Fr[],
194
310
  fork: MerkleTreeWriteOperations,
311
+ bindings?: LoggerBindings,
195
312
  ): Promise<CheckpointBuilder> {
196
313
  const stateReference = await fork.getStateReference();
197
314
  const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
198
315
 
199
- log.verbose(`Building new checkpoint ${checkpointNumber}`, {
316
+ this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
200
317
  checkpointNumber,
201
318
  msgCount: l1ToL2Messages.length,
202
319
  initialStateReference: stateReference.toInspect(),
203
320
  initialArchiveRoot: bufferToHex(archiveTree.root),
204
321
  constants,
322
+ feeAssetPriceModifier,
205
323
  });
206
324
 
207
325
  const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
208
326
  checkpointNumber,
209
327
  constants,
210
328
  l1ToL2Messages,
329
+ previousCheckpointOutHashes,
211
330
  fork,
331
+ bindings,
332
+ feeAssetPriceModifier,
212
333
  );
213
334
 
214
335
  return new CheckpointBuilder(
@@ -218,6 +339,8 @@ export class FullNodeCheckpointsBuilder {
218
339
  this.contractDataSource,
219
340
  this.dateProvider,
220
341
  this.telemetryClient,
342
+ bindings,
343
+ this.debugLogStore,
221
344
  );
222
345
  }
223
346
 
@@ -227,32 +350,47 @@ export class FullNodeCheckpointsBuilder {
227
350
  async openCheckpoint(
228
351
  checkpointNumber: CheckpointNumber,
229
352
  constants: CheckpointGlobalVariables,
353
+ feeAssetPriceModifier: bigint,
230
354
  l1ToL2Messages: Fr[],
355
+ previousCheckpointOutHashes: Fr[],
231
356
  fork: MerkleTreeWriteOperations,
232
- existingBlocks: L2BlockNew[] = [],
357
+ existingBlocks: L2Block[] = [],
358
+ bindings?: LoggerBindings,
233
359
  ): Promise<CheckpointBuilder> {
234
360
  const stateReference = await fork.getStateReference();
235
361
  const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
236
362
 
237
363
  if (existingBlocks.length === 0) {
238
- return this.startCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork);
364
+ return this.startCheckpoint(
365
+ checkpointNumber,
366
+ constants,
367
+ feeAssetPriceModifier,
368
+ l1ToL2Messages,
369
+ previousCheckpointOutHashes,
370
+ fork,
371
+ bindings,
372
+ );
239
373
  }
240
374
 
241
- log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
375
+ this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
242
376
  checkpointNumber,
243
377
  msgCount: l1ToL2Messages.length,
244
378
  existingBlockCount: existingBlocks.length,
245
379
  initialStateReference: stateReference.toInspect(),
246
380
  initialArchiveRoot: bufferToHex(archiveTree.root),
247
381
  constants,
382
+ feeAssetPriceModifier,
248
383
  });
249
384
 
250
385
  const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
251
386
  checkpointNumber,
252
387
  constants,
388
+ feeAssetPriceModifier,
253
389
  l1ToL2Messages,
390
+ previousCheckpointOutHashes,
254
391
  fork,
255
392
  existingBlocks,
393
+ bindings,
256
394
  );
257
395
 
258
396
  return new CheckpointBuilder(
@@ -262,6 +400,13 @@ export class FullNodeCheckpointsBuilder {
262
400
  this.contractDataSource,
263
401
  this.dateProvider,
264
402
  this.telemetryClient,
403
+ bindings,
404
+ this.debugLogStore,
265
405
  );
266
406
  }
407
+
408
+ /** Returns a fork of the world state at the given block number. */
409
+ getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations> {
410
+ return this.worldState.fork(blockNumber);
411
+ }
267
412
  }
package/src/config.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  secretValueConfigHelper,
7
7
  } from '@aztec/foundation/config';
8
8
  import { EthAddress } from '@aztec/foundation/eth-address';
9
+ import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec/stdlib/ha-signing';
9
10
  import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
10
11
 
11
12
  export type { ValidatorClientConfig };
@@ -53,16 +54,10 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
53
54
  description: 'Re-execute transactions before attesting',
54
55
  ...booleanConfigHelper(true),
55
56
  },
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
57
  alwaysReexecuteBlockProposals: {
62
- env: 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS',
63
58
  description:
64
59
  'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
65
- ...booleanConfigHelper(false),
60
+ defaultValue: true,
66
61
  },
67
62
  fishermanMode: {
68
63
  env: 'FISHERMAN_MODE',
@@ -70,16 +65,40 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
70
65
  'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
71
66
  ...booleanConfigHelper(false),
72
67
  },
73
- // TODO(palla/mbps): Change default to false once checkpoint validation is stable
74
68
  skipCheckpointProposalValidation: {
75
- description: 'Skip checkpoint proposal validation and always attest (default: true)',
76
- defaultValue: true,
69
+ description: 'Skip checkpoint proposal validation and always attest (default: false)',
70
+ defaultValue: false,
77
71
  },
78
- // TODO(palla/mbps): Change default to false once block sync is stable
79
72
  skipPushProposedBlocksToArchiver: {
80
- description: 'Skip pushing re-executed blocks to archiver (default: true)',
81
- defaultValue: true,
73
+ description: 'Skip pushing re-executed blocks to archiver (default: false)',
74
+ defaultValue: false,
75
+ },
76
+ attestToEquivocatedProposals: {
77
+ description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
78
+ ...booleanConfigHelper(false),
79
+ },
80
+ validateMaxL2BlockGas: {
81
+ env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
82
+ description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
83
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
84
+ },
85
+ validateMaxDABlockGas: {
86
+ env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
87
+ description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
88
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
89
+ },
90
+ validateMaxTxsPerBlock: {
91
+ env: 'VALIDATOR_MAX_TX_PER_BLOCK',
92
+ description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
93
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
94
+ },
95
+ validateMaxTxsPerCheckpoint: {
96
+ env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
97
+ description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
98
+ parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
82
99
  },
100
+ ...localSignerConfigMappings,
101
+ ...validatorHASignerConfigMappings,
83
102
  };
84
103
 
85
104
  /**