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

Prover SetUp #24

Merged
merged 3 commits into from
Sep 26, 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
12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,27 @@
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
transpiler = transpiler;
parallel-crypto3 = parallel-crypto3;
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
});
zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
transpiler = transpiler;
parallel-crypto3 = parallel-crypto3;
});
zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
transpiler = transpiler;
parallel-crypto3 = parallel-crypto3;
});
zkevm-framework-clang-debug = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
stdenv = pkgs.llvmPackages_19.stdenv;
Expand Down Expand Up @@ -224,6 +233,9 @@
enableDebug = false;
crypto3 = packages.crypto3;
evm-assigner = evm-assigner-gcc;
transpiler = transpiler-gcc;
proof-producer = proof-producer-gcc;
parallel-crypto3 = packages.parallel-crypto3;
});

transpiler-gcc = (pkgs.callPackage ./transpiler/transpiler.nix {
Expand Down
21 changes: 20 additions & 1 deletion proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

find_package(crypto3 REQUIRED)
find_package(parallel-crypto3 REQUIRED)
find_package(crypto3_transpiler REQUIRED)
find_package(transpiler REQUIRED)

# TODO: move thread to actor-core
find_package(Boost REQUIRED COMPONENTS filesystem log program_options thread)
Expand Down Expand Up @@ -92,3 +92,22 @@ set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/bin/proof-producer")

include(CPack)

# INSTALL

set(CONFIG_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/proof-producer)
set(TARGET_NAMESPACE crypto3::)
install(EXPORT proof-producerTargets NAMESPACE ${TARGET_NAMESPACE} DESTINATION ${CONFIG_PATH})

include(CMakePackageConfigHelpers)
configure_package_config_file(
cmake/Config.cmake.in
proof-producer-config.cmake
INSTALL_DESTINATION ${CONFIG_PATH}
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/proof-producer-config.cmake
DESTINATION ${CONFIG_PATH}
)
45 changes: 29 additions & 16 deletions proof-producer/bin/proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,35 @@ function(setup_proof_generator_target)
src/main.cpp
)

add_library(${ARG_TARGET_NAME}-lib INTERFACE)

# Make sure to add these dependencies before the others, since for multi-threaded version dependency on
# actor-zk must come first.
if(ARG_ADDITIONAL_DEPENDENCIES)
foreach(lib IN LISTS ARG_ADDITIONAL_DEPENDENCIES)
target_link_libraries(${ARG_TARGET_NAME} ${lib})
target_link_libraries(${ARG_TARGET_NAME}-lib INTERFACE ${lib})
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
endforeach()
endif()

target_include_directories(${ARG_TARGET_NAME}-lib INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_link_libraries(${ARG_TARGET_NAME}-lib INTERFACE
crypto3::all
crypto3::transpiler
Boost::filesystem
Boost::log
Boost::thread
)

target_include_directories(${ARG_TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_link_libraries(${ARG_TARGET_NAME} PRIVATE ${ARG_TARGET_NAME}-lib Boost::program_options)

set_target_properties(${ARG_TARGET_NAME} PROPERTIES
LINKER_LANGUAGE CXX
EXPORT_NAME ${ARG_TARGET_NAME}
Expand All @@ -60,29 +81,21 @@ function(setup_proof_generator_target)
target_compile_options(${ARG_TARGET_NAME} PRIVATE "-fconstexpr-ops-limit=4294967295")
endif ()

target_include_directories(${ARG_TARGET_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_link_libraries(${ARG_TARGET_NAME}
crypto3::all

crypto3_transpiler

Boost::filesystem
Boost::log
Boost::program_options
Boost::thread
)
endfunction()

# Declare single-threaded target
set(SINGLE_THREADED_TARGET "${CURRENT_PROJECT_NAME}-single-threaded")
setup_proof_generator_target(TARGET_NAME ${SINGLE_THREADED_TARGET})


# Declare multi-threaded target
set(MULTI_THREADED_TARGET "${CURRENT_PROJECT_NAME}-multi-threaded")
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
setup_proof_generator_target(TARGET_NAME ${MULTI_THREADED_TARGET} ADDITIONAL_DEPENDENCIES parallel-crypto3::all)

install(TARGETS ${SINGLE_THREADED_TARGET} ${MULTI_THREADED_TARGET} RUNTIME DESTINATION bin)
akokoshn marked this conversation as resolved.
Show resolved Hide resolved

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# Install library
install(TARGETS ${SINGLE_THREADED_TARGET}-lib ${MULTI_THREADED_TARGET}-lib EXPORT proof-producerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR})
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ namespace nil {
commitment_scheme.state_commited(crypto3::zk::snark::LOOKUP_BATCH);
commitment_scheme.mark_batch_as_fixed(crypto3::zk::snark::FIXED_VALUES_BATCH);

commitment_scheme.set_fixed_polys_values(common_data_->commitment_scheme_data);
commitment_scheme.set_fixed_polys_values(common_data_.has_value() ? common_data_->commitment_scheme_data :
public_preprocessed_data_->common_data.commitment_scheme_data);

std::size_t theta_power = commitment_scheme.compute_theta_power_for_combined_Q();

Expand Down Expand Up @@ -492,6 +493,13 @@ namespace nil {
return true;
}

bool set_circuit(const ConstraintSystem& circuit) {
BOOST_LOG_TRIVIAL(info) << "Set circuit" << std::endl;

constraint_system_.emplace(std::move(circuit));
return true;
}

bool read_assignment_table(const boost::filesystem::path& assignment_table_file_) {
BOOST_LOG_TRIVIAL(info) << "Read assignment table from " << assignment_table_file_;

Expand All @@ -512,6 +520,20 @@ namespace nil {
return true;
}

bool set_assignment_table(const AssignmentTable& assignment_table, std::size_t used_rows_amount) {
BOOST_LOG_TRIVIAL(info) << "Set external assignment table" << std::endl;

table_description_->witness_columns = assignment_table.witnesses_amount();
table_description_->public_input_columns = assignment_table.public_inputs_amount();
table_description_->constant_columns = assignment_table.constants_amount();
table_description_->selector_columns = assignment_table.selectors_amount();
table_description_->usable_rows_amount = used_rows_amount;
table_description_->rows_amount = assignment_table.rows_amount();
assignment_table_.emplace(std::move(assignment_table));
public_inputs_.emplace(assignment_table_->public_inputs());
return true;
}

bool save_assignment_description(const boost::filesystem::path& assignment_description_file) {
BOOST_LOG_TRIVIAL(info) << "Writing assignment description to " << assignment_description_file;

Expand Down
4 changes: 2 additions & 2 deletions proof-producer/bin/proof-producer/src/arg_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
// limitations under the License.
//---------------------------------------------------------------------------//

#include "nil/proof-generator/arg_parser.hpp"
#include <arg_parser.hpp>

#include "nil/proof-generator/arithmetization_params.hpp"
#include <nil/proof-generator/arithmetization_params.hpp>

#include <fstream>
#include <iomanip>
Expand Down
2 changes: 1 addition & 1 deletion proof-producer/bin/proof-producer/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <optional>
#include <utility>

#include <nil/proof-generator/arg_parser.hpp>
#include <arg_parser.hpp>
#include <nil/proof-generator/file_operations.hpp>
#include <nil/proof-generator/prover.hpp>

Expand Down
8 changes: 8 additions & 0 deletions proof-producer/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(crypto3 REQUIRED)
find_dependency(transpiler REQUIRED)
find_dependency(parallel-crypto3 REQUIRED)

include("${CMAKE_CURRENT_LIST_DIR}/proof-producerTargets.cmake")
19 changes: 11 additions & 8 deletions transpiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ endif()
cm_workspace(crypto3)
cm_project(transpiler WORKSPACE_NAME crypto3 LANGUAGES ASM C CXX)

cm_setup_version(VERSION 0.1.0 PREFIX crypto3_transpiler)
cm_setup_version(VERSION 0.1.0 PREFIX ${CURRENT_PROJECT_NAME})

find_package(crypto3 REQUIRED)

add_library(crypto3_transpiler INTERFACE)
add_library(${CURRENT_PROJECT_NAME} INTERFACE)

set_target_properties(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} PROPERTIES
set_target_properties(${CURRENT_PROJECT_NAME} PROPERTIES
EXPORT_NAME ${CURRENT_PROJECT_NAME})


target_include_directories(crypto3_transpiler INTERFACE
target_include_directories(${CURRENT_PROJECT_NAME} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

target_link_libraries(crypto3_transpiler INTERFACE
target_link_libraries(${CURRENT_PROJECT_NAME} INTERFACE
crypto3::all
${Boost_LIBRARIES})

Expand All @@ -44,17 +44,20 @@ cm_add_test_subdirectory(test)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
set(CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/crypto3_transpiler)
set(CONFIG_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${CURRENT_PROJECT_NAME})

configure_package_config_file(
cmake/Config.cmake.in
crypto3_transpilerConfig.cmake
${CURRENT_PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CONFIG_DIR}
)

install(TARGETS ${CURRENT_PROJECT_NAME} EXPORT ${CURRENT_PROJECT_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(EXPORT ${CURRENT_PROJECT_NAME}Targets NAMESPACE ${CMAKE_WORKSPACE_NAME}:: DESTINATION ${CONFIG_DIR})

# Install generated cmake config
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/crypto3_transpilerConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/${CURRENT_PROJECT_NAME}-config.cmake
DESTINATION ${CONFIG_DIR}
)

Expand Down
12 changes: 1 addition & 11 deletions transpiler/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,4 @@ include(CMakeFindDependencyMacro)
find_dependency(Boost COMPONENTS REQUIRED
container json filesystem log log_setup program_options thread system unit_test_framework)

# Protect against multiple inclusion
if (TARGET crypto3_transpiler)
return()
endif()


add_library(crypto3_transpiler INTERFACE IMPORTED)

set_target_properties(crypto3_transpiler PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "@CMAKE_INSTALL_FULL_INCLUDEDIR@"
INTERFACE_LINK_LIBRARIES ${Boost_LIBRARIES})
include("${CMAKE_CURRENT_LIST_DIR}/transpilerTargets.cmake")
2 changes: 1 addition & 1 deletion transpiler/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

include(CMTest)

cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
cm_test_link_libraries(${CURRENT_PROJECT_NAME}
crypto3::all
${Boost_LIBRARIES})

Expand Down
3 changes: 3 additions & 0 deletions zkevm-framework/bin/assigner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ target_include_directories(${TARGET_NAME}
${CMAKE_CURRENT_SOURCE_DIR}/include
)

find_package(proof-producer REQUIRED)

target_link_libraries(${TARGET_NAME}
PRIVATE
zkEVMPreset
zkEVMAssignerRunner
zkEVMJsonHelpers
zkEVMOutputArtifacts
crypto3::proof-producer-multi-threaded-lib
Boost::program_options
Boost::log
Boost::random
Expand Down
Loading
Loading