Skip to content

Commit

Permalink
zkevm-framework: enable partial proof in assigner
Browse files Browse the repository at this point in the history
  • Loading branch information
akokoshn committed Sep 20, 2024
1 parent dc8911c commit 1b2238b
Show file tree
Hide file tree
Showing 10 changed files with 335 additions and 115 deletions.
8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,24 @@
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
transpiler = transpiler;
proof-producer = proof-producer;
});
zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3;
evm-assigner = evm-assigner;
transpiler = transpiler;
proof-producer = proof-producer;
});
zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
evm-assigner = evm-assigner;
transpiler = transpiler;
proof-producer = proof-producer;
});

transpiler = (pkgs.callPackage ./transpiler/transpiler.nix {
Expand Down Expand Up @@ -186,6 +192,8 @@
enableDebug = false;
crypto3 = packages.crypto3;
evm-assigner = evm-assigner-gcc;
transpiler = transpiler-gcc;
proof-producer = proof-producer-gcc;
});

transpiler-gcc = (pkgs.callPackage ./transpiler/transpiler.nix {
Expand Down
19 changes: 19 additions & 0 deletions proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,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}
)
26 changes: 26 additions & 0 deletions proof-producer/bin/proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@ 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})
endforeach()
endif()

Expand All @@ -65,6 +68,11 @@ function(setup_proof_generator_target)
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_include_directories(${ARG_TARGET_NAME}-lib INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

target_link_libraries(${ARG_TARGET_NAME}
crypto3::all

Expand All @@ -75,14 +83,32 @@ function(setup_proof_generator_target)
Boost::program_options
Boost::thread
)

target_link_libraries(${ARG_TARGET_NAME}-lib INTERFACE
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")
setup_proof_generator_target(TARGET_NAME ${MULTI_THREADED_TARGET} ADDITIONAL_DEPENDENCIES actor::zk)

install(TARGETS ${SINGLE_THREADED_TARGET} ${MULTI_THREADED_TARGET} RUNTIME DESTINATION bin)

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})
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ namespace nil {
*constraint_system_,
*lpc_scheme_,
true);
std::cout << "create prover\n";
Proof proof = prover.process();
BOOST_LOG_TRIVIAL(info) << "Proof generated";

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

bool set_circuit(const ConstraintSystem& circuit) {
BOOST_LOG_TRIVIAL(info) << "Set circui" << 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
7 changes: 7 additions & 0 deletions proof-producer/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(crypto3 REQUIRED)
find_dependency(crypto3_transpiler)

include("${CMAKE_CURRENT_LIST_DIR}/proof-producerTargets.cmake")
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-single-threaded-lib
Boost::program_options
Boost::log
Boost::random
Expand Down
Loading

0 comments on commit 1b2238b

Please sign in to comment.