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