@aztec/validator-client 0.0.0-test.1 → 0.0.1-commit.023c3e5

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 (78) hide show
  1. package/README.md +282 -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 +546 -0
  5. package/dest/checkpoint_builder.d.ts +66 -0
  6. package/dest/checkpoint_builder.d.ts.map +1 -0
  7. package/dest/checkpoint_builder.js +173 -0
  8. package/dest/config.d.ts +3 -14
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +41 -8
  11. package/dest/duties/validation_service.d.ts +50 -13
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +123 -17
  14. package/dest/factory.d.ts +28 -6
  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/ha_key_store.d.ts +99 -0
  21. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  22. package/dest/key_store/ha_key_store.js +208 -0
  23. package/dest/key_store/index.d.ts +4 -1
  24. package/dest/key_store/index.d.ts.map +1 -1
  25. package/dest/key_store/index.js +3 -0
  26. package/dest/key_store/interface.d.ts +85 -6
  27. package/dest/key_store/interface.d.ts.map +1 -1
  28. package/dest/key_store/interface.js +3 -3
  29. package/dest/key_store/local_key_store.d.ts +46 -11
  30. package/dest/key_store/local_key_store.d.ts.map +1 -1
  31. package/dest/key_store/local_key_store.js +68 -17
  32. package/dest/key_store/node_keystore_adapter.d.ts +151 -0
  33. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -0
  34. package/dest/key_store/node_keystore_adapter.js +330 -0
  35. package/dest/key_store/web3signer_key_store.d.ts +66 -0
  36. package/dest/key_store/web3signer_key_store.d.ts.map +1 -0
  37. package/dest/key_store/web3signer_key_store.js +156 -0
  38. package/dest/metrics.d.ts +13 -5
  39. package/dest/metrics.d.ts.map +1 -1
  40. package/dest/metrics.js +63 -22
  41. package/dest/tx_validator/index.d.ts +3 -0
  42. package/dest/tx_validator/index.d.ts.map +1 -0
  43. package/dest/tx_validator/index.js +2 -0
  44. package/dest/tx_validator/nullifier_cache.d.ts +14 -0
  45. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
  46. package/dest/tx_validator/nullifier_cache.js +24 -0
  47. package/dest/tx_validator/tx_validator_factory.d.ts +19 -0
  48. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
  49. package/dest/tx_validator/tx_validator_factory.js +54 -0
  50. package/dest/validator.d.ts +73 -58
  51. package/dest/validator.d.ts.map +1 -1
  52. package/dest/validator.js +559 -166
  53. package/package.json +37 -21
  54. package/src/block_proposal_handler.ts +555 -0
  55. package/src/checkpoint_builder.ts +314 -0
  56. package/src/config.ts +52 -22
  57. package/src/duties/validation_service.ts +193 -19
  58. package/src/factory.ts +65 -11
  59. package/src/index.ts +5 -1
  60. package/src/key_store/ha_key_store.ts +269 -0
  61. package/src/key_store/index.ts +3 -0
  62. package/src/key_store/interface.ts +100 -5
  63. package/src/key_store/local_key_store.ts +77 -18
  64. package/src/key_store/node_keystore_adapter.ts +398 -0
  65. package/src/key_store/web3signer_key_store.ts +205 -0
  66. package/src/metrics.ts +86 -23
  67. package/src/tx_validator/index.ts +2 -0
  68. package/src/tx_validator/nullifier_cache.ts +30 -0
  69. package/src/tx_validator/tx_validator_factory.ts +154 -0
  70. package/src/validator.ts +757 -221
  71. package/dest/errors/index.d.ts +0 -2
  72. package/dest/errors/index.d.ts.map +0 -1
  73. package/dest/errors/index.js +0 -1
  74. package/dest/errors/validator.error.d.ts +0 -29
  75. package/dest/errors/validator.error.d.ts.map +0 -1
  76. package/dest/errors/validator.error.js +0 -45
  77. package/src/errors/index.ts +0 -1
  78. package/src/errors/validator.error.ts +0 -55
