@aztec/validator-client 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9

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 (69) hide show
  1. package/README.md +285 -0
  2. package/dest/block_proposal_handler.d.ts +25 -14
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +339 -93
  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 +175 -0
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +20 -7
  11. package/dest/duties/validation_service.d.ts +47 -15
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +119 -30
  14. package/dest/factory.d.ts +13 -8
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +2 -2
  17. package/dest/index.d.ts +3 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +2 -0
  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 +2 -1
  24. package/dest/key_store/index.d.ts.map +1 -1
  25. package/dest/key_store/index.js +1 -0
  26. package/dest/key_store/interface.d.ts +36 -6
  27. package/dest/key_store/interface.d.ts.map +1 -1
  28. package/dest/key_store/local_key_store.d.ts +10 -5
  29. package/dest/key_store/local_key_store.d.ts.map +1 -1
  30. package/dest/key_store/local_key_store.js +9 -5
  31. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  32. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  33. package/dest/key_store/node_keystore_adapter.js +18 -4
  34. package/dest/key_store/web3signer_key_store.d.ts +10 -11
  35. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  36. package/dest/key_store/web3signer_key_store.js +13 -10
  37. package/dest/metrics.d.ts +8 -5
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +48 -33
  40. package/dest/tx_validator/index.d.ts +3 -0
  41. package/dest/tx_validator/index.d.ts.map +1 -0
  42. package/dest/tx_validator/index.js +2 -0
  43. package/dest/tx_validator/nullifier_cache.d.ts +14 -0
  44. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
  45. package/dest/tx_validator/nullifier_cache.js +24 -0
  46. package/dest/tx_validator/tx_validator_factory.d.ts +19 -0
  47. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
  48. package/dest/tx_validator/tx_validator_factory.js +54 -0
  49. package/dest/validator.d.ts +77 -22
  50. package/dest/validator.d.ts.map +1 -1
  51. package/dest/validator.js +521 -72
  52. package/package.json +24 -14
  53. package/src/block_proposal_handler.ts +265 -73
  54. package/src/checkpoint_builder.ts +321 -0
  55. package/src/config.ts +20 -6
  56. package/src/duties/validation_service.ts +173 -37
  57. package/src/factory.ts +17 -8
  58. package/src/index.ts +2 -0
  59. package/src/key_store/ha_key_store.ts +269 -0
  60. package/src/key_store/index.ts +1 -0
  61. package/src/key_store/interface.ts +44 -5
  62. package/src/key_store/local_key_store.ts +14 -5
  63. package/src/key_store/node_keystore_adapter.ts +28 -5
  64. package/src/key_store/web3signer_key_store.ts +22 -12
  65. package/src/metrics.ts +67 -36
  66. package/src/tx_validator/index.ts +2 -0
  67. package/src/tx_validator/nullifier_cache.ts +30 -0
  68. package/src/tx_validator/tx_validator_factory.ts +154 -0
  69. package/src/validator.ts +697 -104
