@aztec/prover-node 0.85.0-alpha-testnet.2 → 0.85.0-alpha-testnet.3
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/dest/actions/download-epoch-proving-job.d.ts +15 -0
- package/dest/actions/download-epoch-proving-job.d.ts.map +1 -0
- package/dest/actions/download-epoch-proving-job.js +35 -0
- package/dest/actions/index.d.ts +3 -0
- package/dest/actions/index.d.ts.map +1 -0
- package/dest/actions/index.js +2 -0
- package/dest/actions/rerun-epoch-proving-job.d.ts +11 -0
- package/dest/actions/rerun-epoch-proving-job.d.ts.map +1 -0
- package/dest/actions/rerun-epoch-proving-job.js +37 -0
- package/dest/actions/upload-epoch-proof-failure.d.ts +15 -0
- package/dest/actions/upload-epoch-proof-failure.d.ts.map +1 -0
- package/dest/actions/upload-epoch-proof-failure.js +78 -0
- package/dest/config.d.ts +4 -4
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -7
- package/dest/factory.d.ts +3 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -8
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/job/epoch-proving-job-data.d.ts +17 -0
- package/dest/job/epoch-proving-job-data.d.ts.map +1 -0
- package/dest/job/epoch-proving-job-data.js +45 -0
- package/dest/job/epoch-proving-job.d.ts +9 -9
- package/dest/job/epoch-proving-job.d.ts.map +1 -1
- package/dest/job/epoch-proving-job.js +38 -21
- package/dest/metrics.d.ts +27 -4
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +104 -36
- package/dest/monitors/epoch-monitor.d.ts +1 -1
- package/dest/monitors/epoch-monitor.d.ts.map +1 -1
- package/dest/monitors/epoch-monitor.js +7 -2
- package/dest/prover-coordination/combined-prover-coordination.d.ts +22 -0
- package/dest/prover-coordination/combined-prover-coordination.d.ts.map +1 -0
- package/dest/prover-coordination/combined-prover-coordination.js +136 -0
- package/dest/prover-coordination/config.d.ts +1 -1
- package/dest/prover-coordination/config.d.ts.map +1 -1
- package/dest/prover-coordination/config.js +5 -4
- package/dest/prover-coordination/factory.d.ts +5 -4
- package/dest/prover-coordination/factory.d.ts.map +1 -1
- package/dest/prover-coordination/factory.js +23 -14
- package/dest/prover-node-publisher.d.ts +1 -0
- package/dest/prover-node-publisher.d.ts.map +1 -1
- package/dest/prover-node-publisher.js +5 -2
- package/dest/prover-node.d.ts +26 -24
- package/dest/prover-node.d.ts.map +1 -1
- package/dest/prover-node.js +102 -50
- package/dest/test/index.d.ts +4 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -1
- package/package.json +20 -20
- package/src/actions/download-epoch-proving-job.ts +46 -0
- package/src/actions/index.ts +2 -0
- package/src/actions/rerun-epoch-proving-job.ts +59 -0
- package/src/actions/upload-epoch-proof-failure.ts +88 -0
- package/src/config.ts +16 -10
- package/src/factory.ts +25 -12
- package/src/index.ts +1 -0
- package/src/job/epoch-proving-job-data.ts +68 -0
- package/src/job/epoch-proving-job.ts +53 -23
- package/src/metrics.ts +111 -38
- package/src/monitors/epoch-monitor.ts +5 -3
- package/src/prover-coordination/combined-prover-coordination.ts +160 -0
- package/src/prover-coordination/config.ts +6 -5
- package/src/prover-coordination/factory.ts +37 -25
- package/src/prover-node-publisher.ts +7 -3
- package/src/prover-node.ts +144 -70
- package/src/test/index.ts +5 -2
|
@@ -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?:
|
|
9
|
-
worldStateSynchronizer
|
|
10
|
-
archiver
|
|
9
|
+
aztecNodeTxProvider?: TxSource;
|
|
10
|
+
worldStateSynchronizer: WorldStateSynchronizer;
|
|
11
|
+
archiver: Archiver | ArchiveSource;
|
|
11
12
|
telemetry?: TelemetryClient;
|
|
12
|
-
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;
|
|
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,CA4C7B"}
|
|
@@ -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,37 @@ 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
|
|
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
|
-
|
|
32
|
-
|
|
34
|
+
let nodes = [];
|
|
35
|
+
if (config.proverCoordinationNodeUrls && config.proverCoordinationNodeUrls.length > 0) {
|
|
36
|
+
log.info('Using prover coordination via node urls');
|
|
33
37
|
const versions = getComponentsVersionsFromConfig(config, protocolContractTreeRoot, getVKTreeRoot());
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
nodes = config.proverCoordinationNodeUrls.map((url)=>{
|
|
39
|
+
log.info(`Creating aztec node client for prover coordination with url: ${url}`);
|
|
40
|
+
return createAztecNodeClient(url, versions, makeTracedFetch([
|
|
41
|
+
1,
|
|
42
|
+
2,
|
|
43
|
+
3
|
|
44
|
+
], false));
|
|
45
|
+
});
|
|
41
46
|
}
|
|
47
|
+
const proofVerifier = config.realProofs ? await BBCircuitVerifier.new(config) : new TestCircuitVerifier();
|
|
48
|
+
const p2pClient = await createP2PClient(P2PClientType.Prover, config, deps.archiver, proofVerifier, deps.worldStateSynchronizer, deps.epochCache, deps.telemetry);
|
|
49
|
+
await p2pClient.start();
|
|
50
|
+
return new CombinedProverCoordination(p2pClient, nodes, coordinationConfig);
|
|
42
51
|
}
|
|
@@ -36,6 +36,7 @@ export declare class ProverNodePublisher {
|
|
|
36
36
|
l1TxUtils: L1TxUtils;
|
|
37
37
|
telemetry?: TelemetryClient;
|
|
38
38
|
});
|
|
39
|
+
getRollupContract(): RollupContract;
|
|
39
40
|
/**
|
|
40
41
|
* Calling `interrupt` will cause any in progress call to `publishRollup` to return `false` asap.
|
|
41
42
|
* 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;AACH,sEAAsE;AACtE,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,EAAE,CAAC;IACpB,UAAU,EAAE,EAAE,CAAC;IACf,iBAAiB,EAAE,EAAE,CAAC;IACtB,YAAY,EAAE,EAAE,CAAC;IACjB,YAAY,EAAE,EAAE,CAAC;IACjB,OAAO,EAAE,EAAE,CAAC;IACZ,QAAQ,EAAE,EAAE,CAAC;IACb,IAAI,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,wBAAwB,CAAC,CAAC;IAC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qBAAa,mBAAmB;IAC9B,OAAO,CAAC,kBAAkB,CAA4B;IACtD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAE5C,SAAS,CAAC,GAAG,yCAA+C;IAE5D,SAAS,CAAC,cAAc,EAAE,cAAc,CAAC;IAEzC,SAAgB,SAAS,EAAE,SAAS,CAAC;gBAGnC,MAAM,EAAE,cAAc,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;YAwD5B,sBAAsB;IAmDpC,OAAO,CAAC,uBAAuB;cA8Bf,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 {
|
|
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
|
|
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.
|
package/dest/prover-node.d.ts
CHANGED
|
@@ -1,28 +1,23 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
1
2
|
import type { Maybe } from '@aztec/foundation/types';
|
|
2
|
-
import type {
|
|
3
|
+
import type { DataStoreConfig } from '@aztec/kv-store/config';
|
|
3
4
|
import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
4
|
-
import type {
|
|
5
|
+
import type { L2BlockSource } from '@aztec/stdlib/block';
|
|
6
|
+
import type { ChainConfig } from '@aztec/stdlib/config';
|
|
5
7
|
import type { ContractDataSource } from '@aztec/stdlib/contract';
|
|
6
8
|
import { type EpochProverManager, type ProverCoordination, type ProverNodeApi, type Service, type WorldStateSyncStatus, type WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
7
9
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
8
|
-
import type { P2PClientType } from '@aztec/stdlib/p2p';
|
|
9
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
10
10
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
11
|
+
import type { SpecificProverNodeConfig } from './config.js';
|
|
12
|
+
import type { EpochProvingJobData } from './job/epoch-proving-job-data.js';
|
|
11
13
|
import { EpochProvingJob, type EpochProvingJobState } from './job/epoch-proving-job.js';
|
|
12
14
|
import type { EpochMonitor, EpochMonitorHandler } from './monitors/epoch-monitor.js';
|
|
13
15
|
import type { ProverNodePublisher } from './prover-node-publisher.js';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
maxPendingJobs: number;
|
|
17
|
-
maxParallelBlocksPerEpoch: number;
|
|
18
|
-
txGatheringTimeoutMs: number;
|
|
19
|
-
txGatheringIntervalMs: number;
|
|
20
|
-
txGatheringMaxParallelRequests: number;
|
|
21
|
-
};
|
|
16
|
+
type ProverNodeOptions = SpecificProverNodeConfig & Partial<DataStoreOptions>;
|
|
17
|
+
type DataStoreOptions = Pick<DataStoreConfig, 'dataDirectory'> & Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'>;
|
|
22
18
|
/**
|
|
23
|
-
* An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven
|
|
24
|
-
*
|
|
25
|
-
* from a tx source in the p2p network or an external node, re-executes their public functions, creates a rollup
|
|
19
|
+
* An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven epochs,
|
|
20
|
+
* fetches their txs from the p2p network or external nodes, re-executes their public functions, creates a rollup
|
|
26
21
|
* proof for the epoch, and submits it to L1.
|
|
27
22
|
*/
|
|
28
23
|
export declare class ProverNode implements EpochMonitorHandler, ProverNodeApi, Traceable {
|
|
@@ -32,31 +27,33 @@ export declare class ProverNode implements EpochMonitorHandler, ProverNodeApi, T
|
|
|
32
27
|
protected readonly l1ToL2MessageSource: L1ToL2MessageSource;
|
|
33
28
|
protected readonly contractDataSource: ContractDataSource;
|
|
34
29
|
protected readonly worldState: WorldStateSynchronizer;
|
|
35
|
-
protected readonly coordination: ProverCoordination
|
|
30
|
+
protected readonly coordination: ProverCoordination;
|
|
36
31
|
protected readonly epochsMonitor: EpochMonitor;
|
|
37
32
|
protected readonly telemetryClient: TelemetryClient;
|
|
38
33
|
private log;
|
|
39
34
|
private dateProvider;
|
|
40
35
|
private jobs;
|
|
41
|
-
private
|
|
42
|
-
private
|
|
36
|
+
private config;
|
|
37
|
+
private jobMetrics;
|
|
38
|
+
private rewardsMetrics;
|
|
43
39
|
private l1Metrics;
|
|
44
40
|
private txFetcher;
|
|
45
41
|
private lastBlockNumber;
|
|
46
42
|
readonly tracer: Tracer;
|
|
47
|
-
constructor(prover: EpochProverManager, publisher: ProverNodePublisher, l2BlockSource: L2BlockSource & Maybe<Service>, l1ToL2MessageSource: L1ToL2MessageSource, contractDataSource: ContractDataSource, worldState: WorldStateSynchronizer, coordination: ProverCoordination
|
|
48
|
-
getProverId():
|
|
49
|
-
getP2P():
|
|
43
|
+
constructor(prover: EpochProverManager, publisher: ProverNodePublisher, l2BlockSource: L2BlockSource & Maybe<Service>, l1ToL2MessageSource: L1ToL2MessageSource, contractDataSource: ContractDataSource, worldState: WorldStateSynchronizer, coordination: ProverCoordination, epochsMonitor: EpochMonitor, config?: Partial<ProverNodeOptions>, telemetryClient?: TelemetryClient);
|
|
44
|
+
getProverId(): Fr;
|
|
45
|
+
getP2P(): import("@aztec/stdlib/interfaces/server").P2PClient | undefined;
|
|
50
46
|
/**
|
|
51
47
|
* Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
|
|
52
48
|
* @param epochNumber - The epoch number that was just completed.
|
|
49
|
+
* @returns false if there is an error, true otherwise
|
|
53
50
|
*/
|
|
54
|
-
handleEpochReadyToProve(epochNumber: bigint): Promise<
|
|
51
|
+
handleEpochReadyToProve(epochNumber: bigint): Promise<boolean>;
|
|
55
52
|
/**
|
|
56
53
|
* Starts the prover node so it periodically checks for unproven epochs in the unfinalised chain from L1 and
|
|
57
54
|
* starts proving jobs for them.
|
|
58
55
|
*/
|
|
59
|
-
start(): void
|
|
56
|
+
start(): Promise<void>;
|
|
60
57
|
/**
|
|
61
58
|
* Stops the prover node and all its dependencies.
|
|
62
59
|
*/
|
|
@@ -70,6 +67,7 @@ export declare class ProverNode implements EpochMonitorHandler, ProverNodeApi, T
|
|
|
70
67
|
*/
|
|
71
68
|
startProof(epochNumber: number | bigint): Promise<void>;
|
|
72
69
|
private runJob;
|
|
70
|
+
protected tryUploadEpochFailure(job: EpochProvingJob): Promise<string | undefined>;
|
|
73
71
|
/**
|
|
74
72
|
* Returns the prover instance.
|
|
75
73
|
*/
|
|
@@ -94,9 +92,13 @@ export declare class ProverNode implements EpochMonitorHandler, ProverNodeApi, T
|
|
|
94
92
|
private gatherEpochData;
|
|
95
93
|
private gatherBlocks;
|
|
96
94
|
private gatherTxs;
|
|
95
|
+
private gatherMessages;
|
|
96
|
+
private gatherPreviousBlockHeader;
|
|
97
97
|
/** Extracted for testing purposes. */
|
|
98
|
-
protected doCreateEpochProvingJob(
|
|
98
|
+
protected doCreateEpochProvingJob(data: EpochProvingJobData, deadline: Date | undefined, publicProcessorFactory: PublicProcessorFactory): EpochProvingJob;
|
|
99
99
|
/** Extracted for testing purposes. */
|
|
100
100
|
protected triggerMonitors(): Promise<void>;
|
|
101
|
+
private validateConfig;
|
|
101
102
|
}
|
|
103
|
+
export {};
|
|
102
104
|
//# sourceMappingURL=prover-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prover-node.d.ts","sourceRoot":"","sources":["../src/prover-node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prover-node.d.ts","sourceRoot":"","sources":["../src/prover-node.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAInD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAW,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC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AAI,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,oBAAoB,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;cAUhF,qBAAqB,CACnC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,oBAAoB,CAAA;KAAE,EAAE,CAAC;IAM5D,OAAO,CAAC,uBAAuB;YAQjB,gBAAgB;IA8B9B,OAAO,CAAC,cAAc;IAItB,kHAAkH;YAEpG,WAAW;YAeX,eAAe;YASf,YAAY;YAQZ,SAAS;YAiBT,cAAc;YAWd,yBAAyB;IAcvC,sCAAsC;IACtC,SAAS,CAAC,uBAAuB,CAC/B,IAAI,EAAE,mBAAmB,EACzB,QAAQ,EAAE,IAAI,GAAG,SAAS,EAC1B,sBAAsB,EAAE,sBAAsB;IAgBhD,sCAAsC;cACtB,eAAe;IAI/B,OAAO,CAAC,cAAc;CAcvB"}
|
package/dest/prover-node.js
CHANGED
|
@@ -4,8 +4,9 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
4
4
|
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
}
|
|
7
|
-
import { compact } from '@aztec/foundation/collection';
|
|
7
|
+
import { assertRequired, compact, pick, sum } 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';
|
|
@@ -13,12 +14,12 @@ import { PublicProcessorFactory } from '@aztec/simulator/server';
|
|
|
13
14
|
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';
|
|
17
|
+
import { uploadEpochProofFailure } from './actions/upload-epoch-proof-failure.js';
|
|
16
18
|
import { EpochProvingJob } from './job/epoch-proving-job.js';
|
|
17
|
-
import {
|
|
19
|
+
import { ProverNodeJobMetrics, ProverNodeRewardsMetrics } from './metrics.js';
|
|
18
20
|
/**
|
|
19
|
-
* An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven
|
|
20
|
-
*
|
|
21
|
-
* from a tx source in the p2p network or an external node, re-executes their public functions, creates a rollup
|
|
21
|
+
* An Aztec Prover Node is a standalone process that monitors the unfinalised chain on L1 for unproven epochs,
|
|
22
|
+
* fetches their txs from the p2p network or external nodes, re-executes their public functions, creates a rollup
|
|
22
23
|
* proof for the epoch, and submits it to L1.
|
|
23
24
|
*/ export class ProverNode {
|
|
24
25
|
prover;
|
|
@@ -33,13 +34,14 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
33
34
|
log;
|
|
34
35
|
dateProvider;
|
|
35
36
|
jobs;
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
config;
|
|
38
|
+
jobMetrics;
|
|
39
|
+
rewardsMetrics;
|
|
38
40
|
l1Metrics;
|
|
39
41
|
txFetcher;
|
|
40
42
|
lastBlockNumber;
|
|
41
43
|
tracer;
|
|
42
|
-
constructor(prover, publisher, l2BlockSource, l1ToL2MessageSource, contractDataSource, worldState, coordination, epochsMonitor,
|
|
44
|
+
constructor(prover, publisher, l2BlockSource, l1ToL2MessageSource, contractDataSource, worldState, coordination, epochsMonitor, config = {}, telemetryClient = getTelemetryClient()){
|
|
43
45
|
this.prover = prover;
|
|
44
46
|
this.publisher = publisher;
|
|
45
47
|
this.l2BlockSource = l2BlockSource;
|
|
@@ -55,32 +57,33 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
55
57
|
this.l1Metrics = new L1Metrics(telemetryClient.getMeter('ProverNodeL1Metrics'), publisher.l1TxUtils.publicClient, [
|
|
56
58
|
publisher.getSenderAddress()
|
|
57
59
|
]);
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
txGatheringTimeoutMs: 60_000,
|
|
60
|
+
this.config = {
|
|
61
|
+
proverNodePollingIntervalMs: 1_000,
|
|
62
|
+
proverNodeMaxPendingJobs: 100,
|
|
63
|
+
proverNodeMaxParallelBlocksPerEpoch: 32,
|
|
63
64
|
txGatheringIntervalMs: 1_000,
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
txGatheringBatchSize: 10,
|
|
66
|
+
txGatheringMaxParallelRequestsPerNode: 100,
|
|
67
|
+
proverNodeFailedEpochStore: undefined,
|
|
68
|
+
...compact(config)
|
|
66
69
|
};
|
|
67
|
-
this.
|
|
70
|
+
this.validateConfig();
|
|
71
|
+
const meter = telemetryClient.getMeter('ProverNode');
|
|
68
72
|
this.tracer = telemetryClient.getTracer('ProverNode');
|
|
69
|
-
this.
|
|
73
|
+
this.jobMetrics = new ProverNodeJobMetrics(meter, telemetryClient.getTracer('EpochProvingJob'));
|
|
74
|
+
this.rewardsMetrics = new ProverNodeRewardsMetrics(meter, EthAddress.fromField(this.prover.getProverId()), this.publisher.getRollupContract());
|
|
75
|
+
this.txFetcher = new RunningPromise(()=>this.checkForTxs(), this.log, this.config.txGatheringIntervalMs);
|
|
70
76
|
}
|
|
71
77
|
getProverId() {
|
|
72
78
|
return this.prover.getProverId();
|
|
73
79
|
}
|
|
74
80
|
getP2P() {
|
|
75
|
-
|
|
76
|
-
if (typeof asP2PClient.isP2PClient === 'function' && asP2PClient.isP2PClient()) {
|
|
77
|
-
return asP2PClient;
|
|
78
|
-
}
|
|
79
|
-
return undefined;
|
|
81
|
+
return this.coordination.getP2PClient();
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
82
84
|
* Handles an epoch being completed by starting a proof for it if there are no active jobs for it.
|
|
83
85
|
* @param epochNumber - The epoch number that was just completed.
|
|
86
|
+
* @returns false if there is an error, true otherwise
|
|
84
87
|
*/ async handleEpochReadyToProve(epochNumber) {
|
|
85
88
|
try {
|
|
86
89
|
this.log.debug(`Running jobs as ${epochNumber} is ready to prove`, {
|
|
@@ -91,25 +94,28 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
91
94
|
this.log.warn(`Not starting proof for ${epochNumber} since there are active jobs for the epoch`, {
|
|
92
95
|
activeJobs: activeJobs.map((job)=>job.uuid)
|
|
93
96
|
});
|
|
94
|
-
return;
|
|
97
|
+
return true;
|
|
95
98
|
}
|
|
96
99
|
await this.startProof(epochNumber);
|
|
100
|
+
return true;
|
|
97
101
|
} catch (err) {
|
|
98
102
|
if (err instanceof EmptyEpochError) {
|
|
99
103
|
this.log.info(`Not starting proof for ${epochNumber} since no blocks were found`);
|
|
100
104
|
} else {
|
|
101
105
|
this.log.error(`Error handling epoch completed`, err);
|
|
102
106
|
}
|
|
107
|
+
return false;
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
110
|
/**
|
|
106
111
|
* Starts the prover node so it periodically checks for unproven epochs in the unfinalised chain from L1 and
|
|
107
112
|
* starts proving jobs for them.
|
|
108
|
-
*/ start() {
|
|
113
|
+
*/ async start() {
|
|
109
114
|
this.txFetcher.start();
|
|
110
115
|
this.epochsMonitor.start(this);
|
|
111
116
|
this.l1Metrics.start();
|
|
112
|
-
|
|
117
|
+
await this.rewardsMetrics.start();
|
|
118
|
+
this.log.info(`Started Prover Node with prover id ${this.prover.getProverId().toString()}`, this.config);
|
|
113
119
|
}
|
|
114
120
|
/**
|
|
115
121
|
* Stops the prover node and all its dependencies.
|
|
@@ -124,11 +130,13 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
124
130
|
await this.worldState.stop();
|
|
125
131
|
await tryStop(this.coordination);
|
|
126
132
|
this.l1Metrics.stop();
|
|
133
|
+
this.rewardsMetrics.stop();
|
|
127
134
|
await this.telemetryClient.stop();
|
|
128
135
|
this.log.info('Stopped ProverNode');
|
|
129
136
|
}
|
|
130
|
-
/** Returns world state status. */ getWorldStateSyncStatus() {
|
|
131
|
-
|
|
137
|
+
/** Returns world state status. */ async getWorldStateSyncStatus() {
|
|
138
|
+
const { syncSummary } = await this.worldState.status();
|
|
139
|
+
return syncSummary;
|
|
132
140
|
}
|
|
133
141
|
/** Returns archiver status. */ getL2Tips() {
|
|
134
142
|
return this.l2BlockSource.getL2Tips();
|
|
@@ -140,25 +148,36 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
140
148
|
void this.runJob(job);
|
|
141
149
|
}
|
|
142
150
|
async runJob(job) {
|
|
151
|
+
const epochNumber = job.getEpochNumber();
|
|
143
152
|
const ctx = {
|
|
144
153
|
id: job.getId(),
|
|
145
|
-
epochNumber
|
|
154
|
+
epochNumber,
|
|
155
|
+
state: undefined
|
|
146
156
|
};
|
|
147
157
|
try {
|
|
148
158
|
await job.run();
|
|
149
159
|
const state = job.getState();
|
|
160
|
+
ctx.state = state;
|
|
150
161
|
if (state === 'reorg') {
|
|
151
|
-
this.log.warn(`Running new job for epoch ${
|
|
152
|
-
await this.createProvingJob(
|
|
162
|
+
this.log.warn(`Running new job for epoch ${epochNumber} due to reorg`, ctx);
|
|
163
|
+
await this.createProvingJob(epochNumber);
|
|
164
|
+
} else if (state === 'failed') {
|
|
165
|
+
this.log.error(`Job for ${epochNumber} exited with state ${state}`, ctx);
|
|
166
|
+
await this.tryUploadEpochFailure(job);
|
|
153
167
|
} else {
|
|
154
|
-
this.log.verbose(`Job for ${
|
|
168
|
+
this.log.verbose(`Job for ${epochNumber} exited with state ${state}`, ctx);
|
|
155
169
|
}
|
|
156
170
|
} catch (err) {
|
|
157
|
-
this.log.error(`Error proving epoch ${
|
|
171
|
+
this.log.error(`Error proving epoch ${epochNumber}`, err, ctx);
|
|
158
172
|
} finally{
|
|
159
173
|
this.jobs.delete(job.getId());
|
|
160
174
|
}
|
|
161
175
|
}
|
|
176
|
+
async tryUploadEpochFailure(job) {
|
|
177
|
+
if (this.config.proverNodeFailedEpochStore) {
|
|
178
|
+
return await uploadEpochProofFailure(this.config.proverNodeFailedEpochStore, job.getId(), job.getProvingData(), this.l2BlockSource, this.worldState, assertRequired(pick(this.config, 'l1ChainId', 'rollupVersion', 'dataDirectory')), this.log);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
162
181
|
/**
|
|
163
182
|
* Returns the prover instance.
|
|
164
183
|
*/ getProver() {
|
|
@@ -179,25 +198,26 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
179
198
|
return jobs.filter((job)=>job.epochNumber === epochNumber && !EpochProvingJobTerminalState.includes(job.status));
|
|
180
199
|
}
|
|
181
200
|
checkMaximumPendingJobs() {
|
|
182
|
-
const { maxPendingJobs } = this.
|
|
183
|
-
|
|
201
|
+
const { proverNodeMaxPendingJobs: maxPendingJobs } = this.config;
|
|
202
|
+
if (maxPendingJobs > 0 && this.jobs.size >= maxPendingJobs) {
|
|
203
|
+
throw new Error(`Maximum pending proving jobs ${maxPendingJobs} reached. Cannot create new job.`);
|
|
204
|
+
}
|
|
184
205
|
}
|
|
185
206
|
async createProvingJob(epochNumber) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
const fromBlock = blocks[0].number;
|
|
192
|
-
const toBlock = blocks.at(-1).number;
|
|
193
|
-
// Fast forward world state to right before the target block and get a fork
|
|
207
|
+
this.checkMaximumPendingJobs();
|
|
208
|
+
// Gather all data for this epoch
|
|
209
|
+
const epochData = await this.gatherEpochData(epochNumber);
|
|
210
|
+
const fromBlock = epochData.blocks[0].number;
|
|
211
|
+
const toBlock = epochData.blocks.at(-1).number;
|
|
194
212
|
this.log.verbose(`Creating proving job for epoch ${epochNumber} for block range ${fromBlock} to ${toBlock}`);
|
|
213
|
+
// Fast forward world state to right before the target block and get a fork
|
|
195
214
|
await this.worldState.syncImmediate(toBlock);
|
|
196
|
-
// Create a processor
|
|
215
|
+
// Create a processor factory
|
|
197
216
|
const publicProcessorFactory = new PublicProcessorFactory(this.contractDataSource, this.dateProvider, this.telemetryClient);
|
|
217
|
+
// Set deadline for this job to run. It will abort if it takes too long.
|
|
198
218
|
const deadlineTs = getProofSubmissionDeadlineTimestamp(epochNumber, await this.getL1Constants());
|
|
199
219
|
const deadline = new Date(Number(deadlineTs) * 1000);
|
|
200
|
-
const job = this.doCreateEpochProvingJob(
|
|
220
|
+
const job = this.doCreateEpochProvingJob(epochData, deadline, publicProcessorFactory);
|
|
201
221
|
this.jobs.set(job.getId(), job);
|
|
202
222
|
return job;
|
|
203
223
|
}
|
|
@@ -213,17 +233,21 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
213
233
|
}
|
|
214
234
|
const txHashes = block.body.txEffects.map((tx)=>tx.txHash);
|
|
215
235
|
this.log.verbose(`Fetching ${txHashes.length} tx hashes for block number ${blockNumber} from coordination`);
|
|
216
|
-
await this.coordination.
|
|
236
|
+
await this.coordination.gatherTxs(txHashes); // This stores the txs in the tx pool, no need to persist them here
|
|
217
237
|
this.lastBlockNumber = blockNumber;
|
|
218
238
|
}
|
|
219
239
|
}
|
|
220
240
|
async gatherEpochData(epochNumber) {
|
|
221
|
-
// Gather blocks for this epoch and their txs
|
|
222
241
|
const blocks = await this.gatherBlocks(epochNumber);
|
|
223
242
|
const txs = await this.gatherTxs(epochNumber, blocks);
|
|
243
|
+
const l1ToL2Messages = await this.gatherMessages(epochNumber, blocks);
|
|
244
|
+
const previousBlockHeader = await this.gatherPreviousBlockHeader(epochNumber, blocks[0]);
|
|
224
245
|
return {
|
|
225
246
|
blocks,
|
|
226
|
-
txs
|
|
247
|
+
txs,
|
|
248
|
+
l1ToL2Messages,
|
|
249
|
+
epochNumber,
|
|
250
|
+
previousBlockHeader
|
|
227
251
|
};
|
|
228
252
|
}
|
|
229
253
|
async gatherBlocks(epochNumber) {
|
|
@@ -246,14 +270,42 @@ import { ProverNodeMetrics } from './metrics.js';
|
|
|
246
270
|
const missingTxHashes = txsToFind.filter((txHashToFind)=>!txHashesFound.some((txHashFound)=>txHashToFind.equals(txHashFound))).join(', ');
|
|
247
271
|
throw new Error(`Txs not found for epoch ${epochNumber}: ${missingTxHashes}`);
|
|
248
272
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
273
|
+
async gatherMessages(epochNumber, blocks) {
|
|
274
|
+
const messages = await Promise.all(blocks.map((b)=>this.l1ToL2MessageSource.getL1ToL2Messages(BigInt(b.number))));
|
|
275
|
+
const messageCount = sum(messages.map((m)=>m.length));
|
|
276
|
+
this.log.verbose(`Gathered all ${messageCount} messages for epoch ${epochNumber}`, {
|
|
277
|
+
epochNumber
|
|
278
|
+
});
|
|
279
|
+
const messagesByBlock = {};
|
|
280
|
+
for(let i = 0; i < blocks.length; i++){
|
|
281
|
+
messagesByBlock[blocks[i].number] = messages[i];
|
|
282
|
+
}
|
|
283
|
+
return messagesByBlock;
|
|
284
|
+
}
|
|
285
|
+
async gatherPreviousBlockHeader(epochNumber, initialBlock) {
|
|
286
|
+
const previousBlockNumber = initialBlock.number - 1;
|
|
287
|
+
const header = await (previousBlockNumber === 0 ? this.worldState.getCommitted().getInitialHeader() : this.l2BlockSource.getBlockHeader(previousBlockNumber));
|
|
288
|
+
if (!header) {
|
|
289
|
+
throw new Error(`Previous block header ${initialBlock.number} not found for proving epoch ${epochNumber}`);
|
|
290
|
+
}
|
|
291
|
+
this.log.verbose(`Gathered previous block header ${header.getBlockNumber()} for epoch ${epochNumber}`);
|
|
292
|
+
return header;
|
|
293
|
+
}
|
|
294
|
+
/** Extracted for testing purposes. */ doCreateEpochProvingJob(data, deadline, publicProcessorFactory) {
|
|
295
|
+
const { proverNodeMaxParallelBlocksPerEpoch: parallelBlockLimit } = this.config;
|
|
296
|
+
return new EpochProvingJob(data, this.worldState, this.prover.createEpochProver(), publicProcessorFactory, this.publisher, this.l2BlockSource, this.jobMetrics, deadline, {
|
|
297
|
+
parallelBlockLimit
|
|
252
298
|
});
|
|
253
299
|
}
|
|
254
300
|
/** Extracted for testing purposes. */ async triggerMonitors() {
|
|
255
301
|
await this.epochsMonitor.work();
|
|
256
302
|
}
|
|
303
|
+
validateConfig() {
|
|
304
|
+
if (this.config.proverNodeFailedEpochStore && (!this.config.dataDirectory || !this.config.l1ChainId || !this.config.rollupVersion)) {
|
|
305
|
+
this.log.warn(`Invalid prover-node config (missing dataDirectory, l1ChainId, or rollupVersion)`, pick(this.config, 'proverNodeFailedEpochStore', 'dataDirectory', 'l1ChainId', 'rollupVersion'));
|
|
306
|
+
throw new Error('All of dataDirectory, l1ChainId, and rollupVersion are required if proverNodeFailedEpochStore is set.');
|
|
307
|
+
}
|
|
308
|
+
}
|
|
257
309
|
}
|
|
258
310
|
_ts_decorate([
|
|
259
311
|
trackSpan('ProverNode.createProvingJob', (epochNumber)=>({
|
package/dest/test/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { EpochProverManager } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { EpochProvingJob } from '../job/epoch-proving-job.js';
|
|
2
3
|
import type { ProverNodePublisher } from '../prover-node-publisher.js';
|
|
3
4
|
import { ProverNode } from '../prover-node.js';
|
|
4
|
-
declare class
|
|
5
|
+
declare abstract class TestProverNodeClass extends ProverNode {
|
|
5
6
|
prover: EpochProverManager;
|
|
6
7
|
publisher: ProverNodePublisher;
|
|
8
|
+
abstract tryUploadEpochFailure(job: EpochProvingJob): Promise<string | undefined>;
|
|
7
9
|
}
|
|
8
|
-
export type TestProverNode =
|
|
10
|
+
export type TestProverNode = TestProverNodeClass;
|
|
9
11
|
export {};
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dest/test/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,uBAAe,mBAAoB,SAAQ,UAAU;IACpC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,mBAAmB,CAAC;aAErB,qBAAqB,CAAC,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;CAClG;AAED,MAAM,MAAM,cAAc,GAAG,mBAAmB,CAAC"}
|
package/dest/test/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-node",
|
|
3
|
-
"version": "0.85.0-alpha-testnet.
|
|
3
|
+
"version": "0.85.0-alpha-testnet.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -53,25 +53,25 @@
|
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@aztec/archiver": "0.85.0-alpha-testnet.
|
|
57
|
-
"@aztec/bb-prover": "0.85.0-alpha-testnet.
|
|
58
|
-
"@aztec/blob-sink": "0.85.0-alpha-testnet.
|
|
59
|
-
"@aztec/constants": "0.85.0-alpha-testnet.
|
|
60
|
-
"@aztec/epoch-cache": "0.85.0-alpha-testnet.
|
|
61
|
-
"@aztec/ethereum": "0.85.0-alpha-testnet.
|
|
62
|
-
"@aztec/foundation": "0.85.0-alpha-testnet.
|
|
63
|
-
"@aztec/kv-store": "0.85.0-alpha-testnet.
|
|
64
|
-
"@aztec/l1-artifacts": "0.85.0-alpha-testnet.
|
|
65
|
-
"@aztec/node-lib": "0.85.0-alpha-testnet.
|
|
66
|
-
"@aztec/noir-protocol-circuits-types": "0.85.0-alpha-testnet.
|
|
67
|
-
"@aztec/p2p": "0.85.0-alpha-testnet.
|
|
68
|
-
"@aztec/protocol-contracts": "0.85.0-alpha-testnet.
|
|
69
|
-
"@aztec/prover-client": "0.85.0-alpha-testnet.
|
|
70
|
-
"@aztec/sequencer-client": "0.85.0-alpha-testnet.
|
|
71
|
-
"@aztec/simulator": "0.85.0-alpha-testnet.
|
|
72
|
-
"@aztec/stdlib": "0.85.0-alpha-testnet.
|
|
73
|
-
"@aztec/telemetry-client": "0.85.0-alpha-testnet.
|
|
74
|
-
"@aztec/world-state": "0.85.0-alpha-testnet.
|
|
56
|
+
"@aztec/archiver": "0.85.0-alpha-testnet.3",
|
|
57
|
+
"@aztec/bb-prover": "0.85.0-alpha-testnet.3",
|
|
58
|
+
"@aztec/blob-sink": "0.85.0-alpha-testnet.3",
|
|
59
|
+
"@aztec/constants": "0.85.0-alpha-testnet.3",
|
|
60
|
+
"@aztec/epoch-cache": "0.85.0-alpha-testnet.3",
|
|
61
|
+
"@aztec/ethereum": "0.85.0-alpha-testnet.3",
|
|
62
|
+
"@aztec/foundation": "0.85.0-alpha-testnet.3",
|
|
63
|
+
"@aztec/kv-store": "0.85.0-alpha-testnet.3",
|
|
64
|
+
"@aztec/l1-artifacts": "0.85.0-alpha-testnet.3",
|
|
65
|
+
"@aztec/node-lib": "0.85.0-alpha-testnet.3",
|
|
66
|
+
"@aztec/noir-protocol-circuits-types": "0.85.0-alpha-testnet.3",
|
|
67
|
+
"@aztec/p2p": "0.85.0-alpha-testnet.3",
|
|
68
|
+
"@aztec/protocol-contracts": "0.85.0-alpha-testnet.3",
|
|
69
|
+
"@aztec/prover-client": "0.85.0-alpha-testnet.3",
|
|
70
|
+
"@aztec/sequencer-client": "0.85.0-alpha-testnet.3",
|
|
71
|
+
"@aztec/simulator": "0.85.0-alpha-testnet.3",
|
|
72
|
+
"@aztec/stdlib": "0.85.0-alpha-testnet.3",
|
|
73
|
+
"@aztec/telemetry-client": "0.85.0-alpha-testnet.3",
|
|
74
|
+
"@aztec/world-state": "0.85.0-alpha-testnet.3",
|
|
75
75
|
"source-map-support": "^0.5.21",
|
|
76
76
|
"tslib": "^2.4.0",
|
|
77
77
|
"viem": "2.23.7"
|