@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
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BatchedBlobAccumulator,
|
|
3
|
+
type FinalBlobBatchingChallenges,
|
|
4
|
+
SpongeBlob,
|
|
5
|
+
encodeCheckpointBlobDataFromBlocks,
|
|
6
|
+
} from '@aztec/blob-lib';
|
|
7
|
+
import {
|
|
8
|
+
type ARCHIVE_HEIGHT,
|
|
9
|
+
BLOBS_PER_CHECKPOINT,
|
|
10
|
+
FIELDS_PER_BLOB,
|
|
11
|
+
type L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH,
|
|
12
|
+
type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
13
|
+
NUM_MSGS_PER_BASE_PARITY,
|
|
14
|
+
} from '@aztec/constants';
|
|
15
|
+
import { BlockNumber } from '@aztec/foundation/branded-types';
|
|
16
|
+
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
17
|
+
import { BLS12Point } from '@aztec/foundation/curves/bls12';
|
|
18
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
19
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
20
|
+
import { type TreeNodeLocation, UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
21
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
22
|
+
import { ParityBasePrivateInputs } from '@aztec/stdlib/parity';
|
|
23
|
+
import {
|
|
24
|
+
BlockMergeRollupPrivateInputs,
|
|
25
|
+
BlockRollupPublicInputs,
|
|
26
|
+
CheckpointConstantData,
|
|
27
|
+
CheckpointRollupPublicInputs,
|
|
28
|
+
CheckpointRootRollupHints,
|
|
29
|
+
CheckpointRootRollupPrivateInputs,
|
|
30
|
+
CheckpointRootSingleBlockRollupPrivateInputs,
|
|
31
|
+
} from '@aztec/stdlib/rollup';
|
|
32
|
+
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
33
|
+
import type { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
34
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
35
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
36
|
+
|
|
37
|
+
import { accumulateBlobs, buildBlobHints, toProofData } from './block-building-helpers.js';
|
|
38
|
+
import { BlockProvingState, type ProofState } from './block-proving-state.js';
|
|
39
|
+
import type { EpochProvingState } from './epoch-proving-state.js';
|
|
40
|
+
|
|
41
|
+
export class CheckpointProvingState {
|
|
42
|
+
private blockProofs: UnbalancedTreeStore<
|
|
43
|
+
ProofState<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
44
|
+
>;
|
|
45
|
+
private checkpointRootProof:
|
|
46
|
+
| ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
47
|
+
| undefined;
|
|
48
|
+
private blocks: (BlockProvingState | undefined)[] = [];
|
|
49
|
+
private startBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
50
|
+
private endBlobAccumulator: BatchedBlobAccumulator | undefined;
|
|
51
|
+
private blobFields: Fr[] | undefined;
|
|
52
|
+
private error: string | undefined;
|
|
53
|
+
public readonly firstBlockNumber: BlockNumber;
|
|
54
|
+
|
|
55
|
+
constructor(
|
|
56
|
+
public readonly index: number,
|
|
57
|
+
public readonly constants: CheckpointConstantData,
|
|
58
|
+
public readonly totalNumBlocks: number,
|
|
59
|
+
private readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
|
|
60
|
+
private readonly headerOfLastBlockInPreviousCheckpoint: BlockHeader,
|
|
61
|
+
private readonly lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
62
|
+
private readonly l1ToL2Messages: Fr[],
|
|
63
|
+
// The snapshot and sibling path before the new l1 to l2 message subtree is inserted.
|
|
64
|
+
private readonly lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
65
|
+
private readonly lastL1ToL2MessageSubtreeRootSiblingPath: Tuple<
|
|
66
|
+
Fr,
|
|
67
|
+
typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
|
|
68
|
+
>,
|
|
69
|
+
// The snapshot and sibling path after the new l1 to l2 message subtree is inserted.
|
|
70
|
+
private readonly newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
71
|
+
private readonly newL1ToL2MessageSubtreeRootSiblingPath: Tuple<
|
|
72
|
+
Fr,
|
|
73
|
+
typeof L1_TO_L2_MSG_SUBTREE_ROOT_SIBLING_PATH_LENGTH
|
|
74
|
+
>,
|
|
75
|
+
public parentEpoch: EpochProvingState,
|
|
76
|
+
private onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void,
|
|
77
|
+
) {
|
|
78
|
+
this.blockProofs = new UnbalancedTreeStore(totalNumBlocks);
|
|
79
|
+
this.firstBlockNumber = BlockNumber(headerOfLastBlockInPreviousCheckpoint.globalVariables.blockNumber + 1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get epochNumber(): number {
|
|
83
|
+
return this.parentEpoch.epochNumber;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public startNewBlock(
|
|
87
|
+
blockNumber: BlockNumber,
|
|
88
|
+
timestamp: UInt64,
|
|
89
|
+
totalNumTxs: number,
|
|
90
|
+
lastArchiveTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
91
|
+
lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>,
|
|
92
|
+
): BlockProvingState {
|
|
93
|
+
const index = Number(blockNumber) - Number(this.firstBlockNumber);
|
|
94
|
+
if (index >= this.totalNumBlocks) {
|
|
95
|
+
throw new Error(`Unable to start a new block at index ${index}. Expected at most ${this.totalNumBlocks} blocks.`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// If this is the first block, we use the snapshot and sibling path before the new l1 to l2 messages are inserted.
|
|
99
|
+
// Otherwise, we use the snapshot and sibling path after the new l1 to l2 messages are inserted, which will always
|
|
100
|
+
// happen in the first block.
|
|
101
|
+
const lastL1ToL2MessageTreeSnapshot =
|
|
102
|
+
index === 0 ? this.lastL1ToL2MessageTreeSnapshot : this.newL1ToL2MessageTreeSnapshot;
|
|
103
|
+
const lastL1ToL2MessageSubtreeRootSiblingPath =
|
|
104
|
+
index === 0 ? this.lastL1ToL2MessageSubtreeRootSiblingPath : this.newL1ToL2MessageSubtreeRootSiblingPath;
|
|
105
|
+
|
|
106
|
+
const startSpongeBlob = index === 0 ? SpongeBlob.init() : this.blocks[index - 1]?.getEndSpongeBlob();
|
|
107
|
+
if (!startSpongeBlob) {
|
|
108
|
+
throw new Error(
|
|
109
|
+
'Cannot start a new block before the trees have progressed from the tx effects in the previous block.',
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const block = new BlockProvingState(
|
|
114
|
+
index,
|
|
115
|
+
blockNumber,
|
|
116
|
+
totalNumTxs,
|
|
117
|
+
this.constants,
|
|
118
|
+
timestamp,
|
|
119
|
+
lastArchiveTreeSnapshot,
|
|
120
|
+
lastArchiveSiblingPath,
|
|
121
|
+
lastL1ToL2MessageTreeSnapshot,
|
|
122
|
+
lastL1ToL2MessageSubtreeRootSiblingPath,
|
|
123
|
+
this.newL1ToL2MessageTreeSnapshot,
|
|
124
|
+
this.headerOfLastBlockInPreviousCheckpoint,
|
|
125
|
+
startSpongeBlob,
|
|
126
|
+
this,
|
|
127
|
+
);
|
|
128
|
+
this.blocks[index] = block;
|
|
129
|
+
|
|
130
|
+
return block;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Returns true if we are still able to accept blocks, false otherwise.
|
|
134
|
+
public isAcceptingBlocks() {
|
|
135
|
+
return this.blocks.filter(b => !!b).length < this.totalNumBlocks;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public setBlockRootRollupProof(
|
|
139
|
+
blockIndex: number,
|
|
140
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
141
|
+
BlockRollupPublicInputs,
|
|
142
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
143
|
+
>,
|
|
144
|
+
): TreeNodeLocation {
|
|
145
|
+
return this.blockProofs.setLeaf(blockIndex, { provingOutput });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
public tryStartProvingBlockMerge(location: TreeNodeLocation) {
|
|
149
|
+
if (this.blockProofs.getNode(location)?.isProving) {
|
|
150
|
+
return false;
|
|
151
|
+
} else {
|
|
152
|
+
this.blockProofs.setNode(location, { isProving: true });
|
|
153
|
+
return true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public setBlockMergeRollupProof(
|
|
158
|
+
location: TreeNodeLocation,
|
|
159
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
160
|
+
BlockRollupPublicInputs,
|
|
161
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
162
|
+
>,
|
|
163
|
+
) {
|
|
164
|
+
this.blockProofs.setNode(location, { provingOutput });
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
public tryStartProvingCheckpointRoot() {
|
|
168
|
+
if (this.checkpointRootProof?.isProving) {
|
|
169
|
+
return false;
|
|
170
|
+
} else {
|
|
171
|
+
this.checkpointRootProof = { isProving: true };
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public setCheckpointRootRollupProof(
|
|
177
|
+
provingOutput: PublicInputsAndRecursiveProof<
|
|
178
|
+
CheckpointRollupPublicInputs,
|
|
179
|
+
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
180
|
+
>,
|
|
181
|
+
): TreeNodeLocation {
|
|
182
|
+
this.checkpointRootProof = { provingOutput };
|
|
183
|
+
return this.parentEpoch.setCheckpointRootRollupProof(this.index, provingOutput);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
public getBaseParityInputs(baseParityIndex: number) {
|
|
187
|
+
const messages = padArrayEnd(
|
|
188
|
+
this.l1ToL2Messages.slice(
|
|
189
|
+
baseParityIndex * NUM_MSGS_PER_BASE_PARITY,
|
|
190
|
+
(baseParityIndex + 1) * NUM_MSGS_PER_BASE_PARITY,
|
|
191
|
+
),
|
|
192
|
+
Fr.ZERO,
|
|
193
|
+
NUM_MSGS_PER_BASE_PARITY,
|
|
194
|
+
);
|
|
195
|
+
return new ParityBasePrivateInputs(messages, this.constants.vkTreeRoot);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public async accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator) {
|
|
199
|
+
if (this.isAcceptingBlocks() || this.blocks.some(b => !b?.hasEndState())) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.blobFields = encodeCheckpointBlobDataFromBlocks(this.blocks.map(b => b!.getBlockBlobData()));
|
|
204
|
+
this.endBlobAccumulator = await accumulateBlobs(this.blobFields!, startBlobAccumulator);
|
|
205
|
+
this.startBlobAccumulator = startBlobAccumulator;
|
|
206
|
+
|
|
207
|
+
this.onBlobAccumulatorSet(this);
|
|
208
|
+
|
|
209
|
+
return this.endBlobAccumulator;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public getEndBlobAccumulator() {
|
|
213
|
+
return this.endBlobAccumulator;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public getParentLocation(location: TreeNodeLocation) {
|
|
217
|
+
return this.blockProofs.getParentLocation(location);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
221
|
+
const [left, right] = this.blockProofs.getChildren(mergeLocation).map(c => c?.provingOutput);
|
|
222
|
+
if (!left || !right) {
|
|
223
|
+
throw new Error('At least one child is not ready for the block merge rollup.');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return new BlockMergeRollupPrivateInputs([toProofData(left), toProofData(right)]);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
public getCheckpointRootRollupType(): CircuitName {
|
|
230
|
+
return this.totalNumBlocks === 1 ? 'rollup-checkpoint-root-single-block' : 'rollup-checkpoint-root';
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
public getCheckpointRootRollupInputs() {
|
|
234
|
+
const proofs = this.#getChildProofsForRoot();
|
|
235
|
+
const nonEmptyProofs = proofs.filter(p => !!p);
|
|
236
|
+
if (proofs.length !== nonEmptyProofs.length) {
|
|
237
|
+
throw new Error('At least one child is not ready for the checkpoint root rollup.');
|
|
238
|
+
}
|
|
239
|
+
if (!this.startBlobAccumulator) {
|
|
240
|
+
throw new Error('Start blob accumulator is not set.');
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// `blobFields` must've been set if `startBlobAccumulator` is set (in `accumulateBlobs`).
|
|
244
|
+
const blobFields = this.blobFields!;
|
|
245
|
+
|
|
246
|
+
const { blobCommitments, blobsHash } = buildBlobHints(blobFields);
|
|
247
|
+
|
|
248
|
+
const hints = CheckpointRootRollupHints.from({
|
|
249
|
+
previousBlockHeader: this.headerOfLastBlockInPreviousCheckpoint,
|
|
250
|
+
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
251
|
+
startBlobAccumulator: this.startBlobAccumulator.toBlobAccumulator(),
|
|
252
|
+
finalBlobChallenges: this.finalBlobBatchingChallenges,
|
|
253
|
+
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_CHECKPOINT),
|
|
254
|
+
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_CHECKPOINT),
|
|
255
|
+
blobsHash,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const [left, right] = nonEmptyProofs.map(p => toProofData(p));
|
|
259
|
+
|
|
260
|
+
return !right
|
|
261
|
+
? new CheckpointRootSingleBlockRollupPrivateInputs(left, hints)
|
|
262
|
+
: new CheckpointRootRollupPrivateInputs([left, right], hints);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
public getBlockProvingStateByBlockNumber(blockNumber: BlockNumber) {
|
|
266
|
+
const index = Number(blockNumber) - Number(this.firstBlockNumber);
|
|
267
|
+
return this.blocks[index];
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public isReadyForBlockMerge(location: TreeNodeLocation) {
|
|
271
|
+
return !!this.blockProofs.getSibling(location)?.provingOutput;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
public isReadyForCheckpointRoot() {
|
|
275
|
+
const allChildProofsReady = this.#getChildProofsForRoot().every(p => !!p);
|
|
276
|
+
return allChildProofsReady && !!this.startBlobAccumulator;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
public verifyState() {
|
|
280
|
+
return this.parentEpoch.verifyState();
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public getError() {
|
|
284
|
+
return this.error;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Attempts to reject the proving state promise with a reason of 'cancelled'
|
|
288
|
+
public cancel() {
|
|
289
|
+
this.reject('Proving cancelled');
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
public reject(reason: string) {
|
|
293
|
+
this.error = reason;
|
|
294
|
+
this.parentEpoch.reject(reason);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
#getChildProofsForRoot() {
|
|
298
|
+
const rootLocation = { level: 0, index: 0 };
|
|
299
|
+
return this.totalNumBlocks === 1
|
|
300
|
+
? [this.blockProofs.getNode(rootLocation)?.provingOutput] // If there's only 1 block, its proof will be stored at the root.
|
|
301
|
+
: this.blockProofs.getChildren(rootLocation).map(c => c?.provingOutput);
|
|
302
|
+
}
|
|
303
|
+
}
|