@@ -193,8 +193,9 @@ export class NodeKeystoreAdapter {
193
193
  /**
194
194
  * Sign typed data with all attester signers across validators.
195
195
  * @param typedData EIP-712 typed data
196
+ * @param _context Signing context (ignored by NodeKeystoreAdapter, used for HA protection)
196
197
  * @returns Array of signatures in validator order, flattened
197
- */ async signTypedData(typedData) {
198
+ */ async signTypedData(typedData, _context) {
198
199
  const jobs = [];
199
200
  for (const i of this.validatorIndices()){
200
201
  const v = this.ensureValidator(i);
@@ -207,8 +208,9 @@ export class NodeKeystoreAdapter {
207
208
  /**
208
209
  * Sign a message with all attester signers across validators.
209
210
  * @param message 32-byte message (already hashed/padded as needed)
211
+ * @param _context Signing context (ignored by NodeKeystoreAdapter, used for HA protection)
210
212
  * @returns Array of signatures in validator order, flattened
211
- */ async signMessage(message) {
213
+ */ async signMessage(message, _context) {
212
214
  const jobs = [];
213
215
  for (const i of this.validatorIndices()){
214
216
  const v = this.ensureValidator(i);
@@ -223,9 +225,10 @@ export class NodeKeystoreAdapter {
223
225
  * Hydrates caches on-demand when the address is first seen.
224
226
  * @param address Address to sign with
225
227
  * @param typedData EIP-712 typed data
228
+ * @param _context Signing context (ignored by NodeKeystoreAdapter, used for HA protection)
226
229
  * @returns Signature from the signer matching the address
227
230
  * @throws Error when no signer exists for the address
228
- */ async signTypedDataWithAddress(address, typedData) {
231
+ */ async signTypedDataWithAddress(address, typedData, _context) {
229
232
  const entry = this.addressIndex.get(NodeKeystoreAdapter.key(address));
230
233
  if (entry) {
231
234
  return await this.keystoreManager.signTypedData(entry.signer, typedData);
@@ -245,9 +248,10 @@ export class NodeKeystoreAdapter {
245
248
  * Hydrates caches on-demand when the address is first seen.
246
249
  * @param address Address to sign with
247
250
  * @param message 32-byte message
251
+ * @param _context Signing context (ignored by NodeKeystoreAdapter, used for HA protection)
248
252
  * @returns Signature from the signer matching the address
249
253
  * @throws Error when no signer exists for the address
250
- */ async signMessageWithAddress(address, message) {
254
+ */ async signMessageWithAddress(address, message, _context) {
251
255
  const entry = this.addressIndex.get(NodeKeystoreAdapter.key(address));
252
256
  if (entry) {
253
257
  return await this.keystoreManager.signMessage(entry.signer, message);
@@ -313,4 +317,14 @@ export class NodeKeystoreAdapter {
313
317
  const validatorIndex = this.findValidatorIndexForAttester(attesterAddress);
314
318
  return this.keystoreManager.getEffectiveRemoteSignerConfig(validatorIndex, attesterAddress);
315
319
  }
320
+ /**
321
+ * Start the key store - no-op
322
+ */ start() {
323
+ return Promise.resolve();
324
+ }
325
+ /**
326
+ * Stop the key store - no-op
327
+ */ stop() {
328
+ return Promise.resolve();
329
+ }
316
330
  }
@@ -1,6 +1,7 @@
1
1
  import type { Buffer32 } from '@aztec/foundation/buffer';
2
2
  import { EthAddress } from '@aztec/foundation/eth-address';
3
3
  import { Signature } from '@aztec/foundation/eth-signature';
4
+ import type { SigningContext } from '@aztec/validator-ha-signer/types';
4
5
  import type { TypedDataDefinition } from 'viem';
5
6
  import type { ValidatorKeyStore } from './interface.js';
6
7
  /**
@@ -29,39 +30,37 @@ export declare class Web3SignerKeyStore implements ValidatorKeyStore {
29
30
  /**
30
31
  * Sign EIP-712 typed data with all keystore addresses
31
32
  * @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
33
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
32
34
  * @return signatures
33
35
  */
34
- signTypedData(typedData: TypedDataDefinition): Promise<Signature[]>;
36
+ signTypedData(typedData: TypedDataDefinition, _context: SigningContext): Promise<Signature[]>;
35
37
  /**
36
38
  * Sign EIP-712 typed data with a specific address
37
39
  * @param address - The address of the signer to use
38
40
  * @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
41
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
39
42
  * @returns signature for the specified address
40
43
  * @throws Error if the address is not found in the keystore or signing fails
41
44
  */
42
- signTypedDataWithAddress(address: EthAddress, typedData: TypedDataDefinition): Promise<Signature>;
45
+ signTypedDataWithAddress(address: EthAddress, typedData: TypedDataDefinition, _context: SigningContext): Promise<Signature>;
43
46
  /**
44
47
  * Sign a message with all keystore addresses using EIP-191 prefix
45
48
  *
46
49
  * @param message - The message to sign
50
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
47
51
  * @return signatures
48
52
  */
49
- signMessage(message: Buffer32): Promise<Signature[]>;
53
+ signMessage(message: Buffer32, _context: SigningContext): Promise<Signature[]>;
50
54
  /**
51
55
  * Sign a message with a specific address using EIP-191 prefix
52
56
  * @param address - The address of the signer to use
53
57
  * @param message - The message to sign
58
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
54
59
  * @returns signature for the specified address
55
60
  * @throws Error if the address is not found in the keystore or signing fails
56
61
  */
57
- signMessageWithAddress(address: EthAddress, message: Buffer32): Promise<Signature>;
58
- /**
59
- * Make a JSON-RPC sign request to Web3Signer using eth_sign
60
- * @param address - The Ethereum address to sign with
61
- * @param data - The data to sign
62
- * @returns The signature
63
- */
62
+ signMessageWithAddress(address: EthAddress, message: Buffer32, _context: SigningContext): Promise<Signature>;
64
63
  private makeJsonRpcSignRequest;
65
64
  private makeJsonRpcSignTypedDataRequest;
66
65
  }
67
- //# sourceMappingURL=web3signer_key_store.d.ts.map
66
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoid2ViM3NpZ25lcl9rZXlfc3RvcmUuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9rZXlfc3RvcmUvd2ViM3NpZ25lcl9rZXlfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsUUFBUSxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFFekQsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLCtCQUErQixDQUFDO0FBQzNELE9BQU8sRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUM1RCxPQUFPLEtBQUssRUFBRSxjQUFjLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUV2RSxPQUFPLEtBQUssRUFBRSxtQkFBbUIsRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUVoRCxPQUFPLEtBQUssRUFBRSxpQkFBaUIsRUFBRSxNQUFNLGdCQUFnQixDQUFDO0FBRXhEOzs7OztHQUtHO0FBQ0gscU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,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;;;GAKG;AACH,qBAAa,kBAAmB,YAAW,iBAAiB;IAExD,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,OAAO;IAFjB,YACU,SAAS,EAAE,UAAU,EAAE,EACvB,OAAO,EAAE,MAAM,EACrB;IAEJ;;;;;OAKG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAK3C;IAED;;;;OAIG;IACI,YAAY,IAAI,UAAU,EAAE,CAElC;IAED;;;;;OAKG;IACI,aAAa,CAAC,SAAS,EAAE,mBAAmB,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAEnG;IAED;;;;;;;OAOG;IACU,wBAAwB,CACnC,OAAO,EAAE,UAAU,EACnB,SAAS,EAAE,mBAAmB,EAC9B,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,CAMpB;IAED;;;;;;OAMG;IACI,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAEpF;IAED;;;;;;;OAOG;IACU,sBAAsB,CACjC,OAAO,EAAE,UAAU,EACnB,OAAO,EAAE,QAAQ,EACjB,QAAQ,EAAE,cAAc,GACvB,OAAO,CAAC,SAAS,CAAC,CAKpB;YAQa,sBAAsB;YAiDtB,+BAA+B;CA6C9C"}
@@ -1,3 +1,4 @@
1
+ import { normalizeSignature } from '@aztec/foundation/crypto/secp256k1-signer';
1
2
  import { Signature } from '@aztec/foundation/eth-signature';
2
3
  /**
3
4
  * Web3Signer Key Store
@@ -32,18 +33,19 @@ import { Signature } from '@aztec/foundation/eth-signature';
32
33
  /**
33
34
  * Sign EIP-712 typed data with all keystore addresses
34
35
  * @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
36
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
35
37
  * @return signatures
36
- */ async signTypedData(typedData) {
37
- const signatures = await Promise.all(this.addresses.map((address)=>this.makeJsonRpcSignTypedDataRequest(address, typedData)));
38
- return signatures;
38
+ */ signTypedData(typedData, _context) {
39
+ return Promise.all(this.addresses.map((address)=>this.makeJsonRpcSignTypedDataRequest(address, typedData)));
39
40
  }
40
41
  /**
41
42
  * Sign EIP-712 typed data with a specific address
42
43
  * @param address - The address of the signer to use
43
44
  * @param typedData - The complete EIP-712 typed data structure (domain, types, primaryType, message)
45
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
44
46
  * @returns signature for the specified address
45
47
  * @throws Error if the address is not found in the keystore or signing fails
46
- */ async signTypedDataWithAddress(address, typedData) {
48
+ */ async signTypedDataWithAddress(address, typedData, _context) {
47
49
  if (!this.addresses.some((addr)=>addr.equals(address))) {
48
50
  throw new Error(`Address ${address.toString()} not found in keystore`);
49
51
  }
@@ -53,18 +55,19 @@ import { Signature } from '@aztec/foundation/eth-signature';
53
55
  * Sign a message with all keystore addresses using EIP-191 prefix
54
56
  *
55
57
  * @param message - The message to sign
58
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
56
59
  * @return signatures
57
- */ async signMessage(message) {
58
- const signatures = await Promise.all(this.addresses.map((address)=>this.makeJsonRpcSignRequest(address, message)));
59
- return signatures;
60
+ */ signMessage(message, _context) {
61
+ return Promise.all(this.addresses.map((address)=>this.makeJsonRpcSignRequest(address, message)));
60
62
  }
61
63
  /**
62
64
  * Sign a message with a specific address using EIP-191 prefix
63
65
  * @param address - The address of the signer to use
64
66
  * @param message - The message to sign
67
+ * @param _context - Signing context (ignored by Web3SignerKeyStore, used for HA protection)
65
68
  * @returns signature for the specified address
66
69
  * @throws Error if the address is not found in the keystore or signing fails
67
- */ async signMessageWithAddress(address, message) {
70
+ */ async signMessageWithAddress(address, message, _context) {
68
71
  if (!this.addresses.some((addr)=>addr.equals(address))) {
69
72
  throw new Error(`Address ${address.toString()} not found in keystore`);
70
73
  }
@@ -112,7 +115,7 @@ import { Signature } from '@aztec/foundation/eth-signature';
112
115
  signatureHex = '0x' + signatureHex;
113
116
  }
114
117
  // Parse the signature from the hex string
115
- return Signature.fromString(signatureHex);
118
+ return normalizeSignature(Signature.fromString(signatureHex));
116
119
  }
117
120
  async makeJsonRpcSignTypedDataRequest(address, typedData) {
118
121
  const url = this.baseUrl;
@@ -148,6 +151,6 @@ import { Signature } from '@aztec/foundation/eth-signature';
148
151
  if (!signatureHex.startsWith('0x')) {
149
152
  signatureHex = '0x' + signatureHex;
150
153
  }
151
- return Signature.fromString(signatureHex);
154
+ return normalizeSignature(Signature.fromString(signatureHex));
152
155
  }
153
156
  }
package/dest/metrics.d.ts CHANGED
@@ -1,16 +1,19 @@
1
1
  import type { BlockProposal } from '@aztec/stdlib/p2p';
2
2
  import { type TelemetryClient } from '@aztec/telemetry-client';
3
+ import type { BlockProposalValidationFailureReason } from './block_proposal_handler.js';
3
4
  export declare class ValidatorMetrics {
4
5
  private failedReexecutionCounter;
5
- private attestationsCount;
6
- private failedAttestationsCount;
6
+ private successfulAttestationsCount;
7
+ private failedAttestationsBadProposalCount;
8
+ private failedAttestationsNodeIssueCount;
7
9
  private reexMana;
8
10
  private reexTx;
9
11
  private reexDuration;
10
12
  constructor(telemetryClient: TelemetryClient);
11
13
  recordReex(time: number, txs: number, mManaTotal: number): void;
12
14
  recordFailedReexecution(proposal: BlockProposal): void;
13
- incAttestations(num: number): void;
14
- incFailedAttestations(num: number, reason: string, inCommittee: boolean): void;
15
+ incSuccessfulAttestations(num: number): void;
16
+ incFailedAttestationsBadProposal(num: number, reason: BlockProposalValidationFailureReason, inCommittee: boolean): void;
17
+ incFailedAttestationsNodeIssue(num: number, reason: BlockProposalValidationFailureReason, inCommittee: boolean): void;
15
18
  }
16
- //# sourceMappingURL=metrics.d.ts.map
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWV0cmljcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21ldHJpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsYUFBYSxFQUFFLE1BQU0sbUJBQW1CLENBQUM7QUFDdkQsT0FBTyxFQUtMLEtBQUssZUFBZSxFQUdyQixNQUFNLHlCQUF5QixDQUFDO0FBRWpDLE9BQU8sS0FBSyxFQUFFLG9DQUFvQyxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFFeEYscUJBQWEsZ0JBQWdCO0lBQzNCLE9BQU8sQ0FBQyx3QkFBd0IsQ0FBZ0I7SUFDaEQsT0FBTyxDQUFDLDJCQUEyQixDQUFnQjtJQUNuRCxPQUFPLENBQUMsa0NBQWtDLENBQWdCO0lBQzFELE9BQU8sQ0FBQyxnQ0FBZ0MsQ0FBZ0I7SUFFeEQsT0FBTyxDQUFDLFFBQVEsQ0FBWTtJQUM1QixPQUFPLENBQUMsTUFBTSxDQUFZO0lBQzFCLE9BQU8sQ0FBQyxZQUFZLENBQVE7SUFFNUIsWUFBWSxlQUFlLEVBQUUsZUFBZSxFQWdEM0M7SUFFTSxVQUFVLENBQUMsSUFBSSxFQUFFLE1BQU0sRUFBRSxHQUFHLEVBQUUsTUFBTSxFQUFFLFVBQVUsRUFBRSxNQUFNLFFBSTlEO0lBRU0sdUJBQXVCLENBQUMsUUFBUSxFQUFFLGFBQWEsUUFNckQ7SUFFTSx5QkFBeUIsQ0FBQyxHQUFHLEVBQUUsTUFBTSxRQUUzQztJQUVNLGdDQUFnQyxDQUNyQyxHQUFHLEVBQUUsTUFBTSxFQUNYLE1BQU0sRUFBRSxvQ0FBb0MsRUFDNUMsV0FBVyxFQUFFLE9BQU8sUUFNckI7SUFFTSw4QkFBOEIsQ0FDbkMsR0FBRyxFQUFFLE1BQU0sRUFDWCxNQUFNLEVBQUUsb0NBQW9DLEVBQzVDLFdBQVcsRUFBRSxPQUFPLFFBTXJCO0NBQ0YifQ==
@@ -1 +1 @@
1
- {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAIL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,wBAAwB,CAAgB;IAChD,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,uBAAuB,CAAgB;IAE/C,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,YAAY,CAAY;gBAEpB,eAAe,EAAE,eAAe;IAsCrC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAMxD,uBAAuB,CAAC,QAAQ,EAAE,aAAa;IAQ/C,eAAe,CAAC,GAAG,EAAE,MAAM;IAI3B,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO;CAM/E"}
1
+ {"version":3,"file":"metrics.d.ts","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAKL,KAAK,eAAe,EAGrB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAC;AAExF,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,wBAAwB,CAAgB;IAChD,OAAO,CAAC,2BAA2B,CAAgB;IACnD,OAAO,CAAC,kCAAkC,CAAgB;IAC1D,OAAO,CAAC,gCAAgC,CAAgB;IAExD,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,YAAY,CAAQ;IAE5B,YAAY,eAAe,EAAE,eAAe,EAgD3C;IAEM,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,QAI9D;IAEM,uBAAuB,CAAC,QAAQ,EAAE,aAAa,QAMrD;IAEM,yBAAyB,CAAC,GAAG,EAAE,MAAM,QAE3C;IAEM,gCAAgC,CACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,oCAAoC,EAC5C,WAAW,EAAE,OAAO,QAMrB;IAEM,8BAA8B,CACnC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,oCAAoC,EAC5C,WAAW,EAAE,OAAO,QAMrB;CACF"}
package/dest/metrics.js CHANGED
@@ -1,41 +1,50 @@
1
- import { Attributes, Metrics, ValueType } from '@aztec/telemetry-client';
1
+ import { Attributes, Metrics, createUpDownCounterWithDefault } from '@aztec/telemetry-client';
2
2
  export class ValidatorMetrics {
3
3
  failedReexecutionCounter;
4
- attestationsCount;
5
- failedAttestationsCount;
4
+ successfulAttestationsCount;
5
+ failedAttestationsBadProposalCount;
6
+ failedAttestationsNodeIssueCount;
6
7
  reexMana;
7
8
  reexTx;
8
9
  reexDuration;
9
10
  constructor(telemetryClient){
10
11
  const meter = telemetryClient.getMeter('Validator');
11
- this.failedReexecutionCounter = meter.createUpDownCounter(Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
12
- description: 'The number of failed re-executions',
13
- unit: 'count',
14
- valueType: ValueType.INT
12
+ this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
13
+ [Attributes.STATUS]: [
14
+ 'failed'
15
+ ]
15
16
  });
16
- this.attestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_ATTESTATION_COUNT, {
17
- description: 'The number of attestations',
18
- valueType: ValueType.INT
17
+ this.successfulAttestationsCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT);
18
+ this.failedAttestationsBadProposalCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT, {
19
+ [Attributes.ERROR_TYPE]: [
20
+ 'invalid_proposal',
21
+ 'state_mismatch',
22
+ 'failed_txs',
23
+ 'in_hash_mismatch',
24
+ 'parent_block_wrong_slot'
25
+ ],
26
+ [Attributes.IS_COMMITTEE_MEMBER]: [
27
+ true,
28
+ false
29
+ ]
19
30
  });
20
- this.failedAttestationsCount = meter.createUpDownCounter(Metrics.VALIDATOR_FAILED_ATTESTATION_COUNT, {
21
- description: 'The number of failed attestations',
22
- valueType: ValueType.INT
23
- });
24
- this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA, {
25
- description: 'The mana consumed by blocks',
26
- valueType: ValueType.DOUBLE,
27
- unit: 'Mmana'
28
- });
29
- this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT, {
30
- description: 'The number of txs in a block proposal',
31
- valueType: ValueType.INT,
32
- unit: 'tx'
33
- });
34
- this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME, {
35
- description: 'The time taken to re-execute a transaction',
36
- unit: 'ms',
37
- valueType: ValueType.INT
31
+ this.failedAttestationsNodeIssueCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT, {
32
+ [Attributes.ERROR_TYPE]: [
33
+ 'parent_block_not_found',
34
+ 'global_variables_mismatch',
35
+ 'block_number_already_exists',
36
+ 'txs_not_available',
37
+ 'timeout',
38
+ 'unknown_error'
39
+ ],
40
+ [Attributes.IS_COMMITTEE_MEMBER]: [
41
+ true,
42
+ false
43
+ ]
38
44
  });
45
+ this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
46
+ this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
47
+ this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME);
39
48
  }
40
49
  recordReex(time, txs, mManaTotal) {
41
50
  this.reexDuration.record(Math.ceil(time));
@@ -49,13 +58,19 @@ export class ValidatorMetrics {
49
58
  [Attributes.BLOCK_PROPOSER]: proposer?.toString() ?? 'unknown'
50
59
  });
51
60
  }
52
- incAttestations(num) {
53
- this.attestationsCount.add(num);
61
+ incSuccessfulAttestations(num) {
62
+ this.successfulAttestationsCount.add(num);
63
+ }
64
+ incFailedAttestationsBadProposal(num, reason, inCommittee) {
65
+ this.failedAttestationsBadProposalCount.add(num, {
66
+ [Attributes.ERROR_TYPE]: reason,
67
+ [Attributes.IS_COMMITTEE_MEMBER]: inCommittee
68
+ });
54
69
  }
55
- incFailedAttestations(num, reason, inCommittee) {
56
- this.failedAttestationsCount.add(num, {
70
+ incFailedAttestationsNodeIssue(num, reason, inCommittee) {
71
+ this.failedAttestationsNodeIssueCount.add(num, {
57
72
  [Attributes.ERROR_TYPE]: reason,
58
- [Attributes.VALIDATOR_STATUS]: inCommittee ? 'in-committee' : 'none'
73
+ [Attributes.IS_COMMITTEE_MEMBER]: inCommittee
59
74
  });
60
75
  }
61
76
  }
@@ -0,0 +1,3 @@
1
+ export * from './nullifier_cache.js';
2
+ export * from './tx_validator_factory.js';
3
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eF92YWxpZGF0b3IvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxzQkFBc0IsQ0FBQztBQUNyQyxjQUFjLDJCQUEyQixDQUFDIn0=
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tx_validator/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './nullifier_cache.js';
2
+ export * from './tx_validator_factory.js';
@@ -0,0 +1,14 @@
1
+ import type { NullifierSource } from '@aztec/p2p';
2
+ import type { MerkleTreeReadOperations } from '@aztec/stdlib/interfaces/server';
3
+ /**
4
+ * Implements a nullifier source by checking a DB and an in-memory collection.
5
+ * Intended for validating transactions as they are added to a block.
6
+ */
7
+ export declare class NullifierCache implements NullifierSource {
8
+ private db;
9
+ nullifiers: Set<string>;
10
+ constructor(db: MerkleTreeReadOperations);
11
+ nullifiersExist(nullifiers: Buffer[]): Promise<boolean[]>;
12
+ addNullifiers(nullifiers: Buffer[]): void;
13
+ }
14
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibnVsbGlmaWVyX2NhY2hlLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHhfdmFsaWRhdG9yL251bGxpZmllcl9jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxlQUFlLEVBQUUsTUFBTSxZQUFZLENBQUM7QUFDbEQsT0FBTyxLQUFLLEVBQUUsd0JBQXdCLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUdoRjs7O0dBR0c7QUFDSCxxQkFBYSxjQUFlLFlBQVcsZUFBZTtJQUd4QyxPQUFPLENBQUMsRUFBRTtJQUZ0QixVQUFVLEVBQUUsR0FBRyxDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBRXhCLFlBQW9CLEVBQUUsRUFBRSx3QkFBd0IsRUFFL0M7SUFFWSxlQUFlLENBQUMsVUFBVSxFQUFFLE1BQU0sRUFBRSxHQUFHLE9BQU8sQ0FBQyxPQUFPLEVBQUUsQ0FBQyxDQU9yRTtJQUVNLGFBQWEsQ0FBQyxVQUFVLEVBQUUsTUFBTSxFQUFFLFFBSXhDO0NBQ0YifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nullifier_cache.d.ts","sourceRoot":"","sources":["../../src/tx_validator/nullifier_cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAGhF;;;GAGG;AACH,qBAAa,cAAe,YAAW,eAAe;IAGxC,OAAO,CAAC,EAAE;IAFtB,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAExB,YAAoB,EAAE,EAAE,wBAAwB,EAE/C;IAEY,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAOrE;IAEM,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,QAIxC;CACF"}
@@ -0,0 +1,24 @@
1
+ import { MerkleTreeId } from '@aztec/stdlib/trees';
2
+ /**
3
+ * Implements a nullifier source by checking a DB and an in-memory collection.
4
+ * Intended for validating transactions as they are added to a block.
5
+ */ export class NullifierCache {
6
+ db;
7
+ nullifiers;
8
+ constructor(db){
9
+ this.db = db;
10
+ this.nullifiers = new Set();
11
+ }
12
+ async nullifiersExist(nullifiers) {
13
+ const cacheResults = nullifiers.map((n)=>this.nullifiers.has(n.toString()));
14
+ const toCheckDb = nullifiers.filter((_n, index)=>!cacheResults[index]);
15
+ const dbHits = await this.db.findLeafIndices(MerkleTreeId.NULLIFIER_TREE, toCheckDb);
16
+ let dbIndex = 0;
17
+ return nullifiers.map((_n, index)=>cacheResults[index] || dbHits[dbIndex++] !== undefined);
18
+ }
19
+ addNullifiers(nullifiers) {
20
+ for (const nullifier of nullifiers){
21
+ this.nullifiers.add(nullifier.toString());
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,19 @@
1
+ import { BlockNumber } from '@aztec/foundation/branded-types';
2
+ import type { LoggerBindings } from '@aztec/foundation/log';
3
+ import type { ContractDataSource } from '@aztec/stdlib/contract';
4
+ import type { GasFees } from '@aztec/stdlib/gas';
5
+ import type { AllowedElement, ClientProtocolCircuitVerifier, MerkleTreeReadOperations, PublicProcessorValidator } from '@aztec/stdlib/interfaces/server';
6
+ import { GlobalVariables, type Tx, type TxValidator } from '@aztec/stdlib/tx';
7
+ import type { UInt64 } from '@aztec/stdlib/types';
8
+ export declare function createValidatorForAcceptingTxs(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, verifier: ClientProtocolCircuitVerifier | undefined, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted }: {
9
+ l1ChainId: number;
10
+ rollupVersion: number;
11
+ setupAllowList: AllowedElement[];
12
+ gasFees: GasFees;
13
+ skipFeeEnforcement?: boolean;
14
+ timestamp: UInt64;
15
+ blockNumber: BlockNumber;
16
+ txsPermitted: boolean;
17
+ }, bindings?: LoggerBindings): TxValidator<Tx>;
18
+ export declare function createValidatorForBlockBuilding(db: MerkleTreeReadOperations, contractDataSource: ContractDataSource, globalVariables: GlobalVariables, setupAllowList: AllowedElement[], bindings?: LoggerBindings): PublicProcessorValidator;
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHhfdmFsaWRhdG9yX2ZhY3RvcnkuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90eF92YWxpZGF0b3IvdHhfdmFsaWRhdG9yX2ZhY3RvcnkudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxNQUFNLGlDQUFpQyxDQUFDO0FBRTlELE9BQU8sS0FBSyxFQUFFLGNBQWMsRUFBRSxNQUFNLHVCQUF1QixDQUF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MsRUFBRSxDQUFDLENBcUNqQjtBQUVELHdCQUFnQiwrQkFBK0IsQ0FDN0MsRUFBRSxFQUFFLHdCQUF3QixFQUM1QixrQkFBa0IsRUFBRSxrQkFBa0IsRUFDdEMsZUFBZSxFQUFFLGVBQWUsRUFDaEMsY0FBYyxFQUFFLGNBQWMsRUFBRSxFQUNoQyxRQUFRLENBQUMsRUFBRSxjQUFjLEdBQ3hCLHdCQUF3QixDQWlCMUIifQ==
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tx_validator_factory.d.ts","sourceRoot":"","sources":["../../src/tx_validator/tx_validator_factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAiB5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EACV,cAAc,EACd,6BAA6B,EAC7B,wBAAwB,EACxB,wBAAwB,EACzB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,KAAK,EAAE,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAIlD,wBAAgB,8BAA8B,CAC5C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,QAAQ,EAAE,6BAA6B,GAAG,SAAS,EACnD,EACE,SAAS,EACT,aAAa,EACb,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,YAAY,EACb,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,cAAc,EAAE,CAAC;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,OAAO,CAAC;CACvB,EACD,QAAQ,CAAC,EAAE,cAAc,GACxB,WAAW,CAAC,EAAE,CAAC,CAqCjB;AAED,wBAAgB,+BAA+B,CAC7C,EAAE,EAAE,wBAAwB,EAC5B,kBAAkB,EAAE,kBAAkB,EACtC,eAAe,EAAE,eAAe,EAChC,cAAc,EAAE,cAAc,EAAE,EAChC,QAAQ,CAAC,EAAE,cAAc,GACxB,wBAAwB,CAiB1B"}
@@ -0,0 +1,54 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
3
+ import { AggregateTxValidator, ArchiveCache, BlockHeaderTxValidator, DataTxValidator, DoubleSpendTxValidator, GasTxValidator, MetadataTxValidator, PhasesTxValidator, SizeTxValidator, TimestampTxValidator, TxPermittedValidator, TxProofValidator } from '@aztec/p2p';
4
+ import { ProtocolContractAddress, protocolContractsHash } from '@aztec/protocol-contracts';
5
+ import { DatabasePublicStateSource } from '@aztec/stdlib/trees';
6
+ import { NullifierCache } from './nullifier_cache.js';
7
+ export function createValidatorForAcceptingTxs(db, contractDataSource, verifier, { l1ChainId, rollupVersion, setupAllowList, gasFees, skipFeeEnforcement, timestamp, blockNumber, txsPermitted }, bindings) {
8
+ const validators = [
9
+ new TxPermittedValidator(txsPermitted, bindings),
10
+ new SizeTxValidator(bindings),
11
+ new DataTxValidator(bindings),
12
+ new MetadataTxValidator({
13
+ l1ChainId: new Fr(l1ChainId),
14
+ rollupVersion: new Fr(rollupVersion),
15
+ protocolContractsHash,
16
+ vkTreeRoot: getVKTreeRoot()
17
+ }, bindings),
18
+ new TimestampTxValidator({
19
+ timestamp,
20
+ blockNumber
21
+ }, bindings),
22
+ new DoubleSpendTxValidator(new NullifierCache(db), bindings),
23
+ new PhasesTxValidator(contractDataSource, setupAllowList, timestamp, bindings),
24
+ new BlockHeaderTxValidator(new ArchiveCache(db), bindings)
25
+ ];
26
+ if (!skipFeeEnforcement) {
27
+ validators.push(new GasTxValidator(new DatabasePublicStateSource(db), ProtocolContractAddress.FeeJuice, gasFees, bindings));
28
+ }
29
+ if (verifier) {
30
+ validators.push(new TxProofValidator(verifier, bindings));
31
+ }
32
+ return new AggregateTxValidator(...validators);
33
+ }
34
+ export function createValidatorForBlockBuilding(db, contractDataSource, globalVariables, setupAllowList, bindings) {
35
+ const nullifierCache = new NullifierCache(db);
36
+ const archiveCache = new ArchiveCache(db);
37
+ const publicStateSource = new DatabasePublicStateSource(db);
38
+ return {
39
+ preprocessValidator: preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList, bindings),
40
+ nullifierCache
41
+ };
42
+ }
43
+ function preprocessValidator(nullifierCache, archiveCache, publicStateSource, contractDataSource, globalVariables, setupAllowList, bindings) {
44
+ // We don't include the TxProofValidator nor the DataTxValidator here because they are already checked by the time we get to block building.
45
+ return new AggregateTxValidator(new MetadataTxValidator({
46
+ l1ChainId: globalVariables.chainId,
47
+ rollupVersion: globalVariables.version,
48
+ protocolContractsHash,
49
+ vkTreeRoot: getVKTreeRoot()
50
+ }, bindings), new TimestampTxValidator({
51
+ timestamp: globalVariables.timestamp,
52
+ blockNumber: globalVariables.blockNumber
53
+ }, bindings), new DoubleSpendTxValidator(nullifierCache, bindings), new PhasesTxValidator(contractDataSource, setupAllowList, globalVariables.timestamp, bindings), new GasTxValidator(publicStateSource, ProtocolContractAddress.FeeJuice, globalVariables.gasFees, bindings), new BlockHeaderTxValidator(archiveCache, bindings));
54
+ }