From 9a0bd8e8c12820c4d0794bc8ded654d62ed58eb5 Mon Sep 17 00:00:00 2001 From: Michael Legleux Date: Tue, 13 Feb 2024 11:04:55 -0800 Subject: [PATCH 1/4] Remove old rippled integration The Conan xrpl package contains all the components necessary to build xbwd now. --- Builds/CMake/XBridgeWitnessNIH.cmake | 36 ------- Builds/CMake/deps/Boost.cmake | 51 ---------- Builds/CMake/deps/FindRipple.cmake | 36 ------- CMakeLists.txt | 91 ++--------------- README.md | 141 ++++++++++++++++++++------- conanfile.txt | 13 +++ 6 files changed, 125 insertions(+), 243 deletions(-) delete mode 100644 Builds/CMake/XBridgeWitnessNIH.cmake delete mode 100644 Builds/CMake/deps/Boost.cmake delete mode 100644 Builds/CMake/deps/FindRipple.cmake create mode 100644 conanfile.txt diff --git a/Builds/CMake/XBridgeWitnessNIH.cmake b/Builds/CMake/XBridgeWitnessNIH.cmake deleted file mode 100644 index 5e9e244..0000000 --- a/Builds/CMake/XBridgeWitnessNIH.cmake +++ /dev/null @@ -1,36 +0,0 @@ -#[===================================================================[ - NIH prefix path..this is where we will download - and build any ExternalProjects, and they will hopefully - survive across build directory deletion (manual cleans) - - Copied from rippled https://github.com/ripple/rippled/blob/develop/Builds/CMake/RippledNIH.cmake - Only called if building directly and a Rippled installation was not found. -#]===================================================================] - -string (REGEX REPLACE "[ \\/%]+" "_" gen_for_path ${CMAKE_GENERATOR}) -string (TOLOWER ${gen_for_path} gen_for_path) -# HACK: trying to shorten paths for windows CI (which hits 260 MAXPATH easily) -# @see: https://issues.jenkins-ci.org/browse/JENKINS-38706?focusedCommentId=339847 -string (REPLACE "visual_studio" "vs" gen_for_path ${gen_for_path}) -if (NOT DEFINED NIH_CACHE_ROOT) - if (DEFINED ENV{NIH_CACHE_ROOT}) - set (NIH_CACHE_ROOT $ENV{NIH_CACHE_ROOT}) - else () - set (NIH_CACHE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/.nih_c") - endif () -endif () -set (nih_cache_path - "${NIH_CACHE_ROOT}/${gen_for_path}/${CMAKE_CXX_COMPILER_ID}_${CMAKE_CXX_COMPILER_VERSION}") -if (NOT is_multiconfig) - set (nih_cache_path "${nih_cache_path}/${CMAKE_BUILD_TYPE}") -endif () -file(TO_CMAKE_PATH "${nih_cache_path}" nih_cache_path) -message (STATUS "NIH-EP cache path: ${nih_cache_path}") -## two convenience variables: -set (ep_lib_prefix ${CMAKE_STATIC_LIBRARY_PREFIX}) -set (ep_lib_suffix ${CMAKE_STATIC_LIBRARY_SUFFIX}) - -# this is a setting for FetchContent and needs to be -# a cache variable -# https://cmake.org/cmake/help/latest/module/FetchContent.html#populating-the-content -set (FETCHCONTENT_BASE_DIR ${nih_cache_path} CACHE STRING "" FORCE) diff --git a/Builds/CMake/deps/Boost.cmake b/Builds/CMake/deps/Boost.cmake deleted file mode 100644 index 23ea5e5..0000000 --- a/Builds/CMake/deps/Boost.cmake +++ /dev/null @@ -1,51 +0,0 @@ -find_package(Boost 1.70 REQUIRED - COMPONENTS - chrono - container - context - coroutine - date_time - filesystem - program_options - regex - system - thread -) - -add_library(ripple_boost INTERFACE) -add_library(Ripple::boost ALIAS ripple_boost) -if(XCODE) - target_include_directories(ripple_boost BEFORE INTERFACE ${Boost_INCLUDE_DIRS}) - target_compile_options(ripple_boost INTERFACE --system-header-prefix="boost/") -else() - target_include_directories(ripple_boost SYSTEM BEFORE INTERFACE ${Boost_INCLUDE_DIRS}) -endif() - -target_link_libraries(ripple_boost - INTERFACE - Boost::boost - Boost::chrono - Boost::container - Boost::coroutine - Boost::date_time - Boost::filesystem - Boost::program_options - Boost::regex - Boost::system - Boost::thread) -if(Boost_COMPILER) - target_link_libraries(ripple_boost INTERFACE Boost::disable_autolinking) -endif() -if(san AND is_clang) - # TODO: gcc does not support -fsanitize-blacklist...can we do something else - # for gcc ? - if(NOT Boost_INCLUDE_DIRS AND TARGET Boost::headers) - get_target_property(Boost_INCLUDE_DIRS Boost::headers INTERFACE_INCLUDE_DIRECTORIES) - endif() - message(STATUS "Adding [${Boost_INCLUDE_DIRS}] to sanitizer blacklist") - file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt "src:${Boost_INCLUDE_DIRS}/*") - target_compile_options(opts - INTERFACE - # ignore boost headers for sanitizing - -fsanitize-blacklist=${CMAKE_CURRENT_BINARY_DIR}/san_bl.txt) -endif() diff --git a/Builds/CMake/deps/FindRipple.cmake b/Builds/CMake/deps/FindRipple.cmake deleted file mode 100644 index eff5b21..0000000 --- a/Builds/CMake/deps/FindRipple.cmake +++ /dev/null @@ -1,36 +0,0 @@ -find_path(Ripple_SRC - NAMES src/ripple/protocol/STXChainBridge.h - PATHS ${RIPPLE_SRC_DIR} - NO_CMAKE_SYSTEM_PATH - NO_SYSTEM_ENVIRONMENT_PATH) -if(Ripple_SRC) - set(Ripple_INCLUDE_DIR ${Ripple_SRC}/src) -endif() - -find_library(Ripple_LIBRARY - NAMES xrpl_core - PATHS ${RIPPLE_BIN_DIR} - NO_CMAKE_SYSTEM_PATH - NO_SYSTEM_ENVIRONMENT_PATH) - -if(Ripple_SRC AND Ripple_LIBRARY) - include(FindPackageHandleStandardArgs) - find_package_handle_standard_args(Ripple DEFAULT_MSG - Ripple_INCLUDE_DIR Ripple_LIBRARY) - if(Ripple_FOUND) - add_library(Ripple::xrpl_core STATIC IMPORTED) - set_target_properties(Ripple::xrpl_core PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${Ripple_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${Ripple_LIBRARY}") - target_link_libraries (Ripple::xrpl_core INTERFACE - ${RIPPLE_BIN_DIR}/src/ed25519-donna/libed25519.a - ${RIPPLE_BIN_DIR}/src/secp256k1/src/libsecp256k1.a) - endif() -endif() - -if(Ripple_FOUND) - message("Looking for RIPPLED ... found") -else() - message("Looking for RIPPLED ... NOT found") -endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index c11c6bc..a277c13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,18 +19,8 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED TRUE) set(CMAKE_VERBOSE_MAKEFILE 1) - - -#[===========================================[ - The tool depends on the xrpl_core - library which is defined by the rippled - project. This looks for installed rippled - libs and, if not found, pulls them in with - FetchContent. -#]===========================================] list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake") -#include(deps/Boost) find_package(SOCI REQUIRED) find_package(fmt REQUIRED) find_package(date REQUIRED) @@ -39,6 +29,7 @@ find_package(Threads) find_package(xxHash) include(XBridgeWitnessNIH) +# find_package(xrpl REQUIRED) get_directory_property(has_parent PARENT_DIRECTORY) @@ -59,79 +50,6 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(_DEBUG) endif() -if (NOT has_parent) - find_package(Ripple QUIET) - if (NOT TARGET Ripple::xrpl_core) - include(deps/FindRipple) - if (NOT TARGET Ripple::xrpl_core) - find_package(Git) - - if (NOT GIT_FOUND) - message (FATAL_ERROR "git is required to determine branch name") - endif () - - execute_process (COMMAND ${GIT_EXECUTABLE} "rev-parse" "--abbrev-ref" "HEAD" - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - RESULT_VARIABLE _git_exit_code - OUTPUT_VARIABLE _branch - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET) - if (NOT _git_exit_code EQUAL 0) - message (WARNING "git command failed - deduced branch might be incorrect") - endif () - - # rippled_tag is cache string and can be overriden when configuring - # with -Drippled_tag=commit_or_tag in order to pick a specific - # rippled version to download. Default tag is develop/master/release as - # determined by the branch of this project - if (NOT (_branch STREQUAL "master" OR _branch STREQUAL "release")) - set (rippled_tag "develop" CACHE STRING - "tag/commit of rippled to fetch from if a local install is not found") - else () - set (rippled_tag "${_branch}" CACHE STRING - "tag/commit of rippled to fetch from if a local install is not found") - endif () - message(STATUS "Installed rippled not found... \ - using local copy from tag/commit [${rippled_tag}]") - include (FetchContent) - FetchContent_Declare( - rippled_src - GIT_REPOSITORY https://github.com/XRPLF/rippled.git - GIT_TAG ${rippled_tag} - ) - FetchContent_GetProperties(rippled_src) - if(NOT rippled_src_POPULATED) - message (STATUS "Pausing to download rippled source...") - FetchContent_Populate(rippled_src) - - set (conan_build_type "Release") - if(CMAKE_BUILD_TYPE STREQUAL "Debug") - set (conan_build_type "Debug") - endif() - - set (conan_profile "default") - if(NOT "${CONAN_PROFILE} " STREQUAL " ") - set (conan_profile ${CONAN_PROFILE}) - endif() - - execute_process (COMMAND conan install ${rippled_src_SOURCE_DIR} --build missing --output-folder . -s build_type=${conan_build_type} -pr=${conan_profile} - WORKING_DIRECTORY ${rippled_src_BINARY_DIR} - RESULT_VARIABLE _git_exit_code - OUTPUT_STRIP_TRAILING_WHITESPACE - ECHO_OUTPUT_VARIABLE - ECHO_ERROR_VARIABLE - ) - if (NOT _git_exit_code EQUAL 0) - message (WARNING "conan exit_code: ${_git_exit_code}\n conan command failed - build might be incorrect") - endif () - - option (tests "Build tests" OFF) - add_subdirectory(${rippled_src_SOURCE_DIR} ${rippled_src_BINARY_DIR}) - endif() - endif() - endif () -endif () - if(xbridge_witness_coverage) set(coverage ${xbridge_witness_coverage} CACHE BOOL "gcc/clang only" FORCE) endif() @@ -219,7 +137,7 @@ if (tests) src/test/RPCParse_test.cpp src/test/WS_test.cpp ) -endif () #tests +endif () add_executable (${PROJECT_NAME} ${SOURCES} @@ -234,8 +152,13 @@ if (is_linux) target_link_options(${PROJECT_NAME} PUBLIC "LINKER:-z,relro,-z,now") endif() target_include_directories (${PROJECT_NAME} PRIVATE src ${date_INCLUDE_DIR}) +<<<<<<< HEAD target_link_libraries (${PROJECT_NAME} PUBLIC Ripple::xrpl_core XBridgeWitness::opts SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL xxHash::xxhash) +======= +target_link_libraries (${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts + SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL) +>>>>>>> 75c520c (Remove old rippled integration) if (san) target_compile_options (${PROJECT_NAME} diff --git a/README.md b/README.md index f797356..a654912 100644 --- a/README.md +++ b/README.md @@ -1,71 +1,140 @@ -# Witness Server for XRPL Sidechains -## Table of contents -* [Documentation](#documentation) -* [Build guide](#build-guide) - * [Dependencies](#dependencies) - * [Conan inclusion](#conan-inclusion) - * [Other dependencies](#other-dependencies) - * [Build steps](#build-and-run) -## Documentation + +# Witness Server for XRPL Sidechains + +This is the Witness Server for [XLS-38d Cross-Chain bridge project](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0038d-cross-chain-bridge). "Witness Servers" validate transfers between "door accounts" that connect a locking chain to each issuing chain by listening for transactions on one or both of the chains and signing attestations to prove certain events happened on a chain. + +## Additional documentation - [XRPL Sidechains concept](https://xrpl.org/xrpl-sidechains.html) -- [Cross bridge transactions](https://opensource.ripple.com/docs/xls-38d-cross-chain-bridge/cross-chain-bridges/) +- [Cross bridge transactions](https://xrpl.org/cross-chain-bridges.html#how-do-bridges-work/) - [XRPL-Standards documentation](https://github.com/XRPLF/XRPL-Standards/tree/master/XLS-0038d-cross-chain-bridge) -## Build guide -### Dependencies +## Minimum Requirements + +- [Python 3.7](https://www.python.org/downloads/) +- [Conan 1.55](https://conan.io/downloads.html) Conan 2.0 is **_not_** supported yet +- [CMake 3.20](https://cmake.org/download/) -#### Conan inclusion +| Compiler | Version | +|-------------|---------| +| GCC | 11 | +| Clang | 13 | +| Apple clang | 15 | -This project depends on conan (v1.5 and higher, v2.0 not supported) to build it's dependencies. See [conan doc](https://docs.conan.io/1/installation.html) to install conan. +## Build and run -#### Other dependencies +1. Create a build directory and `cd` into it. -* C++20 compiler (gcc >=11, clang >=13) -* [cmake](https://cmake.org) - at least 3.20 +```bash +mkdir .build && cd .build +``` +2. Configure Conan. -### Build and run +Add Ripple's Artifactory as a Conan remote to source the `libxrpl` Conan package. -1) Create a build directory. For example: build -2) Change to that directory. -3) Configure conan (once before very 1st build) +```bash +conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod -``` bash +``` +
+ Optional local development of xrpl library + +The Conan `xrpl` recipe is also available by checking out the [`rippled` source](https://github.com/XRPLF/rippled.git) and exporting the recipe locally. + +```bash +git clone https://github.com/XRPLF/rippled.git +cd rippled +conan export . +``` +
+ +```bash conan profile update settings.cppstd=20 default conan profile update settings.compiler.libcxx=libstdc++11 default -conan profile update settings.arch=x86_64 default ``` +
+
+ Example Conan profiles + +### Linux +```ini + [settings] + arch=x86_64 + arch_build=x86_64 + os=Linux + os_build=Linux + build_type=Release + compiler=gcc + compiler.cppstd=20 + compiler.libcxx=libstdc++11 + compiler.version=11 +``` +### macOS -4) Run conan. The command is: +On macOS [you may get an error from Boost](https://github.com/XRPLF/rippled/blob/develop/BUILD.md#call-to-async_teardown-is-ambiguous) +which requires adding some CMake flags to your Conan profile. +``` +conan profile update 'env.CXXFLAGS="-DBOOST_ASIO_DISABLE_CONCEPTS"' default +conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_ASIO_DISABLE_CONCEPTS"]' default +``` -``` bash -conan install -b missing -s build_type=Release --output-folder . .. +```ini +[settings] +os=Macos +os_build=Macos +arch=armv8 +arch_build=armv8 +compiler=apple-clang +compiler.version=15 +build_type=Release +compiler.cppstd=20 +compiler.libcxx=libc++ +[options] +[conf] +tools.build:cxxflags=['-DBOOST_ASIO_DISABLE_CONCEPTS'] +[build_requires] +[env] +CXXFLAGS=-DBOOST_ASIO_DISABLE_CONCEPTS ``` +
+ +3. Run Conan to install and/or build dependencies. -5) Create a build file (replace .. with the appropriate directory). 2 pckage system supported - deb and rpm: -* 5.1 Default. If you have [rippled](https://github.com/XRPLF/rippled/tree/develop) installed by your packet manager - cmake will try to find it. If nothing found - this setup will download rippled and build it. ``` bash -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/generators/conan_toolchain.cmake -DPKG=deb .. +conan install .. \ + --output-folder . \ + --build missing \ + --settings build_type=Release ``` -* 5.2 If you have [rippled](https://github.com/XRPLF/rippled/tree/develop) build from source you can use it +4. Configure CMake. + ``` bash -cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=build/generators/conan_toolchain.cmake -DRIPPLE_SRC_DIR=/home/user/repo/rippled -DRIPPLE_BIN_DIR=/home/user/repo/rippled/build-release -DPKG=deb .. +cmake .. \ + -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake ``` -6) Build the project: +5. Build with CMake. ``` bash -make -j $(nproc) +cmake --build --parallel $(nproc) ``` -7) Run +6. Run the unit tests. ``` bash -./xbridge_witnessd --conf /home/user/repo/config.json +./xbridge_witnessd --unittest ``` -Check for config examples in documenation + +[Check the documentation for configuration examples.](https://xrpl.org/witness-servers.html#witness-server-configuration) + +## Additional help + +Additional help for Conan/CMake issues may be found in [`rippled`'s build instructions.](https://github.com/XRPLF/rippled/blob/develop/BUILD.md) + +Feel free to open an [issue](https://github.com/ripple/xbridge_witness/issues) if you have a feature request or something doesn't work as expected. diff --git a/conanfile.txt b/conanfile.txt new file mode 100644 index 0000000..715935d --- /dev/null +++ b/conanfile.txt @@ -0,0 +1,13 @@ +[requires] +fmt/10.1.1 +openssl/1.1.1u +xrpl/2.1.0-rc1 +soci/4.0.3 + +[generators] +CMakeDeps +CMakeToolchain + +[options] +xrpl:tests=False +xrpl:rocksdb=False From d68775d0ab8280f4c4e466e56d1c6afbe0fba45e Mon Sep 17 00:00:00 2001 From: Michael Legleux Date: Tue, 13 Feb 2024 11:30:44 -0800 Subject: [PATCH 2/4] Build packages with libxrpl --- Builds/CMake/packaging/build_packages.sh | 15 ++-- CMakeLists.txt | 100 +++++++++++------------ 2 files changed, 58 insertions(+), 57 deletions(-) diff --git a/Builds/CMake/packaging/build_packages.sh b/Builds/CMake/packaging/build_packages.sh index f7a5a77..81c956f 100755 --- a/Builds/CMake/packaging/build_packages.sh +++ b/Builds/CMake/packaging/build_packages.sh @@ -7,7 +7,6 @@ bin_dir="${src_dir}/build" pkg_dir="${src_dir}/packages" build_config=Release conan_packages_to_build="missing" -#conan_profile="default" nproc=$(($(nproc) - 2)) if [ $nproc -lt 3 ]; then @@ -21,10 +20,14 @@ if [ $ID = centos ]; then source /opt/rh/rh-python38/enable conan_packages_to_build="" # blank bc all dependencies need to be built for CentOS 7 currently #conan_profile="centos" # TODO: Make a "centos" profile and upload the bin pkgs - #conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod || true fi -conan profile new default --detect +if ! (conan remote list | grep conan-non-prod); then + conan remote add --insert 0 conan-non-prod http://18.143.149.228:8081/artifactory/api/conan/conan-non-prod +fi +if ! (conan profile list | grep default); then + conan profile new default --detect; +fi conan profile update settings.compiler.cppstd=20 default conan profile update settings.compiler.libcxx=libstdc++11 default @@ -39,7 +42,7 @@ cmake \ -B "${bin_dir}" \ -DCMAKE_BUILD_TYPE=${build_config} \ -DPKG=deb \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=conan_toolchain.cmake \ cmake \ --build "${bin_dir}" \ @@ -51,8 +54,8 @@ cmake \ -S "${src_dir}" \ -B "${bin_dir}" \ -DCMAKE_BUILD_TYPE=${build_config} \ - -DPKG=rpm \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake + -DCMAKE_TOOLCHAIN_FILE:FILEPATH=conan_toolchain.cmake \ + -DPKG=rpm cmake \ --build "${bin_dir}" \ diff --git a/CMakeLists.txt b/CMakeLists.txt index a277c13..a9db31b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ -cmake_minimum_required (VERSION 3.20) -project (xbridge_witnessd) +cmake_minimum_required(VERSION 3.20) +project(xbridge_witnessd) -if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11)) message(FATAL_ERROR "Use gcc >= 11.0") -elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)) +elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13)) message(FATAL_ERROR "Use clang >= 13.0") endif() @@ -33,20 +33,13 @@ include(XBridgeWitnessNIH) get_directory_property(has_parent PARENT_DIRECTORY) -if(coverage) - # Rippled also responds to the "coverage" flag, so clear it if it's set until - # the dependency is set up. - set(xbridge_witness_coverage ${coverage}) - set(coverage OFF CACHE BOOL "gcc/clang only" FORCE) -endif() - add_compile_definitions( BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT BOOST_CONTAINER_FWD_BAD_DEQUE HAS_UNCAUGHT_EXCEPTIONS=1 ) -if (CMAKE_BUILD_TYPE STREQUAL "Debug") +if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(_DEBUG) endif() @@ -55,31 +48,31 @@ if(xbridge_witness_coverage) endif() # this one is a string and therefore can't be an option -set (san "" CACHE STRING "On gcc & clang, add sanitizer instrumentation") -set_property (CACHE san PROPERTY STRINGS ";undefined;memory;address;thread") -if (san) - string (TOLOWER ${san} san) - set (SAN_FLAG "-fsanitize=${san}") - set (SAN_LIB "") - if (is_gcc) - if (san STREQUAL "address") - set (SAN_LIB "asan") - elseif (san STREQUAL "thread") - set (SAN_LIB "tsan") - elseif (san STREQUAL "memory") - set (SAN_LIB "msan") - elseif (san STREQUAL "undefined") - set (SAN_LIB "ubsan") - endif () - endif () - set (_saved_CRL ${CMAKE_REQUIRED_LIBRARIES}) - set (CMAKE_REQUIRED_LIBRARIES "${SAN_FLAG};${SAN_LIB}") - check_cxx_compiler_flag (${SAN_FLAG} COMPILER_SUPPORTS_SAN) - set (CMAKE_REQUIRED_LIBRARIES ${_saved_CRL}) - if (NOT COMPILER_SUPPORTS_SAN) - message (FATAL_ERROR "${san} sanitizer does not seem to be supported by your compiler") - endif () -endif () +set(san "" CACHE STRING "On gcc & clang, add sanitizer instrumentation") +set_property(CACHE san PROPERTY STRINGS ";undefined;memory;address;thread") +if(san) + string(TOLOWER ${san} san) + set(SAN_FLAG "-fsanitize=${san}") + set(SAN_LIB "") + if(is_gcc) + if(san STREQUAL "address") + set(SAN_LIB "asan") + elseif(san STREQUAL "thread") + set(SAN_LIB "tsan") + elseif(san STREQUAL "memory") + set(SAN_LIB "msan") + elseif(san STREQUAL "undefined") + set(SAN_LIB "ubsan") + endif() + endif() + set(_saved_CRL ${CMAKE_REQUIRED_LIBRARIES}) + set(CMAKE_REQUIRED_LIBRARIES "${SAN_FLAG};${SAN_LIB}") + check_cxx_compiler_flag(${SAN_FLAG} COMPILER_SUPPORTS_SAN) + set(CMAKE_REQUIRED_LIBRARIES ${_saved_CRL}) + if(NOT COMPILER_SUPPORTS_SAN) + message(FATAL_ERROR "${san} sanitizer does not seem to be supported by your compiler") + endif() +endif() include(XBridgeWitnessSanity) include(XBridgeWitnessCov) @@ -128,7 +121,7 @@ set(SOURCES option(tests "Enable unit tests" ON) -if (tests) +if(tests) set(UNIT_TESTS src/test/Config_test.cpp src/test/DB_test.cpp @@ -139,51 +132,56 @@ if (tests) ) endif () -add_executable (${PROJECT_NAME} +add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${UNIT_TESTS} ) -install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) +install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) target_compile_options(${PROJECT_NAME} PUBLIC "-fstack-protector-strong") -if (is_linux) +if(is_linux) target_link_options(${PROJECT_NAME} PUBLIC "LINKER:-z,relro,-z,now") endif() +<<<<<<< HEAD target_include_directories (${PROJECT_NAME} PRIVATE src ${date_INCLUDE_DIR}) <<<<<<< HEAD target_link_libraries (${PROJECT_NAME} PUBLIC Ripple::xrpl_core XBridgeWitness::opts SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL xxHash::xxhash) ======= target_link_libraries (${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts +======= +target_include_directories(${PROJECT_NAME} PRIVATE src ${date_INCLUDE_DIR}) +target_link_libraries(${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts +>>>>>>> a480329 (Build packages with libxrpl) SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL) >>>>>>> 75c520c (Remove old rippled integration) -if (san) - target_compile_options (${PROJECT_NAME} +if(san) + target_compile_options(${PROJECT_NAME} INTERFACE # sanitizers recommend minimum of -O1 for reasonable performance $<$:-O1> ${SAN_FLAG} -fno-omit-frame-pointer) - target_compile_definitions (${PROJECT_NAME} + target_compile_definitions(${PROJECT_NAME} INTERFACE $<$:SANITIZER=ASAN> $<$:SANITIZER=TSAN> $<$:SANITIZER=MSAN> $<$:SANITIZER=UBSAN>) - target_link_libraries (${PROJECT_NAME} INTERFACE ${SAN_FLAG} ${SAN_LIB}) -endif () + target_link_libraries(${PROJECT_NAME} INTERFACE ${SAN_FLAG} ${SAN_LIB}) +endif() -if (has_parent) - set_target_properties (${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_ALL ON) - set_target_properties (${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) -endif () +if(has_parent) + set_target_properties(${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_ALL ON) + set_target_properties(${PROJECT_NAME} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD ON) +endif() #fix for MAC get_target_property(FMT_INC_DIRS fmt::fmt INTERFACE_INCLUDE_DIRECTORIES) -list (GET FMT_INC_DIRS 0 FMT_INC_DIR) +list(GET FMT_INC_DIRS 0 FMT_INC_DIR) target_include_directories(${PROJECT_NAME} BEFORE PRIVATE ${FMT_INC_DIR}) include(packaging/package) From 1e87a2b494d69e9271663ad50a936faed17db705 Mon Sep 17 00:00:00 2001 From: Michael Legleux Date: Tue, 2 Apr 2024 16:37:19 -0700 Subject: [PATCH 3/4] include xxhash --- CMakeLists.txt | 34 ++++++----- conanfile.py | 152 ------------------------------------------------- conanfile.txt | 3 +- 3 files changed, 18 insertions(+), 171 deletions(-) delete mode 100644 conanfile.py diff --git a/CMakeLists.txt b/CMakeLists.txt index a9db31b..4682182 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,15 +21,13 @@ set(CMAKE_VERBOSE_MAKEFILE 1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake") -find_package(SOCI REQUIRED) -find_package(fmt REQUIRED) find_package(date REQUIRED) +find_package(fmt REQUIRED) find_package(OpenSSL REQUIRED) +find_package(SOCI REQUIRED) find_package(Threads) -find_package(xxHash) - -include(XBridgeWitnessNIH) -# find_package(xrpl REQUIRED) +find_package(xrpl REQUIRED) +find_package(xxHash REQUIRED) get_directory_property(has_parent PARENT_DIRECTORY) @@ -144,19 +142,19 @@ target_compile_options(${PROJECT_NAME} PUBLIC "-fstack-protector-strong") if(is_linux) target_link_options(${PROJECT_NAME} PUBLIC "LINKER:-z,relro,-z,now") endif() -<<<<<<< HEAD + target_include_directories (${PROJECT_NAME} PRIVATE src ${date_INCLUDE_DIR}) -<<<<<<< HEAD -target_link_libraries (${PROJECT_NAME} PUBLIC Ripple::xrpl_core XBridgeWitness::opts - SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL xxHash::xxhash) -======= -target_link_libraries (${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts -======= -target_include_directories(${PROJECT_NAME} PRIVATE src ${date_INCLUDE_DIR}) -target_link_libraries(${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts ->>>>>>> a480329 (Build packages with libxrpl) - SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL) ->>>>>>> 75c520c (Remove old rippled integration) +target_link_libraries(${PROJECT_NAME} + PUBLIC + xrpl::libxrpl + XBridgeWitness::opts + SOCI::soci_core_static + SOCI::soci_sqlite3_static + fmt::fmt + OpenSSL::Crypto + OpenSSL::SSL + xxHash::xxhash + ) if(san) target_compile_options(${PROJECT_NAME} diff --git a/conanfile.py b/conanfile.py deleted file mode 100644 index 58a872f..0000000 --- a/conanfile.py +++ /dev/null @@ -1,152 +0,0 @@ -from conan import ConanFile -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout -import re -from sys import platform - -class Xrpl(ConanFile): - name = 'xrpl' - - license = 'ISC' - author = 'John Freeman ' - url = 'https://github.com/xrplf/rippled' - description = 'The XRP Ledger' - settings = 'os', 'compiler', 'build_type', 'arch' - options = { - 'assertions': [True, False], - 'coverage': [True, False], - 'fPIC': [True, False], - 'jemalloc': [True, False], - 'reporting': [True, False], - 'rocksdb': [True, False], - 'shared': [True, False], - 'static': [True, False], - 'tests': [True, False], - 'unity': [True, False], - } - - requires = [ - 'boost/1.82.0', - 'date/3.0.1', - 'grpc/1.50.1', - 'libarchive/3.6.2', - 'lz4/1.9.3', - 'nudb/2.0.8', - 'openssl/1.1.1u', - 'protobuf/3.21.9', - 'snappy/1.1.10', - 'soci/4.0.3', - 'sqlite3/3.42.0', - 'zlib/1.2.13', - 'fmt/8.1.1', - 'xxhash/0.8.2' - ] - - default_options = { - 'assertions': False, - 'coverage': False, - 'fPIC': True, - 'jemalloc': False, - 'reporting': False, - 'rocksdb': False, - 'shared': False, - 'static': True, - 'tests': True, - 'unity': False, - - 'cassandra-cpp-driver:shared': False, - 'cassandra-cpp-driver:use_atomic': None, - 'date:header_only': True, - 'grpc:shared': False, - 'grpc:secure': True, - 'libarchive:shared': False, - 'libarchive:with_acl': False, - 'libarchive:with_bzip2': False, - 'libarchive:with_cng': False, - 'libarchive:with_expat': False, - 'libarchive:with_iconv': False, - 'libarchive:with_libxml2': False, - 'libarchive:with_lz4': True, - 'libarchive:with_lzma': False, - 'libarchive:with_lzo': False, - 'libarchive:with_nettle': False, - 'libarchive:with_openssl': False, - 'libarchive:with_pcreposix': False, - 'libarchive:with_xattr': False, - 'libarchive:with_zlib': False, - 'libpq:shared': False, - 'lz4:shared': False, - 'openssl:shared': False, - 'protobuf:shared': False, - 'protobuf:with_zlib': True, - 'rocksdb:enable_sse': False, - 'rocksdb:lite': False, - 'rocksdb:shared': False, - 'rocksdb:use_rtti': True, - 'rocksdb:with_jemalloc': False, - 'rocksdb:with_lz4': True, - 'rocksdb:with_snappy': True, - 'snappy:shared': False, - 'soci:shared': False, - 'soci:with_sqlite3': True, - 'soci:with_boost': True, - } - - def set_version(self): - self.version = "1.0.0" - - def configure(self): - if self.settings.compiler == 'apple-clang': - self.options['boost'].visibility = 'global' - - def requirements(self): - if self.options.jemalloc: - self.requires('jemalloc/5.3.0') - if self.options.reporting: - self.requires('cassandra-cpp-driver/2.15.3') - self.requires('libpq/14.7') - if self.options.rocksdb: - self.requires('rocksdb/6.29.5') - if platform.startswith('linux'): - self.requires('liburing/2.2') - - exports_sources = ( - 'CMakeLists.txt', 'Builds/*', 'bin/getRippledInfo', 'src/*', 'cfg/*' - ) - - def layout(self): - cmake_layout(self) - # Fix this setting to follow the default introduced in Conan 1.48 - # to align with our build instructions. - self.folders.generators = 'build/generators' - - generators = 'CMakeDeps' - def generate(self): - tc = CMakeToolchain(self) - tc.variables['tests'] = self.options.tests - tc.variables['assert'] = self.options.assertions - tc.variables['coverage'] = self.options.coverage - tc.variables['jemalloc'] = self.options.jemalloc - tc.variables['reporting'] = self.options.reporting - tc.variables['rocksdb'] = self.options.rocksdb - tc.variables['BUILD_SHARED_LIBS'] = self.options.shared - tc.variables['static'] = self.options.static - tc.variables['unity'] = self.options.unity - tc.generate() - - def build(self): - cmake = CMake(self) - cmake.verbose = True - cmake.configure() - cmake.build() - - def package(self): - cmake = CMake(self) - cmake.verbose = True - cmake.install() - - def package_info(self): - self.cpp_info.libs = [ - 'libxrpl_core.a', - 'libed25519.a', - 'libsecp256k1.a', - ] diff --git a/conanfile.txt b/conanfile.txt index 715935d..9b12283 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,8 +1,9 @@ [requires] fmt/10.1.1 openssl/1.1.1u -xrpl/2.1.0-rc1 +xrpl/2.2.0-b1 soci/4.0.3 +xxhash/0.8.2 [generators] CMakeDeps From 3e6d7ec6be4fd86125addb269408defac033df1a Mon Sep 17 00:00:00 2001 From: Michael Legleux Date: Thu, 4 Apr 2024 11:52:27 -0700 Subject: [PATCH 4/4] xbwd does not use xxhash; xxhash dep fixed in rippled-2.2.0-b2 --- CMakeLists.txt | 2 -- conanfile.txt | 3 +-- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4682182..a9a7dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ find_package(OpenSSL REQUIRED) find_package(SOCI REQUIRED) find_package(Threads) find_package(xrpl REQUIRED) -find_package(xxHash REQUIRED) get_directory_property(has_parent PARENT_DIRECTORY) @@ -153,7 +152,6 @@ target_link_libraries(${PROJECT_NAME} fmt::fmt OpenSSL::Crypto OpenSSL::SSL - xxHash::xxhash ) if(san) diff --git a/conanfile.txt b/conanfile.txt index 9b12283..e127d2f 100644 --- a/conanfile.txt +++ b/conanfile.txt @@ -1,9 +1,8 @@ [requires] fmt/10.1.1 openssl/1.1.1u -xrpl/2.2.0-b1 +xrpl/2.2.0-b2 soci/4.0.3 -xxhash/0.8.2 [generators] CMakeDeps