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/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.py b/conanfile.py
deleted file mode 100644
index 7f46b13..0000000
--- a/conanfile.py
+++ /dev/null
@@ -1,151 +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'
- ]
-
- 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
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