@aztec/prover-client 0.0.1-commit.b655e406 → 0.0.1-commit.b8a057fa
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/config.d.ts +2 -2
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +17 -3
- package/dest/index.d.ts +1 -1
- package/dest/light/index.d.ts +2 -0
- package/dest/light/index.d.ts.map +1 -0
- package/dest/light/index.js +1 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts +52 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +233 -0
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +9 -18
- package/dest/mocks/test_context.d.ts +38 -55
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +143 -142
- package/dest/orchestrator/block-building-helpers.d.ts +18 -20
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +90 -115
- package/dest/orchestrator/block-proving-state.d.ts +20 -11
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +87 -19
- package/dest/orchestrator/checkpoint-proving-state.d.ts +24 -27
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/checkpoint-proving-state.js +28 -94
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +161 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +1066 -0
- package/dest/orchestrator/chonk-cache.d.ts +39 -0
- package/dest/orchestrator/chonk-cache.d.ts.map +1 -0
- package/dest/orchestrator/chonk-cache.js +80 -0
- package/dest/orchestrator/index.d.ts +4 -2
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -15
- package/dest/orchestrator/proving-scheduler.d.ts +81 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +120 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +88 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +232 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts +61 -0
- package/dest/orchestrator/top-tree-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-state.js +185 -0
- package/dest/orchestrator/tx-proving-state.d.ts +7 -6
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +7 -16
- package/dest/prover-client/factory.d.ts +3 -3
- package/dest/prover-client/factory.d.ts.map +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +65 -8
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +66 -14
- package/dest/proving_broker/broker_prover_facade.d.ts +26 -24
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +21 -33
- package/dest/proving_broker/config.d.ts +14 -62
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +29 -6
- package/dest/proving_broker/factory.d.ts +1 -1
- package/dest/proving_broker/fixtures.d.ts +3 -2
- package/dest/proving_broker/fixtures.d.ts.map +1 -1
- package/dest/proving_broker/fixtures.js +3 -2
- package/dest/proving_broker/index.d.ts +2 -1
- package/dest/proving_broker/index.d.ts.map +1 -1
- package/dest/proving_broker/index.js +1 -0
- package/dest/proving_broker/proof_store/factory.d.ts +2 -5
- package/dest/proving_broker/proof_store/factory.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/factory.js +7 -30
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts +18 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.d.ts.map +1 -0
- package/dest/proving_broker/proof_store/file_store_proof_store.js +60 -0
- package/dest/proving_broker/proof_store/index.d.ts +2 -2
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
- package/dest/proving_broker/proving_agent.d.ts +5 -9
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +4 -19
- package/dest/proving_broker/proving_broker.d.ts +8 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +74 -22
- package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +394 -5
- package/dest/proving_broker/proving_broker_database.d.ts +3 -2
- package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts +3 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.js +22 -35
- package/dest/proving_broker/proving_job_controller.d.ts +5 -3
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +8 -6
- package/dest/proving_broker/rpc.d.ts +9 -5
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +87 -23
- package/dest/test/epoch_settlement.d.ts +36 -0
- package/dest/test/epoch_settlement.d.ts.map +1 -0
- package/dest/test/epoch_settlement.js +52 -0
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +1 -0
- package/dest/test/mock_proof_store.d.ts +1 -1
- package/dest/test/mock_proof_store.d.ts.map +1 -1
- package/dest/test/mock_prover.d.ts +5 -6
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +4 -4
- package/package.json +25 -23
- package/src/config.ts +19 -3
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +322 -0
- package/src/mocks/fixtures.ts +9 -31
- package/src/mocks/test_context.ts +182 -217
- package/src/orchestrator/block-building-helpers.ts +129 -209
- package/src/orchestrator/block-proving-state.ts +109 -22
- package/src/orchestrator/checkpoint-proving-state.ts +32 -123
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +1044 -0
- package/src/orchestrator/chonk-cache.ts +99 -0
- package/src/orchestrator/index.ts +8 -1
- package/src/orchestrator/orchestrator_metrics.ts +2 -25
- package/src/orchestrator/proving-scheduler.ts +160 -0
- package/src/orchestrator/top-tree-orchestrator.ts +384 -0
- package/src/orchestrator/top-tree-proving-state.ts +219 -0
- package/src/orchestrator/tx-proving-state.ts +10 -27
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +148 -29
- package/src/proving_broker/broker_prover_facade.ts +47 -56
- package/src/proving_broker/config.ts +33 -3
- package/src/proving_broker/fixtures.ts +8 -3
- package/src/proving_broker/index.ts +1 -0
- package/src/proving_broker/proof_store/factory.ts +10 -32
- package/src/proving_broker/proof_store/file_store_proof_store.ts +78 -0
- package/src/proving_broker/proof_store/index.ts +1 -1
- package/src/proving_broker/proving_agent.ts +6 -19
- package/src/proving_broker/proving_broker.ts +70 -17
- package/src/proving_broker/proving_broker_database/memory.ts +2 -1
- package/src/proving_broker/proving_broker_database/persisted.ts +22 -7
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_broker_instrumentation.ts +23 -35
- package/src/proving_broker/proving_job_controller.ts +13 -7
- package/src/proving_broker/rpc.ts +46 -20
- package/src/test/epoch_settlement.ts +82 -0
- package/src/test/index.ts +1 -0
- package/src/test/mock_prover.ts +3 -15
- package/dest/block-factory/index.d.ts +0 -2
- package/dest/block-factory/index.d.ts.map +0 -1
- package/dest/block-factory/index.js +0 -1
- package/dest/block-factory/light.d.ts +0 -38
- package/dest/block-factory/light.d.ts.map +0 -1
- package/dest/block-factory/light.js +0 -94
- package/dest/orchestrator/epoch-proving-state.d.ts +0 -73
- package/dest/orchestrator/epoch-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/epoch-proving-state.js +0 -233
- package/dest/orchestrator/orchestrator.d.ts +0 -113
- package/dest/orchestrator/orchestrator.d.ts.map +0 -1
- package/dest/orchestrator/orchestrator.js +0 -848
- package/dest/prover-client/server-epoch-prover.d.ts +0 -31
- package/dest/prover-client/server-epoch-prover.d.ts.map +0 -1
- package/dest/prover-client/server-epoch-prover.js +0 -40
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +0 -14
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +0 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +0 -52
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
- package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
- package/src/block-factory/index.ts +0 -1
- package/src/block-factory/light.ts +0 -140
- package/src/orchestrator/epoch-proving-state.ts +0 -328
- package/src/orchestrator/orchestrator.ts +0 -1272
- package/src/prover-client/server-epoch-prover.ts +0 -70
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -76
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
ForkMerkleTreeOperations,
|
|
3
|
+
ProvingJobBroker,
|
|
4
|
+
ReadonlyWorldStateAccess,
|
|
5
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
2
6
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
3
7
|
|
|
4
8
|
import type { ProverClientConfig } from '../config.js';
|
|
@@ -6,7 +10,7 @@ import { ProverClient } from './prover-client.js';
|
|
|
6
10
|
|
|
7
11
|
export function createProverClient(
|
|
8
12
|
config: ProverClientConfig,
|
|
9
|
-
worldState: ForkMerkleTreeOperations,
|
|
13
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
10
14
|
broker: ProvingJobBroker,
|
|
11
15
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
12
16
|
) {
|
|
@@ -1,52 +1,166 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
3
|
import { times } from '@aztec/foundation/collection';
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
6
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
7
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
8
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
9
|
import {
|
|
7
10
|
type ActualProverConfig,
|
|
8
|
-
type EpochProver,
|
|
9
11
|
type EpochProverManager,
|
|
10
12
|
type ForkMerkleTreeOperations,
|
|
11
13
|
type ProvingJobBroker,
|
|
12
14
|
type ProvingJobConsumer,
|
|
13
15
|
type ProvingJobProducer,
|
|
16
|
+
type ReadonlyWorldStateAccess,
|
|
14
17
|
type ServerCircuitProver,
|
|
15
18
|
tryStop,
|
|
16
19
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
21
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
17
22
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
18
23
|
|
|
19
24
|
import type { ProverClientConfig } from '../config.js';
|
|
20
|
-
import {
|
|
25
|
+
import { CheckpointSubTreeOrchestrator } from '../orchestrator/checkpoint-sub-tree-orchestrator.js';
|
|
26
|
+
import type { ChonkCache } from '../orchestrator/chonk-cache.js';
|
|
27
|
+
import { TopTreeOrchestrator } from '../orchestrator/top-tree-orchestrator.js';
|
|
21
28
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
22
29
|
import { InlineProofStore, type ProofStore, createProofStore } from '../proving_broker/proof_store/index.js';
|
|
23
30
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
24
|
-
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The factory surface that `EpochProvingJob` (in `prover-node`) depends on. Implemented
|
|
34
|
+
* by `ProverClient`. Defined here rather than in stdlib because the return types
|
|
35
|
+
* (`CheckpointSubTreeOrchestrator`, `TopTreeOrchestrator`) are concrete classes from
|
|
36
|
+
* this package.
|
|
37
|
+
*
|
|
38
|
+
* A single `BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
|
|
39
|
+
* every orchestrator (every sub-tree and every top-tree across every concurrent epoch
|
|
40
|
+
* job). The broker delivers each completed-job notification exactly once (drained on
|
|
41
|
+
* the first `getCompletedJobs` poll), so multiple facades polling the same broker
|
|
42
|
+
* race and lose notifications
|
|
43
|
+
*
|
|
44
|
+
* The facade's job map cleans up entries on resolve/reject, and the prover-node
|
|
45
|
+
* keeps `ProverClient` alive for its whole lifetime
|
|
46
|
+
*/
|
|
47
|
+
export interface EpochProverFactory {
|
|
48
|
+
getProverId(): EthAddress;
|
|
49
|
+
/**
|
|
50
|
+
* Constructs and starts a `CheckpointSubTreeOrchestrator` for a single checkpoint
|
|
51
|
+
* against the supplied shared `chonkCache`. The cache is owned by the prover-node
|
|
52
|
+
* and survives across epochs / sessions.
|
|
53
|
+
*/
|
|
54
|
+
createCheckpointSubTreeOrchestrator(
|
|
55
|
+
chonkCache: ChonkCache,
|
|
56
|
+
epochNumber: EpochNumber,
|
|
57
|
+
checkpointConstants: CheckpointConstantData,
|
|
58
|
+
l1ToL2Messages: Fr[],
|
|
59
|
+
totalNumBlocks: number,
|
|
60
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
61
|
+
): Promise<CheckpointSubTreeOrchestrator>;
|
|
62
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
63
|
+
}
|
|
25
64
|
|
|
26
65
|
/** Manages proving of epochs by orchestrating the proving of individual blocks relying on a pool of prover agents. */
|
|
27
|
-
export class ProverClient implements EpochProverManager {
|
|
66
|
+
export class ProverClient implements EpochProverManager, EpochProverFactory {
|
|
28
67
|
private running = false;
|
|
29
68
|
private agents: ProvingAgent[] = [];
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
69
|
+
/**
|
|
70
|
+
* The single broker facade shared by every orchestrator created from this client.
|
|
71
|
+
* Constructed lazily on `start()` and torn down on `stop()` — see the comment on
|
|
72
|
+
* `EpochProverFactory` for why a single shared facade is required.
|
|
73
|
+
*/
|
|
74
|
+
private facade: BrokerCircuitProverFacade | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Single deferred-proving-job queue shared across every orchestrator (sub-trees and
|
|
77
|
+
* top-trees, across every concurrent epoch session). Throttles the total rate of job
|
|
78
|
+
* submission to the broker once, rather than once per orchestrator. Started lazily
|
|
79
|
+
* alongside the facade and cancelled on `stop()`.
|
|
80
|
+
*/
|
|
81
|
+
private deferredJobQueue: SerialQueue | undefined;
|
|
33
82
|
|
|
34
83
|
private constructor(
|
|
35
84
|
private config: ProverClientConfig,
|
|
36
|
-
private worldState: ForkMerkleTreeOperations,
|
|
85
|
+
private worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
37
86
|
private orchestratorClient: ProvingJobProducer,
|
|
87
|
+
private proofStore: ProofStore,
|
|
88
|
+
private failedProofStore: ProofStore | undefined,
|
|
38
89
|
private agentClient?: ProvingJobConsumer,
|
|
39
90
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
40
|
-
private log = createLogger('prover-client:tx-prover'),
|
|
41
|
-
) {
|
|
42
|
-
|
|
43
|
-
|
|
91
|
+
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
92
|
+
) {}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Lazy-init the shared facade. The broker delivers each completed-job notification
|
|
96
|
+
* exactly once (drained on the first `getCompletedJobs` poll), so we cannot start
|
|
97
|
+
* a shared facade alongside the per-call facades that `createEpochProver` builds —
|
|
98
|
+
* they would race for notifications and one side would silently drop them. Starting
|
|
99
|
+
* the shared facade only on first use of one of the new factory methods keeps the
|
|
100
|
+
* legacy `createEpochProver` path race-free.
|
|
101
|
+
*/
|
|
102
|
+
private getFacade(): BrokerCircuitProverFacade {
|
|
103
|
+
if (!this.running) {
|
|
104
|
+
throw new Error('ProverClient is not running; call start() before constructing orchestrators.');
|
|
105
|
+
}
|
|
106
|
+
if (!this.facade) {
|
|
107
|
+
this.facade = new BrokerCircuitProverFacade(
|
|
108
|
+
this.orchestratorClient,
|
|
109
|
+
this.proofStore,
|
|
110
|
+
this.failedProofStore,
|
|
111
|
+
undefined,
|
|
112
|
+
this.log.getBindings(),
|
|
113
|
+
);
|
|
114
|
+
this.facade.start();
|
|
115
|
+
}
|
|
116
|
+
return this.facade;
|
|
44
117
|
}
|
|
45
118
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
119
|
+
/** Lazy-init the shared deferred-job queue, started with the configured enqueue concurrency. */
|
|
120
|
+
private getDeferredJobQueue(): SerialQueue {
|
|
121
|
+
if (!this.running) {
|
|
122
|
+
throw new Error('ProverClient is not running; call start() before constructing orchestrators.');
|
|
123
|
+
}
|
|
124
|
+
if (!this.deferredJobQueue) {
|
|
125
|
+
this.deferredJobQueue = new SerialQueue();
|
|
126
|
+
this.deferredJobQueue.start(this.config.enqueueConcurrency);
|
|
127
|
+
}
|
|
128
|
+
return this.deferredJobQueue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public createCheckpointSubTreeOrchestrator(
|
|
132
|
+
chonkCache: ChonkCache,
|
|
133
|
+
epochNumber: EpochNumber,
|
|
134
|
+
checkpointConstants: CheckpointConstantData,
|
|
135
|
+
l1ToL2Messages: Fr[],
|
|
136
|
+
totalNumBlocks: number,
|
|
137
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
138
|
+
): Promise<CheckpointSubTreeOrchestrator> {
|
|
139
|
+
return CheckpointSubTreeOrchestrator.start(
|
|
140
|
+
this.worldState,
|
|
141
|
+
this.getFacade(),
|
|
142
|
+
this.config.proverId,
|
|
143
|
+
chonkCache,
|
|
144
|
+
epochNumber,
|
|
145
|
+
this.config.cancelJobsOnStop,
|
|
146
|
+
this.getDeferredJobQueue(),
|
|
147
|
+
checkpointConstants,
|
|
148
|
+
l1ToL2Messages,
|
|
149
|
+
totalNumBlocks,
|
|
150
|
+
headerOfLastBlockInPreviousCheckpoint,
|
|
151
|
+
this.telemetry,
|
|
152
|
+
this.log.getBindings(),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
public createTopTreeOrchestrator(): TopTreeOrchestrator {
|
|
157
|
+
return new TopTreeOrchestrator(
|
|
158
|
+
this.getFacade(),
|
|
159
|
+
this.config.proverId,
|
|
160
|
+
this.getDeferredJobQueue(),
|
|
161
|
+
this.telemetry,
|
|
162
|
+
this.log.getBindings(),
|
|
163
|
+
);
|
|
50
164
|
}
|
|
51
165
|
|
|
52
166
|
public getProverId(): EthAddress {
|
|
@@ -88,6 +202,14 @@ export class ProverClient implements EpochProverManager {
|
|
|
88
202
|
}
|
|
89
203
|
this.running = false;
|
|
90
204
|
await this.stopAgents();
|
|
205
|
+
if (this.deferredJobQueue) {
|
|
206
|
+
await this.deferredJobQueue.cancel();
|
|
207
|
+
this.deferredJobQueue = undefined;
|
|
208
|
+
}
|
|
209
|
+
if (this.facade) {
|
|
210
|
+
await tryStop(this.facade, this.log);
|
|
211
|
+
this.facade = undefined;
|
|
212
|
+
}
|
|
91
213
|
await tryStop(this.orchestratorClient);
|
|
92
214
|
}
|
|
93
215
|
|
|
@@ -99,11 +221,13 @@ export class ProverClient implements EpochProverManager {
|
|
|
99
221
|
*/
|
|
100
222
|
public static async new(
|
|
101
223
|
config: ProverClientConfig,
|
|
102
|
-
worldState: ForkMerkleTreeOperations,
|
|
224
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
103
225
|
broker: ProvingJobBroker,
|
|
104
226
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
105
227
|
) {
|
|
106
|
-
const
|
|
228
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
229
|
+
const failedProofStore = config.failedProofStore ? await createProofStore(config.failedProofStore) : undefined;
|
|
230
|
+
const prover = new ProverClient(config, worldState, broker, proofStore, failedProofStore, broker, telemetry);
|
|
107
231
|
await prover.start();
|
|
108
232
|
return prover;
|
|
109
233
|
}
|
|
@@ -127,17 +251,11 @@ export class ProverClient implements EpochProverManager {
|
|
|
127
251
|
|
|
128
252
|
const proofStore = new InlineProofStore();
|
|
129
253
|
const prover = await buildServerCircuitProver(this.config, this.telemetry);
|
|
254
|
+
const bindings = this.log.getBindings();
|
|
130
255
|
this.agents = times(
|
|
131
256
|
this.config.proverAgentCount,
|
|
132
257
|
() =>
|
|
133
|
-
new ProvingAgent(
|
|
134
|
-
this.agentClient!,
|
|
135
|
-
proofStore,
|
|
136
|
-
prover,
|
|
137
|
-
[],
|
|
138
|
-
this.config.proverAgentPollIntervalMs,
|
|
139
|
-
this.telemetry,
|
|
140
|
-
),
|
|
258
|
+
new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
|
|
141
259
|
);
|
|
142
260
|
|
|
143
261
|
await Promise.all(this.agents.map(agent => agent.start()));
|
|
@@ -149,15 +267,16 @@ export class ProverClient implements EpochProverManager {
|
|
|
149
267
|
}
|
|
150
268
|
|
|
151
269
|
export function buildServerCircuitProver(
|
|
152
|
-
config: ActualProverConfig & ACVMConfig & BBConfig,
|
|
270
|
+
config: Omit<ActualProverConfig, 'enqueueConcurrency'> & ACVMConfig & BBConfig,
|
|
153
271
|
telemetry: TelemetryClient,
|
|
154
272
|
): Promise<ServerCircuitProver> {
|
|
155
273
|
if (config.realProofs) {
|
|
156
274
|
return BBNativeRollupProver.new(config, telemetry);
|
|
157
275
|
}
|
|
158
276
|
|
|
277
|
+
const logger = createLogger('prover-client:acvm-native');
|
|
159
278
|
const simulator = config.acvmBinaryPath
|
|
160
|
-
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath)
|
|
279
|
+
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
|
|
161
280
|
: undefined;
|
|
162
281
|
|
|
163
282
|
return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
2
|
+
AVM_V2_PROOF_LENGTH_IN_FIELDS,
|
|
3
3
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
4
4
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
5
5
|
RECURSIVE_PROOF_LENGTH,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
8
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
9
|
+
import { chunk } from '@aztec/foundation/collection';
|
|
10
|
+
import { type Logger, type LoggerBindings, createLogger } from '@aztec/foundation/log';
|
|
10
11
|
import { type PromiseWithResolvers, RunningPromise, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
11
12
|
import { truncate } from '@aztec/foundation/string';
|
|
12
13
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
13
14
|
import {
|
|
14
|
-
type ProofAndVerificationKey,
|
|
15
15
|
type ProofUri,
|
|
16
16
|
type ProvingJobId,
|
|
17
17
|
type ProvingJobInputsMap,
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
makeProvingJobId,
|
|
24
24
|
} from '@aztec/stdlib/interfaces/server';
|
|
25
25
|
import type { ParityBasePrivateInputs, ParityPublicInputs, ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
26
|
-
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
26
|
+
import { ProvingRequestType, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
27
27
|
import type {
|
|
28
28
|
BlockMergeRollupPrivateInputs,
|
|
29
29
|
BlockRollupPublicInputs,
|
|
@@ -47,6 +47,8 @@ import type {
|
|
|
47
47
|
TxRollupPublicInputs,
|
|
48
48
|
} from '@aztec/stdlib/rollup';
|
|
49
49
|
|
|
50
|
+
import { createHash } from 'node:crypto';
|
|
51
|
+
|
|
50
52
|
import { InlineProofStore, type ProofStore } from './proof_store/index.js';
|
|
51
53
|
|
|
52
54
|
// Perform a snapshot sync every 30 seconds
|
|
@@ -69,14 +71,17 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
69
71
|
private runningPromise?: RunningPromise;
|
|
70
72
|
private timeOfLastSnapshotSync = Date.now();
|
|
71
73
|
private jobsToRetrieve: Set<ProvingJobId> = new Set();
|
|
74
|
+
private log: Logger;
|
|
72
75
|
|
|
73
76
|
constructor(
|
|
74
77
|
private broker: ProvingJobProducer,
|
|
75
78
|
private proofStore: ProofStore = new InlineProofStore(),
|
|
76
79
|
private failedProofStore?: ProofStore,
|
|
77
80
|
private pollIntervalMs = 1000,
|
|
78
|
-
|
|
79
|
-
) {
|
|
81
|
+
bindings?: LoggerBindings,
|
|
82
|
+
) {
|
|
83
|
+
this.log = createLogger('prover-client:broker-circuit-prover-facade', bindings);
|
|
84
|
+
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
87
|
* This is a critical section. This function can not be async since it writes
|
|
@@ -130,7 +135,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
130
135
|
id: ProvingJobId,
|
|
131
136
|
type: T,
|
|
132
137
|
inputs: ProvingJobInputsMap[T],
|
|
133
|
-
epochNumber =
|
|
138
|
+
epochNumber = EpochNumber.ZERO,
|
|
134
139
|
signal?: AbortSignal,
|
|
135
140
|
): Promise<ProvingJobResultsMap[T]> {
|
|
136
141
|
const { job: job, isEnqueued } = this.getOrCreateProvingJob(id, type, signal);
|
|
@@ -223,17 +228,11 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
223
228
|
// We collect all returned notifications and return them
|
|
224
229
|
const allCompleted = new Set<ProvingJobId>();
|
|
225
230
|
try {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
const completed = await this.broker.getCompletedJobs(slice);
|
|
231
|
+
const batches = ids.length > 0 ? chunk(ids, SNAPSHOT_SYNC_CHECK_MAX_REQUEST_SIZE) : [[]];
|
|
232
|
+
await asyncPool(1, batches, async batch => {
|
|
233
|
+
const completed = await this.broker.getCompletedJobs(batch);
|
|
230
234
|
completed.forEach(id => allCompleted.add(id));
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
if (numRequests === 0) {
|
|
234
|
-
const final = await this.broker.getCompletedJobs([]);
|
|
235
|
-
final.forEach(id => allCompleted.add(id));
|
|
236
|
-
}
|
|
235
|
+
});
|
|
237
236
|
} catch (err) {
|
|
238
237
|
this.log.error(`Error thrown when requesting completed job notifications from the broker`, err);
|
|
239
238
|
}
|
|
@@ -349,12 +348,8 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
349
348
|
.map(id => this.jobs.get(id)!)
|
|
350
349
|
.filter(x => x !== undefined);
|
|
351
350
|
const totalJobsToRetrieve = toBeRetrieved.length;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
const slice = toBeRetrieved.splice(0, MAX_CONCURRENT_JOB_SETTLED_REQUESTS);
|
|
355
|
-
const results = await Promise.all(slice.map(job => processJob(job!)));
|
|
356
|
-
totalJobsRetrieved += results.filter(x => x).length;
|
|
357
|
-
}
|
|
351
|
+
const results = await asyncPool(MAX_CONCURRENT_JOB_SETTLED_REQUESTS, toBeRetrieved, job => processJob(job));
|
|
352
|
+
const totalJobsRetrieved = results.filter(x => x).length;
|
|
358
353
|
if (totalJobsToRetrieve > 0) {
|
|
359
354
|
this.log.verbose(
|
|
360
355
|
`Successfully retrieved ${totalJobsRetrieved} of ${totalJobsToRetrieve} jobs that should be ready, total ready jobs is now: ${this.jobsToRetrieve.size}`,
|
|
@@ -397,30 +392,22 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
397
392
|
|
|
398
393
|
getAvmProof(
|
|
399
394
|
inputs: AvmCircuitInputs,
|
|
400
|
-
skipPublicInputsValidation?: boolean, // TODO(#14234)[Unconditional PIs validation]: remove this argument
|
|
401
395
|
signal?: AbortSignal,
|
|
402
|
-
epochNumber?:
|
|
403
|
-
): Promise<
|
|
404
|
-
this.log.info(`getAvmProof() called with skipPublicInputsValidation: ${skipPublicInputsValidation}`);
|
|
405
|
-
|
|
396
|
+
epochNumber?: EpochNumber,
|
|
397
|
+
): Promise<RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS>> {
|
|
406
398
|
return this.enqueueJob(
|
|
407
399
|
this.generateId(ProvingRequestType.PUBLIC_VM, inputs, epochNumber),
|
|
408
400
|
ProvingRequestType.PUBLIC_VM,
|
|
409
401
|
inputs,
|
|
410
402
|
epochNumber,
|
|
411
403
|
signal,
|
|
412
|
-
)
|
|
413
|
-
// TODO(#14234)[Unconditional PIs validation]: Remove ".then()".
|
|
414
|
-
// Override the default value of skipPublicInputsValidation potentially set in BBNativeRollupProver.getAvmProof().
|
|
415
|
-
result.proof.proof[0] = skipPublicInputsValidation ? new Fr(1) : new Fr(0);
|
|
416
|
-
return result;
|
|
417
|
-
});
|
|
404
|
+
);
|
|
418
405
|
}
|
|
419
406
|
|
|
420
407
|
getBaseParityProof(
|
|
421
408
|
inputs: ParityBasePrivateInputs,
|
|
422
409
|
signal?: AbortSignal,
|
|
423
|
-
epochNumber?:
|
|
410
|
+
epochNumber?: EpochNumber,
|
|
424
411
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
425
412
|
return this.enqueueJob(
|
|
426
413
|
this.generateId(ProvingRequestType.PARITY_BASE, inputs, epochNumber),
|
|
@@ -434,7 +421,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
434
421
|
getTxMergeRollupProof(
|
|
435
422
|
input: TxMergeRollupPrivateInputs,
|
|
436
423
|
signal?: AbortSignal,
|
|
437
|
-
epochNumber?:
|
|
424
|
+
epochNumber?: EpochNumber,
|
|
438
425
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
439
426
|
return this.enqueueJob(
|
|
440
427
|
this.generateId(ProvingRequestType.TX_MERGE_ROLLUP, input, epochNumber),
|
|
@@ -448,7 +435,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
448
435
|
getPublicChonkVerifierProof(
|
|
449
436
|
inputs: PublicChonkVerifierPrivateInputs,
|
|
450
437
|
signal?: AbortSignal,
|
|
451
|
-
epochNumber?:
|
|
438
|
+
epochNumber?: EpochNumber,
|
|
452
439
|
): Promise<
|
|
453
440
|
PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
454
441
|
> {
|
|
@@ -464,7 +451,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
464
451
|
getPrivateTxBaseRollupProof(
|
|
465
452
|
baseRollupInput: PrivateTxBaseRollupPrivateInputs,
|
|
466
453
|
signal?: AbortSignal,
|
|
467
|
-
epochNumber?:
|
|
454
|
+
epochNumber?: EpochNumber,
|
|
468
455
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
469
456
|
return this.enqueueJob(
|
|
470
457
|
this.generateId(ProvingRequestType.PRIVATE_TX_BASE_ROLLUP, baseRollupInput, epochNumber),
|
|
@@ -478,7 +465,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
478
465
|
getPublicTxBaseRollupProof(
|
|
479
466
|
inputs: PublicTxBaseRollupPrivateInputs,
|
|
480
467
|
signal?: AbortSignal,
|
|
481
|
-
epochNumber?:
|
|
468
|
+
epochNumber?: EpochNumber,
|
|
482
469
|
): Promise<PublicInputsAndRecursiveProof<TxRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
483
470
|
return this.enqueueJob(
|
|
484
471
|
this.generateId(ProvingRequestType.PUBLIC_TX_BASE_ROLLUP, inputs, epochNumber),
|
|
@@ -492,7 +479,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
492
479
|
getRootParityProof(
|
|
493
480
|
inputs: ParityRootPrivateInputs,
|
|
494
481
|
signal?: AbortSignal,
|
|
495
|
-
epochNumber?:
|
|
482
|
+
epochNumber?: EpochNumber,
|
|
496
483
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
497
484
|
return this.enqueueJob(
|
|
498
485
|
this.generateId(ProvingRequestType.PARITY_ROOT, inputs, epochNumber),
|
|
@@ -506,7 +493,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
506
493
|
getBlockRootFirstRollupProof(
|
|
507
494
|
input: BlockRootFirstRollupPrivateInputs,
|
|
508
495
|
signal?: AbortSignal,
|
|
509
|
-
epochNumber?:
|
|
496
|
+
epochNumber?: EpochNumber,
|
|
510
497
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
511
498
|
return this.enqueueJob(
|
|
512
499
|
this.generateId(ProvingRequestType.BLOCK_ROOT_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -520,7 +507,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
520
507
|
getBlockRootSingleTxFirstRollupProof(
|
|
521
508
|
input: BlockRootSingleTxFirstRollupPrivateInputs,
|
|
522
509
|
signal?: AbortSignal,
|
|
523
|
-
epochNumber?:
|
|
510
|
+
epochNumber?: EpochNumber,
|
|
524
511
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
525
512
|
return this.enqueueJob(
|
|
526
513
|
this.generateId(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -534,7 +521,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
534
521
|
getBlockRootEmptyTxFirstRollupProof(
|
|
535
522
|
input: BlockRootEmptyTxFirstRollupPrivateInputs,
|
|
536
523
|
signal?: AbortSignal,
|
|
537
|
-
epochNumber?:
|
|
524
|
+
epochNumber?: EpochNumber,
|
|
538
525
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
539
526
|
return this.enqueueJob(
|
|
540
527
|
this.generateId(ProvingRequestType.BLOCK_ROOT_EMPTY_TX_FIRST_ROLLUP, input, epochNumber),
|
|
@@ -548,7 +535,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
548
535
|
getBlockRootRollupProof(
|
|
549
536
|
input: BlockRootRollupPrivateInputs,
|
|
550
537
|
signal?: AbortSignal,
|
|
551
|
-
epochNumber?:
|
|
538
|
+
epochNumber?: EpochNumber,
|
|
552
539
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
553
540
|
return this.enqueueJob(
|
|
554
541
|
this.generateId(ProvingRequestType.BLOCK_ROOT_ROLLUP, input, epochNumber),
|
|
@@ -562,7 +549,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
562
549
|
getBlockRootSingleTxRollupProof(
|
|
563
550
|
input: BlockRootSingleTxRollupPrivateInputs,
|
|
564
551
|
signal?: AbortSignal,
|
|
565
|
-
epochNumber?:
|
|
552
|
+
epochNumber?: EpochNumber,
|
|
566
553
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
567
554
|
return this.enqueueJob(
|
|
568
555
|
this.generateId(ProvingRequestType.BLOCK_ROOT_SINGLE_TX_ROLLUP, input, epochNumber),
|
|
@@ -576,7 +563,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
576
563
|
getBlockMergeRollupProof(
|
|
577
564
|
input: BlockMergeRollupPrivateInputs,
|
|
578
565
|
signal?: AbortSignal,
|
|
579
|
-
epochNumber?:
|
|
566
|
+
epochNumber?: EpochNumber,
|
|
580
567
|
): Promise<PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>> {
|
|
581
568
|
return this.enqueueJob(
|
|
582
569
|
this.generateId(ProvingRequestType.BLOCK_MERGE_ROLLUP, input, epochNumber),
|
|
@@ -590,7 +577,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
590
577
|
getCheckpointRootRollupProof(
|
|
591
578
|
input: CheckpointRootRollupPrivateInputs,
|
|
592
579
|
signal?: AbortSignal,
|
|
593
|
-
epochNumber?:
|
|
580
|
+
epochNumber?: EpochNumber,
|
|
594
581
|
): Promise<
|
|
595
582
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
596
583
|
> {
|
|
@@ -606,7 +593,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
606
593
|
getCheckpointRootSingleBlockRollupProof(
|
|
607
594
|
input: CheckpointRootSingleBlockRollupPrivateInputs,
|
|
608
595
|
signal?: AbortSignal,
|
|
609
|
-
epochNumber?:
|
|
596
|
+
epochNumber?: EpochNumber,
|
|
610
597
|
): Promise<
|
|
611
598
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
612
599
|
> {
|
|
@@ -622,7 +609,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
622
609
|
getCheckpointPaddingRollupProof(
|
|
623
610
|
input: CheckpointPaddingRollupPrivateInputs,
|
|
624
611
|
signal?: AbortSignal,
|
|
625
|
-
epochNumber?:
|
|
612
|
+
epochNumber?: EpochNumber,
|
|
626
613
|
): Promise<
|
|
627
614
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
628
615
|
> {
|
|
@@ -638,7 +625,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
638
625
|
getCheckpointMergeRollupProof(
|
|
639
626
|
input: CheckpointMergeRollupPrivateInputs,
|
|
640
627
|
signal?: AbortSignal,
|
|
641
|
-
epochNumber?:
|
|
628
|
+
epochNumber?: EpochNumber,
|
|
642
629
|
): Promise<
|
|
643
630
|
PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
644
631
|
> {
|
|
@@ -654,7 +641,7 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
654
641
|
getRootRollupProof(
|
|
655
642
|
input: RootRollupPrivateInputs,
|
|
656
643
|
signal?: AbortSignal,
|
|
657
|
-
epochNumber?:
|
|
644
|
+
epochNumber?: EpochNumber,
|
|
658
645
|
): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
659
646
|
return this.enqueueJob(
|
|
660
647
|
this.generateId(ProvingRequestType.ROOT_ROLLUP, input, epochNumber),
|
|
@@ -665,8 +652,12 @@ export class BrokerCircuitProverFacade implements ServerCircuitProver {
|
|
|
665
652
|
);
|
|
666
653
|
}
|
|
667
654
|
|
|
668
|
-
private generateId(
|
|
669
|
-
|
|
670
|
-
|
|
655
|
+
private generateId(
|
|
656
|
+
type: ProvingRequestType,
|
|
657
|
+
inputs: { toBuffer(): Buffer },
|
|
658
|
+
epochNumber = EpochNumber.ZERO,
|
|
659
|
+
): ProvingJobId {
|
|
660
|
+
const inputsHash = createHash('sha256').update(inputs.toBuffer()).digest('hex');
|
|
661
|
+
return makeProvingJobId(epochNumber, type, inputsHash);
|
|
671
662
|
}
|
|
672
663
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
1
|
+
import { type L1ReaderConfig, l1ReaderConfigMappings } from '@aztec/ethereum/l1-reader';
|
|
2
2
|
import {
|
|
3
3
|
type ConfigMappingsType,
|
|
4
4
|
booleanConfigHelper,
|
|
5
5
|
getDefaultConfig,
|
|
6
6
|
numberConfigHelper,
|
|
7
|
+
optionalNumberConfigHelper,
|
|
7
8
|
} from '@aztec/foundation/config';
|
|
8
9
|
import { pickConfigMappings } from '@aztec/foundation/config';
|
|
9
|
-
import { type DataStoreConfig, dataConfigMappings } from '@aztec/kv-store/config';
|
|
10
10
|
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
|
|
11
|
+
import { type DataStoreConfig, dataConfigMappings } from '@aztec/stdlib/kv-store';
|
|
11
12
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
12
13
|
|
|
13
14
|
import { z } from 'zod';
|
|
@@ -31,6 +32,8 @@ export const ProverBrokerConfig = z.object({
|
|
|
31
32
|
proverBrokerBatchIntervalMs: z.number().int().nonnegative(),
|
|
32
33
|
/** The maximum number of epochs to keep results for */
|
|
33
34
|
proverBrokerMaxEpochsToKeepResultsFor: z.number().int().nonnegative(),
|
|
35
|
+
/** Enable debug replay mode for replaying proving jobs from stored inputs */
|
|
36
|
+
proverBrokerDebugReplayEnabled: z.boolean(),
|
|
34
37
|
});
|
|
35
38
|
|
|
36
39
|
export type ProverBrokerConfig = z.infer<typeof ProverBrokerConfig> &
|
|
@@ -71,9 +74,14 @@ export const proverBrokerConfigMappings: ConfigMappingsType<ProverBrokerConfig>
|
|
|
71
74
|
},
|
|
72
75
|
proverBrokerStoreMapSizeKb: {
|
|
73
76
|
env: 'PROVER_BROKER_STORE_MAP_SIZE_KB',
|
|
74
|
-
|
|
77
|
+
...optionalNumberConfigHelper(),
|
|
75
78
|
description: "The size of the prover broker's database. Will override the dataStoreMapSizeKb if set.",
|
|
76
79
|
},
|
|
80
|
+
proverBrokerDebugReplayEnabled: {
|
|
81
|
+
env: 'PROVER_BROKER_DEBUG_REPLAY_ENABLED',
|
|
82
|
+
description: 'Enable debug replay mode for replaying proving jobs from stored inputs',
|
|
83
|
+
...booleanConfigHelper(false),
|
|
84
|
+
},
|
|
77
85
|
...dataConfigMappings,
|
|
78
86
|
...l1ReaderConfigMappings,
|
|
79
87
|
...pickConfigMappings(chainConfigMappings, ['rollupVersion']),
|
|
@@ -98,6 +106,12 @@ export const ProverAgentConfig = z.object({
|
|
|
98
106
|
proverTestDelayMs: z.number(),
|
|
99
107
|
/** If using realistic delays, what percentage of realistic times to apply. */
|
|
100
108
|
proverTestDelayFactor: z.number(),
|
|
109
|
+
/** The delay (ms) to inject during fake proof verification */
|
|
110
|
+
proverTestVerificationDelayMs: z.number().optional(),
|
|
111
|
+
/** Whether to abort pending proving jobs when the orchestrator is cancelled */
|
|
112
|
+
cancelJobsOnStop: z.boolean(),
|
|
113
|
+
/** Where to store proving results. Must be accessible to both prover node and agents. If not set will inline-encode the parameters */
|
|
114
|
+
proofStore: z.string().optional(),
|
|
101
115
|
});
|
|
102
116
|
|
|
103
117
|
export type ProverAgentConfig = z.infer<typeof ProverAgentConfig>;
|
|
@@ -146,4 +160,20 @@ export const proverAgentConfigMappings: ConfigMappingsType<ProverAgentConfig> =
|
|
|
146
160
|
description: 'If using realistic delays, what percentage of realistic times to apply.',
|
|
147
161
|
...numberConfigHelper(1),
|
|
148
162
|
},
|
|
163
|
+
proverTestVerificationDelayMs: {
|
|
164
|
+
env: 'PROVER_TEST_VERIFICATION_DELAY_MS',
|
|
165
|
+
description: 'The delay (ms) to inject during fake proof verification',
|
|
166
|
+
...numberConfigHelper(10),
|
|
167
|
+
},
|
|
168
|
+
cancelJobsOnStop: {
|
|
169
|
+
env: 'PROVER_CANCEL_JOBS_ON_STOP',
|
|
170
|
+
description:
|
|
171
|
+
'Whether to abort pending proving jobs when the orchestrator is cancelled. ' +
|
|
172
|
+
'When false (default), jobs remain in the broker queue and can be reused on restart/reorg.',
|
|
173
|
+
...booleanConfigHelper(false),
|
|
174
|
+
},
|
|
175
|
+
proofStore: {
|
|
176
|
+
env: 'PROVER_PROOF_STORE',
|
|
177
|
+
description: 'Optional proof input store for the prover',
|
|
178
|
+
},
|
|
149
179
|
};
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { randomBytes } from '@aztec/foundation/crypto/random';
|
|
2
3
|
import { type ProofUri, type ProvingJobId, makeProvingJobId } from '@aztec/stdlib/interfaces/server';
|
|
3
4
|
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
4
5
|
|
|
5
|
-
export function makeRandomProvingJobId(epochNumber?:
|
|
6
|
-
return makeProvingJobId(
|
|
6
|
+
export function makeRandomProvingJobId(epochNumber?: EpochNumber): ProvingJobId {
|
|
7
|
+
return makeProvingJobId(
|
|
8
|
+
epochNumber ?? EpochNumber(1),
|
|
9
|
+
ProvingRequestType.PARITY_BASE,
|
|
10
|
+
randomBytes(8).toString('hex'),
|
|
11
|
+
);
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
export function makeInputsUri(): ProofUri {
|