@aztec/validator-client 0.0.1-commit.87a0206 → 0.0.1-commit.88c5703d4
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/README.md +55 -10
- package/dest/block_proposal_handler.d.ts +5 -4
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +122 -62
- package/dest/checkpoint_builder.d.ts +16 -5
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +121 -44
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -1
- package/dest/duties/validation_service.d.ts +2 -2
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +6 -12
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +2 -1
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +9 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/validator.d.ts +30 -8
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +171 -33
- package/package.json +19 -19
- package/src/block_proposal_handler.ts +149 -80
- package/src/checkpoint_builder.ts +137 -39
- package/src/config.ts +26 -1
- package/src/duties/validation_service.ts +12 -11
- package/src/factory.ts +1 -0
- package/src/index.ts +0 -1
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +18 -0
- package/src/validator.ts +216 -39
- package/dest/tx_validator/index.d.ts +0 -3
- package/dest/tx_validator/index.d.ts.map +0 -1
- package/dest/tx_validator/index.js +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -19
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- package/src/tx_validator/index.ts +0 -2
- package/src/tx_validator/nullifier_cache.ts +0 -30
- 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
8
|
import { DateProvider, elapsed } from '@aztec/foundation/timer';
|
|
7
|
-
import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
9
|
+
import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
|
|
8
10
|
import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
|
|
9
11
|
import {
|
|
10
12
|
GuardedMerkleTreeOperations,
|
|
@@ -23,16 +25,16 @@ import {
|
|
|
23
25
|
FullNodeBlockBuilderConfigKeys,
|
|
24
26
|
type ICheckpointBlockBuilder,
|
|
25
27
|
type ICheckpointsBuilder,
|
|
28
|
+
InsufficientValidTxsError,
|
|
26
29
|
type MerkleTreeWriteOperations,
|
|
27
|
-
NoValidTxsError,
|
|
28
30
|
type PublicProcessorLimits,
|
|
29
31
|
type WorldStateSynchronizer,
|
|
30
32
|
} from '@aztec/stdlib/interfaces/server';
|
|
33
|
+
import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
31
34
|
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
32
35
|
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
33
36
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
34
|
-
|
|
35
|
-
import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
|
|
37
|
+
import { ForkCheckpoint } from '@aztec/world-state';
|
|
36
38
|
|
|
37
39
|
// Re-export for backward compatibility
|
|
38
40
|
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
@@ -52,6 +54,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
52
54
|
private dateProvider: DateProvider,
|
|
53
55
|
private telemetryClient: TelemetryClient,
|
|
54
56
|
bindings?: LoggerBindings,
|
|
57
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
55
58
|
) {
|
|
56
59
|
this.log = createLogger('checkpoint-builder', {
|
|
57
60
|
...bindings,
|
|
@@ -65,12 +68,13 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* Builds a single block within this checkpoint.
|
|
71
|
+
* Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
|
|
68
72
|
*/
|
|
69
73
|
async buildBlock(
|
|
70
74
|
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
71
75
|
blockNumber: BlockNumber,
|
|
72
76
|
timestamp: bigint,
|
|
73
|
-
opts: PublicProcessorLimits & { expectedEndState?: StateReference } = {},
|
|
77
|
+
opts: PublicProcessorLimits & { expectedEndState?: StateReference; minValidTxs?: number } = {},
|
|
74
78
|
): Promise<BuildBlockInCheckpointResult> {
|
|
75
79
|
const slot = this.checkpointBuilder.constants.slotNumber;
|
|
76
80
|
|
|
@@ -94,39 +98,53 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
94
98
|
});
|
|
95
99
|
const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
|
|
96
100
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// (only the first block in a checkpoint can be empty)
|
|
103
|
-
if (processedTxs.length === 0 && this.checkpointBuilder.getBlockCount() > 0) {
|
|
104
|
-
throw new NoValidTxsError(failedTxs);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Add block to checkpoint
|
|
108
|
-
const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
|
|
109
|
-
expectedEndState: opts.expectedEndState,
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
// How much public gas was processed
|
|
113
|
-
const publicGas = processedTxs.reduce((acc, tx) => acc.add(tx.gasUsed.publicGas), Gas.empty());
|
|
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),
|
|
105
|
+
};
|
|
114
106
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
failedTxs: failedTxs.map(tx => tx.tx.txHash.toString()),
|
|
119
|
-
});
|
|
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);
|
|
120
110
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
}
|
|
130
148
|
}
|
|
131
149
|
|
|
132
150
|
/** Completes the checkpoint and returns it. */
|
|
@@ -147,11 +165,79 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
147
165
|
return this.checkpointBuilder.clone().completeCheckpoint();
|
|
148
166
|
}
|
|
149
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
|
+
|
|
150
231
|
protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
|
|
151
|
-
const txPublicSetupAllowList =
|
|
232
|
+
const txPublicSetupAllowList = [
|
|
233
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
234
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
235
|
+
];
|
|
152
236
|
const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
153
237
|
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
154
238
|
|
|
239
|
+
const collectDebugLogs = this.debugLogStore.isEnabled;
|
|
240
|
+
|
|
155
241
|
const bindings = this.log.getBindings();
|
|
156
242
|
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
|
|
157
243
|
guardedFork,
|
|
@@ -159,6 +245,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
159
245
|
globalVariables,
|
|
160
246
|
this.telemetryClient,
|
|
161
247
|
bindings,
|
|
248
|
+
collectDebugLogs,
|
|
162
249
|
);
|
|
163
250
|
|
|
164
251
|
const processor = new PublicProcessor(
|
|
@@ -170,9 +257,10 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
|
170
257
|
this.telemetryClient,
|
|
171
258
|
createLogger('simulator:public-processor', bindings),
|
|
172
259
|
this.config,
|
|
260
|
+
this.debugLogStore,
|
|
173
261
|
);
|
|
174
262
|
|
|
175
|
-
const validator =
|
|
263
|
+
const validator = createTxValidatorForBlockBuilding(
|
|
176
264
|
fork,
|
|
177
265
|
this.contractDataSource,
|
|
178
266
|
globalVariables,
|
|
@@ -197,6 +285,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
197
285
|
private contractDataSource: ContractDataSource,
|
|
198
286
|
private dateProvider: DateProvider,
|
|
199
287
|
private telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
288
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
200
289
|
) {
|
|
201
290
|
this.log = createLogger('checkpoint-builder');
|
|
202
291
|
}
|
|
@@ -215,6 +304,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
215
304
|
async startCheckpoint(
|
|
216
305
|
checkpointNumber: CheckpointNumber,
|
|
217
306
|
constants: CheckpointGlobalVariables,
|
|
307
|
+
feeAssetPriceModifier: bigint,
|
|
218
308
|
l1ToL2Messages: Fr[],
|
|
219
309
|
previousCheckpointOutHashes: Fr[],
|
|
220
310
|
fork: MerkleTreeWriteOperations,
|
|
@@ -229,6 +319,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
229
319
|
initialStateReference: stateReference.toInspect(),
|
|
230
320
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
231
321
|
constants,
|
|
322
|
+
feeAssetPriceModifier,
|
|
232
323
|
});
|
|
233
324
|
|
|
234
325
|
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
@@ -238,6 +329,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
238
329
|
previousCheckpointOutHashes,
|
|
239
330
|
fork,
|
|
240
331
|
bindings,
|
|
332
|
+
feeAssetPriceModifier,
|
|
241
333
|
);
|
|
242
334
|
|
|
243
335
|
return new CheckpointBuilder(
|
|
@@ -248,6 +340,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
248
340
|
this.dateProvider,
|
|
249
341
|
this.telemetryClient,
|
|
250
342
|
bindings,
|
|
343
|
+
this.debugLogStore,
|
|
251
344
|
);
|
|
252
345
|
}
|
|
253
346
|
|
|
@@ -257,6 +350,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
257
350
|
async openCheckpoint(
|
|
258
351
|
checkpointNumber: CheckpointNumber,
|
|
259
352
|
constants: CheckpointGlobalVariables,
|
|
353
|
+
feeAssetPriceModifier: bigint,
|
|
260
354
|
l1ToL2Messages: Fr[],
|
|
261
355
|
previousCheckpointOutHashes: Fr[],
|
|
262
356
|
fork: MerkleTreeWriteOperations,
|
|
@@ -270,6 +364,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
270
364
|
return this.startCheckpoint(
|
|
271
365
|
checkpointNumber,
|
|
272
366
|
constants,
|
|
367
|
+
feeAssetPriceModifier,
|
|
273
368
|
l1ToL2Messages,
|
|
274
369
|
previousCheckpointOutHashes,
|
|
275
370
|
fork,
|
|
@@ -284,11 +379,13 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
284
379
|
initialStateReference: stateReference.toInspect(),
|
|
285
380
|
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
286
381
|
constants,
|
|
382
|
+
feeAssetPriceModifier,
|
|
287
383
|
});
|
|
288
384
|
|
|
289
385
|
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
|
|
290
386
|
checkpointNumber,
|
|
291
387
|
constants,
|
|
388
|
+
feeAssetPriceModifier,
|
|
292
389
|
l1ToL2Messages,
|
|
293
390
|
previousCheckpointOutHashes,
|
|
294
391
|
fork,
|
|
@@ -304,6 +401,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
|
304
401
|
this.dateProvider,
|
|
305
402
|
this.telemetryClient,
|
|
306
403
|
bindings,
|
|
404
|
+
this.debugLogStore,
|
|
307
405
|
);
|
|
308
406
|
}
|
|
309
407
|
|
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(
|
|
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
|
-
//
|
|
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
|
-
|
|
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.
|
|
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
|
@@ -29,6 +29,7 @@ export function createBlockProposalHandler(
|
|
|
29
29
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
30
30
|
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
31
31
|
txsPermitted: !config.disableTransactions,
|
|
32
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock,
|
|
32
33
|
});
|
|
33
34
|
return new BlockProposalHandler(
|
|
34
35
|
deps.checkpointsBuilder,
|
package/src/index.ts
CHANGED
|
@@ -240,7 +240,7 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
if (error instanceof SlashingProtectionError) {
|
|
243
|
-
this.log.
|
|
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,
|
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
|
}
|