@aztec/bb-prover 0.66.0 → 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.
@@ -42,7 +42,7 @@ import {
42
42
  makeRecursiveProofFromBinary,
43
43
  } from '@aztec/circuits.js';
44
44
  import { runInDirectory } from '@aztec/foundation/fs';
45
- import { createDebugLogger } from '@aztec/foundation/log';
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 * as fs from 'fs/promises';
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 = createDebugLogger('aztec:bb-prover');
103
+ const logger = createLogger('bb-prover');
104
104
 
105
105
  // All `ServerCircuitArtifact` are recursive.
106
106
  const SERVER_CIRCUIT_RECURSIVE = true;
@@ -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.fromString)
799
- .concat(json.slice(3 + numPublicInputs).map(Fr.fromString));
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.fromString)
881
- .concat(json.slice(3 + numPublicInputs).map(Fr.fromString));
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
  );
@@ -0,0 +1,85 @@
1
+ import {
2
+ AztecAddress,
3
+ BlockHeader,
4
+ ContractStorageRead,
5
+ ContractStorageUpdateRequest,
6
+ Gas,
7
+ GlobalVariables,
8
+ L2ToL1Message,
9
+ LogHash,
10
+ MAX_ENQUEUED_CALLS_PER_CALL,
11
+ MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
12
+ MAX_L2_TO_L1_MSGS_PER_CALL,
13
+ MAX_NOTE_HASHES_PER_CALL,
14
+ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
15
+ MAX_NULLIFIERS_PER_CALL,
16
+ MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
17
+ MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
18
+ MAX_PUBLIC_DATA_READS_PER_CALL,
19
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
20
+ MAX_UNENCRYPTED_LOGS_PER_CALL,
21
+ NoteHash,
22
+ Nullifier,
23
+ PublicCircuitPublicInputs,
24
+ PublicInnerCallRequest,
25
+ ReadRequest,
26
+ RevertCode,
27
+ TreeLeafReadRequest,
28
+ } from '@aztec/circuits.js';
29
+ import { computeVarArgsHash } from '@aztec/circuits.js/hash';
30
+ import { padArrayEnd } from '@aztec/foundation/collection';
31
+ import { type PublicFunctionCallResult } from '@aztec/simulator';
32
+
33
+ // TODO: pub somewhere more usable - copied from abstract phase manager
34
+ export function getPublicInputs(result: PublicFunctionCallResult): PublicCircuitPublicInputs {
35
+ return PublicCircuitPublicInputs.from({
36
+ callContext: result.executionRequest.callContext,
37
+ proverAddress: AztecAddress.ZERO,
38
+ argsHash: computeVarArgsHash(result.executionRequest.args),
39
+ noteHashes: padArrayEnd(result.noteHashes, NoteHash.empty(), MAX_NOTE_HASHES_PER_CALL),
40
+ nullifiers: padArrayEnd(result.nullifiers, Nullifier.empty(), MAX_NULLIFIERS_PER_CALL),
41
+ l2ToL1Msgs: padArrayEnd(result.l2ToL1Messages, L2ToL1Message.empty(), MAX_L2_TO_L1_MSGS_PER_CALL),
42
+ startSideEffectCounter: result.startSideEffectCounter,
43
+ endSideEffectCounter: result.endSideEffectCounter,
44
+ returnsHash: computeVarArgsHash(result.returnValues),
45
+ noteHashReadRequests: padArrayEnd(
46
+ result.noteHashReadRequests,
47
+ TreeLeafReadRequest.empty(),
48
+ MAX_NOTE_HASH_READ_REQUESTS_PER_CALL,
49
+ ),
50
+ nullifierReadRequests: padArrayEnd(
51
+ result.nullifierReadRequests,
52
+ ReadRequest.empty(),
53
+ MAX_NULLIFIER_READ_REQUESTS_PER_CALL,
54
+ ),
55
+ nullifierNonExistentReadRequests: padArrayEnd(
56
+ result.nullifierNonExistentReadRequests,
57
+ ReadRequest.empty(),
58
+ MAX_NULLIFIER_NON_EXISTENT_READ_REQUESTS_PER_CALL,
59
+ ),
60
+ l1ToL2MsgReadRequests: padArrayEnd(
61
+ result.l1ToL2MsgReadRequests,
62
+ TreeLeafReadRequest.empty(),
63
+ MAX_L1_TO_L2_MSG_READ_REQUESTS_PER_CALL,
64
+ ),
65
+ contractStorageReads: padArrayEnd(
66
+ result.contractStorageReads,
67
+ ContractStorageRead.empty(),
68
+ MAX_PUBLIC_DATA_READS_PER_CALL,
69
+ ),
70
+ contractStorageUpdateRequests: padArrayEnd(
71
+ result.contractStorageUpdateRequests,
72
+ ContractStorageUpdateRequest.empty(),
73
+ MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_CALL,
74
+ ),
75
+ publicCallRequests: padArrayEnd([], PublicInnerCallRequest.empty(), MAX_ENQUEUED_CALLS_PER_CALL),
76
+ unencryptedLogsHashes: padArrayEnd(result.unencryptedLogsHashes, LogHash.empty(), MAX_UNENCRYPTED_LOGS_PER_CALL),
77
+ historicalHeader: BlockHeader.empty(),
78
+ globalVariables: GlobalVariables.empty(),
79
+ startGasLeft: Gas.from(result.startGasLeft),
80
+ endGasLeft: Gas.from(result.endGasLeft),
81
+ transactionFee: result.transactionFee,
82
+ // TODO(@just-mitch): need better mapping from simulator to revert code.
83
+ revertCode: result.reverted ? RevertCode.APP_LOGIC_REVERTED : RevertCode.OK,
84
+ });
85
+ }
@@ -35,7 +35,7 @@ import {
35
35
  makeEmptyRecursiveProof,
36
36
  makeRecursiveProof,
37
37
  } from '@aztec/circuits.js';
38
- import { createDebugLogger } from '@aztec/foundation/log';
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 = createDebugLogger('aztec:test-prover');
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 * as fs from 'fs/promises';
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.fromString);
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.fromString);
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 DebugLogger, type LogFn, createDebugLogger } from '@aztec/foundation/log';
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 * as fs from 'fs/promises';
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: DebugLogger,
33
+ private logger: Logger,
34
34
  ) {}
35
35
 
36
36
  public static async new(
37
37
  config: BBConfig,
38
38
  initialCircuits: ProtocolArtifact[] = [],
39
- logger = createDebugLogger('aztec:bb-verifier'),
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>>();