Skip to content

Commit ac95729

Browse files
authored
chore: delete honk_recursion for building ACIR (#13664)
Closes AztecProtocol/barretenberg#1013 in the context for building ACIR. When we updated verify_proof_with_type to no longer default to plonk proofs, we forgot to also delete some hacky code wrt using the honk_recursion flag for figuring out which recursive verifier to use. Since we always receive the proof type through the actual constraint, there's no need to use the honk_recursion flag to pick this out, so it can be completely removed for this context.
1 parent ae578a2 commit ac95729

File tree

11 files changed

+57
-96
lines changed

11 files changed

+57
-96
lines changed

barretenberg/cpp/src/barretenberg/api/acir_format_getters.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ acir_format::WitnessVector get_witness(std::string const& witness_path)
1111
return acir_format::witness_buf_to_witness_data(witness_data);
1212
}
1313

14-
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path, uint32_t honk_recursion)
14+
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path)
1515
{
1616
auto bytecode = get_bytecode(bytecode_path);
17-
return acir_format::circuit_buf_to_acir_format(bytecode, honk_recursion);
17+
return acir_format::circuit_buf_to_acir_format(bytecode);
1818
}
1919

2020
acir_format::WitnessVectorStack get_witness_stack(std::string const& witness_path)
@@ -23,10 +23,10 @@ acir_format::WitnessVectorStack get_witness_stack(std::string const& witness_pat
2323
return acir_format::witness_buf_to_witness_stack(witness_data);
2424
}
2525

26-
std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path, uint32_t honk_recursion)
26+
std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path)
2727
{
2828
auto bytecode = get_bytecode(bytecode_path);
29-
return acir_format::program_buf_to_acir_format(bytecode, honk_recursion);
29+
return acir_format::program_buf_to_acir_format(bytecode);
3030
}
3131

3232
} // namespace bb

barretenberg/cpp/src/barretenberg/api/acir_format_getters.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace bb {
66
acir_format::WitnessVector get_witness(std::string const& witness_path);
7-
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path, uint32_t honk_recursion);
7+
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path);
88
acir_format::WitnessVectorStack get_witness_stack(std::string const& witness_path);
9-
std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path, uint32_t honk_recursion);
9+
std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path);
1010
} // namespace bb

