@aztec/validator-client 4.0.0-devnet.2-patch.4 → 4.0.0-devnet.3-patch.1
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 +41 -0
- package/dest/checkpoint_builder.d.ts +19 -6
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +115 -39
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +20 -0
- package/dest/duties/validation_service.d.ts +1 -1
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +3 -9
- package/dest/factory.d.ts +7 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -5
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +10 -2
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- 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} +356 -36
- package/dest/validator.d.ts +11 -22
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +41 -217
- package/package.json +19 -19
- package/src/checkpoint_builder.ts +135 -39
- package/src/config.ts +20 -0
- package/src/duties/validation_service.ts +3 -9
- package/src/factory.ts +9 -3
- package/src/index.ts +1 -2
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +19 -1
- package/src/{block_proposal_handler.ts → proposal_handler.ts} +412 -44
- package/src/validator.ts +48 -240
- package/dest/block_proposal_handler.d.ts +0 -63
- package/dest/block_proposal_handler.d.ts.map +0 -1
- 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
package/dest/validator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,WAAW,EACX,gBAAgB,EAEhB,qBAAqB,EACrB,UAAU,EACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAmD,GAAG,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAE/F,OAAO,EAAoC,KAAK,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC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AgB,EAAE,gBAAgB,EAClC,OAAO,EAAE,EAAE,EACX,qBAAqB,EAAE,MAAM,EAC7B,aAAa,EAAE,qCAAqC,GAAG,SAAS,EAChE,eAAe,EAAE,UAAU,GAAG,SAAS,EACvC,OAAO,GAAE,yBAA8B,GACtC,OAAO,CAAC,kBAAkB,CAAC,CAyB7B;IAEK,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;IAEK,0BAA0B,CAC9B,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAC1C,OAAO,CAAC,SAAS,CAAC,CAEpB;IAEK,sBAAsB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAiB3F;IAEK,mBAAmB,CACvB,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,IAAI,GACb,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAiElC;YAEa,iBAAiB;CAwBhC"}
|
package/dest/validator.js
CHANGED
|
@@ -1,26 +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 { getEpochAtSlot
|
|
13
|
-
import { accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
|
|
7
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
14
8
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
15
9
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
16
|
-
import { createHASigner } from '@aztec/validator-ha-signer/factory';
|
|
10
|
+
import { createHASigner, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
|
|
17
11
|
import { DutyType } from '@aztec/validator-ha-signer/types';
|
|
18
12
|
import { EventEmitter } from 'events';
|
|
19
|
-
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
20
13
|
import { ValidationService } from './duties/validation_service.js';
|
|
21
14
|
import { HAKeyStore } from './key_store/ha_key_store.js';
|
|
22
15
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
23
16
|
import { ValidatorMetrics } from './metrics.js';
|
|
17
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
24
18
|
// We maintain a set of proposers who have proposed invalid blocks.
|
|
25
19
|
// Just cap the set to avoid unbounded growth.
|
|
26
20
|
const MAX_PROPOSERS_OF_INVALID_BLOCKS = 1000;
|
|
@@ -35,11 +29,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
35
29
|
keyStore;
|
|
36
30
|
epochCache;
|
|
37
31
|
p2pClient;
|
|
38
|
-
|
|
39
|
-
blockSource;
|
|
40
|
-
checkpointsBuilder;
|
|
41
|
-
worldState;
|
|
42
|
-
l1ToL2MessageSource;
|
|
32
|
+
proposalHandler;
|
|
43
33
|
config;
|
|
44
34
|
blobClient;
|
|
45
35
|
haSigner;
|
|
@@ -54,10 +44,11 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
54
44
|
/** Tracks the last checkpoint proposal we created. */ lastProposedCheckpoint;
|
|
55
45
|
lastEpochForCommitteeUpdateLoop;
|
|
56
46
|
epochCacheUpdateLoop;
|
|
47
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */ lastAttestedEpochByAttester;
|
|
57
48
|
proposersOfInvalidBlocks;
|
|
58
49
|
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */ lastAttestedProposal;
|
|
59
|
-
constructor(keyStore, epochCache, p2pClient,
|
|
60
|
-
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();
|
|
61
52
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
62
53
|
this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
|
|
63
54
|
this.tracer = telemetry.getTracer('Validator');
|
|
@@ -96,6 +87,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
96
87
|
this.log.trace(`No committee found for slot`);
|
|
97
88
|
return;
|
|
98
89
|
}
|
|
90
|
+
this.metrics.setCurrentEpoch(epoch);
|
|
99
91
|
if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
|
|
100
92
|
const me = this.getValidatorAddresses();
|
|
101
93
|
const committeeSet = new Set(committee.map((v)=>v.toString()));
|
|
@@ -111,16 +103,22 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
111
103
|
this.log.error(`Error updating epoch committee`, err);
|
|
112
104
|
}
|
|
113
105
|
}
|
|
114
|
-
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) {
|
|
115
107
|
const metrics = new ValidatorMetrics(telemetry);
|
|
116
108
|
const blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
117
|
-
txsPermitted: !config.disableTransactions
|
|
109
|
+
txsPermitted: !config.disableTransactions,
|
|
110
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock
|
|
118
111
|
});
|
|
119
|
-
const
|
|
112
|
+
const proposalHandler = new ProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, blobClient, metrics, dateProvider, telemetry);
|
|
120
113
|
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
121
114
|
let validatorKeyStore = nodeKeystoreAdapter;
|
|
122
115
|
let haSigner;
|
|
123
|
-
if (
|
|
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) {
|
|
124
122
|
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
125
123
|
const haConfig = {
|
|
126
124
|
...config,
|
|
@@ -130,14 +128,14 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
130
128
|
haSigner = signer;
|
|
131
129
|
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
132
130
|
}
|
|
133
|
-
const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient,
|
|
131
|
+
const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, proposalHandler, config, blobClient, haSigner, dateProvider, telemetry);
|
|
134
132
|
return validator;
|
|
135
133
|
}
|
|
136
134
|
getValidatorAddresses() {
|
|
137
135
|
return this.keyStore.getAddresses().filter((addr)=>!this.config.disabledValidators.some((disabled)=>disabled.equals(addr)));
|
|
138
136
|
}
|
|
139
|
-
|
|
140
|
-
return this.
|
|
137
|
+
getProposalHandler() {
|
|
138
|
+
return this.proposalHandler;
|
|
141
139
|
}
|
|
142
140
|
signWithAddress(addr, msg, context) {
|
|
143
141
|
return this.keyStore.signTypedDataWithAddress(addr, msg, context);
|
|
@@ -231,13 +229,12 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
231
229
|
this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
|
|
232
230
|
return false;
|
|
233
231
|
}
|
|
234
|
-
//
|
|
232
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
235
233
|
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
236
|
-
this.log.
|
|
234
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
237
235
|
proposer: proposer.toString(),
|
|
238
236
|
slotNumber
|
|
239
237
|
});
|
|
240
|
-
return false;
|
|
241
238
|
}
|
|
242
239
|
// Check if we're in the committee (for metrics purposes)
|
|
243
240
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
@@ -255,10 +252,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
255
252
|
// In fisherman mode, we always reexecute to validate proposals.
|
|
256
253
|
const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } = this.config;
|
|
257
254
|
const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
|
|
258
|
-
const validationResult = await this.
|
|
255
|
+
const validationResult = await this.proposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
|
|
259
256
|
if (!validationResult.isValid) {
|
|
260
|
-
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
261
257
|
const reason = validationResult.reason || 'unknown';
|
|
258
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
262
259
|
// Classify failure reason: bad proposal vs node issue
|
|
263
260
|
const badProposalReasons = [
|
|
264
261
|
'invalid_proposal',
|
|
@@ -305,52 +302,36 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
305
302
|
this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
|
|
306
303
|
return undefined;
|
|
307
304
|
}
|
|
308
|
-
// Reject proposals with invalid signatures
|
|
309
|
-
if (!proposer) {
|
|
310
|
-
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
|
|
311
|
-
return undefined;
|
|
312
|
-
}
|
|
313
305
|
// Ignore proposals from ourselves (may happen in HA setups)
|
|
314
|
-
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
315
|
-
this.log.
|
|
306
|
+
if (proposer && this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
307
|
+
this.log.debug(`Ignoring block proposal from self for slot ${slotNumber}`, {
|
|
316
308
|
proposer: proposer.toString(),
|
|
317
309
|
slotNumber
|
|
318
310
|
});
|
|
319
311
|
return undefined;
|
|
320
312
|
}
|
|
321
|
-
//
|
|
322
|
-
if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
|
|
323
|
-
this.log.warn(`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${slotNumber}`);
|
|
324
|
-
return undefined;
|
|
325
|
-
}
|
|
326
|
-
// 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
|
|
327
314
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
328
315
|
const partOfCommittee = inCommittee.length > 0;
|
|
329
316
|
const proposalInfo = {
|
|
330
317
|
slotNumber,
|
|
331
318
|
archive: proposal.archive.toString(),
|
|
332
|
-
proposer: proposer
|
|
333
|
-
txCount: proposal.txHashes.length
|
|
319
|
+
proposer: proposer?.toString()
|
|
334
320
|
};
|
|
335
321
|
this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
|
|
336
322
|
...proposalInfo,
|
|
337
|
-
txHashes: proposal.txHashes.map((t)=>t.toString()),
|
|
338
323
|
fishermanMode: this.config.fishermanMode || false
|
|
339
324
|
});
|
|
340
|
-
// Validate the checkpoint proposal
|
|
325
|
+
// Validate the checkpoint proposal and upload blobs (unless skipCheckpointProposalValidation is set)
|
|
341
326
|
if (this.config.skipCheckpointProposalValidation) {
|
|
342
327
|
this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
343
328
|
} else {
|
|
344
|
-
const validationResult = await this.
|
|
329
|
+
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
345
330
|
if (!validationResult.isValid) {
|
|
346
331
|
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
347
332
|
return undefined;
|
|
348
333
|
}
|
|
349
334
|
}
|
|
350
|
-
// Upload blobs to filestore if we can (fire and forget)
|
|
351
|
-
if (this.blobClient.canUpload()) {
|
|
352
|
-
void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
|
|
353
|
-
}
|
|
354
335
|
// Check that I have any address in current committee before attesting
|
|
355
336
|
// In fisherman mode, we still create attestations for validation even if not in committee
|
|
356
337
|
if (!partOfCommittee && !this.config.fishermanMode) {
|
|
@@ -364,6 +345,16 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
364
345
|
fishermanMode: this.config.fishermanMode || false
|
|
365
346
|
});
|
|
366
347
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
348
|
+
// Track epoch participation per attester: count each (attester, epoch) pair at most once
|
|
349
|
+
const proposalEpoch = getEpochAtSlot(slotNumber, this.epochCache.getL1Constants());
|
|
350
|
+
for (const attester of inCommittee){
|
|
351
|
+
const key = attester.toString();
|
|
352
|
+
const lastEpoch = this.lastAttestedEpochByAttester.get(key);
|
|
353
|
+
if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
|
|
354
|
+
this.lastAttestedEpochByAttester.set(key, proposalEpoch);
|
|
355
|
+
this.metrics.incAttestedEpochCount(attester);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
367
358
|
// Determine which validators should attest
|
|
368
359
|
let attestors;
|
|
369
360
|
if (partOfCommittee) {
|
|
@@ -414,173 +405,6 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
414
405
|
await this.p2pClient.addOwnCheckpointAttestations(attestations);
|
|
415
406
|
return attestations;
|
|
416
407
|
}
|
|
417
|
-
/**
|
|
418
|
-
* Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
|
|
419
|
-
* @returns Validation result with isValid flag and reason if invalid.
|
|
420
|
-
*/ async validateCheckpointProposal(proposal, proposalInfo) {
|
|
421
|
-
const slot = proposal.slotNumber;
|
|
422
|
-
// Timeout block syncing at the start of the next slot
|
|
423
|
-
const config = this.checkpointsBuilder.getConfig();
|
|
424
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
|
|
425
|
-
const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
|
|
426
|
-
// Wait for last block to sync by archive
|
|
427
|
-
let lastBlockHeader;
|
|
428
|
-
try {
|
|
429
|
-
lastBlockHeader = await retryUntil(async ()=>{
|
|
430
|
-
await this.blockSource.syncImmediate();
|
|
431
|
-
return this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
432
|
-
}, `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`, timeoutSeconds, 0.5);
|
|
433
|
-
} catch (err) {
|
|
434
|
-
if (err instanceof TimeoutError) {
|
|
435
|
-
this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
|
|
436
|
-
return {
|
|
437
|
-
isValid: false,
|
|
438
|
-
reason: 'last_block_not_found'
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
|
|
442
|
-
return {
|
|
443
|
-
isValid: false,
|
|
444
|
-
reason: 'block_fetch_error'
|
|
445
|
-
};
|
|
446
|
-
}
|
|
447
|
-
if (!lastBlockHeader) {
|
|
448
|
-
this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
|
|
449
|
-
return {
|
|
450
|
-
isValid: false,
|
|
451
|
-
reason: 'last_block_not_found'
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
// Get all full blocks for the slot and checkpoint
|
|
455
|
-
const blocks = await this.blockSource.getBlocksForSlot(slot);
|
|
456
|
-
if (blocks.length === 0) {
|
|
457
|
-
this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
|
|
458
|
-
return {
|
|
459
|
-
isValid: false,
|
|
460
|
-
reason: 'no_blocks_for_slot'
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
// Ensure the last block for this slot matches the archive in the checkpoint proposal
|
|
464
|
-
if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
|
|
465
|
-
this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
|
|
466
|
-
return {
|
|
467
|
-
isValid: false,
|
|
468
|
-
reason: 'last_block_archive_mismatch'
|
|
469
|
-
};
|
|
470
|
-
}
|
|
471
|
-
this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
|
|
472
|
-
...proposalInfo,
|
|
473
|
-
blockNumbers: blocks.map((b)=>b.number)
|
|
474
|
-
});
|
|
475
|
-
// Get checkpoint constants from first block
|
|
476
|
-
const firstBlock = blocks[0];
|
|
477
|
-
const constants = this.extractCheckpointConstants(firstBlock);
|
|
478
|
-
const checkpointNumber = firstBlock.checkpointNumber;
|
|
479
|
-
// Get L1-to-L2 messages for this checkpoint
|
|
480
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
481
|
-
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
482
|
-
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
483
|
-
const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch)).filter((c)=>c.checkpointNumber < checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
484
|
-
// Fork world state at the block before the first block
|
|
485
|
-
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
486
|
-
const fork = await this.worldState.fork(parentBlockNumber);
|
|
487
|
-
try {
|
|
488
|
-
// Create checkpoint builder with all existing blocks
|
|
489
|
-
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, proposal.feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
|
|
490
|
-
// Complete the checkpoint to get computed values
|
|
491
|
-
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
492
|
-
// Compare checkpoint header with proposal
|
|
493
|
-
if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
|
|
494
|
-
this.log.warn(`Checkpoint header mismatch`, {
|
|
495
|
-
...proposalInfo,
|
|
496
|
-
computed: computedCheckpoint.header.toInspect(),
|
|
497
|
-
proposal: proposal.checkpointHeader.toInspect()
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
isValid: false,
|
|
501
|
-
reason: 'checkpoint_header_mismatch'
|
|
502
|
-
};
|
|
503
|
-
}
|
|
504
|
-
// Compare archive root with proposal
|
|
505
|
-
if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
|
|
506
|
-
this.log.warn(`Archive root mismatch`, {
|
|
507
|
-
...proposalInfo,
|
|
508
|
-
computed: computedCheckpoint.archive.root.toString(),
|
|
509
|
-
proposal: proposal.archive.toString()
|
|
510
|
-
});
|
|
511
|
-
return {
|
|
512
|
-
isValid: false,
|
|
513
|
-
reason: 'archive_mismatch'
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
// Check that the accumulated epoch out hash matches the value in the proposal.
|
|
517
|
-
// The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
|
|
518
|
-
const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
|
|
519
|
-
const computedEpochOutHash = accumulateCheckpointOutHashes([
|
|
520
|
-
...previousCheckpointOutHashes,
|
|
521
|
-
checkpointOutHash
|
|
522
|
-
]);
|
|
523
|
-
const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
|
|
524
|
-
if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
|
|
525
|
-
this.log.warn(`Epoch out hash mismatch`, {
|
|
526
|
-
proposalEpochOutHash: proposalEpochOutHash.toString(),
|
|
527
|
-
computedEpochOutHash: computedEpochOutHash.toString(),
|
|
528
|
-
checkpointOutHash: checkpointOutHash.toString(),
|
|
529
|
-
previousCheckpointOutHashes: previousCheckpointOutHashes.map((h)=>h.toString()),
|
|
530
|
-
...proposalInfo
|
|
531
|
-
});
|
|
532
|
-
return {
|
|
533
|
-
isValid: false,
|
|
534
|
-
reason: 'out_hash_mismatch'
|
|
535
|
-
};
|
|
536
|
-
}
|
|
537
|
-
this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
|
|
538
|
-
return {
|
|
539
|
-
isValid: true
|
|
540
|
-
};
|
|
541
|
-
} finally{
|
|
542
|
-
await fork.close();
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* Extract checkpoint global variables from a block.
|
|
547
|
-
*/ extractCheckpointConstants(block) {
|
|
548
|
-
const gv = block.header.globalVariables;
|
|
549
|
-
return {
|
|
550
|
-
chainId: gv.chainId,
|
|
551
|
-
version: gv.version,
|
|
552
|
-
slotNumber: gv.slotNumber,
|
|
553
|
-
timestamp: gv.timestamp,
|
|
554
|
-
coinbase: gv.coinbase,
|
|
555
|
-
feeRecipient: gv.feeRecipient,
|
|
556
|
-
gasFees: gv.gasFees
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
/**
|
|
560
|
-
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
561
|
-
*/ async uploadBlobsForCheckpoint(proposal, proposalInfo) {
|
|
562
|
-
try {
|
|
563
|
-
const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
564
|
-
if (!lastBlockHeader) {
|
|
565
|
-
this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
|
|
569
|
-
if (blocks.length === 0) {
|
|
570
|
-
this.log.warn(`No blocks found for blob upload`, proposalInfo);
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
const blobFields = blocks.flatMap((b)=>b.toBlobFields());
|
|
574
|
-
const blobs = await getBlobsPerL1Block(blobFields);
|
|
575
|
-
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
576
|
-
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
577
|
-
...proposalInfo,
|
|
578
|
-
numBlobs: blobs.length
|
|
579
|
-
});
|
|
580
|
-
} catch (err) {
|
|
581
|
-
this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
408
|
slashInvalidBlock(proposal) {
|
|
585
409
|
const proposer = proposal.getSender();
|
|
586
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": "4.0.0-devnet.
|
|
3
|
+
"version": "4.0.0-devnet.3-patch.1",
|
|
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.0.0-devnet.
|
|
68
|
-
"@aztec/blob-lib": "4.0.0-devnet.
|
|
69
|
-
"@aztec/constants": "4.0.0-devnet.
|
|
70
|
-
"@aztec/epoch-cache": "4.0.0-devnet.
|
|
71
|
-
"@aztec/ethereum": "4.0.0-devnet.
|
|
72
|
-
"@aztec/foundation": "4.0.0-devnet.
|
|
73
|
-
"@aztec/node-keystore": "4.0.0-devnet.
|
|
74
|
-
"@aztec/noir-protocol-circuits-types": "4.0.0-devnet.
|
|
75
|
-
"@aztec/p2p": "4.0.0-devnet.
|
|
76
|
-
"@aztec/protocol-contracts": "4.0.0-devnet.
|
|
77
|
-
"@aztec/prover-client": "4.0.0-devnet.
|
|
78
|
-
"@aztec/simulator": "4.0.0-devnet.
|
|
79
|
-
"@aztec/slasher": "4.0.0-devnet.
|
|
80
|
-
"@aztec/stdlib": "4.0.0-devnet.
|
|
81
|
-
"@aztec/telemetry-client": "4.0.0-devnet.
|
|
82
|
-
"@aztec/validator-ha-signer": "4.0.0-devnet.
|
|
67
|
+
"@aztec/blob-client": "4.0.0-devnet.3-patch.1",
|
|
68
|
+
"@aztec/blob-lib": "4.0.0-devnet.3-patch.1",
|
|
69
|
+
"@aztec/constants": "4.0.0-devnet.3-patch.1",
|
|
70
|
+
"@aztec/epoch-cache": "4.0.0-devnet.3-patch.1",
|
|
71
|
+
"@aztec/ethereum": "4.0.0-devnet.3-patch.1",
|
|
72
|
+
"@aztec/foundation": "4.0.0-devnet.3-patch.1",
|
|
73
|
+
"@aztec/node-keystore": "4.0.0-devnet.3-patch.1",
|
|
74
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-devnet.3-patch.1",
|
|
75
|
+
"@aztec/p2p": "4.0.0-devnet.3-patch.1",
|
|
76
|
+
"@aztec/protocol-contracts": "4.0.0-devnet.3-patch.1",
|
|
77
|
+
"@aztec/prover-client": "4.0.0-devnet.3-patch.1",
|
|
78
|
+
"@aztec/simulator": "4.0.0-devnet.3-patch.1",
|
|
79
|
+
"@aztec/slasher": "4.0.0-devnet.3-patch.1",
|
|
80
|
+
"@aztec/stdlib": "4.0.0-devnet.3-patch.1",
|
|
81
|
+
"@aztec/telemetry-client": "4.0.0-devnet.3-patch.1",
|
|
82
|
+
"@aztec/validator-ha-signer": "4.0.0-devnet.3-patch.1",
|
|
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.0.0-devnet.
|
|
90
|
-
"@aztec/world-state": "4.0.0-devnet.
|
|
89
|
+
"@aztec/archiver": "4.0.0-devnet.3-patch.1",
|
|
90
|
+
"@aztec/world-state": "4.0.0-devnet.3-patch.1",
|
|
91
91
|
"@electric-sql/pglite": "^0.3.14",
|
|
92
92
|
"@jest/globals": "^30.0.0",
|
|
93
93
|
"@types/jest": "^30.0.0",
|