@aztec/prover-client 3.0.0-nightly.20250917 → 3.0.0-nightly.20250919
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 +59 -52
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +215 -187
- 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 +331 -203
- package/dest/orchestrator/tx-proving-state.d.ts +3 -3
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +5 -5
- 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 +18 -13
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +36 -21
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +1 -0
- 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/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +27 -16
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +34 -14
- package/dest/test/mock_prover.d.ts +18 -13
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +31 -16
- package/package.json +16 -17
- 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 +232 -244
- package/src/orchestrator/checkpoint-proving-state.ts +294 -0
- package/src/orchestrator/epoch-proving-state.ts +169 -121
- package/src/orchestrator/orchestrator.ts +483 -262
- package/src/orchestrator/tx-proving-state.ts +6 -6
- package/src/prover-client/server-epoch-prover.ts +30 -16
- package/src/proving_broker/broker_prover_facade.ts +151 -83
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/index.ts +1 -0
- package/src/proving_broker/proving_broker.ts +34 -16
- package/src/proving_broker/proving_job_controller.ts +34 -14
- package/src/test/mock_prover.ts +125 -54
- 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/src/bin/get-proof-inputs.ts +0 -59
|
@@ -1,268 +1,304 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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';
|
|
2
|
+
import { assertLength } from '@aztec/foundation/serialize';
|
|
5
3
|
import { UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { VkData } from '@aztec/stdlib/vks';
|
|
12
|
-
import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmptyBlockBlobsHash } from './block-building-helpers.js';
|
|
4
|
+
import { getBlockBlobFields } from '@aztec/stdlib/block';
|
|
5
|
+
import { ParityRootPrivateInputs } from '@aztec/stdlib/parity';
|
|
6
|
+
import { BlockRootEmptyTxFirstRollupPrivateInputs, BlockRootFirstRollupPrivateInputs, BlockRootRollupPrivateInputs, BlockRootSingleTxFirstRollupPrivateInputs, BlockRootSingleTxRollupPrivateInputs, TxMergeRollupPrivateInputs } from '@aztec/stdlib/rollup';
|
|
7
|
+
import { GlobalVariables } from '@aztec/stdlib/tx';
|
|
8
|
+
import { buildHeaderFromCircuitOutputs, toProofData } from './block-building-helpers.js';
|
|
13
9
|
/**
|
|
14
10
|
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
15
11
|
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
16
12
|
*/ export class BlockProvingState {
|
|
17
13
|
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;
|
|
14
|
+
blockNumber;
|
|
39
15
|
totalNumTxs;
|
|
16
|
+
constants;
|
|
17
|
+
timestamp;
|
|
18
|
+
lastArchiveTreeSnapshot;
|
|
19
|
+
lastArchiveSiblingPath;
|
|
20
|
+
lastL1ToL2MessageTreeSnapshot;
|
|
21
|
+
lastL1ToL2MessageSubtreeSiblingPath;
|
|
22
|
+
newL1ToL2MessageTreeSnapshot;
|
|
23
|
+
headerOfLastBlockInPreviousCheckpoint;
|
|
24
|
+
startSpongeBlob;
|
|
25
|
+
parentCheckpoint;
|
|
26
|
+
baseOrMergeProofs;
|
|
27
|
+
baseParityProofs;
|
|
28
|
+
rootParityProof;
|
|
29
|
+
blockRootProof;
|
|
30
|
+
builtBlockHeader;
|
|
31
|
+
endSpongeBlob;
|
|
40
32
|
txs;
|
|
33
|
+
isFirstBlock;
|
|
41
34
|
error;
|
|
42
|
-
constructor(index,
|
|
35
|
+
constructor(index, blockNumber, totalNumTxs, constants, timestamp, lastArchiveTreeSnapshot, lastArchiveSiblingPath, lastL1ToL2MessageTreeSnapshot, lastL1ToL2MessageSubtreeSiblingPath, newL1ToL2MessageTreeSnapshot, headerOfLastBlockInPreviousCheckpoint, startSpongeBlob, parentCheckpoint){
|
|
43
36
|
this.index = index;
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.lastArchiveSnapshot = lastArchiveSnapshot;
|
|
37
|
+
this.blockNumber = blockNumber;
|
|
38
|
+
this.totalNumTxs = totalNumTxs;
|
|
39
|
+
this.constants = constants;
|
|
40
|
+
this.timestamp = timestamp;
|
|
41
|
+
this.lastArchiveTreeSnapshot = lastArchiveTreeSnapshot;
|
|
50
42
|
this.lastArchiveSiblingPath = lastArchiveSiblingPath;
|
|
51
|
-
this.
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
this.
|
|
55
|
-
this.
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
58
|
-
this.
|
|
43
|
+
this.lastL1ToL2MessageTreeSnapshot = lastL1ToL2MessageTreeSnapshot;
|
|
44
|
+
this.lastL1ToL2MessageSubtreeSiblingPath = lastL1ToL2MessageSubtreeSiblingPath;
|
|
45
|
+
this.newL1ToL2MessageTreeSnapshot = newL1ToL2MessageTreeSnapshot;
|
|
46
|
+
this.headerOfLastBlockInPreviousCheckpoint = headerOfLastBlockInPreviousCheckpoint;
|
|
47
|
+
this.startSpongeBlob = startSpongeBlob;
|
|
48
|
+
this.parentCheckpoint = parentCheckpoint;
|
|
49
|
+
this.baseOrMergeProofs = new UnbalancedTreeStore(0);
|
|
50
|
+
this.baseParityProofs = Array.from({
|
|
59
51
|
length: NUM_BASE_PARITY_PER_ROOT_PARITY
|
|
60
52
|
}).map((_)=>undefined);
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
this.txs = [];
|
|
54
|
+
this.isFirstBlock = index === 0;
|
|
55
|
+
if (!totalNumTxs && !this.isFirstBlock) {
|
|
56
|
+
throw new Error(`Cannot create a block with 0 txs, unless it's the first block.`);
|
|
64
57
|
}
|
|
58
|
+
this.baseOrMergeProofs = new UnbalancedTreeStore(totalNumTxs);
|
|
65
59
|
}
|
|
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;
|
|
60
|
+
get epochNumber() {
|
|
61
|
+
return this.parentCheckpoint.epochNumber;
|
|
78
62
|
}
|
|
79
63
|
// Adds a transaction to the proving state, returns it's index
|
|
80
64
|
addNewTx(tx) {
|
|
81
|
-
if (!this.
|
|
82
|
-
throw new Error(`
|
|
65
|
+
if (!this.isAcceptingTxs()) {
|
|
66
|
+
throw new Error(`Cannot add more txs to block ${this.blockNumber}.`);
|
|
83
67
|
}
|
|
84
68
|
const txIndex = this.txs.length;
|
|
85
69
|
this.txs[txIndex] = tx;
|
|
86
70
|
return txIndex;
|
|
87
71
|
}
|
|
72
|
+
isAcceptingTxs() {
|
|
73
|
+
return this.txs.length < this.totalNumTxs;
|
|
74
|
+
}
|
|
75
|
+
getProcessedTxs() {
|
|
76
|
+
return this.txs.map((t)=>t.processedTx);
|
|
77
|
+
}
|
|
78
|
+
tryStartProvingBase(txIndex) {
|
|
79
|
+
if (this.baseOrMergeProofs.getLeaf(txIndex)?.isProving) {
|
|
80
|
+
return false;
|
|
81
|
+
} else {
|
|
82
|
+
this.baseOrMergeProofs.setLeaf(txIndex, {
|
|
83
|
+
isProving: true
|
|
84
|
+
});
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
88
|
setBaseRollupProof(txIndex, provingOutput) {
|
|
89
|
-
return this.
|
|
89
|
+
return this.baseOrMergeProofs.setLeaf(txIndex, {
|
|
90
|
+
provingOutput
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
tryStartProvingMerge(location) {
|
|
94
|
+
if (this.baseOrMergeProofs.getNode(location)?.isProving) {
|
|
95
|
+
return false;
|
|
96
|
+
} else {
|
|
97
|
+
this.baseOrMergeProofs.setNode(location, {
|
|
98
|
+
isProving: true
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
90
102
|
}
|
|
91
103
|
setMergeRollupProof(location, provingOutput) {
|
|
92
|
-
this.
|
|
104
|
+
this.baseOrMergeProofs.setNode(location, {
|
|
105
|
+
provingOutput
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
tryStartProvingBaseParity(index) {
|
|
109
|
+
if (this.baseParityProofs[index]?.isProving) {
|
|
110
|
+
return false;
|
|
111
|
+
} else {
|
|
112
|
+
this.baseParityProofs[index] = {
|
|
113
|
+
isProving: true
|
|
114
|
+
};
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
93
117
|
}
|
|
94
118
|
// Stores a set of root parity inputs at the given index
|
|
95
119
|
setBaseParityProof(index, provingOutput) {
|
|
96
120
|
if (index >= NUM_BASE_PARITY_PER_ROOT_PARITY) {
|
|
97
121
|
throw new Error(`Unable to set a base parity proofs at index ${index}. Expected at most ${NUM_BASE_PARITY_PER_ROOT_PARITY} proofs.`);
|
|
98
122
|
}
|
|
99
|
-
this.
|
|
123
|
+
this.baseParityProofs[index] = {
|
|
124
|
+
provingOutput
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
tryStartProvingRootParity() {
|
|
128
|
+
if (this.rootParityProof?.isProving) {
|
|
129
|
+
return false;
|
|
130
|
+
} else {
|
|
131
|
+
this.rootParityProof = {
|
|
132
|
+
isProving: true
|
|
133
|
+
};
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
100
136
|
}
|
|
101
137
|
setRootParityProof(provingOutput) {
|
|
102
|
-
this.
|
|
138
|
+
this.rootParityProof = {
|
|
139
|
+
provingOutput
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
tryStartProvingBlockRoot() {
|
|
143
|
+
if (this.blockRootProof?.isProving) {
|
|
144
|
+
return false;
|
|
145
|
+
} else {
|
|
146
|
+
this.blockRootProof = {
|
|
147
|
+
isProving: true
|
|
148
|
+
};
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
103
151
|
}
|
|
104
152
|
setBlockRootRollupProof(provingOutput) {
|
|
105
|
-
this.
|
|
153
|
+
this.blockRootProof = {
|
|
154
|
+
provingOutput
|
|
155
|
+
};
|
|
156
|
+
return this.parentCheckpoint.setBlockRootRollupProof(this.index, provingOutput);
|
|
106
157
|
}
|
|
107
|
-
|
|
108
|
-
this.
|
|
158
|
+
getBlockRootRollupOutput() {
|
|
159
|
+
return this.blockRootProof?.provingOutput?.inputs;
|
|
109
160
|
}
|
|
110
|
-
|
|
111
|
-
this.
|
|
161
|
+
setBuiltBlockHeader(blockHeader) {
|
|
162
|
+
this.builtBlockHeader = blockHeader;
|
|
112
163
|
}
|
|
113
|
-
|
|
114
|
-
this.
|
|
164
|
+
getBuiltBlockHeader() {
|
|
165
|
+
return this.builtBlockHeader;
|
|
115
166
|
}
|
|
116
|
-
|
|
117
|
-
if (
|
|
118
|
-
|
|
119
|
-
return;
|
|
167
|
+
getGlobalVariables() {
|
|
168
|
+
if (this.txs.length) {
|
|
169
|
+
return this.txs[0].processedTx.globalVariables;
|
|
120
170
|
}
|
|
121
|
-
const
|
|
122
|
-
|
|
171
|
+
const constants = this.constants;
|
|
172
|
+
return GlobalVariables.from({
|
|
173
|
+
chainId: constants.chainId,
|
|
174
|
+
version: constants.version,
|
|
175
|
+
blockNumber: this.blockNumber,
|
|
176
|
+
slotNumber: constants.slotNumber,
|
|
177
|
+
timestamp: this.timestamp,
|
|
178
|
+
coinbase: constants.coinbase,
|
|
179
|
+
feeRecipient: constants.feeRecipient,
|
|
180
|
+
gasFees: constants.gasFees
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
getStartSpongeBlob() {
|
|
184
|
+
return this.startSpongeBlob;
|
|
123
185
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return this.txs;
|
|
186
|
+
setEndSpongeBlob(endSpongeBlob) {
|
|
187
|
+
this.endSpongeBlob = endSpongeBlob;
|
|
127
188
|
}
|
|
128
|
-
|
|
129
|
-
return this.
|
|
189
|
+
getEndSpongeBlob() {
|
|
190
|
+
return this.endSpongeBlob;
|
|
191
|
+
}
|
|
192
|
+
getBlockBlobFields() {
|
|
193
|
+
return getBlockBlobFields(this.txs.map((t)=>t.processedTx.txEffect));
|
|
130
194
|
}
|
|
131
195
|
getParentLocation(location) {
|
|
132
|
-
return this.
|
|
196
|
+
return this.baseOrMergeProofs.getParentLocation(location);
|
|
133
197
|
}
|
|
134
198
|
getMergeRollupInputs(mergeLocation) {
|
|
135
|
-
const [left, right] = this.
|
|
199
|
+
const [left, right] = this.baseOrMergeProofs.getChildren(mergeLocation).map((c)=>c?.provingOutput);
|
|
136
200
|
if (!left || !right) {
|
|
137
|
-
throw new Error('At
|
|
201
|
+
throw new Error('At least one child is not ready for the merge rollup.');
|
|
138
202
|
}
|
|
139
|
-
return new
|
|
140
|
-
|
|
141
|
-
|
|
203
|
+
return new TxMergeRollupPrivateInputs([
|
|
204
|
+
toProofData(left),
|
|
205
|
+
toProofData(right)
|
|
142
206
|
]);
|
|
143
207
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
208
|
+
getBlockRootRollupTypeAndInputs() {
|
|
209
|
+
const provingOutputs = this.#getChildProvingOutputsForBlockRoot();
|
|
210
|
+
if (!provingOutputs.every((p)=>!!p)) {
|
|
211
|
+
throw new Error('At least one child is not ready for the block root rollup.');
|
|
147
212
|
}
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
throw new Error('At lease one child is not ready for the block root.');
|
|
213
|
+
const previousRollups = provingOutputs.map((p)=>toProofData(p));
|
|
214
|
+
if (this.isFirstBlock) {
|
|
215
|
+
return this.#getFirstBlockRootRollupTypeAndInputs(previousRollups);
|
|
152
216
|
}
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
protocolContractTreeRoot
|
|
161
|
-
});
|
|
162
|
-
this.blobsHash = await getEmptyBlockBlobsHash();
|
|
217
|
+
const [leftRollup, rightRollup] = previousRollups;
|
|
218
|
+
if (!rightRollup) {
|
|
219
|
+
return {
|
|
220
|
+
rollupType: 'rollup-block-root-single-tx',
|
|
221
|
+
inputs: new BlockRootSingleTxRollupPrivateInputs(leftRollup, this.lastArchiveSiblingPath)
|
|
222
|
+
};
|
|
223
|
+
} else {
|
|
163
224
|
return {
|
|
164
|
-
rollupType: '
|
|
165
|
-
inputs:
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
225
|
+
rollupType: 'rollup-block-root',
|
|
226
|
+
inputs: new BlockRootRollupPrivateInputs([
|
|
227
|
+
leftRollup,
|
|
228
|
+
rightRollup
|
|
229
|
+
], this.lastArchiveSiblingPath)
|
|
169
230
|
};
|
|
170
231
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
232
|
+
}
|
|
233
|
+
#getFirstBlockRootRollupTypeAndInputs([leftRollup, rightRollup]) {
|
|
234
|
+
if (!this.rootParityProof?.provingOutput) {
|
|
235
|
+
throw new Error('Root parity is not ready.');
|
|
236
|
+
}
|
|
237
|
+
const l1ToL2Roots = toProofData(this.rootParityProof.provingOutput);
|
|
238
|
+
if (!leftRollup) {
|
|
175
239
|
return {
|
|
176
|
-
rollupType: '
|
|
177
|
-
inputs: new
|
|
240
|
+
rollupType: 'rollup-block-root-first-empty-tx',
|
|
241
|
+
inputs: new BlockRootEmptyTxFirstRollupPrivateInputs(l1ToL2Roots, this.lastArchiveTreeSnapshot, this.headerOfLastBlockInPreviousCheckpoint.state, this.constants, this.startSpongeBlob, this.timestamp, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
242
|
+
};
|
|
243
|
+
} else if (!rightRollup) {
|
|
244
|
+
return {
|
|
245
|
+
rollupType: 'rollup-block-root-first-single-tx',
|
|
246
|
+
inputs: new BlockRootSingleTxFirstRollupPrivateInputs(l1ToL2Roots, leftRollup, this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
178
247
|
};
|
|
179
248
|
} else {
|
|
180
249
|
return {
|
|
181
|
-
rollupType: 'block-root-
|
|
182
|
-
inputs: new
|
|
250
|
+
rollupType: 'rollup-block-root-first',
|
|
251
|
+
inputs: new BlockRootFirstRollupPrivateInputs(l1ToL2Roots, [
|
|
252
|
+
leftRollup,
|
|
253
|
+
rightRollup
|
|
254
|
+
], this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeSiblingPath, this.lastArchiveSiblingPath)
|
|
183
255
|
};
|
|
184
256
|
}
|
|
185
257
|
}
|
|
186
|
-
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
protocolContractTreeRoot,
|
|
190
|
-
proverId: this.proverId.toField()
|
|
191
|
-
});
|
|
192
|
-
return PaddingBlockRootRollupInputs.from({
|
|
193
|
-
constants
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
getRootParityInputs() {
|
|
197
|
-
if (!this.baseParityProvingOutputs.every((p)=>!!p)) {
|
|
258
|
+
getParityRootInputs() {
|
|
259
|
+
const baseParityProvingOutputs = this.baseParityProofs.filter((p)=>!!p?.provingOutput).map((p)=>p.provingOutput);
|
|
260
|
+
if (baseParityProvingOutputs.length !== this.baseParityProofs.length) {
|
|
198
261
|
throw new Error('At lease one base parity is not ready.');
|
|
199
262
|
}
|
|
200
|
-
const children =
|
|
201
|
-
return new
|
|
263
|
+
const children = baseParityProvingOutputs.map((p)=>toProofData(p));
|
|
264
|
+
return new ParityRootPrivateInputs(assertLength(children, NUM_BASE_PARITY_PER_ROOT_PARITY));
|
|
202
265
|
}
|
|
203
266
|
// Returns a specific transaction proving state
|
|
204
267
|
getTxProvingState(txIndex) {
|
|
205
268
|
return this.txs[txIndex];
|
|
206
269
|
}
|
|
207
270
|
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;
|
|
271
|
+
if (!this.blockRootProof?.provingOutput) {
|
|
272
|
+
throw new Error('Block root rollup is not ready.');
|
|
217
273
|
}
|
|
218
|
-
|
|
219
|
-
return buildHeaderFromCircuitOutputs(previousRollupData.map((d)=>d.baseOrMergeRollupPublicInputs), this.rootParityProvingOutput.inputs, this.blockRootProvingOutput.inputs, this.blobsHash, endState);
|
|
274
|
+
return await buildHeaderFromCircuitOutputs(this.blockRootProof.provingOutput.inputs);
|
|
220
275
|
}
|
|
221
276
|
isReadyForMergeRollup(location) {
|
|
222
|
-
return this.
|
|
277
|
+
return !!this.baseOrMergeProofs.getSibling(location)?.provingOutput;
|
|
223
278
|
}
|
|
224
279
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
225
280
|
isReadyForBlockRootRollup() {
|
|
226
|
-
const childProofs = this.#
|
|
227
|
-
return this.
|
|
281
|
+
const childProofs = this.#getChildProvingOutputsForBlockRoot();
|
|
282
|
+
return (!this.isFirstBlock || !!this.rootParityProof?.provingOutput) && childProofs.every((p)=>!!p);
|
|
228
283
|
}
|
|
229
284
|
// Returns true if we have sufficient root parity inputs to execute the root parity circuit
|
|
230
285
|
isReadyForRootParity() {
|
|
231
|
-
return this.
|
|
286
|
+
return this.baseParityProofs.every((p)=>!!p?.provingOutput);
|
|
232
287
|
}
|
|
233
288
|
isComplete() {
|
|
234
|
-
return !!this.
|
|
289
|
+
return !!this.blockRootProof;
|
|
235
290
|
}
|
|
236
|
-
// Returns whether the proving state is still valid
|
|
237
291
|
verifyState() {
|
|
238
|
-
return this.
|
|
292
|
+
return this.parentCheckpoint.verifyState();
|
|
293
|
+
}
|
|
294
|
+
getError() {
|
|
295
|
+
return this.error;
|
|
239
296
|
}
|
|
240
297
|
reject(reason) {
|
|
241
298
|
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
|
-
});
|
|
299
|
+
this.parentCheckpoint.reject(reason);
|
|
255
300
|
}
|
|
256
|
-
|
|
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
|
-
});
|
|
264
|
-
}
|
|
265
|
-
#getChildProofsForBlockRoot() {
|
|
301
|
+
#getChildProvingOutputsForBlockRoot() {
|
|
266
302
|
if (this.totalNumTxs === 0) {
|
|
267
303
|
return [];
|
|
268
304
|
}
|
|
@@ -272,15 +308,7 @@ import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmpt
|
|
|
272
308
|
};
|
|
273
309
|
// If there's only 1 tx, its base rollup proof will be stored at the root.
|
|
274
310
|
return this.totalNumTxs === 1 ? [
|
|
275
|
-
this.
|
|
276
|
-
] : this.
|
|
277
|
-
}
|
|
278
|
-
#getPreviousRollupData({ inputs, proof, verificationKey }) {
|
|
279
|
-
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
280
|
-
const vkData = new VkData(verificationKey, leafIndex, getVKSiblingPath(leafIndex));
|
|
281
|
-
return new PreviousRollupData(inputs, proof, vkData);
|
|
282
|
-
}
|
|
283
|
-
#getRootParityData({ inputs, proof, verificationKey }) {
|
|
284
|
-
return new RootParityInput(proof, verificationKey.keyAsFields, getVKSiblingPath(getVKIndex(verificationKey)), inputs);
|
|
311
|
+
this.baseOrMergeProofs.getNode(rootLocation)?.provingOutput
|
|
312
|
+
] : this.baseOrMergeProofs.getChildren(rootLocation).map((c)=>c?.provingOutput);
|
|
285
313
|
}
|
|
286
314
|
}
|
|
@@ -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 { ParityBasePrivateInputs } 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): ParityBasePrivateInputs;
|
|
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,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAuB,MAAM,yBAAyB,CAAC;AACrF,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,sBAAsB,EACtB,4BAA4B,EAE5B,iCAAiC,EACjC,4CAA4C,EAC7C,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,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