@aztec-labs/validator-client 6.0.0-nightly.20260829

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.
Files changed (62) hide show
  1. package/README.md +327 -0
  2. package/dest/checkpoint_builder.d.ts +92 -0
  3. package/dest/checkpoint_builder.d.ts.map +1 -0
  4. package/dest/checkpoint_builder.js +272 -0
  5. package/dest/config.d.ts +17 -0
  6. package/dest/config.d.ts.map +1 -0
  7. package/dest/config.js +102 -0
  8. package/dest/duties/validation_service.d.ts +65 -0
  9. package/dest/duties/validation_service.d.ts.map +1 -0
  10. package/dest/duties/validation_service.js +128 -0
  11. package/dest/factory.d.ts +41 -0
  12. package/dest/factory.d.ts.map +1 -0
  13. package/dest/factory.js +19 -0
  14. package/dest/index.d.ts +7 -0
  15. package/dest/index.d.ts.map +1 -0
  16. package/dest/index.js +6 -0
  17. package/dest/key_store/ha_key_store.d.ts +99 -0
  18. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  19. package/dest/key_store/ha_key_store.js +208 -0
  20. package/dest/key_store/index.d.ts +6 -0
  21. package/dest/key_store/index.d.ts.map +1 -0
  22. package/dest/key_store/index.js +5 -0
  23. package/dest/key_store/interface.d.ts +104 -0
  24. package/dest/key_store/interface.d.ts.map +1 -0
  25. package/dest/key_store/interface.js +4 -0
  26. package/dest/key_store/local_key_store.d.ts +63 -0
  27. package/dest/key_store/local_key_store.d.ts.map +1 -0
  28. package/dest/key_store/local_key_store.js +83 -0
  29. package/dest/key_store/node_keystore_adapter.d.ts +151 -0
  30. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -0
  31. package/dest/key_store/node_keystore_adapter.js +330 -0
  32. package/dest/key_store/web3signer_key_store.d.ts +74 -0
  33. package/dest/key_store/web3signer_key_store.d.ts.map +1 -0
  34. package/dest/key_store/web3signer_key_store.js +147 -0
  35. package/dest/metrics.d.ts +31 -0
  36. package/dest/metrics.d.ts.map +1 -0
  37. package/dest/metrics.js +101 -0
  38. package/dest/proposal_handler.d.ts +188 -0
  39. package/dest/proposal_handler.d.ts.map +1 -0
  40. package/dest/proposal_handler.js +1438 -0
  41. package/dest/streaming_inbox_checks.d.ts +103 -0
  42. package/dest/streaming_inbox_checks.d.ts.map +1 -0
  43. package/dest/streaming_inbox_checks.js +112 -0
  44. package/dest/validator.d.ts +137 -0
  45. package/dest/validator.d.ts.map +1 -0
  46. package/dest/validator.js +771 -0
  47. package/package.json +110 -0
  48. package/src/checkpoint_builder.ts +449 -0
  49. package/src/config.ts +130 -0
  50. package/src/duties/validation_service.ts +224 -0
  51. package/src/factory.ts +95 -0
  52. package/src/index.ts +6 -0
  53. package/src/key_store/ha_key_store.ts +268 -0
  54. package/src/key_store/index.ts +5 -0
  55. package/src/key_store/interface.ts +120 -0
  56. package/src/key_store/local_key_store.ts +104 -0
  57. package/src/key_store/node_keystore_adapter.ts +397 -0
  58. package/src/key_store/web3signer_key_store.ts +188 -0
  59. package/src/metrics.ts +150 -0
  60. package/src/proposal_handler.ts +1598 -0
  61. package/src/streaming_inbox_checks.ts +198 -0
  62. package/src/validator.ts +1125 -0
