@aztec/validator-client 0.0.1-commit.ffe5b04ea → 0.0.1-commit.fff30aa
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 +9 -10
- package/dest/checkpoint_builder.d.ts +10 -7
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +64 -41
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -2
- package/dest/duties/validation_service.js +1 -1
- package/dest/factory.d.ts +7 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +5 -5
- package/dest/index.d.ts +2 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +2 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/proposal_handler.d.ts +94 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/{block_proposal_handler.js → proposal_handler.js} +313 -12
- package/dest/validator.d.ts +10 -23
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +44 -248
- package/package.json +19 -19
- package/src/checkpoint_builder.ts +79 -52
- package/src/config.ts +1 -2
- package/src/duties/validation_service.ts +1 -1
- package/src/factory.ts +9 -4
- package/src/index.ts +1 -1
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +1 -1
- package/src/{block_proposal_handler.ts → proposal_handler.ts} +362 -13
- package/src/validator.ts +57 -270
- package/dest/block_proposal_handler.d.ts +0 -63
- package/dest/block_proposal_handler.d.ts.map +0 -1
package/dest/validator.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import { getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
2
|
-
import { validateFeeAssetPriceModifier } from '@aztec/ethereum/contracts';
|
|
3
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
4
|
-
import { TimeoutError } from '@aztec/foundation/error';
|
|
5
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
2
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
8
3
|
import { sleep } from '@aztec/foundation/sleep';
|
|
9
4
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
5
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
11
6
|
import { OffenseType, WANT_TO_SLASH_EVENT } from '@aztec/slasher';
|
|
12
|
-
import {
|
|
13
|
-
import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
14
|
-
import { accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
|
|
7
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
15
8
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
16
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
17
|
-
import { createHASigner,
|
|
10
|
+
import { createHASigner, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
|
|
18
11
|
import { DutyType } from '@aztec/validator-ha-signer/types';
|
|
19
12
|
import { EventEmitter } from 'events';
|
|
20
|
-
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
21
13
|
import { ValidationService } from './duties/validation_service.js';
|
|
22
14
|
import { HAKeyStore } from './key_store/ha_key_store.js';
|
|
23
15
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
24
16
|
import { ValidatorMetrics } from './metrics.js';
|
|
17
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
25
18
|
// We maintain a set of proposers who have proposed invalid blocks.
|
|
26
19
|
// Just cap the set to avoid unbounded growth.
|
|
27
20
|
const MAX_PROPOSERS_OF_INVALID_BLOCKS = 1000;
|
|
@@ -36,14 +29,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
36
29
|
keyStore;
|
|
37
30
|
epochCache;
|
|
38
31
|
p2pClient;
|
|
39
|
-
|
|
40
|
-
blockSource;
|
|
41
|
-
checkpointsBuilder;
|
|
42
|
-
worldState;
|
|
43
|
-
l1ToL2MessageSource;
|
|
32
|
+
proposalHandler;
|
|
44
33
|
config;
|
|
45
34
|
blobClient;
|
|
46
|
-
|
|
35
|
+
haSigner;
|
|
47
36
|
dateProvider;
|
|
48
37
|
tracer;
|
|
49
38
|
validationService;
|
|
@@ -58,8 +47,8 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
58
47
|
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */ lastAttestedEpochByAttester;
|
|
59
48
|
proposersOfInvalidBlocks;
|
|
60
49
|
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */ lastAttestedProposal;
|
|
61
|
-
constructor(keyStore, epochCache, p2pClient,
|
|
62
|
-
super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.
|
|
50
|
+
constructor(keyStore, epochCache, p2pClient, proposalHandler, config, blobClient, haSigner, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
|
|
51
|
+
super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.proposalHandler = proposalHandler, this.config = config, this.blobClient = blobClient, this.haSigner = haSigner, this.dateProvider = dateProvider, this.hasRegisteredHandlers = false, this.lastAttestedEpochByAttester = new Map(), this.proposersOfInvalidBlocks = new Set();
|
|
63
52
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
64
53
|
this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
|
|
65
54
|
this.tracer = telemetry.getTracer('Validator');
|
|
@@ -114,43 +103,39 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
114
103
|
this.log.error(`Error updating epoch committee`, err);
|
|
115
104
|
}
|
|
116
105
|
}
|
|
117
|
-
static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient()) {
|
|
106
|
+
static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), slashingProtectionDb) {
|
|
118
107
|
const metrics = new ValidatorMetrics(telemetry);
|
|
119
108
|
const blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
120
109
|
txsPermitted: !config.disableTransactions,
|
|
121
110
|
maxTxsPerBlock: config.validateMaxTxsPerBlock
|
|
122
111
|
});
|
|
123
|
-
const
|
|
112
|
+
const proposalHandler = new ProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, blobClient, metrics, dateProvider, telemetry);
|
|
124
113
|
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
let validatorKeyStore = nodeKeystoreAdapter;
|
|
115
|
+
let haSigner;
|
|
116
|
+
if (slashingProtectionDb) {
|
|
117
|
+
// Shared database mode: use a pre-existing database (e.g. for testing HA setups).
|
|
118
|
+
const { signer } = createSignerFromSharedDb(slashingProtectionDb, config);
|
|
119
|
+
haSigner = signer;
|
|
120
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
121
|
+
} else if (config.haSigningEnabled) {
|
|
128
122
|
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
129
123
|
const haConfig = {
|
|
130
124
|
...config,
|
|
131
125
|
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000
|
|
132
126
|
};
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
// Single-node mode: use LMDB-backed local signing protection.
|
|
139
|
-
// This prevents double-signing if the node crashes and restarts mid-proposal.
|
|
140
|
-
({ signer: slashingProtectionSigner } = await createLocalSignerWithProtection(config, {
|
|
141
|
-
telemetryClient: telemetry,
|
|
142
|
-
dateProvider
|
|
143
|
-
}));
|
|
144
|
-
}
|
|
145
|
-
const validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, slashingProtectionSigner);
|
|
146
|
-
const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider, telemetry);
|
|
127
|
+
const { signer } = await createHASigner(haConfig);
|
|
128
|
+
haSigner = signer;
|
|
129
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
130
|
+
}
|
|
131
|
+
const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, proposalHandler, config, blobClient, haSigner, dateProvider, telemetry);
|
|
147
132
|
return validator;
|
|
148
133
|
}
|
|
149
134
|
getValidatorAddresses() {
|
|
150
135
|
return this.keyStore.getAddresses().filter((addr)=>!this.config.disabledValidators.some((disabled)=>disabled.equals(addr)));
|
|
151
136
|
}
|
|
152
|
-
|
|
153
|
-
return this.
|
|
137
|
+
getProposalHandler() {
|
|
138
|
+
return this.proposalHandler;
|
|
154
139
|
}
|
|
155
140
|
signWithAddress(addr, msg, context) {
|
|
156
141
|
return this.keyStore.signTypedDataWithAddress(addr, msg, context);
|
|
@@ -171,8 +156,17 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
171
156
|
};
|
|
172
157
|
}
|
|
173
158
|
reloadKeystore(newManager) {
|
|
159
|
+
if (this.config.haSigningEnabled && !this.haSigner) {
|
|
160
|
+
this.log.warn('HA signing is enabled in config but was not initialized at startup. ' + 'Restart the node to enable HA signing.');
|
|
161
|
+
} else if (!this.config.haSigningEnabled && this.haSigner) {
|
|
162
|
+
this.log.warn('HA signing was disabled via config update but the HA signer is still active. ' + 'Restart the node to fully disable HA signing.');
|
|
163
|
+
}
|
|
174
164
|
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
175
|
-
|
|
165
|
+
if (this.haSigner) {
|
|
166
|
+
this.keyStore = new HAKeyStore(newAdapter, this.haSigner);
|
|
167
|
+
} else {
|
|
168
|
+
this.keyStore = newAdapter;
|
|
169
|
+
}
|
|
176
170
|
this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
|
|
177
171
|
}
|
|
178
172
|
async start() {
|
|
@@ -235,13 +229,12 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
235
229
|
this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
|
|
236
230
|
return false;
|
|
237
231
|
}
|
|
238
|
-
//
|
|
232
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
239
233
|
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
240
|
-
this.log.
|
|
234
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
241
235
|
proposer: proposer.toString(),
|
|
242
236
|
slotNumber
|
|
243
237
|
});
|
|
244
|
-
return false;
|
|
245
238
|
}
|
|
246
239
|
// Check if we're in the committee (for metrics purposes)
|
|
247
240
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
@@ -259,10 +252,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
259
252
|
// In fisherman mode, we always reexecute to validate proposals.
|
|
260
253
|
const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } = this.config;
|
|
261
254
|
const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
|
|
262
|
-
const validationResult = await this.
|
|
255
|
+
const validationResult = await this.proposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
|
|
263
256
|
if (!validationResult.isValid) {
|
|
264
|
-
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
265
257
|
const reason = validationResult.reason || 'unknown';
|
|
258
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
266
259
|
// Classify failure reason: bad proposal vs node issue
|
|
267
260
|
const badProposalReasons = [
|
|
268
261
|
'invalid_proposal',
|
|
@@ -309,50 +302,36 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
309
302
|
this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
|
|
310
303
|
return undefined;
|
|
311
304
|
}
|
|
312
|
-
// Reject proposals with invalid signatures
|
|
313
|
-
if (!proposer) {
|
|
314
|
-
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
|
|
315
|
-
return undefined;
|
|
316
|
-
}
|
|
317
305
|
// Ignore proposals from ourselves (may happen in HA setups)
|
|
318
|
-
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
319
|
-
this.log.
|
|
306
|
+
if (proposer && this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
307
|
+
this.log.debug(`Ignoring block proposal from self for slot ${slotNumber}`, {
|
|
320
308
|
proposer: proposer.toString(),
|
|
321
309
|
slotNumber
|
|
322
310
|
});
|
|
323
311
|
return undefined;
|
|
324
312
|
}
|
|
325
|
-
//
|
|
326
|
-
if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
|
|
327
|
-
this.log.warn(`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${slotNumber}`);
|
|
328
|
-
return undefined;
|
|
329
|
-
}
|
|
330
|
-
// Check that I have any address in current committee before attesting
|
|
313
|
+
// Check that I have any address in the committee where this checkpoint will land before attesting
|
|
331
314
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
332
315
|
const partOfCommittee = inCommittee.length > 0;
|
|
333
316
|
const proposalInfo = {
|
|
334
317
|
slotNumber,
|
|
335
318
|
archive: proposal.archive.toString(),
|
|
336
|
-
proposer: proposer
|
|
319
|
+
proposer: proposer?.toString()
|
|
337
320
|
};
|
|
338
321
|
this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
|
|
339
322
|
...proposalInfo,
|
|
340
323
|
fishermanMode: this.config.fishermanMode || false
|
|
341
324
|
});
|
|
342
|
-
// Validate the checkpoint proposal
|
|
325
|
+
// Validate the checkpoint proposal and upload blobs (unless skipCheckpointProposalValidation is set)
|
|
343
326
|
if (this.config.skipCheckpointProposalValidation) {
|
|
344
327
|
this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
345
328
|
} else {
|
|
346
|
-
const validationResult = await this.
|
|
329
|
+
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
347
330
|
if (!validationResult.isValid) {
|
|
348
331
|
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
349
332
|
return undefined;
|
|
350
333
|
}
|
|
351
334
|
}
|
|
352
|
-
// Upload blobs to filestore if we can (fire and forget)
|
|
353
|
-
if (this.blobClient.canUpload()) {
|
|
354
|
-
void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
|
|
355
|
-
}
|
|
356
335
|
// Check that I have any address in current committee before attesting
|
|
357
336
|
// In fisherman mode, we still create attestations for validation even if not in committee
|
|
358
337
|
if (!partOfCommittee && !this.config.fishermanMode) {
|
|
@@ -426,189 +405,6 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
426
405
|
await this.p2pClient.addOwnCheckpointAttestations(attestations);
|
|
427
406
|
return attestations;
|
|
428
407
|
}
|
|
429
|
-
/**
|
|
430
|
-
* Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
|
|
431
|
-
* @returns Validation result with isValid flag and reason if invalid.
|
|
432
|
-
*/ async validateCheckpointProposal(proposal, proposalInfo) {
|
|
433
|
-
const slot = proposal.slotNumber;
|
|
434
|
-
// Timeout block syncing at the start of the next slot
|
|
435
|
-
const config = this.checkpointsBuilder.getConfig();
|
|
436
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
|
|
437
|
-
const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
|
|
438
|
-
// Wait for last block to sync by archive
|
|
439
|
-
let lastBlockHeader;
|
|
440
|
-
try {
|
|
441
|
-
lastBlockHeader = await retryUntil(async ()=>{
|
|
442
|
-
await this.blockSource.syncImmediate();
|
|
443
|
-
return this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
444
|
-
}, `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`, timeoutSeconds, 0.5);
|
|
445
|
-
} catch (err) {
|
|
446
|
-
if (err instanceof TimeoutError) {
|
|
447
|
-
this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
|
|
448
|
-
return {
|
|
449
|
-
isValid: false,
|
|
450
|
-
reason: 'last_block_not_found'
|
|
451
|
-
};
|
|
452
|
-
}
|
|
453
|
-
this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
|
|
454
|
-
return {
|
|
455
|
-
isValid: false,
|
|
456
|
-
reason: 'block_fetch_error'
|
|
457
|
-
};
|
|
458
|
-
}
|
|
459
|
-
if (!lastBlockHeader) {
|
|
460
|
-
this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
|
|
461
|
-
return {
|
|
462
|
-
isValid: false,
|
|
463
|
-
reason: 'last_block_not_found'
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
// Get all full blocks for the slot and checkpoint
|
|
467
|
-
const blocks = await this.blockSource.getBlocksForSlot(slot);
|
|
468
|
-
if (blocks.length === 0) {
|
|
469
|
-
this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
|
|
470
|
-
return {
|
|
471
|
-
isValid: false,
|
|
472
|
-
reason: 'no_blocks_for_slot'
|
|
473
|
-
};
|
|
474
|
-
}
|
|
475
|
-
// Ensure the last block for this slot matches the archive in the checkpoint proposal
|
|
476
|
-
if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
|
|
477
|
-
this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
|
|
478
|
-
return {
|
|
479
|
-
isValid: false,
|
|
480
|
-
reason: 'last_block_archive_mismatch'
|
|
481
|
-
};
|
|
482
|
-
}
|
|
483
|
-
this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
|
|
484
|
-
...proposalInfo,
|
|
485
|
-
blockNumbers: blocks.map((b)=>b.number)
|
|
486
|
-
});
|
|
487
|
-
// Get checkpoint constants from first block
|
|
488
|
-
const firstBlock = blocks[0];
|
|
489
|
-
const constants = this.extractCheckpointConstants(firstBlock);
|
|
490
|
-
const checkpointNumber = firstBlock.checkpointNumber;
|
|
491
|
-
// Get L1-to-L2 messages for this checkpoint
|
|
492
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
493
|
-
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
494
|
-
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
495
|
-
const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch)).filter((c)=>c.checkpointNumber < checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
496
|
-
// Fork world state at the block before the first block
|
|
497
|
-
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
498
|
-
const fork = await this.worldState.fork(parentBlockNumber);
|
|
499
|
-
try {
|
|
500
|
-
// Create checkpoint builder with all existing blocks
|
|
501
|
-
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, proposal.feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
|
|
502
|
-
// Complete the checkpoint to get computed values
|
|
503
|
-
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
504
|
-
// Compare checkpoint header with proposal
|
|
505
|
-
if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
|
|
506
|
-
this.log.warn(`Checkpoint header mismatch`, {
|
|
507
|
-
...proposalInfo,
|
|
508
|
-
computed: computedCheckpoint.header.toInspect(),
|
|
509
|
-
proposal: proposal.checkpointHeader.toInspect()
|
|
510
|
-
});
|
|
511
|
-
return {
|
|
512
|
-
isValid: false,
|
|
513
|
-
reason: 'checkpoint_header_mismatch'
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
// Compare archive root with proposal
|
|
517
|
-
if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
|
|
518
|
-
this.log.warn(`Archive root mismatch`, {
|
|
519
|
-
...proposalInfo,
|
|
520
|
-
computed: computedCheckpoint.archive.root.toString(),
|
|
521
|
-
proposal: proposal.archive.toString()
|
|
522
|
-
});
|
|
523
|
-
return {
|
|
524
|
-
isValid: false,
|
|
525
|
-
reason: 'archive_mismatch'
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
// Check that the accumulated epoch out hash matches the value in the proposal.
|
|
529
|
-
// The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
|
|
530
|
-
const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
|
|
531
|
-
const computedEpochOutHash = accumulateCheckpointOutHashes([
|
|
532
|
-
...previousCheckpointOutHashes,
|
|
533
|
-
checkpointOutHash
|
|
534
|
-
]);
|
|
535
|
-
const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
|
|
536
|
-
if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
|
|
537
|
-
this.log.warn(`Epoch out hash mismatch`, {
|
|
538
|
-
proposalEpochOutHash: proposalEpochOutHash.toString(),
|
|
539
|
-
computedEpochOutHash: computedEpochOutHash.toString(),
|
|
540
|
-
checkpointOutHash: checkpointOutHash.toString(),
|
|
541
|
-
previousCheckpointOutHashes: previousCheckpointOutHashes.map((h)=>h.toString()),
|
|
542
|
-
...proposalInfo
|
|
543
|
-
});
|
|
544
|
-
return {
|
|
545
|
-
isValid: false,
|
|
546
|
-
reason: 'out_hash_mismatch'
|
|
547
|
-
};
|
|
548
|
-
}
|
|
549
|
-
// Final round of validations on the checkpoint, just in case.
|
|
550
|
-
try {
|
|
551
|
-
validateCheckpoint(computedCheckpoint, {
|
|
552
|
-
rollupManaLimit: this.checkpointsBuilder.getConfig().rollupManaLimit,
|
|
553
|
-
maxDABlockGas: this.config.validateMaxDABlockGas,
|
|
554
|
-
maxL2BlockGas: this.config.validateMaxL2BlockGas,
|
|
555
|
-
maxTxsPerBlock: this.config.validateMaxTxsPerBlock,
|
|
556
|
-
maxTxsPerCheckpoint: this.config.validateMaxTxsPerCheckpoint
|
|
557
|
-
});
|
|
558
|
-
} catch (err) {
|
|
559
|
-
this.log.warn(`Checkpoint validation failed: ${err}`, proposalInfo);
|
|
560
|
-
return {
|
|
561
|
-
isValid: false,
|
|
562
|
-
reason: 'checkpoint_validation_failed'
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
|
|
566
|
-
return {
|
|
567
|
-
isValid: true
|
|
568
|
-
};
|
|
569
|
-
} finally{
|
|
570
|
-
await fork.close();
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
/**
|
|
574
|
-
* Extract checkpoint global variables from a block.
|
|
575
|
-
*/ extractCheckpointConstants(block) {
|
|
576
|
-
const gv = block.header.globalVariables;
|
|
577
|
-
return {
|
|
578
|
-
chainId: gv.chainId,
|
|
579
|
-
version: gv.version,
|
|
580
|
-
slotNumber: gv.slotNumber,
|
|
581
|
-
timestamp: gv.timestamp,
|
|
582
|
-
coinbase: gv.coinbase,
|
|
583
|
-
feeRecipient: gv.feeRecipient,
|
|
584
|
-
gasFees: gv.gasFees
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
/**
|
|
588
|
-
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
589
|
-
*/ async uploadBlobsForCheckpoint(proposal, proposalInfo) {
|
|
590
|
-
try {
|
|
591
|
-
const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
592
|
-
if (!lastBlockHeader) {
|
|
593
|
-
this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
|
|
597
|
-
if (blocks.length === 0) {
|
|
598
|
-
this.log.warn(`No blocks found for blob upload`, proposalInfo);
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
const blobFields = blocks.flatMap((b)=>b.toBlobFields());
|
|
602
|
-
const blobs = await getBlobsPerL1Block(blobFields);
|
|
603
|
-
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
604
|
-
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
605
|
-
...proposalInfo,
|
|
606
|
-
numBlobs: blobs.length
|
|
607
|
-
});
|
|
608
|
-
} catch (err) {
|
|
609
|
-
this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
408
|
slashInvalidBlock(proposal) {
|
|
613
409
|
const proposer = proposal.getSender();
|
|
614
410
|
// Skip if signature is invalid (shouldn't happen since we validate earlier)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/validator-client",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.fff30aa",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -64,30 +64,30 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/blob-client": "0.0.1-commit.
|
|
68
|
-
"@aztec/blob-lib": "0.0.1-commit.
|
|
69
|
-
"@aztec/constants": "0.0.1-commit.
|
|
70
|
-
"@aztec/epoch-cache": "0.0.1-commit.
|
|
71
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
72
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
73
|
-
"@aztec/node-keystore": "0.0.1-commit.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
75
|
-
"@aztec/p2p": "0.0.1-commit.
|
|
76
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
77
|
-
"@aztec/prover-client": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/slasher": "0.0.1-commit.
|
|
80
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
81
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
82
|
-
"@aztec/validator-ha-signer": "0.0.1-commit.
|
|
67
|
+
"@aztec/blob-client": "0.0.1-commit.fff30aa",
|
|
68
|
+
"@aztec/blob-lib": "0.0.1-commit.fff30aa",
|
|
69
|
+
"@aztec/constants": "0.0.1-commit.fff30aa",
|
|
70
|
+
"@aztec/epoch-cache": "0.0.1-commit.fff30aa",
|
|
71
|
+
"@aztec/ethereum": "0.0.1-commit.fff30aa",
|
|
72
|
+
"@aztec/foundation": "0.0.1-commit.fff30aa",
|
|
73
|
+
"@aztec/node-keystore": "0.0.1-commit.fff30aa",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.fff30aa",
|
|
75
|
+
"@aztec/p2p": "0.0.1-commit.fff30aa",
|
|
76
|
+
"@aztec/protocol-contracts": "0.0.1-commit.fff30aa",
|
|
77
|
+
"@aztec/prover-client": "0.0.1-commit.fff30aa",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.fff30aa",
|
|
79
|
+
"@aztec/slasher": "0.0.1-commit.fff30aa",
|
|
80
|
+
"@aztec/stdlib": "0.0.1-commit.fff30aa",
|
|
81
|
+
"@aztec/telemetry-client": "0.0.1-commit.fff30aa",
|
|
82
|
+
"@aztec/validator-ha-signer": "0.0.1-commit.fff30aa",
|
|
83
83
|
"koa": "^2.16.1",
|
|
84
84
|
"koa-router": "^13.1.1",
|
|
85
85
|
"tslib": "^2.4.0",
|
|
86
86
|
"viem": "npm:@aztec/viem@2.38.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@aztec/archiver": "0.0.1-commit.
|
|
90
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
89
|
+
"@aztec/archiver": "0.0.1-commit.fff30aa",
|
|
90
|
+
"@aztec/world-state": "0.0.1-commit.fff30aa",
|
|
91
91
|
"@electric-sql/pglite": "^0.3.14",
|
|
92
92
|
"@jest/globals": "^30.0.0",
|
|
93
93
|
"@types/jest": "^30.0.0",
|