@aztec/validator-client 0.0.0-test.1 → 0.0.1-commit.1142ef1

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 (74) hide show
  1. package/README.md +256 -0
  2. package/dest/block_proposal_handler.d.ts +63 -0
  3. package/dest/block_proposal_handler.d.ts.map +1 -0
  4. package/dest/block_proposal_handler.js +551 -0
  5. package/dest/checkpoint_builder.d.ts +70 -0
  6. package/dest/checkpoint_builder.d.ts.map +1 -0
  7. package/dest/checkpoint_builder.js +155 -0
  8. package/dest/config.d.ts +3 -14
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +46 -7
  11. package/dest/duties/validation_service.d.ts +36 -12
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +69 -16
  14. package/dest/factory.d.ts +27 -5
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +13 -6
  17. package/dest/index.d.ts +6 -2
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +5 -1
  20. package/dest/key_store/index.d.ts +3 -1
  21. package/dest/key_store/index.d.ts.map +1 -1
  22. package/dest/key_store/index.js +2 -0
  23. package/dest/key_store/interface.d.ts +55 -6
  24. package/dest/key_store/interface.d.ts.map +1 -1
  25. package/dest/key_store/interface.js +3 -3
  26. package/dest/key_store/local_key_store.d.ts +41 -11
  27. package/dest/key_store/local_key_store.d.ts.map +1 -1
  28. package/dest/key_store/local_key_store.js +64 -17
  29. package/dest/key_store/node_keystore_adapter.d.ts +138 -0
  30. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -0
  31. package/dest/key_store/node_keystore_adapter.js +316 -0
  32. package/dest/key_store/web3signer_key_store.d.ts +61 -0
  33. package/dest/key_store/web3signer_key_store.d.ts.map +1 -0
  34. package/dest/key_store/web3signer_key_store.js +152 -0
  35. package/dest/metrics.d.ts +12 -5
  36. package/dest/metrics.d.ts.map +1 -1
  37. package/dest/metrics.js +36 -24
  38. package/dest/tx_validator/index.d.ts +3 -0
  39. package/dest/tx_validator/index.d.ts.map +1 -0
  40. package/dest/tx_validator/index.js +2 -0
  41. package/dest/tx_validator/nullifier_cache.d.ts +14 -0
  42. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
  43. package/dest/tx_validator/nullifier_cache.js +24 -0
  44. package/dest/tx_validator/tx_validator_factory.d.ts +18 -0
  45. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
  46. package/dest/tx_validator/tx_validator_factory.js +53 -0
  47. package/dest/validator.d.ts +73 -58
  48. package/dest/validator.d.ts.map +1 -1
  49. package/dest/validator.js +557 -166
  50. package/package.json +33 -21
  51. package/src/block_proposal_handler.ts +556 -0
  52. package/src/checkpoint_builder.ts +267 -0
  53. package/src/config.ts +58 -22
  54. package/src/duties/validation_service.ts +124 -18
  55. package/src/factory.ts +64 -11
  56. package/src/index.ts +5 -1
  57. package/src/key_store/index.ts +2 -0
  58. package/src/key_store/interface.ts +61 -5
  59. package/src/key_store/local_key_store.ts +68 -18
  60. package/src/key_store/node_keystore_adapter.ts +375 -0
  61. package/src/key_store/web3signer_key_store.ts +192 -0
  62. package/src/metrics.ts +48 -24
  63. package/src/tx_validator/index.ts +2 -0
  64. package/src/tx_validator/nullifier_cache.ts +30 -0
  65. package/src/tx_validator/tx_validator_factory.ts +133 -0
  66. package/src/validator.ts +749 -218
  67. package/dest/errors/index.d.ts +0 -2
  68. package/dest/errors/index.d.ts.map +0 -1
  69. package/dest/errors/index.js +0 -1
  70. package/dest/errors/validator.error.d.ts +0 -29
  71. package/dest/errors/validator.error.d.ts.map +0 -1
  72. package/dest/errors/validator.error.js +0 -45
  73. package/src/errors/index.ts +0 -1
  74. package/src/errors/validator.error.ts +0 -55
