@aztec/prover-client 0.75.0 → 0.76.1
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/mocks/test_context.d.ts +4 -4
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +17 -19
- package/dest/orchestrator/block-building-helpers.d.ts +1 -1
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +5 -23
- package/dest/orchestrator/block-proving-state.d.ts +2 -2
- package/dest/orchestrator/block-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/block-proving-state.js +16 -16
- package/dest/orchestrator/epoch-proving-state.d.ts +2 -2
- package/dest/orchestrator/epoch-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/epoch-proving-state.js +8 -11
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +35 -35
- package/dest/orchestrator/tx-proving-state.d.ts +2 -2
- package/dest/orchestrator/tx-proving-state.d.ts.map +1 -1
- package/dest/orchestrator/tx-proving-state.js +14 -14
- package/dest/proving_broker/proving_agent.d.ts +1 -0
- package/dest/proving_broker/proving_agent.d.ts.map +1 -1
- package/dest/proving_broker/proving_agent.js +26 -11
- package/dest/proving_broker/proving_broker.d.ts +4 -7
- package/dest/proving_broker/proving_broker.d.ts.map +1 -1
- package/dest/proving_broker/proving_broker.js +21 -23
- package/dest/proving_broker/rpc.d.ts +19 -4
- package/dest/proving_broker/rpc.d.ts.map +1 -1
- package/dest/proving_broker/rpc.js +28 -10
- package/dest/test/mock_prover.d.ts +2 -0
- package/dest/test/mock_prover.d.ts.map +1 -1
- package/dest/test/mock_prover.js +5 -1
- package/package.json +12 -12
- package/src/mocks/test_context.ts +23 -22
- package/src/orchestrator/block-building-helpers.ts +2 -39
- package/src/orchestrator/block-proving-state.ts +15 -15
- package/src/orchestrator/epoch-proving-state.ts +7 -10
- package/src/orchestrator/orchestrator.ts +36 -39
- package/src/orchestrator/tx-proving-state.ts +13 -13
- package/src/proving_broker/proving_agent.ts +30 -11
- package/src/proving_broker/proving_broker.ts +53 -27
- package/src/proving_broker/rpc.ts +32 -6
- package/src/test/mock_prover.ts +7 -1
- package/dest/prover-agent/index.d.ts +0 -4
- package/dest/prover-agent/index.d.ts.map +0 -1
- package/dest/prover-agent/index.js +0 -4
- package/dest/prover-agent/memory-proving-queue.d.ts +0 -82
- package/dest/prover-agent/memory-proving-queue.d.ts.map +0 -1
- package/dest/prover-agent/memory-proving-queue.js +0 -260
- package/dest/prover-agent/prover-agent.d.ts +0 -43
- package/dest/prover-agent/prover-agent.d.ts.map +0 -1
- package/dest/prover-agent/prover-agent.js +0 -204
- package/dest/prover-agent/proving-error.d.ts +0 -5
- package/dest/prover-agent/proving-error.d.ts.map +0 -1
- package/dest/prover-agent/proving-error.js +0 -9
- package/dest/prover-agent/queue_metrics.d.ts +0 -10
- package/dest/prover-agent/queue_metrics.d.ts.map +0 -1
- package/dest/prover-agent/queue_metrics.js +0 -23
- package/dest/prover-agent/rpc.d.ts +0 -11
- package/dest/prover-agent/rpc.d.ts.map +0 -1
- package/dest/prover-agent/rpc.js +0 -18
- package/src/prover-agent/index.ts +0 -3
- package/src/prover-agent/memory-proving-queue.ts +0 -416
- package/src/prover-agent/prover-agent.ts +0 -248
- package/src/prover-agent/proving-error.ts +0 -9
- package/src/prover-agent/queue_metrics.ts +0 -29
- package/src/prover-agent/rpc.ts +0 -22
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/prover-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.76.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
7
|
"./block-builder": "./dest/block_builder/index.js",
|
|
8
8
|
"./broker": "./dest/proving_broker/index.js",
|
|
9
|
-
"./prover-agent": "./dest/prover-agent/index.js",
|
|
10
9
|
"./orchestrator": "./dest/orchestrator/index.js",
|
|
11
10
|
"./helpers": "./dest/orchestrator/block-building-helpers.js",
|
|
12
11
|
"./config": "./dest/config.js"
|
|
@@ -67,16 +66,17 @@
|
|
|
67
66
|
]
|
|
68
67
|
},
|
|
69
68
|
"dependencies": {
|
|
70
|
-
"@aztec/bb-prover": "0.
|
|
71
|
-
"@aztec/
|
|
72
|
-
"@aztec/
|
|
73
|
-
"@aztec/
|
|
74
|
-
"@aztec/
|
|
75
|
-
"@aztec/
|
|
76
|
-
"@aztec/protocol-
|
|
77
|
-
"@aztec/
|
|
78
|
-
"@aztec/
|
|
79
|
-
"@aztec/
|
|
69
|
+
"@aztec/bb-prover": "0.76.1",
|
|
70
|
+
"@aztec/blob-lib": "0.76.1",
|
|
71
|
+
"@aztec/circuit-types": "0.76.1",
|
|
72
|
+
"@aztec/circuits.js": "0.76.1",
|
|
73
|
+
"@aztec/foundation": "0.76.1",
|
|
74
|
+
"@aztec/kv-store": "0.76.1",
|
|
75
|
+
"@aztec/noir-protocol-circuits-types": "0.76.1",
|
|
76
|
+
"@aztec/protocol-contracts": "0.76.1",
|
|
77
|
+
"@aztec/simulator": "0.76.1",
|
|
78
|
+
"@aztec/telemetry-client": "0.76.1",
|
|
79
|
+
"@aztec/world-state": "0.76.1",
|
|
80
80
|
"@google-cloud/storage": "^7.15.0",
|
|
81
81
|
"@iarna/toml": "^2.2.5",
|
|
82
82
|
"@noir-lang/types": "portal:../../noir/packages/types",
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
WASMSimulatorWithBlobs,
|
|
28
28
|
type WorldStateDB,
|
|
29
29
|
} from '@aztec/simulator/server';
|
|
30
|
-
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
31
30
|
import { type MerkleTreeAdminDatabase } from '@aztec/world-state';
|
|
32
31
|
import { NativeWorldStateService } from '@aztec/world-state/native';
|
|
33
32
|
|
|
@@ -40,8 +39,7 @@ import { AvmFinalizedCallResult } from '../../../simulator/src/avm/avm_contract_
|
|
|
40
39
|
import { type AvmPersistableStateManager } from '../../../simulator/src/avm/journal/journal.js';
|
|
41
40
|
import { buildBlock } from '../block_builder/light.js';
|
|
42
41
|
import { ProvingOrchestrator } from '../orchestrator/index.js';
|
|
43
|
-
import {
|
|
44
|
-
import { ProverAgent } from '../prover-agent/prover-agent.js';
|
|
42
|
+
import { TestBroker } from '../test/mock_prover.js';
|
|
45
43
|
import { getEnvironmentConfig, getSimulationProvider, makeGlobals, updateExpectedTreesFromTxs } from './fixtures.js';
|
|
46
44
|
|
|
47
45
|
export class TestContext {
|
|
@@ -54,7 +52,7 @@ export class TestContext {
|
|
|
54
52
|
public simulationProvider: SimulationProvider,
|
|
55
53
|
public globalVariables: GlobalVariables,
|
|
56
54
|
public prover: ServerCircuitProver,
|
|
57
|
-
public
|
|
55
|
+
public broker: TestBroker,
|
|
58
56
|
public orchestrator: TestProvingOrchestrator,
|
|
59
57
|
public blockNumber: number,
|
|
60
58
|
public directoriesToCleanup: string[],
|
|
@@ -115,12 +113,10 @@ export class TestContext {
|
|
|
115
113
|
directoriesToCleanup.push(config.directoryToCleanup);
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
const
|
|
119
|
-
const orchestrator = new TestProvingOrchestrator(ws,
|
|
120
|
-
const agent = new ProverAgent(localProver, proverCount, undefined);
|
|
116
|
+
const broker = new TestBroker(proverCount, localProver);
|
|
117
|
+
const orchestrator = new TestProvingOrchestrator(ws, broker.facade, Fr.ZERO);
|
|
121
118
|
|
|
122
|
-
|
|
123
|
-
agent.start(queue);
|
|
119
|
+
await broker.start();
|
|
124
120
|
|
|
125
121
|
return new this(
|
|
126
122
|
publicTxSimulator,
|
|
@@ -129,7 +125,7 @@ export class TestContext {
|
|
|
129
125
|
simulationProvider,
|
|
130
126
|
globalVariables,
|
|
131
127
|
localProver,
|
|
132
|
-
|
|
128
|
+
broker,
|
|
133
129
|
orchestrator,
|
|
134
130
|
blockNumber,
|
|
135
131
|
directoriesToCleanup,
|
|
@@ -152,7 +148,7 @@ export class TestContext {
|
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
async cleanup() {
|
|
155
|
-
await this.
|
|
151
|
+
await this.broker.stop();
|
|
156
152
|
for (const dir of this.directoriesToCleanup.filter(x => x !== '')) {
|
|
157
153
|
await fs.rm(dir, { recursive: true, force: true });
|
|
158
154
|
}
|
|
@@ -160,15 +156,13 @@ export class TestContext {
|
|
|
160
156
|
|
|
161
157
|
public makeProcessedTx(opts?: Parameters<typeof makeBloatedProcessedTx>[0]): Promise<ProcessedTx>;
|
|
162
158
|
public makeProcessedTx(seed?: number): Promise<ProcessedTx>;
|
|
163
|
-
public
|
|
164
|
-
seedOrOpts?: Parameters<typeof makeBloatedProcessedTx>[0] | number,
|
|
165
|
-
): Promise<ProcessedTx> {
|
|
159
|
+
public makeProcessedTx(seedOrOpts?: Parameters<typeof makeBloatedProcessedTx>[0] | number): Promise<ProcessedTx> {
|
|
166
160
|
const opts = typeof seedOrOpts === 'number' ? { seed: seedOrOpts } : seedOrOpts;
|
|
167
161
|
const blockNum = (opts?.globalVariables ?? this.globalVariables).blockNumber.toNumber();
|
|
168
162
|
const header = this.getBlockHeader(blockNum - 1);
|
|
169
163
|
return makeBloatedProcessedTx({
|
|
170
164
|
header,
|
|
171
|
-
vkTreeRoot:
|
|
165
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
172
166
|
protocolContractTreeRoot,
|
|
173
167
|
globalVariables: this.globalVariables,
|
|
174
168
|
...opts,
|
|
@@ -189,7 +183,7 @@ export class TestContext {
|
|
|
189
183
|
const txs = await timesParallel(numTxs, i =>
|
|
190
184
|
this.makeProcessedTx({ seed: i + blockNum * 1000, globalVariables, ...makeProcessedTxOpts(i) }),
|
|
191
185
|
);
|
|
192
|
-
await this.
|
|
186
|
+
await this.setTreeRoots(txs);
|
|
193
187
|
|
|
194
188
|
const block = await buildBlock(txs, globalVariables, msgs, db);
|
|
195
189
|
this.headers.set(blockNum, block.header);
|
|
@@ -226,17 +220,24 @@ export class TestContext {
|
|
|
226
220
|
);
|
|
227
221
|
}
|
|
228
222
|
|
|
229
|
-
public async
|
|
223
|
+
public async setTreeRoots(txs: ProcessedTx[]) {
|
|
230
224
|
const db = await this.worldState.fork();
|
|
231
225
|
for (const tx of txs) {
|
|
226
|
+
const startStateReference = await db.getStateReference();
|
|
232
227
|
await updateExpectedTreesFromTxs(db, [tx]);
|
|
233
|
-
const
|
|
228
|
+
const endStateReference = await db.getStateReference();
|
|
234
229
|
if (tx.avmProvingRequest) {
|
|
230
|
+
tx.avmProvingRequest.inputs.publicInputs.startTreeSnapshots = new TreeSnapshots(
|
|
231
|
+
startStateReference.l1ToL2MessageTree,
|
|
232
|
+
startStateReference.partial.noteHashTree,
|
|
233
|
+
startStateReference.partial.nullifierTree,
|
|
234
|
+
startStateReference.partial.publicDataTree,
|
|
235
|
+
);
|
|
235
236
|
tx.avmProvingRequest.inputs.publicInputs.endTreeSnapshots = new TreeSnapshots(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
endStateReference.l1ToL2MessageTree,
|
|
238
|
+
endStateReference.partial.noteHashTree,
|
|
239
|
+
endStateReference.partial.nullifierTree,
|
|
240
|
+
endStateReference.partial.publicDataTree,
|
|
240
241
|
);
|
|
241
242
|
}
|
|
242
243
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Blob } from '@aztec/blob-lib';
|
|
1
2
|
import {
|
|
2
3
|
Body,
|
|
3
4
|
MerkleTreeId,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
type GlobalVariables,
|
|
16
17
|
MAX_NOTE_HASHES_PER_TX,
|
|
17
18
|
MAX_NULLIFIERS_PER_TX,
|
|
18
|
-
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
19
19
|
MembershipWitness,
|
|
20
20
|
MerkleTreeCalculator,
|
|
21
21
|
NOTE_HASH_SUBTREE_HEIGHT,
|
|
@@ -41,10 +41,8 @@ import {
|
|
|
41
41
|
PrivateBaseRollupHints,
|
|
42
42
|
PrivateBaseStateDiffHints,
|
|
43
43
|
PublicBaseRollupHints,
|
|
44
|
-
PublicBaseStateDiffHints,
|
|
45
44
|
} from '@aztec/circuits.js/rollup';
|
|
46
45
|
import { makeTuple } from '@aztec/foundation/array';
|
|
47
|
-
import { Blob } from '@aztec/foundation/blob';
|
|
48
46
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
49
47
|
import { sha256Trunc } from '@aztec/foundation/crypto';
|
|
50
48
|
import { type Logger } from '@aztec/foundation/log';
|
|
@@ -139,39 +137,6 @@ export const buildBaseRollupHints = runInSpan(
|
|
|
139
137
|
await startSpongeBlob.absorb(tx.txEffect.toBlobFields());
|
|
140
138
|
|
|
141
139
|
if (tx.avmProvingRequest) {
|
|
142
|
-
// Build public base rollup hints
|
|
143
|
-
const stateDiffHints = PublicBaseStateDiffHints.from({
|
|
144
|
-
nullifierPredecessorPreimages: makeTuple(MAX_NULLIFIERS_PER_TX, i =>
|
|
145
|
-
i < nullifierWitnessLeaves.length
|
|
146
|
-
? (nullifierWitnessLeaves[i].leafPreimage as NullifierLeafPreimage)
|
|
147
|
-
: NullifierLeafPreimage.empty(),
|
|
148
|
-
),
|
|
149
|
-
nullifierPredecessorMembershipWitnesses: makeTuple(MAX_NULLIFIERS_PER_TX, i =>
|
|
150
|
-
i < nullifierPredecessorMembershipWitnessesWithoutPadding.length
|
|
151
|
-
? nullifierPredecessorMembershipWitnessesWithoutPadding[i]
|
|
152
|
-
: makeEmptyMembershipWitness(NULLIFIER_TREE_HEIGHT),
|
|
153
|
-
),
|
|
154
|
-
sortedNullifiers: makeTuple(MAX_NULLIFIERS_PER_TX, i => Fr.fromBuffer(sortednullifiers[i])),
|
|
155
|
-
sortedNullifierIndexes: makeTuple(MAX_NULLIFIERS_PER_TX, i => sortedNewLeavesIndexes[i]),
|
|
156
|
-
noteHashSubtreeSiblingPath,
|
|
157
|
-
nullifierSubtreeSiblingPath,
|
|
158
|
-
lowPublicDataWritesPreimages: padArrayEnd(
|
|
159
|
-
txPublicDataUpdateRequestInfo.lowPublicDataWritesPreimages,
|
|
160
|
-
PublicDataTreeLeafPreimage.empty(),
|
|
161
|
-
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
162
|
-
),
|
|
163
|
-
lowPublicDataWritesMembershipWitnesses: padArrayEnd(
|
|
164
|
-
txPublicDataUpdateRequestInfo.lowPublicDataWritesMembershipWitnesses,
|
|
165
|
-
MembershipWitness.empty(PUBLIC_DATA_TREE_HEIGHT),
|
|
166
|
-
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
167
|
-
),
|
|
168
|
-
publicDataTreeSiblingPaths: padArrayEnd(
|
|
169
|
-
txPublicDataUpdateRequestInfo.publicDataWritesSiblingPaths,
|
|
170
|
-
makeTuple(PUBLIC_DATA_TREE_HEIGHT, () => Fr.ZERO),
|
|
171
|
-
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
172
|
-
),
|
|
173
|
-
});
|
|
174
|
-
|
|
175
140
|
const blockHash = await tx.constants.historicalHeader.hash();
|
|
176
141
|
const archiveRootMembershipWitness = await getMembershipWitnessFor(
|
|
177
142
|
blockHash,
|
|
@@ -181,9 +146,7 @@ export const buildBaseRollupHints = runInSpan(
|
|
|
181
146
|
);
|
|
182
147
|
|
|
183
148
|
return PublicBaseRollupHints.from({
|
|
184
|
-
start,
|
|
185
149
|
startSpongeBlob: inputSpongeBlob,
|
|
186
|
-
stateDiffHints,
|
|
187
150
|
archiveRootMembershipWitness,
|
|
188
151
|
constants,
|
|
189
152
|
});
|
|
@@ -441,7 +404,7 @@ export const getConstantRollupData = runInSpan(
|
|
|
441
404
|
'getConstantRollupData',
|
|
442
405
|
async (_span, globalVariables: GlobalVariables, db: MerkleTreeReadOperations): Promise<ConstantRollupData> => {
|
|
443
406
|
return ConstantRollupData.from({
|
|
444
|
-
vkTreeRoot:
|
|
407
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
445
408
|
protocolContractTreeRoot,
|
|
446
409
|
lastArchive: await getTreeSnapshot(MerkleTreeId.ARCHIVE, db),
|
|
447
410
|
globalVariables,
|
|
@@ -164,13 +164,13 @@ export class BlockProvingState {
|
|
|
164
164
|
return this.baseOrMergeProvingOutputs.getParentLocation(location);
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
public
|
|
167
|
+
public getMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
168
168
|
const [left, right] = this.baseOrMergeProvingOutputs.getChildren(mergeLocation);
|
|
169
169
|
if (!left || !right) {
|
|
170
170
|
throw new Error('At lease one child is not ready.');
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
return new MergeRollupInputs([
|
|
173
|
+
return new MergeRollupInputs([this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)]);
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
public async getBlockRootRollupTypeAndInputs(proverId: Fr) {
|
|
@@ -184,13 +184,13 @@ export class BlockProvingState {
|
|
|
184
184
|
throw new Error('At lease one child is not ready for the block root.');
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
const data =
|
|
187
|
+
const data = this.#getBlockRootRollupData(proverId);
|
|
188
188
|
|
|
189
189
|
if (this.totalNumTxs === 0) {
|
|
190
190
|
const constants = ConstantRollupData.from({
|
|
191
191
|
lastArchive: this.lastArchiveSnapshot,
|
|
192
192
|
globalVariables: this.globalVariables,
|
|
193
|
-
vkTreeRoot:
|
|
193
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
194
194
|
protocolContractTreeRoot,
|
|
195
195
|
});
|
|
196
196
|
|
|
@@ -234,7 +234,7 @@ export class BlockProvingState {
|
|
|
234
234
|
const newArchive = this.blockRootProvingOutput!.inputs.newArchive;
|
|
235
235
|
|
|
236
236
|
const data = BlockRootRollupData.from({
|
|
237
|
-
l1ToL2Roots:
|
|
237
|
+
l1ToL2Roots: this.#getRootParityData(this.rootParityProvingOutput!),
|
|
238
238
|
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
239
239
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
240
240
|
previousBlockHeader: newBlockHeader,
|
|
@@ -244,7 +244,7 @@ export class BlockProvingState {
|
|
|
244
244
|
const constants = ConstantRollupData.from({
|
|
245
245
|
lastArchive: newArchive,
|
|
246
246
|
globalVariables: this.globalVariables,
|
|
247
|
-
vkTreeRoot:
|
|
247
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
248
248
|
protocolContractTreeRoot,
|
|
249
249
|
});
|
|
250
250
|
|
|
@@ -255,12 +255,12 @@ export class BlockProvingState {
|
|
|
255
255
|
});
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
public
|
|
258
|
+
public getRootParityInputs() {
|
|
259
259
|
if (!this.baseParityProvingOutputs.every(p => !!p)) {
|
|
260
260
|
throw new Error('At lease one base parity is not ready.');
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
const children =
|
|
263
|
+
const children = this.baseParityProvingOutputs.map(p => this.#getRootParityData(p!));
|
|
264
264
|
return new RootParityInputs(
|
|
265
265
|
children as Tuple<RootParityInput<typeof RECURSIVE_PROOF_LENGTH>, typeof NUM_BASE_PARITY_PER_ROOT_PARITY>,
|
|
266
266
|
);
|
|
@@ -326,9 +326,9 @@ export class BlockProvingState {
|
|
|
326
326
|
this.parentEpoch.reject(reason);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
|
|
329
|
+
#getBlockRootRollupData(proverId: Fr) {
|
|
330
330
|
return BlockRootRollupData.from({
|
|
331
|
-
l1ToL2Roots:
|
|
331
|
+
l1ToL2Roots: this.#getRootParityData(this.rootParityProvingOutput!),
|
|
332
332
|
l1ToL2MessageSubtreeSiblingPath: this.l1ToL2MessageSubtreeSiblingPath,
|
|
333
333
|
newArchiveSiblingPath: this.newArchiveSiblingPath,
|
|
334
334
|
previousBlockHeader: this.previousBlockHeader,
|
|
@@ -358,25 +358,25 @@ export class BlockProvingState {
|
|
|
358
358
|
: this.baseOrMergeProvingOutputs.getChildren(rootLocation);
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
|
|
361
|
+
#getPreviousRollupData({
|
|
362
362
|
inputs,
|
|
363
363
|
proof,
|
|
364
364
|
verificationKey,
|
|
365
365
|
}: PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>) {
|
|
366
|
-
const leafIndex =
|
|
366
|
+
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
367
367
|
return new PreviousRollupData(
|
|
368
368
|
inputs,
|
|
369
369
|
proof,
|
|
370
370
|
verificationKey.keyAsFields,
|
|
371
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex),
|
|
371
|
+
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
372
372
|
);
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
|
|
375
|
+
#getRootParityData({ inputs, proof, verificationKey }: PublicInputsAndRecursiveProof<ParityPublicInputs>) {
|
|
376
376
|
return new RootParityInput(
|
|
377
377
|
proof,
|
|
378
378
|
verificationKey.keyAsFields,
|
|
379
|
-
|
|
379
|
+
getVKSiblingPath(getVKIndex(verificationKey)),
|
|
380
380
|
inputs,
|
|
381
381
|
);
|
|
382
382
|
}
|
|
@@ -150,26 +150,23 @@ export class EpochProvingState {
|
|
|
150
150
|
return this.blockRootOrMergeProvingOutputs.getParentLocation(location);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
public
|
|
153
|
+
public getBlockMergeRollupInputs(mergeLocation: TreeNodeLocation) {
|
|
154
154
|
const [left, right] = this.blockRootOrMergeProvingOutputs.getChildren(mergeLocation);
|
|
155
155
|
if (!left || !right) {
|
|
156
156
|
throw new Error('At lease one child is not ready.');
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
return new BlockMergeRollupInputs([
|
|
160
|
-
await this.#getPreviousRollupData(left),
|
|
161
|
-
await this.#getPreviousRollupData(right),
|
|
162
|
-
]);
|
|
159
|
+
return new BlockMergeRollupInputs([this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)]);
|
|
163
160
|
}
|
|
164
161
|
|
|
165
|
-
public
|
|
162
|
+
public getRootRollupInputs(proverId: Fr) {
|
|
166
163
|
const [left, right] = this.#getChildProofsForRoot();
|
|
167
164
|
if (!left || !right) {
|
|
168
165
|
throw new Error('At lease one child is not ready.');
|
|
169
166
|
}
|
|
170
167
|
|
|
171
168
|
return RootRollupInputs.from({
|
|
172
|
-
previousRollupData: [
|
|
169
|
+
previousRollupData: [this.#getPreviousRollupData(left), this.#getPreviousRollupData(right)],
|
|
173
170
|
proverId,
|
|
174
171
|
});
|
|
175
172
|
}
|
|
@@ -241,7 +238,7 @@ export class EpochProvingState {
|
|
|
241
238
|
: this.blockRootOrMergeProvingOutputs.getChildren(rootLocation);
|
|
242
239
|
}
|
|
243
240
|
|
|
244
|
-
|
|
241
|
+
#getPreviousRollupData({
|
|
245
242
|
inputs,
|
|
246
243
|
proof,
|
|
247
244
|
verificationKey,
|
|
@@ -249,12 +246,12 @@ export class EpochProvingState {
|
|
|
249
246
|
BlockRootOrBlockMergePublicInputs,
|
|
250
247
|
typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH
|
|
251
248
|
>) {
|
|
252
|
-
const leafIndex =
|
|
249
|
+
const leafIndex = getVKIndex(verificationKey.keyAsFields);
|
|
253
250
|
return new PreviousRollupBlockData(
|
|
254
251
|
inputs,
|
|
255
252
|
proof,
|
|
256
253
|
verificationKey.keyAsFields,
|
|
257
|
-
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex),
|
|
254
|
+
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
258
255
|
);
|
|
259
256
|
}
|
|
260
257
|
}
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
SingleTxBlockRootRollupInputs,
|
|
37
37
|
TubeInputs,
|
|
38
38
|
} from '@aztec/circuits.js/rollup';
|
|
39
|
-
import { padArrayEnd,
|
|
39
|
+
import { padArrayEnd, times } from '@aztec/foundation/collection';
|
|
40
40
|
import { AbortError } from '@aztec/foundation/error';
|
|
41
41
|
import { createLogger } from '@aztec/foundation/log';
|
|
42
42
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
@@ -247,7 +247,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
247
247
|
const tubeInputs = new TubeInputs(tx.clientIvcProof);
|
|
248
248
|
const tubeProof = promiseWithResolvers<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>>();
|
|
249
249
|
logger.debug(`Starting tube circuit for tx ${txHash}`);
|
|
250
|
-
this.doEnqueueTube(txHash, tubeInputs, proof =>
|
|
250
|
+
this.doEnqueueTube(txHash, tubeInputs, proof => tubeProof.resolve(proof));
|
|
251
251
|
this.provingState?.cachedTubeProofs.set(txHash, tubeProof.promise);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
@@ -458,8 +458,8 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
458
458
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
459
459
|
'Too many L1 to L2 messages',
|
|
460
460
|
);
|
|
461
|
-
const baseParityInputs =
|
|
462
|
-
BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i,
|
|
461
|
+
const baseParityInputs = times(NUM_BASE_PARITY_PER_ROOT_PARITY, i =>
|
|
462
|
+
BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i, getVKTreeRoot()),
|
|
463
463
|
);
|
|
464
464
|
|
|
465
465
|
const l1ToL2MessageSubtreeSiblingPath = assertLength(
|
|
@@ -517,7 +517,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
517
517
|
|
|
518
518
|
// Executes the base rollup circuit and stored the output as intermediate state for the parent merge/root circuit
|
|
519
519
|
// Executes the next level of merge if all inputs are available
|
|
520
|
-
private
|
|
520
|
+
private enqueueBaseRollup(provingState: BlockProvingState, txIndex: number) {
|
|
521
521
|
if (!provingState.verifyState()) {
|
|
522
522
|
logger.debug('Not running base rollup, state invalid');
|
|
523
523
|
return;
|
|
@@ -525,7 +525,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
525
525
|
|
|
526
526
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
527
527
|
const { processedTx } = txProvingState;
|
|
528
|
-
const { rollupType, inputs } =
|
|
528
|
+
const { rollupType, inputs } = txProvingState.getBaseRollupTypeAndInputs();
|
|
529
529
|
|
|
530
530
|
logger.debug(`Enqueuing deferred proving base rollup for ${processedTx.hash.toString()}`);
|
|
531
531
|
|
|
@@ -573,11 +573,11 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
573
573
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
574
574
|
const txHash = txProvingState.processedTx.hash.toString();
|
|
575
575
|
|
|
576
|
-
const handleResult =
|
|
576
|
+
const handleResult = (result: ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>) => {
|
|
577
577
|
logger.debug(`Got tube proof for tx index: ${txIndex}`, { txHash });
|
|
578
578
|
txProvingState.setTubeProof(result);
|
|
579
579
|
this.provingState?.cachedTubeProofs.delete(txHash);
|
|
580
|
-
|
|
580
|
+
this.checkAndEnqueueNextTxCircuit(provingState, txIndex);
|
|
581
581
|
};
|
|
582
582
|
|
|
583
583
|
if (this.provingState?.cachedTubeProofs.has(txHash)) {
|
|
@@ -593,7 +593,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
593
593
|
private doEnqueueTube(
|
|
594
594
|
txHash: string,
|
|
595
595
|
inputs: TubeInputs,
|
|
596
|
-
handler: (result: ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>) =>
|
|
596
|
+
handler: (result: ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>) => void,
|
|
597
597
|
provingState: EpochProvingState | BlockProvingState = this.provingState!,
|
|
598
598
|
) {
|
|
599
599
|
if (!provingState?.verifyState()) {
|
|
@@ -619,13 +619,13 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
619
619
|
|
|
620
620
|
// Executes the merge rollup circuit and stored the output as intermediate state for the parent merge/block root circuit
|
|
621
621
|
// Enqueues the next level of merge if all inputs are available
|
|
622
|
-
private
|
|
622
|
+
private enqueueMergeRollup(provingState: BlockProvingState, location: TreeNodeLocation) {
|
|
623
623
|
if (!provingState.verifyState()) {
|
|
624
624
|
logger.debug('Not running merge rollup. State no longer valid.');
|
|
625
625
|
return;
|
|
626
626
|
}
|
|
627
627
|
|
|
628
|
-
const inputs =
|
|
628
|
+
const inputs = provingState.getMergeRollupInputs(location);
|
|
629
629
|
|
|
630
630
|
this.deferredProving(
|
|
631
631
|
provingState,
|
|
@@ -697,7 +697,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
697
697
|
if (epochProvingState.totalNumBlocks === 1) {
|
|
698
698
|
await this.enqueueEpochPadding(epochProvingState);
|
|
699
699
|
} else {
|
|
700
|
-
|
|
700
|
+
this.checkAndEnqueueNextBlockMergeRollup(epochProvingState, leafLocation);
|
|
701
701
|
}
|
|
702
702
|
},
|
|
703
703
|
);
|
|
@@ -722,30 +722,30 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
722
722
|
},
|
|
723
723
|
signal => this.prover.getBaseParityProof(inputs, signal, provingState.epochNumber),
|
|
724
724
|
),
|
|
725
|
-
|
|
725
|
+
provingOutput => {
|
|
726
726
|
provingState.setBaseParityProof(index, provingOutput);
|
|
727
|
-
|
|
727
|
+
this.checkAndEnqueueRootParityCircuit(provingState);
|
|
728
728
|
},
|
|
729
729
|
);
|
|
730
730
|
}
|
|
731
731
|
|
|
732
|
-
private
|
|
732
|
+
private checkAndEnqueueRootParityCircuit(provingState: BlockProvingState) {
|
|
733
733
|
if (!provingState.isReadyForRootParity()) {
|
|
734
734
|
return;
|
|
735
735
|
}
|
|
736
736
|
|
|
737
|
-
|
|
737
|
+
this.enqueueRootParityCircuit(provingState);
|
|
738
738
|
}
|
|
739
739
|
|
|
740
740
|
// Runs the root parity circuit ans stored the outputs
|
|
741
741
|
// Enqueues the root rollup proof if all inputs are available
|
|
742
|
-
private
|
|
742
|
+
private enqueueRootParityCircuit(provingState: BlockProvingState) {
|
|
743
743
|
if (!provingState.verifyState()) {
|
|
744
744
|
logger.debug('Not running root parity. State no longer valid.');
|
|
745
745
|
return;
|
|
746
746
|
}
|
|
747
747
|
|
|
748
|
-
const inputs =
|
|
748
|
+
const inputs = provingState.getRootParityInputs();
|
|
749
749
|
|
|
750
750
|
this.deferredProving(
|
|
751
751
|
provingState,
|
|
@@ -767,13 +767,13 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
767
767
|
|
|
768
768
|
// Executes the block merge rollup circuit and stored the output as intermediate state for the parent merge/block root circuit
|
|
769
769
|
// Enqueues the next level of merge if all inputs are available
|
|
770
|
-
private
|
|
770
|
+
private enqueueBlockMergeRollup(provingState: EpochProvingState, location: TreeNodeLocation) {
|
|
771
771
|
if (!provingState.verifyState()) {
|
|
772
772
|
logger.debug('Not running block merge rollup. State no longer valid.');
|
|
773
773
|
return;
|
|
774
774
|
}
|
|
775
775
|
|
|
776
|
-
const inputs =
|
|
776
|
+
const inputs = provingState.getBlockMergeRollupInputs(location);
|
|
777
777
|
|
|
778
778
|
this.deferredProving(
|
|
779
779
|
provingState,
|
|
@@ -786,9 +786,9 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
786
786
|
},
|
|
787
787
|
signal => this.prover.getBlockMergeRollupProof(inputs, signal, provingState.epochNumber),
|
|
788
788
|
),
|
|
789
|
-
|
|
789
|
+
result => {
|
|
790
790
|
provingState.setBlockMergeRollupProof(location, result);
|
|
791
|
-
|
|
791
|
+
this.checkAndEnqueueNextBlockMergeRollup(provingState, location);
|
|
792
792
|
},
|
|
793
793
|
);
|
|
794
794
|
}
|
|
@@ -814,16 +814,16 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
814
814
|
},
|
|
815
815
|
signal => this.prover.getEmptyBlockRootRollupProof(inputs, signal, provingState.epochNumber),
|
|
816
816
|
),
|
|
817
|
-
|
|
817
|
+
result => {
|
|
818
818
|
logger.debug('Completed proof for padding block root.');
|
|
819
819
|
provingState.setPaddingBlockRootProof(result);
|
|
820
|
-
|
|
820
|
+
this.checkAndEnqueueRootRollup(provingState);
|
|
821
821
|
},
|
|
822
822
|
);
|
|
823
823
|
}
|
|
824
824
|
|
|
825
825
|
// Executes the root rollup circuit
|
|
826
|
-
private
|
|
826
|
+
private enqueueRootRollup(provingState: EpochProvingState) {
|
|
827
827
|
if (!provingState.verifyState()) {
|
|
828
828
|
logger.debug('Not running root rollup, state no longer valid');
|
|
829
829
|
return;
|
|
@@ -831,7 +831,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
831
831
|
|
|
832
832
|
logger.debug(`Preparing root rollup`);
|
|
833
833
|
|
|
834
|
-
const inputs =
|
|
834
|
+
const inputs = provingState.getRootRollupInputs(this.proverId);
|
|
835
835
|
|
|
836
836
|
this.deferredProving(
|
|
837
837
|
provingState,
|
|
@@ -861,7 +861,7 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
861
861
|
if (parentLocation.level === 0) {
|
|
862
862
|
await this.checkAndEnqueueBlockRootRollup(provingState);
|
|
863
863
|
} else {
|
|
864
|
-
|
|
864
|
+
this.enqueueMergeRollup(provingState, parentLocation);
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
|
|
@@ -890,29 +890,26 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
890
890
|
await this.enqueueBlockRootRollup(provingState);
|
|
891
891
|
}
|
|
892
892
|
|
|
893
|
-
private
|
|
894
|
-
provingState: EpochProvingState,
|
|
895
|
-
currentLocation: TreeNodeLocation,
|
|
896
|
-
) {
|
|
893
|
+
private checkAndEnqueueNextBlockMergeRollup(provingState: EpochProvingState, currentLocation: TreeNodeLocation) {
|
|
897
894
|
if (!provingState.isReadyForBlockMerge(currentLocation)) {
|
|
898
895
|
return;
|
|
899
896
|
}
|
|
900
897
|
|
|
901
898
|
const parentLocation = provingState.getParentLocation(currentLocation);
|
|
902
899
|
if (parentLocation.level === 0) {
|
|
903
|
-
|
|
900
|
+
this.checkAndEnqueueRootRollup(provingState);
|
|
904
901
|
} else {
|
|
905
|
-
|
|
902
|
+
this.enqueueBlockMergeRollup(provingState, parentLocation);
|
|
906
903
|
}
|
|
907
904
|
}
|
|
908
905
|
|
|
909
|
-
private
|
|
906
|
+
private checkAndEnqueueRootRollup(provingState: EpochProvingState) {
|
|
910
907
|
if (!provingState.isReadyForRootRollup()) {
|
|
911
908
|
logger.debug('Not ready for root rollup');
|
|
912
909
|
return;
|
|
913
910
|
}
|
|
914
911
|
|
|
915
|
-
|
|
912
|
+
this.enqueueRootRollup(provingState);
|
|
916
913
|
}
|
|
917
914
|
|
|
918
915
|
/**
|
|
@@ -960,14 +957,14 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
960
957
|
},
|
|
961
958
|
);
|
|
962
959
|
|
|
963
|
-
this.deferredProving(provingState, doAvmProving,
|
|
960
|
+
this.deferredProving(provingState, doAvmProving, proofAndVk => {
|
|
964
961
|
logger.debug(`Proven VM for tx index: ${txIndex}`);
|
|
965
962
|
txProvingState.setAvmProof(proofAndVk);
|
|
966
|
-
|
|
963
|
+
this.checkAndEnqueueNextTxCircuit(provingState, txIndex);
|
|
967
964
|
});
|
|
968
965
|
}
|
|
969
966
|
|
|
970
|
-
private
|
|
967
|
+
private checkAndEnqueueNextTxCircuit(provingState: BlockProvingState, txIndex: number) {
|
|
971
968
|
const txProvingState = provingState.getTxProvingState(txIndex);
|
|
972
969
|
if (!txProvingState.ready()) {
|
|
973
970
|
return;
|
|
@@ -976,6 +973,6 @@ export class ProvingOrchestrator implements EpochProver {
|
|
|
976
973
|
// We must have completed all proving (tube proof and (if required) vm proof are generated), we now move to the base rollup.
|
|
977
974
|
logger.debug(`Public functions completed for tx ${txIndex} enqueueing base rollup`);
|
|
978
975
|
|
|
979
|
-
|
|
976
|
+
this.enqueueBaseRollup(provingState, txIndex);
|
|
980
977
|
}
|
|
981
978
|
}
|