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: Support disabling aztec vm in non-wasm builds #6965

Merged
merged 7 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions barretenberg/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ endif(DOXYGEN_FOUND)

option(DISABLE_ASM "Disable custom assembly" OFF)
option(DISABLE_ADX "Disable ADX assembly variant" OFF)
option(DISABLE_AZTEC_VM "Don't build Aztec VM (acceptable if iterating on core proving)" OFF)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Made this not on by default

option(MULTITHREADING "Enable multi-threading" ON)
option(OMP_MULTITHREADING "Enable OMP multi-threading" OFF)
option(FUZZING "Build ONLY fuzzing harnesses" OFF)
Expand Down Expand Up @@ -144,6 +145,12 @@ include(cmake/module.cmake)
include(cmake/msgpack.cmake)
include(cmake/backward-cpp.cmake)

if (WASM)
set(DISABLE_AZTEC_VM ON)
endif()
if(DISABLE_AZTEC_VM)
add_definitions(-DDISABLE_AZTEC_VM=1)
endif()
add_subdirectory(src)
if (ENABLE_ASAN AND NOT(FUZZING))
find_program(LLVM_SYMBOLIZER_PATH NAMES llvm-symbolizer-16)
Expand Down
2 changes: 1 addition & 1 deletion barretenberg/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ set(BARRETENBERG_TARGET_OBJECTS
$<TARGET_OBJECTS:translator_vm_recursion_objects>
$<TARGET_OBJECTS:ultra_honk_objects>)

if(NOT WASM)
if(NOT DISABLE_AZTEC_VM)
# enable AVM
list(APPEND BARRETENBERG_TARGET_OBJECTS $<TARGET_OBJECTS:vm_objects>)
endif()
Expand Down
6 changes: 6 additions & 0 deletions barretenberg/cpp/src/barretenberg/bb/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
#include "barretenberg/dsl/acir_format/acir_format.hpp"
#include "barretenberg/honk/proof_system/types/proof.hpp"
#include "barretenberg/plonk/proof_system/proving_key/serialize.hpp"
#ifndef DISABLE_AZTEC_VM
#include "barretenberg/vm/avm_trace/avm_common.hpp"
#include "barretenberg/vm/avm_trace/avm_execution.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

pushed this to also not have to parse the headers

#endif
#include "config.hpp"
#include "get_bn254_crs.hpp"
#include "get_bytecode.hpp"
Expand Down Expand Up @@ -514,6 +516,7 @@ void vk_as_fields(const std::string& vk_path, const std::string& output_path)
}
}

#ifndef DISABLE_AZTEC_VM
/**
* @brief Writes an avm proof and corresponding (incomplete) verification key to files.
*
Expand Down Expand Up @@ -586,6 +589,7 @@ bool avm_verify(const std::filesystem::path& proof_path, const std::filesystem::
vinfo("verified: ", verified);
return verified;
}
#endif

/**
* @brief Creates a proof for an ACIR circuit
Expand Down Expand Up @@ -892,6 +896,7 @@ int main(int argc, char* argv[])
} else if (command == "vk_as_fields") {
std::string output_path = get_option(args, "-o", vk_path + "_fields.json");
vk_as_fields(vk_path, output_path);
#ifndef DISABLE_AZTEC_VM
} else if (command == "avm_prove") {
std::filesystem::path avm_bytecode_path = get_option(args, "--avm-bytecode", "./target/avm_bytecode.bin");
std::filesystem::path avm_calldata_path = get_option(args, "--avm-calldata", "./target/avm_calldata.bin");
Expand All @@ -903,6 +908,7 @@ int main(int argc, char* argv[])
avm_prove(avm_bytecode_path, avm_calldata_path, avm_public_inputs_path, avm_hints_path, output_path);
} else if (command == "avm_verify") {
return avm_verify(proof_path, vk_path) ? 0 : 1;
#endif
} else if (command == "prove_ultra_honk") {
std::string output_path = get_option(args, "-o", "./proofs/proof");
prove_honk<UltraFlavor>(bytecode_path, witness_path, output_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ std::vector<bool_t<C>> element<C, Fq, Fr, G>::compute_naf(const Fr& scalar, cons
C* ctx = scalar.context;
uint512_t scalar_multiplier_512 = uint512_t(uint256_t(scalar.get_value()) % Fr::modulus);
uint256_t scalar_multiplier = scalar_multiplier_512.lo;
// NAF can't handl 0
// NAF can't handle 0
if (scalar_multiplier == 0) {
scalar_multiplier = Fr::modulus;
}
Expand Down
4 changes: 2 additions & 2 deletions barretenberg/cpp/src/barretenberg/vm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if(NOT WASM)
barretenberg_module(vm honk sumcheck)
if(NOT DISABLE_AZTEC_VM)
barretenberg_module(vm honk sumcheck)
endif()
Loading