@aztec/bb-prover 0.76.4 → 0.77.0-testnet-ignition.21
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 +8 -8
- package/dest/avm_proving_tests/avm_proving_tester.d.ts.map +1 -1
- package/dest/avm_proving_tests/avm_proving_tester.js +24 -25
- package/dest/bb/cli.d.ts +3 -3
- package/dest/bb/cli.d.ts.map +1 -1
- package/dest/bb/cli.js +4 -9
- package/dest/bb/execute.d.ts +7 -37
- package/dest/bb/execute.d.ts.map +1 -1
- package/dest/bb/execute.js +359 -357
- package/dest/bb/index.js +4 -6
- package/dest/config.js +1 -2
- package/dest/honk.d.ts +1 -1
- package/dest/honk.d.ts.map +1 -1
- package/dest/honk.js +8 -5
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/instrumentation.d.ts +2 -2
- package/dest/instrumentation.d.ts.map +1 -1
- package/dest/instrumentation.js +50 -47
- package/dest/prover/bb_native_private_kernel_prover.d.ts +4 -4
- package/dest/prover/bb_native_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_native_private_kernel_prover.js +19 -19
- package/dest/prover/bb_private_kernel_prover.d.ts +7 -6
- package/dest/prover/bb_private_kernel_prover.d.ts.map +1 -1
- package/dest/prover/bb_private_kernel_prover.js +14 -15
- package/dest/prover/bb_prover.d.ts +7 -10
- package/dest/prover/bb_prover.d.ts.map +1 -1
- package/dest/prover/bb_prover.js +402 -447
- package/dest/prover/client_ivc_proof_utils.d.ts +3 -3
- package/dest/prover/client_ivc_proof_utils.d.ts.map +1 -1
- package/dest/prover/client_ivc_proof_utils.js +18 -12
- package/dest/prover/index.js +0 -1
- package/dest/stats.d.ts +2 -2
- package/dest/stats.d.ts.map +1 -1
- package/dest/stats.js +15 -14
- package/dest/test/delay_values.d.ts +4 -0
- package/dest/test/delay_values.d.ts.map +1 -0
- package/dest/test/delay_values.js +29 -0
- package/dest/test/index.js +0 -1
- package/dest/test/test_circuit_prover.d.ts +16 -7
- package/dest/test/test_circuit_prover.d.ts.map +1 -1
- package/dest/test/test_circuit_prover.js +165 -161
- package/dest/test/test_verifier.d.ts +2 -1
- package/dest/test/test_verifier.d.ts.map +1 -1
- package/dest/test/test_verifier.js +0 -1
- package/dest/verification_key/verification_key_data.d.ts +1 -1
- package/dest/verification_key/verification_key_data.d.ts.map +1 -1
- package/dest/verification_key/verification_key_data.js +13 -9
- package/dest/verifier/bb_verifier.d.ts +6 -4
- package/dest/verifier/bb_verifier.d.ts.map +1 -1
- package/dest/verifier/bb_verifier.js +18 -18
- package/dest/verifier/index.js +0 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts +5 -4
- package/dest/wasm/bb_wasm_private_kernel_prover.d.ts.map +1 -1
- package/dest/wasm/bb_wasm_private_kernel_prover.js +26 -11
- package/dest/wasm/bundle.d.ts +1 -1
- package/dest/wasm/bundle.d.ts.map +1 -1
- package/dest/wasm/bundle.js +1 -2
- package/dest/wasm/lazy.d.ts +1 -1
- package/dest/wasm/lazy.d.ts.map +1 -1
- package/dest/wasm/lazy.js +1 -2
- package/package.json +18 -19
- package/src/avm_proving_tests/avm_proving_tester.ts +17 -33
- package/src/bb/cli.ts +3 -3
- package/src/bb/execute.ts +80 -211
- package/src/honk.ts +1 -1
- package/src/index.ts +1 -1
- package/src/instrumentation.ts +10 -10
- package/src/prover/bb_native_private_kernel_prover.ts +5 -4
- package/src/prover/bb_private_kernel_prover.ts +20 -20
- package/src/prover/bb_prover.ts +33 -100
- package/src/prover/client_ivc_proof_utils.ts +3 -3
- package/src/stats.ts +2 -2
- package/src/test/delay_values.ts +31 -0
- package/src/test/test_circuit_prover.ts +149 -120
- package/src/test/test_verifier.ts +2 -1
- package/src/verification_key/verification_key_data.ts +4 -7
- package/src/verifier/bb_verifier.ts +16 -9
- package/src/wasm/bb_wasm_private_kernel_prover.ts +18 -5
- package/src/wasm/bundle.ts +1 -1
- package/src/wasm/lazy.ts +1 -1
package/src/prover/bb_prover.ts
CHANGED
|
@@ -1,45 +1,14 @@
|
|
|
1
1
|
/* eslint-disable require-await */
|
|
2
|
-
import {
|
|
3
|
-
type ProofAndVerificationKey,
|
|
4
|
-
ProvingError,
|
|
5
|
-
type PublicInputsAndRecursiveProof,
|
|
6
|
-
type ServerCircuitProver,
|
|
7
|
-
makeProofAndVerificationKey,
|
|
8
|
-
makePublicInputsAndRecursiveProof,
|
|
9
|
-
} from '@aztec/circuit-types';
|
|
10
|
-
import { type CircuitProvingStats, type CircuitWitnessGenerationStats } from '@aztec/circuit-types/stats';
|
|
11
2
|
import {
|
|
12
3
|
AGGREGATION_OBJECT_LENGTH,
|
|
13
4
|
AVM_PROOF_LENGTH_IN_FIELDS,
|
|
14
|
-
type AvmCircuitInputs,
|
|
15
|
-
type BaseParityInputs,
|
|
16
|
-
Fr,
|
|
17
5
|
IPA_CLAIM_LENGTH,
|
|
18
6
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
19
7
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
20
|
-
type ParityPublicInputs,
|
|
21
|
-
Proof,
|
|
22
8
|
RECURSIVE_PROOF_LENGTH,
|
|
23
|
-
RecursiveProof,
|
|
24
|
-
type RootParityInputs,
|
|
25
9
|
TUBE_PROOF_LENGTH,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} from '@aztec/circuits.js';
|
|
29
|
-
import {
|
|
30
|
-
type BaseOrMergeRollupPublicInputs,
|
|
31
|
-
type BlockMergeRollupInputs,
|
|
32
|
-
type BlockRootOrBlockMergePublicInputs,
|
|
33
|
-
type BlockRootRollupInputs,
|
|
34
|
-
type EmptyBlockRootRollupInputs,
|
|
35
|
-
type MergeRollupInputs,
|
|
36
|
-
type PrivateBaseRollupInputs,
|
|
37
|
-
type PublicBaseRollupInputs,
|
|
38
|
-
type RootRollupInputs,
|
|
39
|
-
type RootRollupPublicInputs,
|
|
40
|
-
type SingleTxBlockRootRollupInputs,
|
|
41
|
-
type TubeInputs,
|
|
42
|
-
} from '@aztec/circuits.js/rollup';
|
|
10
|
+
} from '@aztec/constants';
|
|
11
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
43
12
|
import { runInDirectory } from '@aztec/foundation/fs';
|
|
44
13
|
import { createLogger } from '@aztec/foundation/log';
|
|
45
14
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
@@ -68,11 +37,38 @@ import {
|
|
|
68
37
|
convertSingleTxBlockRootRollupInputsToWitnessMap,
|
|
69
38
|
convertSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
70
39
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
71
|
-
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
|
|
40
|
+
import { ServerCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
72
41
|
import { NativeACVMSimulator } from '@aztec/simulator/server';
|
|
42
|
+
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
43
|
+
import { ProvingError } from '@aztec/stdlib/errors';
|
|
44
|
+
import {
|
|
45
|
+
type ProofAndVerificationKey,
|
|
46
|
+
type PublicInputsAndRecursiveProof,
|
|
47
|
+
type ServerCircuitProver,
|
|
48
|
+
makeProofAndVerificationKey,
|
|
49
|
+
makePublicInputsAndRecursiveProof,
|
|
50
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
51
|
+
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
52
|
+
import { Proof, RecursiveProof, makeRecursiveProofFromBinary } from '@aztec/stdlib/proofs';
|
|
53
|
+
import type {
|
|
54
|
+
BaseOrMergeRollupPublicInputs,
|
|
55
|
+
BlockMergeRollupInputs,
|
|
56
|
+
BlockRootOrBlockMergePublicInputs,
|
|
57
|
+
BlockRootRollupInputs,
|
|
58
|
+
EmptyBlockRootRollupInputs,
|
|
59
|
+
MergeRollupInputs,
|
|
60
|
+
PrivateBaseRollupInputs,
|
|
61
|
+
PublicBaseRollupInputs,
|
|
62
|
+
RootRollupInputs,
|
|
63
|
+
RootRollupPublicInputs,
|
|
64
|
+
SingleTxBlockRootRollupInputs,
|
|
65
|
+
TubeInputs,
|
|
66
|
+
} from '@aztec/stdlib/rollup';
|
|
67
|
+
import type { CircuitProvingStats, CircuitWitnessGenerationStats } from '@aztec/stdlib/stats';
|
|
68
|
+
import type { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
73
69
|
import { Attributes, type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
74
70
|
|
|
75
|
-
import {
|
|
71
|
+
import type { WitnessMap } from '@noir-lang/types';
|
|
76
72
|
import { assert } from 'console';
|
|
77
73
|
import crypto from 'crypto';
|
|
78
74
|
import { promises as fs } from 'fs';
|
|
@@ -90,7 +86,6 @@ import {
|
|
|
90
86
|
generateTubeProof,
|
|
91
87
|
verifyAvmProof,
|
|
92
88
|
verifyProof,
|
|
93
|
-
writeProofAsFields,
|
|
94
89
|
} from '../bb/execute.js';
|
|
95
90
|
import type { ACVMConfig, BBConfig } from '../config.js';
|
|
96
91
|
import { type UltraHonkFlavor, getUltraHonkFlavorForCircuit } from '../honk.js';
|
|
@@ -561,7 +556,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
561
556
|
duration: provingResult.durationMs,
|
|
562
557
|
proofSize: avmProof.binaryProof.buffer.length,
|
|
563
558
|
eventName: 'circuit-proving',
|
|
564
|
-
inputSize: input.
|
|
559
|
+
inputSize: input.serializeWithMessagePack().length,
|
|
565
560
|
circuitSize: verificationKey.circuitSize, // FIX: wrong in VK
|
|
566
561
|
numPublicInputs: verificationKey.numPublicInputs, // FIX: wrong in VK
|
|
567
562
|
} satisfies CircuitProvingStats,
|
|
@@ -710,69 +705,6 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
710
705
|
await this.runInDirectory(operation);
|
|
711
706
|
}
|
|
712
707
|
|
|
713
|
-
/**
|
|
714
|
-
* Will check a recursive proof argument for validity of it's 'fields' format of proof and convert if required
|
|
715
|
-
* @param proof - The input proof that may need converting
|
|
716
|
-
* @returns - The valid proof
|
|
717
|
-
*/
|
|
718
|
-
public async ensureValidProof(
|
|
719
|
-
proof: RecursiveProof<typeof NESTED_RECURSIVE_PROOF_LENGTH>, // WORKTODO
|
|
720
|
-
circuit: ServerProtocolArtifact,
|
|
721
|
-
vk: VerificationKeyData,
|
|
722
|
-
) {
|
|
723
|
-
// If the 'fields' proof is already valid then simply return
|
|
724
|
-
// This will be false for proofs coming from clients
|
|
725
|
-
if (proof.fieldsValid) {
|
|
726
|
-
return proof;
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
const operation = async (bbWorkingDirectory: string) => {
|
|
730
|
-
const numPublicInputs = vk.numPublicInputs - AGGREGATION_OBJECT_LENGTH - IPA_CLAIM_LENGTH;
|
|
731
|
-
const proofFullFilename = path.join(bbWorkingDirectory, PROOF_FILENAME);
|
|
732
|
-
const vkFullFilename = path.join(bbWorkingDirectory, VK_FILENAME);
|
|
733
|
-
|
|
734
|
-
logger.debug(
|
|
735
|
-
`Converting proof to fields format for circuit ${circuit}, directory ${bbWorkingDirectory}, num public inputs: ${vk.numPublicInputs}, proof length ${proof.binaryProof.buffer.length}, vk length ${vk.keyAsBytes.length}`,
|
|
736
|
-
);
|
|
737
|
-
|
|
738
|
-
await fs.writeFile(proofFullFilename, proof.binaryProof.buffer);
|
|
739
|
-
await fs.writeFile(vkFullFilename, vk.keyAsBytes);
|
|
740
|
-
|
|
741
|
-
const logFunction = (message: string) => {
|
|
742
|
-
logger.debug(`${circuit} BB out - ${message}`);
|
|
743
|
-
};
|
|
744
|
-
|
|
745
|
-
const result = await writeProofAsFields(
|
|
746
|
-
this.config.bbBinaryPath,
|
|
747
|
-
bbWorkingDirectory,
|
|
748
|
-
PROOF_FILENAME,
|
|
749
|
-
vkFullFilename,
|
|
750
|
-
logFunction,
|
|
751
|
-
);
|
|
752
|
-
|
|
753
|
-
if (result.status === BB_RESULT.FAILURE) {
|
|
754
|
-
const errorMessage = `Failed to convert ${circuit} proof to fields, ${result.reason}`;
|
|
755
|
-
throw new ProvingError(errorMessage, result, result.retry);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
const proofString = await fs.readFile(path.join(bbWorkingDirectory, PROOF_FIELDS_FILENAME), {
|
|
759
|
-
encoding: 'utf-8',
|
|
760
|
-
});
|
|
761
|
-
const json = JSON.parse(proofString);
|
|
762
|
-
const fields = json
|
|
763
|
-
.slice(0, 3)
|
|
764
|
-
.map(Fr.fromHexString)
|
|
765
|
-
.concat(json.slice(3 + numPublicInputs).map(Fr.fromHexString));
|
|
766
|
-
return new RecursiveProof(
|
|
767
|
-
fields,
|
|
768
|
-
new Proof(proof.binaryProof.buffer, vk.numPublicInputs),
|
|
769
|
-
true,
|
|
770
|
-
NESTED_RECURSIVE_PROOF_LENGTH, // WORKTODO
|
|
771
|
-
);
|
|
772
|
-
};
|
|
773
|
-
return await this.runInDirectory(operation);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
708
|
/**
|
|
777
709
|
* Returns the verification key data for a circuit.
|
|
778
710
|
* @param circuitType - The type of circuit for which the verification key is required
|
|
@@ -843,6 +775,7 @@ export class BBNativeRollupProver implements ServerCircuitProver {
|
|
|
843
775
|
throw err;
|
|
844
776
|
}),
|
|
845
777
|
this.config.bbSkipCleanup,
|
|
778
|
+
logger,
|
|
846
779
|
);
|
|
847
780
|
}
|
|
848
781
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ClientIvcProof } from '@aztec/
|
|
1
|
+
import { ClientIvcProof } from '@aztec/stdlib/proofs';
|
|
2
2
|
|
|
3
3
|
import { promises as fs } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
|
|
6
|
-
export const CLIENT_IVC_VK_FILE_NAME = '
|
|
7
|
-
export const CLIENT_IVC_PROOF_FILE_NAME = '
|
|
6
|
+
export const CLIENT_IVC_VK_FILE_NAME = 'vk';
|
|
7
|
+
export const CLIENT_IVC_PROOF_FILE_NAME = 'proof';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* TODO(#7371): eventually remove client_ivc_prove_output_all_msgpack and properly handle these accumulators and VKs
|
package/src/stats.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
1
|
+
import type { ProtocolArtifact } from '@aztec/noir-protocol-circuits-types/types';
|
|
2
|
+
import type { CircuitName } from '@aztec/stdlib/stats';
|
|
3
3
|
|
|
4
4
|
export function mapProtocolArtifactNameToCircuitName(artifact: ProtocolArtifact): CircuitName {
|
|
5
5
|
switch (artifact) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ProvingRequestType } from '@aztec/stdlib/proofs';
|
|
2
|
+
|
|
3
|
+
export const WITGEN_DELAY_MS: Record<ProvingRequestType, number> = {
|
|
4
|
+
[ProvingRequestType.BASE_PARITY]: 60,
|
|
5
|
+
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: 650,
|
|
6
|
+
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: 60_000,
|
|
7
|
+
[ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP]: 0,
|
|
8
|
+
[ProvingRequestType.MERGE_ROLLUP]: 0,
|
|
9
|
+
[ProvingRequestType.PRIVATE_BASE_ROLLUP]: 400_000,
|
|
10
|
+
[ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP]: 0, // TBD
|
|
11
|
+
[ProvingRequestType.PUBLIC_BASE_ROLLUP]: 470_000,
|
|
12
|
+
[ProvingRequestType.ROOT_PARITY]: 100,
|
|
13
|
+
[ProvingRequestType.ROOT_ROLLUP]: 650,
|
|
14
|
+
[ProvingRequestType.TUBE_PROOF]: 0,
|
|
15
|
+
[ProvingRequestType.PUBLIC_VM]: 0,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const PROOF_DELAY_MS: Record<ProvingRequestType, number> = {
|
|
19
|
+
[ProvingRequestType.BASE_PARITY]: 3_000,
|
|
20
|
+
[ProvingRequestType.BLOCK_MERGE_ROLLUP]: 15_000,
|
|
21
|
+
[ProvingRequestType.BLOCK_ROOT_ROLLUP]: 55_000,
|
|
22
|
+
[ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP]: 0,
|
|
23
|
+
[ProvingRequestType.MERGE_ROLLUP]: 0,
|
|
24
|
+
[ProvingRequestType.PRIVATE_BASE_ROLLUP]: 145_000,
|
|
25
|
+
[ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP]: 0, // TBD
|
|
26
|
+
[ProvingRequestType.PUBLIC_BASE_ROLLUP]: 160_000,
|
|
27
|
+
[ProvingRequestType.ROOT_PARITY]: 30_000,
|
|
28
|
+
[ProvingRequestType.ROOT_ROLLUP]: 15_000,
|
|
29
|
+
[ProvingRequestType.TUBE_PROOF]: 30_000,
|
|
30
|
+
[ProvingRequestType.PUBLIC_VM]: 0,
|
|
31
|
+
};
|
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type ProofAndVerificationKey,
|
|
3
|
-
type PublicInputsAndRecursiveProof,
|
|
4
|
-
type ServerCircuitProver,
|
|
5
|
-
makeProofAndVerificationKey,
|
|
6
|
-
makePublicInputsAndRecursiveProof,
|
|
7
|
-
} from '@aztec/circuit-types';
|
|
8
1
|
import {
|
|
9
2
|
AVM_PROOF_LENGTH_IN_FIELDS,
|
|
10
3
|
AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS,
|
|
11
|
-
type AvmCircuitInputs,
|
|
12
|
-
type BaseParityInputs,
|
|
13
4
|
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
14
5
|
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
15
|
-
type ParityPublicInputs,
|
|
16
|
-
type Proof,
|
|
17
6
|
RECURSIVE_PROOF_LENGTH,
|
|
18
|
-
type RootParityInputs,
|
|
19
7
|
TUBE_PROOF_LENGTH,
|
|
20
|
-
|
|
21
|
-
makeEmptyRecursiveProof,
|
|
22
|
-
makeRecursiveProof,
|
|
23
|
-
} from '@aztec/circuits.js';
|
|
24
|
-
import {
|
|
25
|
-
type BaseOrMergeRollupPublicInputs,
|
|
26
|
-
type BlockMergeRollupInputs,
|
|
27
|
-
type BlockRootOrBlockMergePublicInputs,
|
|
28
|
-
type BlockRootRollupInputs,
|
|
29
|
-
type EmptyBlockRootRollupInputs,
|
|
30
|
-
type MergeRollupInputs,
|
|
31
|
-
type PrivateBaseRollupInputs,
|
|
32
|
-
type PublicBaseRollupInputs,
|
|
33
|
-
type RootRollupInputs,
|
|
34
|
-
type RootRollupPublicInputs,
|
|
35
|
-
type SingleTxBlockRootRollupInputs,
|
|
36
|
-
type TubeInputs,
|
|
37
|
-
} from '@aztec/circuits.js/rollup';
|
|
8
|
+
} from '@aztec/constants';
|
|
38
9
|
import { createLogger } from '@aztec/foundation/log';
|
|
39
10
|
import { sleep } from '@aztec/foundation/sleep';
|
|
40
11
|
import { Timer } from '@aztec/foundation/timer';
|
|
@@ -62,14 +33,50 @@ import {
|
|
|
62
33
|
convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap,
|
|
63
34
|
convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
64
35
|
} from '@aztec/noir-protocol-circuits-types/server';
|
|
65
|
-
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/vks';
|
|
36
|
+
import { ProtocolCircuitVks } from '@aztec/noir-protocol-circuits-types/server/vks';
|
|
66
37
|
import { type SimulationProvider, WASMSimulatorWithBlobs, emitCircuitSimulationStats } from '@aztec/simulator/server';
|
|
38
|
+
import type { AvmCircuitInputs } from '@aztec/stdlib/avm';
|
|
39
|
+
import {
|
|
40
|
+
type ProofAndVerificationKey,
|
|
41
|
+
type PublicInputsAndRecursiveProof,
|
|
42
|
+
type ServerCircuitProver,
|
|
43
|
+
makeProofAndVerificationKey,
|
|
44
|
+
makePublicInputsAndRecursiveProof,
|
|
45
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
46
|
+
import type { BaseParityInputs, ParityPublicInputs, RootParityInputs } from '@aztec/stdlib/parity';
|
|
47
|
+
import { type Proof, ProvingRequestType, makeEmptyRecursiveProof, makeRecursiveProof } from '@aztec/stdlib/proofs';
|
|
48
|
+
import type {
|
|
49
|
+
BaseOrMergeRollupPublicInputs,
|
|
50
|
+
BlockMergeRollupInputs,
|
|
51
|
+
BlockRootOrBlockMergePublicInputs,
|
|
52
|
+
BlockRootRollupInputs,
|
|
53
|
+
EmptyBlockRootRollupInputs,
|
|
54
|
+
MergeRollupInputs,
|
|
55
|
+
PrivateBaseRollupInputs,
|
|
56
|
+
PublicBaseRollupInputs,
|
|
57
|
+
RootRollupInputs,
|
|
58
|
+
RootRollupPublicInputs,
|
|
59
|
+
SingleTxBlockRootRollupInputs,
|
|
60
|
+
TubeInputs,
|
|
61
|
+
} from '@aztec/stdlib/rollup';
|
|
62
|
+
import { VerificationKeyData } from '@aztec/stdlib/vks';
|
|
67
63
|
import { type TelemetryClient, getTelemetryClient, trackSpan } from '@aztec/telemetry-client';
|
|
68
64
|
|
|
69
|
-
import {
|
|
65
|
+
import type { WitnessMap } from '@noir-lang/types';
|
|
70
66
|
|
|
71
67
|
import { ProverInstrumentation } from '../instrumentation.js';
|
|
72
68
|
import { mapProtocolArtifactNameToCircuitName } from '../stats.js';
|
|
69
|
+
import { PROOF_DELAY_MS, WITGEN_DELAY_MS } from './delay_values.js';
|
|
70
|
+
|
|
71
|
+
type TestDelay =
|
|
72
|
+
| {
|
|
73
|
+
proverTestDelayType: 'fixed';
|
|
74
|
+
proverTestDelayMs?: number;
|
|
75
|
+
}
|
|
76
|
+
| {
|
|
77
|
+
proverTestDelayType: 'realistic';
|
|
78
|
+
proverTestDelayFactor?: number;
|
|
79
|
+
};
|
|
73
80
|
|
|
74
81
|
/**
|
|
75
82
|
* A class for use in testing situations (e2e, unit test, etc) and temporarily for assembling a block in the sequencer.
|
|
@@ -82,7 +89,7 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
82
89
|
|
|
83
90
|
constructor(
|
|
84
91
|
private simulationProvider?: SimulationProvider,
|
|
85
|
-
private opts: {
|
|
92
|
+
private opts: TestDelay = { proverTestDelayType: 'fixed', proverTestDelayMs: 0 },
|
|
86
93
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
87
94
|
) {
|
|
88
95
|
this.instrumentation = new ProverInstrumentation(telemetry, 'TestCircuitProver');
|
|
@@ -98,15 +105,17 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
98
105
|
* @returns The public inputs of the parity circuit.
|
|
99
106
|
*/
|
|
100
107
|
@trackSpan('TestCircuitProver.getBaseParityProof')
|
|
101
|
-
public
|
|
108
|
+
public getBaseParityProof(
|
|
102
109
|
inputs: BaseParityInputs,
|
|
103
110
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof RECURSIVE_PROOF_LENGTH>> {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
return this.applyDelay(ProvingRequestType.BASE_PARITY, () =>
|
|
112
|
+
this.simulate(
|
|
113
|
+
inputs,
|
|
114
|
+
'BaseParityArtifact',
|
|
115
|
+
RECURSIVE_PROOF_LENGTH,
|
|
116
|
+
convertBaseParityInputsToWitnessMap,
|
|
117
|
+
convertBaseParityOutputsFromWitnessMap,
|
|
118
|
+
),
|
|
110
119
|
);
|
|
111
120
|
}
|
|
112
121
|
|
|
@@ -116,53 +125,57 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
116
125
|
* @returns The public inputs of the parity circuit.
|
|
117
126
|
*/
|
|
118
127
|
@trackSpan('TestCircuitProver.getRootParityProof')
|
|
119
|
-
public
|
|
128
|
+
public getRootParityProof(
|
|
120
129
|
inputs: RootParityInputs,
|
|
121
130
|
): Promise<PublicInputsAndRecursiveProof<ParityPublicInputs, typeof NESTED_RECURSIVE_PROOF_LENGTH>> {
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
131
|
+
return this.applyDelay(ProvingRequestType.ROOT_PARITY, () =>
|
|
132
|
+
this.simulate(
|
|
133
|
+
inputs,
|
|
134
|
+
'RootParityArtifact',
|
|
135
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
136
|
+
convertRootParityInputsToWitnessMap,
|
|
137
|
+
convertRootParityOutputsFromWitnessMap,
|
|
138
|
+
),
|
|
128
139
|
);
|
|
129
140
|
}
|
|
130
141
|
|
|
131
|
-
public
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
makeEmptyRecursiveProof(TUBE_PROOF_LENGTH),
|
|
135
|
-
VerificationKeyData.makeFakeRollupHonk(),
|
|
142
|
+
public getTubeProof(_tubeInput: TubeInputs): Promise<ProofAndVerificationKey<typeof TUBE_PROOF_LENGTH>> {
|
|
143
|
+
return this.applyDelay(ProvingRequestType.TUBE_PROOF, () =>
|
|
144
|
+
makeProofAndVerificationKey(makeEmptyRecursiveProof(TUBE_PROOF_LENGTH), VerificationKeyData.makeFakeRollupHonk()),
|
|
136
145
|
);
|
|
137
146
|
}
|
|
138
147
|
|
|
139
148
|
@trackSpan('TestCircuitProver.getPrivateBaseRollupProof')
|
|
140
|
-
public
|
|
149
|
+
public getPrivateBaseRollupProof(
|
|
141
150
|
inputs: PrivateBaseRollupInputs,
|
|
142
151
|
): Promise<
|
|
143
152
|
PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
144
153
|
> {
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
return this.applyDelay(ProvingRequestType.PRIVATE_BASE_ROLLUP, () =>
|
|
155
|
+
this.simulate(
|
|
156
|
+
inputs,
|
|
157
|
+
'PrivateBaseRollupArtifact',
|
|
158
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
159
|
+
convertSimulatedPrivateBaseRollupInputsToWitnessMap,
|
|
160
|
+
convertSimulatedPrivateBaseRollupOutputsFromWitnessMap,
|
|
161
|
+
),
|
|
151
162
|
);
|
|
152
163
|
}
|
|
153
164
|
|
|
154
165
|
@trackSpan('TestCircuitProver.getPublicBaseRollupProof')
|
|
155
|
-
public
|
|
166
|
+
public getPublicBaseRollupProof(
|
|
156
167
|
inputs: PublicBaseRollupInputs,
|
|
157
168
|
): Promise<
|
|
158
169
|
PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
159
170
|
> {
|
|
160
|
-
return
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_BASE_ROLLUP, () =>
|
|
172
|
+
this.simulate(
|
|
173
|
+
inputs,
|
|
174
|
+
'PublicBaseRollupArtifact',
|
|
175
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
176
|
+
convertSimulatedPublicBaseRollupInputsToWitnessMap,
|
|
177
|
+
convertSimulatedPublicBaseRollupOutputsFromWitnessMap,
|
|
178
|
+
),
|
|
166
179
|
);
|
|
167
180
|
}
|
|
168
181
|
|
|
@@ -172,17 +185,19 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
172
185
|
* @returns The public inputs as outputs of the simulation.
|
|
173
186
|
*/
|
|
174
187
|
@trackSpan('TestCircuitProver.getMergeRollupProof')
|
|
175
|
-
public
|
|
188
|
+
public getMergeRollupProof(
|
|
176
189
|
input: MergeRollupInputs,
|
|
177
190
|
): Promise<
|
|
178
191
|
PublicInputsAndRecursiveProof<BaseOrMergeRollupPublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
179
192
|
> {
|
|
180
|
-
return
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
193
|
+
return this.applyDelay(ProvingRequestType.MERGE_ROLLUP, () =>
|
|
194
|
+
this.simulate(
|
|
195
|
+
input,
|
|
196
|
+
'MergeRollupArtifact',
|
|
197
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
198
|
+
convertMergeRollupInputsToWitnessMap,
|
|
199
|
+
convertMergeRollupOutputsFromWitnessMap,
|
|
200
|
+
),
|
|
186
201
|
);
|
|
187
202
|
}
|
|
188
203
|
|
|
@@ -192,17 +207,19 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
192
207
|
* @returns The public inputs as outputs of the simulation.
|
|
193
208
|
*/
|
|
194
209
|
@trackSpan('TestCircuitProver.getBlockRootRollupProof')
|
|
195
|
-
public
|
|
210
|
+
public getBlockRootRollupProof(
|
|
196
211
|
input: BlockRootRollupInputs,
|
|
197
212
|
): Promise<
|
|
198
213
|
PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
199
214
|
> {
|
|
200
|
-
return
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
215
|
+
return this.applyDelay(ProvingRequestType.BLOCK_ROOT_ROLLUP, () =>
|
|
216
|
+
this.simulate(
|
|
217
|
+
input,
|
|
218
|
+
'BlockRootRollupArtifact',
|
|
219
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
220
|
+
convertSimulatedBlockRootRollupInputsToWitnessMap,
|
|
221
|
+
convertSimulatedBlockRootRollupOutputsFromWitnessMap,
|
|
222
|
+
),
|
|
206
223
|
);
|
|
207
224
|
}
|
|
208
225
|
|
|
@@ -212,12 +229,14 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
212
229
|
): Promise<
|
|
213
230
|
PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
214
231
|
> {
|
|
215
|
-
return await this.
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
232
|
+
return await this.applyDelay(ProvingRequestType.SINGLE_TX_BLOCK_ROOT_ROLLUP, () =>
|
|
233
|
+
this.simulate(
|
|
234
|
+
input,
|
|
235
|
+
'SingleTxBlockRootRollupArtifact',
|
|
236
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
237
|
+
convertSimulatedSingleTxBlockRootRollupInputsToWitnessMap,
|
|
238
|
+
convertSimulatedSingleTxBlockRootRollupOutputsFromWitnessMap,
|
|
239
|
+
),
|
|
221
240
|
);
|
|
222
241
|
}
|
|
223
242
|
|
|
@@ -227,17 +246,19 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
227
246
|
* @returns The public inputs as outputs of the simulation.
|
|
228
247
|
*/
|
|
229
248
|
@trackSpan('TestCircuitProver.getEmptyBlockRootRollupProof')
|
|
230
|
-
public
|
|
249
|
+
public getEmptyBlockRootRollupProof(
|
|
231
250
|
input: EmptyBlockRootRollupInputs,
|
|
232
251
|
): Promise<
|
|
233
252
|
PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
234
253
|
> {
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
254
|
+
return this.applyDelay(ProvingRequestType.EMPTY_BLOCK_ROOT_ROLLUP, () =>
|
|
255
|
+
this.simulate(
|
|
256
|
+
input,
|
|
257
|
+
'EmptyBlockRootRollupArtifact',
|
|
258
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
259
|
+
convertEmptyBlockRootRollupInputsToWitnessMap,
|
|
260
|
+
convertEmptyBlockRootRollupOutputsFromWitnessMap,
|
|
261
|
+
),
|
|
241
262
|
);
|
|
242
263
|
}
|
|
243
264
|
|
|
@@ -247,17 +268,19 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
247
268
|
* @returns The public inputs as outputs of the simulation.
|
|
248
269
|
*/
|
|
249
270
|
@trackSpan('TestCircuitProver.getBlockMergeRollupProof')
|
|
250
|
-
public
|
|
271
|
+
public getBlockMergeRollupProof(
|
|
251
272
|
input: BlockMergeRollupInputs,
|
|
252
273
|
): Promise<
|
|
253
274
|
PublicInputsAndRecursiveProof<BlockRootOrBlockMergePublicInputs, typeof NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH>
|
|
254
275
|
> {
|
|
255
|
-
return
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
276
|
+
return this.applyDelay(ProvingRequestType.BLOCK_MERGE_ROLLUP, () =>
|
|
277
|
+
this.simulate(
|
|
278
|
+
input,
|
|
279
|
+
'BlockMergeRollupArtifact',
|
|
280
|
+
NESTED_RECURSIVE_ROLLUP_HONK_PROOF_LENGTH,
|
|
281
|
+
convertBlockMergeRollupInputsToWitnessMap,
|
|
282
|
+
convertBlockMergeRollupOutputsFromWitnessMap,
|
|
283
|
+
),
|
|
261
284
|
);
|
|
262
285
|
}
|
|
263
286
|
|
|
@@ -267,35 +290,42 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
267
290
|
* @returns The public inputs as outputs of the simulation.
|
|
268
291
|
*/
|
|
269
292
|
@trackSpan('TestCircuitProver.getRootRollupProof')
|
|
270
|
-
public
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
293
|
+
public getRootRollupProof(input: RootRollupInputs): Promise<PublicInputsAndRecursiveProof<RootRollupPublicInputs>> {
|
|
294
|
+
return this.applyDelay(ProvingRequestType.ROOT_ROLLUP, () =>
|
|
295
|
+
this.simulate(
|
|
296
|
+
input,
|
|
297
|
+
'RootRollupArtifact',
|
|
298
|
+
NESTED_RECURSIVE_PROOF_LENGTH,
|
|
299
|
+
convertRootRollupInputsToWitnessMap,
|
|
300
|
+
convertRootRollupOutputsFromWitnessMap,
|
|
301
|
+
),
|
|
279
302
|
);
|
|
280
303
|
}
|
|
281
304
|
|
|
282
|
-
public
|
|
283
|
-
_inputs: AvmCircuitInputs,
|
|
284
|
-
): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> {
|
|
305
|
+
public getAvmProof(_inputs: AvmCircuitInputs): Promise<ProofAndVerificationKey<typeof AVM_PROOF_LENGTH_IN_FIELDS>> {
|
|
285
306
|
// We can't simulate the AVM because we don't have enough context to do so (e.g., DBs).
|
|
286
307
|
// We just return an empty proof and VK data.
|
|
287
308
|
this.logger.debug('Skipping AVM simulation in TestCircuitProver.');
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
309
|
+
return this.applyDelay(ProvingRequestType.PUBLIC_VM, () =>
|
|
310
|
+
makeProofAndVerificationKey(
|
|
311
|
+
makeEmptyRecursiveProof(AVM_PROOF_LENGTH_IN_FIELDS),
|
|
312
|
+
VerificationKeyData.makeFake(AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS),
|
|
313
|
+
),
|
|
292
314
|
);
|
|
293
315
|
}
|
|
294
316
|
|
|
295
|
-
private async
|
|
296
|
-
|
|
297
|
-
|
|
317
|
+
private async applyDelay<F extends () => any>(type: ProvingRequestType, fn: F): Promise<Awaited<ReturnType<F>>> {
|
|
318
|
+
const timer = new Timer();
|
|
319
|
+
const res = await fn();
|
|
320
|
+
const duration = timer.ms();
|
|
321
|
+
if (this.opts.proverTestDelayType === 'fixed') {
|
|
322
|
+
await sleep(Math.max(0, (this.opts.proverTestDelayMs ?? 0) - duration));
|
|
323
|
+
} else if (this.opts.proverTestDelayType === 'realistic') {
|
|
324
|
+
const delay = WITGEN_DELAY_MS[type] + PROOF_DELAY_MS[type];
|
|
325
|
+
await sleep(Math.max(0, delay * (this.opts.proverTestDelayFactor ?? 1) - duration));
|
|
298
326
|
}
|
|
327
|
+
|
|
328
|
+
return res;
|
|
299
329
|
}
|
|
300
330
|
|
|
301
331
|
// Not implemented for test circuits
|
|
@@ -333,7 +363,6 @@ export class TestCircuitProver implements ServerCircuitProver {
|
|
|
333
363
|
|
|
334
364
|
this.instrumentation.recordDuration('simulationDuration', circuitName, timer);
|
|
335
365
|
emitCircuitSimulationStats(circuitName, timer.ms(), input.toBuffer().length, result.toBuffer().length, this.logger);
|
|
336
|
-
await this.delay();
|
|
337
366
|
return makePublicInputsAndRecursiveProof(result, makeRecursiveProof(proofLength), ProtocolCircuitVks[artifactName]);
|
|
338
367
|
}
|
|
339
368
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
|
|
2
|
+
import type { Tx } from '@aztec/stdlib/tx';
|
|
2
3
|
|
|
3
4
|
export class TestCircuitVerifier implements ClientProtocolCircuitVerifier {
|
|
4
5
|
verifyProof(_tx: Tx): Promise<boolean> {
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
VerificationKeyData,
|
|
6
|
-
} from '@aztec/circuits.js';
|
|
7
|
-
import { hashVK } from '@aztec/circuits.js/hash';
|
|
1
|
+
import { AVM_VERIFICATION_KEY_LENGTH_IN_FIELDS } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
import { hashVK } from '@aztec/stdlib/hash';
|
|
4
|
+
import { VerificationKeyAsFields, VerificationKeyData } from '@aztec/stdlib/vks';
|
|
8
5
|
|
|
9
6
|
import { strict as assert } from 'assert';
|
|
10
7
|
import { promises as fs } from 'fs';
|