@aztec/prover-node 0.85.0 → 0.86.0

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 (41) hide show
  1. package/dest/config.d.ts +2 -2
  2. package/dest/config.d.ts.map +1 -1
  3. package/dest/config.js +8 -8
  4. package/dest/factory.d.ts +3 -2
  5. package/dest/factory.d.ts.map +1 -1
  6. package/dest/factory.js +9 -9
  7. package/dest/job/epoch-proving-job.d.ts +2 -2
  8. package/dest/job/epoch-proving-job.d.ts.map +1 -1
  9. package/dest/job/epoch-proving-job.js +1 -1
  10. package/dest/metrics.d.ts +27 -4
  11. package/dest/metrics.d.ts.map +1 -1
  12. package/dest/metrics.js +104 -36
  13. package/dest/monitors/epoch-monitor.d.ts +1 -1
  14. package/dest/monitors/epoch-monitor.d.ts.map +1 -1
  15. package/dest/monitors/epoch-monitor.js +7 -2
  16. package/dest/prover-coordination/combined-prover-coordination.d.ts +22 -0
  17. package/dest/prover-coordination/combined-prover-coordination.d.ts.map +1 -0
  18. package/dest/prover-coordination/combined-prover-coordination.js +136 -0
  19. package/dest/prover-coordination/config.d.ts +1 -1
  20. package/dest/prover-coordination/config.d.ts.map +1 -1
  21. package/dest/prover-coordination/config.js +4 -4
  22. package/dest/prover-coordination/factory.d.ts +5 -4
  23. package/dest/prover-coordination/factory.d.ts.map +1 -1
  24. package/dest/prover-coordination/factory.js +20 -14
  25. package/dest/prover-node-publisher.d.ts +1 -2
  26. package/dest/prover-node-publisher.d.ts.map +1 -1
  27. package/dest/prover-node-publisher.js +7 -13
  28. package/dest/prover-node.d.ts +8 -10
  29. package/dest/prover-node.d.ts.map +1 -1
  30. package/dest/prover-node.js +21 -17
  31. package/package.json +20 -22
  32. package/src/config.ts +10 -10
  33. package/src/factory.ts +10 -10
  34. package/src/job/epoch-proving-job.ts +3 -3
  35. package/src/metrics.ts +111 -38
  36. package/src/monitors/epoch-monitor.ts +5 -3
  37. package/src/prover-coordination/combined-prover-coordination.ts +160 -0
  38. package/src/prover-coordination/config.ts +5 -5
  39. package/src/prover-coordination/factory.ts +36 -25
  40. package/src/prover-node-publisher.ts +9 -18
  41. package/src/prover-node.ts +35 -25
