@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.
Files changed (133) hide show
  1. package/dest/block-factory/index.d.ts +1 -1
  2. package/dest/block-factory/light.d.ts +5 -3
  3. package/dest/block-factory/light.d.ts.map +1 -1
  4. package/dest/block-factory/light.js +32 -11
  5. package/dest/config.d.ts +2 -2
  6. package/dest/config.d.ts.map +1 -1
  7. package/dest/config.js +2 -2
  8. package/dest/index.d.ts +1 -1
  9. package/dest/light/index.d.ts +2 -0
  10. package/dest/light/index.d.ts.map +1 -0
  11. package/dest/light/index.js +1 -0
  12. package/dest/light/lightweight_checkpoint_builder.d.ts +36 -0
  13. package/dest/light/lightweight_checkpoint_builder.d.ts.map +1 -0
  14. package/dest/light/lightweight_checkpoint_builder.js +147 -0
  15. package/dest/mocks/fixtures.d.ts +5 -5
  16. package/dest/mocks/fixtures.d.ts.map +1 -1
  17. package/dest/mocks/fixtures.js +33 -15
  18. package/dest/mocks/test_context.d.ts +38 -33
  19. package/dest/mocks/test_context.d.ts.map +1 -1
  20. package/dest/mocks/test_context.js +133 -82
  21. package/dest/orchestrator/block-building-helpers.d.ts +35 -35
  22. package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
  23. package/dest/orchestrator/block-building-helpers.js +151 -187
  24. package/dest/orchestrator/block-proving-state.d.ts +68 -55
  25. package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
  26. package/dest/orchestrator/block-proving-state.js +273 -185
  27. package/dest/orchestrator/checkpoint-proving-state.d.ts +63 -0
  28. package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
  29. package/dest/orchestrator/checkpoint-proving-state.js +210 -0
  30. package/dest/orchestrator/epoch-proving-state.d.ts +38 -31
  31. package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
  32. package/dest/orchestrator/epoch-proving-state.js +128 -84
  33. package/dest/orchestrator/index.d.ts +1 -1
  34. package/dest/orchestrator/orchestrator.d.ts +35 -34
  35. package/dest/orchestrator/orchestrator.d.ts.map +1 -1
  36. package/dest/orchestrator/orchestrator.js +777 -292
  37. package/dest/orchestrator/orchestrator_metrics.d.ts +1 -3
  38. package/dest/orchestrator/orchestrator_metrics.d.ts.map +1 -1
  39. package/dest/orchestrator/orchestrator_metrics.js +0 -9
  40. package/dest/orchestrator/tx-proving-state.d.ts +12 -10
  41. package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
  42. package/dest/orchestrator/tx-proving-state.js +23 -29
  43. package/dest/prover-client/factory.d.ts +3 -3
  44. package/dest/prover-client/factory.d.ts.map +1 -1
  45. package/dest/prover-client/index.d.ts +1 -1
  46. package/dest/prover-client/prover-client.d.ts +3 -3
  47. package/dest/prover-client/prover-client.d.ts.map +1 -1
  48. package/dest/prover-client/prover-client.js +1 -1
  49. package/dest/prover-client/server-epoch-prover.d.ts +13 -11
  50. package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
  51. package/dest/prover-client/server-epoch-prover.js +9 -9
  52. package/dest/proving_broker/broker_prover_facade.d.ts +23 -18
  53. package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
  54. package/dest/proving_broker/broker_prover_facade.js +42 -33
  55. package/dest/proving_broker/config.d.ts +18 -14
  56. package/dest/proving_broker/config.d.ts.map +1 -1
  57. package/dest/proving_broker/config.js +12 -6
  58. package/dest/proving_broker/factory.d.ts +1 -1
  59. package/dest/proving_broker/factory.js +1 -1
  60. package/dest/proving_broker/fixtures.d.ts +3 -2
  61. package/dest/proving_broker/fixtures.d.ts.map +1 -1
  62. package/dest/proving_broker/fixtures.js +3 -2
  63. package/dest/proving_broker/index.d.ts +1 -1
  64. package/dest/proving_broker/proof_store/factory.d.ts +2 -2
  65. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts +1 -1
  66. package/dest/proving_broker/proof_store/gcs_proof_store.d.ts.map +1 -1
  67. package/dest/proving_broker/proof_store/index.d.ts +2 -1
  68. package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
  69. package/dest/proving_broker/proof_store/index.js +1 -0
  70. package/dest/proving_broker/proof_store/inline_proof_store.d.ts +1 -1
  71. package/dest/proving_broker/proof_store/inline_proof_store.d.ts.map +1 -1
  72. package/dest/proving_broker/proof_store/proof_store.d.ts +1 -1
  73. package/dest/proving_broker/proving_agent.d.ts +3 -8
  74. package/dest/proving_broker/proving_agent.d.ts.map +1 -1
  75. package/dest/proving_broker/proving_agent.js +1 -16
  76. package/dest/proving_broker/proving_broker.d.ts +2 -2
  77. package/dest/proving_broker/proving_broker.d.ts.map +1 -1
  78. package/dest/proving_broker/proving_broker.js +35 -29
  79. package/dest/proving_broker/proving_broker_database/memory.d.ts +3 -2
  80. package/dest/proving_broker/proving_broker_database/memory.d.ts.map +1 -1
  81. package/dest/proving_broker/proving_broker_database/persisted.d.ts +5 -3
  82. package/dest/proving_broker/proving_broker_database/persisted.d.ts.map +1 -1
  83. package/dest/proving_broker/proving_broker_database/persisted.js +397 -8
  84. package/dest/proving_broker/proving_broker_database.d.ts +3 -2
  85. package/dest/proving_broker/proving_broker_database.d.ts.map +1 -1
  86. package/dest/proving_broker/proving_broker_instrumentation.d.ts +1 -1
  87. package/dest/proving_broker/proving_broker_instrumentation.d.ts.map +1 -1
  88. package/dest/proving_broker/proving_job_controller.d.ts +3 -2
  89. package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
  90. package/dest/proving_broker/proving_job_controller.js +40 -21
  91. package/dest/proving_broker/rpc.d.ts +4 -4
  92. package/dest/test/mock_proof_store.d.ts +3 -3
  93. package/dest/test/mock_proof_store.d.ts.map +1 -1
  94. package/dest/test/mock_prover.d.ts +23 -19
  95. package/dest/test/mock_prover.d.ts.map +1 -1
  96. package/dest/test/mock_prover.js +36 -21
  97. package/package.json +21 -19
  98. package/src/block-factory/light.ts +40 -17
  99. package/src/config.ts +2 -2
  100. package/src/light/index.ts +1 -0
  101. package/src/light/lightweight_checkpoint_builder.ts +198 -0
  102. package/src/mocks/fixtures.ts +41 -36
  103. package/src/mocks/test_context.ts +196 -114
  104. package/src/orchestrator/block-building-helpers.ts +233 -313
  105. package/src/orchestrator/block-proving-state.ts +315 -247
  106. package/src/orchestrator/checkpoint-proving-state.ts +303 -0
  107. package/src/orchestrator/epoch-proving-state.ts +176 -129
  108. package/src/orchestrator/orchestrator.ts +558 -348
  109. package/src/orchestrator/orchestrator_metrics.ts +1 -20
  110. package/src/orchestrator/tx-proving-state.ts +47 -55
  111. package/src/prover-client/factory.ts +6 -2
  112. package/src/prover-client/prover-client.ts +4 -11
  113. package/src/prover-client/server-epoch-prover.ts +30 -21
  114. package/src/proving_broker/broker_prover_facade.ts +175 -112
  115. package/src/proving_broker/config.ts +14 -7
  116. package/src/proving_broker/factory.ts +1 -1
  117. package/src/proving_broker/fixtures.ts +8 -3
  118. package/src/proving_broker/proof_store/index.ts +1 -0
  119. package/src/proving_broker/proving_agent.ts +1 -17
  120. package/src/proving_broker/proving_broker.ts +42 -27
  121. package/src/proving_broker/proving_broker_database/memory.ts +2 -1
  122. package/src/proving_broker/proving_broker_database/persisted.ts +25 -10
  123. package/src/proving_broker/proving_broker_database.ts +2 -1
  124. package/src/proving_broker/proving_job_controller.ts +42 -22
  125. package/src/test/mock_prover.ts +143 -66
  126. package/dest/bin/get-proof-inputs.d.ts +0 -2
  127. package/dest/bin/get-proof-inputs.d.ts.map +0 -1
  128. package/dest/bin/get-proof-inputs.js +0 -51
  129. package/dest/proving_broker/proving_agent_instrumentation.d.ts +0 -8
  130. package/dest/proving_broker/proving_agent_instrumentation.d.ts.map +0 -1
  131. package/dest/proving_broker/proving_agent_instrumentation.js +0 -16
  132. package/src/bin/get-proof-inputs.ts +0 -59
  133. 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
