@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
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import type { BatchedBlob, BatchedBlobAccumulator, FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type { NESTED_RECURSIVE_PROOF_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
3
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
4
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
5
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { Proof } from '@aztec/stdlib/proofs';
|
|
7
|
+
import {
|
|
8
|
+
CheckpointMergeRollupPrivateInputs,
|
|
9
|
+
CheckpointPaddingRollupPrivateInputs,
|
|
10
|
+
CheckpointRollupPublicInputs,
|
|
11
|
+
RootRollupPrivateInputs,
|
|
12
|
+
type RootRollupPublicInputs,
|
|
13
|
+
} from '@aztec/stdlib/rollup';
|
|
14
|
+
|
|
15
|
+
import { toProofData } from './block-building-helpers.js';
|
|
16
|
+
import type { ProofState } from './block-proving-state.js';
|
|
17
|
+
|
|
18
|
+
enum TOP_TREE_LIFECYCLE {
|
|
19
|
+
CREATED,
|
|
20
|
+
RESOLVED,
|
|
21
|
+
REJECTED,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Lean top-tree-only state. Owns the merge tree of checkpoint root proofs, the
|
|
26
|
+
* single-checkpoint padding proof slot, the final root rollup proof, and the blob
|
|
27
|
+
* accumulator endpoints needed to finalise the epoch's batched blob proof.
|
|
28
|
+
*
|
|
29
|
+
* Constructed with `totalNumCheckpoints` and `finalBlobBatchingChallenges` upfront —
|
|
30
|
+
* by the time the top tree starts, all checkpoints are known and the challenges are
|
|
31
|
+
* derivable from their blob fields.
|
|
32
|
+
*/
|
|
33
|
+
export class TopTreeProvingState {
|
|
34
|
+
private checkpointProofs: UnbalancedTreeStore<
|
|
35
|
+
ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
36
|
+
>;
|
|
37
|
+
private checkpointPaddingProof:
|
|
38
|
+
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
39
|
+
| undefined;
|
|
40
|
+
private rootRollupProof: ProofState<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
41
|
+
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
42
|
+
private finalBatchedBlob: BatchedBlob | undefined;
|
|
43
|
+
private lifecycle = TOP_TREE_LIFECYCLE.CREATED;
|
|
44
|
+
|
|
45
|
+
constructor(
|
|
46
|
+
public readonly epochNumber: EpochNumber,
|
|
47
|
+
public readonly totalNumCheckpoints: number,
|
|
48
|
+
public readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
49
|
+
public readonly startBlobAccumulator: BatchedBlobAccumulator,
|
|
50
|
+
private readonly completionCallback: () => void,
|
|
51
|
+
private readonly rejectionCallback: (reason: string) => void,
|
|
52
|
+
) {
|
|
53
|
+
if (totalNumCheckpoints < 1) {
|
|
54
|
+
throw new Error(`TopTreeProvingState requires at least one checkpoint; got ${totalNumCheckpoints}.`);
|
|
55
|
+
}
|
|
56
|
+
this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// --- checkpoint root rollup ---
|
|
60
|
+
|
|
61
|
+
public setCheckpointRootRollupProof(
|
|
62
|
+
checkpointIndex: number,
|
|
63
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
64
|
+
CheckpointRollupPublicInputs,
|
|
65
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
66
|
+
>,
|
|
67
|
+
): TreeNodeLocation {
|
|
68
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// --- checkpoint merge rollup ---
|
|
72
|
+
|
|
73
|
+
public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
|
|
74
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
this.checkpointProofs.setNode(location, { isProving: true });
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public setCheckpointMergeRollupProof(
|
|
82
|
+
location: TreeNodeLocation,
|
|
83
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
84
|
+
CheckpointRollupPublicInputs,
|
|
85
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
86
|
+
>,
|
|
87
|
+
) {
|
|
88
|
+
this.checkpointProofs.setNode(location, { provingOutput });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public isReadyForCheckpointMerge(location: TreeNodeLocation) {
|
|
92
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public getParentLocation(location: TreeNodeLocation) {
|
|
96
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
100
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
101
|
+
if (!left || !right) {
|
|
102
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
103
|
+
}
|
|
104
|
+
return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// --- padding (single-checkpoint case) ---
|
|
108
|
+
|
|
109
|
+
public tryStartProvingPaddingCheckpoint() {
|
|
110
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
this.checkpointPaddingProof = { isProving: true };
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public setCheckpointPaddingProof(
|
|
118
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
119
|
+
CheckpointRollupPublicInputs,
|
|
120
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
121
|
+
>,
|
|
122
|
+
) {
|
|
123
|
+
this.checkpointPaddingProof = { provingOutput };
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
public getPaddingCheckpointInputs() {
|
|
127
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// --- root rollup ---
|
|
131
|
+
|
|
132
|
+
public tryStartProvingRootRollup() {
|
|
133
|
+
if (this.rootRollupProof?.isProving) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
136
|
+
this.rootRollupProof = { isProving: true };
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
|
|
141
|
+
this.rootRollupProof = { provingOutput };
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
public isReadyForRootRollup() {
|
|
145
|
+
const childProofs = this.#getChildProofsForRoot();
|
|
146
|
+
return childProofs.every(p => !!p);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
public getRootRollupInputs() {
|
|
150
|
+
const [left, right] = this.#getChildProofsForRoot();
|
|
151
|
+
if (!left || !right) {
|
|
152
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
153
|
+
}
|
|
154
|
+
return RootRollupPrivateInputs.from({
|
|
155
|
+
previousRollups: [toProofData(left), toProofData(right)],
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// --- blob accumulator finalisation ---
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Sets the end-of-epoch blob accumulator, computed by the top-tree orchestrator
|
|
163
|
+
* from the surviving checkpoints' blob fields. Required before `finalizeBatchedBlob`.
|
|
164
|
+
*/
|
|
165
|
+
public setEndBlobAccumulator(accumulator: BatchedBlobAccumulator) {
|
|
166
|
+
this.endBlobAccumulator = accumulator;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
public async finalizeBatchedBlob() {
|
|
170
|
+
if (!this.endBlobAccumulator) {
|
|
171
|
+
throw new Error('End blob accumulator not set; call setEndBlobAccumulator before finalize.');
|
|
172
|
+
}
|
|
173
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
|
|
177
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
178
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
179
|
+
throw new Error('Top-tree proof not ready; root rollup or batched blob missing.');
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
proof: provingOutput.proof.binaryProof,
|
|
183
|
+
publicInputs: provingOutput.inputs,
|
|
184
|
+
batchedBlobInputs: this.finalBatchedBlob,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// --- lifecycle ---
|
|
189
|
+
|
|
190
|
+
public verifyState() {
|
|
191
|
+
return this.lifecycle === TOP_TREE_LIFECYCLE.CREATED;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
public resolve() {
|
|
195
|
+
if (!this.verifyState()) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
this.lifecycle = TOP_TREE_LIFECYCLE.RESOLVED;
|
|
199
|
+
this.completionCallback();
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public reject(reason: string) {
|
|
203
|
+
if (!this.verifyState()) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
this.lifecycle = TOP_TREE_LIFECYCLE.REJECTED;
|
|
207
|
+
this.rejectionCallback(reason);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public cancel() {
|
|
211
|
+
this.reject('Top-tree proving cancelled');
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
#getChildProofsForRoot() {
|
|
215
|
+
const rootLocation = { level: 0, index: 0 };
|
|
216
|
+
return this.totalNumCheckpoints === 1
|
|
217
|
+
? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
|
|
218
|
+
: this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
@@ -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
|
) {
|