@aztec/validator-client 0.0.1-commit.b6e433891 → 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 (42) hide show
  1. package/README.md +12 -11
  2. package/dest/checkpoint_builder.d.ts +6 -4
  3. package/dest/checkpoint_builder.d.ts.map +1 -1
  4. package/dest/checkpoint_builder.js +16 -8
  5. package/dest/config.d.ts +9 -3
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +23 -10
  8. package/dest/duties/validation_service.d.ts +12 -13
  9. package/dest/duties/validation_service.d.ts.map +1 -1
  10. package/dest/duties/validation_service.js +32 -38
  11. package/dest/factory.d.ts +8 -4
  12. package/dest/factory.d.ts.map +1 -1
  13. package/dest/factory.js +18 -6
  14. package/dest/index.d.ts +2 -2
  15. package/dest/index.d.ts.map +1 -1
  16. package/dest/index.js +1 -1
  17. package/dest/key_store/web3signer_key_store.d.ts +10 -2
  18. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  19. package/dest/key_store/web3signer_key_store.js +32 -41
  20. package/dest/metrics.d.ts +6 -2
  21. package/dest/metrics.d.ts.map +1 -1
  22. package/dest/metrics.js +12 -0
  23. package/dest/proposal_handler.d.ts +165 -0
  24. package/dest/proposal_handler.d.ts.map +1 -0
  25. package/dest/proposal_handler.js +1207 -0
  26. package/dest/validator.d.ts +35 -21
  27. package/dest/validator.d.ts.map +1 -1
  28. package/dest/validator.js +225 -249
  29. package/package.json +19 -19
  30. package/src/checkpoint_builder.ts +16 -7
  31. package/src/config.ts +31 -12
  32. package/src/duties/validation_service.ts +51 -47
  33. package/src/factory.ts +25 -4
  34. package/src/index.ts +1 -1
  35. package/src/key_store/web3signer_key_store.ts +43 -59
  36. package/src/metrics.ts +19 -1
  37. package/src/proposal_handler.ts +1314 -0
  38. package/src/validator.ts +294 -281
  39. package/dest/block_proposal_handler.d.ts +0 -64
  40. package/dest/block_proposal_handler.d.ts.map +0 -1
  41. package/dest/block_proposal_handler.js +0 -614
  42. package/src/block_proposal_handler.ts +0 -632
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/validator-client",
3
- "version": "0.0.1-commit.b6e433891",
3
+ "version": "0.0.1-commit.b8a057fa",
4
4
  "main": "dest/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,30 +64,30 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/blob-client": "0.0.1-commit.b6e433891",
68
- "@aztec/blob-lib": "0.0.1-commit.b6e433891",
69
- "@aztec/constants": "0.0.1-commit.b6e433891",
70
- "@aztec/epoch-cache": "0.0.1-commit.b6e433891",
71
- "@aztec/ethereum": "0.0.1-commit.b6e433891",
72
- "@aztec/foundation": "0.0.1-commit.b6e433891",
73
- "@aztec/node-keystore": "0.0.1-commit.b6e433891",
74
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b6e433891",
75
- "@aztec/p2p": "0.0.1-commit.b6e433891",
76
- "@aztec/protocol-contracts": "0.0.1-commit.b6e433891",
77
- "@aztec/prover-client": "0.0.1-commit.b6e433891",
78
- "@aztec/simulator": "0.0.1-commit.b6e433891",
79
- "@aztec/slasher": "0.0.1-commit.b6e433891",
80
- "@aztec/stdlib": "0.0.1-commit.b6e433891",
81
- "@aztec/telemetry-client": "0.0.1-commit.b6e433891",
82
- "@aztec/validator-ha-signer": "0.0.1-commit.b6e433891",
67
+ "@aztec/blob-client": "0.0.1-commit.b8a057fa",
68
+ "@aztec/blob-lib": "0.0.1-commit.b8a057fa",
69
+ "@aztec/constants": "0.0.1-commit.b8a057fa",
70
+ "@aztec/epoch-cache": "0.0.1-commit.b8a057fa",
71
+ "@aztec/ethereum": "0.0.1-commit.b8a057fa",
72
+ "@aztec/foundation": "0.0.1-commit.b8a057fa",
73
+ "@aztec/node-keystore": "0.0.1-commit.b8a057fa",
74
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.b8a057fa",
75
+ "@aztec/p2p": "0.0.1-commit.b8a057fa",
76
+ "@aztec/protocol-contracts": "0.0.1-commit.b8a057fa",
77
+ "@aztec/prover-client": "0.0.1-commit.b8a057fa",
78
+ "@aztec/simulator": "0.0.1-commit.b8a057fa",
79
+ "@aztec/slasher": "0.0.1-commit.b8a057fa",
80
+ "@aztec/stdlib": "0.0.1-commit.b8a057fa",
81
+ "@aztec/telemetry-client": "0.0.1-commit.b8a057fa",
82
+ "@aztec/validator-ha-signer": "0.0.1-commit.b8a057fa",
83
83
  "koa": "^2.16.1",