@@ -0,0 +1,173 @@
1
+ import { merge, pick } from '@aztec/foundation/collection';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { bufferToHex } from '@aztec/foundation/string';
4
+ import { 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, NoValidTxsError } 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
+ /**
15
+ * Builder for a single checkpoint. Handles building blocks within the checkpoint
16
+ * and completing it.
17
+ */ export class CheckpointBuilder {
18
+ checkpointBuilder;
19
+ fork;
20
+ config;
21
+ contractDataSource;
22
+ dateProvider;
23
+ telemetryClient;
24
+ log;
25
+ constructor(checkpointBuilder, fork, config, contractDataSource, dateProvider, telemetryClient, bindings){
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
+ this.log = createLogger('checkpoint-builder', {
33
+ ...bindings,
34
+ instanceId: `checkpoint-${checkpointBuilder.checkpointNumber}`
35
+ });
36
+ }
37
+ getConstantData() {
38
+ return this.checkpointBuilder.constants;
39
+ }
40
+ /**
41
+ * Builds a single block within this checkpoint.
42
+ */ async buildBlock(pendingTxs, blockNumber, timestamp, opts = {}) {
43
+ const slot = this.checkpointBuilder.constants.slotNumber;
44
+ this.log.verbose(`Building block ${blockNumber} for slot ${slot} within checkpoint`, {
45
+ slot,
46
+ blockNumber,
47
+ ...opts,
48
+ currentTime: new Date(this.dateProvider.now())
49
+ });
50
+ const constants = this.checkpointBuilder.constants;
51
+ const globalVariables = GlobalVariables.from({
52
+ chainId: constants.chainId,
53
+ version: constants.version,
54
+ blockNumber,
55
+ slotNumber: constants.slotNumber,
56
+ timestamp,
57
+ coinbase: constants.coinbase,
58
+ feeRecipient: constants.feeRecipient,
59
+ gasFees: constants.gasFees
60
+ });
61
+ const { processor, validator } = await this.makeBlockBuilderDeps(globalVariables, this.fork);
62
+ const [publicProcessorDuration, [processedTxs, failedTxs, usedTxs, _, usedTxBlobFields]] = await elapsed(()=>processor.process(pendingTxs, opts, validator));
63
+ // Throw if we didn't collect a single valid tx and we're not allowed to build empty blocks
64
+ // (only the first block in a checkpoint can be empty)
65
+ if (processedTxs.length === 0 && this.checkpointBuilder.getBlockCount() > 0) {
66
+ throw new NoValidTxsError(failedTxs);
67
+ }
68
+ // Add block to checkpoint
69
+ const block = await this.checkpointBuilder.addBlock(globalVariables, processedTxs, {
70
+ expectedEndState: opts.expectedEndState
71
+ });
72
+ // How much public gas was processed
73
+ const publicGas = processedTxs.reduce((acc, tx)=>acc.add(tx.gasUsed.publicGas), Gas.empty());
74
+ this.log.debug('Built block within checkpoint', {
75
+ header: block.header.toInspect(),
76
+ processedTxs: processedTxs.map((tx)=>tx.hash.toString()),
77
+ failedTxs: failedTxs.map((tx)=>tx.tx.txHash.toString())
78
+ });
79
+ return {
80
+ block,
81
+ publicGas,
82
+ publicProcessorDuration,
83
+ numTxs: processedTxs.length,
84
+ failedTxs,
85
+ usedTxs,
86
+ usedTxBlobFields
87
+ };
88
+ }
89
+ /** Completes the checkpoint and returns it. */ async completeCheckpoint() {
90
+ const checkpoint = await this.checkpointBuilder.completeCheckpoint();
91
+ this.log.verbose(`Completed checkpoint ${checkpoint.number}`, {
92
+ checkpointNumber: checkpoint.number,
93
+ numBlocks: checkpoint.blocks.length,
94
+ archiveRoot: checkpoint.archive.root.toString()
95
+ });
96
+ return checkpoint;
97
+ }
98
+ /** Gets the checkpoint currently in progress. */ getCheckpoint() {
99
+ return this.checkpointBuilder.clone().completeCheckpoint();
100
+ }
101
+ async makeBlockBuilderDeps(globalVariables, fork) {
102
+ const txPublicSetupAllowList = this.config.txPublicSetupAllowList ?? await getDefaultAllowedSetupFunctions();
103
+ const contractsDB = new PublicContractsDB(this.contractDataSource, this.log.getBindings());
104
+ const guardedFork = new GuardedMerkleTreeOperations(fork);
105
+ const bindings = this.log.getBindings();
106
+ const publicTxSimulator = createPublicTxSimulatorForBlockBuilding(guardedFork, contractsDB, globalVariables, this.telemetryClient, bindings);
107
+ const processor = new PublicProcessor(globalVariables, guardedFork, contractsDB, publicTxSimulator, this.dateProvider, this.telemetryClient, createLogger('simulator:public-processor', bindings), this.config);
108
+ const validator = createValidatorForBlockBuilding(fork, this.contractDataSource, globalVariables, txPublicSetupAllowList, this.log.getBindings());
109
+ return {
110
+ processor,
111
+ validator
112
+ };
113
+ }
114
+ }
115
+ /** Factory for creating checkpoint builders. */ export class FullNodeCheckpointsBuilder {
116
+ config;
117
+ worldState;
118
+ contractDataSource;
119
+ dateProvider;
120
+ telemetryClient;
121
+ log;
122
+ constructor(config, worldState, contractDataSource, dateProvider, telemetryClient = getTelemetryClient()){
123
+ this.config = config;
124
+ this.worldState = worldState;
125
+ this.contractDataSource = contractDataSource;
126
+ this.dateProvider = dateProvider;
127
+ this.telemetryClient = telemetryClient;
128
+ this.log = createLogger('checkpoint-builder');
129
+ }
130
+ getConfig() {
131
+ return this.config;
132
+ }
133
+ updateConfig(config) {
134
+ this.config = merge(this.config, pick(config, ...FullNodeBlockBuilderConfigKeys));
135
+ }
136
+ /**
137
+ * Starts a new checkpoint and returns a CheckpointBuilder to build blocks within it.
138
+ */ async startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings) {
139
+ const stateReference = await fork.getStateReference();
140
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
141
+ this.log.verbose(`Building new checkpoint ${checkpointNumber}`, {
142
+ checkpointNumber,
143
+ msgCount: l1ToL2Messages.length,
144
+ initialStateReference: stateReference.toInspect(),
145
+ initialArchiveRoot: bufferToHex(archiveTree.root),
146
+ constants
147
+ });
148
+ const lightweightBuilder = await LightweightCheckpointBuilder.startNewCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
149
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings);
150
+ }
151
+ /**
152
+ * Opens a checkpoint, either starting fresh or resuming from existing blocks.
153
+ */ async openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks = [], bindings) {
154
+ const stateReference = await fork.getStateReference();
155
+ const archiveTree = await fork.getTreeInfo(MerkleTreeId.ARCHIVE);
156
+ if (existingBlocks.length === 0) {
157
+ return this.startCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, bindings);
158
+ }
159
+ this.log.verbose(`Resuming checkpoint ${checkpointNumber} with ${existingBlocks.length} existing blocks`, {
160
+ checkpointNumber,
161
+ msgCount: l1ToL2Messages.length,
162
+ existingBlockCount: existingBlocks.length,
163
+ initialStateReference: stateReference.toInspect(),
164
+ initialArchiveRoot: bufferToHex(archiveTree.root),
165
+ constants
166
+ });
167
+ const lightweightBuilder = await LightweightCheckpointBuilder.resumeCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, existingBlocks, bindings);
168
+ return new CheckpointBuilder(lightweightBuilder, fork, this.config, this.contractDataSource, this.dateProvider, this.telemetryClient, bindings);
169
+ }
170
+ /** Returns a fork of the world state at the given block number. */ getFork(blockNumber) {
171
+ return this.worldState.fork(blockNumber);
172
+ }
173
+ }
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uZmlnLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFDTCxLQUFLLGtCQUFrQixFQUt4QixNQUFNLDBCQUEwQixDQUFDO0FBRWxDLE9BQU8sS0FBSyxFQUFFLHFCQUFxQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFHN0UsWUFBWSxFQUFFLHFCQUFxQixFQUFFLENBQUM7QUFFdEMsZUFBTyxNQUFNLDZCQUE2QixFQUFFLGtCQUFrQixDQUFDLHFCQUFxQixDQStEbkYsQ0FBQztBQUVGOzs7O0dBSUc7QUFDSCx3QkFBZ0IsZ0JBQWdCLElBQUkscUJBQXFCLENBRXhEIn0=
@@ -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;AAG7E,YAAY,EAAE,qBAAqB,EAAE,CAAC;AAEtC,eAAO,MAAM,6BAA6B,EAAE,kBAAkB,CAAC,qBAAqB,CA+DnF,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,qBAAqB,CAExD"}
package/dest/config.js CHANGED
@@ -1,15 +1,30 @@
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
+ import { validatorHASignerConfigMappings } from '@aztec/validator-ha-signer/config';
3
4
  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'
