@aztec/prover-client 0.45.0 → 0.46.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/fixtures.d.ts.map +1 -1
- package/dest/mocks/fixtures.js +12 -10
- package/dest/mocks/test_context.d.ts.map +1 -1
- package/dest/mocks/test_context.js +4 -5
- package/dest/orchestrator/block-building-helpers.d.ts.map +1 -1
- package/dest/orchestrator/block-building-helpers.js +16 -25
- package/dest/orchestrator/orchestrator.d.ts +2 -2
- package/dest/orchestrator/orchestrator.d.ts.map +1 -1
- package/dest/orchestrator/orchestrator.js +13 -7
- package/dest/orchestrator/proving-state.d.ts +2 -3
- package/dest/orchestrator/proving-state.d.ts.map +1 -1
- package/dest/orchestrator/proving-state.js +2 -3
- package/dest/tx-prover/tx-prover.d.ts +3 -6
- package/dest/tx-prover/tx-prover.d.ts.map +1 -1
- package/dest/tx-prover/tx-prover.js +5 -9
- package/package.json +10 -10
- package/src/mocks/fixtures.ts +15 -13
- package/src/mocks/test_context.ts +3 -10
- package/src/orchestrator/block-building-helpers.ts +20 -34
- package/src/orchestrator/orchestrator.ts +14 -6
- package/src/orchestrator/proving-state.ts +0 -2
- package/src/tx-prover/tx-prover.ts +4 -10
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type GlobalVariables,
|
|
10
10
|
KernelData,
|
|
11
11
|
type L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH,
|
|
12
|
-
|
|
12
|
+
MAX_NULLIFIERS_PER_TX,
|
|
13
13
|
MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX,
|
|
14
14
|
MembershipWitness,
|
|
15
15
|
MergeRollupInputs,
|
|
@@ -30,7 +30,6 @@ import {
|
|
|
30
30
|
PublicDataTreeLeaf,
|
|
31
31
|
type PublicDataTreeLeafPreimage,
|
|
32
32
|
PublicDataUpdateRequest,
|
|
33
|
-
ROLLUP_VK_TREE_HEIGHT,
|
|
34
33
|
type RecursiveProof,
|
|
35
34
|
type RootParityInput,
|
|
36
35
|
RootRollupInputs,
|
|
@@ -45,16 +44,10 @@ import {
|
|
|
45
44
|
import { assertPermutation, makeTuple } from '@aztec/foundation/array';
|
|
46
45
|
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
47
46
|
import { type Tuple, assertLength, toFriendlyJSON } from '@aztec/foundation/serialize';
|
|
47
|
+
import { getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
48
48
|
import { HintsBuilder, computeFeePayerBalanceLeafSlot } from '@aztec/simulator';
|
|
49
49
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
50
50
|
|
|
51
|
-
// Denotes fields that are not used now, but will be in the future
|
|
52
|
-
const FUTURE_FR = new Fr(0n);
|
|
53
|
-
const FUTURE_NUM = 0;
|
|
54
|
-
|
|
55
|
-
// Denotes fields that should be deleted
|
|
56
|
-
const DELETE_FR = new Fr(0n);
|
|
57
|
-
|
|
58
51
|
/**
|
|
59
52
|
* Type representing the names of the trees for the base rollup.
|
|
60
53
|
*/
|
|
@@ -102,8 +95,8 @@ export async function buildBaseRollupInput(
|
|
|
102
95
|
|
|
103
96
|
// Update the note hash trees with the new items being inserted to get the new roots
|
|
104
97
|
// that will be used by the next iteration of the base rollup circuit, skipping the empty ones
|
|
105
|
-
const
|
|
106
|
-
await db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE,
|
|
98
|
+
const noteHashes = tx.data.end.noteHashes;
|
|
99
|
+
await db.appendLeaves(MerkleTreeId.NOTE_HASH_TREE, noteHashes);
|
|
107
100
|
|
|
108
101
|
// The read witnesses for a given TX should be generated before the writes of the same TX are applied.
|
|
109
102
|
// All reads that refer to writes in the same tx are transient and can be simplified out.
|
|
@@ -112,12 +105,12 @@ export async function buildBaseRollupInput(
|
|
|
112
105
|
// Update the nullifier tree, capturing the low nullifier info for each individual operation
|
|
113
106
|
const {
|
|
114
107
|
lowLeavesWitnessData: nullifierWitnessLeaves,
|
|
115
|
-
newSubtreeSiblingPath:
|
|
116
|
-
sortedNewLeaves:
|
|
108
|
+
newSubtreeSiblingPath: nullifiersSubtreeSiblingPath,
|
|
109
|
+
sortedNewLeaves: sortednullifiers,
|
|
117
110
|
sortedNewLeavesIndexes,
|
|
118
111
|
} = await db.batchInsert(
|
|
119
112
|
MerkleTreeId.NULLIFIER_TREE,
|
|
120
|
-
tx.data.end.
|
|
113
|
+
tx.data.end.nullifiers.map(n => n.toBuffer()),
|
|
121
114
|
NULLIFIER_SUBTREE_HEIGHT,
|
|
122
115
|
);
|
|
123
116
|
if (nullifierWitnessLeaves === undefined) {
|
|
@@ -130,7 +123,7 @@ export async function buildBaseRollupInput(
|
|
|
130
123
|
MembershipWitness.fromBufferArray(l.index, assertLength(l.siblingPath.toBufferArray(), NULLIFIER_TREE_HEIGHT)),
|
|
131
124
|
);
|
|
132
125
|
|
|
133
|
-
const nullifierSubtreeSiblingPathArray =
|
|
126
|
+
const nullifierSubtreeSiblingPathArray = nullifiersSubtreeSiblingPath.toFields();
|
|
134
127
|
|
|
135
128
|
const nullifierSubtreeSiblingPath = makeTuple(NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH, i =>
|
|
136
129
|
i < nullifierSubtreeSiblingPathArray.length ? nullifierSubtreeSiblingPathArray[i] : Fr.ZERO,
|
|
@@ -139,18 +132,18 @@ export async function buildBaseRollupInput(
|
|
|
139
132
|
const publicDataSiblingPath = txPublicDataUpdateRequestInfo.newPublicDataSubtreeSiblingPath;
|
|
140
133
|
|
|
141
134
|
const stateDiffHints = StateDiffHints.from({
|
|
142
|
-
nullifierPredecessorPreimages: makeTuple(
|
|
135
|
+
nullifierPredecessorPreimages: makeTuple(MAX_NULLIFIERS_PER_TX, i =>
|
|
143
136
|
i < nullifierWitnessLeaves.length
|
|
144
137
|
? (nullifierWitnessLeaves[i].leafPreimage as NullifierLeafPreimage)
|
|
145
138
|
: NullifierLeafPreimage.empty(),
|
|
146
139
|
),
|
|
147
|
-
nullifierPredecessorMembershipWitnesses: makeTuple(
|
|
140
|
+
nullifierPredecessorMembershipWitnesses: makeTuple(MAX_NULLIFIERS_PER_TX, i =>
|
|
148
141
|
i < nullifierPredecessorMembershipWitnessesWithoutPadding.length
|
|
149
142
|
? nullifierPredecessorMembershipWitnessesWithoutPadding[i]
|
|
150
143
|
: makeEmptyMembershipWitness(NULLIFIER_TREE_HEIGHT),
|
|
151
144
|
),
|
|
152
|
-
sortedNullifiers: makeTuple(
|
|
153
|
-
sortedNullifierIndexes: makeTuple(
|
|
145
|
+
sortedNullifiers: makeTuple(MAX_NULLIFIERS_PER_TX, i => Fr.fromBuffer(sortednullifiers[i])),
|
|
146
|
+
sortedNullifierIndexes: makeTuple(MAX_NULLIFIERS_PER_TX, i => sortedNewLeavesIndexes[i]),
|
|
154
147
|
noteHashSubtreeSiblingPath,
|
|
155
148
|
nullifierSubtreeSiblingPath,
|
|
156
149
|
publicDataSiblingPath,
|
|
@@ -267,18 +260,13 @@ export function getPreviousRollupDataFromPublicInputs(
|
|
|
267
260
|
rollupProof: RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>,
|
|
268
261
|
vk: VerificationKeyAsFields,
|
|
269
262
|
) {
|
|
263
|
+
const leafIndex = getVKIndex(vk);
|
|
264
|
+
|
|
270
265
|
return new PreviousRollupData(
|
|
271
266
|
rollupOutput,
|
|
272
267
|
rollupProof,
|
|
273
268
|
vk,
|
|
274
|
-
|
|
275
|
-
// MembershipWitness for a VK tree to be implemented in the future
|
|
276
|
-
FUTURE_NUM,
|
|
277
|
-
new MembershipWitness(
|
|
278
|
-
ROLLUP_VK_TREE_HEIGHT,
|
|
279
|
-
BigInt(FUTURE_NUM),
|
|
280
|
-
makeTuple(ROLLUP_VK_TREE_HEIGHT, () => FUTURE_FR),
|
|
281
|
-
),
|
|
269
|
+
new MembershipWitness(VK_TREE_HEIGHT, BigInt(leafIndex), getVKSiblingPath(leafIndex)),
|
|
282
270
|
);
|
|
283
271
|
}
|
|
284
272
|
|
|
@@ -287,10 +275,7 @@ export async function getConstantRollupData(
|
|
|
287
275
|
db: MerkleTreeOperations,
|
|
288
276
|
): Promise<ConstantRollupData> {
|
|
289
277
|
return ConstantRollupData.from({
|
|
290
|
-
|
|
291
|
-
mergeRollupVkHash: DELETE_FR,
|
|
292
|
-
privateKernelVkTreeRoot: FUTURE_FR,
|
|
293
|
-
publicKernelVkTreeRoot: FUTURE_FR,
|
|
278
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
294
279
|
lastArchive: await getTreeSnapshot(MerkleTreeId.ARCHIVE, db),
|
|
295
280
|
globalVariables,
|
|
296
281
|
});
|
|
@@ -303,6 +288,8 @@ export async function getTreeSnapshot(id: MerkleTreeId, db: MerkleTreeOperations
|
|
|
303
288
|
|
|
304
289
|
export function getKernelDataFor(tx: ProcessedTx, vk: VerificationKeyData): KernelData {
|
|
305
290
|
const recursiveProof = makeRecursiveProofFromBinary(tx.proof, NESTED_RECURSIVE_PROOF_LENGTH);
|
|
291
|
+
const leafIndex = getVKIndex(vk);
|
|
292
|
+
|
|
306
293
|
return new KernelData(
|
|
307
294
|
tx.data,
|
|
308
295
|
recursiveProof,
|
|
@@ -310,9 +297,8 @@ export function getKernelDataFor(tx: ProcessedTx, vk: VerificationKeyData): Kern
|
|
|
310
297
|
// VK for the kernel circuit
|
|
311
298
|
vk,
|
|
312
299
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
assertLength(Array(VK_TREE_HEIGHT).fill(FUTURE_FR), VK_TREE_HEIGHT),
|
|
300
|
+
leafIndex,
|
|
301
|
+
getVKSiblingPath(leafIndex),
|
|
316
302
|
);
|
|
317
303
|
}
|
|
318
304
|
|
|
@@ -45,7 +45,6 @@ import {
|
|
|
45
45
|
RootParityInputs,
|
|
46
46
|
type VerificationKeyAsFields,
|
|
47
47
|
VerificationKeyData,
|
|
48
|
-
type VerificationKeys,
|
|
49
48
|
makeEmptyProof,
|
|
50
49
|
} from '@aztec/circuits.js';
|
|
51
50
|
import { makeTuple } from '@aztec/foundation/array';
|
|
@@ -55,6 +54,7 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
55
54
|
import { promiseWithResolvers } from '@aztec/foundation/promise';
|
|
56
55
|
import { BufferReader, type Tuple } from '@aztec/foundation/serialize';
|
|
57
56
|
import { pushTestData } from '@aztec/foundation/testing';
|
|
57
|
+
import { ProtocolCircuitVks, getVKIndex, getVKSiblingPath, getVKTreeRoot } from '@aztec/noir-protocol-circuits-types';
|
|
58
58
|
import { Attributes, type TelemetryClient, type Tracer, trackSpan, wrapCallbackInSpan } from '@aztec/telemetry-client';
|
|
59
59
|
import { type MerkleTreeOperations } from '@aztec/world-state';
|
|
60
60
|
|
|
@@ -128,7 +128,6 @@ export class ProvingOrchestrator {
|
|
|
128
128
|
numTxs: number,
|
|
129
129
|
globalVariables: GlobalVariables,
|
|
130
130
|
l1ToL2Messages: Fr[],
|
|
131
|
-
verificationKeys: VerificationKeys,
|
|
132
131
|
): Promise<ProvingTicket> {
|
|
133
132
|
// Create initial header if not done so yet
|
|
134
133
|
if (!this.initialHeader) {
|
|
@@ -150,7 +149,7 @@ export class ProvingOrchestrator {
|
|
|
150
149
|
throw new Error('Too many L1 to L2 messages');
|
|
151
150
|
}
|
|
152
151
|
baseParityInputs = Array.from({ length: NUM_BASE_PARITY_PER_ROOT_PARITY }, (_, i) =>
|
|
153
|
-
BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i),
|
|
152
|
+
BaseParityInputs.fromSlice(l1ToL2MessagesPadded, i, getVKTreeRoot()),
|
|
154
153
|
);
|
|
155
154
|
|
|
156
155
|
const messageTreeSnapshot = await getTreeSnapshot(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, this.db);
|
|
@@ -188,7 +187,6 @@ export class ProvingOrchestrator {
|
|
|
188
187
|
baseParityInputs.length,
|
|
189
188
|
messageTreeSnapshot,
|
|
190
189
|
newL1ToL2MessageTreeRootSiblingPath,
|
|
191
|
-
verificationKeys,
|
|
192
190
|
);
|
|
193
191
|
|
|
194
192
|
for (let i = 0; i < baseParityInputs.length; i++) {
|
|
@@ -271,6 +269,7 @@ export class ProvingOrchestrator {
|
|
|
271
269
|
this.initialHeader ?? (await this.db.buildInitialHeader()),
|
|
272
270
|
this.provingState.globalVariables.chainId,
|
|
273
271
|
this.provingState.globalVariables.version,
|
|
272
|
+
getVKTreeRoot(),
|
|
274
273
|
);
|
|
275
274
|
const txInputs: Array<{ inputs: BaseRollupInputs; snapshot: TreeSnapshots }> = [];
|
|
276
275
|
for (let i = 0; i < paddingTxCount; i++) {
|
|
@@ -318,6 +317,7 @@ export class ProvingOrchestrator {
|
|
|
318
317
|
chainId: unprovenPaddingTx.data.constants.txContext.chainId,
|
|
319
318
|
version: unprovenPaddingTx.data.constants.txContext.version,
|
|
320
319
|
header: unprovenPaddingTx.data.constants.historicalHeader,
|
|
320
|
+
vkTreeRoot: getVKTreeRoot(),
|
|
321
321
|
},
|
|
322
322
|
signal,
|
|
323
323
|
),
|
|
@@ -346,6 +346,9 @@ export class ProvingOrchestrator {
|
|
|
346
346
|
for (let i = 0; i < txInputs.length; i++) {
|
|
347
347
|
txInputs[i].inputs.kernelData.vk = paddingTx.verificationKey;
|
|
348
348
|
txInputs[i].inputs.kernelData.proof = paddingTx.recursiveProof;
|
|
349
|
+
|
|
350
|
+
txInputs[i].inputs.kernelData.vkIndex = getVKIndex(paddingTx.verificationKey);
|
|
351
|
+
txInputs[i].inputs.kernelData.vkPath = getVKSiblingPath(txInputs[i].inputs.kernelData.vkIndex);
|
|
349
352
|
this.enqueueFirstProof(txInputs[i].inputs, txInputs[i].snapshot, paddingTx, provingState);
|
|
350
353
|
}
|
|
351
354
|
}
|
|
@@ -448,7 +451,7 @@ export class ProvingOrchestrator {
|
|
|
448
451
|
private async prepareTransaction(tx: ProcessedTx, provingState: ProvingState) {
|
|
449
452
|
// Pass the private kernel tail vk here as the previous one.
|
|
450
453
|
// If there are public functions then this key will be overwritten once the public tail has been proven
|
|
451
|
-
const previousKernelVerificationKey =
|
|
454
|
+
const previousKernelVerificationKey = ProtocolCircuitVks.PrivateKernelTailArtifact;
|
|
452
455
|
|
|
453
456
|
const txInputs = await this.prepareBaseRollupInputs(provingState, tx, previousKernelVerificationKey);
|
|
454
457
|
if (!txInputs) {
|
|
@@ -468,7 +471,7 @@ export class ProvingOrchestrator {
|
|
|
468
471
|
tx,
|
|
469
472
|
inputs,
|
|
470
473
|
treeSnapshots,
|
|
471
|
-
|
|
474
|
+
ProtocolCircuitVks.PrivateKernelTailToPublicArtifact,
|
|
472
475
|
);
|
|
473
476
|
const txIndex = provingState.addNewTx(txProvingState);
|
|
474
477
|
const numPublicKernels = txProvingState.getNumPublicKernels();
|
|
@@ -982,6 +985,11 @@ export class ProvingOrchestrator {
|
|
|
982
985
|
// Take the final public tail proof and verification key and pass them to the base rollup
|
|
983
986
|
txProvingState.baseRollupInputs.kernelData.proof = result.proof;
|
|
984
987
|
txProvingState.baseRollupInputs.kernelData.vk = result.verificationKey;
|
|
988
|
+
txProvingState.baseRollupInputs.kernelData.vkIndex = getVKIndex(result.verificationKey);
|
|
989
|
+
txProvingState.baseRollupInputs.kernelData.vkPath = getVKSiblingPath(
|
|
990
|
+
txProvingState.baseRollupInputs.kernelData.vkIndex,
|
|
991
|
+
);
|
|
992
|
+
|
|
985
993
|
this.enqueueBaseRollup(provingState, BigInt(txIndex), txProvingState);
|
|
986
994
|
return;
|
|
987
995
|
}
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type RootParityInput,
|
|
14
14
|
type RootRollupPublicInputs,
|
|
15
15
|
type VerificationKeyAsFields,
|
|
16
|
-
type VerificationKeys,
|
|
17
16
|
} from '@aztec/circuits.js';
|
|
18
17
|
import { type Tuple } from '@aztec/foundation/serialize';
|
|
19
18
|
|
|
@@ -61,7 +60,6 @@ export class ProvingState {
|
|
|
61
60
|
numRootParityInputs: number,
|
|
62
61
|
public readonly messageTreeSnapshot: AppendOnlyTreeSnapshot,
|
|
63
62
|
public readonly messageTreeRootSiblingPath: Tuple<Fr, typeof L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH>,
|
|
64
|
-
public readonly privateKernelVerificationKeys: VerificationKeys,
|
|
65
63
|
) {
|
|
66
64
|
this.rootParityInputs = Array.from({ length: numRootParityInputs }).map(_ => undefined);
|
|
67
65
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
type ProvingTicket,
|
|
8
8
|
type ServerCircuitProver,
|
|
9
9
|
} from '@aztec/circuit-types/interfaces';
|
|
10
|
-
import { type Fr, type GlobalVariables, type Header
|
|
10
|
+
import { type Fr, type GlobalVariables, type Header } from '@aztec/circuits.js';
|
|
11
11
|
import { NativeACVMSimulator } from '@aztec/simulator';
|
|
12
12
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
13
13
|
import { type WorldStateSynchronizer } from '@aztec/world-state';
|
|
@@ -28,7 +28,6 @@ export class TxProver implements ProverClient {
|
|
|
28
28
|
private constructor(
|
|
29
29
|
private config: ProverClientConfig,
|
|
30
30
|
private worldStateSynchronizer: WorldStateSynchronizer,
|
|
31
|
-
private vks: VerificationKeys,
|
|
32
31
|
private telemetry: TelemetryClient,
|
|
33
32
|
private agent?: ProverAgent,
|
|
34
33
|
initialHeader?: Header,
|
|
@@ -42,13 +41,9 @@ export class TxProver implements ProverClient {
|
|
|
42
41
|
);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
async updateProverConfig(config: Partial<ProverClientConfig
|
|
44
|
+
async updateProverConfig(config: Partial<ProverClientConfig>): Promise<void> {
|
|
46
45
|
const newConfig = { ...this.config, ...config };
|
|
47
46
|
|
|
48
|
-
if (config.vks) {
|
|
49
|
-
this.vks = config.vks;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
47
|
if (newConfig.realProofs !== this.config.realProofs && this.agent) {
|
|
53
48
|
const circuitProver = await TxProver.buildCircuitProver(newConfig, this.telemetry);
|
|
54
49
|
this.agent.setCircuitProver(circuitProver);
|
|
@@ -100,7 +95,6 @@ export class TxProver implements ProverClient {
|
|
|
100
95
|
*/
|
|
101
96
|
public static async new(
|
|
102
97
|
config: ProverClientConfig,
|
|
103
|
-
vks: VerificationKeys,
|
|
104
98
|
worldStateSynchronizer: WorldStateSynchronizer,
|
|
105
99
|
telemetry: TelemetryClient,
|
|
106
100
|
initialHeader?: Header,
|
|
@@ -113,7 +107,7 @@ export class TxProver implements ProverClient {
|
|
|
113
107
|
)
|
|
114
108
|
: undefined;
|
|
115
109
|
|
|
116
|
-
const prover = new TxProver(config, worldStateSynchronizer,
|
|
110
|
+
const prover = new TxProver(config, worldStateSynchronizer, telemetry, agent, initialHeader);
|
|
117
111
|
await prover.start();
|
|
118
112
|
return prover;
|
|
119
113
|
}
|
|
@@ -146,7 +140,7 @@ export class TxProver implements ProverClient {
|
|
|
146
140
|
): Promise<ProvingTicket> {
|
|
147
141
|
const previousBlockNumber = globalVariables.blockNumber.toNumber() - 1;
|
|
148
142
|
await this.worldStateSynchronizer.syncImmediate(previousBlockNumber);
|
|
149
|
-
return this.orchestrator.startNewBlock(numTxs, globalVariables, newL1ToL2Messages
|
|
143
|
+
return this.orchestrator.startNewBlock(numTxs, globalVariables, newL1ToL2Messages);
|
|
150
144
|
}
|
|
151
145
|
|
|
152
146
|
/**
|