84
84
  "koa-router": "^13.1.1",
85
85
  "tslib": "^2.4.0",
86
86
  "viem": "npm:@aztec/viem@2.38.2"
87
87
  },
88
88
  "devDependencies": {
89
- "@aztec/archiver": "0.0.1-commit.b6e433891",
90
- "@aztec/world-state": "0.0.1-commit.b6e433891",
89
+ "@aztec/archiver": "0.0.1-commit.b8a057fa",
90
+ "@aztec/world-state": "0.0.1-commit.b8a057fa",
91
91
  "@electric-sql/pglite": "^0.3.14",
92
92
  "@jest/globals": "^30.0.0",
93
93
  "@types/jest": "^30.0.0",
@@ -9,6 +9,7 @@ import { DateProvider, elapsed } from '@aztec/foundation/timer';
9
9
  import { createTxValidatorForBlockBuilding, getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
10
10
  import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
11
11
  import {
12
+ type AvmSimulator,
12
13
  GuardedMerkleTreeOperations,
13
14
  PublicContractsDB,
14
15
  PublicProcessor,
@@ -57,6 +58,7 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
57
58
  private contractDataSource: ContractDataSource,
58
59
  private dateProvider: DateProvider,
59
60
  private telemetryClient: TelemetryClient,
61
+ private avmSimulator: AvmSimulator,
60
62
  bindings?: LoggerBindings,
61
63
  private debugLogStore: DebugLogStore = new NullDebugLogStore(),
62
64
  ) {
@@ -219,10 +221,12 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
219
221
  if (opts.isBuildingProposal) {
220
222
  const remainingBlocks = Math.max(1, opts.maxBlocksPerCheckpoint - existingBlocks.length);
221
223
  const multiplier = opts.perBlockAllocationMultiplier;
224
+ // DA gas and blob fields use a higher multiplier so the largest contract class deploy fits a block.
225
+ const daMultiplier = opts.perBlockDAAllocationMultiplier ?? multiplier;
222
226
 
223
227
  cappedL2Gas = Math.min(cappedL2Gas, Math.ceil((remainingMana / remainingBlocks) * multiplier));
224
- cappedDAGas = Math.min(cappedDAGas, Math.ceil((remainingDAGas / remainingBlocks) * multiplier));
225
- cappedBlobFields = Math.min(cappedBlobFields, Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * multiplier));
228
+ cappedDAGas = Math.min(cappedDAGas, Math.ceil((remainingDAGas / remainingBlocks) * daMultiplier));
229
+ cappedBlobFields = Math.min(cappedBlobFields, Math.ceil((maxBlobFieldsForTxs / remainingBlocks) * daMultiplier));
226
230
  cappedMaxTransactions = Math.min(cappedMaxTransactions, Math.ceil((remainingTxs / remainingBlocks) * multiplier));
227
231
  }
228
232
 
@@ -241,16 +245,18 @@ export class CheckpointBuilder implements ICheckpointBlockBuilder {
241
245
  const contractsDB = this.contractsDB;
242
246
  const guardedFork = new GuardedMerkleTreeOperations(fork);
243
247
 
244
- const collectDebugLogs = this.debugLogStore.isEnabled;
245
-
246
248
  const bindings = this.log.getBindings();
249
+ // Extract the WSDB fork ID so the C++ AVM can modify the same fork in-place; the simulator reads
250
+ // contract data from `contractsDB`, scoped to this fork for the duration of each simulation.
251
+ const wsdbForkId = fork.getRevision().forkId;
247
252
  const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(
248
- guardedFork,
249
- contractsDB,
253
+ this.avmSimulator,
250
254
  globalVariables,
255
+ contractsDB,
256
+ wsdbForkId,
251
257
  this.telemetryClient,
252
258
  bindings,
253
- collectDebugLogs,
259
+ this.debugLogStore?.isEnabled ?? false,
254
260
  );
255
261
 
256
262
  const processor = new PublicProcessor(
@@ -289,6 +295,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
289
295
  private worldState: WorldStateSynchronizer,
290
296
  private contractDataSource: ContractDataSource,
291
297
  private dateProvider: DateProvider,
298
+ private avmSimulator: AvmSimulator,
292
299
  private telemetryClient: TelemetryClient = getTelemetryClient(),
293
300
  private debugLogStore: DebugLogStore = new NullDebugLogStore(),
294
301
  ) {
@@ -344,6 +351,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
344
351
  this.contractDataSource,
345
352
  this.dateProvider,
346
353
  this.telemetryClient,
354
+ this.avmSimulator,
347
355
  bindings,
348
356
  this.debugLogStore,
349
357
  );
@@ -405,6 +413,7 @@ export class FullNodeCheckpointsBuilder implements ICheckpointsBuilder {
405
413
  this.contractDataSource,
406
414
  this.dateProvider,
407
415
  this.telemetryClient,
416
+ this.avmSimulator,
408
417
  bindings,
409
418
  this.debugLogStore,
410
419
  );
package/src/config.ts CHANGED
@@ -3,15 +3,27 @@ import {
3
3
  booleanConfigHelper,
4
4
  getConfigFromMappings,
5
5
  numberConfigHelper,
6
+ optionalNumberConfigHelper,
7
+ pickConfigMappings,
6
8
  secretValueConfigHelper,
7
9
  } from '@aztec/foundation/config';
8
10
  import { EthAddress } from '@aztec/foundation/eth-address';
11
+ import { type SequencerConfig, sharedSequencerConfigMappings } from '@aztec/stdlib/config';
9
12
  import { localSignerConfigMappings, validatorHASignerConfigMappings } from '@aztec/stdlib/ha-signing';
10
13
  import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
11
14
 
12
15
  export type { ValidatorClientConfig };
13
16
 
14
- export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientConfig> = {
17
+ /**
18
+ * Default clock-disparity tolerance (ms) for proposal/attestation receive windows, mirroring the p2p config
19
+ * default. Used by the validator-client validators when the merged node config does not carry the value.
20
+ */
21
+ export const DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS = 500;
22
+
23
+ export const validatorClientConfigMappings: ConfigMappingsType<
24
+ ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>
25
+ > = {
26
+ ...pickConfigMappings(sharedSequencerConfigMappings, ['blockDurationMs']),
15
27
  validatorPrivateKeys: {
16
28
  env: 'VALIDATOR_PRIVATE_KEYS',
17
29
  description: 'List of private keys of the validators participating in attestation duties',
@@ -30,6 +42,12 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
30
42
  .map(address => EthAddress.fromString(address.trim())),
31
43
  defaultValue: [],
32
44
  },
45
+ l1ChainId: {
46
+ env: 'L1_CHAIN_ID',
47
+ description: 'The chain ID of the ethereum host.',
48
+ parseEnv: (val: string) => +val,
49
+ defaultValue: 31337,
50
+ },
33
51
  disableValidator: {
34
52
  env: 'VALIDATOR_DISABLED',
35
53
  description: 'Do not run the validator',
@@ -49,11 +67,6 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
49
67
  description: 'Interval between polling for new attestations',
50
68
  ...numberConfigHelper(200),
51
69
  },
52
- validatorReexecute: {
53
- env: 'VALIDATOR_REEXECUTE',
54
- description: 'Re-execute transactions before attesting',
55
- ...booleanConfigHelper(true),
56
- },
57
70
  alwaysReexecuteBlockProposals: {
58
71
  description:
59
72
  'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
@@ -77,25 +90,29 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
77
90
  description: 'Agree to attest to equivocated checkpoint proposals (for testing purposes only)',
78
91
  ...booleanConfigHelper(false),
79
92
  },
93
+ skipProposalSlotValidation: {
94
+ description: 'Accept proposal validation regardless of slot timing (for testing only)',
95
+ ...booleanConfigHelper(false),
96
+ },
80
97
  validateMaxL2BlockGas: {
81
98
  env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
82
99
  description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
83
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
100
+ ...optionalNumberConfigHelper(),
84
101
  },
85
102
  validateMaxDABlockGas: {
86
103
  env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
87
104
  description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
88
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
105
+ ...optionalNumberConfigHelper(),
89
106
  },
90
107
  validateMaxTxsPerBlock: {
91
108
  env: 'VALIDATOR_MAX_TX_PER_BLOCK',
92
109
  description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
93
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
110
+ ...optionalNumberConfigHelper(),
94
111
  },
95
112
  validateMaxTxsPerCheckpoint: {
96
113
  env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
97
114
  description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
98
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
115
+ ...optionalNumberConfigHelper(),
99
116
  },
100
117
  ...localSignerConfigMappings,
101
118
  ...validatorHASignerConfigMappings,
@@ -106,6 +123,8 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
106
123
  * Note: If an environment variable is not set, the default value is used.
107
124
  * @returns The validator configuration.
108
125
  */
109
- export function getProverEnvVars(): ValidatorClientConfig {
110
- return getConfigFromMappings<ValidatorClientConfig>(validatorClientConfigMappings);
126
+ export function getProverEnvVars(): ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'> {
127
+ return getConfigFromMappings<ValidatorClientConfig & Pick<SequencerConfig, 'blockDurationMs'>>(
128
+ validatorClientConfigMappings,
129
+ );
111
130
  }
@@ -1,17 +1,9 @@
1
- import {
2
- BlockNumber,
3
- type CheckpointNumber,
4
- IndexWithinCheckpoint,
5
- type SlotNumber,
6
- } from '@aztec/foundation/branded-types';
7
- import { Buffer32 } from '@aztec/foundation/buffer';
8
- import { keccak256 } from '@aztec/foundation/crypto/keccak';
1
+ import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
9
2
  import { Fr } from '@aztec/foundation/curves/bn254';
10
3
  import type { EthAddress } from '@aztec/foundation/eth-address';
11
4
  import type { Signature } from '@aztec/foundation/eth-signature';
12
5
  import { createLogger } from '@aztec/foundation/log';
13
- import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
14
- import type { CreateCheckpointProposalLastBlockData } from '@aztec/stdlib/interfaces/server';
6
+ import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
15
7
  import {
16
8
  BlockProposal,
17
9
  type BlockProposalOptions,
@@ -20,9 +12,10 @@ import {
20
12
  type CheckpointProposalCore,
21
13
  type CheckpointProposalOptions,
22
14
  ConsensusPayload,
23
- SignatureDomainSeparator,
15
+ type CoordinationSignatureContext,
16
+ getCoordinationSignatureTypedData,
24
17
  } from '@aztec/stdlib/p2p';
25
- import type { CheckpointHeader } from '@aztec/stdlib/rollup';
18
+ import { CheckpointHeader } from '@aztec/stdlib/rollup';
26
19
  import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
27
20
  import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
28
21
  import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
@@ -32,6 +25,7 @@ import type { ValidatorKeyStore } from '../key_store/interface.js';
32
25
  export class ValidationService {
33
26
  constructor(
34
27
  private keyStore: ValidatorKeyStore,
28
+ private signatureContext: CoordinationSignatureContext,
35
29
  private log = createLogger('validator:validation-service'),
36
30
  ) {}
37
31
 
@@ -52,6 +46,7 @@ export class ValidationService {
52
46
  */
53
47
  public createBlockProposal(
54
48
  blockHeader: BlockHeader,
49
+ checkpointNumber: CheckpointNumber,
55
50
  blockIndexWithinCheckpoint: IndexWithinCheckpoint,
56
51
  inHash: Fr,
57
52
  archive: Fr,
@@ -67,17 +62,26 @@ export class ValidationService {
67
62
 
68
63
  // Create a signer that uses the appropriate address
69
64
  const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
70
- const payloadSigner = (payload: Buffer32, context: SigningContext) =>
71
- this.keyStore.signMessageWithAddress(address, payload, context);
65
+ const payloadSigner = (
66
+ typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
67
+ context: SigningContext,
68
+ ) => this.keyStore.signTypedDataWithAddress(address, typedData, context);
69
+ const txsSigner = (
70
+ typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
71
+ context: SigningContext,
72
+ ) => this.keyStore.signTypedDataWithAddress(address, typedData, context);
72
73
 
73
74
  return BlockProposal.createProposalFromSigner(
74
75
  blockHeader,
76
+ checkpointNumber,
75
77
  blockIndexWithinCheckpoint,
76
78
  inHash,
77
79
  archive,
78
80
  txs.map(tx => tx.getTxHash()),
79
81
  options.publishFullTxs ? txs : undefined,
82
+ this.signatureContext,
80
83
  payloadSigner,
84
+ txsSigner,
81
85
  );
82
86
  }
83
87
 
@@ -86,7 +90,7 @@ export class ValidationService {
86
90
  *
87
91
  * @param checkpointHeader - The checkpoint header containing aggregated data
88
92
  * @param archive - The archive of the checkpoint
89
- * @param lastBlockInfo - Info about the last block (header, index, txs) or undefined
93
+ * @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
90
94
  * @param proposerAttesterAddress - The address of the proposer
91
95
  * @param options - Checkpoint proposal options
92
96
  *
@@ -95,36 +99,41 @@ export class ValidationService {
95
99
  public createCheckpointProposal(
96
100
  checkpointHeader: CheckpointHeader,
97
101
  archive: Fr,
102
+ checkpointNumber: CheckpointNumber,
98
103
  feeAssetPriceModifier: bigint,
99
- lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
104
+ lastBlockProposal: BlockProposal | undefined,
100
105
  proposerAttesterAddress: EthAddress | undefined,
101
106
  options: CheckpointProposalOptions,
102
107
  ): Promise<CheckpointProposal> {
103
- // For testing: change the archive to trigger state_mismatch validation failure
108
+ // For testing: corrupt the checkpoint so observers' checkpoint validation fails.
109
+ //
110
+ // Keep `archive` aligned with `lastBlockProposal.archiveRoot` so the archive-based lookup
111
+ // in `validateCheckpointProposal` (`getBlockData({ archive })`) still succeeds
104
112
  if (options.broadcastInvalidCheckpointProposal) {
105
- archive = Fr.random();
113
+ archive = lastBlockProposal?.archiveRoot ?? Fr.random();
114
+ checkpointHeader = CheckpointHeader.from({
115
+ ...checkpointHeader,
116
+ epochOutHash: Fr.random(),
117
+ });
106
118
  this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
107
119
  }
108
120
 
109
121
  // Create a signer that takes payload and context, and uses the appropriate address
110
- const payloadSigner = (payload: Buffer32, context: SigningContext) => {
122
+ const payloadSigner = (
123
+ typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
124
+ context: SigningContext,
125
+ ) => {
111
126
  const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
112
- return this.keyStore.signMessageWithAddress(address, payload, context);
113
- };
114
-
115
- // Last block to include in the proposal
116
- const lastBlock = lastBlockInfo && {
117
- blockHeader: lastBlockInfo.blockHeader,
118
- indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
119
- txHashes: lastBlockInfo.txs.map(tx => tx.getTxHash()),
120
- txs: options.publishFullTxs ? lastBlockInfo.txs : undefined,
127
+ return this.keyStore.signTypedDataWithAddress(address, typedData, context);
121
128
  };
122
129
 
123
130
  return CheckpointProposal.createProposalFromSigner(
124
131
  checkpointHeader,
125
132
  archive,
133
+ checkpointNumber,
126
134
  feeAssetPriceModifier,
127
- lastBlock,
135
+ lastBlockProposal,
136
+ this.signatureContext,
128
137
  payloadSigner,
129
138
  );
130
139
  }
@@ -142,29 +151,27 @@ export class ValidationService {
142
151
  async attestToCheckpointProposal(
143
152
  proposal: CheckpointProposalCore,
144
153
  attestors: EthAddress[],
154
+ checkpointNumber: CheckpointNumber,
145
155
  ): Promise<CheckpointAttestation[]> {
146
156
  // Create the attestation payload from the checkpoint proposal
147
- const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive, proposal.feeAssetPriceModifier);
148
- const buf = Buffer32.fromBuffer(
149
- keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)),
157
+ const payload = new ConsensusPayload(
158
+ proposal.checkpointHeader,
159
+ proposal.archive,
160
+ proposal.feeAssetPriceModifier,
161
+ this.signatureContext,
150
162
  );
163
+ const typedData = getCoordinationSignatureTypedData(payload);
151
164
 
152
- // TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
153
- // CheckpointProposalCore doesn't have lastBlock info, so use 0 as a proxy.
154
- // blockNumber is NOT used for the primary key so it's safe to use here.
155
- // See CheckpointHeader TODO and SigningContext types documentation.
156
- const blockNumber = BlockNumber(0);
157
165
  const context: SigningContext = {
158
166
  slot: proposal.slotNumber,
159
- blockNumber,
167
+ checkpointNumber,
160
168
  dutyType: DutyType.ATTESTATION,
161
169
  };
162
170
 
163
171
  // Sign each attestor in parallel, catching HA errors per-attestor
164
172
  const results = await Promise.allSettled(
165
173
  attestors.map(async attestor => {
166
- const sig = await this.keyStore.signMessageWithAddress(attestor, buf, context);
167
- // return new BlockAttestation(proposal.payload, sig, proposal.signature);
174
+ const sig = await this.keyStore.signTypedDataWithAddress(attestor, typedData, context);
168
175
  return new CheckpointAttestation(payload, sig, proposal.signature);
169
176
  }),
170
177
  );
@@ -195,7 +202,6 @@ export class ValidationService {
195
202
  * @param attestationsAndSigners - The attestations and signers to sign
196
203
  * @param proposer - The proposer address to sign with
197
204
  * @param slot - The slot number for HA signing context
198
- * @param blockNumber - The block or checkpoint number for HA signing context
199
205
  * @returns signature
200
206
  * @throws DutyAlreadySignedError if already signed by another HA node
201
207
  * @throws SlashingProtectionError if attempting to sign different data for same slot
@@ -204,17 +210,15 @@ export class ValidationService {
204
210
  attestationsAndSigners: CommitteeAttestationsAndSigners,
205
211
  proposer: EthAddress,
206
212
  slot: SlotNumber,
207
- blockNumber: BlockNumber | CheckpointNumber,
213
+ checkpointNumber: CheckpointNumber,
208
214
  ): Promise<Signature> {
209
215
  const context: SigningContext = {
210
216
  slot,
211
- blockNumber,
217
+ checkpointNumber,
212
218
  dutyType: DutyType.ATTESTATIONS_AND_SIGNERS,
213
219
  };
214
220
 
215
- const buf = Buffer32.fromBuffer(
216
- keccak256(attestationsAndSigners.getPayloadToSign(SignatureDomainSeparator.attestationsAndSigners)),
217
- );
218
- return this.keyStore.signMessageWithAddress(proposer, buf, context);
221
+ const typedData = getCoordinationSignatureTypedData(attestationsAndSigners);
222
+ return this.keyStore.signTypedDataWithAddress(proposer, typedData, context);
219
223
  }
220
224
  }
package/src/factory.ts CHANGED
@@ -4,17 +4,20 @@ import type { DateProvider } from '@aztec/foundation/timer';
4
4
  import type { KeystoreManager } from '@aztec/node-keystore';
5
5
  import { BlockProposalValidator, type P2PClient } from '@aztec/p2p';
6
6
  import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
7
+ import type { CheckpointReexecutionTracker } from '@aztec/stdlib/checkpoint';
7
8
  import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
8
9
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
10
+ import { ConsensusTimetable } from '@aztec/stdlib/timetable';
9
11
  import type { TelemetryClient } from '@aztec/telemetry-client';
10
12
  import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
11
13
 
12
- import { BlockProposalHandler } from './block_proposal_handler.js';
13
14
  import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
15
+ import { DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS } from './config.js';
14
16
  import { ValidatorMetrics } from './metrics.js';
17
+ import { ProposalHandler } from './proposal_handler.js';
15
18
  import { ValidatorClient } from './validator.js';
16
19
 
17
- export function createBlockProposalHandler(
20
+ export function createProposalHandler(
18
21
  config: ValidatorClientFullConfig,
19
22
  deps: {
20
23
  checkpointsBuilder: FullNodeCheckpointsBuilder;
@@ -23,16 +26,28 @@ export function createBlockProposalHandler(
23
26
  l1ToL2MessageSource: L1ToL2MessageSource;
24
27
  p2pClient: P2PClient;
25
28
  epochCache: EpochCache;
29
+ blobClient: BlobClientInterface;
26
30
  dateProvider: DateProvider;
27
31
  telemetry: TelemetryClient;
32
+ reexecutionTracker: CheckpointReexecutionTracker;
28
33
  },
29
34
  ) {
30
35
  const metrics = new ValidatorMetrics(deps.telemetry);
31
- const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
36
+ const consensusTimetable = new ConsensusTimetable({
37
+ l1Constants: deps.epochCache.getL1Constants(),
38
+ blockDuration: config.blockDurationMs / 1000,
39
+ });
40
+ const blockProposalValidator = new BlockProposalValidator(deps.epochCache, consensusTimetable, {
32
41
  txsPermitted: !config.disableTransactions,
33
42
  maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
43
+ maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
44
+ signatureContext: {
45
+ chainId: config.l1ChainId,
46
+ rollupAddress: config.rollupAddress,
47
+ },
48
+ clockDisparityMs: config.maxGossipClockDisparityMs ?? DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS,
34
49
  });
35
- return new BlockProposalHandler(
50
+ return new ProposalHandler(
36
51
  deps.checkpointsBuilder,
37
52
  deps.worldState,
38
53
  deps.blockSource,
@@ -40,10 +55,14 @@ export function createBlockProposalHandler(
40
55
  deps.p2pClient.getTxProvider(),
41
56
  blockProposalValidator,
42
57
  deps.epochCache,
58
+ consensusTimetable,
43
59
  config,
60
+ deps.blobClient,
61
+ deps.reexecutionTracker,
44
62
  metrics,
45
63
  deps.dateProvider,
46
64
  deps.telemetry,
65
+ undefined,
47
66
  );
48
67
  }
49
68
 
@@ -60,6 +79,7 @@ export function createValidatorClient(
60
79
  epochCache: EpochCache;
61
80
  keyStoreManager: KeystoreManager | undefined;
62
81
  blobClient: BlobClientInterface;
82
+ reexecutionTracker: CheckpointReexecutionTracker;
63
83
  slashingProtectionDb?: SlashingProtectionDatabase;
64
84
  },
65
85
  ) {
@@ -79,6 +99,7 @@ export function createValidatorClient(
79
99
  txProvider,
80
100
  deps.keyStoreManager,
81
101
  deps.blobClient,
102
+ deps.reexecutionTracker,
82
103
  deps.dateProvider,
83
104
  deps.telemetry,
84
105
  deps.slashingProtectionDb,
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export * from './block_proposal_handler.js';
1
+ export * from './proposal_handler.js';
2
2
  export * from './checkpoint_builder.js';
3
3
  export * from './config.js';
4
4
  export * from './factory.js';