5
+ validatorPrivateKeys: {
6
+ env: 'VALIDATOR_PRIVATE_KEYS',
7
+ description: 'List of private keys of the validators participating in attestation duties',
8
+ ...secretValueConfigHelper((val)=>val ? val.split(',').map((key)=>`0x${key.replace('0x', '')}`) : []),
9
+ fallback: [
10
+ 'VALIDATOR_PRIVATE_KEY'
11
+ ]
12
+ },
13
+ validatorAddresses: {
14
+ env: 'VALIDATOR_ADDRESSES',
15
+ description: 'List of addresses of the validators to use with remote signers',
16
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
17
+ defaultValue: []
8
18
  },
9
19
  disableValidator: {
10
20
  env: 'VALIDATOR_DISABLED',
11
21
  description: 'Do not run the validator',
12
- ...booleanConfigHelper()
22
+ ...booleanConfigHelper(false)
23
+ },
24
+ disabledValidators: {
25
+ description: 'Temporarily disable these specific validator addresses',
26
+ parseEnv: (val)=>val.split(',').filter((address)=>address && address.trim().length > 0).map((address)=>EthAddress.fromString(address.trim())),
27
+ defaultValue: []
13
28
  },
14
29
  attestationPollingIntervalMs: {
15
30
  env: 'VALIDATOR_ATTESTATIONS_POLLING_INTERVAL_MS',
@@ -20,7 +35,25 @@ export const validatorClientConfigMappings = {
20
35
  env: 'VALIDATOR_REEXECUTE',
21
36
  description: 'Re-execute transactions before attesting',
22
37
  ...booleanConfigHelper(true)
23
- }
38
+ },
39
+ alwaysReexecuteBlockProposals: {
40
+ description: 'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
41
+ defaultValue: true
42
+ },
43
+ fishermanMode: {
44
+ env: 'FISHERMAN_MODE',
45
+ description: 'Whether to run in fisherman mode: validates all proposals and attestations but does not broadcast attestations or participate in consensus.',
46
+ ...booleanConfigHelper(false)
47
+ },
48
+ skipCheckpointProposalValidation: {
49
+ description: 'Skip checkpoint proposal validation and always attest (default: false)',
50
+ defaultValue: false
51
+ },
52
+ skipPushProposedBlocksToArchiver: {
53
+ description: 'Skip pushing re-executed blocks to archiver (default: false)',
54
+ defaultValue: false
55
+ },
56
+ ...validatorHASignerConfigMappings
24
57
  };
