From 80379927e8ced6414571a31d41e1f6b6d85b3c79 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 22 Mar 2024 09:20:06 -0500 Subject: [PATCH 01/16] Remove unused files --- Builds/CMake/CMakeFuncs.cmake | 159 ------- Builds/CMake/CMake_sqlite3.txt | 60 --- Builds/CMake/SociConfig.cmake.patched | 106 ----- Builds/CMake/echo_file.cmake | 17 - Builds/README.md | 1 - Builds/Test.py | 405 ------------------ Builds/build_all.sh | 7 - src/ripple/beast/unit_test/main.cpp | 113 ----- src/ripple/json/TODO.md | 7 - src/ripple/json/impl/LICENSE | 1 - src/ripple/json/impl/version | 1 - src/ripple/rpc/handlers/NodeToShardStatus.cpp | 0 src/ripple/shamap/impl/CMakeLists.txt | 0 13 files changed, 877 deletions(-) delete mode 100644 Builds/CMake/CMake_sqlite3.txt delete mode 100644 Builds/CMake/SociConfig.cmake.patched delete mode 100644 Builds/CMake/echo_file.cmake delete mode 100644 Builds/README.md delete mode 100755 Builds/Test.py delete mode 100755 Builds/build_all.sh delete mode 100644 src/ripple/beast/unit_test/main.cpp delete mode 100644 src/ripple/json/TODO.md delete mode 100644 src/ripple/json/impl/LICENSE delete mode 100644 src/ripple/json/impl/version delete mode 100644 src/ripple/rpc/handlers/NodeToShardStatus.cpp delete mode 100644 src/ripple/shamap/impl/CMakeLists.txt diff --git a/Builds/CMake/CMakeFuncs.cmake b/Builds/CMake/CMakeFuncs.cmake index fb60fd9b4eb..a4c66a120dd 100644 --- a/Builds/CMake/CMakeFuncs.cmake +++ b/Builds/CMake/CMakeFuncs.cmake @@ -1,4 +1,3 @@ - macro(group_sources_in source_dir curdir) file(GLOB children RELATIVE ${source_dir}/${curdir} ${source_dir}/${curdir}/*) @@ -29,165 +28,8 @@ macro (exclude_if_included target_) endif () endmacro () -function (print_ep_logs _target) - ExternalProject_Get_Property (${_target} STAMP_DIR) - add_custom_command(TARGET ${_target} POST_BUILD - COMMENT "${_target} BUILD OUTPUT" - COMMAND ${CMAKE_COMMAND} - -DIN_FILE=${STAMP_DIR}/${_target}-build-out.log - -P ${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake/echo_file.cmake - COMMAND ${CMAKE_COMMAND} - -DIN_FILE=${STAMP_DIR}/${_target}-build-err.log - -P ${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake/echo_file.cmake) -endfunction () - -#[=========================================================[ - This is a function override for one function in the - standard ExternalProject module. We want to change - the generated build script slightly to include printing - the build logs in the case of failure. Those modifications - have been made here. This function override could break - in the future if the ExternalProject module changes internal - function names or changes the way it generates the build - scripts. - See: - https://gitlab.kitware.com/cmake/cmake/blob/df1ddeec128d68cc636f2dde6c2acd87af5658b6/Modules/ExternalProject.cmake#L1855-1952 -#]=========================================================] - -function(_ep_write_log_script name step cmd_var) - ExternalProject_Get_Property(${name} stamp_dir) - set(command "${${cmd_var}}") - - set(make "") - set(code_cygpath_make "") - if(command MATCHES "^\\$\\(MAKE\\)") - # GNU make recognizes the string "$(MAKE)" as recursive make, so - # ensure that it appears directly in the makefile. - string(REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}") - set(make "-Dmake=$(MAKE)") - - if(WIN32 AND NOT CYGWIN) - set(code_cygpath_make " -if(\${make} MATCHES \"^/\") - execute_process( - COMMAND cygpath -w \${make} - OUTPUT_VARIABLE cygpath_make - ERROR_VARIABLE cygpath_make - RESULT_VARIABLE cygpath_error - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - if(NOT cygpath_error) - set(make \${cygpath_make}) - endif() -endif() -") - endif() - endif() - - set(config "") - if("${CMAKE_CFG_INTDIR}" MATCHES "^\\$") - string(REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}") - set(config "-Dconfig=${CMAKE_CFG_INTDIR}") - endif() - - # Wrap multiple 'COMMAND' lines up into a second-level wrapper - # script so all output can be sent to one log file. - if(command MATCHES "(^|;)COMMAND;") - set(code_execute_process " -${code_cygpath_make} -execute_process(COMMAND \${command} RESULT_VARIABLE result) -if(result) - set(msg \"Command failed (\${result}):\\n\") - foreach(arg IN LISTS command) - set(msg \"\${msg} '\${arg}'\") - endforeach() - message(FATAL_ERROR \"\${msg}\") -endif() -") - set(code "") - set(cmd "") - set(sep "") - foreach(arg IN LISTS command) - if("x${arg}" STREQUAL "xCOMMAND") - if(NOT "x${cmd}" STREQUAL "x") - string(APPEND code "set(command \"${cmd}\")${code_execute_process}") - endif() - set(cmd "") - set(sep "") - else() - string(APPEND cmd "${sep}${arg}") - set(sep ";") - endif() - endforeach() - string(APPEND code "set(command \"${cmd}\")${code_execute_process}") - file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$-impl.cmake" CONTENT "${code}") - set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$-impl.cmake) - endif() - - # Wrap the command in a script to log output to files. - set(script ${stamp_dir}/${name}-${step}-$.cmake) - set(logbase ${stamp_dir}/${name}-${step}) - set(code " -${code_cygpath_make} -function (_echo_file _fil) - file (READ \${_fil} _cont) - execute_process (COMMAND \${CMAKE_COMMAND} -E echo \"\${_cont}\") -endfunction () -set(command \"${command}\") -execute_process( - COMMAND \${command} - RESULT_VARIABLE result - OUTPUT_FILE \"${logbase}-out.log\" - ERROR_FILE \"${logbase}-err.log\" - ) -if(result) - set(msg \"Command failed: \${result}\\n\") - foreach(arg IN LISTS command) - set(msg \"\${msg} '\${arg}'\") - endforeach() - execute_process (COMMAND \${CMAKE_COMMAND} -E echo \"Build output for ${logbase} : \") - _echo_file (\"${logbase}-out.log\") - _echo_file (\"${logbase}-err.log\") - set(msg \"\${msg}\\nSee above\\n\") - message(FATAL_ERROR \"\${msg}\") -else() - set(msg \"${name} ${step} command succeeded. See also ${logbase}-*.log\") - message(STATUS \"\${msg}\") -endif() -") - file(GENERATE OUTPUT "${script}" CONTENT "${code}") - set(command ${CMAKE_COMMAND} ${make} ${config} -P ${script}) - set(${cmd_var} "${command}" PARENT_SCOPE) -endfunction() - find_package(Git) -# function that calls git log to get current hash -function (git_hash hash_val) - # note: optional second extra string argument not in signature - if (NOT GIT_FOUND) - return () - endif () - set (_hash "") - set (_format "%H") - if (ARGC GREATER_EQUAL 2) - string (TOLOWER ${ARGV1} _short) - if (_short STREQUAL "short") - set (_format "%h") - endif () - endif () - execute_process (COMMAND ${GIT_EXECUTABLE} "log" "--pretty=${_format}" "-n1" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - RESULT_VARIABLE _git_exit_code - OUTPUT_VARIABLE _temp_hash - OUTPUT_STRIP_TRAILING_WHITESPACE - ERROR_QUIET) - if (_git_exit_code EQUAL 0) - set (_hash ${_temp_hash}) - endif () - set (${hash_val} "${_hash}" PARENT_SCOPE) -endfunction () - function (git_branch branch_val) if (NOT GIT_FOUND) return () @@ -204,4 +46,3 @@ function (git_branch branch_val) endif () set (${branch_val} "${_branch}" PARENT_SCOPE) endfunction () - diff --git a/Builds/CMake/CMake_sqlite3.txt b/Builds/CMake/CMake_sqlite3.txt deleted file mode 100644 index d80557a9fc6..00000000000 --- a/Builds/CMake/CMake_sqlite3.txt +++ /dev/null @@ -1,60 +0,0 @@ - -#[=========================================================[ - SQLITE doesn't provide build files in the - standard source-only distribution. So we wrote - a simple cmake file and we copy it to the - external project folder so that we can use - this file to build the lib with ExternalProject -#]=========================================================] - -add_library (sqlite3 STATIC sqlite3.c) -#[=========================================================[ - When compiled with SQLITE_THREADSAFE=1, SQLite operates - in serialized mode. In this mode, SQLite can be safely - used by multiple threads with no restriction. - - NOTE: This implies a global mutex! - - When compiled with SQLITE_THREADSAFE=2, SQLite can be - used in a multithreaded program so long as no two - threads attempt to use the same database connection at - the same time. - - NOTE: This is the preferred threading model, but not - currently enabled because we need to investigate our - use-model and concurrency requirements. - - TODO: consider whether any other options should be - used: https://www.sqlite.org/compile.html -#]=========================================================] - -target_compile_definitions (sqlite3 - PRIVATE - SQLITE_THREADSAFE=1 - HAVE_USLEEP=1) -target_compile_options (sqlite3 - PRIVATE - $<$: - -wd4100 - -wd4127 - -wd4232 - -wd4244 - -wd4701 - -wd4706 - -wd4996 - > - $<$>:-Wno-array-bounds>) -install ( - TARGETS - sqlite3 - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include) -install ( - FILES - sqlite3.h - sqlite3ext.h - DESTINATION include) - - diff --git a/Builds/CMake/SociConfig.cmake.patched b/Builds/CMake/SociConfig.cmake.patched deleted file mode 100644 index 11bcd1f3d0f..00000000000 --- a/Builds/CMake/SociConfig.cmake.patched +++ /dev/null @@ -1,106 +0,0 @@ -################################################################################ -# SociConfig.cmake - CMake build configuration of SOCI library -################################################################################ -# Copyright (C) 2010 Mateusz Loskot -# -# Distributed under the Boost Software License, Version 1.0. -# (See accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -################################################################################ - -include(CheckCXXSymbolExists) - -if(WIN32) - check_cxx_symbol_exists("_M_AMD64" "" SOCI_TARGET_ARCH_X64) - if(NOT RTC_ARCH_X64) - check_cxx_symbol_exists("_M_IX86" "" SOCI_TARGET_ARCH_X86) - endif(NOT RTC_ARCH_X64) - # add check for arm here - # see http://msdn.microsoft.com/en-us/library/b0084kay.aspx -else(WIN32) - check_cxx_symbol_exists("__i386__" "" SOCI_TARGET_ARCH_X86) - check_cxx_symbol_exists("__x86_64__" "" SOCI_TARGET_ARCH_X64) - check_cxx_symbol_exists("__arm__" "" SOCI_TARGET_ARCH_ARM) -endif(WIN32) - -if(NOT DEFINED LIB_SUFFIX) - if(SOCI_TARGET_ARCH_X64) - set(_lib_suffix "64") - else() - set(_lib_suffix "") - endif() - set(LIB_SUFFIX ${_lib_suffix} CACHE STRING "Specifies suffix for the lib directory") -endif() - -# -# C++11 Option -# - -if(NOT SOCI_CXX_C11) - set (SOCI_CXX_C11 OFF CACHE BOOL "Build to the C++11 standard") -endif() - -# -# Force compilation flags and set desired warnings level -# - -if (MSVC) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_NONSTDC_NO_WARNING) - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - - if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") - string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /we4266") - endif() - -else() - - set(SOCI_GCC_CLANG_COMMON_FLAGS "") - # "-pedantic -Werror -Wno-error=parentheses -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Woverloaded-virtual -Wredundant-decls -Wno-long-long") - - - if (SOCI_CXX_C11) - set(SOCI_CXX_VERSION_FLAGS "-std=c++11") - else() - set(SOCI_CXX_VERSION_FLAGS "-std=gnu++98") - endif() - - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" OR "${CMAKE_CXX_COMPILER}" MATCHES "clang") - - if(NOT CMAKE_CXX_COMPILER_VERSION LESS 3.1 AND SOCI_ASAN) - set(SOCI_GCC_CLANG_COMMON_FLAGS "${SOCI_GCC_CLANG_COMMON_FLAGS} -fsanitize=address") - endif() - - # enforce C++11 for Clang - set(SOCI_CXX_C11 ON) - set(SOCI_CXX_VERSION_FLAGS "-std=c++11") - add_definitions(-DCATCH_CONFIG_CPP11_NO_IS_ENUM) - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_GCC_CLANG_COMMON_FLAGS} ${SOCI_CXX_VERSION_FLAGS}") - - elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - - if(NOT CMAKE_CXX_COMPILER_VERSION LESS 4.8 AND SOCI_ASAN) - set(SOCI_GCC_CLANG_COMMON_FLAGS "${SOCI_GCC_CLANG_COMMON_FLAGS} -fsanitize=address") - endif() - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SOCI_GCC_CLANG_COMMON_FLAGS} ${SOCI_CXX_VERSION_FLAGS} ") - if (CMAKE_COMPILER_IS_GNUCXX) - if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-variadic-macros") - endif() - endif() - - else() - message(WARNING "Unknown toolset - using default flags to build SOCI") - endif() - -endif() - -# Set SOCI_HAVE_* variables for soci-config.h generator -set(SOCI_HAVE_CXX_C11 ${SOCI_CXX_C11} CACHE INTERNAL "Enables C++11 support") diff --git a/Builds/CMake/echo_file.cmake b/Builds/CMake/echo_file.cmake deleted file mode 100644 index 8a593a7899d..00000000000 --- a/Builds/CMake/echo_file.cmake +++ /dev/null @@ -1,17 +0,0 @@ -#[=========================================================[ - This is a CMake script file that is used to write - the contents of a file to stdout (using the cmake - echo command). The input file is passed via the - IN_FILE variable. -#]=========================================================] - -if (EXISTS ${IN_FILE}) - file (READ ${IN_FILE} contents) - ## only print files that actually have some text in them - if (contents MATCHES "[a-z0-9A-Z]+") - execute_process( - COMMAND - ${CMAKE_COMMAND} -E echo "${contents}") - endif () -endif () - diff --git a/Builds/README.md b/Builds/README.md deleted file mode 100644 index e99ba8c9a49..00000000000 --- a/Builds/README.md +++ /dev/null @@ -1 +0,0 @@ -[Please see the BUILD instructions here](../BUILD.md) diff --git a/Builds/Test.py b/Builds/Test.py deleted file mode 100755 index 29cf8ea8a22..00000000000 --- a/Builds/Test.py +++ /dev/null @@ -1,405 +0,0 @@ -#!/usr/bin/env python - -# This file is part of rippled: https://github.com/ripple/rippled -# Copyright (c) 2012 - 2017 Ripple Labs Inc. -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -# ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -""" -Invocation: - - ./Builds/Test.py - builds and tests all configurations - -The build must succeed without shell aliases for this to work. - -To pass flags to cmake, put them at the very end of the command line, after -the -- flag - like this: - - ./Builds/Test.py -- -j4 # Pass -j4 to cmake --build - - -Common problems: - -1) Boost not found. Solution: export BOOST_ROOT=[path to boost folder] - -2) OpenSSL not found. Solution: export OPENSSL_ROOT=[path to OpenSSL folder] - -3) cmake is not found. Solution: Be sure cmake directory is on your $PATH - -""" -from __future__ import absolute_import, division, print_function, unicode_literals - -import argparse -import itertools -import os -import platform -import re -import shutil -import sys -import subprocess - - -def powerset(iterable): - """powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)""" - s = list(iterable) - return itertools.chain.from_iterable(itertools.combinations(s, r) for r in range(len(s) + 1)) - -IS_WINDOWS = platform.system().lower() == 'windows' -IS_OS_X = platform.system().lower() == 'darwin' - -# CMake -if IS_WINDOWS: - CMAKE_UNITY_CONFIGS = ['Debug', 'Release'] - CMAKE_NONUNITY_CONFIGS = ['Debug', 'Release'] -else: - CMAKE_UNITY_CONFIGS = [] - CMAKE_NONUNITY_CONFIGS = [] -CMAKE_UNITY_COMBOS = { '' : [['rippled'], CMAKE_UNITY_CONFIGS], - '.nounity' : [['rippled'], CMAKE_NONUNITY_CONFIGS] } - -if IS_WINDOWS: - CMAKE_DIR_TARGETS = { ('msvc' + unity,) : targets for unity, targets in - CMAKE_UNITY_COMBOS.items() } -elif IS_OS_X: - CMAKE_DIR_TARGETS = { (build + unity,) : targets - for build in ['debug', 'release'] - for unity, targets in CMAKE_UNITY_COMBOS.items() } -else: - CMAKE_DIR_TARGETS = { (cc + "." + build + unity,) : targets - for cc in ['gcc', 'clang'] - for build in ['debug', 'release', 'coverage', 'profile'] - for unity, targets in CMAKE_UNITY_COMBOS.items() } - -# list of tuples of all possible options -if IS_WINDOWS or IS_OS_X: - CMAKE_ALL_GENERATE_OPTIONS = [tuple(x) for x in powerset(['-GNinja', '-Dassert=true'])] -else: - CMAKE_ALL_GENERATE_OPTIONS = list(set( - [tuple(x) for x in powerset(['-GNinja', '-Dstatic=true', '-Dassert=true', '-Dsan=address'])] + - [tuple(x) for x in powerset(['-GNinja', '-Dstatic=true', '-Dassert=true', '-Dsan=thread'])])) - -parser = argparse.ArgumentParser( - description='Test.py - run ripple tests' -) - -parser.add_argument( - '--all', '-a', - action='store_true', - help='Build all configurations.', -) - -parser.add_argument( - '--keep_going', '-k', - action='store_true', - help='Keep going after one configuration has failed.', -) - -parser.add_argument( - '--silent', '-s', - action='store_true', - help='Silence all messages except errors', -) - -parser.add_argument( - '--verbose', '-v', - action='store_true', - help=('Report more information about which commands are executed and the ' - 'results.'), -) - -parser.add_argument( - '--test', '-t', - default='', - help='Add a prefix for unit tests', -) - -parser.add_argument( - '--testjobs', - default='0', - type=int, - help='Run tests in parallel' -) - -parser.add_argument( - '--ipv6', - action='store_true', - help='Use IPv6 localhost when running unit tests.', -) - -parser.add_argument( - '--clean', '-c', - action='store_true', - help='delete all build artifacts after testing', -) - -parser.add_argument( - '--quiet', '-q', - action='store_true', - help='Reduce output where possible (unit tests)', -) - -parser.add_argument( - '--dir', '-d', - default=(), - nargs='*', - help='Specify one or more CMake dir names. ' - 'Will also be used as -Dtarget= running cmake.' -) - -parser.add_argument( - '--target', - default=(), - nargs='*', - help='Specify one or more CMake build targets. ' - 'Will be used as --target running cmake --build.' - ) - -parser.add_argument( - '--config', - default=(), - nargs='*', - help='Specify one or more CMake build configs. ' - 'Will be used as --config running cmake --build.' - ) - -parser.add_argument( - '--generator_option', - action='append', - help='Specify a CMake generator option. Repeat for multiple options. ' - 'Will be passed to the cmake generator. ' - 'Due to limits of the argument parser, arguments starting with \'-\' ' - 'must be attached to this option. e.g. --generator_option=-GNinja.') - -parser.add_argument( - '--build_option', - action='append', - help='Specify a build option. Repeat for multiple options. ' - 'Will be passed to the build tool via cmake --build. ' - 'Due to limits of the argument parser, arguments starting with \'-\' ' - 'must be attached to this option. e.g. --build_option=-j8.') - -parser.add_argument( - 'extra_args', - default=(), - nargs='*', - help='Extra arguments are passed through to the tools' -) - -ARGS = parser.parse_args() - -def decodeString(line): - # Python 2 vs. Python 3 - if isinstance(line, str): - return line - else: - return line.decode() - -def shell(cmd, args=(), silent=False, cust_env=None): - """"Execute a shell command and return the output.""" - silent = ARGS.silent or silent - verbose = not silent and ARGS.verbose - if verbose: - print('$' + cmd, *args) - - command = (cmd,) + args - - # shell is needed in Windows to find executable in the path - process = subprocess.Popen( - command, - stdin=subprocess.PIPE, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - env=cust_env, - shell=IS_WINDOWS) - lines = [] - count = 0 - # readline returns '' at EOF - for line in iter(process.stdout.readline, ''): - if process.poll() is None: - decoded = decodeString(line) - lines.append(decoded) - if verbose: - print(decoded, end='') - elif not silent: - count += 1 - if count >= 80: - print() - count = 0 - else: - print('.', end='') - else: - break - - if not verbose and count: - print() - process.wait() - return process.returncode, lines - -def get_cmake_dir(cmake_dir): - return os.path.join('build' , 'cmake' , cmake_dir) - -def run_cmake(directory, cmake_dir, args): - print('Generating build in', directory, 'with', *args or ('default options',)) - old_dir = os.getcwd() - if not os.path.exists(directory): - os.makedirs(directory) - os.chdir(directory) - if IS_WINDOWS and not any(arg.startswith("-G") for arg in args) and not os.path.exists("CMakeCache.txt"): - if '--ninja' in args: - args += ( '-GNinja', ) - else: - args += ( '-GVisual Studio 14 2015 Win64', ) - # hack to extract cmake options/args from the legacy target format - if re.search('\.unity', cmake_dir): - args += ( '-Dunity=ON', ) - if re.search('\.nounity', cmake_dir): - args += ( '-Dunity=OFF', ) - if re.search('coverage', cmake_dir): - args += ( '-Dcoverage=ON', ) - if re.search('profile', cmake_dir): - args += ( '-Dprofile=ON', ) - if re.search('debug', cmake_dir): - args += ( '-DCMAKE_BUILD_TYPE=Debug', ) - if re.search('release', cmake_dir): - args += ( '-DCMAKE_BUILD_TYPE=Release', ) - m = re.search('gcc(-[^.]*)', cmake_dir) - if m: - args += ( '-DCMAKE_C_COMPILER=' + m.group(0), - '-DCMAKE_CXX_COMPILER=g++' + m.group(1), ) - elif re.search('gcc', cmake_dir): - args += ( '-DCMAKE_C_COMPILER=gcc', '-DCMAKE_CXX_COMPILER=g++', ) - m = re.search('clang(-[^.]*)', cmake_dir) - if m: - args += ( '-DCMAKE_C_COMPILER=' + m.group(0), - '-DCMAKE_CXX_COMPILER=clang++' + m.group(1), ) - elif re.search('clang', cmake_dir): - args += ( '-DCMAKE_C_COMPILER=clang', '-DCMAKE_CXX_COMPILER=clang++', ) - - args += ( os.path.join('..', '..', '..'), ) - resultcode, lines = shell('cmake', args) - - if resultcode: - print('Generating FAILED:') - if not ARGS.verbose: - print(*lines, sep='') - sys.exit(1) - - os.chdir(old_dir) - -def run_cmake_build(directory, target, config, args): - print('Building', target, config, 'in', directory, 'with', *args or ('default options',)) - build_args=('--build', directory) - if target: - build_args += ('--target', target) - if config: - build_args += ('--config', config) - if args: - build_args += ('--',) - build_args += tuple(args) - resultcode, lines = shell('cmake', build_args) - - if resultcode: - print('Build FAILED:') - if not ARGS.verbose: - print(*lines, sep='') - sys.exit(1) - -def run_cmake_tests(directory, target, config): - failed = [] - if IS_WINDOWS: - target += '.exe' - executable = os.path.join(directory, config if config else 'Debug', target) - if(not os.path.exists(executable)): - executable = os.path.join(directory, target) - print('Unit tests for', executable) - testflag = '--unittest' - quiet = '' - testjobs = '' - ipv6 = '' - if ARGS.test: - testflag += ('=' + ARGS.test) - if ARGS.quiet: - quiet = '-q' - if ARGS.ipv6: - ipv6 = '--unittest-ipv6' - if ARGS.testjobs: - testjobs = ('--unittest-jobs=' + str(ARGS.testjobs)) - resultcode, lines = shell(executable, (testflag, quiet, testjobs, ipv6)) - - if resultcode: - if not ARGS.verbose: - print('ERROR:', *lines, sep='') - failed.append([target, 'unittest']) - - return failed - -def main(): - all_failed = [] - if ARGS.all: - build_dir_targets = CMAKE_DIR_TARGETS - generator_options = CMAKE_ALL_GENERATE_OPTIONS - else: - build_dir_targets = { tuple(ARGS.dir) : [ARGS.target, ARGS.config] } - if ARGS.generator_option: - generator_options = [tuple(ARGS.generator_option)] - else: - generator_options = [tuple()] - - if not build_dir_targets: - # Let CMake choose the build tool. - build_dir_targets = { () : [] } - - if ARGS.build_option: - ARGS.build_option = ARGS.build_option + list(ARGS.extra_args) - else: - ARGS.build_option = list(ARGS.extra_args) - - for args in generator_options: - for build_dirs, (build_targets, build_configs) in build_dir_targets.items(): - if not build_dirs: - build_dirs = ('default',) - if not build_targets: - build_targets = ('rippled',) - if not build_configs: - build_configs = ('',) - for cmake_dir in build_dirs: - cmake_full_dir = get_cmake_dir(cmake_dir) - run_cmake(cmake_full_dir, cmake_dir, args) - - for target in build_targets: - for config in build_configs: - run_cmake_build(cmake_full_dir, target, config, ARGS.build_option) - failed = run_cmake_tests(cmake_full_dir, target, config) - - if failed: - print('FAILED:', *(':'.join(f) for f in failed)) - if not ARGS.keep_going: - sys.exit(1) - else: - all_failed.extend([decodeString(cmake_dir + - "." + target + "." + config), ':'.join(f)] - for f in failed) - else: - print('Success') - if ARGS.clean: - shutil.rmtree(cmake_full_dir) - - if all_failed: - if len(all_failed) > 1: - print() - print('FAILED:', *(':'.join(f) for f in all_failed)) - sys.exit(1) - -if __name__ == '__main__': - main() - sys.exit(0) diff --git a/Builds/build_all.sh b/Builds/build_all.sh deleted file mode 100755 index 3a08e3b5a5d..00000000000 --- a/Builds/build_all.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -num_procs=$(lscpu -p | grep -v '^#' | sort -u -t, -k 2,4 | wc -l) # number of physical cores - -path=$(cd $(dirname $0) && pwd) -cd $(dirname $path) -${path}/Test.py -a -c --testjobs=${num_procs} -- -j${num_procs} diff --git a/src/ripple/beast/unit_test/main.cpp b/src/ripple/beast/unit_test/main.cpp deleted file mode 100644 index aa1a0f5367b..00000000000 --- a/src/ripple/beast/unit_test/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -// -// Copyright (c) 2013-2017 Vinnie Falco (vinnie dot falco at gmail dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef BOOST_MSVC -#ifndef WIN32_LEAN_AND_MEAN // VC_EXTRALEAN -#define WIN32_LEAN_AND_MEAN -#include -#undef WIN32_LEAN_AND_MEAN -#else -#include -#endif -#endif - -namespace beast { -namespace unit_test { - -static std::string -prefix(suite_info const& s) -{ - if (s.manual()) - return "|M| "; - return " "; -} - -static void -print(std::ostream& os, suite_list const& c) -{ - std::size_t manual = 0; - for (auto const& s : c) - { - os << prefix(s) << s.full_name() << '\n'; - if (s.manual()) - ++manual; - } - os << amount(c.size(), "suite") << " total, " - << amount(manual, "manual suite") << '\n'; -} - -// Print the list of suites -// Used with the --print command line option -static void -print(std::ostream& os) -{ - os << "------------------------------------------\n"; - print(os, global_suites()); - os << "------------------------------------------" << std::endl; -} - -} // namespace unit_test -} // namespace beast - -// Simple main used to produce stand -// alone executables that run unit tests. -int -main(int ac, char const* av[]) -{ - using namespace std; - using namespace beast::unit_test; - - namespace po = boost::program_options; - po::options_description desc("Options"); - desc.add_options()("help,h", "Produce a help message")( - "print,p", "Print the list of available test suites")( - "suites,s", po::value(), "suites to run"); - - po::positional_options_description p; - po::variables_map vm; - po::store(po::parse_command_line(ac, av, desc), vm); - po::notify(vm); - - dstream log(std::cerr); - std::unitbuf(log); - - if (vm.count("help")) - { - log << desc << std::endl; - } - else if (vm.count("print")) - { - print(log); - } - else - { - std::string suites; - if (vm.count("suites") > 0) - suites = vm["suites"].as(); - reporter r(log); - bool failed; - if (!suites.empty()) - failed = r.run_each_if(global_suites(), match_auto(suites)); - else - failed = r.run_each(global_suites()); - if (failed) - return EXIT_FAILURE; - return EXIT_SUCCESS; - } -} diff --git a/src/ripple/json/TODO.md b/src/ripple/json/TODO.md deleted file mode 100644 index c77c36363d5..00000000000 --- a/src/ripple/json/TODO.md +++ /dev/null @@ -1,7 +0,0 @@ -# JSON TODO - -- Investigate other third party libraries, especially those that are - proven hardened against attacks, or perform better - -- Implement canonical JSON API to do signing - diff --git a/src/ripple/json/impl/LICENSE b/src/ripple/json/impl/LICENSE deleted file mode 100644 index 4e6a5529203..00000000000 --- a/src/ripple/json/impl/LICENSE +++ /dev/null @@ -1 +0,0 @@ -The json - cpp library and this documentation are in Public Domain. diff --git a/src/ripple/json/impl/version b/src/ripple/json/impl/version deleted file mode 100644 index 79a2734bbf3..00000000000 --- a/src/ripple/json/impl/version +++ /dev/null @@ -1 +0,0 @@ -0.5.0 \ No newline at end of file diff --git a/src/ripple/rpc/handlers/NodeToShardStatus.cpp b/src/ripple/rpc/handlers/NodeToShardStatus.cpp deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/src/ripple/shamap/impl/CMakeLists.txt b/src/ripple/shamap/impl/CMakeLists.txt deleted file mode 100644 index e69de29bb2d..00000000000 From dd312c3cc5990212fec53d017639590b759ab874 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Sat, 23 Mar 2024 10:01:30 -0500 Subject: [PATCH 02/16] Remove packaging scripts --- Builds/CMake/RippledRelease.cmake | 180 ---- Builds/containers/README.md | 31 - Builds/containers/centos-builder/Dockerfile | 26 - .../containers/centos-builder/centos_setup.sh | 22 - .../containers/gitlab-ci/build_container.sh | 28 - Builds/containers/gitlab-ci/build_package.sh | 28 - .../gitlab-ci/docker_alpine_setup.sh | 15 - Builds/containers/gitlab-ci/get_component.sh | 16 - Builds/containers/gitlab-ci/pkgbuild.yml | 771 ------------------ .../gitlab-ci/push_to_artifactory.sh | 92 --- Builds/containers/gitlab-ci/sign_package.sh | 38 - Builds/containers/gitlab-ci/smoketest.sh | 101 --- .../containers/gitlab-ci/tag_docker_image.sh | 21 - .../gitlab-ci/verify_head_commit.sh | 17 - .../containers/packaging/dpkg/build_dpkg.sh | 99 --- .../packaging/dpkg/debian/README.Debian | 3 - .../containers/packaging/dpkg/debian/compat | 1 - .../containers/packaging/dpkg/debian/control | 19 - .../packaging/dpkg/debian/copyright | 86 -- Builds/containers/packaging/dpkg/debian/dirs | 3 - Builds/containers/packaging/dpkg/debian/docs | 3 - .../packaging/dpkg/debian/rippled-dev.install | 3 - .../dpkg/debian/rippled-reporting.dirs | 3 - .../dpkg/debian/rippled-reporting.install | 8 - .../dpkg/debian/rippled-reporting.links | 3 - .../dpkg/debian/rippled-reporting.postinst | 33 - .../packaging/dpkg/debian/rippled.conffiles | 2 - .../packaging/dpkg/debian/rippled.install | 8 - .../packaging/dpkg/debian/rippled.links | 3 - .../packaging/dpkg/debian/rippled.postinst | 35 - .../packaging/dpkg/debian/rippled.postrm | 17 - .../packaging/dpkg/debian/rippled.preinst | 20 - .../packaging/dpkg/debian/rippled.prerm | 20 - Builds/containers/packaging/dpkg/debian/rules | 81 -- .../packaging/dpkg/debian/source/format | 1 - .../dpkg/debian/source/local-options | 2 - .../packaging/rpm/50-rippled-reporting.preset | 1 - .../packaging/rpm/50-rippled.preset | 1 - Builds/containers/packaging/rpm/build_rpm.sh | 82 -- Builds/containers/packaging/rpm/rippled.spec | 239 ------ Builds/containers/shared/install_cmake.sh | 37 - Builds/containers/shared/rippled-logrotate | 15 - .../shared/rippled-reporting.service | 15 - Builds/containers/shared/rippled.service | 15 - Builds/containers/shared/update-rippled-cron | 10 - Builds/containers/shared/update-rippled.sh | 65 -- Builds/containers/shared/update_sources.sh | 20 - Builds/containers/ubuntu-builder/Dockerfile | 22 - .../containers/ubuntu-builder/ubuntu_setup.sh | 47 -- .../ubuntu-builder/ubuntu_setup2.sh | 49 -- .../ubuntu-builder/ubuntu_setup3.sh | 7 - CMakeLists.txt | 1 - 52 files changed, 2465 deletions(-) delete mode 100644 Builds/CMake/RippledRelease.cmake delete mode 100644 Builds/containers/README.md delete mode 100644 Builds/containers/centos-builder/Dockerfile delete mode 100755 Builds/containers/centos-builder/centos_setup.sh delete mode 100644 Builds/containers/gitlab-ci/build_container.sh delete mode 100644 Builds/containers/gitlab-ci/build_package.sh delete mode 100644 Builds/containers/gitlab-ci/docker_alpine_setup.sh delete mode 100644 Builds/containers/gitlab-ci/get_component.sh delete mode 100644 Builds/containers/gitlab-ci/pkgbuild.yml delete mode 100644 Builds/containers/gitlab-ci/push_to_artifactory.sh delete mode 100644 Builds/containers/gitlab-ci/sign_package.sh delete mode 100644 Builds/containers/gitlab-ci/smoketest.sh delete mode 100644 Builds/containers/gitlab-ci/tag_docker_image.sh delete mode 100644 Builds/containers/gitlab-ci/verify_head_commit.sh delete mode 100755 Builds/containers/packaging/dpkg/build_dpkg.sh delete mode 100644 Builds/containers/packaging/dpkg/debian/README.Debian delete mode 100644 Builds/containers/packaging/dpkg/debian/compat delete mode 100644 Builds/containers/packaging/dpkg/debian/control delete mode 100644 Builds/containers/packaging/dpkg/debian/copyright delete mode 100644 Builds/containers/packaging/dpkg/debian/dirs delete mode 100644 Builds/containers/packaging/dpkg/debian/docs delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled-dev.install delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled-reporting.dirs delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled-reporting.install delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled-reporting.links delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled-reporting.postinst delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.conffiles delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.install delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.links delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.postinst delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.postrm delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.preinst delete mode 100644 Builds/containers/packaging/dpkg/debian/rippled.prerm delete mode 100755 Builds/containers/packaging/dpkg/debian/rules delete mode 100644 Builds/containers/packaging/dpkg/debian/source/format delete mode 100644 Builds/containers/packaging/dpkg/debian/source/local-options delete mode 100644 Builds/containers/packaging/rpm/50-rippled-reporting.preset delete mode 100644 Builds/containers/packaging/rpm/50-rippled.preset delete mode 100755 Builds/containers/packaging/rpm/build_rpm.sh delete mode 100644 Builds/containers/packaging/rpm/rippled.spec delete mode 100755 Builds/containers/shared/install_cmake.sh delete mode 100644 Builds/containers/shared/rippled-logrotate delete mode 100644 Builds/containers/shared/rippled-reporting.service delete mode 100644 Builds/containers/shared/rippled.service delete mode 100644 Builds/containers/shared/update-rippled-cron delete mode 100755 Builds/containers/shared/update-rippled.sh delete mode 100755 Builds/containers/shared/update_sources.sh delete mode 100644 Builds/containers/ubuntu-builder/Dockerfile delete mode 100755 Builds/containers/ubuntu-builder/ubuntu_setup.sh delete mode 100755 Builds/containers/ubuntu-builder/ubuntu_setup2.sh delete mode 100755 Builds/containers/ubuntu-builder/ubuntu_setup3.sh diff --git a/Builds/CMake/RippledRelease.cmake b/Builds/CMake/RippledRelease.cmake deleted file mode 100644 index a0ad3696572..00000000000 --- a/Builds/CMake/RippledRelease.cmake +++ /dev/null @@ -1,180 +0,0 @@ -#[===================================================================[ - package/container targets - (optional) -#]===================================================================] - -if (is_root_project) - if (NOT DOCKER) - find_program (DOCKER docker) - endif () - - if (DOCKER) - # if no container label is provided, use current git hash - git_hash (commit_hash) - if (NOT container_label) - set (container_label ${commit_hash}) - endif () - message (STATUS "using [${container_label}] as build container tag...") - - file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/packages) - - #[===================================================================[ - rpm - #]===================================================================] - add_custom_target (rpm_container - docker build - --pull - --build-arg GIT_COMMIT=${commit_hash} - -t rippleci/rippled-rpm-builder:${container_label} - $<$:--cache-from=${rpm_cache_from}> - -f centos-builder/Dockerfile . - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Builds/containers - VERBATIM - USES_TERMINAL - COMMAND_EXPAND_LISTS - SOURCES - Builds/containers/centos-builder/Dockerfile - Builds/containers/centos-builder/centos_setup.sh - Builds/containers/shared/update-rippled.sh - Builds/containers/shared/update_sources.sh - Builds/containers/shared/rippled.service - Builds/containers/shared/rippled-reporting.service - Builds/containers/packaging/rpm/rippled.spec - Builds/containers/packaging/rpm/build_rpm.sh - Builds/containers/packaging/rpm/50-rippled.preset - Builds/containers/packaging/rpm/50-rippled-reporting.preset - bin/getRippledInfo - ) - exclude_from_default (rpm_container) - add_custom_target (rpm - docker run - -v ${CMAKE_CURRENT_SOURCE_DIR}:/opt/rippled_bld/pkg/rippled - -v ${CMAKE_CURRENT_BINARY_DIR}/packages:/opt/rippled_bld/pkg/out - -t rippled-rpm-builder:${container_label} - /bin/bash -c "cp -fpu rippled/Builds/containers/packaging/rpm/build_rpm.sh . && ./build_rpm.sh" - VERBATIM - USES_TERMINAL - COMMAND_EXPAND_LISTS - SOURCES - Builds/containers/packaging/rpm/rippled.spec - ) - exclude_from_default (rpm) - if (NOT have_package_container) - add_dependencies(rpm rpm_container) - endif () - #[===================================================================[ - dpkg - #]===================================================================] - # currently use ubuntu 18.04 as a base b/c it has one of - # the lower versions of libc among ubuntu and debian releases. - # we could change this in the future and build with some other deb - # based system. - add_custom_target (dpkg_container - docker build - --pull - --build-arg DIST_TAG=18.04 - --build-arg GIT_COMMIT=${commit_hash} - -t rippled-dpkg-builder:${container_label} - $<$:--cache-from=${dpkg_cache_from}> - -f ubuntu-builder/Dockerfile . - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Builds/containers - VERBATIM - USES_TERMINAL - COMMAND_EXPAND_LISTS - SOURCES - Builds/containers/packaging/dpkg/debian/rippled-reporting.links - Builds/containers/packaging/dpkg/debian/copyright - Builds/containers/packaging/dpkg/debian/rules - Builds/containers/packaging/dpkg/debian/rippled-reporting.install - Builds/containers/packaging/dpkg/debian/rippled-reporting.postinst - Builds/containers/packaging/dpkg/debian/rippled.links - Builds/containers/packaging/dpkg/debian/rippled.prerm - Builds/containers/packaging/dpkg/debian/rippled.postinst - Builds/containers/packaging/dpkg/debian/rippled-dev.install - Builds/containers/packaging/dpkg/debian/dirs - Builds/containers/packaging/dpkg/debian/rippled.postrm - Builds/containers/packaging/dpkg/debian/rippled.conffiles - Builds/containers/packaging/dpkg/debian/compat - Builds/containers/packaging/dpkg/debian/source/format - Builds/containers/packaging/dpkg/debian/source/local-options - Builds/containers/packaging/dpkg/debian/README.Debian - Builds/containers/packaging/dpkg/debian/rippled.install - Builds/containers/packaging/dpkg/debian/rippled.preinst - Builds/containers/packaging/dpkg/debian/docs - Builds/containers/packaging/dpkg/debian/control - Builds/containers/packaging/dpkg/debian/rippled-reporting.dirs - Builds/containers/packaging/dpkg/build_dpkg.sh - Builds/containers/ubuntu-builder/Dockerfile - Builds/containers/ubuntu-builder/ubuntu_setup.sh - bin/getRippledInfo - Builds/containers/shared/install_cmake.sh - Builds/containers/shared/update-rippled.sh - Builds/containers/shared/update_sources.sh - Builds/containers/shared/rippled.service - Builds/containers/shared/rippled-reporting.service - Builds/containers/shared/rippled-logrotate - Builds/containers/shared/update-rippled-cron - ) - exclude_from_default (dpkg_container) - add_custom_target (dpkg - docker run - -v ${CMAKE_CURRENT_SOURCE_DIR}:/opt/rippled_bld/pkg/rippled - -v ${CMAKE_CURRENT_BINARY_DIR}/packages:/opt/rippled_bld/pkg/out - -t rippled-dpkg-builder:${container_label} - /bin/bash -c "cp -fpu rippled/Builds/containers/packaging/dpkg/build_dpkg.sh . && ./build_dpkg.sh" - VERBATIM - USES_TERMINAL - COMMAND_EXPAND_LISTS - SOURCES - Builds/containers/packaging/dpkg/debian/control - ) - exclude_from_default (dpkg) - if (NOT have_package_container) - add_dependencies(dpkg dpkg_container) - endif () - #[===================================================================[ - ci container - #]===================================================================] - # now use the same ubuntu image for our travis-ci docker images, - # but we use a newer distro (18.04 vs 16.04). - # - # the following steps assume the github pkg repo, but it's possible to - # adapt these for other docker hub repositories. - # - # steps for publishing a new CI image when you make changes: - # - # mkdir bld.ci && cd bld.ci && cmake -Dpackages_only=ON -Dcontainer_label=CI_LATEST - # cmake --build . --target ci_container --verbose - # docker tag rippled-ci-builder:CI_LATEST /rippled-ci-builder:YYYY-MM-DD - # (NOTE: change YYYY-MM-DD to match current date, or use a different - # tag/version scheme if you prefer) - # docker push /rippled-ci-builder:YYYY-MM-DD - # (NOTE: is probably your user or org name if using - # docker hub, or it might be something like - # docker.pkg.github.com/ripple/rippled if using the github pkg - # registry. for any registry, you will need to be logged-in via - # docker and have push access.) - # - # ...then change the DOCKER_IMAGE line in .travis.yml : - # - DOCKER_IMAGE="/rippled-ci-builder:YYYY-MM-DD" - add_custom_target (ci_container - docker build - --pull - --build-arg DIST_TAG=18.04 - --build-arg GIT_COMMIT=${commit_hash} - --build-arg CI_USE=true - -t rippled-ci-builder:${container_label} - $<$:--cache-from=${ci_cache_from}> - -f ubuntu-builder/Dockerfile . - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Builds/containers - VERBATIM - USES_TERMINAL - COMMAND_EXPAND_LISTS - SOURCES - Builds/containers/ubuntu-builder/Dockerfile - Builds/containers/ubuntu-builder/ubuntu_setup.sh - ) - exclude_from_default (ci_container) - else () - message (STATUS "docker NOT found -- won't be able to build containers for packaging") - endif () -endif () diff --git a/Builds/containers/README.md b/Builds/containers/README.md deleted file mode 100644 index 9d96eb7719b..00000000000 --- a/Builds/containers/README.md +++ /dev/null @@ -1,31 +0,0 @@ - -# rippled Packaging and Containers - -This folder contains docker container definitions and configuration -files to support building rpm and deb packages of rippled. The container -definitions include some additional software/packages that are used -for general build/test CI workflows of rippled but are not explicitly -needed for the package building workflow. - -## CMake Targets - -If you have docker installed on your local system, then the main -CMake file will enable several targets related to building packages: -`rpm_container`, `rpm`, `dpkg_container`, and `dpkg`. The package targets -depend on the container targets and will trigger a build of those first. -The container builds can take several dozen minutes to complete (depending -on hardware specs), so quick build cycles are not possible currently. As -such, these targets are often best suited to CI/automated build systems. - -The package build can be invoked like any other cmake target from the -rippled root folder: -``` -mkdir -p build/pkg && cd build/pkg -cmake -Dpackages_only=ON ../.. -cmake --build . --target rpm -``` -Upon successful completion, the generated package files will be in -the `build/pkg/packages` directory. For deb packages, simply replace -`rpm` with `dpkg` in the build command above. - - diff --git a/Builds/containers/centos-builder/Dockerfile b/Builds/containers/centos-builder/Dockerfile deleted file mode 100644 index ef5f80f7bfd..00000000000 --- a/Builds/containers/centos-builder/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -FROM rippleci/centos:7 -ARG GIT_COMMIT=unknown -ARG CI_USE=false - -LABEL git-commit=$GIT_COMMIT - -COPY centos-builder/centos_setup.sh /tmp/ -COPY shared/install_cmake.sh /tmp/ -RUN chmod +x /tmp/centos_setup.sh && \ - chmod +x /tmp/install_cmake.sh -RUN /tmp/centos_setup.sh - -RUN /tmp/install_cmake.sh 3.16.3 /opt/local/cmake-3.16 -RUN ln -s /opt/local/cmake-3.16 /opt/local/cmake -ENV PATH="/opt/local/cmake/bin:$PATH" -# TODO: Install latest CMake for testing -RUN if [ "${CI_USE}" = true ] ; then /tmp/install_cmake.sh 3.16.3 /opt/local/cmake-3.16; fi - -RUN mkdir -m 777 -p /opt/rippled_bld/pkg - -WORKDIR /opt/rippled_bld/pkg -RUN mkdir -m 777 ./rpmbuild -RUN mkdir -m 777 ./rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS} - -COPY packaging/rpm/build_rpm.sh ./ -CMD ./build_rpm.sh diff --git a/Builds/containers/centos-builder/centos_setup.sh b/Builds/containers/centos-builder/centos_setup.sh deleted file mode 100755 index ea110058bb8..00000000000 --- a/Builds/containers/centos-builder/centos_setup.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash -set -ex - -source /etc/os-release - -yum -y upgrade -yum -y update -yum -y install epel-release centos-release-scl -yum -y install \ - wget curl time gcc-c++ yum-utils autoconf automake pkgconfig libtool \ - libstdc++-static rpm-build gnupg which make cmake \ - devtoolset-11 devtoolset-11-gdb devtoolset-11-binutils devtoolset-11-libstdc++-devel \ - devtoolset-11-libasan-devel devtoolset-11-libtsan-devel devtoolset-11-libubsan-devel devtoolset-11-liblsan-devel \ - flex flex-devel bison bison-devel parallel \ - ncurses ncurses-devel ncurses-libs graphviz graphviz-devel \ - lzip p7zip bzip2 bzip2-devel lzma-sdk lzma-sdk-devel xz-devel \ - zlib zlib-devel zlib-static texinfo openssl openssl-static \ - jemalloc jemalloc-devel \ - libicu-devel htop \ - rh-python38 \ - ninja-build git svn \ - swig perl-Digest-MD5 diff --git a/Builds/containers/gitlab-ci/build_container.sh b/Builds/containers/gitlab-ci/build_container.sh deleted file mode 100644 index ea47b4a112c..00000000000 --- a/Builds/containers/gitlab-ci/build_container.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env sh -set -ex -pkgtype=$1 -if [ "${pkgtype}" = "rpm" ] ; then - container_name="${RPM_CONTAINER_NAME}" -elif [ "${pkgtype}" = "dpkg" ] ; then - container_name="${DPKG_CONTAINER_NAME}" -else - echo "invalid package type" - exit 1 -fi - -if docker pull "${ARTIFACTORY_HUB}/${container_name}:latest_${CI_COMMIT_REF_SLUG}"; then - echo "found container for latest - using as cache." - docker tag \ - "${ARTIFACTORY_HUB}/${container_name}:latest_${CI_COMMIT_REF_SLUG}" \ - "${container_name}:latest_${CI_COMMIT_REF_SLUG}" - CMAKE_EXTRA="-D${pkgtype}_cache_from=${container_name}:latest_${CI_COMMIT_REF_SLUG}" -fi - -cmake --version -test -d build && rm -rf build -mkdir -p build/container && cd build/container -eval time \ - cmake -Dpackages_only=ON -DCMAKE_VERBOSE_MAKEFILE=ON ${CMAKE_EXTRA} \ - -G Ninja ../.. -time cmake --build . --target "${pkgtype}_container" -- -v - diff --git a/Builds/containers/gitlab-ci/build_package.sh b/Builds/containers/gitlab-ci/build_package.sh deleted file mode 100644 index 4c591677fd2..00000000000 --- a/Builds/containers/gitlab-ci/build_package.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env sh -set -ex -pkgtype=$1 -if [ "${pkgtype}" = "rpm" ] ; then - container_name="${RPM_CONTAINER_FULLNAME}" - container_tag="${RPM_CONTAINER_TAG}" -elif [ "${pkgtype}" = "dpkg" ] ; then - container_name="${DPKG_CONTAINER_FULLNAME}" - container_tag="${DPKG_CONTAINER_TAG}" -else - echo "invalid package type" - exit 1 -fi -time docker pull "${ARTIFACTORY_HUB}/${container_name}" -docker tag \ - "${ARTIFACTORY_HUB}/${container_name}" \ - "${container_name}" -docker images -test -d build && rm -rf build -mkdir -p build/${pkgtype} && cd build/${pkgtype} -time cmake \ - -Dpackages_only=ON \ - -Dcontainer_label="${container_tag}" \ - -Dhave_package_container=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -Dunity=OFF \ - -G Ninja ../.. -time cmake --build . --target ${pkgtype} -- -v diff --git a/Builds/containers/gitlab-ci/docker_alpine_setup.sh b/Builds/containers/gitlab-ci/docker_alpine_setup.sh deleted file mode 100644 index 0d6e011313e..00000000000 --- a/Builds/containers/gitlab-ci/docker_alpine_setup.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env sh -set -e -# used as a before/setup script for docker steps in gitlab-ci -# expects to be run in standard alpine/dind image -echo $(nproc) -docker login -u rippled \ - -p ${ARTIFACTORY_DEPLOY_KEY_RIPPLED} ${ARTIFACTORY_HUB} -apk add --update py-pip -apk add \ - bash util-linux coreutils binutils grep \ - make ninja cmake build-base gcc g++ abuild git \ - python3 python3-dev -pip3 install awscli --break-system-packages -# list curdir contents to build log: -ls -la diff --git a/Builds/containers/gitlab-ci/get_component.sh b/Builds/containers/gitlab-ci/get_component.sh deleted file mode 100644 index 99963f40864..00000000000 --- a/Builds/containers/gitlab-ci/get_component.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env sh -case ${CI_COMMIT_REF_NAME} in - develop) - export COMPONENT="nightly" - ;; - release) - export COMPONENT="unstable" - ;; - master) - export COMPONENT="stable" - ;; - *) - export COMPONENT="_unknown_" - ;; -esac - diff --git a/Builds/containers/gitlab-ci/pkgbuild.yml b/Builds/containers/gitlab-ci/pkgbuild.yml deleted file mode 100644 index 0aa46d1eecf..00000000000 --- a/Builds/containers/gitlab-ci/pkgbuild.yml +++ /dev/null @@ -1,771 +0,0 @@ -######################################################################### -## ## -## gitlab CI defintition for rippled build containers and distro ## -## packages (rpm and dpkg). ## -## ## -######################################################################### - -# NOTE: these are sensible defaults for Ripple pipelines. These -# can be overridden by project or group variables as needed. -variables: - # these containers are built manually using the rippled - # cmake build (container targets) and tagged/pushed so they - # can be used here - RPM_CONTAINER_TAG: "2023-02-13" - RPM_CONTAINER_NAME: "rippled-rpm-builder" - RPM_CONTAINER_FULLNAME: "${RPM_CONTAINER_NAME}:${RPM_CONTAINER_TAG}" - DPKG_CONTAINER_TAG: "2023-07-31" - DPKG_CONTAINER_NAME: "rippled-dpkg-builder" - DPKG_CONTAINER_FULLNAME: "${DPKG_CONTAINER_NAME}:${DPKG_CONTAINER_TAG}" - ARTIFACTORY_HOST: "artifactory.ops.ripple.com" - ARTIFACTORY_HUB: "${ARTIFACTORY_HOST}:6555" - GIT_SIGN_PUBKEYS_URL: "https://gitlab.ops.ripple.com/xrpledger/rippled-packages/snippets/49/raw" - PUBLIC_REPO_ROOT: "https://repos.ripple.com/repos" - # also need to define this variable ONLY for the primary - # build/publish pipeline on the mainline repo: - # IS_PRIMARY_REPO = "true" - -stages: - - build_packages - - sign_packages - - smoketest - - verify_sig - - tag_images - - push_to_test - - verify_from_test - - wait_approval_prod - - push_to_prod - - verify_from_prod - - get_final_hashes - - build_containers - -.dind_template: &dind_param - before_script: - - . ./Builds/containers/gitlab-ci/docker_alpine_setup.sh - variables: - docker_driver: overlay2 - DOCKER_TLS_CERTDIR: "" - image: - name: artifactory.ops.ripple.com/docker:latest - services: - # workaround for TLS issues - consider going back - # back to unversioned `dind` when issues are resolved - - name: artifactory.ops.ripple.com/docker:stable-dind - alias: docker - tags: - - 4xlarge - -.only_primary_template: &only_primary - only: - refs: - - /^(master|release|develop)$/ - variables: - - $IS_PRIMARY_REPO == "true" - -.smoketest_local_template: &run_local_smoketest - tags: - - xlarge - script: - - . ./Builds/containers/gitlab-ci/smoketest.sh local - -.smoketest_repo_template: &run_repo_smoketest - tags: - - xlarge - script: - - . ./Builds/containers/gitlab-ci/smoketest.sh repo - -######################################################################### -## ## -## stage: build_packages ## -## ## -## build packages using containers from previous stage. ## -## ## -######################################################################### - -rpm_build: - timeout: "1h 30m" - stage: build_packages - <<: *dind_param - artifacts: - paths: - - build/rpm/packages/ - script: - - . ./Builds/containers/gitlab-ci/build_package.sh rpm - -dpkg_build: - timeout: "1h 30m" - stage: build_packages - <<: *dind_param - artifacts: - paths: - - build/dpkg/packages/ - script: - - . ./Builds/containers/gitlab-ci/build_package.sh dpkg - -######################################################################### -## ## -## stage: sign_packages ## -## ## -## build packages using containers from previous stage. ## -## ## -######################################################################### - -rpm_sign: - stage: sign_packages - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/centos:7 - <<: *only_primary - before_script: - - | - # Make sure GnuPG is installed - yum -y install gnupg rpm-sign - # checking GPG signing support - if [ -n "$GPG_KEY_B64" ]; then - echo "$GPG_KEY_B64"| base64 -d | gpg --batch --no-tty --allow-secret-key-import --import - - unset GPG_KEY_B64 - export GPG_PASSPHRASE=$(echo $GPG_KEY_PASS_B64 | base64 -di) - unset GPG_KEY_PASS_B64 - export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5) - else - echo -e "\033[0;31m****** GPG signing disabled ******\033[0m" - exit 1 - fi - artifacts: - paths: - - build/rpm/packages/ - script: - - ls -alh build/rpm/packages - - . ./Builds/containers/gitlab-ci/sign_package.sh rpm - -dpkg_sign: - stage: sign_packages - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/ubuntu:18.04 - <<: *only_primary - before_script: - - | - # make sure we have GnuPG - apt update - apt install -y gpg dpkg-sig - # checking GPG signing support - if [ -n "$GPG_KEY_B64" ]; then - echo "$GPG_KEY_B64"| base64 -d | gpg --batch --no-tty --allow-secret-key-import --import - - unset GPG_KEY_B64 - export GPG_PASSPHRASE=$(echo $GPG_KEY_PASS_B64 | base64 -di) - unset GPG_KEY_PASS_B64 - export GPG_KEYID=$(gpg --with-colon --list-secret-keys | head -n1 | cut -d : -f 5) - else - echo -e "\033[0;31m****** GPG signing disabled ******\033[0m" - exit 1 - fi - artifacts: - paths: - - build/dpkg/packages/ - script: - - ls -alh build/dpkg/packages - - . ./Builds/containers/gitlab-ci/sign_package.sh dpkg - -######################################################################### -## ## -## stage: smoketest ## -## ## -## install unsigned packages from previous step and run unit tests. ## -## ## -######################################################################### - -centos_7_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/centos:7 - <<: *run_local_smoketest - -rocky_8_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:8 - <<: *run_local_smoketest - -rocky_9_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:9 - - <<: *run_local_smoketest - -alma_8_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/almalinux:8 - <<: *run_local_smoketest - -alma_9_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/almalinux:9 - - <<: *run_local_smoketest - -fedora_38_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/fedora:38 - <<: *run_local_smoketest - -fedora_39_smoketest: - stage: smoketest - dependencies: - - rpm_build - image: - name: artifactory.ops.ripple.com/fedora:39 - <<: *run_local_smoketest - -ubuntu_18_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/ubuntu:18.04 - <<: *run_local_smoketest - -ubuntu_20_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/ubuntu:20.04 - <<: *run_local_smoketest - -ubuntu_22_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/ubuntu:22.04 - <<: *run_local_smoketest - -debian_10_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/debian:10 - <<: *run_local_smoketest - -debian_11_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/debian:11 - <<: *run_local_smoketest - -debian_12_smoketest: - stage: smoketest - dependencies: - - dpkg_build - image: - name: artifactory.ops.ripple.com/debian:12 - <<: *run_local_smoketest - -######################################################################### -## ## -## stage: verify_sig ## -## ## -## use git/gpg to verify that HEAD is signed by an approved ## -## committer. The whitelist of pubkeys is manually mantained ## -## and fetched from GIT_SIGN_PUBKEYS_URL (currently a snippet ## -## link). ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -verify_head_signed: - stage: verify_sig - image: - name: artifactory.ops.ripple.com/ubuntu:latest - <<: *only_primary - script: - - . ./Builds/containers/gitlab-ci/verify_head_commit.sh - -######################################################################### -## ## -## stage: tag_images ## -## ## -## apply rippled version tag to containers from previous stage. ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -tag_bld_images: - stage: tag_images - variables: - docker_driver: overlay2 - DOCKER_TLS_CERTDIR: "" - image: - name: artifactory.ops.ripple.com/docker:latest - services: - # workaround for TLS issues - consider going back - # back to unversioned `dind` when issues are resolved - - name: artifactory.ops.ripple.com/docker:stable-dind - alias: docker - tags: - - large - dependencies: - - rpm_sign - - dpkg_sign - <<: *only_primary - script: - - . ./Builds/containers/gitlab-ci/tag_docker_image.sh - -######################################################################### -## ## -## stage: push_to_test ## -## ## -## push packages to artifactory repositories (test) ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -push_test: - stage: push_to_test - variables: - DEB_REPO: "rippled-deb-test-mirror" - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/alpine:latest - artifacts: - paths: - - files.info - dependencies: - - rpm_sign - - dpkg_sign - <<: *only_primary - script: - - . ./Builds/containers/gitlab-ci/push_to_artifactory.sh "PUT" "." - -######################################################################### -## ## -## stage: verify_from_test ## -## ## -## install/test packages from test repos. ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -centos_7_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/centos:7 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -rocky_8_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:8 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -rocky_9_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:9 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -almalinux_8_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/almalinux:8 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -almalinux_9_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/almalinux:9 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -fedora_38_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/fedora:38 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -fedora_39_verify_repo_test: - stage: verify_from_test - variables: - RPM_REPO: "rippled-rpm-test-mirror" - image: - name: artifactory.ops.ripple.com/fedora:39 - - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_18_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "bionic" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/ubuntu:18.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_20_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "focal" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/ubuntu:20.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_22_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "jammy" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/ubuntu:22.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_10_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "buster" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/debian:10 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_11_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "bullseye" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/debian:11 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_12_verify_repo_test: - stage: verify_from_test - variables: - DISTRO: "bookworm" - DEB_REPO: "rippled-deb-test-mirror" - image: - name: artifactory.ops.ripple.com/debian:12 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -######################################################################### -## ## -## stage: wait_approval_prod ## -## ## -## wait for manual approval before proceeding to next stage ## -## which pushes to prod repo. ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### -wait_before_push_prod: - stage: wait_approval_prod - image: - name: artifactory.ops.ripple.com/alpine:latest - <<: *only_primary - script: - - echo "proceeding to next stage" - when: manual - allow_failure: false - -######################################################################### -## ## -## stage: push_to_prod ## -## ## -## push packages to artifactory repositories (prod) ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -push_prod: - variables: - DEB_REPO: "rippled-deb" - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/alpine:latest - stage: push_to_prod - artifacts: - paths: - - files.info - dependencies: - - rpm_sign - - dpkg_sign - <<: *only_primary - script: - - . ./Builds/containers/gitlab-ci/push_to_artifactory.sh "PUT" "." - -######################################################################### -## ## -## stage: verify_from_prod ## -## ## -## install/test packages from prod repos. ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -centos_7_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/centos:7 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -rocky_8_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:8 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -rocky_9_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/rockylinux/rockylinux:9 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -alma_8_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/almalinux:8 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -alma_9_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/almalinux:9 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -fedora_37_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/fedora:37 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -fedora_38_verify_repo_prod: - stage: verify_from_prod - variables: - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/fedora:38 - dependencies: - - rpm_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_18_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "bionic" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/ubuntu:18.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_20_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "focal" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/ubuntu:20.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -ubuntu_22_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "jammy" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/ubuntu:22.04 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_10_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "buster" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/debian:10 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_11_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "bullseye" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/debian:11 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - -debian_12_verify_repo_prod: - stage: verify_from_prod - variables: - DISTRO: "bookworm" - DEB_REPO: "rippled-deb" - image: - name: artifactory.ops.ripple.com/debian:12 - dependencies: - - dpkg_sign - <<: *only_primary - <<: *run_repo_smoketest - - -######################################################################### -## ## -## stage: get_final_hashes ## -## ## -## fetch final hashes from artifactory. ## -## ONLY RUNS FOR PRIMARY BRANCHES/REPO ## -## ## -######################################################################### - -get_prod_hashes: - variables: - DEB_REPO: "rippled-deb" - RPM_REPO: "rippled-rpm" - image: - name: artifactory.ops.ripple.com/alpine:latest - stage: get_final_hashes - artifacts: - paths: - - files.info - dependencies: - - rpm_sign - - dpkg_sign - <<: *only_primary - script: - - . ./Builds/containers/gitlab-ci/push_to_artifactory.sh "GET" ".checksums" - -######################################################################### -## ## -## stage: build_containers ## -## ## -## build containers from docker definitions. These containers are NOT ## -## used for the package build. This step is only used to ensure that ## -## the package build targets and files are still working properly. ## -## ## -######################################################################### - -build_centos_container: - stage: build_containers - <<: *dind_param - script: - - . ./Builds/containers/gitlab-ci/build_container.sh rpm - -build_ubuntu_container: - stage: build_containers - <<: *dind_param - script: - - . ./Builds/containers/gitlab-ci/build_container.sh dpkg diff --git a/Builds/containers/gitlab-ci/push_to_artifactory.sh b/Builds/containers/gitlab-ci/push_to_artifactory.sh deleted file mode 100644 index f82f503daf6..00000000000 --- a/Builds/containers/gitlab-ci/push_to_artifactory.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/usr/bin/env sh -set -e -action=$1 -filter=$2 - -. ./Builds/containers/gitlab-ci/get_component.sh - -apk add curl jq coreutils util-linux -TOPDIR=$(pwd) - -# DPKG - -cd $TOPDIR -cd build/dpkg/packages -CURLARGS="-sk -X${action} -urippled:${ARTIFACTORY_DEPLOY_KEY_RIPPLED}" -RIPPLED_PKG=$(ls rippled_*.deb) -RIPPLED_REPORTING_PKG=$(ls rippled-reporting_*.deb) -RIPPLED_DBG_PKG=$(ls rippled-dbgsym_*.*deb) -RIPPLED_REPORTING_DBG_PKG=$(ls rippled-reporting-dbgsym_*.*deb) -# TODO - where to upload src tgz? -RIPPLED_SRC=$(ls rippled_*.orig.tar.gz) -DEB_MATRIX=";deb.component=${COMPONENT};deb.architecture=amd64" -for dist in bookworm buster bullseye bionic focal jammy; do - DEB_MATRIX="${DEB_MATRIX};deb.distribution=${dist}" -done -echo "{ \"debs\": {" > "${TOPDIR}/files.info" -for deb in ${RIPPLED_PKG} ${RIPPLED_DBG_PKG} ${RIPPLED_REPORTING_PKG} ${RIPPLED_REPORTING_DBG_PKG}; do - # first item doesn't get a comma separator - if [ $deb != $RIPPLED_PKG ] ; then - echo "," >> "${TOPDIR}/files.info" - fi - echo "\"${deb}\"": | tee -a "${TOPDIR}/files.info" - ca="${CURLARGS}" - if [ "${action}" = "PUT" ] ; then - url="https://${ARTIFACTORY_HOST}/artifactory/${DEB_REPO}/pool/${COMPONENT}/${deb}${DEB_MATRIX}" - ca="${ca} -T${deb}" - elif [ "${action}" = "GET" ] ; then - url="https://${ARTIFACTORY_HOST}/artifactory/api/storage/${DEB_REPO}/pool/${COMPONENT}/${deb}" - fi - echo "file info request url --> ${url}" - eval "curl ${ca} \"${url}\"" | jq -M "${filter}" | tee -a "${TOPDIR}/files.info" -done -echo "}," >> "${TOPDIR}/files.info" - -# RPM - -cd $TOPDIR -cd build/rpm/packages -RIPPLED_PKG=$(ls rippled-[0-9]*.x86_64.rpm) -RIPPLED_DEV_PKG=$(ls rippled-devel*.rpm) -RIPPLED_DBG_PKG=$(ls rippled-debuginfo*.rpm) -RIPPLED_REPORTING_PKG=$(ls rippled-reporting*.rpm) -# TODO - where to upload src rpm ? -RIPPLED_SRC=$(ls rippled-[0-9]*.src.rpm) -echo "\"rpms\": {" >> "${TOPDIR}/files.info" -for rpm in ${RIPPLED_PKG} ${RIPPLED_DEV_PKG} ${RIPPLED_DBG_PKG} ${RIPPLED_REPORTING_PKG}; do - # first item doesn't get a comma separator - if [ $rpm != $RIPPLED_PKG ] ; then - echo "," >> "${TOPDIR}/files.info" - fi - echo "\"${rpm}\"": | tee -a "${TOPDIR}/files.info" - ca="${CURLARGS}" - if [ "${action}" = "PUT" ] ; then - url="https://${ARTIFACTORY_HOST}/artifactory/${RPM_REPO}/${COMPONENT}/" - ca="${ca} -T${rpm}" - elif [ "${action}" = "GET" ] ; then - url="https://${ARTIFACTORY_HOST}/artifactory/api/storage/${RPM_REPO}/${COMPONENT}/${rpm}" - fi - echo "file info request url --> ${url}" - eval "curl ${ca} \"${url}\"" | jq -M "${filter}" | tee -a "${TOPDIR}/files.info" -done -echo "}}" >> "${TOPDIR}/files.info" -jq '.' "${TOPDIR}/files.info" > "${TOPDIR}/files.info.tmp" -mv "${TOPDIR}/files.info.tmp" "${TOPDIR}/files.info" - -if [ ! -z "${SLACK_NOTIFY_URL}" ] && [ "${action}" = "GET" ] ; then - # extract files.info content to variable and sanitize so it can - # be interpolated into a slack text field below - finfo=$(cat ${TOPDIR}/files.info | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' | sed -E 's/"/\\"/g') - # try posting file info to slack. - # can add channel field to payload if the - # default channel is incorrect. Get rid of - # newlines in payload json since slack doesn't accept them - CONTENT=$(tr -d '[\n]' <> /etc/apt/sources.list - updateWithRetry - # uncomment this next line if you want to see the available package versions - # apt-cache policy rippled - apt-get -y install rippled=${dpkg_full_version} - elif [ "${install_from}" = "local" ] ; then - # cached pkg install - updateWithRetry - apt-get -y install libprotobuf-dev libprotoc-dev protobuf-compiler libssl-dev - rm -f build/dpkg/packages/rippled-dbgsym*.* - dpkg --no-debsig -i build/dpkg/packages/*.deb - else - echo "unrecognized pkg source!" - exit 1 - fi -else - yum -y update - if [ "${install_from}" = "repo" ] ; then - pkgs=("yum-utils coreutils util-linux") - case "$ID" in - rocky|almalinux) - pkgs="${pkgs[@]/coreutils}" - esac - yum install -y $pkgs - REPOFILE="/etc/yum.repos.d/artifactory.repo" - echo "[Artifactory]" > ${REPOFILE} - echo "name=Artifactory" >> ${REPOFILE} - echo "baseurl=${REPO_ROOT}/${RPM_REPO}/${COMPONENT}/" >> ${REPOFILE} - echo "enabled=1" >> ${REPOFILE} - echo "gpgcheck=0" >> ${REPOFILE} - echo "gpgkey=${REPO_ROOT}/${RPM_REPO}/${COMPONENT}/repodata/repomd.xml.key" >> ${REPOFILE} - echo "repo_gpgcheck=1" >> ${REPOFILE} - yum -y update - # uncomment this next line if you want to see the available package versions - # yum --showduplicates list rippled - yum -y install ${rpm_version_release} - elif [ "${install_from}" = "local" ] ; then - rm -f build/rpm/packages/rippled-debug*.rpm - rm -f build/rpm/packages/rippled-devel*.rpm - rm -f build/rpm/packages/*.src.rpm - rpm -i build/rpm/packages/*.rpm - else - echo "unrecognized pkg source!" - exit 1 - fi -fi - -# verify installed version -INSTALLED=$(/opt/ripple/bin/rippled --version | awk '{print $NF}') -if [ "${rippled_version}" != "${INSTALLED}" ] ; then - echo "INSTALLED version ${INSTALLED} does not match ${rippled_version}" - exit 1 -fi -# run unit tests -/opt/ripple/bin/rippled --unittest --unittest-jobs $(nproc) -/opt/ripple/bin/validator-keys --unittest diff --git a/Builds/containers/gitlab-ci/tag_docker_image.sh b/Builds/containers/gitlab-ci/tag_docker_image.sh deleted file mode 100644 index 66259059536..00000000000 --- a/Builds/containers/gitlab-ci/tag_docker_image.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env sh -set -e -docker login -u rippled \ - -p ${ARTIFACTORY_DEPLOY_KEY_RIPPLED} "${ARTIFACTORY_HUB}" -# this gives us rippled_version : -source build/rpm/packages/build_vars -docker pull "${ARTIFACTORY_HUB}/${RPM_CONTAINER_FULLNAME}" -docker pull "${ARTIFACTORY_HUB}/${DPKG_CONTAINER_FULLNAME}" -# tag/push two labels...one using the current rippled version and one just using "latest" -for label in ${rippled_version} latest ; do - docker tag \ - "${ARTIFACTORY_HUB}/${RPM_CONTAINER_FULLNAME}" \ - "${ARTIFACTORY_HUB}/${RPM_CONTAINER_NAME}:${label}_${CI_COMMIT_REF_SLUG}" - docker push \ - "${ARTIFACTORY_HUB}/${RPM_CONTAINER_NAME}:${label}_${CI_COMMIT_REF_SLUG}" - docker tag \ - "${ARTIFACTORY_HUB}/${DPKG_CONTAINER_FULLNAME}" \ - "${ARTIFACTORY_HUB}/${DPKG_CONTAINER_NAME}:${label}_${CI_COMMIT_REF_SLUG}" - docker push \ - "${ARTIFACTORY_HUB}/${DPKG_CONTAINER_NAME}:${label}_${CI_COMMIT_REF_SLUG}" -done diff --git a/Builds/containers/gitlab-ci/verify_head_commit.sh b/Builds/containers/gitlab-ci/verify_head_commit.sh deleted file mode 100644 index f724b7e968e..00000000000 --- a/Builds/containers/gitlab-ci/verify_head_commit.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env sh -set -ex -apt -y update -DEBIAN_FRONTEND="noninteractive" apt-get -y install tzdata -apt -y install software-properties-common curl git gnupg -curl -sk -o rippled-pubkeys.txt "${GIT_SIGN_PUBKEYS_URL}" -gpg --import rippled-pubkeys.txt -if git verify-commit HEAD; then - echo "git commit signature check passed" -else - echo "git commit signature check failed" - git log -n 5 --color \ - --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an> [%G?]%Creset' \ - --abbrev-commit - exit 1 -fi - diff --git a/Builds/containers/packaging/dpkg/build_dpkg.sh b/Builds/containers/packaging/dpkg/build_dpkg.sh deleted file mode 100755 index 65bbb40f343..00000000000 --- a/Builds/containers/packaging/dpkg/build_dpkg.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env bash -set -ex - -# make sure pkg source files are up to date with repo -cd /opt/rippled_bld/pkg -cp -fpru rippled/Builds/containers/packaging/dpkg/debian/. debian/ -cp -fpu rippled/Builds/containers/shared/rippled*.service debian/ -cp -fpu rippled/Builds/containers/shared/update_sources.sh . -source update_sources.sh - -# Build the dpkg - -#dpkg uses - as separator, so we need to change our -bN versions to tilde -RIPPLED_DPKG_VERSION=$(echo "${RIPPLED_VERSION}" | sed 's!-!~!g') -# TODO - decide how to handle the trailing/release -# version here (hardcoded to 1). Does it ever need to change? -RIPPLED_DPKG_FULL_VERSION="${RIPPLED_DPKG_VERSION}-1" -git config --global --add safe.directory /opt/rippled_bld/pkg/rippled -cd /opt/rippled_bld/pkg/rippled -if [[ -n $(git status --porcelain) ]]; then - git status - error "Unstaged changes in this repo - please commit first" -fi -git archive --format tar.gz --prefix rippled-${RIPPLED_DPKG_VERSION}/ -o ../rippled-${RIPPLED_DPKG_VERSION}.tar.gz HEAD -cd .. -# dpkg debmake would normally create this link, but we do it manually -ln -s ./rippled-${RIPPLED_DPKG_VERSION}.tar.gz rippled_${RIPPLED_DPKG_VERSION}.orig.tar.gz -tar xvf rippled-${RIPPLED_DPKG_VERSION}.tar.gz -cd rippled-${RIPPLED_DPKG_VERSION} -cp -pr ../debian . - -# dpkg requires a changelog. We don't currently maintain -# a useable one, so let's just fake it with our current version -# TODO : not sure if the "unstable" will need to change for -# release packages (?) -NOWSTR=$(TZ=UTC date -R) -cat << CHANGELOG > ./debian/changelog -rippled (${RIPPLED_DPKG_FULL_VERSION}) unstable; urgency=low - - * see RELEASENOTES - - -- Ripple Labs Inc. ${NOWSTR} -CHANGELOG - -# PATH must be preserved for our more modern cmake in /opt/local -# TODO : consider allowing lintian to run in future ? -export DH_BUILD_DDEBS=1 -debuild --no-lintian --preserve-envvar PATH --preserve-env -us -uc -rc=$?; if [[ $rc != 0 ]]; then - error "error building dpkg" -fi -cd .. - -# copy artifacts -cp rippled-reporting_${RIPPLED_DPKG_FULL_VERSION}_amd64.deb ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.deb ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_FULL_VERSION}.dsc ${PKG_OUTDIR} -# dbgsym suffix is ddeb under newer debuild, but just deb under earlier -cp rippled-dbgsym_${RIPPLED_DPKG_FULL_VERSION}_amd64.* ${PKG_OUTDIR} -cp rippled-reporting-dbgsym_${RIPPLED_DPKG_FULL_VERSION}_amd64.* ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.changes ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.build ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_VERSION}.orig.tar.gz ${PKG_OUTDIR} -cp rippled_${RIPPLED_DPKG_FULL_VERSION}.debian.tar.xz ${PKG_OUTDIR} -# buildinfo is only generated by later version of debuild -if [ -e rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.buildinfo ] ; then - cp rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.buildinfo ${PKG_OUTDIR} -fi - -pushd ${PKG_OUTDIR} -for f in *.ddeb; do mv -- "$f" "${f%.ddeb}.deb"; done -popd - -cat rippled_${RIPPLED_DPKG_FULL_VERSION}_amd64.changes -# extract the text in the .changes file that appears between -# Checksums-Sha256: ... -# and -# Files: ... -awk '/Checksums-Sha256:/{hit=1;next}/Files:/{hit=0}hit' \ - rippled_${RIPPLED_DPKG_VERSION}-1_amd64.changes | \ - sed -E 's!^[[:space:]]+!!' > shasums -DEB_SHA256=$(cat shasums | \ - grep "rippled_${RIPPLED_DPKG_VERSION}-1_amd64.deb" | cut -d " " -f 1) -DBG_SHA256=$(cat shasums | \ - grep "rippled-dbgsym_${RIPPLED_DPKG_VERSION}-1_amd64.*" | cut -d " " -f 1) -REPORTING_DBG_SHA256=$(cat shasums | \ - grep "rippled-reporting-dbgsym_${RIPPLED_DPKG_VERSION}-1_amd64.*" | cut -d " " -f 1) -REPORTING_SHA256=$(cat shasums | \ - grep "rippled-reporting_${RIPPLED_DPKG_VERSION}-1_amd64.deb" | cut -d " " -f 1) -SRC_SHA256=$(cat shasums | \ - grep "rippled_${RIPPLED_DPKG_VERSION}.orig.tar.gz" | cut -d " " -f 1) -echo "deb_sha256=${DEB_SHA256}" >> ${PKG_OUTDIR}/build_vars -echo "dbg_sha256=${DBG_SHA256}" >> ${PKG_OUTDIR}/build_vars -echo "reporting_sha256=${REPORTING_SHA256}" >> ${PKG_OUTDIR}/build_vars -echo "reporting_dbg_sha256=${REPORTING_DBG_SHA256}" >> ${PKG_OUTDIR}/build_vars -echo "src_sha256=${SRC_SHA256}" >> ${PKG_OUTDIR}/build_vars -echo "rippled_version=${RIPPLED_VERSION}" >> ${PKG_OUTDIR}/build_vars -echo "dpkg_version=${RIPPLED_DPKG_VERSION}" >> ${PKG_OUTDIR}/build_vars -echo "dpkg_full_version=${RIPPLED_DPKG_FULL_VERSION}" >> ${PKG_OUTDIR}/build_vars diff --git a/Builds/containers/packaging/dpkg/debian/README.Debian b/Builds/containers/packaging/dpkg/debian/README.Debian deleted file mode 100644 index 25ba6b55f70..00000000000 --- a/Builds/containers/packaging/dpkg/debian/README.Debian +++ /dev/null @@ -1,3 +0,0 @@ -rippled daemon - - -- Mike Ellery Tue, 04 Dec 2018 18:19:03 +0000 diff --git a/Builds/containers/packaging/dpkg/debian/compat b/Builds/containers/packaging/dpkg/debian/compat deleted file mode 100644 index f599e28b8ab..00000000000 --- a/Builds/containers/packaging/dpkg/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/Builds/containers/packaging/dpkg/debian/control b/Builds/containers/packaging/dpkg/debian/control deleted file mode 100644 index b840eb228be..00000000000 --- a/Builds/containers/packaging/dpkg/debian/control +++ /dev/null @@ -1,19 +0,0 @@ -Source: rippled -Section: misc -Priority: extra -Maintainer: Ripple Labs Inc. -Build-Depends: cmake, debhelper (>=9), zlib1g-dev, dh-systemd, ninja-build -Standards-Version: 3.9.7 -Homepage: http://ripple.com/ - -Package: rippled -Architecture: any -Multi-Arch: foreign -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: rippled daemon - -Package: rippled-reporting -Architecture: any -Multi-Arch: foreign -Depends: ${misc:Depends}, ${shlibs:Depends} -Description: rippled reporting daemon diff --git a/Builds/containers/packaging/dpkg/debian/copyright b/Builds/containers/packaging/dpkg/debian/copyright deleted file mode 100644 index dce318fd765..00000000000 --- a/Builds/containers/packaging/dpkg/debian/copyright +++ /dev/null @@ -1,86 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: rippled -Source: https://github.com/ripple/rippled - -Files: * -Copyright: 2012-2019 Ripple Labs Inc. - -License: __UNKNOWN__ - -The accompanying files under various copyrights. - -Copyright (c) 2012, 2013, 2014 Ripple Labs Inc. - -Permission to use, copy, modify, and distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - -The accompanying files incorporate work covered by the following copyright -and previous license notice: - -Copyright (c) 2011 Arthur Britto, David Schwartz, Jed McCaleb, -Vinnie Falco, Bob Way, Eric Lombrozo, Nikolaos D. Bougalis, Howard Hinnant - -Some code from Raw Material Software, Ltd., provided under the terms of the - ISC License. See the corresponding source files for more details. - Copyright (c) 2013 - Raw Material Software Ltd. - Please visit http://www.juce.com - -Some code from ASIO examples: -// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com) -// -// Distributed under the Boost Software License, Version 1.0. (See accompanying -// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -Some code from Bitcoin: -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2011 The Bitcoin developers -// Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. - -Some code from Tom Wu: -This software is covered under the following copyright: - -/* - * Copyright (c) 2003-2005 Tom Wu - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL TOM WU BE LIABLE FOR ANY SPECIAL, INCIDENTAL, - * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER - * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF - * THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * In addition, the following condition applies: - * - * All redistributions must retain an intact copy of this copyright notice - * and disclaimer. - */ - -Address all questions regarding this license to: - - Tom Wu - tjw@cs.Stanford.EDU diff --git a/Builds/containers/packaging/dpkg/debian/dirs b/Builds/containers/packaging/dpkg/debian/dirs deleted file mode 100644 index aed307ee178..00000000000 --- a/Builds/containers/packaging/dpkg/debian/dirs +++ /dev/null @@ -1,3 +0,0 @@ -/var/log/rippled/ -/var/lib/rippled/ -/etc/systemd/system/rippled.service.d/ diff --git a/Builds/containers/packaging/dpkg/debian/docs b/Builds/containers/packaging/dpkg/debian/docs deleted file mode 100644 index 17aa966627c..00000000000 --- a/Builds/containers/packaging/dpkg/debian/docs +++ /dev/null @@ -1,3 +0,0 @@ -README.md -LICENSE.md -RELEASENOTES.md diff --git a/Builds/containers/packaging/dpkg/debian/rippled-dev.install b/Builds/containers/packaging/dpkg/debian/rippled-dev.install deleted file mode 100644 index a222857c0b7..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -opt/ripple/include -opt/ripple/lib/*.a -opt/ripple/lib/cmake/ripple diff --git a/Builds/containers/packaging/dpkg/debian/rippled-reporting.dirs b/Builds/containers/packaging/dpkg/debian/rippled-reporting.dirs deleted file mode 100644 index 0f5cdbd40a7..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled-reporting.dirs +++ /dev/null @@ -1,3 +0,0 @@ -/var/log/rippled-reporting/ -/var/lib/rippled-reporting/ -/etc/systemd/system/rippled-reporting.service.d/ \ No newline at end of file diff --git a/Builds/containers/packaging/dpkg/debian/rippled-reporting.install b/Builds/containers/packaging/dpkg/debian/rippled-reporting.install deleted file mode 100644 index 0cee940f59e..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled-reporting.install +++ /dev/null @@ -1,8 +0,0 @@ -build.rippled-reporting/rippled-reporting opt/rippled-reporting/bin -cfg/rippled-reporting.cfg opt/rippled-reporting/etc -debian/tmp/opt/rippled-reporting/etc/validators.txt opt/rippled-reporting/etc - -opt/rippled-reporting/bin/update-rippled-reporting.sh -opt/rippled-reporting/bin/getRippledReportingInfo -opt/rippled-reporting/etc/update-rippled-reporting-cron -etc/logrotate.d/rippled-reporting diff --git a/Builds/containers/packaging/dpkg/debian/rippled-reporting.links b/Builds/containers/packaging/dpkg/debian/rippled-reporting.links deleted file mode 100644 index ab83b0c816d..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled-reporting.links +++ /dev/null @@ -1,3 +0,0 @@ -opt/rippled-reporting/etc/rippled-reporting.cfg etc/opt/rippled-reporting/rippled-reporting.cfg -opt/rippled-reporting/etc/validators.txt etc/opt/rippled-reporting/validators.txt -opt/rippled-reporting/bin/rippled-reporting usr/local/bin/rippled-reporting diff --git a/Builds/containers/packaging/dpkg/debian/rippled-reporting.postinst b/Builds/containers/packaging/dpkg/debian/rippled-reporting.postinst deleted file mode 100644 index 64044197344..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled-reporting.postinst +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -set -e - -USER_NAME=rippled-reporting -GROUP_NAME=rippled-reporting -case "$1" in - configure) - id -u $USER_NAME >/dev/null 2>&1 || \ - adduser --system --quiet \ - --home /nonexistent --no-create-home \ - --disabled-password \ - --group "$GROUP_NAME" - chown -R $USER_NAME:$GROUP_NAME /var/log/rippled-reporting/ - chown -R $USER_NAME:$GROUP_NAME /var/lib/rippled-reporting/ - chmod 755 /var/log/rippled-reporting/ - chmod 755 /var/lib/rippled-reporting/ - chown -R $USER_NAME:$GROUP_NAME /opt/rippled-reporting - - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - - -#DEBHELPER# - -exit 0 diff --git a/Builds/containers/packaging/dpkg/debian/rippled.conffiles b/Builds/containers/packaging/dpkg/debian/rippled.conffiles deleted file mode 100644 index 0c6d1c36d42..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.conffiles +++ /dev/null @@ -1,2 +0,0 @@ -/opt/ripple/etc/rippled.cfg -/opt/ripple/etc/validators.txt diff --git a/Builds/containers/packaging/dpkg/debian/rippled.install b/Builds/containers/packaging/dpkg/debian/rippled.install deleted file mode 100644 index 3ce9f60fb3a..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.install +++ /dev/null @@ -1,8 +0,0 @@ -opt/ripple/bin/rippled -opt/ripple/bin/validator-keys -opt/ripple/bin/update-rippled.sh -opt/ripple/bin/getRippledInfo -opt/ripple/etc/rippled.cfg -opt/ripple/etc/validators.txt -opt/ripple/etc/update-rippled-cron -etc/logrotate.d/rippled diff --git a/Builds/containers/packaging/dpkg/debian/rippled.links b/Builds/containers/packaging/dpkg/debian/rippled.links deleted file mode 100644 index ff2abd82b31..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.links +++ /dev/null @@ -1,3 +0,0 @@ -opt/ripple/etc/rippled.cfg etc/opt/ripple/rippled.cfg -opt/ripple/etc/validators.txt etc/opt/ripple/validators.txt -opt/ripple/bin/rippled usr/local/bin/rippled diff --git a/Builds/containers/packaging/dpkg/debian/rippled.postinst b/Builds/containers/packaging/dpkg/debian/rippled.postinst deleted file mode 100644 index 9838fa593f7..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.postinst +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -set -e - -USER_NAME=rippled -GROUP_NAME=rippled -case "$1" in - configure) - id -u $USER_NAME >/dev/null 2>&1 || \ - adduser --system --quiet \ - --home /nonexistent --no-create-home \ - --disabled-password \ - --group "$GROUP_NAME" - chown -R $USER_NAME:$GROUP_NAME /var/log/rippled/ - chown -R $USER_NAME:$GROUP_NAME /var/lib/rippled/ - chown -R $USER_NAME:$GROUP_NAME /opt/ripple - chmod 755 /var/log/rippled/ - chmod 755 /var/lib/rippled/ - chmod 644 /opt/ripple/etc/update-rippled-cron - chmod 644 /etc/logrotate.d/rippled - chown -R root:$GROUP_NAME /opt/ripple/etc/update-rippled-cron - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - - -#DEBHELPER# - -exit 0 diff --git a/Builds/containers/packaging/dpkg/debian/rippled.postrm b/Builds/containers/packaging/dpkg/debian/rippled.postrm deleted file mode 100644 index 9086993a1f5..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.postrm +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh -set -e - -case "$1" in - purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - - -#DEBHELPER# - -exit 0 diff --git a/Builds/containers/packaging/dpkg/debian/rippled.preinst b/Builds/containers/packaging/dpkg/debian/rippled.preinst deleted file mode 100644 index 10575345a2b..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.preinst +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -case "$1" in - install|upgrade) - ;; - - abort-upgrade) - ;; - - *) - echo "preinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - - -#DEBHELPER# - -exit 0 diff --git a/Builds/containers/packaging/dpkg/debian/rippled.prerm b/Builds/containers/packaging/dpkg/debian/rippled.prerm deleted file mode 100644 index adabdbfb72a..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rippled.prerm +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh -set -e - -case "$1" in - remove|upgrade|deconfigure) - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - - -#DEBHELPER# - -exit 0 diff --git a/Builds/containers/packaging/dpkg/debian/rules b/Builds/containers/packaging/dpkg/debian/rules deleted file mode 100755 index 08b180e104c..00000000000 --- a/Builds/containers/packaging/dpkg/debian/rules +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/make -f -export DH_VERBOSE = 1 -export DH_OPTIONS = -v -# debuild sets some warnings that don't work well -# for our curent build..so try to remove those flags here: -export CFLAGS:=$(subst -Wformat,,$(CFLAGS)) -export CFLAGS:=$(subst -Werror=format-security,,$(CFLAGS)) -export CXXFLAGS:=$(subst -Wformat,,$(CXXFLAGS)) -export CXXFLAGS:=$(subst -Werror=format-security,,$(CXXFLAGS)) - -%: - dh $@ --with systemd - -override_dh_systemd_start: - dh_systemd_start --no-restart-on-upgrade - -override_dh_auto_configure: - /root/.pyenv/shims/conan export external/snappy snappy/1.1.10@ - /root/.pyenv/shims/conan export external/soci soci/4.0.3@ - - mkdir build.rippled - - cd build.rippled && \ - /root/.pyenv/shims/conan install .. \ - --profile gcc \ - --output-folder . \ - --build missing \ - --settings build_type=Release - - cd build.rippled && \ - cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -Dvalidator_keys=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake - - mkdir build.rippled-reporting - - cd build.rippled-reporting && \ - /root/.pyenv/shims/conan install .. \ - --profile gcc \ - --output-folder . \ - --settings compiler.cppstd=17 \ - --settings build_type=Release \ - --build missing \ - --build boost \ - --build sqlite3 \ - --build libuv \ - --options reporting=True - - cd build.rippled-reporting && \ - cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -Dvalidator_keys=ON \ - -Dstatic=ON \ - -Dunity=OFF \ - -Dreporting=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake - -override_dh_auto_build: - cmake --build build.rippled --target rippled --target validator-keys --parallel 8 - cmake --build build.rippled-reporting --target rippled --parallel 8 - -override_dh_auto_install: - cmake --install build.rippled --prefix debian/tmp/opt/ripple - install -D build.rippled/validator-keys/validator-keys debian/tmp/opt/ripple/bin/validator-keys - install -D Builds/containers/shared/update-rippled.sh debian/tmp/opt/ripple/bin/update-rippled.sh - install -D bin/getRippledInfo debian/tmp/opt/ripple/bin/getRippledInfo - install -D Builds/containers/shared/update-rippled-cron debian/tmp/opt/ripple/etc/update-rippled-cron - install -D Builds/containers/shared/rippled-logrotate debian/tmp/etc/logrotate.d/rippled - rm -rf debian/tmp/opt/ripple/lib64/cmake/date - - mkdir -p debian/tmp/opt/rippled-reporting/etc - mkdir -p debian/tmp/opt/rippled-reporting/bin - cp cfg/validators-example.txt debian/tmp/opt/rippled-reporting/etc/validators.txt - - sed -E 's/rippled?/rippled-reporting/g' Builds/containers/shared/update-rippled.sh > debian/tmp/opt/rippled-reporting/bin/update-rippled-reporting.sh - sed -E 's/rippled?/rippled-reporting/g' bin/getRippledInfo > debian/tmp/opt/rippled-reporting/bin/getRippledReportingInfo - sed -E 's/rippled?/rippled-reporting/g' Builds/containers/shared/update-rippled-cron > debian/tmp/opt/rippled-reporting/etc/update-rippled-reporting-cron - sed -E 's/rippled?/rippled-reporting/g' Builds/containers/shared/rippled-logrotate > debian/tmp/etc/logrotate.d/rippled-reporting diff --git a/Builds/containers/packaging/dpkg/debian/source/format b/Builds/containers/packaging/dpkg/debian/source/format deleted file mode 100644 index 163aaf8d82b..00000000000 --- a/Builds/containers/packaging/dpkg/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/Builds/containers/packaging/dpkg/debian/source/local-options b/Builds/containers/packaging/dpkg/debian/source/local-options deleted file mode 100644 index 00131ee8c41..00000000000 --- a/Builds/containers/packaging/dpkg/debian/source/local-options +++ /dev/null @@ -1,2 +0,0 @@ -#abort-on-upstream-changes -#unapply-patches diff --git a/Builds/containers/packaging/rpm/50-rippled-reporting.preset b/Builds/containers/packaging/rpm/50-rippled-reporting.preset deleted file mode 100644 index 50d16dd7acd..00000000000 --- a/Builds/containers/packaging/rpm/50-rippled-reporting.preset +++ /dev/null @@ -1 +0,0 @@ -enable rippled-reporting.service \ No newline at end of file diff --git a/Builds/containers/packaging/rpm/50-rippled.preset b/Builds/containers/packaging/rpm/50-rippled.preset deleted file mode 100644 index 854e20a0872..00000000000 --- a/Builds/containers/packaging/rpm/50-rippled.preset +++ /dev/null @@ -1 +0,0 @@ -enable rippled.service \ No newline at end of file diff --git a/Builds/containers/packaging/rpm/build_rpm.sh b/Builds/containers/packaging/rpm/build_rpm.sh deleted file mode 100755 index 57e576b510b..00000000000 --- a/Builds/containers/packaging/rpm/build_rpm.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/usr/bin/env bash -set -ex - -cd /opt/rippled_bld/pkg -cp -fpu rippled/Builds/containers/packaging/rpm/rippled.spec . -cp -fpu rippled/Builds/containers/shared/update_sources.sh . -source update_sources.sh - -# Build the rpm - -IFS='-' read -r RIPPLED_RPM_VERSION RELEASE <<< "$RIPPLED_VERSION" -export RIPPLED_RPM_VERSION - -RPM_RELEASE=${RPM_RELEASE-1} - -# post-release version -if [ "hf" = "$(echo "$RELEASE" | cut -c -2)" ]; then - RPM_RELEASE="${RPM_RELEASE}.${RELEASE}" -# pre-release version (-b or -rc) -elif [[ $RELEASE ]]; then - RPM_RELEASE="0.${RPM_RELEASE}.${RELEASE}" -fi - -export RPM_RELEASE - -if [[ $RPM_PATCH ]]; then - RPM_PATCH=".${RPM_PATCH}" - export RPM_PATCH -fi - -cd /opt/rippled_bld/pkg/rippled - -if [[ -n $(git status --porcelain) ]]; then - git status - error "Unstaged changes in this repo - please commit first" -fi - -git archive --format tar.gz --prefix rippled/ -o ../rpmbuild/SOURCES/rippled.tar.gz HEAD - -cd .. - -source /opt/rh/devtoolset-11/enable - -rpmbuild --define "_topdir ${PWD}/rpmbuild" -ba rippled.spec - -rc=$?; if [[ $rc != 0 ]]; then - error "error building rpm" -fi - -# Make a tar of the rpm and source rpm -RPM_VERSION_RELEASE=$(rpm -qp --qf='%{NAME}-%{VERSION}-%{RELEASE}' ./rpmbuild/RPMS/x86_64/rippled-[0-9]*.rpm) -tar_file=$RPM_VERSION_RELEASE.tar.gz - -cp ./rpmbuild/RPMS/x86_64/* ${PKG_OUTDIR} -cp ./rpmbuild/SRPMS/* ${PKG_OUTDIR} - -RPM_MD5SUM=$(rpm -q --queryformat '%{SIGMD5}\n' -p ./rpmbuild/RPMS/x86_64/rippled-[0-9]*.rpm 2>/dev/null) -DBG_MD5SUM=$(rpm -q --queryformat '%{SIGMD5}\n' -p ./rpmbuild/RPMS/x86_64/rippled-debuginfo*.rpm 2>/dev/null) -DEV_MD5SUM=$(rpm -q --queryformat '%{SIGMD5}\n' -p ./rpmbuild/RPMS/x86_64/rippled-devel*.rpm 2>/dev/null) -REP_MD5SUM=$(rpm -q --queryformat '%{SIGMD5}\n' -p ./rpmbuild/RPMS/x86_64/rippled-reporting*.rpm 2>/dev/null) -SRC_MD5SUM=$(rpm -q --queryformat '%{SIGMD5}\n' -p ./rpmbuild/SRPMS/*.rpm 2>/dev/null) - -RPM_SHA256="$(sha256sum ./rpmbuild/RPMS/x86_64/rippled-[0-9]*.rpm | awk '{ print $1}')" -DBG_SHA256="$(sha256sum ./rpmbuild/RPMS/x86_64/rippled-debuginfo*.rpm | awk '{ print $1}')" -REP_SHA256="$(sha256sum ./rpmbuild/RPMS/x86_64/rippled-reporting*.rpm | awk '{ print $1}')" -DEV_SHA256="$(sha256sum ./rpmbuild/RPMS/x86_64/rippled-devel*.rpm | awk '{ print $1}')" -SRC_SHA256="$(sha256sum ./rpmbuild/SRPMS/*.rpm | awk '{ print $1}')" - -echo "rpm_md5sum=$RPM_MD5SUM" > ${PKG_OUTDIR}/build_vars -echo "rep_md5sum=$REP_MD5SUM" >> ${PKG_OUTDIR}/build_vars -echo "dbg_md5sum=$DBG_MD5SUM" >> ${PKG_OUTDIR}/build_vars -echo "dev_md5sum=$DEV_MD5SUM" >> ${PKG_OUTDIR}/build_vars -echo "src_md5sum=$SRC_MD5SUM" >> ${PKG_OUTDIR}/build_vars -echo "rpm_sha256=$RPM_SHA256" >> ${PKG_OUTDIR}/build_vars -echo "rep_sha256=$REP_SHA256" >> ${PKG_OUTDIR}/build_vars -echo "dbg_sha256=$DBG_SHA256" >> ${PKG_OUTDIR}/build_vars -echo "dev_sha256=$DEV_SHA256" >> ${PKG_OUTDIR}/build_vars -echo "src_sha256=$SRC_SHA256" >> ${PKG_OUTDIR}/build_vars -echo "rippled_version=$RIPPLED_VERSION" >> ${PKG_OUTDIR}/build_vars -echo "rpm_version=$RIPPLED_RPM_VERSION" >> ${PKG_OUTDIR}/build_vars -echo "rpm_file_name=$tar_file" >> ${PKG_OUTDIR}/build_vars -echo "rpm_version_release=$RPM_VERSION_RELEASE" >> ${PKG_OUTDIR}/build_vars diff --git a/Builds/containers/packaging/rpm/rippled.spec b/Builds/containers/packaging/rpm/rippled.spec deleted file mode 100644 index 0c2f454fa42..00000000000 --- a/Builds/containers/packaging/rpm/rippled.spec +++ /dev/null @@ -1,239 +0,0 @@ -%define rippled_version %(echo $RIPPLED_RPM_VERSION) -%define rpm_release %(echo $RPM_RELEASE) -%define rpm_patch %(echo $RPM_PATCH) -%define _prefix /opt/ripple - -Name: rippled -# Dashes in Version extensions must be converted to underscores -Version: %{rippled_version} -Release: %{rpm_release}%{?dist}%{rpm_patch} -Summary: rippled daemon - -License: MIT -URL: http://ripple.com/ -Source0: rippled.tar.gz - -BuildRequires: cmake zlib-static ninja-build - -%description -rippled - -%package devel -Summary: Files for development of applications using xrpl core library -Group: Development/Libraries -Requires: zlib-static - -%description devel -core library for development of standalone applications that sign transactions. - -%package reporting -Summary: Reporting Server for rippled - -%description reporting -History server for XRP Ledger - -%prep -%setup -c -n rippled - -%build - -source /opt/rh/devtoolset-11/enable -source /opt/rh/rh-python38/enable - -pip install "conan<2" - -conan profile new default --detect -conan profile update settings.compiler.cppstd=20 default -conan profile update settings.compiler.libcxx=libstdc++11 default - -cd rippled - -conan export external/snappy snappy/1.1.10@ -conan export external/soci soci/4.0.3@ - -mkdir -p bld.rippled -pushd bld.rippled - -cp /opt/libcstd/libstdc++.so.6.0.22 /usr/lib64 -cp /opt/libcstd/libstdc++.so.6.0.22 /lib64 -ln -sf /usr/lib64/libstdc++.so.6.0.22 /usr/lib64/libstdc++.so.6 -ln -sf /lib64/libstdc++.so.6.0.22 /usr/lib64/libstdc++.so.6 - -conan install .. \ - --profile default \ - --output-folder . \ - --build missing \ - --settings build_type=Release - -cmake .. \ - -DCMAKE_BUILD_TYPE=Release \ - -Dvalidator_keys=ON \ - -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake - -cmake --build . --parallel $(nproc) --target rippled --target validator-keys - -popd - -mkdir -p bld.rippled-reporting -pushd bld.rippled-reporting - -conan install .. \ - --settings build_type=Release \ - --output-folder . \ - --build missing \ - --settings compiler.cppstd=17 \ - --options reporting=True - -cmake .. \ - -G Ninja \ - -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake \ - -DCMAKE_INSTALL_PREFIX=%{_prefix} \ - -DCMAKE_BUILD_TYPE=Release \ - -Dunity=OFF \ - -Dstatic=ON \ - -Dvalidator_keys=ON \ - -Dreporting=ON \ - -DCMAKE_VERBOSE_MAKEFILE=ON \ - -cmake --build . --parallel $(nproc) --target rippled - -%pre -test -e /etc/pki/tls || { mkdir -p /etc/pki; ln -s /usr/lib/ssl /etc/pki/tls; } - -%install -rm -rf $RPM_BUILD_ROOT -DESTDIR=$RPM_BUILD_ROOT cmake --build rippled/bld.rippled --target install #-- -v -mkdir -p $RPM_BUILD_ROOT -rm -rf ${RPM_BUILD_ROOT}%{_prefix}/lib64/ -install -d ${RPM_BUILD_ROOT}/etc/opt/ripple -install -d ${RPM_BUILD_ROOT}/usr/local/bin - -install -D ./rippled/cfg/rippled-example.cfg ${RPM_BUILD_ROOT}/%{_prefix}/etc/rippled.cfg -install -D ./rippled/cfg/validators-example.txt ${RPM_BUILD_ROOT}/%{_prefix}/etc/validators.txt - -ln -sf %{_prefix}/etc/rippled.cfg ${RPM_BUILD_ROOT}/etc/opt/ripple/rippled.cfg -ln -sf %{_prefix}/etc/validators.txt ${RPM_BUILD_ROOT}/etc/opt/ripple/validators.txt -ln -sf %{_prefix}/bin/rippled ${RPM_BUILD_ROOT}/usr/local/bin/rippled -install -D rippled/bld.rippled/validator-keys/validator-keys ${RPM_BUILD_ROOT}%{_bindir}/validator-keys -install -D ./rippled/Builds/containers/shared/rippled.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/rippled.service -install -D ./rippled/Builds/containers/packaging/rpm/50-rippled.preset ${RPM_BUILD_ROOT}/usr/lib/systemd/system-preset/50-rippled.preset -install -D ./rippled/Builds/containers/shared/update-rippled.sh ${RPM_BUILD_ROOT}%{_bindir}/update-rippled.sh -install -D ./rippled/bin/getRippledInfo ${RPM_BUILD_ROOT}%{_bindir}/getRippledInfo -install -D ./rippled/Builds/containers/shared/update-rippled-cron ${RPM_BUILD_ROOT}%{_prefix}/etc/update-rippled-cron -install -D ./rippled/Builds/containers/shared/rippled-logrotate ${RPM_BUILD_ROOT}/etc/logrotate.d/rippled -install -d $RPM_BUILD_ROOT/var/log/rippled -install -d $RPM_BUILD_ROOT/var/lib/rippled - -# reporting mode -%define _prefix /opt/rippled-reporting -mkdir -p ${RPM_BUILD_ROOT}/etc/opt/rippled-reporting/ -install -D rippled/bld.rippled-reporting/rippled-reporting ${RPM_BUILD_ROOT}%{_bindir}/rippled-reporting -install -D ./rippled/cfg/rippled-reporting.cfg ${RPM_BUILD_ROOT}%{_prefix}/etc/rippled-reporting.cfg -install -D ./rippled/cfg/validators-example.txt ${RPM_BUILD_ROOT}%{_prefix}/etc/validators.txt -install -D ./rippled/Builds/containers/packaging/rpm/50-rippled-reporting.preset ${RPM_BUILD_ROOT}/usr/lib/systemd/system-preset/50-rippled-reporting.preset -ln -sf %{_prefix}/bin/rippled-reporting ${RPM_BUILD_ROOT}/usr/local/bin/rippled-reporting -ln -sf %{_prefix}/etc/rippled-reporting.cfg ${RPM_BUILD_ROOT}/etc/opt/rippled-reporting/rippled-reporting.cfg -ln -sf %{_prefix}/etc/validators.txt ${RPM_BUILD_ROOT}/etc/opt/rippled-reporting/validators.txt -install -d $RPM_BUILD_ROOT/var/log/rippled-reporting -install -d $RPM_BUILD_ROOT/var/lib/rippled-reporting -install -D ./rippled/Builds/containers/shared/rippled-reporting.service ${RPM_BUILD_ROOT}/usr/lib/systemd/system/rippled-reporting.service -sed -E 's/rippled?/rippled-reporting/g' ./rippled/Builds/containers/shared/update-rippled.sh > ${RPM_BUILD_ROOT}%{_bindir}/update-rippled-reporting.sh -sed -E 's/rippled?/rippled-reporting/g' ./rippled/bin/getRippledInfo > ${RPM_BUILD_ROOT}%{_bindir}/getRippledReportingInfo -sed -E 's/rippled?/rippled-reporting/g' ./rippled/Builds/containers/shared/update-rippled-cron > ${RPM_BUILD_ROOT}%{_prefix}/etc/update-rippled-reporting-cron -sed -E 's/rippled?/rippled-reporting/g' ./rippled/Builds/containers/shared/rippled-logrotate > ${RPM_BUILD_ROOT}/etc/logrotate.d/rippled-reporting - - -%post -%define _prefix /opt/ripple -USER_NAME=rippled -GROUP_NAME=rippled - -getent passwd $USER_NAME &>/dev/null || useradd $USER_NAME -getent group $GROUP_NAME &>/dev/null || groupadd $GROUP_NAME - -chown -R $USER_NAME:$GROUP_NAME /var/log/rippled/ -chown -R $USER_NAME:$GROUP_NAME /var/lib/rippled/ -chown -R $USER_NAME:$GROUP_NAME %{_prefix}/ - -chmod 755 /var/log/rippled/ -chmod 755 /var/lib/rippled/ - -chmod 644 %{_prefix}/etc/update-rippled-cron -chmod 644 /etc/logrotate.d/rippled -chown -R root:$GROUP_NAME %{_prefix}/etc/update-rippled-cron - -%post reporting -%define _prefix /opt/rippled-reporting -USER_NAME=rippled-reporting -GROUP_NAME=rippled-reporting - -getent passwd $USER_NAME &>/dev/null || useradd -r $USER_NAME -getent group $GROUP_NAME &>/dev/null || groupadd $GROUP_NAME - -chown -R $USER_NAME:$GROUP_NAME /var/log/rippled-reporting/ -chown -R $USER_NAME:$GROUP_NAME /var/lib/rippled-reporting/ -chown -R $USER_NAME:$GROUP_NAME %{_prefix}/ - -chmod 755 /var/log/rippled-reporting/ -chmod 755 /var/lib/rippled-reporting/ -chmod -x /usr/lib/systemd/system/rippled-reporting.service - - -%files -%define _prefix /opt/ripple -%doc rippled/README.md rippled/LICENSE.md -%{_bindir}/rippled -/usr/local/bin/rippled -%{_bindir}/update-rippled.sh -%{_bindir}/getRippledInfo -%{_prefix}/etc/update-rippled-cron -%{_bindir}/validator-keys -%config(noreplace) %{_prefix}/etc/rippled.cfg -%config(noreplace) /etc/opt/ripple/rippled.cfg -%config(noreplace) %{_prefix}/etc/validators.txt -%config(noreplace) /etc/opt/ripple/validators.txt -%config(noreplace) /etc/logrotate.d/rippled -%config(noreplace) /usr/lib/systemd/system/rippled.service -%config(noreplace) /usr/lib/systemd/system-preset/50-rippled.preset - -%dir /var/log/rippled/ -%dir /var/lib/rippled/ - -%files devel -%{_prefix}/include -%{_prefix}/lib/*.a -%{_prefix}/lib/cmake/ripple - -%files reporting -%define _prefix /opt/rippled-reporting -%doc rippled/README.md rippled/LICENSE.md - -%{_bindir}/rippled-reporting -/usr/local/bin/rippled-reporting -%config(noreplace) /etc/opt/rippled-reporting/rippled-reporting.cfg -%config(noreplace) %{_prefix}/etc/rippled-reporting.cfg -%config(noreplace) %{_prefix}/etc/validators.txt -%config(noreplace) /etc/opt/rippled-reporting/validators.txt -%config(noreplace) /usr/lib/systemd/system/rippled-reporting.service -%config(noreplace) /usr/lib/systemd/system-preset/50-rippled-reporting.preset -%dir /var/log/rippled-reporting/ -%dir /var/lib/rippled-reporting/ -%{_bindir}/update-rippled-reporting.sh -%{_bindir}/getRippledReportingInfo -%{_prefix}/etc/update-rippled-reporting-cron -%config(noreplace) /etc/logrotate.d/rippled-reporting - -%changelog -* Wed Aug 28 2019 Mike Ellery -- Switch to subproject build for validator-keys - -* Wed May 15 2019 Mike Ellery -- Make validator-keys use local rippled build for core lib - -* Wed Aug 01 2018 Mike Ellery -- add devel package for signing library - -* Thu Jun 02 2016 Brandon Wilson -- Install validators.txt diff --git a/Builds/containers/shared/install_cmake.sh b/Builds/containers/shared/install_cmake.sh deleted file mode 100755 index e6f84dd6c03..00000000000 --- a/Builds/containers/shared/install_cmake.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -e - -IFS=. read cm_maj cm_min cm_rel <<<"$1" -: ${cm_rel:-0} -CMAKE_ROOT=${2:-"${HOME}/cmake"} - -function cmake_version () -{ - if [[ -d ${CMAKE_ROOT} ]] ; then - local perms=$(test $(uname) = "Linux" && echo "/111" || echo "+111") - local installed=$(find ${CMAKE_ROOT} -perm ${perms} -type f -name cmake) - if [[ "${installed}" != "" ]] ; then - echo "$(${installed} --version | head -1)" - fi - fi -} - -installed=$(cmake_version) -if [[ "${installed}" != "" && ${installed} =~ ${cm_maj}.${cm_min}.${cm_rel} ]] ; then - echo "cmake already installed: ${installed}" - exit -fi -# From CMake 20+ "Linux" is lowercase so using `uname` won't create be the correct path -if [ ${cm_min} -gt 19 ]; then - linux="linux" -else - linux=$(uname) -fi -pkgname="cmake-${cm_maj}.${cm_min}.${cm_rel}-${linux}-x86_64.tar.gz" -tmppkg="/tmp/cmake.tar.gz" -wget --quiet https://cmake.org/files/v${cm_maj}.${cm_min}/${pkgname} -O ${tmppkg} -mkdir -p ${CMAKE_ROOT} -cd ${CMAKE_ROOT} -tar --strip-components 1 -xf ${tmppkg} -rm -f ${tmppkg} -echo "installed: $(cmake_version)" diff --git a/Builds/containers/shared/rippled-logrotate b/Builds/containers/shared/rippled-logrotate deleted file mode 100644 index 120aa91d3cc..00000000000 --- a/Builds/containers/shared/rippled-logrotate +++ /dev/null @@ -1,15 +0,0 @@ -/var/log/rippled/*.log { - daily - minsize 200M - rotate 7 - nocreate - missingok - notifempty - compress - compresscmd /usr/bin/nice - compressoptions -n19 ionice -c3 gzip - compressext .gz - postrotate - /opt/ripple/bin/rippled --conf /opt/ripple/etc/rippled.cfg logrotate - endscript -} diff --git a/Builds/containers/shared/rippled-reporting.service b/Builds/containers/shared/rippled-reporting.service deleted file mode 100644 index 69edf4794ab..00000000000 --- a/Builds/containers/shared/rippled-reporting.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Ripple Daemon -After=network-online.target -Wants=network-online.target - -[Service] -Type=simple -ExecStart=/opt/rippled-reporting/bin/rippled-reporting --silent --conf /etc/opt/rippled-reporting/rippled-reporting.cfg -Restart=on-failure -User=rippled-reporting -Group=rippled-reporting -LimitNOFILE=65536 - -[Install] -WantedBy=multi-user.target diff --git a/Builds/containers/shared/rippled.service b/Builds/containers/shared/rippled.service deleted file mode 100644 index 24d9dd97590..00000000000 --- a/Builds/containers/shared/rippled.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Ripple Daemon -After=network-online.target -Wants=network-online.target - -[Service] -Type=simple -ExecStart=/opt/ripple/bin/rippled --net --silent --conf /etc/opt/ripple/rippled.cfg -Restart=on-failure -User=rippled -Group=rippled -LimitNOFILE=65536 - -[Install] -WantedBy=multi-user.target diff --git a/Builds/containers/shared/update-rippled-cron b/Builds/containers/shared/update-rippled-cron deleted file mode 100644 index c7744219f9a..00000000000 --- a/Builds/containers/shared/update-rippled-cron +++ /dev/null @@ -1,10 +0,0 @@ -# For automatic updates, symlink this file to /etc/cron.d/ -# Do not remove the newline at the end of this cron script - -# bash required for use of RANDOM below. -SHELL=/bin/bash -PATH=/sbin;/bin;/usr/sbin;/usr/bin - -# invoke check/update script with random delay up to 59 mins -0 * * * * root sleep $((RANDOM*3540/32768)) && /opt/ripple/bin/update-rippled.sh - diff --git a/Builds/containers/shared/update-rippled.sh b/Builds/containers/shared/update-rippled.sh deleted file mode 100755 index 19409ece0cb..00000000000 --- a/Builds/containers/shared/update-rippled.sh +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env bash - -# auto-update script for rippled daemon - -# Check for sudo/root permissions -if [[ $(id -u) -ne 0 ]] ; then - echo "This update script must be run as root or sudo" - exit 1 -fi - -LOCKDIR=/tmp/rippleupdate.lock -UPDATELOG=/var/log/rippled/update.log - -function cleanup { - # If this directory isn't removed, future updates will fail. - rmdir $LOCKDIR -} - -# Use mkdir to check if process is already running. mkdir is atomic, as against file create. -if ! mkdir $LOCKDIR 2>/dev/null; then - echo $(date -u) "lockdir exists - won't proceed." >> $UPDATELOG - exit 1 -fi -trap cleanup EXIT - -source /etc/os-release -can_update=false - -if [[ "$ID" == "ubuntu" || "$ID" == "debian" ]] ; then - # Silent update - apt-get update -qq - - # The next line is an "awk"ward way to check if the package needs to be updated. - RIPPLE=$(apt-get install -s --only-upgrade rippled | awk '/^Inst/ { print $2 }') - test "$RIPPLE" == "rippled" && can_update=true - - function apply_update { - apt-get install rippled -qq - } -elif [[ "$ID" == "fedora" || "$ID" == "centos" || "$ID" == "rhel" || "$ID" == "scientific" ]] ; then - RIPPLE_REPO=${RIPPLE_REPO-stable} - yum --disablerepo=* --enablerepo=ripple-$RIPPLE_REPO clean expire-cache - - yum check-update -q --enablerepo=ripple-$RIPPLE_REPO rippled || can_update=true - - function apply_update { - yum update -y --enablerepo=ripple-$RIPPLE_REPO rippled - } -else - echo "unrecognized distro!" - exit 1 -fi - -# Do the actual update and restart the service after reloading systemctl daemon. -if [ "$can_update" = true ] ; then - exec 3>&1 1>>${UPDATELOG} 2>&1 - set -e - apply_update - systemctl daemon-reload - systemctl restart rippled.service - echo $(date -u) "rippled daemon updated." -else - echo $(date -u) "no updates available" >> $UPDATELOG -fi - diff --git a/Builds/containers/shared/update_sources.sh b/Builds/containers/shared/update_sources.sh deleted file mode 100755 index 56ca958b287..00000000000 --- a/Builds/containers/shared/update_sources.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -function error { - echo $1 - exit 1 -} - -cd /opt/rippled_bld/pkg/rippled -export RIPPLED_VERSION=$(egrep -i -o "\b(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-[0-9a-z\-]+(\.[0-9a-z\-]+)*)?(\+[0-9a-z\-]+(\.[0-9a-z\-]+)*)?\b" src/ripple/protocol/impl/BuildInfo.cpp) - -: ${PKG_OUTDIR:=/opt/rippled_bld/pkg/out} -export PKG_OUTDIR -if [ ! -d ${PKG_OUTDIR} ]; then - error "${PKG_OUTDIR} is not mounted" -fi - -if [ -x ${OPENSSL_ROOT}/bin/openssl ]; then - LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${OPENSSL_ROOT}/lib ${OPENSSL_ROOT}/bin/openssl version -a -fi - diff --git a/Builds/containers/ubuntu-builder/Dockerfile b/Builds/containers/ubuntu-builder/Dockerfile deleted file mode 100644 index e2604d3a1ca..00000000000 --- a/Builds/containers/ubuntu-builder/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -ARG DIST_TAG=18.04 -FROM ubuntu:$DIST_TAG -ARG GIT_COMMIT=unknown -ARG CI_USE=false -LABEL git-commit=$GIT_COMMIT - -WORKDIR /root -COPY ubuntu-builder/ubuntu_setup.sh . -COPY ubuntu-builder/ubuntu_setup2.sh . - -RUN ./ubuntu_setup.sh && rm ubuntu_setup.sh - -RUN ./ubuntu_setup2.sh && rm ubuntu_setup2.sh - -COPY ubuntu-builder/ubuntu_setup3.sh . -RUN ./ubuntu_setup3.sh && rm ubuntu_setup3.sh - -RUN mkdir -m 777 -p /opt/rippled_bld/pkg/ -WORKDIR /opt/rippled_bld/pkg - -COPY packaging/dpkg/build_dpkg.sh ./ -CMD ./build_dpkg.sh diff --git a/Builds/containers/ubuntu-builder/ubuntu_setup.sh b/Builds/containers/ubuntu-builder/ubuntu_setup.sh deleted file mode 100755 index 778bcf53c0b..00000000000 --- a/Builds/containers/ubuntu-builder/ubuntu_setup.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o xtrace - -# Parameters - -gcc_version=${GCC_VERSION:-11} - -export DEBIAN_FRONTEND=noninteractive - -apt update -# Iteratively build the list of packages to install so that we can interleave -# the lines with comments explaining their inclusion. -dependencies='' -# - for add-apt-repository -dependencies+=' software-properties-common' -# - to download CMake -dependencies+=' curl' -# - to build CMake -dependencies+=' libssl-dev' -# - for Python -dependencies+=' libbz2-dev liblzma-dev libsqlite3-dev' -# - to download rippled -dependencies+=' git' -# - CMake generators (but not CMake itself) -dependencies+=' make ninja-build' -apt-get install --yes ${dependencies} - -add-apt-repository --yes ppa:ubuntu-toolchain-r/test -apt-get install --yes gcc-${gcc_version} g++-${gcc_version} -apt-get install --yes build-essential libssl-dev zlib1g-dev \ -libbz2-dev libreadline-dev libsqlite3-dev curl \ -libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev - -# Give us nice unversioned aliases for gcc and company. -update-alternatives --install \ - /usr/bin/gcc gcc /usr/bin/gcc-${gcc_version} 100 \ - --slave /usr/bin/g++ g++ /usr/bin/g++-${gcc_version} \ - --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-${gcc_version} \ - --slave /usr/bin/gcc-nm gcc-nm /usr/bin/gcc-nm-${gcc_version} \ - --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-${gcc_version} \ - --slave /usr/bin/gcov gcov /usr/bin/gcov-${gcc_version} \ - --slave /usr/bin/gcov-tool gcov-tool /usr/bin/gcov-dump-${gcc_version} \ - --slave /usr/bin/gcov-dump gcov-dump /usr/bin/gcov-tool-${gcc_version} -update-alternatives --auto gcc diff --git a/Builds/containers/ubuntu-builder/ubuntu_setup2.sh b/Builds/containers/ubuntu-builder/ubuntu_setup2.sh deleted file mode 100755 index 07ea577c68a..00000000000 --- a/Builds/containers/ubuntu-builder/ubuntu_setup2.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o xtrace - -# Parameters - -gcc_version=${GCC_VERSION:-11} -cmake_version=${CMAKE_VERSION:-3.25.1} -cmake_sha256=1c511d09516af493694ed9baf13c55947a36389674d657a2d5e0ccedc6b291d8 -conan_version=${CONAN_VERSION:-1.60} - -curl https://pyenv.run | bash -export PYENV_ROOT="$HOME/.pyenv" -command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" -eval "$(pyenv init -)" - -pyenv install 3.11.2 -pyenv global 3.11.2 - -# Download and unpack CMake. -cmake_slug="cmake-${cmake_version}" -cmake_archive="${cmake_slug}.tar.gz" -curl --location --remote-name \ - "https://github.com/Kitware/CMake/releases/download/v${cmake_version}/${cmake_archive}" -echo "${cmake_sha256} ${cmake_archive}" | sha256sum --check -tar -xzf ${cmake_archive} -rm ${cmake_archive} - -# Build and install CMake. -cd ${cmake_slug} -./bootstrap --parallel=$(nproc) -make --jobs $(nproc) -make install -cd .. -rm --recursive --force ${cmake_slug} - -# Install Conan. -pip install --upgrade pip -pip install conan==${conan_version} - -conan profile new --detect gcc -conan profile update settings.compiler=gcc gcc -conan profile update settings.compiler.version=${gcc_version} gcc -conan profile update settings.compiler.libcxx=libstdc++11 gcc -conan profile update settings.compiler.cppstd=20 gcc -conan profile update env.CC=/usr/bin/gcc gcc -conan profile update env.CXX=/usr/bin/g++ gcc diff --git a/Builds/containers/ubuntu-builder/ubuntu_setup3.sh b/Builds/containers/ubuntu-builder/ubuntu_setup3.sh deleted file mode 100755 index 91c7ca2406a..00000000000 --- a/Builds/containers/ubuntu-builder/ubuntu_setup3.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o xtrace - -apt-get install --yes build-essential fakeroot devscripts cmake debhelper dh-systemd diff --git a/CMakeLists.txt b/CMakeLists.txt index efe0ebf31ff..4754d76e425 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ endif () include(RippledSanity) include(RippledVersion) include(RippledSettings) -include(RippledRelease) # this check has to remain in the top-level cmake # because of the early return statement if (packages_only) From e2384885f5f630c8f0ffe4bf21a169b433a16858 Mon Sep 17 00:00:00 2001 From: Pretty Printer Date: Thu, 21 Mar 2024 21:29:31 -0500 Subject: [PATCH 03/16] Consolidate external libraries --- CMakeLists.txt | 4 +- external/README.md | 11 ++++++ .../ed25519-donna/CMakeLists.txt | 0 {src => external}/ed25519-donna/README.md | 0 .../ed25519-donna/curve25519-donna-32bit.h | 0 .../ed25519-donna/curve25519-donna-64bit.h | 0 .../ed25519-donna/curve25519-donna-helpers.h | 0 .../ed25519-donna/curve25519-donna-sse2.h | 0 .../ed25519-donna/ed25519-donna-32bit-sse2.h | 0 .../ed25519-donna-32bit-tables.h | 0 .../ed25519-donna/ed25519-donna-64bit-sse2.h | 0 .../ed25519-donna-64bit-tables.h | 0 .../ed25519-donna-64bit-x86-32bit.h | 0 .../ed25519-donna/ed25519-donna-64bit-x86.h | 0 .../ed25519-donna-basepoint-table.h | 0 .../ed25519-donna/ed25519-donna-batchverify.h | 0 .../ed25519-donna/ed25519-donna-impl-base.h | 0 .../ed25519-donna/ed25519-donna-impl-sse2.h | 0 .../ed25519-donna-portable-identify.h | 0 .../ed25519-donna/ed25519-donna-portable.h | 0 .../ed25519-donna/ed25519-donna.h | 0 .../ed25519-donna/ed25519-hash-custom.h | 0 .../ed25519-donna/ed25519-hash.h | 0 .../ed25519-randombytes-custom.h | 0 .../ed25519-donna/ed25519-randombytes.h | 0 {src => external}/ed25519-donna/ed25519.c | 0 {src => external}/ed25519-donna/ed25519.h | 0 .../ed25519-donna/fuzz/README.md | 0 .../ed25519-donna/fuzz/build-nix.php | 0 .../ed25519-donna/fuzz/curve25519-ref10.c | 0 .../ed25519-donna/fuzz/curve25519-ref10.h | 0 .../ed25519-donna/fuzz/ed25519-donna-sse2.c | 0 .../ed25519-donna/fuzz/ed25519-donna.c | 0 .../ed25519-donna/fuzz/ed25519-donna.h | 0 .../ed25519-donna/fuzz/ed25519-ref10.c | 0 .../ed25519-donna/fuzz/ed25519-ref10.h | 0 .../ed25519-donna/fuzz/fuzz-curve25519.c | 0 .../ed25519-donna/fuzz/fuzz-ed25519.c | 0 .../ed25519-donna/modm-donna-32bit.h | 0 .../ed25519-donna/modm-donna-64bit.h | 0 {src => external}/ed25519-donna/regression.h | 0 .../ed25519-donna/test-internals.c | 0 {src => external}/ed25519-donna/test-ticks.h | 0 {src => external}/ed25519-donna/test.c | 0 {src => external}/secp256k1/.cirrus.yml | 0 {src => external}/secp256k1/.gitattributes | 0 {src => external}/secp256k1/.gitignore | 0 {src => external}/secp256k1/CHANGELOG.md | 0 {src => external}/secp256k1/CMakeLists.txt | 0 {src => external}/secp256k1/CMakePresets.json | 0 {src => external}/secp256k1/COPYING | 0 {src => external}/secp256k1/Makefile.am | 0 {src => external}/secp256k1/README.md | 0 {src => external}/secp256k1/SECURITY.md | 0 {src => external}/secp256k1/autogen.sh | 0 .../secp256k1/build-aux/m4/bitcoin_secp.m4 | 0 {src => external}/secp256k1/ci/cirrus.sh | 0 .../secp256k1/ci/linux-debian.Dockerfile | 0 .../secp256k1/cmake/CheckArm32Assembly.cmake | 0 .../cmake/CheckStringOptionValue.cmake | 0 .../secp256k1/cmake/CheckX86_64Assembly.cmake | 0 .../secp256k1/cmake/FindValgrind.cmake | 0 .../secp256k1/cmake/TryAppendCFlags.cmake | 0 .../cmake/arm-linux-gnueabihf.toolchain.cmake | 0 .../secp256k1/cmake/config.cmake.in | 0 .../secp256k1/cmake/source_arm32.s | 0 .../cmake/x86_64-w64-mingw32.toolchain.cmake | 0 {src => external}/secp256k1/configure.ac | 0 .../secp256k1/contrib/lax_der_parsing.c | 0 .../secp256k1/contrib/lax_der_parsing.h | 0 .../contrib/lax_der_privatekey_parsing.c | 0 .../contrib/lax_der_privatekey_parsing.h | 0 .../secp256k1/doc/release-process.md | 0 .../secp256k1/doc/safegcd_implementation.md | 0 .../secp256k1/examples/CMakeLists.txt | 0 .../secp256k1/examples/EXAMPLES_COPYING | 0 {src => external}/secp256k1/examples/ecdh.c | 0 {src => external}/secp256k1/examples/ecdsa.c | 0 .../secp256k1/examples/examples_util.h | 0 .../secp256k1/examples/schnorr.c | 0 .../secp256k1/include/secp256k1.h | 0 .../secp256k1/include/secp256k1_ecdh.h | 0 .../secp256k1/include/secp256k1_extrakeys.h | 0 .../include/secp256k1_preallocated.h | 0 .../secp256k1/include/secp256k1_recovery.h | 0 .../secp256k1/include/secp256k1_schnorrsig.h | 0 .../secp256k1/libsecp256k1.pc.in | 0 .../secp256k1/sage/gen_exhaustive_groups.sage | 0 .../sage/gen_split_lambda_constants.sage | 0 .../secp256k1/sage/group_prover.sage | 0 .../sage/prove_group_implementations.sage | 0 .../secp256k1/sage/secp256k1_params.sage | 0 .../secp256k1/sage/weierstrass_prover.sage | 0 .../secp256k1/src/CMakeLists.txt | 0 .../secp256k1/src/asm/field_10x26_arm.s | 0 {src => external}/secp256k1/src/assumptions.h | 0 {src => external}/secp256k1/src/bench.c | 0 {src => external}/secp256k1/src/bench.h | 0 .../secp256k1/src/bench_ecmult.c | 0 .../secp256k1/src/bench_internal.c | 0 {src => external}/secp256k1/src/checkmem.h | 0 {src => external}/secp256k1/src/ctime_tests.c | 0 {src => external}/secp256k1/src/ecdsa.h | 0 {src => external}/secp256k1/src/ecdsa_impl.h | 0 {src => external}/secp256k1/src/eckey.h | 0 {src => external}/secp256k1/src/eckey_impl.h | 0 {src => external}/secp256k1/src/ecmult.h | 0 .../secp256k1/src/ecmult_compute_table.h | 0 .../secp256k1/src/ecmult_compute_table_impl.h | 0 .../secp256k1/src/ecmult_const.h | 0 .../secp256k1/src/ecmult_const_impl.h | 0 {src => external}/secp256k1/src/ecmult_gen.h | 0 .../secp256k1/src/ecmult_gen_compute_table.h | 0 .../src/ecmult_gen_compute_table_impl.h | 0 .../secp256k1/src/ecmult_gen_impl.h | 0 {src => external}/secp256k1/src/ecmult_impl.h | 0 {src => external}/secp256k1/src/field.h | 0 {src => external}/secp256k1/src/field_10x26.h | 0 .../secp256k1/src/field_10x26_impl.h | 0 {src => external}/secp256k1/src/field_5x52.h | 0 .../secp256k1/src/field_5x52_asm_impl.h | 0 .../secp256k1/src/field_5x52_impl.h | 0 .../secp256k1/src/field_5x52_int128_impl.h | 0 {src => external}/secp256k1/src/field_impl.h | 0 {src => external}/secp256k1/src/group.h | 0 {src => external}/secp256k1/src/group_impl.h | 0 {src => external}/secp256k1/src/hash.h | 0 {src => external}/secp256k1/src/hash_impl.h | 0 {src => external}/secp256k1/src/int128.h | 0 {src => external}/secp256k1/src/int128_impl.h | 0 .../secp256k1/src/int128_native.h | 0 .../secp256k1/src/int128_native_impl.h | 0 .../secp256k1/src/int128_struct.h | 0 .../secp256k1/src/int128_struct_impl.h | 0 {src => external}/secp256k1/src/modinv32.h | 0 .../secp256k1/src/modinv32_impl.h | 0 {src => external}/secp256k1/src/modinv64.h | 0 .../secp256k1/src/modinv64_impl.h | 0 .../src/modules/ecdh/Makefile.am.include | 0 .../secp256k1/src/modules/ecdh/bench_impl.h | 0 .../secp256k1/src/modules/ecdh/main_impl.h | 0 .../secp256k1/src/modules/ecdh/tests_impl.h | 0 .../src/modules/extrakeys/Makefile.am.include | 0 .../src/modules/extrakeys/main_impl.h | 0 .../modules/extrakeys/tests_exhaustive_impl.h | 0 .../src/modules/extrakeys/tests_impl.h | 0 .../src/modules/recovery/Makefile.am.include | 0 .../src/modules/recovery/bench_impl.h | 0 .../src/modules/recovery/main_impl.h | 0 .../modules/recovery/tests_exhaustive_impl.h | 0 .../src/modules/recovery/tests_impl.h | 0 .../modules/schnorrsig/Makefile.am.include | 0 .../src/modules/schnorrsig/bench_impl.h | 0 .../src/modules/schnorrsig/main_impl.h | 0 .../schnorrsig/tests_exhaustive_impl.h | 0 .../src/modules/schnorrsig/tests_impl.h | 0 .../secp256k1/src/precompute_ecmult.c | 0 .../secp256k1/src/precompute_ecmult_gen.c | 0 .../secp256k1/src/precomputed_ecmult.c | 0 .../secp256k1/src/precomputed_ecmult.h | 0 .../secp256k1/src/precomputed_ecmult_gen.c | 0 .../secp256k1/src/precomputed_ecmult_gen.h | 0 {src => external}/secp256k1/src/scalar.h | 0 {src => external}/secp256k1/src/scalar_4x64.h | 0 .../secp256k1/src/scalar_4x64_impl.h | 0 {src => external}/secp256k1/src/scalar_8x32.h | 0 .../secp256k1/src/scalar_8x32_impl.h | 0 {src => external}/secp256k1/src/scalar_impl.h | 0 {src => external}/secp256k1/src/scalar_low.h | 0 .../secp256k1/src/scalar_low_impl.h | 0 {src => external}/secp256k1/src/scratch.h | 0 .../secp256k1/src/scratch_impl.h | 0 {src => external}/secp256k1/src/secp256k1.c | 0 {src => external}/secp256k1/src/selftest.h | 0 {src => external}/secp256k1/src/testrand.h | 0 .../secp256k1/src/testrand_impl.h | 0 {src => external}/secp256k1/src/tests.c | 0 .../secp256k1/src/tests_exhaustive.c | 0 {src => external}/secp256k1/src/util.h | 0 .../src/wycheproof/WYCHEPROOF_COPYING | 0 .../ecdsa_secp256k1_sha256_bitcoin_test.h | 0 .../ecdsa_secp256k1_sha256_bitcoin_test.json | 0 .../tools/tests_wycheproof_generate.py | 0 src/README.md | 38 ------------------- 184 files changed, 13 insertions(+), 40 deletions(-) create mode 100644 external/README.md rename {src => external}/ed25519-donna/CMakeLists.txt (100%) rename {src => external}/ed25519-donna/README.md (100%) rename {src => external}/ed25519-donna/curve25519-donna-32bit.h (100%) rename {src => external}/ed25519-donna/curve25519-donna-64bit.h (100%) rename {src => external}/ed25519-donna/curve25519-donna-helpers.h (100%) rename {src => external}/ed25519-donna/curve25519-donna-sse2.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-32bit-sse2.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-32bit-tables.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-64bit-sse2.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-64bit-tables.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-64bit-x86-32bit.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-64bit-x86.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-basepoint-table.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-batchverify.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-impl-base.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-impl-sse2.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-portable-identify.h (100%) rename {src => external}/ed25519-donna/ed25519-donna-portable.h (100%) rename {src => external}/ed25519-donna/ed25519-donna.h (100%) rename {src => external}/ed25519-donna/ed25519-hash-custom.h (100%) rename {src => external}/ed25519-donna/ed25519-hash.h (100%) rename {src => external}/ed25519-donna/ed25519-randombytes-custom.h (100%) rename {src => external}/ed25519-donna/ed25519-randombytes.h (100%) rename {src => external}/ed25519-donna/ed25519.c (100%) rename {src => external}/ed25519-donna/ed25519.h (100%) rename {src => external}/ed25519-donna/fuzz/README.md (100%) rename {src => external}/ed25519-donna/fuzz/build-nix.php (100%) rename {src => external}/ed25519-donna/fuzz/curve25519-ref10.c (100%) rename {src => external}/ed25519-donna/fuzz/curve25519-ref10.h (100%) rename {src => external}/ed25519-donna/fuzz/ed25519-donna-sse2.c (100%) rename {src => external}/ed25519-donna/fuzz/ed25519-donna.c (100%) rename {src => external}/ed25519-donna/fuzz/ed25519-donna.h (100%) rename {src => external}/ed25519-donna/fuzz/ed25519-ref10.c (100%) rename {src => external}/ed25519-donna/fuzz/ed25519-ref10.h (100%) rename {src => external}/ed25519-donna/fuzz/fuzz-curve25519.c (100%) rename {src => external}/ed25519-donna/fuzz/fuzz-ed25519.c (100%) rename {src => external}/ed25519-donna/modm-donna-32bit.h (100%) rename {src => external}/ed25519-donna/modm-donna-64bit.h (100%) rename {src => external}/ed25519-donna/regression.h (100%) rename {src => external}/ed25519-donna/test-internals.c (100%) rename {src => external}/ed25519-donna/test-ticks.h (100%) rename {src => external}/ed25519-donna/test.c (100%) rename {src => external}/secp256k1/.cirrus.yml (100%) rename {src => external}/secp256k1/.gitattributes (100%) rename {src => external}/secp256k1/.gitignore (100%) rename {src => external}/secp256k1/CHANGELOG.md (100%) rename {src => external}/secp256k1/CMakeLists.txt (100%) rename {src => external}/secp256k1/CMakePresets.json (100%) rename {src => external}/secp256k1/COPYING (100%) rename {src => external}/secp256k1/Makefile.am (100%) rename {src => external}/secp256k1/README.md (100%) rename {src => external}/secp256k1/SECURITY.md (100%) rename {src => external}/secp256k1/autogen.sh (100%) rename {src => external}/secp256k1/build-aux/m4/bitcoin_secp.m4 (100%) rename {src => external}/secp256k1/ci/cirrus.sh (100%) rename {src => external}/secp256k1/ci/linux-debian.Dockerfile (100%) rename {src => external}/secp256k1/cmake/CheckArm32Assembly.cmake (100%) rename {src => external}/secp256k1/cmake/CheckStringOptionValue.cmake (100%) rename {src => external}/secp256k1/cmake/CheckX86_64Assembly.cmake (100%) rename {src => external}/secp256k1/cmake/FindValgrind.cmake (100%) rename {src => external}/secp256k1/cmake/TryAppendCFlags.cmake (100%) rename {src => external}/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake (100%) rename {src => external}/secp256k1/cmake/config.cmake.in (100%) rename {src => external}/secp256k1/cmake/source_arm32.s (100%) rename {src => external}/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake (100%) rename {src => external}/secp256k1/configure.ac (100%) rename {src => external}/secp256k1/contrib/lax_der_parsing.c (100%) rename {src => external}/secp256k1/contrib/lax_der_parsing.h (100%) rename {src => external}/secp256k1/contrib/lax_der_privatekey_parsing.c (100%) rename {src => external}/secp256k1/contrib/lax_der_privatekey_parsing.h (100%) rename {src => external}/secp256k1/doc/release-process.md (100%) rename {src => external}/secp256k1/doc/safegcd_implementation.md (100%) rename {src => external}/secp256k1/examples/CMakeLists.txt (100%) rename {src => external}/secp256k1/examples/EXAMPLES_COPYING (100%) rename {src => external}/secp256k1/examples/ecdh.c (100%) rename {src => external}/secp256k1/examples/ecdsa.c (100%) rename {src => external}/secp256k1/examples/examples_util.h (100%) rename {src => external}/secp256k1/examples/schnorr.c (100%) rename {src => external}/secp256k1/include/secp256k1.h (100%) rename {src => external}/secp256k1/include/secp256k1_ecdh.h (100%) rename {src => external}/secp256k1/include/secp256k1_extrakeys.h (100%) rename {src => external}/secp256k1/include/secp256k1_preallocated.h (100%) rename {src => external}/secp256k1/include/secp256k1_recovery.h (100%) rename {src => external}/secp256k1/include/secp256k1_schnorrsig.h (100%) rename {src => external}/secp256k1/libsecp256k1.pc.in (100%) rename {src => external}/secp256k1/sage/gen_exhaustive_groups.sage (100%) rename {src => external}/secp256k1/sage/gen_split_lambda_constants.sage (100%) rename {src => external}/secp256k1/sage/group_prover.sage (100%) rename {src => external}/secp256k1/sage/prove_group_implementations.sage (100%) rename {src => external}/secp256k1/sage/secp256k1_params.sage (100%) rename {src => external}/secp256k1/sage/weierstrass_prover.sage (100%) rename {src => external}/secp256k1/src/CMakeLists.txt (100%) rename {src => external}/secp256k1/src/asm/field_10x26_arm.s (100%) rename {src => external}/secp256k1/src/assumptions.h (100%) rename {src => external}/secp256k1/src/bench.c (100%) rename {src => external}/secp256k1/src/bench.h (100%) rename {src => external}/secp256k1/src/bench_ecmult.c (100%) rename {src => external}/secp256k1/src/bench_internal.c (100%) rename {src => external}/secp256k1/src/checkmem.h (100%) rename {src => external}/secp256k1/src/ctime_tests.c (100%) rename {src => external}/secp256k1/src/ecdsa.h (100%) rename {src => external}/secp256k1/src/ecdsa_impl.h (100%) rename {src => external}/secp256k1/src/eckey.h (100%) rename {src => external}/secp256k1/src/eckey_impl.h (100%) rename {src => external}/secp256k1/src/ecmult.h (100%) rename {src => external}/secp256k1/src/ecmult_compute_table.h (100%) rename {src => external}/secp256k1/src/ecmult_compute_table_impl.h (100%) rename {src => external}/secp256k1/src/ecmult_const.h (100%) rename {src => external}/secp256k1/src/ecmult_const_impl.h (100%) rename {src => external}/secp256k1/src/ecmult_gen.h (100%) rename {src => external}/secp256k1/src/ecmult_gen_compute_table.h (100%) rename {src => external}/secp256k1/src/ecmult_gen_compute_table_impl.h (100%) rename {src => external}/secp256k1/src/ecmult_gen_impl.h (100%) rename {src => external}/secp256k1/src/ecmult_impl.h (100%) rename {src => external}/secp256k1/src/field.h (100%) rename {src => external}/secp256k1/src/field_10x26.h (100%) rename {src => external}/secp256k1/src/field_10x26_impl.h (100%) rename {src => external}/secp256k1/src/field_5x52.h (100%) rename {src => external}/secp256k1/src/field_5x52_asm_impl.h (100%) rename {src => external}/secp256k1/src/field_5x52_impl.h (100%) rename {src => external}/secp256k1/src/field_5x52_int128_impl.h (100%) rename {src => external}/secp256k1/src/field_impl.h (100%) rename {src => external}/secp256k1/src/group.h (100%) rename {src => external}/secp256k1/src/group_impl.h (100%) rename {src => external}/secp256k1/src/hash.h (100%) rename {src => external}/secp256k1/src/hash_impl.h (100%) rename {src => external}/secp256k1/src/int128.h (100%) rename {src => external}/secp256k1/src/int128_impl.h (100%) rename {src => external}/secp256k1/src/int128_native.h (100%) rename {src => external}/secp256k1/src/int128_native_impl.h (100%) rename {src => external}/secp256k1/src/int128_struct.h (100%) rename {src => external}/secp256k1/src/int128_struct_impl.h (100%) rename {src => external}/secp256k1/src/modinv32.h (100%) rename {src => external}/secp256k1/src/modinv32_impl.h (100%) rename {src => external}/secp256k1/src/modinv64.h (100%) rename {src => external}/secp256k1/src/modinv64_impl.h (100%) rename {src => external}/secp256k1/src/modules/ecdh/Makefile.am.include (100%) rename {src => external}/secp256k1/src/modules/ecdh/bench_impl.h (100%) rename {src => external}/secp256k1/src/modules/ecdh/main_impl.h (100%) rename {src => external}/secp256k1/src/modules/ecdh/tests_impl.h (100%) rename {src => external}/secp256k1/src/modules/extrakeys/Makefile.am.include (100%) rename {src => external}/secp256k1/src/modules/extrakeys/main_impl.h (100%) rename {src => external}/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h (100%) rename {src => external}/secp256k1/src/modules/extrakeys/tests_impl.h (100%) rename {src => external}/secp256k1/src/modules/recovery/Makefile.am.include (100%) rename {src => external}/secp256k1/src/modules/recovery/bench_impl.h (100%) rename {src => external}/secp256k1/src/modules/recovery/main_impl.h (100%) rename {src => external}/secp256k1/src/modules/recovery/tests_exhaustive_impl.h (100%) rename {src => external}/secp256k1/src/modules/recovery/tests_impl.h (100%) rename {src => external}/secp256k1/src/modules/schnorrsig/Makefile.am.include (100%) rename {src => external}/secp256k1/src/modules/schnorrsig/bench_impl.h (100%) rename {src => external}/secp256k1/src/modules/schnorrsig/main_impl.h (100%) rename {src => external}/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h (100%) rename {src => external}/secp256k1/src/modules/schnorrsig/tests_impl.h (100%) rename {src => external}/secp256k1/src/precompute_ecmult.c (100%) rename {src => external}/secp256k1/src/precompute_ecmult_gen.c (100%) rename {src => external}/secp256k1/src/precomputed_ecmult.c (100%) rename {src => external}/secp256k1/src/precomputed_ecmult.h (100%) rename {src => external}/secp256k1/src/precomputed_ecmult_gen.c (100%) rename {src => external}/secp256k1/src/precomputed_ecmult_gen.h (100%) rename {src => external}/secp256k1/src/scalar.h (100%) rename {src => external}/secp256k1/src/scalar_4x64.h (100%) rename {src => external}/secp256k1/src/scalar_4x64_impl.h (100%) rename {src => external}/secp256k1/src/scalar_8x32.h (100%) rename {src => external}/secp256k1/src/scalar_8x32_impl.h (100%) rename {src => external}/secp256k1/src/scalar_impl.h (100%) rename {src => external}/secp256k1/src/scalar_low.h (100%) rename {src => external}/secp256k1/src/scalar_low_impl.h (100%) rename {src => external}/secp256k1/src/scratch.h (100%) rename {src => external}/secp256k1/src/scratch_impl.h (100%) rename {src => external}/secp256k1/src/secp256k1.c (100%) rename {src => external}/secp256k1/src/selftest.h (100%) rename {src => external}/secp256k1/src/testrand.h (100%) rename {src => external}/secp256k1/src/testrand_impl.h (100%) rename {src => external}/secp256k1/src/tests.c (100%) rename {src => external}/secp256k1/src/tests_exhaustive.c (100%) rename {src => external}/secp256k1/src/util.h (100%) rename {src => external}/secp256k1/src/wycheproof/WYCHEPROOF_COPYING (100%) rename {src => external}/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h (100%) rename {src => external}/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json (100%) rename {src => external}/secp256k1/tools/tests_wycheproof_generate.py (100%) delete mode 100644 src/README.md diff --git a/CMakeLists.txt b/CMakeLists.txt index 4754d76e425..a8c7de7b23b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -70,9 +70,9 @@ set_target_properties(OpenSSL::SSL PROPERTIES INTERFACE_COMPILE_DEFINITIONS OPENSSL_NO_SSL2 ) set(SECP256K1_INSTALL TRUE) -add_subdirectory(src/secp256k1) +add_subdirectory(external/secp256k1) add_library(secp256k1::secp256k1 ALIAS secp256k1) -add_subdirectory(src/ed25519-donna) +add_subdirectory(external/ed25519-donna) find_package(lz4 REQUIRED) # Target names with :: are not allowed in a generator expression. # We need to pull the include directories and imported location properties diff --git a/external/README.md b/external/README.md new file mode 100644 index 00000000000..f45f80965a5 --- /dev/null +++ b/external/README.md @@ -0,0 +1,11 @@ +The subdirectories in this directory contain either copies or Conan recipes +of external libraries used by rippled. +The Conan recipes include patches we have not yet pushed upstream. + +| Folder | Upstream | Description | +|:----------------|:---------------------------------------------|:------------| +| `ed25519-donna` | [Project](https://github.com/floodyberry/ed25519-donna) | [Ed25519](http://ed25519.cr.yp.to/) digital signatures | +| `rocksdb` | [Recipe](https://github.com/conan-io/conan-center-index/tree/master/recipes/rocksdb) | Fast key/value database. (Supports rotational disks better than NuDB.) | +| `secp256k1` | [Project](https://github.com/bitcoin-core/secp256k1) | ECDSA digital signatures using the **secp256k1** curve | +| `snappy` | [Recipe](https://github.com/conan-io/conan-center-index/tree/master/recipes/snappy) | "Snappy" lossless compression algorithm. | +| `soci` | [Recipe](https://github.com/conan-io/conan-center-index/tree/master/recipes/soci) | Abstraction layer for database access. | diff --git a/src/ed25519-donna/CMakeLists.txt b/external/ed25519-donna/CMakeLists.txt similarity index 100% rename from src/ed25519-donna/CMakeLists.txt rename to external/ed25519-donna/CMakeLists.txt diff --git a/src/ed25519-donna/README.md b/external/ed25519-donna/README.md similarity index 100% rename from src/ed25519-donna/README.md rename to external/ed25519-donna/README.md diff --git a/src/ed25519-donna/curve25519-donna-32bit.h b/external/ed25519-donna/curve25519-donna-32bit.h similarity index 100% rename from src/ed25519-donna/curve25519-donna-32bit.h rename to external/ed25519-donna/curve25519-donna-32bit.h diff --git a/src/ed25519-donna/curve25519-donna-64bit.h b/external/ed25519-donna/curve25519-donna-64bit.h similarity index 100% rename from src/ed25519-donna/curve25519-donna-64bit.h rename to external/ed25519-donna/curve25519-donna-64bit.h diff --git a/src/ed25519-donna/curve25519-donna-helpers.h b/external/ed25519-donna/curve25519-donna-helpers.h similarity index 100% rename from src/ed25519-donna/curve25519-donna-helpers.h rename to external/ed25519-donna/curve25519-donna-helpers.h diff --git a/src/ed25519-donna/curve25519-donna-sse2.h b/external/ed25519-donna/curve25519-donna-sse2.h similarity index 100% rename from src/ed25519-donna/curve25519-donna-sse2.h rename to external/ed25519-donna/curve25519-donna-sse2.h diff --git a/src/ed25519-donna/ed25519-donna-32bit-sse2.h b/external/ed25519-donna/ed25519-donna-32bit-sse2.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-32bit-sse2.h rename to external/ed25519-donna/ed25519-donna-32bit-sse2.h diff --git a/src/ed25519-donna/ed25519-donna-32bit-tables.h b/external/ed25519-donna/ed25519-donna-32bit-tables.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-32bit-tables.h rename to external/ed25519-donna/ed25519-donna-32bit-tables.h diff --git a/src/ed25519-donna/ed25519-donna-64bit-sse2.h b/external/ed25519-donna/ed25519-donna-64bit-sse2.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-64bit-sse2.h rename to external/ed25519-donna/ed25519-donna-64bit-sse2.h diff --git a/src/ed25519-donna/ed25519-donna-64bit-tables.h b/external/ed25519-donna/ed25519-donna-64bit-tables.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-64bit-tables.h rename to external/ed25519-donna/ed25519-donna-64bit-tables.h diff --git a/src/ed25519-donna/ed25519-donna-64bit-x86-32bit.h b/external/ed25519-donna/ed25519-donna-64bit-x86-32bit.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-64bit-x86-32bit.h rename to external/ed25519-donna/ed25519-donna-64bit-x86-32bit.h diff --git a/src/ed25519-donna/ed25519-donna-64bit-x86.h b/external/ed25519-donna/ed25519-donna-64bit-x86.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-64bit-x86.h rename to external/ed25519-donna/ed25519-donna-64bit-x86.h diff --git a/src/ed25519-donna/ed25519-donna-basepoint-table.h b/external/ed25519-donna/ed25519-donna-basepoint-table.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-basepoint-table.h rename to external/ed25519-donna/ed25519-donna-basepoint-table.h diff --git a/src/ed25519-donna/ed25519-donna-batchverify.h b/external/ed25519-donna/ed25519-donna-batchverify.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-batchverify.h rename to external/ed25519-donna/ed25519-donna-batchverify.h diff --git a/src/ed25519-donna/ed25519-donna-impl-base.h b/external/ed25519-donna/ed25519-donna-impl-base.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-impl-base.h rename to external/ed25519-donna/ed25519-donna-impl-base.h diff --git a/src/ed25519-donna/ed25519-donna-impl-sse2.h b/external/ed25519-donna/ed25519-donna-impl-sse2.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-impl-sse2.h rename to external/ed25519-donna/ed25519-donna-impl-sse2.h diff --git a/src/ed25519-donna/ed25519-donna-portable-identify.h b/external/ed25519-donna/ed25519-donna-portable-identify.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-portable-identify.h rename to external/ed25519-donna/ed25519-donna-portable-identify.h diff --git a/src/ed25519-donna/ed25519-donna-portable.h b/external/ed25519-donna/ed25519-donna-portable.h similarity index 100% rename from src/ed25519-donna/ed25519-donna-portable.h rename to external/ed25519-donna/ed25519-donna-portable.h diff --git a/src/ed25519-donna/ed25519-donna.h b/external/ed25519-donna/ed25519-donna.h similarity index 100% rename from src/ed25519-donna/ed25519-donna.h rename to external/ed25519-donna/ed25519-donna.h diff --git a/src/ed25519-donna/ed25519-hash-custom.h b/external/ed25519-donna/ed25519-hash-custom.h similarity index 100% rename from src/ed25519-donna/ed25519-hash-custom.h rename to external/ed25519-donna/ed25519-hash-custom.h diff --git a/src/ed25519-donna/ed25519-hash.h b/external/ed25519-donna/ed25519-hash.h similarity index 100% rename from src/ed25519-donna/ed25519-hash.h rename to external/ed25519-donna/ed25519-hash.h diff --git a/src/ed25519-donna/ed25519-randombytes-custom.h b/external/ed25519-donna/ed25519-randombytes-custom.h similarity index 100% rename from src/ed25519-donna/ed25519-randombytes-custom.h rename to external/ed25519-donna/ed25519-randombytes-custom.h diff --git a/src/ed25519-donna/ed25519-randombytes.h b/external/ed25519-donna/ed25519-randombytes.h similarity index 100% rename from src/ed25519-donna/ed25519-randombytes.h rename to external/ed25519-donna/ed25519-randombytes.h diff --git a/src/ed25519-donna/ed25519.c b/external/ed25519-donna/ed25519.c similarity index 100% rename from src/ed25519-donna/ed25519.c rename to external/ed25519-donna/ed25519.c diff --git a/src/ed25519-donna/ed25519.h b/external/ed25519-donna/ed25519.h similarity index 100% rename from src/ed25519-donna/ed25519.h rename to external/ed25519-donna/ed25519.h diff --git a/src/ed25519-donna/fuzz/README.md b/external/ed25519-donna/fuzz/README.md similarity index 100% rename from src/ed25519-donna/fuzz/README.md rename to external/ed25519-donna/fuzz/README.md diff --git a/src/ed25519-donna/fuzz/build-nix.php b/external/ed25519-donna/fuzz/build-nix.php similarity index 100% rename from src/ed25519-donna/fuzz/build-nix.php rename to external/ed25519-donna/fuzz/build-nix.php diff --git a/src/ed25519-donna/fuzz/curve25519-ref10.c b/external/ed25519-donna/fuzz/curve25519-ref10.c similarity index 100% rename from src/ed25519-donna/fuzz/curve25519-ref10.c rename to external/ed25519-donna/fuzz/curve25519-ref10.c diff --git a/src/ed25519-donna/fuzz/curve25519-ref10.h b/external/ed25519-donna/fuzz/curve25519-ref10.h similarity index 100% rename from src/ed25519-donna/fuzz/curve25519-ref10.h rename to external/ed25519-donna/fuzz/curve25519-ref10.h diff --git a/src/ed25519-donna/fuzz/ed25519-donna-sse2.c b/external/ed25519-donna/fuzz/ed25519-donna-sse2.c similarity index 100% rename from src/ed25519-donna/fuzz/ed25519-donna-sse2.c rename to external/ed25519-donna/fuzz/ed25519-donna-sse2.c diff --git a/src/ed25519-donna/fuzz/ed25519-donna.c b/external/ed25519-donna/fuzz/ed25519-donna.c similarity index 100% rename from src/ed25519-donna/fuzz/ed25519-donna.c rename to external/ed25519-donna/fuzz/ed25519-donna.c diff --git a/src/ed25519-donna/fuzz/ed25519-donna.h b/external/ed25519-donna/fuzz/ed25519-donna.h similarity index 100% rename from src/ed25519-donna/fuzz/ed25519-donna.h rename to external/ed25519-donna/fuzz/ed25519-donna.h diff --git a/src/ed25519-donna/fuzz/ed25519-ref10.c b/external/ed25519-donna/fuzz/ed25519-ref10.c similarity index 100% rename from src/ed25519-donna/fuzz/ed25519-ref10.c rename to external/ed25519-donna/fuzz/ed25519-ref10.c diff --git a/src/ed25519-donna/fuzz/ed25519-ref10.h b/external/ed25519-donna/fuzz/ed25519-ref10.h similarity index 100% rename from src/ed25519-donna/fuzz/ed25519-ref10.h rename to external/ed25519-donna/fuzz/ed25519-ref10.h diff --git a/src/ed25519-donna/fuzz/fuzz-curve25519.c b/external/ed25519-donna/fuzz/fuzz-curve25519.c similarity index 100% rename from src/ed25519-donna/fuzz/fuzz-curve25519.c rename to external/ed25519-donna/fuzz/fuzz-curve25519.c diff --git a/src/ed25519-donna/fuzz/fuzz-ed25519.c b/external/ed25519-donna/fuzz/fuzz-ed25519.c similarity index 100% rename from src/ed25519-donna/fuzz/fuzz-ed25519.c rename to external/ed25519-donna/fuzz/fuzz-ed25519.c diff --git a/src/ed25519-donna/modm-donna-32bit.h b/external/ed25519-donna/modm-donna-32bit.h similarity index 100% rename from src/ed25519-donna/modm-donna-32bit.h rename to external/ed25519-donna/modm-donna-32bit.h diff --git a/src/ed25519-donna/modm-donna-64bit.h b/external/ed25519-donna/modm-donna-64bit.h similarity index 100% rename from src/ed25519-donna/modm-donna-64bit.h rename to external/ed25519-donna/modm-donna-64bit.h diff --git a/src/ed25519-donna/regression.h b/external/ed25519-donna/regression.h similarity index 100% rename from src/ed25519-donna/regression.h rename to external/ed25519-donna/regression.h diff --git a/src/ed25519-donna/test-internals.c b/external/ed25519-donna/test-internals.c similarity index 100% rename from src/ed25519-donna/test-internals.c rename to external/ed25519-donna/test-internals.c diff --git a/src/ed25519-donna/test-ticks.h b/external/ed25519-donna/test-ticks.h similarity index 100% rename from src/ed25519-donna/test-ticks.h rename to external/ed25519-donna/test-ticks.h diff --git a/src/ed25519-donna/test.c b/external/ed25519-donna/test.c similarity index 100% rename from src/ed25519-donna/test.c rename to external/ed25519-donna/test.c diff --git a/src/secp256k1/.cirrus.yml b/external/secp256k1/.cirrus.yml similarity index 100% rename from src/secp256k1/.cirrus.yml rename to external/secp256k1/.cirrus.yml diff --git a/src/secp256k1/.gitattributes b/external/secp256k1/.gitattributes similarity index 100% rename from src/secp256k1/.gitattributes rename to external/secp256k1/.gitattributes diff --git a/src/secp256k1/.gitignore b/external/secp256k1/.gitignore similarity index 100% rename from src/secp256k1/.gitignore rename to external/secp256k1/.gitignore diff --git a/src/secp256k1/CHANGELOG.md b/external/secp256k1/CHANGELOG.md similarity index 100% rename from src/secp256k1/CHANGELOG.md rename to external/secp256k1/CHANGELOG.md diff --git a/src/secp256k1/CMakeLists.txt b/external/secp256k1/CMakeLists.txt similarity index 100% rename from src/secp256k1/CMakeLists.txt rename to external/secp256k1/CMakeLists.txt diff --git a/src/secp256k1/CMakePresets.json b/external/secp256k1/CMakePresets.json similarity index 100% rename from src/secp256k1/CMakePresets.json rename to external/secp256k1/CMakePresets.json diff --git a/src/secp256k1/COPYING b/external/secp256k1/COPYING similarity index 100% rename from src/secp256k1/COPYING rename to external/secp256k1/COPYING diff --git a/src/secp256k1/Makefile.am b/external/secp256k1/Makefile.am similarity index 100% rename from src/secp256k1/Makefile.am rename to external/secp256k1/Makefile.am diff --git a/src/secp256k1/README.md b/external/secp256k1/README.md similarity index 100% rename from src/secp256k1/README.md rename to external/secp256k1/README.md diff --git a/src/secp256k1/SECURITY.md b/external/secp256k1/SECURITY.md similarity index 100% rename from src/secp256k1/SECURITY.md rename to external/secp256k1/SECURITY.md diff --git a/src/secp256k1/autogen.sh b/external/secp256k1/autogen.sh similarity index 100% rename from src/secp256k1/autogen.sh rename to external/secp256k1/autogen.sh diff --git a/src/secp256k1/build-aux/m4/bitcoin_secp.m4 b/external/secp256k1/build-aux/m4/bitcoin_secp.m4 similarity index 100% rename from src/secp256k1/build-aux/m4/bitcoin_secp.m4 rename to external/secp256k1/build-aux/m4/bitcoin_secp.m4 diff --git a/src/secp256k1/ci/cirrus.sh b/external/secp256k1/ci/cirrus.sh similarity index 100% rename from src/secp256k1/ci/cirrus.sh rename to external/secp256k1/ci/cirrus.sh diff --git a/src/secp256k1/ci/linux-debian.Dockerfile b/external/secp256k1/ci/linux-debian.Dockerfile similarity index 100% rename from src/secp256k1/ci/linux-debian.Dockerfile rename to external/secp256k1/ci/linux-debian.Dockerfile diff --git a/src/secp256k1/cmake/CheckArm32Assembly.cmake b/external/secp256k1/cmake/CheckArm32Assembly.cmake similarity index 100% rename from src/secp256k1/cmake/CheckArm32Assembly.cmake rename to external/secp256k1/cmake/CheckArm32Assembly.cmake diff --git a/src/secp256k1/cmake/CheckStringOptionValue.cmake b/external/secp256k1/cmake/CheckStringOptionValue.cmake similarity index 100% rename from src/secp256k1/cmake/CheckStringOptionValue.cmake rename to external/secp256k1/cmake/CheckStringOptionValue.cmake diff --git a/src/secp256k1/cmake/CheckX86_64Assembly.cmake b/external/secp256k1/cmake/CheckX86_64Assembly.cmake similarity index 100% rename from src/secp256k1/cmake/CheckX86_64Assembly.cmake rename to external/secp256k1/cmake/CheckX86_64Assembly.cmake diff --git a/src/secp256k1/cmake/FindValgrind.cmake b/external/secp256k1/cmake/FindValgrind.cmake similarity index 100% rename from src/secp256k1/cmake/FindValgrind.cmake rename to external/secp256k1/cmake/FindValgrind.cmake diff --git a/src/secp256k1/cmake/TryAppendCFlags.cmake b/external/secp256k1/cmake/TryAppendCFlags.cmake similarity index 100% rename from src/secp256k1/cmake/TryAppendCFlags.cmake rename to external/secp256k1/cmake/TryAppendCFlags.cmake diff --git a/src/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake b/external/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake similarity index 100% rename from src/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake rename to external/secp256k1/cmake/arm-linux-gnueabihf.toolchain.cmake diff --git a/src/secp256k1/cmake/config.cmake.in b/external/secp256k1/cmake/config.cmake.in similarity index 100% rename from src/secp256k1/cmake/config.cmake.in rename to external/secp256k1/cmake/config.cmake.in diff --git a/src/secp256k1/cmake/source_arm32.s b/external/secp256k1/cmake/source_arm32.s similarity index 100% rename from src/secp256k1/cmake/source_arm32.s rename to external/secp256k1/cmake/source_arm32.s diff --git a/src/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake b/external/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake similarity index 100% rename from src/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake rename to external/secp256k1/cmake/x86_64-w64-mingw32.toolchain.cmake diff --git a/src/secp256k1/configure.ac b/external/secp256k1/configure.ac similarity index 100% rename from src/secp256k1/configure.ac rename to external/secp256k1/configure.ac diff --git a/src/secp256k1/contrib/lax_der_parsing.c b/external/secp256k1/contrib/lax_der_parsing.c similarity index 100% rename from src/secp256k1/contrib/lax_der_parsing.c rename to external/secp256k1/contrib/lax_der_parsing.c diff --git a/src/secp256k1/contrib/lax_der_parsing.h b/external/secp256k1/contrib/lax_der_parsing.h similarity index 100% rename from src/secp256k1/contrib/lax_der_parsing.h rename to external/secp256k1/contrib/lax_der_parsing.h diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.c b/external/secp256k1/contrib/lax_der_privatekey_parsing.c similarity index 100% rename from src/secp256k1/contrib/lax_der_privatekey_parsing.c rename to external/secp256k1/contrib/lax_der_privatekey_parsing.c diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.h b/external/secp256k1/contrib/lax_der_privatekey_parsing.h similarity index 100% rename from src/secp256k1/contrib/lax_der_privatekey_parsing.h rename to external/secp256k1/contrib/lax_der_privatekey_parsing.h diff --git a/src/secp256k1/doc/release-process.md b/external/secp256k1/doc/release-process.md similarity index 100% rename from src/secp256k1/doc/release-process.md rename to external/secp256k1/doc/release-process.md diff --git a/src/secp256k1/doc/safegcd_implementation.md b/external/secp256k1/doc/safegcd_implementation.md similarity index 100% rename from src/secp256k1/doc/safegcd_implementation.md rename to external/secp256k1/doc/safegcd_implementation.md diff --git a/src/secp256k1/examples/CMakeLists.txt b/external/secp256k1/examples/CMakeLists.txt similarity index 100% rename from src/secp256k1/examples/CMakeLists.txt rename to external/secp256k1/examples/CMakeLists.txt diff --git a/src/secp256k1/examples/EXAMPLES_COPYING b/external/secp256k1/examples/EXAMPLES_COPYING similarity index 100% rename from src/secp256k1/examples/EXAMPLES_COPYING rename to external/secp256k1/examples/EXAMPLES_COPYING diff --git a/src/secp256k1/examples/ecdh.c b/external/secp256k1/examples/ecdh.c similarity index 100% rename from src/secp256k1/examples/ecdh.c rename to external/secp256k1/examples/ecdh.c diff --git a/src/secp256k1/examples/ecdsa.c b/external/secp256k1/examples/ecdsa.c similarity index 100% rename from src/secp256k1/examples/ecdsa.c rename to external/secp256k1/examples/ecdsa.c diff --git a/src/secp256k1/examples/examples_util.h b/external/secp256k1/examples/examples_util.h similarity index 100% rename from src/secp256k1/examples/examples_util.h rename to external/secp256k1/examples/examples_util.h diff --git a/src/secp256k1/examples/schnorr.c b/external/secp256k1/examples/schnorr.c similarity index 100% rename from src/secp256k1/examples/schnorr.c rename to external/secp256k1/examples/schnorr.c diff --git a/src/secp256k1/include/secp256k1.h b/external/secp256k1/include/secp256k1.h similarity index 100% rename from src/secp256k1/include/secp256k1.h rename to external/secp256k1/include/secp256k1.h diff --git a/src/secp256k1/include/secp256k1_ecdh.h b/external/secp256k1/include/secp256k1_ecdh.h similarity index 100% rename from src/secp256k1/include/secp256k1_ecdh.h rename to external/secp256k1/include/secp256k1_ecdh.h diff --git a/src/secp256k1/include/secp256k1_extrakeys.h b/external/secp256k1/include/secp256k1_extrakeys.h similarity index 100% rename from src/secp256k1/include/secp256k1_extrakeys.h rename to external/secp256k1/include/secp256k1_extrakeys.h diff --git a/src/secp256k1/include/secp256k1_preallocated.h b/external/secp256k1/include/secp256k1_preallocated.h similarity index 100% rename from src/secp256k1/include/secp256k1_preallocated.h rename to external/secp256k1/include/secp256k1_preallocated.h diff --git a/src/secp256k1/include/secp256k1_recovery.h b/external/secp256k1/include/secp256k1_recovery.h similarity index 100% rename from src/secp256k1/include/secp256k1_recovery.h rename to external/secp256k1/include/secp256k1_recovery.h diff --git a/src/secp256k1/include/secp256k1_schnorrsig.h b/external/secp256k1/include/secp256k1_schnorrsig.h similarity index 100% rename from src/secp256k1/include/secp256k1_schnorrsig.h rename to external/secp256k1/include/secp256k1_schnorrsig.h diff --git a/src/secp256k1/libsecp256k1.pc.in b/external/secp256k1/libsecp256k1.pc.in similarity index 100% rename from src/secp256k1/libsecp256k1.pc.in rename to external/secp256k1/libsecp256k1.pc.in diff --git a/src/secp256k1/sage/gen_exhaustive_groups.sage b/external/secp256k1/sage/gen_exhaustive_groups.sage similarity index 100% rename from src/secp256k1/sage/gen_exhaustive_groups.sage rename to external/secp256k1/sage/gen_exhaustive_groups.sage diff --git a/src/secp256k1/sage/gen_split_lambda_constants.sage b/external/secp256k1/sage/gen_split_lambda_constants.sage similarity index 100% rename from src/secp256k1/sage/gen_split_lambda_constants.sage rename to external/secp256k1/sage/gen_split_lambda_constants.sage diff --git a/src/secp256k1/sage/group_prover.sage b/external/secp256k1/sage/group_prover.sage similarity index 100% rename from src/secp256k1/sage/group_prover.sage rename to external/secp256k1/sage/group_prover.sage diff --git a/src/secp256k1/sage/prove_group_implementations.sage b/external/secp256k1/sage/prove_group_implementations.sage similarity index 100% rename from src/secp256k1/sage/prove_group_implementations.sage rename to external/secp256k1/sage/prove_group_implementations.sage diff --git a/src/secp256k1/sage/secp256k1_params.sage b/external/secp256k1/sage/secp256k1_params.sage similarity index 100% rename from src/secp256k1/sage/secp256k1_params.sage rename to external/secp256k1/sage/secp256k1_params.sage diff --git a/src/secp256k1/sage/weierstrass_prover.sage b/external/secp256k1/sage/weierstrass_prover.sage similarity index 100% rename from src/secp256k1/sage/weierstrass_prover.sage rename to external/secp256k1/sage/weierstrass_prover.sage diff --git a/src/secp256k1/src/CMakeLists.txt b/external/secp256k1/src/CMakeLists.txt similarity index 100% rename from src/secp256k1/src/CMakeLists.txt rename to external/secp256k1/src/CMakeLists.txt diff --git a/src/secp256k1/src/asm/field_10x26_arm.s b/external/secp256k1/src/asm/field_10x26_arm.s similarity index 100% rename from src/secp256k1/src/asm/field_10x26_arm.s rename to external/secp256k1/src/asm/field_10x26_arm.s diff --git a/src/secp256k1/src/assumptions.h b/external/secp256k1/src/assumptions.h similarity index 100% rename from src/secp256k1/src/assumptions.h rename to external/secp256k1/src/assumptions.h diff --git a/src/secp256k1/src/bench.c b/external/secp256k1/src/bench.c similarity index 100% rename from src/secp256k1/src/bench.c rename to external/secp256k1/src/bench.c diff --git a/src/secp256k1/src/bench.h b/external/secp256k1/src/bench.h similarity index 100% rename from src/secp256k1/src/bench.h rename to external/secp256k1/src/bench.h diff --git a/src/secp256k1/src/bench_ecmult.c b/external/secp256k1/src/bench_ecmult.c similarity index 100% rename from src/secp256k1/src/bench_ecmult.c rename to external/secp256k1/src/bench_ecmult.c diff --git a/src/secp256k1/src/bench_internal.c b/external/secp256k1/src/bench_internal.c similarity index 100% rename from src/secp256k1/src/bench_internal.c rename to external/secp256k1/src/bench_internal.c diff --git a/src/secp256k1/src/checkmem.h b/external/secp256k1/src/checkmem.h similarity index 100% rename from src/secp256k1/src/checkmem.h rename to external/secp256k1/src/checkmem.h diff --git a/src/secp256k1/src/ctime_tests.c b/external/secp256k1/src/ctime_tests.c similarity index 100% rename from src/secp256k1/src/ctime_tests.c rename to external/secp256k1/src/ctime_tests.c diff --git a/src/secp256k1/src/ecdsa.h b/external/secp256k1/src/ecdsa.h similarity index 100% rename from src/secp256k1/src/ecdsa.h rename to external/secp256k1/src/ecdsa.h diff --git a/src/secp256k1/src/ecdsa_impl.h b/external/secp256k1/src/ecdsa_impl.h similarity index 100% rename from src/secp256k1/src/ecdsa_impl.h rename to external/secp256k1/src/ecdsa_impl.h diff --git a/src/secp256k1/src/eckey.h b/external/secp256k1/src/eckey.h similarity index 100% rename from src/secp256k1/src/eckey.h rename to external/secp256k1/src/eckey.h diff --git a/src/secp256k1/src/eckey_impl.h b/external/secp256k1/src/eckey_impl.h similarity index 100% rename from src/secp256k1/src/eckey_impl.h rename to external/secp256k1/src/eckey_impl.h diff --git a/src/secp256k1/src/ecmult.h b/external/secp256k1/src/ecmult.h similarity index 100% rename from src/secp256k1/src/ecmult.h rename to external/secp256k1/src/ecmult.h diff --git a/src/secp256k1/src/ecmult_compute_table.h b/external/secp256k1/src/ecmult_compute_table.h similarity index 100% rename from src/secp256k1/src/ecmult_compute_table.h rename to external/secp256k1/src/ecmult_compute_table.h diff --git a/src/secp256k1/src/ecmult_compute_table_impl.h b/external/secp256k1/src/ecmult_compute_table_impl.h similarity index 100% rename from src/secp256k1/src/ecmult_compute_table_impl.h rename to external/secp256k1/src/ecmult_compute_table_impl.h diff --git a/src/secp256k1/src/ecmult_const.h b/external/secp256k1/src/ecmult_const.h similarity index 100% rename from src/secp256k1/src/ecmult_const.h rename to external/secp256k1/src/ecmult_const.h diff --git a/src/secp256k1/src/ecmult_const_impl.h b/external/secp256k1/src/ecmult_const_impl.h similarity index 100% rename from src/secp256k1/src/ecmult_const_impl.h rename to external/secp256k1/src/ecmult_const_impl.h diff --git a/src/secp256k1/src/ecmult_gen.h b/external/secp256k1/src/ecmult_gen.h similarity index 100% rename from src/secp256k1/src/ecmult_gen.h rename to external/secp256k1/src/ecmult_gen.h diff --git a/src/secp256k1/src/ecmult_gen_compute_table.h b/external/secp256k1/src/ecmult_gen_compute_table.h similarity index 100% rename from src/secp256k1/src/ecmult_gen_compute_table.h rename to external/secp256k1/src/ecmult_gen_compute_table.h diff --git a/src/secp256k1/src/ecmult_gen_compute_table_impl.h b/external/secp256k1/src/ecmult_gen_compute_table_impl.h similarity index 100% rename from src/secp256k1/src/ecmult_gen_compute_table_impl.h rename to external/secp256k1/src/ecmult_gen_compute_table_impl.h diff --git a/src/secp256k1/src/ecmult_gen_impl.h b/external/secp256k1/src/ecmult_gen_impl.h similarity index 100% rename from src/secp256k1/src/ecmult_gen_impl.h rename to external/secp256k1/src/ecmult_gen_impl.h diff --git a/src/secp256k1/src/ecmult_impl.h b/external/secp256k1/src/ecmult_impl.h similarity index 100% rename from src/secp256k1/src/ecmult_impl.h rename to external/secp256k1/src/ecmult_impl.h diff --git a/src/secp256k1/src/field.h b/external/secp256k1/src/field.h similarity index 100% rename from src/secp256k1/src/field.h rename to external/secp256k1/src/field.h diff --git a/src/secp256k1/src/field_10x26.h b/external/secp256k1/src/field_10x26.h similarity index 100% rename from src/secp256k1/src/field_10x26.h rename to external/secp256k1/src/field_10x26.h diff --git a/src/secp256k1/src/field_10x26_impl.h b/external/secp256k1/src/field_10x26_impl.h similarity index 100% rename from src/secp256k1/src/field_10x26_impl.h rename to external/secp256k1/src/field_10x26_impl.h diff --git a/src/secp256k1/src/field_5x52.h b/external/secp256k1/src/field_5x52.h similarity index 100% rename from src/secp256k1/src/field_5x52.h rename to external/secp256k1/src/field_5x52.h diff --git a/src/secp256k1/src/field_5x52_asm_impl.h b/external/secp256k1/src/field_5x52_asm_impl.h similarity index 100% rename from src/secp256k1/src/field_5x52_asm_impl.h rename to external/secp256k1/src/field_5x52_asm_impl.h diff --git a/src/secp256k1/src/field_5x52_impl.h b/external/secp256k1/src/field_5x52_impl.h similarity index 100% rename from src/secp256k1/src/field_5x52_impl.h rename to external/secp256k1/src/field_5x52_impl.h diff --git a/src/secp256k1/src/field_5x52_int128_impl.h b/external/secp256k1/src/field_5x52_int128_impl.h similarity index 100% rename from src/secp256k1/src/field_5x52_int128_impl.h rename to external/secp256k1/src/field_5x52_int128_impl.h diff --git a/src/secp256k1/src/field_impl.h b/external/secp256k1/src/field_impl.h similarity index 100% rename from src/secp256k1/src/field_impl.h rename to external/secp256k1/src/field_impl.h diff --git a/src/secp256k1/src/group.h b/external/secp256k1/src/group.h similarity index 100% rename from src/secp256k1/src/group.h rename to external/secp256k1/src/group.h diff --git a/src/secp256k1/src/group_impl.h b/external/secp256k1/src/group_impl.h similarity index 100% rename from src/secp256k1/src/group_impl.h rename to external/secp256k1/src/group_impl.h diff --git a/src/secp256k1/src/hash.h b/external/secp256k1/src/hash.h similarity index 100% rename from src/secp256k1/src/hash.h rename to external/secp256k1/src/hash.h diff --git a/src/secp256k1/src/hash_impl.h b/external/secp256k1/src/hash_impl.h similarity index 100% rename from src/secp256k1/src/hash_impl.h rename to external/secp256k1/src/hash_impl.h diff --git a/src/secp256k1/src/int128.h b/external/secp256k1/src/int128.h similarity index 100% rename from src/secp256k1/src/int128.h rename to external/secp256k1/src/int128.h diff --git a/src/secp256k1/src/int128_impl.h b/external/secp256k1/src/int128_impl.h similarity index 100% rename from src/secp256k1/src/int128_impl.h rename to external/secp256k1/src/int128_impl.h diff --git a/src/secp256k1/src/int128_native.h b/external/secp256k1/src/int128_native.h similarity index 100% rename from src/secp256k1/src/int128_native.h rename to external/secp256k1/src/int128_native.h diff --git a/src/secp256k1/src/int128_native_impl.h b/external/secp256k1/src/int128_native_impl.h similarity index 100% rename from src/secp256k1/src/int128_native_impl.h rename to external/secp256k1/src/int128_native_impl.h diff --git a/src/secp256k1/src/int128_struct.h b/external/secp256k1/src/int128_struct.h similarity index 100% rename from src/secp256k1/src/int128_struct.h rename to external/secp256k1/src/int128_struct.h diff --git a/src/secp256k1/src/int128_struct_impl.h b/external/secp256k1/src/int128_struct_impl.h similarity index 100% rename from src/secp256k1/src/int128_struct_impl.h rename to external/secp256k1/src/int128_struct_impl.h diff --git a/src/secp256k1/src/modinv32.h b/external/secp256k1/src/modinv32.h similarity index 100% rename from src/secp256k1/src/modinv32.h rename to external/secp256k1/src/modinv32.h diff --git a/src/secp256k1/src/modinv32_impl.h b/external/secp256k1/src/modinv32_impl.h similarity index 100% rename from src/secp256k1/src/modinv32_impl.h rename to external/secp256k1/src/modinv32_impl.h diff --git a/src/secp256k1/src/modinv64.h b/external/secp256k1/src/modinv64.h similarity index 100% rename from src/secp256k1/src/modinv64.h rename to external/secp256k1/src/modinv64.h diff --git a/src/secp256k1/src/modinv64_impl.h b/external/secp256k1/src/modinv64_impl.h similarity index 100% rename from src/secp256k1/src/modinv64_impl.h rename to external/secp256k1/src/modinv64_impl.h diff --git a/src/secp256k1/src/modules/ecdh/Makefile.am.include b/external/secp256k1/src/modules/ecdh/Makefile.am.include similarity index 100% rename from src/secp256k1/src/modules/ecdh/Makefile.am.include rename to external/secp256k1/src/modules/ecdh/Makefile.am.include diff --git a/src/secp256k1/src/modules/ecdh/bench_impl.h b/external/secp256k1/src/modules/ecdh/bench_impl.h similarity index 100% rename from src/secp256k1/src/modules/ecdh/bench_impl.h rename to external/secp256k1/src/modules/ecdh/bench_impl.h diff --git a/src/secp256k1/src/modules/ecdh/main_impl.h b/external/secp256k1/src/modules/ecdh/main_impl.h similarity index 100% rename from src/secp256k1/src/modules/ecdh/main_impl.h rename to external/secp256k1/src/modules/ecdh/main_impl.h diff --git a/src/secp256k1/src/modules/ecdh/tests_impl.h b/external/secp256k1/src/modules/ecdh/tests_impl.h similarity index 100% rename from src/secp256k1/src/modules/ecdh/tests_impl.h rename to external/secp256k1/src/modules/ecdh/tests_impl.h diff --git a/src/secp256k1/src/modules/extrakeys/Makefile.am.include b/external/secp256k1/src/modules/extrakeys/Makefile.am.include similarity index 100% rename from src/secp256k1/src/modules/extrakeys/Makefile.am.include rename to external/secp256k1/src/modules/extrakeys/Makefile.am.include diff --git a/src/secp256k1/src/modules/extrakeys/main_impl.h b/external/secp256k1/src/modules/extrakeys/main_impl.h similarity index 100% rename from src/secp256k1/src/modules/extrakeys/main_impl.h rename to external/secp256k1/src/modules/extrakeys/main_impl.h diff --git a/src/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h b/external/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h similarity index 100% rename from src/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h rename to external/secp256k1/src/modules/extrakeys/tests_exhaustive_impl.h diff --git a/src/secp256k1/src/modules/extrakeys/tests_impl.h b/external/secp256k1/src/modules/extrakeys/tests_impl.h similarity index 100% rename from src/secp256k1/src/modules/extrakeys/tests_impl.h rename to external/secp256k1/src/modules/extrakeys/tests_impl.h diff --git a/src/secp256k1/src/modules/recovery/Makefile.am.include b/external/secp256k1/src/modules/recovery/Makefile.am.include similarity index 100% rename from src/secp256k1/src/modules/recovery/Makefile.am.include rename to external/secp256k1/src/modules/recovery/Makefile.am.include diff --git a/src/secp256k1/src/modules/recovery/bench_impl.h b/external/secp256k1/src/modules/recovery/bench_impl.h similarity index 100% rename from src/secp256k1/src/modules/recovery/bench_impl.h rename to external/secp256k1/src/modules/recovery/bench_impl.h diff --git a/src/secp256k1/src/modules/recovery/main_impl.h b/external/secp256k1/src/modules/recovery/main_impl.h similarity index 100% rename from src/secp256k1/src/modules/recovery/main_impl.h rename to external/secp256k1/src/modules/recovery/main_impl.h diff --git a/src/secp256k1/src/modules/recovery/tests_exhaustive_impl.h b/external/secp256k1/src/modules/recovery/tests_exhaustive_impl.h similarity index 100% rename from src/secp256k1/src/modules/recovery/tests_exhaustive_impl.h rename to external/secp256k1/src/modules/recovery/tests_exhaustive_impl.h diff --git a/src/secp256k1/src/modules/recovery/tests_impl.h b/external/secp256k1/src/modules/recovery/tests_impl.h similarity index 100% rename from src/secp256k1/src/modules/recovery/tests_impl.h rename to external/secp256k1/src/modules/recovery/tests_impl.h diff --git a/src/secp256k1/src/modules/schnorrsig/Makefile.am.include b/external/secp256k1/src/modules/schnorrsig/Makefile.am.include similarity index 100% rename from src/secp256k1/src/modules/schnorrsig/Makefile.am.include rename to external/secp256k1/src/modules/schnorrsig/Makefile.am.include diff --git a/src/secp256k1/src/modules/schnorrsig/bench_impl.h b/external/secp256k1/src/modules/schnorrsig/bench_impl.h similarity index 100% rename from src/secp256k1/src/modules/schnorrsig/bench_impl.h rename to external/secp256k1/src/modules/schnorrsig/bench_impl.h diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/external/secp256k1/src/modules/schnorrsig/main_impl.h similarity index 100% rename from src/secp256k1/src/modules/schnorrsig/main_impl.h rename to external/secp256k1/src/modules/schnorrsig/main_impl.h diff --git a/src/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h b/external/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h similarity index 100% rename from src/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h rename to external/secp256k1/src/modules/schnorrsig/tests_exhaustive_impl.h diff --git a/src/secp256k1/src/modules/schnorrsig/tests_impl.h b/external/secp256k1/src/modules/schnorrsig/tests_impl.h similarity index 100% rename from src/secp256k1/src/modules/schnorrsig/tests_impl.h rename to external/secp256k1/src/modules/schnorrsig/tests_impl.h diff --git a/src/secp256k1/src/precompute_ecmult.c b/external/secp256k1/src/precompute_ecmult.c similarity index 100% rename from src/secp256k1/src/precompute_ecmult.c rename to external/secp256k1/src/precompute_ecmult.c diff --git a/src/secp256k1/src/precompute_ecmult_gen.c b/external/secp256k1/src/precompute_ecmult_gen.c similarity index 100% rename from src/secp256k1/src/precompute_ecmult_gen.c rename to external/secp256k1/src/precompute_ecmult_gen.c diff --git a/src/secp256k1/src/precomputed_ecmult.c b/external/secp256k1/src/precomputed_ecmult.c similarity index 100% rename from src/secp256k1/src/precomputed_ecmult.c rename to external/secp256k1/src/precomputed_ecmult.c diff --git a/src/secp256k1/src/precomputed_ecmult.h b/external/secp256k1/src/precomputed_ecmult.h similarity index 100% rename from src/secp256k1/src/precomputed_ecmult.h rename to external/secp256k1/src/precomputed_ecmult.h diff --git a/src/secp256k1/src/precomputed_ecmult_gen.c b/external/secp256k1/src/precomputed_ecmult_gen.c similarity index 100% rename from src/secp256k1/src/precomputed_ecmult_gen.c rename to external/secp256k1/src/precomputed_ecmult_gen.c diff --git a/src/secp256k1/src/precomputed_ecmult_gen.h b/external/secp256k1/src/precomputed_ecmult_gen.h similarity index 100% rename from src/secp256k1/src/precomputed_ecmult_gen.h rename to external/secp256k1/src/precomputed_ecmult_gen.h diff --git a/src/secp256k1/src/scalar.h b/external/secp256k1/src/scalar.h similarity index 100% rename from src/secp256k1/src/scalar.h rename to external/secp256k1/src/scalar.h diff --git a/src/secp256k1/src/scalar_4x64.h b/external/secp256k1/src/scalar_4x64.h similarity index 100% rename from src/secp256k1/src/scalar_4x64.h rename to external/secp256k1/src/scalar_4x64.h diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/external/secp256k1/src/scalar_4x64_impl.h similarity index 100% rename from src/secp256k1/src/scalar_4x64_impl.h rename to external/secp256k1/src/scalar_4x64_impl.h diff --git a/src/secp256k1/src/scalar_8x32.h b/external/secp256k1/src/scalar_8x32.h similarity index 100% rename from src/secp256k1/src/scalar_8x32.h rename to external/secp256k1/src/scalar_8x32.h diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/external/secp256k1/src/scalar_8x32_impl.h similarity index 100% rename from src/secp256k1/src/scalar_8x32_impl.h rename to external/secp256k1/src/scalar_8x32_impl.h diff --git a/src/secp256k1/src/scalar_impl.h b/external/secp256k1/src/scalar_impl.h similarity index 100% rename from src/secp256k1/src/scalar_impl.h rename to external/secp256k1/src/scalar_impl.h diff --git a/src/secp256k1/src/scalar_low.h b/external/secp256k1/src/scalar_low.h similarity index 100% rename from src/secp256k1/src/scalar_low.h rename to external/secp256k1/src/scalar_low.h diff --git a/src/secp256k1/src/scalar_low_impl.h b/external/secp256k1/src/scalar_low_impl.h similarity index 100% rename from src/secp256k1/src/scalar_low_impl.h rename to external/secp256k1/src/scalar_low_impl.h diff --git a/src/secp256k1/src/scratch.h b/external/secp256k1/src/scratch.h similarity index 100% rename from src/secp256k1/src/scratch.h rename to external/secp256k1/src/scratch.h diff --git a/src/secp256k1/src/scratch_impl.h b/external/secp256k1/src/scratch_impl.h similarity index 100% rename from src/secp256k1/src/scratch_impl.h rename to external/secp256k1/src/scratch_impl.h diff --git a/src/secp256k1/src/secp256k1.c b/external/secp256k1/src/secp256k1.c similarity index 100% rename from src/secp256k1/src/secp256k1.c rename to external/secp256k1/src/secp256k1.c diff --git a/src/secp256k1/src/selftest.h b/external/secp256k1/src/selftest.h similarity index 100% rename from src/secp256k1/src/selftest.h rename to external/secp256k1/src/selftest.h diff --git a/src/secp256k1/src/testrand.h b/external/secp256k1/src/testrand.h similarity index 100% rename from src/secp256k1/src/testrand.h rename to external/secp256k1/src/testrand.h diff --git a/src/secp256k1/src/testrand_impl.h b/external/secp256k1/src/testrand_impl.h similarity index 100% rename from src/secp256k1/src/testrand_impl.h rename to external/secp256k1/src/testrand_impl.h diff --git a/src/secp256k1/src/tests.c b/external/secp256k1/src/tests.c similarity index 100% rename from src/secp256k1/src/tests.c rename to external/secp256k1/src/tests.c diff --git a/src/secp256k1/src/tests_exhaustive.c b/external/secp256k1/src/tests_exhaustive.c similarity index 100% rename from src/secp256k1/src/tests_exhaustive.c rename to external/secp256k1/src/tests_exhaustive.c diff --git a/src/secp256k1/src/util.h b/external/secp256k1/src/util.h similarity index 100% rename from src/secp256k1/src/util.h rename to external/secp256k1/src/util.h diff --git a/src/secp256k1/src/wycheproof/WYCHEPROOF_COPYING b/external/secp256k1/src/wycheproof/WYCHEPROOF_COPYING similarity index 100% rename from src/secp256k1/src/wycheproof/WYCHEPROOF_COPYING rename to external/secp256k1/src/wycheproof/WYCHEPROOF_COPYING diff --git a/src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h b/external/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h similarity index 100% rename from src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h rename to external/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h diff --git a/src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json b/external/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json similarity index 100% rename from src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json rename to external/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json diff --git a/src/secp256k1/tools/tests_wycheproof_generate.py b/external/secp256k1/tools/tests_wycheproof_generate.py similarity index 100% rename from src/secp256k1/tools/tests_wycheproof_generate.py rename to external/secp256k1/tools/tests_wycheproof_generate.py diff --git a/src/README.md b/src/README.md deleted file mode 100644 index dc54bb27425..00000000000 --- a/src/README.md +++ /dev/null @@ -1,38 +0,0 @@ -# rippled Source - -Some of these directories come from entire outside repositories brought in -using [git-subtree][]. This means that the source files are inserted directly -into the `rippled` repository. They can be edited and committed just as if they -were normal files. -[git-subtree]: https://github.com/apenwarr/git-subtree - -If you create a commit that contains files both from a subtree, and from the -`rippled` source tree, please use care when designing the commit message, since -it will appear in the subtree's individual repository when the changes are -pushed back to the upstream. Better yet, do not mix files from subtrees and -`ripple` in the same commit at all. - -Source folders: - -| Folder | Upstream Repo | Description | -|:----------------|:---------------------------------------------|:------------| -| `beast` | N/A | legacy utility code that was formerly associated with boost::beast -| `ed25519-donna` | https://github.com/floodyberry/ed25519-donna | [Ed25519](http://ed25519.cr.yp.to/) digital signatures | -| `ripple` | N/A | **Core source code for `rippled`** | -| `secp256k1` | https://github.com/bitcoin-core/secp256k1 | ECDSA digital signatures using the **secp256k1** curve | -| `test` | N/A | **Unit tests for `rippled`** | - -The following dependencies are downloaded and built using ExternalProject -(or FetchContent, where possible). Refer to CMakeLists.txt file for -details about how these sources are built : - -| Name | Upstream Repo | Description | -|:----------------|:---------------------------------------------|:------------| -| `lz4` | https://github.com/lz4/lz4 | LZ4 lossless compression algorithm | -| `nudb` | https://github.com/vinniefalco/NuDB | Constant-time insert-only key/value database for SSD drives (Less memory usage than RocksDB.) | -| `snappy` | https://github.com/google/snappy | "Snappy" lossless compression algorithm. | -| `soci` | https://github.com/SOCI/soci | Abstraction layer for database access. | -| `sqlite` | https://www.sqlite.org/src | An embedded database engine that writes to simple files. | -| `rocksdb` | https://github.com/facebook/rocksdb | Fast key/value database. (Supports rotational disks better than NuDB.) | -| `protobuf` | https://github.com/google/protobuf | Protocol buffer data interchange format. Only downloaded/built if a suitable version is not found by find_package, or if the local_protobuf option is explicitly set | - From 3fcfb5cd4959537471070a089bd26ca88c85fe9e Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 22 Mar 2024 09:15:08 -0500 Subject: [PATCH 04/16] Simplify protobuf generation --- Builds/CMake/RippledCore.cmake | 47 ++++++++++++- Builds/CMake/RippledInstall.cmake | 1 + Builds/CMake/deps/Protobuf.cmake | 27 ------- Builds/CMake/deps/gRPC.cmake | 82 ---------------------- Builds/CMake/target_protobuf_sources.cmake | 62 ++++++++++++++++ CMakeLists.txt | 3 +- conanfile.py | 4 ++ 7 files changed, 114 insertions(+), 112 deletions(-) delete mode 100644 Builds/CMake/deps/Protobuf.cmake delete mode 100644 Builds/CMake/deps/gRPC.cmake create mode 100644 Builds/CMake/target_protobuf_sources.cmake diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index f826c428135..a34a4a5d4d6 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -3,10 +3,55 @@ core functionality, useable by some client software perhaps #]===================================================================] +include(target_protobuf_sources) + file (GLOB_RECURSE rb_headers src/ripple/beast/*.h src/ripple/beast/*.hpp) +# Protocol buffers cannot participate in a unity build, +# because all the generated sources +# define a bunch of `static const` variables with the same names, +# so we just build them as a separate library. +add_library(xrpl.libpb) +target_protobuf_sources(xrpl.libpb ripple/proto + LANGUAGE cpp + IMPORT_DIRS src/ripple/proto + PROTOS src/ripple/proto/ripple.proto +) + +file(GLOB_RECURSE protos "src/ripple/proto/org/*.proto") +target_protobuf_sources(xrpl.libpb ripple/proto + LANGUAGE cpp + IMPORT_DIRS src/ripple/proto + PROTOS "${protos}" +) +target_protobuf_sources(xrpl.libpb ripple/proto + LANGUAGE grpc + IMPORT_DIRS src/ripple/proto + PROTOS "${protos}" + PLUGIN protoc-gen-grpc=$ + GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc +) + +target_compile_options(xrpl.libpb + PUBLIC + $<$:-wd4996> + $<$: + --system-header-prefix="google/protobuf" + -Wno-deprecated-dynamic-exception-spec + > + PRIVATE + $<$:-wd4065> + $<$>:-Wno-deprecated-declarations> +) + +target_link_libraries(xrpl.libpb + PUBLIC + protobuf::libprotobuf + gRPC::grpc++ +) + add_library (xrpl_core ${rb_headers}) ## headers added here for benefit of IDEs if (unity) @@ -17,7 +62,6 @@ add_library(libxrpl INTERFACE) target_link_libraries(libxrpl INTERFACE xrpl_core) add_library(xrpl::libxrpl ALIAS libxrpl) - #[===============================[ beast/legacy FILES: TODO: review these sources for removal or replacement @@ -152,6 +196,7 @@ target_link_libraries (xrpl_core Ripple::syslibs secp256k1::secp256k1 ed25519::ed25519 + xrpl.libpb date::date Ripple::opts xxHash::xxhash) diff --git a/Builds/CMake/RippledInstall.cmake b/Builds/CMake/RippledInstall.cmake index eef90c14615..b9dd44cfc2c 100644 --- a/Builds/CMake/RippledInstall.cmake +++ b/Builds/CMake/RippledInstall.cmake @@ -9,6 +9,7 @@ install ( ripple_syslibs ripple_boost xrpl_core + xrpl.libpb EXPORT RippleExports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib diff --git a/Builds/CMake/deps/Protobuf.cmake b/Builds/CMake/deps/Protobuf.cmake deleted file mode 100644 index e5d866cb069..00000000000 --- a/Builds/CMake/deps/Protobuf.cmake +++ /dev/null @@ -1,27 +0,0 @@ -find_package(Protobuf 3.8) - -set(output_dir ${CMAKE_BINARY_DIR}/proto_gen) -file(MAKE_DIRECTORY ${output_dir}) -set(ccbd ${CMAKE_CURRENT_BINARY_DIR}) -set(CMAKE_CURRENT_BINARY_DIR ${output_dir}) -protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS src/ripple/proto/ripple.proto) -set(CMAKE_CURRENT_BINARY_DIR ${ccbd}) - -target_include_directories(xrpl_core SYSTEM PUBLIC - # The generated implementation imports the header relative to the output - # directory. - $ - $ -) -target_sources(xrpl_core PRIVATE ${output_dir}/src/ripple/proto/ripple.pb.cc) -install( - FILES ${output_dir}/src/ripple/proto/ripple.pb.h - DESTINATION include/ripple/proto) -target_link_libraries(xrpl_core PUBLIC protobuf::libprotobuf) -target_compile_options(xrpl_core - PUBLIC - $<$: - --system-header-prefix="google/protobuf" - -Wno-deprecated-dynamic-exception-spec - > -) diff --git a/Builds/CMake/deps/gRPC.cmake b/Builds/CMake/deps/gRPC.cmake deleted file mode 100644 index de3a88b7bf9..00000000000 --- a/Builds/CMake/deps/gRPC.cmake +++ /dev/null @@ -1,82 +0,0 @@ -find_package(gRPC 1.23) - -#[=================================[ - generate protobuf sources for - grpc defs and bundle into a - static lib -#]=================================] -set(output_dir "${CMAKE_BINARY_DIR}/proto_gen_grpc") -set(GRPC_GEN_DIR "${output_dir}/ripple/proto") -file(MAKE_DIRECTORY ${GRPC_GEN_DIR}) -set(GRPC_PROTO_SRCS) -set(GRPC_PROTO_HDRS) -set(GRPC_PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/src/ripple/proto/org") -file(GLOB_RECURSE GRPC_DEFINITION_FILES "${GRPC_PROTO_ROOT}/*.proto") -foreach(file ${GRPC_DEFINITION_FILES}) - # /home/user/rippled/src/ripple/proto/org/.../v1/get_ledger.proto - get_filename_component(_abs_file ${file} ABSOLUTE) - # /home/user/rippled/src/ripple/proto/org/.../v1 - get_filename_component(_abs_dir ${_abs_file} DIRECTORY) - # get_ledger - get_filename_component(_basename ${file} NAME_WE) - # /home/user/rippled/src/ripple/proto - get_filename_component(_proto_inc ${GRPC_PROTO_ROOT} DIRECTORY) # updir one level - # org/.../v1/get_ledger.proto - file(RELATIVE_PATH _rel_root_file ${_proto_inc} ${_abs_file}) - # org/.../v1 - get_filename_component(_rel_root_dir ${_rel_root_file} DIRECTORY) - # src/ripple/proto/org/.../v1 - file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir}) - - # .cmake/proto_gen_grpc/ripple/proto/org/.../v1/get_ledger.grpc.pb.cc - set(src_1 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.grpc.pb.cc") - set(src_2 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.pb.cc") - set(hdr_1 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.grpc.pb.h") - set(hdr_2 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.pb.h") - add_custom_command( - OUTPUT ${src_1} ${src_2} ${hdr_1} ${hdr_2} - COMMAND protobuf::protoc - ARGS --grpc_out=${GRPC_GEN_DIR} - --cpp_out=${GRPC_GEN_DIR} - --plugin=protoc-gen-grpc=$ - -I ${_proto_inc} -I ${_rel_dir} - ${_abs_file} - DEPENDS ${_abs_file} protobuf::protoc gRPC::grpc_cpp_plugin - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Running gRPC C++ protocol buffer compiler on ${file}" - VERBATIM) - set_source_files_properties(${src_1} ${src_2} ${hdr_1} ${hdr_2} PROPERTIES - GENERATED TRUE - SKIP_UNITY_BUILD_INCLUSION ON - ) - list(APPEND GRPC_PROTO_SRCS ${src_1} ${src_2}) - list(APPEND GRPC_PROTO_HDRS ${hdr_1} ${hdr_2}) -endforeach() - -target_include_directories(xrpl_core SYSTEM PUBLIC - $ - $ - # The generated sources include headers relative to this path. Fix it later. - $ -) -target_sources(xrpl_core PRIVATE ${GRPC_PROTO_SRCS}) -install( - DIRECTORY ${output_dir}/ripple - DESTINATION include/ - FILES_MATCHING PATTERN "*.h" -) -target_link_libraries(xrpl_core PUBLIC - "gRPC::grpc++" - # libgrpc is missing references. - absl::random_random -) -target_compile_options(xrpl_core - PRIVATE - $<$:-wd4065> - $<$>:-Wno-deprecated-declarations> - PUBLIC - $<$:-wd4996> - $<$: - --system-header-prefix="google/protobuf" - -Wno-deprecated-dynamic-exception-spec - >) diff --git a/Builds/CMake/target_protobuf_sources.cmake b/Builds/CMake/target_protobuf_sources.cmake new file mode 100644 index 00000000000..da2ef6dc9a2 --- /dev/null +++ b/Builds/CMake/target_protobuf_sources.cmake @@ -0,0 +1,62 @@ +find_package(Protobuf REQUIRED) + +# .proto files import each other like this: +# +# import "path/to/file.proto"; +# +# For the protobuf compiler to find these imports, +# the parent directory of "path" must be in the import path. +# +# When generating C++, +# it turns into an include statement like this: +# +# #include "path/to/file.pb.h" +# +# and the header is generated at a path relative to the output directory +# that matches the given .proto path relative to the source directory +# minus the first matching prefix on the import path. +# +# In other words, a file `include/package/path/to/file.proto` +# with import path [`include/package`, `include`] +# will generate files `output/path/to/file.pb.{h,cc}` +# with includes like `#include "path/to/file.pb.h". +# +# During build, the generated files can find each other if the output +# directory is an include directory, but we want to install that directory +# under our package's include directory (`include/package`), not as a sibling. +# After install, they can find each other if that subdirectory is an include +# directory. + +# Add protocol buffer sources to an existing library target. +# target: +# The name of the library target. +# prefix: +# The install prefix for headers relative to `CMAKE_INSTALL_INCLUDEDIR`. +# This prefix should appear at the start of all your consumer includes. +# ARGN: +# A list of .proto files. +function(target_protobuf_sources target prefix) + set(dir "${CMAKE_CURRENT_BINARY_DIR}/pb-${target}") + file(MAKE_DIRECTORY "${dir}/${prefix}") + + protobuf_generate( + TARGET ${target} + PROTOC_OUT_DIR "${dir}/${prefix}" + "${ARGN}" + ) + target_include_directories(${target} SYSTEM PUBLIC + # Allows #include used by consumer files. + $ + # Allows #include "path/to/file.proto" used by generated files. + $ + # Allows #include used by consumer files. + $ + # Allows #include "path/to/file.proto" used by generated files. + $ + ) + install( + DIRECTORY ${dir}/ + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILES_MATCHING PATTERN "*.h" + ) +endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index a8c7de7b23b..4a099195020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,7 @@ set(SECP256K1_INSTALL TRUE) add_subdirectory(external/secp256k1) add_library(secp256k1::secp256k1 ALIAS secp256k1) add_subdirectory(external/ed25519-donna) +find_package(gRPC REQUIRED) find_package(lz4 REQUIRED) # Target names with :: are not allowed in a generator expression. # We need to pull the include directories and imported location properties @@ -132,8 +133,6 @@ endif() ### include(RippledCore) -include(deps/Protobuf) -include(deps/gRPC) include(RippledInstall) include(RippledMultiConfig) include(RippledValidatorKeys) diff --git a/conanfile.py b/conanfile.py index dc7dc5d596f..1d4259777cf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -39,6 +39,10 @@ class Xrpl(ConanFile): 'xxhash/0.8.2', ] + tool_requires = [ + 'protobuf/3.21.9', + ] + default_options = { 'assertions': False, 'coverage': False, From 241b9ddde9e11beb7480600fd5ed90e1ef109b21 Mon Sep 17 00:00:00 2001 From: Pretty Printer Date: Sat, 23 Mar 2024 13:51:38 -0500 Subject: [PATCH 05/16] Rename .hpp to .h --- Builds/CMake/RippledCore.cmake | 29 +++++++++---------- .../test/{fail_counter.hpp => fail_counter.h} | 0 .../test/{fail_stream.hpp => fail_stream.h} | 0 .../test/{pipe_stream.hpp => pipe_stream.h} | 0 .../beast/test/{sig_wait.hpp => sig_wait.h} | 0 ...{string_iostream.hpp => string_iostream.h} | 0 .../{string_istream.hpp => string_istream.h} | 0 .../{string_ostream.hpp => string_ostream.h} | 0 .../{test_allocator.hpp => test_allocator.h} | 0 .../beast/test/{yield_to.hpp => yield_to.h} | 0 .../beast/unit_test/{amount.hpp => amount.h} | 0 ...{const_container.hpp => const_container.h} | 0 .../unit_test/{dstream.hpp => dstream.h} | 0 .../{global_suites.hpp => global_suites.h} | 0 .../beast/unit_test/{match.hpp => match.h} | 0 .../unit_test/{recorder.hpp => recorder.h} | 0 .../unit_test/{reporter.hpp => reporter.h} | 0 .../unit_test/{results.hpp => results.h} | 0 .../beast/unit_test/{runner.hpp => runner.h} | 0 .../beast/unit_test/{suite.hpp => suite.h} | 0 .../{suite_info.hpp => suite_info.h} | 0 .../{suite_list.hpp => suite_list.h} | 0 .../beast/unit_test/{thread.hpp => thread.h} | 0 23 files changed, 14 insertions(+), 15 deletions(-) rename src/ripple/beast/test/{fail_counter.hpp => fail_counter.h} (100%) rename src/ripple/beast/test/{fail_stream.hpp => fail_stream.h} (100%) rename src/ripple/beast/test/{pipe_stream.hpp => pipe_stream.h} (100%) rename src/ripple/beast/test/{sig_wait.hpp => sig_wait.h} (100%) rename src/ripple/beast/test/{string_iostream.hpp => string_iostream.h} (100%) rename src/ripple/beast/test/{string_istream.hpp => string_istream.h} (100%) rename src/ripple/beast/test/{string_ostream.hpp => string_ostream.h} (100%) rename src/ripple/beast/test/{test_allocator.hpp => test_allocator.h} (100%) rename src/ripple/beast/test/{yield_to.hpp => yield_to.h} (100%) rename src/ripple/beast/unit_test/{amount.hpp => amount.h} (100%) rename src/ripple/beast/unit_test/detail/{const_container.hpp => const_container.h} (100%) rename src/ripple/beast/unit_test/{dstream.hpp => dstream.h} (100%) rename src/ripple/beast/unit_test/{global_suites.hpp => global_suites.h} (100%) rename src/ripple/beast/unit_test/{match.hpp => match.h} (100%) rename src/ripple/beast/unit_test/{recorder.hpp => recorder.h} (100%) rename src/ripple/beast/unit_test/{reporter.hpp => reporter.h} (100%) rename src/ripple/beast/unit_test/{results.hpp => results.h} (100%) rename src/ripple/beast/unit_test/{runner.hpp => runner.h} (100%) rename src/ripple/beast/unit_test/{suite.hpp => suite.h} (100%) rename src/ripple/beast/unit_test/{suite_info.hpp => suite_info.h} (100%) rename src/ripple/beast/unit_test/{suite_list.hpp => suite_list.h} (100%) rename src/ripple/beast/unit_test/{thread.hpp => thread.h} (100%) diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index a34a4a5d4d6..b3db53b22dd 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -6,8 +6,7 @@ include(target_protobuf_sources) file (GLOB_RECURSE rb_headers - src/ripple/beast/*.h - src/ripple/beast/*.hpp) + src/ripple/beast/*.h) # Protocol buffers cannot participate in a unity build, # because all the generated sources @@ -438,22 +437,22 @@ install ( DESTINATION include/ripple/beast) install ( FILES - src/ripple/beast/unit_test/amount.hpp - src/ripple/beast/unit_test/dstream.hpp - src/ripple/beast/unit_test/global_suites.hpp - src/ripple/beast/unit_test/match.hpp - src/ripple/beast/unit_test/recorder.hpp - src/ripple/beast/unit_test/reporter.hpp - src/ripple/beast/unit_test/results.hpp - src/ripple/beast/unit_test/runner.hpp - src/ripple/beast/unit_test/suite_info.hpp - src/ripple/beast/unit_test/suite_list.hpp - src/ripple/beast/unit_test/suite.hpp - src/ripple/beast/unit_test/thread.hpp + src/ripple/beast/unit_test/amount.h + src/ripple/beast/unit_test/dstream.h + src/ripple/beast/unit_test/global_suites.h + src/ripple/beast/unit_test/match.h + src/ripple/beast/unit_test/recorder.h + src/ripple/beast/unit_test/reporter.h + src/ripple/beast/unit_test/results.h + src/ripple/beast/unit_test/runner.h + src/ripple/beast/unit_test/suite_info.h + src/ripple/beast/unit_test/suite_list.h + src/ripple/beast/unit_test/suite.h + src/ripple/beast/unit_test/thread.h DESTINATION include/ripple/beast/unit_test) install ( FILES - src/ripple/beast/unit_test/detail/const_container.hpp + src/ripple/beast/unit_test/detail/const_container.h DESTINATION include/ripple/beast/unit_test/detail) install ( FILES diff --git a/src/ripple/beast/test/fail_counter.hpp b/src/ripple/beast/test/fail_counter.h similarity index 100% rename from src/ripple/beast/test/fail_counter.hpp rename to src/ripple/beast/test/fail_counter.h diff --git a/src/ripple/beast/test/fail_stream.hpp b/src/ripple/beast/test/fail_stream.h similarity index 100% rename from src/ripple/beast/test/fail_stream.hpp rename to src/ripple/beast/test/fail_stream.h diff --git a/src/ripple/beast/test/pipe_stream.hpp b/src/ripple/beast/test/pipe_stream.h similarity index 100% rename from src/ripple/beast/test/pipe_stream.hpp rename to src/ripple/beast/test/pipe_stream.h diff --git a/src/ripple/beast/test/sig_wait.hpp b/src/ripple/beast/test/sig_wait.h similarity index 100% rename from src/ripple/beast/test/sig_wait.hpp rename to src/ripple/beast/test/sig_wait.h diff --git a/src/ripple/beast/test/string_iostream.hpp b/src/ripple/beast/test/string_iostream.h similarity index 100% rename from src/ripple/beast/test/string_iostream.hpp rename to src/ripple/beast/test/string_iostream.h diff --git a/src/ripple/beast/test/string_istream.hpp b/src/ripple/beast/test/string_istream.h similarity index 100% rename from src/ripple/beast/test/string_istream.hpp rename to src/ripple/beast/test/string_istream.h diff --git a/src/ripple/beast/test/string_ostream.hpp b/src/ripple/beast/test/string_ostream.h similarity index 100% rename from src/ripple/beast/test/string_ostream.hpp rename to src/ripple/beast/test/string_ostream.h diff --git a/src/ripple/beast/test/test_allocator.hpp b/src/ripple/beast/test/test_allocator.h similarity index 100% rename from src/ripple/beast/test/test_allocator.hpp rename to src/ripple/beast/test/test_allocator.h diff --git a/src/ripple/beast/test/yield_to.hpp b/src/ripple/beast/test/yield_to.h similarity index 100% rename from src/ripple/beast/test/yield_to.hpp rename to src/ripple/beast/test/yield_to.h diff --git a/src/ripple/beast/unit_test/amount.hpp b/src/ripple/beast/unit_test/amount.h similarity index 100% rename from src/ripple/beast/unit_test/amount.hpp rename to src/ripple/beast/unit_test/amount.h diff --git a/src/ripple/beast/unit_test/detail/const_container.hpp b/src/ripple/beast/unit_test/detail/const_container.h similarity index 100% rename from src/ripple/beast/unit_test/detail/const_container.hpp rename to src/ripple/beast/unit_test/detail/const_container.h diff --git a/src/ripple/beast/unit_test/dstream.hpp b/src/ripple/beast/unit_test/dstream.h similarity index 100% rename from src/ripple/beast/unit_test/dstream.hpp rename to src/ripple/beast/unit_test/dstream.h diff --git a/src/ripple/beast/unit_test/global_suites.hpp b/src/ripple/beast/unit_test/global_suites.h similarity index 100% rename from src/ripple/beast/unit_test/global_suites.hpp rename to src/ripple/beast/unit_test/global_suites.h diff --git a/src/ripple/beast/unit_test/match.hpp b/src/ripple/beast/unit_test/match.h similarity index 100% rename from src/ripple/beast/unit_test/match.hpp rename to src/ripple/beast/unit_test/match.h diff --git a/src/ripple/beast/unit_test/recorder.hpp b/src/ripple/beast/unit_test/recorder.h similarity index 100% rename from src/ripple/beast/unit_test/recorder.hpp rename to src/ripple/beast/unit_test/recorder.h diff --git a/src/ripple/beast/unit_test/reporter.hpp b/src/ripple/beast/unit_test/reporter.h similarity index 100% rename from src/ripple/beast/unit_test/reporter.hpp rename to src/ripple/beast/unit_test/reporter.h diff --git a/src/ripple/beast/unit_test/results.hpp b/src/ripple/beast/unit_test/results.h similarity index 100% rename from src/ripple/beast/unit_test/results.hpp rename to src/ripple/beast/unit_test/results.h diff --git a/src/ripple/beast/unit_test/runner.hpp b/src/ripple/beast/unit_test/runner.h similarity index 100% rename from src/ripple/beast/unit_test/runner.hpp rename to src/ripple/beast/unit_test/runner.h diff --git a/src/ripple/beast/unit_test/suite.hpp b/src/ripple/beast/unit_test/suite.h similarity index 100% rename from src/ripple/beast/unit_test/suite.hpp rename to src/ripple/beast/unit_test/suite.h diff --git a/src/ripple/beast/unit_test/suite_info.hpp b/src/ripple/beast/unit_test/suite_info.h similarity index 100% rename from src/ripple/beast/unit_test/suite_info.hpp rename to src/ripple/beast/unit_test/suite_info.h diff --git a/src/ripple/beast/unit_test/suite_list.hpp b/src/ripple/beast/unit_test/suite_list.h similarity index 100% rename from src/ripple/beast/unit_test/suite_list.hpp rename to src/ripple/beast/unit_test/suite_list.h diff --git a/src/ripple/beast/unit_test/thread.hpp b/src/ripple/beast/unit_test/thread.h similarity index 100% rename from src/ripple/beast/unit_test/thread.hpp rename to src/ripple/beast/unit_test/thread.h From 760f16f56835663d9286bd29294d074de26a7ba6 Mon Sep 17 00:00:00 2001 From: Pretty Printer Date: Sat, 23 Mar 2024 13:51:59 -0500 Subject: [PATCH 06/16] Format formerly .hpp files --- src/ripple/beast/test/fail_counter.h | 68 ++-- src/ripple/beast/test/fail_stream.h | 116 +++--- src/ripple/beast/test/pipe_stream.h | 357 ++++++++---------- src/ripple/beast/test/sig_wait.h | 15 +- src/ripple/beast/test/string_iostream.h | 105 +++--- src/ripple/beast/test/string_istream.h | 100 +++-- src/ripple/beast/test/string_ostream.h | 98 +++-- src/ripple/beast/test/test_allocator.h | 59 ++- src/ripple/beast/test/yield_to.h | 53 ++- src/ripple/beast/unit_test/amount.h | 23 +- .../beast/unit_test/detail/const_container.h | 14 +- src/ripple/beast/unit_test/dstream.h | 55 ++- src/ripple/beast/unit_test/global_suites.h | 25 +- src/ripple/beast/unit_test/match.h | 135 ++++--- src/ripple/beast/unit_test/recorder.h | 27 +- src/ripple/beast/unit_test/reporter.h | 161 ++++---- src/ripple/beast/unit_test/results.h | 36 +- src/ripple/beast/unit_test/runner.h | 86 ++--- src/ripple/beast/unit_test/suite.h | 288 ++++++-------- src/ripple/beast/unit_test/suite_info.h | 33 +- src/ripple/beast/unit_test/suite_list.h | 26 +- src/ripple/beast/unit_test/thread.h | 40 +- 22 files changed, 845 insertions(+), 1075 deletions(-) diff --git a/src/ripple/beast/test/fail_counter.h b/src/ripple/beast/test/fail_counter.h index 8c577cbea84..8a11602e22d 100644 --- a/src/ripple/beast/test/fail_counter.h +++ b/src/ripple/beast/test/fail_counter.h @@ -8,16 +8,13 @@ #ifndef BEAST_TEST_FAIL_COUNTER_HPP #define BEAST_TEST_FAIL_COUNTER_HPP -#include #include +#include namespace beast { namespace test { -enum class error -{ - fail_error = 1 -}; +enum class error { fail_error = 1 }; namespace detail { @@ -33,11 +30,11 @@ class fail_error_category : public boost::system::error_category std::string message(int ev) const override { - switch(static_cast(ev)) + switch (static_cast(ev)) { - default: - case error::fail_error: - return "test error"; + default: + case error::fail_error: + return "test error"; } } @@ -48,39 +45,34 @@ class fail_error_category : public boost::system::error_category } bool - equivalent(int ev, - boost::system::error_condition const& condition - ) const noexcept override + equivalent(int ev, boost::system::error_condition const& condition) + const noexcept override { - return condition.value() == ev && - &condition.category() == this; + return condition.value() == ev && &condition.category() == this; } bool equivalent(error_code const& error, int ev) const noexcept override { - return error.value() == ev && - &error.category() == this; + return error.value() == ev && &error.category() == this; } }; -inline -boost::system::error_category const& +inline boost::system::error_category const& get_error_category() { static fail_error_category const cat{}; return cat; } -} // detail +} // namespace detail -inline -error_code +inline error_code make_error_code(error ev) { return error_code{ static_cast::type>(ev), - detail::get_error_category()}; + detail::get_error_category()}; } /** An error code with an error set on default construction @@ -91,12 +83,11 @@ make_error_code(error ev) */ struct fail_error_code : error_code { - fail_error_code() - : error_code(make_error_code(error::fail_error)) + fail_error_code() : error_code(make_error_code(error::fail_error)) { } - template + template fail_error_code(Arg0&& arg0, ArgN&&... argn) : error_code(arg0, std::forward(argn)...) { @@ -120,11 +111,10 @@ class fail_counter @param The 0-based index of the operation to fail on or after. */ - explicit - fail_counter(std::size_t n, - error_code ev = make_error_code(error::fail_error)) - : n_(n) - , ec_(ev) + explicit fail_counter( + std::size_t n, + error_code ev = make_error_code(error::fail_error)) + : n_(n), ec_(ev) { } @@ -132,9 +122,9 @@ class fail_counter void fail() { - if(n_ > 0) + if (n_ > 0) --n_; - if(! n_) + if (!n_) BOOST_THROW_EXCEPTION(system_error{ec_}); } @@ -142,9 +132,9 @@ class fail_counter bool fail(error_code& ec) { - if(n_ > 0) + if (n_ > 0) --n_; - if(! n_) + if (!n_) { ec = ec_; return true; @@ -154,17 +144,17 @@ class fail_counter } }; -} // test -} // beast +} // namespace test +} // namespace beast namespace boost { namespace system { -template<> +template <> struct is_error_code_enum { static bool const value = true; }; -} // system -} // boost +} // namespace system +} // namespace boost #endif diff --git a/src/ripple/beast/test/fail_stream.h b/src/ripple/beast/test/fail_stream.h index c4b38538bf5..a1465f006ca 100644 --- a/src/ripple/beast/test/fail_stream.h +++ b/src/ripple/beast/test/fail_stream.h @@ -8,13 +8,13 @@ #ifndef BEAST_TEST_FAIL_STREAM_HPP #define BEAST_TEST_FAIL_STREAM_HPP +#include #include #include -#include #include -#include +#include #include -#include +#include namespace beast { namespace test { @@ -24,7 +24,7 @@ namespace test { On the Nth operation, the stream will fail with the specified error code, or the default error code of invalid_argument. */ -template +template class fail_stream { boost::optional fc_; @@ -32,31 +32,26 @@ class fail_stream NextLayer next_layer_; public: - using next_layer_type = - typename std::remove_reference::type; + using next_layer_type = typename std::remove_reference::type; - using lowest_layer_type = - typename get_lowest_layer::type; + using lowest_layer_type = typename get_lowest_layer::type; fail_stream(fail_stream&&) = delete; fail_stream(fail_stream const&) = delete; - fail_stream& operator=(fail_stream&&) = delete; - fail_stream& operator=(fail_stream const&) = delete; - - template - explicit - fail_stream(std::size_t n, Args&&... args) - : fc_(n) - , pfc_(&*fc_) - , next_layer_(std::forward(args)...) + fail_stream& + operator=(fail_stream&&) = delete; + fail_stream& + operator=(fail_stream const&) = delete; + + template + explicit fail_stream(std::size_t n, Args&&... args) + : fc_(n), pfc_(&*fc_), next_layer_(std::forward(args)...) { } - template - explicit - fail_stream(fail_counter& fc, Args&&... args) - : pfc_(&fc) - , next_layer_(std::forward(args)...) + template + explicit fail_stream(fail_counter& fc, Args&&... args) + : pfc_(&fc), next_layer_(std::forward(args)...) { } @@ -84,7 +79,7 @@ class fail_stream return next_layer_.get_io_service(); } - template + template std::size_t read_some(MutableBufferSequence const& buffers) { @@ -92,35 +87,33 @@ class fail_stream return next_layer_.read_some(buffers); } - template + template std::size_t read_some(MutableBufferSequence const& buffers, error_code& ec) { - if(pfc_->fail(ec)) + if (pfc_->fail(ec)) return 0; return next_layer_.read_some(buffers, ec); } - template - async_return_type< - ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const& buffers, - ReadHandler&& handler) + template + async_return_type + async_read_some(MutableBufferSequence const& buffers, ReadHandler&& handler) { error_code ec; - if(pfc_->fail(ec)) + if (pfc_->fail(ec)) { - async_completion init{handler}; + async_completion init{ + handler}; next_layer_.get_io_service().post( bind_handler(init.completion_handler, ec, 0)); return init.result.get(); } - return next_layer_.async_read_some(buffers, - std::forward(handler)); + return next_layer_.async_read_some( + buffers, std::forward(handler)); } - template + template std::size_t write_some(ConstBufferSequence const& buffers) { @@ -128,57 +121,54 @@ class fail_stream return next_layer_.write_some(buffers); } - template + template std::size_t write_some(ConstBufferSequence const& buffers, error_code& ec) { - if(pfc_->fail(ec)) + if (pfc_->fail(ec)) return 0; return next_layer_.write_some(buffers, ec); } - template - async_return_type< - WriteHandler, void(error_code, std::size_t)> - async_write_some(ConstBufferSequence const& buffers, - WriteHandler&& handler) + template + async_return_type + async_write_some(ConstBufferSequence const& buffers, WriteHandler&& handler) { error_code ec; - if(pfc_->fail(ec)) + if (pfc_->fail(ec)) { - async_completion init{handler}; + async_completion init{ + handler}; next_layer_.get_io_service().post( bind_handler(init.completion_handler, ec, 0)); return init.result.get(); } - return next_layer_.async_write_some(buffers, - std::forward(handler)); + return next_layer_.async_write_some( + buffers, std::forward(handler)); } - friend - void - teardown(websocket::teardown_tag, + friend void + teardown( + websocket::teardown_tag, fail_stream& stream, - boost::system::error_code& ec) + boost::system::error_code& ec) { - if(stream.pfc_->fail(ec)) + if (stream.pfc_->fail(ec)) return; beast::websocket_helpers::call_teardown(stream.next_layer(), ec); } - template - friend - void - async_teardown(websocket::teardown_tag, + template + friend void + async_teardown( + websocket::teardown_tag, fail_stream& stream, - TeardownHandler&& handler) + TeardownHandler&& handler) { error_code ec; - if(stream.pfc_->fail(ec)) + if (stream.pfc_->fail(ec)) { - stream.get_io_service().post( - bind_handler(std::move(handler), ec)); + stream.get_io_service().post(bind_handler(std::move(handler), ec)); return; } beast::websocket_helpers::call_async_teardown( @@ -186,7 +176,7 @@ class fail_stream } }; -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/pipe_stream.h b/src/ripple/beast/test/pipe_stream.h index dfaef479b03..1aaaadfa4ff 100644 --- a/src/ripple/beast/test/pipe_stream.h +++ b/src/ripple/beast/test/pipe_stream.h @@ -8,17 +8,17 @@ #ifndef BEAST_TEST_PIPE_STREAM_HPP #define BEAST_TEST_PIPE_STREAM_HPP +#include +#include +#include +#include #include #include #include #include #include -#include #include -#include -#include -#include -#include +#include #include #include #include @@ -46,7 +46,8 @@ class pipe struct read_op { virtual ~read_op() = default; - virtual void operator()() = 0; + virtual void + operator()() = 0; }; struct state @@ -69,24 +70,18 @@ class pipe { friend class pipe; - template + template class read_op_impl; state& in_; state& out_; boost::asio::io_service& ios_; fail_counter* fc_ = nullptr; - std::size_t read_max_ = - (std::numeric_limits::max)(); - std::size_t write_max_ = - (std::numeric_limits::max)(); - - stream(state& in, state& out, - boost::asio::io_service& ios) - : in_(in) - , out_(out) - , ios_(ios) - , buffer(in_.b) + std::size_t read_max_ = (std::numeric_limits::max)(); + std::size_t write_max_ = (std::numeric_limits::max)(); + + stream(state& in, state& out, boost::asio::io_service& ios) + : in_(in), out_(out), ios_(ios), buffer(in_.b) { } @@ -148,8 +143,7 @@ class pipe void clear() { - in_.b.consume((std::numeric_limits< - std::size_t>::max)()); + in_.b.consume((std::numeric_limits::max)()); } /** Close the stream. @@ -157,57 +151,56 @@ class pipe The other end of the pipe will see `boost::asio::error::eof` on read. */ - template + template void close(); - template + template std::size_t read_some(MutableBufferSequence const& buffers); - template + template std::size_t - read_some(MutableBufferSequence const& buffers, - error_code& ec); + read_some(MutableBufferSequence const& buffers, error_code& ec); - template - async_return_type< - ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const& buffers, + template + async_return_type + async_read_some( + MutableBufferSequence const& buffers, ReadHandler&& handler); - template + template std::size_t write_some(ConstBufferSequence const& buffers); - template + template std::size_t - write_some( - ConstBufferSequence const& buffers, error_code&); + write_some(ConstBufferSequence const& buffers, error_code&); - template - async_return_type< - WriteHandler, void(error_code, std::size_t)> - async_write_some(ConstBufferSequence const& buffers, + template + async_return_type + async_write_some( + ConstBufferSequence const& buffers, WriteHandler&& handler); - friend - void - teardown(websocket::teardown_tag, - stream&, boost::system::error_code& ec) + friend void + teardown( + websocket::teardown_tag, + stream&, + boost::system::error_code& ec) { ec.assign(0, ec.category()); } - template - friend - void - async_teardown(websocket::teardown_tag, - stream& s, TeardownHandler&& handler) + template + friend void + async_teardown( + websocket::teardown_tag, + stream& s, + TeardownHandler&& handler) { s.get_io_service().post( - bind_handler(std::move(handler), - error_code{})); + bind_handler(std::move(handler), error_code{})); } }; @@ -215,10 +208,8 @@ class pipe The client and server endpoints will use the same `io_service`. */ - explicit - pipe(boost::asio::io_service& ios) - : client(s_[0], s_[1], ios) - , server(s_[1], s_[0], ios) + explicit pipe(boost::asio::io_service& ios) + : client(s_[0], s_[1], ios), server(s_[1], s_[0], ios) { } @@ -226,11 +217,8 @@ class pipe The client and server endpoints will different `io_service` objects. */ - explicit - pipe(boost::asio::io_service& ios1, - boost::asio::io_service& ios2) - : client(s_[0], s_[1], ios1) - , server(s_[1], s_[0], ios2) + explicit pipe(boost::asio::io_service& ios1, boost::asio::io_service& ios2) + : client(s_[0], s_[1], ios1), server(s_[1], s_[0], ios2) { } @@ -243,28 +231,21 @@ class pipe //------------------------------------------------------------------------------ -template -class pipe::stream::read_op_impl : - public pipe::read_op +template +class pipe::stream::read_op_impl : public pipe::read_op { stream& s_; Buffers b_; Handler h_; public: - read_op_impl(stream& s, - Buffers const& b, Handler&& h) - : s_(s) - , b_(b) - , h_(std::move(h)) + read_op_impl(stream& s, Buffers const& b, Handler&& h) + : s_(s), b_(b), h_(std::move(h)) { } - read_op_impl(stream& s, - Buffers const& b, Handler const& h) - : s_(s) - , b_(b) - , h_(h) + read_op_impl(stream& s, Buffers const& b, Handler const& h) + : s_(s), b_(b), h_(h) { } @@ -274,103 +255,89 @@ class pipe::stream::read_op_impl : //------------------------------------------------------------------------------ -template +template void -pipe::stream:: -read_op_impl::operator()() +pipe::stream::read_op_impl::operator()() { using boost::asio::buffer_copy; using boost::asio::buffer_size; - s_.ios_.post( - [&]() + s_.ios_.post([&]() { + BOOST_ASSERT(s_.in_.op); + std::unique_lock lock{s_.in_.m}; + if (s_.in_.b.size() > 0) + { + auto const bytes_transferred = + buffer_copy(b_, s_.in_.b.data(), s_.read_max_); + s_.in_.b.consume(bytes_transferred); + auto& s = s_; + Handler h{std::move(h_)}; + lock.unlock(); + s.in_.op.reset(nullptr); + ++s.nread; + s.ios_.post( + bind_handler(std::move(h), error_code{}, bytes_transferred)); + } + else { - BOOST_ASSERT(s_.in_.op); - std::unique_lock lock{s_.in_.m}; - if(s_.in_.b.size() > 0) - { - auto const bytes_transferred = buffer_copy( - b_, s_.in_.b.data(), s_.read_max_); - s_.in_.b.consume(bytes_transferred); - auto& s = s_; - Handler h{std::move(h_)}; - lock.unlock(); - s.in_.op.reset(nullptr); - ++s.nread; - s.ios_.post(bind_handler(std::move(h), - error_code{}, bytes_transferred)); - } - else - { - BOOST_ASSERT(s_.in_.eof); - auto& s = s_; - Handler h{std::move(h_)}; - lock.unlock(); - s.in_.op.reset(nullptr); - ++s.nread; - s.ios_.post(bind_handler(std::move(h), - boost::asio::error::eof, 0)); - } - }); + BOOST_ASSERT(s_.in_.eof); + auto& s = s_; + Handler h{std::move(h_)}; + lock.unlock(); + s.in_.op.reset(nullptr); + ++s.nread; + s.ios_.post(bind_handler(std::move(h), boost::asio::error::eof, 0)); + } + }); } //------------------------------------------------------------------------------ -template +template void -pipe::stream:: -close() +pipe::stream::close() { std::lock_guard lock{out_.m}; out_.eof = true; - if(out_.op) + if (out_.op) out_.op.get()->operator()(); else out_.cv.notify_all(); } - -template +template std::size_t -pipe::stream:: -read_some(MutableBufferSequence const& buffers) +pipe::stream::read_some(MutableBufferSequence const& buffers) { - static_assert(is_mutable_buffer_sequence< - MutableBufferSequence>::value, + static_assert( + is_mutable_buffer_sequence::value, "MutableBufferSequence requirements not met"); error_code ec; auto const n = read_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } -template +template std::size_t -pipe::stream:: -read_some(MutableBufferSequence const& buffers, - error_code& ec) +pipe::stream::read_some(MutableBufferSequence const& buffers, error_code& ec) { - static_assert(is_mutable_buffer_sequence< - MutableBufferSequence>::value, + static_assert( + is_mutable_buffer_sequence::value, "MutableBufferSequence requirements not met"); using boost::asio::buffer_copy; using boost::asio::buffer_size; - BOOST_ASSERT(! in_.op); + BOOST_ASSERT(!in_.op); BOOST_ASSERT(buffer_size(buffers) > 0); - if(fc_ && fc_->fail(ec)) + if (fc_ && fc_->fail(ec)) return 0; std::unique_lock lock{in_.m}; - in_.cv.wait(lock, - [&]() - { - return in_.b.size() > 0 || in_.eof; - }); + in_.cv.wait(lock, [&]() { return in_.b.size() > 0 || in_.eof; }); std::size_t bytes_transferred; - if(in_.b.size() > 0) - { + if (in_.b.size() > 0) + { ec.assign(0, ec.category()); - bytes_transferred = buffer_copy( - buffers, in_.b.data(), read_max_); + bytes_transferred = buffer_copy(buffers, in_.b.data(), read_max_); in_.b.consume(bytes_transferred); } else @@ -383,99 +350,90 @@ read_some(MutableBufferSequence const& buffers, return bytes_transferred; } -template -async_return_type< - ReadHandler, void(error_code, std::size_t)> -pipe::stream:: -async_read_some(MutableBufferSequence const& buffers, +template +async_return_type +pipe::stream::async_read_some( + MutableBufferSequence const& buffers, ReadHandler&& handler) { - static_assert(is_mutable_buffer_sequence< - MutableBufferSequence>::value, + static_assert( + is_mutable_buffer_sequence::value, "MutableBufferSequence requirements not met"); using boost::asio::buffer_copy; using boost::asio::buffer_size; - BOOST_ASSERT(! in_.op); + BOOST_ASSERT(!in_.op); BOOST_ASSERT(buffer_size(buffers) > 0); - async_completion init{handler}; - if(fc_) + async_completion init{handler}; + if (fc_) { error_code ec; - if(fc_->fail(ec)) - return ios_.post(bind_handler( - init.completion_handler, ec, 0)); + if (fc_->fail(ec)) + return ios_.post(bind_handler(init.completion_handler, ec, 0)); } { std::unique_lock lock{in_.m}; - if(in_.eof) + if (in_.eof) { lock.unlock(); ++nread; - ios_.post(bind_handler(init.completion_handler, - boost::asio::error::eof, 0)); + ios_.post(bind_handler( + init.completion_handler, boost::asio::error::eof, 0)); } - else if(buffer_size(buffers) == 0 || - buffer_size(in_.b.data()) > 0) + else if (buffer_size(buffers) == 0 || buffer_size(in_.b.data()) > 0) { - auto const bytes_transferred = buffer_copy( - buffers, in_.b.data(), read_max_); + auto const bytes_transferred = + buffer_copy(buffers, in_.b.data(), read_max_); in_.b.consume(bytes_transferred); lock.unlock(); ++nread; - ios_.post(bind_handler(init.completion_handler, - error_code{}, bytes_transferred)); + ios_.post(bind_handler( + init.completion_handler, error_code{}, bytes_transferred)); } else { - in_.op.reset(new read_op_impl, - MutableBufferSequence>{*this, buffers, - init.completion_handler}); + in_.op.reset( + new read_op_impl< + handler_type, + MutableBufferSequence>{ + *this, buffers, init.completion_handler}); } } return init.result.get(); } -template +template std::size_t -pipe::stream:: -write_some(ConstBufferSequence const& buffers) +pipe::stream::write_some(ConstBufferSequence const& buffers) { - static_assert(is_const_buffer_sequence< - ConstBufferSequence>::value, + static_assert( + is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); - BOOST_ASSERT(! out_.eof); + BOOST_ASSERT(!out_.eof); error_code ec; - auto const bytes_transferred = - write_some(buffers, ec); - if(ec) + auto const bytes_transferred = write_some(buffers, ec); + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return bytes_transferred; } -template +template std::size_t -pipe::stream:: -write_some( - ConstBufferSequence const& buffers, error_code& ec) +pipe::stream::write_some(ConstBufferSequence const& buffers, error_code& ec) { - static_assert(is_const_buffer_sequence< - ConstBufferSequence>::value, + static_assert( + is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); using boost::asio::buffer_copy; using boost::asio::buffer_size; - BOOST_ASSERT(! out_.eof); - if(fc_ && fc_->fail(ec)) + BOOST_ASSERT(!out_.eof); + if (fc_ && fc_->fail(ec)) return 0; - auto const n = (std::min)( - buffer_size(buffers), write_max_); + auto const n = (std::min)(buffer_size(buffers), write_max_); std::unique_lock lock{out_.m}; - auto const bytes_transferred = - buffer_copy(out_.b.prepare(n), buffers); + auto const bytes_transferred = buffer_copy(out_.b.prepare(n), buffers); out_.b.commit(bytes_transferred); lock.unlock(); - if(out_.op) + if (out_.op) out_.op.get()->operator()(); else out_.cv.notify_all(); @@ -484,46 +442,41 @@ write_some( return bytes_transferred; } -template -async_return_type< - WriteHandler, void(error_code, std::size_t)> -pipe::stream:: -async_write_some(ConstBufferSequence const& buffers, +template +async_return_type +pipe::stream::async_write_some( + ConstBufferSequence const& buffers, WriteHandler&& handler) { - static_assert(is_const_buffer_sequence< - ConstBufferSequence>::value, + static_assert( + is_const_buffer_sequence::value, "ConstBufferSequence requirements not met"); using boost::asio::buffer_copy; using boost::asio::buffer_size; - BOOST_ASSERT(! out_.eof); - async_completion init{handler}; - if(fc_) + BOOST_ASSERT(!out_.eof); + async_completion init{handler}; + if (fc_) { error_code ec; - if(fc_->fail(ec)) - return ios_.post(bind_handler( - init.completion_handler, ec, 0)); + if (fc_->fail(ec)) + return ios_.post(bind_handler(init.completion_handler, ec, 0)); } - auto const n = - (std::min)(buffer_size(buffers), write_max_); + auto const n = (std::min)(buffer_size(buffers), write_max_); std::unique_lock lock{out_.m}; - auto const bytes_transferred = - buffer_copy(out_.b.prepare(n), buffers); + auto const bytes_transferred = buffer_copy(out_.b.prepare(n), buffers); out_.b.commit(bytes_transferred); lock.unlock(); - if(out_.op) + if (out_.op) out_.op.get()->operator()(); else out_.cv.notify_all(); ++nwrite; - ios_.post(bind_handler(init.completion_handler, - error_code{}, bytes_transferred)); + ios_.post( + bind_handler(init.completion_handler, error_code{}, bytes_transferred)); return init.result.get(); } -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/sig_wait.h b/src/ripple/beast/test/sig_wait.h index cadd21660e8..92720561fa6 100644 --- a/src/ripple/beast/test/sig_wait.h +++ b/src/ripple/beast/test/sig_wait.h @@ -14,21 +14,16 @@ namespace beast { namespace test { /// Block until SIGINT or SIGTERM is received. -inline -void +inline void sig_wait() { boost::asio::io_service ios; - boost::asio::signal_set signals( - ios, SIGINT, SIGTERM); - signals.async_wait( - [&](boost::system::error_code const&, int) - { - }); + boost::asio::signal_set signals(ios, SIGINT, SIGTERM); + signals.async_wait([&](boost::system::error_code const&, int) {}); ios.run(); } -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/string_iostream.h b/src/ripple/beast/test/string_iostream.h index eeeb7e21ab1..56f741be068 100644 --- a/src/ripple/beast/test/string_iostream.h +++ b/src/ripple/beast/test/string_iostream.h @@ -8,20 +8,21 @@ #ifndef BEAST_TEST_STRING_IOSTREAM_HPP #define BEAST_TEST_STRING_IOSTREAM_HPP +#include +#include +#include #include #include #include #include #include -#include -#include -#include #include namespace beast { namespace test { -/** A SyncStream and AsyncStream that reads from a string and writes to another string. +/** A SyncStream and AsyncStream that reads from a string and writes to another + string. This class behaves like a socket, except that written data is appended to a string exposed as a public data member, and when @@ -37,9 +38,10 @@ class string_iostream public: std::string str; - string_iostream(boost::asio::io_service& ios, - std::string s, std::size_t read_max = - (std::numeric_limits::max)()) + string_iostream( + boost::asio::io_service& ios, + std::string s, + std::size_t read_max = (std::numeric_limits::max)()) : s_(std::move(s)) , cb_(boost::asio::buffer(s_)) , ios_(ios) @@ -53,25 +55,24 @@ class string_iostream return ios_; } - template + template std::size_t read_some(MutableBufferSequence const& buffers) { error_code ec; auto const n = read_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - read_some(MutableBufferSequence const& buffers, - error_code& ec) + read_some(MutableBufferSequence const& buffers, error_code& ec) { - auto const n = boost::asio::buffer_copy( - buffers, buffer_prefix(read_max_, cb_)); - if(n > 0) + auto const n = + boost::asio::buffer_copy(buffers, buffer_prefix(read_max_, cb_)); + if (n > 0) { ec.assign(0, ec.category()); cb_ = cb_ + n; @@ -83,91 +84,83 @@ class string_iostream return n; } - template - async_return_type< - ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const& buffers, - ReadHandler&& handler) + template + async_return_type + async_read_some(MutableBufferSequence const& buffers, ReadHandler&& handler) { - auto const n = boost::asio::buffer_copy( - buffers, boost::asio::buffer(s_)); + auto const n = + boost::asio::buffer_copy(buffers, boost::asio::buffer(s_)); error_code ec; - if(n > 0) + if (n > 0) s_.erase(0, n); else ec = boost::asio::error::eof; - async_completion init{handler}; - ios_.post(bind_handler( - init.completion_handler, ec, n)); + async_completion init{ + handler}; + ios_.post(bind_handler(init.completion_handler, ec, n)); return init.result.get(); } - template + template std::size_t write_some(ConstBufferSequence const& buffers) { error_code ec; auto const n = write_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - write_some( - ConstBufferSequence const& buffers, error_code& ec) + write_some(ConstBufferSequence const& buffers, error_code& ec) { ec.assign(0, ec.category()); - using boost::asio::buffer_size; using boost::asio::buffer_cast; + using boost::asio::buffer_size; auto const n = buffer_size(buffers); str.reserve(str.size() + n); - for(boost::asio::const_buffer buffer : buffers) - str.append(buffer_cast(buffer), - buffer_size(buffer)); + for (boost::asio::const_buffer buffer : buffers) + str.append(buffer_cast(buffer), buffer_size(buffer)); return n; } - template - async_return_type< - WriteHandler, void(error_code, std::size_t)> - async_write_some(ConstBufferSequence const& buffers, - WriteHandler&& handler) + template + async_return_type + async_write_some(ConstBufferSequence const& buffers, WriteHandler&& handler) { error_code ec; auto const bytes_transferred = write_some(buffers, ec); - async_completion init{handler}; + async_completion init{ + handler}; get_io_service().post( bind_handler(init.completion_handler, ec, bytes_transferred)); return init.result.get(); } - friend - void - teardown(websocket::teardown_tag, + friend void + teardown( + websocket::teardown_tag, string_iostream&, - boost::system::error_code& ec) + boost::system::error_code& ec) { ec.assign(0, ec.category()); } - template - friend - void - async_teardown(websocket::teardown_tag, + template + friend void + async_teardown( + websocket::teardown_tag, string_iostream& stream, - TeardownHandler&& handler) + TeardownHandler&& handler) { stream.get_io_service().post( - bind_handler(std::move(handler), - error_code{})); + bind_handler(std::move(handler), error_code{})); } }; -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/string_istream.h b/src/ripple/beast/test/string_istream.h index c9692b87268..81f35469905 100644 --- a/src/ripple/beast/test/string_istream.h +++ b/src/ripple/beast/test/string_istream.h @@ -8,13 +8,13 @@ #ifndef BEAST_TEST_STRING_ISTREAM_HPP #define BEAST_TEST_STRING_ISTREAM_HPP +#include +#include +#include #include #include #include #include -#include -#include -#include #include namespace beast { @@ -34,9 +34,10 @@ class string_istream std::size_t read_max_; public: - string_istream(boost::asio::io_service& ios, - std::string s, std::size_t read_max = - (std::numeric_limits::max)()) + string_istream( + boost::asio::io_service& ios, + std::string s, + std::size_t read_max = (std::numeric_limits::max)()) : s_(std::move(s)) , cb_(boost::asio::buffer(s_)) , ios_(ios) @@ -50,25 +51,23 @@ class string_istream return ios_; } - template + template std::size_t read_some(MutableBufferSequence const& buffers) { error_code ec; auto const n = read_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - read_some(MutableBufferSequence const& buffers, - error_code& ec) + read_some(MutableBufferSequence const& buffers, error_code& ec) { - auto const n = boost::asio::buffer_copy( - buffers, cb_, read_max_); - if(n > 0) + auto const n = boost::asio::buffer_copy(buffers, cb_, read_max_); + if (n > 0) { ec.assign(0, ec.category()); cb_ = cb_ + n; @@ -80,82 +79,77 @@ class string_istream return n; } - template - async_return_type< - ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const& buffers, - ReadHandler&& handler) + template + async_return_type + async_read_some(MutableBufferSequence const& buffers, ReadHandler&& handler) { - auto const n = boost::asio::buffer_copy( - buffers, boost::asio::buffer(s_)); + auto const n = + boost::asio::buffer_copy(buffers, boost::asio::buffer(s_)); error_code ec; - if(n > 0) + if (n > 0) s_.erase(0, n); else ec = boost::asio::error::eof; - async_completion init{handler}; - ios_.post(bind_handler( - init.completion_handler, ec, n)); + async_completion init{ + handler}; + ios_.post(bind_handler(init.completion_handler, ec, n)); return init.result.get(); } - template + template std::size_t write_some(ConstBufferSequence const& buffers) { error_code ec; auto const n = write_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - write_some(ConstBufferSequence const& buffers, - error_code& ec) + write_some(ConstBufferSequence const& buffers, error_code& ec) { ec.assign(0, ec.category()); return boost::asio::buffer_size(buffers); } - template - async_return_type< - WriteHandler, void(error_code, std::size_t)> - async_write_some(ConstBuffeSequence const& buffers, - WriteHandler&& handler) + template + async_return_type + async_write_some(ConstBuffeSequence const& buffers, WriteHandler&& handler) { - async_completion init{handler}; - ios_.post(bind_handler(init.completion_handler, - error_code{}, boost::asio::buffer_size(buffers))); + async_completion init{ + handler}; + ios_.post(bind_handler( + init.completion_handler, + error_code{}, + boost::asio::buffer_size(buffers))); return init.result.get(); } - friend - void - teardown(websocket::teardown_tag, + friend void + teardown( + websocket::teardown_tag, string_istream&, - boost::system::error_code& ec) + boost::system::error_code& ec) { ec.assign(0, ec.category()); } - template - friend - void - async_teardown(websocket::teardown_tag, + template + friend void + async_teardown( + websocket::teardown_tag, string_istream& stream, - TeardownHandler&& handler) + TeardownHandler&& handler) { stream.get_io_service().post( - bind_handler(std::move(handler), - error_code{})); + bind_handler(std::move(handler), error_code{})); } }; -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/string_ostream.h b/src/ripple/beast/test/string_ostream.h index dd57d8a9991..4cca9e7fce0 100644 --- a/src/ripple/beast/test/string_ostream.h +++ b/src/ripple/beast/test/string_ostream.h @@ -8,14 +8,14 @@ #ifndef BEAST_TEST_STRING_OSTREAM_HPP #define BEAST_TEST_STRING_OSTREAM_HPP +#include +#include +#include #include #include #include #include #include -#include -#include -#include #include namespace beast { @@ -29,12 +29,10 @@ class string_ostream public: std::string str; - explicit - string_ostream(boost::asio::io_service& ios, - std::size_t write_max = - (std::numeric_limits::max)()) - : ios_(ios) - , write_max_(write_max) + explicit string_ostream( + boost::asio::io_service& ios, + std::size_t write_max = (std::numeric_limits::max)()) + : ios_(ios), write_max_(write_max) { } @@ -44,106 +42,96 @@ class string_ostream return ios_; } - template + template std::size_t read_some(MutableBufferSequence const& buffers) { error_code ec; auto const n = read_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - read_some(MutableBufferSequence const&, - error_code& ec) + read_some(MutableBufferSequence const&, error_code& ec) { ec = boost::asio::error::eof; return 0; } - template - async_return_type< - ReadHandler, void(error_code, std::size_t)> - async_read_some(MutableBufferSequence const&, - ReadHandler&& handler) + template + async_return_type + async_read_some(MutableBufferSequence const&, ReadHandler&& handler) { - async_completion init{handler}; - ios_.post(bind_handler(init.completion_handler, - boost::asio::error::eof, 0)); + async_completion init{ + handler}; + ios_.post( + bind_handler(init.completion_handler, boost::asio::error::eof, 0)); return init.result.get(); } - template + template std::size_t write_some(ConstBufferSequence const& buffers) { error_code ec; auto const n = write_some(buffers, ec); - if(ec) + if (ec) BOOST_THROW_EXCEPTION(system_error{ec}); return n; } - template + template std::size_t - write_some( - ConstBufferSequence const& buffers, error_code& ec) + write_some(ConstBufferSequence const& buffers, error_code& ec) { ec.assign(0, ec.category()); - using boost::asio::buffer_size; using boost::asio::buffer_cast; - auto const n = - (std::min)(buffer_size(buffers), write_max_); + using boost::asio::buffer_size; + auto const n = (std::min)(buffer_size(buffers), write_max_); str.reserve(str.size() + n); - for(boost::asio::const_buffer buffer : - buffer_prefix(n, buffers)) - str.append(buffer_cast(buffer), - buffer_size(buffer)); + for (boost::asio::const_buffer buffer : buffer_prefix(n, buffers)) + str.append(buffer_cast(buffer), buffer_size(buffer)); return n; } - template - async_return_type< - WriteHandler, void(error_code, std::size_t)> - async_write_some(ConstBufferSequence const& buffers, - WriteHandler&& handler) + template + async_return_type + async_write_some(ConstBufferSequence const& buffers, WriteHandler&& handler) { error_code ec; auto const bytes_transferred = write_some(buffers, ec); - async_completion init{handler}; + async_completion init{ + handler}; get_io_service().post( bind_handler(init.completion_handler, ec, bytes_transferred)); return init.result.get(); } - friend - void - teardown(websocket::teardown_tag, + friend void + teardown( + websocket::teardown_tag, string_ostream&, - boost::system::error_code& ec) + boost::system::error_code& ec) { ec.assign(0, ec.category()); } - template - friend - void - async_teardown(websocket::teardown_tag, + template + friend void + async_teardown( + websocket::teardown_tag, string_ostream& stream, - TeardownHandler&& handler) + TeardownHandler&& handler) { stream.get_io_service().post( - bind_handler(std::move(handler), - error_code{})); + bind_handler(std::move(handler), error_code{})); } }; -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/test_allocator.h b/src/ripple/beast/test/test_allocator.h index bc468de2aee..598e22c2766 100644 --- a/src/ripple/beast/test/test_allocator.h +++ b/src/ripple/beast/test/test_allocator.h @@ -25,42 +25,40 @@ struct test_allocator_info std::size_t nselect = 0; test_allocator_info() - : id([] - { - static std::atomic sid(0); - return ++sid; - }()) + : id([] { + static std::atomic sid(0); + return ++sid; + }()) { } }; -template +template class test_allocator; -template +template struct test_allocator_base { }; -template +template struct test_allocator_base { - static - test_allocator - select_on_container_copy_construction(test_allocator< - T, Equal, Assign, Move, Swap, true> const& a) + static test_allocator + select_on_container_copy_construction( + test_allocator const& a) { return test_allocator{}; } }; -template -class test_allocator : public test_allocator_base< - T, Equal, Assign, Move, Swap, Select> +template +class test_allocator + : public test_allocator_base { std::shared_ptr info_; - template + template friend class test_allocator; public: @@ -72,36 +70,32 @@ class test_allocator : public test_allocator_base< using propagate_on_container_move_assignment = std::integral_constant; - using propagate_on_container_swap = - std::integral_constant; + using propagate_on_container_swap = std::integral_constant; - template + template struct rebind { using other = test_allocator; }; - test_allocator() - : info_(std::make_shared()) + test_allocator() : info_(std::make_shared()) { } - test_allocator(test_allocator const& u) noexcept - : info_(u.info_) + test_allocator(test_allocator const& u) noexcept : info_(u.info_) { ++info_->ncopy; } - template - test_allocator(test_allocator const& u) noexcept + template + test_allocator( + test_allocator const& u) noexcept : info_(u.info_) { ++info_->ncopy; } - test_allocator(test_allocator&& t) - : info_(t.info_) + test_allocator(test_allocator&& t) : info_(t.info_) { ++info_->nmove; } @@ -125,8 +119,7 @@ class test_allocator : public test_allocator_base< value_type* allocate(std::size_t n) { - return static_cast( - ::operator new (n*sizeof(value_type))); + return static_cast(::operator new(n * sizeof(value_type))); } void @@ -144,7 +137,7 @@ class test_allocator : public test_allocator_base< bool operator!=(test_allocator const& other) const { - return ! this->operator==(other); + return !this->operator==(other); } std::size_t @@ -160,7 +153,7 @@ class test_allocator : public test_allocator_base< } }; -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/test/yield_to.h b/src/ripple/beast/test/yield_to.h index 03de3e4cb33..9d0f50eebff 100644 --- a/src/ripple/beast/test/yield_to.h +++ b/src/ripple/beast/test/yield_to.h @@ -40,23 +40,19 @@ class enable_yield_to public: /// The type of yield context passed to functions. - using yield_context = - boost::asio::yield_context; + using yield_context = boost::asio::yield_context; - explicit - enable_yield_to(std::size_t concurrency = 1) - : work_(ios_) + explicit enable_yield_to(std::size_t concurrency = 1) : work_(ios_) { threads_.reserve(concurrency); - while(concurrency--) - threads_.emplace_back( - [&]{ ios_.run(); }); + while (concurrency--) + threads_.emplace_back([&] { ios_.run(); }); } ~enable_yield_to() { work_ = boost::none; - for(auto& t : threads_) + for (auto& t : threads_) t.join(); } @@ -79,11 +75,11 @@ class enable_yield_to @param fn... One or more functions to invoke. */ #if BEAST_DOXYGEN - template + template void - yield_to(FN&&... fn) + yield_to(FN&&... fn); #else - template + template void yield_to(F0&& f0, FN&&... fn); #endif @@ -94,41 +90,38 @@ class enable_yield_to { } - template + template void spawn(F0&& f, FN&&... fn); }; -template +template void -enable_yield_to:: -yield_to(F0&& f0, FN&&... fn) +enable_yield_to::yield_to(F0&& f0, FN&&... fn) { running_ = 1 + sizeof...(FN); spawn(f0, fn...); std::unique_lock lock{m_}; - cv_.wait(lock, [&]{ return running_ == 0; }); + cv_.wait(lock, [&] { return running_ == 0; }); } -template -inline -void -enable_yield_to:: -spawn(F0&& f, FN&&... fn) +template +inline void +enable_yield_to::spawn(F0&& f, FN&&... fn) { - boost::asio::spawn(ios_, - [&](yield_context yield) - { + boost::asio::spawn( + ios_, + [&](yield_context yield) { f(yield); std::lock_guard lock{m_}; - if(--running_ == 0) + if (--running_ == 0) cv_.notify_all(); - } - , boost::coroutines::attributes(2 * 1024 * 1024)); + }, + boost::coroutines::attributes(2 * 1024 * 1024)); spawn(fn...); } -} // test -} // beast +} // namespace test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/amount.h b/src/ripple/beast/unit_test/amount.h index a045d4d7554..6f2182f599d 100644 --- a/src/ripple/beast/unit_test/amount.h +++ b/src/ripple/beast/unit_test/amount.h @@ -24,32 +24,29 @@ class amount public: amount(amount const&) = default; - amount& operator=(amount const&) = delete; + amount& + operator=(amount const&) = delete; - template + template amount(std::size_t n, std::string const& what); - friend - std::ostream& + friend std::ostream& operator<<(std::ostream& s, amount const& t); }; -template -amount::amount(std::size_t n, std::string const& what) - : n_(n) - , what_(what) +template +amount::amount(std::size_t n, std::string const& what) : n_(n), what_(what) { } -inline -std::ostream& +inline std::ostream& operator<<(std::ostream& s, amount const& t) { - s << t.n_ << " " << t.what_ <<((t.n_ != 1) ? "s" : ""); + s << t.n_ << " " << t.what_ << ((t.n_ != 1) ? "s" : ""); return s; } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/detail/const_container.h b/src/ripple/beast/unit_test/detail/const_container.h index ed613537de8..b1f089feedf 100644 --- a/src/ripple/beast/unit_test/detail/const_container.h +++ b/src/ripple/beast/unit_test/detail/const_container.h @@ -16,7 +16,7 @@ namespace detail { The interface allows for limited read only operations. Derived classes provide additional behavior. */ -template +template class const_container { private: @@ -25,12 +25,14 @@ class const_container cont_type m_cont; protected: - cont_type& cont() + cont_type& + cont() { return m_cont; } - cont_type const& cont() const + cont_type const& + cont() const { return m_cont; } @@ -84,8 +86,8 @@ class const_container /** @} */ }; -} // detail -} // unit_test -} // beast +} // namespace detail +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/dstream.h b/src/ripple/beast/unit_test/dstream.h index fe02a26edd7..ff2036a12cb 100644 --- a/src/ripple/beast/unit_test/dstream.h +++ b/src/ripple/beast/unit_test/dstream.h @@ -27,37 +27,37 @@ namespace unit_test { namespace detail { -template -class dstream_buf - : public std::basic_stringbuf +template +class dstream_buf : public std::basic_stringbuf { using ostream = std::basic_ostream; bool dbg_; ostream& os_; - template - void write(T const*) = delete; + template + void + write(T const*) = delete; - void write(char const* s) + void + write(char const* s) { - if(dbg_) - /*boost::detail::winapi*/::OutputDebugStringA(s); + if (dbg_) + /*boost::detail::winapi*/ ::OutputDebugStringA(s); os_ << s; } - void write(wchar_t const* s) + void + write(wchar_t const* s) { - if(dbg_) - /*boost::detail::winapi*/::OutputDebugStringW(s); + if (dbg_) + /*boost::detail::winapi*/ ::OutputDebugStringW(s); os_ << s; } public: - explicit - dstream_buf(ostream& os) - : os_(os) - , dbg_(/*boost::detail::winapi*/::IsDebuggerPresent() != 0) + explicit dstream_buf(ostream& os) + : os_(os), dbg_(/*boost::detail::winapi*/ ::IsDebuggerPresent() != 0) { } @@ -75,7 +75,7 @@ class dstream_buf } }; -} // detail +} // namespace detail /** std::ostream with Visual Studio IDE redirection. @@ -84,28 +84,23 @@ class dstream_buf is attached when the stream is created, output will be additionally copied to the Visual Studio Output window. */ -template< +template < class CharT, class Traits = std::char_traits, - class Allocator = std::allocator -> -class basic_dstream - : public std::basic_ostream + class Allocator = std::allocator> +class basic_dstream : public std::basic_ostream { - detail::dstream_buf< - CharT, Traits, Allocator> buf_; + detail::dstream_buf buf_; public: /** Construct a stream. @param os The output stream to wrap. */ - explicit - basic_dstream(std::ostream& os) - : std::basic_ostream(&buf_) - , buf_(os) + explicit basic_dstream(std::ostream& os) + : std::basic_ostream(&buf_), buf_(os) { - if(os.flags() & std::ios::unitbuf) + if (os.flags() & std::ios::unitbuf) std::unitbuf(*this); } }; @@ -120,7 +115,7 @@ using dwstream = std::wostream&; #endif -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/global_suites.h b/src/ripple/beast/unit_test/global_suites.h index b641ed7cb29..d1ee4d17732 100644 --- a/src/ripple/beast/unit_test/global_suites.h +++ b/src/ripple/beast/unit_test/global_suites.h @@ -16,36 +16,37 @@ namespace unit_test { namespace detail { /// Holds test suites registered during static initialization. -inline -suite_list& +inline suite_list& global_suites() { static suite_list s; return s; } -template +template struct insert_suite { - insert_suite(char const* name, char const* module, - char const* library, bool manual, int priority) + insert_suite( + char const* name, + char const* module, + char const* library, + bool manual, + int priority) { - global_suites().insert( - name, module, library, manual, priority); + global_suites().insert(name, module, library, manual, priority); } }; -} // detail +} // namespace detail /// Holds test suites registered during static initialization. -inline -suite_list const& +inline suite_list const& global_suites() { return detail::global_suites(); } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/match.h b/src/ripple/beast/unit_test/match.h index 689b189567d..e5b341b338a 100644 --- a/src/ripple/beast/unit_test/match.h +++ b/src/ripple/beast/unit_test/match.h @@ -18,8 +18,7 @@ namespace unit_test { class selector { public: - enum mode_t - { + enum mode_t { // Run all tests except manual ones all, @@ -45,83 +44,81 @@ class selector std::string library_; public: - template - explicit - selector(mode_t mode, std::string const& pattern = ""); + template + explicit selector(mode_t mode, std::string const& pattern = ""); - template + template bool operator()(suite_info const& s); }; //------------------------------------------------------------------------------ -template +template selector::selector(mode_t mode, std::string const& pattern) - : mode_(mode) - , pat_(pattern) + : mode_(mode), pat_(pattern) { - if(mode_ == automatch && pattern.empty()) + if (mode_ == automatch && pattern.empty()) mode_ = all; } -template +template bool selector::operator()(suite_info const& s) { - switch(mode_) + switch (mode_) { - case automatch: - // suite or full name - if(s.name() == pat_ || s.full_name() == pat_) - { - mode_ = none; - return true; - } - - // check module - if(pat_ == s.module()) - { - mode_ = module; - library_ = s.library(); - return ! s.manual(); - } - - // check library - if(pat_ == s.library()) - { - mode_ = library; - return ! s.manual(); - } - - // check start of name - if (s.name().starts_with(pat_) || s.full_name().starts_with(pat_)) - { - // Don't change the mode so that the partial pattern can match - // more than once - return !s.manual(); - } - - return false; - - case suite: - return pat_ == s.name(); - - case module: - return pat_ == s.module() && ! s.manual(); - - case library: - return pat_ == s.library() && ! s.manual(); - - case none: - return false; - - case all: - default: - break; + case automatch: + // suite or full name + if (s.name() == pat_ || s.full_name() == pat_) + { + mode_ = none; + return true; + } + + // check module + if (pat_ == s.module()) + { + mode_ = module; + library_ = s.library(); + return !s.manual(); + } + + // check library + if (pat_ == s.library()) + { + mode_ = library; + return !s.manual(); + } + + // check start of name + if (s.name().starts_with(pat_) || s.full_name().starts_with(pat_)) + { + // Don't change the mode so that the partial pattern can match + // more than once + return !s.manual(); + } + + return false; + + case suite: + return pat_ == s.name(); + + case module: + return pat_ == s.module() && !s.manual(); + + case library: + return pat_ == s.library() && !s.manual(); + + case none: + return false; + + case all: + default: + break; }; - return ! s.manual(); + return !s.manual(); } //------------------------------------------------------------------------------ @@ -143,38 +140,34 @@ selector::operator()(suite_info const& s) not marked manual are selected from then on. */ -inline -selector +inline selector match_auto(std::string const& name) { return selector(selector::automatch, name); } /** Return a predicate that matches all suites not marked manual. */ -inline -selector +inline selector match_all() { return selector(selector::all); } /** Returns a predicate that matches a specific suite. */ -inline -selector +inline selector match_suite(std::string const& name) { return selector(selector::suite, name); } /** Returns a predicate that matches all suites in a library. */ -inline -selector +inline selector match_library(std::string const& name) { return selector(selector::library, name); } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/recorder.h b/src/ripple/beast/unit_test/recorder.h index c7c543889f0..5aa1f712494 100644 --- a/src/ripple/beast/unit_test/recorder.h +++ b/src/ripple/beast/unit_test/recorder.h @@ -33,58 +33,51 @@ class recorder : public runner } private: - virtual - void + virtual void on_suite_begin(suite_info const& info) override { m_suite = suite_results(info.full_name()); } - virtual - void + virtual void on_suite_end() override { m_results.insert(std::move(m_suite)); } - virtual - void + virtual void on_case_begin(std::string const& name) override { m_case = case_results(name); } - virtual - void + virtual void on_case_end() override { - if(m_case.tests.size() > 0) + if (m_case.tests.size() > 0) m_suite.insert(std::move(m_case)); } - virtual - void + virtual void on_pass() override { m_case.tests.pass(); } - virtual - void + virtual void on_fail(std::string const& reason) override { m_case.tests.fail(reason); } - virtual - void + virtual void on_log(std::string const& s) override { m_case.log.insert(s); } }; -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/reporter.h b/src/ripple/beast/unit_test/reporter.h index 844c321a077..a61ff0460c2 100644 --- a/src/ripple/beast/unit_test/reporter.h +++ b/src/ripple/beast/unit_test/reporter.h @@ -29,7 +29,7 @@ namespace detail { /** A simple test runner that writes everything to a stream in real time. The totals are output when the object is destroyed. */ -template +template class reporter : public runner { private: @@ -41,9 +41,7 @@ class reporter : public runner std::size_t total = 0; std::size_t failed = 0; - explicit - case_results(std::string name_ = "") - : name(std::move(name_)) + explicit case_results(std::string name_ = "") : name(std::move(name_)) { } }; @@ -56,9 +54,7 @@ class reporter : public runner std::size_t failed = 0; typename clock_type::time_point start = clock_type::now(); - explicit - suite_results(std::string name_ = "") - : name(std::move(name_)) + explicit suite_results(std::string name_ = "") : name(std::move(name_)) { } @@ -68,13 +64,9 @@ class reporter : public runner struct results { - using run_time = std::pair; + using run_time = std::pair; - enum - { - max_top = 10 - }; + enum { max_top = 10 }; std::size_t suites = 0; std::size_t cases = 0; @@ -94,85 +86,75 @@ class reporter : public runner public: reporter(reporter const&) = delete; - reporter& operator=(reporter const&) = delete; + reporter& + operator=(reporter const&) = delete; ~reporter(); - explicit - reporter(std::ostream& os = std::cout); + explicit reporter(std::ostream& os = std::cout); private: - static - std::string + static std::string fmtdur(typename clock_type::duration const& d); - virtual - void + virtual void on_suite_begin(suite_info const& info) override; - virtual - void + virtual void on_suite_end() override; - virtual - void + virtual void on_case_begin(std::string const& name) override; - virtual - void + virtual void on_case_end() override; - virtual - void + virtual void on_pass() override; - virtual - void + virtual void on_fail(std::string const& reason) override; - virtual - void + virtual void on_log(std::string const& s) override; }; //------------------------------------------------------------------------------ -template +template void -reporter<_>:: -suite_results::add(case_results const& r) +reporter<_>::suite_results::add(case_results const& r) { ++cases; total += r.total; failed += r.failed; } -template +template void -reporter<_>:: -results::add(suite_results const& r) +reporter<_>::results::add(suite_results const& r) { ++suites; total += r.total; cases += r.cases; failed += r.failed; auto const elapsed = clock_type::now() - r.start; - if(elapsed >= std::chrono::seconds{1}) + if (elapsed >= std::chrono::seconds{1}) { - auto const iter = std::lower_bound(top.begin(), - top.end(), elapsed, - [](run_time const& t1, - typename clock_type::duration const& t2) - { + auto const iter = std::lower_bound( + top.begin(), + top.end(), + elapsed, + [](run_time const& t1, typename clock_type::duration const& t2) { return t1.second > t2; }); - if(iter != top.end()) + if (iter != top.end()) { - if(top.size() == max_top) + if (top.size() == max_top) top.resize(top.size() - 1); top.emplace(iter, r.name, elapsed); } - else if(top.size() < max_top) + else if (top.size() < max_top) { top.emplace_back(r.name, elapsed); } @@ -181,115 +163,100 @@ results::add(suite_results const& r) //------------------------------------------------------------------------------ -template -reporter<_>:: -reporter(std::ostream& os) - : os_(os) +template +reporter<_>::reporter(std::ostream& os) : os_(os) { } -template +template reporter<_>::~reporter() { - if(results_.top.size() > 0) + if (results_.top.size() > 0) { os_ << "Longest suite times:\n"; - for(auto const& i : results_.top) - os_ << std::setw(8) << - fmtdur(i.second) << " " << i.first << '\n'; + for (auto const& i : results_.top) + os_ << std::setw(8) << fmtdur(i.second) << " " << i.first << '\n'; } auto const elapsed = clock_type::now() - results_.start; - os_ << - fmtdur(elapsed) << ", " << - amount{results_.suites, "suite"} << ", " << - amount{results_.cases, "case"} << ", " << - amount{results_.total, "test"} << " total, " << - amount{results_.failed, "failure"} << - std::endl; + os_ << fmtdur(elapsed) << ", " << amount{results_.suites, "suite"} << ", " + << amount{results_.cases, "case"} << ", " + << amount{results_.total, "test"} << " total, " + << amount{results_.failed, "failure"} << std::endl; } -template +template std::string reporter<_>::fmtdur(typename clock_type::duration const& d) { using namespace std::chrono; auto const ms = duration_cast(d); - if(ms < seconds{1}) - return boost::lexical_cast( - ms.count()) + "ms"; + if (ms < seconds{1}) + return boost::lexical_cast(ms.count()) + "ms"; std::stringstream ss; - ss << std::fixed << std::setprecision(1) << - (ms.count()/1000.) << "s"; + ss << std::fixed << std::setprecision(1) << (ms.count() / 1000.) << "s"; return ss.str(); } -template +template void -reporter<_>:: -on_suite_begin(suite_info const& info) +reporter<_>::on_suite_begin(suite_info const& info) { suite_results_ = suite_results{info.full_name()}; } -template +template void reporter<_>::on_suite_end() { results_.add(suite_results_); } -template +template void -reporter<_>:: -on_case_begin(std::string const& name) +reporter<_>::on_case_begin(std::string const& name) { case_results_ = case_results(name); - os_ << suite_results_.name << - (case_results_.name.empty() ? "" : - (" " + case_results_.name)) << std::endl; + os_ << suite_results_.name + << (case_results_.name.empty() ? "" : (" " + case_results_.name)) + << std::endl; } -template +template void -reporter<_>:: -on_case_end() +reporter<_>::on_case_end() { suite_results_.add(case_results_); } -template +template void -reporter<_>:: -on_pass() +reporter<_>::on_pass() { ++case_results_.total; } -template +template void -reporter<_>:: -on_fail(std::string const& reason) +reporter<_>::on_fail(std::string const& reason) { ++case_results_.failed; ++case_results_.total; - os_ << - "#" << case_results_.total << " failed" << - (reason.empty() ? "" : ": ") << reason << std::endl; + os_ << "#" << case_results_.total << " failed" + << (reason.empty() ? "" : ": ") << reason << std::endl; } -template +template void -reporter<_>:: -on_log(std::string const& s) +reporter<_>::on_log(std::string const& s) { os_ << s; } -} // detail +} // namespace detail using reporter = detail::reporter<>; -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/results.h b/src/ripple/beast/unit_test/results.h index 58d6e9c8a83..c9478a7f477 100644 --- a/src/ripple/beast/unit_test/results.h +++ b/src/ripple/beast/unit_test/results.h @@ -23,14 +23,12 @@ class case_results /** Holds the result of evaluating one test condition. */ struct test { - explicit test(bool pass_) - : pass(pass_) + explicit test(bool pass_) : pass(pass_) { } test(bool pass_, std::string const& reason_) - : pass(pass_) - , reason(reason_) + : pass(pass_), reason(reason_) { } @@ -39,15 +37,13 @@ class case_results }; private: - class tests_t - : public detail::const_container > + class tests_t : public detail::const_container> { private: std::size_t failed_; public: - tests_t() - : failed_(0) + tests_t() : failed_(0) { } @@ -81,8 +77,7 @@ class case_results } }; - class log_t - : public detail::const_container > + class log_t : public detail::const_container> { public: /** Insert a string into the log. */ @@ -96,8 +91,7 @@ class case_results std::string name_; public: - explicit case_results(std::string const& name = "") - : name_(name) + explicit case_results(std::string const& name = "") : name_(name) { } @@ -118,8 +112,7 @@ class case_results //-------------------------------------------------------------------------- /** Holds the set of testcase results in a suite. */ -class suite_results - : public detail::const_container > +class suite_results : public detail::const_container> { private: std::string name_; @@ -127,8 +120,7 @@ class suite_results std::size_t failed_ = 0; public: - explicit suite_results(std::string const& name = "") - : name_(name) + explicit suite_results(std::string const& name = "") : name_(name) { } @@ -177,8 +169,7 @@ class suite_results // VFALCO TODO Make this a template class using scoped allocators /** Holds the results of running a set of testsuites. */ -class results - : public detail::const_container > +class results : public detail::const_container> { private: std::size_t m_cases; @@ -186,10 +177,7 @@ class results std::size_t failed_; public: - results() - : m_cases(0) - , total_(0) - , failed_(0) + results() : m_cases(0), total_(0), failed_(0) { } @@ -236,7 +224,7 @@ class results /** @} */ }; -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/runner.h b/src/ripple/beast/unit_test/runner.h index 17fa0b9d7d2..f8d8f99be44 100644 --- a/src/ripple/beast/unit_test/runner.h +++ b/src/ripple/beast/unit_test/runner.h @@ -34,7 +34,8 @@ class runner runner() = default; virtual ~runner() = default; runner(runner const&) = delete; - runner& operator=(runner const&) = delete; + runner& + operator=(runner const&) = delete; /** Set the argument string. @@ -59,7 +60,7 @@ class runner /** Run the specified suite. @return `true` if any conditions failed. */ - template + template bool run(suite_info const& s); @@ -69,7 +70,7 @@ class runner must be convertible to `suite_info`. @return `true` if any conditions failed. */ - template + template bool run(FwdIter first, FwdIter last); @@ -80,14 +81,14 @@ class runner @endcode @return `true` if any conditions failed. */ - template + template bool run_if(FwdIter first, FwdIter last, Pred pred = Pred{}); /** Run all suites in a container. @return `true` if any conditions failed. */ - template + template bool run_each(SequenceContainer const& c); @@ -98,56 +99,49 @@ class runner @endcode @return `true` if any conditions failed. */ - template + template bool run_each_if(SequenceContainer const& c, Pred pred = Pred{}); protected: /// Called when a new suite starts. - virtual - void + virtual void on_suite_begin(suite_info const&) { } /// Called when a suite ends. - virtual - void + virtual void on_suite_end() { } /// Called when a new case starts. - virtual - void + virtual void on_case_begin(std::string const&) { } /// Called when a new case ends. - virtual - void + virtual void on_case_end() { } /// Called for each passing condition. - virtual - void + virtual void on_pass() { } /// Called for each failing condition. - virtual - void + virtual void on_fail(std::string const&) { } /// Called when a test logs output. - virtual - void + virtual void on_log(std::string const&) { } @@ -156,26 +150,26 @@ class runner friend class suite; // Start a new testcase. - template + template void testcase(std::string const& name); - template + template void pass(); - template + template void fail(std::string const& reason); - template + template void log(std::string const& s); }; //------------------------------------------------------------------------------ -template +template bool runner::run(suite_info const& s) { @@ -191,98 +185,98 @@ runner::run(suite_info const& s) return failed_; } -template +template bool runner::run(FwdIter first, FwdIter last) { bool failed(false); - for(;first != last; ++first) + for (; first != last; ++first) failed = run(*first) || failed; return failed; } -template +template bool runner::run_if(FwdIter first, FwdIter last, Pred pred) { bool failed(false); - for(;first != last; ++first) - if(pred(*first)) + for (; first != last; ++first) + if (pred(*first)) failed = run(*first) || failed; return failed; } -template +template bool runner::run_each(SequenceContainer const& c) { bool failed(false); - for(auto const& s : c) + for (auto const& s : c) failed = run(s) || failed; return failed; } -template +template bool runner::run_each_if(SequenceContainer const& c, Pred pred) { bool failed(false); - for(auto const& s : c) - if(pred(s)) + for (auto const& s : c) + if (pred(s)) failed = run(s) || failed; return failed; } -template +template void runner::testcase(std::string const& name) { std::lock_guard lock(mutex_); // Name may not be empty - BOOST_ASSERT(default_ || ! name.empty()); + BOOST_ASSERT(default_ || !name.empty()); // Forgot to call pass or fail BOOST_ASSERT(default_ || cond_); - if(! default_) + if (!default_) on_case_end(); default_ = false; cond_ = false; on_case_begin(name); } -template +template void runner::pass() { std::lock_guard lock(mutex_); - if(default_) + if (default_) testcase(""); on_pass(); cond_ = true; } -template +template void runner::fail(std::string const& reason) { std::lock_guard lock(mutex_); - if(default_) + if (default_) testcase(""); on_fail(reason); failed_ = true; cond_ = true; } -template +template void runner::log(std::string const& s) { std::lock_guard lock(mutex_); - if(default_) + if (default_) testcase(""); on_log(s); } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/suite.h b/src/ripple/beast/unit_test/suite.h index befc9a281dc..6a6c03ccb68 100644 --- a/src/ripple/beast/unit_test/suite.h +++ b/src/ripple/beast/unit_test/suite.h @@ -21,14 +21,12 @@ namespace unit_test { namespace detail { -template -static -std::string -make_reason(String const& reason, - char const* file, int line) +template +static std::string +make_reason(String const& reason, char const* file, int line) { std::string s(reason); - if(! s.empty()) + if (!s.empty()) s.append(": "); namespace fs = boost::filesystem; s.append(fs::path{file}.filename().string()); @@ -38,15 +36,11 @@ make_reason(String const& reason, return s; } -} // detail +} // namespace detail class thread; -enum abort_t -{ - no_abort_on_fail, - abort_on_fail -}; +enum abort_t { no_abort_on_fail, abort_on_fail }; /** A testsuite class. @@ -73,16 +67,13 @@ class suite } }; - template - class log_buf - : public std::basic_stringbuf + template + class log_buf : public std::basic_stringbuf { suite& suite_; public: - explicit - log_buf(suite& self) - : suite_(self) + explicit log_buf(suite& self) : suite_(self) { } @@ -95,27 +86,24 @@ class suite sync() override { auto const& s = this->str(); - if(s.size() > 0) + if (s.size() > 0) suite_.runner_->log(s); this->str(""); return 0; } }; - template< + template < class CharT, class Traits = std::char_traits, - class Allocator = std::allocator - > + class Allocator = std::allocator> class log_os : public std::basic_ostream { log_buf buf_; public: - explicit - log_os(suite& self) - : std::basic_ostream(&buf_) - , buf_(self) + explicit log_os(suite& self) + : std::basic_ostream(&buf_), buf_(self) { } }; @@ -128,9 +116,7 @@ class suite std::stringstream ss_; public: - explicit - testcase_t(suite& self) - : suite_(self) + explicit testcase_t(suite& self) : suite_(self) { } @@ -145,13 +131,12 @@ class suite @param abort Determines if suite continues running after a failure. */ void - operator()(std::string const& name, - abort_t abort = no_abort_on_fail); + operator()(std::string const& name, abort_t abort = no_abort_on_fail); scoped_testcase operator()(abort_t abort); - template + template scoped_testcase operator<<(T const& t); }; @@ -170,22 +155,20 @@ class suite /** Returns the "current" running suite. If no suite is running, nullptr is returned. */ - static - suite* + static suite* this_suite() { return *p_this_suite(); } - suite() - : log(*this) - , testcase(*this) + suite() : log(*this), testcase(*this) { } virtual ~suite() = default; suite(suite const&) = delete; - suite& operator=(suite const&) = delete; + suite& + operator=(suite const&) = delete; /** Invokes the test using the specified runner. @@ -194,12 +177,12 @@ class suite forwarded constructor arguments to the base. Normally this is called by the framework for you. */ - template + template void operator()(runner& r); /** Record a successful test condition. */ - template + template void pass(); @@ -212,11 +195,11 @@ class suite @param line The source code line number where the test failed. */ /** @{ */ - template + template void fail(String const& reason, char const* file, int line); - template + template void fail(std::string const& reason = ""); /** @} */ @@ -239,57 +222,59 @@ class suite @return `true` if the test condition indicates success. */ /** @{ */ - template + template bool expect(Condition const& shouldBeTrue) { return expect(shouldBeTrue, ""); } - template + template bool expect(Condition const& shouldBeTrue, String const& reason); - template + template bool - expect(Condition const& shouldBeTrue, - char const* file, int line) + expect(Condition const& shouldBeTrue, char const* file, int line) { return expect(shouldBeTrue, "", file, line); } - template + template bool - expect(Condition const& shouldBeTrue, - String const& reason, char const* file, int line); + expect( + Condition const& shouldBeTrue, + String const& reason, + char const* file, + int line); /** @} */ // // DEPRECATED // // Expect an exception from f() - template + template bool except(F&& f, String const& reason); - template + template bool except(F&& f) { return except(f, ""); } - template + template bool except(F&& f, String const& reason); - template + template bool except(F&& f) { return except(f, ""); } - template + template bool unexcept(F&& f, String const& reason); - template + template bool unexcept(F&& f) { @@ -305,12 +290,11 @@ class suite // DEPRECATED // @return `true` if the test condition indicates success(a false value) - template + template bool - unexpected(Condition shouldBeFalse, - String const& reason); + unexpected(Condition shouldBeFalse, String const& reason); - template + template bool unexpected(Condition shouldBeFalse) { @@ -320,8 +304,7 @@ class suite private: friend class thread; - static - suite** + static suite** p_this_suite() { static suite* pts = nullptr; @@ -329,14 +312,13 @@ class suite } /** Runs the suite. */ - virtual - void + virtual void run() = 0; void propagate_abort(); - template + template void run(runner& r); }; @@ -351,35 +333,32 @@ class suite::scoped_testcase std::stringstream& ss_; public: - scoped_testcase& operator=(scoped_testcase const&) = delete; + scoped_testcase& + operator=(scoped_testcase const&) = delete; ~scoped_testcase() { auto const& name = ss_.str(); - if(! name.empty()) + if (!name.empty()) suite_.runner_->testcase(name); } - scoped_testcase(suite& self, std::stringstream& ss) - : suite_(self) - , ss_(ss) + scoped_testcase(suite& self, std::stringstream& ss) : suite_(self), ss_(ss) { ss_.clear(); ss_.str({}); } - template - scoped_testcase(suite& self, - std::stringstream& ss, T const& t) - : suite_(self) - , ss_(ss) + template + scoped_testcase(suite& self, std::stringstream& ss, T const& t) + : suite_(self), ss_(ss) { ss_.clear(); ss_.str({}); ss_ << t; } - template + template scoped_testcase& operator<<(T const& t) { @@ -390,37 +369,32 @@ class suite::scoped_testcase //------------------------------------------------------------------------------ -inline -void -suite::testcase_t::operator()( - std::string const& name, abort_t abort) +inline void +suite::testcase_t::operator()(std::string const& name, abort_t abort) { suite_.abort_ = abort == abort_on_fail; suite_.runner_->testcase(name); } -inline -suite::scoped_testcase +inline suite::scoped_testcase suite::testcase_t::operator()(abort_t abort) { suite_.abort_ = abort == abort_on_fail; - return { suite_, ss_ }; + return {suite_, ss_}; } -template -inline -suite::scoped_testcase +template +inline suite::scoped_testcase suite::testcase_t::operator<<(T const& t) { - return { suite_, ss_, t }; + return {suite_, ss_, t}; } //------------------------------------------------------------------------------ -template +template void -suite:: -operator()(runner& r) +suite::operator()(runner& r) { *p_this_suite() = this; try @@ -428,20 +402,18 @@ operator()(runner& r) run(r); *p_this_suite() = nullptr; } - catch(...) + catch (...) { *p_this_suite() = nullptr; throw; } } -template +template bool -suite:: -expect( - Condition const& shouldBeTrue, String const& reason) +suite::expect(Condition const& shouldBeTrue, String const& reason) { - if(shouldBeTrue) + if (shouldBeTrue) { pass(); return true; @@ -450,13 +422,15 @@ expect( return false; } -template +template bool -suite:: -expect(Condition const& shouldBeTrue, - String const& reason, char const* file, int line) +suite::expect( + Condition const& shouldBeTrue, + String const& reason, + char const* file, + int line) { - if(shouldBeTrue) + if (shouldBeTrue) { pass(); return true; @@ -467,10 +441,9 @@ expect(Condition const& shouldBeTrue, // DEPRECATED -template +template bool -suite:: -except(F&& f, String const& reason) +suite::except(F&& f, String const& reason) { try { @@ -478,17 +451,16 @@ except(F&& f, String const& reason) fail(reason); return false; } - catch(...) + catch (...) { pass(); } return true; } -template +template bool -suite:: -except(F&& f, String const& reason) +suite::except(F&& f, String const& reason) { try { @@ -496,17 +468,16 @@ except(F&& f, String const& reason) fail(reason); return false; } - catch(E const&) + catch (E const&) { pass(); } return true; } -template +template bool -suite:: -unexcept(F&& f, String const& reason) +suite::unexcept(F&& f, String const& reason) { try { @@ -514,73 +485,64 @@ unexcept(F&& f, String const& reason) pass(); return true; } - catch(...) + catch (...) { fail(reason); } return false; } -template +template bool -suite:: -unexpected( - Condition shouldBeFalse, String const& reason) +suite::unexpected(Condition shouldBeFalse, String const& reason) { - bool const b = - static_cast(shouldBeFalse); - if(! b) + bool const b = static_cast(shouldBeFalse); + if (!b) pass(); else fail(reason); - return ! b; + return !b; } -template +template void -suite:: -pass() +suite::pass() { propagate_abort(); runner_->pass(); } // ::fail -template +template void -suite:: -fail(std::string const& reason) +suite::fail(std::string const& reason) { propagate_abort(); runner_->fail(reason); - if(abort_) + if (abort_) { aborted_ = true; BOOST_THROW_EXCEPTION(abort_exception()); } } -template +template void -suite:: -fail(String const& reason, char const* file, int line) +suite::fail(String const& reason, char const* file, int line) { fail(detail::make_reason(reason, file, line)); } -inline -void -suite:: -propagate_abort() +inline void +suite::propagate_abort() { - if(abort_ && aborted_) + if (abort_ && aborted_) BOOST_THROW_EXCEPTION(abort_exception()); } -template +template void -suite:: -run(runner& r) +suite::run(runner& r) { runner_ = &r; @@ -588,16 +550,15 @@ run(runner& r) { run(); } - catch(abort_exception const&) + catch (abort_exception const&) { // ends the suite } - catch(std::exception const& e) + catch (std::exception const& e) { - runner_->fail("unhandled exception: " + - std::string(e.what())); + runner_->fail("unhandled exception: " + std::string(e.what())); } - catch(...) + catch (...) { runner_->fail("unhandled exception"); } @@ -616,20 +577,21 @@ run(runner& r) If the condition is false, the file and line number are reported. */ -#define BEAST_EXPECTS(cond, reason) ((cond) ? (pass(), true) : \ - (fail((reason), __FILE__, __LINE__), false)) +#define BEAST_EXPECTS(cond, reason) \ + ((cond) ? (pass(), true) : (fail((reason), __FILE__, __LINE__), false)) #endif -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast //------------------------------------------------------------------------------ // detail: // This inserts the suite with the given manual flag -#define BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,manual,priority) \ - static beast::unit_test::detail::insert_suite \ - Library ## Module ## Class ## _test_instance( \ +#define BEAST_DEFINE_TESTSUITE_INSERT( \ + Class, Module, Library, manual, priority) \ + static beast::unit_test::detail::insert_suite \ + Library##Module##Class##_test_instance( \ #Class, #Module, #Library, manual, priority) //------------------------------------------------------------------------------ @@ -678,21 +640,21 @@ run(runner& r) */ #if BEAST_NO_UNIT_TEST_INLINE -#define BEAST_DEFINE_TESTSUITE(Class,Module,Library) -#define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) -#define BEAST_DEFINE_TESTSUITE_PRIO(Class,Module,Library,Priority) -#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class,Module,Library,Priority) +#define BEAST_DEFINE_TESTSUITE(Class, Module, Library) +#define BEAST_DEFINE_TESTSUITE_MANUAL(Class, Module, Library) +#define BEAST_DEFINE_TESTSUITE_PRIO(Class, Module, Library, Priority) +#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class, Module, Library, Priority) #else #include -#define BEAST_DEFINE_TESTSUITE(Class,Module,Library) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false,0) -#define BEAST_DEFINE_TESTSUITE_MANUAL(Class,Module,Library) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true,0) -#define BEAST_DEFINE_TESTSUITE_PRIO(Class,Module,Library,Priority) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,false,Priority) -#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class,Module,Library,Priority) \ - BEAST_DEFINE_TESTSUITE_INSERT(Class,Module,Library,true,Priority) +#define BEAST_DEFINE_TESTSUITE(Class, Module, Library) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, false, 0) +#define BEAST_DEFINE_TESTSUITE_MANUAL(Class, Module, Library) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, true, 0) +#define BEAST_DEFINE_TESTSUITE_PRIO(Class, Module, Library, Priority) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, false, Priority) +#define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class, Module, Library, Priority) \ + BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, true, Priority) #endif #endif diff --git a/src/ripple/beast/unit_test/suite_info.h b/src/ripple/beast/unit_test/suite_info.h index 0131fb9028e..a7e63d606c8 100644 --- a/src/ripple/beast/unit_test/suite_info.h +++ b/src/ripple/beast/unit_test/suite_info.h @@ -32,12 +32,12 @@ class suite_info public: suite_info( - std::string name, - std::string module, - std::string library, - bool manual, - int priority, - run_type run) + std::string name, + std::string module, + std::string library, + bool manual, + int priority, + run_type run) : name_(std::move(name)) , module_(std::move(module)) , library_(std::move(library)) @@ -86,21 +86,22 @@ class suite_info run_(r); } - friend - bool + friend bool operator<(suite_info const& lhs, suite_info const& rhs) { // we want higher priority suites sorted first, thus the negation // of priority value here - return std::forward_as_tuple(-lhs.priority_, lhs.library_, lhs.module_, lhs.name_) < - std::forward_as_tuple(-rhs.priority_, rhs.library_, rhs.module_, rhs.name_); + return std::forward_as_tuple( + -lhs.priority_, lhs.library_, lhs.module_, lhs.name_) < + std::forward_as_tuple( + -rhs.priority_, rhs.library_, rhs.module_, rhs.name_); } }; //------------------------------------------------------------------------------ /// Convenience for producing suite_info for a given test type. -template +template suite_info make_suite_info( std::string name, @@ -115,14 +116,10 @@ make_suite_info( std::move(library), manual, priority, - [](runner& r) - { - Suite{}(r); - } - ); + [](runner& r) { Suite{}(r); }); } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/suite_list.h b/src/ripple/beast/unit_test/suite_list.h index 1a7e241e98b..5f0541db84e 100644 --- a/src/ripple/beast/unit_test/suite_list.h +++ b/src/ripple/beast/unit_test/suite_list.h @@ -8,19 +8,18 @@ #ifndef BEAST_UNIT_TEST_SUITE_LIST_HPP #define BEAST_UNIT_TEST_SUITE_LIST_HPP -#include #include +#include #include -#include #include +#include #include namespace beast { namespace unit_test { /// A container of test suites. -class suite_list - : public detail::const_container > +class suite_list : public detail::const_container> { private: #ifndef NDEBUG @@ -33,7 +32,7 @@ class suite_list The suite must not already exist. */ - template + template void insert( char const* name, @@ -45,7 +44,7 @@ class suite_list //------------------------------------------------------------------------------ -template +template void suite_list::insert( char const* name, @@ -59,20 +58,19 @@ suite_list::insert( std::string s; s = std::string(library) + "." + module + "." + name; auto const result(names_.insert(s)); - BOOST_ASSERT(result.second); // Duplicate name + BOOST_ASSERT(result.second); // Duplicate name } { - auto const result(classes_.insert( - std::type_index(typeid(Suite)))); - BOOST_ASSERT(result.second); // Duplicate type + auto const result(classes_.insert(std::type_index(typeid(Suite)))); + BOOST_ASSERT(result.second); // Duplicate type } #endif - cont().emplace(make_suite_info( - name, module, library, manual, priority)); + cont().emplace( + make_suite_info(name, module, library, manual, priority)); } -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif diff --git a/src/ripple/beast/unit_test/thread.h b/src/ripple/beast/unit_test/thread.h index 9f02ba5ee28..3fd22a30cbe 100644 --- a/src/ripple/beast/unit_test/thread.h +++ b/src/ripple/beast/unit_test/thread.h @@ -29,31 +29,27 @@ class thread thread() = default; thread(thread const&) = delete; - thread& operator=(thread const&) = delete; + thread& + operator=(thread const&) = delete; - thread(thread&& other) - : s_(other.s_) - , t_(std::move(other.t_)) + thread(thread&& other) : s_(other.s_), t_(std::move(other.t_)) { } - thread& operator=(thread&& other) + thread& + operator=(thread&& other) { s_ = other.s_; t_ = std::move(other.t_); return *this; } - template - explicit - thread(suite& s, F&& f, Args&&... args) - : s_(&s) + template + explicit thread(suite& s, F&& f, Args&&... args) : s_(&s) { std::function b = - std::bind(std::forward(f), - std::forward(args)...); - t_ = std::thread(&thread::run, this, - std::move(b)); + std::bind(std::forward(f), std::forward(args)...); + t_ = std::thread(&thread::run, this, std::move(b)); } bool @@ -68,8 +64,7 @@ class thread return t_.get_id(); } - static - unsigned + static unsigned hardware_concurrency() noexcept { return std::thread::hardware_concurrency(); @@ -97,28 +92,27 @@ class thread private: void - run(std::function f) + run(std::function f) { try { f(); } - catch(suite::abort_exception const&) + catch (suite::abort_exception const&) { } - catch(std::exception const& e) + catch (std::exception const& e) { - s_->fail("unhandled exception: " + - std::string(e.what())); + s_->fail("unhandled exception: " + std::string(e.what())); } - catch(...) + catch (...) { s_->fail("unhandled exception"); } } }; -} // unit_test -} // beast +} // namespace unit_test +} // namespace beast #endif From 0eebe6a5f4246fced516d52b83ec4e7f47373edd Mon Sep 17 00:00:00 2001 From: Pretty Printer Date: Sat, 23 Mar 2024 13:58:11 -0500 Subject: [PATCH 07/16] Rewrite includes $ find src/ripple/ src/test/ -type f -exec sed -i 's:include\s*["<]ripple/\(.*\)\.h\(pp\)\?[">]:include :' {} + --- src/ripple/app/main/Main.cpp | 2 +- src/ripple/app/paths/AMMLiquidity.h | 16 +++++++-------- src/ripple/beast/unit_test.h | 20 +++++++++---------- src/ripple/beast/unit_test/global_suites.h | 2 +- src/ripple/beast/unit_test/match.h | 2 +- src/ripple/beast/unit_test/recorder.h | 4 ++-- src/ripple/beast/unit_test/reporter.h | 4 ++-- src/ripple/beast/unit_test/results.h | 2 +- src/ripple/beast/unit_test/runner.h | 2 +- src/ripple/beast/unit_test/suite.h | 4 ++-- src/ripple/beast/unit_test/suite_list.h | 4 ++-- src/ripple/beast/unit_test/thread.h | 2 +- src/ripple/overlay/impl/TxMetrics.cpp | 4 ++-- src/ripple/overlay/impl/TxMetrics.h | 4 ++-- src/test/app/PayStrand_test.cpp | 2 +- src/test/app/TheoreticalQuality_test.cpp | 2 +- src/test/app/XChain_test.cpp | 2 +- src/test/basics/DetectCrash_test.cpp | 2 +- .../beast/beast_io_latency_probe_test.cpp | 2 +- src/test/beast/define_print.cpp | 6 +++--- src/test/jtx/AMMTest.h | 2 +- src/test/nodestore/Timing_test.cpp | 2 +- src/test/peerfinder/PeerFinder_test.cpp | 2 +- src/test/protocol/ApiVersion_test.cpp | 2 +- src/test/server/ServerStatus_test.cpp | 2 +- src/test/unit_test/multi_runner.cpp | 2 +- src/test/unit_test/multi_runner.h | 4 ++-- 27 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index c806bfb7da5..710e4e9674f 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -35,7 +35,7 @@ #include #ifdef ENABLE_TESTS -#include +#include #include #endif // ENABLE_TESTS diff --git a/src/ripple/app/paths/AMMLiquidity.h b/src/ripple/app/paths/AMMLiquidity.h index f1be112b2d6..60155dbf13f 100644 --- a/src/ripple/app/paths/AMMLiquidity.h +++ b/src/ripple/app/paths/AMMLiquidity.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_TX_AMMLIQUIDITY_H_INCLUDED #define RIPPLE_APP_TX_AMMLIQUIDITY_H_INCLUDED -#include "ripple/app/misc/AMMHelpers.h" -#include "ripple/app/misc/AMMUtils.h" -#include "ripple/app/paths/AMMContext.h" -#include "ripple/basics/Log.h" -#include "ripple/ledger/ReadView.h" -#include "ripple/ledger/View.h" -#include "ripple/protocol/Quality.h" -#include "ripple/protocol/STLedgerEntry.h" +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/beast/unit_test.h b/src/ripple/beast/unit_test.h index b80c188def6..70747ea341b 100644 --- a/src/ripple/beast/unit_test.h +++ b/src/ripple/beast/unit_test.h @@ -20,16 +20,16 @@ #ifndef BEAST_UNIT_TEST_H_INCLUDED #define BEAST_UNIT_TEST_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef BEAST_EXPECT #define BEAST_EXPECT_S1(x) #x diff --git a/src/ripple/beast/unit_test/global_suites.h b/src/ripple/beast/unit_test/global_suites.h index d1ee4d17732..3fcdcc052bf 100644 --- a/src/ripple/beast/unit_test/global_suites.h +++ b/src/ripple/beast/unit_test/global_suites.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_GLOBAL_SUITES_HPP #define BEAST_UNIT_TEST_GLOBAL_SUITES_HPP -#include +#include namespace beast { namespace unit_test { diff --git a/src/ripple/beast/unit_test/match.h b/src/ripple/beast/unit_test/match.h index e5b341b338a..306bc569982 100644 --- a/src/ripple/beast/unit_test/match.h +++ b/src/ripple/beast/unit_test/match.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_MATCH_HPP #define BEAST_UNIT_TEST_MATCH_HPP -#include +#include #include namespace beast { diff --git a/src/ripple/beast/unit_test/recorder.h b/src/ripple/beast/unit_test/recorder.h index 5aa1f712494..439e194c335 100644 --- a/src/ripple/beast/unit_test/recorder.h +++ b/src/ripple/beast/unit_test/recorder.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_RECORDER_HPP #define BEAST_UNIT_TEST_RECORDER_HPP -#include -#include +#include +#include namespace beast { namespace unit_test { diff --git a/src/ripple/beast/unit_test/reporter.h b/src/ripple/beast/unit_test/reporter.h index a61ff0460c2..76b65a8b1e5 100644 --- a/src/ripple/beast/unit_test/reporter.h +++ b/src/ripple/beast/unit_test/reporter.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_REPORTER_HPP #define BEAST_UNIT_TEST_REPORTER_HPP -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/results.h b/src/ripple/beast/unit_test/results.h index c9478a7f477..dd43fb17a72 100644 --- a/src/ripple/beast/unit_test/results.h +++ b/src/ripple/beast/unit_test/results.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_RESULTS_HPP #define BEAST_UNIT_TEST_RESULTS_HPP -#include +#include #include #include diff --git a/src/ripple/beast/unit_test/runner.h b/src/ripple/beast/unit_test/runner.h index f8d8f99be44..bdee7aee5a8 100644 --- a/src/ripple/beast/unit_test/runner.h +++ b/src/ripple/beast/unit_test/runner.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_RUNNER_H_INCLUDED #define BEAST_UNIT_TEST_RUNNER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/suite.h b/src/ripple/beast/unit_test/suite.h index 6a6c03ccb68..23c4c4fad1f 100644 --- a/src/ripple/beast/unit_test/suite.h +++ b/src/ripple/beast/unit_test/suite.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_SUITE_HPP #define BEAST_UNIT_TEST_SUITE_HPP -#include +#include #include #include #include @@ -646,7 +646,7 @@ suite::run(runner& r) #define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class, Module, Library, Priority) #else -#include +#include #define BEAST_DEFINE_TESTSUITE(Class, Module, Library) \ BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, false, 0) #define BEAST_DEFINE_TESTSUITE_MANUAL(Class, Module, Library) \ diff --git a/src/ripple/beast/unit_test/suite_list.h b/src/ripple/beast/unit_test/suite_list.h index 5f0541db84e..a1aed563c71 100644 --- a/src/ripple/beast/unit_test/suite_list.h +++ b/src/ripple/beast/unit_test/suite_list.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_SUITE_LIST_HPP #define BEAST_UNIT_TEST_SUITE_LIST_HPP -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/thread.h b/src/ripple/beast/unit_test/thread.h index 3fd22a30cbe..8b2d024a840 100644 --- a/src/ripple/beast/unit_test/thread.h +++ b/src/ripple/beast/unit_test/thread.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_THREAD_HPP #define BEAST_UNIT_TEST_THREAD_HPP -#include +#include #include #include #include diff --git a/src/ripple/overlay/impl/TxMetrics.cpp b/src/ripple/overlay/impl/TxMetrics.cpp index f77f746b3d1..c9b826e9a36 100644 --- a/src/ripple/overlay/impl/TxMetrics.cpp +++ b/src/ripple/overlay/impl/TxMetrics.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include "ripple/overlay/impl/TxMetrics.h" -#include "ripple/protocol/jss.h" +#include +#include #include diff --git a/src/ripple/overlay/impl/TxMetrics.h b/src/ripple/overlay/impl/TxMetrics.h index a37d7e7a48e..d70cadee1b1 100644 --- a/src/ripple/overlay/impl/TxMetrics.h +++ b/src/ripple/overlay/impl/TxMetrics.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_OVERLAY_TXMETRICS_H_INCLUDED #define RIPPLE_OVERLAY_TXMETRICS_H_INCLUDED -#include "ripple/json/json_value.h" -#include "ripple/protocol/messages.h" +#include +#include #include diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 55c15e54fc0..ae17b8e0d43 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -15,6 +15,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include "ripple/app/paths/AMMContext.h" #include #include diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index b76ea723542..ae537a45657 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include "ripple/app/paths/AMMContext.h" #include #include diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index e2816f06096..a0837782a9c 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/test/basics/DetectCrash_test.cpp b/src/test/basics/DetectCrash_test.cpp index 300c9485272..70f0bdb83be 100644 --- a/src/test/basics/DetectCrash_test.cpp +++ b/src/test/basics/DetectCrash_test.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include diff --git a/src/test/beast/beast_io_latency_probe_test.cpp b/src/test/beast/beast_io_latency_probe_test.cpp index b2bf67b10b9..32206ced7f7 100644 --- a/src/test/beast/beast_io_latency_probe_test.cpp +++ b/src/test/beast/beast_io_latency_probe_test.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/test/beast/define_print.cpp b/src/test/beast/define_print.cpp index af51aeee55f..3f527907a3f 100644 --- a/src/test/beast/define_print.cpp +++ b/src/test/beast/define_print.cpp @@ -5,9 +5,9 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include -#include -#include +#include +#include +#include #include // Include this .cpp in your project to gain access to the printing suite diff --git a/src/test/jtx/AMMTest.h b/src/test/jtx/AMMTest.h index ad831d110e0..7831713382f 100644 --- a/src/test/jtx/AMMTest.h +++ b/src/test/jtx/AMMTest.h @@ -19,7 +19,7 @@ #ifndef RIPPLE_TEST_JTX_AMMTEST_H_INCLUDED #define RIPPLE_TEST_JTX_AMMTEST_H_INCLUDED -#include +#include #include #include #include diff --git a/src/test/nodestore/Timing_test.cpp b/src/test/nodestore/Timing_test.cpp index 931ad798831..61cfb0994dc 100644 --- a/src/test/nodestore/Timing_test.cpp +++ b/src/test/nodestore/Timing_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/test/peerfinder/PeerFinder_test.cpp b/src/test/peerfinder/PeerFinder_test.cpp index daa316e566c..feabe69b647 100644 --- a/src/test/peerfinder/PeerFinder_test.cpp +++ b/src/test/peerfinder/PeerFinder_test.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/test/protocol/ApiVersion_test.cpp b/src/test/protocol/ApiVersion_test.cpp index f4aba9e9966..81ff0184e1e 100644 --- a/src/test/protocol/ApiVersion_test.cpp +++ b/src/test/protocol/ApiVersion_test.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index 684532c4fc2..249b0fd4512 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index c1111e4cfeb..cd84c3c999f 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include diff --git a/src/test/unit_test/multi_runner.h b/src/test/unit_test/multi_runner.h index 57d6d33f9e2..c003a99f998 100644 --- a/src/test/unit_test/multi_runner.h +++ b/src/test/unit_test/multi_runner.h @@ -20,8 +20,8 @@ #ifndef TEST_UNIT_TEST_MULTI_RUNNER_H #define TEST_UNIT_TEST_MULTI_RUNNER_H -#include -#include +#include +#include #include #include From 35fe9570206585f4b21f8f387343cf594f8d2500 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Mon, 25 Mar 2024 15:37:01 -0500 Subject: [PATCH 08/16] Fix source lists --- Builds/CMake/RippledCore.cmake | 56 ++++++++++++++++------------------ CMakeLists.txt | 1 - 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index b3db53b22dd..bf4c3fdea9d 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -88,16 +88,23 @@ target_sources (xrpl_core PRIVATE target_sources (xrpl_core PRIVATE #[===============================[ main sources: - subdir: basics (partial) + subdir: basics #]===============================] + src/ripple/basics/impl/Archive.cpp src/ripple/basics/impl/base64.cpp + src/ripple/basics/impl/BasicConfig.cpp src/ripple/basics/impl/contract.cpp src/ripple/basics/impl/CountedObject.cpp src/ripple/basics/impl/FileUtilities.cpp src/ripple/basics/impl/IOUAmount.cpp src/ripple/basics/impl/Log.cpp + src/ripple/basics/impl/make_SSLContext.cpp + src/ripple/basics/impl/mulDiv.cpp src/ripple/basics/impl/Number.cpp + src/ripple/basics/impl/partitioned_unordered_map.cpp + src/ripple/basics/impl/ResolverAsio.cpp src/ripple/basics/impl/StringUtilities.cpp + src/ripple/basics/impl/UptimeClock.cpp #[===============================[ main sources: subdir: json @@ -166,6 +173,20 @@ target_sources (xrpl_core PRIVATE src/ripple/protocol/impl/NFTSyntheticSerializer.cpp src/ripple/protocol/impl/NFTokenID.cpp src/ripple/protocol/impl/NFTokenOfferID.cpp + #[===============================[ + main sources: + subdir: resource + #]===============================] + src/ripple/resource/impl/Charge.cpp + src/ripple/resource/impl/Consumer.cpp + src/ripple/resource/impl/Fees.cpp + src/ripple/resource/impl/ResourceManager.cpp + #[===============================[ + main sources: + subdir: server + #]===============================] + src/ripple/server/impl/JSONRPCUtil.cpp + src/ripple/server/impl/Port.cpp #[===============================[ main sources: subdir: crypto @@ -190,14 +211,15 @@ target_compile_options (xrpl_core $<$:-Wno-maybe-uninitialized>) target_link_libraries (xrpl_core PUBLIC + date::date + ed25519::ed25519 + LibArchive::LibArchive OpenSSL::Crypto Ripple::boost + Ripple::opts Ripple::syslibs secp256k1::secp256k1 - ed25519::ed25519 xrpl.libpb - date::date - Ripple::opts xxHash::xxhash) #[=================================[ main/core headers installation @@ -612,17 +634,6 @@ target_sources (rippled PRIVATE src/ripple/app/tx/impl/apply.cpp src/ripple/app/tx/impl/applySteps.cpp src/ripple/app/tx/impl/details/NFTokenUtils.cpp - #[===============================[ - main sources: - subdir: basics (partial) - #]===============================] - src/ripple/basics/impl/Archive.cpp - src/ripple/basics/impl/BasicConfig.cpp - src/ripple/basics/impl/ResolverAsio.cpp - src/ripple/basics/impl/UptimeClock.cpp - src/ripple/basics/impl/make_SSLContext.cpp - src/ripple/basics/impl/mulDiv.cpp - src/ripple/basics/impl/partitioned_unordered_map.cpp #[===============================[ main sources: subdir: conditions @@ -723,14 +734,6 @@ target_sources (rippled PRIVATE src/ripple/peerfinder/impl/PeerfinderManager.cpp src/ripple/peerfinder/impl/SlotImp.cpp src/ripple/peerfinder/impl/SourceStrings.cpp - #[===============================[ - main sources: - subdir: resource - #]===============================] - src/ripple/resource/impl/Charge.cpp - src/ripple/resource/impl/Consumer.cpp - src/ripple/resource/impl/Fees.cpp - src/ripple/resource/impl/ResourceManager.cpp #[===============================[ main sources: subdir: rpc @@ -817,13 +820,6 @@ target_sources (rippled PRIVATE subdir: perflog #]===============================] src/ripple/perflog/impl/PerfLogImp.cpp - - #[===============================[ - main sources: - subdir: server - #]===============================] - src/ripple/server/impl/JSONRPCUtil.cpp - src/ripple/server/impl/Port.cpp #[===============================[ main sources: subdir: shamap diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a099195020..dcb493e5293 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,6 @@ find_package(xxHash REQUIRED) target_link_libraries(ripple_libs INTERFACE ed25519::ed25519 - LibArchive::LibArchive lz4::lz4 OpenSSL::Crypto OpenSSL::SSL From 985c80fbc6131f3a8cedd0da7e8af98dfceb13c7 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Mon, 25 Mar 2024 15:37:13 -0500 Subject: [PATCH 09/16] Add markers around source lists --- Builds/CMake/RippledCore.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake index bf4c3fdea9d..6b7b2aae683 100644 --- a/Builds/CMake/RippledCore.cmake +++ b/Builds/CMake/RippledCore.cmake @@ -65,6 +65,7 @@ add_library(xrpl::libxrpl ALIAS libxrpl) beast/legacy FILES: TODO: review these sources for removal or replacement #]===============================] +# BEGIN LIBXRPL SOURCES target_sources (xrpl_core PRIVATE src/ripple/beast/clock/basic_seconds_clock.cpp src/ripple/beast/core/CurrentThreadName.cpp @@ -194,6 +195,7 @@ target_sources (xrpl_core PRIVATE src/ripple/crypto/impl/RFC1751.cpp src/ripple/crypto/impl/csprng.cpp src/ripple/crypto/impl/secure_erase.cpp) +# END LIBXRPL SOURCES add_library (Ripple::xrpl_core ALIAS xrpl_core) target_include_directories (xrpl_core @@ -224,6 +226,7 @@ target_link_libraries (xrpl_core #[=================================[ main/core headers installation #]=================================] +# BEGIN LIBXRPL HEADERS install ( FILES src/ripple/basics/Archive.h @@ -484,6 +487,7 @@ install ( src/ripple/beast/utility/Zero.h src/ripple/beast/utility/rngfill.h DESTINATION include/ripple/beast/utility) +# END LIBXRPL HEADERS #[===================================================================[ rippled executable #]===================================================================] @@ -500,6 +504,7 @@ endif () if (tests) target_compile_definitions(rippled PUBLIC ENABLE_TESTS) endif() +# BEGIN XRPLD SOURCES target_sources (rippled PRIVATE #[===============================[ main sources: @@ -833,6 +838,7 @@ target_sources (rippled PRIVATE src/ripple/shamap/impl/SHAMapSync.cpp src/ripple/shamap/impl/SHAMapTreeNode.cpp src/ripple/shamap/impl/ShardFamily.cpp) +# END XRPLD SOURCES #[===============================[ test sources: From 513842b23fcda9b6a8781fccfab8539d510d7d8e Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 29 Mar 2024 19:03:46 -0500 Subject: [PATCH 10/16] Address compiler warnings --- src/ripple/protocol/impl/SecretKey.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/protocol/impl/SecretKey.cpp b/src/ripple/protocol/impl/SecretKey.cpp index 63661888f48..e83068610c9 100644 --- a/src/ripple/protocol/impl/SecretKey.cpp +++ b/src/ripple/protocol/impl/SecretKey.cpp @@ -191,7 +191,7 @@ class Generator auto gsk = [this, tweak = calculateTweak(ordinal)]() { auto rpk = root_; - if (secp256k1_ec_privkey_tweak_add( + if (secp256k1_ec_seckey_tweak_add( secp256k1Context(), rpk.data(), tweak.data()) == 1) { SecretKey sk{Slice{rpk.data(), rpk.size()}}; From b84f7e7c1022df82da33cc5db39632c3e2be44b2 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 19 Apr 2024 09:17:15 -0500 Subject: [PATCH 11/16] Ignore more commits --- .git-blame-ignore-revs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index eba2b99e209..de2d90d36ec 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -2,3 +2,7 @@ # To use it by default in git blame: # git config blame.ignoreRevsFile .git-blame-ignore-revs 50760c693510894ca368e90369b0cc2dabfd07f3 +e2384885f5f630c8f0ffe4bf21a169b433a16858 +241b9ddde9e11beb7480600fd5ed90e1ef109b21 +760f16f56835663d9286bd29294d074de26a7ba6 +0eebe6a5f4246fced516d52b83ec4e7f47373edd From e9859ac1b16f8ab275955e89c05108f366327fd4 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Wed, 24 Apr 2024 13:54:46 -0400 Subject: [PATCH 12/16] test: Add RPC error checking support to unit tests (#4987) --- src/test/app/MultiSign_test.cpp | 11 +++- src/test/app/Regression_test.cpp | 4 +- src/test/app/TxQ_test.cpp | 9 +-- src/test/jtx.h | 1 + src/test/jtx/Env.h | 19 +++++- src/test/jtx/Env_test.cpp | 9 ++- src/test/jtx/JTx.h | 3 + src/test/jtx/impl/Env.cpp | 106 +++++++++++++++++++++++-------- src/test/jtx/rpc.h | 86 +++++++++++++++++++++++++ src/test/protocol/Memo_test.cpp | 27 ++++++-- 10 files changed, 230 insertions(+), 45 deletions(-) create mode 100644 src/test/jtx/rpc.h diff --git a/src/test/app/MultiSign_test.cpp b/src/test/app/MultiSign_test.cpp index 6e918e36c79..0e151b38d0a 100644 --- a/src/test/app/MultiSign_test.cpp +++ b/src/test/app/MultiSign_test.cpp @@ -250,7 +250,8 @@ class MultiSign_test : public beast::unit_test::suite env(noop(alice), msig(demon, demon), fee(3 * baseFee), - ter(telENV_RPC_FAILED)); + rpc("invalidTransaction", + "fails local checks: Duplicate Signers not allowed.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); @@ -361,7 +362,10 @@ class MultiSign_test : public beast::unit_test::suite msig phantoms{bogie, demon}; std::reverse(phantoms.signers.begin(), phantoms.signers.end()); std::uint32_t const aliceSeq = env.seq(alice); - env(noop(alice), phantoms, ter(telENV_RPC_FAILED)); + env(noop(alice), + phantoms, + rpc("invalidTransaction", + "fails local checks: Unsorted Signers array.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); } @@ -1640,7 +1644,8 @@ class MultiSign_test : public beast::unit_test::suite env(noop(alice), msig(demon, demon), fee(3 * baseFee), - ter(telENV_RPC_FAILED)); + rpc("invalidTransaction", + "fails local checks: Duplicate Signers not allowed.")); env.close(); BEAST_EXPECT(env.seq(alice) == aliceSeq); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index e2c4b355a9d..f743a30f079 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -149,7 +149,9 @@ struct Regression_test : public beast::unit_test::suite secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob); jt.stx.reset(secp256r1Sig.release()); - env(jt, ter(telENV_RPC_FAILED)); + env(jt, + rpc("invalidTransaction", + "fails local checks: Invalid signature.")); }; Account const alice{"alice", KeyType::secp256k1}; diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 4ddb15a1454..086bb787d68 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -1058,16 +1058,17 @@ class TxQPosNegFlows_test : public beast::unit_test::suite auto const& jt = env.jt(noop(alice)); BEAST_EXPECT(jt.stx); - bool didApply; - TER ter; + Env::ParsedResult parsed; env.app().openLedger().modify( [&](OpenView& view, beast::Journal j) { - std::tie(ter, didApply) = ripple::apply( + // No need to initialize, since it's about to get set + bool didApply; + std::tie(parsed.ter, didApply) = ripple::apply( env.app(), view, *jt.stx, tapNONE, env.journal); return didApply; }); - env.postconditions(jt, ter, didApply); + env.postconditions(jt, parsed); } checkMetrics(__LINE__, env, 1, std::nullopt, 4, 2, 256); diff --git a/src/test/jtx.h b/src/test/jtx.h index 03bbf154e63..e6651fc1f0d 100644 --- a/src/test/jtx.h +++ b/src/test/jtx.h @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index 69640179b11..0f21bff9fb6 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -120,6 +120,20 @@ class Env Account const& master = Account::master; + /// Used by parseResult() and postConditions() + struct ParsedResult + { + std::optional ter{}; + // RPC errors tend to return either a "code" and a "message" (sometimes + // with an "error" that corresponds to the "code"), or with an "error" + // and an "exception". However, this structure allows all possible + // combinations. + std::optional rpcCode{}; + std::string rpcMessage; + std::string rpcError; + std::string rpcException; + }; + private: struct AppBundle { @@ -493,7 +507,7 @@ class Env /** Gets the TER result and `didApply` flag from a RPC Json result object. */ - static std::pair + static ParsedResult parseResult(Json::Value const& jr); /** Submit an existing JTx. @@ -514,8 +528,7 @@ class Env void postconditions( JTx const& jt, - TER ter, - bool didApply, + ParsedResult const& parsed, Json::Value const& jr = Json::Value()); /** Apply funclets and submit. */ diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index 8a42b554b8e..5c08469e0b8 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -747,9 +747,12 @@ class Env_test : public beast::unit_test::suite // Force the factor low enough to fail params[jss::fee_mult_max] = 1; params[jss::fee_div_max] = 2; - // RPC errors result in telENV_RPC_FAILED - envs(noop(alice), fee(none), seq(none), ter(telENV_RPC_FAILED))( - params); + envs( + noop(alice), + fee(none), + seq(none), + rpc(rpcHIGH_FEE, + "Fee of 10 exceeds the requested tx limit of 5"))(params); auto tx = env.tx(); BEAST_EXPECT(!tx); diff --git a/src/test/jtx/JTx.h b/src/test/jtx/JTx.h index 5f73c25f4e7..06b68dda336 100644 --- a/src/test/jtx/JTx.h +++ b/src/test/jtx/JTx.h @@ -44,6 +44,9 @@ struct JTx Json::Value jv; requires_t require; std::optional ter = TER{tesSUCCESS}; + std::optional> rpcCode = std::nullopt; + std::optional>> + rpcException = std::nullopt; bool fill_fee = true; bool fill_seq = true; bool fill_sig = true; diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 17d2d511846..884caf9162e 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -272,24 +272,48 @@ Env::trust(STAmount const& amount, Account const& account) test.expect(balance(account) == start); } -std::pair +Env::ParsedResult Env::parseResult(Json::Value const& jr) { - TER ter; - if (jr.isObject() && jr.isMember(jss::result) && - jr[jss::result].isMember(jss::engine_result_code)) - ter = TER::fromInt(jr[jss::result][jss::engine_result_code].asInt()); + auto error = [](ParsedResult& parsed, Json::Value const& object) { + // Use an error code that is not used anywhere in the transaction + // engine to distinguish this case. + parsed.ter = telENV_RPC_FAILED; + // Extract information about the error + if (!object.isObject()) + return; + if (object.isMember(jss::error_code)) + parsed.rpcCode = + safe_cast(object[jss::error_code].asInt()); + if (object.isMember(jss::error_message)) + parsed.rpcMessage = object[jss::error_message].asString(); + if (object.isMember(jss::error)) + parsed.rpcError = object[jss::error].asString(); + if (object.isMember(jss::error_exception)) + parsed.rpcException = object[jss::error_exception].asString(); + }; + ParsedResult parsed; + if (jr.isObject() && jr.isMember(jss::result)) + { + auto const& result = jr[jss::result]; + if (result.isMember(jss::engine_result_code)) + { + parsed.ter = TER::fromInt(result[jss::engine_result_code].asInt()); + parsed.rpcCode.emplace(rpcSUCCESS); + } + else + error(parsed, result); + } else - // Use an error code that is not used anywhere in the transaction engine - // to distinguish this case. - ter = telENV_RPC_FAILED; - return std::make_pair(ter, isTesSuccess(ter) || isTecClaim(ter)); + error(parsed, jr); + + return parsed; } void Env::submit(JTx const& jt) { - bool didApply; + ParsedResult parsedResult; auto const jr = [&]() { if (jt.stx) { @@ -298,7 +322,9 @@ Env::submit(JTx const& jt) jt.stx->add(s); auto const jr = rpc("submit", strHex(s.slice())); - std::tie(ter_, didApply) = parseResult(jr); + parsedResult = parseResult(jr); + test.expect(parsedResult.ter, "ter uninitialized!"); + ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED); return jr; } @@ -306,20 +332,17 @@ Env::submit(JTx const& jt) { // Parsing failed or the JTx is // otherwise missing the stx field. - ter_ = temMALFORMED; - didApply = false; + parsedResult.ter = ter_ = temMALFORMED; return Json::Value(); } }(); - return postconditions(jt, ter_, didApply, jr); + return postconditions(jt, parsedResult, jr); } void Env::sign_and_submit(JTx const& jt, Json::Value params) { - bool didApply; - auto const account = lookup(jt.jv[jss::Account].asString()); auto const& passphrase = account.name(); @@ -348,24 +371,55 @@ Env::sign_and_submit(JTx const& jt, Json::Value params) if (!txid_.parseHex(jr[jss::result][jss::tx_json][jss::hash].asString())) txid_.zero(); - std::tie(ter_, didApply) = parseResult(jr); + ParsedResult const parsedResult = parseResult(jr); + test.expect(parsedResult.ter, "ter uninitialized!"); + ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED); - return postconditions(jt, ter_, didApply, jr); + return postconditions(jt, parsedResult, jr); } void Env::postconditions( JTx const& jt, - TER ter, - bool didApply, + ParsedResult const& parsed, Json::Value const& jr) { - if (jt.ter && - !test.expect( - ter == *jt.ter, - "apply: Got " + transToken(ter) + " (" + transHuman(ter) + - "); Expected " + transToken(*jt.ter) + " (" + - transHuman(*jt.ter) + ")")) + bool bad = !test.expect(parsed.ter, "apply: No ter result!"); + bad = + (jt.ter && parsed.ter && + !test.expect( + *parsed.ter == *jt.ter, + "apply: Got " + transToken(*parsed.ter) + " (" + + transHuman(*parsed.ter) + "); Expected " + + transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")")); + using namespace std::string_literals; + bad = (jt.rpcCode && + !test.expect( + parsed.rpcCode == jt.rpcCode->first && + parsed.rpcMessage == jt.rpcCode->second, + "apply: Got RPC result "s + + (parsed.rpcCode + ? RPC::get_error_info(*parsed.rpcCode).token.c_str() + : "NO RESULT") + + " (" + parsed.rpcMessage + "); Expected " + + RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" + + jt.rpcCode->second + ")")) || + bad; + // If we have an rpcCode (just checked), then the rpcException check is + // optional - the 'error' field may not be defined, but if it is, it must + // match rpcError. + bad = + (jt.rpcException && + !test.expect( + (jt.rpcCode && parsed.rpcError.empty()) || + (parsed.rpcError == jt.rpcException->first && + (!jt.rpcException->second || + parsed.rpcException == *jt.rpcException->second)), + "apply: Got RPC result "s + parsed.rpcError + " (" + + parsed.rpcException + "); Expected " + jt.rpcException->first + + " (" + jt.rpcException->second.value_or("n/a") + ")")) || + bad; + if (bad) { test.log << pretty(jt.jv) << std::endl; if (jr) diff --git a/src/test/jtx/rpc.h b/src/test/jtx/rpc.h new file mode 100644 index 00000000000..f9962849698 --- /dev/null +++ b/src/test/jtx/rpc.h @@ -0,0 +1,86 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2024 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_TEST_JTX_RPC_H_INCLUDED +#define RIPPLE_TEST_JTX_RPC_H_INCLUDED + +#include +#include + +namespace ripple { +namespace test { +namespace jtx { + +/** Set the expected result code for a JTx + The test will fail if the code doesn't match. +*/ +class rpc +{ +private: + std::optional code_; + std::optional errorMessage_; + std::optional error_; + std::optional errorException_; + +public: + /// If there's an error code, we expect an error message + explicit rpc(error_code_i code, std::optional m = {}) + : code_(code), errorMessage_(m) + { + } + + /// If there is not a code, we expect an exception message + explicit rpc( + std::string error, + std::optional exceptionMessage = {}) + : error_(error), errorException_(exceptionMessage) + { + } + + void + operator()(Env&, JTx& jt) const + { + // The RPC request should fail. RPC errors result in telENV_RPC_FAILED. + jt.ter = telENV_RPC_FAILED; + if (code_) + { + auto const& errorInfo = RPC::get_error_info(*code_); + // When an RPC request returns an error code ('error_code'), it + // always includes an error message ('error_message'), and sometimes + // includes an error token ('error'). If it does, the error token is + // always obtained from the lookup into the ErrorInfo lookup table. + // + // Take advantage of that fact to populate jt.rpcException. The + // check will be aware of whether the rpcExcpetion can be safely + // ignored. + jt.rpcCode = { + *code_, + errorMessage_ ? *errorMessage_ : errorInfo.message.c_str()}; + jt.rpcException = {errorInfo.token.c_str(), std::nullopt}; + } + if (error_) + jt.rpcException = {*error_, errorException_}; + } +}; + +} // namespace jtx +} // namespace test +} // namespace ripple + +#endif diff --git a/src/test/protocol/Memo_test.cpp b/src/test/protocol/Memo_test.cpp index 89ae6dfe18a..e119ee76eec 100644 --- a/src/test/protocol/Memo_test.cpp +++ b/src/test/protocol/Memo_test.cpp @@ -56,7 +56,10 @@ class Memo_test : public beast::unit_test::suite JTx memoSize = makeJtxWithMemo(); memoSize.jv[sfMemos.jsonName][0u][sfMemo.jsonName] [sfMemoData.jsonName] = std::string(2020, '0'); - env(memoSize, ter(telENV_RPC_FAILED)); + env(memoSize, + rpc("invalidTransaction", + "fails local checks: The memo exceeds the maximum allowed " + "size.")); // This memo is just barely small enough. memoSize.jv[sfMemos.jsonName][0u][sfMemo.jsonName] @@ -72,7 +75,10 @@ class Memo_test : public beast::unit_test::suite auto& m = mi[sfCreatedNode.jsonName]; // CreatedNode in Memos m[sfMemoData.jsonName] = "3030303030"; - env(memoNonMemo, ter(telENV_RPC_FAILED)); + env(memoNonMemo, + rpc("invalidTransaction", + "fails local checks: A memo array may contain only Memo " + "objects.")); } { // Put an invalid field in a Memo object. @@ -80,7 +86,10 @@ class Memo_test : public beast::unit_test::suite memoExtra .jv[sfMemos.jsonName][0u][sfMemo.jsonName][sfFlags.jsonName] = 13; - env(memoExtra, ter(telENV_RPC_FAILED)); + env(memoExtra, + rpc("invalidTransaction", + "fails local checks: A memo may contain only MemoType, " + "MemoData or MemoFormat fields.")); } { // Put a character that is not allowed in a URL in a MemoType field. @@ -88,7 +97,11 @@ class Memo_test : public beast::unit_test::suite memoBadChar.jv[sfMemos.jsonName][0u][sfMemo.jsonName] [sfMemoType.jsonName] = strHex(std::string_view("ONE Date: Fri, 26 Apr 2024 01:05:12 +0800 Subject: [PATCH 13/16] chore: fix typos (#4958) --- src/ripple/app/misc/TxQ.h | 2 +- src/ripple/app/paths/impl/Steps.h | 2 +- src/ripple/app/reporting/ETLSource.cpp | 2 +- src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ripple/app/misc/TxQ.h b/src/ripple/app/misc/TxQ.h index c7bd1f1d3d7..7be29b49021 100644 --- a/src/ripple/app/misc/TxQ.h +++ b/src/ripple/app/misc/TxQ.h @@ -322,7 +322,7 @@ class TxQ /** * @brief Returns minimum required fee for tx and two sequences: - * first vaild sequence for this account in current ledger + * first valid sequence for this account in current ledger * and first available sequence for transaction * @param view current open ledger * @param tx the transaction diff --git a/src/ripple/app/paths/impl/Steps.h b/src/ripple/app/paths/impl/Steps.h index 1ae2273929d..033b9696f1d 100644 --- a/src/ripple/app/paths/impl/Steps.h +++ b/src/ripple/app/paths/impl/Steps.h @@ -417,7 +417,7 @@ toStrand( quality of the tip of the book drops below this value, then evaluating the strand can stop. @param sendMax Optional asset to send. - @param paths Paths to use to fullfill the payment. Each path in the pathset + @param paths Paths to use to fulfill the payment. Each path in the pathset contains an ordered collection of the offer books to use and accounts to ripple through. @param addDefaultPath Determines if the default path should be included diff --git a/src/ripple/app/reporting/ETLSource.cpp b/src/ripple/app/reporting/ETLSource.cpp index be31f4fdfa9..73ba9816950 100644 --- a/src/ripple/app/reporting/ETLSource.cpp +++ b/src/ripple/app/reporting/ETLSource.cpp @@ -27,7 +27,7 @@ namespace ripple { // Create ETL source without grpc endpoint // Fetch ledger and load initial ledger will fail for this source -// Primarly used in read-only mode, to monitor when ledgers are validated +// Primarily used in read-only mode, to monitor when ledgers are validated ETLSource::ETLSource(std::string ip, std::string wsPort, ReportingETL& etl) : ip_(ip) , wsPort_(wsPort) diff --git a/src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp b/src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp index 02471c1d482..3b6aaf60ea1 100644 --- a/src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp +++ b/src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp @@ -259,7 +259,7 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx) // We also _must not_ check the tx submitter in brokered // mode, because then we are confirming that the broker can // cover what the buyer will pay, which doesn't make sense, causes - // an unncessary tec, and is also resolved with this amendment. + // an unnecessary tec, and is also resolved with this amendment. if (accountFunds( ctx.view, ctx.tx[sfAccount], From b65cea1984248ee5fa2fc02015914d543820902e Mon Sep 17 00:00:00 2001 From: seelabs Date: Thu, 18 Apr 2024 17:12:05 -0400 Subject: [PATCH 14/16] Add global access to the current ledger rules: It can be difficult to make transaction breaking changes to low level code because the low level code does not have access to a ledger and the current activated amendments in that ledger (the "rules"). This patch adds global access to the current ledger rules as a `std::optional`. If the optional is not seated, then there is no active transaction. --- src/ripple/app/tx/impl/Transactor.cpp | 3 +++ src/ripple/protocol/Rules.h | 37 +++++++++++++++++++++++++++ src/ripple/protocol/impl/Rules.cpp | 25 ++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 1affb6fcc56..7dcf3f15ab7 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -831,8 +831,11 @@ Transactor::operator()() { JLOG(j_.trace()) << "apply: " << ctx_.tx.getTransactionID(); + // raii classes for the current ledger rules. fixSTAmountCanonicalize and + // fixSTAmountCanonicalize predate the rulesGuard and should be replaced. STAmountSO stAmountSO{view().rules().enabled(fixSTAmountCanonicalize)}; NumberSO stNumberSO{view().rules().enabled(fixUniversalNumber)}; + CurrentTransactionRulesGuard currentTransctionRulesGuard(view().rules()); #ifdef DEBUG { diff --git a/src/ripple/protocol/Rules.h b/src/ripple/protocol/Rules.h index 52d01c6f589..f8ff8c00c0c 100644 --- a/src/ripple/protocol/Rules.h +++ b/src/ripple/protocol/Rules.h @@ -23,6 +23,7 @@ #include #include #include + #include namespace ripple { @@ -42,9 +43,14 @@ class Rules public: Rules(Rules const&) = default; + Rules(Rules&&) = default; + Rules& operator=(Rules const&) = default; + Rules& + operator=(Rules&&) = default; + Rules() = delete; /** Construct an empty rule set. @@ -90,5 +96,36 @@ class Rules operator!=(Rules const& other) const; }; +std::optional const& +getCurrentTransactionRules(); + +void +setCurrentTransactionRules(std::optional r); + +/** RAII class to set and restore the current transaction rules + */ +class CurrentTransactionRulesGuard +{ +public: + explicit CurrentTransactionRulesGuard(Rules r) + : saved_(getCurrentTransactionRules()) + { + setCurrentTransactionRules(std::move(r)); + } + + ~CurrentTransactionRulesGuard() + { + setCurrentTransactionRules(saved_); + } + + CurrentTransactionRulesGuard() = delete; + CurrentTransactionRulesGuard(CurrentTransactionRulesGuard const&) = delete; + CurrentTransactionRulesGuard& + operator=(CurrentTransactionRulesGuard const&) = delete; + +private: + std::optional saved_; +}; + } // namespace ripple #endif diff --git a/src/ripple/protocol/impl/Rules.cpp b/src/ripple/protocol/impl/Rules.cpp index c8f4720bd6c..9bb8bd47a8b 100644 --- a/src/ripple/protocol/impl/Rules.cpp +++ b/src/ripple/protocol/impl/Rules.cpp @@ -17,11 +17,36 @@ */ //============================================================================== +#include #include #include +#include + namespace ripple { +namespace { +// Use a static inisde a function to help prevent order-of-initialization issues +LocalValue>& +getCurrentTransactionRulesRef() +{ + static LocalValue> r; + return r; +} +} // namespace + +std::optional const& +getCurrentTransactionRules() +{ + return *getCurrentTransactionRulesRef(); +} + +void +setCurrentTransactionRules(std::optional r) +{ + *getCurrentTransactionRulesRef() = std::move(r); +} + class Rules::Impl { private: From 3f7ce939c8cdea08d4161762e5d2a8d9d93c6790 Mon Sep 17 00:00:00 2001 From: seelabs Date: Mon, 22 Apr 2024 11:53:47 -0400 Subject: [PATCH 15/16] fix amendment: AMM swap should honor invariants: (#5002) The AMM has an invariant for swaps where: new_balance_1*new_balance_2 >= old_balance_1*old_balance_2 Due to rounding, this invariant could sometimes be violated (although by very small amounts). This patch introduces an amendment `fixAMMRounding` that changes the rounding to always favor the AMM. Doing this should maintain the invariant. Co-authored-by: Bronek Kozicki Co-authored-by: thejohnfreeman --- src/ripple/app/misc/AMMHelpers.h | 133 +- src/ripple/basics/Number.h | 7 + src/ripple/ledger/impl/View.cpp | 12 +- src/ripple/protocol/AmountConversions.h | 52 +- src/ripple/protocol/Feature.h | 3 +- src/ripple/protocol/impl/Feature.cpp | 1 + src/ripple/protocol/impl/Rules.cpp | 2 +- src/test/app/AMMExtended_test.cpp | 540 +++++--- src/test/app/AMM_test.cpp | 1557 +++++++++++++++-------- src/test/jtx/impl/AMM.cpp | 1 - 10 files changed, 1604 insertions(+), 704 deletions(-) diff --git a/src/ripple/app/misc/AMMHelpers.h b/src/ripple/app/misc/AMMHelpers.h index e84c6c535ea..7bdaf23d69f 100644 --- a/src/ripple/app/misc/AMMHelpers.h +++ b/src/ripple/app/misc/AMMHelpers.h @@ -24,8 +24,10 @@ #include #include #include +#include #include #include +#include #include #include @@ -228,10 +230,62 @@ swapAssetIn( TIn const& assetIn, std::uint16_t tfee) { - return toAmount( - getIssue(pool.out), - pool.out - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - Number::rounding_mode::downward); + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixAMMRounding)) + { + // set rounding to always favor the amm. Clip to zero. + // calculate: + // pool.out - + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // and explicitly set the rounding modes + // Favoring the amm means we should: + // minimize: + // pool.out - + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // maximize: + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // (pool.in * pool.out) + // minimize: + // (pool.in + assetIn * feeMult(tfee)), + // minimize: + // assetIn * feeMult(tfee) + // feeMult is: (1-fee), fee is tfee/100000 + // minimize: + // 1-fee + // maximize: + // fee + saveNumberRoundMode _{Number::getround()}; + + Number::setround(Number::upward); + auto const numerator = pool.in * pool.out; + auto const fee = getFee(tfee); + + Number::setround(Number::downward); + auto const denom = pool.in + assetIn * (1 - fee); + + if (denom.signum() <= 0) + return toAmount(getIssue(pool.out), 0); + + Number::setround(Number::upward); + auto const ratio = numerator / denom; + + Number::setround(Number::downward); + auto const swapOut = pool.out - ratio; + + if (swapOut.signum() < 0) + return toAmount(getIssue(pool.out), 0); + + return toAmount( + getIssue(pool.out), swapOut, Number::rounding_mode::downward); + } + else + { + return toAmount( + getIssue(pool.out), + pool.out - + (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + Number::rounding_mode::downward); + } } /** Swap assetOut out of the pool and swap in a proportional amount @@ -250,11 +304,62 @@ swapAssetOut( TOut const& assetOut, std::uint16_t tfee) { - return toAmount( - getIssue(pool.in), - ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / - feeMult(tfee), - Number::rounding_mode::upward); + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixAMMRounding)) + { + // set rounding to always favor the amm. Clip to zero. + // calculate: + // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / + // (1-tfee/100000) + // maximize: + // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) + // maximize: + // (pool.in * pool.out) / (pool.out - assetOut) + // maximize: + // (pool.in * pool.out) + // minimize + // (pool.out - assetOut) + // minimize: + // (1-tfee/100000) + // maximize: + // tfee/100000 + + saveNumberRoundMode _{Number::getround()}; + + Number::setround(Number::upward); + auto const numerator = pool.in * pool.out; + + Number::setround(Number::downward); + auto const denom = pool.out - assetOut; + if (denom.signum() <= 0) + { + return toMaxAmount(getIssue(pool.in)); + } + + Number::setround(Number::upward); + auto const ratio = numerator / denom; + auto const numerator2 = ratio - pool.in; + auto const fee = getFee(tfee); + + Number::setround(Number::downward); + auto const feeMult = 1 - fee; + + Number::setround(Number::upward); + auto const swapIn = numerator2 / feeMult; + if (swapIn.signum() < 0) + return toAmount(getIssue(pool.in), 0); + + return toAmount( + getIssue(pool.in), swapIn, Number::rounding_mode::upward); + } + else + { + return toAmount( + getIssue(pool.in), + ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / + feeMult(tfee), + Number::rounding_mode::upward); + } } /** Return square of n. @@ -263,12 +368,12 @@ Number square(Number const& n); /** Adjust LP tokens to deposit/withdraw. - * Amount type keeps 16 digits. Maintaining the LP balance by adding deposited - * tokens or subtracting withdrawn LP tokens from LP balance results in - * losing precision in LP balance. I.e. the resulting LP balance + * Amount type keeps 16 digits. Maintaining the LP balance by adding + * deposited tokens or subtracting withdrawn LP tokens from LP balance + * results in losing precision in LP balance. I.e. the resulting LP balance * is less than the actual sum of LP tokens. To adjust for this, subtract - * old tokens balance from the new one for deposit or vice versa for withdraw - * to cancel out the precision loss. + * old tokens balance from the new one for deposit or vice versa for + * withdraw to cancel out the precision loss. * @param lptAMMBalance LPT AMM Balance * @param lpTokens LP tokens to deposit or withdraw * @param isDeposit true if deposit, false if withdraw diff --git a/src/ripple/basics/Number.h b/src/ripple/basics/Number.h index c308abec712..48cea443ee3 100644 --- a/src/ripple/basics/Number.h +++ b/src/ripple/basics/Number.h @@ -133,6 +133,13 @@ class Number return x.mantissa_ < y.mantissa_; } + /** Return the sign of the amount */ + constexpr int + signum() const noexcept + { + return (mantissa_ < 0) ? -1 : (mantissa_ ? 1 : 0); + } + friend constexpr bool operator>(Number const& x, Number const& y) noexcept { diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index 5050e8764e9..a68f3a51387 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -1147,7 +1147,17 @@ accountSend( beast::Journal j, WaiveTransferFee waiveFee) { - assert(saAmount >= beast::zero); + if (view.rules().enabled(fixAMMRounding)) + { + if (saAmount < beast::zero) + { + return tecINTERNAL; + } + } + else + { + assert(saAmount >= beast::zero); + } /* If we aren't sending anything or if the sender is the same as the * receiver then we don't need to do anything. diff --git a/src/ripple/protocol/AmountConversions.h b/src/ripple/protocol/AmountConversions.h index 7403d7b9419..dc0defe6972 100644 --- a/src/ripple/protocol/AmountConversions.h +++ b/src/ripple/protocol/AmountConversions.h @@ -24,6 +24,8 @@ #include #include +#include + namespace ripple { inline STAmount @@ -130,16 +132,44 @@ toAmount( saveNumberRoundMode rm(Number::getround()); if (isXRP(issue)) Number::setround(mode); + if constexpr (std::is_same_v) return IOUAmount(n); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) return XRPAmount(static_cast(n)); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) { if (isXRP(issue)) return STAmount(issue, static_cast(n)); return STAmount(issue, n.mantissa(), n.exponent()); } + else + { + constexpr bool alwaysFalse = !std::is_same_v; + static_assert(alwaysFalse, "Unsupported type for toAmount"); + } +} + +template +T +toMaxAmount(Issue const& issue) +{ + if constexpr (std::is_same_v) + return IOUAmount(STAmount::cMaxValue, STAmount::cMaxOffset); + else if constexpr (std::is_same_v) + return XRPAmount(static_cast(STAmount::cMaxNativeN)); + else if constexpr (std::is_same_v) + { + if (isXRP(issue)) + return STAmount( + issue, static_cast(STAmount::cMaxNativeN)); + return STAmount(issue, STAmount::cMaxValue, STAmount::cMaxOffset); + } + else + { + constexpr bool alwaysFalse = !std::is_same_v; + static_assert(alwaysFalse, "Unsupported type for toMaxAmount"); + } } inline STAmount @@ -157,10 +187,15 @@ getIssue(T const& amt) { if constexpr (std::is_same_v) return noIssue(); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) return xrpIssue(); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) return amt.issue(); + else + { + constexpr bool alwaysFalse = !std::is_same_v; + static_assert(alwaysFalse, "Unsupported type for getIssue"); + } } template @@ -169,10 +204,15 @@ get(STAmount const& a) { if constexpr (std::is_same_v) return a.iou(); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) return a.xrp(); - if constexpr (std::is_same_v) + else if constexpr (std::is_same_v) return a; + else + { + constexpr bool alwaysFalse = !std::is_same_v; + static_assert(alwaysFalse, "Unsupported type for get"); + } } } // namespace ripple diff --git a/src/ripple/protocol/Feature.h b/src/ripple/protocol/Feature.h index fb6b3907736..b8788a74de7 100644 --- a/src/ripple/protocol/Feature.h +++ b/src/ripple/protocol/Feature.h @@ -74,7 +74,7 @@ namespace detail { // Feature.cpp. Because it's only used to reserve storage, and determine how // large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than // the actual number of amendments. A LogicError on startup will verify this. -static constexpr std::size_t numFeatures = 72; +static constexpr std::size_t numFeatures = 73; /** Amendments that this server supports and the default voting behavior. Whether they are enabled depends on the Rules defined in the validated @@ -359,6 +359,7 @@ extern uint256 const featurePriceOracle; extern uint256 const fixEmptyDID; extern uint256 const fixXChainRewardRounding; extern uint256 const fixPreviousTxnID; +extern uint256 const fixAMMRounding; } // namespace ripple diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/ripple/protocol/impl/Feature.cpp index a81edad336d..8c8ff403e3f 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/ripple/protocol/impl/Feature.cpp @@ -466,6 +466,7 @@ REGISTER_FEATURE(PriceOracle, Supported::yes, VoteBehavior::De REGISTER_FIX (fixEmptyDID, Supported::yes, VoteBehavior::DefaultNo); REGISTER_FIX (fixXChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo); REGISTER_FIX (fixPreviousTxnID, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixAMMRounding, Supported::yes, VoteBehavior::DefaultNo); // The following amendments are obsolete, but must remain supported // because they could potentially get enabled. diff --git a/src/ripple/protocol/impl/Rules.cpp b/src/ripple/protocol/impl/Rules.cpp index 9bb8bd47a8b..e65a9678f65 100644 --- a/src/ripple/protocol/impl/Rules.cpp +++ b/src/ripple/protocol/impl/Rules.cpp @@ -26,7 +26,7 @@ namespace ripple { namespace { -// Use a static inisde a function to help prevent order-of-initialization issues +// Use a static inside a function to help prevent order-of-initialization issues LocalValue>& getCurrentTransactionRulesRef() { diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 449a795c228..8dd915c8d91 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -93,10 +94,20 @@ struct AMMExtended_test : public jtx::AMMTest sendmax(BTC(1'000)), txflags(tfPartialPayment)); - BEAST_EXPECT(ammCarol.expectBalances( - STAmount{BTC, UINT64_C(1'001'000000374812), -12}, - USD(100'000), - ammCarol.tokens())); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammCarol.expectBalances( + STAmount{BTC, UINT64_C(1'001'000000374812), -12}, + USD(100'000), + ammCarol.tokens())); + } + else + { + BEAST_EXPECT(ammCarol.expectBalances( + STAmount{BTC, UINT64_C(1'001'000000374815), -12}, + USD(100'000), + ammCarol.tokens())); + } env.require(balance(bob, USD(200'100))); BEAST_EXPECT(isOffer(env, carol, BTC(49), XRP(49))); @@ -709,12 +720,24 @@ struct AMMExtended_test : public jtx::AMMTest auto const jrr = env.rpc("json", "submit", to_string(payment)); BEAST_EXPECT(jrr[jss::result][jss::status] == "success"); BEAST_EXPECT(jrr[jss::result][jss::engine_result] == "tesSUCCESS"); - BEAST_EXPECT(ammAlice.expectBalances( - STAmount(XTS, UINT64_C(101'010101010101), -12), - XXX(99), - ammAlice.tokens())); - BEAST_EXPECT(expectLine( - env, bob, STAmount{XTS, UINT64_C(98'989898989899), -12})); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammAlice.expectBalances( + STAmount(XTS, UINT64_C(101'010101010101), -12), + XXX(99), + ammAlice.tokens())); + BEAST_EXPECT(expectLine( + env, bob, STAmount{XTS, UINT64_C(98'989898989899), -12})); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + STAmount(XTS, UINT64_C(101'0101010101011), -13), + XXX(99), + ammAlice.tokens())); + BEAST_EXPECT(expectLine( + env, bob, STAmount{XTS, UINT64_C(98'9898989898989), -13})); + } BEAST_EXPECT(expectLine(env, bob, XXX(101))); } @@ -1404,6 +1427,7 @@ struct AMMExtended_test : public jtx::AMMTest using namespace jtx; FeatureBitset const all{supported_amendments()}; testRmFundedOffer(all); + testRmFundedOffer(all - fixAMMRounding); testEnforceNoRipple(all); testFillModes(all); testOfferCrossWithXRP(all); @@ -1417,6 +1441,7 @@ struct AMMExtended_test : public jtx::AMMTest testOfferCreateThenCross(all); testSellFlagExceedLimit(all); testGatewayCrossCurrency(all); + testGatewayCrossCurrency(all - fixAMMRounding); // testPartialCross // testXRPDirectCross // testDirectCross @@ -2292,16 +2317,36 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 77.2727USD with 75.5555GBP and pays 25% tr fee - // on 75.5555GBP - // 1,200 - 75.55555*1.25 = 1200 - 94.4444 = 1105.55555GBP - BEAST_EXPECT(expectLine( - env, alice, STAmount{GBP, UINT64_C(1'105'555555555555), -12})); - // 75.5555GBP is swapped in for 77.7272USD - BEAST_EXPECT(amm.expectBalances( - STAmount{GBP, UINT64_C(1'075'555555555556), -12}, - STAmount{USD, UINT64_C(1'022'727272727272), -12}, - amm.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 77.2727USD with 75.5555GBP and pays 25% tr fee + // on 75.5555GBP + // 1,200 - 75.55555*1.25 = 1200 - 94.4444 = 1105.55555GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'105'555555555555), -12})); + // 75.5555GBP is swapped in for 77.7272USD + BEAST_EXPECT(amm.expectBalances( + STAmount{GBP, UINT64_C(1'075'555555555556), -12}, + STAmount{USD, UINT64_C(1'022'727272727272), -12}, + amm.tokens())); + } + else + { + // alice buys 77.2727USD with 75.5555GBP and pays 25% tr fee + // on 75.5555GBP + // 1,200 - 75.55555*1.25 = 1200 - 94.4444 = 1105.55555GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'105'555555555554), -12})); + // 75.5555GBP is swapped in for 77.7272USD + BEAST_EXPECT(amm.expectBalances( + STAmount{GBP, UINT64_C(1'075'555555555557), -12}, + STAmount{USD, UINT64_C(1'022'727272727272), -12}, + amm.tokens())); + } BEAST_EXPECT(expectLine( env, carol, STAmount{USD, UINT64_C(1'277'272727272728), -12})); } @@ -2319,18 +2364,36 @@ struct AMMExtended_test : public jtx::AMMTest env(offer(alice, EUR(100), USD(100))); env.close(); - // 95.2380USD is swapped in for 100EUR - BEAST_EXPECT(amm.expectBalances( - STAmount{USD, UINT64_C(1'095'238095238095), -12}, - EUR(1'050), - amm.tokens())); - // alice pays 25% tr fee on 95.2380USD - // 1200-95.2380*1.25 = 1200 - 119.0477 = 1080.9523USD - BEAST_EXPECT(expectLine( - env, - alice, - STAmount{USD, UINT64_C(1'080'952380952381), -12}, - EUR(1'300))); + if (!features[fixAMMRounding]) + { + // 95.2380USD is swapped in for 100EUR + BEAST_EXPECT(amm.expectBalances( + STAmount{USD, UINT64_C(1'095'238095238095), -12}, + EUR(1'050), + amm.tokens())); + // alice pays 25% tr fee on 95.2380USD + // 1200-95.2380*1.25 = 1200 - 119.0477 = 1080.9523USD + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{USD, UINT64_C(1'080'952380952381), -12}, + EUR(1'300))); + } + else + { + // 95.2380USD is swapped in for 100EUR + BEAST_EXPECT(amm.expectBalances( + STAmount{USD, UINT64_C(1'095'238095238096), -12}, + EUR(1'050), + amm.tokens())); + // alice pays 25% tr fee on 95.2380USD + // 1200-95.2380*1.25 = 1200 - 119.0477 = 1080.9523USD + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{USD, UINT64_C(1'080'95238095238), -11}, + EUR(1'300))); + } BEAST_EXPECT(expectOffers(env, alice, 0)); } @@ -2354,20 +2417,42 @@ struct AMMExtended_test : public jtx::AMMTest env(pay(gw, dan, USD(1'000))); AMM ammDan(env, dan, USD(1'000), EUR(1'050)); - // alice -> bob -> gw -> carol. $50 should have transfer fee; - // $10, no fee - env(pay(alice, carol, EUR(50)), - path(bob, gw, ~EUR), - sendmax(USDA(60)), - txflags(tfNoRippleDirect)); - - BEAST_EXPECT( - ammDan.expectBalances(USD(1'050), EUR(1'000), ammDan.tokens())); - BEAST_EXPECT(expectLine(env, dan, USD(0))); - BEAST_EXPECT(expectLine(env, dan, EUR(0))); - BEAST_EXPECT(expectLine(env, bob, USD(-10))); - BEAST_EXPECT(expectLine(env, bob, USDA(60))); - BEAST_EXPECT(expectLine(env, carol, EUR(50))); + if (!features[fixAMMRounding]) + { + // alice -> bob -> gw -> carol. $50 should have transfer fee; + // $10, no fee + env(pay(alice, carol, EUR(50)), + path(bob, gw, ~EUR), + sendmax(USDA(60)), + txflags(tfNoRippleDirect)); + BEAST_EXPECT(ammDan.expectBalances( + USD(1'050), EUR(1'000), ammDan.tokens())); + BEAST_EXPECT(expectLine(env, dan, USD(0))); + BEAST_EXPECT(expectLine(env, dan, EUR(0))); + BEAST_EXPECT(expectLine(env, bob, USD(-10))); + BEAST_EXPECT(expectLine(env, bob, USDA(60))); + BEAST_EXPECT(expectLine(env, carol, EUR(50))); + } + else + { + // alice -> bob -> gw -> carol. $50 should have transfer fee; + // $10, no fee + env(pay(alice, carol, EUR(50)), + path(bob, gw, ~EUR), + sendmax(USDA(60.1)), + txflags(tfNoRippleDirect)); + BEAST_EXPECT(ammDan.expectBalances( + STAmount{USD, UINT64_C(1'050'000000000001), -12}, + EUR(1'000), + ammDan.tokens())); + BEAST_EXPECT(expectLine(env, dan, USD(0))); + BEAST_EXPECT(expectLine(env, dan, EUR(0))); + BEAST_EXPECT(expectLine( + env, bob, STAmount{USD, INT64_C(-10'000000000001), -12})); + BEAST_EXPECT(expectLine( + env, bob, STAmount{USDA, UINT64_C(60'000000000001), -12})); + BEAST_EXPECT(expectLine(env, carol, EUR(50))); + } } } @@ -2401,11 +2486,21 @@ struct AMMExtended_test : public jtx::AMMTest // alice buys 107.1428USD with 120GBP and pays 25% tr fee on 120GBP // 1,000 - 120*1.25 = 850GBP BEAST_EXPECT(expectLine(env, alice, GBP(850))); - // 120GBP is swapped in for 107.1428USD - BEAST_EXPECT(amm.expectBalances( - GBP(1'120), - STAmount{USD, UINT64_C(892'8571428571428), -13}, - amm.tokens())); + if (!features[fixAMMRounding]) + { + // 120GBP is swapped in for 107.1428USD + BEAST_EXPECT(amm.expectBalances( + GBP(1'120), + STAmount{USD, UINT64_C(892'8571428571428), -13}, + amm.tokens())); + } + else + { + BEAST_EXPECT(amm.expectBalances( + GBP(1'120), + STAmount{USD, UINT64_C(892'8571428571429), -13}, + amm.tokens())); + } // 25% of 85.7142USD is paid in tr fee // 85.7142*1.25 = 107.1428USD BEAST_EXPECT(expectLine( @@ -2479,20 +2574,39 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment)); env.close(); - // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on 120GBP - // 1,000 - 120*1.25 = 850GBP BEAST_EXPECT(expectLine(env, alice, GBP(850))); - // 120GBP is swapped in for 107.1428EUR - BEAST_EXPECT(amm1.expectBalances( - GBP(1'120), - STAmount{EUR, UINT64_C(892'8571428571428), -13}, - amm1.tokens())); - // 25% on 85.7142EUR is paid in tr fee 85.7142*1.25 = 107.1428EUR - // 85.7142EUR is swapped in for 78.9473USD - BEAST_EXPECT(amm2.expectBalances( - STAmount(EUR, UINT64_C(1'085'714285714286), -12), - STAmount{USD, UINT64_C(921'0526315789471), -13}, - amm2.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on + // 120GBP 1,000 - 120*1.25 = 850GBP 120GBP is swapped in for + // 107.1428EUR + BEAST_EXPECT(amm1.expectBalances( + GBP(1'120), + STAmount{EUR, UINT64_C(892'8571428571428), -13}, + amm1.tokens())); + // 25% on 85.7142EUR is paid in tr fee 85.7142*1.25 = + // 107.1428EUR 85.7142EUR is swapped in for 78.9473USD + BEAST_EXPECT(amm2.expectBalances( + STAmount(EUR, UINT64_C(1'085'714285714286), -12), + STAmount{USD, UINT64_C(921'0526315789471), -13}, + amm2.tokens())); + } + else + { + // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on + // 120GBP 1,000 - 120*1.25 = 850GBP 120GBP is swapped in for + // 107.1428EUR + BEAST_EXPECT(amm1.expectBalances( + GBP(1'120), + STAmount{EUR, UINT64_C(892'8571428571429), -13}, + amm1.tokens())); + // 25% on 85.7142EUR is paid in tr fee 85.7142*1.25 = + // 107.1428EUR 85.7142EUR is swapped in for 78.9473USD + BEAST_EXPECT(amm2.expectBalances( + STAmount(EUR, UINT64_C(1'085'714285714286), -12), + STAmount{USD, UINT64_C(921'052631578948), -12}, + amm2.tokens())); + } // 25% on 63.1578USD is paid in tr fee 63.1578*1.25 = 78.9473USD BEAST_EXPECT(expectLine( env, carol, STAmount(USD, UINT64_C(1'063'157894736842), -12))); @@ -2578,13 +2692,31 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 28.125USD with 24GBP and pays 25% tr fee - // on 24GBP - // 1,200 - 24*1.25 = 1,170GBP - BEAST_EXPECT(expectLine(env, alice, GBP(1'170))); - // 24GBP is swapped in for 28.125USD - BEAST_EXPECT( - amm.expectBalances(GBP(1'024), USD(1'171.875), amm.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 28.125USD with 24GBP and pays 25% tr fee + // on 24GBP + // 1,200 - 24*1.25 = 1,170GBP + BEAST_EXPECT(expectLine(env, alice, GBP(1'170))); + // 24GBP is swapped in for 28.125USD + BEAST_EXPECT(amm.expectBalances( + GBP(1'024), USD(1'171.875), amm.tokens())); + } + else + { + // alice buys 28.125USD with 24GBP and pays 25% tr fee + // on 24GBP + // 1,200 - 24*1.25 =~ 1,170GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'169'999999999999), -12})); + // 24GBP is swapped in for 28.125USD + BEAST_EXPECT(amm.expectBalances( + STAmount{GBP, UINT64_C(1'024'000000000001), -12}, + USD(1'171.875), + amm.tokens())); + } // 25% on 22.5USD is paid in tr fee // 22.5*1.25 = 28.125USD BEAST_EXPECT(expectLine(env, carol, USD(1'222.5))); @@ -2617,31 +2749,66 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 70.4210EUR with 70.4210GBP via the offer - // and pays 25% tr fee on 70.4210GBP - // 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP - BEAST_EXPECT(expectLine( - env, alice, STAmount{GBP, UINT64_C(1'311'973684210527), -12})); - // ed doesn't pay tr fee, the balances reflect consumed offer - // 70.4210GBP/70.4210EUR - BEAST_EXPECT(expectLine( - env, - ed, - STAmount{EUR, UINT64_C(1'329'578947368421), -12}, - STAmount{GBP, UINT64_C(1'470'421052631579), -12})); - BEAST_EXPECT(expectOffers( - env, - ed, - 1, - {Amounts{ - STAmount{GBP, UINT64_C(929'5789473684212), -13}, - STAmount{EUR, UINT64_C(929'5789473684212), -13}}})); - // 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 = 70.4210EUR - // 56.3368EUR is swapped in for 74.6651USD - BEAST_EXPECT(amm.expectBalances( - STAmount{EUR, UINT64_C(1'056'336842105263), -12}, - STAmount{USD, UINT64_C(1'325'334821428571), -12}, - amm.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 70.4210EUR with 70.4210GBP via the offer + // and pays 25% tr fee on 70.4210GBP + // 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'311'973684210527), -12})); + // ed doesn't pay tr fee, the balances reflect consumed offer + // 70.4210GBP/70.4210EUR + BEAST_EXPECT(expectLine( + env, + ed, + STAmount{EUR, UINT64_C(1'329'578947368421), -12}, + STAmount{GBP, UINT64_C(1'470'421052631579), -12})); + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {Amounts{ + STAmount{GBP, UINT64_C(929'5789473684212), -13}, + STAmount{EUR, UINT64_C(929'5789473684212), -13}}})); + // 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 = 70.4210EUR + // 56.3368EUR is swapped in for 74.6651USD + BEAST_EXPECT(amm.expectBalances( + STAmount{EUR, UINT64_C(1'056'336842105263), -12}, + STAmount{USD, UINT64_C(1'325'334821428571), -12}, + amm.tokens())); + } + else + { + // alice buys 70.4210EUR with 70.4210GBP via the offer + // and pays 25% tr fee on 70.4210GBP + // 1,400 - 70.4210*1.25 = 1400 - 88.0262 = 1311.9736GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'311'973684210525), -12})); + // ed doesn't pay tr fee, the balances reflect consumed offer + // 70.4210GBP/70.4210EUR + BEAST_EXPECT(expectLine( + env, + ed, + STAmount{EUR, UINT64_C(1'329'57894736842), -11}, + STAmount{GBP, UINT64_C(1'470'42105263158), -11})); + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {Amounts{ + STAmount{GBP, UINT64_C(929'57894736842), -11}, + STAmount{EUR, UINT64_C(929'57894736842), -11}}})); + // 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 = 70.4210EUR + // 56.3368EUR is swapped in for 74.6651USD + BEAST_EXPECT(amm.expectBalances( + STAmount{EUR, UINT64_C(1'056'336842105264), -12}, + STAmount{USD, UINT64_C(1'325'334821428571), -12}, + amm.tokens())); + } // 25% on 59.7321USD is paid in tr fee 59.7321*1.25 = 74.6651USD BEAST_EXPECT(expectLine( env, carol, STAmount(USD, UINT64_C(1'459'732142857143), -12))); @@ -2674,17 +2841,40 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 53.3322EUR with 56.3368GBP via the amm - // and pays 25% tr fee on 56.3368GBP - // 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP - BEAST_EXPECT(expectLine( - env, alice, STAmount{GBP, UINT64_C(1'329'578947368421), -12})); - //// 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 = 70.4210EUR - // 56.3368GBP is swapped in for 53.3322EUR - BEAST_EXPECT(amm.expectBalances( - STAmount{GBP, UINT64_C(1'056'336842105263), -12}, - STAmount{EUR, UINT64_C(946'6677295918366), -13}, - amm.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 53.3322EUR with 56.3368GBP via the amm + // and pays 25% tr fee on 56.3368GBP + // 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'329'578947368421), -12})); + //// 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 + ///= 70.4210EUR + // 56.3368GBP is swapped in for 53.3322EUR + BEAST_EXPECT(amm.expectBalances( + STAmount{GBP, UINT64_C(1'056'336842105263), -12}, + STAmount{EUR, UINT64_C(946'6677295918366), -13}, + amm.tokens())); + } + else + { + // alice buys 53.3322EUR with 56.3368GBP via the amm + // and pays 25% tr fee on 56.3368GBP + // 1,400 - 56.3368*1.25 = 1400 - 70.4210 = 1329.5789GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'329'57894736842), -11})); + //// 25% on 56.3368EUR is paid in tr fee 56.3368*1.25 + ///= 70.4210EUR + // 56.3368GBP is swapped in for 53.3322EUR + BEAST_EXPECT(amm.expectBalances( + STAmount{GBP, UINT64_C(1'056'336842105264), -12}, + STAmount{EUR, UINT64_C(946'6677295918366), -13}, + amm.tokens())); + } // 25% on 42.6658EUR is paid in tr fee 42.6658*1.25 = 53.3322EUR // 42.6658EUR/59.7321USD BEAST_EXPECT(expectLine( @@ -2729,22 +2919,48 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // alice buys 53.3322EUR with 107.5308GBP - // 25% on 86.0246GBP is paid in tr fee - // 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP - BEAST_EXPECT(expectLine( - env, alice, STAmount{GBP, UINT64_C(1'292'469135802469), -12})); - // 86.0246GBP is swapped in for 79.2106EUR - BEAST_EXPECT(amm1.expectBalances( - STAmount{GBP, UINT64_C(1'086'024691358025), -12}, - STAmount{EUR, UINT64_C(920'78937795562), -11}, - amm1.tokens())); - // 25% on 63.3684EUR is paid in tr fee 63.3684*1.25 = 79.2106EUR - // 63.3684EUR is swapped in for 83.4291USD - BEAST_EXPECT(amm2.expectBalances( - STAmount{EUR, UINT64_C(1'063'368497635504), -12}, - STAmount{USD, UINT64_C(1'316'570881226053), -12}, - amm2.tokens())); + if (!features[fixAMMRounding]) + { + // alice buys 53.3322EUR with 107.5308GBP + // 25% on 86.0246GBP is paid in tr fee + // 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'292'469135802469), -12})); + // 86.0246GBP is swapped in for 79.2106EUR + BEAST_EXPECT(amm1.expectBalances( + STAmount{GBP, UINT64_C(1'086'024691358025), -12}, + STAmount{EUR, UINT64_C(920'78937795562), -11}, + amm1.tokens())); + // 25% on 63.3684EUR is paid in tr fee 63.3684*1.25 = 79.2106EUR + // 63.3684EUR is swapped in for 83.4291USD + BEAST_EXPECT(amm2.expectBalances( + STAmount{EUR, UINT64_C(1'063'368497635504), -12}, + STAmount{USD, UINT64_C(1'316'570881226053), -12}, + amm2.tokens())); + } + else + { + // alice buys 53.3322EUR with 107.5308GBP + // 25% on 86.0246GBP is paid in tr fee + // 1,400 - 86.0246*1.25 = 1400 - 107.5308 = 1229.4691GBP + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{GBP, UINT64_C(1'292'469135802466), -12})); + // 86.0246GBP is swapped in for 79.2106EUR + BEAST_EXPECT(amm1.expectBalances( + STAmount{GBP, UINT64_C(1'086'024691358027), -12}, + STAmount{EUR, UINT64_C(920'7893779556188), -13}, + amm1.tokens())); + // 25% on 63.3684EUR is paid in tr fee 63.3684*1.25 = 79.2106EUR + // 63.3684EUR is swapped in for 83.4291USD + BEAST_EXPECT(amm2.expectBalances( + STAmount{EUR, UINT64_C(1'063'368497635505), -12}, + STAmount{USD, UINT64_C(1'316'570881226053), -12}, + amm2.tokens())); + } // 25% on 66.7432USD is paid in tr fee 66.7432*1.25 = 83.4291USD BEAST_EXPECT(expectLine( env, carol, STAmount(USD, UINT64_C(1'466'743295019157), -12))); @@ -2774,17 +2990,34 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - // 108.1481GBP is swapped in for 97.5935EUR - BEAST_EXPECT(amm1.expectBalances( - STAmount{GBP, UINT64_C(1'108'148148148149), -12}, - STAmount{EUR, UINT64_C(902'4064171122988), -13}, - amm1.tokens())); - // 25% on 78.0748EUR is paid in tr fee 78.0748*1.25 = 97.5935EUR - // 78.0748EUR is swapped in for 101.3888USD - BEAST_EXPECT(amm2.expectBalances( - STAmount{EUR, UINT64_C(1'078'074866310161), -12}, - STAmount{USD, UINT64_C(1'298'611111111111), -12}, - amm2.tokens())); + if (!features[fixAMMRounding]) + { + // 108.1481GBP is swapped in for 97.5935EUR + BEAST_EXPECT(amm1.expectBalances( + STAmount{GBP, UINT64_C(1'108'148148148149), -12}, + STAmount{EUR, UINT64_C(902'4064171122988), -13}, + amm1.tokens())); + // 25% on 78.0748EUR is paid in tr fee 78.0748*1.25 = 97.5935EUR + // 78.0748EUR is swapped in for 101.3888USD + BEAST_EXPECT(amm2.expectBalances( + STAmount{EUR, UINT64_C(1'078'074866310161), -12}, + STAmount{USD, UINT64_C(1'298'611111111111), -12}, + amm2.tokens())); + } + else + { + // 108.1481GBP is swapped in for 97.5935EUR + BEAST_EXPECT(amm1.expectBalances( + STAmount{GBP, UINT64_C(1'108'148148148151), -12}, + STAmount{EUR, UINT64_C(902'4064171122975), -13}, + amm1.tokens())); + // 25% on 78.0748EUR is paid in tr fee 78.0748*1.25 = 97.5935EUR + // 78.0748EUR is swapped in for 101.3888USD + BEAST_EXPECT(amm2.expectBalances( + STAmount{EUR, UINT64_C(1'078'074866310162), -12}, + STAmount{USD, UINT64_C(1'298'611111111111), -12}, + amm2.tokens())); + } // 25% on 81.1111USD is paid in tr fee 81.1111*1.25 = 101.3888USD BEAST_EXPECT(expectLine( env, carol, STAmount{USD, UINT64_C(1'481'111111111111), -12})); @@ -3037,15 +3270,33 @@ struct AMMExtended_test : public jtx::AMMTest env(offer(bob, XRP(100), USD(100))); env(offer(bob, XRP(1'000), USD(100))); AMM ammDan(env, dan, XRP(1'000), USD(1'100)); - env(pay(alice, carol, USD(10'000)), - paths(XRP), - delivermin(USD(200)), - txflags(tfPartialPayment), - sendmax(XRP(200))); - env.require(balance(bob, USD(0))); - env.require(balance(carol, USD(200))); - BEAST_EXPECT( - ammDan.expectBalances(XRP(1'100), USD(1'000), ammDan.tokens())); + if (!features[fixAMMRounding]) + { + env(pay(alice, carol, USD(10'000)), + paths(XRP), + delivermin(USD(200)), + txflags(tfPartialPayment), + sendmax(XRP(200))); + env.require(balance(bob, USD(0))); + env.require(balance(carol, USD(200))); + BEAST_EXPECT(ammDan.expectBalances( + XRP(1'100), USD(1'000), ammDan.tokens())); + } + else + { + env(pay(alice, carol, USD(10'000)), + paths(XRP), + delivermin(USD(200)), + txflags(tfPartialPayment), + sendmax(XRPAmount(200'000'001))); + env.require(balance(bob, USD(0))); + env.require(balance( + carol, STAmount{USD, UINT64_C(200'00000090909), -11})); + BEAST_EXPECT(ammDan.expectBalances( + XRPAmount{1'100'000'001}, + STAmount{USD, UINT64_C(999'99999909091), -11}, + ammDan.tokens())); + } } } @@ -3829,7 +4080,9 @@ struct AMMExtended_test : public jtx::AMMTest testBookStep(all); testBookStep(all | ownerPaysFee); testTransferRate(all | ownerPaysFee); + testTransferRate((all - fixAMMRounding) | ownerPaysFee); testTransferRateNoOwnerFee(all); + testTransferRateNoOwnerFee(all - fixAMMRounding); testLimitQuality(); testXRPPathLoop(); } @@ -3848,6 +4101,7 @@ struct AMMExtended_test : public jtx::AMMTest using namespace jtx; FeatureBitset const all{supported_amendments()}; test_convert_all_of_an_asset(all); + test_convert_all_of_an_asset(all - fixAMMRounding); } void diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index b6e2035c7b0..ecf68c9ae62 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -2727,7 +2729,7 @@ struct AMM_test : public jtx::AMMTest } void - testBid() + testBid(FeatureBitset features) { testcase("Bid"); using namespace jtx; @@ -2736,109 +2738,134 @@ struct AMM_test : public jtx::AMMTest // Auction slot initially is owned by AMM creator, who pays 0 price. // Bid 110 tokens. Pay bidMin. - testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - env(ammAlice.bid({.account = carol, .bidMin = 110})); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - // 110 tokens are burned. - BEAST_EXPECT(ammAlice.expectBalances( - XRP(11'000), USD(11'000), IOUAmount{10'999'890, 0})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); + env(ammAlice.bid({.account = carol, .bidMin = 110})); + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); + // 110 tokens are burned. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(11'000), USD(11'000), IOUAmount{10'999'890, 0})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Bid with min/max when the pay price is less than min. - testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - // Bid exactly 110. Pay 110 because the pay price is < 110. - env(ammAlice.bid({.account = carol, .bidMin = 110, .bidMax = 110})); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - BEAST_EXPECT(ammAlice.expectBalances( - XRP(11'000), USD(11'000), IOUAmount{10'999'890})); - // Bid exactly 180-200. Pay 180 because the pay price is < 180. - env(ammAlice.bid({.account = alice, .bidMin = 180, .bidMax = 200})); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{180})); - BEAST_EXPECT(ammAlice.expectBalances( - XRP(11'000), USD(11'000), IOUAmount{10'999'814'5, -1})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); + // Bid exactly 110. Pay 110 because the pay price is < 110. + env(ammAlice.bid( + {.account = carol, .bidMin = 110, .bidMax = 110})); + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); + BEAST_EXPECT(ammAlice.expectBalances( + XRP(11'000), USD(11'000), IOUAmount{10'999'890})); + // Bid exactly 180-200. Pay 180 because the pay price is < 180. + env(ammAlice.bid( + {.account = alice, .bidMin = 180, .bidMax = 200})); + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{180})); + BEAST_EXPECT(ammAlice.expectBalances( + XRP(11'000), USD(11'000), IOUAmount{10'999'814'5, -1})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Start bid at bidMin 110. - testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); - // Bid, pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); + // Bid, pay bidMin. + env(ammAlice.bid({.account = carol, .bidMin = 110})); + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); - ammAlice.deposit(bob, 1'000'000); - // Bid, pay the computed price. - env(ammAlice.bid({.account = bob})); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount(1155, -1))); + fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); + ammAlice.deposit(bob, 1'000'000); + // Bid, pay the computed price. + env(ammAlice.bid({.account = bob})); + BEAST_EXPECT( + ammAlice.expectAuctionSlot(0, 0, IOUAmount(1155, -1))); - // Bid bidMax fails because the computed price is higher. - env(ammAlice.bid({ - .account = carol, - .bidMax = 120, - }), - ter(tecAMM_FAILED)); - // Bid MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMax = 600})); - BEAST_EXPECT( - ammAlice.expectAuctionSlot(0, 0, IOUAmount{121'275, -3})); + // Bid bidMax fails because the computed price is higher. + env(ammAlice.bid({ + .account = carol, + .bidMax = 120, + }), + ter(tecAMM_FAILED)); + // Bid MaxSlotPrice succeeds - pay computed price + env(ammAlice.bid({.account = carol, .bidMax = 600})); + BEAST_EXPECT( + ammAlice.expectAuctionSlot(0, 0, IOUAmount{121'275, -3})); - // Bid Min/MaxSlotPrice fails because the computed price is not in - // range - env(ammAlice.bid({ - .account = carol, - .bidMin = 10, - .bidMax = 100, - }), - ter(tecAMM_FAILED)); - // Bid Min/MaxSlotPrice succeeds - pay computed price - env(ammAlice.bid({.account = carol, .bidMin = 100, .bidMax = 600})); - BEAST_EXPECT( - ammAlice.expectAuctionSlot(0, 0, IOUAmount{127'33875, -5})); - }); + // Bid Min/MaxSlotPrice fails because the computed price is not + // in range + env(ammAlice.bid({ + .account = carol, + .bidMin = 10, + .bidMax = 100, + }), + ter(tecAMM_FAILED)); + // Bid Min/MaxSlotPrice succeeds - pay computed price + env(ammAlice.bid( + {.account = carol, .bidMin = 100, .bidMax = 600})); + BEAST_EXPECT( + ammAlice.expectAuctionSlot(0, 0, IOUAmount{127'33875, -5})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Slot states. - testAMM([&](AMM& ammAlice, Env& env) { - ammAlice.deposit(carol, 1'000'000); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); - fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); - ammAlice.deposit(bob, 1'000'000); - BEAST_EXPECT(ammAlice.expectBalances( - XRP(12'000), USD(12'000), IOUAmount{12'000'000, 0})); + fund(env, gw, {bob}, {USD(10'000)}, Fund::Acct); + ammAlice.deposit(bob, 1'000'000); + BEAST_EXPECT(ammAlice.expectBalances( + XRP(12'000), USD(12'000), IOUAmount{12'000'000, 0})); - // Initial state. Pay bidMin. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); + // Initial state. Pay bidMin. + env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{110})); - // 1st Interval after close, price for 0th interval. - env(ammAlice.bid({.account = bob})); - env.close(seconds(AUCTION_SLOT_INTERVAL_DURATION + 1)); - BEAST_EXPECT( - ammAlice.expectAuctionSlot(0, 1, IOUAmount{1'155, -1})); + // 1st Interval after close, price for 0th interval. + env(ammAlice.bid({.account = bob})); + env.close(seconds(AUCTION_SLOT_INTERVAL_DURATION + 1)); + BEAST_EXPECT( + ammAlice.expectAuctionSlot(0, 1, IOUAmount{1'155, -1})); - // 10th Interval after close, price for 1st interval. - env(ammAlice.bid({.account = carol})); - env.close(seconds(10 * AUCTION_SLOT_INTERVAL_DURATION + 1)); - BEAST_EXPECT( - ammAlice.expectAuctionSlot(0, 10, IOUAmount{121'275, -3})); - - // 20th Interval (expired) after close, price for 10th interval. - env(ammAlice.bid({.account = bob})); - env.close(seconds( - AUCTION_SLOT_TIME_INTERVALS * AUCTION_SLOT_INTERVAL_DURATION + - 1)); - BEAST_EXPECT(ammAlice.expectAuctionSlot( - 0, std::nullopt, IOUAmount{127'33875, -5})); - - // 0 Interval. - env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); - BEAST_EXPECT( - ammAlice.expectAuctionSlot(0, std::nullopt, IOUAmount{110})); - // ~321.09 tokens burnt on bidding fees. - BEAST_EXPECT(ammAlice.expectBalances( - XRP(12'000), USD(12'000), IOUAmount{11'999'678'91, -2})); - }); + // 10th Interval after close, price for 1st interval. + env(ammAlice.bid({.account = carol})); + env.close(seconds(10 * AUCTION_SLOT_INTERVAL_DURATION + 1)); + BEAST_EXPECT( + ammAlice.expectAuctionSlot(0, 10, IOUAmount{121'275, -3})); + + // 20th Interval (expired) after close, price for 10th interval. + env(ammAlice.bid({.account = bob})); + env.close(seconds( + AUCTION_SLOT_TIME_INTERVALS * + AUCTION_SLOT_INTERVAL_DURATION + + 1)); + BEAST_EXPECT(ammAlice.expectAuctionSlot( + 0, std::nullopt, IOUAmount{127'33875, -5})); + + // 0 Interval. + env(ammAlice.bid({.account = carol, .bidMin = 110})).close(); + BEAST_EXPECT(ammAlice.expectAuctionSlot( + 0, std::nullopt, IOUAmount{110})); + // ~321.09 tokens burnt on bidding fees. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(12'000), USD(12'000), IOUAmount{11'999'678'91, -2})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Pool's fee 1%. Bid bidMin. // Auction slot owner and auth account trade at discounted fee - @@ -2928,10 +2955,20 @@ struct AMM_test : public jtx::AMMTest // alice pays ~1.011USD in fees, which is ~10 times more // than carol's fee // 100.099431529USD swapped in for 100XRP - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{13'000'000'668}, - STAmount{USD, UINT64_C(13'114'03663047264), -11}, - ammTokens)); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'000'000'668}, + STAmount{USD, UINT64_C(13'114'03663047264), -11}, + ammTokens)); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'000'000'668}, + STAmount{USD, UINT64_C(13'114'03663047265), -11}, + ammTokens)); + } // Auction slot expired, no discounted fee env.close(seconds(TOTAL_TIME_SLOT_SECS + 1)); // clock is parent's based @@ -2947,74 +2984,113 @@ struct AMM_test : public jtx::AMMTest } // carol pays ~9.94USD in fees, which is ~10 times more in // trading fees vs discounted fee. - BEAST_EXPECT( - env.balance(carol, USD) == - STAmount(USD, UINT64_C(29'389'06197177128), -11)); - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{13'000'000'668}, - STAmount{USD, UINT64_C(13'123'98038490681), -11}, - ammTokens)); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'389'06197177128), -11)); + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'000'000'668}, + STAmount{USD, UINT64_C(13'123'98038490681), -11}, + ammTokens)); + } + else + { + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'389'06197177127), -11)); + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'000'000'668}, + STAmount{USD, UINT64_C(13'123'98038490683), -11}, + ammTokens)); + } env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); env.close(); // carol pays ~1.008XRP in trading fee, which is // ~10 times more than the discounted fee. // 99.815876XRP is swapped in for 100USD - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount(13'100'824'790), - STAmount{USD, UINT64_C(13'023'98038490681), -11}, - ammTokens)); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount(13'100'824'790), + STAmount{USD, UINT64_C(13'023'98038490681), -11}, + ammTokens)); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount(13'100'824'790), + STAmount{USD, UINT64_C(13'023'98038490683), -11}, + ammTokens)); + } }, std::nullopt, - 1'000); + 1'000, + std::nullopt, + features); // Bid tiny amount - testAMM([&](AMM& ammAlice, Env& env) { - // Bid a tiny amount - auto const tiny = Number{STAmount::cMinValue, STAmount::cMinOffset}; - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{tiny}})); - // Auction slot purchase price is equal to the tiny amount - // since the minSlotPrice is 0 with no trading fee. - BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny})); - // The purchase price is too small to affect the total tokens - BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'000), USD(10'000), ammAlice.tokens())); - // Bid the tiny amount - env(ammAlice.bid({ - .account = alice, - .bidMin = IOUAmount{STAmount::cMinValue, STAmount::cMinOffset}, - })); - // Pay slightly higher price - BEAST_EXPECT(ammAlice.expectAuctionSlot( - 0, 0, IOUAmount{tiny * Number{105, -2}})); - // The purchase price is still too small to affect the total tokens - BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'000), USD(10'000), ammAlice.tokens())); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + // Bid a tiny amount + auto const tiny = + Number{STAmount::cMinValue, STAmount::cMinOffset}; + env(ammAlice.bid( + {.account = alice, .bidMin = IOUAmount{tiny}})); + // Auction slot purchase price is equal to the tiny amount + // since the minSlotPrice is 0 with no trading fee. + BEAST_EXPECT(ammAlice.expectAuctionSlot(0, 0, IOUAmount{tiny})); + // The purchase price is too small to affect the total tokens + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'000), USD(10'000), ammAlice.tokens())); + // Bid the tiny amount + env(ammAlice.bid({ + .account = alice, + .bidMin = + IOUAmount{STAmount::cMinValue, STAmount::cMinOffset}, + })); + // Pay slightly higher price + BEAST_EXPECT(ammAlice.expectAuctionSlot( + 0, 0, IOUAmount{tiny * Number{105, -2}})); + // The purchase price is still too small to affect the total + // tokens + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'000), USD(10'000), ammAlice.tokens())); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Reset auth account - testAMM([&](AMM& ammAlice, Env& env) { - env(ammAlice.bid({ - .account = alice, - .bidMin = IOUAmount{100}, - .authAccounts = {carol}, - })); - BEAST_EXPECT(ammAlice.expectAuctionSlot({carol})); - env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{100}})); - BEAST_EXPECT(ammAlice.expectAuctionSlot({})); - Account bob("bob"); - Account dan("dan"); - fund(env, {bob, dan}, XRP(1'000)); - env(ammAlice.bid({ - .account = alice, - .bidMin = IOUAmount{100}, - .authAccounts = {bob, dan}, - })); - BEAST_EXPECT(ammAlice.expectAuctionSlot({bob, dan})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + env(ammAlice.bid({ + .account = alice, + .bidMin = IOUAmount{100}, + .authAccounts = {carol}, + })); + BEAST_EXPECT(ammAlice.expectAuctionSlot({carol})); + env(ammAlice.bid({.account = alice, .bidMin = IOUAmount{100}})); + BEAST_EXPECT(ammAlice.expectAuctionSlot({})); + Account bob("bob"); + Account dan("dan"); + fund(env, {bob, dan}, XRP(1'000)); + env(ammAlice.bid({ + .account = alice, + .bidMin = IOUAmount{100}, + .authAccounts = {bob, dan}, + })); + BEAST_EXPECT(ammAlice.expectAuctionSlot({bob, dan})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Bid all tokens, still own the slot and trade at a discount { - Env env(*this); + Env env(*this, features); fund(env, gw, {alice, bob}, XRP(2'000), {USD(2'000)}); AMM amm(env, gw, XRP(1'000), USD(1'010), false, 1'000); auto const lpIssue = amm.lptIssue(); @@ -3035,15 +3111,25 @@ struct AMM_test : public jtx::AMMTest IOUAmount{1'004'487'562112089, -9})); // Bob pays the full fee ~0.1USD env(pay(bob, alice, XRP(10)), path(~XRP), sendmax(USD(11))); - BEAST_EXPECT(amm.expectBalances( - XRPAmount{1'000'010'011}, - STAmount{USD, UINT64_C(1'010'10090898081), -11}, - IOUAmount{1'004'487'562112089, -9})); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(amm.expectBalances( + XRPAmount{1'000'010'011}, + STAmount{USD, UINT64_C(1'010'10090898081), -11}, + IOUAmount{1'004'487'562112089, -9})); + } + else + { + BEAST_EXPECT(amm.expectBalances( + XRPAmount{1'000'010'011}, + STAmount{USD, UINT64_C(1'010'100908980811), -12}, + IOUAmount{1'004'487'562112089, -9})); + } } // preflight tests { - Env env(*this); + Env env(*this, features); fund(env, gw, {alice, bob}, XRP(2'000), {USD(2'000)}); AMM amm(env, gw, XRP(1'000), USD(1'010), false, 1'000); Json::Value tx = amm.bid({.account = alice, .bidMin = 500}); @@ -3256,7 +3342,7 @@ struct AMM_test : public jtx::AMMTest } void - testBasicPaymentEngine() + testBasicPaymentEngine(FeatureBitset features) { testcase("Basic Payment"); using namespace jtx; @@ -3280,7 +3366,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLedgerEntryRoot( env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); }, - {{XRP(10'000), USD(10'100)}}); + {{XRP(10'000), USD(10'100)}}, + 0, + std::nullopt, + {features}); // Payment 100USD for 100XRP, use default path. testAMM( @@ -3297,7 +3386,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLedgerEntryRoot( env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); }, - {{XRP(10'000), USD(10'100)}}); + {{XRP(10'000), USD(10'100)}}, + 0, + std::nullopt, + {features}); // This payment is identical to above. While it has // both default path and path, activeStrands has one path. @@ -3315,7 +3407,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLedgerEntryRoot( env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); }, - {{XRP(10'000), USD(10'100)}}); + {{XRP(10'000), USD(10'100)}}, + 0, + std::nullopt, + {features}); // Payment with limitQuality set. testAMM( @@ -3349,7 +3444,10 @@ struct AMM_test : public jtx::AMMTest ter(tecPATH_DRY)); env.close(); }, - {{XRP(10'000), USD(10'010)}}); + {{XRP(10'000), USD(10'010)}}, + 0, + std::nullopt, + {features}); // Payment with limitQuality and transfer fee set. testAMM( @@ -3377,7 +3475,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLedgerEntryRoot( env, bob, XRP(30'000) - XRP(10) - txfee(env, 1))); }, - {{XRP(10'000), USD(10'010)}}); + {{XRP(10'000), USD(10'010)}}, + 0, + std::nullopt, + {features}); // Fail when partial payment is not set. testAMM( @@ -3390,14 +3491,17 @@ struct AMM_test : public jtx::AMMTest txflags(tfNoRippleDirect), ter(tecPATH_PARTIAL)); }, - {{XRP(10'000), USD(10'000)}}); + {{XRP(10'000), USD(10'000)}}, + 0, + std::nullopt, + {features}); // Non-default path (with AMM) has a better quality than default path. // The max possible liquidity is taken out of non-default // path ~29.9XRP/29.9EUR, ~29.9EUR/~29.99USD. The rest // is taken from the offer. { - Env env(*this); + Env env(*this, features); fund( env, gw, {alice, carol}, {USD(30'000), EUR(30'000)}, Fund::All); env.close(); @@ -3416,17 +3520,34 @@ struct AMM_test : public jtx::AMMTest XRPAmount(10'030'082'730), STAmount(EUR, UINT64_C(9'970'007498125468), -12), ammEUR_XRP.tokens())); - BEAST_EXPECT(ammUSD_EUR.expectBalances( - STAmount(USD, UINT64_C(9'970'097277662122), -12), - STAmount(EUR, UINT64_C(10'029'99250187452), -11), - ammUSD_EUR.tokens())); - BEAST_EXPECT(expectOffers( - env, - alice, - 1, - {{Amounts{ - XRPAmount(30'201'749), - STAmount(USD, UINT64_C(29'90272233787818), -14)}}})); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammUSD_EUR.expectBalances( + STAmount(USD, UINT64_C(9'970'097277662122), -12), + STAmount(EUR, UINT64_C(10'029'99250187452), -11), + ammUSD_EUR.tokens())); + BEAST_EXPECT(expectOffers( + env, + alice, + 1, + {{Amounts{ + XRPAmount(30'201'749), + STAmount(USD, UINT64_C(29'90272233787818), -14)}}})); + } + else + { + BEAST_EXPECT(ammUSD_EUR.expectBalances( + STAmount(USD, UINT64_C(9'970'097277662172), -12), + STAmount(EUR, UINT64_C(10'029'99250187452), -11), + ammUSD_EUR.tokens())); + BEAST_EXPECT(expectOffers( + env, + alice, + 1, + {{Amounts{ + XRPAmount(30'201'749), + STAmount(USD, UINT64_C(29'9027223378284), -13)}}})); + } // Initial 30,000 + 100 BEAST_EXPECT(expectLine(env, carol, STAmount{USD, 30'100})); // Initial 1,000 - 30082730(AMM pool) - 70798251(offer) - 10(tx fee) @@ -3440,46 +3561,53 @@ struct AMM_test : public jtx::AMMTest // Default path (with AMM) has a better quality than a non-default path. // The max possible liquidity is taken out of default // path ~49XRP/49USD. The rest is taken from the offer. - testAMM([&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - env.close(); - env.trust(EUR(2'000), alice); - env.close(); - env(pay(gw, alice, EUR(1'000))); - env(offer(alice, XRP(101), EUR(100)), txflags(tfPassive)); - env.close(); - env(offer(alice, EUR(100), USD(100)), txflags(tfPassive)); - env.close(); - env(pay(bob, carol, USD(100)), - path(~EUR, ~USD), - sendmax(XRP(102)), - txflags(tfPartialPayment)); - env.close(); - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount(10'050'238'637), - STAmount(USD, UINT64_C(9'950'01249687578), -11), - ammAlice.tokens())); - BEAST_EXPECT(expectOffers( - env, - alice, - 2, - {{Amounts{ - XRPAmount(50'487'378), - STAmount(EUR, UINT64_C(49'98750312422), -11)}, - Amounts{ - STAmount(EUR, UINT64_C(49'98750312422), -11), - STAmount(USD, UINT64_C(49'98750312422), -11)}}})); - // Initial 30,000 + 99.99999999999 - BEAST_EXPECT(expectLine( - env, carol, STAmount{USD, UINT64_C(30'099'99999999999), -11})); - // Initial 1,000 - 50238637(AMM pool) - 50512622(offer) - 10(tx - // fee) - BEAST_EXPECT(expectLedgerEntryRoot( - env, - bob, - XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - - txfee(env, 1))); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + env.fund(XRP(1'000), bob); + env.close(); + env.trust(EUR(2'000), alice); + env.close(); + env(pay(gw, alice, EUR(1'000))); + env(offer(alice, XRP(101), EUR(100)), txflags(tfPassive)); + env.close(); + env(offer(alice, EUR(100), USD(100)), txflags(tfPassive)); + env.close(); + env(pay(bob, carol, USD(100)), + path(~EUR, ~USD), + sendmax(XRP(102)), + txflags(tfPartialPayment)); + env.close(); + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount(10'050'238'637), + STAmount(USD, UINT64_C(9'950'01249687578), -11), + ammAlice.tokens())); + BEAST_EXPECT(expectOffers( + env, + alice, + 2, + {{Amounts{ + XRPAmount(50'487'378), + STAmount(EUR, UINT64_C(49'98750312422), -11)}, + Amounts{ + STAmount(EUR, UINT64_C(49'98750312422), -11), + STAmount(USD, UINT64_C(49'98750312422), -11)}}})); + // Initial 30,000 + 99.99999999999 + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{USD, UINT64_C(30'099'99999999999), -11})); + // Initial 1,000 - 50238637(AMM pool) - 50512622(offer) - 10(tx + // fee) + BEAST_EXPECT(expectLedgerEntryRoot( + env, + bob, + XRP(1'000) - XRPAmount{50'238'637} - XRPAmount{50'512'622} - + txfee(env, 1))); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Default path with AMM and Order Book offer. AMM is consumed first, // remaining amount is consumed by the offer. @@ -3493,10 +3621,24 @@ struct AMM_test : public jtx::AMMTest sendmax(XRP(200)), txflags(tfPartialPayment)); env.close(); - BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'100), USD(10'000), ammAlice.tokens())); - // Initial 30,000 + 200 - BEAST_EXPECT(expectLine(env, carol, USD(30'200))); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'100), USD(10'000), ammAlice.tokens())); + // Initial 30,000 + 200 + BEAST_EXPECT(expectLine(env, carol, USD(30'200))); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'100), + STAmount(USD, UINT64_C(10'000'00000000001), -11), + ammAlice.tokens())); + BEAST_EXPECT(expectLine( + env, + carol, + STAmount(USD, UINT64_C(30'199'99999999999), -11))); + } // Initial 30,000 - 10000(AMM pool LP) - 100(AMM offer) - // - 100(offer) - 10(tx fee) - one reserve BEAST_EXPECT(expectLedgerEntryRoot( @@ -3506,13 +3648,16 @@ struct AMM_test : public jtx::AMMTest ammCrtFee(env) - txfee(env, 1))); BEAST_EXPECT(expectOffers(env, bob, 0)); }, - {{XRP(10'000), USD(10'100)}}); + {{XRP(10'000), USD(10'100)}}, + 0, + std::nullopt, + {features}); // Default path with AMM and Order Book offer. // Order Book offer is consumed first. // Remaining amount is consumed by AMM. { - Env env(*this); + Env env(*this, features); fund(env, gw, {alice, bob, carol}, XRP(20'000), {USD(2'000)}); env(offer(bob, XRP(50), USD(150)), txflags(tfPassive)); AMM ammAlice(env, alice, XRP(1'000), USD(1'050)); @@ -3541,7 +3686,10 @@ struct AMM_test : public jtx::AMMTest env, bob, XRP(30'000) - XRP(100) - txfee(env, 1))); BEAST_EXPECT(expectOffers(env, bob, 0)); }, - {{XRP(10'000), USD(10'100)}}); + {{XRP(10'000), USD(10'100)}}, + 0, + std::nullopt, + {features}); // Offer crossing IOU/IOU and transfer rate testAMM( @@ -3559,7 +3707,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine(env, carol, EUR(30'100))); BEAST_EXPECT(expectOffers(env, bob, 0)); }, - {{GBP(1'000), EUR(1'100)}}); + {{GBP(1'000), EUR(1'100)}}, + 0, + std::nullopt, + {features}); // Payment and transfer fee // Scenario: @@ -3583,7 +3734,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine(env, bob, GBP(75))); BEAST_EXPECT(expectLine(env, carol, EUR(30'080))); }, - {{GBP(1'000), EUR(1'100)}}); + {{GBP(1'000), EUR(1'100)}}, + 0, + std::nullopt, + {features}); // Payment and transfer fee, multiple steps // Scenario: @@ -3622,7 +3776,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine(env, ed, EUR(300), USD(100))); BEAST_EXPECT(expectLine(env, carol, USD(80))); }, - {{GBP(10'000), EUR(10'125)}}); + {{GBP(10'000), EUR(10'125)}}, + 0, + std::nullopt, + {features}); // Pay amounts close to one side of the pool testAMM( @@ -3648,11 +3805,14 @@ struct AMM_test : public jtx::AMMTest txflags(tfPartialPayment), ter(tesSUCCESS)); }, - {{XRP(100), USD(100)}}); + {{XRP(100), USD(100)}}, + 0, + std::nullopt, + {features}); // Multiple paths/steps { - Env env(*this); + Env env(*this, features); auto const ETH = gw["ETH"]; fund( env, @@ -3673,27 +3833,50 @@ struct AMM_test : public jtx::AMMTest path(~USD), path(~ETH, ~EUR, ~USD), sendmax(XRP(200))); - // XRP-ETH-EUR-USD - // This path provides ~26.06USD/26.2XRP - BEAST_EXPECT(xrp_eth.expectBalances( - XRPAmount(10'026'208'900), - STAmount{ETH, UINT64_C(10'073'65779244494), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'926'34220755506), -11}, - STAmount{EUR, UINT64_C(10'973'54232078752), -11}, - eth_eur.tokens())); - BEAST_EXPECT(eur_usd.expectBalances( - STAmount{EUR, UINT64_C(10'126'45767921248), -11}, - STAmount{USD, UINT64_C(9'973'93151712086), -11}, - eur_usd.tokens())); - - // XRP-USD path - // This path provides ~73.9USD/74.1XRP - BEAST_EXPECT(xrp_usd.expectBalances( - XRPAmount(10'224'106'246), - STAmount{USD, UINT64_C(10'126'06848287914), -11}, - xrp_usd.tokens())); + if (!features[fixAMMRounding]) + { + // XRP-ETH-EUR-USD + // This path provides ~26.06USD/26.2XRP + BEAST_EXPECT(xrp_eth.expectBalances( + XRPAmount(10'026'208'900), + STAmount{ETH, UINT64_C(10'073'65779244494), -11}, + xrp_eth.tokens())); + BEAST_EXPECT(eth_eur.expectBalances( + STAmount{ETH, UINT64_C(10'926'34220755506), -11}, + STAmount{EUR, UINT64_C(10'973'54232078752), -11}, + eth_eur.tokens())); + BEAST_EXPECT(eur_usd.expectBalances( + STAmount{EUR, UINT64_C(10'126'45767921248), -11}, + STAmount{USD, UINT64_C(9'973'93151712086), -11}, + eur_usd.tokens())); + // XRP-USD path + // This path provides ~73.9USD/74.1XRP + BEAST_EXPECT(xrp_usd.expectBalances( + XRPAmount(10'224'106'246), + STAmount{USD, UINT64_C(10'126'06848287914), -11}, + xrp_usd.tokens())); + } + else + { + BEAST_EXPECT(xrp_eth.expectBalances( + XRPAmount(10'026'208'900), + STAmount{ETH, UINT64_C(10'073'65779244461), -11}, + xrp_eth.tokens())); + BEAST_EXPECT(eth_eur.expectBalances( + STAmount{ETH, UINT64_C(10'926'34220755539), -11}, + STAmount{EUR, UINT64_C(10'973'5423207872), -10}, + eth_eur.tokens())); + BEAST_EXPECT(eur_usd.expectBalances( + STAmount{EUR, UINT64_C(10'126'4576792128), -10}, + STAmount{USD, UINT64_C(9'973'93151712057), -11}, + eur_usd.tokens())); + // XRP-USD path + // This path provides ~73.9USD/74.1XRP + BEAST_EXPECT(xrp_usd.expectBalances( + XRPAmount(10'224'106'246), + STAmount{USD, UINT64_C(10'126'06848287943), -11}, + xrp_usd.tokens())); + } // XRP-EUR-BTC-USD // This path doesn't provide any liquidity due to how @@ -3713,7 +3896,7 @@ struct AMM_test : public jtx::AMMTest // Dependent AMM { - Env env(*this); + Env env(*this, features); auto const ETH = gw["ETH"]; fund( env, @@ -3731,85 +3914,148 @@ struct AMM_test : public jtx::AMMTest path(~EUR, ~BTC, ~USD), path(~ETH, ~EUR, ~BTC, ~USD), sendmax(XRP(200))); - // XRP-EUR-BTC-USD path provides ~17.8USD/~18.7XRP - // XRP-ETH-EUR-BTC-USD path provides ~82.2USD/82.4XRP - BEAST_EXPECT(xrp_eur.expectBalances( - XRPAmount(10'118'738'472), - STAmount{EUR, UINT64_C(9'981'544436337968), -12}, - xrp_eur.tokens())); - BEAST_EXPECT(eur_btc.expectBalances( - STAmount{EUR, UINT64_C(10'101'16096785173), -11}, - STAmount{BTC, UINT64_C(10'097'91426968066), -11}, - eur_btc.tokens())); - BEAST_EXPECT(btc_usd.expectBalances( - STAmount{BTC, UINT64_C(10'202'08573031934), -11}, - USD(9'900), - btc_usd.tokens())); - BEAST_EXPECT(xrp_eth.expectBalances( - XRPAmount(10'082'446'397), - STAmount{ETH, UINT64_C(10'017'41072778012), -11}, - xrp_eth.tokens())); - BEAST_EXPECT(eth_eur.expectBalances( - STAmount{ETH, UINT64_C(10'982'58927221988), -11}, - STAmount{EUR, UINT64_C(10'917'2945958103), -10}, - eth_eur.tokens())); + if (!features[fixAMMRounding]) + { + // XRP-EUR-BTC-USD path provides ~17.8USD/~18.7XRP + // XRP-ETH-EUR-BTC-USD path provides ~82.2USD/82.4XRP + BEAST_EXPECT(xrp_eur.expectBalances( + XRPAmount(10'118'738'472), + STAmount{EUR, UINT64_C(9'981'544436337968), -12}, + xrp_eur.tokens())); + BEAST_EXPECT(eur_btc.expectBalances( + STAmount{EUR, UINT64_C(10'101'16096785173), -11}, + STAmount{BTC, UINT64_C(10'097'91426968066), -11}, + eur_btc.tokens())); + BEAST_EXPECT(btc_usd.expectBalances( + STAmount{BTC, UINT64_C(10'202'08573031934), -11}, + USD(9'900), + btc_usd.tokens())); + BEAST_EXPECT(xrp_eth.expectBalances( + XRPAmount(10'082'446'397), + STAmount{ETH, UINT64_C(10'017'41072778012), -11}, + xrp_eth.tokens())); + BEAST_EXPECT(eth_eur.expectBalances( + STAmount{ETH, UINT64_C(10'982'58927221988), -11}, + STAmount{EUR, UINT64_C(10'917'2945958103), -10}, + eth_eur.tokens())); + } + else + { + BEAST_EXPECT(xrp_eur.expectBalances( + XRPAmount(10'118'738'472), + STAmount{EUR, UINT64_C(9'981'544436337923), -12}, + xrp_eur.tokens())); + BEAST_EXPECT(eur_btc.expectBalances( + STAmount{EUR, UINT64_C(10'101'16096785188), -11}, + STAmount{BTC, UINT64_C(10'097'91426968059), -11}, + eur_btc.tokens())); + BEAST_EXPECT(btc_usd.expectBalances( + STAmount{BTC, UINT64_C(10'202'08573031941), -11}, + USD(9'900), + btc_usd.tokens())); + BEAST_EXPECT(xrp_eth.expectBalances( + XRPAmount(10'082'446'397), + STAmount{ETH, UINT64_C(10'017'41072777996), -11}, + xrp_eth.tokens())); + BEAST_EXPECT(eth_eur.expectBalances( + STAmount{ETH, UINT64_C(10'982'58927222004), -11}, + STAmount{EUR, UINT64_C(10'917'2945958102), -10}, + eth_eur.tokens())); + } BEAST_EXPECT(expectLine(env, carol, USD(300))); } // AMM offers limit // Consuming 30 CLOB offers, results in hitting 30 AMM offers limit. - testAMM([&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - fund(env, gw, {bob}, {EUR(400)}, Fund::IOUOnly); - env(trust(alice, EUR(200))); - for (int i = 0; i < 30; ++i) - env(offer(alice, EUR(1.0 + 0.01 * i), XRP(1))); - // This is worse quality offer than 30 offers above. - // It will not be consumed because of AMM offers limit. - env(offer(alice, EUR(140), XRP(100))); - env(pay(bob, carol, USD(100)), - path(~XRP, ~USD), - sendmax(EUR(400)), - txflags(tfPartialPayment | tfNoRippleDirect)); - // Carol gets ~29.91USD because of the AMM offers limit - BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'030), - STAmount{USD, UINT64_C(9'970'089730807577), -12}, - ammAlice.tokens())); - BEAST_EXPECT(expectLine( - env, carol, STAmount{USD, UINT64_C(30'029'91026919241), -11})); - BEAST_EXPECT(expectOffers(env, alice, 1, {{{EUR(140), XRP(100)}}})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + env.fund(XRP(1'000), bob); + fund(env, gw, {bob}, {EUR(400)}, Fund::IOUOnly); + env(trust(alice, EUR(200))); + for (int i = 0; i < 30; ++i) + env(offer(alice, EUR(1.0 + 0.01 * i), XRP(1))); + // This is worse quality offer than 30 offers above. + // It will not be consumed because of AMM offers limit. + env(offer(alice, EUR(140), XRP(100))); + env(pay(bob, carol, USD(100)), + path(~XRP, ~USD), + sendmax(EUR(400)), + txflags(tfPartialPayment | tfNoRippleDirect)); + if (!features[fixAMMRounding]) + { + // Carol gets ~29.91USD because of the AMM offers limit + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'030), + STAmount{USD, UINT64_C(9'970'089730807577), -12}, + ammAlice.tokens())); + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{USD, UINT64_C(30'029'91026919241), -11})); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'030), + STAmount{USD, UINT64_C(9'970'089730807827), -12}, + ammAlice.tokens())); + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{USD, UINT64_C(30'029'91026919217), -11})); + } + BEAST_EXPECT( + expectOffers(env, alice, 1, {{{EUR(140), XRP(100)}}})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // This payment is fulfilled - testAMM([&](AMM& ammAlice, Env& env) { - env.fund(XRP(1'000), bob); - fund(env, gw, {bob}, {EUR(400)}, Fund::IOUOnly); - env(trust(alice, EUR(200))); - for (int i = 0; i < 29; ++i) - env(offer(alice, EUR(1.0 + 0.01 * i), XRP(1))); - // This is worse quality offer than 30 offers above. - // It will not be consumed because of AMM offers limit. - env(offer(alice, EUR(140), XRP(100))); - env(pay(bob, carol, USD(100)), - path(~XRP, ~USD), - sendmax(EUR(400)), - txflags(tfPartialPayment | tfNoRippleDirect)); - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{10'101'010'102}, USD(9'900), ammAlice.tokens())); - // Carol gets ~100USD - BEAST_EXPECT(expectLine( - env, carol, STAmount{USD, UINT64_C(30'099'99999999999), -11})); - BEAST_EXPECT(expectOffers( - env, - alice, - 1, - {{{STAmount{EUR, 39'1858572, -7}, XRPAmount{27'989'898}}}})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + env.fund(XRP(1'000), bob); + fund(env, gw, {bob}, {EUR(400)}, Fund::IOUOnly); + env(trust(alice, EUR(200))); + for (int i = 0; i < 29; ++i) + env(offer(alice, EUR(1.0 + 0.01 * i), XRP(1))); + // This is worse quality offer than 30 offers above. + // It will not be consumed because of AMM offers limit. + env(offer(alice, EUR(140), XRP(100))); + env(pay(bob, carol, USD(100)), + path(~XRP, ~USD), + sendmax(EUR(400)), + txflags(tfPartialPayment | tfNoRippleDirect)); + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{10'101'010'102}, USD(9'900), ammAlice.tokens())); + if (!features[fixAMMRounding]) + { + // Carol gets ~100USD + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{USD, UINT64_C(30'099'99999999999), -11})); + } + else + { + BEAST_EXPECT(expectLine(env, carol, USD(30'100))); + } + BEAST_EXPECT(expectOffers( + env, + alice, + 1, + {{{STAmount{EUR, UINT64_C(39'1858572), -7}, + XRPAmount{27'989'898}}}})); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Offer crossing with AMM and another offer. AMM has a better // quality and is consumed first. { - Env env(*this); + Env env(*this, features); fund(env, gw, {alice, carol, bob}, XRP(30'000), {USD(30'000)}); env(offer(bob, XRP(100), USD(100.001))); AMM ammAlice(env, alice, XRP(10'000), USD(10'100)); @@ -3828,16 +4074,21 @@ struct AMM_test : public jtx::AMMTest } // Individually frozen account - testAMM([&](AMM& ammAlice, Env& env) { - env(trust(gw, carol["USD"](0), tfSetFreeze)); - env(trust(gw, alice["USD"](0), tfSetFreeze)); - env.close(); - env(pay(alice, carol, USD(1)), - path(~USD), - sendmax(XRP(10)), - txflags(tfNoRippleDirect | tfPartialPayment), - ter(tesSUCCESS)); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + env(trust(gw, carol["USD"](0), tfSetFreeze)); + env(trust(gw, alice["USD"](0), tfSetFreeze)); + env.close(); + env(pay(alice, carol, USD(1)), + path(~USD), + sendmax(XRP(10)), + txflags(tfNoRippleDirect | tfPartialPayment), + ter(tesSUCCESS)); + }, + std::nullopt, + 0, + std::nullopt, + {features}); } void @@ -4046,7 +4297,7 @@ struct AMM_test : public jtx::AMMTest } void - testAMMAndCLOB() + testAMMAndCLOB(FeatureBitset features) { testcase("AMMAndCLOB, offer quality change"); using namespace jtx; @@ -4056,7 +4307,7 @@ struct AMM_test : public jtx::AMMTest auto const LP2 = Account("LP2"); auto prep = [&](auto const& offerCb, auto const& expectCb) { - Env env(*this); + Env env(*this, features); env.fund(XRP(30'000'000'000), gw); env(offer(gw, XRP(11'500'000'000), TST(1'000'000'000))); @@ -4072,9 +4323,8 @@ struct AMM_test : public jtx::AMMTest expectCb(env); }; - // If we replace AMM with equivalent CLOB offer, which - // AMM generates when it is consumed, then the - // result must be identical. + // If we replace AMM with an equivalent CLOB offer, which AMM generates + // when it is consumed, then the result must be equivalent, too. std::string lp2TSTBalance; std::string lp2TakerGets; std::string lp2TakerPays; @@ -4092,11 +4342,18 @@ struct AMM_test : public jtx::AMMTest // Execute with CLOB offer prep( [&](Env& env) { - env(offer( - LP1, - XRPAmount{18'095'133}, - STAmount{TST, UINT64_C(1'68737984885388), -14}), - txflags(tfPassive)); + if (!features[fixAMMRounding]) + env(offer( + LP1, + XRPAmount{18'095'133}, + STAmount{TST, UINT64_C(1'68737984885388), -14}), + txflags(tfPassive)); + else + env(offer( + LP1, + XRPAmount{18'095'132}, + STAmount{TST, UINT64_C(1'68737984885387), -14}), + txflags(tfPassive)); }, [&](Env& env) { BEAST_EXPECT( @@ -4111,7 +4368,7 @@ struct AMM_test : public jtx::AMMTest } void - testTradingFee() + testTradingFee(FeatureBitset features) { testcase("Trading Fee"); using namespace jtx; @@ -4143,7 +4400,10 @@ struct AMM_test : public jtx::AMMTest carol, STAmount{USD, UINT64_C(29'994'96220068281), -11})); }, - {{USD(1'000), EUR(1'000)}}); + {{USD(1'000), EUR(1'000)}}, + 0, + std::nullopt, + {features}); // Single deposit with EP not exceeding specified: // 100USD with EP not to exceed 0.1 (AssetIn/TokensOut). 1% fee. @@ -4163,7 +4423,9 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(tokensNoFee == IOUAmount(487'644'85901109, -8)); }, std::nullopt, - 1'000); + 1'000, + std::nullopt, + {features}); // Single deposit with EP not exceeding specified: // 200USD with EP not to exceed 0.002020 (AssetIn/TokensOut). 1% fee @@ -4183,7 +4445,9 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(tokensNoFee == IOUAmount(98'475'81871545, -8)); }, std::nullopt, - 1'000); + 1'000, + std::nullopt, + {features}); // Single Withdrawal, 1% fee testAMM( @@ -4203,7 +4467,10 @@ struct AMM_test : public jtx::AMMTest carol, STAmount{USD, UINT64_C(29'994'97487437186), -11})); }, - {{USD(1'000), EUR(1'000)}}); + {{USD(1'000), EUR(1'000)}}, + 0, + std::nullopt, + {features}); // Withdraw with EPrice limit, 1% fee. testAMM( @@ -4231,7 +4498,9 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(tokensFee == IOUAmount(750'588'23529411, -8)); }, std::nullopt, - 1'000); + 1'000, + std::nullopt, + {features}); // Payment, 1% fee testAMM( @@ -4277,7 +4546,10 @@ struct AMM_test : public jtx::AMMTest STAmount{EUR, UINT64_C(1'010'10101010101), -11}, ammAlice.tokens())); }, - {{USD(1'000), EUR(1'010)}}); + {{USD(1'000), EUR(1'010)}}, + 0, + std::nullopt, + {features}); // Offer crossing, 0.5% fee testAMM( @@ -4312,19 +4584,32 @@ struct AMM_test : public jtx::AMMTest {{Amounts{ STAmount{EUR, UINT64_C(5'025125628140703), -15}, STAmount{USD, UINT64_C(5'025125628140703), -15}}}})); - BEAST_EXPECT(ammAlice.expectBalances( - STAmount{USD, UINT64_C(1'004'974874371859), -12}, - STAmount{EUR, UINT64_C(1'005'025125628141), -12}, - ammAlice.tokens())); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(ammAlice.expectBalances( + STAmount{USD, UINT64_C(1'004'974874371859), -12}, + STAmount{EUR, UINT64_C(1'005'025125628141), -12}, + ammAlice.tokens())); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + STAmount{USD, UINT64_C(1'004'97487437186), -11}, + STAmount{EUR, UINT64_C(1'005'025125628141), -12}, + ammAlice.tokens())); + } }, - {{USD(1'000), EUR(1'010)}}); + {{USD(1'000), EUR(1'010)}}, + 0, + std::nullopt, + {features}); // Payment with AMM and CLOB offer, 0 fee // AMM liquidity is consumed first up to CLOB offer quality // CLOB offer is fully consumed next // Remaining amount is consumed via AMM liquidity { - Env env(*this); + Env env(*this, features); Account const ed("ed"); fund( env, @@ -4339,15 +4624,28 @@ struct AMM_test : public jtx::AMMTest sendmax(EUR(15)), txflags(tfNoRippleDirect)); BEAST_EXPECT(expectLine(env, ed, USD(2'010))); - BEAST_EXPECT(expectLine(env, bob, EUR(1'990))); - BEAST_EXPECT(ammAlice.expectBalances( - USD(1'000), EUR(1'005), ammAlice.tokens())); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(expectLine(env, bob, EUR(1'990))); + BEAST_EXPECT(ammAlice.expectBalances( + USD(1'000), EUR(1'005), ammAlice.tokens())); + } + else + { + BEAST_EXPECT(expectLine( + env, bob, STAmount(EUR, UINT64_C(1989'999999999999), -12))); + BEAST_EXPECT(ammAlice.expectBalances( + USD(1'000), + STAmount(EUR, UINT64_C(1005'000000000001), -12), + ammAlice.tokens())); + } BEAST_EXPECT(expectOffers(env, carol, 0)); } - // Payment with AMM and CLOB offer. Same as above but with 0.25% fee. + // Payment with AMM and CLOB offer. Same as above but with 0.25% + // fee. { - Env env(*this); + Env env(*this, features); Account const ed("ed"); fund( env, @@ -4363,12 +4661,28 @@ struct AMM_test : public jtx::AMMTest sendmax(EUR(15)), txflags(tfNoRippleDirect)); BEAST_EXPECT(expectLine(env, ed, USD(2'010))); - BEAST_EXPECT(expectLine( - env, bob, STAmount{EUR, UINT64_C(1'989'987453007618), -12})); - BEAST_EXPECT(ammAlice.expectBalances( - USD(1'000), - STAmount{EUR, UINT64_C(1'005'012546992382), -12}, - ammAlice.tokens())); + if (!features[fixAMMRounding]) + { + BEAST_EXPECT(expectLine( + env, + bob, + STAmount{EUR, UINT64_C(1'989'987453007618), -12})); + BEAST_EXPECT(ammAlice.expectBalances( + USD(1'000), + STAmount{EUR, UINT64_C(1'005'012546992382), -12}, + ammAlice.tokens())); + } + else + { + BEAST_EXPECT(expectLine( + env, + bob, + STAmount{EUR, UINT64_C(1'989'987453007616), -12})); + BEAST_EXPECT(ammAlice.expectBalances( + USD(1'000), + STAmount{EUR, UINT64_C(1'005'012546992384), -12}, + ammAlice.tokens())); + } BEAST_EXPECT(expectOffers(env, carol, 0)); } @@ -4376,7 +4690,7 @@ struct AMM_test : public jtx::AMMTest // spot price quality, but 1% fee offsets that. As the result // the entire trade is executed via LOB. { - Env env(*this); + Env env(*this, features); Account const ed("ed"); fund( env, @@ -4403,7 +4717,7 @@ struct AMM_test : public jtx::AMMTest // The CLOB offer is consumed first and the remaining // amount is consumed via AMM liquidity. { - Env env(*this); + Env env(*this, features); Account const ed("ed"); fund( env, @@ -4494,8 +4808,8 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(!ammAlice.ammExists()); BEAST_EXPECT(expectLine( env, alice, STAmount{USD, UINT64_C(30'000'0000000013), -10})); - // alice XRP balance is 30,000initial - 50 ammcreate fee - 10drops - // fee + // alice XRP balance is 30,000initial - 50 ammcreate fee - + // 10drops fee BEAST_EXPECT(accountBalance(env, alice) == "29949999990"); }); @@ -4737,7 +5051,7 @@ struct AMM_test : public jtx::AMMTest } void - testSelection() + testSelection(FeatureBitset features) { testcase("Offer/Strand Selection"); using namespace jtx; @@ -4773,15 +5087,15 @@ struct AMM_test : public jtx::AMMTest // as CLOB's offer and can't generate a better quality offer. // The transfer fee in this case doesn't change the CLOB quality // because trIn is ignored on adjustment and trOut on payment is - // also ignored because ownerPaysTransferFee is false in this case. - // Run test for 0) offer, 1) AMM, 2) offer and AMM - // to verify that the quality is better in the first case, - // and CLOB is selected in the second case. + // also ignored because ownerPaysTransferFee is false in this + // case. Run test for 0) offer, 1) AMM, 2) offer and AMM to + // verify that the quality is better in the first case, and CLOB + // is selected in the second case. { std::array q; for (auto i = 0; i < 3; ++i) { - Env env(*this); + Env env(*this, features); prep(env, rates.first, rates.second); std::optional amm; if (i == 0 || i == 2) @@ -4814,10 +5128,11 @@ struct AMM_test : public jtx::AMMTest // Offer crossing: AMM has the same spot price quality // as CLOB's offer and can't generate a better quality offer. // The transfer fee in this case doesn't change the CLOB quality - // because the quality adjustment is ignored for the offer crossing. + // because the quality adjustment is ignored for the offer + // crossing. for (auto i = 0; i < 3; ++i) { - Env env(*this); + Env env(*this, features); prep(env, rates.first, rates.second); std::optional amm; if (i == 0 || i == 2) @@ -4857,7 +5172,7 @@ struct AMM_test : public jtx::AMMTest std::array q; for (auto i = 0; i < 3; ++i) { - Env env(*this); + Env env(*this, features); prep(env, rates.first, rates.second); std::optional amm; if (i == 0 || i == 2) @@ -4877,7 +5192,7 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(!amm->expectBalances( USD(1'000), ETH(1'000), amm->tokens())); } - if (i == 2) + if (i == 2 && !features[fixAMMRounding]) { if (rates.first == 1.5) { @@ -4908,6 +5223,37 @@ struct AMM_test : public jtx::AMMTest -13}}}})); } } + else if (i == 2) + { + if (rates.first == 1.5) + { + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, UINT64_C(378'6327949540812), -13}, + STAmount{ + USD, + UINT64_C(283'9745962155609), + -13}}}})); + } + else + { + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, UINT64_C(325'2994616207479), -13}, + STAmount{ + USD, + UINT64_C(243'9745962155609), + -13}}}})); + } + } BEAST_EXPECT(expectLine(env, bob, USD(2'100))); q[i] = Quality(Amounts{ ETH(2'000) - env.balance(carol, ETH), @@ -4922,7 +5268,7 @@ struct AMM_test : public jtx::AMMTest // Same as the offer-crossing but reduced offer quality for (auto i = 0; i < 3; ++i) { - Env env(*this); + Env env(*this, features); prep(env, rates.first, rates.second); std::optional amm; if (i == 0 || i == 2) @@ -4940,7 +5286,8 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(!amm->expectBalances( USD(1'000), ETH(1'000), amm->tokens())); } - // Partially crosses, AMM is selected, CLOB fails limitQuality + // Partially crosses, AMM is selected, CLOB fails + // limitQuality if (i == 2) { if (rates.first == 1.5) @@ -4978,20 +5325,21 @@ struct AMM_test : public jtx::AMMTest // AMM strand's best quality is equal to AMM's spot price // quality, which is 1. Both strands (steps) are adjusted // for the transfer fee in qualityUpperBound. In case - // of two strands, AMM offers have better quality and are consumed - // first, remaining liquidity is generated by CLOB offers. - // Liquidity from two strands is better in this case than in case - // of one strand with two book steps. Liquidity from one strand - // with AMM has better quality than either one strand with two book - // steps or two strands. It may appear unintuitive, but one strand - // with AMM is optimized and generates one AMM offer, while in case - // of two strands, multiple AMM offers are generated, which results - // in slightly worse overall quality. + // of two strands, AMM offers have better quality and are + // consumed first, remaining liquidity is generated by CLOB + // offers. Liquidity from two strands is better in this case + // than in case of one strand with two book steps. Liquidity + // from one strand with AMM has better quality than either one + // strand with two book steps or two strands. It may appear + // unintuitive, but one strand with AMM is optimized and + // generates one AMM offer, while in case of two strands, + // multiple AMM offers are generated, which results in slightly + // worse overall quality. { std::array q; for (auto i = 0; i < 3; ++i) { - Env env(*this); + Env env(*this, features); prep(env, rates.first, rates.second); std::optional amm; @@ -5013,7 +5361,7 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine(env, bob, USD(2'100))); - if (i == 2) + if (i == 2 && !features[fixAMMRounding]) { if (rates.first == 1.5) { @@ -5056,6 +5404,49 @@ struct AMM_test : public jtx::AMMTest }}})); } } + else if (i == 2) + { + if (rates.first == 1.5) + { + // Liquidity is consumed from AMM strand only + BEAST_EXPECT(amm->expectBalances( + STAmount{ + ETH, UINT64_C(1'176'660389557593), -12}, + USD(850), + amm->tokens())); + } + else + { + BEAST_EXPECT(amm->expectBalances( + STAmount{ETH, UINT64_C(1'179'54009433964), -11}, + STAmount{USD, UINT64_C(847'7880529867501), -13}, + amm->tokens())); + BEAST_EXPECT(expectOffers( + env, + ed, + 2, + {{Amounts{ + STAmount{ + ETH, + UINT64_C(343'3179205198749), + -13}, + STAmount{ + CAN, + UINT64_C(343'3179205198749), + -13}, + }, + Amounts{ + STAmount{ + CAN, + UINT64_C(362'2119470132499), + -13}, + STAmount{ + USD, + UINT64_C(362'2119470132499), + -13}, + }}})); + } + } q[i] = Quality(Amounts{ ETH(2'000) - env.balance(carol, ETH), env.balance(bob, USD) - USD(2'000)}); @@ -5095,8 +5486,8 @@ struct AMM_test : public jtx::AMMTest .account = gw, .asset1Out = USD(1), .err = ter(err2)}); // with the amendment disabled and ledger not closed, // second vote succeeds if the first vote sets the trading fee - // to non-zero; if the first vote sets the trading fee to >0 && <9 - // then the second withdraw succeeds if the second vote sets + // to non-zero; if the first vote sets the trading fee to >0 && + // <9 then the second withdraw succeeds if the second vote sets // the trading fee so that the discounted fee is non-zero amm.vote(VoteArg{.account = alice, .tfee = 20, .err = ter(err3)}); amm.withdraw(WithdrawArg{ @@ -5226,11 +5617,11 @@ struct AMM_test : public jtx::AMMTest } void - testFixOverflowOffer() + testFixOverflowOffer(FeatureBitset features) { using namespace jtx; using namespace std::chrono; - FeatureBitset const all{supported_amendments()}; + FeatureBitset const all{features}; Account const gatehub{"gatehub"}; Account const bitstamp{"bitstamp"}; @@ -5247,9 +5638,13 @@ struct AMM_test : public jtx::AMMTest sendmax const sendMaxUsdBIT; STAmount const sendUsdGH; STAmount const failUsdGH; + STAmount const failUsdGHr; STAmount const failUsdBIT; + STAmount const failUsdBITr; STAmount const goodUsdGH; + STAmount const goodUsdGHr; STAmount const goodUsdBIT; + STAmount const goodUsdBITr; IOUAmount const lpTokenBalance; double const offer1BtcGH = 0.1; double const offer2BtcGH = 0.1; @@ -5262,89 +5657,109 @@ struct AMM_test : public jtx::AMMTest for (auto const& input : { InputSet{ - .testCase = "Test Fix Overflow Offer", // - .poolUsdBIT = 3, // - .poolUsdGH = 273, // - .sendMaxUsdBIT{usdBIT(50)}, // - .sendUsdGH{usdGH, uint64_t(272'455089820359), -12}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(46'47826086956522), -14}, // - .goodUsdGH{usdGH, uint64_t(96'7543114220382), -13}, // - .goodUsdBIT{usdBIT, uint64_t(8'464739069120721), -15}, // - .lpTokenBalance = {28'61817604250837, -14}, // - .offer1BtcGH = 0.1, // - .offer2BtcGH = 0.1, // - .offer2UsdGH = 1, // - .rateBIT = 1.15, // - .rateGH = 1.2, // + .testCase = "Test Fix Overflow Offer", // + .poolUsdBIT = 3, // + .poolUsdGH = 273, // + .sendMaxUsdBIT{usdBIT(50)}, // + .sendUsdGH{usdGH, uint64_t(272'455089820359), -12}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(46'47826086956522), -14}, // + .failUsdBITr{usdBIT, uint64_t(46'47826086956521), -14}, // + .goodUsdGH{usdGH, uint64_t(96'7543114220382), -13}, // + .goodUsdGHr{usdGH, uint64_t(96'7543114222965), -13}, // + .goodUsdBIT{usdBIT, uint64_t(8'464739069120721), -15}, // + .goodUsdBITr{usdBIT, uint64_t(8'464739069098152), -15}, // + .lpTokenBalance = {28'61817604250837, -14}, // + .offer1BtcGH = 0.1, // + .offer2BtcGH = 0.1, // + .offer2UsdGH = 1, // + .rateBIT = 1.15, // + .rateGH = 1.2, // }, InputSet{ - .testCase = "Overflow test {1, 100, 0.111}", // - .poolUsdBIT = 1, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(0.111)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(1'111), -3}, // - .goodUsdGH{usdGH, uint64_t(90'04347888284115), -14}, // - .goodUsdBIT{usdBIT, uint64_t(1'111), -3}, // - .lpTokenBalance{10, 0}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {1, 100, 0.111}", // + .poolUsdBIT = 1, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(0.111)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(1'111), -3}, // + .failUsdBITr{usdBIT, uint64_t(1'111), -3}, // + .goodUsdGH{usdGH, uint64_t(90'04347888284115), -14}, // + .goodUsdGHr{usdGH, uint64_t(90'04347888284201), -14}, // + .goodUsdBIT{usdBIT, uint64_t(1'111), -3}, // + .goodUsdBITr{usdBIT, uint64_t(1'111), -3}, // + .lpTokenBalance{10, 0}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {1, 100, 1.00}", // - .poolUsdBIT = 1, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(1.00)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(2), 0}, // - .goodUsdGH{usdGH, uint64_t(52'94379354424079), -14}, // - .goodUsdBIT{usdBIT, uint64_t(2), 0}, // - .lpTokenBalance{10, 0}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {1, 100, 1.00}", // + .poolUsdBIT = 1, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(1.00)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(2), 0}, // + .failUsdBITr{usdBIT, uint64_t(2), 0}, // + .goodUsdGH{usdGH, uint64_t(52'94379354424079), -14}, // + .goodUsdGHr{usdGH, uint64_t(52'94379354424135), -14}, // + .goodUsdBIT{usdBIT, uint64_t(2), 0}, // + .goodUsdBITr{usdBIT, uint64_t(2), 0}, // + .lpTokenBalance{10, 0}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {1, 100, 4.6432}", // - .poolUsdBIT = 1, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(4.6432)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(5'6432), -4}, // - .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // - .goodUsdBIT{usdBIT, uint64_t(2'821579689703915), -15}, // - .lpTokenBalance{10, 0}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {1, 100, 4.6432}", // + .poolUsdBIT = 1, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(4.6432)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(5'6432), -4}, // + .failUsdBITr{usdBIT, uint64_t(5'6432), -4}, // + .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdGHr{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdBIT{usdBIT, uint64_t(2'821579689703915), -15}, // + .goodUsdBITr{usdBIT, uint64_t(2'821579689703954), -15}, // + .lpTokenBalance{10, 0}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {1, 100, 10}", // - .poolUsdBIT = 1, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(10)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(11), 0}, // - .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // - .goodUsdBIT{usdBIT, uint64_t(2'821579689703915), -15}, // - .lpTokenBalance{10, 0}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {1, 100, 10}", // + .poolUsdBIT = 1, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(10)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(11), 0}, // + .failUsdBITr{usdBIT, uint64_t(11), 0}, // + .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdGHr{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdBIT{usdBIT, uint64_t(2'821579689703915), -15}, // + .goodUsdBITr{usdBIT, uint64_t(2'821579689703954), -15}, // + .lpTokenBalance{10, 0}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ .testCase = "Overflow test {50, 100, 5.55}", // @@ -5353,9 +5768,13 @@ struct AMM_test : public jtx::AMMTest .sendMaxUsdBIT{usdBIT(5.55)}, // .sendUsdGH{usdGH, 100}, // .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // .failUsdBIT{usdBIT, uint64_t(55'55), -2}, // + .failUsdBITr{usdBIT, uint64_t(55'55), -2}, // .goodUsdGH{usdGH, uint64_t(90'04347888284113), -14}, // + .goodUsdGHr{usdGH, uint64_t(90'0434788828413), -13}, // .goodUsdBIT{usdBIT, uint64_t(55'55), -2}, // + .goodUsdBITr{usdBIT, uint64_t(55'55), -2}, // .lpTokenBalance{uint64_t(70'71067811865475), -14}, // .offer1BtcGH = 1e-5, // .offer2BtcGH = 1, // @@ -5364,55 +5783,67 @@ struct AMM_test : public jtx::AMMTest .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {50, 100, 50.00}", // - .poolUsdBIT = 50, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(50.00)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH{usdGH, uint64_t(52'94379354424081), -14}, // - .failUsdBIT{usdBIT, uint64_t(100), 0}, // - .goodUsdGH{usdGH, uint64_t(52'94379354424081), -14}, // - .goodUsdBIT{usdBIT, uint64_t(100), 0}, // - .lpTokenBalance{uint64_t(70'71067811865475), -14}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {50, 100, 50.00}", // + .poolUsdBIT = 50, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(50.00)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH{usdGH, uint64_t(52'94379354424081), -14}, // + .failUsdGHr{usdGH, uint64_t(52'94379354424092), -14}, // + .failUsdBIT{usdBIT, uint64_t(100), 0}, // + .failUsdBITr{usdBIT, uint64_t(100), 0}, // + .goodUsdGH{usdGH, uint64_t(52'94379354424081), -14}, // + .goodUsdGHr{usdGH, uint64_t(52'94379354424092), -14}, // + .goodUsdBIT{usdBIT, uint64_t(100), 0}, // + .goodUsdBITr{usdBIT, uint64_t(100), 0}, // + .lpTokenBalance{uint64_t(70'71067811865475), -14}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {50, 100, 232.16}", // - .poolUsdBIT = 50, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(232.16)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(282'16), -2}, // - .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // - .goodUsdBIT{usdBIT, uint64_t(141'0789844851958), -13}, // - .lpTokenBalance{70'71067811865475, -14}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {50, 100, 232.16}", // + .poolUsdBIT = 50, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(232.16)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(282'16), -2}, // + .failUsdBITr{usdBIT, uint64_t(282'16), -2}, // + .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdGHr{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdBIT{usdBIT, uint64_t(141'0789844851958), -13}, // + .goodUsdBITr{usdBIT, uint64_t(141'0789844851962), -13}, // + .lpTokenBalance{70'71067811865475, -14}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, InputSet{ - .testCase = "Overflow test {50, 100, 500}", // - .poolUsdBIT = 50, // - .poolUsdGH = 100, // - .sendMaxUsdBIT{usdBIT(500)}, // - .sendUsdGH{usdGH, 100}, // - .failUsdGH = STAmount{0}, // - .failUsdBIT{usdBIT, uint64_t(550), 0}, // - .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // - .goodUsdBIT{usdBIT, uint64_t(141'0789844851958), -13}, // - .lpTokenBalance{70'71067811865475, -14}, // - .offer1BtcGH = 1e-5, // - .offer2BtcGH = 1, // - .offer2UsdGH = 1e-5, // - .rateBIT = 0, // - .rateGH = 0, // + .testCase = "Overflow test {50, 100, 500}", // + .poolUsdBIT = 50, // + .poolUsdGH = 100, // + .sendMaxUsdBIT{usdBIT(500)}, // + .sendUsdGH{usdGH, 100}, // + .failUsdGH = STAmount{0}, // + .failUsdGHr = STAmount{0}, // + .failUsdBIT{usdBIT, uint64_t(550), 0}, // + .failUsdBITr{usdBIT, uint64_t(550), 0}, // + .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdGHr{usdGH, uint64_t(35'44113971506987), -14}, // + .goodUsdBIT{usdBIT, uint64_t(141'0789844851958), -13}, // + .goodUsdBITr{usdBIT, uint64_t(141'0789844851962), -13}, // + .lpTokenBalance{70'71067811865475, -14}, // + .offer1BtcGH = 1e-5, // + .offer2BtcGH = 1, // + .offer2UsdGH = 1e-5, // + .rateBIT = 0, // + .rateGH = 0, // }, }) { @@ -5463,34 +5894,47 @@ struct AMM_test : public jtx::AMMTest sendmax(input.sendMaxUsdBIT), txflags(tfPartialPayment)); env.close(); + + auto const failUsdGH = features[fixAMMRounding] + ? input.failUsdGHr + : input.failUsdGH; + auto const failUsdBIT = features[fixAMMRounding] + ? input.failUsdBITr + : input.failUsdBIT; + auto const goodUsdGH = features[fixAMMRounding] + ? input.goodUsdGHr + : input.goodUsdGH; + auto const goodUsdBIT = features[fixAMMRounding] + ? input.goodUsdBITr + : input.goodUsdBIT; if (!features[fixAMMOverflowOffer]) + { BEAST_EXPECT(amm.expectBalances( - input.failUsdGH, - input.failUsdBIT, - input.lpTokenBalance)); + failUsdGH, failUsdBIT, input.lpTokenBalance)); + } else { BEAST_EXPECT(amm.expectBalances( - input.goodUsdGH, - input.goodUsdBIT, - input.lpTokenBalance)); + goodUsdGH, goodUsdBIT, input.lpTokenBalance)); - // Invariant: LPToken balance must not change in a payment - // or a swap transaction + // Invariant: LPToken balance must not change in a + // payment or a swap transaction BEAST_EXPECT( amm.getLPTokensBalance() == preSwapLPTokenBalance); // Invariant: The square root of (product of the pool // balances) must be at least the LPTokenBalance Number const sqrtPoolProduct = - root2(input.goodUsdGH * input.goodUsdBIT); + root2(goodUsdGH * goodUsdBIT); // Include a tiny tolerance for the test cases using - // .goodUsdGH{usdGH, uint64_t(35'44113971506987), -14}, - // .goodUsdBIT{usdBIT, uint64_t(2'821579689703915), -15}, + // .goodUsdGH{usdGH, uint64_t(35'44113971506987), + // -14}, .goodUsdBIT{usdBIT, + // uint64_t(2'821579689703915), -15}, // These two values multiply - // to 99.99999999999994227040383754105 which gets internally - // rounded to 100, due to representation error. + // to 99.99999999999994227040383754105 which gets + // internally rounded to 100, due to representation + // error. BEAST_EXPECT( (sqrtPoolProduct + Number{1, -14} >= input.lpTokenBalance)); @@ -5500,8 +5944,46 @@ struct AMM_test : public jtx::AMMTest } void - testAll() + testSwapRounding() + { + testcase("swapRounding"); + using namespace jtx; + + const STAmount xrpPool{XRP, UINT64_C(51600'000981)}; + const STAmount iouPool{USD, UINT64_C(803040'9987141784), -10}; + + const STAmount xrpBob{XRP, UINT64_C(1092'878933)}; + const STAmount iouBob{ + USD, UINT64_C(3'988035892323031), -28}; // 3.9...e-13 + + testAMM( + [&](AMM& amm, Env& env) { + // Check our AMM starting conditions. + auto [xrpBegin, iouBegin, lptBegin] = amm.balances(XRP, USD); + + // Set Bob's starting conditions. + env.fund(xrpBob, bob); + env.trust(USD(1'000'000), bob); + env(pay(gw, bob, iouBob)); + env.close(); + + env(offer(bob, XRP(6300), USD(100'000))); + env.close(); + + // Assert that AMM is unchanged. + BEAST_EXPECT( + amm.expectBalances(xrpBegin, iouBegin, amm.tokens())); + }, + {{xrpPool, iouPool}}, + 889, + std::nullopt, + {jtx::supported_amendments() | fixAMMRounding}); + } + + void + run() override { + FeatureBitset const all{jtx::supported_amendments()}; testInvalidInstance(); testInstanceCreate(); testInvalidDeposit(); @@ -5511,29 +5993,30 @@ struct AMM_test : public jtx::AMMTest testInvalidFeeVote(); testFeeVote(); testInvalidBid(); - testBid(); + testBid(all); + testBid(all - fixAMMRounding); testInvalidAMMPayment(); - testBasicPaymentEngine(); + testBasicPaymentEngine(all); + testBasicPaymentEngine(all - fixAMMRounding); testAMMTokens(); testAmendment(); testFlags(); testRippling(); - testAMMAndCLOB(); - testTradingFee(); + testAMMAndCLOB(all); + testAMMAndCLOB(all - fixAMMRounding); + testTradingFee(all); + testTradingFee(all - fixAMMRounding); testAdjustedTokens(); testAutoDelete(); testClawback(); testAMMID(); - testSelection(); + testSelection(all); + testSelection(all - fixAMMRounding); testFixDefaultInnerObj(); testMalformed(); - testFixOverflowOffer(); - } - - void - run() override - { - testAll(); + testFixOverflowOffer(all); + testFixOverflowOffer(all - fixAMMRounding); + testSwapRounding(); } }; diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index eddb9691693..38cdb201854 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -234,7 +234,6 @@ AMM::expectBalances( balances(asset1.issue(), asset2.issue(), account); return asset1 == asset1Balance && asset2 == asset2Balance && lptAMMBalance == STAmount{lpt, lptIssue_}; - return false; } IOUAmount From 02ec8b7962bfc1e046b85ab9414cfcf08be072b9 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Fri, 26 Apr 2024 10:56:09 -0400 Subject: [PATCH 16/16] Set version to 2.2.0-rc1 --- src/ripple/protocol/impl/BuildInfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/protocol/impl/BuildInfo.cpp b/src/ripple/protocol/impl/BuildInfo.cpp index 3505069b34f..64718e8176d 100644 --- a/src/ripple/protocol/impl/BuildInfo.cpp +++ b/src/ripple/protocol/impl/BuildInfo.cpp @@ -33,7 +33,7 @@ namespace BuildInfo { // and follow the format described at http://semver.org/ //------------------------------------------------------------------------------ // clang-format off -char const* const versionString = "2.2.0-b3" +char const* const versionString = "2.2.0-rc1" // clang-format on #if defined(DEBUG) || defined(SANITIZER)