@aztec/bb-prover 0.0.1-commit.9b94fc1 → 0.0.1-commit.9ee6fcc6
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/avm_proving_tests/avm_proving_tester.d.ts +5 -4
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +26 -10
- package/dest/bb/execute.d.ts +7 -6
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +52 -76
- package/dest/config.d.ts +12 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/instrumentation.d.ts +1 -1
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +21 -43
- package/dest/prover/client/bb_private_kernel_prover.d.ts +9 -3
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/client/bb_private_kernel_prover.js +16 -4
- package/dest/prover/client/bundle.d.ts +3 -3
- package/dest/prover/client/bundle.d.ts.map +1 -1
- package/dest/prover/client/bundle.js +2 -3
- package/dest/prover/client/lazy.d.ts +3 -3
- package/dest/prover/client/lazy.d.ts.map +1 -1
- package/dest/prover/client/lazy.js +2 -3
- package/dest/prover/proof_utils.js +1 -1
- package/dest/prover/server/bb_prover.d.ts +6 -9
- package/dest/prover/server/bb_prover.d.ts.map +1 -1
- package/dest/prover/server/bb_prover.js +416 -43
- package/dest/test/delay_values.d.ts +1 -1
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +28 -26
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/test_circuit_prover.d.ts +4 -4
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +462 -59
- package/dest/verification_key/verification_key_data.d.ts +1 -8
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +1 -20
- package/dest/verifier/batch_chonk_verifier.d.ts +45 -0
- package/dest/verifier/batch_chonk_verifier.d.ts.map +1 -0
- package/dest/verifier/batch_chonk_verifier.js +232 -0
- package/dest/verifier/bb_verifier.d.ts +1 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +1 -4
- package/dest/verifier/index.d.ts +2 -1
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_chonk_verifier.d.ts +2 -3
- package/dest/verifier/queued_chonk_verifier.d.ts.map +1 -1
- package/dest/verifier/queued_chonk_verifier.js +15 -45
- package/package.json +20 -19
- package/src/avm_proving_tests/avm_proving_tester.ts +31 -19
- package/src/bb/execute.ts +41 -60
- package/src/config.ts +11 -0
- package/src/instrumentation.ts +20 -43
- package/src/prover/client/bb_private_kernel_prover.ts +20 -6
- package/src/prover/client/bundle.ts +3 -4
- package/src/prover/client/lazy.ts +3 -4
- package/src/prover/proof_utils.ts +1 -1
- package/src/prover/server/bb_prover.ts +23 -38
- package/src/test/delay_values.ts +30 -26
- package/src/test/index.ts +1 -0
- package/src/test/test_circuit_prover.ts +10 -13
- package/src/verification_key/verification_key_data.ts +1 -26
- package/src/verifier/batch_chonk_verifier.ts +276 -0
- package/src/verifier/bb_verifier.ts +1 -5
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_chonk_verifier.ts +15 -47
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
3
|
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
5
|
-
import { strict as assert } from 'assert';
|
|
6
4
|
import { promises as fs } from 'fs';
|
|
7
5
|
import * as path from 'path';
|
|
8
6
|
import { VK_FILENAME } from '../bb/execute.js';
|
|
@@ -19,20 +17,3 @@ import { VK_FILENAME } from '../bb/execute.js';
|
|
|
19
17
|
const vkAsFields = await VerificationKeyAsFields.fromKey(fields);
|
|
20
18
|
return new VerificationKeyData(vkAsFields, rawBinary);
|
|
21
19
|
}
|
|
22
|
-
/**
|
|
23
|
-
* Reads the verification key data stored in a binary file at the specified directory location and parses into a VerificationKeyData.
|
|
24
|
-
* We do not assume any JSON file available but only the binary version, contrary to the above extractVkData() method.
|
|
25
|
-
* @param vkDirectoryPath - The directory containing the verification key binary data file.
|
|
26
|
-
* @returns The verification key data
|
|
27
|
-
*/ export async function extractAvmVkData(vkDirectoryPath) {
|
|
28
|
-
const rawBinary = await fs.readFile(path.join(vkDirectoryPath, VK_FILENAME));
|
|
29
|
-
const numFields = rawBinary.length / Fr.SIZE_IN_BYTES;
|
|
30
|
-
assert(numFields <= AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED, 'Invalid AVM verification key length');
|
|
31
|
-
const reader = BufferReader.asReader(rawBinary);
|
|
32
|
-
const fieldsArray = reader.readArray(numFields, Fr);
|
|
33
|
-
const fieldsArrayPadded = fieldsArray.concat(Array(AVM_V2_VERIFICATION_KEY_LENGTH_IN_FIELDS_PADDED - fieldsArray.length).fill(new Fr(0)));
|
|
34
|
-
const vkAsFields = await VerificationKeyAsFields.fromKey(fieldsArrayPadded);
|
|
35
|
-
// TODO(#16644): We should have a different type for AVM verification keys since we don't have circuit size or num public inputs in AVM VKs.
|
|
36
|
-
const vk = new VerificationKeyData(vkAsFields, rawBinary);
|
|
37
|
-
return vk;
|
|
38
|
-
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
|
+
import type { BBConfig } from '../config.js';
|
|
4
|
+
/**
|
|
5
|
+
* Batch verifier for Chonk IVC proofs. Uses the bb batch verifier service
|
|
6
|
+
* which batches IPA verification into a single SRS MSM for better throughput.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* - Spawns a persistent `bb msgpack run` process via Barretenberg (native backend)
|
|
10
|
+
* - Sends proofs via the msgpack RPC protocol (ChonkBatchVerifierQueue)
|
|
11
|
+
* - Receives results via a named FIFO pipe (async, out-of-order)
|
|
12
|
+
* - Bisects batch failures to isolate individual bad proofs
|
|
13
|
+
*/
|
|
14
|
+
export declare class BatchChonkVerifier implements ClientProtocolCircuitVerifier {
|
|
15
|
+
private config;
|
|
16
|
+
private vkBuffers;
|
|
17
|
+
private batchSize;
|
|
18
|
+
private label;
|
|
19
|
+
private bb;
|
|
20
|
+
private fifoPath;
|
|
21
|
+
private nextRequestId;
|
|
22
|
+
private pendingRequests;
|
|
23
|
+
private sendQueue;
|
|
24
|
+
private fifoReader;
|
|
25
|
+
private logger;
|
|
26
|
+
/** Maps artifact name to VK index in the batch verifier. */
|
|
27
|
+
private vkIndexMap;
|
|
28
|
+
/** Bound cleanup handler for process exit signals. */
|
|
29
|
+
private exitCleanup;
|
|
30
|
+
private constructor();
|
|
31
|
+
/** Create and start a BatchChonkVerifier using the protocol circuit VKs. */
|
|
32
|
+
static new(config: BBConfig, batchSize: number, label: string): Promise<BatchChonkVerifier>;
|
|
33
|
+
/** Create and start a BatchChonkVerifier with custom VKs (for testing). */
|
|
34
|
+
static newForTesting(config: Pick<BBConfig, 'bbChonkVerifyConcurrency'> & Partial<Pick<BBConfig, 'bbBinaryPath'>>, vks: Uint8Array[], batchSize: number): Promise<BatchChonkVerifier>;
|
|
35
|
+
private start;
|
|
36
|
+
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
37
|
+
/** Enqueue raw proof fields for verification. Used directly by tests with custom VKs. */
|
|
38
|
+
enqueueProof(vkIndex: number, proofFields: Uint8Array[]): Promise<IVCProofVerificationResult>;
|
|
39
|
+
stop(): Promise<void>;
|
|
40
|
+
private startFifoReader;
|
|
41
|
+
private handleResult;
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CA8BjC;IAED,OAAO,CAAC,eAAe;IA2BvB,OAAO,CAAC,YAAY;IA2BpB,OAAO,CAAC,mBAAmB;IAc3B,OAAO,CAAC,qBAAqB;CAQ9B"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { BackendType, Barretenberg } from '@aztec/bb.js';
|
|
2
|
+
import { FifoFrameReader } from '@aztec/foundation/fifo';
|
|
3
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
4
|
+
import { SerialQueue } from '@aztec/foundation/queue';
|
|
5
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
6
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
7
|
+
import { Unpackr } from 'msgpackr';
|
|
8
|
+
import { execFile } from 'node:child_process';
|
|
9
|
+
import { unlinkSync } from 'node:fs';
|
|
10
|
+
import { unlink } from 'node:fs/promises';
|
|
11
|
+
import * as os from 'node:os';
|
|
12
|
+
import * as path from 'node:path';
|
|
13
|
+
import { promisify } from 'node:util';
|
|
14
|
+
const execFileAsync = promisify(execFile);
|
|
15
|
+
/** Maps client protocol artifacts used for chonk verification to VK indices. */ const CHONK_VK_ARTIFACTS = [
|
|
16
|
+
'HidingKernelToRollup',
|
|
17
|
+
'HidingKernelToPublic'
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* Batch verifier for Chonk IVC proofs. Uses the bb batch verifier service
|
|
21
|
+
* which batches IPA verification into a single SRS MSM for better throughput.
|
|
22
|
+
*
|
|
23
|
+
* Architecture:
|
|
24
|
+
* - Spawns a persistent `bb msgpack run` process via Barretenberg (native backend)
|
|
25
|
+
* - Sends proofs via the msgpack RPC protocol (ChonkBatchVerifierQueue)
|
|
26
|
+
* - Receives results via a named FIFO pipe (async, out-of-order)
|
|
27
|
+
* - Bisects batch failures to isolate individual bad proofs
|
|
28
|
+
*/ export class BatchChonkVerifier {
|
|
29
|
+
config;
|
|
30
|
+
vkBuffers;
|
|
31
|
+
batchSize;
|
|
32
|
+
label;
|
|
33
|
+
bb;
|
|
34
|
+
fifoPath;
|
|
35
|
+
nextRequestId;
|
|
36
|
+
pendingRequests;
|
|
37
|
+
sendQueue;
|
|
38
|
+
fifoReader;
|
|
39
|
+
logger;
|
|
40
|
+
/** Maps artifact name to VK index in the batch verifier. */ vkIndexMap;
|
|
41
|
+
/** Bound cleanup handler for process exit signals. */ exitCleanup;
|
|
42
|
+
constructor(config, vkBuffers, batchSize, label){
|
|
43
|
+
this.config = config;
|
|
44
|
+
this.vkBuffers = vkBuffers;
|
|
45
|
+
this.batchSize = batchSize;
|
|
46
|
+
this.label = label;
|
|
47
|
+
this.nextRequestId = 0;
|
|
48
|
+
this.pendingRequests = new Map();
|
|
49
|
+
this.logger = createLogger('bb-prover:batch_chonk_verifier');
|
|
50
|
+
this.vkIndexMap = new Map();
|
|
51
|
+
this.exitCleanup = null;
|
|
52
|
+
this.fifoPath = path.join(os.tmpdir(), `bb-batch-${label}-${process.pid}-${Date.now()}.fifo`);
|
|
53
|
+
this.fifoReader = new FifoFrameReader();
|
|
54
|
+
this.sendQueue = new SerialQueue();
|
|
55
|
+
this.sendQueue.start(1);
|
|
56
|
+
}
|
|
57
|
+
/** Create and start a BatchChonkVerifier using the protocol circuit VKs. */ static async new(config, batchSize, label) {
|
|
58
|
+
const vkBuffers = [];
|
|
59
|
+
const vkIndexMap = new Map();
|
|
60
|
+
for (const artifact of CHONK_VK_ARTIFACTS){
|
|
61
|
+
const vk = ProtocolCircuitVks[artifact];
|
|
62
|
+
if (!vk) {
|
|
63
|
+
throw new Error(`Missing VK for ${artifact}`);
|
|
64
|
+
}
|
|
65
|
+
vkIndexMap.set(artifact, vkBuffers.length);
|
|
66
|
+
vkBuffers.push(vk.keyAsBytes);
|
|
67
|
+
}
|
|
68
|
+
const verifier = new BatchChonkVerifier(config, vkBuffers, batchSize, label);
|
|
69
|
+
verifier.vkIndexMap = vkIndexMap;
|
|
70
|
+
await verifier.start();
|
|
71
|
+
return verifier;
|
|
72
|
+
}
|
|
73
|
+
/** Create and start a BatchChonkVerifier with custom VKs (for testing). */ static async newForTesting(config, vks, batchSize) {
|
|
74
|
+
const verifier = new BatchChonkVerifier(config, vks, batchSize, 'test');
|
|
75
|
+
for(let i = 0; i < vks.length; i++){
|
|
76
|
+
verifier.vkIndexMap.set(String(i), i);
|
|
77
|
+
}
|
|
78
|
+
await verifier.start();
|
|
79
|
+
return verifier;
|
|
80
|
+
}
|
|
81
|
+
async start() {
|
|
82
|
+
this.logger.info('Starting BatchChonkVerifier');
|
|
83
|
+
this.bb = await Barretenberg.new({
|
|
84
|
+
bbPath: this.config.bbBinaryPath,
|
|
85
|
+
backend: BackendType.NativeUnixSocket
|
|
86
|
+
});
|
|
87
|
+
await this.bb.initSRSChonk();
|
|
88
|
+
await execFileAsync('mkfifo', [
|
|
89
|
+
this.fifoPath
|
|
90
|
+
]);
|
|
91
|
+
this.registerExitCleanup();
|
|
92
|
+
await this.bb.chonkBatchVerifierStart({
|
|
93
|
+
vks: this.vkBuffers,
|
|
94
|
+
numCores: this.config.bbChonkVerifyConcurrency || 0,
|
|
95
|
+
batchSize: this.batchSize,
|
|
96
|
+
fifoPath: this.fifoPath
|
|
97
|
+
});
|
|
98
|
+
this.startFifoReader();
|
|
99
|
+
this.logger.info('BatchChonkVerifier started', {
|
|
100
|
+
fifoPath: this.fifoPath
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
verifyProof(tx) {
|
|
104
|
+
const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
105
|
+
const vkIndex = this.vkIndexMap.get(circuit);
|
|
106
|
+
if (vkIndex === undefined) {
|
|
107
|
+
throw new Error(`No VK index for circuit ${circuit}`);
|
|
108
|
+
}
|
|
109
|
+
const proofWithPubInputs = tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields());
|
|
110
|
+
const proofFields = proofWithPubInputs.fieldsWithPublicInputs.map((f)=>f.toBuffer());
|
|
111
|
+
return this.enqueueProof(vkIndex, proofFields);
|
|
112
|
+
}
|
|
113
|
+
/** Enqueue raw proof fields for verification. Used directly by tests with custom VKs. */ enqueueProof(vkIndex, proofFields) {
|
|
114
|
+
const totalTimer = new Timer();
|
|
115
|
+
const requestId = this.nextRequestId++;
|
|
116
|
+
const resultPromise = new Promise((resolve, reject)=>{
|
|
117
|
+
this.pendingRequests.set(requestId, {
|
|
118
|
+
resolve,
|
|
119
|
+
reject,
|
|
120
|
+
totalTimer
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
void this.sendQueue.put(async ()=>{
|
|
124
|
+
await this.bb.chonkBatchVerifierQueue({
|
|
125
|
+
requestId,
|
|
126
|
+
vkIndex,
|
|
127
|
+
proofFields
|
|
128
|
+
});
|
|
129
|
+
}).catch((err)=>{
|
|
130
|
+
const pending = this.pendingRequests.get(requestId);
|
|
131
|
+
if (pending) {
|
|
132
|
+
this.pendingRequests.delete(requestId);
|
|
133
|
+
pending.reject(err instanceof Error ? err : new Error(String(err)));
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return resultPromise;
|
|
137
|
+
}
|
|
138
|
+
async stop() {
|
|
139
|
+
this.logger.info('Stopping BatchChonkVerifier');
|
|
140
|
+
// Stop accepting new proofs
|
|
141
|
+
await this.sendQueue.end();
|
|
142
|
+
// Stop the bb service (flushes remaining proofs)
|
|
143
|
+
try {
|
|
144
|
+
await this.bb.chonkBatchVerifierStop({});
|
|
145
|
+
} catch (err) {
|
|
146
|
+
this.logger.warn(`Error stopping batch verifier service: ${err}`);
|
|
147
|
+
}
|
|
148
|
+
// Stop FIFO reader
|
|
149
|
+
this.fifoReader.stop();
|
|
150
|
+
// Clean up FIFO file and deregister exit handler
|
|
151
|
+
await unlink(this.fifoPath).catch(()=>{});
|
|
152
|
+
this.deregisterExitCleanup();
|
|
153
|
+
// Reject any remaining pending requests
|
|
154
|
+
for (const [id, pending] of this.pendingRequests){
|
|
155
|
+
pending.reject(new Error('BatchChonkVerifier stopped'));
|
|
156
|
+
this.pendingRequests.delete(id);
|
|
157
|
+
}
|
|
158
|
+
// Destroy bb process
|
|
159
|
+
await this.bb.destroy();
|
|
160
|
+
this.logger.info('BatchChonkVerifier stopped');
|
|
161
|
+
}
|
|
162
|
+
startFifoReader() {
|
|
163
|
+
const unpackr = new Unpackr({
|
|
164
|
+
useRecords: false
|
|
165
|
+
});
|
|
166
|
+
this.fifoReader.on('frame', (payload)=>{
|
|
167
|
+
try {
|
|
168
|
+
const result = unpackr.unpack(payload);
|
|
169
|
+
this.handleResult(result);
|
|
170
|
+
} catch (err) {
|
|
171
|
+
this.logger.error(`FIFO: failed to decode msgpack result: ${err}`);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
this.fifoReader.on('error', (err)=>{
|
|
175
|
+
this.logger.error(`FIFO reader error: ${err}`);
|
|
176
|
+
});
|
|
177
|
+
this.fifoReader.on('end', ()=>{
|
|
178
|
+
this.logger.debug('FIFO reader: stream ended');
|
|
179
|
+
for (const [id, pending] of this.pendingRequests){
|
|
180
|
+
pending.reject(new Error('FIFO stream ended unexpectedly'));
|
|
181
|
+
this.pendingRequests.delete(id);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
this.fifoReader.start(this.fifoPath);
|
|
185
|
+
}
|
|
186
|
+
handleResult(result) {
|
|
187
|
+
const pending = this.pendingRequests.get(result.request_id);
|
|
188
|
+
if (!pending) {
|
|
189
|
+
this.logger.warn(`Received result for unknown request_id=${result.request_id}`);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
this.pendingRequests.delete(result.request_id);
|
|
193
|
+
const valid = result.status === 0; // VerifyStatus::OK
|
|
194
|
+
const durationMs = result.time_in_verify_ms;
|
|
195
|
+
const totalDurationMs = pending.totalTimer.ms();
|
|
196
|
+
const ivcResult = {
|
|
197
|
+
valid,
|
|
198
|
+
durationMs,
|
|
199
|
+
totalDurationMs
|
|
200
|
+
};
|
|
201
|
+
if (!valid) {
|
|
202
|
+
this.logger.warn(`Proof verification failed for request_id=${result.request_id}: ${result.error_message}`);
|
|
203
|
+
} else {
|
|
204
|
+
this.logger.debug(`Proof verified`, {
|
|
205
|
+
requestId: result.request_id,
|
|
206
|
+
durationMs: Math.ceil(durationMs),
|
|
207
|
+
totalDurationMs: Math.ceil(totalDurationMs)
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
pending.resolve(ivcResult);
|
|
211
|
+
}
|
|
212
|
+
registerExitCleanup() {
|
|
213
|
+
// Signal handlers must be synchronous — unlinkSync is intentional here
|
|
214
|
+
this.exitCleanup = ()=>{
|
|
215
|
+
try {
|
|
216
|
+
unlinkSync(this.fifoPath);
|
|
217
|
+
} catch {
|
|
218
|
+
/* ignore */ }
|
|
219
|
+
};
|
|
220
|
+
process.on('exit', this.exitCleanup);
|
|
221
|
+
process.on('SIGINT', this.exitCleanup);
|
|
222
|
+
process.on('SIGTERM', this.exitCleanup);
|
|
223
|
+
}
|
|
224
|
+
deregisterExitCleanup() {
|
|
225
|
+
if (this.exitCleanup) {
|
|
226
|
+
process.removeListener('exit', this.exitCleanup);
|
|
227
|
+
process.removeListener('SIGINT', this.exitCleanup);
|
|
228
|
+
process.removeListener('SIGTERM', this.exitCleanup);
|
|
229
|
+
this.exitCleanup = null;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -15,4 +15,4 @@ export declare class BBCircuitVerifier implements ClientProtocolCircuitVerifier
|
|
|
15
15
|
verifyProofForCircuit(circuit: ServerProtocolArtifact, proof: Proof): Promise<void>;
|
|
16
16
|
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
17
17
|
}
|
|
18
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
18
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmJfdmVyaWZpZXIuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9iY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DRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAFhB,OAAO,eAGH;IAEG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC,8BAMpF;IAEM,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAM5E;IAEY,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,iBAmC/E;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"bb_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/bb_verifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAGlE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAE5B,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAElD,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAa7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI7C,qBAAa,iBAAkB,YAAW,6BAA6B;IAEnE,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IAFhB,OAAO,eAGH;IAEG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAE3B;IAED,OAAoB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAqC,8BAMpF;IAEM,sBAAsB,CAAC,OAAO,EAAE,gBAAgB,GAAG,mBAAmB,CAM5E;IAEY,qBAAqB,CAAC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,KAAK,iBAmC/E;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CA6CpE;CACF"}
|
|
@@ -67,16 +67,13 @@ export class BBCircuitVerifier {
|
|
|
67
67
|
const circuit = tx.data.forPublic ? 'HidingKernelToPublic' : 'HidingKernelToRollup';
|
|
68
68
|
// Block below is almost copy-pasted from verifyProofForCircuit
|
|
69
69
|
const operation = async (bbWorkingDirectory)=>{
|
|
70
|
-
const logFunction = (message)=>{
|
|
71
|
-
this.logger.debug(`${proofType} BB out - ${message}`);
|
|
72
|
-
};
|
|
73
70
|
const proofPath = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
74
71
|
await writeChonkProofToPath(tx.chonkProof.attachPublicInputs(tx.data.publicInputs().toFields()), proofPath);
|
|
75
72
|
const verificationKeyPath = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
76
73
|
const verificationKey = this.getVerificationKeyData(circuit);
|
|
77
74
|
await fs.writeFile(verificationKeyPath, verificationKey.keyAsBytes);
|
|
78
75
|
const timer = new Timer();
|
|
79
|
-
const result = await verifyChonkProof(this.config.bbBinaryPath, proofPath, verificationKeyPath,
|
|
76
|
+
const result = await verifyChonkProof(this.config.bbBinaryPath, proofPath, verificationKeyPath, this.logger, this.config.bbIVCConcurrency);
|
|
80
77
|
verificationDuration = timer.ms();
|
|
81
78
|
if (result.status === BB_RESULT.FAILURE) {
|
|
82
79
|
const errorMessage = `Failed to verify ${proofType} proof for ${circuit}!`;
|
package/dest/verifier/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './batch_chonk_verifier.js';
|
|
1
2
|
export * from './bb_verifier.js';
|
|
2
3
|
export * from './queued_chonk_verifier.js';
|
|
3
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy92ZXJpZmllci9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDJCQUEyQixDQUFDO0FBQzFDLGNBQWMsa0JBQWtCLENBQUM7QUFDakMsY0FBYyw0QkFBNEIsQ0FBQyJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/verifier/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,4BAA4B,CAAC"}
|
package/dest/verifier/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import type { ClientProtocolCircuitVerifier, IVCProofVerificationResult } from '@aztec/stdlib/interfaces/server';
|
|
2
2
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
3
3
|
import { type TelemetryClient } from '@aztec/telemetry-client';
|
|
4
|
-
import type { BBConfig } from '../config.js';
|
|
5
4
|
export declare class QueuedIVCVerifier implements ClientProtocolCircuitVerifier {
|
|
6
5
|
private verifier;
|
|
7
6
|
private telemetry;
|
|
8
7
|
private logger;
|
|
9
8
|
private queue;
|
|
10
9
|
private metrics;
|
|
11
|
-
constructor(
|
|
10
|
+
constructor(verifier: ClientProtocolCircuitVerifier, concurrency: number, telemetry?: TelemetryClient, logger?: import("@aztec/foundation/log").Logger);
|
|
12
11
|
verifyProof(tx: Tx): Promise<IVCProofVerificationResult>;
|
|
13
12
|
stop(): Promise<void>;
|
|
14
13
|
}
|
|
15
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
14
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicXVldWVkX2Nob25rX3ZlcmlmaWVyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdmVyaWZpZXIvcXVldWVkX2Nob25rX3ZlcmlmaWVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLDZCQUE2QixFQUFFLDBCQUEwQixFQUFFLE1BQU0saUNBQWlDLENBQUM7QUFDakgsT0FBTyxLQUFLLEVBQUUsRUFBRSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFDM0MsT0FBTyxFQU1MLEtBQUssZUFBZSxFQUlyQixNQUFNLHlCQUF5QixDQUFDO0FBbUVqQyxxQkFBYSxpQkFBa0IsWUFBVyw2QkFBNkI7SUFLbkUsT0FBTyxDQUFDLFFBQVE7SUFFaEIsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLE1BQU07SUFQaEIsT0FBTyxDQUFDLEtBQUssQ0FBYztJQUMzQixPQUFPLENBQUMsT0FBTyxDQUFxQjtJQUVwQyxZQUNVLFFBQVEsRUFBRSw2QkFBNkIsRUFDL0MsV0FBVyxFQUFFLE1BQU0sRUFDWCxTQUFTLEdBQUUsZUFBc0MsRUFDakQsTUFBTSx5Q0FBa0QsRUFNakU7SUFFWSxXQUFXLENBQUMsRUFBRSxFQUFFLEVBQUUsR0FBRyxPQUFPLENBQUMsMEJBQTBCLENBQUMsQ0FJcEU7SUFFSyxJQUFJLElBQUksT0FBTyxDQUFDLElBQUksQ0FBQyxDQUcxQjtDQUNGIn0=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"queued_chonk_verifier.d.ts","sourceRoot":"","sources":["../../src/verifier/queued_chonk_verifier.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,6BAA6B,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AACjH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAML,KAAK,eAAe,EAIrB,MAAM,yBAAyB,CAAC;AAmEjC,qBAAa,iBAAkB,YAAW,6BAA6B;IAKnE,OAAO,CAAC,QAAQ;IAEhB,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,MAAM;IAPhB,OAAO,CAAC,KAAK,CAAc;IAC3B,OAAO,CAAC,OAAO,CAAqB;IAEpC,YACU,QAAQ,EAAE,6BAA6B,EAC/C,WAAW,EAAE,MAAM,EACX,SAAS,GAAE,eAAsC,EACjD,MAAM,yCAAkD,EAMjE;IAEY,WAAW,CAAC,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAIpE;IAEK,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAG1B;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import { SerialQueue } from '@aztec/foundation/queue';
|
|
3
|
-
import { Attributes, Metrics,
|
|
3
|
+
import { Attributes, Metrics, createUpDownCounterWithDefault, getTelemetryClient } from '@aztec/telemetry-client';
|
|
4
4
|
import { createHistogram } from 'node:perf_hooks';
|
|
5
5
|
class IVCVerifierMetrics {
|
|
6
6
|
ivcVerificationHistogram;
|
|
@@ -17,46 +17,15 @@ class IVCVerifierMetrics {
|
|
|
17
17
|
aggDurationMetrics;
|
|
18
18
|
constructor(client, name = 'QueuedIVCVerifier'){
|
|
19
19
|
const meter = client.getMeter(name);
|
|
20
|
-
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
valueType: ValueType.INT
|
|
24
|
-
});
|
|
25
|
-
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME, {
|
|
26
|
-
unit: 'ms',
|
|
27
|
-
description: 'Total duration to verify chonk proofs, including serde',
|
|
28
|
-
valueType: ValueType.INT
|
|
29
|
-
});
|
|
30
|
-
this.ivcFailureCount = meter.createUpDownCounter(Metrics.IVC_VERIFIER_FAILURE_COUNT, {
|
|
31
|
-
description: 'Count of failed IVC proof verifications',
|
|
32
|
-
valueType: ValueType.INT
|
|
33
|
-
});
|
|
20
|
+
this.ivcVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TIME);
|
|
21
|
+
this.ivcTotalVerificationHistogram = meter.createHistogram(Metrics.IVC_VERIFIER_TOTAL_TIME);
|
|
22
|
+
this.ivcFailureCount = createUpDownCounterWithDefault(meter, Metrics.IVC_VERIFIER_FAILURE_COUNT);
|
|
34
23
|
this.aggDurationMetrics = {
|
|
35
|
-
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX, {
|
|
41
|
-
valueType: ValueType.DOUBLE,
|
|
42
|
-
description: 'MAX ivc verification',
|
|
43
|
-
unit: 'ms'
|
|
44
|
-
}),
|
|
45
|
-
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN, {
|
|
46
|
-
valueType: ValueType.DOUBLE,
|
|
47
|
-
description: 'MIN ivc verification',
|
|
48
|
-
unit: 'ms'
|
|
49
|
-
}),
|
|
50
|
-
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50, {
|
|
51
|
-
valueType: ValueType.DOUBLE,
|
|
52
|
-
description: 'P50 ivc verification',
|
|
53
|
-
unit: 'ms'
|
|
54
|
-
}),
|
|
55
|
-
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90, {
|
|
56
|
-
valueType: ValueType.DOUBLE,
|
|
57
|
-
description: 'P90 ivc verification',
|
|
58
|
-
unit: 'ms'
|
|
59
|
-
})
|
|
24
|
+
avg: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_AVG),
|
|
25
|
+
max: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MAX),
|
|
26
|
+
min: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_MIN),
|
|
27
|
+
p50: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P50),
|
|
28
|
+
p90: meter.createObservableGauge(Metrics.IVC_VERIFIER_AGG_DURATION_P90)
|
|
60
29
|
};
|
|
61
30
|
meter.addBatchObservableCallback(this.aggregate, Object.values(this.aggDurationMetrics));
|
|
62
31
|
}
|
|
@@ -112,21 +81,22 @@ export class QueuedIVCVerifier {
|
|
|
112
81
|
logger;
|
|
113
82
|
queue;
|
|
114
83
|
metrics;
|
|
115
|
-
constructor(
|
|
84
|
+
constructor(verifier, concurrency, telemetry = getTelemetryClient(), logger = createLogger('bb-prover:queued_chonk_verifier')){
|
|
116
85
|
this.verifier = verifier;
|
|
117
86
|
this.telemetry = telemetry;
|
|
118
87
|
this.logger = logger;
|
|
119
88
|
this.metrics = new IVCVerifierMetrics(this.telemetry, 'QueuedIVCVerifier');
|
|
120
89
|
this.queue = new SerialQueue();
|
|
121
|
-
this.logger.info(`Starting QueuedIVCVerifier with ${
|
|
122
|
-
this.queue.start(
|
|
90
|
+
this.logger.info(`Starting QueuedIVCVerifier with ${concurrency} concurrent verifiers`);
|
|
91
|
+
this.queue.start(concurrency);
|
|
123
92
|
}
|
|
124
93
|
async verifyProof(tx) {
|
|
125
94
|
const result = await this.queue.put(()=>this.verifier.verifyProof(tx));
|
|
126
95
|
this.metrics.recordIVCVerification(result);
|
|
127
96
|
return result;
|
|
128
97
|
}
|
|
129
|
-
stop() {
|
|
130
|
-
|
|
98
|
+
async stop() {
|
|
99
|
+
await this.queue.end();
|
|
100
|
+
await this.verifier.stop();
|
|
131
101
|
}
|
|
132
102
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/bb-prover",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.9ee6fcc6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"../package.common.json"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"build": "yarn clean &&
|
|
29
|
-
"build:dev": "
|
|
28
|
+
"build": "yarn clean && ../scripts/tsc.sh",
|
|
29
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
30
30
|
"clean": "rm -rf ./dest .tsbuildinfo",
|
|
31
31
|
"bb": "node --no-warnings ./dest/bb/index.js",
|
|
32
32
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
@@ -69,32 +69,33 @@
|
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@aztec/bb.js": "0.0.1-commit.
|
|
73
|
-
"@aztec/constants": "0.0.1-commit.
|
|
74
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
75
|
-
"@aztec/noir-noirc_abi": "0.0.1-commit.
|
|
76
|
-
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.
|
|
77
|
-
"@aztec/noir-types": "0.0.1-commit.
|
|
78
|
-
"@aztec/simulator": "0.0.1-commit.
|
|
79
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
80
|
-
"@aztec/telemetry-client": "0.0.1-commit.
|
|
81
|
-
"@aztec/world-state": "0.0.1-commit.
|
|
72
|
+
"@aztec/bb.js": "0.0.1-commit.9ee6fcc6",
|
|
73
|
+
"@aztec/constants": "0.0.1-commit.9ee6fcc6",
|
|
74
|
+
"@aztec/foundation": "0.0.1-commit.9ee6fcc6",
|
|
75
|
+
"@aztec/noir-noirc_abi": "0.0.1-commit.9ee6fcc6",
|
|
76
|
+
"@aztec/noir-protocol-circuits-types": "0.0.1-commit.9ee6fcc6",
|
|
77
|
+
"@aztec/noir-types": "0.0.1-commit.9ee6fcc6",
|
|
78
|
+
"@aztec/simulator": "0.0.1-commit.9ee6fcc6",
|
|
79
|
+
"@aztec/stdlib": "0.0.1-commit.9ee6fcc6",
|
|
80
|
+
"@aztec/telemetry-client": "0.0.1-commit.9ee6fcc6",
|
|
81
|
+
"@aztec/world-state": "0.0.1-commit.9ee6fcc6",
|
|
82
82
|
"commander": "^12.1.0",
|
|
83
|
+
"msgpackr": "^1.11.2",
|
|
83
84
|
"pako": "^2.1.0",
|
|
84
85
|
"source-map-support": "^0.5.21",
|
|
85
86
|
"tslib": "^2.4.0"
|
|
86
87
|
},
|
|
87
88
|
"devDependencies": {
|
|
88
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
89
|
-
"@aztec/kv-store": "0.0.1-commit.
|
|
90
|
-
"@aztec/noir-contracts.js": "0.0.1-commit.
|
|
91
|
-
"@aztec/noir-test-contracts.js": "0.0.1-commit.
|
|
92
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
89
|
+
"@aztec/ethereum": "0.0.1-commit.9ee6fcc6",
|
|
90
|
+
"@aztec/kv-store": "0.0.1-commit.9ee6fcc6",
|
|
91
|
+
"@aztec/noir-contracts.js": "0.0.1-commit.9ee6fcc6",
|
|
92
|
+
"@aztec/noir-test-contracts.js": "0.0.1-commit.9ee6fcc6",
|
|
93
|
+
"@aztec/protocol-contracts": "0.0.1-commit.9ee6fcc6",
|
|
93
94
|
"@jest/globals": "^30.0.0",
|
|
94
95
|
"@types/jest": "^30.0.0",
|
|
95
96
|
"@types/node": "^22.15.17",
|
|
96
97
|
"@types/source-map-support": "^0.5.10",
|
|
97
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
98
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
98
99
|
"jest": "^30.0.0",
|
|
99
100
|
"jest-mock-extended": "^4.0.0",
|
|
100
101
|
"ts-node": "^10.9.1",
|