@aztec/validator-client 0.0.1-commit.7d4e6cd → 0.0.1-commit.858058eac
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.
- package/README.md +53 -24
- package/dest/block_proposal_handler.d.ts +8 -8
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +27 -32
- package/dest/checkpoint_builder.d.ts +21 -25
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +50 -32
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -14
- package/dest/duties/validation_service.d.ts +19 -6
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +72 -19
- package/dest/factory.d.ts +2 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +1 -1
- package/dest/key_store/ha_key_store.d.ts +99 -0
- package/dest/key_store/ha_key_store.d.ts.map +1 -0
- package/dest/key_store/ha_key_store.js +208 -0
- package/dest/key_store/index.d.ts +2 -1
- package/dest/key_store/index.d.ts.map +1 -1
- package/dest/key_store/index.js +1 -0
- package/dest/key_store/interface.d.ts +36 -6
- package/dest/key_store/interface.d.ts.map +1 -1
- package/dest/key_store/local_key_store.d.ts +10 -5
- package/dest/key_store/local_key_store.d.ts.map +1 -1
- package/dest/key_store/local_key_store.js +8 -4
- package/dest/key_store/node_keystore_adapter.d.ts +18 -5
- package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
- package/dest/key_store/node_keystore_adapter.js +18 -4
- package/dest/key_store/web3signer_key_store.d.ts +10 -5
- package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
- package/dest/key_store/web3signer_key_store.js +8 -4
- package/dest/metrics.d.ts +4 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +34 -5
- package/dest/tx_validator/tx_validator_factory.d.ts +4 -3
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -1
- package/dest/tx_validator/tx_validator_factory.js +17 -16
- package/dest/validator.d.ts +35 -16
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +194 -91
- package/package.json +21 -17
- package/src/block_proposal_handler.ts +41 -42
- package/src/checkpoint_builder.ts +85 -38
- package/src/config.ts +11 -13
- package/src/duties/validation_service.ts +91 -23
- package/src/factory.ts +1 -0
- package/src/key_store/ha_key_store.ts +269 -0
- package/src/key_store/index.ts +1 -0
- package/src/key_store/interface.ts +44 -5
- package/src/key_store/local_key_store.ts +13 -4
- package/src/key_store/node_keystore_adapter.ts +27 -4
- package/src/key_store/web3signer_key_store.ts +17 -4
- package/src/metrics.ts +45 -6
- package/src/tx_validator/tx_validator_factory.ts +52 -31
- package/src/validator.ts +253 -111
|
@@ -2,6 +2,7 @@ import type { Buffer32 } from '@aztec/foundation/buffer';
|
|
|
2
2
|
import { normalizeSignature } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
+
import type { SigningContext } from '@aztec/validator-ha-signer/types';
|
|
5
6
|
|
|
6
7
|
import type { TypedDataDefinition } from 'viem';
|
|
7
8
|
|
|
@@ -44,9 +45,10 @@ export class Web3SignerKeyStore implements ValidatorKeyStore {
|
|
|
44
45
|
/**
|
|
45
46
|
* Sign EIP-712 typed data with all keystore addresses
|
|
46
47
|
* @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
|
|
48
|
+
* @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
|
|
47
49
|
* @return signatures
|
|
48
50
|
*/
|
|
49
|
-
public signTypedData(typedData: TypedDataDefinition): Promise<Signature[]> {
|
|
51
|
+
public signTypedData(typedData: TypedDataDefinition, _context: SigningContext): Promise<Signature[]> {
|
|
50
52
|
return Promise.all(this.addresses.map(address => this.makeJsonRpcSignTypedDataRequest(address, typedData)));
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -54,10 +56,15 @@ export class Web3SignerKeyStore implements ValidatorKeyStore {
|
|
|
54
56
|
* Sign EIP-712 typed data with a specific address
|
|
55
57
|
* @param address - The address of the signer to use
|
|
56
58
|
* @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
|
|
59
|
+
* @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
|
|
57
60
|
* @returns signature for the specified address
|
|
58
61
|
* @throws Error if the address is not found in the keystore or signing fails
|
|
59
62
|
*/
|
|
60
|
-
public async signTypedDataWithAddress(
|
|
63
|
+
public async signTypedDataWithAddress(
|
|
64
|
+
address: EthAddress,
|
|
65
|
+
typedData: TypedDataDefinition,
|
|
66
|
+
_context: SigningContext,
|
|
67
|
+
): Promise<Signature> {
|
|
61
68
|
if (!this.addresses.some(addr => addr.equals(address))) {
|
|
62
69
|
throw new Error(`Address ${address.toString()} not found in keystore`);
|
|
63
70
|
}
|
|
@@ -69,9 +76,10 @@ export class Web3SignerKeyStore implements ValidatorKeyStore {
|
|
|
69
76
|
* Sign a message with all keystore addresses using EIP-191 prefix
|
|
70
77
|
*
|
|
71
78
|
* @param message - The message to sign
|
|
79
|
+
* @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
|
|
72
80
|
* @return signatures
|
|
73
81
|
*/
|
|
74
|
-
public signMessage(message: Buffer32): Promise<Signature[]> {
|
|
82
|
+
public signMessage(message: Buffer32, _context: SigningContext): Promise<Signature[]> {
|
|
75
83
|
return Promise.all(this.addresses.map(address => this.makeJsonRpcSignRequest(address, message)));
|
|
76
84
|
}
|
|
77
85
|
|
|
@@ -79,10 +87,15 @@ export class Web3SignerKeyStore implements ValidatorKeyStore {
|
|
|
79
87
|
* Sign a message with a specific address using EIP-191 prefix
|
|
80
88
|
* @param address - The address of the signer to use
|
|
81
89
|
* @param message - The message to sign
|
|
90
|
+
* @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
|
|
82
91
|
* @returns signature for the specified address
|
|
83
92
|
* @throws Error if the address is not found in the keystore or signing fails
|
|
84
93
|
*/
|
|
85
|
-
public async signMessageWithAddress(
|
|
94
|
+
public async signMessageWithAddress(
|
|
95
|
+
address: EthAddress,
|
|
96
|
+
message: Buffer32,
|
|
97
|
+
_context: SigningContext,
|
|
98
|
+
): Promise<Signature> {
|
|
86
99
|
if (!this.addresses.some(addr => addr.equals(address))) {
|
|
87
100
|
throw new Error(`Address ${address.toString()} not found in keystore`);
|
|
88
101
|
}
|
package/src/metrics.ts
CHANGED
|
@@ -6,8 +6,11 @@ import {
|
|
|
6
6
|
Metrics,
|
|
7
7
|
type TelemetryClient,
|
|
8
8
|
type UpDownCounter,
|
|
9
|
+
createUpDownCounterWithDefault,
|
|
9
10
|
} from '@aztec/telemetry-client';
|
|
10
11
|
|
|
12
|
+
import type { BlockProposalValidationFailureReason } from './block_proposal_handler.js';
|
|
13
|
+
|
|
11
14
|
export class ValidatorMetrics {
|
|
12
15
|
private failedReexecutionCounter: UpDownCounter;
|
|
13
16
|
private successfulAttestationsCount: UpDownCounter;
|
|
@@ -21,16 +24,44 @@ export class ValidatorMetrics {
|
|
|
21
24
|
constructor(telemetryClient: TelemetryClient) {
|
|
22
25
|
const meter = telemetryClient.getMeter('Validator');
|
|
23
26
|
|
|
24
|
-
this.failedReexecutionCounter = meter
|
|
27
|
+
this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
|
|
28
|
+
[Attributes.STATUS]: ['failed'],
|
|
29
|
+
});
|
|
25
30
|
|
|
26
|
-
this.successfulAttestationsCount =
|
|
31
|
+
this.successfulAttestationsCount = createUpDownCounterWithDefault(
|
|
32
|
+
meter,
|
|
33
|
+
Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT,
|
|
34
|
+
);
|
|
27
35
|
|
|
28
|
-
this.failedAttestationsBadProposalCount =
|
|
36
|
+
this.failedAttestationsBadProposalCount = createUpDownCounterWithDefault(
|
|
37
|
+
meter,
|
|
29
38
|
Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT,
|
|
39
|
+
{
|
|
40
|
+
[Attributes.ERROR_TYPE]: [
|
|
41
|
+
'invalid_proposal',
|
|
42
|
+
'state_mismatch',
|
|
43
|
+
'failed_txs',
|
|
44
|
+
'in_hash_mismatch',
|
|
45
|
+
'parent_block_wrong_slot',
|
|
46
|
+
],
|
|
47
|
+
[Attributes.IS_COMMITTEE_MEMBER]: [true, false],
|
|
48
|
+
},
|
|
30
49
|
);
|
|
31
50
|
|
|
32
|
-
this.failedAttestationsNodeIssueCount =
|
|
51
|
+
this.failedAttestationsNodeIssueCount = createUpDownCounterWithDefault(
|
|
52
|
+
meter,
|
|
33
53
|
Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT,
|
|
54
|
+
{
|
|
55
|
+
[Attributes.ERROR_TYPE]: [
|
|
56
|
+
'parent_block_not_found',
|
|
57
|
+
'global_variables_mismatch',
|
|
58
|
+
'block_number_already_exists',
|
|
59
|
+
'txs_not_available',
|
|
60
|
+
'timeout',
|
|
61
|
+
'unknown_error',
|
|
62
|
+
],
|
|
63
|
+
[Attributes.IS_COMMITTEE_MEMBER]: [true, false],
|
|
64
|
+
},
|
|
34
65
|
);
|
|
35
66
|
|
|
36
67
|
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
|
|
@@ -58,14 +89,22 @@ export class ValidatorMetrics {
|
|
|
58
89
|
this.successfulAttestationsCount.add(num);
|
|
59
90
|
}
|
|
60
91
|
|
|
61
|
-
public incFailedAttestationsBadProposal(
|
|
92
|
+
public incFailedAttestationsBadProposal(
|
|
93
|
+
num: number,
|
|
94
|
+
reason: BlockProposalValidationFailureReason,
|
|
95
|
+
inCommittee: boolean,
|
|
96
|
+
) {
|
|
62
97
|
this.failedAttestationsBadProposalCount.add(num, {
|
|
63
98
|
[Attributes.ERROR_TYPE]: reason,
|
|
64
99
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
|
|
65
100
|
});
|
|
66
101
|
}
|
|
67
102
|
|
|
68
|
-
public incFailedAttestationsNodeIssue(
|
|
103
|
+
public incFailedAttestationsNodeIssue(
|
|
104
|
+
num: number,
|
|
105
|
+
reason: BlockProposalValidationFailureReason,
|
|
106
|
+
inCommittee: boolean,
|
|
107
|
+
) {
|
|
69
108
|
this.failedAttestationsNodeIssueCount.add(num, {
|
|
70
109
|
[Attributes.ERROR_TYPE]: reason,
|
|
71
110
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import type { LoggerBindings } from '@aztec/foundation/log';
|
|
3
4
|
import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
5
|
import {
|
|
5
6
|
AggregateTxValidator,
|
|
@@ -10,6 +11,7 @@ import {
|
|
|
10
11
|
GasTxValidator,
|
|
11
12
|
MetadataTxValidator,
|
|
12
13
|
PhasesTxValidator,
|
|
14
|
+
SizeTxValidator,
|
|
13
15
|
TimestampTxValidator,
|
|
14
16
|
TxPermittedValidator,
|
|
15
17
|
TxProofValidator,
|
|
@@ -52,31 +54,41 @@ export function createValidatorForAcceptingTxs(
|
|
|
52
54
|
blockNumber: BlockNumber;
|
|
53
55
|
txsPermitted: boolean;
|
|
54
56
|
},
|
|
57
|
+
bindings?: LoggerBindings,
|
|
55
58
|
): TxValidator<Tx> {
|
|
56
59
|
const validators: TxValidator<Tx>[] = [
|
|
57
|
-
new TxPermittedValidator(txsPermitted),
|
|
58
|
-
new
|
|
59
|
-
new
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
new
|
|
70
|
-
|
|
71
|
-
|
|
60
|
+
new TxPermittedValidator(txsPermitted, bindings),
|
|
61
|
+
new SizeTxValidator(bindings),
|
|
62
|
+
new DataTxValidator(bindings),
|
|
63
|
+
new MetadataTxValidator(
|
|
64
|
+
{
|
|
65
|
+
l1ChainId: new Fr(l1ChainId),
|
|
66
|
+
rollupVersion: new Fr(rollupVersion),
|
|
67
|
+
protocolContractsHash,
|
|
68
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
69
|
+
},
|
|
70
|
+
bindings,
|
|
71
|
+
),
|
|
72
|
+
new TimestampTxValidator(
|
|
73
|
+
{
|
|
74
|
+
timestamp,
|
|
75
|
+
blockNumber,
|
|
76
|
+
},
|
|
77
|
+
bindings,
|
|
78
|
+
),
|
|
79
|
+
new DoubleSpendTxValidator(new NullifierCache(db), bindings),
|
|
80
|
+
new PhasesTxValidator(contractDataSource, setupAllowList, timestamp, bindings),
|
|
81
|
+
new BlockHeaderTxValidator(new ArchiveCache(db), bindings),
|
|
72
82
|
];
|
|
73
83
|
|
|
74
84
|
if (!skipFeeEnforcement) {
|
|
75
|
-
validators.push(
|
|
85
|
+
validators.push(
|
|
86
|
+
new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, gasFees, bindings),
|
|
87
|
+
);
|
|
76
88
|
}
|
|
77
89
|
|
|
78
90
|
if (verifier) {
|
|
79
|
-
validators.push(new TxProofValidator(verifier));
|
|
91
|
+
validators.push(new TxProofValidator(verifier, bindings));
|
|
80
92
|
}
|
|
81
93
|
|
|
82
94
|
return new AggregateTxValidator(...validators);
|
|
@@ -87,6 +99,7 @@ export function createValidatorForBlockBuilding(
|
|
|
87
99
|
contractDataSource: ContractDataSource,
|
|
88
100
|
globalVariables: GlobalVariables,
|
|
89
101
|
setupAllowList: AllowedElement[],
|
|
102
|
+
bindings?: LoggerBindings,
|
|
90
103
|
): PublicProcessorValidator {
|
|
91
104
|
const nullifierCache = new NullifierCache(db);
|
|
92
105
|
const archiveCache = new ArchiveCache(db);
|
|
@@ -100,6 +113,7 @@ export function createValidatorForBlockBuilding(
|
|
|
100
113
|
contractDataSource,
|
|
101
114
|
globalVariables,
|
|
102
115
|
setupAllowList,
|
|
116
|
+
bindings,
|
|
103
117
|
),
|
|
104
118
|
nullifierCache,
|
|
105
119
|
};
|
|
@@ -112,22 +126,29 @@ function preprocessValidator(
|
|
|
112
126
|
contractDataSource: ContractDataSource,
|
|
113
127
|
globalVariables: GlobalVariables,
|
|
114
128
|
setupAllowList: AllowedElement[],
|
|
129
|
+
bindings?: LoggerBindings,
|
|
115
130
|
): TxValidator<Tx> {
|
|
116
131
|
// We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
|
|
117
132
|
return new AggregateTxValidator(
|
|
118
|
-
new MetadataTxValidator(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
133
|
+
new MetadataTxValidator(
|
|
134
|
+
{
|
|
135
|
+
l1ChainId: globalVariables.chainId,
|
|
136
|
+
rollupVersion: globalVariables.version,
|
|
137
|
+
protocolContractsHash,
|
|
138
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
139
|
+
},
|
|
140
|
+
bindings,
|
|
141
|
+
),
|
|
142
|
+
new TimestampTxValidator(
|
|
143
|
+
{
|
|
144
|
+
timestamp: globalVariables.timestamp,
|
|
145
|
+
blockNumber: globalVariables.blockNumber,
|
|
146
|
+
},
|
|
147
|
+
bindings,
|
|
148
|
+
),
|
|
149
|
+
new DoubleSpendTxValidator(nullifierCache, bindings),
|
|
150
|
+
new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp, bindings),
|
|
151
|
+
new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees, bindings),
|
|
152
|
+
new BlockHeaderTxValidator(archiveCache, bindings),
|
|
132
153
|
);
|
|
133
154
|
}
|