@@ -0,0 +1,155 @@
1
+ import { merge, pick } from '@aztec/foundation/collection';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { bufferToHex } from '@aztec/foundation/string';
4
+ import { Timer, elapsed } from '@aztec/foundation/timer';
5
+ import { getDefaultAllowedSetupFunctions } from '@aztec/p2p/msg_validators';
6
+ import { LightweightCheckpointBuilder } from '@aztec/prover-client/light';
7
+ import { GuardedMerkleTreeOperations, PublicContractsDB, PublicProcessor, createPublicTxSimulatorForBlockBuilding } from '@aztec/simulator/server';
8
+ import { Gas } from '@aztec/stdlib/gas';
9
+ import { FullNodeBlockBuilderConfigKeys } from '@aztec/stdlib/interfaces/server';
10
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
11
+ import { GlobalVariables } from '@aztec/stdlib/tx';
12
+ import { getTelemetryClient } from '@aztec/telemetry-client';
13
+ import { createValidatorForBlockBuilding } from './tx_validator/tx_validator_factory.js';
14
+ const log = createLogger('checkpoint-builder');
15
+ /**
16
+ * Builder for a single checkpoint. Handles building blocks within the checkpoint
17
+ * and completing it.
18
+ */ export class CheckpointBuilder {
19
+ checkpointBuilder;
20
+ fork;
21
+ config;
22
+ contractDataSource;
23
+ dateProvider;
24
+ telemetryClient;
25
+ constructor(checkpointBuilder, fork, config, contractDataSource, dateProvider, telemetryClient){
26
+ this.checkpointBuilder = checkpointBuilder;
27
+ this.fork = fork;
28
+ this.config = config;
29
+ this.contractDataSource = contractDataSource;
30
+ this.dateProvider = dateProvider;
31
+ this.telemetryClient = telemetryClient;
32
+ }
33
+ getConstantData() {
34
+ return this.checkpointBuilder.constants;
35
+ }
36
+ /**
37
+ * Builds a single block within this checkpoint.
38
+ */ async buildBlock(pendingTxs, blockNumber, timestamp, opts) {
39
+ const blockBuildingTimer = new Timer();
40
+ const slot = this.checkpointBuilder.constants.slotNumber;
41
+ log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
42
+ slot,
43
+ blockNumber,
44
+ ...opts
45
+ });
46
+ const constants = this.checkpointBuilder.constants;
47
+ const globalVariables = GlobalVariables.from({
48
+ chainId: constants.chainId,
49
+ version: constants.version,
50
+ blockNumber,
51
+ slotNumber: constants.slotNumber,
52
+ timestamp,
53
+ coinbase: constants.coinbase,
54
+ feeRecipient: constants.feeRecipient,
55
+ gasFees: constants.gasFees
56
+ });
57
+ const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
58
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs]] = await elapsed(()=>processor.process(pendingTxs, opts, validator));
59
+ // Add block to checkpoint
60
+ const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
61
+ expectedEndState: opts.expectedEndState
62
+ });
63
+ // How much public gas was processed
64
+ const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
65
+ const res = {
66
+ block,
67
+ publicGas,
68
+ publicProcessorDuration,
69
+ numTxs: processedTxs.length,
70
+ failedTxs,
71
+ blockBuildingTimer,
72
+ usedTxs
73
+ };
74
+ log.debug('Built block within checkpoint', res.block.header);
75
+ return res;
76
+ }
77
+ /** Completes the checkpoint and returns it. */ async completeCheckpoint() {
78
+ const checkpoint = await this.checkpointBuilder.completeCheckpoint();
79
+ log.verbose(`Completed checkpoint ${checkpoint.number}`, {
80
+ checkpointNumber: checkpoint.number,
81
+ numBlocks: checkpoint.blocks.length,
82
+ archiveRoot: checkpoint.archive.root.toString()
83
+ });
84
+ return checkpoint;
85
+ }
86
+ /** Gets the checkpoint currently in progress. */ getCheckpoint() {
87
+ return this.checkpointBuilder.clone().completeCheckpoint();
88
+ }
89
+ async makeBlockBuilderDeps(globalVariables, fork) {
90
+ const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
91
+ const contractsDB = new PublicContractsDB(this.contractDataSource);
92
+ const guardedFork = new GuardedMerkleTreeOperations(fork);
93
+ const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(guardedFork, contractsDB, globalVariables, this.telemetryClient);
94
+ const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, undefined, this.config);
95
+ const validator = createValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList);
96
+ return {
97
+ processor,
98
+ validator
99
+ };
100
+ }
101
+ }
102
+ /**
103
+ * Factory for creating checkpoint builders.
104
+ */ export class FullNodeCheckpointsBuilder {
105
+ config;
106
+ contractDataSource;
107
+ dateProvider;
108
+ telemetryClient;
109
+ constructor(config, contractDataSource, dateProvider, telemetryClient = getTelemetryClient()){
110
+ this.config = config;
111
+ this.contractDataSource = contractDataSource;
112
+ this.dateProvider = dateProvider;
113
+ this.telemetryClient = telemetryClient;
114
+ }
115
+ getConfig() {
116
+ return this.config;
117
+ }
118
+ updateConfig(config) {
119
+ this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
120
+ }
121
+ /**
122
+ * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
123
+ */ async startCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork) {
124
+ const stateReference = await fork.getStateReference();
125
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
126
+ log.verbose(`Building new checkpoint ${checkpointNumber}`, {
127
+ checkpointNumber,
128
+ msgCount: l1ToL2Messages.length,
129
+ initialStateReference: stateReference.toInspect(),
130
+ initialArchiveRoot: bufferToHex(archiveTree.root),
131
+ constants
132
+ });
133
+ const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork);
134
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient);
135
+ }
136
+ /**
137
+ * Opens a checkpoint, either starting fresh or resuming from existing blocks.
138
+ */ async openCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork, existingBlocks = []) {
139
+ const stateReference = await fork.getStateReference();
140
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
141
+ if (existingBlocks.length === 0) {
142
+ return this.startCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork);
143
+ }
144
+ log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
145
+ checkpointNumber,
146
+ msgCount: l1ToL2Messages.length,
147
+ existingBlockCount: existingBlocks.length,
148
+ initialStateReference: stateReference.toInspect(),
149
+ initialArchiveRoot: bufferToHex(archiveTree.root),
150
+ constants
151
+ });
152
+ const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, l1ToL2Messages, fork, existingBlocks);
153
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient);
154
+ }
155
+ }
package/dest/config.d.ts CHANGED
@@ -1,17 +1,6 @@
1
1
  import { type ConfigMappingsType } from '@aztec/foundation/config';