25
58
  /**
26
59
  * Returns the prover configuration from the environment variables.
@@ -1,29 +1,66 @@
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 { BlockNumber, type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import type { EthAddress } from '@aztec/foundation/eth-address';
4
+ import type { Signature } from '@aztec/foundation/eth-signature';
5
+ import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
6
+ import type { CreateCheckpointProposalLastBlockData } from '@aztec/stdlib/interfaces/server';
7
+ import { BlockProposal, type BlockProposalOptions, CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions } from '@aztec/stdlib/p2p';
8
+ import type { CheckpointHeader } from '@aztec/stdlib/rollup';
9
+ import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
4
10
  import type { ValidatorKeyStore } from '../key_store/interface.js';
5
11
  export declare class ValidationService {
6
12
  private keyStore;
7
- constructor(keyStore: ValidatorKeyStore);
13
+ private log;
14
+ constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
8
15
  /**
9
16
  * Create a block proposal with the given header, archive, and transactions
10
17
  *
11
- * @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
12
21
  * @param archive - The archive of the current block
13
- * @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
24
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
14
25
  *
15
- * @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
16
29
  */
17
- createBlockProposal(header: BlockHeader, archive: Fr, txs: TxHash[]): Promise<BlockProposal>;
30
+ createBlockProposal(blockHeader: BlockHeader, blockIndexWithinCheckpoint: IndexWithinCheckpoint, inHash: Fr, archive: Fr, txs: Tx[], proposerAttesterAddress: EthAddress | undefined, options: BlockProposalOptions): Promise<BlockProposal>;
18
31
  /**
19
- * Attest 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 lastBlockInfo - Info about the last block (header, index, txs) 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, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAttesterAddress: EthAddress | undefined, options: CheckpointProposalOptions): Promise<CheckpointProposal>;
43
+ /**
44
+ * Attest with selection of validators to the given checkpoint proposal
20
45
  *
21
46
  * NOTE: This is just a blind signing.
22
47
  * We assume that the proposal is valid and DA guarantees have been checked previously.
23
48
  *
24
- * @param proposal - The proposal to attest to
25
- * @returns attestation
49
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
50
+ * @param attestors - The validators to attest with
51
+ * @returns checkpoint attestations
52
+ */
53
+ attestToCheckpointProposal(proposal: CheckpointProposalCore, attestors: EthAddress[]): 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
+ * @param blockNumber - The block or checkpoint number for HA signing context
60
+ * @returns signature
61
+ * @throws DutyAlreadySignedError if already signed by another HA node
62
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
26
63
  */
