From 7bb24576a3f33ef49d62aa1d7dad439f28594434 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:23:22 +0000 Subject: [PATCH 01/15] comment out manifest for now --- .../cpp/src/barretenberg/transcript/transcript.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 06d09946bcc..8020ccc5fbd 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -48,9 +48,10 @@ class TranscriptManifest { } } - template void add_challenge(size_t round, Strings&... labels) + template + void add_challenge([[maybe_unused]] size_t round, [[maybe_unused]] Strings&... labels) { - manifest[round].challenge_label = { labels... }; + // manifest[round].challenge_label = { labels... }; } template void add_challenge(size_t round, std::array labels) @@ -65,9 +66,11 @@ class TranscriptManifest { call_add_challenge(); } - void add_entry(size_t round, const std::string& element_label, size_t element_size) + void add_entry([[maybe_unused]] size_t round, + [[maybe_unused]] const std::string& element_label, + [[maybe_unused]] size_t element_size) { - manifest[round].entries.emplace_back(element_label, element_size); + // manifest[round].entries.emplace_back(element_label, element_size); } [[nodiscard]] size_t size() const { return manifest.size(); } From c08599d045505463719c48b30f84ad401ea7e18b Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:23:49 +0000 Subject: [PATCH 02/15] fix tracy build --- .../cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp index 0e97f5dd05a..24f664f8158 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/decider_proving_key.cpp @@ -96,7 +96,7 @@ template void DeciderProvingKey_::allocate_select template void DeciderProvingKey_::allocate_table_lookup_polynomials(const Circuit& circuit) { - PROFILE_THIS_NAME("allocate_table_lookup_polynomials"); + PROFILE_THIS_NAME("allocate_table_lookup_and_lookup_read_polynomials"); size_t table_offset = circuit.blocks.lookup.trace_offset; // TODO(https://github.com/AztecProtocol/barretenberg/issues/1193): can potentially improve memory footprint @@ -113,7 +113,6 @@ void DeciderProvingKey_::allocate_table_lookup_polynomials(const Circuit // Allocate the read counts and tags polynomials proving_key.polynomials.lookup_read_counts = Polynomial(max_tables_size, dyadic_circuit_size, table_offset); proving_key.polynomials.lookup_read_tags = Polynomial(max_tables_size, dyadic_circuit_size, table_offset); - ZoneScopedN("allocating lookup and databus inverses"); const size_t lookup_block_end = static_cast(circuit.blocks.lookup.trace_offset + circuit.blocks.lookup.get_fixed_size(is_structured)); @@ -147,6 +146,7 @@ template void DeciderProvingKey_::allocate_databus_polynomials(const Circuit& circuit) requires HasDataBus { + PROFILE_THIS_NAME("allocate_databus_and_lookup_inverse_polynomials"); proving_key.polynomials.calldata = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); proving_key.polynomials.calldata_read_counts = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); proving_key.polynomials.calldata_read_tags = Polynomial(MAX_DATABUS_SIZE, proving_key.circuit_size); From 1290a37e9bb586921cbd235aa4fba957cd18338f Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:24:00 +0000 Subject: [PATCH 03/15] update exec pipe error output --- barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp b/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp index 5ab7fcab34b..bd8f7cda186 100644 --- a/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp +++ b/barretenberg/cpp/src/barretenberg/bb/exec_pipe.hpp @@ -8,7 +8,7 @@ inline std::vector exec_pipe(std::string const& command) { FILE* pipe = popen(command.c_str(), "r"); if (!pipe) { - throw std::runtime_error("popen() failed!"); + throw std::runtime_error("popen() failed! Can't run: " + command); } std::vector result; From a846f7a23d86c994b936bffea76083e0fefb96c1 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:24:12 +0000 Subject: [PATCH 04/15] deallocate builder before proving --- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index a3e037af23f..148c048540a 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -311,6 +311,15 @@ WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t cons *result = ClientIVC::verify(proof, vk); } +template +UltraProver_ construct_prover(acir_format::AcirProgram& program, const acir_format::ProgramMetadata& metadata) +{ + auto builder = acir_format::create_circuit(program, metadata); + + UltraProver_ prover{ builder }; + return prover; +} + WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t const* witness_vec, @@ -323,9 +332,7 @@ WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) }; - auto builder = acir_format::create_circuit(program, metadata); - - UltraProver prover{ builder }; + UltraProver prover = construct_prover(program, metadata); auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -335,14 +342,14 @@ WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { - auto constraint_system = - acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), /*honk_recursion=*/1); - auto witness = acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)); + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - auto builder = acir_format::create_circuit( - constraint_system, *recursive, 0, witness, /*honk_recursion=*/1); + acir_format::AcirProgram program{ + acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), + acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) + }; - UltraKeccakProver prover{ builder }; + UltraKeccakProver prover = construct_prover(program, metadata); auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -377,6 +384,7 @@ WASM_EXPORT void acir_verify_ultra_keccak_honk(uint8_t const* proof_buf, uint8_t *result = verifier.verify_proof(proof); } +// WORKTODO: fix memory for write_vk UH flows WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out) { using DeciderProvingKey = DeciderProvingKey_; From d20a6791b390dde482aa6be96fe9e97fe56a7bbd Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:24:30 +0000 Subject: [PATCH 05/15] reserve memory for memory_read and write records vectors --- .../barretenberg/trace_to_polynomials/trace_to_polynomials.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp index bd44c7cebc8..0b3c83cc3b8 100644 --- a/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp +++ b/barretenberg/cpp/src/barretenberg/trace_to_polynomials/trace_to_polynomials.cpp @@ -74,9 +74,11 @@ void TraceToPolynomials::add_memory_records_to_proving_key(TraceData& tr ASSERT(proving_key.memory_read_records.empty() && proving_key.memory_write_records.empty()); // Update indices of RAM/ROM reads/writes based on where block containing these gates sits in the trace + proving_key.memory_read_records.reserve(builder.memory_read_records.size()); for (auto& index : builder.memory_read_records) { proving_key.memory_read_records.emplace_back(index + trace_data.ram_rom_offset); } + proving_key.memory_write_records.reserve(builder.memory_write_records.size()); for (auto& index : builder.memory_write_records) { proving_key.memory_write_records.emplace_back(index + trace_data.ram_rom_offset); } From f0c2eacd99a8a1600ec0950fc88df2c4fc143148 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:24:44 +0000 Subject: [PATCH 06/15] free proving_key before sumcheck in wasm --- barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp index 36b534e0dcb..8b619a76b23 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/oink_prover.cpp @@ -59,10 +59,10 @@ template void OinkProver::prove() // Generate relation separators alphas for sumcheck/combiner computation proving_key->alphas = generate_alphas_round(); -#ifndef __wasm__ + // #ifndef __wasm__ // Free the commitment key proving_key->proving_key.commitment_key = nullptr; -#endif + // #endif } /** From 2a96e92e8dec722d73b0e971e6598db97ce9cbf0 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 21:45:51 +0000 Subject: [PATCH 07/15] fix bn254 srs file reading to be the num_points --- barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp index ad23caec6a4..e0eb99beb05 100644 --- a/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/get_bn254_crs.cpp @@ -41,7 +41,7 @@ std::vector get_bn254_g1_data(const std::filesystem::path& p if (g1_file_size >= num_points * 64 && g1_file_size % 64 == 0) { vinfo("using cached bn254 crs of size ", std::to_string(g1_file_size / 64), " at ", g1_path); - auto data = read_file(g1_path, g1_file_size); + auto data = read_file(g1_path, num_points * 64); auto points = std::vector(num_points); for (size_t i = 0; i < num_points; ++i) { points[i] = from_buffer(data, i * 64); From f2a88166fbd116e9794aa82afb48a99ea372ad7e Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Mon, 10 Feb 2025 22:26:51 +0000 Subject: [PATCH 08/15] add TODO to main.ts --- barretenberg/ts/src/main.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 3a492e21495..53b30dc2439 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -83,7 +83,8 @@ async function initUltraPlonk( honkRecursion = false, ) { const api = await Barretenberg.new({ threads }); - + + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraPlonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, honkRecursion, api); // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin @@ -112,8 +113,10 @@ async function initUltraPlonk( async function initUltraHonk(bytecodePath: string, recursive: boolean, crsPath: string) { const api = await Barretenberg.new({ threads }); + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, /*honkRecursion=*/ true, api); + // const circuitSize = 864047; // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize))); From c6047ba2cf51d2293af22fbf3f5e1d7b42cf9e23 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 17:29:31 +0000 Subject: [PATCH 09/15] add flag to manifest to turn it in only for specific tests and in some native and recursive verifiers --- .../eccvm/eccvm_transcript.test.cpp | 16 ++++++++++ .../src/barretenberg/eccvm/eccvm_verifier.cpp | 3 ++ .../protogalaxy/protogalaxy_verifier.cpp | 1 + .../eccvm_recursive_verifier.cpp | 2 ++ .../eccvm_recursive_verifier.test.cpp | 2 ++ .../protogalaxy_recursive_verifier.cpp | 1 + .../protogalaxy_recursive_verifier.test.cpp | 2 ++ .../barretenberg/transcript/transcript.hpp | 32 +++++++++++++++---- .../ultra_honk/mega_transcript.test.cpp | 4 +++ .../ultra_honk/ultra_transcript.test.cpp | 4 +++ .../ultra_honk/ultra_verifier.cpp | 4 ++- .../ultra_honk/ultra_verifier.hpp | 1 + 12 files changed, 64 insertions(+), 8 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp index be64494b572..2d2b096ce8b 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_transcript.test.cpp @@ -278,6 +278,8 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof ECCVMProver prover(builder); + prover.transcript->enable_manifest(); + prover.ipa_transcript->enable_manifest(); ECCVMProof proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -285,6 +287,7 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) auto prover_manifest = prover.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { ASSERT_EQ(prover_manifest[round], manifest_expected[round]) << "Prover manifest discrepency in round " << round; } @@ -293,6 +296,7 @@ TEST_F(ECCVMTranscriptTests, ProverManifestConsistency) auto prover_ipa_manifest = prover.ipa_transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(ipa_manifest_expected.size() > 0); for (size_t round = 0; round < ipa_manifest_expected.size(); ++round) { ASSERT_EQ(prover_ipa_manifest[round], ipa_manifest_expected[round]) << "IPA prover manifest discrepency in round " << round; @@ -311,6 +315,8 @@ TEST_F(ECCVMTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof ECCVMProver prover(builder); + prover.transcript->enable_manifest(); + prover.ipa_transcript->enable_manifest(); ECCVMProof proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -325,10 +331,20 @@ TEST_F(ECCVMTranscriptTests, VerifierManifestConsistency) // The last challenge generated by the ECCVM Prover is the translation univariate batching challenge and, on the // verifier side, is only generated in the translator verifier hence the ECCVM prover's manifest will have one extra // challenge + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size() - 1; ++round) { ASSERT_EQ(prover_manifest[round], verifier_manifest[round]) << "Prover/Verifier manifest discrepency in round " << round; } + + // Check consistency of IPA transcripts + auto prover_ipa_manifest = prover.ipa_transcript->get_manifest(); + auto verifier_ipa_manifest = verifier.ipa_transcript->get_manifest(); + ASSERT(prover_ipa_manifest.size() > 0); + for (size_t round = 0; round < prover_ipa_manifest.size(); ++round) { + ASSERT_EQ(prover_ipa_manifest[round], verifier_ipa_manifest[round]) + << "Prover/Verifier IPA manifest discrepency in round " << round; + } } /** diff --git a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp index 8a7d43f880b..82606aa3729 100644 --- a/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/eccvm/eccvm_verifier.cpp @@ -20,6 +20,9 @@ bool ECCVMVerifier::verify_proof(const ECCVMProof& proof) RelationParameters relation_parameters; transcript = std::make_shared(proof.pre_ipa_proof); ipa_transcript = std::make_shared(proof.ipa_proof); + transcript->enable_manifest(); + ipa_transcript->enable_manifest(); + VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp index 3d7cbec843d..b4eadf05b82 100644 --- a/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/protogalaxy/protogalaxy_verifier.cpp @@ -19,6 +19,7 @@ void ProtogalaxyVerifier_::run_oink_verifier_on_each_in const std::vector& proof) { transcript = std::make_shared(proof); + transcript->enable_manifest(); size_t index = 0; auto key = keys_to_fold[0]; auto domain_separator = std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp index 101dc7067a7..078049b831e 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.cpp @@ -34,6 +34,8 @@ ECCVMRecursiveVerifier_::verify_proof(const ECCVMProof& proof) StdlibProof stdlib_ipa_proof = bb::convert_native_proof_to_stdlib(builder, proof.ipa_proof); transcript = std::make_shared(stdlib_proof); ipa_transcript = std::make_shared(stdlib_ipa_proof); + transcript->enable_manifest(); + ipa_transcript->enable_manifest(); VerifierCommitments commitments{ key }; CommitmentLabels commitment_labels; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp index 88dadca1976..8fb03176910 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp @@ -102,6 +102,8 @@ template class ECCVMRecursiveTests : public ::testing EXPECT_TRUE(native_result); auto recursive_manifest = verifier.transcript->get_manifest(); auto native_manifest = native_verifier.transcript->get_manifest(); + + EXPECT(recursive_manifest.size() > 0); for (size_t i = 0; i < recursive_manifest.size(); ++i) { EXPECT_EQ(recursive_manifest[i], native_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp index 607f7b17f17..1e1a93aeae9 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.cpp @@ -19,6 +19,7 @@ void ProtogalaxyRecursiveVerifier_::run_oink_verifier_o const std::vector& proof) { transcript = std::make_shared(proof); + transcript->enable_manifest(); size_t index = 0; auto key = keys_to_fold[0]; auto domain_separator = std::to_string(index); diff --git a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp index 18e8643ab3b..40f31064e90 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/protogalaxy_verifier/protogalaxy_recursive_verifier.test.cpp @@ -238,6 +238,7 @@ template class ProtogalaxyRecursiveTests : public tes auto recursive_folding_manifest = verifier.transcript->get_manifest(); auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); + ASSERT(recursive_folding_manifest.size() > 0); for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; @@ -316,6 +317,7 @@ template class ProtogalaxyRecursiveTests : public tes auto recursive_folding_manifest = verifier.transcript->get_manifest(); auto native_folding_manifest = native_folding_verifier.transcript->get_manifest(); + ASSERT(recursive_folding_manifest.size() > 0); for (size_t i = 0; i < recursive_folding_manifest.size(); ++i) { EXPECT_EQ(recursive_folding_manifest[i], native_folding_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index 8020ccc5fbd..f52a7fcea3b 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -51,7 +51,7 @@ class TranscriptManifest { template void add_challenge([[maybe_unused]] size_t round, [[maybe_unused]] Strings&... labels) { - // manifest[round].challenge_label = { labels... }; + manifest[round].challenge_label = { labels... }; } template void add_challenge(size_t round, std::array labels) @@ -70,7 +70,7 @@ class TranscriptManifest { [[maybe_unused]] const std::string& element_label, [[maybe_unused]] size_t element_size) { - // manifest[round].entries.emplace_back(element_label, element_size); + manifest[round].entries.emplace_back(element_label, element_size); } [[nodiscard]] size_t size() const { return manifest.size(); } @@ -153,6 +153,8 @@ template class BaseTranscript { Fr previous_challenge{}; // default-initialized to zeros std::vector current_round_data; + bool use_manifest = false; // indicates whether the manifest is turned on, currently only on for manifest tests. + // "Manifest" object that records a summary of the transcript interactions TranscriptManifest manifest; @@ -214,8 +216,10 @@ template class BaseTranscript { */ void consume_prover_element_frs(const std::string& label, std::span element_frs) { - // Add an entry to the current round of the manifest - manifest.add_entry(round_number, label, element_frs.size()); + if (use_manifest) { + // Add an entry to the current round of the manifest + manifest.add_entry(round_number, label, element_frs.size()); + } current_round_data.insert(current_round_data.end(), element_frs.begin(), element_frs.end()); @@ -279,6 +283,12 @@ template class BaseTranscript { std::copy(proof.begin(), proof.end(), std::back_inserter(proof_data)); } + /** + * @brief Enables the manifest + * + */ + void enable_manifest() { use_manifest = true; } + /** * @brief After all the prover messages have been sent, finalize the round by hashing all the data and then * create the number of requested challenges. @@ -293,8 +303,10 @@ template class BaseTranscript { { constexpr size_t num_challenges = sizeof...(Strings); - // Add challenge labels for current round to the manifest - manifest.add_challenge(round_number, labels...); + if (use_manifest) { + // Add challenge labels for current round to the manifest + manifest.add_challenge(round_number, labels...); + } // Compute the new challenge buffer from which we derive the challenges. @@ -441,7 +453,13 @@ template class BaseTranscript { [[nodiscard]] TranscriptManifest get_manifest() const { return manifest; }; - void print() { manifest.print(); } + void print() + { + if (!use_manifest) { + info("Warning: manifest is not enabled!"); + } + manifest.print(); + } }; template diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp index 17c558b1c85..b3fe19b10b6 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/mega_transcript.test.cpp @@ -193,12 +193,14 @@ TYPED_TEST(MegaTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto proving_key = std::make_shared(builder); Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite auto manifest_expected = TestFixture::construct_mega_honk_manifest(); auto prover_manifest = prover.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { if (prover_manifest[round] != manifest_expected[round]) { info("Prover manifest discrepency in round ", round); @@ -229,6 +231,7 @@ TYPED_TEST(MegaTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto proving_key = std::make_shared(builder); Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -242,6 +245,7 @@ TYPED_TEST(MegaTranscriptTests, VerifierManifestConsistency) auto verifier_manifest = verifier.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size(); ++round) { if (prover_manifest[round] != verifier_manifest[round]) { info("Prover/Verifier manifest discrepency in round ", round); diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp index 2f61e40aa92..26aefc31c46 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_transcript.test.cpp @@ -200,6 +200,7 @@ TYPED_TEST(UltraTranscriptTests, ProverManifestConsistency) // Automatically generate a transcript manifest by constructing a proof auto proving_key = std::make_shared(builder); typename TestFixture::Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Check that the prover generated manifest agrees with the manifest hard coded in this suite @@ -208,6 +209,7 @@ TYPED_TEST(UltraTranscriptTests, ProverManifestConsistency) // Note: a manifest can be printed using manifest.print() manifest_expected.print(); prover_manifest.print(); + ASSERT(manifest_expected.size() > 0); for (size_t round = 0; round < manifest_expected.size(); ++round) { ASSERT_EQ(prover_manifest[round], manifest_expected[round]) << "Prover manifest discrepency in round " << round; } @@ -228,6 +230,7 @@ TYPED_TEST(UltraTranscriptTests, VerifierManifestConsistency) // Automatically generate a transcript manifest in the prover by constructing a proof auto proving_key = std::make_shared(builder); typename TestFixture::Prover prover(proving_key); + prover.transcript->enable_manifest(); auto proof = prover.construct_proof(); // Automatically generate a transcript manifest in the verifier by verifying a proof @@ -258,6 +261,7 @@ TYPED_TEST(UltraTranscriptTests, VerifierManifestConsistency) auto verifier_manifest = verifier.transcript->get_manifest(); // Note: a manifest can be printed using manifest.print() + ASSERT(prover_manifest.size() > 0); for (size_t round = 0; round < prover_manifest.size(); ++round) { ASSERT_EQ(prover_manifest[round], verifier_manifest[round]) << "Prover/Verifier manifest discrepency in round " << round; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp index 692ac54397f..2c10eef26e3 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.cpp @@ -15,6 +15,7 @@ template bool UltraVerifier_::verify_proof(const HonkP using FF = typename Flavor::FF; transcript = std::make_shared(proof); + transcript->enable_manifest(); // Enable manifest for the verifier. OinkVerifier oink_verifier{ verification_key, transcript }; oink_verifier.verify(); @@ -58,7 +59,8 @@ template bool UltraVerifier_::verify_proof(const HonkP }; // verify the ipa_proof with this claim - auto ipa_transcript = std::make_shared(ipa_proof); + ipa_transcript = std::make_shared(ipa_proof); + ipa_transcript->enable_manifest(); // Enable manifest for the verifier. bool ipa_result = IPA::reduce_verify(ipa_verification_key, ipa_claim, ipa_transcript); if (!ipa_result) { return false; diff --git a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp index effd6a3de94..884bd6ecb90 100644 --- a/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp +++ b/barretenberg/cpp/src/barretenberg/ultra_honk/ultra_verifier.hpp @@ -27,6 +27,7 @@ template class UltraVerifier_ { bool verify_proof(const HonkProof& proof, const HonkProof& ipa_proof = {}); std::shared_ptr transcript{ nullptr }; + std::shared_ptr ipa_transcript{ nullptr }; std::shared_ptr verification_key; std::shared_ptr> ipa_verification_key; }; From 6e97025e81d961e3a3322b42d711e95631d5849f Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 18:04:34 +0000 Subject: [PATCH 10/15] cleanup --- .../cpp/src/barretenberg/transcript/transcript.hpp | 7 ++----- barretenberg/ts/src/main.ts | 1 - 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp index f52a7fcea3b..032bc847294 100644 --- a/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp +++ b/barretenberg/cpp/src/barretenberg/transcript/transcript.hpp @@ -48,8 +48,7 @@ class TranscriptManifest { } } - template - void add_challenge([[maybe_unused]] size_t round, [[maybe_unused]] Strings&... labels) + template void add_challenge(size_t round, Strings&... labels) { manifest[round].challenge_label = { labels... }; } @@ -66,9 +65,7 @@ class TranscriptManifest { call_add_challenge(); } - void add_entry([[maybe_unused]] size_t round, - [[maybe_unused]] const std::string& element_label, - [[maybe_unused]] size_t element_size) + void add_entry(size_t round, const std::string& element_label, size_t element_size) { manifest[round].entries.emplace_back(element_label, element_size); } diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index 53b30dc2439..f65db00fbbb 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -116,7 +116,6 @@ async function initUltraHonk(bytecodePath: string, recursive: boolean, crsPath: // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraHonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, /*honkRecursion=*/ true, api); - // const circuitSize = 864047; // TODO(https://github.com/AztecProtocol/barretenberg/issues/811): remove subgroupSizeOverride hack for goblin const dyadicCircuitSize = Math.pow(2, Math.ceil(Math.log2(circuitSize))); From 111c657eff892fd6c2370cf36d9b61f5935eb831 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 18:04:43 +0000 Subject: [PATCH 11/15] fix build --- .../stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp index 8fb03176910..76ec71551ad 100644 --- a/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp +++ b/barretenberg/cpp/src/barretenberg/stdlib/eccvm_verifier/eccvm_recursive_verifier.test.cpp @@ -103,7 +103,7 @@ template class ECCVMRecursiveTests : public ::testing auto recursive_manifest = verifier.transcript->get_manifest(); auto native_manifest = native_verifier.transcript->get_manifest(); - EXPECT(recursive_manifest.size() > 0); + ASSERT(recursive_manifest.size() > 0); for (size_t i = 0; i < recursive_manifest.size(); ++i) { EXPECT_EQ(recursive_manifest[i], native_manifest[i]) << "Recursive Verifier/Verifier manifest discrepency in round " << i; From 80d0631356769365702758195b4b0fb3e1fc290e Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 18:06:14 +0000 Subject: [PATCH 12/15] use lambdas to properly free pre-proving data --- .../barretenberg/dsl/acir_proofs/c_bind.cpp | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index 148c048540a..bc52ff4dc63 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -311,28 +311,23 @@ WASM_EXPORT void acir_verify_aztec_client(uint8_t const* proof_buf, uint8_t cons *result = ClientIVC::verify(proof, vk); } -template -UltraProver_ construct_prover(acir_format::AcirProgram& program, const acir_format::ProgramMetadata& metadata) -{ - auto builder = acir_format::create_circuit(program, metadata); - - UltraProver_ prover{ builder }; - return prover; -} - WASM_EXPORT void acir_prove_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t const* witness_vec, uint8_t** out) { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ - acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), - acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) - }; + // Lambda function to ensure things get freed before proving. + UltraProver prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion), + acir_format::witness_buf_to_witness_data( + from_buffer>(witness_vec)) }; + auto builder = acir_format::create_circuit(program, metadata); + + return UltraProver(builder); + }(); - UltraProver prover = construct_prover(program, metadata); auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -342,14 +337,17 @@ WASM_EXPORT void acir_prove_ultra_keccak_honk(uint8_t const* acir_vec, uint8_t const* witness_vec, uint8_t** out) { - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ - acir_format::circuit_buf_to_acir_format(from_buffer>(acir_vec), metadata.honk_recursion), - acir_format::witness_buf_to_witness_data(from_buffer>(witness_vec)) - }; - - UltraKeccakProver prover = construct_prover(program, metadata); + // Lambda function to ensure things get freed before proving. + UltraKeccakProver prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion), + acir_format::witness_buf_to_witness_data( + from_buffer>(witness_vec)) }; + auto builder = acir_format::create_circuit(program, metadata); + + return UltraKeccakProver(builder); + }(); auto proof = prover.construct_proof(); *out = to_heap_buffer(to_buffer(proof)); } @@ -384,19 +382,18 @@ WASM_EXPORT void acir_verify_ultra_keccak_honk(uint8_t const* proof_buf, uint8_t *result = verifier.verify_proof(proof); } -// WORKTODO: fix memory for write_vk UH flows WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* recursive, uint8_t** out) { using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraFlavor::VerificationKey; - - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - - acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( - from_buffer>(acir_vec), metadata.honk_recursion) }; - auto builder = acir_format::create_circuit(program, metadata); - - DeciderProvingKey proving_key(builder); + // lambda to free the builder + DeciderProvingKey proving_key = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion) }; + auto builder = acir_format::create_circuit(program, metadata); + return DeciderProvingKey(builder); + }(); VerificationKey vk(proving_key.proving_key); *out = to_heap_buffer(to_buffer(vk)); } @@ -408,11 +405,14 @@ WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool c const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( - from_buffer>(acir_vec), metadata.honk_recursion) }; - auto builder = acir_format::create_circuit(program, metadata); - - DeciderProvingKey proving_key(builder); + // lambda to free the builder + DeciderProvingKey proving_key = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; + acir_format::AcirProgram program{ acir_format::circuit_buf_to_acir_format( + from_buffer>(acir_vec), metadata.honk_recursion) }; + auto builder = acir_format::create_circuit(program, metadata); + return DeciderProvingKey(builder); + }(); VerificationKey vk(proving_key.proving_key); *out = to_heap_buffer(to_buffer(vk)); } From a3491d992543a56d1db8f785480bdda471d0498d Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 21:48:41 +0000 Subject: [PATCH 13/15] free builder before vk construction in main.cpp --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 17 ++++++++++------- .../src/barretenberg/dsl/acir_proofs/c_bind.cpp | 4 ++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index f9d45093549..89d6c9dcb8d 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -910,17 +910,20 @@ UltraProver_ compute_valid_prover(const std::string& bytecodePath, } else if constexpr (IsAnyOf) { honk_recursion = 2; } - const acir_format::ProgramMetadata metadata{ .recursive = recursive, .honk_recursion = honk_recursion }; - acir_format::AcirProgram program{ get_constraint_system(bytecodePath, metadata.honk_recursion) }; - if (!witnessPath.empty()) { - program.witness = get_witness(witnessPath); - } // TODO(https://github.com/AztecProtocol/barretenberg/issues/1180): Don't init grumpkin crs when unnecessary. init_grumpkin_crs(1 << CONST_ECCVM_LOG_N); - auto builder = acir_format::create_circuit(program, metadata); - auto prover = Prover{ builder }; + auto prover = [&] { + const acir_format::ProgramMetadata metadata{ .recursive = recursive, .honk_recursion = honk_recursion }; + acir_format::AcirProgram program{ get_constraint_system(bytecodePath, metadata.honk_recursion) }; + if (!witnessPath.empty()) { + program.witness = get_witness(witnessPath); + } + auto builder = acir_format::create_circuit(program, metadata); + return Prover{ builder }; + }(); + size_t required_crs_size = prover.proving_key->proving_key.circuit_size; if constexpr (Flavor::HasZK) { // Ensure there are enough points to commit to the libra polynomials required for zero-knowledge sumcheck diff --git a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp index bc52ff4dc63..980c57eec92 100644 --- a/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp +++ b/barretenberg/cpp/src/barretenberg/dsl/acir_proofs/c_bind.cpp @@ -395,6 +395,7 @@ WASM_EXPORT void acir_write_vk_ultra_honk(uint8_t const* acir_vec, bool const* r return DeciderProvingKey(builder); }(); VerificationKey vk(proving_key.proving_key); + vinfo("Constructed UltraHonk verification key"); *out = to_heap_buffer(to_buffer(vk)); } @@ -403,8 +404,6 @@ WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool c using DeciderProvingKey = DeciderProvingKey_; using VerificationKey = UltraKeccakFlavor::VerificationKey; - const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; - // lambda to free the builder DeciderProvingKey proving_key = [&] { const acir_format::ProgramMetadata metadata{ .recursive = *recursive, .honk_recursion = 1 }; @@ -414,6 +413,7 @@ WASM_EXPORT void acir_write_vk_ultra_keccak_honk(uint8_t const* acir_vec, bool c return DeciderProvingKey(builder); }(); VerificationKey vk(proving_key.proving_key); + vinfo("Constructed UltraKeccakHonk verification key"); *out = to_heap_buffer(to_buffer(vk)); } From a5e7bf9350315e3ae8c3cc146d8a6d9ccf17a04c Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Tue, 11 Feb 2025 22:06:42 +0000 Subject: [PATCH 14/15] fix yarn formatting --- barretenberg/ts/src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/barretenberg/ts/src/main.ts b/barretenberg/ts/src/main.ts index f65db00fbbb..da73d019bb0 100755 --- a/barretenberg/ts/src/main.ts +++ b/barretenberg/ts/src/main.ts @@ -83,7 +83,7 @@ async function initUltraPlonk( honkRecursion = false, ) { const api = await Barretenberg.new({ threads }); - + // TODO(https://github.com/AztecProtocol/barretenberg/issues/1248): Get rid of this call to avoid building the circuit twice. // TODO(https://github.com/AztecProtocol/barretenberg/issues/1126): use specific UltraPlonk function const circuitSize = await getGatesUltra(bytecodePath, recursive, honkRecursion, api); From c3e82b2282b36b0b938e6524736ba022a7c0ebc2 Mon Sep 17 00:00:00 2001 From: lucasxia01 Date: Wed, 12 Feb 2025 00:14:45 +0000 Subject: [PATCH 15/15] add comment --- barretenberg/cpp/src/barretenberg/bb/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/barretenberg/cpp/src/barretenberg/bb/main.cpp b/barretenberg/cpp/src/barretenberg/bb/main.cpp index 89d6c9dcb8d..8412faee038 100644 --- a/barretenberg/cpp/src/barretenberg/bb/main.cpp +++ b/barretenberg/cpp/src/barretenberg/bb/main.cpp @@ -914,6 +914,9 @@ UltraProver_ compute_valid_prover(const std::string& bytecodePath, // TODO(https://github.com/AztecProtocol/barretenberg/issues/1180): Don't init grumpkin crs when unnecessary. init_grumpkin_crs(1 << CONST_ECCVM_LOG_N); + // Lambda function to ensure the builder gets freed before generating the vk. Vk generation requires initialing the + // pippenger runtime state which leads to it being the peak, when its functionality is purely for debugging purposes + // here. auto prover = [&] { const acir_format::ProgramMetadata metadata{ .recursive = recursive, .honk_recursion = honk_recursion }; acir_format::AcirProgram program{ get_constraint_system(bytecodePath, metadata.honk_recursion) };