@aztec/validator-client 0.0.1-commit.c2595eba → 0.0.1-commit.c2eed6949

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 (50) hide show
  1. package/README.md +62 -18
  2. package/dest/block_proposal_handler.d.ts +5 -4
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +130 -62
  5. package/dest/checkpoint_builder.d.ts +23 -14
  6. package/dest/checkpoint_builder.d.ts.map +1 -1
  7. package/dest/checkpoint_builder.js +125 -41
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +26 -1
  11. package/dest/duties/validation_service.d.ts +2 -2
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +6 -12
  14. package/dest/factory.d.ts +3 -1
  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 +1 -1
  21. package/dest/key_store/ha_key_store.d.ts.map +1 -1
  22. package/dest/key_store/ha_key_store.js +3 -3
  23. package/dest/metrics.d.ts +9 -1
  24. package/dest/metrics.d.ts.map +1 -1
  25. package/dest/metrics.js +12 -0
  26. package/dest/validator.d.ts +37 -10
  27. package/dest/validator.d.ts.map +1 -1
  28. package/dest/validator.js +214 -47
  29. package/package.json +19 -19
  30. package/src/block_proposal_handler.ts +157 -80
  31. package/src/checkpoint_builder.ts +145 -38
  32. package/src/config.ts +26 -1
  33. package/src/duties/validation_service.ts +12 -11
  34. package/src/factory.ts +4 -0
  35. package/src/index.ts +0 -1
  36. package/src/key_store/ha_key_store.ts +3 -3
  37. package/src/metrics.ts +18 -0
  38. package/src/validator.ts +276 -57
  39. package/dest/tx_validator/index.d.ts +0 -3
  40. package/dest/tx_validator/index.d.ts.map +0 -1
  41. package/dest/tx_validator/index.js +0 -2
  42. package/dest/tx_validator/nullifier_cache.d.ts +0 -14
  43. package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
  44. package/dest/tx_validator/nullifier_cache.js +0 -24
  45. package/dest/tx_validator/tx_validator_factory.d.ts +0 -19
  46. package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
  47. package/dest/tx_validator/tx_validator_factory.js +0 -54
  48. package/src/tx_validator/index.ts +0 -2
  49. package/src/tx_validator/nullifier_cache.ts +0 -30
  50. package/src/tx_validator/tx_validator_factory.ts +0 -154
@@ -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
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,
@@ -18,29 +20,26 @@ import type { ContractDataSource } from '@aztec/stdlib/contract';
18
20
  import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
19
21
  import { Gas } from '@aztec/stdlib/gas';
20
22
  import {
23
+ type BlockBuilderOptions,
21
24
  type BuildBlockInCheckpointResult,
22
25
  type FullNodeBlockBuilderConfig,
23
26
  FullNodeBlockBuilderConfigKeys,
24
27
  type ICheckpointBlockBuilder,
25
28
  type ICheckpointsBuilder,
29
+ InsufficientValidTxsError,
26
30
  type MerkleTreeWriteOperations,
27
31
  type PublicProcessorLimits,
28
32
  type WorldStateSynchronizer,
29
33
  } from '@aztec/stdlib/interfaces/server';
34
+ import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
30
35
  import { MerkleTreeId } from '@aztec/stdlib/trees';
31
36
  import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
32
37
  import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
33
-
34
- import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
38
+ import { ForkCheckpoint } from '@aztec/world-state';
35
39
 
36
40
  // Re-export for backward compatibility
37
41
  export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
38
42
 