barretenberg/cpp/src/barretenberg/api/api_client_ivc.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void write_standalone_vk(const std::string& output_data_type,
5858
init_bn254_crs(1 << CONST_PG_LOG_N);
5959
init_grumpkin_crs(1 << CONST_ECCVM_LOG_N);
6060

61-
Program program{ get_constraint_system(bytecode_path, /*honk_recursion=*/0), /*witness=*/{} };
61+
Program program{ get_constraint_system(bytecode_path), /*witness=*/{} };
6262
auto& ivc_constraints = program.constraints.ivc_recursion_constraints;
6363

6464
TraceSettings trace_settings{ AZTEC_TRACE_STRUCTURE };
@@ -88,7 +88,7 @@ size_t get_num_public_inputs_in_final_circuit(const std::filesystem::path& input
8888
auto steps = PrivateExecutionStepRaw::load_and_decompress(input_path);
8989
const PrivateExecutionStepRaw& last_step = steps.back();
9090
std::vector<uint8_t> bytecode_buf(last_step.bytecode.begin(), last_step.bytecode.end());
91-
const AcirFormat constraints = circuit_buf_to_acir_format(bytecode_buf, /*honk_recursion=*/0);
91+
const AcirFormat constraints = circuit_buf_to_acir_format(bytecode_buf);
9292
return constraints.public_inputs.size();
9393
}
9494

@@ -246,7 +246,7 @@ void gate_count_for_ivc(const std::string& bytecode_path, bool include_gates_per
246246
// All circuit reports will be built into the std::string below
247247
std::string functions_string = "{\"functions\": [\n ";
248248
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1181): Use enum for honk_recursion.
249-
auto constraint_systems = get_constraint_systems(bytecode_path, /*honk_recursion=*/0);
249+
auto constraint_systems = get_constraint_systems(bytecode_path);
250250

251251
// Initialize an SRS to make the ClientIVC constructor happy
252252
init_bn254_crs(1 << CONST_PG_LOG_N);

barretenberg/cpp/src/barretenberg/api/api_ultra_honk.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Circuit _compute_circuit(const std::string& bytecode_path, const std::string& wi
3232
init_grumpkin_crs(1 << CONST_ECCVM_LOG_N);
3333

3434
const acir_format::ProgramMetadata metadata{ .honk_recursion = honk_recursion };
35-
acir_format::AcirProgram program{ get_constraint_system(bytecode_path, metadata.honk_recursion) };
35+
acir_format::AcirProgram program{ get_constraint_system(bytecode_path) };
3636

3737
if (!witness_path.empty()) {
3838
program.witness = get_witness(witness_path);
@@ -270,7 +270,7 @@ void write_recursion_inputs_ultra_honk(const std::string& bytecode_path,
270270
const acir_format::ProgramMetadata metadata{ .honk_recursion = honk_recursion };
271271

272272
acir_format::AcirProgram program;
273-
program.constraints = get_constraint_system(bytecode_path, metadata.honk_recursion);
273+
program.constraints = get_constraint_system(bytecode_path);
274274
program.witness = get_witness(witness_path);
275275
auto builder = acir_format::create_circuit<Builder>(program, metadata);
276276

barretenberg/cpp/src/barretenberg/api/api_ultra_plonk.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void prove_ultra_plonk(const std::string& bytecode_path,
5454
const std::string& output_path,
5555
const bool recursive)
5656
{
57-
auto constraint_system = get_constraint_system(bytecode_path, /*honk_recursion=*/0);
57+
auto constraint_system = get_constraint_system(bytecode_path);
5858
auto witness = get_witness(witness_path);
5959

6060
acir_proofs::AcirComposer acir_composer{ 0, verbose_logging };
@@ -88,7 +88,7 @@ void prove_output_all_ultra_plonk(const std::string& bytecode_path,
8888
const std::string& output_path,
8989
const bool recursive)
9090
{
91-
auto constraint_system = get_constraint_system(bytecode_path, /*honk_recursion=*/0);
91+
auto constraint_system = get_constraint_system(bytecode_path);
9292
auto witness = get_witness(witness_path);
9393

9494
acir_proofs::AcirComposer acir_composer{ 0, verbose_logging };
@@ -172,7 +172,7 @@ bool prove_and_verify_ultra_plonk(const std::string& bytecode_path,
172172
const bool recursive,
173173
const std::string& witness_path)
174174
{
175-
auto constraint_system = get_constraint_system(bytecode_path, /*honk_recursion=*/0);
175+
auto constraint_system = get_constraint_system(bytecode_path);
176176
auto witness = get_witness(witness_path);
177177

178178
acir_proofs::AcirComposer acir_composer{ 0, verbose_logging };
@@ -234,7 +234,7 @@ void contract_ultra_plonk(const std::string& output_path, const std::string& vk_
234234
*/
235235
void write_vk_ultra_plonk(const std::string& bytecode_path, const std::string& output_path, const bool recursive)
236236
{
237-
auto constraint_system = get_constraint_system(bytecode_path, false);
237+
auto constraint_system = get_constraint_system(bytecode_path);
238238
acir_proofs::AcirComposer acir_composer{ 0, verbose_logging };
239239
acir_composer.create_finalized_circuit(constraint_system, recursive);
240240
acir_composer.finalize_circuit();
@@ -253,7 +253,7 @@ void write_vk_ultra_plonk(const std::string& bytecode_path, const std::string& o
253253

254254
void write_pk_ultra_plonk(const std::string& bytecode_path, const std::string& output_path, const bool recursive)
255255
{
256-
auto constraint_system = get_constraint_system(bytecode_path, /*honk_recursion=*/0);
256+
auto constraint_system = get_constraint_system(bytecode_path);
257257
acir_proofs::AcirComposer acir_composer{ 0, verbose_logging };
258258
acir_composer.create_finalized_circuit(constraint_system, recursive);
259259
acir_composer.finalize_circuit();

barretenberg/cpp/src/barretenberg/api/gate_count.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void gate_count(const std::string& bytecode_path,
2525

2626
// All circuit reports will be built into the string below
2727
std::string functions_string = "{\"functions\": [\n ";
28-
auto constraint_systems = get_constraint_systems(bytecode_path, honk_recursion);
28+
auto constraint_systems = get_constraint_systems(bytecode_path);
2929

3030
const acir_format::ProgramMetadata metadata{ .recursive = recursive,
3131
.honk_recursion = honk_recursion,

barretenberg/cpp/src/barretenberg/client_ivc/private_execution_steps.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ void PrivateExecutionSteps::parse(const std::vector<PrivateExecutionStepRaw>& st
8080
// use spans instead of vectors.
8181
std::vector<uint8_t> bytecode_buf(step.bytecode.begin(), step.bytecode.end());
8282
std::vector<uint8_t> witness_buf(step.witness.begin(), step.witness.end());
83-
acir_format::AcirFormat constraints =
84-
acir_format::circuit_buf_to_acir_format(bytecode_buf, /*honk_recursion=*/0);
83+
acir_format::AcirFormat constraints = acir_format::circuit_buf_to_acir_format(bytecode_buf);
8584
acir_format::WitnessVector witness = acir_format::witness_buf_to_witness_data(witness_buf);
8685

8786
folding_stack.push_back({ constraints, witness });

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_integration.test.cpp

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,24 @@ class AcirIntegrationTest : public ::testing::Test {
2929
}
3030

3131
// Function to check if a file exists
32-
bool file_exists(const std::string& path)
32+
static bool file_exists(const std::string& path)
3333
{
3434
std::ifstream file(path);
3535
return file.good();
3636
}
3737

38-
acir_format::AcirProgramStack get_program_stack_data_from_test_file(const std::string& test_program_name,
39-
uint32_t honk_recursion = 0)
38+
static acir_format::AcirProgramStack get_program_stack_data_from_test_file(const std::string& test_program_name)
4039
{
4140
std::string base_path = "../../acir_tests/acir_tests/" + test_program_name + "/target";
4241
std::string bytecode_path = base_path + "/program.json";
4342
std::string witness_path = base_path + "/witness.gz";
4443

45-
return acir_format::get_acir_program_stack(bytecode_path, witness_path, honk_recursion);
44+
return acir_format::get_acir_program_stack(bytecode_path, witness_path);
4645
}
4746

48-
acir_format::AcirProgram get_program_data_from_test_file(const std::string& test_program_name,
49-
uint32_t honk_recursion = 0)
47+
static acir_format::AcirProgram get_program_data_from_test_file(const std::string& test_program_name)
5048
{
51-
auto program_stack = get_program_stack_data_from_test_file(test_program_name, honk_recursion);
49+
auto program_stack = get_program_stack_data_from_test_file(test_program_name);
5250
ASSERT(program_stack.size() == 1); // Otherwise this method will not return full stack data
5351

5452
return program_stack.back();
@@ -148,10 +146,7 @@ TEST_P(AcirIntegrationSingleTest, DISABLED_ProveAndVerifyProgram)
148146

149147
std::string test_name = GetParam();
150148
info("Test: ", test_name);
151-
acir_format::AcirProgram acir_program = get_program_data_from_test_file(
152-
test_name,
153-
/*honk_recursion=*/0); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013):
154-
// Assumes Flavor is not UltraHonk
149+
acir_format::AcirProgram acir_program = get_program_data_from_test_file(test_name);
155150

156151
// Construct a bberg circuit from the acir representation
157152
Builder builder = acir_format::create_circuit<Builder>(acir_program);
@@ -371,9 +366,7 @@ TEST_P(AcirIntegrationFoldingTest, DISABLED_ProveAndVerifyProgramStack)
371366
std::string test_name = GetParam();
372367
info("Test: ", test_name);
373368

374-
auto program_stack = get_program_stack_data_from_test_file(
375-
test_name, /*honk_recursion=*/0); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013):
376-
// Assumes Flavor is not UltraHonk
369+
auto program_stack = get_program_stack_data_from_test_file(test_name);
377370

378371
while (!program_stack.empty()) {
379372
auto program = program_stack.back();
@@ -479,9 +472,7 @@ TEST_F(AcirIntegrationTest, DISABLED_UpdateAcirCircuit)
479472
using Builder = Flavor::CircuitBuilder;
480473

481474
std::string test_name = "6_array"; // arbitrary program with RAM gates
482-
auto acir_program = get_program_data_from_test_file(
483-
test_name, /*honk_recursion=*/0); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013):
484-
// Assumes Flavor is not UltraHonk
475+
auto acir_program = get_program_data_from_test_file(test_name);
485476

486477
// Construct a bberg circuit from the acir representation
487478
Builder circuit = acir_format::create_circuit<Builder>(acir_program);
@@ -514,12 +505,8 @@ TEST_F(AcirIntegrationTest, DISABLED_HonkRecursion)
514505
using Flavor = UltraFlavor;
515506
using Builder = Flavor::CircuitBuilder;
516507

517-
std::string test_name = "verify_honk_proof"; // arbitrary program with RAM gates
518-
// Note: honk_recursion set to 1 here we are using the UltraFlavor.
519-
// The honk_recursion flag determines whether a noir program will be recursively verified via Honk in a Noir
520-
// program.
521-
auto acir_program = get_program_data_from_test_file(test_name,
522-
/*honk_recursion=*/1);
508+
std::string test_name = "verify_honk_proof"; // program that recursively verifies a honk proof
509+
auto acir_program = get_program_data_from_test_file(test_name);
523510

524511
// Construct a bberg circuit from the acir representation
525512
Builder circuit = acir_format::create_circuit<Builder>(acir_program);

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.cpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -548,10 +548,7 @@ WitnessOrConstant<bb::fr> parse_input(Acir::FunctionInput input)
548548
return result;
549549
}
550550

551-
void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg,
552-
AcirFormat& af,
553-
uint32_t honk_recursion,
554-
size_t opcode_index)
551+
void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg, AcirFormat& af, size_t opcode_index)
555552
{
556553
std::visit(
557554
[&](auto&& arg) {
@@ -722,17 +719,6 @@ void handle_blackbox_func_call(Acir::Opcode::BlackBoxFuncCall const& arg,
722719
auto input_key = get_witness_from_function_input(arg.key_hash);
723720

724721
auto proof_type_in = arg.proof_type;
725-
// TODO(https://github.com/AztecProtocol/barretenberg/issues/1074): Eventually arg.proof_type will
726-
// be the only means for setting the proof type. use of honk_recursion flag in this context can go
727-
// away once all noir programs (e.g. protocol circuits) are updated to use the new pattern.
728-
if (proof_type_in != HONK && proof_type_in != AVM && proof_type_in != ROLLUP_HONK &&
729-
proof_type_in != ROOT_ROLLUP_HONK) {
730-
if (honk_recursion == 1) {
731-
proof_type_in = HONK;
732-
} else if (honk_recursion == 2) {
733-
proof_type_in = ROLLUP_HONK;
734-
}
735-
}
736722

737723
auto c = RecursionConstraint{
738724
.key = transform::map(arg.verification_key,
@@ -888,7 +874,7 @@ void handle_memory_op(Acir::Opcode::MemoryOp const& mem_op, BlockConstraint& blo
888874
block.trace.push_back(acir_mem_op);
889875
}
890876

891-
AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit, uint32_t honk_recursion)
877+
AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit)
892878
{
893879
AcirFormat af;
894880
// `varnum` is the true number of variables, thus we add one to the index which starts at zero
@@ -907,7 +893,7 @@ AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit, uint32_t h
907893
if constexpr (std::is_same_v<T, Acir::Opcode::AssertZero>) {
908894
handle_arithmetic(arg, af, i);
909895
} else if constexpr (std::is_same_v<T, Acir::Opcode::BlackBoxFuncCall>) {
910-
handle_blackbox_func_call(arg, af, honk_recursion, i);
896+
handle_blackbox_func_call(arg, af, i);
911897
} else if constexpr (std::is_same_v<T, Acir::Opcode::MemoryInit>) {
912898
auto block = handle_memory_init(arg);
913899
uint32_t block_id = arg.block_id.value;
@@ -934,15 +920,15 @@ AcirFormat circuit_serde_to_acir_format(Acir::Circuit const& circuit, uint32_t h
934920
return af;
935921
}
936922

937-
AcirFormat circuit_buf_to_acir_format(std::vector<uint8_t> const& buf, uint32_t honk_recursion)
923+
AcirFormat circuit_buf_to_acir_format(std::vector<uint8_t> const& buf)
938924
{
939925
// TODO(https://github.com/AztecProtocol/barretenberg/issues/927): Move to using just
940926
// `program_buf_to_acir_format` once Honk fully supports all ACIR test flows For now the backend still expects
941927
// to work with a single ACIR function
942928
auto program = deserialize_program(buf);
943929
auto circuit = program.functions[0];
944930

945-
return circuit_serde_to_acir_format(circuit, honk_recursion);
931+
return circuit_serde_to_acir_format(circuit);
946932
}
947933

948934
/**
@@ -982,14 +968,14 @@ WitnessVector witness_buf_to_witness_data(std::vector<uint8_t> const& buf)
982968
return witness_map_to_witness_vector(w);
983969
}
984970

985-
std::vector<AcirFormat> program_buf_to_acir_format(std::vector<uint8_t> const& buf, uint32_t honk_recursion)
971+
std::vector<AcirFormat> program_buf_to_acir_format(std::vector<uint8_t> const& buf)
986972
{
987973
auto program = deserialize_program(buf);
988974

989975
std::vector<AcirFormat> constraint_systems;
990976
constraint_systems.reserve(program.functions.size());
991977
for (auto const& function : program.functions) {
992-
constraint_systems.emplace_back(circuit_serde_to_acir_format(function, honk_recursion));
978+
constraint_systems.emplace_back(circuit_serde_to_acir_format(function));
993979
}
994980

995981
return constraint_systems;
@@ -1006,16 +992,11 @@ WitnessVectorStack witness_buf_to_witness_stack(std::vector<uint8_t> const& buf)
1006992
return witness_vector_stack;
1007993
}
1008994

1009-
AcirProgramStack get_acir_program_stack(std::string const& bytecode_path,
1010-
std::string const& witness_path,
1011-
uint32_t honk_recursion)
995+
AcirProgramStack get_acir_program_stack(std::string const& bytecode_path, std::string const& witness_path)
1012996
{
1013997
vinfo("in get_acir_program_stack; witness path is ", witness_path);
1014998
std::vector<uint8_t> bytecode = get_bytecode(bytecode_path);
1015-
std::vector<AcirFormat> constraint_systems =
1016-
program_buf_to_acir_format(bytecode,
1017-
honk_recursion); // TODO(https://github.com/AztecProtocol/barretenberg/issues/1013):
1018-
// Remove honk recursion flag
999+
std::vector<AcirFormat> constraint_systems = program_buf_to_acir_format(bytecode);
10191000
WitnessVectorStack witness_stack = [&]() {
10201001
if (witness_path.empty()) {
10211002
info("producing a stack of empties");

barretenberg/cpp/src/barretenberg/dsl/acir_format/acir_to_constraint_buf.hpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,11 @@ namespace acir_format {
1414
*/
1515
WitnessVector witness_buf_to_witness_data(std::vector<uint8_t> const& buf);
1616

17-
AcirFormat circuit_buf_to_acir_format(std::vector<uint8_t> const& buf, uint32_t honk_recursion);
17+
AcirFormat circuit_buf_to_acir_format(std::vector<uint8_t> const& buf);
1818

19-
std::vector<AcirFormat> program_buf_to_acir_format(std::vector<uint8_t> const& buf, uint32_t honk_recursion);
19+
std::vector<AcirFormat> program_buf_to_acir_format(std::vector<uint8_t> const& buf);
2020

2121
WitnessVectorStack witness_buf_to_witness_stack(std::vector<uint8_t> const& buf);
2222

23-
AcirProgramStack get_acir_program_stack(std::string const& bytecode_path,
24-
std::string const& witness_path,
25-
uint32_t honk_recursion);
23+
AcirProgramStack get_acir_program_stack(std::string const& bytecode_path, std::string const& witness_path);
2624
} // namespace acir_format

0 commit comments

Comments
 (0)