Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: multiple trace structuring configurations #7408

Merged
merged 13 commits into from
Jul 11, 2024
Merged
5 changes: 3 additions & 2 deletions barretenberg/cpp/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fi

if [ ! -d ./srs_db/grumpkin ]; then
# The Grumpkin SRS is generated manually at the moment, only up to a large enough size for tests
# If tests require more points, the parameter can be increased here.
cd ./build && cmake --build . --parallel --target grumpkin_srs_gen && ./bin/grumpkin_srs_gen 8192
# If tests require more points, the parameter can be increased here. Note: IPA requires
# dyadic_circuit_size + 1 points so in general this number will be a power of two plus 1
cd ./build && cmake --build . --parallel --target grumpkin_srs_gen && ./bin/grumpkin_srs_gen 8193
fi
7 changes: 4 additions & 3 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ void client_ivc_prove_output_all_msgpack(const std::string& bytecodePath,
}
// TODO(#7371) dedupe this with the rest of the similar code
ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::E2E_FULL_TEST;

// Accumulate the entire program stack into the IVC
for (Program& program : folding_stack) {
// auto& stack_item = program_stack.witness_stack[i];
Expand Down Expand Up @@ -395,7 +396,7 @@ bool foldAndVerifyProgram(const std::string& bytecodePath, const std::string& wi
init_grumpkin_crs(1 << 16);

ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::SMALL_TEST;

auto program_stack = acir_format::get_acir_program_stack(
bytecodePath, witnessPath, false); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013): this
Expand Down Expand Up @@ -437,7 +438,7 @@ void client_ivc_prove_output_all(const std::string& bytecodePath,
init_grumpkin_crs(1 << 16);

ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::E2E_FULL_TEST;

auto program_stack = acir_format::get_acir_program_stack(
bytecodePath, witnessPath, false); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013): this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ BENCHMARK_DEFINE_F(ClientIVCBench, Full)(benchmark::State& state)
BENCHMARK_DEFINE_F(ClientIVCBench, FullStructured)(benchmark::State& state)
{
ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::CLIENT_IVC_BENCH;

auto num_circuits = static_cast<size_t>(state.range(0));
auto precomputed_vks = precompute_verification_keys(ivc, num_circuits);
Expand Down
8 changes: 4 additions & 4 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void ClientIVC::accumulate(ClientCircuit& circuit, const std::shared_ptr<Verific
goblin.merge(circuit);

// Construct the prover instance for circuit
prover_instance = std::make_shared<ProverInstance>(circuit, structured_flag);
prover_instance = std::make_shared<ProverInstance>(circuit, trace_structure);

// Track the maximum size of each block for all circuits porcessed (for debugging purposes only)
max_block_sizes.update(circuit);
Expand Down Expand Up @@ -116,10 +116,10 @@ std::vector<std::shared_ptr<ClientIVC::VerificationKey>> ClientIVC::precompute_f
vkeys.emplace_back(instance_vk);
}

// Reset the scheme so it can be reused for actual accumulation, maintaining the structured trace flag as is
bool structured = structured_flag;
// Reset the scheme so it can be reused for actual accumulation, maintaining the trace structure setting as is
TraceStructure structure = trace_structure;
*this = ClientIVC();
this->structured_flag = structured;
this->trace_structure = structure;

return vkeys;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class ClientIVC {
std::shared_ptr<VerificationKey> instance_vk;

// A flag indicating whether or not to construct a structured trace in the ProverInstance
bool structured_flag = false;
TraceStructure trace_structure = TraceStructure::NONE;

// A flag indicating whether the IVC has been initialized with an initial instance
bool initialized = false;
Expand Down
10 changes: 5 additions & 5 deletions barretenberg/cpp/src/barretenberg/client_ivc/client_ivc.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,12 @@ TEST_F(ClientIVCTests, BasicLarge)
TEST_F(ClientIVCTests, BasicStructured)
{
ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::SMALL_TEST;

// Construct some circuits of varying size
Builder circuit_0 = create_mock_circuit(ivc, /*log2_num_gates=*/5);
Builder circuit_1 = create_mock_circuit(ivc, /*log2_num_gates=*/10);
Builder circuit_2 = create_mock_circuit(ivc, /*log2_num_gates=*/15);
Builder circuit_1 = create_mock_circuit(ivc, /*log2_num_gates=*/8);
Builder circuit_2 = create_mock_circuit(ivc, /*log2_num_gates=*/11);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to gain from having these be larger values so just making them a bit smaller


// The circuits can be accumulated as normal due to the structured trace
ivc.accumulate(circuit_0);
Expand Down Expand Up @@ -194,13 +194,13 @@ TEST_F(ClientIVCTests, PrecomputedVerificationKeys)
TEST_F(ClientIVCTests, StructuredPrecomputedVKs)
{
ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::SMALL_TEST;

// Construct a set of arbitrary circuits
size_t NUM_CIRCUITS = 3;
std::vector<Builder> circuits;
for (size_t idx = 0; idx < NUM_CIRCUITS; ++idx) {
circuits.emplace_back(create_mock_circuit(ivc));
circuits.emplace_back(create_mock_circuit(ivc, /*log2_num_gates=*/5));
}

// Precompute the (structured) verification keys that will be needed for the IVC
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ template <class Curve> class CommitmentKey {
{
BB_OP_COUNT_TIME();
const size_t degree = polynomial.size();
ASSERT(degree <= srs->get_monomial_size());
if (degree > srs->get_monomial_size()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just improving the printout here

info("Attempting to commit to a polynomial of degree ",
degree,
" with an SRS of size ",
srs->get_monomial_size());
ASSERT(false);
}
return scalar_multiplication::pippenger_unsafe<Curve>(
const_cast<Fr*>(polynomial.data()), srs->get_monomial_points(), degree, pippenger_runtime_state);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ TEST_P(AcirIntegrationFoldingTest, DISABLED_FoldAndVerifyProgramStack)
// Assumes Flavor is not UltraHonk

ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::SMALL_TEST;

while (!program_stack.empty()) {
auto program = program_stack.back();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ WASM_EXPORT void acir_fold_and_verify_program_stack(uint8_t const* acir_vec, uin
ProgramStack program_stack{ constraint_systems, witness_stack };

ClientIVC ivc;
ivc.structured_flag = true;
ivc.trace_structure = TraceStructure::SMALL_TEST;

while (!program_stack.empty()) {
auto stack_item = program_stack.back();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include "barretenberg/plonk_honk_shared/arithmetization/arithmetization.hpp"
#include "barretenberg/plonk_honk_shared/arithmetization/standard_arithmetization.hpp"
#include "barretenberg/transcript/transcript.hpp"
namespace bb::plonk {
class settings_base {
Expand Down
Loading
Loading