@@ -0,0 +1,136 @@
1
+ import { asyncPool } from '@aztec/foundation/async-pool';
2
+ import { createLogger } from '@aztec/foundation/log';
3
+ import { TxHash } from '@aztec/stdlib/tx';
4
+ // Wraps the p2p client into a coordination pool
5
+ class P2PCoordinationPool {
6
+ p2p;
7
+ constructor(p2p){
8
+ this.p2p = p2p;
9
+ }
10
+ getTxsByHash(txHashes) {
11
+ return this.p2p.getTxsByHash(txHashes);
12
+ }
13
+ hasTxsInPool(txHashes) {
14
+ return this.p2p.hasTxsInPool(txHashes);
15
+ }
16
+ getTxsByHashFromPool(txHashes) {
17
+ return this.p2p.getTxsByHashFromPool(txHashes);
18
+ }
19
+ addTxs(txs) {
20
+ return this.p2p.addTxs(txs);
21
+ }
22
+ }
23
+ // Wraps an in memory tx pool into a coordination pool. Used for testing when no p2p/tx pool is available.
24
+ class InMemoryCoordinationPool {
25
+ txs = new Map();
26
+ getTxsByHash(txHashes) {
27
+ return Promise.resolve(txHashes.map((hash)=>this.txs.get(hash.toString())));
28
+ }
29
+ hasTxsInPool(txHashes) {
30
+ return Promise.resolve(txHashes.map((hash)=>this.txs.has(hash.toString())));
31
+ }
32
+ getTxsByHashFromPool(txHashes) {
33
+ return this.getTxsByHash(txHashes);
34
+ }
35
+ async addTxs(txs) {
36
+ const hashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
37
+ txs.forEach((tx, index)=>this.txs.set(hashes[index].toString(), tx));
38
+ }
39
+ }
40
+ // Class to implement combined transaction retrieval from p2p and any available nodes
41
+ export class CombinedProverCoordination {
42
+ p2p;
43
+ aztecNodes;
44
+ options;
45
+ log;
46
+ constructor(p2p, aztecNodes, options = {
47
+ txGatheringBatchSize: 10,
48
+ txGatheringMaxParallelRequestsPerNode: 10
49
+ }, log = createLogger('prover-node:combined-prover-coordination')){
50
+ this.p2p = p2p;
51
+ this.aztecNodes = aztecNodes;
52
+ this.options = options;
53
+ this.log = log;
54
+ }
55
+ getP2PClient() {
56
+ return this.p2p;
57
+ }
58
+ async getTxsByHash(txHashes) {
59
+ const pool = this.p2p ? new P2PCoordinationPool(this.p2p) : new InMemoryCoordinationPool();
60
+ await this.#gatherTxs(txHashes, pool);
61
+ const availability = await pool.hasTxsInPool(txHashes);
62
+ const notFound = txHashes.filter((_, index)=>!availability[index]);
63
+ if (notFound.length > 0) {
64
+ throw new Error(`Could not find txs: ${notFound.map((tx)=>tx.toString())}`);
65
+ }
66
+ const txs = await pool.getTxsByHashFromPool(txHashes);
67
+ return txs.filter((tx)=>tx !== undefined);
68
+ }
69
+ async gatherTxs(txHashes) {
70
+ const pool = this.p2p ? new P2PCoordinationPool(this.p2p) : new InMemoryCoordinationPool();
71
+ await this.#gatherTxs(txHashes, pool);
72
+ }
73
+ async #gatherTxs(txHashes, pool) {
74
+ const availability = await pool.hasTxsInPool(txHashes);
75
+ const notFound = txHashes.filter((_, index)=>!availability[index]);
76
+ const txsToFind = new Set(notFound.map((tx)=>tx.toString()));
77
+ if (txsToFind.size === 0) {
78
+ this.log.info(`Check for ${txHashes.length} txs found all in the pool}`);
79
+ return;
80
+ }
81
+ this.log.info(`Check for ${txHashes.length} txs found ${txsToFind.size} missing. Will gather from nodes and p2p`);
82
+ const originalToFind = txsToFind.size;
83
+ await this.#gatherTxsFromAllNodes(txsToFind, pool);
84
+ if (txsToFind.size === 0) {
85
+ this.log.info(`Found all ${originalToFind} txs directly from nodes`);
86
+ return;
87
+ }
88
+ const toFindFromP2P = txsToFind.size;
89
+ this.log.verbose(`Gathering ${toFindFromP2P} txs from p2p network`);
90
+ const foundFromP2P = await pool.getTxsByHash([
91
+ ...txsToFind
92
+ ].map((tx)=>TxHash.fromString(tx)));
93
+ const numFoundFromNodes = originalToFind - toFindFromP2P;
94
+ const numNotFound = toFindFromP2P - foundFromP2P.length;
95
+ if (numNotFound === 0) {
96
+ this.log.info(`Found all ${originalToFind} txs. ${numFoundFromNodes} from nodes, ${foundFromP2P.length} from p2p`);
97
+ return;
98
+ }
99
+ this.log.warn(`Failed to find ${numNotFound} txs from any source. Found ${foundFromP2P.length} from p2p and ${numFoundFromNodes} from nodes`);
100
+ }
101
+ async #gatherTxsFromAllNodes(txsToFind, pool) {
102
+ if (txsToFind.size === 0 || this.aztecNodes.length === 0) {
103
+ return;
104
+ }
105
+ await Promise.all(this.aztecNodes.map((aztecNode)=>this.#gatherTxsFromNode(txsToFind, aztecNode, pool)));
106
+ }
107
+ async #gatherTxsFromNode(txsToFind, aztecNode, pool) {
108
+ const totalTxsRequired = txsToFind.size;
109
+ // It's possible that the set is empty as we already found the txs
110
+ if (totalTxsRequired === 0) {
111
+ return;
112
+ }
113
+ let totalTxsGathered = 0;
114
+ const batches = [];
115
+ const allTxs = [
116
+ ...txsToFind
117
+ ];
118
+ while(allTxs.length){
119
+ const batch = allTxs.splice(0, this.options.txGatheringBatchSize);
120
+ batches.push(batch);
121
+ }
122
+ await asyncPool(this.options.txGatheringMaxParallelRequestsPerNode, batches, async (batch)=>{
123
+ try {
124
+ const txs = (await aztecNode.getTxsByHash(batch.map((b)=>TxHash.fromString(b)))).filter((tx)=>!!tx);
125
+ const hashes = await Promise.all(txs.map((tx)=>tx.getTxHash()));
126
+ await pool.addTxs(txs);
127
+ hashes.forEach((hash)=>txsToFind.delete(hash.toString()));
128
+ totalTxsGathered += txs.length;
129
+ } catch (err) {
130
+ this.log.error(`Error gathering txs from aztec node: ${err}`);
131
+ return;
132
+ }
133
+ });
134
+ this.log.verbose(`Gathered ${totalTxsGathered} of ${totalTxsRequired} txs from a node`);
135
+ }
136
+ }
@@ -1,6 +1,6 @@
1
1
  import { type ConfigMappingsType } from '@aztec/foundation/config';