27
- attestToProposal(proposal: BlockProposal): Promise<BlockAttestation>;
64
+ signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, blockNumber: BlockNumber | CheckpointNumber): Promise<Signature>;
28
65
  }
29
- //# sourceMappingURL=validation_service.d.ts.map
66
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGlvbl9zZXJ2aWNlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvZHV0aWVzL3ZhbGlkYXRpb25fc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQ0wsV0FBVyxFQUNYLEtBQUssZ0JBQWdCLEVBQ3JCLHFCQUFxQixFQUNyQixLQUFLLFVBQVUsRUFDaEIsTUFBTSxpQ0FBaUMsQ0FBQztBQUd6QyxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sK0JBQStCLENBQUM7QUFDaEUsT0FBTyxLQUFLLEVBQUUsU0FBUyxFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFFakUsT0FBTyxLQUFLLEVBQUUsK0JBQStCLEVBQUUsTUFBTSxxQkFBcUIsQ0FBQztBQUMzRSxPQUFPLEtBQUssRUFBRSxxQ0FBcUMsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBQzdGLE9BQU8sRUFDTCxhQUFhLEVBQ2IsS0FBSyxvQkFBb0IsRUFDekIscUJBQXFCLEVBQ3JCLGtCQUFrQixFQUNsQixLQUFLLHNCQUFzQixFQUMzQixLQUFLLHlCQUF5QixFQUcvQixNQUFNLG1CQUFtQixDQUFDO0FBQzNCLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sc0JBQXNC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Q0FBQyxDQW9EbEM7SUFFRDs7Ozs7Ozs7O09BU0c7SUFDSCwwQkFBMEIsQ0FDeEIsc0JBQXNCLEVBQUUsK0JBQStCLEVBQ3ZELFFBQVEsRUFBRSxVQUFVLEVBQ3BCLElBQUksRUFBRSxVQUFVLEVBQ2hCLFdBQVcsRUFBRSxXQUFXLEdBQUcsZ0JBQWdCLEdBQzFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FXcEI7Q0FDRiJ9
@@ -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":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,gBAAgB,EACrB,qBAAqB,EACrB,KAAK,UAAU,EAChB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAA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ChC,SAAS,EAAE,UAAU,EAAE,GACtB,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAoDlC;IAED;;;;;;;;;OASG;IACH,0BAA0B,CACxB,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAC1C,OAAO,CAAC,SAAS,CAAC,CAWpB;CACF"}
@@ -1,35 +1,141 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
1
2
  import { Buffer32 } from '@aztec/foundation/buffer';
