@aztec/prover-client 0.0.0-test.0 → 0.0.1-commit.03f7ef2
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 +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 +36 -0
- package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
- package/dest/light/lightweight_checkpoint_builder.js +147 -0
- package/dest/mocks/fixtures.d.ts +8 -8
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +34 -16
- package/dest/mocks/test_context.d.ts +41 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +138 -87
- package/dest/orchestrator/block-building-helpers.d.ts +37 -30
- 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 +70 -48
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +282 -177
- package/dest/orchestrator/checkpoint-proving-state.d.ts +63 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +210 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +41 -27
- 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 +36 -33
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +379 -250
- package/dest/orchestrator/orchestrator_metrics.d.ts +1 -1
- package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
- 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 +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 +23 -16
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +59 -40
- package/dest/proving_broker/config.d.ts +19 -10
- package/dest/proving_broker/config.d.ts.map +1 -1
- package/dest/proving_broker/config.js +23 -6
- 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 -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 +39 -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 +87 -60
- 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 +37 -19
- package/package.json +34 -31
- package/src/block-factory/index.ts +1 -0
- package/src/block-factory/light.ts +137 -0
- package/src/config.ts +25 -9
- package/src/light/index.ts +1 -0
- package/src/light/lightweight_checkpoint_builder.ts +198 -0
- package/src/mocks/fixtures.ts +44 -39
- package/src/mocks/test_context.ts +213 -116
- package/src/orchestrator/block-building-helpers.ts +258 -334
- package/src/orchestrator/block-proving-state.ts +325 -231
- package/src/orchestrator/checkpoint-proving-state.ts +303 -0
- package/src/orchestrator/epoch-proving-state.ts +191 -113
- package/src/orchestrator/orchestrator.ts +582 -314
- package/src/orchestrator/tx-proving-state.ts +49 -64
- package/src/prover-client/prover-client.ts +16 -14
- package/src/prover-client/server-epoch-prover.ts +40 -22
- package/src/proving_broker/broker_prover_facade.ts +205 -126
- package/src/proving_broker/config.ts +25 -7
- package/src/proving_broker/factory.ts +2 -1
- package/src/proving_broker/fixtures.ts +8 -3
- 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 +56 -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 +92 -81
- package/src/proving_broker/rpc.ts +1 -6
- package/src/test/mock_proof_store.ts +14 -0
- package/src/test/mock_prover.ts +158 -59
- 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
|
|
8
|
+
import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
|
|
9
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
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,98 @@ 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: BlockNumber) {
|
|
130
|
+
return this.checkpoints.find(
|
|
131
|
+
c =>
|
|
132
|
+
c &&
|
|
133
|
+
Number(blockNumber) >= Number(c.firstBlockNumber) &&
|
|
134
|
+
Number(blockNumber) < Number(c.firstBlockNumber) + c.totalNumBlocks,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
|
|
139
|
+
return this.getCheckpointProvingStateByBlockNumber(blockNumber)?.getBlockProvingStateByBlockNumber(blockNumber);
|
|
96
140
|
}
|
|
97
141
|
|
|
98
142
|
// Returns true if this proving state is still valid, false otherwise
|
|
@@ -103,95 +147,146 @@ export class EpochProvingState {
|
|
|
103
147
|
);
|
|
104
148
|
}
|
|
105
149
|
|
|
106
|
-
// Returns true if we are still able to accept
|
|
107
|
-
public
|
|
108
|
-
return this.
|
|
150
|
+
// Returns true if we are still able to accept checkpoints, false otherwise.
|
|
151
|
+
public isAcceptingCheckpoints() {
|
|
152
|
+
return this.checkpoints.filter(c => !!c).length < this.totalNumCheckpoints;
|
|
109
153
|
}
|
|
110
154
|
|
|
111
|
-
public
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
155
|
+
public setCheckpointRootRollupProof(
|
|
156
|
+
checkpointIndex: number,
|
|
157
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
158
|
+
CheckpointRollupPublicInputs,
|
|
115
159
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
116
160
|
>,
|
|
117
161
|
): TreeNodeLocation {
|
|
118
|
-
return this.
|
|
162
|
+
return this.checkpointProofs.setLeaf(checkpointIndex, { provingOutput });
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public tryStartProvingCheckpointMerge(location: TreeNodeLocation) {
|
|
166
|
+
if (this.checkpointProofs.getNode(location)?.isProving) {
|
|
167
|
+
return false;
|
|
168
|
+
} else {
|
|
169
|
+
this.checkpointProofs.setNode(location, { isProving: true });
|
|
170
|
+
return true;
|
|
171
|
+
}
|
|
119
172
|
}
|
|
120
173
|
|
|
121
|
-
public
|
|
174
|
+
public setCheckpointMergeRollupProof(
|
|
122
175
|
location: TreeNodeLocation,
|
|
123
|
-
|
|
124
|
-
|
|
176
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
177
|
+
CheckpointRollupPublicInputs,
|
|
125
178
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
126
179
|
>,
|
|
127
180
|
) {
|
|
128
|
-
this.
|
|
181
|
+
this.checkpointProofs.setNode(location, { provingOutput });
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public tryStartProvingRootRollup() {
|
|
185
|
+
if (this.rootRollupProof?.isProving) {
|
|
186
|
+
return false;
|
|
187
|
+
} else {
|
|
188
|
+
this.rootRollupProof = { isProving: true };
|
|
189
|
+
return true;
|
|
190
|
+
}
|
|
129
191
|
}
|
|
130
192
|
|
|
131
|
-
public setRootRollupProof(
|
|
132
|
-
this.
|
|
193
|
+
public setRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
|
|
194
|
+
this.rootRollupProof = { provingOutput };
|
|
133
195
|
}
|
|
134
196
|
|
|
135
|
-
public
|
|
136
|
-
|
|
137
|
-
|
|
197
|
+
public tryStartProvingPaddingCheckpoint() {
|
|
198
|
+
if (this.checkpointPaddingProof?.isProving) {
|
|
199
|
+
return false;
|
|
200
|
+
} else {
|
|
201
|
+
this.checkpointPaddingProof = { isProving: true };
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public setCheckpointPaddingProof(
|
|
207
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
208
|
+
CheckpointRollupPublicInputs,
|
|
138
209
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
139
210
|
>,
|
|
140
211
|
) {
|
|
141
|
-
this.
|
|
212
|
+
this.checkpointPaddingProof = { provingOutput };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
public async setBlobAccumulators() {
|
|
216
|
+
let previousAccumulator = this.startBlobAccumulator;
|
|
217
|
+
// Accumulate blobs as far as we can for this epoch.
|
|
218
|
+
for (let i = 0; i < this.totalNumCheckpoints; i++) {
|
|
219
|
+
const checkpoint = this.checkpoints[i];
|
|
220
|
+
if (!checkpoint) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
const endAccumulator =
|
|
225
|
+
checkpoint.getEndBlobAccumulator() || (await checkpoint.accumulateBlobs(previousAccumulator));
|
|
226
|
+
if (!endAccumulator) {
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
previousAccumulator = endAccumulator;
|
|
231
|
+
|
|
232
|
+
// If this is the last checkpoint, set the end blob accumulator.
|
|
233
|
+
if (i === this.totalNumCheckpoints - 1) {
|
|
234
|
+
this.endBlobAccumulator = endAccumulator;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public async finalizeBatchedBlob() {
|
|
240
|
+
if (!this.endBlobAccumulator) {
|
|
241
|
+
throw new Error('End blob accumulator not ready.');
|
|
242
|
+
}
|
|
243
|
+
this.finalBatchedBlob = await this.endBlobAccumulator.finalize(true /* verifyProof */);
|
|
142
244
|
}
|
|
143
245
|
|
|
144
246
|
public getParentLocation(location: TreeNodeLocation) {
|
|
145
|
-
return this.
|
|
247
|
+
return this.checkpointProofs.getParentLocation(location);
|
|
146
248
|
}
|
|
147
249
|
|
|
148
|
-
public
|
|
149
|
-
const [left, right] = this.
|
|
250
|
+
public getCheckpointMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
251
|
+
const [left, right] = this.checkpointProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
150
252
|
if (!left || !right) {
|
|
151
|
-
throw new Error('At
|
|
253
|
+
throw new Error('At least one child is not ready for the checkpoint merge rollup.');
|
|
152
254
|
}
|
|
153
255
|
|
|
154
|
-
return new
|
|
256
|
+
return new CheckpointMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
155
257
|
}
|
|
156
258
|
|
|
157
|
-
public getRootRollupInputs(
|
|
259
|
+
public getRootRollupInputs() {
|
|
158
260
|
const [left, right] = this.#getChildProofsForRoot();
|
|
159
261
|
if (!left || !right) {
|
|
160
|
-
throw new Error('At
|
|
262
|
+
throw new Error('At least one child is not ready for the root rollup.');
|
|
161
263
|
}
|
|
162
264
|
|
|
163
|
-
return
|
|
164
|
-
|
|
165
|
-
proverId,
|
|
265
|
+
return RootRollupPrivateInputs.from({
|
|
266
|
+
previousRollups: [toProofData(left), toProofData(right)],
|
|
166
267
|
});
|
|
167
268
|
}
|
|
168
269
|
|
|
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);
|
|
270
|
+
public getPaddingCheckpointInputs() {
|
|
271
|
+
return new CheckpointPaddingRollupPrivateInputs();
|
|
175
272
|
}
|
|
176
273
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
return this.blocks.find(block => block?.blockNumber === blockNumber);
|
|
180
|
-
}
|
|
274
|
+
public getEpochProofResult(): { proof: Proof; publicInputs: RootRollupPublicInputs; batchedBlobInputs: BatchedBlob } {
|
|
275
|
+
const provingOutput = this.rootRollupProof?.provingOutput;
|
|
181
276
|
|
|
182
|
-
|
|
183
|
-
if (!this.rootRollupProvingOutput) {
|
|
277
|
+
if (!provingOutput || !this.finalBatchedBlob) {
|
|
184
278
|
throw new Error('Unable to get epoch proof result. Root rollup is not ready.');
|
|
185
279
|
}
|
|
186
280
|
|
|
187
281
|
return {
|
|
188
|
-
proof:
|
|
189
|
-
publicInputs:
|
|
282
|
+
proof: provingOutput.proof.binaryProof,
|
|
283
|
+
publicInputs: provingOutput.inputs,
|
|
284
|
+
batchedBlobInputs: this.finalBatchedBlob,
|
|
190
285
|
};
|
|
191
286
|
}
|
|
192
287
|
|
|
193
|
-
public
|
|
194
|
-
return this.
|
|
288
|
+
public isReadyForCheckpointMerge(location: TreeNodeLocation) {
|
|
289
|
+
return !!this.checkpointProofs.getSibling(location)?.provingOutput;
|
|
195
290
|
}
|
|
196
291
|
|
|
197
292
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
@@ -228,25 +323,8 @@ export class EpochProvingState {
|
|
|
228
323
|
#getChildProofsForRoot() {
|
|
229
324
|
const rootLocation = { level: 0, index: 0 };
|
|
230
325
|
// 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
|
-
);
|
|
326
|
+
return this.totalNumCheckpoints === 1
|
|
327
|
+
? [this.checkpointProofs.getNode(rootLocation)?.provingOutput, this.checkpointPaddingProof?.provingOutput]
|
|
328
|
+
: this.checkpointProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
251
329
|
}
|
|
252
330
|
}
|