@aztec/prover-client 3.0.0-nightly.20250916 → 3.0.0-nightly.20250918
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/light.d.ts +5 -3
- package/dest/block-factory/light.d.ts.map +1 -1
- package/dest/block-factory/light.js +16 -9
- package/dest/mocks/fixtures.d.ts +3 -1
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +19 -2
- package/dest/mocks/test_context.d.ts +30 -9
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +68 -15
- package/dest/orchestrator/block-building-helpers.d.ts +16 -14
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +69 -66
- package/dest/orchestrator/block-proving-state.d.ts +53 -46
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +209 -172
- package/dest/orchestrator/checkpoint-proving-state.d.ts +62 -0
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +1 -0
- package/dest/orchestrator/checkpoint-proving-state.js +208 -0
- package/dest/orchestrator/epoch-proving-state.d.ts +32 -25
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +132 -81
- package/dest/orchestrator/orchestrator.d.ts +25 -24
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +318 -190
- package/dest/prover-client/server-epoch-prover.d.ts +8 -7
- package/dest/prover-client/server-epoch-prover.d.ts.map +1 -1
- package/dest/prover-client/server-epoch-prover.js +7 -7
- package/dest/proving_broker/broker_prover_facade.d.ts +12 -7
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +30 -15
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +18 -7
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +26 -6
- package/dest/test/mock_prover.d.ts +12 -7
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +25 -10
- package/package.json +15 -15
- package/src/block-factory/light.ts +33 -9
- package/src/mocks/fixtures.ts +25 -7
- package/src/mocks/test_context.ts +113 -21
- package/src/orchestrator/block-building-helpers.ts +107 -93
- package/src/orchestrator/block-proving-state.ts +225 -212
- package/src/orchestrator/checkpoint-proving-state.ts +294 -0
- package/src/orchestrator/epoch-proving-state.ts +169 -121
- package/src/orchestrator/orchestrator.ts +466 -247
- package/src/prover-client/server-epoch-prover.ts +30 -16
- package/src/proving_broker/broker_prover_facade.ts +145 -71
- package/src/proving_broker/proving_broker.ts +24 -6
- package/src/proving_broker/proving_job_controller.ts +26 -6
- package/src/test/mock_prover.ts +105 -28
|
@@ -1,203 +1,267 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BLOBS_PER_BLOCK, FIELDS_PER_BLOB, NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
3
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
4
|
-
import { BLS12Point, Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { NUM_BASE_PARITY_PER_ROOT_PARITY } from '@aztec/constants';
|
|
5
2
|
import { UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
6
|
-
import { getVKIndex, getVKSiblingPath
|
|
7
|
-
import {
|
|
3
|
+
import { getVKIndex, getVKSiblingPath } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
4
|
+
import { getBlockBlobFields } from '@aztec/stdlib/block';
|
|
8
5
|
import { RootParityInput, RootParityInputs } from '@aztec/stdlib/parity';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
6
|
+
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, MergeRollupInputs, PreviousRollupData } from '@aztec/stdlib/rollup';
|
|
7
|
+
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
11
8
|
import { VkData } from '@aztec/stdlib/vks';
|
|
12
|
-
import {
|
|
9
|
+
import { buildHeaderFromCircuitOutputs, toProofData } from './block-building-helpers.js';
|
|
13
10
|
/**
|
|
14
11
|
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
15
12
|
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
16
13
|
*/ export class BlockProvingState {
|
|
17
14
|
index;
|
|
18
|
-
|
|
19
|
-
newL1ToL2Messages;
|
|
20
|
-
l1ToL2MessageTreeSnapshot;
|
|
21
|
-
l1ToL2MessageSubtreeSiblingPath;
|
|
22
|
-
l1ToL2MessageTreeSnapshotAfterInsertion;
|
|
23
|
-
lastArchiveSnapshot;
|
|
24
|
-
lastArchiveSiblingPath;
|
|
25
|
-
newArchiveSiblingPath;
|
|
26
|
-
previousBlockHeader;
|
|
27
|
-
proverId;
|
|
28
|
-
parentEpoch;
|
|
29
|
-
baseOrMergeProvingOutputs;
|
|
30
|
-
baseParityProvingOutputs;
|
|
31
|
-
rootParityProvingOutput;
|
|
32
|
-
blockRootProvingOutput;
|
|
33
|
-
blockRootRollupStarted;
|
|
34
|
-
block;
|
|
35
|
-
spongeBlobState;
|
|
36
|
-
startBlobAccumulator;
|
|
37
|
-
endBlobAccumulator;
|
|
38
|
-
blobsHash;
|
|
15
|
+
blockNumber;
|
|
39
16
|
totalNumTxs;
|
|
17
|
+
constants;
|
|
18
|
+
timestamp;
|
|
19
|
+
lastArchiveTreeSnapshot;
|
|
20
|
+
lastArchiveSiblingPath;
|
|
21
|
+
lastL1ToL2MessageTreeSnapshot;
|
|
22
|
+
lastL1ToL2MessageSubtreeSiblingPath;
|
|
23
|
+
newL1ToL2MessageTreeSnapshot;
|
|
24
|
+
headerOfLastBlockInPreviousCheckpoint;
|
|
25
|
+
startSpongeBlob;
|
|
26
|
+
parentCheckpoint;
|
|
27
|
+
baseOrMergeProofs;
|
|
28
|
+
baseParityProofs;
|
|
29
|
+
rootParityProof;
|
|
30
|
+
blockRootProof;
|
|
31
|
+
builtBlockHeader;
|
|
32
|
+
endSpongeBlob;
|
|
40
33
|
txs;
|
|
34
|
+
isFirstBlock;
|
|
41
35
|
error;
|
|
42
|
-
constructor(index,
|
|
36
|
+
constructor(index, blockNumber, totalNumTxs, constants, timestamp, lastArchiveTreeSnapshot, lastArchiveSiblingPath, lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeSiblingPath, newL1ToL2MessageTreeSnapshot, headerOfLastBlockInPreviousCheckpoint, startSpongeBlob, parentCheckpoint){
|
|
43
37
|
this.index = index;
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.lastArchiveSnapshot = lastArchiveSnapshot;
|
|
38
|
+
this.blockNumber = blockNumber;
|
|
39
|
+
this.totalNumTxs = totalNumTxs;
|
|
40
|
+
this.constants = constants;
|
|
41
|
+
this.timestamp = timestamp;
|
|
42
|
+
this.lastArchiveTreeSnapshot = lastArchiveTreeSnapshot;
|
|
50
43
|
this.lastArchiveSiblingPath = lastArchiveSiblingPath;
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
44
|
+
this.lastL1ToL2MessageTreeSnapshot = lastL1ToL2MessageTreeSnapshot;
|
|
45
|
+
this.lastL1ToL2MessageSubtreeSiblingPath = lastL1ToL2MessageSubtreeSiblingPath;
|
|
46
|
+
this.newL1ToL2MessageTreeSnapshot = newL1ToL2MessageTreeSnapshot;
|
|
47
|
+
this.headerOfLastBlockInPreviousCheckpoint = headerOfLastBlockInPreviousCheckpoint;
|
|
48
|
+
this.startSpongeBlob = startSpongeBlob;
|
|
49
|
+
this.parentCheckpoint = parentCheckpoint;
|
|
50
|
+
this.baseOrMergeProofs = new UnbalancedTreeStore(0);
|
|
51
|
+
this.baseParityProofs = Array.from({
|
|
59
52
|
length: NUM_BASE_PARITY_PER_ROOT_PARITY
|
|
60
53
|
}).map((_)=>undefined);
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
this.txs = [];
|
|
55
|
+
this.isFirstBlock = index === 0;
|
|
56
|
+
if (!totalNumTxs && !this.isFirstBlock) {
|
|
57
|
+
throw new Error(`Cannot create a block with 0 txs, unless it's the first block.`);
|
|
64
58
|
}
|
|
59
|
+
this.baseOrMergeProofs = new UnbalancedTreeStore(totalNumTxs);
|
|
65
60
|
}
|
|
66
|
-
get
|
|
67
|
-
return this.
|
|
68
|
-
}
|
|
69
|
-
startNewBlock(numTxs, numBlobFields) {
|
|
70
|
-
if (this.spongeBlobState) {
|
|
71
|
-
throw new Error(`Block ${this.blockNumber} already initalised.`);
|
|
72
|
-
}
|
|
73
|
-
this.baseOrMergeProvingOutputs = new UnbalancedTreeStore(numTxs);
|
|
74
|
-
// Initialize the sponge which will eventually absorb all tx effects to be added to the blob.
|
|
75
|
-
// Like l1 to l2 messages, we need to know beforehand how many effects will be absorbed.
|
|
76
|
-
this.spongeBlobState = SpongeBlob.init(numBlobFields);
|
|
77
|
-
this.totalNumTxs = numTxs;
|
|
61
|
+
get epochNumber() {
|
|
62
|
+
return this.parentCheckpoint.epochNumber;
|
|
78
63
|
}
|
|
79
64
|
// Adds a transaction to the proving state, returns it's index
|
|
80
65
|
addNewTx(tx) {
|
|
81
|
-
if (!this.
|
|
82
|
-
throw new Error(`
|
|
66
|
+
if (!this.isAcceptingTxs()) {
|
|
67
|
+
throw new Error(`Cannot add more txs to block ${this.blockNumber}.`);
|
|
83
68
|
}
|
|
84
69
|
const txIndex = this.txs.length;
|
|
85
70
|
this.txs[txIndex] = tx;
|
|
86
71
|
return txIndex;
|
|
87
72
|
}
|
|
73
|
+
isAcceptingTxs() {
|
|
74
|
+
return this.txs.length < this.totalNumTxs;
|
|
75
|
+
}
|
|
76
|
+
getProcessedTxs() {
|
|
77
|
+
return this.txs.map((t)=>t.processedTx);
|
|
78
|
+
}
|
|
79
|
+
tryStartProvingBase(txIndex) {
|
|
80
|
+
if (this.baseOrMergeProofs.getLeaf(txIndex)?.isProving) {
|
|
81
|
+
return false;
|
|
82
|
+
} else {
|
|
83
|
+
this.baseOrMergeProofs.setLeaf(txIndex, {
|
|
84
|
+
isProving: true
|
|
85
|
+
});
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
88
89
|
setBaseRollupProof(txIndex, provingOutput) {
|
|
89
|
-
return this.
|
|
90
|
+
return this.baseOrMergeProofs.setLeaf(txIndex, {
|
|
91
|
+
provingOutput
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
tryStartProvingMerge(location) {
|
|
95
|
+
if (this.baseOrMergeProofs.getNode(location)?.isProving) {
|
|
96
|
+
return false;
|
|
97
|
+
} else {
|
|
98
|
+
this.baseOrMergeProofs.setNode(location, {
|
|
99
|
+
isProving: true
|
|
100
|
+
});
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
90
103
|
}
|
|
91
104
|
setMergeRollupProof(location, provingOutput) {
|
|
92
|
-
this.
|
|
105
|
+
this.baseOrMergeProofs.setNode(location, {
|
|
106
|
+
provingOutput
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
tryStartProvingBaseParity(index) {
|
|
110
|
+
if (this.baseParityProofs[index]?.isProving) {
|
|
111
|
+
return false;
|
|
112
|
+
} else {
|
|
113
|
+
this.baseParityProofs[index] = {
|
|
114
|
+
isProving: true
|
|
115
|
+
};
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
93
118
|
}
|
|
94
119
|
// Stores a set of root parity inputs at the given index
|
|
95
120
|
setBaseParityProof(index, provingOutput) {
|
|
96
121
|
if (index >= NUM_BASE_PARITY_PER_ROOT_PARITY) {
|
|
97
122
|
throw new Error(`Unable to set a base parity proofs at index ${index}. Expected at most ${NUM_BASE_PARITY_PER_ROOT_PARITY} proofs.`);
|
|
98
123
|
}
|
|
99
|
-
this.
|
|
124
|
+
this.baseParityProofs[index] = {
|
|
125
|
+
provingOutput
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
tryStartProvingRootParity() {
|
|
129
|
+
if (this.rootParityProof?.isProving) {
|
|
130
|
+
return false;
|
|
131
|
+
} else {
|
|
132
|
+
this.rootParityProof = {
|
|
133
|
+
isProving: true
|
|
134
|
+
};
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
100
137
|
}
|
|
101
138
|
setRootParityProof(provingOutput) {
|
|
102
|
-
this.
|
|
139
|
+
this.rootParityProof = {
|
|
140
|
+
provingOutput
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
tryStartProvingBlockRoot() {
|
|
144
|
+
if (this.blockRootProof?.isProving) {
|
|
145
|
+
return false;
|
|
146
|
+
} else {
|
|
147
|
+
this.blockRootProof = {
|
|
148
|
+
isProving: true
|
|
149
|
+
};
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
103
152
|
}
|
|
104
153
|
setBlockRootRollupProof(provingOutput) {
|
|
105
|
-
this.
|
|
154
|
+
this.blockRootProof = {
|
|
155
|
+
provingOutput
|
|
156
|
+
};
|
|
157
|
+
return this.parentCheckpoint.setBlockRootRollupProof(this.index, provingOutput);
|
|
106
158
|
}
|
|
107
|
-
|
|
108
|
-
this.
|
|
159
|
+
getBlockRootRollupOutput() {
|
|
160
|
+
return this.blockRootProof?.provingOutput?.inputs;
|
|
109
161
|
}
|
|
110
|
-
|
|
111
|
-
this.
|
|
162
|
+
setBuiltBlockHeader(blockHeader) {
|
|
163
|
+
this.builtBlockHeader = blockHeader;
|
|
112
164
|
}
|
|
113
|
-
|
|
114
|
-
this.
|
|
165
|
+
getBuiltBlockHeader() {
|
|
166
|
+
return this.builtBlockHeader;
|
|
115
167
|
}
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
return;
|
|
168
|
+
getGlobalVariables() {
|
|
169
|
+
if (this.txs.length) {
|
|
170
|
+
return this.txs[0].processedTx.globalVariables;
|
|
120
171
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
172
|
+
const constants = this.constants;
|
|
173
|
+
return GlobalVariables.from({
|
|
174
|
+
chainId: constants.chainId,
|
|
175
|
+
version: constants.version,
|
|
176
|
+
blockNumber: this.blockNumber,
|
|
177
|
+
slotNumber: constants.slotNumber,
|
|
178
|
+
timestamp: this.timestamp,
|
|
179
|
+
coinbase: constants.coinbase,
|
|
180
|
+
feeRecipient: constants.feeRecipient,
|
|
181
|
+
gasFees: constants.gasFees
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
getStartSpongeBlob() {
|
|
185
|
+
return this.startSpongeBlob;
|
|
123
186
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return this.txs;
|
|
187
|
+
setEndSpongeBlob(endSpongeBlob) {
|
|
188
|
+
this.endSpongeBlob = endSpongeBlob;
|
|
127
189
|
}
|
|
128
|
-
|
|
129
|
-
return this.
|
|
190
|
+
getEndSpongeBlob() {
|
|
191
|
+
return this.endSpongeBlob;
|
|
192
|
+
}
|
|
193
|
+
getBlockBlobFields() {
|
|
194
|
+
return getBlockBlobFields(this.txs.map((t)=>t.processedTx.txEffect));
|
|
130
195
|
}
|
|
131
196
|
getParentLocation(location) {
|
|
132
|
-
return this.
|
|
197
|
+
return this.baseOrMergeProofs.getParentLocation(location);
|
|
133
198
|
}
|
|
134
199
|
getMergeRollupInputs(mergeLocation) {
|
|
135
|
-
const [left, right] = this.
|
|
200
|
+
const [left, right] = this.baseOrMergeProofs.getChildren(mergeLocation).map((c)=>c?.provingOutput);
|
|
136
201
|
if (!left || !right) {
|
|
137
|
-
throw new Error('At
|
|
202
|
+
throw new Error('At least one child is not ready for the merge rollup.');
|
|
138
203
|
}
|
|
139
204
|
return new MergeRollupInputs([
|
|
140
205
|
this.#getPreviousRollupData(left),
|
|
141
206
|
this.#getPreviousRollupData(right)
|
|
142
207
|
]);
|
|
143
208
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
209
|
+
getBlockRootRollupTypeAndInputs() {
|
|
210
|
+
const provingOutputs = this.#getChildProvingOutputsForBlockRoot();
|
|
211
|
+
if (!provingOutputs.every((p)=>!!p)) {
|
|
212
|
+
throw new Error('At least one child is not ready for the block root rollup.');
|
|
147
213
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
throw new Error('At lease one child is not ready for the block root.');
|
|
214
|
+
const previousRollups = provingOutputs.map((p)=>toProofData(p));
|
|
215
|
+
if (this.isFirstBlock) {
|
|
216
|
+
return this.#getFirstBlockRootRollupTypeAndInputs(previousRollups);
|
|
152
217
|
}
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
protocolContractTreeRoot
|
|
161
|
-
});
|
|
162
|
-
this.blobsHash = await getEmptyBlockBlobsHash();
|
|
218
|
+
const [leftRollup, rightRollup] = previousRollups;
|
|
219
|
+
if (!rightRollup) {
|
|
220
|
+
return {
|
|
221
|
+
rollupType: 'block-root-single-tx-rollup',
|
|
222
|
+
inputs: new BlockRootSingleTxRollupPrivateInputs(leftRollup, this.lastArchiveSiblingPath)
|
|
223
|
+
};
|
|
224
|
+
} else {
|
|
163
225
|
return {
|
|
164
|
-
rollupType: '
|
|
165
|
-
inputs:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
226
|
+
rollupType: 'block-root-rollup',
|
|
227
|
+
inputs: new BlockRootRollupPrivateInputs([
|
|
228
|
+
leftRollup,
|
|
229
|
+
rightRollup
|
|
230
|
+
], this.lastArchiveSiblingPath)
|
|
169
231
|
};
|
|
170
232
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
233
|
+
}
|
|
234
|
+
#getFirstBlockRootRollupTypeAndInputs([leftRollup, rightRollup]) {
|
|
235
|
+
if (!this.rootParityProof?.provingOutput) {
|
|
236
|
+
throw new Error('Root parity is not ready.');
|
|
237
|
+
}
|
|
238
|
+
const l1ToL2Roots = toProofData(this.rootParityProof.provingOutput);
|
|
239
|
+
if (!leftRollup) {
|
|
175
240
|
return {
|
|
176
|
-
rollupType: '
|
|
177
|
-
inputs: new
|
|
241
|
+
rollupType: 'block-root-empty-tx-first-rollup',
|
|
242
|
+
inputs: new BlockRootEmptyTxFirstRollupPrivateInputs(l1ToL2Roots, this.lastArchiveTreeSnapshot, this.headerOfLastBlockInPreviousCheckpoint.state, this.constants, this.startSpongeBlob, this.timestamp, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
243
|
+
};
|
|
244
|
+
} else if (!rightRollup) {
|
|
245
|
+
return {
|
|
246
|
+
rollupType: 'block-root-single-tx-first-rollup',
|
|
247
|
+
inputs: new BlockRootSingleTxFirstRollupPrivateInputs(l1ToL2Roots, leftRollup, this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
178
248
|
};
|
|
179
249
|
} else {
|
|
180
250
|
return {
|
|
181
|
-
rollupType: 'block-root-rollup',
|
|
182
|
-
inputs: new
|
|
251
|
+
rollupType: 'block-root-first-rollup',
|
|
252
|
+
inputs: new BlockRootFirstRollupPrivateInputs(l1ToL2Roots, [
|
|
253
|
+
leftRollup,
|
|
254
|
+
rightRollup
|
|
255
|
+
], this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
183
256
|
};
|
|
184
257
|
}
|
|
185
258
|
}
|
|
186
|
-
getPaddingBlockRootInputs() {
|
|
187
|
-
const constants = EpochConstantData.from({
|
|
188
|
-
vkTreeRoot: getVKTreeRoot(),
|
|
189
|
-
protocolContractTreeRoot,
|
|
190
|
-
proverId: this.proverId.toField()
|
|
191
|
-
});
|
|
192
|
-
return PaddingBlockRootRollupInputs.from({
|
|
193
|
-
constants
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
259
|
getRootParityInputs() {
|
|
197
|
-
|
|
260
|
+
const baseParityProvingOutputs = this.baseParityProofs.filter((p)=>!!p?.provingOutput).map((p)=>p.provingOutput);
|
|
261
|
+
if (baseParityProvingOutputs.length !== this.baseParityProofs.length) {
|
|
198
262
|
throw new Error('At lease one base parity is not ready.');
|
|
199
263
|
}
|
|
200
|
-
const children =
|
|
264
|
+
const children = baseParityProvingOutputs.map((p)=>this.#getRootParityData(p));
|
|
201
265
|
return new RootParityInputs(children);
|
|
202
266
|
}
|
|
203
267
|
// Returns a specific transaction proving state
|
|
@@ -205,64 +269,37 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmpt
|
|
|
205
269
|
return this.txs[txIndex];
|
|
206
270
|
}
|
|
207
271
|
async buildHeaderFromProvingOutputs() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
if (this.totalNumTxs !== 0) {
|
|
211
|
-
const previousRollupData = this.#getChildProofsForBlockRoot();
|
|
212
|
-
const lastRollup = previousRollupData[previousRollupData.length - 1];
|
|
213
|
-
if (!lastRollup) {
|
|
214
|
-
throw new Error('End state of the block is not available. Last rollup is not ready yet.');
|
|
215
|
-
}
|
|
216
|
-
endPartialState = lastRollup.inputs.end;
|
|
272
|
+
if (!this.blockRootProof?.provingOutput) {
|
|
273
|
+
throw new Error('Block root rollup is not ready.');
|
|
217
274
|
}
|
|
218
|
-
|
|
219
|
-
return buildHeaderFromCircuitOutputs(previousRollupData.map((d)=>d.baseOrMergeRollupPublicInputs), this.rootParityProvingOutput.inputs, this.blockRootProvingOutput.inputs, this.blobsHash, endState);
|
|
275
|
+
return await buildHeaderFromCircuitOutputs(this.blockRootProof.provingOutput.inputs);
|
|
220
276
|
}
|
|
221
277
|
isReadyForMergeRollup(location) {
|
|
222
|
-
return this.
|
|
278
|
+
return !!this.baseOrMergeProofs.getSibling(location)?.provingOutput;
|
|
223
279
|
}
|
|
224
280
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
225
281
|
isReadyForBlockRootRollup() {
|
|
226
|
-
const childProofs = this.#
|
|
227
|
-
return this.
|
|
282
|
+
const childProofs = this.#getChildProvingOutputsForBlockRoot();
|
|
283
|
+
return (!this.isFirstBlock || !!this.rootParityProof?.provingOutput) && childProofs.every((p)=>!!p);
|
|
228
284
|
}
|
|
229
285
|
// Returns true if we have sufficient root parity inputs to execute the root parity circuit
|
|
230
286
|
isReadyForRootParity() {
|
|
231
|
-
return this.
|
|
287
|
+
return this.baseParityProofs.every((p)=>!!p?.provingOutput);
|
|
232
288
|
}
|
|
233
289
|
isComplete() {
|
|
234
|
-
return !!this.
|
|
290
|
+
return !!this.blockRootProof;
|
|
235
291
|
}
|
|
236
|
-
// Returns whether the proving state is still valid
|
|
237
292
|
verifyState() {
|
|
238
|
-
return this.
|
|
293
|
+
return this.parentCheckpoint.verifyState();
|
|
294
|
+
}
|
|
295
|
+
getError() {
|
|
296
|
+
return this.error;
|
|
239
297
|
}
|
|
240
298
|
reject(reason) {
|
|
241
299
|
this.error = reason;
|
|
242
|
-
this.
|
|
243
|
-
}
|
|
244
|
-
#getBlockRootRollupData() {
|
|
245
|
-
return BlockRootRollupData.from({
|
|
246
|
-
l1ToL2Roots: this.#getRootParityData(this.rootParityProvingOutput),
|
|
247
|
-
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
248
|
-
previousArchiveSiblingPath: this.lastArchiveSiblingPath,
|
|
249
|
-
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
250
|
-
previousBlockHeader: this.previousBlockHeader,
|
|
251
|
-
startBlobAccumulator: BlobAccumulatorPublicInputs.fromBatchedBlobAccumulator(this.startBlobAccumulator),
|
|
252
|
-
finalBlobChallenges: this.startBlobAccumulator.finalBlobChallenges,
|
|
253
|
-
proverId: this.proverId.toField()
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
async #getBlockRootRollupBlobData() {
|
|
257
|
-
const txEffects = this.txs.map((txProvingState)=>txProvingState.processedTx.txEffect);
|
|
258
|
-
const { blobFields, blobCommitments, blobsHash } = await buildBlobHints(txEffects);
|
|
259
|
-
return BlockRootRollupBlobData.from({
|
|
260
|
-
blobFields: padArrayEnd(blobFields, Fr.ZERO, FIELDS_PER_BLOB * BLOBS_PER_BLOCK),
|
|
261
|
-
blobCommitments: padArrayEnd(blobCommitments, BLS12Point.ZERO, BLOBS_PER_BLOCK),
|
|
262
|
-
blobsHash
|
|
263
|
-
});
|
|
300
|
+
this.parentCheckpoint.reject(reason);
|
|
264
301
|
}
|
|
265
|
-
#
|
|
302
|
+
#getChildProvingOutputsForBlockRoot() {
|
|
266
303
|
if (this.totalNumTxs === 0) {
|
|
267
304
|
return [];
|
|
268
305
|
}
|
|
@@ -272,8 +309,8 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmpt
|
|
|
272
309
|
};
|
|
273
310
|
// If there's only 1 tx, its base rollup proof will be stored at the root.
|
|
274
311
|
return this.totalNumTxs === 1 ? [
|
|
275
|
-
this.
|
|
276
|
-
] : this.
|
|
312
|
+
this.baseOrMergeProofs.getNode(rootLocation)?.provingOutput
|
|
313
|
+
] : this.baseOrMergeProofs.getChildren(rootLocation).map((c)=>c?.provingOutput);
|
|
277
314
|
}
|
|
278
315
|
#getPreviousRollupData({ inputs, proof, verificationKey }) {
|
|
279
316
|
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { BatchedBlobAccumulator, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
+
import { type ARCHIVE_HEIGHT, type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, type NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
3
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
4
|
+
import type { Tuple } from '@aztec/foundation/serialize';
|
|
5
|
+
import { type TreeNodeLocation } from '@aztec/foundation/trees';
|
|
6
|
+
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import { BaseParityInputs } from '@aztec/stdlib/parity';
|
|
8
|
+
import { BlockMergeRollupPrivateInputs, BlockRollupPublicInputs, CheckpointConstantData, CheckpointRollupPublicInputs, CheckpointRootRollupPrivateInputs, CheckpointRootSingleBlockRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
9
|
+
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
10
|
+
import type { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
11
|
+
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
12
|
+
import type { UInt64 } from '@aztec/stdlib/types';
|
|
13
|
+
import { BlockProvingState } from './block-proving-state.js';
|
|
14
|
+
import type { EpochProvingState } from './epoch-proving-state.js';
|
|
15
|
+
export declare class CheckpointProvingState {
|
|
16
|
+
#private;
|
|
17
|
+
readonly index: number;
|
|
18
|
+
readonly constants: CheckpointConstantData;
|
|
19
|
+
readonly totalNumBlocks: number;
|
|
20
|
+
private readonly totalNumBlobFields;
|
|
21
|
+
private readonly finalBlobBatchingChallenges;
|
|
22
|
+
private readonly headerOfLastBlockInPreviousCheckpoint;
|
|
23
|
+
private readonly lastArchiveSiblingPath;
|
|
24
|
+
private readonly l1ToL2Messages;
|
|
25
|
+
private readonly lastL1ToL2MessageTreeSnapshot;
|
|
26
|
+
private readonly lastL1ToL2MessageSubtreeSiblingPath;
|
|
27
|
+
private readonly newL1ToL2MessageTreeSnapshot;
|
|
28
|
+
private readonly newL1ToL2MessageSubtreeSiblingPath;
|
|
29
|
+
parentEpoch: EpochProvingState;
|
|
30
|
+
private onBlobAccumulatorSet;
|
|
31
|
+
private blockProofs;
|
|
32
|
+
private checkpointRootProof;
|
|
33
|
+
private blocks;
|
|
34
|
+
private startBlobAccumulator;
|
|
35
|
+
private endBlobAccumulator;
|
|
36
|
+
private error;
|
|
37
|
+
readonly firstBlockNumber: number;
|
|
38
|
+
constructor(index: number, constants: CheckpointConstantData, totalNumBlocks: number, totalNumBlobFields: number, finalBlobBatchingChallenges: FinalBlobBatchingChallenges, headerOfLastBlockInPreviousCheckpoint: BlockHeader, lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>, l1ToL2Messages: Fr[], lastL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot, lastL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>, newL1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot, newL1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>, parentEpoch: EpochProvingState, onBlobAccumulatorSet: (checkpoint: CheckpointProvingState) => void);
|
|
39
|
+
get epochNumber(): number;
|
|
40
|
+
startNewBlock(blockNumber: number, timestamp: UInt64, totalNumTxs: number, lastArchiveTreeSnapshot: AppendOnlyTreeSnapshot, lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>): BlockProvingState;
|
|
41
|
+
isAcceptingBlocks(): boolean;
|
|
42
|
+
setBlockRootRollupProof(blockIndex: number, provingOutput: PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): TreeNodeLocation;
|
|
43
|
+
tryStartProvingBlockMerge(location: TreeNodeLocation): boolean;
|
|
44
|
+
setBlockMergeRollupProof(location: TreeNodeLocation, provingOutput: PublicInputsAndRecursiveProof<BlockRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
45
|
+
tryStartProvingCheckpointRoot(): boolean;
|
|
46
|
+
setCheckpointRootRollupProof(provingOutput: PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): TreeNodeLocation;
|
|
47
|
+
getBaseParityInputs(baseParityIndex: number): BaseParityInputs;
|
|
48
|
+
accumulateBlobs(startBlobAccumulator: BatchedBlobAccumulator): Promise<BatchedBlobAccumulator | undefined>;
|
|
49
|
+
getEndBlobAccumulator(): BatchedBlobAccumulator | undefined;
|
|
50
|
+
getParentLocation(location: TreeNodeLocation): TreeNodeLocation;
|
|
51
|
+
getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation): BlockMergeRollupPrivateInputs;
|
|
52
|
+
getCheckpointRootRollupType(): CircuitName;
|
|
53
|
+
getCheckpointRootRollupInputs(): Promise<CheckpointRootSingleBlockRollupPrivateInputs | CheckpointRootRollupPrivateInputs>;
|
|
54
|
+
getBlockProvingStateByBlockNumber(blockNumber: number): BlockProvingState | undefined;
|
|
55
|
+
isReadyForBlockMerge(location: TreeNodeLocation): boolean;
|
|
56
|
+
isReadyForCheckpointRoot(): boolean;
|
|
57
|
+
verifyState(): boolean;
|
|
58
|
+
getError(): string | undefined;
|
|
59
|
+
cancel(): void;
|
|
60
|
+
reject(reason: string): void;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=checkpoint-proving-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkpoint-proving-state.d.ts","sourceRoot":"","sources":["../../src/orchestrator/checkpoint-proving-state.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAEtB,KAAK,2BAA2B,EAEjC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,cAAc,EAGnB,KAAK,wCAAwC,EAC7C,KAAK,yCAAyC,EAE/C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAc,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,EAAE,KAAK,EAA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