@aztec/prover-client 0.0.1-fake-c83136db25 → 0.0.1-fake-ceab37513c
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/bin/get-proof-inputs.d.ts +2 -0
- package/dest/bin/get-proof-inputs.d.ts.map +1 -0
- package/dest/bin/get-proof-inputs.js +51 -0
- package/dest/block-factory/light.d.ts +3 -5
- package/dest/block-factory/light.d.ts.map +1 -1
- package/dest/block-factory/light.js +9 -16
- package/dest/config.js +1 -1
- package/dest/mocks/fixtures.d.ts +1 -4
- package/dest/mocks/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +3 -31
- package/dest/mocks/test_context.d.ts +9 -32
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +22 -78
- package/dest/orchestrator/block-building-helpers.d.ts +31 -33
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +137 -126
- package/dest/orchestrator/block-proving-state.d.ts +53 -60
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +187 -214
- package/dest/orchestrator/epoch-proving-state.d.ts +28 -34
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +84 -128
- package/dest/orchestrator/orchestrator.d.ts +30 -31
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +236 -368
- package/dest/orchestrator/tx-proving-state.d.ts +9 -11
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +23 -26
- package/dest/prover-client/server-epoch-prover.d.ts +8 -9
- 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 +15 -20
- package/dest/proving_broker/broker_prover_facade.d.ts.map +1 -1
- package/dest/proving_broker/broker_prover_facade.js +21 -36
- package/dest/proving_broker/fixtures.js +1 -1
- package/dest/proving_broker/proof_store/index.d.ts +0 -1
- package/dest/proving_broker/proof_store/index.d.ts.map +1 -1
- package/dest/proving_broker/proof_store/index.js +0 -1
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +18 -29
- package/dest/proving_broker/proving_job_controller.d.ts.map +1 -1
- package/dest/proving_broker/proving_job_controller.js +18 -38
- package/dest/test/mock_prover.d.ts +17 -22
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +20 -35
- package/package.json +17 -16
- package/src/bin/get-proof-inputs.ts +59 -0
- package/src/block-factory/light.ts +9 -35
- package/src/config.ts +1 -1
- package/src/mocks/fixtures.ts +11 -39
- package/src/mocks/test_context.ts +31 -137
- package/src/orchestrator/block-building-helpers.ts +211 -211
- package/src/orchestrator/block-proving-state.ts +245 -235
- package/src/orchestrator/epoch-proving-state.ts +127 -172
- package/src/orchestrator/orchestrator.ts +303 -545
- package/src/orchestrator/tx-proving-state.ts +43 -49
- package/src/prover-client/server-epoch-prover.ts +18 -28
- package/src/proving_broker/broker_prover_facade.ts +86 -157
- package/src/proving_broker/fixtures.ts +1 -1
- package/src/proving_broker/proof_store/index.ts +0 -1
- package/src/proving_broker/proving_broker.ts +18 -36
- package/src/proving_broker/proving_job_controller.ts +18 -38
- package/src/test/mock_prover.ts +60 -142
- package/dest/orchestrator/checkpoint-proving-state.d.ts +0 -63
- package/dest/orchestrator/checkpoint-proving-state.d.ts.map +0 -1
- package/dest/orchestrator/checkpoint-proving-state.js +0 -211
- package/src/orchestrator/checkpoint-proving-state.ts +0 -299
|
@@ -1,303 +1,268 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { BatchedBlobAccumulator, BlobAccumulatorPublicInputs, SpongeBlob } from '@aztec/blob-lib';
|
|
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';
|
|
3
5
|
import { UnbalancedTreeStore } from '@aztec/foundation/trees';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
|
|
7
|
+
import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
|
|
8
|
+
import { RootParityInput, RootParityInputs } from '@aztec/stdlib/parity';
|
|
9
|
+
import { BlockConstantData, BlockRootRollupBlobData, BlockRootRollupData, BlockRootRollupInputs, EmptyBlockRootRollupInputs, EpochConstantData, MergeRollupInputs, PaddingBlockRootRollupInputs, PreviousRollupData, SingleTxBlockRootRollupInputs } from '@aztec/stdlib/rollup';
|
|
10
|
+
import { StateReference } from '@aztec/stdlib/tx';
|
|
11
|
+
import { VkData } from '@aztec/stdlib/vks';
|
|
12
|
+
import { accumulateBlobs, buildBlobHints, buildHeaderFromCircuitOutputs, getEmptyBlockBlobsHash } from './block-building-helpers.js';
|
|
8
13
|
/**
|
|
9
14
|
* The current state of the proving schedule for a given block. Managed by ProvingState.
|
|
10
15
|
* Contains the raw inputs and intermediate state to generate every constituent proof in the tree.
|
|
11
16
|
*/ export class BlockProvingState {
|
|
12
17
|
index;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
globalVariables;
|
|
19
|
+
newL1ToL2Messages;
|
|
20
|
+
l1ToL2MessageTreeSnapshot;
|
|
21
|
+
l1ToL2MessageSubtreeSiblingPath;
|
|
22
|
+
l1ToL2MessageTreeSnapshotAfterInsertion;
|
|
23
|
+
lastArchiveSnapshot;
|
|
18
24
|
lastArchiveSiblingPath;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
39
|
+
totalNumTxs;
|
|
31
40
|
txs;
|
|
32
|
-
isFirstBlock;
|
|
33
41
|
error;
|
|
34
|
-
constructor(index,
|
|
42
|
+
constructor(index, globalVariables, newL1ToL2Messages, l1ToL2MessageTreeSnapshot, l1ToL2MessageSubtreeSiblingPath, l1ToL2MessageTreeSnapshotAfterInsertion, lastArchiveSnapshot, lastArchiveSiblingPath, newArchiveSiblingPath, previousBlockHeader, proverId, parentEpoch){
|
|
35
43
|
this.index = index;
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
44
|
+
this.globalVariables = globalVariables;
|
|
45
|
+
this.newL1ToL2Messages = newL1ToL2Messages;
|
|
46
|
+
this.l1ToL2MessageTreeSnapshot = l1ToL2MessageTreeSnapshot;
|
|
47
|
+
this.l1ToL2MessageSubtreeSiblingPath = l1ToL2MessageSubtreeSiblingPath;
|
|
48
|
+
this.l1ToL2MessageTreeSnapshotAfterInsertion = l1ToL2MessageTreeSnapshotAfterInsertion;
|
|
49
|
+
this.lastArchiveSnapshot = lastArchiveSnapshot;
|
|
41
50
|
this.lastArchiveSiblingPath = lastArchiveSiblingPath;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
51
|
+
this.newArchiveSiblingPath = newArchiveSiblingPath;
|
|
52
|
+
this.previousBlockHeader = previousBlockHeader;
|
|
53
|
+
this.proverId = proverId;
|
|
54
|
+
this.parentEpoch = parentEpoch;
|
|
55
|
+
this.baseOrMergeProvingOutputs = new UnbalancedTreeStore(0);
|
|
56
|
+
this.blockRootRollupStarted = false;
|
|
57
|
+
this.txs = [];
|
|
58
|
+
this.baseParityProvingOutputs = Array.from({
|
|
50
59
|
length: NUM_BASE_PARITY_PER_ROOT_PARITY
|
|
51
60
|
}).map((_)=>undefined);
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
54
|
-
|
|
55
|
-
throw new Error(`Cannot create a block with 0 txs, unless it's the first block.`);
|
|
61
|
+
this.totalNumTxs = 0;
|
|
62
|
+
if (this.blockNumber == parentEpoch.firstBlockNumber) {
|
|
63
|
+
this.startBlobAccumulator = BatchedBlobAccumulator.newWithChallenges(parentEpoch.finalBlobBatchingChallenges);
|
|
56
64
|
}
|
|
57
|
-
this.baseOrMergeProofs = new UnbalancedTreeStore(totalNumTxs);
|
|
58
65
|
}
|
|
59
|
-
get
|
|
60
|
-
return this.
|
|
66
|
+
get blockNumber() {
|
|
67
|
+
return this.globalVariables.blockNumber;
|
|
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
78
|
}
|
|
62
79
|
// Adds a transaction to the proving state, returns it's index
|
|
63
80
|
addNewTx(tx) {
|
|
64
|
-
if (!this.
|
|
65
|
-
throw new Error(`
|
|
81
|
+
if (!this.spongeBlobState) {
|
|
82
|
+
throw new Error(`Invalid block proving state, call startNewBlock before adding transactions.`);
|
|
66
83
|
}
|
|
67
84
|
const txIndex = this.txs.length;
|
|
68
85
|
this.txs[txIndex] = tx;
|
|
69
86
|
return txIndex;
|
|
70
87
|
}
|
|
71
|
-
isAcceptingTxs() {
|
|
72
|
-
return this.txs.length < this.totalNumTxs;
|
|
73
|
-
}
|
|
74
|
-
getProcessedTxs() {
|
|
75
|
-
return this.txs.map((t)=>t.processedTx);
|
|
76
|
-
}
|
|
77
|
-
tryStartProvingBase(txIndex) {
|
|
78
|
-
if (this.baseOrMergeProofs.getLeaf(txIndex)?.isProving) {
|
|
79
|
-
return false;
|
|
80
|
-
} else {
|
|
81
|
-
this.baseOrMergeProofs.setLeaf(txIndex, {
|
|
82
|
-
isProving: true
|
|
83
|
-
});
|
|
84
|
-
return true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
88
|
setBaseRollupProof(txIndex, provingOutput) {
|
|
88
|
-
return this.
|
|
89
|
-
provingOutput
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
tryStartProvingMerge(location) {
|
|
93
|
-
if (this.baseOrMergeProofs.getNode(location)?.isProving) {
|
|
94
|
-
return false;
|
|
95
|
-
} else {
|
|
96
|
-
this.baseOrMergeProofs.setNode(location, {
|
|
97
|
-
isProving: true
|
|
98
|
-
});
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
89
|
+
return this.baseOrMergeProvingOutputs.setLeaf(txIndex, provingOutput);
|
|
101
90
|
}
|
|
102
91
|
setMergeRollupProof(location, provingOutput) {
|
|
103
|
-
this.
|
|
104
|
-
provingOutput
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
tryStartProvingBaseParity(index) {
|
|
108
|
-
if (this.baseParityProofs[index]?.isProving) {
|
|
109
|
-
return false;
|
|
110
|
-
} else {
|
|
111
|
-
this.baseParityProofs[index] = {
|
|
112
|
-
isProving: true
|
|
113
|
-
};
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
92
|
+
this.baseOrMergeProvingOutputs.setNode(location, provingOutput);
|
|
116
93
|
}
|
|
117
94
|
// Stores a set of root parity inputs at the given index
|
|
118
95
|
setBaseParityProof(index, provingOutput) {
|
|
119
96
|
if (index >= NUM_BASE_PARITY_PER_ROOT_PARITY) {
|
|
120
97
|
throw new Error(`Unable to set a base parity proofs at index ${index}. Expected at most ${NUM_BASE_PARITY_PER_ROOT_PARITY} proofs.`);
|
|
121
98
|
}
|
|
122
|
-
this.
|
|
123
|
-
provingOutput
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
tryStartProvingRootParity() {
|
|
127
|
-
if (this.rootParityProof?.isProving) {
|
|
128
|
-
return false;
|
|
129
|
-
} else {
|
|
130
|
-
this.rootParityProof = {
|
|
131
|
-
isProving: true
|
|
132
|
-
};
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
99
|
+
this.baseParityProvingOutputs[index] = provingOutput;
|
|
135
100
|
}
|
|
136
101
|
setRootParityProof(provingOutput) {
|
|
137
|
-
this.
|
|
138
|
-
provingOutput
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
tryStartProvingBlockRoot() {
|
|
142
|
-
if (this.blockRootProof?.isProving) {
|
|
143
|
-
return false;
|
|
144
|
-
} else {
|
|
145
|
-
this.blockRootProof = {
|
|
146
|
-
isProving: true
|
|
147
|
-
};
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
102
|
+
this.rootParityProvingOutput = provingOutput;
|
|
150
103
|
}
|
|
151
104
|
setBlockRootRollupProof(provingOutput) {
|
|
152
|
-
this.
|
|
153
|
-
provingOutput
|
|
154
|
-
};
|
|
155
|
-
return this.parentCheckpoint.setBlockRootRollupProof(this.index, provingOutput);
|
|
105
|
+
this.blockRootProvingOutput = provingOutput;
|
|
156
106
|
}
|
|
157
|
-
|
|
158
|
-
|
|
107
|
+
setBlock(block) {
|
|
108
|
+
this.block = block;
|
|
159
109
|
}
|
|
160
|
-
|
|
161
|
-
this.
|
|
110
|
+
setStartBlobAccumulator(accumulator) {
|
|
111
|
+
this.startBlobAccumulator = accumulator;
|
|
162
112
|
}
|
|
163
|
-
|
|
164
|
-
|
|
113
|
+
setEndBlobAccumulator(accumulator) {
|
|
114
|
+
this.endBlobAccumulator = accumulator;
|
|
165
115
|
}
|
|
166
|
-
|
|
167
|
-
if (this.
|
|
168
|
-
|
|
116
|
+
async accumulateBlobs() {
|
|
117
|
+
if (!this.block || !this.startBlobAccumulator) {
|
|
118
|
+
// We only want to accumulate once we have all txs, so we wait until the block is set.
|
|
119
|
+
return;
|
|
169
120
|
}
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
chainId: constants.chainId,
|
|
173
|
-
version: constants.version,
|
|
174
|
-
blockNumber: this.blockNumber,
|
|
175
|
-
slotNumber: constants.slotNumber,
|
|
176
|
-
timestamp: this.timestamp,
|
|
177
|
-
coinbase: constants.coinbase,
|
|
178
|
-
feeRecipient: constants.feeRecipient,
|
|
179
|
-
gasFees: constants.gasFees
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
getStartSpongeBlob() {
|
|
183
|
-
return this.startSpongeBlob;
|
|
121
|
+
const endBlobAccumulator = await accumulateBlobs(this.allTxs.map((t)=>t.processedTx), this.startBlobAccumulator);
|
|
122
|
+
this.setEndBlobAccumulator(endBlobAccumulator);
|
|
184
123
|
}
|
|
185
|
-
|
|
186
|
-
|
|
124
|
+
// Returns the complete set of transaction proving state objects
|
|
125
|
+
get allTxs() {
|
|
126
|
+
return this.txs;
|
|
187
127
|
}
|
|
188
|
-
|
|
189
|
-
return this.
|
|
190
|
-
}
|
|
191
|
-
getTxEffects() {
|
|
192
|
-
return this.txs.map((t)=>t.processedTx.txEffect);
|
|
128
|
+
/** Returns the block number as an epoch number. Used for prioritizing proof requests. */ get epochNumber() {
|
|
129
|
+
return this.parentEpoch.epochNumber;
|
|
193
130
|
}
|
|
194
131
|
getParentLocation(location) {
|
|
195
|
-
return this.
|
|
132
|
+
return this.baseOrMergeProvingOutputs.getParentLocation(location);
|
|
196
133
|
}
|
|
197
134
|
getMergeRollupInputs(mergeLocation) {
|
|
198
|
-
const [left, right] = this.
|
|
135
|
+
const [left, right] = this.baseOrMergeProvingOutputs.getChildren(mergeLocation);
|
|
199
136
|
if (!left || !right) {
|
|
200
|
-
throw new Error('At
|
|
137
|
+
throw new Error('At lease one child is not ready.');
|
|
201
138
|
}
|
|
202
|
-
return new
|
|
203
|
-
|
|
204
|
-
|
|
139
|
+
return new MergeRollupInputs([
|
|
140
|
+
this.#getPreviousRollupData(left),
|
|
141
|
+
this.#getPreviousRollupData(right)
|
|
205
142
|
]);
|
|
206
143
|
}
|
|
207
|
-
getBlockRootRollupTypeAndInputs() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
throw new Error('At least one child is not ready for the block root rollup.');
|
|
144
|
+
async getBlockRootRollupTypeAndInputs() {
|
|
145
|
+
if (!this.rootParityProvingOutput) {
|
|
146
|
+
throw new Error('Root parity is not ready.');
|
|
211
147
|
}
|
|
212
|
-
const
|
|
213
|
-
|
|
214
|
-
|
|
148
|
+
const proofs = this.#getChildProofsForBlockRoot();
|
|
149
|
+
const nonEmptyProofs = proofs.filter((p)=>!!p);
|
|
150
|
+
if (proofs.length !== nonEmptyProofs.length) {
|
|
151
|
+
throw new Error('At lease one child is not ready for the block root.');
|
|
215
152
|
}
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
153
|
+
const data = this.#getBlockRootRollupData();
|
|
154
|
+
if (this.totalNumTxs === 0) {
|
|
155
|
+
const constants = BlockConstantData.from({
|
|
156
|
+
lastArchive: this.lastArchiveSnapshot,
|
|
157
|
+
newL1ToL2: this.l1ToL2MessageTreeSnapshotAfterInsertion,
|
|
158
|
+
globalVariables: this.globalVariables,
|
|
159
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
160
|
+
protocolContractTreeRoot
|
|
161
|
+
});
|
|
162
|
+
this.blobsHash = await getEmptyBlockBlobsHash();
|
|
223
163
|
return {
|
|
224
|
-
rollupType: '
|
|
225
|
-
inputs:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
164
|
+
rollupType: 'empty-block-root-rollup',
|
|
165
|
+
inputs: EmptyBlockRootRollupInputs.from({
|
|
166
|
+
data,
|
|
167
|
+
constants
|
|
168
|
+
})
|
|
229
169
|
};
|
|
230
170
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
const l1ToL2Roots = toProofData(this.rootParityProof.provingOutput);
|
|
237
|
-
if (!leftRollup) {
|
|
171
|
+
const previousRollupData = await Promise.all(nonEmptyProofs.map((p)=>this.#getPreviousRollupData(p)));
|
|
172
|
+
const blobData = await this.#getBlockRootRollupBlobData();
|
|
173
|
+
this.blobsHash = blobData.blobsHash;
|
|
174
|
+
if (previousRollupData.length === 1) {
|
|
238
175
|
return {
|
|
239
|
-
rollupType: '
|
|
240
|
-
inputs: new
|
|
241
|
-
};
|
|
242
|
-
} else if (!rightRollup) {
|
|
243
|
-
return {
|
|
244
|
-
rollupType: 'rollup-block-root-first-single-tx',
|
|
245
|
-
inputs: new BlockRootSingleTxFirstRollupPrivateInputs(l1ToL2Roots, leftRollup, this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeRootSiblingPath, this.lastArchiveSiblingPath)
|
|
176
|
+
rollupType: 'single-tx-block-root-rollup',
|
|
177
|
+
inputs: new SingleTxBlockRootRollupInputs(previousRollupData, data, blobData)
|
|
246
178
|
};
|
|
247
179
|
} else {
|
|
248
180
|
return {
|
|
249
|
-
rollupType: '
|
|
250
|
-
inputs: new
|
|
251
|
-
leftRollup,
|
|
252
|
-
rightRollup
|
|
253
|
-
], this.lastL1ToL2MessageTreeSnapshot, this.lastL1ToL2MessageSubtreeRootSiblingPath, this.lastArchiveSiblingPath)
|
|
181
|
+
rollupType: 'block-root-rollup',
|
|
182
|
+
inputs: new BlockRootRollupInputs(previousRollupData, data, blobData)
|
|
254
183
|
};
|
|
255
184
|
}
|
|
256
185
|
}
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
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
|
+
getRootParityInputs() {
|
|
197
|
+
if (!this.baseParityProvingOutputs.every((p)=>!!p)) {
|
|
260
198
|
throw new Error('At lease one base parity is not ready.');
|
|
261
199
|
}
|
|
262
|
-
const children = baseParityProvingOutputs.map((p)=>
|
|
263
|
-
return new
|
|
200
|
+
const children = this.baseParityProvingOutputs.map((p)=>this.#getRootParityData(p));
|
|
201
|
+
return new RootParityInputs(children);
|
|
264
202
|
}
|
|
265
203
|
// Returns a specific transaction proving state
|
|
266
204
|
getTxProvingState(txIndex) {
|
|
267
205
|
return this.txs[txIndex];
|
|
268
206
|
}
|
|
269
207
|
async buildHeaderFromProvingOutputs() {
|
|
270
|
-
|
|
271
|
-
|
|
208
|
+
const previousRollupData = this.totalNumTxs === 0 ? [] : await Promise.all(this.#getChildProofsForBlockRoot().map((p)=>this.#getPreviousRollupData(p)));
|
|
209
|
+
let endPartialState = this.previousBlockHeader.state.partial;
|
|
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
217
|
}
|
|
273
|
-
|
|
218
|
+
const endState = new StateReference(this.l1ToL2MessageTreeSnapshotAfterInsertion, endPartialState);
|
|
219
|
+
return buildHeaderFromCircuitOutputs(previousRollupData.map((d)=>d.baseOrMergeRollupPublicInputs), this.rootParityProvingOutput.inputs, this.blockRootProvingOutput.inputs, this.blobsHash, endState);
|
|
274
220
|
}
|
|
275
221
|
isReadyForMergeRollup(location) {
|
|
276
|
-
return
|
|
222
|
+
return this.baseOrMergeProvingOutputs.getSibling(location) !== undefined;
|
|
277
223
|
}
|
|
278
224
|
// Returns true if we have sufficient inputs to execute the block root rollup
|
|
279
225
|
isReadyForBlockRootRollup() {
|
|
280
|
-
const childProofs = this.#
|
|
281
|
-
return
|
|
226
|
+
const childProofs = this.#getChildProofsForBlockRoot();
|
|
227
|
+
return this.block !== undefined && this.rootParityProvingOutput !== undefined && this.endBlobAccumulator !== undefined && childProofs.every((p)=>!!p);
|
|
282
228
|
}
|
|
283
229
|
// Returns true if we have sufficient root parity inputs to execute the root parity circuit
|
|
284
230
|
isReadyForRootParity() {
|
|
285
|
-
return this.
|
|
231
|
+
return this.baseParityProvingOutputs.every((p)=>!!p);
|
|
286
232
|
}
|
|
287
233
|
isComplete() {
|
|
288
|
-
return !!this.
|
|
234
|
+
return !!this.blockRootProvingOutput;
|
|
289
235
|
}
|
|
236
|
+
// Returns whether the proving state is still valid
|
|
290
237
|
verifyState() {
|
|
291
|
-
return this.
|
|
292
|
-
}
|
|
293
|
-
getError() {
|
|
294
|
-
return this.error;
|
|
238
|
+
return this.parentEpoch.verifyState();
|
|
295
239
|
}
|
|
296
240
|
reject(reason) {
|
|
297
241
|
this.error = reason;
|
|
298
|
-
this.
|
|
242
|
+
this.parentEpoch.reject(reason);
|
|
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
255
|
}
|
|
300
|
-
#
|
|
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
|
+
});
|
|
264
|
+
}
|
|
265
|
+
#getChildProofsForBlockRoot() {
|
|
301
266
|
if (this.totalNumTxs === 0) {
|
|
302
267
|
return [];
|
|
303
268
|
}
|
|
@@ -307,7 +272,15 @@ import { buildHeaderFromCircuitOutputs, toProofData } from './block-building-hel
|
|
|
307
272
|
};
|
|
308
273
|
// If there's only 1 tx, its base rollup proof will be stored at the root.
|
|
309
274
|
return this.totalNumTxs === 1 ? [
|
|
310
|
-
this.
|
|
311
|
-
] : this.
|
|
275
|
+
this.baseOrMergeProvingOutputs.getNode(rootLocation)
|
|
276
|
+
] : this.baseOrMergeProvingOutputs.getChildren(rootLocation);
|
|
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);
|
|
312
285
|
}
|
|
313
286
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { BatchedBlob, type FinalBlobBatchingChallenges } from '@aztec/blob-lib';
|
|
2
|
-
import type { ARCHIVE_HEIGHT,
|
|
2
|
+
import type { ARCHIVE_HEIGHT, L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH, NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH } from '@aztec/constants';
|
|
3
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
4
|
import type { Fr } from '@aztec/foundation/fields';
|
|
4
5
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
5
6
|
import { type TreeNodeLocation } from '@aztec/foundation/trees';
|
|
6
|
-
import type { PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
7
|
+
import type { ProofAndVerificationKey, PublicInputsAndRecursiveProof } from '@aztec/stdlib/interfaces/server';
|
|
7
8
|
import type { Proof } from '@aztec/stdlib/proofs';
|
|
8
|
-
import {
|
|
9
|
+
import { BlockMergeRollupInputs, type BlockRootOrBlockMergePublicInputs, RootRollupInputs, type RootRollupPublicInputs } from '@aztec/stdlib/rollup';
|
|
9
10
|
import type { AppendOnlyTreeSnapshot, MerkleTreeId } from '@aztec/stdlib/trees';
|
|
10
|
-
import type { BlockHeader } from '@aztec/stdlib/tx';
|
|
11
|
-
import {
|
|
11
|
+
import type { BlockHeader, GlobalVariables } from '@aztec/stdlib/tx';
|
|
12
|
+
import { BlockProvingState } from './block-proving-state.js';
|
|
12
13
|
export type TreeSnapshots = Map<MerkleTreeId, AppendOnlyTreeSnapshot>;
|
|
13
14
|
export type ProvingResult = {
|
|
14
15
|
status: 'success';
|
|
@@ -25,46 +26,39 @@ export type ProvingResult = {
|
|
|
25
26
|
export declare class EpochProvingState {
|
|
26
27
|
#private;
|
|
27
28
|
readonly epochNumber: number;
|
|
28
|
-
readonly
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
readonly firstBlockNumber: number;
|
|
30
|
+
readonly totalNumBlocks: number;
|
|
31
|
+
readonly finalBlobBatchingChallenges: FinalBlobBatchingChallenges;
|
|
31
32
|
private completionCallback;
|
|
32
33
|
private rejectionCallback;
|
|
33
|
-
private
|
|
34
|
-
private
|
|
35
|
-
private
|
|
36
|
-
private checkpoints;
|
|
37
|
-
private startBlobAccumulator;
|
|
38
|
-
private endBlobAccumulator;
|
|
34
|
+
private blockRootOrMergeProvingOutputs;
|
|
35
|
+
private paddingBlockRootProvingOutput;
|
|
36
|
+
private rootRollupProvingOutput;
|
|
39
37
|
private finalBatchedBlob;
|
|
40
38
|
private provingStateLifecycle;
|
|
41
|
-
readonly
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
getCheckpointProvingStateByBlockNumber(blockNumber: number): CheckpointProvingState | undefined;
|
|
46
|
-
getBlockProvingStateByBlockNumber(blockNumber: number): import("./block-proving-state.js").BlockProvingState | undefined;
|
|
39
|
+
readonly cachedTubeProofs: Map<string, Promise<ProofAndVerificationKey<535>>>;
|
|
40
|
+
blocks: (BlockProvingState | undefined)[];
|
|
41
|
+
constructor(epochNumber: number, firstBlockNumber: number, totalNumBlocks: number, finalBlobBatchingChallenges: FinalBlobBatchingChallenges, completionCallback: (result: ProvingResult) => void, rejectionCallback: (reason: string) => void);
|
|
42
|
+
startNewBlock(globalVariables: GlobalVariables, l1ToL2Messages: Fr[], l1ToL2MessageTreeSnapshot: AppendOnlyTreeSnapshot, l1ToL2MessageSubtreeSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>, l1ToL2MessageTreeSnapshotAfterInsertion: AppendOnlyTreeSnapshot, lastArchiveSnapshot: AppendOnlyTreeSnapshot, lastArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>, newArchiveSiblingPath: Tuple<Fr, typeof ARCHIVE_HEIGHT>, previousBlockHeader: BlockHeader, proverId: EthAddress): BlockProvingState;
|
|
47
43
|
verifyState(): boolean;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
setCheckpointPaddingProof(provingOutput: PublicInputsAndRecursiveProof<CheckpointRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
56
|
-
setBlobAccumulators(): Promise<void>;
|
|
57
|
-
finalizeBatchedBlob(): Promise<void>;
|
|
44
|
+
isAcceptingBlocks(): boolean;
|
|
45
|
+
setBlockRootRollupProof(blockIndex: number, proof: PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): TreeNodeLocation;
|
|
46
|
+
setBlockMergeRollupProof(location: TreeNodeLocation, proof: PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
47
|
+
setRootRollupProof(proof: PublicInputsAndRecursiveProof<RootRollupPublicInputs>): void;
|
|
48
|
+
setPaddingBlockRootProof(proof: PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>): void;
|
|
49
|
+
setFinalBatchedBlob(batchedBlob: BatchedBlob): void;
|
|
50
|
+
setBlobAccumulators(toBlock?: number): Promise<void>;
|
|
58
51
|
getParentLocation(location: TreeNodeLocation): TreeNodeLocation;
|
|
59
|
-
|
|
60
|
-
getRootRollupInputs():
|
|
61
|
-
|
|
52
|
+
getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation): BlockMergeRollupInputs;
|
|
53
|
+
getRootRollupInputs(): RootRollupInputs;
|
|
54
|
+
getPaddingBlockRootInputs(): import("@aztec/stdlib/rollup").PaddingBlockRootRollupInputs;
|
|
55
|
+
getBlockProvingStateByBlockNumber(blockNumber: number): BlockProvingState | undefined;
|
|
62
56
|
getEpochProofResult(): {
|
|
63
57
|
proof: Proof;
|
|
64
58
|
publicInputs: RootRollupPublicInputs;
|
|
65
59
|
batchedBlobInputs: BatchedBlob;
|
|
66
60
|
};
|
|
67
|
-
|
|
61
|
+
isReadyForBlockMerge(location: TreeNodeLocation): boolean;
|
|
68
62
|
isReadyForRootRollup(): boolean;
|
|
69
63
|
cancel(): void;
|
|
70
64
|
reject(reason: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"epoch-proving-state.d.ts","sourceRoot":"","sources":["../../src/orchestrator/epoch-proving-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"epoch-proving-state.d.ts","sourceRoot":"","sources":["../../src/orchestrator/epoch-proving-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAChF,OAAO,KAAK,EACV,cAAc,EACd,wCAAwC,EACxC,yCAAyC,EAE1C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,KAAK,gBAAgB,EAAu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