@aztec/validator-client 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa

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 (61) hide show
  1. package/README.md +327 -0
  2. package/dest/checkpoint_builder.d.ts +81 -0
  3. package/dest/checkpoint_builder.d.ts.map +1 -0
  4. package/dest/checkpoint_builder.js +259 -0
  5. package/dest/config.d.ts +9 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +60 -13
  8. package/dest/duties/validation_service.d.ts +44 -16
  9. package/dest/duties/validation_service.d.ts.map +1 -1
  10. package/dest/duties/validation_service.js +104 -34
  11. package/dest/factory.d.ts +22 -11
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +19 -6
  14. package/dest/index.d.ts +3 -2
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +2 -1
  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 +2 -1
  21. package/dest/key_store/index.d.ts.map +1 -1
  22. package/dest/key_store/index.js +1 -0
  23. package/dest/key_store/interface.d.ts +36 -6
  24. package/dest/key_store/interface.d.ts.map +1 -1
  25. package/dest/key_store/local_key_store.d.ts +10 -5
  26. package/dest/key_store/local_key_store.d.ts.map +1 -1
  27. package/dest/key_store/local_key_store.js +9 -5
  28. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  29. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  30. package/dest/key_store/node_keystore_adapter.js +18 -4
  31. package/dest/key_store/web3signer_key_store.d.ts +13 -6
  32. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  33. package/dest/key_store/web3signer_key_store.js +41 -46
  34. package/dest/metrics.d.ts +16 -3
  35. package/dest/metrics.d.ts.map +1 -1
  36. package/dest/metrics.js +58 -30
  37. package/dest/proposal_handler.d.ts +165 -0
  38. package/dest/proposal_handler.d.ts.map +1 -0
  39. package/dest/proposal_handler.js +1207 -0
  40. package/dest/validator.d.ts +94 -25
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +534 -95
  43. package/package.json +24 -14
  44. package/src/checkpoint_builder.ts +426 -0
  45. package/src/config.ts +68 -14
  46. package/src/duties/validation_service.ts +170 -46
  47. package/src/factory.ts +46 -12
  48. package/src/index.ts +2 -1
  49. package/src/key_store/ha_key_store.ts +269 -0
  50. package/src/key_store/index.ts +1 -0
  51. package/src/key_store/interface.ts +44 -5
  52. package/src/key_store/local_key_store.ts +14 -5
  53. package/src/key_store/node_keystore_adapter.ts +28 -5
  54. package/src/key_store/web3signer_key_store.ts +61 -64
  55. package/src/metrics.ts +81 -33
  56. package/src/proposal_handler.ts +1314 -0
  57. package/src/validator.ts +762 -142
  58. package/dest/block_proposal_handler.d.ts +0 -52
  59. package/dest/block_proposal_handler.d.ts.map +0 -1
  60. package/dest/block_proposal_handler.js +0 -286
  61. package/src/block_proposal_handler.ts +0 -343
