@aztec/prover-client 0.0.0-test.1 → 0.0.1-commit.5476d83
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/block-factory/index.d.ts +2 -0
- package/dest/block-factory/index.d.ts.map +1 -0
- package/dest/block-factory/light.d.ts +38 -0
- package/dest/block-factory/light.d.ts.map +1 -0
- package/dest/block-factory/light.js +108 -0
- package/dest/config.d.ts +7 -7
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +11 -1
- package/dest/index.d.ts +1 -1
- package/dest/light/lightweight_checkpoint_builder.d.ts +28 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +107 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +32 -14
- package/dest/mocks/test_context.d.ts +40 -31
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +134 -86
- 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 +168 -188
- package/dest/orchestrator/block-proving-state.d.ts +68 -47
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +281 -176
- package/dest/orchestrator/checkpoint-proving-state.d.ts +62 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +208 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +40 -26
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +143 -73
- package/dest/orchestrator/index.d.ts +1 -1
- package/dest/orchestrator/orchestrator.d.ts +35 -32
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +389 -239
- package/dest/orchestrator/orchestrator_metrics.d.ts +3 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator_metrics.js +9 -0
- package/dest/orchestrator/tx-proving-state.d.ts +13 -11
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +23 -40
- package/dest/prover-client/factory.d.ts +1 -1
- package/dest/prover-client/index.d.ts +1 -1
- package/dest/prover-client/prover-client.d.ts +4 -4
- package/dest/prover-client/prover-client.d.ts.map +1 -1
- package/dest/prover-client/prover-client.js +5 -4
- package/dest/prover-client/server-epoch-prover.d.ts +15 -11
- 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 +23 -16
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +67 -41
- package/dest/proving_broker/config.d.ts +18 -9
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +22 -5
- 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 +2 -1
- package/dest/proving_broker/index.d.ts +1 -1
- package/dest/proving_broker/proof_store/factory.d.ts +2 -2
- package/dest/proving_broker/proof_store/factory.js +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/gcs_proof_store.js +1 -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 +4 -4
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +83 -47
- package/dest/proving_broker/proving_agent_instrumentation.d.ts +1 -1
- package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.d.ts +13 -4
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +36 -23
- 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 +3 -2
- package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker_database/persisted.js +12 -10
- 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 +1 -1
- package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.d.ts +9 -9
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +89 -61
- package/dest/proving_broker/rpc.d.ts +4 -6
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +1 -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 +32 -31
- package/src/block-factory/index.ts +1 -0
- package/src/block-factory/light.ts +137 -0
- package/src/config.ts +24 -8
- package/src/light/lightweight_checkpoint_builder.ts +142 -0
- package/src/mocks/fixtures.ts +42 -37
- package/src/mocks/test_context.ts +207 -115
- package/src/orchestrator/block-building-helpers.ts +256 -333
- package/src/orchestrator/block-proving-state.ts +323 -230
- package/src/orchestrator/checkpoint-proving-state.ts +301 -0
- package/src/orchestrator/epoch-proving-state.ts +187 -112
- package/src/orchestrator/orchestrator.ts +592 -299
- package/src/orchestrator/orchestrator_metrics.ts +20 -1
- package/src/orchestrator/tx-proving-state.ts +50 -64
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +39 -21
- package/src/proving_broker/broker_prover_facade.ts +214 -126
- package/src/proving_broker/config.ts +24 -6
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +7 -2
- package/src/proving_broker/proof_store/factory.ts +1 -1
- package/src/proving_broker/proof_store/gcs_proof_store.ts +5 -1
- 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 +89 -47
- package/src/proving_broker/proving_broker.ts +53 -33
- package/src/proving_broker/proving_broker_database/memory.ts +3 -2
- package/src/proving_broker/proving_broker_database/persisted.ts +14 -12
- package/src/proving_broker/proving_broker_database.ts +2 -1
- package/src/proving_broker/proving_job_controller.ts +94 -82
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +164 -60
- 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/light.d.ts +0 -33
- package/dest/block_builder/light.d.ts.map +0 -1
- package/dest/block_builder/light.js +0 -82
- 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/dest/{block_builder → block-factory}/index.js +0 -0
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { BatchedBlob, BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import type {
|
|
3
|
+
ARCHIVE_HEIGHT,
|
|
4
|
+
L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
5
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
6
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
7
7
|
} from '@aztec/constants';
|
|
8
|
+
import { EpochNumber } from '@aztec/foundation/branded-types';
|
|
8
9
|
import type { Fr } from '@aztec/foundation/fields';
|
|
9
10
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
11
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
12
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
13
13
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
CheckpointConstantData,
|
|
16
|
+
CheckpointMergeRollupPrivateInputs,
|
|
17
|
+
CheckpointPaddingRollupPrivateInputs,
|
|
18
|
+
CheckpointRollupPublicInputs,
|
|
19
|
+
PublicChonkVerifierPublicInputs,
|
|
20
|
+
RootRollupPrivateInputs,
|
|
19
21
|
type RootRollupPublicInputs,
|
|
20
22
|
} from '@aztec/stdlib/rollup';
|
|
21
23
|
import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
22
|
-
import type { BlockHeader
|
|
24
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
23
25
|
|
|
24
|
-
import {
|
|
26
|
+
import { toProofData } from './block-building-helpers.js';
|
|
27
|
+
import type { ProofState } from './block-proving-state.js';
|
|
28
|
+
import { CheckpointProvingState } from './checkpoint-proving-state.js';
|
|
25
29
|
|
|
26
30
|
export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
|
|
27
31
|
|
|
@@ -41,58 +45,95 @@ export type ProvingResult = { status: 'success' } | { status: 'failure'; reason:
|
|
|
41
45
|
* Captures resolve and reject callbacks to provide a promise base interface to the consumer of our proving.
|
|
42
46
|
*/
|
|
43
47
|
export class EpochProvingState {
|
|
44
|
-
private
|
|
45
|
-
|
|
48
|
+
private checkpointProofs: UnbalancedTreeStore<
|
|
49
|
+
ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
46
50
|
>;
|
|
47
|
-
private
|
|
48
|
-
|
|
|
51
|
+
private checkpointPaddingProof:
|
|
52
|
+
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
49
53
|
| undefined;
|
|
50
|
-
private
|
|
54
|
+
private rootRollupProof: ProofState<RootRollupPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH> | undefined;
|
|
55
|
+
private checkpoints: (CheckpointProvingState | undefined)[] = [];
|
|
56
|
+
private startBlobAccumulator: BatchedBlobAccumulator;
|
|
57
|
+
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
58
|
+
private finalBatchedBlob: BatchedBlob | undefined;
|
|
51
59
|
private provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
|
|
52
60
|
|
|
53
|
-
// Map from tx hash to
|
|
54
|
-
public readonly
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
// Map from tx hash to chonk verifier proof promise. Used when kickstarting chonk verifier proofs before tx processing.
|
|
62
|
+
public readonly cachedChonkVerifierProofs = new Map<
|
|
63
|
+
string,
|
|
64
|
+
Promise<
|
|
65
|
+
PublicInputsAndRecursiveProof<PublicChonkVerifierPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
66
|
+
>
|
|
67
|
+
>();
|
|
57
68
|
|
|
58
69
|
constructor(
|
|
59
|
-
public readonly epochNumber:
|
|
60
|
-
public readonly
|
|
61
|
-
|
|
70
|
+
public readonly epochNumber: EpochNumber,
|
|
71
|
+
public readonly totalNumCheckpoints: number,
|
|
72
|
+
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
73
|
+
private onCheckpointBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
|
|
62
74
|
private completionCallback: (result: ProvingResult) => void,
|
|
63
75
|
private rejectionCallback: (reason: string) => void,
|
|
64
76
|
) {
|
|
65
|
-
this.
|
|
77
|
+
this.checkpointProofs = new UnbalancedTreeStore(totalNumCheckpoints);
|
|
78
|
+
this.startBlobAccumulator = BatchedBlobAccumulator.newWithChallenges(finalBlobBatchingChallenges);
|
|
66
79
|
}
|
|
67
80
|
|
|
68
81
|
// Adds a block to the proving state, returns its index
|
|
69
82
|
// Will update the proving life cycle if this is the last block
|
|
70
|
-
public
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
l1ToL2MessageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot,
|
|
75
|
-
lastArchiveSnapshot: AppendOnlyTreeSnapshot,
|
|
76
|
-
newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
83
|
+
public startNewCheckpoint(
|
|
84
|
+
checkpointIndex: number,
|
|
85
|
+
constants: CheckpointConstantData,
|
|
86
|
+
totalNumBlocks: number,
|
|
77
87
|
previousBlockHeader: BlockHeader,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
89
|
+
l1ToL2Messages: Fr[],
|
|
90
|
+
lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
91
|
+
lastL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
|
|
92
|
+
newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
93
|
+
newL1ToL2MessageSubtreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH>,
|
|
94
|
+
): CheckpointProvingState {
|
|
95
|
+
if (checkpointIndex >= this.totalNumCheckpoints) {
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Unable to start a new checkpoint at index ${checkpointIndex}. Expected at most ${this.totalNumCheckpoints} checkpoints.`,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const checkpoint = new CheckpointProvingState(
|
|
102
|
+
checkpointIndex,
|
|
103
|
+
constants,
|
|
104
|
+
totalNumBlocks,
|
|
105
|
+
this.finalBlobBatchingChallenges,
|
|
88
106
|
previousBlockHeader,
|
|
107
|
+
lastArchiveSiblingPath,
|
|
108
|
+
l1ToL2Messages,
|
|
109
|
+
lastL1ToL2MessageTreeSnapshot,
|
|
110
|
+
lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
111
|
+
newL1ToL2MessageTreeSnapshot,
|
|
112
|
+
newL1ToL2MessageSubtreeRootSiblingPath,
|
|
89
113
|
this,
|
|
114
|
+
this.onCheckpointBlobAccumulatorSet,
|
|
90
115
|
);
|
|
91
|
-
this.
|
|
92
|
-
|
|
116
|
+
this.checkpoints[checkpointIndex] = checkpoint;
|
|
117
|
+
|
|
118
|
+
if (this.checkpoints.filter(c => !!c).length === this.totalNumCheckpoints) {
|
|
93
119
|
this.provingStateLifecycle = PROVING_STATE_LIFECYCLE.PROVING_STATE_FULL;
|
|
94
120
|
}
|
|
95
|
-
|
|
121
|
+
|
|
122
|
+
return checkpoint;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public getCheckpointProvingState(index: number) {
|
|
126
|
+
return this.checkpoints[index];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public getCheckpointProvingStateByBlockNumber(blockNumber: number) {
|
|
130
|
+
return this.checkpoints.find(
|
|
131
|
+
c => c && blockNumber >= c.firstBlockNumber && blockNumber < c.firstBlockNumber + c.totalNumBlocks,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public getBlockProvingStateByBlockNumber(blockNumber: number) {
|
|
136
|
+
return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
|
|
96
137
|
}
|
|
97
138
|
|
|
98
139
|
// Returns true if this proving state is still valid, false otherwise
|
|
@@ -103,95 +144,146 @@ export class EpochProvingState {
|
|
|
103
144
|
);
|
|
104
145
|
}
|
|
105
146
|
|
|
106
|
-
// Returns true if we are still able to accept
|
|
107
|
-
public
|
|
108
|
-
return this.
|
|
147
|
+
// Returns true if we are still able to accept checkpoints, false otherwise.
|
|
148
|
+
public isAcceptingCheckpoints() {
|
|
149
|
+
return this.checkpoints.filter(c => !!c).length < this.totalNumCheckpoints;
|
|
109
150
|
}
|
|
110
151
|
|
|
111
|
-
public
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
152
|
+
public setCheckpointRootRollupProof(
|
|
153
|
+
checkpointIndex: number,
|
|
154
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
155
|
+
CheckpointRollupPublicInputs,
|
|
115
156
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
116
157
|
>,
|
|
117
158
|
): TreeNodeLocation {
|
|
118
|
-
return this.
|
|
159
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
|
|
163
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
164
|
+
return false;
|
|
165
|
+
} else {
|
|
166
|
+
this.checkpointProofs.setNode(location, { isProving: true });
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
119
169
|
}
|
|
120
170
|
|
|
121
|
-
public
|
|
171
|
+
public setCheckpointMergeRollupProof(
|
|
122
172
|
location: TreeNodeLocation,
|
|
123
|
-
|
|
124
|
-
|
|
173
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
174
|
+
CheckpointRollupPublicInputs,
|
|
125
175
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
126
176
|
>,
|
|
127
177
|
) {
|
|
128
|
-
this.
|
|
178
|
+
this.checkpointProofs.setNode(location, { provingOutput });
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
public tryStartProvingRootRollup() {
|
|
182
|
+
if (this.rootRollupProof?.isProving) {
|
|
183
|
+
return false;
|
|
184
|
+
} else {
|
|
185
|
+
this.rootRollupProof = { isProving: true };
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
129
188
|
}
|
|
130
189
|
|
|
131
|
-
public setRootRollupProof(
|
|
132
|
-
this.
|
|
190
|
+
public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
|
|
191
|
+
this.rootRollupProof = { provingOutput };
|
|
133
192
|
}
|
|
134
193
|
|
|
135
|
-
public
|
|
136
|
-
|
|
137
|
-
|
|
194
|
+
public tryStartProvingPaddingCheckpoint() {
|
|
195
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
196
|
+
return false;
|
|
197
|
+
} else {
|
|
198
|
+
this.checkpointPaddingProof = { isProving: true };
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
public setCheckpointPaddingProof(
|
|
204
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
205
|
+
CheckpointRollupPublicInputs,
|
|
138
206
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
139
207
|
>,
|
|
140
208
|
) {
|
|
141
|
-
this.
|
|
209
|
+
this.checkpointPaddingProof = { provingOutput };
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public async setBlobAccumulators() {
|
|
213
|
+
let previousAccumulator = this.startBlobAccumulator;
|
|
214
|
+
// Accumulate blobs as far as we can for this epoch.
|
|
215
|
+
for (let i = 0; i < this.totalNumCheckpoints; i++) {
|
|
216
|
+
const checkpoint = this.checkpoints[i];
|
|
217
|
+
if (!checkpoint) {
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const endAccumulator =
|
|
222
|
+
checkpoint.getEndBlobAccumulator() || (await checkpoint.accumulateBlobs(previousAccumulator));
|
|
223
|
+
if (!endAccumulator) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
previousAccumulator = endAccumulator;
|
|
228
|
+
|
|
229
|
+
// If this is the last checkpoint, set the end blob accumulator.
|
|
230
|
+
if (i === this.totalNumCheckpoints - 1) {
|
|
231
|
+
this.endBlobAccumulator = endAccumulator;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public async finalizeBatchedBlob() {
|
|
237
|
+
if (!this.endBlobAccumulator) {
|
|
238
|
+
throw new Error('End blob accumulator not ready.');
|
|
239
|
+
}
|
|
240
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
|
|
142
241
|
}
|
|
143
242
|
|
|
144
243
|
public getParentLocation(location: TreeNodeLocation) {
|
|
145
|
-
return this.
|
|
244
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
146
245
|
}
|
|
147
246
|
|
|
148
|
-
public
|
|
149
|
-
const [left, right] = this.
|
|
247
|
+
public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
248
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
150
249
|
if (!left || !right) {
|
|
151
|
-
throw new Error('At
|
|
250
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
152
251
|
}
|
|
153
252
|
|
|
154
|
-
return new
|
|
253
|
+
return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
155
254
|
}
|
|
156
255
|
|
|
157
|
-
public getRootRollupInputs(
|
|
256
|
+
public getRootRollupInputs() {
|
|
158
257
|
const [left, right] = this.#getChildProofsForRoot();
|
|
159
258
|
if (!left || !right) {
|
|
160
|
-
throw new Error('At
|
|
259
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
161
260
|
}
|
|
162
261
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
proverId,
|
|
262
|
+
return RootRollupPrivateInputs.from({
|
|
263
|
+
previousRollups: [toProofData(left), toProofData(right)],
|
|
166
264
|
});
|
|
167
265
|
}
|
|
168
266
|
|
|
169
|
-
public
|
|
170
|
-
|
|
171
|
-
throw new Error('Epoch needs one completed block in order to be padded.');
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return this.blocks[0].getPaddingBlockRootInputs(proverId);
|
|
267
|
+
public getPaddingCheckpointInputs() {
|
|
268
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
175
269
|
}
|
|
176
270
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return this.blocks.find(block => block?.blockNumber === blockNumber);
|
|
180
|
-
}
|
|
271
|
+
public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
|
|
272
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
181
273
|
|
|
182
|
-
|
|
183
|
-
if (!this.rootRollupProvingOutput) {
|
|
274
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
184
275
|
throw new Error('Unable to get epoch proof result. Root rollup is not ready.');
|
|
185
276
|
}
|
|
186
277
|
|
|
187
278
|
return {
|
|
188
|
-
proof:
|
|
189
|
-
publicInputs:
|
|
279
|
+
proof: provingOutput.proof.binaryProof,
|
|
280
|
+
publicInputs: provingOutput.inputs,
|
|
281
|
+
batchedBlobInputs: this.finalBatchedBlob,
|
|
190
282
|
};
|
|
191
283
|
}
|
|
192
284
|
|
|
193
|
-
public
|
|
194
|
-
return this.
|
|
285
|
+
public isReadyForCheckpointMerge(location: TreeNodeLocation) {
|
|
286
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
195
287
|
}
|
|
196
288
|
|
|
197
289
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
@@ -228,25 +320,8 @@ export class EpochProvingState {
|
|
|
228
320
|
#getChildProofsForRoot() {
|
|
229
321
|
const rootLocation = { level: 0, index: 0 };
|
|
230
322
|
// If there's only 1 block, its block root proof will be stored at the root.
|
|
231
|
-
return this.
|
|
232
|
-
? [this.
|
|
233
|
-
: this.
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
#getPreviousRollupData({
|
|
237
|
-
inputs,
|
|
238
|
-
proof,
|
|
239
|
-
verificationKey,
|
|
240
|
-
}: PublicInputsAndRecursiveProof<
|
|
241
|
-
BlockRootOrBlockMergePublicInputs,
|
|
242
|
-
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
243
|
-
>) {
|
|
244
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
245
|
-
return new PreviousRollupBlockData(
|
|
246
|
-
inputs,
|
|
247
|
-
proof,
|
|
248
|
-
verificationKey.keyAsFields,
|
|
249
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
250
|
-
);
|
|
323
|
+
return this.totalNumCheckpoints === 1
|
|
324
|
+
? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
|
|
325
|
+
: this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
251
326
|
}
|
|
252
327
|
}
|