@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.017a351
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 +8 -8
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -2
- 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 +231 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +36 -17
- package/dest/mocks/test_context.d.ts +45 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +162 -90
- package/dest/orchestrator/block-building-helpers.d.ts +36 -29
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +170 -189
- package/dest/orchestrator/block-proving-state.d.ts +73 -48
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +289 -177
- package/dest/orchestrator/checkpoint-proving-state.d.ts +83 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +252 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts +107 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-sub-tree-orchestrator.js +151 -0
- package/dest/orchestrator/epoch-proving-context.d.ts +51 -0
- package/dest/orchestrator/epoch-proving-context.d.ts.map +1 -0
- package/dest/orchestrator/epoch-proving-context.js +81 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +43 -28
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +179 -73
- package/dest/orchestrator/index.d.ts +4 -1
- package/dest/orchestrator/index.d.ts.map +1 -1
- package/dest/orchestrator/index.js +3 -0
- package/dest/orchestrator/orchestrator.d.ts +59 -51
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +808 -385
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +2 -6
- package/dest/orchestrator/proving-scheduler.d.ts +72 -0
- package/dest/orchestrator/proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/proving-scheduler.js +117 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts +83 -0
- package/dest/orchestrator/top-tree-orchestrator.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-orchestrator.js +182 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts +62 -0
- package/dest/orchestrator/top-tree-proving-scheduler.d.ts.map +1 -0
- package/dest/orchestrator/top-tree-proving-scheduler.js +73 -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 +15 -12
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +27 -44
- 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 +68 -9
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +68 -14
- package/dest/prover-client/server-epoch-prover.d.ts +16 -12
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +11 -11
- package/dest/proving_broker/broker_prover_facade.d.ts +28 -19
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +74 -61
- package/dest/proving_broker/config.d.ts +18 -61
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +43 -9
- package/dest/proving_broker/factory.d.ts +2 -2
- package/dest/proving_broker/factory.d.ts.map +1 -1
- package/dest/proving_broker/factory.js +5 -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 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +1 -0
- 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 +8 -12
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +86 -65
- package/dest/proving_broker/proving_broker.d.ts +18 -6
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +108 -44
- 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/memory.js +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 +401 -11
- 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 +11 -10
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +92 -62
- package/dest/proving_broker/rpc.d.ts +9 -7
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +88 -27
- package/dest/test/mock_proof_store.d.ts +9 -0
- package/dest/test/mock_proof_store.d.ts.map +1 -0
- package/dest/test/mock_proof_store.js +10 -0
- package/dest/test/mock_prover.d.ts +23 -17
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +38 -20
- package/package.json +34 -33
- package/src/config.ts +41 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +320 -0
- package/src/mocks/fixtures.ts +46 -40
- package/src/mocks/test_context.ts +231 -120
- package/src/orchestrator/block-building-helpers.ts +258 -334
- package/src/orchestrator/block-proving-state.ts +334 -231
- package/src/orchestrator/checkpoint-proving-state.ts +362 -0
- package/src/orchestrator/checkpoint-sub-tree-orchestrator.ts +271 -0
- package/src/orchestrator/epoch-proving-context.ts +101 -0
- package/src/orchestrator/epoch-proving-state.ts +239 -111
- package/src/orchestrator/index.ts +8 -0
- package/src/orchestrator/orchestrator.ts +591 -451
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/proving-scheduler.ts +156 -0
- package/src/orchestrator/top-tree-orchestrator.ts +314 -0
- package/src/orchestrator/top-tree-proving-scheduler.ts +154 -0
- package/src/orchestrator/top-tree-proving-state.ts +220 -0
- package/src/orchestrator/tx-proving-state.ts +48 -66
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +173 -38
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +227 -149
- package/src/proving_broker/config.ts +49 -8
- package/src/proving_broker/factory.ts +2 -1
- 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 -0
- package/src/proving_broker/proof_store/inline_proof_store.ts +1 -1
- package/src/proving_broker/proving_agent.ts +95 -66
- package/src/proving_broker/proving_broker.ts +121 -49
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +31 -15
- 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 +100 -83
- package/src/proving_broker/rpc.ts +46 -25
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +156 -64
- package/dest/bin/get-proof-inputs.d.ts +0 -2
- package/dest/bin/get-proof-inputs.d.ts.map +0 -1
- package/dest/bin/get-proof-inputs.js +0 -51
- package/dest/block_builder/index.d.ts +0 -6
- package/dest/block_builder/index.d.ts.map +0 -1
- package/dest/block_builder/index.js +0 -1
- package/dest/block_builder/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- 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 -51
- 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/bin/get-proof-inputs.ts +0 -59
- package/src/block_builder/index.ts +0 -6
- package/src/block_builder/light.ts +0 -101
- package/src/proving_broker/proof_store/gcs_proof_store.ts +0 -72
- package/src/proving_broker/proving_agent_instrumentation.ts +0 -21
|
@@ -1,55 +1,184 @@
|
|
|
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';
|
|
3
|
-
import { Fr } from '@aztec/foundation/
|
|
4
|
-
import {
|
|
4
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
7
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
|
-
import
|
|
7
|
-
ActualProverConfig,
|
|
8
|
-
EpochProver,
|
|
9
|
-
EpochProverManager,
|
|
10
|
-
ForkMerkleTreeOperations,
|
|
11
|
-
ProvingJobBroker,
|
|
12
|
-
ProvingJobConsumer,
|
|
13
|
-
ProvingJobProducer,
|
|
14
|
-
|
|
8
|
+
import {
|
|
9
|
+
type ActualProverConfig,
|
|
10
|
+
type EpochProver,
|
|
11
|
+
type EpochProverManager,
|
|
12
|
+
type ForkMerkleTreeOperations,
|
|
13
|
+
type ProvingJobBroker,
|
|
14
|
+
type ProvingJobConsumer,
|
|
15
|
+
type ProvingJobProducer,
|
|
16
|
+
type ReadonlyWorldStateAccess,
|
|
17
|
+
type ServerCircuitProver,
|
|
18
|
+
tryStop,
|
|
15
19
|
} from '@aztec/stdlib/interfaces/server';
|
|
20
|
+
import type { CheckpointConstantData } from '@aztec/stdlib/rollup';
|
|
21
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
16
22
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
17
23
|
|
|
18
24
|
import type { ProverClientConfig } from '../config.js';
|
|
25
|
+
import { CheckpointSubTreeOrchestrator } from '../orchestrator/checkpoint-sub-tree-orchestrator.js';
|
|
26
|
+
import { EpochProvingContext } from '../orchestrator/epoch-proving-context.js';
|
|
19
27
|
import { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
28
|
+
import { TopTreeOrchestrator } from '../orchestrator/top-tree-orchestrator.js';
|
|
20
29
|
import { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
21
30
|
import { InlineProofStore, type ProofStore, createProofStore } from '../proving_broker/proof_store/index.js';
|
|
22
31
|
import { ProvingAgent } from '../proving_broker/proving_agent.js';
|
|
23
32
|
import { ServerEpochProver } from './server-epoch-prover.js';
|
|
24
33
|
|
|
34
|
+
/**
|
|
35
|
+
* The factory surface that `EpochProvingJob` (in `prover-node`) depends on. Implemented
|
|
36
|
+
* by `ProverClient`. Defined here rather than in stdlib because the return types
|
|
37
|
+
* (`CheckpointSubTreeOrchestrator`, `TopTreeOrchestrator`) are concrete classes from
|
|
38
|
+
* this package.
|
|
39
|
+
*
|
|
40
|
+
* A single `BrokerCircuitProverFacade` is owned by `ProverClient` and shared across
|
|
41
|
+
* every orchestrator (every sub-tree and every top-tree across every concurrent epoch
|
|
42
|
+
* job). The broker delivers each completed-job notification exactly once (drained on
|
|
43
|
+
* the first `getCompletedJobs` poll), so multiple facades polling the same broker
|
|
44
|
+
* race and lose notifications
|
|
45
|
+
*
|
|
46
|
+
* The facade's job map cleans up entries on resolve/reject, and the prover-node
|
|
47
|
+
* keeps `ProverClient` alive for its whole lifetime
|
|
48
|
+
*/
|
|
49
|
+
export interface EpochProverFactory {
|
|
50
|
+
getProverId(): EthAddress;
|
|
51
|
+
/**
|
|
52
|
+
* Constructs a per-epoch shared context for the caching of e.g. chonk verifier results
|
|
53
|
+
*/
|
|
54
|
+
createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext;
|
|
55
|
+
/**
|
|
56
|
+
* Constructs and starts a `CheckpointSubTreeOrchestrator` for a single checkpoint.
|
|
57
|
+
*/
|
|
58
|
+
createCheckpointSubTreeOrchestrator(
|
|
59
|
+
epochContext: EpochProvingContext,
|
|
60
|
+
checkpointConstants: CheckpointConstantData,
|
|
61
|
+
l1ToL2Messages: Fr[],
|
|
62
|
+
totalNumBlocks: number,
|
|
63
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
64
|
+
): Promise<CheckpointSubTreeOrchestrator>;
|
|
65
|
+
createTopTreeOrchestrator(): TopTreeOrchestrator;
|
|
66
|
+
}
|
|
67
|
+
|
|
25
68
|
/** Manages proving of epochs by orchestrating the proving of individual blocks relying on a pool of prover agents. */
|
|
26
|
-
export class ProverClient implements EpochProverManager {
|
|
69
|
+
export class ProverClient implements EpochProverManager, EpochProverFactory {
|
|
27
70
|
private running = false;
|
|
28
71
|
private agents: ProvingAgent[] = [];
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
72
|
+
/**
|
|
73
|
+
* The single broker facade shared by every orchestrator created from this client.
|
|
74
|
+
* Constructed lazily on `start()` and torn down on `stop()` — see the comment on
|
|
75
|
+
* `EpochProverFactory` for why a single shared facade is required.
|
|
76
|
+
*/
|
|
77
|
+
private facade: BrokerCircuitProverFacade | undefined;
|
|
32
78
|
|
|
33
79
|
private constructor(
|
|
34
80
|
private config: ProverClientConfig,
|
|
35
|
-
private worldState: ForkMerkleTreeOperations,
|
|
81
|
+
private worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
36
82
|
private orchestratorClient: ProvingJobProducer,
|
|
83
|
+
private proofStore: ProofStore,
|
|
84
|
+
private failedProofStore: ProofStore | undefined,
|
|
37
85
|
private agentClient?: ProvingJobConsumer,
|
|
38
86
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
39
|
-
private log = createLogger('prover-client:tx-prover'),
|
|
40
|
-
) {
|
|
41
|
-
|
|
42
|
-
|
|
87
|
+
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
88
|
+
) {}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Lazy-init the shared facade. The broker delivers each completed-job notification
|
|
92
|
+
* exactly once (drained on the first `getCompletedJobs` poll), so we cannot start
|
|
93
|
+
* a shared facade alongside the per-call facades that `createEpochProver` builds —
|
|
94
|
+
* they would race for notifications and one side would silently drop them. Starting
|
|
95
|
+
* the shared facade only on first use of one of the new factory methods keeps the
|
|
96
|
+
* legacy `createEpochProver` path race-free.
|
|
97
|
+
*/
|
|
98
|
+
private getFacade(): BrokerCircuitProverFacade {
|
|
99
|
+
if (!this.running) {
|
|
100
|
+
throw new Error('ProverClient is not running; call start() before constructing orchestrators.');
|
|
101
|
+
}
|
|
102
|
+
if (!this.facade) {
|
|
103
|
+
this.facade = new BrokerCircuitProverFacade(
|
|
104
|
+
this.orchestratorClient,
|
|
105
|
+
this.proofStore,
|
|
106
|
+
this.failedProofStore,
|
|
107
|
+
undefined,
|
|
108
|
+
this.log.getBindings(),
|
|
109
|
+
);
|
|
110
|
+
this.facade.start();
|
|
111
|
+
}
|
|
112
|
+
return this.facade;
|
|
43
113
|
}
|
|
44
114
|
|
|
115
|
+
/**
|
|
116
|
+
* Legacy single-class epoch prover. Each call constructs its own
|
|
117
|
+
* `BrokerCircuitProverFacade`; the new factory methods (`createCheckpointSubTreeOrchestrator`,
|
|
118
|
+
* `createTopTreeOrchestrator`, `createEpochProvingContext`) share a single facade
|
|
119
|
+
* owned by `ProverClient`. Both APIs coexist while the prover-node migrates onto
|
|
120
|
+
* the new pair.
|
|
121
|
+
*/
|
|
45
122
|
public createEpochProver(): EpochProver {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
123
|
+
const bindings = this.log.getBindings();
|
|
124
|
+
const facade = new BrokerCircuitProverFacade(
|
|
125
|
+
this.orchestratorClient,
|
|
126
|
+
this.proofStore,
|
|
127
|
+
this.failedProofStore,
|
|
128
|
+
undefined,
|
|
129
|
+
bindings,
|
|
130
|
+
);
|
|
131
|
+
const orchestrator = new ProvingOrchestrator(
|
|
132
|
+
this.worldState,
|
|
133
|
+
facade,
|
|
134
|
+
this.config.proverId,
|
|
135
|
+
this.config.cancelJobsOnStop,
|
|
136
|
+
this.config.enqueueConcurrency,
|
|
137
|
+
this.telemetry,
|
|
138
|
+
bindings,
|
|
139
|
+
);
|
|
48
140
|
return new ServerEpochProver(facade, orchestrator);
|
|
49
141
|
}
|
|
50
142
|
|
|
51
|
-
public
|
|
52
|
-
return this.
|
|
143
|
+
public createEpochProvingContext(epochNumber: EpochNumber): EpochProvingContext {
|
|
144
|
+
return new EpochProvingContext(this.getFacade(), epochNumber, this.log.getBindings());
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public createCheckpointSubTreeOrchestrator(
|
|
148
|
+
epochContext: EpochProvingContext,
|
|
149
|
+
checkpointConstants: CheckpointConstantData,
|
|
150
|
+
l1ToL2Messages: Fr[],
|
|
151
|
+
totalNumBlocks: number,
|
|
152
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
153
|
+
): Promise<CheckpointSubTreeOrchestrator> {
|
|
154
|
+
return CheckpointSubTreeOrchestrator.start(
|
|
155
|
+
this.worldState,
|
|
156
|
+
this.getFacade(),
|
|
157
|
+
this.config.proverId,
|
|
158
|
+
epochContext,
|
|
159
|
+
this.config.cancelJobsOnStop,
|
|
160
|
+
this.config.enqueueConcurrency,
|
|
161
|
+
checkpointConstants,
|
|
162
|
+
l1ToL2Messages,
|
|
163
|
+
totalNumBlocks,
|
|
164
|
+
headerOfLastBlockInPreviousCheckpoint,
|
|
165
|
+
this.telemetry,
|
|
166
|
+
this.log.getBindings(),
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public createTopTreeOrchestrator(): TopTreeOrchestrator {
|
|
171
|
+
return new TopTreeOrchestrator(
|
|
172
|
+
this.getFacade(),
|
|
173
|
+
this.config.proverId,
|
|
174
|
+
this.config.enqueueConcurrency,
|
|
175
|
+
this.telemetry,
|
|
176
|
+
this.log.getBindings(),
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public getProverId(): EthAddress {
|
|
181
|
+
return this.config.proverId;
|
|
53
182
|
}
|
|
54
183
|
|
|
55
184
|
async updateProverConfig(config: Partial<ProverClientConfig>): Promise<void> {
|
|
@@ -87,6 +216,15 @@ export class ProverClient implements EpochProverManager {
|
|
|
87
216
|
}
|
|
88
217
|
this.running = false;
|
|
89
218
|
await this.stopAgents();
|
|
219
|
+
if (this.facade) {
|
|
220
|
+
try {
|
|
221
|
+
await this.facade.stop();
|
|
222
|
+
} catch (err) {
|
|
223
|
+
this.log.error('Error stopping shared broker facade', err);
|
|
224
|
+
}
|
|
225
|
+
this.facade = undefined;
|
|
226
|
+
}
|
|
227
|
+
await tryStop(this.orchestratorClient);
|
|
90
228
|
}
|
|
91
229
|
|
|
92
230
|
/**
|
|
@@ -97,11 +235,13 @@ export class ProverClient implements EpochProverManager {
|
|
|
97
235
|
*/
|
|
98
236
|
public static async new(
|
|
99
237
|
config: ProverClientConfig,
|
|
100
|
-
worldState: ForkMerkleTreeOperations,
|
|
238
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
101
239
|
broker: ProvingJobBroker,
|
|
102
240
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
103
241
|
) {
|
|
104
|
-
const
|
|
242
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
243
|
+
const failedProofStore = config.failedProofStore ? await createProofStore(config.failedProofStore) : undefined;
|
|
244
|
+
const prover = new ProverClient(config, worldState, broker, proofStore, failedProofStore, broker, telemetry);
|
|
105
245
|
await prover.start();
|
|
106
246
|
return prover;
|
|
107
247
|
}
|
|
@@ -125,17 +265,11 @@ export class ProverClient implements EpochProverManager {
|
|
|
125
265
|
|
|
126
266
|
const proofStore = new InlineProofStore();
|
|
127
267
|
const prover = await buildServerCircuitProver(this.config, this.telemetry);
|
|
268
|
+
const bindings = this.log.getBindings();
|
|
128
269
|
this.agents = times(
|
|
129
270
|
this.config.proverAgentCount,
|
|
130
271
|
() =>
|
|
131
|
-
new ProvingAgent(
|
|
132
|
-
this.agentClient!,
|
|
133
|
-
proofStore,
|
|
134
|
-
prover,
|
|
135
|
-
[],
|
|
136
|
-
this.config.proverAgentPollIntervalMs,
|
|
137
|
-
this.telemetry,
|
|
138
|
-
),
|
|
272
|
+
new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
|
|
139
273
|
);
|
|
140
274
|
|
|
141
275
|
await Promise.all(this.agents.map(agent => agent.start()));
|
|
@@ -147,16 +281,17 @@ export class ProverClient implements EpochProverManager {
|
|
|
147
281
|
}
|
|
148
282
|
|
|
149
283
|
export function buildServerCircuitProver(
|
|
150
|
-
config: ActualProverConfig & ACVMConfig & BBConfig,
|
|
284
|
+
config: Omit<ActualProverConfig, 'enqueueConcurrency'> & ACVMConfig & BBConfig,
|
|
151
285
|
telemetry: TelemetryClient,
|
|
152
286
|
): Promise<ServerCircuitProver> {
|
|
153
287
|
if (config.realProofs) {
|
|
154
288
|
return BBNativeRollupProver.new(config, telemetry);
|
|
155
289
|
}
|
|
156
290
|
|
|
157
|
-
const
|
|
158
|
-
|
|
291
|
+
const logger = createLogger('prover-client:acvm-native');
|
|
292
|
+
const simulator = config.acvmBinaryPath
|
|
293
|
+
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
|
|
159
294
|
: undefined;
|
|
160
295
|
|
|
161
|
-
return Promise.resolve(new TestCircuitProver(
|
|
296
|
+
return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
|
|
162
297
|
}
|
|
@@ -1,49 +1,67 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { BatchedBlob, FinalBlobBatchingChallenges } from '@aztec/blob-lib/types';
|
|
2
|
+
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
3
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
4
|
+
import type { EthAddress } from '@aztec/stdlib/block';
|
|
3
5
|
import type { EpochProver } from '@aztec/stdlib/interfaces/server';
|
|
4
6
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
5
|
-
import type { RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
6
|
-
import type { BlockHeader,
|
|
7
|
+
import type { CheckpointConstantData, RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
8
|
+
import type { BlockHeader, ProcessedTx, Tx } from '@aztec/stdlib/tx';
|
|
9
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
7
10
|
|
|
8
11
|
import type { ProvingOrchestrator } from '../orchestrator/orchestrator.js';
|
|
9
12
|
import type { BrokerCircuitProverFacade } from '../proving_broker/broker_prover_facade.js';
|
|
10
13
|
|
|
11
14
|
/** Encapsulates the proving orchestrator and the broker facade */
|
|
12
15
|
export class ServerEpochProver implements EpochProver {
|
|
13
|
-
constructor(
|
|
16
|
+
constructor(
|
|
17
|
+
private facade: BrokerCircuitProverFacade,
|
|
18
|
+
private orchestrator: ProvingOrchestrator,
|
|
19
|
+
) {}
|
|
14
20
|
|
|
15
|
-
startNewEpoch(
|
|
16
|
-
|
|
21
|
+
startNewEpoch(
|
|
22
|
+
epochNumber: EpochNumber,
|
|
23
|
+
totalNumCheckpoints: number,
|
|
24
|
+
finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
25
|
+
): void {
|
|
26
|
+
this.orchestrator.startNewEpoch(epochNumber, totalNumCheckpoints, finalBlobBatchingChallenges);
|
|
17
27
|
this.facade.start();
|
|
18
28
|
}
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
startNewCheckpoint(
|
|
30
|
+
checkpointIndex: number,
|
|
31
|
+
constants: CheckpointConstantData,
|
|
32
|
+
l1ToL2Messages: Fr[],
|
|
33
|
+
totalNumBlocks: number,
|
|
34
|
+
headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
35
|
+
): Promise<void> {
|
|
36
|
+
return this.orchestrator.startNewCheckpoint(
|
|
37
|
+
checkpointIndex,
|
|
38
|
+
constants,
|
|
39
|
+
l1ToL2Messages,
|
|
40
|
+
totalNumBlocks,
|
|
41
|
+
headerOfLastBlockInPreviousCheckpoint,
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
startChonkVerifierCircuits(txs: Tx[]): Promise<void> {
|
|
45
|
+
return this.orchestrator.startChonkVerifierCircuits(txs);
|
|
21
46
|
}
|
|
22
|
-
setBlockCompleted(blockNumber:
|
|
47
|
+
setBlockCompleted(blockNumber: BlockNumber, expectedBlockHeader?: BlockHeader): Promise<BlockHeader> {
|
|
23
48
|
return this.orchestrator.setBlockCompleted(blockNumber, expectedBlockHeader);
|
|
24
49
|
}
|
|
25
|
-
|
|
26
|
-
return this.orchestrator.
|
|
50
|
+
finalizeEpoch(): Promise<{ publicInputs: RootRollupPublicInputs; proof: Proof; batchedBlobInputs: BatchedBlob }> {
|
|
51
|
+
return this.orchestrator.finalizeEpoch();
|
|
27
52
|
}
|
|
28
53
|
cancel(): void {
|
|
29
54
|
this.orchestrator.cancel();
|
|
30
55
|
}
|
|
31
|
-
getProverId():
|
|
56
|
+
getProverId(): EthAddress {
|
|
32
57
|
return this.orchestrator.getProverId();
|
|
33
58
|
}
|
|
34
|
-
getBlock(index: number): L2Block {
|
|
35
|
-
return this.orchestrator.getBlock(index);
|
|
36
|
-
}
|
|
37
59
|
async stop(): Promise<void> {
|
|
38
60
|
await this.facade.stop();
|
|
39
61
|
await this.orchestrator.stop();
|
|
40
62
|
}
|
|
41
|
-
startNewBlock(
|
|
42
|
-
|
|
43
|
-
l1ToL2Messages: Fr[],
|
|
44
|
-
previousBlockHeader: BlockHeader,
|
|
45
|
-
): Promise<void> {
|
|
46
|
-
return this.orchestrator.startNewBlock(globalVariables, l1ToL2Messages, previousBlockHeader);
|
|
63
|
+
startNewBlock(blockNumber: BlockNumber, timestamp: UInt64, totalNumTxs: number): Promise<void> {
|
|
64
|
+
return this.orchestrator.startNewBlock(blockNumber, timestamp, totalNumTxs);
|
|
47
65
|
}
|
|
48
66
|
addTxs(txs: ProcessedTx[]): Promise<void> {
|
|
49
67
|
return this.orchestrator.addTxs(txs);
|