@@ -0,0 +1,259 @@
1
+ import { NUM_CHECKPOINT_END_MARKER_FIELDS, getNumBlockEndBlobFields } from '@aztec/blob-lib/encoding';
2
+ import { BLOBS_PER_CHECKPOINT, FIELDS_PER_BLOB, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT } from '@aztec/constants';
3
+ import { merge, pick, sum } from '@aztec/foundation/collection';
4
+ import { createLogger } from '@aztec/foundation/log';
5
+ import { bufferToHex } from '@aztec/foundation/string';
6
+ import { elapsed } from '@aztec/foundation/timer';
7
+ import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
8
+ import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
9
+ import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, createPublicTxSimulatorForBlockBuilding } from '@aztec/simulator/server';
10
+ import { Gas } from '@aztec/stdlib/gas';
11
+ import { FullNodeBlockBuilderConfigKeys, InsufficientValidTxsError } from '@aztec/stdlib/interfaces/server';
12
+ import { NullDebugLogStore } from '@aztec/stdlib/logs';
13
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
14
+ import { GlobalVariables } from '@aztec/stdlib/tx';
15
+ import { getTelemetryClient } from '@aztec/telemetry-client';
16
+ import { ForkCheckpoint } from '@aztec/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
92
+ const { block } = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
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 isFirstBlock = existingBlocks.length === 0;
148
+ const blockEndOverhead = getNumBlockEndBlobFields(isFirstBlock);
149
+ const maxBlobFieldsForTxs = totalBlobCapacity - usedBlobFields - blockEndOverhead;
150
+ // Remaining txs
151
+ const usedTxs = sum(existingBlocks.map((b)=>b.body.txEffects.length));
152
+ const remainingTxs = Math.max(0, (this.config.maxTxsPerCheckpoint ?? Infinity) - usedTxs);
153
+ // Cap by per-block limit + remaining checkpoint budget
154
+ let cappedL2Gas = Math.min(opts.maxBlockGas?.l2Gas ?? Infinity, remainingMana);
155
+ let cappedDAGas = Math.min(opts.maxBlockGas?.daGas ?? Infinity, remainingDAGas);
156
+ let cappedBlobFields = Math.min(opts.maxBlobFields ?? Infinity, maxBlobFieldsForTxs);
157
+ let cappedMaxTransactions = Math.min(opts.maxTransactions ?? Infinity, remainingTxs);
158
+ // Proposer mode: further cap by fair share of remaining budget across remaining blocks
159
+ if (opts.isBuildingProposal) {
160
+ const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
161
+ const multiplier = opts.perBlockAllocationMultiplier;
162
+ // DA gas and blob fields use a higher multiplier so the largest contract class deploy fits a block.
163
+ const daMultiplier = opts.perBlockDAAllocationMultiplier ?? multiplier;
164
+ cappedL2Gas = Math.min(cappedL2Gas, Math.ceil(remainingMana / remainingBlocks * multiplier));
165
+ cappedDAGas = Math.min(cappedDAGas, Math.ceil(remainingDAGas / remainingBlocks * daMultiplier));
166
+ cappedBlobFields = Math.min(cappedBlobFields, Math.ceil(maxBlobFieldsForTxs / remainingBlocks * daMultiplier));
167
+ cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil(remainingTxs / remainingBlocks * multiplier));
168
+ }
169
+ return {
170
+ maxBlockGas: new Gas(cappedDAGas, cappedL2Gas),
171
+ maxBlobFields: cappedBlobFields,
172
+ maxTransactions: Number.isFinite(cappedMaxTransactions) ? cappedMaxTransactions : undefined
173
+ };
174
+ }
175
+ async makeBlockBuilderDeps(globalVariables, fork) {
176
+ const txPublicSetupAllowList = [
177
+ ...await getDefaultAllowedSetupFunctions(),
178
+ ...this.config.txPublicSetupAllowListExtend ?? []
179
+ ];
180
+ const contractsDB = this.contractsDB;
181
+ const guardedFork = new GuardedMerkleTreeOperations(fork);
182
+ const bindings = this.log.getBindings();
183
+ // Extract the WSDB fork ID so the C++ AVM can modify the same fork in-place; the simulator reads
184
+ // contract data from `contractsDB`, scoped to this fork for the duration of each simulation.
185
+ const wsdbForkId = fork.getRevision().forkId;
186
+ const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(this.avmSimulator, globalVariables, contractsDB, wsdbForkId, this.telemetryClient, bindings, this.debugLogStore?.isEnabled ?? false);
187
+ const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', bindings), this.config, this.debugLogStore);
188
+ const validator = createTxValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList, this.log.getBindings());
189
+ return {
190
+ processor,
191
+ validator
192
+ };
193
+ }
194
+ }
195
+ /** Factory for creating checkpoint builders. */ export class FullNodeCheckpointsBuilder {
196
+ config;
197
+ worldState;
198
+ contractDataSource;
199
+ dateProvider;
200
+ avmSimulator;
201
+ telemetryClient;
202
+ debugLogStore;
203
+ log;
204
+ constructor(config, worldState, contractDataSource, dateProvider, avmSimulator, telemetryClient = getTelemetryClient(), debugLogStore = new NullDebugLogStore()){
205
+ this.config = config;
206
+ this.worldState = worldState;
207
+ this.contractDataSource = contractDataSource;
208
+ this.dateProvider = dateProvider;
209
+ this.avmSimulator = avmSimulator;
210
+ this.telemetryClient = telemetryClient;
211
+ this.debugLogStore = debugLogStore;
212
+ this.log = createLogger('checkpoint-builder');
213
+ }
214
+ getConfig() {
215
+ return this.config;
216
+ }
217
+ updateConfig(config) {
218
+ this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
219
+ }
220
+ /**
221
+ * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
222
+ */ async startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings) {
223
+ const stateReference = await fork.getStateReference();
224
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
225
+ this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
226
+ checkpointNumber,
227
+ msgCount: l1ToL2Messages.length,
228
+ initialStateReference: stateReference.toInspect(),
229
+ initialArchiveRoot: bufferToHex(archiveTree.root),
230
+ constants,
231
+ feeAssetPriceModifier
232
+ });
233
+ const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings, feeAssetPriceModifier);
234
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, this.avmSimulator, bindings, this.debugLogStore);
235
+ }
236
+ /**
237
+ * Opens a checkpoint, either starting fresh or resuming from existing blocks.
238
+ */ async openCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks = [], bindings) {
239
+ const stateReference = await fork.getStateReference();
240
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
241
+ if (existingBlocks.length === 0) {
242
+ return this.startCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
243
+ }
244
+ this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
245
+ checkpointNumber,
246
+ msgCount: l1ToL2Messages.length,
247
+ existingBlockCount: existingBlocks.length,
248
+ initialStateReference: stateReference.toInspect(),
249
+ initialArchiveRoot: bufferToHex(archiveTree.root),
250
+ constants,
251
+ feeAssetPriceModifier
252
+ });
253
+ const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks, bindings);
254
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, this.avmSimulator, bindings, this.debugLogStore);
255
+ }
256
+ /** Returns a fork of the world state at the given block number. */ getFork(blockNumber) {
257
+ return this.worldState.fork(blockNumber);
258
+ }
259
+ }
package/dest/config.d.ts CHANGED
@@ -1,11 +1,17 @@
1
1
  import { type ConfigMappingsType } from '@aztec/foundation/config';
