From be89154fa2bfa515b8b52bd4be636ef7b5a33afc Mon Sep 17 00:00:00 2001 From: akokoshn Date: Wed, 25 Sep 2024 09:30:43 +0300 Subject: [PATCH] CleunUp proof-producer Cmake --- flake.nix | 8 +-- proof-producer/CMakeLists.txt | 2 +- .../bin/proof-producer/CMakeLists.txt | 51 +++++++------------ .../bin/proof-producer/src/arg_parser.cpp | 4 +- .../proof-generator => src}/arg_parser.hpp | 0 .../bin/proof-producer/src/main.cpp | 2 +- proof-producer/cmake/Config.cmake.in | 3 +- run.sh | 24 --------- transpiler/CMakeLists.txt | 19 ++++--- transpiler/cmake/Config.cmake.in | 12 +---- transpiler/test/CMakeLists.txt | 2 +- zkevm-framework/bin/assigner/CMakeLists.txt | 2 - zkevm-framework/zkevm-framework.nix | 4 +- 13 files changed, 44 insertions(+), 89 deletions(-) rename proof-producer/bin/proof-producer/{include/nil/proof-generator => src}/arg_parser.hpp (100%) delete mode 100644 run.sh diff --git a/flake.nix b/flake.nix index 4038324071..bbe36fcae7 100644 --- a/flake.nix +++ b/flake.nix @@ -94,8 +94,8 @@ enableDebug = false; crypto3 = crypto3; evm-assigner = evm-assigner; - transpiler = transpiler; proof-producer = proof-producer; + transpiler = transpiler; parallel-crypto3 = parallel-crypto3; }); zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { @@ -103,8 +103,8 @@ enableDebug = false; crypto3 = crypto3; evm-assigner = evm-assigner; - transpiler = transpiler; proof-producer = proof-producer; + transpiler = transpiler; parallel-crypto3 = parallel-crypto3; }); zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { @@ -112,8 +112,8 @@ runTests = true; crypto3 = crypto3; evm-assigner = evm-assigner; - transpiler = transpiler; proof-producer = proof-producer; + transpiler = transpiler; parallel-crypto3 = parallel-crypto3; }); zkevm-framework-clang-debug = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { @@ -233,7 +233,7 @@ enableDebug = false; crypto3 = packages.crypto3; evm-assigner = evm-assigner-gcc; - transpiler = packages.transpiler; + transpiler = transpiler-gcc; proof-producer = proof-producer-gcc; parallel-crypto3 = packages.parallel-crypto3; }); diff --git a/proof-producer/CMakeLists.txt b/proof-producer/CMakeLists.txt index aee30ef88d..8c899e65df 100644 --- a/proof-producer/CMakeLists.txt +++ b/proof-producer/CMakeLists.txt @@ -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) diff --git a/proof-producer/bin/proof-producer/CMakeLists.txt b/proof-producer/bin/proof-producer/CMakeLists.txt index 58de2c627a..87e799a565 100644 --- a/proof-producer/bin/proof-producer/CMakeLists.txt +++ b/proof-producer/bin/proof-producer/CMakeLists.txt @@ -46,54 +46,41 @@ function(setup_proof_generator_target) # 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() - set_target_properties(${ARG_TARGET_NAME} PROPERTIES - LINKER_LANGUAGE CXX - EXPORT_NAME ${ARG_TARGET_NAME} - CXX_STANDARD 17 - CXX_STANDARD_REQUIRED TRUE) - - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(${ARG_TARGET_NAME} PRIVATE "-fconstexpr-steps=2147483647") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_compile_options(${ARG_TARGET_NAME} PRIVATE "-fconstexpr-ops-limit=4294967295") - endif () - - target_include_directories(${ARG_TARGET_NAME} PUBLIC - $ - $ - ) - target_include_directories(${ARG_TARGET_NAME}-lib INTERFACE - $ $ + $ ) - target_link_libraries(${ARG_TARGET_NAME} + target_link_libraries(${ARG_TARGET_NAME}-lib INTERFACE crypto3::all - - crypto3_transpiler - + crypto3::transpiler Boost::filesystem Boost::log - Boost::program_options Boost::thread ) - target_link_libraries(${ARG_TARGET_NAME}-lib INTERFACE - crypto3::all + target_include_directories(${ARG_TARGET_NAME} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR}/src + ) - crypto3::transpiler + 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} + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED TRUE) + + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${ARG_TARGET_NAME} PRIVATE "-fconstexpr-steps=2147483647") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_compile_options(${ARG_TARGET_NAME} PRIVATE "-fconstexpr-ops-limit=4294967295") + endif () - Boost::filesystem - Boost::log - Boost::program_options - Boost::thread - ) endfunction() # Declare single-threaded target diff --git a/proof-producer/bin/proof-producer/src/arg_parser.cpp b/proof-producer/bin/proof-producer/src/arg_parser.cpp index 1e74678edc..61210149e5 100644 --- a/proof-producer/bin/proof-producer/src/arg_parser.cpp +++ b/proof-producer/bin/proof-producer/src/arg_parser.cpp @@ -14,9 +14,9 @@ // limitations under the License. //---------------------------------------------------------------------------// -#include "nil/proof-generator/arg_parser.hpp" +#include -#include "nil/proof-generator/arithmetization_params.hpp" +#include #include #include diff --git a/proof-producer/bin/proof-producer/include/nil/proof-generator/arg_parser.hpp b/proof-producer/bin/proof-producer/src/arg_parser.hpp similarity index 100% rename from proof-producer/bin/proof-producer/include/nil/proof-generator/arg_parser.hpp rename to proof-producer/bin/proof-producer/src/arg_parser.hpp diff --git a/proof-producer/bin/proof-producer/src/main.cpp b/proof-producer/bin/proof-producer/src/main.cpp index ab22d77ea2..1d6c8a20a2 100644 --- a/proof-producer/bin/proof-producer/src/main.cpp +++ b/proof-producer/bin/proof-producer/src/main.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/proof-producer/cmake/Config.cmake.in b/proof-producer/cmake/Config.cmake.in index 560a39a6a5..61bbe94004 100644 --- a/proof-producer/cmake/Config.cmake.in +++ b/proof-producer/cmake/Config.cmake.in @@ -2,6 +2,7 @@ include(CMakeFindDependencyMacro) find_dependency(crypto3 REQUIRED) -find_dependency(crypto3_transpiler) +find_dependency(transpiler REQUIRED) +find_dependency(parallel-crypto3 REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/proof-producerTargets.cmake") diff --git a/run.sh b/run.sh deleted file mode 100644 index 7c283bcfe4..0000000000 --- a/run.sh +++ /dev/null @@ -1,24 +0,0 @@ -echo "1th circuit partial proof" -./result/bin/assigner --shard-id 1 --block-hash 0x001 --path /root/tmp/out/ --target-circuits add.0 -e pallas --input 326522724692461750427768532537390503835 --input 89059515727727869117346995944635890507 --input 291547819587797372485177713898460727720 --input 194782098816759892662980765881849306481 --log-level debug -echo "2th circuit partial proof" -./result/bin/assigner --shard-id 1 --block-hash 0x001 --path /root/tmp/out/ --target-circuits add.1 -e pallas --input 326522724692461750427768532537390503835 --input 89059515727727869117346995944635890507 --input 291547819587797372485177713898460727720 --input 194782098816759892662980765881849306481 --log-level debug - -echo "aggregate challenges" -./result/bin/proof-producer-multi-threaded --stage="generate-aggregated-challenge" --input-challenge-files "/root/tmp/out/challenge.0.1.0x001" "/root/tmp/out/challenge.1.1.0x001" --aggregated-challenge-file="/root/tmp/out/aggregated_challenges.1.0x001" - -echo "compute Q 1th circuit" -./result/bin/proof-producer-multi-threaded --stage="compute-combined-Q" --aggregated-challenge-file="/root/tmp/out/aggregated_challenges.1.0x001" --combined-Q-starting-power=0 --commitment-state-file="/root/tmp/out/commitment_state.0.1.0x001" --combined-Q-polynomial-file="/root/tmp/out/combined_Q.0.1.0x001" -echo "compute Q 2th circuit" -./result/bin/proof-producer-multi-threaded --stage="compute-combined-Q" --aggregated-challenge-file="/root/tmp/out/aggregated_challenges.1.0x001" --combined-Q-starting-power=0 --commitment-state-file="/root/tmp/out/commitment_state.1.1.0x001" --combined-Q-polynomial-file="/root/tmp/out/combined_Q.1.1.0x001" - -echo "aggregate FRY" -./result/bin/proof-producer-multi-threaded --stage="aggregated-FRI" --assignment-description-file="/root/tmp/out/assignment_table_description.0.1.0x001" --aggregated-challenge-file="/root/tmp/out/aggregated_challenges.1.0x001" --input-combined-Q-polynomial-files "/root/tmp/out/combined_Q.0.1.0x001" "/root/tmp/out/combined_Q.1.1.0x001" --proof="/root/tmp/out/aggregated_FRI_proof.1.0x001" --proof-of-work-file="/root/tmp/out/POW.1.0x001" --consistency-checks-challenges-file="/root/tmp/out/challenges.1.0x001" - -echo "consistency check 1th circuit" -./result/bin/proof-producer-multi-threaded --stage="consistency-checks" --commitment-state-file="/root/tmp/out/commitment_state.0.1.0x001" --combined-Q-polynomial-file="/root/tmp/out/combined_Q.0.1.0x001" --consistency-checks-challenges-file="/root/tmp/out/challenges.1.0x001" --proof="/root/tmp/out/LPC_consistency_check_proof.0.1.0x001" -echo "consistency check 2th circuit" -./result/bin/proof-producer-multi-threaded --stage="consistency-checks" --commitment-state-file="/root/tmp/out/commitment_state.1.1.0x001" --combined-Q-polynomial-file="/root/tmp/out/combined_Q.1.1.0x001" --consistency-checks-challenges-file="/root/tmp/out/challenges.1.0x001" --proof="/root/tmp/out/LPC_consistency_check_proof.1.1.0x001" - - -echo "merge final proof" -./result/bin/proof-producer-multi-threaded --stage merge-proofs --partial-proof "/root/tmp/out/proof.0.1.0x001" "/root/tmp/out/proof.1.1.0x001" --initial-proof "/root/tmp/out/LPC_consistency_check_proof.0.1.0x001" "/root/tmp/out/LPC_consistency_check_proof.1.1.0x001" --aggregated-FRI-proof "/root/tmp/out/aggregated_FRI_proof.1.0x001" --proof "/root/tmp/out/final-proof.1.0x001" diff --git a/transpiler/CMakeLists.txt b/transpiler/CMakeLists.txt index 738b84eae1..24aa498e1a 100644 --- a/transpiler/CMakeLists.txt +++ b/transpiler/CMakeLists.txt @@ -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 "$" "$" ${Boost_INCLUDE_DIRS}) -target_link_libraries(crypto3_transpiler INTERFACE +target_link_libraries(${CURRENT_PROJECT_NAME} INTERFACE crypto3::all ${Boost_LIBRARIES}) @@ -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} ) diff --git a/transpiler/cmake/Config.cmake.in b/transpiler/cmake/Config.cmake.in index df4f6dcf48..b32dc80601 100644 --- a/transpiler/cmake/Config.cmake.in +++ b/transpiler/cmake/Config.cmake.in @@ -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") diff --git a/transpiler/test/CMakeLists.txt b/transpiler/test/CMakeLists.txt index daf769e3db..e30ee2a907 100644 --- a/transpiler/test/CMakeLists.txt +++ b/transpiler/test/CMakeLists.txt @@ -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}) diff --git a/zkevm-framework/bin/assigner/CMakeLists.txt b/zkevm-framework/bin/assigner/CMakeLists.txt index 76bb52b969..b739999a7d 100644 --- a/zkevm-framework/bin/assigner/CMakeLists.txt +++ b/zkevm-framework/bin/assigner/CMakeLists.txt @@ -13,8 +13,6 @@ target_include_directories(${TARGET_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/include ) -find_package(actor_zk REQUIRED) - find_package(proof-producer REQUIRED) target_link_libraries(${TARGET_NAME} diff --git a/zkevm-framework/zkevm-framework.nix b/zkevm-framework/zkevm-framework.nix index 7427d840af..4b2332600b 100644 --- a/zkevm-framework/zkevm-framework.nix +++ b/zkevm-framework/zkevm-framework.nix @@ -12,9 +12,9 @@ valijson, gtest, evm-assigner, + proof-producer, transpiler, parallel-crypto3, - proof-producer, enableDebugging, enableDebug ? false, runTests ? false, @@ -31,7 +31,7 @@ in stdenv.mkDerivation rec { # enableDebugging will keep debug symbols in boost propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ]; - buildInputs = [crypto3 evm-assigner proof-producer transpiler parallel-crypto3 intx ethash sszpp valijson gtest]; + buildInputs = [crypto3 evm-assigner proof-producer parallel-crypto3 transpiler intx ethash sszpp valijson gtest]; cmakeFlags = [