2
2
  export type ProverCoordinationConfig = {
3
- proverCoordinationNodeUrl: string | undefined;
3
+ proverCoordinationNodeUrls: string[];
4
4
  };
5
5
  export declare const proverCoordinationConfigMappings: ConfigMappingsType<ProverCoordinationConfig>;
6
6
  export declare function getTxProviderConfigFromEnv(): ProverCoordinationConfig;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/prover-coordination/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAE1F,MAAM,MAAM,wBAAwB,GAAG;IACrC,yBAAyB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC/C,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,kBAAkB,CAAC,wBAAwB,CAMzF,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,wBAAwB,CAErE"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/prover-coordination/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,0BAA0B,CAAC;AAE1F,MAAM,MAAM,wBAAwB,GAAG;IACrC,0BAA0B,EAAE,MAAM,EAAE,CAAC;CACtC,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE,kBAAkB,CAAC,wBAAwB,CAMzF,CAAC;AAEF,wBAAgB,0BAA0B,IAAI,wBAAwB,CAErE"}
@@ -1,9 +1,9 @@
1
1
  import { getConfigFromMappings } from '@aztec/foundation/config';
2
2
  export const proverCoordinationConfigMappings = {
3
- proverCoordinationNodeUrl: {
4
- env: 'PROVER_COORDINATION_NODE_URL',
5
- description: 'The URL of the tx provider node',
6
- parseEnv: (val)=>val
3
+ proverCoordinationNodeUrls: {
4
+ env: 'PROVER_COORDINATION_NODE_URLS',
5
+ description: 'The URLs of the tx provider nodes',
6
+ parseEnv: (val)=>val.split(',').map((url)=>url.trim().replace(/\/$/, ''))
7
7
  }
8
8
  };
9
9
  export function getTxProviderConfigFromEnv() {
@@ -4,12 +4,13 @@ import type { DataStoreConfig } from '@aztec/kv-store/config';
4
4
  import type { ProverCoordination, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
5
5
  import { type TelemetryClient } from '@aztec/telemetry-client';
6
6
  import type { ProverNodeConfig } from '../config.js';
7
+ import { type TxSource } from './combined-prover-coordination.js';
7
8
  type ProverCoordinationDeps = {
8
- aztecNodeTxProvider?: ProverCoordination;
9
- worldStateSynchronizer?: WorldStateSynchronizer;
10
- archiver?: Archiver | ArchiveSource;
9
+ aztecNodeTxProvider?: TxSource;
10
+ worldStateSynchronizer: WorldStateSynchronizer;
11
+ archiver: Archiver | ArchiveSource;
11
12
  telemetry?: TelemetryClient;
12
- epochCache?: EpochCache;
13
+ epochCache: EpochCache;
13
14
  };
14
15
  /**
15
16
  * Creates a prover coordination service.
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/prover-coordination/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAGlG,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,KAAK,sBAAsB,GAAG;IAC5B,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;IAChD,QAAQ,CAAC,EAAE,QAAQ,GAAG,aAAa,CAAC;IACpC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,gBAAgB,GAAG,eAAe,EAC1C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAqC7B"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/prover-coordination/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAK9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAGlG,OAAO,EAAE,KAAK,eAAe,EAAmB,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAGL,KAAK,QAAQ,EACd,MAAM,mCAAmC,CAAC;AAG3C,KAAK,sBAAsB,GAAG;IAC5B,mBAAmB,CAAC,EAAE,QAAQ,CAAC;IAC/B,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,QAAQ,EAAE,QAAQ,GAAG,aAAa,CAAC;IACnC,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,UAAU,EAAE,UAAU,CAAC;CACxB,CAAC;AAEF;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,gBAAgB,GAAG,eAAe,EAC1C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CA2C7B"}
@@ -7,6 +7,7 @@ import { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
7
7
  import { P2PClientType } from '@aztec/stdlib/p2p';
8
8
  import { getComponentsVersionsFromConfig } from '@aztec/stdlib/versioning';
9
9
  import { makeTracedFetch } from '@aztec/telemetry-client';
10
+ import { CombinedProverCoordination } from './combined-prover-coordination.js';
10
11
  /**
11
12
  * Creates a prover coordination service.
12
13
  * If p2p is enabled, prover coordination is done via p2p.
@@ -14,29 +15,34 @@ import { makeTracedFetch } from '@aztec/telemetry-client';
14
15
  * If an aztec node is provided, it is returned directly.
15
16
  */ export async function createProverCoordination(config, deps) {
16
17
  const log = createLogger('prover-node:prover-coordination');
18
+ const coordinationConfig = {
19
+ txGatheringBatchSize: config.txGatheringBatchSize ?? 10,
20
+ txGatheringMaxParallelRequestsPerNode: config.txGatheringMaxParallelRequestsPerNode ?? 10
21
+ };
17
22
  if (deps.aztecNodeTxProvider) {
18
23
  log.info('Using prover coordination via aztec node');
19
- return deps.aztecNodeTxProvider;
24
+ return new CombinedProverCoordination(undefined, [
25
+ deps.aztecNodeTxProvider
26
+ ], coordinationConfig);
20
27
  }
21
28
  if (config.p2pEnabled) {
22
29
  log.info('Using prover coordination via p2p');
23
30
  if (!deps.archiver || !deps.worldStateSynchronizer || !deps.telemetry || !deps.epochCache) {
24
31
  throw new Error('Missing dependencies for p2p prover coordination');
25
32
  }
26
- const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
27
- const p2pClient = await createP2PClient(P2PClientType.Prover, config, deps.archiver, proofVerifier, deps.worldStateSynchronizer, deps.epochCache, deps.telemetry);
28
- await p2pClient.start();
29
- return p2pClient;
30
33
  }
31
- if (config.proverCoordinationNodeUrl) {
32
- log.info('Using prover coordination via node url');
34
+ let nodes = [];
35
+ if (config.proverCoordinationNodeUrls.length > 0) {
36
+ log.info('Using prover coordination via node urls');
33
37
  const versions = getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot());
34
- return createAztecNodeClient(config.proverCoordinationNodeUrl, versions, makeTracedFetch([
35
- 1,
36
- 2,
37
- 3
38
- ], false));
39
- } else {
40
- throw new Error(`Aztec Node URL for Tx Provider is not set.`);
38
+ nodes = config.proverCoordinationNodeUrls.map((url)=>createAztecNodeClient(url, versions, makeTracedFetch([
39
+ 1,
40
+ 2,
41
+ 3
42
+ ], false)));
41
43
  }
44
+ const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
45
+ const p2pClient = await createP2PClient(P2PClientType.Prover, config, deps.archiver, proofVerifier, deps.worldStateSynchronizer, deps.epochCache, deps.telemetry);
46
+ await p2pClient.start();
47
+ return new CombinedProverCoordination(p2pClient, nodes, coordinationConfig);
42
48
  }
@@ -15,8 +15,6 @@ export type L1SubmitEpochProofArgs = {
15
15
  epochSize: number;
16
16
  previousArchive: Fr;
17
17
  endArchive: Fr;
18
- previousBlockHash: Fr;
19
- endBlockHash: Fr;
20
18
  endTimestamp: Fr;
21
19
  outHash: Fr;
22
20
  proverId: Fr;
@@ -36,6 +34,7 @@ export declare class ProverNodePublisher {
36
34
  l1TxUtils: L1TxUtils;
37
35
  telemetry?: TelemetryClient;
38
36
  });
37
+ getRollupContract(): RollupContract;
39
38
  /**
40
39
  * Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
41
40
  * Be warned, the call may return false even if the tx subsequently gets successfully mined.
@@ -1 +1 @@
1
- {"version":3,"file":"prover-node-publisher.d.ts","sourceRoot":"","sources":["../src/prover-node-publisher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIzD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAE,KAAK,eAAe,EAAsB,MAAM,yBAAyB,CAAC;AAMnF;;GAEG;A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Ac,GAAG,eAAe,EACxC,IAAI,EAAE;QACJ,cAAc,EAAE,cAAc,CAAC;QAC/B,SAAS,EAAE,SAAS,CAAC;QACrB,SAAS,CAAC,EAAE,eAAe,CAAC;KAC7B;IAYI,iBAAiB;IAIxB;;;;;OAKG;IACI,SAAS;IAKhB,wDAAwD;IACjD,OAAO;IAIP,gBAAgB;IAIV,gBAAgB,CAAC,IAAI,EAAE;QAClC,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,YAAY,EAAE,sBAAsB,CAAC;QACrC,KAAK,EAAE,KAAK,CAAC;KACd,GAAG,OAAO,CAAC,OAAO,CAAC;YA+CN,4BAA4B;YA+C5B,sBAAsB;IAmDpC,OAAO,CAAC,uBAAuB;cA4Bf,kBAAkB;CAGnC"}
@@ -9,7 +9,7 @@ import { Timer } from '@aztec/foundation/timer';
9
9
  import { RollupAbi } from '@aztec/l1-artifacts';
10
10
  import { getTelemetryClient } from '@aztec/telemetry-client';
11
11
  import { encodeFunctionData } from 'viem';
12
- import { ProverNodeMetrics } from './metrics.js';
12
+ import { ProverNodePublisherMetrics } from './metrics.js';
13
13
  export class ProverNodePublisher {
14
14
  interruptibleSleep = new InterruptibleSleep();
15
15
  sleepTimeMs;
@@ -21,10 +21,13 @@ export class ProverNodePublisher {
21
21
  constructor(config, deps){
22
22
  this.sleepTimeMs = config?.l1PublishRetryIntervalMS ?? 60_000;
23
23
  const telemetry = deps.telemetry ?? getTelemetryClient();
24
- this.metrics = new ProverNodeMetrics(telemetry, 'ProverNode');
24
+ this.metrics = new ProverNodePublisherMetrics(telemetry, 'ProverNode');
25
25
  this.rollupContract = deps.rollupContract;
26
26
  this.l1TxUtils = deps.l1TxUtils;
27
27
  }
28
+ getRollupContract() {
29
+ return this.rollupContract;
30
+ }
28
31
  /**
29
32
  * Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
30
33
  * Be warned, the call may return false even if the tx subsequently gets successfully mined.
@@ -100,23 +103,16 @@ export class ProverNodePublisher {
100
103
  if (toBlock > pending) {
101
104
  throw new Error(`Cannot submit epoch proof for ${fromBlock}-${toBlock} as pending block is ${pending}`);
102
105
  }
103
- // Check the block hash and archive for the immediate block before the epoch
106
+ // Check the archive for the immediate block before the epoch
104
107
  const blockLog = await this.rollupContract.getBlock(BigInt(fromBlock - 1));
105
108
  if (publicInputs.previousArchive.root.toString() !== blockLog.archive) {
106
109
  throw new Error(`Previous archive root mismatch: ${publicInputs.previousArchive.root.toString()} !== ${blockLog.archive}`);
107
110
  }
108
- // TODO: Remove zero check once we inject the proper zero blockhash
109
- if (blockLog.blockHash !== Fr.ZERO.toString() && publicInputs.previousBlockHash.toString() !== blockLog.blockHash) {
110
- throw new Error(`Previous block hash mismatch: ${publicInputs.previousBlockHash.toString()} !== ${blockLog.blockHash}`);
111
- }
112
- // Check the block hash and archive for the last block in the epoch
111
+ // Check the archive for the last block in the epoch
113
112
  const endBlockLog = await this.rollupContract.getBlock(BigInt(toBlock));
114
113
  if (publicInputs.endArchive.root.toString() !== endBlockLog.archive) {
115
114
  throw new Error(`End archive root mismatch: ${publicInputs.endArchive.root.toString()} !== ${endBlockLog.archive}`);
116
115
  }
117
- if (publicInputs.endBlockHash.toString() !== endBlockLog.blockHash) {
118
- throw new Error(`End block hash mismatch: ${publicInputs.endBlockHash.toString()} !== ${endBlockLog.blockHash}`);
119
- }
120
116
  // Compare the public inputs computed by the contract with the ones injected
121
117
  const rollupPublicInputs = await this.rollupContract.getEpochProofPublicInputs(this.getSubmitEpochProofArgs(args));
122
118
  const argsPublicInputs = [
@@ -173,8 +169,6 @@ export class ProverNodePublisher {
173
169
  {
174
170
  previousArchive: args.publicInputs.previousArchive.root.toString(),
175
171
  endArchive: args.publicInputs.endArchive.root.toString(),
176
- previousBlockHash: args.publicInputs.previousBlockHash.toString(),
177
- endBlockHash: args.publicInputs.endBlockHash.toString(),
178
172
  endTimestamp: args.publicInputs.endTimestamp.toBigInt(),
179
173
  outHash: args.publicInputs.outHash.toString(),
180
174
  proverId: EthAddress.fromField(args.publicInputs.proverId).toString()
@@ -1,11 +1,9 @@
1
1
  import type { Maybe } from '@aztec/foundation/types';
2
- import type { P2P } from '@aztec/p2p';
3
2
  import { PublicProcessorFactory } from '@aztec/simulator/server';
4
3
  import type { L2Block, L2BlockSource } from '@aztec/stdlib/block';
5
4
  import type { ContractDataSource } from '@aztec/stdlib/contract';
6
5
  import { type EpochProverManager, type ProverCoordination, type ProverNodeApi, type Service, type WorldStateSyncStatus, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
7
6
  import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
8
- import type { P2PClientType } from '@aztec/stdlib/p2p';
9
7
  import type { Tx } from '@aztec/stdlib/tx';
10
8
  import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
11
9
  import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-job.js';
@@ -15,9 +13,7 @@ export type ProverNodeOptions = {
15
13
  pollingIntervalMs: number;
16
14
  maxPendingJobs: number;
17
15
  maxParallelBlocksPerEpoch: number;
18
- txGatheringTimeoutMs: number;
19
16
  txGatheringIntervalMs: number;
20
- txGatheringMaxParallelRequests: number;
21
17
  };
22
18
  /**
23
19
  * An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven blocks,
@@ -32,31 +28,33 @@ export declare class ProverNode implements EpochMonitorHandler, ProverNodeApi, T
32
28
  protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
33
29
  protected readonly contractDataSource: ContractDataSource;
34
30
  protected readonly worldState: WorldStateSynchronizer;
35
- protected readonly coordination: ProverCoordination & Maybe<Service>;
31
+ protected readonly coordination: ProverCoordination;
36
32
  protected readonly epochsMonitor: EpochMonitor;
37
33
  protected readonly telemetryClient: TelemetryClient;
38
34
  private log;
39
35
  private dateProvider;
40
36
  private jobs;
41
37
  private options;
42
- private metrics;
38
+ private jobMetrics;
39
+ private rewardsMetrics;
43
40
  private l1Metrics;
44
41
  private txFetcher;
45
42
  private lastBlockNumber;
46
43
  readonly tracer: Tracer;
47
- constructor(prover: EpochProverManager, publisher: ProverNodePublisher, l2BlockSource: L2BlockSource & Maybe<Service>, l1ToL2MessageSource: L1ToL2MessageSource, contractDataSource: ContractDataSource, worldState: WorldStateSynchronizer, coordination: ProverCoordination & Maybe<Service>, epochsMonitor: EpochMonitor, options?: Partial<ProverNodeOptions>, telemetryClient?: TelemetryClient);
44
+ constructor(prover: EpochProverManager, publisher: ProverNodePublisher, l2BlockSource: L2BlockSource & Maybe<Service>, l1ToL2MessageSource: L1ToL2MessageSource, contractDataSource: ContractDataSource, worldState: WorldStateSynchronizer, coordination: ProverCoordination, epochsMonitor: EpochMonitor, options?: Partial<ProverNodeOptions>, telemetryClient?: TelemetryClient);
48
45
  getProverId(): import("@aztec/foundation/schemas").Fr;
49
- getP2P(): P2P<P2PClientType.Prover> | undefined;
46
+ getP2P(): import("@aztec/stdlib/interfaces/server").P2PClient | undefined;
50
47
  /**
51
48
  * Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
52
49
  * @param epochNumber - The epoch number that was just completed.
50
+ * @returns false if there is an error, true otherwise
53
51
  */
54
- handleEpochReadyToProve(epochNumber: bigint): Promise<void>;
52
+ handleEpochReadyToProve(epochNumber: bigint): Promise<boolean>;
55
53
  /**
56
54
  * Starts the prover node so it periodically checks for unproven epochs in the unfinalised chain from L1 and
57
55
  * starts proving jobs for them.
58
56
  */
59
- start(): void;
57
+ start(): Promise<void>;
60
58
  /**
61
59
  * Stops the prover node and all its dependencies.
62
60
  */
@@ -1 +1 @@
1
- {"version":3,"file":"prover-node.d.ts","sourceRoot":"","sources":["../src/prover-node.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAA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AoB,CAAA;KAAE,EAAE,CAAC;IAM5D,OAAO,CAAC,uBAAuB;YAMjB,gBAAgB;IA8B9B,OAAO,CAAC,cAAc;IAItB,kHAAkH;YAEpG,WAAW;YAeX,eAAe;YAQf,YAAY;YAQZ,SAAS;IAiBvB,sCAAsC;IACtC,SAAS,CAAC,uBAAuB,CAC/B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,IAAI,GAAG,SAAS,EAC1B,MAAM,EAAE,OAAO,EAAE,EACjB,GAAG,EAAE,EAAE,EAAE,EACT,sBAAsB,EAAE,sBAAsB;IAkBhD,sCAAsC;cACtB,eAAe;CAGhC"}
@@ -6,6 +6,7 @@ function _ts_decorate(decorators, target, key, desc) {
6
6
  }
7
7
  import { compact } from '@aztec/foundation/collection';
8
8
  import { memoize } from '@aztec/foundation/decorators';
9
+ import { EthAddress } from '@aztec/foundation/eth-address';
9
10
  import { createLogger } from '@aztec/foundation/log';
10
11
  import { RunningPromise } from '@aztec/foundation/running-promise';
11
12
  import { DateProvider } from '@aztec/foundation/timer';
@@ -14,7 +15,7 @@ import { getProofSubmissionDeadlineTimestamp } from '@aztec/stdlib/epoch-helpers
14
15
  import { EpochProvingJobTerminalState, tryStop } from '@aztec/stdlib/interfaces/server';
15
16
  import { Attributes, L1Metrics, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
16
17
  import { EpochProvingJob } from './job/epoch-proving-job.js';
17
- import { ProverNodeMetrics } from './metrics.js';
18
+ import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
18
19
  /**
19
20
  * An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven blocks,
20
21
  * submits bids for proving them, and monitors if they are accepted. If so, the prover node fetches the txs
@@ -34,7 +35,8 @@ import { ProverNodeMetrics } from './metrics.js';
34
35
  dateProvider;
35
36
  jobs;
36
37
  options;
37
- metrics;
38
+ jobMetrics;
39
+ rewardsMetrics;
38
40
  l1Metrics;
39
41
  txFetcher;
40
42
  lastBlockNumber;
@@ -52,35 +54,32 @@ import { ProverNodeMetrics } from './metrics.js';
52
54
  this.log = createLogger('prover-node');
53
55
  this.dateProvider = new DateProvider();
54
56
  this.jobs = new Map();
55
- this.l1Metrics = new L1Metrics(telemetryClient.getMeter('ProverNodeL1Metrics'), publisher.l1TxUtils.publicClient, [
57
+ this.l1Metrics = new L1Metrics(telemetryClient.getMeter('ProverNodeL1Metrics'), publisher.l1TxUtils.client, [
56
58
  publisher.getSenderAddress()
57
59
  ]);
58
60
  this.options = {
59
61
  pollingIntervalMs: 1_000,
60
62
  maxPendingJobs: 100,
61
63
  maxParallelBlocksPerEpoch: 32,
62
- txGatheringTimeoutMs: 60_000,
63
64
  txGatheringIntervalMs: 1_000,
64
- txGatheringMaxParallelRequests: 100,
65
65
  ...compact(options)
66
66
  };
67
- this.metrics = new ProverNodeMetrics(telemetryClient, 'ProverNode');
67
+ const meter = telemetryClient.getMeter('ProverNode');
68
68
  this.tracer = telemetryClient.getTracer('ProverNode');
69
+ this.jobMetrics = new ProverNodeJobMetrics(meter, telemetryClient.getTracer('EpochProvingJob'));
70
+ this.rewardsMetrics = new ProverNodeRewardsMetrics(meter, EthAddress.fromField(this.prover.getProverId()), this.publisher.getRollupContract());
69
71
  this.txFetcher = new RunningPromise(()=>this.checkForTxs(), this.log, this.options.txGatheringIntervalMs);
70
72
  }
71
73
  getProverId() {
72
74
  return this.prover.getProverId();
73
75
  }
74
76
  getP2P() {
75
- const asP2PClient = this.coordination;
76
- if (typeof asP2PClient.isP2PClient === 'function' && asP2PClient.isP2PClient()) {
77
- return asP2PClient;
78
- }
79
- return undefined;
77
+ return this.coordination.getP2PClient();
80
78
  }
81
79
  /**
82
80
  * Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
83
81
  * @param epochNumber - The epoch number that was just completed.
82
+ * @returns false if there is an error, true otherwise
84
83
  */ async handleEpochReadyToProve(epochNumber) {
85
84
  try {
86
85
  this.log.debug(`Running jobs as ${epochNumber} is ready to prove`, {
@@ -91,24 +90,27 @@ import { ProverNodeMetrics } from './metrics.js';
91
90
  this.log.warn(`Not starting proof for ${epochNumber} since there are active jobs for the epoch`, {
92
91
  activeJobs: activeJobs.map((job)=>job.uuid)
93
92
  });
94
- return;
93
+ return true;
95
94
  }
96
95
  await this.startProof(epochNumber);
96
+ return true;
97
97
  } catch (err) {
98
98
  if (err instanceof EmptyEpochError) {
99
99
  this.log.info(`Not starting proof for ${epochNumber} since no blocks were found`);
100
100
  } else {
101
101
  this.log.error(`Error handling epoch completed`, err);
102
102
  }
103
+ return false;
103
104
  }
104
105
  }
105
106
  /**
106
107
  * Starts the prover node so it periodically checks for unproven epochs in the unfinalised chain from L1 and
107
108
  * starts proving jobs for them.
108
- */ start() {
109
+ */ async start() {
109
110
  this.txFetcher.start();
110
111
  this.epochsMonitor.start(this);
111
112
  this.l1Metrics.start();
113
+ await this.rewardsMetrics.start();
112
114
  this.log.info(`Started Prover Node with prover id ${this.prover.getProverId().toString()}`, this.options);
113
115
  }
114
116
  /**
@@ -124,11 +126,13 @@ import { ProverNodeMetrics } from './metrics.js';
124
126
  await this.worldState.stop();
125
127
  await tryStop(this.coordination);
126
128
  this.l1Metrics.stop();
129
+ this.rewardsMetrics.stop();
127
130
  await this.telemetryClient.stop();
128
131
  this.log.info('Stopped ProverNode');
129
132
  }
130
- /** Returns world state status. */ getWorldStateSyncStatus() {
131
- return this.worldState.status().then((s)=>s.syncSummary);
133
+ /** Returns world state status. */ async getWorldStateSyncStatus() {
134
+ const { syncSummary } = await this.worldState.status();
135
+ return syncSummary;
132
136
  }
133
137
  /** Returns archiver status. */ getL2Tips() {
134
138
  return this.l2BlockSource.getL2Tips();
@@ -213,7 +217,7 @@ import { ProverNodeMetrics } from './metrics.js';
213
217
  }
214
218
  const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
215
219
  this.log.verbose(`Fetching ${txHashes.length} tx hashes for block number ${blockNumber} from coordination`);
216
- await this.coordination.getTxsByHash(txHashes); // This stores the txs in the tx pool, no need to persist them here
220
+ await this.coordination.gatherTxs(txHashes); // This stores the txs in the tx pool, no need to persist them here
217
221
  this.lastBlockNumber = blockNumber;
218
222
  }
219
223
  }
@@ -247,7 +251,7 @@ import { ProverNodeMetrics } from './metrics.js';
247
251
  throw new Error(`Txs not found for epoch ${epochNumber}: ${missingTxHashes}`);
248
252
  }
249
253
  /** Extracted for testing purposes. */ doCreateEpochProvingJob(epochNumber, deadline, blocks, txs, publicProcessorFactory) {
250
- return new EpochProvingJob(this.worldState, epochNumber, blocks, txs, this.prover.createEpochProver(), publicProcessorFactory, this.publisher, this.l2BlockSource, this.l1ToL2MessageSource, this.metrics, deadline, {
254
+ return new EpochProvingJob(this.worldState, epochNumber, blocks, txs, this.prover.createEpochProver(), publicProcessorFactory, this.publisher, this.l2BlockSource, this.l1ToL2MessageSource, this.jobMetrics, deadline, {
251
255
  parallelBlockLimit: this.options.maxParallelBlocksPerEpoch
252
256
  });
253
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/prover-node",
3
- "version": "0.85.0",
3
+ "version": "0.86.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./dest/index.js",
@@ -14,8 +14,6 @@
14
14
  "build": "yarn clean && tsc -b",
15
15
  "build:dev": "tsc -b --watch",
16
16
  "clean": "rm -rf ./dest .tsbuildinfo",
17
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
18
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
19
17
  "bb": "node --no-warnings ./dest/bb/index.js",
20
18
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
21
19
  },
@@ -53,25 +51,25 @@
53
51
  ]
54
52
  },
55
53
  "dependencies": {
56
- "@aztec/archiver": "0.85.0",
57
- "@aztec/bb-prover": "0.85.0",
58
- "@aztec/blob-sink": "0.85.0",
59
- "@aztec/constants": "0.85.0",
60
- "@aztec/epoch-cache": "0.85.0",
61
- "@aztec/ethereum": "0.85.0",
62
- "@aztec/foundation": "0.85.0",
63
- "@aztec/kv-store": "0.85.0",
64
- "@aztec/l1-artifacts": "0.85.0",
65
- "@aztec/node-lib": "0.85.0",
66
- "@aztec/noir-protocol-circuits-types": "0.85.0",
67
- "@aztec/p2p": "0.85.0",
68
- "@aztec/protocol-contracts": "0.85.0",
69
- "@aztec/prover-client": "0.85.0",
70
- "@aztec/sequencer-client": "0.85.0",
71
- "@aztec/simulator": "0.85.0",
72
- "@aztec/stdlib": "0.85.0",
73
- "@aztec/telemetry-client": "0.85.0",
74
- "@aztec/world-state": "0.85.0",
54
+ "@aztec/archiver": "0.86.0",
55
+ "@aztec/bb-prover": "0.86.0",
56
+ "@aztec/blob-sink": "0.86.0",
57
+ "@aztec/constants": "0.86.0",
58
+ "@aztec/epoch-cache": "0.86.0",
59
+ "@aztec/ethereum": "0.86.0",
60
+ "@aztec/foundation": "0.86.0",
61
+ "@aztec/kv-store": "0.86.0",
62
+ "@aztec/l1-artifacts": "0.86.0",
63
+ "@aztec/node-lib": "0.86.0",
64
+ "@aztec/noir-protocol-circuits-types": "0.86.0",
65
+ "@aztec/p2p": "0.86.0",
66
+ "@aztec/protocol-contracts": "0.86.0",
67
+ "@aztec/prover-client": "0.86.0",
68
+ "@aztec/sequencer-client": "0.86.0",
69
+ "@aztec/simulator": "0.86.0",
70
+ "@aztec/stdlib": "0.86.0",
71
+ "@aztec/telemetry-client": "0.86.0",
72
+ "@aztec/world-state": "0.86.0",
75
73
  "source-map-support": "^0.5.21",
76
74
  "tslib": "^2.4.0",
77
75
  "viem": "2.23.7"