@@ -0,0 +1,272 @@
1
+ import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec-labs/blob-lib/encoding';
2
+ import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec-labs/constants';
3
+ import { merge, pick, sum } from '@aztec-labs/foundation/collection';
4
+ import { createLogger } from '@aztec-labs/foundation/log';
5
+ import { bufferToHex } from '@aztec-labs/foundation/string';
6
+ import { elapsed } from '@aztec-labs/foundation/timer';
7
+ import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec-labs/p2p/msg_validators';
8
+ import { LightweightCheckpointBuilder } from '@aztec-labs/prover-client/light';
9
+ import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, createPublicTxSimulatorForBlockBuilding } from '@aztec-labs/simulator/server';
10
+ import { Gas } from '@aztec-labs/stdlib/gas';
11
+ import { FullNodeBlockBuilderConfigKeys, InsufficientValidTxsError } from '@aztec-labs/stdlib/interfaces/server';
12
+ import { NullDebugLogStore } from '@aztec-labs/stdlib/logs';
13
+ import { MerkleTreeId } from '@aztec-labs/stdlib/trees';
14
+ import { GlobalVariables } from '@aztec-labs/stdlib/tx';
15
+ import { getTelemetryClient } from '@aztec-labs/telemetry-client';
16
+ import { ForkCheckpoint } from '@aztec-labs/world-state';
17
+ /**
18
+ * Builder for a single checkpoint. Handles building blocks within the checkpoint
19
+ * and completing it.
20
+ */ export class CheckpointBuilder {
21
+ checkpointBuilder;
22
+ fork;
23
+ config;
24
+ contractDataSource;
25
+ dateProvider;
26
+ telemetryClient;
27
+ avmSimulator;
28
+ debugLogStore;
29
+ log;
30
+ /** Persistent contracts DB shared across all blocks in this checkpoint. */ contractsDB;
31
+ constructor(checkpointBuilder, fork, config, contractDataSource, dateProvider, telemetryClient, avmSimulator, bindings, debugLogStore = new NullDebugLogStore()){
32
+ this.checkpointBuilder = checkpointBuilder;
33
+ this.fork = fork;
34
+ this.config = config;
35
+ this.contractDataSource = contractDataSource;
36
+ this.dateProvider = dateProvider;
37
+ this.telemetryClient = telemetryClient;
38
+ this.avmSimulator = avmSimulator;
39
+ this.debugLogStore = debugLogStore;
40
+ this.log = createLogger('checkpoint-builder', {
41
+ ...bindings,
42
+ instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`
43
+ });
44
+ this.contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
45
+ }
46
+ getConstantData() {
47
+ return this.checkpointBuilder.constants;
48
+ }
49
+ /**
50
+ * Builds a single block within this checkpoint.
51
+ * Automatically caps gas and blob field limits based on checkpoint-level budgets and prior blocks.
52
+ */ async buildBlock(pendingTxs, blockNumber, timestamp, opts) {
53
+ const slot = this.checkpointBuilder.constants.slotNumber;
54
+ this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
55
+ slot,
56
+ blockNumber,
57
+ ...opts,
58
+ currentTime: new Date(this.dateProvider.now())
59
+ });
60
+ const constants = this.checkpointBuilder.constants;
61
+ const globalVariables = GlobalVariables.from({
62
+ chainId: constants.chainId,
63
+ version: constants.version,
64
+ blockNumber,
65
+ slotNumber: constants.slotNumber,
66
+ timestamp,
67
+ coinbase: constants.coinbase,
68
+ feeRecipient: constants.feeRecipient,
69
+ gasFees: constants.gasFees
70
+ });
71
+ const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
72
+ // Cap gas limits amd available blob fields by remaining checkpoint-level budgets
73
+ const cappedOpts = {
74
+ ...opts,
75
+ ...this.capLimitsByCheckpointBudgets(opts)
76
+ };
77
+ // Create a block-level checkpoint on the contracts DB so we can roll back on failure
78
+ this.contractsDB.createCheckpoint();
79
+ // We execute all merkle tree operations on a world state fork checkpoint
80
+ // This enables us to discard all modifications in the event that we fail to successfully process sufficient transactions
81
+ const forkCheckpoint = await ForkCheckpoint.new(this.fork);
82
+ try {
83
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, cappedOpts, validator));
84
+ // Throw before updating state if we don't have enough valid txs
85
+ const minValidTxs = opts.minValidTxs ?? 0;
86
+ if (processedTxs.length < minValidTxs) {
87
+ throw new InsufficientValidTxsError(processedTxs.length, minValidTxs, failedTxs);
88
+ }
89
+ // Commit the fork checkpoint
90
+ await forkCheckpoint.commit();
91
+ // Add block to checkpoint, inserting this block's streaming L1-to-L2 message bundle (if any) into the fork.
92
+ const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, opts.l1ToL2Messages ?? [], {
93
+ expectedEndState: opts.expectedEndState
94
+ });
95
+ this.contractsDB.commitCheckpoint();
96
+ this.log.debug('Built block within checkpoint', {
97
+ header: block.header.toInspect(),
98
+ processedTxs: processedTxs.map((tx)=>tx.hash.toString()),
99
+ failedTxs: failedTxs.map((tx)=>tx.tx.txHash.toString())
100
+ });
101
+ return {
102
+ block,
103
+ publicProcessorDuration,
104
+ numTxs: processedTxs.length,
105
+ failedTxs,
106
+ usedTxs
107
+ };
108
+ } catch (err) {
109
+ // Revert all changes to contracts db
110
+ this.contractsDB.revertCheckpoint();
111
+ // If we reached the point of committing the checkpoint, this does nothing
112
+ // Otherwise it reverts any changes made to the fork for this failed block
113
+ await forkCheckpoint.revert();
114
+ throw err;
115
+ }
116
+ }
117
+ /** Completes the checkpoint and returns it. */ async completeCheckpoint() {
118
+ const checkpoint = await this.checkpointBuilder.completeCheckpoint();
119
+ this.log.verbose(`Completed checkpoint ${checkpoint.number}`, {
120
+ checkpointNumber: checkpoint.number,
121
+ numBlocks: checkpoint.blocks.length,
122
+ archiveRoot: checkpoint.archive.root.toString()
123
+ });
124
+ return checkpoint;
125
+ }
126
+ /** Gets the checkpoint currently in progress. */ getCheckpoint() {
127
+ return this.checkpointBuilder.clone().completeCheckpoint();
128
+ }
129
+ /**
130
+ * Caps per-block gas and blob field limits by remaining checkpoint-level budgets.
131
+ * When building a proposal (isBuildingProposal=true), computes a fair share of remaining budget
132
+ * across remaining blocks scaled by the multiplier. When validating, only caps by per-block limit
133
+ * and remaining checkpoint budget (no redistribution or multiplier).
134
+ */ capLimitsByCheckpointBudgets(opts) {
135
+ const existingBlocks = this.checkpointBuilder.getBlocks();
136
+ // Remaining L2 gas (mana)
137
+ // IMPORTANT: This assumes mana is computed solely based on L2 gas used in transactions.
138
+ // This may change in the future.
139
+ const usedMana = sum(existingBlocks.map((b)=>b.header.totalManaUsed.toNumber()));
140
+ const remainingMana = this.config.rollupManaLimit - usedMana;
141
+ // Remaining DA gas
142
+ const usedDAGas = sum(existingBlocks.map((b)=>b.computeDAGasUsed())) ?? 0;
143
+ const remainingDAGas = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT - usedDAGas;
144
+ // Remaining blob fields (block blob fields include both tx data and block-end overhead)
145
+ const usedBlobFields = sum(existingBlocks.map((b)=>b.toBlobFields().length));
146
+ const totalBlobCapacity = BLOBS_PER_CHECKPOINT * FIELDS_PER_BLOB - NUM_CHECKPOINT_END_MARKER_FIELDS;
147
+ const blockEndOverhead = getNumBlockEndBlobFields();
148
+ const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
149
+ // Remaining txs
150
+ const usedTxs = sum(existingBlocks.map((b)=>b.body.txEffects.length));
151
+ const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
152
+ // Cap by per-block limit + remaining checkpoint budget
153
+ let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
154
+ let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
155
+ let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
156
+ let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
157
+ // Proposer mode: further cap by fair share of remaining budget across remaining blocks
158
+ if (opts.isBuildingProposal) {
159
+ const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
160
+ const multiplier = opts.perBlockAllocationMultiplier;
161
+ // DA gas and blob fields use a higher multiplier so the largest contract class deploy fits a block.
162
+ const daMultiplier = opts.perBlockDAAllocationMultiplier ?? multiplier;
163
+ cappedL2Gas = Math.min(cappedL2Gas, Math.ceil(remainingMana / remainingBlocks * multiplier));
164
+ cappedDAGas = Math.min(cappedDAGas, Math.ceil(remainingDAGas / remainingBlocks * daMultiplier));
165
+ cappedBlobFields = Math.min(cappedBlobFields, Math.ceil(maxBlobFieldsForTxs / remainingBlocks * daMultiplier));
166
+ cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil(remainingTxs / remainingBlocks * multiplier));
167
+ }
168
+ return {
169
+ maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
170
+ maxBlobFields: cappedBlobFields,
171
+ maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined
172
+ };
173
+ }
174
+ async makeBlockBuilderDeps(globalVariables, fork) {
175
+ const txPublicSetupAllowList = [
176
+ ...await getDefaultAllowedSetupFunctions(),
177
+ ...this.config.txPublicSetupAllowListExtend ?? []
178
+ ];
179
+ const contractsDB = this.contractsDB;
180
+ const guardedFork = new GuardedMerkleTreeOperations(fork);
181
+ const bindings = this.log.getBindings();
182
+ // Extract the WSDB fork ID so the C++ AVM can modify the same fork in-place; the simulator reads
183
+ // contract data from `contractsDB`, scoped to this fork for the duration of each simulation.
184
+ const wsdbForkId = fork.getRevision().forkId;
185
+ const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(this.avmSimulator, globalVariables, contractsDB, wsdbForkId, this.telemetryClient, bindings, this.debugLogStore?.isEnabled ?? false);
186
+ const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', bindings), this.config, this.debugLogStore);
187
+ const validator = createTxValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList, this.log.getBindings());
188
+ return {
189
+ processor,
190
+ validator
191
+ };
192
+ }
193
+ }
194
+ /** Factory for creating checkpoint builders. */ export class FullNodeCheckpointsBuilder {
195
+ config;
196
+ worldState;
197
+ contractDataSource;
198
+ dateProvider;
199
+ avmSimulator;
200
+ telemetryClient;
201
+ debugLogStore;
202
+ log;
203
+ constructor(config, worldState, contractDataSource, dateProvider, avmSimulator, telemetryClient = getTelemetryClient(), debugLogStore = new NullDebugLogStore()){
204
+ this.config = config;
205
+ this.worldState = worldState;
206
+ this.contractDataSource = contractDataSource;
207
+ this.dateProvider = dateProvider;
208
+ this.avmSimulator = avmSimulator;
209
+ this.telemetryClient = telemetryClient;
210
+ this.debugLogStore = debugLogStore;
211
+ this.log = createLogger('checkpoint-builder');
212
+ }
213
+ getConfig() {
214
+ return this.config;
215
+ }
216
+ updateConfig(config) {
217
+ this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
218
+ }
219
+ /**
220
+ * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
221
+ */ async startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, previousCheckpointOutHashes, previousInboxRollingHash, fork, bindings) {
222
+ const stateReference = await fork.getStateReference();
223
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
224
+ this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
225
+ checkpointNumber,
226
+ initialStateReference: stateReference.toInspect(),
227
+ initialArchiveRoot: bufferToHex(archiveTree.root),
228
+ constants,
229
+ feeAssetPriceModifier
230
+ });
231
+ const lightweightBuilder = LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, previousCheckpointOutHashes, previousInboxRollingHash, fork, bindings, feeAssetPriceModifier);
232
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, this.avmSimulator, bindings, this.debugLogStore);
233
+ }
234
+ /**
235
+ * Opens a checkpoint, either starting fresh or resuming from existing blocks.
236
+ * @param l1ToL2Messages - Messages the existing blocks already consumed, which seed the resumed checkpoint's
237
+ * rolling hash. Must be empty when starting fresh: a fresh checkpoint takes its messages per block, via
238
+ * `buildBlock`.
239
+ */ async openCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, previousInboxRollingHash, fork, existingBlocks = [], bindings) {
240
+ const stateReference = await fork.getStateReference();
241
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
242
+ if (existingBlocks.length === 0) {
243
+ if (l1ToL2Messages.length > 0) {
244
+ throw new Error(`Cannot open checkpoint ${checkpointNumber} with ${l1ToL2Messages.length} messages and no existing blocks: ` + `a fresh checkpoint consumes its messages per block`);
245
+ }
246
+ return this.startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, previousCheckpointOutHashes, previousInboxRollingHash, fork, bindings);
247
+ }
248
+ this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
249
+ checkpointNumber,
250
+ msgCount: l1ToL2Messages.length,
251
+ existingBlockCount: existingBlocks.length,
252
+ initialStateReference: stateReference.toInspect(),
253
+ initialArchiveRoot: bufferToHex(archiveTree.root),
254
+ constants,
255
+ feeAssetPriceModifier
256
+ });
257
+ const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, previousInboxRollingHash, fork, existingBlocks, bindings);
258
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, this.avmSimulator, bindings, this.debugLogStore);
259
+ }
260
+ /**
261
+ * Syncs world state to the given block number and returns a fork of it at that block.
262
+ *
263
+ * Syncing first is required: the block source (archiver) can already hold a block while world state
264
+ * still trails it, and forking a not-yet-applied block throws a raw "initialize from future block"
265
+ * tree error. syncImmediate blocks until world state reaches the block, or throws a typed error if it
266
+ * genuinely cannot. When `blockHash` is provided it is verified against the synced block, triggering a
267
+ * resync on mismatch (reorg detection).
268
+ */ async getFork(blockNumber, blockHash) {
269
+ await this.worldState.syncImmediate(blockNumber, blockHash);
270
+ return this.worldState.fork(blockNumber);
271
+ }
272
+ }
@@ -0,0 +1,17 @@
1
+ import { type ConfigMappingsType } from '@aztec-labs/foundation/config';
2
+ import { type SequencerConfig } from '@aztec-labs/stdlib/config';
3
+ import type { ValidatorClientConfig } from '@aztec-labs/stdlib/interfaces/server';
4
+ export type { ValidatorClientConfig };
5
+ /**
6
+ * Default clock-disparity tolerance (ms) for proposal/attestation receive windows, mirroring the p2p config
7
+ * default. Used by the validator-client validators when the merged node config does not carry the value.
8
+ */
9
+ export declare const DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS = 500;
10
+ export declare const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>>;
11
+ /**
12
+ * Returns the prover configuration from the environment variables.
13
+ * Note: If an environment variable is not set, the default value is used.
14
+ * @returns The validator configuration.
15
+ */
16
+ export declare function getProverEnvVars(): ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>;
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQU94QixNQUFNLCtCQUErQixDQUFDO0FBRXZDLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBaUMsTUFBTSwyQkFBMkIsQ0FBQztBQUVoRyxPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBRWxGLFlBQVksRUFBRSxxQkFBcUIsRUFBRSxDQUFDO0FBRXRDOzs7R0FHRztBQUNILGVBQU8sTUFBTSxxQ0FBcUMsTUFBTSxDQUFDO0FBRXpELGVBQU8sTUFBTSw2QkFBNkIsRUFBRSxrQkFBa0IsQ0FDNUQscUJBQXFCLEdBQUcsSUFBSSxDQUFDLGVBQWUsRUFBRSxpQkFBaUIsQ0FBQyxDQStGakUsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZ0JBQWdCLElBQUkscUJBQXFCLEdBQUcsSUFBSSxDQUFDLGVBQWUsRUFBRSxpQkFBaUIsQ0FBQyxDQUluRyJ9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAOxB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,KAAK,eAAe,EAAiC,MAAM,2BAA2B,CAAC;AAEhG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAElF,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC;;;GAGG;AACH,eAAO,MAAM,qCAAqC,MAAM,CAAC;AAEzD,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAC5D,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CA+FjE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAInG"}
package/dest/config.js ADDED
@@ -0,0 +1,102 @@
1
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretValueConfigHelper } from '@aztec-labs/foundation/config';
2
+ import { EthAddress } from '@aztec-labs/foundation/eth-address';
3
+ import { sharedSequencerConfigMappings } from '@aztec-labs/stdlib/config';
4
+ import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec-labs/stdlib/ha-signing';
5
+ /**
6
+ * Default clock-disparity tolerance (ms) for proposal/attestation receive windows, mirroring the p2p config
7
+ * default. Used by the validator-client validators when the merged node config does not carry the value.
8
+ */ export const DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS = 500;
9
+ export const validatorClientConfigMappings = {
10
+ ...pickConfigMappings(sharedSequencerConfigMappings, [
11
+ 'blockDurationMs'
12
+ ]),
13
+ validatorPrivateKeys: {
14
+ env: 'VALIDATOR_PRIVATE_KEYS',
15
+ description: 'List of private keys of the validators participating in attestation duties',
16
+ ...secretValueConfigHelper((val)=>val ? val.split(',').map((key)=>`0x${key.replace('0x', '')}`) : []),
17
+ fallback: [
18
+ 'VALIDATOR_PRIVATE_KEY'
19
+ ]
20
+ },
21
+ validatorAddresses: {
22
+ env: 'VALIDATOR_ADDRESSES',
23
+ description: 'List of addresses of the validators to use with remote signers',
24
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
25
+ defaultValue: []
26
+ },
27
+ l1ChainId: {
28
+ env: 'L1_CHAIN_ID',
29
+ description: 'The chain ID of the ethereum host.',
30
+ parseEnv: (val)=>+val,
31
+ defaultValue: 31337
32
+ },
33
+ disableValidator: {
34
+ env: 'VALIDATOR_DISABLED',
35
+ description: 'Do not run the validator',
36
+ ...booleanConfigHelper(false)
37
+ },
38
+ disabledValidators: {
39
+ description: 'Temporarily disable these specific validator addresses',
40
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
41
+ defaultValue: []
42
+ },
43
+ attestationPollingIntervalMs: {
44
+ env: 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS',
45
+ description: 'Interval between polling for new attestations',
46
+ ...numberConfigHelper(200)
47
+ },
48
+ alwaysReexecuteBlockProposals: {
49
+ description: 'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
50
+ defaultValue: true
51
+ },
52
+ fishermanMode: {
53
+ env: 'FISHERMAN_MODE',
54
+ description: 'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
55
+ ...booleanConfigHelper(false)
56
+ },
57
+ skipCheckpointProposalValidation: {
58
+ description: 'Skip checkpoint proposal validation and always attest (default: false)',
59
+ defaultValue: false
60
+ },
61
+ skipPushProposedBlocksToArchiver: {
62
+ description: 'Skip pushing re-executed blocks to archiver (default: false)',
63
+ defaultValue: false
64
+ },
65
+ attestToEquivocatedProposals: {
66
+ description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
67
+ ...booleanConfigHelper(false)
68
+ },
69
+ skipProposalSlotValidation: {
70
+ description: 'Accept proposal validation regardless of slot timing (for testing only)',
71
+ ...booleanConfigHelper(false)
72
+ },
73
+ validateMaxL2BlockGas: {
74
+ env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
75
+ description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
76
+ ...optionalNumberConfigHelper()
77
+ },
78
+ validateMaxDABlockGas: {
79
+ env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
80
+ description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
81
+ ...optionalNumberConfigHelper()
82
+ },
83
+ validateMaxTxsPerBlock: {
84
+ env: 'VALIDATOR_MAX_TX_PER_BLOCK',
85
+ description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
86
+ ...optionalNumberConfigHelper()
87
+ },
88
+ validateMaxTxsPerCheckpoint: {
89
+ env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
90
+ description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
91
+ ...optionalNumberConfigHelper()
92
+ },
93
+ ...localSignerConfigMappings,
94
+ ...validatorHASignerConfigMappings
95
+ };
96
+ /**
97
+ * Returns the prover configuration from the environment variables.
98
+ * Note: If an environment variable is not set, the default value is used.
99
+ * @returns The validator configuration.
100
+ */ export function getProverEnvVars() {
101
+ return getConfigFromMappings(validatorClientConfigMappings);
102
+ }
@@ -0,0 +1,65 @@
1
+ import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec-labs/foundation/branded-types';
2
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
3
+ import type { EthAddress } from '@aztec-labs/foundation/eth-address';
4
+ import type { Signature } from '@aztec-labs/foundation/eth-signature';
5
+ import { CommitteeAttestationsAndSigners } from '@aztec-labs/stdlib/block';
6
+ import type { InboxBucketRef } from '@aztec-labs/stdlib/messaging';
7
+ import { BlockProposal, type BlockProposalOptions, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions, type CoordinationSignatureContext } from '@aztec-labs/stdlib/p2p';
8
+ import { CheckpointHeader } from '@aztec-labs/stdlib/rollup';
9
+ import type { BlockHeader, Tx } from '@aztec-labs/stdlib/tx';
10
+ import type { ValidatorKeyStore } from '../key_store/interface.js';
11
+ export declare class ValidationService {
12
+ private keyStore;
13
+ private signatureContext;
14
+ private log;
15
+ constructor(keyStore: ValidatorKeyStore, signatureContext: CoordinationSignatureContext, log?: import("@aztec-labs/foundation/log").Logger);
16
+ /**
17
+ * Create a block proposal with the given header, archive, and transactions
18
+ *
19
+ * @param blockHeader - The block header
20
+ * @param blockIndexWithinCheckpoint - The block index within checkpoint for HA signing context
21
+ * @param archive - The archive of the current block
22
+ * @param txs - Ordered list of transactions (Tx[])
23
+ * @param proposerAttesterAddress - The address of the proposer/attester, or undefined
24
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
25
+ *
26
+ * @returns A block proposal signing the above information
27
+ * @throws DutyAlreadySignedError if HA signer indicates duty already signed by another node
28
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
29
+ */
30
+ createBlockProposal(blockHeader: BlockHeader, checkpointNumber: CheckpointNumber, blockIndexWithinCheckpoint: IndexWithinCheckpoint, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions, bucketRef?: InboxBucketRef): Promise<BlockProposal>;
31
+ /**
32
+ * Create a checkpoint proposal with the last block header and checkpoint header
33
+ *
34
+ * @param checkpointHeader - The checkpoint header containing aggregated data
35
+ * @param archive - The archive of the checkpoint
36
+ * @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
37
+ * @param proposerAttesterAddress - The address of the proposer
38
+ * @param options - Checkpoint proposal options
39
+ *
40
+ * @returns A checkpoint proposal signing the above information
41
+ */
42
+ createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, checkpointNumber: CheckpointNumber, feeAssetPriceModifier: bigint, lastBlockProposal: BlockProposal | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
43
+ /**
44
+ * Attest with selection of validators to the given checkpoint proposal
45
+ *
46
+ * NOTE: This is just a blind signing.
47
+ * We assume that the proposal is valid and DA guarantees have been checked previously.
48
+ *
49
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
50
+ * @param attestors - The validators to attest with
51
+ * @returns checkpoint attestations
52
+ */
53
+ attestToCheckpointProposal(proposal: CheckpointProposalCore, attestors: EthAddress[], checkpointNumber: CheckpointNumber): Promise<CheckpointAttestation[]>;
54
+ /**
55
+ * Sign attestations and signers payload
56
+ * @param attestationsAndSigners - The attestations and signers to sign
57
+ * @param proposer - The proposer address to sign with
58
+ * @param slot - The slot number for HA signing context
59
+ * @returns signature
60
+ * @throws DutyAlreadySignedError if already signed by another HA node
61
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
62
+ */
63
+ signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, checkpointNumber: CheckpointNumber): Promise<Signature>;
64
+ }
65
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbl9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZHV0aWVzL3ZhbGlkYXRpb25fc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxxQkFBcUIsRUFBRSxLQUFLLFVBQVUsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQ3JILE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxxQ0FBcUMsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQ0FBb0MsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxzQ0FBc0MsQ0FBQztBQUV0RSxPQUFPLEVBQUUsK0JBQStCLEVBQUUsTUFBTSwwQkFBMEIsQ0FBQztBQUMzRSxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUNuRSxPQUFPLEVBQ0wsYUFBYSxFQUNiLEtBQUssb0JBQW9CLEVBQ3pCLHFCQUF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CAAC,qBAAqB,EAAE,CAAC,CA2ClC;IAED;;;;;;;;OAQG;IACH,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,gBAAgB,EAAE,gBAAgB,GACjC,OAAO,CAAC,SAAS,CAAC,CASpB;CACF"}
@@ -0,0 +1,128 @@
1
+ import { Fr } from '@aztec-labs/foundation/curves/bn254';
2
+ import { createLogger } from '@aztec-labs/foundation/log';
3
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload, getCoordinationSignatureTypedData } from '@aztec-labs/stdlib/p2p';
4
+ import { CheckpointHeader } from '@aztec-labs/stdlib/rollup';
5
+ import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec-labs/validator-ha-signer/errors';
6
+ import { DutyType } from '@aztec-labs/validator-ha-signer/types';
7
+ export class ValidationService {
8
+ keyStore;
9
+ signatureContext;
10
+ log;
11
+ constructor(keyStore, signatureContext, log = createLogger('validator:validation-service')){
12
+ this.keyStore = keyStore;
13
+ this.signatureContext = signatureContext;
14
+ this.log = log;
15
+ }
16
+ /**
17
+ * Create a block proposal with the given header, archive, and transactions
18
+ *
19
+ * @param blockHeader - The block header
20
+ * @param blockIndexWithinCheckpoint - The block index within checkpoint for HA signing context
21
+ * @param archive - The archive of the current block
22
+ * @param txs - Ordered list of transactions (Tx[])
23
+ * @param proposerAttesterAddress - The address of the proposer/attester, or undefined
24
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
25
+ *
26
+ * @returns A block proposal signing the above information
27
+ * @throws DutyAlreadySignedError if HA signer indicates duty already signed by another node
28
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
29
+ */ createBlockProposal(blockHeader, checkpointNumber, blockIndexWithinCheckpoint, archive, txs, proposerAttesterAddress, options, bucketRef) {
30
+ // For testing: change the new archive to trigger state_mismatch validation failure
31
+ if (options.broadcastInvalidBlockProposal) {
32
+ archive = Fr.random();
33
+ this.log.warn(`Creating INVALID block proposal for slot ${blockHeader.globalVariables.slotNumber}`);
34
+ }
35
+ // Create a signer that uses the appropriate address
36
+ const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
37
+ const payloadSigner = (typedData, context)=>this.keyStore.signTypedDataWithAddress(address, typedData, context);
38
+ const txsSigner = (typedData, context)=>this.keyStore.signTypedDataWithAddress(address, typedData, context);
39
+ return BlockProposal.createProposalFromSigner(blockHeader, checkpointNumber, blockIndexWithinCheckpoint, archive, txs.map((tx)=>tx.getTxHash()), options.publishFullTxs ? txs : undefined, this.signatureContext, payloadSigner, txsSigner, bucketRef);
40
+ }
41
+ /**
42
+ * Create a checkpoint proposal with the last block header and checkpoint header
43
+ *
44
+ * @param checkpointHeader - The checkpoint header containing aggregated data
45
+ * @param archive - The archive of the checkpoint
46
+ * @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
47
+ * @param proposerAttesterAddress - The address of the proposer
48
+ * @param options - Checkpoint proposal options
49
+ *
50
+ * @returns A checkpoint proposal signing the above information
51
+ */ createCheckpointProposal(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, proposerAttesterAddress, options) {
52
+ // For testing: corrupt the checkpoint so observers' checkpoint validation fails.
53
+ //
54
+ // Keep `archive` aligned with `lastBlockProposal.archiveRoot` so the archive-based lookup
55
+ // in `validateCheckpointProposal` (`getBlockData({ archive })`) still succeeds
56
+ if (options.broadcastInvalidCheckpointProposal) {
57
+ archive = lastBlockProposal?.archiveRoot ?? Fr.random();
58
+ checkpointHeader = CheckpointHeader.from({
59
+ ...checkpointHeader,
60
+ epochOutHash: Fr.random()
61
+ });
62
+ this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
63
+ }
64
+ // Create a signer that takes payload and context, and uses the appropriate address
65
+ const payloadSigner = (typedData, context)=>{
66
+ const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
67
+ return this.keyStore.signTypedDataWithAddress(address, typedData, context);
68
+ };
69
+ return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, this.signatureContext, payloadSigner);
70
+ }
71
+ /**
72
+ * Attest with selection of validators to the given checkpoint proposal
73
+ *
74
+ * NOTE: This is just a blind signing.
75
+ * We assume that the proposal is valid and DA guarantees have been checked previously.
76
+ *
77
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
78
+ * @param attestors - The validators to attest with
79
+ * @returns checkpoint attestations
80
+ */ async attestToCheckpointProposal(proposal, attestors, checkpointNumber) {
81
+ // Create the attestation payload from the checkpoint proposal
82
+ const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier, this.signatureContext);
83
+ const typedData = getCoordinationSignatureTypedData(payload);
84
+ const context = {
85
+ slot: proposal.slotNumber,
86
+ checkpointNumber,
87
+ dutyType: DutyType.ATTESTATION
88
+ };
89
+ // Sign each attestor in parallel, catching HA errors per-attestor
90
+ const results = await Promise.allSettled(attestors.map(async (attestor)=>{
91
+ const sig = await this.keyStore.signTypedDataWithAddress(attestor, typedData, context);
92
+ return new CheckpointAttestation(payload, sig, proposal.signature);
93
+ }));
94
+ const attestations = [];
95
+ for(let i = 0; i < results.length; i++){
96
+ const result = results[i];
97
+ if (result.status === 'fulfilled') {
98
+ attestations.push(result.value);
99
+ } else {
100
+ const error = result.reason;
101
+ if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
102
+ this.log.verbose(`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`);
103
+ // Continue with remaining attestors
104
+ } else {
105
+ throw error;
106
+ }
107
+ }
108
+ }
109
+ return attestations;
110
+ }
111
+ /**
112
+ * Sign attestations and signers payload
113
+ * @param attestationsAndSigners - The attestations and signers to sign
114
+ * @param proposer - The proposer address to sign with
115
+ * @param slot - The slot number for HA signing context
116
+ * @returns signature
117
+ * @throws DutyAlreadySignedError if already signed by another HA node
118
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
119
+ */ signAttestationsAndSigners(attestationsAndSigners, proposer, slot, checkpointNumber) {
120
+ const context = {
121
+ slot,
122
+ checkpointNumber,
123
+ dutyType: DutyType.ATTESTATIONS_AND_SIGNERS
124
+ };
125
+ const typedData = getCoordinationSignatureTypedData(attestationsAndSigners);
126
+ return this.keyStore.signTypedDataWithAddress(proposer, typedData, context);
127
+ }
128
+ }
@@ -0,0 +1,41 @@
1
+ import type { BlobClientInterface } from '@aztec-labs/blob-client/client';
2
+ import type { EpochCache } from '@aztec-labs/epoch-cache';
3
+ import type { DateProvider } from '@aztec-labs/foundation/timer';
4
+ import type { KeystoreManager } from '@aztec-labs/node-keystore';
5
+ import type { P2PClient } from '@aztec-labs/p2p';
6
+ import type { L2BlockSink, L2BlockSource } from '@aztec-labs/stdlib/block';
7
+ import type { CheckpointReexecutionTracker } from '@aztec-labs/stdlib/checkpoint';
8
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec-labs/stdlib/interfaces/server';
9
+ import type { L1ToL2MessageSource } from '@aztec-labs/stdlib/messaging';
10
+ import type { TelemetryClient } from '@aztec-labs/telemetry-client';
11
+ import type { SlashingProtectionDatabase } from '@aztec-labs/validator-ha-signer/types';
12
+ import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
13
+ import { ProposalHandler } from './proposal_handler.js';
14
+ import { ValidatorClient } from './validator.js';
15
+ export declare function createProposalHandler(config: ValidatorClientFullConfig, deps: {
16
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
17
+ worldState: WorldStateSynchronizer;
18
+ blockSource: L2BlockSource & L2BlockSink;
19
+ l1ToL2MessageSource: L1ToL2MessageSource;
20
+ p2pClient: P2PClient;
21
+ epochCache: EpochCache;
22
+ blobClient: BlobClientInterface;
23
+ dateProvider: DateProvider;
24
+ telemetry: TelemetryClient;
25
+ reexecutionTracker: CheckpointReexecutionTracker;
26
+ }): ProposalHandler;
27
+ export declare function createValidatorClient(config: ValidatorClientFullConfig, deps: {
28
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
29
+ worldState: WorldStateSynchronizer;
30
+ p2pClient: P2PClient;
31
+ blockSource: L2BlockSource & L2BlockSink;
32
+ l1ToL2MessageSource: L1ToL2MessageSource;
33
+ telemetry: TelemetryClient;
34
+ dateProvider: DateProvider;
35
+ epochCache: EpochCache;
36
+ keyStoreManager: KeystoreManager | undefined;
37
+ blobClient: BlobClientInterface;
38
+ reexecutionTracker: CheckpointReexecutionTracker;
39
+ slashingProtectionDb?: SlashingProtectionDatabase;
40
+ }): Promise<ValidatorClient> | undefined;
41
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUMxRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUMxRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw4QkFBOEIsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNqRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQkFBaUIsQ0FBQztBQUNqRCxPQUFPLEtBQUssRUFBRSxXQUFXLEVBQUUsYUFBYSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDM0UsT0FBTyxLQUFLLEVBQUUsNEJBQTRCLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUNsRixPQUFPLEtBQUssRUFBRSx5QkFBeUIsRUFBRSxzQkFBc0IsRUFBRSxNQUFNLHNDQUFzQyxDQUFDO0FBQzlH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