Skip to content

Commit

Permalink
feat: Use UltraRollupHonk in rollup (#10342)
Browse files Browse the repository at this point in the history
Uses UltraRollupFlavor and UltraRecursiveRollupFlavor in the rollup.

Modifies UltraRecursiveVerifier tests to also test rollup flavors.

Adds new test program, `verify_rollup_honk_proof`, and new flows for
test program.
  • Loading branch information
lucasxia01 authored Dec 24, 2024
1 parent ca612e7 commit 82bc146
Show file tree
Hide file tree
Showing 74 changed files with 1,132 additions and 430 deletions.
2 changes: 1 addition & 1 deletion aztec-nargo/compile_then_postprocess.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ for artifact in $artifacts_to_process; do

echo "Generating verification key for function $fn_name"
# BB outputs the verification key to stdout as raw bytes, however, we need to base64 encode it before storing it in the artifact
verification_key=$($BB write_vk_for_ivc -h -b ${fn_artifact_path} -o - | base64)
verification_key=$($BB write_vk_for_ivc -b ${fn_artifact_path} -o - | base64)
rm $fn_artifact_path
jq ".functions[$fn_index].verification_key = \"$verification_key\"" $artifact > $artifact.tmp
mv $artifact.tmp $artifact
Expand Down
6 changes: 4 additions & 2 deletions barretenberg/acir_tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ function test {
}

local plonk_tests=$(find ./acir_tests -maxdepth 1 -mindepth 1 -type d | \
grep -vE 'verify_honk_proof|double_verify_honk_proof')
grep -vE 'verify_honk_proof|double_verify_honk_proof|verify_rollup_honk_proof')
local honk_tests=$(find ./acir_tests -maxdepth 1 -mindepth 1 -type d | \
grep -vE 'single_verify_proof|double_verify_proof|double_verify_nested_proof')
grep -vE 'single_verify_proof|double_verify_proof|double_verify_nested_proof|verify_rollup_honk_proof')

# barretenberg-acir-tests-sol:
run FLOW=sol ./run_test.sh assert_statement
Expand Down Expand Up @@ -119,6 +119,8 @@ function test {
run SYS=ultra_honk FLOW=prove_then_verify RECURSIVE=true ./run_test.sh assert_statement
run SYS=ultra_honk FLOW=prove_then_verify RECURSIVE=true ./run_test.sh double_verify_honk_proof
run SYS=ultra_honk FLOW=prove_and_verify_program ./run_test.sh merkle_insert
run SYS=ultra_rollup_honk FLOW=prove_and_verify ./run_test.sh verify_rollup_honk_proof


# barretenberg-acir-tests-bb-client-ivc:
run FLOW=prove_then_verify_client_ivc ./run_test.sh 6_array
Expand Down
44 changes: 29 additions & 15 deletions barretenberg/acir_tests/regenerate_verify_honk_proof_inputs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,44 @@ CRS_PATH=~/.bb-crs
BRANCH=master
VERBOSE=${VERBOSE:+-v}

if [ -f $BIN ]; then
BIN=$(realpath $BIN)
if [ -f "$BIN" ]; then
BIN=$(realpath "$BIN")
else
BIN=$(realpath $(which $BIN))
BIN=$(realpath "$(which "$BIN")")
fi

export BRANCH

# the program for which a proof will be recursively verified
# The program for which a proof will be recursively verified
PROGRAM=assert_statement
# the program containing the recursive verifier
RECURSIVE_PROGRAM=verify_honk_proof
# The programs containing the recursive verifier
RECURSIVE_PROGRAMS=(verify_honk_proof verify_rollup_honk_proof)

./reset_acir_tests.sh --programs "$PROGRAM"
./reset_acir_tests.sh --no-rebuild-nargo --programs "$PROGRAM"
cd "acir_tests/$PROGRAM"

TOML_DIR=../../../../noir/noir-repo/test_programs/execution_success/"$RECURSIVE_PROGRAM"
if [ ! -d "$TOML_DIR" ]; then
echo "Error: Directory $TOML_DIR does not exist."
exit 1
fi
# Base directory for TOML outputs
BASE_TOML_DIR=../../../../noir/noir-repo/test_programs/execution_success

for RECURSIVE_PROGRAM in "${RECURSIVE_PROGRAMS[@]}"; do
TOML_DIR="$BASE_TOML_DIR/$RECURSIVE_PROGRAM"

if [ ! -d "$TOML_DIR" ]; then
echo "Error: Directory $TOML_DIR does not exist."
exit 1
fi

echo "Generating recursion inputs for $RECURSIVE_PROGRAM and writing to directory $TOML_DIR"

# Decide the command based on the recursive program
if [[ "$RECURSIVE_PROGRAM" == "verify_rollup_honk_proof" ]]; then
COMMAND="write_recursion_inputs_rollup_honk"
else
COMMAND="write_recursion_inputs_honk"
fi

echo "Generating recursion inputs and writing to directory $TOML_DIR"
$BIN write_recursion_inputs_honk --recursive $VERBOSE -c $CRS_PATH -b ./target/program.json -o "$TOML_DIR"
$BIN "$COMMAND" --recursive $VERBOSE -c "$CRS_PATH" -b ./target/program.json -o "$TOML_DIR"
done

cd ../..
./reset_acir_tests.sh --programs "$RECURSIVE_PROGRAM"
./reset_acir_tests.sh --no-rebuild-nargo --programs "${RECURSIVE_PROGRAMS[@]}"
4 changes: 2 additions & 2 deletions barretenberg/acir_tests/run_acir_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ SKIP_ARRAY+=(regression_5045)
# if HONK is false, we should skip verify_honk_proof
if [ "$HONK" = false ]; then
# Don't run programs with Honk recursive verifier
SKIP_ARRAY+=(verify_honk_proof double_verify_honk_proof)
SKIP_ARRAY+=(verify_honk_proof double_verify_honk_proof verify_rollup_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_nested_proof)
SKIP_ARRAY+=(single_verify_proof double_verify_proof double_verify_nested_proof verify_rollup_honk_proof)
fi

if [ "$CLIENT_IVC_SKIPS" = true ]; then
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/bb/acir_format_getters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ acir_format::WitnessVector get_witness(std::string const& witness_path)
return acir_format::witness_buf_to_witness_data(witness_data);
}

acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path, bool honk_recursion)
acir_format::AcirFormat get_constraint_system(std::string const& bytecode_path, uint32_t honk_recursion)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::circuit_buf_to_acir_format(bytecode, honk_recursion);
Expand All @@ -25,7 +25,7 @@ acir_format::WitnessVectorStack get_witness_stack(std::string const& witness_pat
return acir_format::witness_buf_to_witness_stack(witness_data);
}

std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path, bool honk_recursion)
std::vector<acir_format::AcirFormat> get_constraint_systems(std::string const& bytecode_path, uint32_t honk_recursion)
{
auto bytecode = get_bytecode(bytecode_path);
return acir_format::program_buf_to_acir_format(bytecode, honk_recursion);
Expand Down
5 changes: 2 additions & 3 deletions barretenberg/cpp/src/barretenberg/bb/api_client_ivc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ class ClientIVCAPI : public API {

// TODO(https://github.com/AztecProtocol/barretenberg/issues/1162): Efficiently unify ACIR stack parsing
if (input_type == "compiletime_stack") {
auto program_stack =
acir_format::get_acir_program_stack(bytecode_path, witness_path, /*honk_recursion=*/false);
auto program_stack = acir_format::get_acir_program_stack(bytecode_path, witness_path, /*honk_recursion=*/0);
// Accumulate the entire program stack into the IVC
while (!program_stack.empty()) {
auto stack_item = program_stack.back();
Expand All @@ -116,7 +115,7 @@ class ClientIVCAPI : public API {
std::vector<uint8_t> witness_buf =
decompress(reinterpret_cast<uint8_t*>(wit.data()), wit.size()); // NOLINT

AcirFormat constraints = circuit_buf_to_acir_format(constraint_buf, /*honk_recursion=*/false);
AcirFormat constraints = circuit_buf_to_acir_format(constraint_buf, /*honk_recursion=*/0);
WitnessVector witness = witness_buf_to_witness_data(witness_buf);

folding_stack.push_back(AcirProgram{ constraints, witness });
Expand Down
Loading

0 comments on commit 82bc146

Please sign in to comment.