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

chore: prove_then_verify_ultra_honk on all existing acir tests #9042

Merged
merged 7 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions barretenberg/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
# Run every acir test through native bb build prove_then_verify flow for UltraPlonk.
# This ensures we test independent pk construction through real/garbage witness data paths.
RUN FLOW=prove_then_verify ./run_acir_tests.sh

# Run the acir test through native bb build prove_then_verify flow for UltraPlonk
# Note that the script will skip the Plonk related tests
RUN FLOW=prove_then_verify_ultra_honk HONK=true ./run_acir_tests.sh

Check failure on line 34 in barretenberg/Earthfile

View workflow job for this annotation

GitHub Actions / bb-acir-tests-bb

Error

The command RUN FLOW=prove_then_verify_ultra_honk HONK=true ./run_acir_tests.sh did not complete successfully. Exit code 1

# Construct and separately verify a UltraHonk proof for a single program
RUN FLOW=prove_then_verify_ultra_honk ./run_acir_tests.sh sha256
# Construct and separately verify a MegaHonk proof for all acir programs
Expand Down
18 changes: 15 additions & 3 deletions barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,26 @@ export BIN CRS_PATH VERBOSE BRANCH

cd acir_tests

echo $HONK

# Convert them to array
# These are not regressions but tests that check proper handling of dependencies or circuits that are part of a workspace
# Running these require extra gluecode so they are skipped for the purpose of these tests
SKIP_ARRAY=(diamond_deps_0 workspace workspace_default_member)

# TODO(https://github.com/AztecProtocol/barretenberg/issues/1108): problem regardless the proof system used
SKIP_ARRAY+=(regression_5045)


# if HONK is false, we should skip verify_honk_proof
if [ "$HONK" = false ]; then
# Insert the new item into the array
# TODO https://github.com/AztecProtocol/barretenberg/issues/1108
SKIP_ARRAY+=(verify_honk_proof regression_5045)
# Don't run programs with Honk recursive verifier
SKIP_ARRAY+=(verify_honk_proof)
fi

if [ "$HONK" = true ]; then
# Don't run programs with Plonk recursive verifier(s)
SKIP_ARRAY+=(single_verify_proof double_verify_proof double_verify_proof_recursive double_verify_nested_proof)
fi