2
- import { keccak256 } from '@aztec/foundation/crypto';
3
- import { BlockAttestation, BlockProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
3
+ import { keccak256 } from '@aztec/foundation/crypto/keccak';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
5
+ import { createLogger } from '@aztec/foundation/log';
6
+ import { BlockProposal, CheckpointAttestation, CheckpointProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
7
+ import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
8
+ import { DutyType } from '@aztec/validator-ha-signer/types';
4
9
  export class ValidationService {
5
10
  keyStore;
6
- constructor(keyStore){
11
+ log;
12
+ constructor(keyStore, log = createLogger('validator:validation-service')){
7
13
  this.keyStore = keyStore;
14
+ this.log = log;
8
15
  }
9
16
  /**
10
17
  * Create a block proposal with the given header, archive, and transactions
11
18
  *
12
- * @param header - The block header
19
+ * @param blockHeader - The block header
20
+ * @param blockIndexWithinCheckpoint - The block index within checkpoint for HA signing context
21
+ * @param inHash - Hash of L1 to L2 messages for this checkpoint
13
22
  * @param archive - The archive of the current block
14
- * @param txs - TxHash[] ordered list of transactions
23
+ * @param txs - Ordered list of transactions (Tx[])
24
+ * @param proposerAttesterAddress - The address of the proposer/attester, or undefined
25
+ * @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
15
26
  *
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);
27
+ * @returns A block proposal signing the above information
28
+ * @throws DutyAlreadySignedError if HA signer indicates duty already signed by another node
29
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
30
+ */ createBlockProposal(blockHeader, blockIndexWithinCheckpoint, inHash, archive, txs, proposerAttesterAddress, options) {
31
+ // For testing: change the new archive to trigger state_mismatch validation failure
32
+ if (options.broadcastInvalidBlockProposal) {
33
+ archive = Fr.random();
34
+ this.log.warn(`Creating INVALID block proposal for slot ${blockHeader.globalVariables.slotNumber}`);
35
+ }
36
+ // Create a signer that uses the appropriate address
37
+ const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
38
+ const payloadSigner = (payload, context)=>this.keyStore.signMessageWithAddress(address, payload, context);
39
+ return BlockProposal.createProposalFromSigner(blockHeader, blockIndexWithinCheckpoint, inHash, archive, txs.map((tx)=>tx.getTxHash()), options.publishFullTxs ? txs : undefined, payloadSigner);
20
40
  }
21
41
  /**
22
- * Attest to the given block proposal constructed by the current sequencer
42
+ * Create a checkpoint proposal with the last block header and checkpoint header
43
+ *
44
+ * @param checkpointHeader - The checkpoint header containing aggregated data
45
+ * @param archive - The archive of the checkpoint
46
+ * @param lastBlockInfo - Info about the last block (header, index, txs) or undefined
47
+ * @param proposerAttesterAddress - The address of the proposer
48
+ * @param options - Checkpoint proposal options
49
+ *
50
+ * @returns A checkpoint proposal signing the above information
51
+ */ createCheckpointProposal(checkpointHeader, archive, lastBlockInfo, proposerAttesterAddress, options) {
52
+ // For testing: change the archive to trigger state_mismatch validation failure
53
+ if (options.broadcastInvalidCheckpointProposal) {
54
+ archive = Fr.random();
55
+ this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
56
+ }
57
+ // Create a signer that takes payload and context, and uses the appropriate address
58
+ const payloadSigner = (payload, context)=>{
59
+ const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
60
+ return this.keyStore.signMessageWithAddress(address, payload, context);
61
+ };
62
+ // Last block to include in the proposal
63
+ const lastBlock = lastBlockInfo && {
64
+ blockHeader: lastBlockInfo.blockHeader,
65
+ indexWithinCheckpoint: lastBlockInfo.indexWithinCheckpoint,
66
+ txHashes: lastBlockInfo.txs.map((tx)=>tx.getTxHash()),
67
+ txs: options.publishFullTxs ? lastBlockInfo.txs : undefined
68
+ };
69
+ return CheckpointProposal.createProposalFromSigner(checkpointHeader, archive, lastBlock, payloadSigner);
70
+ }
71
+ /**
72
+ * Attest with selection of validators to the given checkpoint proposal
23
73
  *
24
74
  * NOTE: This is just a blind signing.
25
75
  * We assume that the proposal is valid and DA guarantees have been checked previously.
26
76
  *
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);
77
+ * @param proposal - The checkpoint proposal (core version without lastBlock) to attest to
78
+ * @param attestors - The validators to attest with
79
+ * @returns checkpoint attestations
80
+ */ async attestToCheckpointProposal(proposal, attestors) {
81
+ // Create the attestation payload from the checkpoint proposal
82
+ const payload = new ConsensusPayload(proposal.checkpointHeader, proposal.archive);
83
+ const buf = Buffer32.fromBuffer(keccak256(payload.getPayloadToSign(SignatureDomainSeparator.checkpointAttestation)));
84
+ // TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
85
+ // Currently using lastBlock.blockNumber as a proxy for checkpoint identification in HA signing.
86
+ // blockNumber is NOT used for the primary key so it's safe to use here.
87
+ // See CheckpointHeader TODO and SigningContext types documentation.
88
+ let blockNumber;
89
+ try {
90
+ blockNumber = proposal.blockNumber;
91
+ } catch {
92
+ // Checkpoint proposal may not have lastBlock, use 0 as fallback
93
+ blockNumber = BlockNumber(0);
94
+ }
95
+ const context = {
96
+ slot: proposal.slotNumber,
97
+ blockNumber,
98
+ dutyType: DutyType.ATTESTATION
99
+ };
100
+ // Sign each attestor in parallel, catching HA errors per-attestor
101
+ const results = await Promise.allSettled(attestors.map(async (attestor)=>{
102
+ const sig = await this.keyStore.signMessageWithAddress(attestor, buf, context);
103
+ // return new BlockAttestation(proposal.payload, sig, proposal.signature);
104
+ return new CheckpointAttestation(payload, sig, proposal.signature);
105
+ }));
106
+ const attestations = [];
107
+ for(let i = 0; i < results.length; i++){
108
+ const result = results[i];
109
+ if (result.status === 'fulfilled') {
110
+ attestations.push(result.value);
111
+ } else {
112
+ const error = result.reason;
113
+ if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
114
+ this.log.info(`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`);
115
+ // Continue with remaining attestors
116
+ } else {
117
+ throw error;
118
+ }
119
+ }
120
+ }
121
+ return attestations;
122
+ }
123
+ /**
124
+ * Sign attestations and signers payload
125
+ * @param attestationsAndSigners - The attestations and signers to sign
126
+ * @param proposer - The proposer address to sign with
127
+ * @param slot - The slot number for HA signing context
128
+ * @param blockNumber - The block or checkpoint number for HA signing context
129
+ * @returns signature
130
+ * @throws DutyAlreadySignedError if already signed by another HA node
131
+ * @throws SlashingProtectionError if attempting to sign different data for same slot
132
+ */ signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber) {
133
+ const context = {
134
+ slot,
135
+ blockNumber,
136
+ dutyType: DutyType.ATTESTATIONS_AND_SIGNERS
137
+ };
138
+ const buf = Buffer32.fromBuffer(keccak256(attestationsAndSigners.getPayloadToSign(SignatureDomainSeparator.attestationsAndSigners)));
139
+ return this.keyStore.signMessageWithAddress(proposer, buf, context);
34
140
  }
35
141
  }
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;
12
- }): ValidatorClient | undefined;
13
- //# sourceMappingURL=factory.d.ts.map
32
+ keyStoreManager: KeystoreManager | undefined;
33
+ blobClient: BlobCl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,EAAE,0BAA0B,CAAC;IAC/C,UAAU,EAAE,sBAAsB,CAAC;IACnC,WAAW,EAAE,aAAa,GAAG,WAAW,CAAC;IACzC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,eAAe,CAAC;CAC5B,wBAmBF;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,yBAAyB,EACjC,IAAI,EAAE;IACJ,kBAAkB,EAAE,0BAA0B,CAAC;IAC/C,UAAU,EAAE,sBAAsB,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,aAAa,GAAG,WAAW,CAAC;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,wCAqBF"}
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, deps.epochCache, 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';