@aztec/validator-client 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6
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 +326 -0
- package/dest/block_proposal_handler.d.ts +26 -14
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +433 -109
- package/dest/checkpoint_builder.d.ts +79 -0
- package/dest/checkpoint_builder.d.ts.map +1 -0
- package/dest/checkpoint_builder.js +251 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +37 -8
- package/dest/duties/validation_service.d.ts +42 -13
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +105 -28
- package/dest/factory.d.ts +15 -8
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +4 -3
- package/dest/index.d.ts +2 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/key_store/ha_key_store.d.ts +99 -0
- package/dest/key_store/ha_key_store.d.ts.map +1 -0
- package/dest/key_store/ha_key_store.js +208 -0
- package/dest/key_store/index.d.ts +2 -1
- package/dest/key_store/index.d.ts.map +1 -1
- package/dest/key_store/index.js +1 -0
- package/dest/key_store/interface.d.ts +36 -6
- package/dest/key_store/interface.d.ts.map +1 -1
- package/dest/key_store/local_key_store.d.ts +10 -5
- package/dest/key_store/local_key_store.d.ts.map +1 -1
- package/dest/key_store/local_key_store.js +9 -5
- package/dest/key_store/node_keystore_adapter.d.ts +18 -5
- package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
- package/dest/key_store/node_keystore_adapter.js +18 -4
- package/dest/key_store/web3signer_key_store.d.ts +10 -5
- package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
- package/dest/key_store/web3signer_key_store.js +9 -5
- package/dest/metrics.d.ts +12 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +46 -30
- package/dest/validator.d.ts +76 -21
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +483 -57
- package/package.json +23 -13
- package/src/block_proposal_handler.ts +370 -79
- package/src/checkpoint_builder.ts +417 -0
- package/src/config.ts +36 -7
- package/src/duties/validation_service.ts +156 -33
- package/src/factory.ts +21 -8
- package/src/index.ts +1 -0
- package/src/key_store/ha_key_store.ts +269 -0
- package/src/key_store/index.ts +1 -0
- package/src/key_store/interface.ts +44 -5
- package/src/key_store/local_key_store.ts +14 -5
- package/src/key_store/node_keystore_adapter.ts +28 -5
- package/src/key_store/web3signer_key_store.ts +18 -5
- package/src/metrics.ts +63 -33
- package/src/validator.ts +659 -90
|
@@ -0,0 +1,417 @@
|
|
|
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
|
+
GuardedMerkleTreeOperations,
|
|
13
|
+
PublicContractsDB,
|
|
14
|
+
PublicProcessor,
|
|
15
|
+
createPublicTxSimulatorForBlockBuilding,
|
|
16
|
+
} from '@aztec/simulator/server';
|
|
17
|
+
import { L2Block } from '@aztec/stdlib/block';
|
|
18
|
+
import { Checkpoint } from '@aztec/stdlib/checkpoint';
|
|
19
|
+
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
20
|
+
import type { L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
21
|
+
import { Gas } from '@aztec/stdlib/gas';
|
|
22
|
+
import {
|
|
23
|
+
type BlockBuilderOptions,
|
|
24
|
+
type BuildBlockInCheckpointResult,
|
|
25
|
+
type FullNodeBlockBuilderConfig,
|
|
26
|
+
FullNodeBlockBuilderConfigKeys,
|
|
27
|
+
type ICheckpointBlockBuilder,
|
|
28
|
+
type ICheckpointsBuilder,
|
|
29
|
+
InsufficientValidTxsError,
|
|
30
|
+
type MerkleTreeWriteOperations,
|
|
31
|
+
type PublicProcessorLimits,
|
|
32
|
+
type WorldStateSynchronizer,
|
|
33
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
34
|
+
import { type DebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
|
|
35
|
+
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
36
|
+
import { type CheckpointGlobalVariables, GlobalVariables, StateReference, Tx } from '@aztec/stdlib/tx';
|
|
37
|
+
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
38
|
+
import { ForkCheckpoint } from '@aztec/world-state';
|
|
39
|
+
|
|
40
|
+
// Re-export for backward compatibility
|
|
41
|
+
export type { BuildBlockInCheckpointResult } from '@aztec/stdlib/interfaces/server';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Builder for a single checkpoint. Handles building blocks within the checkpoint
|
|
45
|
+
* and completing it.
|
|
46
|
+
*/
|
|
47
|
+
export class CheckpointBuilder implements ICheckpointBlockBuilder {
|
|
48
|
+
private log: Logger;
|
|
49
|
+
|
|
50
|
+
/** Persistent contracts DB shared across all blocks in this checkpoint. */
|
|
51
|
+
protected contractsDB: PublicContractsDB;
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
private checkpointBuilder: LightweightCheckpointBuilder,
|
|
55
|
+
private fork: MerkleTreeWriteOperations,
|
|
56
|
+
private config: FullNodeBlockBuilderConfig,
|
|
57
|
+
private contractDataSource: ContractDataSource,
|
|
58
|
+
private dateProvider: DateProvider,
|
|
59
|
+
private telemetryClient: TelemetryClient,
|
|
60
|
+
bindings?: LoggerBindings,
|
|
61
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
62
|
+
) {
|
|
63
|
+
this.log = createLogger('checkpoint-builder', {
|
|
64
|
+
...bindings,
|
|
65
|
+
instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`,
|
|
66
|
+
});
|
|
67
|
+
this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getConstantData(): CheckpointGlobalVariables {
|
|
71
|
+
return this.checkpointBuilder.constants;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Builds a single block within this checkpoint.
|
|
76
|
+
* Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
|
|
77
|
+
*/
|
|
78
|
+
async buildBlock(
|
|
79
|
+
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
80
|
+
blockNumber: BlockNumber,
|
|
81
|
+
timestamp: bigint,
|
|
82
|
+
opts: BlockBuilderOptions & { expectedEndState?: StateReference },
|
|
83
|
+
): Promise<BuildBlockInCheckpointResult> {
|
|
84
|
+
const slot = this.checkpointBuilder.constants.slotNumber;
|
|
85
|
+
|
|
86
|
+
this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
|
|
87
|
+
slot,
|
|
88
|
+
blockNumber,
|
|
89
|
+
...opts,
|
|
90
|
+
currentTime: new Date(this.dateProvider.now()),
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const constants = this.checkpointBuilder.constants;
|
|
94
|
+
const globalVariables = GlobalVariables.from({
|
|
95
|
+
chainId: constants.chainId,
|
|
96
|
+
version: constants.version,
|
|
97
|
+
blockNumber,
|
|
98
|
+
slotNumber: constants.slotNumber,
|
|
99
|
+
timestamp,
|
|
100
|
+
coinbase: constants.coinbase,
|
|
101
|
+
feeRecipient: constants.feeRecipient,
|
|
102
|
+
gasFees: constants.gasFees,
|
|
103
|
+
});
|
|
104
|
+
const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
|
|
105
|
+
|
|
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
|
+
};
|
|
111
|
+
|
|
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);
|
|
117
|
+
|
|
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
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Completes the checkpoint and returns it. */
|
|
163
|
+
async completeCheckpoint(): Promise<Checkpoint> {
|
|
164
|
+
const checkpoint = await this.checkpointBuilder.completeCheckpoint();
|
|
165
|
+
|
|
166
|
+
this.log.verbose(`Completed checkpoint ${checkpoint.number}`, {
|
|
167
|
+
checkpointNumber: checkpoint.number,
|
|
168
|
+
numBlocks: checkpoint.blocks.length,
|
|
169
|
+
archiveRoot: checkpoint.archive.root.toString(),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
return checkpoint;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** Gets the checkpoint currently in progress. */
|
|
176
|
+
getCheckpoint(): Promise<Checkpoint> {
|
|
177
|
+
return this.checkpointBuilder.clone().completeCheckpoint();
|
|
178
|
+
}
|
|
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
|
+
|
|
236
|
+
protected async makeBlockBuilderDeps(globalVariables: GlobalVariables, fork: MerkleTreeWriteOperations) {
|
|
237
|
+
const txPublicSetupAllowList = [
|
|
238
|
+
...(await getDefaultAllowedSetupFunctions()),
|
|
239
|
+
...(this.config.txPublicSetupAllowListExtend ?? []),
|
|
240
|
+
];
|
|
241
|
+
const contractsDB = this.contractsDB;
|
|
242
|
+
const guardedFork = new GuardedMerkleTreeOperations(fork);
|
|
243
|
+
|
|
244
|
+
const collectDebugLogs = this.debugLogStore.isEnabled;
|
|
245
|
+
|
|
246
|
+
const bindings = this.log.getBindings();
|
|
247
|
+
const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
|
|
248
|
+
guardedFork,
|
|
249
|
+
contractsDB,
|
|
250
|
+
globalVariables,
|
|
251
|
+
this.telemetryClient,
|
|
252
|
+
bindings,
|
|
253
|
+
collectDebugLogs,
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
const processor = new PublicProcessor(
|
|
257
|
+
globalVariables,
|
|
258
|
+
guardedFork,
|
|
259
|
+
contractsDB,
|
|
260
|
+
publicTxSimulator,
|
|
261
|
+
this.dateProvider,
|
|
262
|
+
this.telemetryClient,
|
|
263
|
+
createLogger('simulator:public-processor', bindings),
|
|
264
|
+
this.config,
|
|
265
|
+
this.debugLogStore,
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
const validator = createTxValidatorForBlockBuilding(
|
|
269
|
+
fork,
|
|
270
|
+
this.contractDataSource,
|
|
271
|
+
globalVariables,
|
|
272
|
+
txPublicSetupAllowList,
|
|
273
|
+
this.log.getBindings(),
|
|
274
|
+
);
|
|
275
|
+
|
|
276
|
+
return {
|
|
277
|
+
processor,
|
|
278
|
+
validator,
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/** Factory for creating checkpoint builders. */
|
|
284
|
+
export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
|
|
285
|
+
private log: Logger;
|
|
286
|
+
|
|
287
|
+
constructor(
|
|
288
|
+
private config: FullNodeBlockBuilderConfig & Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'>,
|
|
289
|
+
private worldState: WorldStateSynchronizer,
|
|
290
|
+
private contractDataSource: ContractDataSource,
|
|
291
|
+
private dateProvider: DateProvider,
|
|
292
|
+
private telemetryClient: TelemetryClient = getTelemetryClient(),
|
|
293
|
+
private debugLogStore: DebugLogStore = new NullDebugLogStore(),
|
|
294
|
+
) {
|
|
295
|
+
this.log = createLogger('checkpoint-builder');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public getConfig(): FullNodeBlockBuilderConfig {
|
|
299
|
+
return this.config;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public updateConfig(config: Partial<FullNodeBlockBuilderConfig>) {
|
|
303
|
+
this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
|
|
308
|
+
*/
|
|
309
|
+
async startCheckpoint(
|
|
310
|
+
checkpointNumber: CheckpointNumber,
|
|
311
|
+
constants: CheckpointGlobalVariables,
|
|
312
|
+
feeAssetPriceModifier: bigint,
|
|
313
|
+
l1ToL2Messages: Fr[],
|
|
314
|
+
previousCheckpointOutHashes: Fr[],
|
|
315
|
+
fork: MerkleTreeWriteOperations,
|
|
316
|
+
bindings?: LoggerBindings,
|
|
317
|
+
): Promise<CheckpointBuilder> {
|
|
318
|
+
const stateReference = await fork.getStateReference();
|
|
319
|
+
const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
320
|
+
|
|
321
|
+
this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
|
|
322
|
+
checkpointNumber,
|
|
323
|
+
msgCount: l1ToL2Messages.length,
|
|
324
|
+
initialStateReference: stateReference.toInspect(),
|
|
325
|
+
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
326
|
+
constants,
|
|
327
|
+
feeAssetPriceModifier,
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(
|
|
331
|
+
checkpointNumber,
|
|
332
|
+
constants,
|
|
333
|
+
l1ToL2Messages,
|
|
334
|
+
previousCheckpointOutHashes,
|
|
335
|
+
fork,
|
|
336
|
+
bindings,
|
|
337
|
+
feeAssetPriceModifier,
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
return new CheckpointBuilder(
|
|
341
|
+
lightweightBuilder,
|
|
342
|
+
fork,
|
|
343
|
+
this.config,
|
|
344
|
+
this.contractDataSource,
|
|
345
|
+
this.dateProvider,
|
|
346
|
+
this.telemetryClient,
|
|
347
|
+
bindings,
|
|
348
|
+
this.debugLogStore,
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Opens a checkpoint, either starting fresh or resuming from existing blocks.
|
|
354
|
+
*/
|
|
355
|
+
async openCheckpoint(
|
|
356
|
+
checkpointNumber: CheckpointNumber,
|
|
357
|
+
constants: CheckpointGlobalVariables,
|
|
358
|
+
feeAssetPriceModifier: bigint,
|
|
359
|
+
l1ToL2Messages: Fr[],
|
|
360
|
+
previousCheckpointOutHashes: Fr[],
|
|
361
|
+
fork: MerkleTreeWriteOperations,
|
|
362
|
+
existingBlocks: L2Block[] = [],
|
|
363
|
+
bindings?: LoggerBindings,
|
|
364
|
+
): Promise<CheckpointBuilder> {
|
|
365
|
+
const stateReference = await fork.getStateReference();
|
|
366
|
+
const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
|
|
367
|
+
|
|
368
|
+
if (existingBlocks.length === 0) {
|
|
369
|
+
return this.startCheckpoint(
|
|
370
|
+
checkpointNumber,
|
|
371
|
+
constants,
|
|
372
|
+
feeAssetPriceModifier,
|
|
373
|
+
l1ToL2Messages,
|
|
374
|
+
previousCheckpointOutHashes,
|
|
375
|
+
fork,
|
|
376
|
+
bindings,
|
|
377
|
+
);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
|
|
381
|
+
checkpointNumber,
|
|
382
|
+
msgCount: l1ToL2Messages.length,
|
|
383
|
+
existingBlockCount: existingBlocks.length,
|
|
384
|
+
initialStateReference: stateReference.toInspect(),
|
|
385
|
+
initialArchiveRoot: bufferToHex(archiveTree.root),
|
|
386
|
+
constants,
|
|
387
|
+
feeAssetPriceModifier,
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(
|
|
391
|
+
checkpointNumber,
|
|
392
|
+
constants,
|
|
393
|
+
feeAssetPriceModifier,
|
|
394
|
+
l1ToL2Messages,
|
|
395
|
+
previousCheckpointOutHashes,
|
|
396
|
+
fork,
|
|
397
|
+
existingBlocks,
|
|
398
|
+
bindings,
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
return new CheckpointBuilder(
|
|
402
|
+
lightweightBuilder,
|
|
403
|
+
fork,
|
|
404
|
+
this.config,
|
|
405
|
+
this.contractDataSource,
|
|
406
|
+
this.dateProvider,
|
|
407
|
+
this.telemetryClient,
|
|
408
|
+
bindings,
|
|
409
|
+
this.debugLogStore,
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** Returns a fork of the world state at the given block number. */
|
|
414
|
+
getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations> {
|
|
415
|
+
return this.worldState.fork(blockNumber);
|
|
416
|
+
}
|
|
417
|
+
}
|
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
|
-
|
|
60
|
+
defaultValue: true,
|
|
66
61
|
},
|
|
67
62
|
fishermanMode: {
|
|
68
63
|
env: 'FISHERMAN_MODE',
|
|
@@ -70,6 +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
|
},
|
|
68
|
+
skipCheckpointProposalValidation: {
|
|
69
|
+
description: 'Skip checkpoint proposal validation and always attest (default: false)',
|
|
70
|
+
defaultValue: false,
|
|
71
|
+
},
|
|
72
|
+
skipPushProposedBlocksToArchiver: {
|
|
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),
|
|
99
|
+
},
|
|
100
|
+
...localSignerConfigMappings,
|
|
101
|
+
...validatorHASignerConfigMappings,
|
|
73
102
|
};
|
|
74
103
|
|
|
75
104
|
/**
|