function test() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ void build_constraints(Builder& builder,
// Add multi scalar mul constraints
for (size_t i = 0; i < constraint_system.multi_scalar_mul_constraints.size(); ++i) {
const auto& constraint = constraint_system.multi_scalar_mul_constraints.at(i);
info("Am I here?");
create_multi_scalar_mul_constraint(builder, constraint, has_valid_witness_assignments);
gate_counter.track_diff(constraint_system.gates_per_opcode,
constraint_system.original_opcode_indices.multi_scalar_mul_constraints.at(i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ class AcirIntegrationFoldingTest : public AcirIntegrationTest, public testing::W
}
};

TEST_P(AcirIntegrationSingleTest, DISABLED_ProveAndVerifyProgram)
TEST_P(AcirIntegrationSingleTest, ProveAndVerifyProgram)
{
using Flavor = MegaFlavor;
using Flavor = UltraFlavor;
// using Flavor = bb::plonk::flavor::Ultra;
using Builder = Flavor::CircuitBuilder;

Expand All @@ -164,7 +164,7 @@ TEST_P(AcirIntegrationSingleTest, DISABLED_ProveAndVerifyProgram)
}
}

// TODO(https://github.com/AztecProtocol/barretenberg/issues/994): Run all tests
// TODO(https://github.com/AztecProtocol/barretenberg/iss ues/994): Run all tests
INSTANTIATE_TEST_SUITE_P(AcirTests,
AcirIntegrationSingleTest,
testing::Values("1327_concrete_in_generic",
Expand Down Expand Up @@ -232,12 +232,10 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"brillig_pedersen",
"brillig_recursion",
"brillig_references",
// "brillig_scalar_mul",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

all of these tests are not part of execution_success so not relevant for proving/verifying

"brillig_schnorr",
"brillig_sha256",
"brillig_signed_cmp",
"brillig_signed_div",
// "brillig_slice_input",
"brillig_slices",
"brillig_to_be_bytes",
"brillig_to_bits",
Expand All @@ -259,7 +257,6 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"databus",
"debug_logs",
"diamond_deps_0",
// "distinct_keyword",
"double_verify_nested_proof",
"double_verify_proof",
"double_verify_proof_recursive",
Expand Down Expand Up @@ -311,16 +308,13 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"regression_4088",
"regression_4124",
"regression_4202",
// "regression_4383",
// "regression_4436",
"regression_4449",
"regression_4709",
"regression_5045",
"regression_capacity_tracker",
"regression_mem_op_predicate",
"regression_method_cannot_be_found",
// "regression_sha256_slice",
"regression_struct_array_conditional",
// "scalar_mul",
"schnorr",
"sha256",
"sha2_byte",
Expand All @@ -342,7 +336,6 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"simple_shift_left_right",
"slice_coercion",
"slice_dynamic_index",
// "slice_init_with_complex_type",
"slice_loop",
"slices",
"strings",
Expand All @@ -368,6 +361,8 @@ INSTANTIATE_TEST_SUITE_P(AcirTests,
"unit_value",
"unsafe_range_constraint",
"witness_compression",
// "workspace",
// "workspace_default_member",
"xor"));

TEST_P(AcirIntegrationFoldingTest, DISABLED_ProveAndVerifyProgramStack)
Expand Down Expand Up @@ -419,7 +414,7 @@ TEST_P(AcirIntegrationFoldingTest, DISABLED_FoldAndVerifyProgramStack)
ivc.accumulate(circuit);

CircuitChecker::check(circuit);
// EXPECT_TRUE(prove_and_verify_honk<Flavor>(circuit));
EXPECT_TRUE(prove_and_verify_honk<Flavor>(circuit));

program_stack.pop_back();
}
Expand Down Expand Up @@ -548,16 +543,18 @@ TEST_F(AcirIntegrationTest, DISABLED_UpdateAcirCircuit)
* @brief Test recursive honk recursive verification
*
*/
TEST_F(AcirIntegrationTest, DISABLED_HonkRecursion)
TEST_F(AcirIntegrationTest, HonkRecursion)
{
using Flavor = UltraFlavor;
using Builder = Flavor::CircuitBuilder;

std::string test_name = "verify_honk_proof"; // arbitrary program with RAM gates
// Note: honk_recursion set to false here because the selection of the honk recursive verifier is indicated by the
// proof_type field of the constraint generated from noir.
// The honk_recursion flag determines whether a noir program will be recursively verified via Honk in a Noir
// program.
auto acir_program = get_program_data_from_test_file(test_name,
/*honk_recursion=*/false);
/*honk_recursion=*/true);

// Construct a bberg circuit from the acir representation
auto circuit = acir_format::create_circuit<Builder>(acir_program.constraints, 0, acir_program.witness);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typename ExecutionTrace_<Flavor>::TraceData ExecutionTrace_<Flavor>::construct_t

for (auto& block : builder.blocks.get()) {
auto block_size = static_cast<uint32_t>(block.size());

info("here");
// Update wire polynomials and copy cycles
// NB: The order of row/column loops is arbitrary but needs to be row/column to match old copy_cycle code
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void UltraCircuitBuilder_<Arithmetization>::add_gates_to_ensure_all_polys_are_no
create_dummy_gate(blocks.aux, this->zero_idx, this->zero_idx, this->zero_idx, this->zero_idx);

// Add nonzero values in w_4 and q_c (q_4*w_4 + q_c --> 1*1 - 1 = 0)
this->one_idx = put_constant_variable(FF::one());
// this->one_idx = put_constant_variable(FF::one());
create_big_add_gate({ this->zero_idx, this->zero_idx, this->zero_idx, this->one_idx, 0, 0, 0, 1, -1 });

// Take care of all polys related to lookups (q_lookup, tables, sorted, etc)
Expand Down Expand Up @@ -550,7 +550,7 @@ void UltraCircuitBuilder_<Arithmetization>::create_ecc_add_gate(const ecc_add_ga
this->assert_valid_variables({ in.x1, in.x2, in.x3, in.y1, in.y2, in.y3 });

auto& block = blocks.elliptic;

info("before size of wire 1", block.wires[1].size());
bool previous_elliptic_gate_exists = block.size() > 0;
bool can_fuse_into_previous_gate = previous_elliptic_gate_exists;
if (can_fuse_into_previous_gate) {
Expand Down Expand Up @@ -589,6 +589,11 @@ void UltraCircuitBuilder_<Arithmetization>::create_ecc_add_gate(const ecc_add_ga
++this->num_gates;
}
create_dummy_gate(block, in.x2, in.x3, in.y3, in.y2);
if (block.wires[1].size() >= 442) {
size_t i = 0;
static_cast<void>(i);
info("prolly culprit");
}
}

/**
Expand All @@ -600,6 +605,7 @@ template <typename Arithmetization>
void UltraCircuitBuilder_<Arithmetization>::create_ecc_dbl_gate(const ecc_dbl_gate_<FF>& in)
{
auto& block = blocks.elliptic;
info("before size of wire 1", block.wires[1].size());

/**
* gate structure:
Expand Down Expand Up @@ -644,6 +650,12 @@ void UltraCircuitBuilder_<Arithmetization>::create_ecc_dbl_gate(const ecc_dbl_ga
++this->num_gates;
}
create_dummy_gate(block, this->zero_idx, in.x3, in.y3, this->zero_idx);
if (block.wires[1].size() >= 442) {
size_t i = 0;
static_cast<void>(i);

info("prolly culprit");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase<typename Arithmetization_
{
// TODO(https://github.com/AztecProtocol/barretenberg/issues/870): reserve space in blocks here somehow?
this->zero_idx = put_constant_variable(FF::zero());
this->one_idx = put_constant_variable(FF::one());
this->tau.insert({ DUMMY_TAG, DUMMY_TAG }); // TODO(luke): explain this
};
/**
Expand Down Expand Up @@ -359,6 +360,7 @@ class UltraCircuitBuilder_ : public CircuitBuilderBase<typename Arithmetization_
// Add the const zero variable after the acir witness has been
// incorporated into variables.
this->zero_idx = put_constant_variable(FF::zero());
this->one_idx = put_constant_variable(FF::one());
this->tau.insert({ DUMMY_TAG, DUMMY_TAG }); // TODO(luke): explain this

this->is_recursive_circuit = recursive;
Expand Down
Loading