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