@aztec/validator-client 0.0.1-commit.21ecf947b → 0.0.1-commit.2448fdb
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} +372 -66
- package/dest/validator.d.ts +13 -18
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +61 -213
- 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/proposal_handler.ts +903 -0
- package/src/validator.ts +78 -239
- 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/block_proposal_handler.ts +0 -556
- 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/src/validator.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
-
import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
3
2
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import { validateFeeAssetPriceModifier } from '@aztec/ethereum/contracts';
|
|
5
3
|
import {
|
|
6
4
|
BlockNumber,
|
|
7
5
|
CheckpointNumber,
|
|
@@ -10,11 +8,9 @@ import {
|
|
|
10
8
|
SlotNumber,
|
|
11
9
|
} from '@aztec/foundation/branded-types';
|
|
12
10
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
13
|
-
import { TimeoutError } from '@aztec/foundation/error';
|
|
14
11
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
15
12
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
16
|
-
import { type
|
|
17
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
13
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
18
14
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
19
15
|
import { sleep } from '@aztec/foundation/sleep';
|
|
20
16
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
@@ -23,8 +19,8 @@ import type { DuplicateAttestationInfo, DuplicateProposalInfo, P2P, PeerId } fro
|
|
|
23
19
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
24
20
|
import { OffenseType, WANT_TO_SLASH_EVENT, type Watcher, type WatcherEmitter } from '@aztec/slasher';
|
|
25
21
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
26
|
-
import type { CommitteeAttestationsAndSigners,
|
|
27
|
-
import { getEpochAtSlot
|
|
22
|
+
import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
23
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
28
24
|
import type {
|
|
29
25
|
CreateCheckpointProposalLastBlockData,
|
|
30
26
|
ITxProvider,
|
|
@@ -32,7 +28,7 @@ import type {
|
|
|
32
28
|
ValidatorClientFullConfig,
|
|
33
29
|
WorldStateSynchronizer,
|
|
34
30
|
} from '@aztec/stdlib/interfaces/server';
|
|
35
|
-
import {
|
|
31
|
+
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
36
32
|
import {
|
|
37
33
|
type BlockProposal,
|
|
38
34
|
type BlockProposalOptions,
|
|
@@ -42,22 +38,23 @@ import {
|
|
|
42
38
|
type CheckpointProposalOptions,
|
|
43
39
|
} from '@aztec/stdlib/p2p';
|
|
44
40
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
45
|
-
import type { BlockHeader,
|
|
41
|
+
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
46
42
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
47
43
|
import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
48
|
-
import { createHASigner } from '@aztec/validator-ha-signer/factory';
|
|
49
|
-
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
44
|
+
import { createHASigner, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
|
|
45
|
+
import { DutyType, type SigningContext, type SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
46
|
+
import type { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
|
|
50
47
|
|
|
51
48
|
import { EventEmitter } from 'events';
|
|
52
49
|
import type { TypedDataDefinition } from 'viem';
|
|
53
50
|
|
|
54
|
-
import { BlockProposalHandler, type BlockProposalValidationFailureReason } from './block_proposal_handler.js';
|
|
55
51
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
56
52
|
import { ValidationService } from './duties/validation_service.js';
|
|
57
53
|
import { HAKeyStore } from './key_store/ha_key_store.js';
|
|
58
54
|
import type { ExtendedValidatorKeyStore } from './key_store/interface.js';
|
|
59
55
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
60
56
|
import { ValidatorMetrics } from './metrics.js';
|
|
57
|
+
import { type BlockProposalValidationFailureReason, ProposalHandler } from './proposal_handler.js';
|
|
61
58
|
|
|
62
59
|
// We maintain a set of proposers who have proposed invalid blocks.
|
|
63
60
|
// Just cap the set to avoid unbounded growth.
|
|
@@ -77,7 +74,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
77
74
|
private validationService: ValidationService;
|
|
78
75
|
private metrics: ValidatorMetrics;
|
|
79
76
|
private log: Logger;
|
|
80
|
-
|
|
81
77
|
// Whether it has already registered handlers on the p2p client
|
|
82
78
|
private hasRegisteredHandlers = false;
|
|
83
79
|
|
|
@@ -89,6 +85,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
89
85
|
|
|
90
86
|
private lastEpochForCommitteeUpdateLoop: EpochNumber | undefined;
|
|
91
87
|
private epochCacheUpdateLoop: RunningPromise;
|
|
88
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */
|
|
89
|
+
private lastAttestedEpochByAttester: Map<string, EpochNumber> = new Map();
|
|
92
90
|
|
|
93
91
|
private proposersOfInvalidBlocks: Set<string> = new Set();
|
|
94
92
|
|
|
@@ -99,13 +97,10 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
99
97
|
private keyStore: ExtendedValidatorKeyStore,
|
|
100
98
|
private epochCache: EpochCache,
|
|
101
99
|
private p2pClient: P2P,
|
|
102
|
-
private
|
|
103
|
-
private blockSource: L2BlockSource,
|
|
104
|
-
private checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
105
|
-
private worldState: WorldStateSynchronizer,
|
|
106
|
-
private l1ToL2MessageSource: L1ToL2MessageSource,
|
|
100
|
+
private proposalHandler: ProposalHandler,
|
|
107
101
|
private config: ValidatorClientFullConfig,
|
|
108
102
|
private blobClient: BlobClientInterface,
|
|
103
|
+
private haSigner: ValidatorHASigner | undefined,
|
|
109
104
|
private dateProvider: DateProvider = new DateProvider(),
|
|
110
105
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
111
106
|
log = createLogger('validator'),
|
|
@@ -159,6 +154,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
159
154
|
this.log.trace(`No committee found for slot`);
|
|
160
155
|
return;
|
|
161
156
|
}
|
|
157
|
+
this.metrics.setCurrentEpoch(epoch);
|
|
162
158
|
if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
|
|
163
159
|
const me = this.getValidatorAddresses();
|
|
164
160
|
const committeeSet = new Set(committee.map(v => v.toString()));
|
|
@@ -192,12 +188,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
192
188
|
blobClient: BlobClientInterface,
|
|
193
189
|
dateProvider: DateProvider = new DateProvider(),
|
|
194
190
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
191
|
+
slashingProtectionDb?: SlashingProtectionDatabase,
|
|
195
192
|
) {
|
|
196
193
|
const metrics = new ValidatorMetrics(telemetry);
|
|
197
194
|
const blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
198
195
|
txsPermitted: !config.disableTransactions,
|
|
196
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock,
|
|
199
197
|
});
|
|
200
|
-
const
|
|
198
|
+
const proposalHandler = new ProposalHandler(
|
|
201
199
|
checkpointsBuilder,
|
|
202
200
|
worldState,
|
|
203
201
|
blockSource,
|
|
@@ -206,33 +204,39 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
206
204
|
blockProposalValidator,
|
|
207
205
|
epochCache,
|
|
208
206
|
config,
|
|
207
|
+
blobClient,
|
|
209
208
|
metrics,
|
|
210
209
|
dateProvider,
|
|
211
210
|
telemetry,
|
|
212
211
|
);
|
|
213
212
|
|
|
214
|
-
|
|
215
|
-
|
|
213
|
+
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
214
|
+
let validatorKeyStore: ExtendedValidatorKeyStore = nodeKeystoreAdapter;
|
|
215
|
+
let haSigner: ValidatorHASigner | undefined;
|
|
216
|
+
if (slashingProtectionDb) {
|
|
217
|
+
// Shared database mode: use a pre-existing database (e.g. for testing HA setups).
|
|
218
|
+
const { signer } = createSignerFromSharedDb(slashingProtectionDb, config);
|
|
219
|
+
haSigner = signer;
|
|
220
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
221
|
+
} else if (config.haSigningEnabled) {
|
|
216
222
|
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
217
223
|
const haConfig = {
|
|
218
224
|
...config,
|
|
219
225
|
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000,
|
|
220
226
|
};
|
|
221
227
|
const { signer } = await createHASigner(haConfig);
|
|
222
|
-
|
|
228
|
+
haSigner = signer;
|
|
229
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
const validator = new ValidatorClient(
|
|
226
233
|
validatorKeyStore,
|
|
227
234
|
epochCache,
|
|
228
235
|
p2pClient,
|
|
229
|
-
|
|
230
|
-
blockSource,
|
|
231
|
-
checkpointsBuilder,
|
|
232
|
-
worldState,
|
|
233
|
-
l1ToL2MessageSource,
|
|
236
|
+
proposalHandler,
|
|
234
237
|
config,
|
|
235
238
|
blobClient,
|
|
239
|
+
haSigner,
|
|
236
240
|
dateProvider,
|
|
237
241
|
telemetry,
|
|
238
242
|
);
|
|
@@ -246,8 +250,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
246
250
|
.filter(addr => !this.config.disabledValidators.some(disabled => disabled.equals(addr)));
|
|
247
251
|
}
|
|
248
252
|
|
|
249
|
-
public
|
|
250
|
-
return this.
|
|
253
|
+
public getProposalHandler() {
|
|
254
|
+
return this.proposalHandler;
|
|
251
255
|
}
|
|
252
256
|
|
|
253
257
|
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
|
|
@@ -270,6 +274,28 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
270
274
|
this.config = { ...this.config, ...config };
|
|
271
275
|
}
|
|
272
276
|
|
|
277
|
+
public reloadKeystore(newManager: KeystoreManager): void {
|
|
278
|
+
if (this.config.haSigningEnabled && !this.haSigner) {
|
|
279
|
+
this.log.warn(
|
|
280
|
+
'HA signing is enabled in config but was not initialized at startup. ' +
|
|
281
|
+
'Restart the node to enable HA signing.',
|
|
282
|
+
);
|
|
283
|
+
} else if (!this.config.haSigningEnabled && this.haSigner) {
|
|
284
|
+
this.log.warn(
|
|
285
|
+
'HA signing was disabled via config update but the HA signer is still active. ' +
|
|
286
|
+
'Restart the node to fully disable HA signing.',
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
291
|
+
if (this.haSigner) {
|
|
292
|
+
this.keyStore = new HAKeyStore(newAdapter, this.haSigner);
|
|
293
|
+
} else {
|
|
294
|
+
this.keyStore = newAdapter;
|
|
295
|
+
}
|
|
296
|
+
this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
|
|
297
|
+
}
|
|
298
|
+
|
|
273
299
|
public async start() {
|
|
274
300
|
if (this.epochCacheUpdateLoop.isRunning()) {
|
|
275
301
|
this.log.warn(`Validator client already started`);
|
|
@@ -353,13 +379,12 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
353
379
|
return false;
|
|
354
380
|
}
|
|
355
381
|
|
|
356
|
-
//
|
|
382
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
357
383
|
if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
358
|
-
this.log.
|
|
384
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
359
385
|
proposer: proposer.toString(),
|
|
360
386
|
slotNumber,
|
|
361
387
|
});
|
|
362
|
-
return false;
|
|
363
388
|
}
|
|
364
389
|
|
|
365
390
|
// Check if we're in the committee (for metrics purposes)
|
|
@@ -384,16 +409,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
384
409
|
alwaysReexecuteBlockProposals ||
|
|
385
410
|
this.blobClient.canUpload();
|
|
386
411
|
|
|
387
|
-
const validationResult = await this.
|
|
412
|
+
const validationResult = await this.proposalHandler.handleBlockProposal(
|
|
388
413
|
proposal,
|
|
389
414
|
proposalSender,
|
|
390
415
|
!!shouldReexecute && !escapeHatchOpen,
|
|
391
416
|
);
|
|
392
417
|
|
|
393
418
|
if (!validationResult.isValid) {
|
|
394
|
-
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
395
|
-
|
|
396
419
|
const reason = validationResult.reason || 'unknown';
|
|
420
|
+
|
|
421
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
422
|
+
|
|
397
423
|
// Classify failure reason: bad proposal vs node issue
|
|
398
424
|
const badProposalReasons: BlockProposalValidationFailureReason[] = [
|
|
399
425
|
'invalid_proposal',
|
|
@@ -457,61 +483,40 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
457
483
|
return undefined;
|
|
458
484
|
}
|
|
459
485
|
|
|
460
|
-
// Reject proposals with invalid signatures
|
|
461
|
-
if (!proposer) {
|
|
462
|
-
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
|
|
463
|
-
return undefined;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
486
|
// Ignore proposals from ourselves (may happen in HA setups)
|
|
467
|
-
if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
468
|
-
this.log.
|
|
487
|
+
if (proposer && this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
488
|
+
this.log.debug(`Ignoring block proposal from self for slot ${slotNumber}`, {
|
|
469
489
|
proposer: proposer.toString(),
|
|
470
490
|
slotNumber,
|
|
471
491
|
});
|
|
472
492
|
return undefined;
|
|
473
493
|
}
|
|
474
494
|
|
|
475
|
-
//
|
|
476
|
-
if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
|
|
477
|
-
this.log.warn(
|
|
478
|
-
`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${slotNumber}`,
|
|
479
|
-
);
|
|
480
|
-
return undefined;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
// Check that I have any address in current committee before attesting
|
|
495
|
+
// Check that I have any address in the committee where this checkpoint will land before attesting
|
|
484
496
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
485
497
|
const partOfCommittee = inCommittee.length > 0;
|
|
486
498
|
|
|
487
499
|
const proposalInfo = {
|
|
488
500
|
slotNumber,
|
|
489
501
|
archive: proposal.archive.toString(),
|
|
490
|
-
proposer: proposer
|
|
491
|
-
txCount: proposal.txHashes.length,
|
|
502
|
+
proposer: proposer?.toString(),
|
|
492
503
|
};
|
|
493
504
|
this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
|
|
494
505
|
...proposalInfo,
|
|
495
|
-
txHashes: proposal.txHashes.map(t => t.toString()),
|
|
496
506
|
fishermanMode: this.config.fishermanMode || false,
|
|
497
507
|
});
|
|
498
508
|
|
|
499
|
-
// Validate the checkpoint proposal
|
|
509
|
+
// Validate the checkpoint proposal and upload blobs (unless skipCheckpointProposalValidation is set)
|
|
500
510
|
if (this.config.skipCheckpointProposalValidation) {
|
|
501
511
|
this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
502
512
|
} else {
|
|
503
|
-
const validationResult = await this.
|
|
513
|
+
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
504
514
|
if (!validationResult.isValid) {
|
|
505
515
|
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
506
516
|
return undefined;
|
|
507
517
|
}
|
|
508
518
|
}
|
|
509
519
|
|
|
510
|
-
// Upload blobs to filestore if we can (fire and forget)
|
|
511
|
-
if (this.blobClient.canUpload()) {
|
|
512
|
-
void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
|
|
513
|
-
}
|
|
514
|
-
|
|
515
520
|
// Check that I have any address in current committee before attesting
|
|
516
521
|
// In fisherman mode, we still create attestations for validation even if not in committee
|
|
517
522
|
if (!partOfCommittee && !this.config.fishermanMode) {
|
|
@@ -528,6 +533,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
528
533
|
|
|
529
534
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
530
535
|
|
|
536
|
+
// Track epoch participation per attester: count each (attester, epoch) pair at most once
|
|
537
|
+
const proposalEpoch = getEpochAtSlot(slotNumber, this.epochCache.getL1Constants());
|
|
538
|
+
for (const attester of inCommittee) {
|
|
539
|
+
const key = attester.toString();
|
|
540
|
+
const lastEpoch = this.lastAttestedEpochByAttester.get(key);
|
|
541
|
+
if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
|
|
542
|
+
this.lastAttestedEpochByAttester.set(key, proposalEpoch);
|
|
543
|
+
this.metrics.incAttestedEpochCount(attester);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
531
547
|
// Determine which validators should attest
|
|
532
548
|
let attestors: EthAddress[];
|
|
533
549
|
if (partOfCommittee) {
|
|
@@ -595,183 +611,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
595
611
|
return attestations;
|
|
596
612
|
}
|
|
597
613
|
|
|
598
|
-
/**
|
|
599
|
-
* Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
|
|
600
|
-
* @returns Validation result with isValid flag and reason if invalid.
|
|
601
|
-
*/
|
|
602
|
-
private async validateCheckpointProposal(
|
|
603
|
-
proposal: CheckpointProposalCore,
|
|
604
|
-
proposalInfo: LogData,
|
|
605
|
-
): Promise<{ isValid: true } | { isValid: false; reason: string }> {
|
|
606
|
-
const slot = proposal.slotNumber;
|
|
607
|
-
|
|
608
|
-
// Timeout block syncing at the start of the next slot
|
|
609
|
-
const config = this.checkpointsBuilder.getConfig();
|
|
610
|
-
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
|
|
611
|
-
const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
|
|
612
|
-
|
|
613
|
-
// Wait for last block to sync by archive
|
|
614
|
-
let lastBlockHeader: BlockHeader | undefined;
|
|
615
|
-
try {
|
|
616
|
-
lastBlockHeader = await retryUntil(
|
|
617
|
-
async () => {
|
|
618
|
-
await this.blockSource.syncImmediate();
|
|
619
|
-
return this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
620
|
-
},
|
|
621
|
-
`waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`,
|
|
622
|
-
timeoutSeconds,
|
|
623
|
-
0.5,
|
|
624
|
-
);
|
|
625
|
-
} catch (err) {
|
|
626
|
-
if (err instanceof TimeoutError) {
|
|
627
|
-
this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
|
|
628
|
-
return { isValid: false, reason: 'last_block_not_found' };
|
|
629
|
-
}
|
|
630
|
-
this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
|
|
631
|
-
return { isValid: false, reason: 'block_fetch_error' };
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
if (!lastBlockHeader) {
|
|
635
|
-
this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
|
|
636
|
-
return { isValid: false, reason: 'last_block_not_found' };
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
// Get all full blocks for the slot and checkpoint
|
|
640
|
-
const blocks = await this.blockSource.getBlocksForSlot(slot);
|
|
641
|
-
if (blocks.length === 0) {
|
|
642
|
-
this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
|
|
643
|
-
return { isValid: false, reason: 'no_blocks_for_slot' };
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
|
|
647
|
-
...proposalInfo,
|
|
648
|
-
blockNumbers: blocks.map(b => b.number),
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
// Get checkpoint constants from first block
|
|
652
|
-
const firstBlock = blocks[0];
|
|
653
|
-
const constants = this.extractCheckpointConstants(firstBlock);
|
|
654
|
-
const checkpointNumber = firstBlock.checkpointNumber;
|
|
655
|
-
|
|
656
|
-
// Get L1-to-L2 messages for this checkpoint
|
|
657
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
658
|
-
|
|
659
|
-
// Compute the previous checkpoint out hashes for the epoch.
|
|
660
|
-
// TODO: There can be a more efficient way to get the previous checkpoint out hashes without having to fetch the
|
|
661
|
-
// actual checkpoints and the blocks/txs in them.
|
|
662
|
-
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
663
|
-
const previousCheckpoints = (await this.blockSource.getCheckpointsForEpoch(epoch))
|
|
664
|
-
.filter(b => b.number < checkpointNumber)
|
|
665
|
-
.sort((a, b) => a.number - b.number);
|
|
666
|
-
const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
|
|
667
|
-
|
|
668
|
-
// Fork world state at the block before the first block
|
|
669
|
-
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
670
|
-
const fork = await this.worldState.fork(parentBlockNumber);
|
|
671
|
-
|
|
672
|
-
try {
|
|
673
|
-
// Create checkpoint builder with all existing blocks
|
|
674
|
-
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
|
|
675
|
-
checkpointNumber,
|
|
676
|
-
constants,
|
|
677
|
-
proposal.feeAssetPriceModifier,
|
|
678
|
-
l1ToL2Messages,
|
|
679
|
-
previousCheckpointOutHashes,
|
|
680
|
-
fork,
|
|
681
|
-
blocks,
|
|
682
|
-
this.log.getBindings(),
|
|
683
|
-
);
|
|
684
|
-
|
|
685
|
-
// Complete the checkpoint to get computed values
|
|
686
|
-
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
687
|
-
|
|
688
|
-
// Compare checkpoint header with proposal
|
|
689
|
-
if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
|
|
690
|
-
this.log.warn(`Checkpoint header mismatch`, {
|
|
691
|
-
...proposalInfo,
|
|
692
|
-
computed: computedCheckpoint.header.toInspect(),
|
|
693
|
-
proposal: proposal.checkpointHeader.toInspect(),
|
|
694
|
-
});
|
|
695
|
-
return { isValid: false, reason: 'checkpoint_header_mismatch' };
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
// Compare archive root with proposal
|
|
699
|
-
if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
|
|
700
|
-
this.log.warn(`Archive root mismatch`, {
|
|
701
|
-
...proposalInfo,
|
|
702
|
-
computed: computedCheckpoint.archive.root.toString(),
|
|
703
|
-
proposal: proposal.archive.toString(),
|
|
704
|
-
});
|
|
705
|
-
return { isValid: false, reason: 'archive_mismatch' };
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
// Check that the accumulated epoch out hash matches the value in the proposal.
|
|
709
|
-
// The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
|
|
710
|
-
const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
|
|
711
|
-
const computedEpochOutHash = accumulateCheckpointOutHashes([...previousCheckpointOutHashes, checkpointOutHash]);
|
|
712
|
-
const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
|
|
713
|
-
if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
|
|
714
|
-
this.log.warn(`Epoch out hash mismatch`, {
|
|
715
|
-
proposalEpochOutHash: proposalEpochOutHash.toString(),
|
|
716
|
-
computedEpochOutHash: computedEpochOutHash.toString(),
|
|
717
|
-
checkpointOutHash: checkpointOutHash.toString(),
|
|
718
|
-
previousCheckpointOutHashes: previousCheckpointOutHashes.map(h => h.toString()),
|
|
719
|
-
...proposalInfo,
|
|
720
|
-
});
|
|
721
|
-
return { isValid: false, reason: 'out_hash_mismatch' };
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
|
|
725
|
-
return { isValid: true };
|
|
726
|
-
} finally {
|
|
727
|
-
await fork.close();
|
|
728
|
-
}
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Extract checkpoint global variables from a block.
|
|
733
|
-
*/
|
|
734
|
-
private extractCheckpointConstants(block: L2Block): CheckpointGlobalVariables {
|
|
735
|
-
const gv = block.header.globalVariables;
|
|
736
|
-
return {
|
|
737
|
-
chainId: gv.chainId,
|
|
738
|
-
version: gv.version,
|
|
739
|
-
slotNumber: gv.slotNumber,
|
|
740
|
-
coinbase: gv.coinbase,
|
|
741
|
-
feeRecipient: gv.feeRecipient,
|
|
742
|
-
gasFees: gv.gasFees,
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
/**
|
|
747
|
-
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
748
|
-
*/
|
|
749
|
-
private async uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void> {
|
|
750
|
-
try {
|
|
751
|
-
const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
752
|
-
if (!lastBlockHeader) {
|
|
753
|
-
this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
|
-
const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
|
|
758
|
-
if (blocks.length === 0) {
|
|
759
|
-
this.log.warn(`No blocks found for blob upload`, proposalInfo);
|
|
760
|
-
return;
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
const blobFields = blocks.flatMap(b => b.toBlobFields());
|
|
764
|
-
const blobs: Blob[] = getBlobsPerL1Block(blobFields);
|
|
765
|
-
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
766
|
-
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
767
|
-
...proposalInfo,
|
|
768
|
-
numBlobs: blobs.length,
|
|
769
|
-
});
|
|
770
|
-
} catch (err) {
|
|
771
|
-
this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
|
|
775
614
|
private slashInvalidBlock(proposal: BlockProposal) {
|
|
776
615
|
const proposer = proposal.getSender();
|
|
777
616
|
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
3
|
-
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
-
import { DateProvider } from '@aztec/foundation/timer';
|
|
5
|
-
import type { P2P, PeerId } from '@aztec/p2p';
|
|
6
|
-
import { BlockProposalValidator } from '@aztec/p2p/msg_validators';
|
|
7
|
-
import type { L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
8
|
-
import type { ITxProvider, ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
9
|
-
import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
10
|
-
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
11
|
-
import { type FailedTx, type Tx } from '@aztec/stdlib/tx';
|
|
12
|
-
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
13
|
-
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
14
|
-
import type { ValidatorMetrics } from './metrics.js';
|
|
15
|
-
export type BlockProposalValidationFailureReason = 'invalid_proposal' | 'parent_block_not_found' | 'parent_block_wrong_slot' | 'in_hash_mismatch' | 'global_variables_mismatch' | 'block_number_already_exists' | 'txs_not_available' | 'state_mismatch' | 'failed_txs' | 'timeout' | 'unknown_error';
|
|
16
|
-
type ReexecuteTransactionsResult = {
|
|
17
|
-
block: L2Block;
|
|
18
|
-
failedTxs: FailedTx[];
|
|
19
|
-
reexecutionTimeMs: number;
|
|
20
|
-
totalManaUsed: number;
|
|
21
|
-
};
|
|
22
|
-
export type BlockProposalValidationSuccessResult = {
|
|
23
|
-
isValid: true;
|
|
24
|
-
blockNumber: BlockNumber;
|
|
25
|
-
reexecutionResult?: ReexecuteTransactionsResult;
|
|
26
|
-
};
|
|
27
|
-
export type BlockProposalValidationFailureResult = {
|
|
28
|
-
isValid: false;
|
|
29
|
-
reason: BlockProposalValidationFailureReason;
|
|
30
|
-
blockNumber?: BlockNumber;
|
|
31
|
-
reexecutionResult?: ReexecuteTransactionsResult;
|
|
32
|
-
};
|
|
33
|
-
export type BlockProposalValidationResult = BlockProposalValidationSuccessResult | BlockProposalValidationFailureResult;
|
|
34
|
-
export declare class BlockProposalHandler {
|
|
35
|
-
private checkpointsBuilder;
|
|
36
|
-
private worldState;
|
|
37
|
-
private blockSource;
|
|
38
|
-
private l1ToL2MessageSource;
|
|
39
|
-
private txProvider;
|
|
40
|
-
private blockProposalValidator;
|
|
41
|
-
private epochCache;
|
|
42
|
-
private config;
|
|
43
|
-
private metrics?;
|
|
44
|
-
private dateProvider;
|
|
45
|
-
private log;
|
|
46
|
-
readonly tracer: Tracer;
|
|
47
|
-
constructor(checkpointsBuilder: FullNodeCheckpointsBuilder, worldState: WorldStateSynchronizer, blockSource: L2BlockSource & L2BlockSink, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: ITxProvider, blockProposalValidator: BlockProposalValidator, epochCache: EpochCache, config: ValidatorClientFullConfig, metrics?: ValidatorMetrics | undefined, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
|
|
48
|
-
registerForReexecution(p2pClient: P2P): BlockProposalHandler;
|
|
49
|
-
handleBlockProposal(proposal: BlockProposal, proposalSender: PeerId, shouldReexecute: boolean): Promise<BlockProposalValidationResult>;
|
|
50
|
-
private getParentBlock;
|
|
51
|
-
private computeCheckpointNumber;
|
|
52
|
-
/**
|
|
53
|
-
* Validates that a non-first block in a checkpoint has consistent global variables with its parent.
|
|
54
|
-
* For blocks with indexWithinCheckpoint > 0, all global variables except blockNumber must match the parent.
|
|
55
|
-
* @returns A failure result if validation fails, undefined if validation passes
|
|
56
|
-
*/
|
|
57
|
-
private validateNonFirstBlockInCheckpoint;
|
|
58
|
-
private getReexecutionDeadline;
|
|
59
|
-
private getReexecuteFailureReason;
|
|
60
|
-
reexecuteTransactions(proposal: BlockProposal, blockNumber: BlockNumber, checkpointNumber: CheckpointNumber, txs: Tx[], l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[]): Promise<ReexecuteTransactionsResult>;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
63
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmxvY2tfcHJvcG9zYWxfaGFuZGxlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2Jsb2NrX3Byb3Bvc2FsX2hhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5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B,sBAAsB,EAAE,sBAAsB,EAC9C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,yBAAyB,EACjC,OAAO,CAAC,8BAAkB,EAC1B,YAAY,GAAE,YAAiC,EACvD,SAAS,GAAE,eAAsC,EACzC,GAAG,yCAAmD,EAM/D;IAED,sBAAsB,CAAC,SAAS,EAAE,GAAG,GAAG,oBAAoB,CA6B3D;IAEK,mBAAmB,CACvB,QAAQ,EAAE,aAAa,EACvB,cAAc,EAAE,MAAM,EACtB,eAAe,EAAE,OAAO,GACvB,OAAO,CAAC,6BAA6B,CAAC,CAmIxC;YAEa,cAAc;YAqCd,uBAAuB;IAoDrC;;;;OAIG;IACH,OAAO,CAAC,iCAAiC;IA4EzC,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,yBAAyB;IAY3B,qBAAqB,CACzB,QAAQ,EAAE,aAAa,EACvB,WAAW,EAAE,WAAW,EACxB,gBAAgB,EAAE,gBAAgB,EAClC,GAAG,EAAE,EAAE,EAAE,EACT,cAAc,EAAE,EAAE,EAAE,EACpB,2BAA2B,EAAE,EAAE,EAAE,GAChC,OAAO,CAAC,2BAA2B,CAAC,CAkGtC;CACF"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export * from './nullifier_cache.js';
|
|
2
|
-
export * from './tx_validator_factory.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eF92YWxpZGF0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLDJCQUEyQixDQUFDIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tx_validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { NullifierSource } from '@aztec/p2p';
|
|
2
|
-
import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
|
|
3
|
-
/**
|
|
4
|
-
* Implements a nullifier source by checking a DB and an in-memory collection.
|
|
5
|
-
* Intended for validating transactions as they are added to a block.
|
|
6
|
-
*/
|
|
7
|
-
export declare class NullifierCache implements NullifierSource {
|
|
8
|
-
private db;
|
|
9
|
-
nullifiers: Set<string>;
|
|
10
|
-
constructor(db: MerkleTreeReadOperations);
|
|
11
|
-
nullifiersExist(nullifiers: Buffer[]): Promise<boolean[]>;
|
|
12
|
-
addNullifiers(nullifiers: Buffer[]): void;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnVsbGlmaWVyX2NhY2hlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHhfdmFsaWRhdG9yL251bGxpZmllcl9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFDbEQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUdoRjs7O0dBR0c7QUFDSCxxQkFBYSxjQUFlLFlBQVcsZUFBZTtJQUd4QyxPQUFPLENBQUMsRUFBRTtJQUZ0QixVQUFVLEVBQUUsR0FBRyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBRXhCLFlBQW9CLEVBQUUsRUFBRSx3QkFBd0IsRUFFL0M7SUFFWSxlQUFlLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxHQUFHLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQU9yRTtJQUVNLGFBQWEsQ0FBQyxVQUFVLEVBQUUsTUFBTSxFQUFFLFFBSXhDO0NBQ0YifQ==
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nullifier_cache.d.ts","sourceRoot":"","sources":["../../src/tx_validator/nullifier_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAGhF;;;GAGG;AACH,qBAAa,cAAe,YAAW,eAAe;IAGxC,OAAO,CAAC,EAAE;IAFtB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAExB,YAAoB,EAAE,EAAE,wBAAwB,EAE/C;IAEY,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAOrE;IAEM,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAIxC;CACF"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { MerkleTreeId } from '@aztec/stdlib/trees';
|
|
2
|
-
/**
|
|
3
|
-
* Implements a nullifier source by checking a DB and an in-memory collection.
|
|
4
|
-
* Intended for validating transactions as they are added to a block.
|
|
5
|
-
*/ export class NullifierCache {
|
|
6
|
-
db;
|
|
7
|
-
nullifiers;
|
|
8
|
-
constructor(db){
|
|
9
|
-
this.db = db;
|
|
10
|
-
this.nullifiers = new Set();
|
|
11
|
-
}
|
|
12
|
-
async nullifiersExist(nullifiers) {
|
|
13
|
-
const cacheResults = nullifiers.map((n)=>this.nullifiers.has(n.toString()));
|
|
14
|
-
const toCheckDb = nullifiers.filter((_n, index)=>!cacheResults[index]);
|
|
15
|
-
const dbHits = await this.db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, toCheckDb);
|
|
16
|
-
let dbIndex = 0;
|
|
17
|
-
return nullifiers.map((_n, index)=>cacheResults[index] || dbHits[dbIndex++] !== undefined);
|
|
18
|
-
}
|
|
19
|
-
addNullifiers(nullifiers) {
|
|
20
|
-
for (const nullifier of nullifiers){
|
|
21
|
-
this.nullifiers.add(nullifier.toString());
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|