2
- /**
3
- * The Validator Configuration
4
- */
5
- export interface ValidatorClientConfig {
6
- /** The private key of the validator participating in attestation duties */
7
- validatorPrivateKey?: string;
8
- /** Do not run the validator */
9
- disableValidator: boolean;
10
- /** Interval between polling for new attestations from peers */
11
- attestationPollingIntervalMs: number;
12
- /** Re-execute transactions before attesting */
13
- validatorReexecute: boolean;
14
- }
2
+ import type { ValidatorClientConfig } from '@aztec/stdlib/interfaces/server';
3
+ export type { ValidatorClientConfig };
15
4
  export declare const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientConfig>;
16
5
  /**
17
6
  * Returns the prover configuration from the environment variables.
@@ -19,4 +8,4 @@ export declare const validatorClientConfigMappings: ConfigMappingsType<Validator
19
8
  * @returns The validator configuration.
20
9
  */
21
10
  export declare function getProverEnvVars(): ValidatorClientConfig;
22
- //# sourceMappingURL=config.d.ts.map
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQUt4QixNQUFNLDBCQUEwQixDQUFDO0FBRWxDLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFN0UsWUFBWSxFQUFFLHFCQUFxQixFQUFFLENBQUM7QUFFdEMsZUFBTyxNQUFNLDZCQUE2QixFQUFFLGtCQUFrQixDQUFDLHFCQUFxQixDQXNFbkYsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZ0JBQWdCLElBQUkscUJBQXFCLENBRXhEIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAElC;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,2EAA2E;IAC3E,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B,+BAA+B;IAC/B,gBAAgB,EAAE,OAAO,CAAC;IAE1B,+DAA+D;IAC/D,4BAA4B,EAAE,MAAM,CAAC;IAErC,+CAA+C;IAC/C,kBAAkB,EAAE,OAAO,CAAC;CAC7B;AAED,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CAqBnF,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,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,CAsEnF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
package/dest/config.js CHANGED
@@ -1,15 +1,29 @@
1
- import { NULL_KEY } from '@aztec/ethereum';
2
- import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
1
+ import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper, secretValueConfigHelper } from '@aztec/foundation/config';
2
+ import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  export const validatorClientConfigMappings = {
4
- validatorPrivateKey: {
5
- env: 'VALIDATOR_PRIVATE_KEY',
6
- parseEnv: (val)=>val ? `0x${val.replace('0x', '')}` : NULL_KEY,
7
- description: 'The private key of the validator participating in attestation duties'
4
+ validatorPrivateKeys: {
5
+ env: 'VALIDATOR_PRIVATE_KEYS',
6
+ description: 'List of private keys of the validators participating in attestation duties',
7
+ ...secretValueConfigHelper((val)=>val ? val.split(',').map((key)=>`0x${key.replace('0x', '')}`) : []),
8
+ fallback: [
9
+ 'VALIDATOR_PRIVATE_KEY'
10
+ ]
11
+ },
12
+ validatorAddresses: {
13
+ env: 'VALIDATOR_ADDRESSES',
14
+ description: 'List of addresses of the validators to use with remote signers',
15
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
16
+ defaultValue: []
8
17
  },
9
18
  disableValidator: {
10
19
  env: 'VALIDATOR_DISABLED',
11
20
  description: 'Do not run the validator',
12
- ...booleanConfigHelper()
21
+ ...booleanConfigHelper(false)
22
+ },
23
+ disabledValidators: {
24
+ description: 'Temporarily disable these specific validator addresses',
25
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
26
+ defaultValue: []
13
27
  },
14
28
  attestationPollingIntervalMs: {
15
29
  env: 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS',
@@ -20,6 +34,31 @@ export const validatorClientConfigMappings = {
20
34
  env: 'VALIDATOR_REEXECUTE',
21
35
  description: 'Re-execute transactions before attesting',
22
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
+ alwaysReexecuteBlockProposals: {
44
+ env: 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS',
45
+ description: 'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
46
+ ...booleanConfigHelper(false)
47
+ },
48
+ fishermanMode: {
49
+ env: 'FISHERMAN_MODE',
50
+ description: 'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
51
+ ...booleanConfigHelper(false)
52
+ },
53
+ // TODO(palla/mbps): Change default to false once checkpoint validation is stable
54
+ skipCheckpointProposalValidation: {
55
+ description: 'Skip checkpoint proposal validation and always attest (default: true)',
56
+ defaultValue: true
57
+ },
58
+ // TODO(palla/mbps): Change default to false once block sync is stable
59
+ skipPushProposedBlocksToArchiver: {
60
+ description: 'Skip pushing re-executed blocks to archiver (default: true)',
61
+ defaultValue: true
23
62
  }
24
63
  };
25
64
  /**
@@ -1,29 +1,53 @@
1
- import type { Fr } from '@aztec/foundation/fields';
2
- import { BlockAttestation, BlockProposal } from '@aztec/stdlib/p2p';
3
- import type { BlockHeader, TxHash } from '@aztec/stdlib/tx';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { EthAddress } from '@aztec/foundation/eth-address';
3
+ import type { Signature } from '@aztec/foundation/eth-signature';
4
+ import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
5
+ import type { CreateCheckpointProposalLastBlockData } from '@aztec/stdlib/interfaces/server';
6
+ import { BlockProposal, type BlockProposalOptions, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions } from '@aztec/stdlib/p2p';
7
+ import type { CheckpointHeader } from '@aztec/stdlib/rollup';
8
+ import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
4
9
  import type { ValidatorKeyStore } from '../key_store/interface.js';
5
10
  export declare class ValidationService {
6
11
  private keyStore;
7
- constructor(keyStore: ValidatorKeyStore);
12
+ private log;
13
+ constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
8
14
  /**
9
15
  * Create a block proposal with the given header, archive, and transactions
10
16
  *
11
- * @param header - The block header
17
+ * @param blockHeader - The block header
18
+ * @param indexWithinCheckpoint - Index of this block within the checkpoint (0-indexed)
19
+ * @param inHash - Hash of L1 to L2 messages for this checkpoint
12
20
  * @param archive - The archive of the current block
13
21
  * @param txs - TxHash[] ordered list of transactions
22
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
14
23
  *
15
- * @returns A block proposal signing the above information (not the current implementation!!!)
24
+ * @returns A block proposal signing the above information
16
25
  */
17
- createBlockProposal(header: BlockHeader, archive: Fr, txs: TxHash[]): Promise<BlockProposal>;
26
+ createBlockProposal(blockHeader: BlockHeader, indexWithinCheckpoint: number, inHash: Fr, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
18
27
  /**
19
- * Attest to the given block proposal constructed by the current sequencer
28
+ * Create a checkpoint proposal with the last block header and checkpoint header
29
+ *
30
+ * @param checkpointHeader - The checkpoint header containing aggregated data
31
+ * @param archive - The archive of the checkpoint
32
+ * @param lastBlockInfo - Info about the last block (header, index, txs) or undefined
33
+ * @param proposerAttesterAddress - The address of the proposer
34
+ * @param options - Checkpoint proposal options
35
+ *
36
+ * @returns A checkpoint proposal signing the above information
37
+ */
38
+ createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
39
+ private getPayloadSigner;
40
+ /**
41
+ * Attest with selection of validators to the given checkpoint proposal
20
42
  *
21
43
  * NOTE: This is just a blind signing.
22
44
  * We assume that the proposal is valid and DA guarantees have been checked previously.
23
45
  *
24
- * @param proposal - The proposal to attest to
25
- * @returns attestation
46
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
47
+ * @param attestors - The validators to attest with
48
+ * @returns checkpoint attestations
26
49
  */
27
- attestToProposal(proposal: BlockProposal): Promise<BlockAttestation>;
50
+ attestToCheckpointProposal(proposal: CheckpointProposalCore, attestors: EthAddress[]): Promise<CheckpointAttestation[]>;
51
+ signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress): Promise<Signature>;
28
52
  }
29
- //# sourceMappingURL=validation_service.d.ts.map
53
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbl9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZHV0aWVzL3ZhbGlkYXRpb25fc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsK0JBQStCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUMzRSxPQUFPLEtBQUssRUFBRSxxQ0FBcUMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzdGLE9BQU8sRUFDTCxhQUFhLEVBQ2IsS0FBSyxvQkFBb0IsRUFDekIscUJBQXFCLEVBQ3JCLGtCQUFrQixFQUNsQixLQUFLLHNCQUFzQixFQUMzQixLQUFLLHlCQUF5QixFQUcvQixNQUFNLG1CQUFtQixDQUFDO0FBQzNCLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDN0QsT0FBTyxLQUFLLEVBQUUsV0FBVyxFQUFFLEVBQUUsRUF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c0IsRUFBRSwrQkFBK0IsRUFDdkQsUUFBUSxFQUFFLFVBQVUsR0FDbkIsT0FBTyxDQUFDLFNBQVMsQ0FBQyxDQUtwQjtDQUNGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAA8C,MAAM,mBAAmB,CAAC;AAChH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ;gBAAR,QAAQ,EAAE,iBAAiB;IAE/C;;;;;;;;OAQG;IACH,mBAAmB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,aAAa,CAAC;IAM5F;;;;;;;;OAQG;IACG,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAS3E"}
1
+ {"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAEjE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,iCAAiC,CAAC;AAC7F,OAAO,EACL,aAAa,EACb,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,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from '@aztec/foundation/crypto';
3
- import { BlockAttestation, BlockProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
2
+ import { keccak256 } from '@aztec/foundation/crypto/keccak';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
+ import { createLogger } from '@aztec/foundation/log';
5
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
4
6
  export class ValidationService {
5
7
  keyStore;
6
- constructor(keyStore){
8
+ log;
9
+ constructor(keyStore, log = createLogger('validator:validation-service')){
7
10
  this.keyStore = keyStore;
11
+ this.log = log;
8
12
  }
9
13
  /**
10
14
  * Create a block proposal with the given header, archive, and transactions
11
15
  *
12
- * @param header - The block header
16
+ * @param blockHeader - The block header
17
+ * @param indexWithinCheckpoint - Index of this block within the checkpoint (0-indexed)
18
+ * @param inHash - Hash of L1 to L2 messages for this checkpoint
13
19
  * @param archive - The archive of the current block
14
20
  * @param txs - TxHash[] ordered list of transactions
21
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
15
22
  *
16
- * @returns A block proposal signing the above information (not the current implementation!!!)
17
- */ createBlockProposal(header, archive, txs) {
18
- const payloadSigner = (payload)=>this.keyStore.signMessage(payload);
19
- return BlockProposal.createProposalFromSigner(new ConsensusPayload(header, archive, txs), payloadSigner);
23
+ * @returns A block proposal signing the above information
24
+ */ createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAttesterAddress, options) {
25
+ const payloadSigner = this.getPayloadSigner(proposerAttesterAddress);
26
+ // For testing: change the new archive to trigger state_mismatch validation failure
27
+ if (options.broadcastInvalidBlockProposal) {
28
+ archive = Fr.random();
29
+ this.log.warn(`Creating INVALID block proposal for slot ${blockHeader.globalVariables.slotNumber}`);
30
+ }
31
+ return BlockProposal.createProposalFromSigner(blockHeader, indexWithinCheckpoint, inHash, archive, txs.map((tx)=>tx.getTxHash()), options.publishFullTxs ? txs : undefined, payloadSigner);
20
32
  }
21
33
  /**
22
- * Attest to the given block proposal constructed by the current sequencer
34
+ * Create a checkpoint proposal with the last block header and checkpoint header
35
+ *
36
+ * @param checkpointHeader - The checkpoint header containing aggregated data
37
+ * @param archive - The archive of the checkpoint
38
+ * @param lastBlockInfo - Info about the last block (header, index, txs) or undefined
39
+ * @param proposerAttesterAddress - The address of the proposer
40
+ * @param options - Checkpoint proposal options
41
+ *
42
+ * @returns A checkpoint proposal signing the above information
43
+ */ createCheckpointProposal(checkpointHeader, archive, lastBlockInfo, proposerAttesterAddress, options) {
44
+ const payloadSigner = this.getPayloadSigner(proposerAttesterAddress);
45
+ // For testing: change the archive to trigger state_mismatch validation failure
46
+ if (options.broadcastInvalidCheckpointProposal) {
47
+ archive = Fr.random();
48
+ this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
49
+ }
50
+ // Last block to include in the proposal
51
+ const lastBlock = lastBlockInfo && {
52
+ blockHeader: lastBlockInfo.blockHeader,
53
+ indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
54
+ txHashes: lastBlockInfo.txs.map((tx)=>tx.getTxHash()),
55
+ txs: options.publishFullTxs ? lastBlockInfo.txs : undefined
56
+ };
57
+ return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, lastBlock, payloadSigner);
58
+ }
59
+ getPayloadSigner(proposerAttesterAddress) {
60
+ if (proposerAttesterAddress !== undefined) {
61
+ return (payload)=>this.keyStore.signMessageWithAddress(proposerAttesterAddress, payload);
62
+ } else {
63
+ // if there is no proposer attester address, just use the first signer
64
+ const signer = this.keyStore.getAddress(0);
65
+ return (payload)=>this.keyStore.signMessageWithAddress(signer, payload);
66
+ }
67
+ }
68
+ /**
69
+ * Attest with selection of validators to the given checkpoint proposal
23
70
  *
24
71
  * NOTE: This is just a blind signing.
25
72
  * We assume that the proposal is valid and DA guarantees have been checked previously.
26
73
  *
27
- * @param proposal - The proposal to attest to
28
- * @returns attestation
29
- */ async attestToProposal(proposal) {
30
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/7961): check that the current validator is correct
31
- const buf = Buffer32.fromBuffer(keccak256(await proposal.payload.getPayloadToSign(SignatureDomainSeparator.blockAttestation)));
32
- const sig = await this.keyStore.signMessage(buf);
33
- return new BlockAttestation(proposal.payload, sig);
74
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
75
+ * @param attestors - The validators to attest with
76
+ * @returns checkpoint attestations
77
+ */ async attestToCheckpointProposal(proposal, attestors) {
78
+ // Create the attestation payload from the checkpoint proposal
79
+ const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
80
+ const buf = Buffer32.fromBuffer(keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)));
81
+ const signatures = await Promise.all(attestors.map((attestor)=>this.keyStore.signMessageWithAddress(attestor, buf)));
82
+ return signatures.map((sig)=>new CheckpointAttestation(payload, sig, proposal.signature));
83
+ }
84
+ async signAttestationsAndSigners(attestationsAndSigners, proposer) {
85
+ const buf = Buffer32.fromBuffer(keccak256(attestationsAndSigners.getPayloadToSign(SignatureDomainSeparator.attestationsAndSigners)));
86
+ return await this.keyStore.signMessageWithAddress(proposer, buf);
34
87
  }
35
88
  }
package/dest/factory.d.ts CHANGED
@@ -1,13 +1,35 @@
1
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
1
2
  import type { EpochCache } from '@aztec/epoch-cache';
2
3
  import type { DateProvider } from '@aztec/foundation/timer';
3
- import type { P2P } from '@aztec/p2p';
4
+ import type { KeystoreManager } from '@aztec/node-keystore';
5
+ import { type P2PClient } from '@aztec/p2p';
6
+ import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
7
+ import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
8
+ import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
4
9
  import type { TelemetryClient } from '@aztec/telemetry-client';
5
- import type { ValidatorClientConfig } from './config.js';
10
+ import { BlockProposalHandler } from './block_proposal_handler.js';
11
+ import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
6
12
  import { ValidatorClient } from './validator.js';
7
- export declare function createValidatorClient(config: ValidatorClientConfig, deps: {
8
- p2pClient: P2P;
13
+ export declare function createBlockProposalHandler(config: ValidatorClientFullConfig, deps: {
14
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
15
+ worldState: WorldStateSynchronizer;
16
+ blockSource: L2BlockSource & L2BlockSink;
17
+ l1ToL2MessageSource: L1ToL2MessageSource;
18
+ p2pClient: P2PClient;
19
+ epochCache: EpochCache;
20
+ dateProvider: DateProvider;
21
+ telemetry: TelemetryClient;
22
+ }): BlockProposalHandler;
23
+ export declare function createValidatorClient(config: ValidatorClientFullConfig, deps: {
24
+ checkpointsBuilder: FullNodeCheckpointsBuilder;
25
+ worldState: WorldStateSynchronizer;
26
+ p2pClient: P2PClient;
27
+ blockSource: L2BlockSource & L2BlockSink;
28
+ l1ToL2MessageSource: L1ToL2MessageSource;
9
29
  telemetry: TelemetryClient;
10
30
  dateProvider: DateProvider;
11
31
  epochCache: EpochCache;
32
+ keyStoreManager: KeystoreManager | undefined;
33
+ blobClient: BlobClientInterface;
12
34
  }): ValidatorClient | undefined;
13
- //# sourceMappingURL=factory.d.ts.map
35
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjdG9yeS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUNyRSxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUNyRCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUM1RCxPQUFP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ixFQUNqQyxJQUFJLEVBQUU7SUFDSixrQkFBa0IsRUFBRSwwQkFBMEIsQ0FBQztJQUMvQyxVQUFVLEVBQUUsc0JBQXNCLENBQUM7SUFDbkMsU0FBUyxFQUFFLFNBQVMsQ0FBQztJQUNyQixXQUFXLEVBQUUsYUFBYSxHQUFHLFdBQVcsQ0FBQztJQUN6QyxtQkFBbUIsRUFBRSxtQkFBbUIsQ0FBQztJQUN6QyxTQUFTLEVBQUUsZUFBZSxDQUFDO0lBQzNCLFlBQVksRUFBRSxZQUFZLENBQUM7SUFDM0IsVUFBVSxFQUFFLFVBQVUsQ0FBQztJQUN2QixlQUFlLEVBQUUsZUFBZSxHQUFHLFNBQVMsQ0FBQztJQUM3QyxVQUFVLEVBQUUsbUJBQW1CLENBQUM7Q0FDakMsK0JBcUJGIn0=
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAI/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE;IACJ,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;CACxB,+BAUF"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,E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;IACzC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,eAAe,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;IAC3B,UAAU,EAAE,UAAU,CAAC;IACvB,eAAe,EAAE,eAAe,GAAG,SAAS,CAAC;IAC7C,UAAU,EAAE,mBAAmB,CAAC;CACjC,+BAqBF"}
package/dest/factory.js CHANGED
@@ -1,11 +1,18 @@
1
- import { generatePrivateKey } from 'viem/accounts';
1
+ import { BlockProposalValidator } from '@aztec/p2p';
2
+ import { BlockProposalHandler } from './block_proposal_handler.js';
3
+ import { ValidatorMetrics } from './metrics.js';
2
4
  import { ValidatorClient } from './validator.js';
5
+ export function createBlockProposalHandler(config, deps) {
6
+ const metrics = new ValidatorMetrics(deps.telemetry);
7
+ const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
8
+ txsPermitted: !config.disableTransactions
9
+ });
10
+ return new BlockProposalHandler(deps.checkpointsBuilder, deps.worldState, deps.blockSource, deps.l1ToL2MessageSource, deps.p2pClient.getTxProvider(), blockProposalValidator, config, metrics, deps.dateProvider, deps.telemetry);
11
+ }
3
12
  export function createValidatorClient(config, deps) {
4
- if (config.disableValidator) {
13
+ if (config.disableValidator || !deps.keyStoreManager) {
5
14
  return undefined;
6
15
  }
7
- if (config.validatorPrivateKey === undefined || config.validatorPrivateKey === '') {
8
- config.validatorPrivateKey = generatePrivateKey();
9
- }
10
- return ValidatorClient.new(config, deps.epochCache, deps.p2pClient, deps.dateProvider, deps.telemetry);
16
+ const txProvider = deps.p2pClient.getTxProvider();
17
+ return ValidatorClient.new(config, deps.checkpointsBuilder, deps.worldState, deps.epochCache, deps.p2pClient, deps.blockSource, deps.l1ToL2MessageSource, txProvider, deps.keyStoreManager, deps.blobClient, deps.dateProvider, deps.telemetry);
11
18
  }
package/dest/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
+ export * from './block_proposal_handler.js';
2
+ export * from './checkpoint_builder.js';
1
3
  export * from './config.js';
2
- export * from './validator.js';
3
4
  export * from './factory.js';
4
- //# sourceMappingURL=index.d.ts.map
5
+ export * from './validator.js';
6
+ export * from './key_store/index.js';
7
+ export * from './tx_validator/index.js';
8
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDZCQUE2QixDQUFDO0FBQzVDLGNBQWMseUJBQXlCLENBQUM7QUFDeEMsY0FBYyxhQUFhLENBQUM7QUFDNUIsY0FBYyxjQUFjLENBQUM7QUFDN0IsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLHNCQUFzQixDQUFDO0FBQ3JDLGNBQWMseUJBQXlCLENBQUMifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
package/dest/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ export * from './block_proposal_handler.js';
2
+ export * from './checkpoint_builder.js';
1
3
  export * from './config.js';
2
- export * from './validator.js';
3
4
  export * from './factory.js';
5
+ export * from './validator.js';
6
+ export * from './key_store/index.js';
7
+ export * from './tx_validator/index.js';
@@ -1,3 +1,5 @@
1
1
  export * from './interface.js';
2
2
  export * from './local_key_store.js';
3
- //# sourceMappingURL=index.d.ts.map
3
+ export * from './node_keystore_adapter.js';
4
+ export * from './web3signer_key_store.js';
5
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9rZXlfc3RvcmUvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxnQkFBZ0IsQ0FBQztBQUMvQixjQUFjLHNCQUFzQixDQUFDO0FBQ3JDLGNBQWMsNEJBQTRCLENBQUM7QUFDM0MsY0FBYywyQkFBMkIsQ0FBQyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/key_store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/key_store/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC"}
@@ -1,2 +1,4 @@
1
1
  export * from './interface.js';
2
2
  export * from './local_key_store.js';
3
+ export * from './node_keystore_adapter.js';
4
+ export * from './web3signer_key_store.js';