2
+ import { type SequencerConfig } from '@aztec/stdlib/config';
2
3
  import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
3
4
  export type { ValidatorClientConfig };
4
- export declare const validatorClientConfigMappings: ConfigMappingsType<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'>>;
5
11
  /**
6
12
  * Returns the prover configuration from the environment variables.
7
13
  * Note: If an environment variable is not set, the default value is used.
8
14
  * @returns The validator configuration.
9
15
  */
10
- export declare function getProverEnvVars(): ValidatorClientConfig;
11
- //# sourceMappingURL=config.d.ts.map
16
+ export declare function getProverEnvVars(): ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>;
17
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQU94QixNQUFNLDBCQUEwQixDQUFDO0FBRWxDLE9BQU8sRUFBRSxLQUFLLGVBQWUsRUFBaUMsTUFBTSxzQkFBc0IsQ0FBQztBQUUzRixPQUFPLEtBQUssRUFBRSxxQkFBcUIsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTdFLFlBQVksRUFBRSxxQkFBcUIsRUFBRSxDQUFDO0FBRXRDOzs7R0FHRztBQUNILGVBQU8sTUFBTSxxQ0FBcUMsTUFBTSxDQUFDO0FBRXpELGVBQU8sTUFBTSw2QkFBNkIsRUFBRSxrQkFBa0IsQ0FDNUQscUJBQXFCLEdBQUcsSUFBSSxDQUFDLGVBQWUsRUFBRSxpQkFBaUIsQ0FBQyxDQStGakUsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZ0JBQWdCLElBQUkscUJBQXFCLEdBQUcsSUFBSSxDQUFDLGVBQWUsRUFBRSxpQkFBaUIsQ0FBQyxDQUluRyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAKxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CAsDnF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EAOxB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,eAAe,EAAiC,MAAM,sBAAsB,CAAC;AAE3F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAE7E,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 CHANGED
@@ -1,6 +1,15 @@
1
- import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, secretValueConfigHelper } from '@aztec/foundation/config';
1
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, optionalNumberConfigHelper, pickConfigMappings, secretValueConfigHelper } from '@aztec/foundation/config';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
+ import { sharedSequencerConfigMappings } from '@aztec/stdlib/config';
4
+ import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec/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;
3
9
  export const validatorClientConfigMappings = {
10
+ ...pickConfigMappings(sharedSequencerConfigMappings, [
11
+ 'blockDurationMs'
12
+ ]),
4
13
  validatorPrivateKeys: {
5
14
  env: 'VALIDATOR_PRIVATE_KEYS',
6
15
  description: 'List of private keys of the validators participating in attestation duties',
@@ -15,6 +24,12 @@ export const validatorClientConfigMappings = {
15
24
  parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
16
25
  defaultValue: []
17
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
+ },
18
33
  disableValidator: {
19
34
  env: 'VALIDATOR_DISABLED',
20
35
  description: 'Do not run the validator',
@@ -30,21 +45,53 @@ export const validatorClientConfigMappings = {
30
45
  description: 'Interval between polling for new attestations',
31
46
  ...numberConfigHelper(200)
32
47
  },
33
- validatorReexecute: {
34
- env: 'VALIDATOR_REEXECUTE',
35
- description: 'Re-execute transactions before attesting',
36
- ...booleanConfigHelper(true)
37
- },
38
- validatorReexecuteDeadlineMs: {
39
- env: 'VALIDATOR_REEXECUTE_DEADLINE_MS',
40
- description: 'Will re-execute until this many milliseconds are left in the slot',
41
- ...numberConfigHelper(6000)
42
- },
43
48
  alwaysReexecuteBlockProposals: {
44
- env: 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS',
45
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)',
46
71
  ...booleanConfigHelper(false)
47
- }
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
48
95
  };
49
96
  /**
50
97
  * Returns the prover configuration from the environment variables.
@@ -1,37 +1,65 @@
1
+ import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
1
3
  import type { EthAddress } from '@aztec/foundation/eth-address';
2
4
  import type { Signature } from '@aztec/foundation/eth-signature';
3
- import { Fr } from '@aztec/foundation/fields';
4
- import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
5
- import { BlockAttestation, BlockProposal, type BlockProposalOptions } from '@aztec/stdlib/p2p';
6
- import type { CheckpointHeader } from '@aztec/stdlib/rollup';
7
- import { StateReference, type Tx } from '@aztec/stdlib/tx';
5
+ import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
6
+ import { BlockProposal, type BlockProposalOptions, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions, type CoordinationSignatureContext } from '@aztec/stdlib/p2p';
7
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
8
+ import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
8
9
  import type { ValidatorKeyStore } from '../key_store/interface.js';
9
10
  export declare class ValidationService {
10
11
  private keyStore;
12
+ private signatureContext;
11
13
  private log;
12
- constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
14
+ constructor(keyStore: ValidatorKeyStore, signatureContext: CoordinationSignatureContext, log?: import("@aztec/foundation/log").Logger);
13
15
  /**
14
16
  * Create a block proposal with the given header, archive, and transactions
15
17
  *
16
- * @param header - The block header
18
+ * @param blockHeader - The block header
19
+ * @param blockIndexWithinCheckpoint - The block index within checkpoint for HA signing context
20
+ * @param inHash - Hash of L1 to L2 messages for this checkpoint
17
21
  * @param archive - The archive of the current block
18
- * @param txs - TxHash[] ordered list of transactions
22
+ * @param txs - Ordered list of transactions (Tx[])
23
+ * @param proposerAttesterAddress - The address of the proposer/attester, or undefined
19
24
  * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
20
25
  *
21
- * @returns A block proposal signing the above information (not the current implementation!!!)
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
22
29
  */
23
- createBlockProposal(header: CheckpointHeader, archive: Fr, stateReference: StateReference, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
30
+ createBlockProposal(blockHeader: BlockHeader, checkpointNumber: CheckpointNumber, blockIndexWithinCheckpoint: IndexWithinCheckpoint, inHash: Fr, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
24
31
  /**
25
- * Attest with selection of validators to the given block proposal, constructed by the current sequencer
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
26
45
  *
27
46
  * NOTE: This is just a blind signing.
28
47
  * We assume that the proposal is valid and DA guarantees have been checked previously.
29
48
  *
30
- * @param proposal - The proposal to attest to
49
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
31
50
  * @param attestors - The validators to attest with
32
- * @returns attestations
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
33
62
  */
34
- attestToProposal(proposal: BlockProposal, attestors: EthAddress[]): Promise<BlockAttestation[]>;
35
- signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress): Promise<Signature>;
63
+ signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, checkpointNumber: CheckpointNumber): Promise<Signature>;
36
64
  }
37
- //# sourceMappingURL=validation_service.d.ts.map
65
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbl9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZHV0aWVzL3ZhbGlkYXRpb25fc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBRSxxQkFBcUIsRUFBRSxLQUFLLFVBQVUsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQ2hILE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFB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