diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 46dbd39..66e73cb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,8 @@ on: jobs: package: name: Build packages - runs-on: ubuntu-latest + runs-on: [self-hosted, heavy] + container: image: rippleci/xbwd-builder steps: @@ -29,12 +30,9 @@ jobs: name: Publish Docker images needs: package env: - # The repo on Docker Hub the image will get pushed to. GHCR will be set by ${{ github.repository_owner }} - DOCKERHUB_REPO: legleux # The the "latest" image will be built from this branch LATEST_BRANCH: main IMAGE_NAME: xbwd - DH_CREDS: "${{ secrets.DOCKERHUB_USER }} ${{ secrets.DOCKERHUB_PW }}" GH_CREDS: ${{ secrets.GITHUB_TOKEN }} steps: @@ -54,22 +52,16 @@ jobs: echo "BASE_IMAGE_NAME=${BASE_IMAGE_NAME}" >> $GITHUB_OUTPUT BRANCH=${GITHUB_REF#refs/heads/} - DH_TAGS="${SHA} ${BRANCH}" GH_TAGS="${SHA} ${BRANCH}" - DH_IMAGE_NAME=${DOCKERHUB_REPO}/${IMAGE_NAME} - echo "DH_IMAGE_NAME=${DH_IMAGE_NAME}" >> $GITHUB_OUTPUT - GH_IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}" echo "GH_IMAGE_NAME=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT if [[ $BRANCH == $LATEST_BRANCH ]]; then echo "Tagging $BRANCH as 'latest'" - DH_TAGS+=" latest" GH_TAGS+=" latest" fi - echo "DH_TAGS=${DH_TAGS}" >> $GITHUB_OUTPUT echo "GH_TAGS=${GH_TAGS}" >> $GITHUB_OUTPUT - name: Build Docker image @@ -80,22 +72,6 @@ jobs: docker build . -t ${IMAGE} --file .github/actions/image/Dockerfile docker run --rm ${IMAGE} /opt/xbwd/bin/xbridge_witnessd --version - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USER }} - password: ${{ secrets.DOCKERHUB_PW }} - - - name: Push to dockerhub - shell: bash - run: | - for tag in ${{ steps.tag_name.outputs.DH_TAGS }}; do - echo "Tagging ${{ steps.tag_name.outputs.BASE_IMAGE_NAME}} to ${{ steps.tag_name.outputs.DH_IMAGE_NAME }}:${tag} for Docker Hub" - docker tag ${{ steps.tag_name.outputs.BASE_IMAGE_NAME}} ${{ steps.tag_name.outputs.DH_IMAGE_NAME }}:${tag} - echo "Pushing ${{ steps.tag_name.outputs.DH_IMAGE_NAME}}:${tag} to Docker Hub" - docker push ${{ steps.tag_name.outputs.DH_IMAGE_NAME}}:${tag} - done - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: 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 55bf058..d41fc9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,25 +19,14 @@ 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) find_package(OpenSSL REQUIRED) find_package(Threads) - -include(XBridgeWitnessNIH) +find_package(xrpl REQUIRED) get_directory_property(has_parent PARENT_DIRECTORY) @@ -58,79 +47,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() @@ -218,7 +134,7 @@ if (tests) src/test/RPCParse_test.cpp src/test/WS_test.cpp ) -endif () #tests +endif () add_executable (${PROJECT_NAME} ${SOURCES} @@ -233,7 +149,7 @@ 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}) -target_link_libraries (${PROJECT_NAME} PUBLIC Ripple::xrpl_core XBridgeWitness::opts +target_link_libraries (${PROJECT_NAME} PUBLIC xrpl::libxrpl XBridgeWitness::opts SOCI::soci_core_static SOCI::soci_sqlite3_static fmt::fmt OpenSSL::Crypto OpenSSL::SSL) if (san) diff --git a/conanfile.py b/conanfile.py index 7f46b13..3008829 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,116 +1,40 @@ from conan import ConanFile from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import re -from sys import platform -class Xrpl(ConanFile): - name = 'xrpl' + +class Xbwd(ConanFile): + name = 'xbwd' license = 'ISC' author = 'John Freeman ' - url = 'https://github.com/xrplf/rippled' - description = 'The XRP Ledger' + url = 'https://github.com/ripple/xbridge_witness_server' + description = 'Witness Server for XRPL Sidechains' 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], + 'tests': [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', + 'fmt/10.1.1', 'openssl/1.1.1u', - 'protobuf/3.21.9', - 'snappy/1.1.10', + 'xrpl/2.0.1-xbwd-headers', 'soci/4.0.3', - 'sqlite3/3.42.0', - 'zlib/1.2.13', - 'fmt/8.1.1' ] 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, + 'xrpl:tests': 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/*' - ) + path = f'{self.recipe_folder}/src/xbwd/app/BuildInfo.cpp' + regex = r'versionString\s?=\s?\"(.*)\"' + with open(path, 'r') as file: + matches = (re.search(regex, line) for line in file) + match = next(m for m in matches if m) + self.version = match.group(1) def layout(self): cmake_layout(self) @@ -119,17 +43,9 @@ def layout(self): 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): @@ -137,15 +53,3 @@ def build(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', - ]