@aztec/bb-prover 0.65.2 → 0.67.0
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/bb/cli.js +2 -2
- package/dest/bb/execute.d.ts +2 -3
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +21 -18
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +2 -11
- package/dest/prover/bb_private_kernel_prover.d.ts +2 -2
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +5 -5
- package/dest/prover/bb_prover.js +9 -9
- package/dest/test/index.d.ts +0 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -2
- package/dest/test/test_avm.js +3 -3
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +3 -3
- package/dest/verification_key/verification_key_data.js +4 -4
- package/dest/verifier/bb_verifier.d.ts +2 -1
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +4 -4
- package/package.json +12 -8
- package/src/bb/cli.ts +1 -1
- package/src/bb/execute.ts +22 -20
- package/src/instrumentation.ts +0 -10
- package/src/prover/bb_private_kernel_prover.ts +5 -5
- package/src/prover/bb_prover.ts +8 -8
- package/src/test/index.ts +0 -1
- package/src/test/test_avm.ts +2 -2
- package/src/test/test_circuit_prover.ts +2 -2
- package/src/verification_key/verification_key_data.ts +3 -3
- package/src/verifier/bb_verifier.ts +4 -4
package/src/instrumentation.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
type TelemetryClient,
|
|
9
9
|
type Tracer,
|
|
10
10
|
ValueType,
|
|
11
|
-
millisecondBuckets,
|
|
12
11
|
} from '@aztec/telemetry-client';
|
|
13
12
|
|
|
14
13
|
/**
|
|
@@ -36,27 +35,18 @@ export class ProverInstrumentation {
|
|
|
36
35
|
description: 'Records how long it takes to simulate a circuit',
|
|
37
36
|
unit: 'ms',
|
|
38
37
|
valueType: ValueType.INT,
|
|
39
|
-
advice: {
|
|
40
|
-
explicitBucketBoundaries: millisecondBuckets(1), // 10ms -> ~327s
|
|
41
|
-
},
|
|
42
38
|
});
|
|
43
39
|
|
|
44
40
|
this.witGenDuration = meter.createHistogram(Metrics.CIRCUIT_WITNESS_GEN_DURATION, {
|
|
45
41
|
description: 'Records how long it takes to generate the partial witness for a circuit',
|
|
46
42
|
unit: 'ms',
|
|
47
43
|
valueType: ValueType.INT,
|
|
48
|
-
advice: {
|
|
49
|
-
explicitBucketBoundaries: millisecondBuckets(1),
|
|
50
|
-
},
|
|
51
44
|
});
|
|
52
45
|
|
|
53
46
|
this.provingDuration = meter.createHistogram(Metrics.CIRCUIT_PROVING_DURATION, {
|
|
54
47
|
unit: 'ms',
|
|
55
48
|
description: 'Records how long it takes to prove a circuit',
|
|
56
49
|
valueType: ValueType.INT,
|
|
57
|
-
advice: {
|
|
58
|
-
explicitBucketBoundaries: millisecondBuckets(2), // 100ms -> 54 minutes
|
|
59
|
-
},
|
|
60
50
|
});
|
|
61
51
|
|
|
62
52
|
this.witGenInputSize = meter.createGauge(Metrics.CIRCUIT_WITNESS_GEN_INPUT_SIZE, {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
type VerificationKeyData,
|
|
21
21
|
} from '@aztec/circuits.js';
|
|
22
22
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
23
|
-
import { type
|
|
23
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
24
24
|
import { Timer } from '@aztec/foundation/timer';
|
|
25
25
|
import {
|
|
26
26
|
ClientCircuitArtifacts,
|
|
@@ -45,7 +45,7 @@ import { type NoirCompiledCircuit } from '@aztec/types/noir';
|
|
|
45
45
|
import { encode } from '@msgpack/msgpack';
|
|
46
46
|
import { serializeWitness } from '@noir-lang/noirc_abi';
|
|
47
47
|
import { type WitnessMap } from '@noir-lang/types';
|
|
48
|
-
import
|
|
48
|
+
import { promises as fs } from 'fs';
|
|
49
49
|
import path from 'path';
|
|
50
50
|
|
|
51
51
|
import {
|
|
@@ -79,10 +79,10 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
79
79
|
private bbBinaryPath: string,
|
|
80
80
|
private bbWorkingDirectory: string,
|
|
81
81
|
private skipCleanup: boolean,
|
|
82
|
-
private log =
|
|
82
|
+
private log = createLogger('bb-prover:native'),
|
|
83
83
|
) {}
|
|
84
84
|
|
|
85
|
-
public static async new(config: BBConfig, log?:
|
|
85
|
+
public static async new(config: BBConfig, log?: Logger) {
|
|
86
86
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
87
87
|
return new BBNativePrivateKernelProver(config.bbBinaryPath, config.bbWorkingDirectory, !!config.bbSkipCleanup, log);
|
|
88
88
|
}
|
|
@@ -391,7 +391,7 @@ export class BBNativePrivateKernelProver implements PrivateKernelProver {
|
|
|
391
391
|
fs.readFile(`${filePath}/${PROOF_FIELDS_FILENAME}`, { encoding: 'utf-8' }),
|
|
392
392
|
]);
|
|
393
393
|
const json = JSON.parse(proofString);
|
|
394
|
-
const fields = json.map(Fr.
|
|
394
|
+
const fields = json.map(Fr.fromHexString);
|
|
395
395
|
const numPublicInputs = vkData.numPublicInputs - AGGREGATION_OBJECT_LENGTH;
|
|
396
396
|
const fieldsWithoutPublicInputs = fields.slice(numPublicInputs);
|
|
397
397
|
this.log.info(
|
package/src/prover/bb_prover.ts
CHANGED
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
makeRecursiveProofFromBinary,
|
|
43
43
|
} from '@aztec/circuits.js';
|
|
44
44
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
45
|
-
import {
|
|
45
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
46
46
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
47
47
|
import { Timer } from '@aztec/foundation/timer';
|
|
48
48
|
import {
|
|
@@ -76,7 +76,7 @@ import { Attributes, type TelemetryClient, trackSpan } from '@aztec/telemetry-cl
|
|
|
76
76
|
import { abiEncode } from '@noir-lang/noirc_abi';
|
|
77
77
|
import { type Abi, type WitnessMap } from '@noir-lang/types';
|
|
78
78
|
import crypto from 'crypto';
|
|
79
|
-
import
|
|
79
|
+
import { promises as fs } from 'fs';
|
|
80
80
|
import * as path from 'path';
|
|
81
81
|
|
|
82
82
|
import {
|
|
@@ -100,7 +100,7 @@ import { ProverInstrumentation } from '../instrumentation.js';
|
|
|
100
100
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
101
101
|
import { extractAvmVkData, extractVkData } from '../verification_key/verification_key_data.js';
|
|
102
102
|
|
|
103
|
-
const logger =
|
|
103
|
+
const logger = createLogger('bb-prover');
|
|
104
104
|
|
|
105
105
|
// All `ServerCircuitArtifact` are recursive.
|
|
106
106
|
const SERVER_CIRCUIT_RECURSIVE = true;
|
|
@@ -535,7 +535,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
535
535
|
private async generateAvmProofWithBB(input: AvmCircuitInputs, workingDirectory: string): Promise<BBSuccess> {
|
|
536
536
|
logger.info(`Proving avm-circuit for ${input.functionName}...`);
|
|
537
537
|
|
|
538
|
-
const provingResult = await generateAvmProof(this.config.bbBinaryPath, workingDirectory, input, logger
|
|
538
|
+
const provingResult = await generateAvmProof(this.config.bbBinaryPath, workingDirectory, input, logger);
|
|
539
539
|
|
|
540
540
|
if (provingResult.status === BB_RESULT.FAILURE) {
|
|
541
541
|
logger.error(`Failed to generate AVM proof for ${input.functionName}: ${provingResult.reason}`);
|
|
@@ -795,8 +795,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
795
795
|
const json = JSON.parse(proofString);
|
|
796
796
|
const fields = json
|
|
797
797
|
.slice(0, 3)
|
|
798
|
-
.map(Fr.
|
|
799
|
-
.concat(json.slice(3 + numPublicInputs).map(Fr.
|
|
798
|
+
.map(Fr.fromHexString)
|
|
799
|
+
.concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
800
800
|
return new RecursiveProof(
|
|
801
801
|
fields,
|
|
802
802
|
new Proof(proof.binaryProof.buffer, vk.numPublicInputs),
|
|
@@ -877,8 +877,8 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
877
877
|
|
|
878
878
|
const fieldsWithoutPublicInputs = json
|
|
879
879
|
.slice(0, 3)
|
|
880
|
-
.map(Fr.
|
|
881
|
-
.concat(json.slice(3 + numPublicInputs).map(Fr.
|
|
880
|
+
.map(Fr.fromHexString)
|
|
881
|
+
.concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
882
882
|
logger.debug(
|
|
883
883
|
`Circuit path: ${filePath}, complete proof length: ${json.length}, num public inputs: ${numPublicInputs}, circuit size: ${vkData.circuitSize}, is recursive: ${vkData.isRecursive}, raw length: ${binaryProof.length}`,
|
|
884
884
|
);
|
package/src/test/index.ts
CHANGED
package/src/test/test_avm.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AztecAddress,
|
|
3
|
+
BlockHeader,
|
|
3
4
|
ContractStorageRead,
|
|
4
5
|
ContractStorageUpdateRequest,
|
|
5
6
|
Gas,
|
|
6
7
|
GlobalVariables,
|
|
7
|
-
Header,
|
|
8
8
|
L2ToL1Message,
|
|
9
9
|
LogHash,
|
|
10
10
|
MAX_ENQUEUED_CALLS_PER_CALL,
|
|
@@ -74,7 +74,7 @@ export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuit
|
|
|
74
74
|
),
|
|
75
75
|
publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_CALL),
|
|
76
76
|
unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
|
|
77
|
-
historicalHeader:
|
|
77
|
+
historicalHeader: BlockHeader.empty(),
|
|
78
78
|
globalVariables: GlobalVariables.empty(),
|
|
79
79
|
startGasLeft: Gas.from(result.startGasLeft),
|
|
80
80
|
endGasLeft: Gas.from(result.endGasLeft),
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
makeEmptyRecursiveProof,
|
|
36
36
|
makeRecursiveProof,
|
|
37
37
|
} from '@aztec/circuits.js';
|
|
38
|
-
import {
|
|
38
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
39
39
|
import { sleep } from '@aztec/foundation/sleep';
|
|
40
40
|
import { Timer } from '@aztec/foundation/timer';
|
|
41
41
|
import {
|
|
@@ -78,7 +78,7 @@ import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
|
78
78
|
export class TestCircuitProver implements ServerCircuitProver {
|
|
79
79
|
private wasmSimulator = new WASMSimulator();
|
|
80
80
|
private instrumentation: ProverInstrumentation;
|
|
81
|
-
private logger =
|
|
81
|
+
private logger = createLogger('bb-prover:test-prover');
|
|
82
82
|
|
|
83
83
|
constructor(
|
|
84
84
|
telemetry: TelemetryClient,
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import { hashVK } from '@aztec/circuits.js/hash';
|
|
8
8
|
|
|
9
9
|
import { strict as assert } from 'assert';
|
|
10
|
-
import
|
|
10
|
+
import { promises as fs } from 'fs';
|
|
11
11
|
import * as path from 'path';
|
|
12
12
|
|
|
13
13
|
import { VK_FIELDS_FILENAME, VK_FILENAME } from '../bb/execute.js';
|
|
@@ -23,7 +23,7 @@ export async function extractVkData(vkDirectoryPath: string): Promise<Verificati
|
|
|
23
23
|
fs.readFile(path.join(vkDirectoryPath, VK_FILENAME)),
|
|
24
24
|
]);
|
|
25
25
|
const fieldsJson = JSON.parse(rawFields);
|
|
26
|
-
const fields = fieldsJson.map(Fr.
|
|
26
|
+
const fields = fieldsJson.map(Fr.fromHexString);
|
|
27
27
|
// The hash is not included in the BB response
|
|
28
28
|
const vkHash = hashVK(fields);
|
|
29
29
|
const vkAsFields = new VerificationKeyAsFields(fields, vkHash);
|
|
@@ -37,7 +37,7 @@ export async function extractAvmVkData(vkDirectoryPath: string): Promise<Verific
|
|
|
37
37
|
fs.readFile(path.join(vkDirectoryPath, VK_FILENAME)),
|
|
38
38
|
]);
|
|
39
39
|
const fieldsJson = JSON.parse(rawFields);
|
|
40
|
-
const fields = fieldsJson.map(Fr.
|
|
40
|
+
const fields = fieldsJson.map(Fr.fromHexString);
|
|
41
41
|
// The first item is the hash, this is not part of the actual VK
|
|
42
42
|
// TODO: is the above actually the case?
|
|
43
43
|
const vkHash = fields[0];
|
|
@@ -2,14 +2,14 @@ import { type ClientProtocolCircuitVerifier, Tx } from '@aztec/circuit-types';
|
|
|
2
2
|
import { type CircuitVerificationStats } from '@aztec/circuit-types/stats';
|
|
3
3
|
import { type Proof, type VerificationKeyData } from '@aztec/circuits.js';
|
|
4
4
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
5
|
-
import { type
|
|
5
|
+
import { type LogFn, type Logger, createLogger } from '@aztec/foundation/log';
|
|
6
6
|
import {
|
|
7
7
|
type ClientProtocolArtifact,
|
|
8
8
|
type ProtocolArtifact,
|
|
9
9
|
ProtocolCircuitArtifacts,
|
|
10
10
|
} from '@aztec/noir-protocol-circuits-types';
|
|
11
11
|
|
|
12
|
-
import
|
|
12
|
+
import { promises as fs } from 'fs';
|
|
13
13
|
import * as path from 'path';
|
|
14
14
|
|
|
15
15
|
import {
|
|
@@ -30,13 +30,13 @@ export class BBCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
|
30
30
|
private constructor(
|
|
31
31
|
private config: BBConfig,
|
|
32
32
|
private verificationKeys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>(),
|
|
33
|
-
private logger:
|
|
33
|
+
private logger: Logger,
|
|
34
34
|
) {}
|
|
35
35
|
|
|
36
36
|
public static async new(
|
|
37
37
|
config: BBConfig,
|
|
38
38
|
initialCircuits: ProtocolArtifact[] = [],
|
|
39
|
-
logger =
|
|
39
|
+
logger = createLogger('bb-prover:verifier'),
|
|
40
40
|
) {
|
|
41
41
|
await fs.mkdir(config.bbWorkingDirectory, { recursive: true });
|
|
42
42
|
const keys = new Map<ProtocolArtifact, Promise<VerificationKeyData>>();
|