- L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
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 type { EthAddress } from '@aztec/foundation/eth-address';
9
- import type { Fr } from '@aztec/foundation/fields';
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 { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
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
- BlockMergeRollupInputs,
17
- type BlockRootOrBlockMergePublicInputs,
18
- PreviousRollupBlockData,
19
- RootRollupInputs,
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, GlobalVariables } from '@aztec/stdlib/tx';
24
- import { VkData } from '@aztec/stdlib/vks';
24
+ import type { BlockHeader } from '@aztec/stdlib/tx';
25
25
 
26
- import { BlockProvingState } from './block-proving-state.js';
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 blockRootOrMergeProvingOutputs: UnbalancedTreeStore<
47
- PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
48
+ private checkpointProofs: UnbalancedTreeStore<
49
+ ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
48
50
  >;
49
- private paddingBlockRootProvingOutput:
50
- | PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
51
+ private checkpointPaddingProof:
52
+ | ProofState<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
51
53
  | undefined;
52
- private rootRollupProvingOutput: PublicInputsAndRecursiveProof<RootRollupPublicInputs> | undefined;
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 tube proof promise. Used when kickstarting tube proofs before tx processing.
57
- public readonly cachedTubeProofs = new Map<string, Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>>();
58
-
59
- public blocks: (BlockProvingState | undefined)[] = [];
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: number,
63
- public readonly firstBlockNumber: number,
64
- public readonly totalNumBlocks: number,
65
- public readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges,
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.blockRootOrMergeProvingOutputs = new UnbalancedTreeStore(totalNumBlocks);
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 startNewBlock(
75
- globalVariables: GlobalVariables,
76
- l1ToL2Messages: Fr[],
77
- l1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot,
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
- proverId: EthAddress,
85
- ): BlockProvingState {
86
- const index = globalVariables.blockNumber - this.firstBlockNumber;
87
- const block = new BlockProvingState(
88
- index,
89
- globalVariables,
90
- l1ToL2Messages,
91
- l1ToL2MessageTreeSnapshot,
92
- l1ToL2MessageSubtreeSiblingPath,
93
- l1ToL2MessageTreeSnapshotAfterInsertion,
94
- lastArchiveSnapshot,
95
- lastArchiveSiblingPath,
96
- newArchiveSiblingPath,
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
- proverId,
107
+ lastArchiveSiblingPath,
108
+ l1ToL2Messages,
109
+ lastL1ToL2MessageTreeSnapshot,
110
+ lastL1ToL2MessageSubtreeRootSiblingPath,
111
+ newL1ToL2MessageTreeSnapshot,
112
+ newL1ToL2MessageSubtreeRootSiblingPath,
99
113
  this,
114
+ this.onCheckpointBlobAccumulatorSet,
100
115
  );
101
- this.blocks[index] = block;
102
- if (this.blocks.filter(b => !!b).length === this.totalNumBlocks) {
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
- return block;
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 blocks, false otherwise
117
- public isAcceptingBlocks() {
118
- return this.provingStateLifecycle === PROVING_STATE_LIFECYCLE.PROVING_STATE_CREATED;
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 setBlockRootRollupProof(
122
- blockIndex: number,
123
- proof: PublicInputsAndRecursiveProof<
124
- BlockRootOrBlockMergePublicInputs,
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.blockRootOrMergeProvingOutputs.setLeaf(blockIndex, proof);
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 setBlockMergeRollupProof(
174
+ public setCheckpointMergeRollupProof(
132
175
  location: TreeNodeLocation,
133
- proof: PublicInputsAndRecursiveProof<
134
- BlockRootOrBlockMergePublicInputs,
176
+ provingOutput: PublicInputsAndRecursiveProof<
177
+ CheckpointRollupPublicInputs,
135
178
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
136
179
  >,
137
180
  ) {
138
- this.blockRootOrMergeProvingOutputs.setNode(location, proof);
181
+ this.checkpointProofs.setNode(location, { provingOutput });
139
182
  }
140
183
 
141
- public setRootRollupProof(proof: PublicInputsAndRecursiveProof<RootRollupPublicInputs>) {
142
- this.rootRollupProvingOutput = proof;
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 setPaddingBlockRootProof(
146
- proof: PublicInputsAndRecursiveProof<
147
- BlockRootOrBlockMergePublicInputs,
206
+ public setCheckpointPaddingProof(
207
+ provingOutput: PublicInputsAndRecursiveProof<
208
+ CheckpointRollupPublicInputs,
148
209
  typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
149
210
  >,
150
211
  ) {
151
- this.paddingBlockRootProvingOutput = proof;
212
+ this.checkpointPaddingProof = { provingOutput };
152
213
  }
153
214
 
154
- public setFinalBatchedBlob(batchedBlob: BatchedBlob) {
155
- this.finalBatchedBlob = batchedBlob;
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 <= end; i++) {
163
- const block = this.blocks[i];
164
- if (!block || !block.block) {
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
- if (!block.startBlobAccumulator) {
169
- // startBlobAccumulator always exists for firstBlockNumber, so the below should never assign an undefined:
170
- block.setStartBlobAccumulator(previousAccumulator!);
223
+
224
+ const endAccumulator =
225
+ checkpoint.getEndBlobAccumulator() || (await checkpoint.accumulateBlobs(previousAccumulator));
226
+ if (!endAccumulator) {
227
+ break;
171
228
  }
172
- if (block.startBlobAccumulator && !block.endBlobAccumulator) {
173
- await block.accumulateBlobs();
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.blockRootOrMergeProvingOutputs.getParentLocation(location);
247
+ return this.checkpointProofs.getParentLocation(location);
181
248
  }
182
249
 
183
- public getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation) {
184
- const [left, right] = this.blockRootOrMergeProvingOutputs.getChildren(mergeLocation);
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 lease one child is not ready.');
253
+ throw new Error('At least one child is not ready for the checkpoint merge rollup.');
187
254
  }
188
255
 
189
- return new BlockMergeRollupInputs([this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)]);
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 lease one child is not ready.');
262
+ throw new Error('At least one child is not ready for the root rollup.');
196
263
  }
197
264
 
198
- return RootRollupInputs.from({
199
- previousRollupData: [this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)],
265
+ return RootRollupPrivateInputs.from({
266
+ previousRollups: [toProofData(left), toProofData(right)],
200
267
  });
201
268
  }
202
269
 
203
- public getPaddingBlockRootInputs() {
204
- if (!this.blocks[0]?.isComplete()) {
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
- if (!this.rootRollupProvingOutput || !this.finalBatchedBlob) {
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: this.rootRollupProvingOutput.proof.binaryProof,
223
- publicInputs: this.rootRollupProvingOutput.inputs,
282
+ proof: provingOutput.proof.binaryProof,
283
+ publicInputs: provingOutput.inputs,
224
284
  batchedBlobInputs: this.finalBatchedBlob,
225
285
  };
226
286
  }
227
287
 
228
- public isReadyForBlockMerge(location: TreeNodeLocation) {
229
- return this.blockRootOrMergeProvingOutputs.getSibling(location) !== undefined;
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.totalNumBlocks === 1
267
- ? [this.blockRootOrMergeProvingOutputs.getNode(rootLocation), this.paddingBlockRootProvingOutput]
268
- : this.blockRootOrMergeProvingOutputs.getChildren(rootLocation);
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
  }