39
- /** Result of building a block within a checkpoint. Extends the base interface with timer. */
40
- export interface BuildBlockInCheckpointResultWithTimer extends BuildBlockInCheckpointResult {
41
- blockBuildingTimer: Timer;
42
- }
43
-
44
43
  /**
45
44
  * Builder for a single checkpoint. Handles building blocks within the checkpoint
46
45
  * and completing it.
@@ -48,6 +47,9 @@ export interface BuildBlockInCheckpointResultWithTimer extends BuildBlockInCheck
48
47
  export class CheckpointBuilder implements ICheckpointBlockBuilder {
49
48
  private log: Logger;
50
49
 
50
+ /** Persistent contracts DB shared across all blocks in this checkpoint. */
51
+ protected contractsDB: PublicContractsDB;
52
+
51
53
  constructor(
52
54
  private checkpointBuilder: LightweightCheckpointBuilder,
53
55
  private fork: MerkleTreeWriteOperations,
@@ -56,11 +58,13 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
56
58
  private dateProvider: DateProvider,
57
59
  private telemetryClient: TelemetryClient,
58
60
  bindings?: LoggerBindings,
61
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
59
62
  ) {
60
63
  this.log = createLogger('checkpoint-builder', {
61
64
  ...bindings,
62
65
  instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`,
63
66
  });
67
+ this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
64
68
  }
65
69
 
66
70
  getConstantData(): CheckpointGlobalVariables {
@@ -69,14 +73,14 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
69
73
 
70
74
  /**
71
75
  * Builds a single block within this checkpoint.
76
+ * Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
72
77
  */
73
78
  async buildBlock(
74
79
  pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
75
80
  blockNumber: BlockNumber,
76
81
  timestamp: bigint,
77
- opts: PublicProcessorLimits & { expectedEndState?: StateReference } = {},
78
- ): Promise<BuildBlockInCheckpointResultWithTimer> {
79
- const blockBuildingTimer = new Timer();
82
+ opts: BlockBuilderOptions & { expectedEndState?: StateReference },
83
+ ): Promise<BuildBlockInCheckpointResult> {
80
84
  const slot = this.checkpointBuilder.constants.slotNumber;
81
85
 
82
86
  this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
@@ -99,30 +103,60 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
99
103
  });
100
104
  const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
101
105
 
102
- const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs, _, usedTxBlobFields]] = await elapsed(() =>
103
- processor.process(pendingTxs, opts, validator),
104
- );
106
+ // Cap gas limits amd available blob fields by remaining checkpoint-level budgets
107
+ const cappedOpts: PublicProcessorLimits & { expectedEndState?: StateReference } = {
108
+ ...opts,
109
+ ...this.capLimitsByCheckpointBudgets(opts),
110
+ };
105
111
 
106
- // Add block to checkpoint
107
- const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
108
- expectedEndState: opts.expectedEndState,
109
- });
112
+ // Create a block-level checkpoint on the contracts DB so we can roll back on failure
113
+ this.contractsDB.createCheckpoint();
114
+ // We execute all merkle tree operations on a world state fork checkpoint
115
+ // This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
116
+ const forkCheckpoint = await ForkCheckpoint.new(this.fork);
110
117
 
111
- // How much public gas was processed
112
- const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
113
-
114
- const res = {
115
- block,
116
- publicGas,
117
- publicProcessorDuration,
118
- numTxs: processedTxs.length,
119
- failedTxs,
120
- blockBuildingTimer,
121
- usedTxs,
122
- usedTxBlobFields,
123
- };
124
- this.log.debug('Built block within checkpoint', res.block.header);
125
- return res;
118
+ try {
119
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(() =>
120
+ processor.process(pendingTxs, cappedOpts, validator),
121
+ );
122
+
123
+ // Throw before updating state if we don't have enough valid txs
124
+ const minValidTxs = opts.minValidTxs ?? 0;
125
+ if (processedTxs.length < minValidTxs) {
126
+ throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
127
+ }
128
+
129
+ // Commit the fork checkpoint
130
+ await forkCheckpoint.commit();
131
+
132
+ // Add block to checkpoint
133
+ const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
134
+ expectedEndState: opts.expectedEndState,
135
+ });
136
+
137
+ this.contractsDB.commitCheckpoint();
138
+
139
+ this.log.debug('Built block within checkpoint', {
140
+ header: block.header.toInspect(),
141
+ processedTxs: processedTxs.map(tx => tx.hash.toString()),
142
+ failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
143
+ });
144
+
145
+ return {
146
+ block,
147
+ publicProcessorDuration,
148
+ numTxs: processedTxs.length,
149
+ failedTxs,
150
+ usedTxs,
151
+ };
152
+ } catch (err) {
153
+ // Revert all changes to contracts db
154
+ this.contractsDB.revertCheckpoint();
155
+ // If we reached the point of committing the checkpoint, this does nothing
156
+ // Otherwise it reverts any changes made to the fork for this failed block
157
+ await forkCheckpoint.revert();
158
+ throw err;
159
+ }
126
160
  }
127
161
 
128
162
  /** Completes the checkpoint and returns it. */
@@ -143,11 +177,72 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
143
177
  return this.checkpointBuilder.clone().completeCheckpoint();
144
178
  }
145
179
 
180
+ /**
181
+ * Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
182
+ * When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
183
+ * across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
184
+ * and remaining checkpoint budget (no redistribution or multiplier).
185
+ */
186
+ protected capLimitsByCheckpointBudgets(
187
+ opts: BlockBuilderOptions,
188
+ ): Pick<PublicProcessorLimits, 'maxBlockGas' | 'maxBlobFields' | 'maxTransactions'> {
189
+ const existingBlocks = this.checkpointBuilder.getBlocks();
190
+
191
+ // Remaining L2 gas (mana)
192
+ // IMPORTANT: This assumes mana is computed solely based on L2 gas used in transactions.
193
+ // This may change in the future.
194
+ const usedMana = sum(existingBlocks.map(b => b.header.totalManaUsed.toNumber()));
195
+ const remainingMana = this.config.rollupManaLimit - usedMana;
196
+
197
+ // Remaining DA gas
198
+ const usedDAGas = sum(existingBlocks.map(b => b.computeDAGasUsed())) ?? 0;
199
+ const remainingDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT - usedDAGas;
200
+
201
+ // Remaining blob fields (block blob fields include both tx data and block-end overhead)
202
+ const usedBlobFields = sum(existingBlocks.map(b => b.toBlobFields().length));
203
+ const totalBlobCapacity = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
204
+ const isFirstBlock = existingBlocks.length === 0;
205
+ const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
206
+ const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
207
+
208
+ // Remaining txs
209
+ const usedTxs = sum(existingBlocks.map(b => b.body.txEffects.length));
210
+ const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
211
+
212
+ // Cap by per-block limit + remaining checkpoint budget
213
+ let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
214
+ let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
215
+ let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
216
+ let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
217
+
218
+ // Proposer mode: further cap by fair share of remaining budget across remaining blocks
219
+ if (opts.isBuildingProposal) {
220
+ const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
221
+ const multiplier = opts.perBlockAllocationMultiplier;
222
+
223
+ cappedL2Gas = Math.min(cappedL2Gas, Math.ceil((remainingMana / remainingBlocks) * multiplier));
224
+ cappedDAGas = Math.min(cappedDAGas, Math.ceil((remainingDAGas / remainingBlocks) * multiplier));
225
+ cappedBlobFields = Math.min(cappedBlobFields, Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * multiplier));
226
+ cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil((remainingTxs / remainingBlocks) * multiplier));
227
+ }
228
+
229
+ return {
230
+ maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
231
+ maxBlobFields: cappedBlobFields,
232
+ maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined,
233
+ };
234
+ }
235
+
146
236
  protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
147
- const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
148
- const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
237
+ const txPublicSetupAllowList = [
238
+ ...(await getDefaultAllowedSetupFunctions()),
239
+ ...(this.config.txPublicSetupAllowListExtend ?? []),
240
+ ];
241
+ const contractsDB = this.contractsDB;
149
242
  const guardedFork = new GuardedMerkleTreeOperations(fork);
150
243
 
244
+ const collectDebugLogs = this.debugLogStore.isEnabled;
245
+
151
246
  const bindings = this.log.getBindings();
152
247
  const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
153
248
  guardedFork,
@@ -155,6 +250,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
155
250
  globalVariables,
156
251
  this.telemetryClient,
157
252
  bindings,
253
+ collectDebugLogs,
158
254
  );
159
255
 
160
256
  const processor = new PublicProcessor(
@@ -166,9 +262,10 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
166
262
  this.telemetryClient,
167
263
  createLogger('simulator:public-processor', bindings),
168
264
  this.config,
265
+ this.debugLogStore,
169
266
  );
170
267
 
171
- const validator = createValidatorForBlockBuilding(
268
+ const validator = createTxValidatorForBlockBuilding(
172
269
  fork,
173
270
  this.contractDataSource,
174
271
  globalVariables,
@@ -193,6 +290,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
193
290
  private contractDataSource: ContractDataSource,
194
291
  private dateProvider: DateProvider,
195
292
  private telemetryClient: TelemetryClient = getTelemetryClient(),
293
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
196
294
  ) {
197
295
  this.log = createLogger('checkpoint-builder');
198
296
  }
@@ -211,6 +309,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
211
309
  async startCheckpoint(
212
310
  checkpointNumber: CheckpointNumber,
213
311
  constants: CheckpointGlobalVariables,
312
+ feeAssetPriceModifier: bigint,
214
313
  l1ToL2Messages: Fr[],
215
314
  previousCheckpointOutHashes: Fr[],
216
315
  fork: MerkleTreeWriteOperations,
@@ -225,6 +324,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
225
324
  initialStateReference: stateReference.toInspect(),
226
325
  initialArchiveRoot: bufferToHex(archiveTree.root),
227
326
  constants,
327
+ feeAssetPriceModifier,
228
328
  });
229
329
 
230
330
  const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
@@ -234,6 +334,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
234
334
  previousCheckpointOutHashes,
235
335
  fork,
236
336
  bindings,
337
+ feeAssetPriceModifier,
237
338
  );
238
339
 
239
340
  return new CheckpointBuilder(
@@ -244,6 +345,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
244
345
  this.dateProvider,
245
346
  this.telemetryClient,
246
347
  bindings,
348
+ this.debugLogStore,
247
349
  );
248
350
  }
249
351
 
@@ -253,6 +355,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
253
355
  async openCheckpoint(
254
356
  checkpointNumber: CheckpointNumber,
255
357
  constants: CheckpointGlobalVariables,
358
+ feeAssetPriceModifier: bigint,
256
359
  l1ToL2Messages: Fr[],
257
360
  previousCheckpointOutHashes: Fr[],
258
361
  fork: MerkleTreeWriteOperations,
@@ -266,6 +369,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
266
369
  return this.startCheckpoint(
267
370
  checkpointNumber,
268
371
  constants,
372
+ feeAssetPriceModifier,
269
373
  l1ToL2Messages,
270
374
  previousCheckpointOutHashes,
271
375
  fork,
@@ -280,11 +384,13 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
280
384
  initialStateReference: stateReference.toInspect(),
281
385
  initialArchiveRoot: bufferToHex(archiveTree.root),
282
386
  constants,
387
+ feeAssetPriceModifier,
283
388
  });
284
389
 
285
390
  const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
286
391
  checkpointNumber,
287
392
  constants,
393
+ feeAssetPriceModifier,
288
394
  l1ToL2Messages,
289
395
  previousCheckpointOutHashes,
290
396
  fork,
@@ -300,6 +406,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
300
406
  this.dateProvider,
301
407
  this.telemetryClient,
302
408
  bindings,
409
+ this.debugLogStore,
303
410
  );
304
411
  }
305
412
 
package/src/config.ts CHANGED
@@ -6,8 +6,8 @@ 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
- import { validatorHASignerConfigMappings } from '@aztec/validator-ha-signer/config';
11
11
 
12
12
  export type { ValidatorClientConfig };
13
13
 
@@ -73,6 +73,31 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
73
73
  description: 'Skip pushing re-executed blocks to archiver (default: false)',
74
74
  defaultValue: false,
75
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),
99
+ },
100
+ ...localSignerConfigMappings,
76
101
  ...validatorHASignerConfigMappings,
77
102
  };
78
103
 
@@ -95,6 +95,7 @@ export class ValidationService {
95
95
  public createCheckpointProposal(
96
96
  checkpointHeader: CheckpointHeader,
97
97
  archive: Fr,
98
+ feeAssetPriceModifier: bigint,
98
99
  lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
99
100
  proposerAttesterAddress: EthAddress | undefined,
100
101
  options: CheckpointProposalOptions,
@@ -119,7 +120,13 @@ export class ValidationService {
119
120
  txs: options.publishFullTxs ? lastBlockInfo.txs : undefined,
120
121
  };
121
122
 
122
- return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, lastBlock, payloadSigner);
123
+ return CheckpointProposal.createProposalFromSigner(
124
+ checkpointHeader,
125
+ archive,
126
+ feeAssetPriceModifier,
127
+ lastBlock,
128
+ payloadSigner,
129
+ );
123
130
  }
124
131
 
125
132
  /**
@@ -137,22 +144,16 @@ export class ValidationService {
137
144
  attestors: EthAddress[],
138
145
  ): Promise<CheckpointAttestation[]> {
139
146
  // Create the attestation payload from the checkpoint proposal
140
- const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
147
+ const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier);
141
148
  const buf = Buffer32.fromBuffer(
142
149
  keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)),
143
150
  );
144
151
 
145
152
  // TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
146
- // Currently using lastBlock.blockNumber as a proxy for checkpoint identification in HA signing.
153
+ // CheckpointProposalCore doesn't have lastBlock info, so use 0 as a proxy.
147
154
  // blockNumber is NOT used for the primary key so it's safe to use here.
148
155
  // See CheckpointHeader TODO and SigningContext types documentation.
149
- let blockNumber: BlockNumber;
150
- try {
151
- blockNumber = proposal.blockNumber;
152
- } catch {
153
- // Checkpoint proposal may not have lastBlock, use 0 as fallback
154
- blockNumber = BlockNumber(0);
155
- }
156
+ const blockNumber = BlockNumber(0);
156
157
  const context: SigningContext = {
157
158
  slot: proposal.slotNumber,
158
159
  blockNumber,
@@ -176,7 +177,7 @@ export class ValidationService {
176
177
  } else {
177
178
  const error = result.reason;
178
179
  if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
179
- this.log.info(
180
+ this.log.verbose(
180
181
  `Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`,
181
182
  );
182
183
  // Continue with remaining attestors
package/src/factory.ts CHANGED
@@ -7,6 +7,7 @@ import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
7
7
  import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
8
8
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
9
9
  import type { TelemetryClient } from '@aztec/telemetry-client';
10
+ import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
10
11
 
11
12
  import { BlockProposalHandler } from './block_proposal_handler.js';
12
13
  import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
@@ -29,6 +30,7 @@ export function createBlockProposalHandler(
29
30
  const metrics = new ValidatorMetrics(deps.telemetry);
30
31
  const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
31
32
  txsPermitted: !config.disableTransactions,
33
+ maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
32
34
  });
33
35
  return new BlockProposalHandler(
34
36
  deps.checkpointsBuilder,
@@ -58,6 +60,7 @@ export function createValidatorClient(
58
60
  epochCache: EpochCache;
59
61
  keyStoreManager: KeystoreManager | undefined;
60
62
  blobClient: BlobClientInterface;
63
+ slashingProtectionDb?: SlashingProtectionDatabase;
61
64
  },
62
65
  ) {
63
66
  if (config.disableValidator || !deps.keyStoreManager) {
@@ -78,5 +81,6 @@ export function createValidatorClient(
78
81
  deps.blobClient,
79
82
  deps.dateProvider,
80
83
  deps.telemetry,
84
+ deps.slashingProtectionDb,
81
85
  );
82
86
  }
package/src/index.ts CHANGED
@@ -4,4 +4,3 @@ export * from './config.js';
4
4
  export * from './factory.js';
5
5
  export * from './validator.js';
6
6
  export * from './key_store/index.js';
7
- export * from './tx_validator/index.js';
@@ -240,7 +240,7 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
240
240
  }
241
241
 
242
242
  if (error instanceof SlashingProtectionError) {
243
- this.log.warn(`Duty already signed by another node with different payload`, {
243
+ this.log.info(`Duty already signed by another node with different payload`, {
244
244
  dutyType: context.dutyType,
245
245
  slot: context.slot,
246
246
  existingMessageHash: error.existingMessageHash,
@@ -256,8 +256,8 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
256
256
  /**
257
257
  * Start the high-availability key store
258
258
  */
259
- public start(): Promise<void> {
260
- return Promise.resolve(this.haSigner.start());
259
+ public async start() {
260
+ await this.haSigner.start();
261
261
  }
262
262
 
263
263
  /**
package/src/metrics.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { EpochNumber } from '@aztec/foundation/branded-types';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
1
3
  import type { BlockProposal } from '@aztec/stdlib/p2p';
2
4
  import {
3
5
  Attributes,
@@ -16,6 +18,8 @@ export class ValidatorMetrics {
16
18
  private successfulAttestationsCount: UpDownCounter;
17
19
  private failedAttestationsBadProposalCount: UpDownCounter;
18
20
  private failedAttestationsNodeIssueCount: UpDownCounter;
21
+ private currentEpoch: Gauge;
22
+ private attestedEpochCount: UpDownCounter;
19
23
 
20
24
  private reexMana: Histogram;
21
25
  private reexTx: Histogram;
@@ -64,6 +68,10 @@ export class ValidatorMetrics {
64
68
  },
65
69
  );
66
70
 
71
+ this.currentEpoch = meter.createGauge(Metrics.VALIDATOR_CURRENT_EPOCH);
72
+
73
+ this.attestedEpochCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTED_EPOCH_COUNT);
74
+
67
75
  this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
68
76
 
69
77
  this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
@@ -110,4 +118,14 @@ export class ValidatorMetrics {
110
118
  [Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
111
119
  });
112
120
  }
121
+
122
+ /** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */
123
+ public setCurrentEpoch(epoch: EpochNumber) {
124
+ this.currentEpoch.record(Number(epoch));
125
+ }
126
+
127
+ /** Increment the count of epochs in which the given attester submitted at least one attestation. */
128
+ public incAttestedEpochCount(attester: EthAddress) {
129
+ this.attestedEpochCount.add(1, { [Attributes.ATTESTER_ADDRESS]: attester.toString() });
130
+ }
113
131
  }