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

fix single-threaded include #70

Merged
merged 19 commits into from
Oct 10, 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
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@

#include <chrono>
#include <set>

#include <nil/crypto3/math/polynomial/polynomial.hpp>

#include <nil/crypto3/container/merkle/tree.hpp>
Expand Down Expand Up @@ -137,7 +136,7 @@ namespace nil {

placeholder_proof<FieldType, ParamsType> process() {
PROFILE_SCOPE("Placeholder prover, total time");

BOOST_LOG_TRIVIAL(info) << "running singlethreaded mode";
// 2. Commit witness columns and public_input columns
_commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table->witnesses());
_commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table->public_inputs());
Expand Down
1 change: 0 additions & 1 deletion evm-assigner/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(crypto3 REQUIRED)
find_dependency(intx REQUIRED)
find_dependency(ethash REQUIRED)

Expand Down
4 changes: 2 additions & 2 deletions evm-assigner/lib/assigner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_library(${PROJECT_NAME} STATIC ${evmone_sources})

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)

find_package(crypto3 REQUIRED)
find_package(parallel-crypto3 REQUIRED)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand All @@ -26,7 +26,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/evmone>)

target_link_libraries(${PROJECT_NAME}
PUBLIC intx::intx crypto3::all ethash::keccak)
PUBLIC intx::intx parallel-crypto3::all ethash::keccak)

set_target_properties(
${PROJECT_NAME}
Expand Down
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 52 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,83 +70,97 @@
evm-assigner = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
runTests = false;
enableDebug = false;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
});
evm-assigner-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
});
evm-assigner-debug-tests = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
});
evm-assigner-clang-debug = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
stdenv = pkgs.llvmPackages_19.stdenv;
enableDebug = true;
runTests = false;
crypto3 = crypto3-clang-debug;
crypto3 = parallel-crypto3-clang-debug;
});

zkevm-framework = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = false;
enableDebug = false;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
parallel-crypto3 = parallel-crypto3;
});
zkevm-framework-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
parallel-crypto3 = parallel-crypto3;
});
zkevm-framework-debug-tests = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
crypto3 = parallel-crypto3;
evm-assigner = evm-assigner;
proof-producer = proof-producer;
parallel-crypto3 = parallel-crypto3;
});
zkevm-framework-clang-debug = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
stdenv = pkgs.llvmPackages_19.stdenv;
enableDebug = true;
runTests = false;
crypto3 = crypto3-clang-debug;
crypto3 = parallel-crypto3-clang-debug;
evm-assigner = evm-assigner-clang-debug;
proof-producer = proof-producer-clang-debug;
parallel-crypto3 = parallel-crypto3-clang-debug;
});

proof-producer = (pkgs.callPackage ./proof-producer/proof-producer.nix {
runTests = false;
enableDebug = false;
crypto3 = crypto3;
parallel-crypto3 = parallel-crypto3;
crypto3 = parallel-crypto3;
});
proof-producer-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix {
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
runTests = true;
enableDebug = false;
crypto3 = crypto3;
parallel-crypto3 = parallel-crypto3;
crypto3 = parallel-crypto3;
});
proof-producer-debug-tests = (pkgs.callPackage ./proof-producer/proof-producer.nix {
enableDebug = true;
runTests = true;
crypto3 = crypto3;
parallel-crypto3 = parallel-crypto3;
crypto3 = parallel-crypto3;
});
proof-producer-clang-debug = (pkgs.callPackage ./proof-producer/proof-producer.nix {
stdenv = pkgs.llvmPackages_19.stdenv;
enableDebug = true;
runTests = false;
crypto3 = crypto3-clang-debug;
parallel-crypto3 = parallel-crypto3-clang-debug;
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 {
Expand Down Expand Up @@ -196,49 +210,57 @@
evm-assigner-gcc = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
runTests = true;
enableDebug = false;
crypto3 = packages.crypto3;
crypto3 = packages.parallel-crypto3;
AndreyMlashkin marked this conversation as resolved.
Show resolved Hide resolved
});
evm-assigner-clang = (pkgs.callPackage ./evm-assigner/evm-assigner.nix {
stdenv = pkgs.llvmPackages_19.stdenv;
runTests = true;
enableDebug = false;
crypto3 = crypto3-clang;
crypto3 = parallel-crypto3-clang;
});

zkevm-framework-gcc = (pkgs.callPackage ./zkevm-framework/zkevm-framework.nix {
runTests = true;
enableDebug = false;
crypto3 = packages.crypto3;
evm-assigner = evm-assigner-gcc;
proof-producer = proof-producer-gcc;
parallel-crypto3 = packages.parallel-crypto3;
crypto3 = packages.parallel-crypto3;
});

proof-producer-gcc = (pkgs.callPackage ./proof-producer/proof-producer.nix {
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
runTests = true;
enableDebug = false;
crypto3 = packages.crypto3;
parallel-crypto3 = packages.parallel-crypto3;
crypto3 = packages.parallel-crypto3;
});
proof-producer-clang = (pkgs.callPackage ./proof-producer/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;
parallel-crypto3 = parallel-crypto3-clang;
});

