@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.001888fc
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 +12 -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 +223 -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 +43 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +152 -87
- 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 +76 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +243 -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 +1 -1
- package/dest/orchestrator/orchestrator.d.ts +55 -35
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +874 -314
- 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/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 +8 -8
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +19 -13
- 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 +64 -45
- package/dest/proving_broker/config.d.ts +32 -11
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +42 -8
- 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 +1 -1
- 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 +17 -5
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +76 -37
- 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 +7 -7
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +9 -4
- 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 +25 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +312 -0
- package/src/mocks/fixtures.ts +46 -40
- package/src/mocks/test_context.ts +223 -116
- 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 +349 -0
- package/src/orchestrator/epoch-proving-state.ts +239 -111
- package/src/orchestrator/orchestrator.ts +674 -355
- package/src/orchestrator/orchestrator_metrics.ts +2 -6
- package/src/orchestrator/tx-proving-state.ts +48 -66
- package/src/prover-client/factory.ts +6 -2
- package/src/prover-client/prover-client.ts +49 -38
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +219 -133
- package/src/proving_broker/config.ts +48 -8
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +8 -3
- 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 +94 -44
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +29 -13
- 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 +14 -5
- 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,4 +1,4 @@
|
|
|
1
|
-
import { type Histogram, Metrics, type TelemetryClient, type Tracer
|
|
1
|
+
import { type Histogram, Metrics, type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
2
2
|
|
|
3
3
|
export class ProvingOrchestratorMetrics {
|
|
4
4
|
public readonly tracer: Tracer;
|
|
@@ -9,11 +9,7 @@ export class ProvingOrchestratorMetrics {
|
|
|
9
9
|
this.tracer = client.getTracer(name);
|
|
10
10
|
const meter = client.getMeter(name);
|
|
11
11
|
|
|
12
|
-
this.baseRollupInputsDuration = meter.createHistogram(Metrics.PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION
|
|
13
|
-
unit: 'ms',
|
|
14
|
-
description: 'Duration to build base rollup inputs',
|
|
15
|
-
valueType: ValueType.INT,
|
|
16
|
-
});
|
|
12
|
+
this.baseRollupInputsDuration = meter.createHistogram(Metrics.PROVING_ORCHESTRATOR_BASE_ROLLUP_INPUTS_DURATION);
|
|
17
13
|
}
|
|
18
14
|
|
|
19
15
|
recordBaseRollupInputs(durationMs: number) {
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
2
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
import { getVkData } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
3
4
|
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
4
|
-
import type {
|
|
5
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { ProofData, ProofDataForFixedVk, RecursiveProof } from '@aztec/stdlib/proofs';
|
|
5
7
|
import {
|
|
6
|
-
AvmProofData,
|
|
7
8
|
type BaseRollupHints,
|
|
8
9
|
PrivateBaseRollupHints,
|
|
9
|
-
|
|
10
|
-
PrivateTubeData,
|
|
10
|
+
PrivateTxBaseRollupPrivateInputs,
|
|
11
11
|
PublicBaseRollupHints,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
TubeInputs,
|
|
12
|
+
PublicChonkVerifierPublicInputs,
|
|
13
|
+
PublicTxBaseRollupPrivateInputs,
|
|
15
14
|
} from '@aztec/stdlib/rollup';
|
|
16
15
|
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
17
16
|
import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
18
17
|
import type { ProcessedTx } from '@aztec/stdlib/tx';
|
|
19
|
-
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
getChonkProofFromTx,
|
|
21
|
+
getPublicChonkVerifierPrivateInputsFromTx,
|
|
22
|
+
toProofData,
|
|
23
|
+
} from './block-building-helpers.js';
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Helper class to manage the proving cycle of a transaction
|
|
@@ -24,13 +28,17 @@ import { VkWitnessData } from '@aztec/stdlib/vks';
|
|
|
24
28
|
* Also stores the inputs to the base rollup for this transaction and the tree snapshots
|
|
25
29
|
*/
|
|
26
30
|
export class TxProvingState {
|
|
27
|
-
private
|
|
28
|
-
|
|
31
|
+
private publicChonkVerifier?: PublicInputsAndRecursiveProof<
|
|
32
|
+
PublicChonkVerifierPublicInputs,
|
|
33
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
34
|
+
>;
|
|
35
|
+
private avmProof?: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>;
|
|
29
36
|
|
|
30
37
|
constructor(
|
|
31
38
|
public readonly processedTx: ProcessedTx,
|
|
32
39
|
private readonly baseRollupHints: BaseRollupHints,
|
|
33
40
|
public readonly treeSnapshots: Map<MerkleTreeId, AppendOnlyTreeSnapshot>,
|
|
41
|
+
private readonly proverId: Fr,
|
|
34
42
|
) {}
|
|
35
43
|
|
|
36
44
|
get requireAvmProof() {
|
|
@@ -38,102 +46,76 @@ export class TxProvingState {
|
|
|
38
46
|
}
|
|
39
47
|
|
|
40
48
|
public ready() {
|
|
41
|
-
return
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public getTubeInputs() {
|
|
45
|
-
return new TubeInputs(this.processedTx.clientIvcProof);
|
|
49
|
+
return !this.requireAvmProof || (!!this.avmProof && !!this.publicChonkVerifier);
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
public getAvmInputs(): AvmCircuitInputs {
|
|
49
53
|
return this.processedTx.avmProvingRequest!.inputs;
|
|
50
54
|
}
|
|
51
55
|
|
|
56
|
+
public getPublicChonkVerifierPrivateInputs() {
|
|
57
|
+
return getPublicChonkVerifierPrivateInputsFromTx(this.processedTx, this.proverId);
|
|
58
|
+
}
|
|
59
|
+
|
|
52
60
|
public getBaseRollupTypeAndInputs() {
|
|
53
61
|
if (this.requireAvmProof) {
|
|
54
62
|
return {
|
|
55
|
-
rollupType: '
|
|
63
|
+
rollupType: 'rollup-tx-base-public' satisfies CircuitName,
|
|
56
64
|
inputs: this.#getPublicBaseInputs(),
|
|
57
65
|
};
|
|
58
66
|
} else {
|
|
59
67
|
return {
|
|
60
|
-
rollupType: '
|
|
68
|
+
rollupType: 'rollup-tx-base-private' satisfies CircuitName,
|
|
61
69
|
inputs: this.#getPrivateBaseInputs(),
|
|
62
70
|
};
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
|
-
public
|
|
67
|
-
|
|
74
|
+
public setPublicChonkVerifierProof(
|
|
75
|
+
publicChonkVerifierProofAndVk: PublicInputsAndRecursiveProof<
|
|
76
|
+
PublicChonkVerifierPublicInputs,
|
|
77
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
78
|
+
>,
|
|
79
|
+
) {
|
|
80
|
+
this.publicChonkVerifier = publicChonkVerifierProofAndVk;
|
|
68
81
|
}
|
|
69
82
|
|
|
70
|
-
public setAvmProof(
|
|
71
|
-
this.
|
|
83
|
+
public setAvmProof(avmProof: RecursiveProof<typeof AVM_V2_PROOF_LENGTH_IN_FIELDS_PADDED>) {
|
|
84
|
+
this.avmProof = avmProof;
|
|
72
85
|
}
|
|
73
86
|
|
|
74
87
|
#getPrivateBaseInputs() {
|
|
75
|
-
if (!this.
|
|
76
|
-
throw new Error('
|
|
88
|
+
if (!(this.baseRollupHints instanceof PrivateBaseRollupHints)) {
|
|
89
|
+
throw new Error('Mismatched base rollup hints, expected private base rollup hints');
|
|
77
90
|
}
|
|
78
91
|
|
|
79
|
-
const
|
|
80
|
-
const tubeData = new PrivateTubeData(
|
|
92
|
+
const privateTailProofData = new ProofData(
|
|
81
93
|
this.processedTx.data.toPrivateToRollupKernelCircuitPublicInputs(),
|
|
82
|
-
this.
|
|
83
|
-
|
|
94
|
+
getChonkProofFromTx(this.processedTx),
|
|
95
|
+
getVkData('HidingKernelToRollup'),
|
|
84
96
|
);
|
|
85
97
|
|
|
86
|
-
|
|
87
|
-
throw new Error('Mismatched base rollup hints, expected private base rollup hints');
|
|
88
|
-
}
|
|
89
|
-
return new PrivateBaseRollupInputs(tubeData, this.baseRollupHints);
|
|
98
|
+
return new PrivateTxBaseRollupPrivateInputs(privateTailProofData, this.baseRollupHints);
|
|
90
99
|
}
|
|
91
100
|
|
|
92
101
|
#getPublicBaseInputs() {
|
|
93
102
|
if (!this.processedTx.avmProvingRequest) {
|
|
94
103
|
throw new Error('Should create private base rollup for a tx not requiring avm proof.');
|
|
95
104
|
}
|
|
96
|
-
if (!this.
|
|
97
|
-
throw new Error('Tx not ready for proving base rollup:
|
|
105
|
+
if (!this.publicChonkVerifier) {
|
|
106
|
+
throw new Error('Tx not ready for proving base rollup: public chonk verifier proof undefined');
|
|
98
107
|
}
|
|
99
|
-
if (!this.
|
|
108
|
+
if (!this.avmProof) {
|
|
100
109
|
throw new Error('Tx not ready for proving base rollup: avm proof undefined');
|
|
101
110
|
}
|
|
102
|
-
|
|
103
|
-
const tubeData = new PublicTubeData(
|
|
104
|
-
this.processedTx.data.toPrivateToPublicKernelCircuitPublicInputs(),
|
|
105
|
-
this.tube.proof,
|
|
106
|
-
this.#getTubeVkData(),
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
const avmProofData = new AvmProofData(
|
|
110
|
-
this.processedTx.avmProvingRequest.inputs.publicInputs,
|
|
111
|
-
this.avm.proof,
|
|
112
|
-
this.#getAvmVkData(),
|
|
113
|
-
);
|
|
114
|
-
|
|
115
111
|
if (!(this.baseRollupHints instanceof PublicBaseRollupHints)) {
|
|
116
112
|
throw new Error('Mismatched base rollup hints, expected public base rollup hints');
|
|
117
113
|
}
|
|
118
114
|
|
|
119
|
-
|
|
120
|
-
}
|
|
115
|
+
const publicChonkVerifierProofData = toProofData(this.publicChonkVerifier);
|
|
121
116
|
|
|
122
|
-
|
|
123
|
-
let vkIndex = TUBE_VK_INDEX;
|
|
124
|
-
try {
|
|
125
|
-
vkIndex = getVKIndex(this.tube!.verificationKey);
|
|
126
|
-
} catch (_ignored) {
|
|
127
|
-
// TODO(#7410) The VK for the tube won't be in the tree for now, so we manually set it to the tube vk index
|
|
128
|
-
}
|
|
129
|
-
const vkPath = getVKSiblingPath(vkIndex);
|
|
130
|
-
|
|
131
|
-
return new VkWitnessData(this.tube!.verificationKey, vkIndex, vkPath);
|
|
132
|
-
}
|
|
117
|
+
const avmProofData = new ProofDataForFixedVk(this.processedTx.avmProvingRequest.inputs.publicInputs, this.avmProof);
|
|
133
118
|
|
|
134
|
-
|
|
135
|
-
const vkIndex = AVM_VK_INDEX;
|
|
136
|
-
const vkPath = getVKSiblingPath(vkIndex);
|
|
137
|
-
return new VkWitnessData(this.avm!.verificationKey, AVM_VK_INDEX, vkPath);
|
|
119
|
+
return new PublicTxBaseRollupPrivateInputs(publicChonkVerifierProofData, avmProofData, this.baseRollupHints);
|
|
138
120
|
}
|
|
139
121
|
}
|
|
@@ -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,17 +1,19 @@
|
|
|
1
1
|
import { type ACVMConfig, type BBConfig, BBNativeRollupProver, TestCircuitProver } from '@aztec/bb-prover';
|
|
2
2
|
import { times } from '@aztec/foundation/collection';
|
|
3
|
-
import {
|
|
4
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
6
|
-
import
|
|
7
|
-
ActualProverConfig,
|
|
8
|
-
EpochProver,
|
|
9
|
-
EpochProverManager,
|
|
10
|
-
ForkMerkleTreeOperations,
|
|
11
|
-
ProvingJobBroker,
|
|
12
|
-
ProvingJobConsumer,
|
|
13
|
-
ProvingJobProducer,
|
|
14
|
-
|
|
6
|
+
import {
|
|
7
|
+
type ActualProverConfig,
|
|
8
|
+
type EpochProver,
|
|
9
|
+
type EpochProverManager,
|
|
10
|
+
type ForkMerkleTreeOperations,
|
|
11
|
+
type ProvingJobBroker,
|
|
12
|
+
type ProvingJobConsumer,
|
|
13
|
+
type ProvingJobProducer,
|
|
14
|
+
type ReadonlyWorldStateAccess,
|
|
15
|
+
type ServerCircuitProver,
|
|
16
|
+
tryStop,
|
|
15
17
|
} from '@aztec/stdlib/interfaces/server';
|
|
16
18
|
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
|
|
17
19
|
|
|
@@ -27,29 +29,40 @@ export class ProverClient implements EpochProverManager {
|
|
|
27
29
|
private running = false;
|
|
28
30
|
private agents: ProvingAgent[] = [];
|
|
29
31
|
|
|
30
|
-
private proofStore: ProofStore;
|
|
31
|
-
private failedProofStore: ProofStore | undefined;
|
|
32
|
-
|
|
33
32
|
private constructor(
|
|
34
33
|
private config: ProverClientConfig,
|
|
35
|
-
private worldState: ForkMerkleTreeOperations,
|
|
34
|
+
private worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
36
35
|
private orchestratorClient: ProvingJobProducer,
|
|
36
|
+
private proofStore: ProofStore,
|
|
37
|
+
private failedProofStore: ProofStore | undefined,
|
|
37
38
|
private agentClient?: ProvingJobConsumer,
|
|
38
39
|
private telemetry: TelemetryClient = getTelemetryClient(),
|
|
39
|
-
private log = createLogger('prover-client:tx-prover'),
|
|
40
|
-
) {
|
|
41
|
-
this.proofStore = new InlineProofStore();
|
|
42
|
-
this.failedProofStore = this.config.failedProofStore ? createProofStore(this.config.failedProofStore) : undefined;
|
|
43
|
-
}
|
|
40
|
+
private log: Logger = createLogger('prover-client:tx-prover'),
|
|
41
|
+
) {}
|
|
44
42
|
|
|
45
43
|
public createEpochProver(): EpochProver {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
44
|
+
const bindings = this.log.getBindings();
|
|
45
|
+
const facade = new BrokerCircuitProverFacade(
|
|
46
|
+
this.orchestratorClient,
|
|
47
|
+
this.proofStore,
|
|
48
|
+
this.failedProofStore,
|
|
49
|
+
undefined,
|
|
50
|
+
bindings,
|
|
51
|
+
);
|
|
52
|
+
const orchestrator = new ProvingOrchestrator(
|
|
53
|
+
this.worldState,
|
|
54
|
+
facade,
|
|
55
|
+
this.config.proverId,
|
|
56
|
+
this.config.cancelJobsOnStop,
|
|
57
|
+
this.config.enqueueConcurrency,
|
|
58
|
+
this.telemetry,
|
|
59
|
+
bindings,
|
|
60
|
+
);
|
|
48
61
|
return new ServerEpochProver(facade, orchestrator);
|
|
49
62
|
}
|
|
50
63
|
|
|
51
|
-
public getProverId():
|
|
52
|
-
return this.config.proverId
|
|
64
|
+
public getProverId(): EthAddress {
|
|
65
|
+
return this.config.proverId;
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
async updateProverConfig(config: Partial<ProverClientConfig>): Promise<void> {
|
|
@@ -87,6 +100,7 @@ export class ProverClient implements EpochProverManager {
|
|
|
87
100
|
}
|
|
88
101
|
this.running = false;
|
|
89
102
|
await this.stopAgents();
|
|
103
|
+
await tryStop(this.orchestratorClient);
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
/**
|
|
@@ -97,11 +111,13 @@ export class ProverClient implements EpochProverManager {
|
|
|
97
111
|
*/
|
|
98
112
|
public static async new(
|
|
99
113
|
config: ProverClientConfig,
|
|
100
|
-
worldState: ForkMerkleTreeOperations,
|
|
114
|
+
worldState: ForkMerkleTreeOperations & ReadonlyWorldStateAccess,
|
|
101
115
|
broker: ProvingJobBroker,
|
|
102
116
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
103
117
|
) {
|
|
104
|
-
const
|
|
118
|
+
const proofStore = await createProofStore(config.proofStore);
|
|
119
|
+
const failedProofStore = config.failedProofStore ? await createProofStore(config.failedProofStore) : undefined;
|
|
120
|
+
const prover = new ProverClient(config, worldState, broker, proofStore, failedProofStore, broker, telemetry);
|
|
105
121
|
await prover.start();
|
|
106
122
|
return prover;
|
|
107
123
|
}
|
|
@@ -125,17 +141,11 @@ export class ProverClient implements EpochProverManager {
|
|
|
125
141
|
|
|
126
142
|
const proofStore = new InlineProofStore();
|
|
127
143
|
const prover = await buildServerCircuitProver(this.config, this.telemetry);
|
|
144
|
+
const bindings = this.log.getBindings();
|
|
128
145
|
this.agents = times(
|
|
129
146
|
this.config.proverAgentCount,
|
|
130
147
|
() =>
|
|
131
|
-
new ProvingAgent(
|
|
132
|
-
this.agentClient!,
|
|
133
|
-
proofStore,
|
|
134
|
-
prover,
|
|
135
|
-
[],
|
|
136
|
-
this.config.proverAgentPollIntervalMs,
|
|
137
|
-
this.telemetry,
|
|
138
|
-
),
|
|
148
|
+
new ProvingAgent(this.agentClient!, proofStore, prover, [], this.config.proverAgentPollIntervalMs, bindings),
|
|
139
149
|
);
|
|
140
150
|
|
|
141
151
|
await Promise.all(this.agents.map(agent => agent.start()));
|
|
@@ -147,16 +157,17 @@ export class ProverClient implements EpochProverManager {
|
|
|
147
157
|
}
|
|
148
158
|
|
|
149
159
|
export function buildServerCircuitProver(
|
|
150
|
-
config: ActualProverConfig & ACVMConfig & BBConfig,
|
|
160
|
+
config: Omit<ActualProverConfig, 'enqueueConcurrency'> & ACVMConfig & BBConfig,
|
|
151
161
|
telemetry: TelemetryClient,
|
|
152
162
|
): Promise<ServerCircuitProver> {
|
|
153
163
|
if (config.realProofs) {
|
|
154
164
|
return BBNativeRollupProver.new(config, telemetry);
|
|
155
165
|
}
|
|
156
166
|
|
|
157
|
-
const
|
|
158
|
-
|
|
167
|
+
const logger = createLogger('prover-client:acvm-native');
|
|
168
|
+
const simulator = config.acvmBinaryPath
|
|
169
|
+
? new NativeACVMSimulator(config.acvmWorkingDirectory, config.acvmBinaryPath, undefined, logger)
|
|
159
170
|
: undefined;
|
|
160
171
|
|
|
161
|
-
return Promise.resolve(new TestCircuitProver(
|
|
172
|
+
return Promise.resolve(new TestCircuitProver(simulator, config, telemetry));
|
|
162
173
|
}
|
|
@@ -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);
|