@aztec/validator-client 3.0.0-nightly.20251007 → 3.0.0-nightly.20251009
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.
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
2
2
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
3
|
-
import
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
5
5
|
import { BlockAttestation, BlockProposal, type BlockProposalOptions } from '@aztec/stdlib/p2p';
|
|
6
6
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
7
|
-
import
|
|
7
|
+
import { StateReference, type Tx } from '@aztec/stdlib/tx';
|
|
8
8
|
import type { ValidatorKeyStore } from '../key_store/interface.js';
|
|
9
9
|
export declare class ValidationService {
|
|
10
10
|
private keyStore;
|
|
11
|
-
|
|
11
|
+
private log;
|
|
12
|
+
constructor(keyStore: ValidatorKeyStore, log?: import("@aztec/foundation/log").Logger);
|
|
12
13
|
/**
|
|
13
14
|
* Create a block proposal with the given header, archive, and transactions
|
|
14
15
|
*
|
|
@@ -16,6 +17,7 @@ export declare class ValidationService {
|
|
|
16
17
|
* @param header - The block header
|
|
17
18
|
* @param archive - The archive of the current block
|
|
18
19
|
* @param txs - TxHash[] ordered list of transactions
|
|
20
|
+
* @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
|
|
19
21
|
*
|
|
20
22
|
* @returns A block proposal signing the above information (not the current implementation!!!)
|
|
21
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation_service.d.ts","sourceRoot":"","sources":["../../src/duties/validation_service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,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
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
3
5
|
import { BlockAttestation, BlockProposal, ConsensusPayload, SignatureDomainSeparator } from '@aztec/stdlib/p2p';
|
|
6
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
4
7
|
export class ValidationService {
|
|
5
8
|
keyStore;
|
|
6
|
-
|
|
9
|
+
log;
|
|
10
|
+
constructor(keyStore, log = createLogger('validator:validation-service')){
|
|
7
11
|
this.keyStore = keyStore;
|
|
12
|
+
this.log = log;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
15
|
* Create a block proposal with the given header, archive, and transactions
|
|
@@ -13,6 +18,7 @@ export class ValidationService {
|
|
|
13
18
|
* @param header - The block header
|
|
14
19
|
* @param archive - The archive of the current block
|
|
15
20
|
* @param txs - TxHash[] ordered list of transactions
|
|
21
|
+
* @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
|
|
16
22
|
*
|
|
17
23
|
* @returns A block proposal signing the above information (not the current implementation!!!)
|
|
18
24
|
*/ async createBlockProposal(blockNumber, header, archive, stateReference, txs, proposerAttesterAddress, options) {
|
|
@@ -26,6 +32,11 @@ export class ValidationService {
|
|
|
26
32
|
}
|
|
27
33
|
// TODO: check if this is calculated earlier / can not be recomputed
|
|
28
34
|
const txHashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
|
|
35
|
+
// For testing: corrupt the state reference to trigger state_mismatch validation failure
|
|
36
|
+
if (options.broadcastInvalidBlockProposal) {
|
|
37
|
+
unfreeze(stateReference.partial).noteHashTree = AppendOnlyTreeSnapshot.random();
|
|
38
|
+
this.log.warn(`Creating INVALID block proposal for block ${blockNumber} at slot ${header.slotNumber.toBigInt()}`);
|
|
39
|
+
}
|
|
29
40
|
return BlockProposal.createProposalFromSigner(blockNumber, new ConsensusPayload(header, archive, stateReference), txHashes, options.publishFullTxs ? txs : undefined, payloadSigner);
|
|
30
41
|
}
|
|
31
42
|
/**
|
package/dest/validator.js
CHANGED
|
@@ -43,7 +43,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
43
43
|
super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.blockProposalHandler = blockProposalHandler, this.config = config, this.dateProvider = dateProvider, this.log = log, this.hasRegisteredHandlers = false, this.proposersOfInvalidBlocks = new Set();
|
|
44
44
|
this.tracer = telemetry.getTracer('Validator');
|
|
45
45
|
this.metrics = new ValidatorMetrics(telemetry);
|
|
46
|
-
this.validationService = new ValidationService(keyStore);
|
|
46
|
+
this.validationService = new ValidationService(keyStore, log.createChild('validation-service'));
|
|
47
47
|
// Refresh epoch cache every second to trigger alert if participation in committee changes
|
|
48
48
|
this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), log, 1000);
|
|
49
49
|
const myAddresses = this.getValidatorAddresses();
|
|
@@ -220,7 +220,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
220
220
|
this.log.verbose(`Already made a proposal for the same slot, skipping proposal`);
|
|
221
221
|
return Promise.resolve(undefined);
|
|
222
222
|
}
|
|
223
|
-
const newProposal = await this.validationService.createBlockProposal(blockNumber, header, archive, stateReference, txs, proposerAddress,
|
|
223
|
+
const newProposal = await this.validationService.createBlockProposal(blockNumber, header, archive, stateReference, txs, proposerAddress, {
|
|
224
|
+
...options,
|
|
225
|
+
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
|
|
226
|
+
});
|
|
224
227
|
this.previousProposal = newProposal;
|
|
225
228
|
return newProposal;
|
|
226
229
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/validator-client",
|
|
3
|
-
"version": "3.0.0-nightly.
|
|
3
|
+
"version": "3.0.0-nightly.20251009",
|
|
4
4
|
"main": "dest/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
]
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
68
|
-
"@aztec/epoch-cache": "3.0.0-nightly.
|
|
69
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
70
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
71
|
-
"@aztec/node-keystore": "3.0.0-nightly.
|
|
72
|
-
"@aztec/p2p": "3.0.0-nightly.
|
|
73
|
-
"@aztec/prover-client": "3.0.0-nightly.
|
|
74
|
-
"@aztec/slasher": "3.0.0-nightly.
|
|
75
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
76
|
-
"@aztec/telemetry-client": "3.0.0-nightly.
|
|
67
|
+
"@aztec/constants": "3.0.0-nightly.20251009",
|
|
68
|
+
"@aztec/epoch-cache": "3.0.0-nightly.20251009",
|
|
69
|
+
"@aztec/ethereum": "3.0.0-nightly.20251009",
|
|
70
|
+
"@aztec/foundation": "3.0.0-nightly.20251009",
|
|
71
|
+
"@aztec/node-keystore": "3.0.0-nightly.20251009",
|
|
72
|
+
"@aztec/p2p": "3.0.0-nightly.20251009",
|
|
73
|
+
"@aztec/prover-client": "3.0.0-nightly.20251009",
|
|
74
|
+
"@aztec/slasher": "3.0.0-nightly.20251009",
|
|
75
|
+
"@aztec/stdlib": "3.0.0-nightly.20251009",
|
|
76
|
+
"@aztec/telemetry-client": "3.0.0-nightly.20251009",
|
|
77
77
|
"koa": "^2.16.1",
|
|
78
78
|
"koa-router": "^13.1.1",
|
|
79
79
|
"tslib": "^2.4.0",
|
|
@@ -2,7 +2,9 @@ import { Buffer32 } from '@aztec/foundation/buffer';
|
|
|
2
2
|
import { keccak256 } from '@aztec/foundation/crypto';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
-
import
|
|
5
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
6
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { unfreeze } from '@aztec/foundation/types';
|
|
6
8
|
import type { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
7
9
|
import {
|
|
8
10
|
BlockAttestation,
|
|
@@ -12,12 +14,16 @@ import {
|
|
|
12
14
|
SignatureDomainSeparator,
|
|
13
15
|
} from '@aztec/stdlib/p2p';
|
|
14
16
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
15
|
-
import
|
|
17
|
+
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
18
|
+
import { StateReference, type Tx } from '@aztec/stdlib/tx';
|
|
16
19
|
|
|
17
20
|
import type { ValidatorKeyStore } from '../key_store/interface.js';
|
|
18
21
|
|
|
19
22
|
export class ValidationService {
|
|
20
|
-
constructor(
|
|
23
|
+
constructor(
|
|
24
|
+
private keyStore: ValidatorKeyStore,
|
|
25
|
+
private log = createLogger('validator:validation-service'),
|
|
26
|
+
) {}
|
|
21
27
|
|
|
22
28
|
/**
|
|
23
29
|
* Create a block proposal with the given header, archive, and transactions
|
|
@@ -26,6 +32,7 @@ export class ValidationService {
|
|
|
26
32
|
* @param header - The block header
|
|
27
33
|
* @param archive - The archive of the current block
|
|
28
34
|
* @param txs - TxHash[] ordered list of transactions
|
|
35
|
+
* @param options - Block proposal options (including broadcastInvalidBlockProposal for testing)
|
|
29
36
|
*
|
|
30
37
|
* @returns A block proposal signing the above information (not the current implementation!!!)
|
|
31
38
|
*/
|
|
@@ -49,6 +56,12 @@ export class ValidationService {
|
|
|
49
56
|
// TODO: check if this is calculated earlier / can not be recomputed
|
|
50
57
|
const txHashes = await Promise.all(txs.map(tx => tx.getTxHash()));
|
|
51
58
|
|
|
59
|
+
// For testing: corrupt the state reference to trigger state_mismatch validation failure
|
|
60
|
+
if (options.broadcastInvalidBlockProposal) {
|
|
61
|
+
unfreeze(stateReference.partial).noteHashTree = AppendOnlyTreeSnapshot.random();
|
|
62
|
+
this.log.warn(`Creating INVALID block proposal for block ${blockNumber} at slot ${header.slotNumber.toBigInt()}`);
|
|
63
|
+
}
|
|
64
|
+
|
|
52
65
|
return BlockProposal.createProposalFromSigner(
|
|
53
66
|
blockNumber,
|
|
54
67
|
new ConsensusPayload(header, archive, stateReference),
|
package/src/validator.ts
CHANGED
|
@@ -78,7 +78,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
78
78
|
this.tracer = telemetry.getTracer('Validator');
|
|
79
79
|
this.metrics = new ValidatorMetrics(telemetry);
|
|
80
80
|
|
|
81
|
-
this.validationService = new ValidationService(keyStore);
|
|
81
|
+
this.validationService = new ValidationService(keyStore, log.createChild('validation-service'));
|
|
82
82
|
|
|
83
83
|
// Refresh epoch cache every second to trigger alert if participation in committee changes
|
|
84
84
|
this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), log, 1000);
|
|
@@ -359,7 +359,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
359
359
|
stateReference,
|
|
360
360
|
txs,
|
|
361
361
|
proposerAddress,
|
|
362
|
-
options,
|
|
362
|
+
{ ...options, broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal },
|
|
363
363
|
);
|
|
364
364
|
this.previousProposal = newProposal;
|
|
365
365
|
return newProposal;
|