@aztec/bb-prover 0.0.0-test.1 → 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/avm_proving_tests/avm_proving_tester.d.ts +12 -17
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +117 -73
- package/dest/bb/execute.d.ts +15 -40
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +117 -159
- package/dest/config.d.ts +2 -0
- package/dest/config.d.ts.map +1 -1
- package/dest/honk.d.ts +1 -1
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +1 -0
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -0
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -4
- package/dest/prover/{bb_private_kernel_prover.d.ts → client/bb_private_kernel_prover.d.ts} +8 -8
- package/dest/prover/client/bb_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_private_kernel_prover.js → client/bb_private_kernel_prover.js} +21 -18
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts +23 -0
- package/dest/prover/client/native/bb_native_private_kernel_prover.d.ts.map +1 -0
- package/dest/prover/{bb_native_private_kernel_prover.js → client/native/bb_native_private_kernel_prover.js} +16 -19
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts +15 -0
- package/dest/prover/client/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -0
- package/dest/{wasm → prover/client/wasm}/bb_wasm_private_kernel_prover.js +13 -11
- package/dest/prover/client/wasm/bundle.d.ts +6 -0
- package/dest/prover/client/wasm/bundle.d.ts.map +1 -0
- package/dest/{wasm → prover/client/wasm}/bundle.js +2 -2
- package/dest/prover/client/wasm/lazy.d.ts +6 -0
- package/dest/prover/client/wasm/lazy.d.ts.map +1 -0
- package/dest/{wasm → prover/client/wasm}/lazy.js +2 -2
- package/dest/prover/index.d.ts +2 -3
- package/dest/prover/index.d.ts.map +1 -1
- package/dest/prover/index.js +2 -3
- package/dest/prover/proof_utils.d.ts +19 -0
- package/dest/prover/proof_utils.d.ts.map +1 -0
- package/dest/prover/proof_utils.js +55 -0
- package/dest/prover/{bb_prover.d.ts → server/bb_prover.d.ts} +8 -8
- package/dest/prover/server/bb_prover.d.ts.map +1 -0
- package/dest/prover/{bb_prover.js → server/bb_prover.js} +68 -75
- package/dest/stats.d.ts +0 -1
- package/dest/stats.d.ts.map +1 -1
- package/dest/stats.js +6 -23
- package/dest/test/delay_values.d.ts.map +1 -1
- package/dest/test/delay_values.js +2 -0
- package/dest/test/test_circuit_prover.d.ts +7 -6
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +20 -12
- package/dest/test/test_verifier.d.ts +3 -2
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +8 -1
- package/dest/verification_key/verification_key_data.d.ts +6 -0
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +23 -29
- package/dest/verifier/bb_verifier.d.ts +5 -2
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +33 -10
- package/dest/verifier/index.d.ts +1 -0
- package/dest/verifier/index.d.ts.map +1 -1
- package/dest/verifier/index.js +1 -0
- package/dest/verifier/queued_ivc_verifier.d.ts +15 -0
- package/dest/verifier/queued_ivc_verifier.d.ts.map +1 -0
- package/dest/verifier/queued_ivc_verifier.js +132 -0
- package/package.json +33 -31
- package/src/avm_proving_tests/avm_proving_tester.ts +193 -97
- package/src/bb/execute.ts +95 -172
- package/src/config.ts +2 -0
- package/src/honk.ts +2 -1
- package/src/index.ts +1 -0
- package/src/instrumentation.ts +0 -2
- package/src/prover/{bb_private_kernel_prover.ts → client/bb_private_kernel_prover.ts} +48 -26
- package/src/prover/{bb_native_private_kernel_prover.ts → client/native/bb_native_private_kernel_prover.ts} +17 -31
- package/src/{wasm → prover/client/wasm}/bb_wasm_private_kernel_prover.ts +16 -11
- package/src/{wasm → prover/client/wasm}/bundle.ts +3 -3
- package/src/{wasm → prover/client/wasm}/lazy.ts +3 -3
- package/src/prover/index.ts +2 -3
- package/src/prover/proof_utils.ts +93 -0
- package/src/prover/{bb_prover.ts → server/bb_prover.ts} +127 -118
- package/src/stats.ts +6 -23
- package/src/test/delay_values.ts +2 -0
- package/src/test/test_circuit_prover.ts +55 -19
- package/src/test/test_verifier.ts +7 -3
- package/src/verification_key/verification_key_data.ts +29 -24
- package/src/verifier/bb_verifier.ts +43 -13
- package/src/verifier/index.ts +1 -0
- package/src/verifier/queued_ivc_verifier.ts +140 -0
- package/dest/prover/bb_native_private_kernel_prover.d.ts +0 -25
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_private_kernel_prover.d.ts.map +0 -1
- package/dest/prover/bb_prover.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.d.ts +0 -25
- package/dest/prover/client_ivc_proof_utils.d.ts.map +0 -1
- package/dest/prover/client_ivc_proof_utils.js +0 -43
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +0 -17
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +0 -1
- package/dest/wasm/bundle.d.ts +0 -6
- package/dest/wasm/bundle.d.ts.map +0 -1
- package/dest/wasm/lazy.d.ts +0 -6
- package/dest/wasm/lazy.d.ts.map +0 -1
- package/src/prover/client_ivc_proof_utils.ts +0 -42
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { PublicTxSimulationTester, type TestEnqueuedCall } from '@aztec/simulator/public/fixtures';
|
|
2
|
-
import {
|
|
3
|
-
import type
|
|
1
|
+
import { PublicTxSimulationTester, SimpleContractDataSource, type TestEnqueuedCall, type TestExecutorMetrics, type TestPrivateInsertions } from '@aztec/simulator/public/fixtures';
|
|
2
|
+
import type { PublicTxResult } from '@aztec/simulator/server';
|
|
3
|
+
import { type AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
5
|
import type { MerkleTreeWriteOperations } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import type { GlobalVariables } from '@aztec/stdlib/tx';
|
|
6
7
|
import { type BBResult, type BBSuccess } from '../bb/execute.js';
|
|
7
8
|
export declare class AvmProvingTester extends PublicTxSimulationTester {
|
|
8
9
|
private bbWorkingDirectory;
|
|
9
10
|
private checkCircuitOnly;
|
|
10
|
-
constructor(bbWorkingDirectory: string, checkCircuitOnly: boolean,
|
|
11
|
-
static
|
|
12
|
-
prove(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
13
|
-
verify(proofRes: BBSuccess): Promise<BBResult>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private bbWorkingDirectory;
|
|
19
|
-
constructor(bbWorkingDirectory: string, worldStateDB: WorldStateDB, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations);
|
|
20
|
-
static create(): Promise<AvmProvingTesterV2>;
|
|
21
|
-
proveV2(avmCircuitInputs: AvmCircuitInputs): Promise<BBResult>;
|
|
22
|
-
verifyV2(proofRes: BBSuccess): Promise<BBResult>;
|
|
23
|
-
simProveVerifyV2(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress): Promise<void>;
|
|
11
|
+
constructor(bbWorkingDirectory: string, checkCircuitOnly: boolean, contractDataSource: SimpleContractDataSource, merkleTrees: MerkleTreeWriteOperations, globals?: GlobalVariables, metrics?: TestExecutorMetrics);
|
|
12
|
+
static new(checkCircuitOnly?: boolean, globals?: GlobalVariables, metrics?: TestExecutorMetrics): Promise<AvmProvingTester>;
|
|
13
|
+
prove(avmCircuitInputs: AvmCircuitInputs, txLabel?: string): Promise<BBResult>;
|
|
14
|
+
verify(proofRes: BBSuccess, publicInputs: AvmCircuitPublicInputs): Promise<BBResult>;
|
|
15
|
+
proveVerify(avmCircuitInputs: AvmCircuitInputs, txLabel?: string): Promise<void>;
|
|
16
|
+
simProveVerify(sender: AztecAddress, setupCalls: TestEnqueuedCall[], appCalls: TestEnqueuedCall[], teardownCall: TestEnqueuedCall | undefined, expectRevert: boolean | undefined, feePayer?: AztecAddress, privateInsertions?: TestPrivateInsertions, txLabel?: string): Promise<PublicTxResult>;
|
|
17
|
+
executeTxWithLabel(txLabel: string, sender: AztecAddress, setupCalls?: TestEnqueuedCall[], appCalls?: TestEnqueuedCall[], teardownCall?: TestEnqueuedCall, feePayer?: AztecAddress, privateInsertions?: TestPrivateInsertions): Promise<PublicTxResult>;
|
|
18
|
+
simProveVerifyAppLogic(appCall: TestEnqueuedCall, expectRevert?: boolean, txLabel?: string): Promise<void>;
|
|
24
19
|
}
|
|
25
20
|
//# sourceMappingURL=avm_proving_tester.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"avm_proving_tester.d.ts","sourceRoot":"","sources":["../../src/avm_proving_tests/avm_proving_tester.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"avm_proving_tester.d.ts","sourceRoot":"","sources":["../../src/avm_proving_tests/avm_proving_tester.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC3B,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,KAAK,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,yBAAyB,EAA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,YAAY,CAAC,EAAE,gBAAgB,EAC/B,QAAQ,CAAC,EAAE,YAAY,EACvB,iBAAiB,CAAC,EAAE,qBAAqB;IAc9B,sBAAsB,CACjC,OAAO,EAAE,gBAAgB,EACzB,YAAY,CAAC,EAAE,OAAO,EACtB,OAAO,GAAE,MAAsB;CAalC"}
|
|
@@ -1,105 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Timer } from '@aztec/foundation/timer';
|
|
2
|
+
import { PublicTxSimulationTester, SimpleContractDataSource } from '@aztec/simulator/public/fixtures';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import { makeAvmCircuitInputs } from '@aztec/stdlib/testing';
|
|
5
|
-
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
6
4
|
import { NativeWorldStateService } from '@aztec/world-state';
|
|
7
5
|
import fs from 'node:fs/promises';
|
|
8
6
|
import { tmpdir } from 'node:os';
|
|
9
7
|
import path from 'path';
|
|
10
|
-
import { BB_RESULT,
|
|
11
|
-
import { extractAvmVkData } from '../verification_key/verification_key_data.js';
|
|
8
|
+
import { BB_RESULT, VK_FILENAME, generateAvmProof, verifyAvmProof } from '../bb/execute.js';
|
|
12
9
|
const BB_PATH = path.resolve('../../barretenberg/cpp/build/bin/bb');
|
|
10
|
+
// An InterceptingLogger that records all log messages and forwards them to a wrapped logger.
|
|
11
|
+
class InterceptingLogger {
|
|
12
|
+
logs = [];
|
|
13
|
+
level;
|
|
14
|
+
module;
|
|
15
|
+
logger;
|
|
16
|
+
constructor(logger){
|
|
17
|
+
this.logger = logger;
|
|
18
|
+
this.level = logger.level;
|
|
19
|
+
this.module = logger.module;
|
|
20
|
+
}
|
|
21
|
+
isLevelEnabled(level) {
|
|
22
|
+
return this.logger.isLevelEnabled(level);
|
|
23
|
+
}
|
|
24
|
+
createChild(_childModule) {
|
|
25
|
+
throw new Error('Not implemented');
|
|
26
|
+
}
|
|
27
|
+
intercept(level, msg, ...args) {
|
|
28
|
+
this.logs.push(...msg.split('\n'));
|
|
29
|
+
// Forward to the wrapped logger
|
|
30
|
+
this.logger[level](msg, ...args);
|
|
31
|
+
}
|
|
32
|
+
// Log methods for each level
|
|
33
|
+
silent(msg, ...args) {
|
|
34
|
+
this.intercept('silent', msg, ...args);
|
|
35
|
+
}
|
|
36
|
+
fatal(msg, ...args) {
|
|
37
|
+
this.intercept('fatal', msg, ...args);
|
|
38
|
+
}
|
|
39
|
+
warn(msg, ...args) {
|
|
40
|
+
this.intercept('warn', msg, ...args);
|
|
41
|
+
}
|
|
42
|
+
info(msg, ...args) {
|
|
43
|
+
this.intercept('info', msg, ...args);
|
|
44
|
+
}
|
|
45
|
+
verbose(msg, ...args) {
|
|
46
|
+
this.intercept('verbose', msg, ...args);
|
|
47
|
+
}
|
|
48
|
+
debug(msg, ...args) {
|
|
49
|
+
this.intercept('debug', msg, ...args);
|
|
50
|
+
}
|
|
51
|
+
trace(msg, ...args) {
|
|
52
|
+
this.intercept('trace', msg, ...args);
|
|
53
|
+
}
|
|
54
|
+
// Error log function can be string or Error
|
|
55
|
+
error(err, ...args) {
|
|
56
|
+
const msg = typeof err === 'string' ? err : err.message;
|
|
57
|
+
this.logs.push(msg);
|
|
58
|
+
this.logger.error(msg, err, ...args);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
13
61
|
export class AvmProvingTester extends PublicTxSimulationTester {
|
|
14
62
|
bbWorkingDirectory;
|
|
15
63
|
checkCircuitOnly;
|
|
16
|
-
constructor(bbWorkingDirectory, checkCircuitOnly,
|
|
17
|
-
super(
|
|
64
|
+
constructor(bbWorkingDirectory, checkCircuitOnly, contractDataSource, merkleTrees, globals, metrics){
|
|
65
|
+
super(merkleTrees, contractDataSource, globals, metrics), this.bbWorkingDirectory = bbWorkingDirectory, this.checkCircuitOnly = checkCircuitOnly;
|
|
18
66
|
}
|
|
19
|
-
static async
|
|
67
|
+
static async new(checkCircuitOnly = false, globals, metrics) {
|
|
20
68
|
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
21
69
|
const contractDataSource = new SimpleContractDataSource();
|
|
22
70
|
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
23
|
-
|
|
24
|
-
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, worldStateDB, contractDataSource, merkleTrees);
|
|
71
|
+
return new AvmProvingTester(bbWorkingDirectory, checkCircuitOnly, contractDataSource, merkleTrees, globals, metrics);
|
|
25
72
|
}
|
|
26
|
-
async prove(avmCircuitInputs) {
|
|
73
|
+
async prove(avmCircuitInputs, txLabel = 'unlabeledTx') {
|
|
74
|
+
const interceptingLogger = new InterceptingLogger(this.logger);
|
|
27
75
|
// Then we prove.
|
|
28
|
-
const proofRes = await generateAvmProof(BB_PATH, this.bbWorkingDirectory, avmCircuitInputs,
|
|
76
|
+
const proofRes = await generateAvmProof(BB_PATH, this.bbWorkingDirectory, avmCircuitInputs, interceptingLogger, this.checkCircuitOnly);
|
|
29
77
|
if (proofRes.status === BB_RESULT.FAILURE) {
|
|
30
78
|
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
31
79
|
}
|
|
80
|
+
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
81
|
+
// Parse the logs into a structured format.
|
|
82
|
+
const logs = interceptingLogger.logs;
|
|
83
|
+
// const traceSizes: { name: string; size: number }[] = [];
|
|
84
|
+
// logs.forEach(log => {
|
|
85
|
+
// const match = log.match(/\b(\w+): (\d+) \(~2/);
|
|
86
|
+
// if (match) {
|
|
87
|
+
// traceSizes.push({
|
|
88
|
+
// name: match[1],
|
|
89
|
+
// size: parseInt(match[2]),
|
|
90
|
+
// });
|
|
91
|
+
// }
|
|
92
|
+
// });
|
|
93
|
+
const times = {};
|
|
94
|
+
logs.forEach((log)=>{
|
|
95
|
+
const match = log.match(/\b([\w/]+)_ms: (\d+)/);
|
|
96
|
+
if (match) {
|
|
97
|
+
times[match[1]] = parseInt(match[2]);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
// Hack to make labels match.
|
|
101
|
+
const txLabelWithCount = `${txLabel}/${this.txCount - 1}`;
|
|
102
|
+
// I need to cast because TS doesnt realize metrics is protected not private.
|
|
103
|
+
this.metrics?.recordProverMetrics(txLabelWithCount, {
|
|
104
|
+
proverSimulationStepMs: times['simulation/all'],
|
|
105
|
+
proverProvingStepMs: times['proving/all'],
|
|
106
|
+
proverTraceGenerationStepMs: times['tracegen/all'],
|
|
107
|
+
traceGenerationInteractionsMs: times['tracegen/interactions'],
|
|
108
|
+
traceGenerationTracesMs: times['tracegen/traces'],
|
|
109
|
+
provingSumcheckMs: times['prove/sumcheck'],
|
|
110
|
+
provingPcsMs: times['prove/pcs_rounds'],
|
|
111
|
+
provingLogDerivativeInverseMs: times['prove/log_derivative_inverse_round'],
|
|
112
|
+
provingLogDerivativeInverseCommitmentsMs: times['prove/log_derivative_inverse_commitments_round'],
|
|
113
|
+
provingWireCommitmentsMs: times['prove/wire_commitments_round']
|
|
114
|
+
});
|
|
32
115
|
return proofRes;
|
|
33
116
|
}
|
|
34
|
-
async verify(proofRes) {
|
|
117
|
+
async verify(proofRes, publicInputs) {
|
|
35
118
|
if (this.checkCircuitOnly) {
|
|
36
|
-
// Skip verification if we
|
|
37
|
-
// Check-circuit
|
|
119
|
+
// Skip verification if we are only checking the circuit.
|
|
120
|
+
// Check-circuit does not generate a proof to verify.
|
|
38
121
|
return proofRes;
|
|
39
122
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Then we verify.
|
|
45
|
-
const rawVkPath = path.join(succeededRes.vkPath, 'vk');
|
|
46
|
-
return await verifyAvmProof(BB_PATH, succeededRes.proofPath, rawVkPath, this.logger);
|
|
47
|
-
}
|
|
48
|
-
async simProveVerify(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
49
|
-
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
50
|
-
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
51
|
-
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
52
|
-
const provingRes = await this.prove(avmCircuitInputs);
|
|
123
|
+
return await verifyAvmProof(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, publicInputs, path.join(proofRes.vkDirectoryPath, VK_FILENAME), this.logger);
|
|
124
|
+
}
|
|
125
|
+
async proveVerify(avmCircuitInputs, txLabel = 'unlabeledTx') {
|
|
126
|
+
const provingRes = await this.prove(avmCircuitInputs, txLabel);
|
|
53
127
|
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
54
|
-
const verificationRes = await this.verify(provingRes);
|
|
128
|
+
const verificationRes = await this.verify(provingRes, avmCircuitInputs.publicInputs);
|
|
55
129
|
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
56
130
|
}
|
|
57
|
-
async
|
|
58
|
-
const simRes = await this.simulateTx(
|
|
59
|
-
appCall
|
|
60
|
-
]);
|
|
131
|
+
async simProveVerify(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender, privateInsertions, txLabel = 'unlabeledTx') {
|
|
132
|
+
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions, txLabel);
|
|
61
133
|
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
134
|
+
const opString = this.checkCircuitOnly ? 'Check circuit' : 'Proving and verification';
|
|
62
135
|
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
136
|
+
const timer = new Timer();
|
|
137
|
+
await this.proveVerify(avmCircuitInputs, txLabel);
|
|
138
|
+
this.logger.info(`${opString} took ${timer.ms()} ms for tx ${txLabel}`);
|
|
139
|
+
return simRes;
|
|
67
140
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
bbWorkingDirectory;
|
|
71
|
-
constructor(bbWorkingDirectory, worldStateDB, contractDataSource, merkleTrees){
|
|
72
|
-
super(worldStateDB, contractDataSource, merkleTrees), this.bbWorkingDirectory = bbWorkingDirectory;
|
|
73
|
-
}
|
|
74
|
-
static async create() {
|
|
75
|
-
const bbWorkingDirectory = await fs.mkdtemp(path.join(tmpdir(), 'bb-'));
|
|
76
|
-
const contractDataSource = new SimpleContractDataSource();
|
|
77
|
-
const merkleTrees = await (await NativeWorldStateService.tmp()).fork();
|
|
78
|
-
const worldStateDB = new WorldStateDB(merkleTrees, contractDataSource);
|
|
79
|
-
return new AvmProvingTesterV2(bbWorkingDirectory, worldStateDB, contractDataSource, merkleTrees);
|
|
141
|
+
async executeTxWithLabel(txLabel, sender, setupCalls, appCalls, teardownCall, feePayer, privateInsertions) {
|
|
142
|
+
return await this.simProveVerify(sender, setupCalls ?? [], appCalls ?? [], teardownCall, /*expectRevert=*/ false, feePayer, privateInsertions, txLabel);
|
|
80
143
|
}
|
|
81
|
-
async
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.logger.error(`Proof generation failed: ${proofRes.reason}`);
|
|
86
|
-
}
|
|
87
|
-
expect(proofRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
88
|
-
return proofRes;
|
|
89
|
-
}
|
|
90
|
-
async verifyV2(proofRes) {
|
|
91
|
-
// TODO: Placeholder for now. They get ignored in C++.
|
|
92
|
-
const inputs = await makeAvmCircuitInputs();
|
|
93
|
-
const rawVkPath = path.join(proofRes.vkPath, 'vk');
|
|
94
|
-
return await verifyAvmProofV2(BB_PATH, this.bbWorkingDirectory, proofRes.proofPath, inputs.publicInputs, rawVkPath, this.logger);
|
|
95
|
-
}
|
|
96
|
-
async simProveVerifyV2(sender, setupCalls, appCalls, teardownCall, expectRevert, feePayer = sender) {
|
|
97
|
-
const simRes = await this.simulateTx(sender, setupCalls, appCalls, teardownCall, feePayer);
|
|
98
|
-
expect(simRes.revertCode.isOK()).toBe(expectRevert ? false : true);
|
|
99
|
-
const avmCircuitInputs = simRes.avmProvingRequest.inputs;
|
|
100
|
-
const provingRes = await this.proveV2(avmCircuitInputs);
|
|
101
|
-
expect(provingRes.status).toEqual(BB_RESULT.SUCCESS);
|
|
102
|
-
const verificationRes = await this.verifyV2(provingRes);
|
|
103
|
-
expect(verificationRes.status).toBe(BB_RESULT.SUCCESS);
|
|
144
|
+
async simProveVerifyAppLogic(appCall, expectRevert, txLabel = 'unlabeledTx') {
|
|
145
|
+
await this.simProveVerify(/*sender=*/ AztecAddress.fromNumber(42), /*setupCalls=*/ [], [
|
|
146
|
+
appCall
|
|
147
|
+
], undefined, expectRevert, /*feePayer=*/ undefined, /*privateInsertions=*/ undefined, txLabel);
|
|
104
148
|
}
|
|
105
149
|
}
|
package/dest/bb/execute.d.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
1
|
import type { LogFn, Logger } from '@aztec/foundation/log';
|
|
4
2
|
import type { AvmCircuitInputs, AvmCircuitPublicInputs } from '@aztec/stdlib/avm';
|
|
5
3
|
import type { UltraHonkFlavor } from '../honk.js';
|
|
6
4
|
export declare const VK_FILENAME = "vk";
|
|
7
|
-
export declare const
|
|
5
|
+
export declare const PUBLIC_INPUTS_FILENAME = "public_inputs";
|
|
8
6
|
export declare const PROOF_FILENAME = "proof";
|
|
9
|
-
export declare const PROOF_FIELDS_FILENAME = "proof_fields.json";
|
|
10
7
|
export declare const AVM_INPUTS_FILENAME = "avm_inputs.bin";
|
|
11
8
|
export declare const AVM_BYTECODE_FILENAME = "avm_bytecode.bin";
|
|
12
9
|
export declare const AVM_PUBLIC_INPUTS_FILENAME = "avm_public_inputs.bin";
|
|
13
|
-
export declare const
|
|
10
|
+
export declare const CLIENT_IVC_PROOF_FILE_NAME = "proof";
|
|
14
11
|
export declare enum BB_RESULT {
|
|
15
12
|
SUCCESS = 0,
|
|
16
13
|
FAILURE = 1,
|
|
@@ -22,7 +19,7 @@ export type BBSuccess = {
|
|
|
22
19
|
/** Full path of the public key. */
|
|
23
20
|
pkPath?: string;
|
|
24
21
|
/** Base directory for the VKs (raw, fields). */
|
|
25
|
-
|
|
22
|
+
vkDirectoryPath?: string;
|
|
26
23
|
/** Full path of the proof. */
|
|
27
24
|
proofPath?: string;
|
|
28
25
|
/** Full path of the contract. */
|
|
@@ -36,7 +33,6 @@ export type BBFailure = {
|
|
|
36
33
|
retry?: boolean;
|
|
37
34
|
};
|
|
38
35
|
export type BBResult = BBSuccess | BBFailure;
|
|
39
|
-
export type VerificationFunction = typeof verifyProof | typeof verifyAvmProof;
|
|
40
36
|
type BBExecResult = {
|
|
41
37
|
status: BB_RESULT;
|
|
42
38
|
exitCode: number;
|
|
@@ -48,11 +44,12 @@ type BBExecResult = {
|
|
|
48
44
|
* @param command - The command to execute
|
|
49
45
|
* @param args - The arguments to pass
|
|
50
46
|
* @param logger - A log function
|
|
47
|
+
* @param timeout - An optional timeout before killing the BB process
|
|
51
48
|
* @param resultParser - An optional handler for detecting success or failure
|
|
52
49
|
* @returns The completed partial witness outputted from the circuit
|
|
53
50
|
*/
|
|
54
|
-
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, resultParser?: (code: number) =>
|
|
55
|
-
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string,
|
|
51
|
+
export declare function executeBB(pathToBB: string, command: string, args: string[], logger: LogFn, concurrency?: number, timeout?: number, resultParser?: (code: number) => code is 0): Promise<BBExecResult>;
|
|
52
|
+
export declare function executeBbClientIvcProof(pathToBB: string, workingDirectory: string, inputsPath: string, log: LogFn, writeVk?: boolean): Promise<BBFailure | BBSuccess>;
|
|
56
53
|
/**
|
|
57
54
|
* Used for generating proofs of noir circuits.
|
|
58
55
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
@@ -64,39 +61,25 @@ export declare function executeBbClientIvcProof(pathToBB: string, workingDirecto
|
|
|
64
61
|
* @param log - A logging function
|
|
65
62
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
66
63
|
*/
|
|
67
|
-
export declare function generateProof(pathToBB: string, workingDirectory: string, circuitName: string, bytecode: Buffer,
|
|
64
|
+
export declare function generateProof(pathToBB: string, workingDirectory: string, circuitName: string, bytecode: Buffer, inputWitnessFile: string, flavor: UltraHonkFlavor, log: Logger): Promise<BBFailure | BBSuccess>;
|
|
68
65
|
/**
|
|
69
66
|
* Used for generating proofs of the tube circuit
|
|
70
67
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
71
|
-
*
|
|
72
|
-
* @param workingDirectory - A working directory for use by bb
|
|
73
|
-
* @param circuitName - An identifier for the circuit
|
|
74
|
-
* @param bytecode - The compiled circuit bytecode
|
|
75
|
-
* @param inputWitnessFile - The circuit input witness
|
|
76
|
-
* @param log - A logging function
|
|
68
|
+
*
|
|
77
69
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
78
70
|
*/
|
|
79
|
-
export declare function generateTubeProof(pathToBB: string, workingDirectory: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
71
|
+
export declare function generateTubeProof(pathToBB: string, workingDirectory: string, vkPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
80
72
|
/**
|
|
81
73
|
* Used for generating AVM proofs.
|
|
82
74
|
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
83
75
|
* @param pathToBB - The full path to the bb binary
|
|
84
76
|
* @param workingDirectory - A working directory for use by bb
|
|
85
77
|
* @param input - The inputs for the public function to be proven
|
|
86
|
-
* @param
|
|
78
|
+
* @param logger - A logging function
|
|
79
|
+
* @param checkCircuitOnly - A boolean to toggle a "check-circuit only" operation instead of proving.
|
|
87
80
|
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
88
81
|
*/
|
|
89
|
-
export declare function
|
|
90
|
-
/**
|
|
91
|
-
* Used for generating AVM proofs (or doing check-circuit).
|
|
92
|
-
* It is assumed that the working directory is a temporary and/or random directory used solely for generating this proof.
|
|
93
|
-
* @param pathToBB - The full path to the bb binary
|
|
94
|
-
* @param workingDirectory - A working directory for use by bb
|
|
95
|
-
* @param bytecode - The AVM bytecode for the public function to be proven (expected to be decompressed)
|
|
96
|
-
* @param log - A logging function
|
|
97
|
-
* @returns An object containing a result indication, the location of the proof and the duration taken
|
|
98
|
-
*/
|
|
99
|
-
export declare function generateAvmProof(pathToBB: string, workingDirectory: string, _input: AvmCircuitInputs, logger: Logger, checkCircuitOnly?: boolean): Promise<BBFailure | BBSuccess>;
|
|
82
|
+
export declare function generateAvmProof(pathToBB: string, workingDirectory: string, input: AvmCircuitInputs, logger: Logger, checkCircuitOnly?: boolean): Promise<BBFailure | BBSuccess>;
|
|
100
83
|
/**
|
|
101
84
|
* Used for verifying proofs of noir circuits
|
|
102
85
|
* @param pathToBB - The full path to the bb binary
|
|
@@ -106,25 +89,17 @@ export declare function generateAvmProof(pathToBB: string, workingDirectory: str
|
|
|
106
89
|
* @returns An object containing a result indication and duration taken
|
|
107
90
|
*/
|
|
108
91
|
export declare function verifyProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, ultraHonkFlavor: UltraHonkFlavor, log: Logger): Promise<BBFailure | BBSuccess>;
|
|
109
|
-
|
|
110
|
-
* Used for verifying proofs of the AVM
|
|
111
|
-
* @param pathToBB - The full path to the bb binary
|
|
112
|
-
* @param proofFullPath - The full path to the proof to be verified
|
|
113
|
-
* @param verificationKeyPath - The full path to the circuit verification key
|
|
114
|
-
* @param log - A logging function
|
|
115
|
-
* @returns An object containing a result indication and duration taken
|
|
116
|
-
*/
|
|
117
|
-
export declare function verifyAvmProof(pathToBB: string, proofFullPath: string, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
118
|
-
export declare function verifyAvmProofV2(pathToBB: string, workingDirectory: string, proofFullPath: string, publicInputs: AvmCircuitPublicInputs, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
92
|
+
export declare function verifyAvmProof(pathToBB: string, workingDirectory: string, proofFullPath: string, publicInputs: AvmCircuitPublicInputs, verificationKeyPath: string, logger: Logger): Promise<BBFailure | BBSuccess>;
|
|
119
93
|
/**
|
|
120
94
|
* Verifies a ClientIvcProof
|
|
121
95
|
* TODO(#7370) The verification keys should be supplied separately
|
|
122
96
|
* @param pathToBB - The full path to the bb binary
|
|
123
97
|
* @param targetPath - The path to the folder with the proof, accumulator, and verification keys
|
|
124
98
|
* @param log - A logging function
|
|
99
|
+
* @param concurrency - The number of threads to use for the verification
|
|
125
100
|
* @returns An object containing a result indication and duration taken
|
|
126
101
|
*/
|
|
127
|
-
export declare function verifyClientIvcProof(pathToBB: string, proofPath: string, keyPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
102
|
+
export declare function verifyClientIvcProof(pathToBB: string, proofPath: string, keyPath: string, log: LogFn, concurrency?: number): Promise<BBFailure | BBSuccess>;
|
|
128
103
|
export declare function generateContractForVerificationKey(pathToBB: string, vkFilePath: string, contractPath: string, log: LogFn): Promise<BBFailure | BBSuccess>;
|
|
129
104
|
/**
|
|
130
105
|
* Compute bb gate count for a given circuit
|
package/dest/bb/execute.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/bb/execute.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"execute.d.ts","sourceRoot":"","sources":["../../src/bb/execute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAMlF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD,eAAO,MAAM,WAAW,OAAO,CAAC;AAChC,eAAO,MAAM,sBAAsB,kBAAkB,CAAC;AACtD,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