From 9ddbe57fc248db2fb97a6cf8602dd8b39fec5649 Mon Sep 17 00:00:00 2001 From: akokoshn Date: Thu, 10 Oct 2024 23:04:58 +0300 Subject: [PATCH] Introduce global CMakeLits.txt --- CMakeLists.txt | 18 ++ crypto3/crypto3.nix => crypto3.nix | 4 +- crypto3/CMakeLists.txt | 46 ++++- .../debug-tools.nix => debug-tools.nix | 4 +- debug-tools/CMakeLists.txt | 2 - debug-tools/cmake/Config.cmake.in | 1 - .../evm-assigner.nix => evm-assigner.nix | 9 +- evm-assigner/CMakeLists.txt | 21 --- evm-assigner/lib/assigner/CMakeLists.txt | 4 +- flake.nix | 157 ++++-------------- ...rallel-crypto3.nix => parallel-crypto3.nix | 12 +- parallel-crypto3/CMakeLists.txt | 52 ++---- .../libs/parallel-zk/test/CMakeLists.txt | 3 +- .../proof-producer.nix => proof-producer.nix | 6 +- proof-producer/CMakeLists.txt | 21 --- .../bin/proof-producer/CMakeLists.txt | 33 ++-- readme.md | 6 +- ...zkevm-framework.nix => zkevm-framework.nix | 13 +- zkevm-framework/CMakeLists.txt | 6 +- zkevm-framework/bin/assigner/CMakeLists.txt | 4 +- .../libs/assigner_runner/CMakeLists.txt | 4 +- .../libs/output_artifacts/CMakeLists.txt | 3 +- zkevm-framework/libs/preset/CMakeLists.txt | 3 +- zkevm-framework/libs/rpc/CMakeLists.txt | 1 + zkevm-framework/tests/bin/CMakeLists.txt | 10 +- .../tests/libs/assigner_runner/CMakeLists.txt | 4 +- 26 files changed, 161 insertions(+), 286 deletions(-) create mode 100644 CMakeLists.txt rename crypto3/crypto3.nix => crypto3.nix (91%) rename debug-tools/debug-tools.nix => debug-tools.nix (86%) rename evm-assigner/evm-assigner.nix => evm-assigner.nix (81%) rename parallel-crypto3/parallel-crypto3.nix => parallel-crypto3.nix (73%) rename proof-producer/proof-producer.nix => proof-producer.nix (83%) rename zkevm-framework/zkevm-framework.nix => zkevm-framework.nix (75%) diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..9644a2d3b4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.27) + +project(placeholder) + +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/crypto3") +if ((${PARALLEL_CRYPTO3_ENABLE}) OR (${PROOF_PRODUCER_ENABLE}) OR (${ZKEVM_FRAMEWORK_ENABLE})) +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/parallel-crypto3") +endif() +if (${ZKEVM_FRAMEWORK_ENABLE}) +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/evm-assigner") +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/zkevm-framework") +endif() +if ((${PROOF_PRODUCER_ENABLE}) OR (${ZKEVM_FRAMEWORK_ENABLE})) +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/proof-producer") +endif() +if (${DEBUG_TOOLS_ENABLE}) +add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/debug-tools") +endif() diff --git a/crypto3/crypto3.nix b/crypto3.nix similarity index 91% rename from crypto3/crypto3.nix rename to crypto3.nix index 982007a43a..ceba56ae78 100644 --- a/crypto3/crypto3.nix +++ b/crypto3.nix @@ -17,7 +17,7 @@ let in stdenv.mkDerivation { name = "Crypto3"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^crypto3(/.*)?$" "CMakeLists.txt"]; hardeningDisable = [ "fortify" ]; nativeBuildInputs = [ cmake ninja pkg-config ] ++ @@ -42,7 +42,7 @@ in stdenv.mkDerivation { checkPhase = '' # JUNIT file without explicit file name is generated after the name of the master test suite inside `CMAKE_CURRENT_SOURCE_DIR` export BOOST_TEST_LOGGER=JUNIT:HRF - ctest --verbose --output-on-failure -R + cd crypto3 && ctest --verbose --output-on-failure -R && cd .. mkdir -p ${placeholder "out"}/test-logs find .. -type f -name '*_test.xml' -exec cp {} ${placeholder "out"}/test-logs \; ''; diff --git a/crypto3/CMakeLists.txt b/crypto3/CMakeLists.txt index 0d3efb2b89..13e25bc1bc 100644 --- a/crypto3/CMakeLists.txt +++ b/crypto3/CMakeLists.txt @@ -67,7 +67,51 @@ endif() find_package(Boost REQUIRED COMPONENTS container random filesystem log log_setup program_options thread system unit_test_framework timer) add_subdirectories("${CMAKE_CURRENT_LIST_DIR}/libs/") -add_subdirectories("${CMAKE_CURRENT_LIST_DIR}/libs/marshalling") +add_subdirectories("${CMAKE_CURRENT_LIST_DIR}/libs/marshalling/") + +add_library(${CMAKE_WORKSPACE_NAME}_all INTERFACE) +add_library(${CMAKE_WORKSPACE_NAME}::all ALIAS ${CMAKE_WORKSPACE_NAME}_all) +target_link_libraries(${CMAKE_WORKSPACE_NAME}_all INTERFACE + crypto3::algebra + crypto3::block + crypto3::blueprint + crypto3::transpiler + crypto3::codec + crypto3::containers + crypto3::hash + crypto3::marshalling-algebra + crypto3::marshalling-core + crypto3::marshalling-multiprecision + crypto3::marshalling-zk + crypto3::math + crypto3::multiprecision + crypto3::passhash + crypto3::pubkey + crypto3::random + crypto3::stream + crypto3::threshold + crypto3::zk) + +add_library(${CMAKE_WORKSPACE_NAME}_common INTERFACE) +add_library(${CMAKE_WORKSPACE_NAME}::common ALIAS ${CMAKE_WORKSPACE_NAME}_common) +target_link_libraries(${CMAKE_WORKSPACE_NAME}_common INTERFACE + crypto3::algebra + crypto3::benchmark_tools + crypto3::block + crypto3::blueprint + crypto3::transpiler + crypto3::codec + crypto3::hash + crypto3::marshalling-algebra + crypto3::marshalling-core + crypto3::marshalling-multiprecision + crypto3::marshalling-zk + crypto3::multiprecision + crypto3::passhash + crypto3::pubkey + crypto3::random + crypto3::stream + crypto3::threshold) if(BUILD_BENCH_TESTS) add_subdirectory(benchmarks) diff --git a/debug-tools/debug-tools.nix b/debug-tools.nix similarity index 86% rename from debug-tools/debug-tools.nix rename to debug-tools.nix index 10dcd883ea..c7ad2ea49c 100644 --- a/debug-tools/debug-tools.nix +++ b/debug-tools.nix @@ -16,14 +16,13 @@ ninja, pango, pangomm, - crypto3, }: let inherit (lib) optional; in stdenv.mkDerivation { name = "debug-tools"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^crypto3(/.*)?$" "^parallel-crypto3(/.*)?$" "CMakeLists.txt"]; nativeBuildInputs = [ cmake ninja pkg-config ] ++ (lib.optional (!stdenv.isDarwin) gdb) ++ @@ -36,6 +35,7 @@ in stdenv.mkDerivation { cmakeFlags = [ "-DCMAKE_BUILD_TYPE=Release" + "-DDEBUG_TOOLS_ENABLE=TRUE" "-G Ninja" ]; diff --git a/debug-tools/CMakeLists.txt b/debug-tools/CMakeLists.txt index 2271eec703..ef7ed2fb31 100644 --- a/debug-tools/CMakeLists.txt +++ b/debug-tools/CMakeLists.txt @@ -45,8 +45,6 @@ endif() list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") -find_package(crypto3 REQUIRED) - find_package(Boost REQUIRED COMPONENTS filesystem log program_options) # Read version from VERSION file diff --git a/debug-tools/cmake/Config.cmake.in b/debug-tools/cmake/Config.cmake.in index 5f1f264b37..a75c0cd0bf 100644 --- a/debug-tools/cmake/Config.cmake.in +++ b/debug-tools/cmake/Config.cmake.in @@ -1,6 +1,5 @@ @PACKAGE_INIT@ include(CMakeFindDependencyMacro) -find_dependency(crypto3 REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/debug-toolsTargets.cmake") diff --git a/evm-assigner/evm-assigner.nix b/evm-assigner.nix similarity index 81% rename from evm-assigner/evm-assigner.nix rename to evm-assigner.nix index e6b0114bfc..83b2a6b941 100644 --- a/evm-assigner/evm-assigner.nix +++ b/evm-assigner.nix @@ -8,10 +8,12 @@ boost_lib ? boost183, gdb, lldb, + cmake_modules, ethash, intx, + sszpp, + valijson, gtest, - crypto3, enableDebugging, enableDebug ? false, runTests ? false, @@ -21,7 +23,7 @@ let in stdenv.mkDerivation rec { name = "evm-assigner"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^evm-assigner(/.*)?$" "^crypto3(/.*)?$" "^parallel-crypto3(/.*)?$" "CMakeLists.txt"]; hardeningDisable = [ "fortify" ]; nativeBuildInputs = [ cmake ninja pkg-config ] ++ @@ -31,13 +33,14 @@ in stdenv.mkDerivation rec { # enableDebugging will keep debug symbols in boost propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost_lib) else boost_lib) ]; - buildInputs = [crypto3 ethash intx gtest]; + buildInputs = [sszpp valijson cmake_modules ethash intx gtest]; cmakeFlags = [ (if runTests then "-DBUILD_TESTS=TRUE" else "") (if runTests then "-DBUILD_ASSIGNER_TESTS=TRUE" else "") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + "-DZKEVM_FRAMEWORK_ENABLE=TRUE" "-G Ninja" ]; diff --git a/evm-assigner/CMakeLists.txt b/evm-assigner/CMakeLists.txt index af4b73e12e..d4546f24cd 100644 --- a/evm-assigner/CMakeLists.txt +++ b/evm-assigner/CMakeLists.txt @@ -110,24 +110,3 @@ endif() include(CTest) add_subdirectory(lib) - -# INSTALL - -set(CONFIG_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/evm-assigner) -set(TARGET_NAMESPACE evm-assigner::) -install(EXPORT assignerTargets NAMESPACE ${TARGET_NAMESPACE} DESTINATION ${CONFIG_PATH}) - -include(CMakePackageConfigHelpers) -configure_package_config_file( - cmake/Config.cmake.in - evm-assigner-config.cmake - INSTALL_DESTINATION ${CONFIG_PATH} -) - -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/evm-assigner-config.cmake - DESTINATION ${CONFIG_PATH} -) - -cable_add_archive_package() diff --git a/evm-assigner/lib/assigner/CMakeLists.txt b/evm-assigner/lib/assigner/CMakeLists.txt index b4b9fcf80d..011e9fcd6b 100644 --- a/evm-assigner/lib/assigner/CMakeLists.txt +++ b/evm-assigner/lib/assigner/CMakeLists.txt @@ -17,8 +17,6 @@ add_library(${PROJECT_NAME} STATIC ${evmone_sources}) target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20) -find_package(parallel-crypto3 REQUIRED) - target_include_directories(${PROJECT_NAME} PUBLIC $ $ @@ -26,7 +24,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC $) target_link_libraries(${PROJECT_NAME} - PUBLIC intx::intx parallel-crypto3::all ethash::keccak) + PUBLIC intx::intx crypto3::common ethash::keccak) set_target_properties( ${PROJECT_NAME} diff --git a/flake.nix b/flake.nix index 6c4c2840b2..66c78777f5 100644 --- a/flake.nix +++ b/flake.nix @@ -22,149 +22,84 @@ }; in rec { packages = rec { - crypto3 = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3 = (pkgs.callPackage ./crypto3.nix { runTests = false; enableDebug = false; }); - crypto3-tests = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-tests = (pkgs.callPackage ./crypto3.nix { runTests = true; enableDebug = false; }); - crypto3-debug-tests = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-debug-tests = (pkgs.callPackage ./crypto3.nix { enableDebug = true; runTests = true; }); - crypto3-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-sanitize = (pkgs.callPackage ./crypto3.nix { enableDebug = true; runTests = true; sanitize = true; }); - crypto3-clang-debug = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-clang-debug = (pkgs.callPackage ./crypto3.nix { stdenv = pkgs.llvmPackages_19.stdenv; runTests = false; enableDebug = true; }); - parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { + parallel-crypto3 = (pkgs.callPackage ./parallel-crypto3.nix { runTests = false; enableDebug = false; - crypto3 = crypto3; }); - parallel-crypto3-tests = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { + parallel-crypto3-tests = (pkgs.callPackage ./parallel-crypto3.nix { runTests = true; enableDebug = false; - crypto3 = crypto3; }); - parallel-crypto3-debug-tests = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { + parallel-crypto3-debug-tests = (pkgs.callPackage ./parallel-crypto3.nix { enableDebug = true; runTests = true; - crypto3 = crypto3; }); - parallel-crypto3-clang-debug = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { + parallel-crypto3-clang-debug = (pkgs.callPackage ./parallel-crypto3.nix { stdenv = pkgs.llvmPackages_19.stdenv; enableDebug = true; runTests = false; - crypto3 = crypto3-clang-debug; }); - evm-assigner = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + zkevm-framework = (pkgs.callPackage ./zkevm-framework.nix { runTests = false; enableDebug = false; - crypto3 = parallel-crypto3; }); - evm-assigner-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework.nix { runTests = true; enableDebug = false; - crypto3 = parallel-crypto3; }); - evm-assigner-debug-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework.nix { enableDebug = true; runTests = true; - crypto3 = parallel-crypto3; }); - evm-assigner-clang-debug = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + zkevm-framework-clang-debug = (pkgs.callPackage ./zkevm-framework.nix { stdenv = pkgs.llvmPackages_19.stdenv; enableDebug = true; runTests = false; - crypto3 = parallel-crypto3-clang-debug; }); - zkevm-framework = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { + proof-producer = (pkgs.callPackage ./proof-producer.nix { runTests = false; enableDebug = false; - crypto3 = parallel-crypto3; - evm-assigner = evm-assigner; - proof-producer = proof-producer; }); - zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { + proof-producer-tests = (pkgs.callPackage ./proof-producer.nix { runTests = true; enableDebug = false; - crypto3 = parallel-crypto3; - evm-assigner = evm-assigner; - proof-producer = proof-producer; }); - zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { + proof-producer-debug-tests = (pkgs.callPackage ./proof-producer.nix { enableDebug = true; runTests = true; - crypto3 = parallel-crypto3; - evm-assigner = evm-assigner; - proof-producer = proof-producer; }); - zkevm-framework-clang-debug = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { + proof-producer-clang-debug = (pkgs.callPackage ./proof-producer.nix { stdenv = pkgs.llvmPackages_19.stdenv; enableDebug = true; runTests = false; - crypto3 = parallel-crypto3-clang-debug; - evm-assigner = evm-assigner-clang-debug; - proof-producer = proof-producer-clang-debug; }); - proof-producer = (pkgs.callPackage ./proof-producer/proof-producer.nix { - runTests = false; - enableDebug = false; - crypto3 = parallel-crypto3; - }); - proof-producer-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix { - runTests = true; - enableDebug = false; - crypto3 = parallel-crypto3; - }); - proof-producer-debug-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix { - enableDebug = true; - runTests = true; - crypto3 = parallel-crypto3; - }); - proof-producer-clang-debug = (pkgs.callPackage ./proof-producer/proof-producer.nix { - stdenv = pkgs.llvmPackages_19.stdenv; - enableDebug = true; - runTests = false; - crypto3 = parallel-crypto3-clang-debug; - }); - - proof-producer-singlethreaded = (pkgs.callPackage ./proof-producer/proof-producer.nix { - runTests = false; - enableDebug = false; - crypto3 = crypto3; - }); - proof-producer-singlethreaded-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix { - runTests = true; - enableDebug = false; - crypto3 = crypto3; - }); - proof-producer-singlethreaded-debug-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix { - enableDebug = true; - runTests = true; - crypto3 = crypto3; - }); - proof-producer-singlethreaded-clang-debug = (pkgs.callPackage ./proof-producer/proof-producer.nix { - stdenv = pkgs.llvmPackages_19.stdenv; - enableDebug = true; - runTests = false; - crypto3 = crypto3; - }); - - debug-tools = (pkgs.callPackage ./debug-tools/debug-tools.nix { - crypto3 = crypto3; + debug-tools = (pkgs.callPackage ./debug-tools.nix { }); # The "all" package will build all packages. Convenient for CI, @@ -173,86 +108,56 @@ # fetched from the cache. all = pkgs.symlinkJoin { name = "all"; - paths = [ crypto3 evm-assigner zkevm-framework proof-producer]; + paths = [ crypto3 zkevm-framework proof-producer]; }; default = all; }; checks = rec { - crypto3-gcc = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-gcc = (pkgs.callPackage ./crypto3.nix { runTests = true; enableDebug = false; }); - crypto3-clang = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-clang = (pkgs.callPackage ./crypto3.nix { stdenv = pkgs.llvmPackages_19.stdenv; runTests = true; enableDebug = false; }); - crypto3-clang-sanitize = (pkgs.callPackage ./crypto3/crypto3.nix { + crypto3-clang-sanitize = (pkgs.callPackage ./crypto3.nix { stdenv = pkgs.llvmPackages_19.stdenv; runTests = true; enableDebug = false; sanitize = true; }); - parallel-crypto3-gcc = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { - runTests = true; - enableDebug = false; - crypto3 = packages.crypto3; - }); - parallel-crypto3-clang = (pkgs.callPackage ./parallel-crypto3/parallel-crypto3.nix { - stdenv = pkgs.llvmPackages_19.stdenv; - runTests = true; - enableDebug = false; - crypto3 = crypto3-clang; - }); - - evm-assigner-gcc = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + parallel-crypto3-gcc = (pkgs.callPackage ./parallel-crypto3.nix { runTests = true; enableDebug = false; - crypto3 = packages.parallel-crypto3; }); - evm-assigner-clang = (pkgs.callPackage ./evm-assigner/evm-assigner.nix { + parallel-crypto3-clang = (pkgs.callPackage ./parallel-crypto3.nix { stdenv = pkgs.llvmPackages_19.stdenv; runTests = true; enableDebug = false; - crypto3 = parallel-crypto3-clang; }); - zkevm-framework-gcc = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix { + zkevm-framework-gcc = (pkgs.callPackage ./zkevm-framework.nix { runTests = true; enableDebug = false; - evm-assigner = evm-assigner-gcc; - proof-producer = proof-producer-gcc; - crypto3 = packages.parallel-crypto3; }); - proof-producer-gcc = (pkgs.callPackage ./proof-producer/proof-producer.nix { + proof-producer-gcc = (pkgs.callPackage ./proof-producer.nix { runTests = true; enableDebug = false; - crypto3 = packages.parallel-crypto3; }); - proof-producer-clang = (pkgs.callPackage ./proof-producer/proof-producer.nix { + proof-producer-clang = (pkgs.callPackage ./proof-producer.nix { stdenv = pkgs.llvmPackages_19.stdenv; runTests = true; enableDebug = false; - crypto3 = parallel-crypto3-clang; - }); - proof-producer-singlethreaded-gcc = (pkgs.callPackage ./proof-producer/proof-producer.nix { - runTests = true; - enableDebug = false; - crypto3 = packages.crypto3; - }); - proof-producer-singlethreaded-clang = (pkgs.callPackage ./proof-producer/proof-producer.nix { - stdenv = pkgs.llvmPackages_19.stdenv; - runTests = true; - enableDebug = false; - crypto3 = crypto3-clang; }); all-clang = pkgs.symlinkJoin { name = "all"; - paths = [ crypto3-clang parallel-crypto3-clang evm-assigner-clang proof-producer-clang proof-producer-singlethreaded-clang ]; + paths = [ crypto3-clang parallel-crypto3-clang proof-producer-clang ]; }; all-sanitizers = pkgs.symlinkJoin { name = "all"; @@ -260,7 +165,7 @@ }; all-gcc = pkgs.symlinkJoin { name = "all"; - paths = [ crypto3-gcc parallel-crypto3-gcc evm-assigner-gcc zkevm-framework-gcc proof-producer-gcc proof-producer-singlethreaded-gcc ]; + paths = [ crypto3-gcc parallel-crypto3-gcc zkevm-framework-gcc proof-producer-gcc ]; }; default = all-gcc; }; @@ -269,10 +174,6 @@ type = "app"; program = "${self.packages.${system}.zkevm-framework}/bin/assigner"; }; - single-threaded = { - type = "app"; - program = "${self.packages.${system}.proof-producer-singlethreaded}/bin/proof-producer-single-threaded"; - }; multi-threaded = { type = "app"; program = "${self.packages.${system}.proof-producer}/bin/proof-producer-multi-threaded"; diff --git a/parallel-crypto3/parallel-crypto3.nix b/parallel-crypto3.nix similarity index 73% rename from parallel-crypto3/parallel-crypto3.nix rename to parallel-crypto3.nix index a27aaedc83..dbadf48a0b 100644 --- a/parallel-crypto3/parallel-crypto3.nix +++ b/parallel-crypto3.nix @@ -7,7 +7,6 @@ gdb, lldb, cmake_modules, - crypto3, enableDebugging, enableDebug ? false, runTests ? false, @@ -17,7 +16,7 @@ let in stdenv.mkDerivation { name = "Parallel Crypto3"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^crypto3(/.*)?$" "^parallel-crypto3(/.*)?$" "CMakeLists.txt"]; hardeningDisable = [ "fortify" ]; nativeBuildInputs = [ cmake ninja pkg-config ] ++ @@ -27,15 +26,20 @@ in stdenv.mkDerivation { # enableDebugging will keep debug symbols in boost propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ]; - buildInputs = [cmake_modules crypto3]; + buildInputs = [cmake_modules]; cmakeFlags = [ (if runTests then "-DBUILD_TESTS=TRUE" else "") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + "-DPARALLEL_CRYPTO3_ENABLE=TRUE" ]; - doCheck = runTests; # tests are inside crypto3-tests derivation + doCheck = runTests; # tests are inside parallel-crypto3-tests derivation + + checkPhase = '' + cd parallel-crypto3 && ctest --verbose --output-on-failure -R && cd .. + ''; shellHook = '' PS1="\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ " diff --git a/parallel-crypto3/CMakeLists.txt b/parallel-crypto3/CMakeLists.txt index ba5454ff3a..c49a615f43 100644 --- a/parallel-crypto3/CMakeLists.txt +++ b/parallel-crypto3/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 3.22 FATAL_ERROR) project(parallel-crypto3) -find_package(CM) +find_package(CM REQUIRED) +include(CMConfig) if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") @@ -29,31 +30,24 @@ if(CMAKE_EXPORT_COMPILE_COMMANDS) endif() # TODO: check what is actually required here -include(CMConfig) include(CMSetupVersion) # TODO: beutify entire cmake tree of parallel crypto3 modules the same way we did in origin crypto3 -find_package(Boost REQUIRED COMPONENTS filesystem log program_options thread random unit_test_framework) -find_package(crypto3 REQUIRED) - -# HACK: since there are no more crypto3::submodule targets, we have to ALIAS any used -# target of such type to recently introduced crypto3::all target -# TODO: update dependencies in actor modules -add_library(crypto3::algebra ALIAS crypto3::all) -add_library(crypto3::block ALIAS crypto3::all) -add_library(crypto3::hash ALIAS crypto3::all) -add_library(crypto3::multiprecision ALIAS crypto3::all) -add_library(crypto3::random ALIAS crypto3::all) -add_library(marshalling::core ALIAS crypto3::all) -add_library(marshalling::crypto3_multiprecision ALIAS crypto3::all) -add_library(marshalling::crypto3_algebra ALIAS crypto3::all) -add_library(marshalling::crypto3_zk ALIAS crypto3::all) +find_package(Boost REQUIRED COMPONENTS filesystem log program_options thread random unit_test_framework container) add_subdirectory(libs/parallelization-utils) add_subdirectory(libs/parallel-containers) add_subdirectory(libs/parallel-math) add_subdirectory(libs/parallel-zk) +add_library(${PROJECT_NAME}_all INTERFACE) +add_library(${PROJECT_NAME}::all ALIAS ${PROJECT_NAME}_all) +target_link_libraries(${PROJECT_NAME}_all INTERFACE + actor::containers + actor::math + actor::zk + actor::core) + # Configure package file to be able to import headers include(CMakePackageConfigHelpers) include(GNUInstallDirs) @@ -70,27 +64,3 @@ install( ${CMAKE_CURRENT_BINARY_DIR}/parallel-crypto3Config.cmake DESTINATION ${CONFIG_DIR} ) -# Re-pack crypto3 includes. Don't include the libs, that are re-written multithreaded way. -install(DIRECTORY - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/algebra - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/bench - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/block - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/detail - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/hash - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/multiprecision - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/random - ${PACKAGE_PREFIX_DIR}/include/nil/crypto3/marshalling - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nil/crypto3) - -install(DIRECTORY - ${PACKAGE_PREFIX_DIR}/include/nil/blueprint - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nil) - -install(DIRECTORY - ${PACKAGE_PREFIX_DIR}/include/nil/marshalling - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nil) - -install(DIRECTORY - ${PACKAGE_PREFIX_DIR}/include/nil/detail - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nil) - diff --git a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt index f9eea44abe..86bc6c7241 100644 --- a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt +++ b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt @@ -14,7 +14,8 @@ target_include_directories(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTER cm_test_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} crypto3::random - #crypto3::marshalling-zk + crypto3::benchmark_tools + crypto3::marshalling-zk Boost::unit_test_framework Boost::log ) diff --git a/proof-producer/proof-producer.nix b/proof-producer.nix similarity index 83% rename from proof-producer/proof-producer.nix rename to proof-producer.nix index d2e6af6dc8..bef5113cd4 100644 --- a/proof-producer/proof-producer.nix +++ b/proof-producer.nix @@ -3,7 +3,6 @@ ninja, pkg-config, cmake, - crypto3, boost, gdb, lldb, @@ -17,7 +16,7 @@ let in stdenv.mkDerivation { name = "Proof-producer"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^proof-producer(/.*)?$" "^crypto3(/.*)?$" "^parallel-crypto3(/.*)?$" "CMakeLists.txt"]; hardeningDisable = [ "fortify" ]; nativeBuildInputs = [ cmake ninja pkg-config ] ++ @@ -27,12 +26,13 @@ in stdenv.mkDerivation { # enableDebugging will keep debug symbols in boost propagatedBuildInputs = [ (if enableDebug then (enableDebugging boost) else boost) ]; - buildInputs = [cmake_modules crypto3 ]; + buildInputs = [cmake_modules ]; cmakeFlags = [ "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + "-DPROOF_PRODUCER_ENABLE=TRUE" "-G Ninja" ]; diff --git a/proof-producer/CMakeLists.txt b/proof-producer/CMakeLists.txt index 1b0c74ce65..f430d20323 100644 --- a/proof-producer/CMakeLists.txt +++ b/proof-producer/CMakeLists.txt @@ -87,24 +87,3 @@ endif() 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} -) diff --git a/proof-producer/bin/proof-producer/CMakeLists.txt b/proof-producer/bin/proof-producer/CMakeLists.txt index de01df4893..32c7e696f1 100644 --- a/proof-producer/bin/proof-producer/CMakeLists.txt +++ b/proof-producer/bin/proof-producer/CMakeLists.txt @@ -81,27 +81,18 @@ function(setup_proof_generator_target) endfunction() -find_package(crypto3 QUIET) -if (${crypto3_FOUND}) - # Declare single-threaded target - set(SINGLE_THREADED_TARGET "${CURRENT_PROJECT_NAME}-single-threaded") - message("Declare single-threaded target ${SINGLE_THREADED_TARGET}") - setup_proof_generator_target(TARGET_NAME ${SINGLE_THREADED_TARGET} ADDITIONAL_DEPENDENCIES crypto3::all) - - # Install library - install(TARGETS ${SINGLE_THREADED_TARGET}-lib EXPORT proof-producerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(TARGETS ${SINGLE_THREADED_TARGET} RUNTIME DESTINATION bin) - -else() - find_package(parallel-crypto3 REQUIRED) - set(MULTI_THREADED_TARGET "${CURRENT_PROJECT_NAME}-multi-threaded") - message("Declare multi-threaded target ${MULTI_THREADED_TARGET}") - setup_proof_generator_target(TARGET_NAME ${MULTI_THREADED_TARGET} ADDITIONAL_DEPENDENCIES parallel-crypto3::all) - - # Install library - install(TARGETS ${MULTI_THREADED_TARGET}-lib EXPORT proof-producerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) - install(TARGETS ${MULTI_THREADED_TARGET} RUNTIME DESTINATION bin) -endif() +set(SINGLE_THREADED_TARGET "${CURRENT_PROJECT_NAME}-single-threaded") +setup_proof_generator_target(TARGET_NAME ${SINGLE_THREADED_TARGET} ADDITIONAL_DEPENDENCIES crypto3::all) +set(MULTI_THREADED_TARGET "${CURRENT_PROJECT_NAME}-multi-threaded") +setup_proof_generator_target(TARGET_NAME ${MULTI_THREADED_TARGET} ADDITIONAL_DEPENDENCIES parallel-crypto3::all crypto3::common) + +# Install + +install(TARGETS ${SINGLE_THREADED_TARGET}-lib EXPORT proof-producerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ${SINGLE_THREADED_TARGET} RUNTIME DESTINATION bin) +install(TARGETS ${MULTI_THREADED_TARGET}-lib EXPORT proof-producerTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ${MULTI_THREADED_TARGET} RUNTIME DESTINATION bin) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/readme.md b/readme.md index 383004288f..f318fef740 100644 --- a/readme.md +++ b/readme.md @@ -24,8 +24,7 @@ curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix For most cases, you want to have an incremental build: ``` nix develop .#crypto3-debug-tests -cd crypto3/ -eval "$configurePhase" +eval "$configurePhase" // automatically move to the build directory eval "$buildPhase" eval "$checkPhase" ``` @@ -33,8 +32,7 @@ eval "$checkPhase" if you want to build a single test: ``` nix develop .#crypto3-debug-tests -cd crypto3/ -eval "$configurePhase" +eval "$configurePhase" // automatically move to the build directory ninja TEST_NAME ``` diff --git a/zkevm-framework/zkevm-framework.nix b/zkevm-framework.nix similarity index 75% rename from zkevm-framework/zkevm-framework.nix rename to zkevm-framework.nix index 9f2b076235..868e0b0042 100644 --- a/zkevm-framework/zkevm-framework.nix +++ b/zkevm-framework.nix @@ -6,14 +6,12 @@ boost, gdb, lldb, - crypto3, + cmake_modules, ethash, intx, sszpp, valijson, gtest, - evm-assigner, - proof-producer, enableDebugging, enableDebug ? false, runTests ? false, @@ -23,7 +21,7 @@ let in stdenv.mkDerivation rec { name = "zkevm-framework"; - src = lib.sourceByRegex ./. [ ".*" ]; + src = lib.sourceByRegex ./. ["^zkevm-framework(/.*)?$" "^evm-assigner(/.*)?$" "^proof-producer(/.*)?$" "^crypto3(/.*)?$" "^parallel-crypto3(/.*)?$" "CMakeLists.txt"]; hardeningDisable = [ "fortify" ]; nativeBuildInputs =[ cmake ninja pkg-config ] ++ @@ -33,12 +31,13 @@ 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 intx ethash sszpp valijson gtest]; + buildInputs = [cmake_modules intx ethash sszpp valijson gtest]; cmakeFlags = [ (if runTests then "-DENABLE_TESTS=TRUE" else "") (if enableDebug then "-DCMAKE_BUILD_TYPE=Debug" else "-DCMAKE_BUILD_TYPE=Release") + "-DZKEVM_FRAMEWORK_ENABLE=TRUE" "-G Ninja" ]; @@ -46,8 +45,8 @@ in stdenv.mkDerivation rec { doCheck = runTests; checkPhase = '' - ctest - ninja executables_tests + cd zkevm-framework && ctest + cd .. && ninja executables_tests ''; shellHook = '' diff --git a/zkevm-framework/CMakeLists.txt b/zkevm-framework/CMakeLists.txt index c0394ed226..a197f07953 100644 --- a/zkevm-framework/CMakeLists.txt +++ b/zkevm-framework/CMakeLists.txt @@ -2,16 +2,12 @@ cmake_minimum_required(VERSION 3.27) project(zkEVM-framework) -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) # Add json helpers to module path -set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/libs/json_helpers/cmake ${CMAKE_MODULE_PATH}) -include(GNUInstallDirs) +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/libs/json_helpers/cmake ${CMAKE_MODULE_PATH}) option(BUILD_DOCS "Build documentation" FALSE) option(ENABLE_TESTS "Enable tests" FALSE) -find_package(parallel-crypto3 REQUIRED) - if(DEFINED CMAKE_BUILD_TYPE AND ${CMAKE_BUILD_TYPE} STREQUAL "Debug") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -ggdb") set(BOOST_FORCEINLINE "OFF") # improves debugging traces diff --git a/zkevm-framework/bin/assigner/CMakeLists.txt b/zkevm-framework/bin/assigner/CMakeLists.txt index b739999a7d..b3eb74a9a0 100644 --- a/zkevm-framework/bin/assigner/CMakeLists.txt +++ b/zkevm-framework/bin/assigner/CMakeLists.txt @@ -13,15 +13,13 @@ 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 + proof-producer-multi-threaded-lib Boost::program_options Boost::log Boost::random diff --git a/zkevm-framework/libs/assigner_runner/CMakeLists.txt b/zkevm-framework/libs/assigner_runner/CMakeLists.txt index f6ebfef881..a6c993ed30 100644 --- a/zkevm-framework/libs/assigner_runner/CMakeLists.txt +++ b/zkevm-framework/libs/assigner_runner/CMakeLists.txt @@ -16,14 +16,14 @@ target_include_directories(zkEVMAssignerRunner ) find_package(Boost COMPONENTS REQUIRED log) -find_package(evm-assigner REQUIRED) target_link_libraries(zkEVMAssignerRunner PUBLIC - evm-assigner::evm-assigner + evm-assigner NilCore zkEVMJsonHelpers zkEVMOutputArtifacts zkEVMRpc + crypto3::common Boost::log ) diff --git a/zkevm-framework/libs/output_artifacts/CMakeLists.txt b/zkevm-framework/libs/output_artifacts/CMakeLists.txt index d6eab4c131..bafd984fc4 100644 --- a/zkevm-framework/libs/output_artifacts/CMakeLists.txt +++ b/zkevm-framework/libs/output_artifacts/CMakeLists.txt @@ -1,5 +1,4 @@ find_package(Boost COMPONENTS REQUIRED program_options regex) -find_package(evm-assigner REQUIRED) set(LIBRARY_NAME zkEVMOutputArtifacts) @@ -7,7 +6,7 @@ add_library(${LIBRARY_NAME} SHARED src/output_artifacts.cpp) target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_23) -target_link_libraries(${LIBRARY_NAME} PUBLIC Boost::program_options evm-assigner::evm-assigner PRIVATE Boost::regex) +target_link_libraries(${LIBRARY_NAME} PUBLIC Boost::program_options crypto3::common evm-assigner PRIVATE Boost::regex) target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/zkevm-framework/libs/preset/CMakeLists.txt b/zkevm-framework/libs/preset/CMakeLists.txt index 26ae2ed803..b88eb1b505 100644 --- a/zkevm-framework/libs/preset/CMakeLists.txt +++ b/zkevm-framework/libs/preset/CMakeLists.txt @@ -1,9 +1,8 @@ add_library(zkEVMPreset INTERFACE) find_package(Boost COMPONENTS REQUIRED log) -find_package(evm-assigner REQUIRED) -target_link_libraries(zkEVMPreset INTERFACE Boost::log evm-assigner::evm-assigner) +target_link_libraries(zkEVMPreset INTERFACE Boost::log evm-assigner) target_include_directories(zkEVMPreset INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ diff --git a/zkevm-framework/libs/rpc/CMakeLists.txt b/zkevm-framework/libs/rpc/CMakeLists.txt index f118c691e6..11132107c1 100644 --- a/zkevm-framework/libs/rpc/CMakeLists.txt +++ b/zkevm-framework/libs/rpc/CMakeLists.txt @@ -7,5 +7,6 @@ target_include_directories(zkEVMRpc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include install(TARGETS zkEVMRpc DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) diff --git a/zkevm-framework/tests/bin/CMakeLists.txt b/zkevm-framework/tests/bin/CMakeLists.txt index 7d6460e2db..bbb8f25a07 100644 --- a/zkevm-framework/tests/bin/CMakeLists.txt +++ b/zkevm-framework/tests/bin/CMakeLists.txt @@ -5,10 +5,10 @@ if(ENABLE_EXECUTABLES_TESTS) add_custom_target(test_run_assigner COMMAND $ - -b ${CMAKE_SOURCE_DIR}/bin/assigner/example_data/call_block.json + -b ${CMAKE_CURRENT_LIST_DIR}../../../bin/assigner/example_data/call_block.json -t assignment -e pallas - -s ${CMAKE_SOURCE_DIR}/bin/assigner/example_data/state.json + -s ${CMAKE_CURRENT_LIST_DIR}../../../bin/assigner/example_data/state.json --input "" --input "" --input "" @@ -17,8 +17,8 @@ if(ENABLE_EXECUTABLES_TESTS) --log-level debug DEPENDS $ - ${CMAKE_SOURCE_DIR}/bin/assigner/example_data/call_block.json - ${CMAKE_SOURCE_DIR}/bin/assigner/example_data/state.json + ${CMAKE_CURRENT_LIST_DIR}../../../bin/assigner/example_data/call_block.json + ${CMAKE_CURRENT_LIST_DIR}../../../bin/assigner/example_data/state.json COMMENT "Running assigner integration test" VERBATIM ) @@ -26,7 +26,7 @@ if(ENABLE_EXECUTABLES_TESTS) # Initial integration test with generating data on cluster and passing them into assigner # Step 1: create Nil CLI config file - set(block_generator_script ${CMAKE_SOURCE_DIR}/bin/block_generator/block_generator.py) + set(block_generator_script ${CMAKE_CURRENT_LIST_DIR}../../../bin/block_generator/block_generator.py) add_custom_command( OUTPUT test_config.yaml COMMAND python3 diff --git a/zkevm-framework/tests/libs/assigner_runner/CMakeLists.txt b/zkevm-framework/tests/libs/assigner_runner/CMakeLists.txt index 95e37e9c35..ccc4674f0b 100644 --- a/zkevm-framework/tests/libs/assigner_runner/CMakeLists.txt +++ b/zkevm-framework/tests/libs/assigner_runner/CMakeLists.txt @@ -5,6 +5,6 @@ find_package(Boost COMPONENTS REQUIRED random) target_link_libraries(assigner_runner_test PRIVATE zkEVMAssignerRunner zkEVMPreset GTest::gtest_main Boost::random) target_compile_definitions(assigner_runner_test - PRIVATE BLOCK_CONFIG="${CMAKE_SOURCE_DIR}/bin/assigner/example_data/call_block.json" - PRIVATE STATE_CONFIG="${CMAKE_SOURCE_DIR}/bin/assigner/example_data/state.json") + PRIVATE BLOCK_CONFIG="${CMAKE_CURRENT_LIST_DIR}/../../../bin/assigner/example_data/call_block.json" + PRIVATE STATE_CONFIG="${CMAKE_CURRENT_LIST_DIR}/../../../bin/assigner/example_data/state.json") gtest_discover_tests(assigner_runner_test)