all-clang = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-clang parallel-crypto3-clang evm-assigner-clang proof-producer-clang ];
paths = [ crypto3-clang parallel-crypto3-clang evm-assigner-clang proof-producer-clang proof-producer-singlethreaded-clang ];
akokoshn marked this conversation as resolved.
Show resolved Hide resolved
};
all-sanitizers = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-clang-sanitize ];
};
all-gcc = pkgs.symlinkJoin {
name = "all";
paths = [ crypto3-gcc parallel-crypto3-gcc evm-assigner-gcc zkevm-framework-gcc proof-producer-gcc ];
paths = [ crypto3-gcc parallel-crypto3-gcc evm-assigner-gcc zkevm-framework-gcc proof-producer-gcc proof-producer-singlethreaded-gcc ];
};
default = all-gcc;
};
Expand All @@ -249,7 +271,7 @@
};
single-threaded = {
type = "app";
program = "${self.packages.${system}.proof-producer}/bin/proof-producer-single-threaded";
program = "${self.packages.${system}.proof-producer-singlethreaded}/bin/proof-producer-single-threaded";
};
multi-threaded = {
type = "app";
Expand Down
24 changes: 24 additions & 0 deletions parallel-crypto3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,27 @@ 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)

4 changes: 4 additions & 0 deletions parallel-crypto3/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ include(CMakeFindDependencyMacro)
find_dependency(Boost COMPONENTS REQUIRED
container json filesystem log log_setup program_options thread system unit_test_framework)

if (${crypto3_FOUND})
message(FATAL_ERROR, "Crypto3 shall not be included next to parallel-crypto3!")
endif()

# Protect against multiple inclusion
if (TARGET parallel-crypto3::all)
return()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace nil {

placeholder_proof<FieldType, ParamsType> process() {
PROFILE_SCOPE("Placeholder prover, total time");
BOOST_LOG_TRIVIAL(info) << "running mutithreaded mode";

// 2. Commit witness columns and public_input columns
_commitment_scheme.append_to_batch(VARIABLE_VALUES_BATCH, _polynomial_table->witnesses());
Expand Down
3 changes: 0 additions & 3 deletions proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

find_package(crypto3 REQUIRED)
find_package(parallel-crypto3 REQUIRED)

# TODO: move thread to actor-core
find_package(Boost REQUIRED COMPONENTS filesystem log program_options thread)
if(ENABLE_TESTS)
Expand Down
51 changes: 29 additions & 22 deletions proof-producer/bin/proof-producer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ function(setup_proof_generator_target)

add_library(${ARG_TARGET_NAME}-lib INTERFACE)

set(INTERFACE_LIBS
Boost::filesystem
Boost::log
Boost::thread
)
# 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 INTERFACE ${lib})
list(APPEND INTERFACE_LIBS ${lib})
endforeach()
endif()

Expand All @@ -55,19 +60,13 @@ function(setup_proof_generator_target)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

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

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 @@ -82,19 +81,27 @@ function(setup_proof_generator_target)

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 parallel-crypto3::all)

install(TARGETS ${SINGLE_THREADED_TARGET} ${MULTI_THREADED_TARGET} RUNTIME DESTINATION bin)
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()

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})
2 changes: 0 additions & 2 deletions proof-producer/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@PACKAGE_INIT@

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

include("${CMAKE_CURRENT_LIST_DIR}/proof-producerTargets.cmake")
Loading
Loading