From 8490f8fc4b680386cad79ccc81003d87dd7950a8 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Mon, 10 Jun 2024 21:27:10 +0100 Subject: [PATCH 01/18] Add Antithesis SDK and libvoidstar.o loader --- CMakeLists.txt | 1 + cmake/RippledCompiler.cmake | 10 +- cmake/RippledCore.cmake | 24 + cmake/RippledSettings.cmake | 3 + external/antithesis-sdk/CMakeLists.txt | 4 + external/antithesis-sdk/LICENSE | 21 + external/antithesis-sdk/README.md | 8 + .../antithesis_instrumentation.h | 113 ++++ external/antithesis-sdk/antithesis_sdk.h | 594 ++++++++++++++++++ src/xrpld/app/main/Main.cpp | 4 + 10 files changed, 781 insertions(+), 1 deletion(-) create mode 100644 external/antithesis-sdk/CMakeLists.txt create mode 100644 external/antithesis-sdk/LICENSE create mode 100644 external/antithesis-sdk/README.md create mode 100644 external/antithesis-sdk/antithesis_instrumentation.h create mode 100644 external/antithesis-sdk/antithesis_sdk.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a69583f9cbf..013f20381f0 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) +add_subdirectory(external/antithesis-sdk) find_package(gRPC REQUIRED) find_package(lz4 REQUIRED) # Target names with :: are not allowed in a generator expression. diff --git a/cmake/RippledCompiler.cmake b/cmake/RippledCompiler.cmake index 43afc628bc3..6b6c191da0a 100644 --- a/cmake/RippledCompiler.cmake +++ b/cmake/RippledCompiler.cmake @@ -120,7 +120,7 @@ else () target_link_libraries (common INTERFACE -rdynamic - $<$:-Wl,-z,relro,-z,now> + $<$:-Wl,-z,relro,-z,now,--build-id> # link to static libc/c++ iff: # * static option set and # * NOT APPLE (AppleClang does not support static libc/c++) and @@ -131,6 +131,14 @@ else () >) endif () +if (voidstar) + if (NOT is_linux) + message(FATAL_ERROR "Antithesis instrumentation requires Linux, aborting...") + elseif (NOT (is_clang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)) + message(FATAL_ERROR "Antithesis instrumentation requires Clang version 16 or later, aborting...") + endif () +endif () + if (use_mold) # use mold linker if available execute_process ( diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake index cc483034714..88f801aef5e 100644 --- a/cmake/RippledCore.cmake +++ b/cmake/RippledCore.cmake @@ -91,6 +91,17 @@ target_link_libraries(xrpl.libxrpl xxHash::xxhash ) +if(voidstar) + target_compile_options(xrpl.libxrpl + PRIVATE + -DENABLE_VOIDSTAR + ) + target_include_directories(xrpl.libxrpl + PRIVATE + ${CMAKE_SOURCE_DIR}/external/antithesis-sdk + ) +endif() + add_executable(rippled) if(unity) set_target_properties(rippled PROPERTIES UNITY_BUILD ON) @@ -121,6 +132,19 @@ target_link_libraries(rippled Ripple::libs xrpl.libxrpl ) + +if(voidstar) + target_compile_options(rippled + PRIVATE + -fsanitize-coverage=trace-pc-guard + -DENABLE_VOIDSTAR + ) + target_include_directories(rippled + PRIVATE + ${CMAKE_SOURCE_DIR}/external/antithesis-sdk + ) +endif() + exclude_if_included(rippled) # define a macro for tests that might need to # be exluded or run differently in CI environment diff --git a/cmake/RippledSettings.cmake b/cmake/RippledSettings.cmake index fae09cc5d3f..28b59e69b1b 100644 --- a/cmake/RippledSettings.cmake +++ b/cmake/RippledSettings.cmake @@ -18,6 +18,9 @@ if(unity) set(CMAKE_UNITY_BUILD_BATCH_SIZE 15 CACHE STRING "") endif() endif() +if(is_clang AND is_linux) + option(voidstar "Add libvoidstar.so loader for Antithesis instrumentation." OFF) +endif() if(is_gcc OR is_clang) option(coverage "Generates coverage info." OFF) option(profile "Add profiling flags" OFF) diff --git a/external/antithesis-sdk/CMakeLists.txt b/external/antithesis-sdk/CMakeLists.txt new file mode 100644 index 00000000000..e25e53cb736 --- /dev/null +++ b/external/antithesis-sdk/CMakeLists.txt @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.25) +project(antithesis-sdk-cpp VERSION $ENV{version} LANGUAGES CXX) + +add_library(antithesis-sdk-cpp INTERFACE antithesis_sdk.h) diff --git a/external/antithesis-sdk/LICENSE b/external/antithesis-sdk/LICENSE new file mode 100644 index 00000000000..90f1712ed1a --- /dev/null +++ b/external/antithesis-sdk/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 Antithesis + +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", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/external/antithesis-sdk/README.md b/external/antithesis-sdk/README.md new file mode 100644 index 00000000000..ce512d7c6fd --- /dev/null +++ b/external/antithesis-sdk/README.md @@ -0,0 +1,8 @@ +# Antithesis C++ SDK + +This library provides methods for C++ programs to configure the [Antithesis](https://antithesis.com) platform. It contains three kinds of functionality: +* Assertion macros that allow you to define test properties about your software or workload. +* Randomness functions for requesting both structured and unstructured randomness from the Antithesis platform. +* Lifecycle functions that inform the Antithesis environment that particular test phases or milestones have been reached. + +For general usage guidance see the [Antithesis C++ SDK Documentation](https://antithesis.com/docs/using_antithesis/sdk/cpp/overview.html) diff --git a/external/antithesis-sdk/antithesis_instrumentation.h b/external/antithesis-sdk/antithesis_instrumentation.h new file mode 100644 index 00000000000..b36fc5832ca --- /dev/null +++ b/external/antithesis-sdk/antithesis_instrumentation.h @@ -0,0 +1,113 @@ +#pragma once + +/* +This header file enables code coverage instrumentation. It is distributed with the Antithesis C++ SDK. + +This header file can be used in both C and C++ programs. (The rest of the SDK works only for C++ programs.) + +You should include it in a single .cpp or .c file. + +The instructions (such as required compiler flags) and usage guidance are found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. +*/ + +#include +#include +#include +#include +#include +#ifndef __cplusplus +#include +#include +#endif + +// If the libvoidstar(determ) library is present, +// pass thru trace_pc_guard related callbacks to it +typedef void (*trace_pc_guard_init_fn)(uint32_t *start, uint32_t *stop); +typedef void (*trace_pc_guard_fn)(uint32_t *guard, uint64_t edge); + +static trace_pc_guard_init_fn trace_pc_guard_init = NULL; +static trace_pc_guard_fn trace_pc_guard = NULL; +static bool did_check_libvoidstar = false; +static bool has_libvoidstar = false; + +static __attribute__((no_sanitize("coverage"))) void debug_message_out(const char *msg) { + (void)printf("%s\n", msg); + return; +} + +extern +#ifdef __cplusplus + "C" +#endif +__attribute__((no_sanitize("coverage"))) void antithesis_load_libvoidstar() { +#ifdef __cplusplus + constexpr +#endif + const char* LIB_PATH = "/usr/lib/libvoidstar.so"; + + if (did_check_libvoidstar) { + return; + } + debug_message_out("TRYING TO LOAD libvoidstar"); + did_check_libvoidstar = true; + void* shared_lib = dlopen(LIB_PATH, RTLD_NOW); + if (!shared_lib) { + debug_message_out("Can not load the Antithesis native library"); + return; + } + + void* trace_pc_guard_init_sym = dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_init"); + if (!trace_pc_guard_init_sym) { + debug_message_out("Can not forward calls to libvoidstar for __sanitizer_cov_trace_pc_guard_init"); + return; + } + + void* trace_pc_guard_sym = dlsym(shared_lib, "__sanitizer_cov_trace_pc_guard_internal"); + if (!trace_pc_guard_sym) { + debug_message_out("Can not forward calls to libvoidstar for __sanitizer_cov_trace_pc_guard"); + return; + } + + trace_pc_guard_init = (trace_pc_guard_init_fn)(trace_pc_guard_init_sym); + trace_pc_guard = (trace_pc_guard_fn)(trace_pc_guard_sym); + has_libvoidstar = true; + debug_message_out("LOADED libvoidstar"); +} + +// The following symbols are indeed reserved identifiers, since we're implementing functions defined +// in the compiler runtime. Not clear how to get Clang on board with that besides narrowly suppressing +// the warning in this case. The sample code on the CoverageSanitizer documentation page fails this +// warning! +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wreserved-identifier" +extern +#ifdef __cplusplus + "C" +#endif +void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) { + debug_message_out("SDK forwarding to libvoidstar for __sanitizer_cov_trace_pc_guard_init()"); + if (!did_check_libvoidstar) { + antithesis_load_libvoidstar(); + } + if (has_libvoidstar) { + trace_pc_guard_init(start, stop); + } + return; +} + +extern +#ifdef __cplusplus + "C" +#endif +void __sanitizer_cov_trace_pc_guard( uint32_t *guard ) { + if (has_libvoidstar) { + uint64_t edge = (uint64_t)(__builtin_return_address(0)); + trace_pc_guard(guard, edge); + } else { + if (guard) { + *guard = 0; + } + } + return; +} +#pragma clang diagnostic pop diff --git a/external/antithesis-sdk/antithesis_sdk.h b/external/antithesis-sdk/antithesis_sdk.h new file mode 100644 index 00000000000..3586273ab8c --- /dev/null +++ b/external/antithesis-sdk/antithesis_sdk.h @@ -0,0 +1,594 @@ +#pragma once + +// This header file contains the Antithesis C++ SDK, which enables C++ applications to integrate with the [Antithesis platform]. +// +// Documentation for the SDK is found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. + +#include +#include +#include +#include +#include +#include + +namespace antithesis { + inline const char* SDK_VERSION = "0.3.0"; + inline const char* PROTOCOL_VERSION = "1.0.0"; + + struct LocalRandom { + std::random_device device; + std::mt19937_64 gen; + std::uniform_int_distribution distribution; + + LocalRandom() : device(), gen(device()), distribution() {} + + uint64_t random() { +#ifdef ANTITHESIS_RANDOM_OVERRIDE + return ANTITHESIS_RANDOM_OVERRIDE(); +#else + return distribution(gen); +#endif + } + }; + + struct JSON; + typedef std::variant BasicValueType; + typedef std::vector JSON_ARRAY; + typedef std::variant ValueType; + + struct JSON : std::map { + JSON( std::initializer_list> args) : std::map(args) {} + }; + + // Declarations that we expose + uint64_t get_random(); +} + +#if defined(NO_ANTITHESIS_SDK) || __cplusplus < 202000L || (defined(__clang__) && __clang_major__ < 16) + +#if __cplusplus < 202000L + #error "The Antithesis C++ API requires C++20 or higher" +#endif +#if defined(__clang__) && __clang_major__ < 16 + #error "The Antithesis C++ API requires clang version 16 or higher" +#endif + +#define ALWAYS(cond, message, ...) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) +#define SOMETIMES(cond, message, ...) +#define REACHABLE(message, ...) +#define UNREACHABLE(message, ...) + + +namespace antithesis { + inline uint64_t get_random() { + static LocalRandom random_gen; + return random_gen.random(); + } + + inline void setup_complete(const JSON& details) { + } + + inline void send_event(const char* name, const JSON& details) { + } +} + +#else + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace antithesis { + constexpr const char* const ERROR_LOG_LINE_PREFIX = "[* antithesis-sdk-cpp *]"; + constexpr const char* LIB_PATH = "/usr/lib/libvoidstar.so"; + constexpr const char* LOCAL_OUTPUT_ENVIRONMENT_VARIABLE = "ANTITHESIS_SDK_LOCAL_OUTPUT"; + + static std::ostream& operator<<(std::ostream& out, const JSON& details); + + struct LibHandler { + virtual ~LibHandler() = default; + virtual void output(const char* message) const = 0; + virtual uint64_t random() = 0; + + void output(const JSON& json) const { + std::ostringstream out; + out << json; + output(out.str().c_str()); + } + }; + + struct AntithesisHandler : LibHandler { + void output(const char* message) const override { + if (message != nullptr) { + fuzz_json_data(message, strlen(message)); + fuzz_flush(); + } + } + + uint64_t random() override { + return fuzz_get_random(); + } + + static std::unique_ptr create() { + void* shared_lib = dlopen(LIB_PATH, RTLD_NOW); + if (!shared_lib) { + error("Can not load the Antithesis native library"); + return nullptr; + } + + void* fuzz_json_data = dlsym(shared_lib, "fuzz_json_data"); + if (!fuzz_json_data) { + error("Can not access symbol fuzz_json_data"); + return nullptr; + } + + void* fuzz_flush = dlsym(shared_lib, "fuzz_flush"); + if (!fuzz_flush) { + error("Can not access symbol fuzz_flush"); + return nullptr; + } + + void* fuzz_get_random = dlsym(shared_lib, "fuzz_get_random"); + if (!fuzz_get_random) { + error("Can not access symbol fuzz_get_random"); + return nullptr; + } + + return std::unique_ptr(new AntithesisHandler( + reinterpret_cast(fuzz_json_data), + reinterpret_cast(fuzz_flush), + reinterpret_cast(fuzz_get_random))); + } + + private: + typedef void (*fuzz_json_data_t)( const char* message, size_t length ); + typedef void (*fuzz_flush_t)(); + typedef uint64_t (*fuzz_get_random_t)(); + + + fuzz_json_data_t fuzz_json_data; + fuzz_flush_t fuzz_flush; + fuzz_get_random_t fuzz_get_random; + + AntithesisHandler(fuzz_json_data_t fuzz_json_data, fuzz_flush_t fuzz_flush, fuzz_get_random_t fuzz_get_random) : + fuzz_json_data(fuzz_json_data), fuzz_flush(fuzz_flush), fuzz_get_random(fuzz_get_random) {} + + static void error(const char* message) { + fprintf(stderr, "%s %s: %s\n", ERROR_LOG_LINE_PREFIX, message, dlerror()); + } + }; + + struct LocalHandler : LibHandler{ + ~LocalHandler() override { + if (file != nullptr) { + fclose(file); + } + } + + void output(const char* message) const override { + if (file != nullptr && message != nullptr) { + fprintf(file, "%s\n", message); + } + } + + uint64_t random() override { + return random_gen.random(); + } + + static std::unique_ptr create() { + return std::unique_ptr(new LocalHandler(create_internal())); + } + private: + FILE* file; + LocalRandom random_gen; + + LocalHandler(FILE* file): file(file), random_gen() { + } + + // If `localOutputEnvVar` is set to a non-empty path, attempt to open that path and truncate the file + // to serve as the log file of the local handler. + // Otherwise, we don't have a log file, and logging is a no-op in the local handler. + static FILE* create_internal() { + const char* path = std::getenv(LOCAL_OUTPUT_ENVIRONMENT_VARIABLE); + if (!path || !path[0]) { + return nullptr; + } + + // Open the file for writing (create if needed and possible) and truncate it + FILE* file = fopen(path, "w"); + if (file == nullptr) { + fprintf(stderr, "%s Failed to open path %s: %s\n", ERROR_LOG_LINE_PREFIX, path, strerror(errno)); + return nullptr; + } + int ret = fchmod(fileno(file), 0644); + if (ret != 0) { + fprintf(stderr, "%s Failed to set permissions for path %s: %s\n", ERROR_LOG_LINE_PREFIX, path, strerror(errno)); + fclose(file); + return nullptr; + } + + return file; + } + }; + + static std::unique_ptr init() { + struct stat stat_buf; + if (stat(LIB_PATH, &stat_buf) == 0) { + std::unique_ptr tmp = AntithesisHandler::create(); + if (!tmp) { + fprintf(stderr, "%s Failed to create handler for Antithesis library\n", ERROR_LOG_LINE_PREFIX); + exit(-1); + } + return tmp; + } else { + return LocalHandler::create(); + } + } + + struct AssertionState { + uint8_t false_not_seen : 1; + uint8_t true_not_seen : 1; + uint8_t rest : 6; + + AssertionState() : false_not_seen(true), true_not_seen(true), rest(0) {} + }; + + template + inline constexpr bool always_false_v = false; + + static std::ostream& operator<<(std::ostream& out, const BasicValueType& basic_value) { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) { + out << std::quoted(arg); + } else if constexpr (std::is_same_v) { + out << (arg ? "true" : "false"); + } else if constexpr (std::is_same_v) { + char tmp[2] = {arg, '\0'}; + out << std::quoted(tmp); + } else if constexpr (std::is_same_v) { + out << arg; + } else if constexpr (std::is_same_v) { + out << arg; + } else if constexpr (std::is_same_v) { + out << arg; + } else if constexpr (std::is_same_v) { + out << arg; + } else if constexpr (std::is_same_v) { + out << std::quoted(arg); + } else if constexpr (std::is_same_v) { + if (arg.empty()) { + out << "null"; + } else { + out << arg; + } + } else { + static_assert(always_false_v, "non-exhaustive BasicValueType visitor!"); + } + }, basic_value); + + return out; + } + + static std::ostream& operator<<(std::ostream& out, const ValueType& value) { + std::visit([&](auto&& arg) + { + using T = std::decay_t; + if constexpr (std::is_same_v) { + out << arg; + } else if constexpr (std::is_same_v>) { + out << '['; + bool first = true; + for (auto &item : arg) { + if (!first) { + out << ','; + } + first = false; + out << item; + } + out << ']'; + } else { + static_assert(always_false_v, "non-exhaustive ValueType visitor!"); + } + }, value); + + return out; + } + + static std::ostream& operator<<(std::ostream& out, const JSON& details) { + out << "{ "; + + bool first = true; + for (auto [key, value] : details) { + if (!first) { + out << ", "; + } + out << std::quoted(key) << ": " << value; + first = false; + } + + out << " }"; + return out; + } + + enum AssertionType { + ALWAYS_ASSERTION, + ALWAYS_OR_UNREACHABLE_ASSERTION, + SOMETIMES_ASSERTION, + REACHABLE_ASSERTION, + UNREACHABLE_ASSERTION, + }; + + inline constexpr bool get_must_hit(AssertionType type) { + switch (type) { + case ALWAYS_ASSERTION: + case SOMETIMES_ASSERTION: + case REACHABLE_ASSERTION: + return true; + case ALWAYS_OR_UNREACHABLE_ASSERTION: + case UNREACHABLE_ASSERTION: + return false; + } + } + + inline constexpr const char* get_assert_type_string(AssertionType type) { + switch (type) { + case ALWAYS_ASSERTION: + case ALWAYS_OR_UNREACHABLE_ASSERTION: + return "always"; + case SOMETIMES_ASSERTION: + return "sometimes"; + case REACHABLE_ASSERTION: + case UNREACHABLE_ASSERTION: + return "reachability"; + } + } + + inline constexpr const char* get_display_type_string(AssertionType type) { + switch (type) { + case ALWAYS_ASSERTION: return "Always"; + case ALWAYS_OR_UNREACHABLE_ASSERTION: return "AlwaysOrUnreachable"; + case SOMETIMES_ASSERTION: return "Sometimes"; + case REACHABLE_ASSERTION: return "Reachable"; + case UNREACHABLE_ASSERTION: return "Unreachable"; + } + } + + struct LocationInfo { + const char* class_name; + const char* function_name; + const char* file_name; + const int line; + const int column; + + JSON to_json() const { + return JSON{ + {"class", class_name}, + {"function", function_name}, + {"file", file_name}, + {"begin_line", line}, + {"begin_column", column}, + }; + } + }; + + inline std::string make_key([[maybe_unused]] const char* message, const LocationInfo& location_info) { + return message; + } + + inline LibHandler& get_lib_handler() { + static LibHandler* lib_handler = nullptr; + if (lib_handler == nullptr) { + lib_handler = init().release(); // Leak on exit, rather than exit-time-destructor + + JSON language_block{ + {"name", "C++"}, + {"version", __VERSION__} + }; + + JSON version_message{ + {"antithesis_sdk", JSON{ + {"language", language_block}, + {"sdk_version", SDK_VERSION}, + {"protocol_version", PROTOCOL_VERSION} + } + }}; + lib_handler->output(version_message); + } + + return *lib_handler; + } + + inline void assert_impl(bool cond, const char* message, const JSON& details, const LocationInfo& location_info, + bool hit, bool must_hit, const char* assert_type, const char* display_type, const char* id) { + JSON assertion{ + {"antithesis_assert", JSON{ + {"hit", hit}, + {"must_hit", must_hit}, + {"assert_type", assert_type}, + {"display_type", display_type}, + {"message", message}, + {"condition", cond}, + {"id", id}, + {"location", location_info.to_json()}, + {"details", details}, + }} + }; + get_lib_handler().output(assertion); + } + + inline void assert_raw(bool cond, const char* message, const JSON& details, + const char* class_name, const char* function_name, const char* file_name, const int line, const int column, + bool hit, bool must_hit, const char* assert_type, const char* display_type, const char* id) { + LocationInfo location_info{ class_name, function_name, file_name, line, column }; + assert_impl(cond, message, details, location_info, hit, must_hit, assert_type, display_type, id); + } + + struct Assertion { + AssertionState state; + AssertionType type; + const char* message; + LocationInfo location; + + Assertion(const char* message, AssertionType type, LocationInfo&& location) : + state(), type(type), message(message), location(std::move(location)) { + this->add_to_catalog(); + } + + void add_to_catalog() const { + const bool condition = (type == REACHABLE_ASSERTION ? true : false); + const bool hit = false; + const char* assert_type = get_assert_type_string(type); + const bool must_hit = get_must_hit(type); + const char* display_type = get_display_type_string(type); + std::string id = make_key(message, location); + assert_impl(condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str()); + } + + [[clang::always_inline]] inline void check_assertion(bool cond, const JSON& details) { + #if defined(NO_ANTITHESIS_SDK) + #error "Antithesis SDK has been disabled" + #endif + if (__builtin_expect(state.false_not_seen || state.true_not_seen, false)) { + check_assertion_internal(cond, details); + } + } + + private: + void check_assertion_internal(bool cond, const JSON& details) { + bool emit = false; + if (!cond && state.false_not_seen) { + emit = true; + state.false_not_seen = false; // TODO: is the race OK? + } + + if (cond && state.true_not_seen) { + emit = true; + state.true_not_seen = false; // TODO: is the race OK? + } + + if (emit) { + const bool hit = true; + const char* assert_type = get_assert_type_string(type); + const bool must_hit = get_must_hit(type); + const char* display_type = get_display_type_string(type); + std::string id = make_key(message, location); + assert_impl(cond, message, details, location, hit, must_hit, assert_type, display_type, id.c_str()); + } + } + }; + + inline uint64_t get_random() { + return get_lib_handler().random(); + } + + inline void setup_complete(const JSON& details) { + JSON json{ + { "antithesis_setup", JSON{ + {"status", "complete"}, + {"details", details} + }} + }; + get_lib_handler().output(json); + } + + inline void send_event(const char* name, const JSON& details) { + JSON json = { { name, details } }; + get_lib_handler().output(json); + } +} + +namespace { + template + struct fixed_string { + std::array contents; + constexpr fixed_string() { + for(unsigned int i=0; i from_c_str( const char* s ) { + fixed_string it; + for(unsigned int i=0; i + fixed_string( const char (&arr)[N] ) -> fixed_string; + + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wunsafe-buffer-usage" + static constexpr size_t string_length( const char * s ) { + for(int l = 0; ; l++) + if (!s[l]) + return l; + } + #pragma clang diagnostic pop + + template + struct CatalogEntry { + [[clang::always_inline]] static inline antithesis::Assertion create() { + antithesis::LocationInfo location{ "", function_name.c_str(), file_name.c_str(), line, column }; + return antithesis::Assertion(message.c_str(), type, std::move(location)); + } + + static inline antithesis::Assertion assertion = create(); + }; +} + +#define FIXED_STRING_FROM_C_STR(s) (fixed_string::from_c_str(s)) + +#define ANTITHESIS_ASSERT_RAW(type, cond, message, ...) ( \ + CatalogEntry< \ + type, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(cond, (antithesis::JSON(__VA_ARGS__)) ) ) + +#define ALWAYS(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::ALWAYS_ASSERTION, cond, message, __VA_ARGS__) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::ALWAYS_OR_UNREACHABLE_ASSERTION, cond, message, __VA_ARGS__) +#define SOMETIMES(cond, message, ...) ANTITHESIS_ASSERT_RAW(antithesis::SOMETIMES_ASSERTION, cond, message, __VA_ARGS__) +#define REACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::REACHABLE_ASSERTION, true, message, __VA_ARGS__) +#define UNREACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::UNREACHABLE_ASSERTION, false, message, __VA_ARGS__) + +#endif + +namespace antithesis { + template + Iter random_choice(Iter begin, Iter end) { + ssize_t num_things = end - begin; + if (num_things == 0) { + return end; + } + + uint64_t uval = get_random(); + ssize_t index = uval % num_things; + return begin + index; + } +} diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index 059d9758d39..b6cf76b30a3 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -69,6 +69,10 @@ #error Multiple supported platforms appear active at once #endif +#ifdef ENABLE_VOIDSTAR +#include "antithesis_instrumentation.h" +#endif + namespace po = boost::program_options; namespace ripple { From 06933bb9b11c859f0c731a0bf8c4ed694d513159 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Wed, 12 Jun 2024 12:16:54 +0100 Subject: [PATCH 02/18] Upgrade Antithesis SDK to 0.3.1 --- external/antithesis-sdk/CMakeLists.txt | 2 +- external/antithesis-sdk/antithesis_sdk.h | 28 +++++++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/external/antithesis-sdk/CMakeLists.txt b/external/antithesis-sdk/CMakeLists.txt index e25e53cb736..fbadcedb42c 100644 --- a/external/antithesis-sdk/CMakeLists.txt +++ b/external/antithesis-sdk/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_minimum_required(VERSION 3.25) -project(antithesis-sdk-cpp VERSION $ENV{version} LANGUAGES CXX) +project(antithesis-sdk-cpp VERSION 0.3.1 LANGUAGES CXX) add_library(antithesis-sdk-cpp INTERFACE antithesis_sdk.h) diff --git a/external/antithesis-sdk/antithesis_sdk.h b/external/antithesis-sdk/antithesis_sdk.h index 3586273ab8c..60fb1e882f0 100644 --- a/external/antithesis-sdk/antithesis_sdk.h +++ b/external/antithesis-sdk/antithesis_sdk.h @@ -8,11 +8,12 @@ #include #include #include +#include #include #include namespace antithesis { - inline const char* SDK_VERSION = "0.3.0"; + inline const char* SDK_VERSION = "0.3.1"; inline const char* PROTOCOL_VERSION = "1.0.0"; struct LocalRandom { @@ -436,6 +437,13 @@ namespace antithesis { assert_impl(cond, message, details, location_info, hit, must_hit, assert_type, display_type, id); } + typedef std::set CatalogEntryTracker; + + inline CatalogEntryTracker& get_catalog_entry_tracker() { + static CatalogEntryTracker catalog_entry_tracker; + return catalog_entry_tracker; + } + struct Assertion { AssertionState state; AssertionType type; @@ -448,13 +456,17 @@ namespace antithesis { } void add_to_catalog() const { - const bool condition = (type == REACHABLE_ASSERTION ? true : false); - const bool hit = false; - const char* assert_type = get_assert_type_string(type); - const bool must_hit = get_must_hit(type); - const char* display_type = get_display_type_string(type); std::string id = make_key(message, location); - assert_impl(condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str()); + CatalogEntryTracker& tracker = get_catalog_entry_tracker(); + if (!tracker.contains(id)) { + tracker.insert(id); + const bool condition = (type == REACHABLE_ASSERTION ? true : false); + const bool hit = false; + const char* assert_type = get_assert_type_string(type); + const bool must_hit = get_must_hit(type); + const char* display_type = get_display_type_string(type); + assert_impl(condition, message, {}, location, hit, must_hit, assert_type, display_type, id.c_str()); + } } [[clang::always_inline]] inline void check_assertion(bool cond, const JSON& details) { @@ -478,7 +490,7 @@ namespace antithesis { emit = true; state.true_not_seen = false; // TODO: is the race OK? } - + if (emit) { const bool hit = true; const char* assert_type = get_assert_type_string(type); From 0fe2abeffa173ebf483105b83e72de9665fe5006 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Wed, 12 Jun 2024 12:22:28 +0100 Subject: [PATCH 03/18] Export antithesis-sdk-cpp to enable PUBLIC use --- cmake/RippledCore.cmake | 18 +++++------------- cmake/RippledInstall.cmake | 1 + external/antithesis-sdk/CMakeLists.txt | 10 ++++++++++ 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake index 88f801aef5e..3ccbd8b48d3 100644 --- a/cmake/RippledCore.cmake +++ b/cmake/RippledCore.cmake @@ -74,6 +74,7 @@ target_compile_definitions(xrpl.libxrpl target_compile_options(xrpl.libxrpl PUBLIC $<$:-Wno-maybe-uninitialized> + $<$:-DENABLE_VOIDSTAR> ) target_link_libraries(xrpl.libxrpl @@ -89,19 +90,9 @@ target_link_libraries(xrpl.libxrpl secp256k1::secp256k1 xrpl.libpb xxHash::xxhash + $<$:antithesis-sdk-cpp> ) -if(voidstar) - target_compile_options(xrpl.libxrpl - PRIVATE - -DENABLE_VOIDSTAR - ) - target_include_directories(xrpl.libxrpl - PRIVATE - ${CMAKE_SOURCE_DIR}/external/antithesis-sdk - ) -endif() - add_executable(rippled) if(unity) set_target_properties(rippled PROPERTIES UNITY_BUILD ON) @@ -137,8 +128,9 @@ if(voidstar) target_compile_options(rippled PRIVATE -fsanitize-coverage=trace-pc-guard - -DENABLE_VOIDSTAR ) + # rippled requries access to antithesis-sdk-cpp implementation file + # antithesis_instrumentation.h , which is not exported as INTERFACE target_include_directories(rippled PRIVATE ${CMAKE_SOURCE_DIR}/external/antithesis-sdk @@ -150,7 +142,7 @@ exclude_if_included(rippled) # be exluded or run differently in CI environment if(is_ci) target_compile_definitions(rippled PRIVATE RIPPLED_RUNNING_IN_CI) -endif () +endif() if(reporting) set(suffix -reporting) diff --git a/cmake/RippledInstall.cmake b/cmake/RippledInstall.cmake index d92cecc24eb..0f3e5483f58 100644 --- a/cmake/RippledInstall.cmake +++ b/cmake/RippledInstall.cmake @@ -10,6 +10,7 @@ install ( ripple_boost xrpl.libpb xrpl.libxrpl + antithesis-sdk-cpp EXPORT RippleExports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib diff --git a/external/antithesis-sdk/CMakeLists.txt b/external/antithesis-sdk/CMakeLists.txt index fbadcedb42c..eff594131d0 100644 --- a/external/antithesis-sdk/CMakeLists.txt +++ b/external/antithesis-sdk/CMakeLists.txt @@ -2,3 +2,13 @@ cmake_minimum_required(VERSION 3.25) project(antithesis-sdk-cpp VERSION 0.3.1 LANGUAGES CXX) add_library(antithesis-sdk-cpp INTERFACE antithesis_sdk.h) + +target_include_directories(antithesis-sdk-cpp INTERFACE + $ + $ +) + +install( + FILES antithesis_sdk.h + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) From 75b3f8fbfb01334b8b78be1b9f6984c7b84ff77a Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Thu, 13 Jun 2024 16:31:52 +0100 Subject: [PATCH 04/18] Add XRPL_ASSERT and XRPL_UNREACHABLE --- Builds/levelization/results/loops.txt | 3 + Builds/levelization/results/ordering.txt | 41 +++++++++ cmake/RippledCompiler.cmake | 4 +- include/xrpl/basics/Buffer.h | 4 +- include/xrpl/basics/FeeUnits.h | 12 +-- include/xrpl/basics/SlabAllocator.h | 8 +- include/xrpl/basics/Slice.h | 4 +- include/xrpl/basics/base_uint.h | 7 +- include/xrpl/basics/instrumentation.h | 43 ++++++++++ .../xrpl/basics/partitioned_unordered_map.h | 4 +- include/xrpl/basics/random.h | 4 +- include/xrpl/basics/spinlock.h | 4 +- include/xrpl/beast/asio/io_latency_probe.h | 6 +- include/xrpl/beast/clock/manual_clock.h | 6 +- .../detail/aged_unordered_container.h | 4 +- include/xrpl/beast/core/LexicalCast.h | 7 +- include/xrpl/beast/net/IPAddress.h | 4 +- include/xrpl/beast/net/IPAddressV6.h | 2 +- include/xrpl/beast/utility/Journal.h | 4 +- include/xrpl/beast/utility/rngfill.h | 4 +- include/xrpl/json/detail/json_assert.h | 4 +- include/xrpl/protocol/AmountConversions.h | 10 +-- include/xrpl/protocol/Feature.h | 6 +- include/xrpl/protocol/Indexes.h | 2 +- include/xrpl/protocol/Issue.h | 2 +- include/xrpl/protocol/MultiApiJson.h | 6 +- include/xrpl/protocol/Quality.h | 2 +- include/xrpl/protocol/Rate.h | 2 +- include/xrpl/protocol/STBitString.h | 4 +- include/xrpl/protocol/STBlob.h | 2 +- include/xrpl/protocol/STInteger.h | 4 +- include/xrpl/protocol/STObject.h | 16 ++-- include/xrpl/protocol/STPathSet.h | 6 +- include/xrpl/protocol/STValidation.h | 6 +- include/xrpl/protocol/Serializer.h | 6 +- include/xrpl/protocol/TxMeta.h | 2 +- include/xrpl/protocol/detail/b58_utils.h | 8 +- include/xrpl/resource/detail/Entry.h | 2 +- include/xrpl/resource/detail/Key.h | 2 +- include/xrpl/resource/detail/Logic.h | 6 +- include/xrpl/server/detail/BaseHTTPPeer.h | 2 +- include/xrpl/server/detail/BasePeer.h | 2 +- include/xrpl/server/detail/BaseWSPeer.h | 5 +- src/libxrpl/basics/Log.cpp | 10 +-- src/libxrpl/basics/Number.cpp | 14 ++-- src/libxrpl/basics/ResolverAsio.cpp | 20 ++--- src/libxrpl/basics/contract.cpp | 2 + .../beast/clock/basic_seconds_clock.cpp | 4 +- src/libxrpl/beast/core/SemanticVersion.cpp | 6 +- src/libxrpl/beast/insight/StatsDCollector.cpp | 4 +- .../beast/utility/src/beast_Journal.cpp | 2 +- .../utility/src/beast_PropertyStream.cpp | 6 +- src/libxrpl/crypto/RFC1751.cpp | 18 ++-- src/libxrpl/crypto/csprng.cpp | 2 +- src/libxrpl/json/Object.cpp | 8 +- src/libxrpl/json/json_writer.cpp | 14 ++-- src/libxrpl/protocol/AMMCore.cpp | 2 +- src/libxrpl/protocol/AccountID.cpp | 2 +- src/libxrpl/protocol/BuildInfo.cpp | 2 +- src/libxrpl/protocol/ErrorCodes.cpp | 4 +- src/libxrpl/protocol/Feature.cpp | 8 +- src/libxrpl/protocol/Indexes.cpp | 14 ++-- src/libxrpl/protocol/Keylet.cpp | 2 +- src/libxrpl/protocol/Quality.cpp | 20 ++--- src/libxrpl/protocol/Rate2.cpp | 12 +-- src/libxrpl/protocol/Rules.cpp | 6 +- src/libxrpl/protocol/SField.cpp | 2 +- src/libxrpl/protocol/STAccount.cpp | 4 +- src/libxrpl/protocol/STAmount.cpp | 29 +++---- src/libxrpl/protocol/STBase.cpp | 12 +-- src/libxrpl/protocol/STBlob.cpp | 4 +- src/libxrpl/protocol/STInteger.cpp | 2 +- src/libxrpl/protocol/STLedgerEntry.cpp | 2 +- src/libxrpl/protocol/STObject.cpp | 2 +- src/libxrpl/protocol/STParsedJSON.cpp | 2 +- src/libxrpl/protocol/STPathSet.cpp | 4 +- src/libxrpl/protocol/STTx.cpp | 4 +- src/libxrpl/protocol/STValidation.cpp | 2 +- src/libxrpl/protocol/STVar.cpp | 2 +- src/libxrpl/protocol/STVector256.cpp | 4 +- src/libxrpl/protocol/Serializer.cpp | 6 +- src/libxrpl/protocol/TxMeta.cpp | 18 ++-- src/libxrpl/protocol/tokens.cpp | 8 +- src/libxrpl/resource/Consumer.cpp | 10 +-- src/test/app/AMM_test.cpp | 2 +- src/test/app/AmendmentTable_test.cpp | 2 +- src/test/app/Check_test.cpp | 2 +- src/test/app/DepositAuth_test.cpp | 4 +- src/test/app/LedgerHistory_test.cpp | 2 +- src/test/app/LedgerLoad_test.cpp | 2 +- src/test/app/LedgerReplay_test.cpp | 6 +- src/test/app/Manifest_test.cpp | 2 +- src/test/app/PayChan_test.cpp | 32 +++---- src/test/app/PayStrand_test.cpp | 8 +- src/test/app/Regression_test.cpp | 2 +- src/test/app/TheoreticalQuality_test.cpp | 6 +- src/test/app/XChain_test.cpp | 15 ++-- src/test/basics/base58_test.cpp | 2 +- src/test/basics/base_uint_test.cpp | 2 +- src/test/consensus/NegativeUNL_test.cpp | 2 +- src/test/csf/BasicNetwork.h | 4 +- src/test/csf/Histogram.h | 4 +- src/test/csf/PeerGroup.h | 2 +- src/test/csf/README.md | 2 +- src/test/csf/collectors.h | 4 +- src/test/csf/ledgers.h | 2 +- src/test/jtx/impl/AMM.cpp | 8 +- src/test/jtx/impl/Account.cpp | 2 +- src/test/jtx/impl/Env.cpp | 2 +- src/test/jtx/impl/Oracle.cpp | 4 +- src/test/jtx/impl/amount.cpp | 4 +- src/test/jtx/impl/quality2.cpp | 4 +- src/test/jtx/impl/xchain_bridge.cpp | 8 +- src/test/nodestore/DatabaseShard_test.cpp | 4 +- src/test/overlay/reduce_relay_test.cpp | 30 +++---- src/test/overlay/short_read_test.cpp | 4 +- src/test/overlay/tx_reduce_relay_test.cpp | 2 +- src/test/rpc/Handler_test.cpp | 2 +- src/test/rpc/JSONRPC_test.cpp | 4 +- src/test/shamap/FetchPack_test.cpp | 2 +- src/test/unit_test/multi_runner.cpp | 5 +- src/xrpld/app/consensus/RCLConsensus.cpp | 14 ++-- src/xrpld/app/consensus/RCLCxPeerPos.cpp | 3 +- src/xrpld/app/consensus/RCLCxTx.h | 4 +- src/xrpld/app/consensus/RCLValidations.cpp | 7 +- src/xrpld/app/ledger/AcceptedLedgerTx.cpp | 4 +- src/xrpld/app/ledger/ConsensusTransSetSF.cpp | 4 +- src/xrpld/app/ledger/Ledger.cpp | 40 ++++----- src/xrpld/app/ledger/LedgerHistory.cpp | 26 +++--- src/xrpld/app/ledger/OpenLedger.h | 4 +- src/xrpld/app/ledger/OrderBookDB.cpp | 2 +- src/xrpld/app/ledger/TransactionStateSF.cpp | 2 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 6 +- src/xrpld/app/ledger/detail/InboundLedger.cpp | 16 ++-- .../app/ledger/detail/InboundLedgers.cpp | 10 +-- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 4 +- .../app/ledger/detail/LedgerDeltaAcquire.cpp | 6 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 30 +++---- .../app/ledger/detail/LedgerReplayTask.cpp | 8 +- .../app/ledger/detail/LedgerReplayer.cpp | 2 +- .../app/ledger/detail/SkipListAcquire.cpp | 4 +- .../app/ledger/detail/TimeoutCounter.cpp | 2 +- src/xrpld/app/main/Application.cpp | 34 ++++---- src/xrpld/app/main/GRPCServer.cpp | 4 +- src/xrpld/app/main/LoadManager.cpp | 2 +- src/xrpld/app/main/NodeStoreScheduler.cpp | 2 +- src/xrpld/app/misc/FeeVoteImpl.cpp | 2 +- src/xrpld/app/misc/HashRouter.cpp | 2 +- src/xrpld/app/misc/NegativeUNLVote.cpp | 6 +- src/xrpld/app/misc/NetworkOPs.cpp | 34 ++++---- src/xrpld/app/misc/SHAMapStoreImp.cpp | 6 +- src/xrpld/app/misc/detail/AMMHelpers.cpp | 2 +- src/xrpld/app/misc/detail/AMMUtils.cpp | 2 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 2 +- src/xrpld/app/misc/detail/Manifest.cpp | 2 +- src/xrpld/app/misc/detail/Transaction.cpp | 2 +- src/xrpld/app/misc/detail/TxQ.cpp | 46 +++++----- src/xrpld/app/misc/detail/ValidatorList.cpp | 51 +++++------ src/xrpld/app/misc/detail/ValidatorSite.cpp | 4 +- src/xrpld/app/misc/detail/WorkBase.h | 2 +- src/xrpld/app/misc/detail/WorkFile.h | 4 +- src/xrpld/app/paths/Credit.cpp | 8 +- src/xrpld/app/paths/Flow.cpp | 2 +- src/xrpld/app/paths/PathRequest.cpp | 2 +- src/xrpld/app/paths/Pathfinder.cpp | 13 +-- src/xrpld/app/paths/RippleLineCache.cpp | 6 +- src/xrpld/app/paths/detail/AMMLiquidity.cpp | 2 +- src/xrpld/app/paths/detail/AmountSpec.h | 12 +-- src/xrpld/app/paths/detail/BookStep.cpp | 12 +-- src/xrpld/app/paths/detail/DirectStep.cpp | 10 +-- src/xrpld/app/paths/detail/FlowDebugInfo.h | 4 +- src/xrpld/app/paths/detail/PaySteps.cpp | 10 +-- src/xrpld/app/paths/detail/StepChecks.h | 2 +- src/xrpld/app/paths/detail/StrandFlow.h | 16 ++-- .../app/paths/detail/XRPEndpointStep.cpp | 4 +- src/xrpld/app/rdb/RelationalDatabase.h | 2 +- .../rdb/backend/detail/PostgresDatabase.cpp | 84 +++++++++---------- .../app/rdb/backend/detail/detail/Node.cpp | 9 +- src/xrpld/app/rdb/detail/Vacuum.cpp | 4 +- src/xrpld/app/reporting/ETLHelpers.h | 2 +- src/xrpld/app/reporting/ETLSource.cpp | 8 +- src/xrpld/app/reporting/ETLSource.h | 6 +- src/xrpld/app/reporting/ReportingETL.cpp | 12 +-- src/xrpld/app/reporting/ReportingETL.h | 6 +- src/xrpld/app/tx/detail/AMMBid.cpp | 4 +- src/xrpld/app/tx/detail/AMMDeposit.cpp | 2 +- src/xrpld/app/tx/detail/AMMVote.cpp | 2 +- src/xrpld/app/tx/detail/AMMWithdraw.cpp | 2 +- src/xrpld/app/tx/detail/ApplyContext.cpp | 4 +- src/xrpld/app/tx/detail/Change.cpp | 4 +- src/xrpld/app/tx/detail/CreateOffer.cpp | 20 ++--- src/xrpld/app/tx/detail/DeleteAccount.cpp | 10 +-- src/xrpld/app/tx/detail/NFTokenMint.cpp | 2 +- src/xrpld/app/tx/detail/NFTokenUtils.cpp | 4 +- src/xrpld/app/tx/detail/Offer.h | 2 +- src/xrpld/app/tx/detail/OfferStream.cpp | 4 +- src/xrpld/app/tx/detail/PayChan.cpp | 4 +- src/xrpld/app/tx/detail/Payment.cpp | 2 +- src/xrpld/app/tx/detail/SetSignerList.cpp | 12 +-- src/xrpld/app/tx/detail/Taker.cpp | 40 ++++----- src/xrpld/app/tx/detail/Transactor.cpp | 20 ++--- src/xrpld/app/tx/detail/XChainBridge.cpp | 4 +- src/xrpld/app/tx/detail/applySteps.cpp | 10 +-- src/xrpld/consensus/Consensus.h | 18 ++-- src/xrpld/consensus/ConsensusTypes.h | 2 +- src/xrpld/consensus/LedgerTiming.h | 4 +- src/xrpld/consensus/LedgerTrie.h | 22 ++--- src/xrpld/consensus/Validations.h | 4 +- src/xrpld/core/Coro.ipp | 4 +- src/xrpld/core/DatabaseCon.h | 2 +- src/xrpld/core/JobTypes.h | 6 +- src/xrpld/core/Pg.cpp | 6 +- src/xrpld/core/detail/Config.cpp | 10 +-- src/xrpld/core/detail/DatabaseCon.cpp | 2 +- src/xrpld/core/detail/Job.cpp | 2 +- src/xrpld/core/detail/JobQueue.cpp | 42 +++++----- src/xrpld/core/detail/LoadEvent.cpp | 4 +- src/xrpld/core/detail/Workers.cpp | 4 +- src/xrpld/ledger/ApplyView.h | 2 +- src/xrpld/ledger/ReadView.h | 2 +- src/xrpld/ledger/detail/ApplyStateTable.cpp | 20 ++--- src/xrpld/ledger/detail/ApplyView.cpp | 4 +- src/xrpld/ledger/detail/ApplyViewImpl.cpp | 2 +- src/xrpld/ledger/detail/BookDirs.cpp | 14 ++-- src/xrpld/ledger/detail/Directory.cpp | 10 +-- src/xrpld/ledger/detail/PaymentSandbox.cpp | 13 ++- src/xrpld/ledger/detail/RawStateTable.cpp | 6 +- src/xrpld/ledger/detail/ReadViewFwdRange.ipp | 2 +- src/xrpld/ledger/detail/View.cpp | 60 ++++++------- src/xrpld/net/detail/DatabaseBody.ipp | 2 +- src/xrpld/net/detail/DatabaseDownloader.cpp | 4 +- src/xrpld/net/detail/HTTPStream.cpp | 4 +- src/xrpld/net/detail/InfoSub.cpp | 2 +- src/xrpld/net/detail/RPCCall.cpp | 2 +- src/xrpld/nodestore/Database.h | 8 +- .../nodestore/backend/CassandraFactory.cpp | 10 +-- src/xrpld/nodestore/backend/MemoryFactory.cpp | 6 +- src/xrpld/nodestore/backend/NuDBFactory.cpp | 4 +- .../nodestore/backend/RocksDBFactory.cpp | 8 +- src/xrpld/nodestore/detail/BatchWriter.cpp | 2 +- src/xrpld/nodestore/detail/Database.cpp | 12 +-- src/xrpld/nodestore/detail/DatabaseNodeImp.h | 2 +- .../nodestore/detail/DatabaseShardImp.cpp | 33 ++++---- src/xrpld/nodestore/detail/DecodedBlob.cpp | 4 +- src/xrpld/nodestore/detail/EncodedBlob.h | 6 +- src/xrpld/nodestore/detail/ManagerImp.cpp | 2 +- src/xrpld/nodestore/detail/Shard.cpp | 4 +- src/xrpld/nodestore/detail/TaskQueue.cpp | 6 +- src/xrpld/overlay/Compression.h | 4 +- src/xrpld/overlay/Slot.h | 2 +- src/xrpld/overlay/detail/ConnectAttempt.cpp | 2 +- src/xrpld/overlay/detail/Message.cpp | 4 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 16 ++-- src/xrpld/overlay/detail/OverlayImpl.h | 4 +- src/xrpld/overlay/detail/PeerImp.cpp | 30 +++---- src/xrpld/overlay/detail/ProtocolMessage.h | 4 +- src/xrpld/overlay/detail/TrafficCount.h | 3 +- src/xrpld/overlay/detail/ZeroCopyStream.h | 2 +- src/xrpld/peerfinder/detail/Bootcache.cpp | 4 +- src/xrpld/peerfinder/detail/Counts.h | 8 +- src/xrpld/peerfinder/detail/Handouts.h | 4 +- src/xrpld/peerfinder/detail/Livecache.h | 6 +- src/xrpld/peerfinder/detail/Logic.h | 22 ++--- src/xrpld/peerfinder/detail/SlotImp.cpp | 12 +-- src/xrpld/perflog/detail/PerfLogImp.cpp | 16 ++-- src/xrpld/rpc/Status.h | 6 +- src/xrpld/rpc/detail/Handler.cpp | 8 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 14 ++-- src/xrpld/rpc/detail/RPCHelpers.h | 2 +- src/xrpld/rpc/detail/Role.cpp | 2 +- src/xrpld/rpc/detail/ShardArchiveHandler.cpp | 4 +- src/xrpld/rpc/detail/Status.cpp | 4 +- src/xrpld/rpc/detail/TransactionSign.cpp | 2 +- src/xrpld/rpc/handlers/AMMInfo.cpp | 6 +- src/xrpld/rpc/handlers/AccountChannels.cpp | 2 +- src/xrpld/rpc/handlers/AccountInfo.cpp | 4 +- src/xrpld/rpc/handlers/AccountLines.cpp | 2 +- src/xrpld/rpc/handlers/AccountOffers.cpp | 2 +- src/xrpld/rpc/handlers/AccountTx.cpp | 6 +- src/xrpld/rpc/handlers/Fee1.cpp | 2 +- src/xrpld/rpc/handlers/LedgerClosed.cpp | 2 +- src/xrpld/rpc/handlers/LedgerDiff.cpp | 2 +- src/xrpld/rpc/handlers/LedgerHandler.cpp | 4 +- src/xrpld/rpc/handlers/NodeToShard.cpp | 2 +- src/xrpld/rpc/handlers/PayChanClaim.cpp | 2 +- src/xrpld/rpc/handlers/Tx.cpp | 14 ++-- src/xrpld/shamap/SHAMap.h | 8 +- src/xrpld/shamap/SHAMapItem.h | 4 +- src/xrpld/shamap/detail/SHAMap.cpp | 84 +++++++++---------- src/xrpld/shamap/detail/SHAMapDelta.cpp | 8 +- src/xrpld/shamap/detail/SHAMapInnerNode.cpp | 52 ++++++------ src/xrpld/shamap/detail/SHAMapLeafNode.cpp | 10 +-- src/xrpld/shamap/detail/SHAMapNodeID.cpp | 14 ++-- src/xrpld/shamap/detail/SHAMapSync.cpp | 16 ++-- src/xrpld/shamap/detail/ShardFamily.cpp | 2 +- src/xrpld/shamap/detail/TaggedPointer.ipp | 14 ++-- 296 files changed, 1257 insertions(+), 1148 deletions(-) create mode 100644 include/xrpl/basics/instrumentation.h diff --git a/Builds/levelization/results/loops.txt b/Builds/levelization/results/loops.txt index ee7e6fd3bc6..78e4b1d2aca 100644 --- a/Builds/levelization/results/loops.txt +++ b/Builds/levelization/results/loops.txt @@ -4,6 +4,9 @@ Loop: test.jtx test.toplevel Loop: test.jtx test.unit_test test.unit_test == test.jtx +Loop: xrpl.basics xrpl.beast + xrpl.basics > xrpl.beast + Loop: xrpl.basics xrpl.json xrpl.json ~= xrpl.basics diff --git a/Builds/levelization/results/ordering.txt b/Builds/levelization/results/ordering.txt index 87f9b03a54e..3e04572d36c 100644 --- a/Builds/levelization/results/ordering.txt +++ b/Builds/levelization/results/ordering.txt @@ -1,14 +1,21 @@ libxrpl.basics > xrpl.basics +libxrpl.basics > xrpl.beast libxrpl.basics > xrpl.protocol +libxrpl.beast > xrpl.basics +libxrpl.beast > xrpl.beast libxrpl.crypto > xrpl.basics libxrpl.json > xrpl.basics +libxrpl.json > xrpl.beast libxrpl.json > xrpl.json libxrpl.protocol > xrpl.basics +libxrpl.protocol > xrpl.beast libxrpl.protocol > xrpl.json libxrpl.protocol > xrpl.protocol libxrpl.resource > xrpl.basics +libxrpl.resource > xrpl.beast libxrpl.resource > xrpl.resource libxrpl.server > xrpl.basics +libxrpl.server > xrpl.beast libxrpl.server > xrpl.json libxrpl.server > xrpl.protocol libxrpl.server > xrpl.server @@ -17,6 +24,7 @@ test.app > test.rpc test.app > test.toplevel test.app > test.unit_test test.app > xrpl.basics +test.app > xrpl.beast test.app > xrpld.app test.app > xrpld.core test.app > xrpld.ledger @@ -28,17 +36,21 @@ test.app > xrpl.resource test.basics > test.jtx test.basics > test.unit_test test.basics > xrpl.basics +test.basics > xrpl.beast test.basics > xrpld.perflog test.basics > xrpld.rpc test.basics > xrpl.json test.basics > xrpl.protocol test.beast > xrpl.basics +test.beast > xrpl.beast test.conditions > xrpl.basics +test.conditions > xrpl.beast test.conditions > xrpld.conditions test.consensus > test.csf test.consensus > test.toplevel test.consensus > test.unit_test test.consensus > xrpl.basics +test.consensus > xrpl.beast test.consensus > xrpld.app test.consensus > xrpld.consensus test.consensus > xrpld.ledger @@ -46,17 +58,21 @@ test.core > test.jtx test.core > test.toplevel test.core > test.unit_test test.core > xrpl.basics +test.core > xrpl.beast test.core > xrpld.core test.core > xrpld.perflog test.core > xrpl.json test.core > xrpl.server test.csf > xrpl.basics +test.csf > xrpl.beast test.csf > xrpld.consensus test.csf > xrpl.json test.csf > xrpl.protocol test.json > test.jtx +test.json > xrpl.beast test.json > xrpl.json test.jtx > xrpl.basics +test.jtx > xrpl.beast test.jtx > xrpld.app test.jtx > xrpld.consensus test.jtx > xrpld.core @@ -70,6 +86,7 @@ test.jtx > xrpl.server test.ledger > test.jtx test.ledger > test.toplevel test.ledger > xrpl.basics +test.ledger > xrpl.beast test.ledger > xrpld.app test.ledger > xrpld.core test.ledger > xrpld.ledger @@ -82,6 +99,7 @@ test.nodestore > test.jtx test.nodestore > test.toplevel test.nodestore > test.unit_test test.nodestore > xrpl.basics +test.nodestore > xrpl.beast test.nodestore > xrpld.app test.nodestore > xrpld.core test.nodestore > xrpld.nodestore @@ -90,6 +108,7 @@ test.nodestore > xrpl.protocol test.overlay > test.jtx test.overlay > test.unit_test test.overlay > xrpl.basics +test.overlay > xrpl.beast test.overlay > xrpld.app test.overlay > xrpld.overlay test.overlay > xrpld.peerfinder @@ -98,20 +117,24 @@ test.overlay > xrpl.protocol test.peerfinder > test.beast test.peerfinder > test.unit_test test.peerfinder > xrpl.basics +test.peerfinder > xrpl.beast test.peerfinder > xrpld.core test.peerfinder > xrpld.peerfinder test.peerfinder > xrpl.protocol test.protocol > test.toplevel test.protocol > xrpl.basics +test.protocol > xrpl.beast test.protocol > xrpl.json test.protocol > xrpl.protocol test.resource > test.unit_test test.resource > xrpl.basics +test.resource > xrpl.beast test.resource > xrpl.resource test.rpc > test.jtx test.rpc > test.nodestore test.rpc > test.toplevel test.rpc > xrpl.basics +test.rpc > xrpl.beast test.rpc > xrpld.app test.rpc > xrpld.core test.rpc > xrpld.net @@ -125,6 +148,7 @@ test.server > test.jtx test.server > test.toplevel test.server > test.unit_test test.server > xrpl.basics +test.server > xrpl.beast test.server > xrpld.app test.server > xrpld.core test.server > xrpld.rpc @@ -132,22 +156,29 @@ test.server > xrpl.json test.server > xrpl.server test.shamap > test.unit_test test.shamap > xrpl.basics +test.shamap > xrpl.beast test.shamap > xrpld.nodestore test.shamap > xrpld.shamap test.shamap > xrpl.protocol test.toplevel > test.csf test.toplevel > xrpl.json test.unit_test > xrpl.basics +test.unit_test > xrpl.beast +xrpl.json > xrpl.beast xrpl.protocol > xrpl.basics +xrpl.protocol > xrpl.beast xrpl.protocol > xrpl.json xrpl.resource > xrpl.basics +xrpl.resource > xrpl.beast xrpl.resource > xrpl.json xrpl.resource > xrpl.protocol xrpl.server > xrpl.basics +xrpl.server > xrpl.beast xrpl.server > xrpl.json xrpl.server > xrpl.protocol xrpld.app > test.unit_test xrpld.app > xrpl.basics +xrpld.app > xrpl.beast xrpld.app > xrpld.conditions xrpld.app > xrpld.consensus xrpld.app > xrpld.perflog @@ -157,25 +188,31 @@ xrpld.app > xrpl.resource xrpld.conditions > xrpl.basics xrpld.conditions > xrpl.protocol xrpld.consensus > xrpl.basics +xrpld.consensus > xrpl.beast xrpld.consensus > xrpl.json xrpld.consensus > xrpl.protocol xrpld.core > xrpl.basics +xrpld.core > xrpl.beast xrpld.core > xrpl.json xrpld.core > xrpl.protocol xrpld.ledger > xrpl.basics +xrpld.ledger > xrpl.beast xrpld.ledger > xrpld.core xrpld.ledger > xrpl.json xrpld.ledger > xrpl.protocol xrpld.net > xrpl.basics +xrpld.net > xrpl.beast xrpld.net > xrpl.json xrpld.net > xrpl.protocol xrpld.net > xrpl.resource xrpld.nodestore > xrpl.basics +xrpld.nodestore > xrpl.beast xrpld.nodestore > xrpld.core xrpld.nodestore > xrpld.unity xrpld.nodestore > xrpl.json xrpld.nodestore > xrpl.protocol xrpld.overlay > xrpl.basics +xrpld.overlay > xrpl.beast xrpld.overlay > xrpld.core xrpld.overlay > xrpld.peerfinder xrpld.overlay > xrpl.json @@ -183,13 +220,16 @@ xrpld.overlay > xrpl.protocol xrpld.overlay > xrpl.resource xrpld.overlay > xrpl.server xrpld.peerfinder > xrpl.basics +xrpld.peerfinder > xrpl.beast xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpl.protocol xrpld.perflog > xrpl.basics +xrpld.perflog > xrpl.beast xrpld.perflog > xrpld.nodestore xrpld.perflog > xrpl.json xrpld.perflog > xrpl.protocol xrpld.rpc > xrpl.basics +xrpld.rpc > xrpl.beast xrpld.rpc > xrpld.core xrpld.rpc > xrpld.ledger xrpld.rpc > xrpld.nodestore @@ -199,5 +239,6 @@ xrpld.rpc > xrpl.protocol xrpld.rpc > xrpl.resource xrpld.rpc > xrpl.server xrpld.shamap > xrpl.basics +xrpld.shamap > xrpl.beast xrpld.shamap > xrpld.nodestore xrpld.shamap > xrpl.protocol diff --git a/cmake/RippledCompiler.cmake b/cmake/RippledCompiler.cmake index 6b6c191da0a..f5c54a17e62 100644 --- a/cmake/RippledCompiler.cmake +++ b/cmake/RippledCompiler.cmake @@ -132,7 +132,9 @@ else () endif () if (voidstar) - if (NOT is_linux) + if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + message(FATAL_ERROR "Antithesis instrumentation requires Debug build type, aborting...") + elseif (NOT is_linux) message(FATAL_ERROR "Antithesis instrumentation requires Linux, aborting...") elseif (NOT (is_clang AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0)) message(FATAL_ERROR "Antithesis instrumentation requires Clang version 16 or later, aborting...") diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index 25ae8ca315c..dba09c18397 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -21,7 +21,7 @@ #define RIPPLE_BASICS_BUFFER_H_INCLUDED #include -#include +#include #include #include #include @@ -112,7 +112,7 @@ class Buffer operator=(Slice s) { // Ensure the slice isn't a subset of the buffer. - assert( + XRPL_ASSERT( s.size() == 0 || size_ == 0 || s.data() < p_.get() || s.data() >= p_.get() + size_); diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 9d5e6e216a4..35f63d8485f 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -20,16 +20,16 @@ #define BASICS_FEES_H_INCLUDED #include +#include #include -#include -#include -#include #include #include #include +#include #include #include +#include namespace ripple { @@ -417,9 +417,9 @@ mulDivU(Source1 value, Dest mul, Source2 div) { // split the asserts so if one hits, the user can tell which // without a debugger. - assert(value.value() >= 0); - assert(mul.value() >= 0); - assert(div.value() >= 0); + XRPL_ASSERT(value.value() >= 0); + XRPL_ASSERT(mul.value() >= 0); + XRPL_ASSERT(div.value() >= 0); return std::nullopt; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 5c4cba343cf..b155312b871 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED +#include #include #include @@ -28,7 +29,6 @@ #include #include -#include #include #include #include @@ -141,7 +141,7 @@ class SlabAllocator void deallocate(std::uint8_t* ptr) noexcept { - assert(own(ptr)); + XRPL_ASSERT(own(ptr)); std::lock_guard l(m_); @@ -184,7 +184,7 @@ class SlabAllocator boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { - assert((itemAlignment_ & (itemAlignment_ - 1)) == 0); + XRPL_ASSERT((itemAlignment_ & (itemAlignment_ - 1)) == 0); } SlabAllocator(SlabAllocator const& other) = delete; @@ -294,7 +294,7 @@ class SlabAllocator bool deallocate(std::uint8_t* ptr) noexcept { - assert(ptr); + XRPL_ASSERT(ptr); for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) { diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 00126f8882d..7a04443e01e 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -21,10 +21,10 @@ #define RIPPLE_BASICS_SLICE_H_INCLUDED #include +#include #include #include #include -#include #include #include #include @@ -103,7 +103,7 @@ class Slice std::uint8_t operator[](std::size_t i) const noexcept { - assert(i < size_); + XRPL_ASSERT(i < size_); return data_[i]; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index 2b44d3072ee..03302e16650 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -289,7 +290,8 @@ class base_uint std::is_trivially_copyable::value>> explicit base_uint(Container const& c) { - assert(c.size() * sizeof(typename Container::value_type) == size()); + XRPL_ASSERT( + c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); } @@ -300,7 +302,8 @@ class base_uint base_uint&> operator=(Container const& c) { - assert(c.size() * sizeof(typename Container::value_type) == size()); + XRPL_ASSERT( + c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); return *this; } diff --git a/include/xrpl/basics/instrumentation.h b/include/xrpl/basics/instrumentation.h new file mode 100644 index 00000000000..ee3e5e0e99f --- /dev/null +++ b/include/xrpl/basics/instrumentation.h @@ -0,0 +1,43 @@ +//------------------------------------------------------------------------------ +/* +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_BASICS_INSTRUMENTATION_H_INCLUDED +#define RIPPLE_BASICS_INSTRUMENTATION_H_INCLUDED + +#include + +#ifdef ENABLE_VOIDSTAR +#include +#else +#define ALWAYS(cond, message, ...) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message&& cond) +#define SOMETIMES(cond, message, ...) +#define REACHABLE(message, ...) +#define UNREACHABLE(message, ...) assert(message && false) +#endif + +#ifndef NDEBUG +#define XRPL_ASSERT(...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), "", {}) +#define XRPL_UNREACHABLE() UNREACHABLE("", {}) +#else +#define XRPL_ASSERT(...) +#define XRPL_UNREACHABLE() +#endif + +#endif diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index 08f4cba9d3e..f6022a3b1b6 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H #define RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H -#include +#include #include #include #include @@ -246,7 +246,7 @@ class partitioned_unordered_map ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); - assert(partitions_); + XRPL_ASSERT(partitions_); } std::size_t diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index 87b303bf6d5..ea4eb431ec9 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED #define RIPPLE_BASICS_RANDOM_H_INCLUDED +#include #include -#include #include #include #include @@ -114,7 +114,7 @@ std::enable_if_t< Integral> rand_int(Engine& engine, Integral min, Integral max) { - assert(max > min); + XRPL_ASSERT(max > min); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index 85a2ac41d51..fbf0995c055 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -18,8 +18,8 @@ #ifndef RIPPLE_BASICS_SPINLOCK_H_INCLUDED #define RIPPLE_BASICS_SPINLOCK_H_INCLUDED +#include #include -#include #include #include @@ -117,7 +117,7 @@ class packed_spinlock packed_spinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { - assert(index >= 0 && (mask_ != 0)); + XRPL_ASSERT(index >= 0 && (mask_ != 0)); } [[nodiscard]] bool diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index bbde13af687..578b1c0a40c 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -20,8 +20,10 @@ #ifndef BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED #define BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED +#include #include #include + #include #include #include @@ -172,7 +174,7 @@ class io_latency_probe , m_repeat(repeat) , m_probe(probe) { - assert(m_probe); + XRPL_ASSERT(m_probe); m_probe->addref(); } @@ -182,7 +184,7 @@ class io_latency_probe , m_repeat(from.m_repeat) , m_probe(from.m_probe) { - assert(m_probe); + XRPL_ASSERT(m_probe); from.m_probe = nullptr; } diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index 97be8e79b90..a444b568667 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -20,8 +20,8 @@ #ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED +#include #include -#include namespace beast { @@ -61,7 +61,7 @@ class manual_clock : public abstract_clock void set(time_point const& when) { - assert(!Clock::is_steady || when >= now_); + XRPL_ASSERT(!Clock::is_steady || when >= now_); now_ = when; } @@ -78,7 +78,7 @@ class manual_clock : public abstract_clock void advance(std::chrono::duration const& elapsed) { - assert(!Clock::is_steady || (now_ + elapsed) >= now_); + XRPL_ASSERT(!Clock::is_steady || (now_ + elapsed) >= now_); now_ += elapsed; } diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 45efb3f5561..5744f0aad21 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1329,7 +1329,7 @@ class aged_unordered_container size_type bucket(Key const& k) const { - assert(bucket_count() != 0); + XRPL_ASSERT(bucket_count() != 0); return m_cont.bucket(k, std::cref(m_config.hash_function())); } @@ -1470,7 +1470,7 @@ class aged_unordered_container { if (would_exceed(additional)) m_buck.resize(size() + additional, m_cont); - assert(load_factor() <= max_load_factor()); + XRPL_ASSERT(load_factor() <= max_load_factor()); } // map, set diff --git a/include/xrpl/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h index e0fa24ca9f5..a7593b46378 100644 --- a/include/xrpl/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -20,9 +20,10 @@ #ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED #define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED +#include + #include #include -#include #include #include #include @@ -159,7 +160,7 @@ struct LexicalCast bool operator()(Out& out, char const* in) const { - assert(in); + XRPL_ASSERT(in); return LexicalCast()(out, in); } }; @@ -174,7 +175,7 @@ struct LexicalCast bool operator()(Out& out, char* in) const { - assert(in); + XRPL_ASSERT(in); return LexicalCast()(out, in); } }; diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index f3a1a7348f2..182bc9ef2ff 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -20,13 +20,13 @@ #ifndef BEAST_NET_IPADDRESS_H_INCLUDED #define BEAST_NET_IPADDRESS_H_INCLUDED +#include #include #include #include #include #include #include -#include #include #include #include @@ -96,7 +96,7 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept else if (addr.is_v6()) hash_append(h, addr.to_v6().to_bytes()); else - assert(false); + XRPL_UNREACHABLE(); } } // namespace beast diff --git a/include/xrpl/beast/net/IPAddressV6.h b/include/xrpl/beast/net/IPAddressV6.h index 74eb6b96d8e..ec2e38f60e5 100644 --- a/include/xrpl/beast/net/IPAddressV6.h +++ b/include/xrpl/beast/net/IPAddressV6.h @@ -20,8 +20,8 @@ #ifndef BEAST_NET_IPADDRESSV6_H_INCLUDED #define BEAST_NET_IPADDRESSV6_H_INCLUDED +#include #include -#include #include #include #include diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 0738748b6c5..5e4e6d09fe5 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_JOURNAL_H_INCLUDED #define BEAST_UTILITY_JOURNAL_H_INCLUDED -#include +#include #include namespace beast { @@ -205,7 +205,7 @@ class Journal */ Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) { - assert(m_level < severities::kDisabled); + XRPL_ASSERT(m_level < severities::kDisabled); } /** Construct or copy another Stream. */ diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index 71f434bdaf9..9b4774af997 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -20,8 +20,8 @@ #ifndef BEAST_RANDOM_RNGFILL_H_INCLUDED #define BEAST_RANDOM_RNGFILL_H_INCLUDED +#include #include -#include #include #include #include @@ -42,7 +42,7 @@ rngfill(void* buffer, std::size_t bytes, Generator& g) bytes -= sizeof(v); } - assert(bytes < sizeof(result_type)); + XRPL_ASSERT(bytes < sizeof(result_type)); #ifdef __GNUC__ // gcc 11.1 (falsely) warns about an array-bounds overflow in release mode. diff --git a/include/xrpl/json/detail/json_assert.h b/include/xrpl/json/detail/json_assert.h index c401ccf7200..10074062d90 100644 --- a/include/xrpl/json/detail/json_assert.h +++ b/include/xrpl/json/detail/json_assert.h @@ -22,9 +22,9 @@ #include -#define JSON_ASSERT_UNREACHABLE assert(false) +#define JSON_ASSERT_UNREACHABLE XRPL_UNREACHABLE() #define JSON_ASSERT(condition) \ - assert(condition); // @todo <= change this into an exception throw + XRPL_ASSERT(condition); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE(condition, message) \ if (!(condition)) \ ripple::Throw(message); diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index 0348e3c975d..e8c7a53c131 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -59,7 +59,7 @@ toSTAmount(XRPAmount const& xrp) inline STAmount toSTAmount(XRPAmount const& xrp, Issue const& iss) { - assert(isXRP(iss.account) && isXRP(iss.currency)); + XRPL_ASSERT(isXRP(iss.account) && isXRP(iss.currency)); return toSTAmount(xrp); } @@ -78,12 +78,12 @@ template <> inline IOUAmount toAmount(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - assert(!isXRP(amt)); + XRPL_ASSERT(!isXRP(amt)); return IOUAmount(sMant, amt.exponent()); } @@ -91,12 +91,12 @@ template <> inline XRPAmount toAmount(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - assert(isXRP(amt)); + XRPL_ASSERT(isXRP(amt)); return XRPAmount(sMant); } diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 7eec46e89eb..481efcd111b 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -151,14 +151,14 @@ class FeatureBitset : private std::bitset explicit FeatureBitset(base const& b) : base(b) { - assert(b.count() == count()); + XRPL_ASSERT(b.count() == count()); } template explicit FeatureBitset(uint256 const& f, Fs&&... fs) { initFromFeatures(f, std::forward(fs)...); - assert(count() == (sizeof...(fs) + 1)); + XRPL_ASSERT(count() == (sizeof...(fs) + 1)); } template @@ -166,7 +166,7 @@ class FeatureBitset : private std::bitset { for (auto const& f : fs) set(featureToBitsetIndex(f)); - assert(fs.size() == count()); + XRPL_ASSERT(fs.size() == count()); } auto diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index f179bbacfab..40116d9638c 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -214,7 +214,7 @@ page(uint256 const& root, std::uint64_t index = 0) noexcept; inline Keylet page(Keylet const& root, std::uint64_t index = 0) noexcept { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); return page(root.key, index); } /** @} */ diff --git a/include/xrpl/protocol/Issue.h b/include/xrpl/protocol/Issue.h index a18502f2138..3bdb4ba5804 100644 --- a/include/xrpl/protocol/Issue.h +++ b/include/xrpl/protocol/Issue.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_ISSUE_H_INCLUDED #define RIPPLE_PROTOCOL_ISSUE_H_INCLUDED +#include #include #include -#include #include #include diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 4514c54ea34..bea99ca889e 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -23,8 +23,8 @@ #include #include +#include #include -#include #include #include #include @@ -158,7 +158,7 @@ struct MultiApiJson -> std:: invoke_result_t { - assert( + XRPL_ASSERT( valid(version) && index(version) >= 0 && index(version) < size); return std::invoke( fn, @@ -175,7 +175,7 @@ struct MultiApiJson operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { - assert( + XRPL_ASSERT( valid(version) && index(version) >= 0 && index(version) < size); return std::invoke(fn, json.val[index(version)]); } diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 1ee2cc9f686..9fee7fd4cf8 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -298,7 +298,7 @@ class Quality friend double relativeDistance(Quality const& q1, Quality const& q2) { - assert(q1.m_value > 0 && q2.m_value > 0); + XRPL_ASSERT(q1.m_value > 0 && q2.m_value > 0); if (q1.m_value == q2.m_value) // make expected common case fast return 0; diff --git a/include/xrpl/protocol/Rate.h b/include/xrpl/protocol/Rate.h index b065acb2316..9315e4c742a 100644 --- a/include/xrpl/protocol/Rate.h +++ b/include/xrpl/protocol/Rate.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_RATE_H_INCLUDED #define RIPPLE_PROTOCOL_RATE_H_INCLUDED +#include #include #include -#include #include #include diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index 7dc92303e72..e810c784dc0 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -162,8 +162,8 @@ template void STBitString::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == getSType()); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == getSType()); s.addBitString(value_); } diff --git a/include/xrpl/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h index bdedbd92105..105cb15a8d4 100644 --- a/include/xrpl/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -23,9 +23,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 6bae2cc3152..747d9a9dddb 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -110,8 +110,8 @@ template inline void STInteger::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == getSType()); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == getSType()); s.addInteger(value_); } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index b3cef83de5f..bd5bc5c0048 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -715,7 +715,7 @@ STObject::Proxy::assign(U&& u) t = dynamic_cast(st_->getPField(*f_, true)); else t = dynamic_cast(st_->makeFieldPresent(*f_)); - assert(t); + XRPL_ASSERT(t); *t = std::forward(u); } @@ -993,13 +993,13 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - assert(mType); - assert(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT(mType); + XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); if (mType->style(f) == soeOPTIONAL) Throw("Missing optional field: " + f.getName()); - assert(mType->style(f) == soeDEFAULT); + XRPL_ASSERT(mType->style(f) == soeDEFAULT); // Used to help handle the case where value_type is a const reference, // otherwise we would return the address of a temporary. @@ -1017,11 +1017,11 @@ STObject::at(OptionaledField const& of) const auto const u = dynamic_cast(b); if (!u) { - assert(mType); - assert(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT(mType); + XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); if (mType->style(*of.f) == soeOPTIONAL) return std::nullopt; - assert(mType->style(*of.f) == soeDEFAULT); + XRPL_ASSERT(mType->style(*of.f) == soeDEFAULT); return typename T::value_type{}; } return u->value(); diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index 473086368fb..80222e009ba 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -21,11 +21,11 @@ #define RIPPLE_PROTOCOL_STPATHSET_H_INCLUDED #include +#include #include #include #include #include -#include #include #include @@ -257,7 +257,7 @@ inline STPathElement::STPathElement( is_offer_ = false; mAccountID = *account; mType |= typeAccount; - assert(mAccountID != noAccount()); + XRPL_ASSERT(mAccountID != noAccount()); } if (currency) @@ -270,7 +270,7 @@ inline STPathElement::STPathElement( { mIssuerID = *issuer; mType |= typeIssuer; - assert(mIssuerID != noAccount()); + XRPL_ASSERT(mIssuerID != noAccount()); } hash_value_ = get_hash(*this); diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index 6cae0971f51..db6394d55d4 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -22,10 +22,10 @@ #include #include +#include #include #include #include -#include #include #include #include @@ -176,7 +176,7 @@ STValidation::STValidation( Throw("Invalid signature in validation"); } - assert(nodeID_.isNonZero()); + XRPL_ASSERT(nodeID_.isNonZero()); } /** Construct, sign and trust a new STValidation issued by this node. @@ -199,7 +199,7 @@ STValidation::STValidation( , nodeID_(nodeID) , seenTime_(signTime) { - assert(nodeID_.isNonZero()); + XRPL_ASSERT(nodeID_.isNonZero()); // First, set our own public key: if (publicKeyType(pk) != KeyType::secp256k1) diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index b85e8eb013d..a03a9eaf6ed 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -25,11 +25,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -55,7 +55,7 @@ class Serializer if (size) { - assert(data != nullptr); + XRPL_ASSERT(data != nullptr); std::memcpy(mData.data(), data, size); } } @@ -300,7 +300,7 @@ Serializer::addVL(Iter begin, Iter end, int len) len -= begin->size(); #endif } - assert(len == 0); + XRPL_ASSERT(len == 0); return ret; } diff --git a/include/xrpl/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h index 7932a4c55a3..32a0b3601a0 100644 --- a/include/xrpl/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -116,7 +116,7 @@ class TxMeta STAmount getDeliveredAmount() const { - assert(hasDeliveredAmount()); + XRPL_ASSERT(hasDeliveredAmount()); return *mDelivered; } diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index f21b416042b..c191ea66527 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -21,11 +21,11 @@ #define RIPPLE_PROTOCOL_B58_UTILS_H_INCLUDED #include +#include #include #include -#include #include #include #include @@ -126,7 +126,7 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) { // should never happen, but if it does then it seems natural to define // the a null set of numbers to be zero, so the remainder is also zero. - assert(0); + XRPL_ASSERT(0); return 0; } @@ -142,8 +142,8 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) unsigned __int128 const denom128 = denom; unsigned __int128 const d = num / denom128; unsigned __int128 const r = num - (denom128 * d); - assert(d >> 64 == 0); - assert(r >> 64 == 0); + XRPL_ASSERT(d >> 64 == 0); + XRPL_ASSERT(r >> 64 == 0); return {static_cast(d), static_cast(r)}; }; diff --git a/include/xrpl/resource/detail/Entry.h b/include/xrpl/resource/detail/Entry.h index d4f32080d9d..7364c22c265 100644 --- a/include/xrpl/resource/detail/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -21,11 +21,11 @@ #define RIPPLE_RESOURCE_ENTRY_H_INCLUDED #include +#include #include #include #include #include -#include namespace ripple { namespace Resource { diff --git a/include/xrpl/resource/detail/Key.h b/include/xrpl/resource/detail/Key.h index 3df2dce039d..772b1ed9191 100644 --- a/include/xrpl/resource/detail/Key.h +++ b/include/xrpl/resource/detail/Key.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RESOURCE_KEY_H_INCLUDED #define RIPPLE_RESOURCE_KEY_H_INCLUDED +#include #include #include -#include namespace ripple { namespace Resource { diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index a57e529e0a2..8067b714ed7 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include namespace ripple { @@ -401,7 +401,7 @@ class Logic { std::lock_guard _(lock_); Entry& entry(iter->second); - assert(entry.refcount == 0); + XRPL_ASSERT(entry.refcount == 0); inactive_.erase(inactive_.iterator_to(entry)); table_.erase(iter); } @@ -433,7 +433,7 @@ class Logic admin_.erase(admin_.iterator_to(entry)); break; default: - assert(false); + XRPL_UNREACHABLE(); break; } inactive_.push_back(entry); diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index 171eb7134e1..d0a798d723a 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -21,6 +21,7 @@ #define RIPPLE_SERVER_BASEHTTPPEER_H_INCLUDED #include +#include #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/include/xrpl/server/detail/BasePeer.h b/include/xrpl/server/detail/BasePeer.h index a90eaabf6e4..2dbc4fb640e 100644 --- a/include/xrpl/server/detail/BasePeer.h +++ b/include/xrpl/server/detail/BasePeer.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_SERVER_BASEPEER_H_INCLUDED #define RIPPLE_SERVER_BASEPEER_H_INCLUDED +#include #include #include #include #include #include #include -#include #include #include diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 4c4049a8b9b..2bd63053ffa 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -20,17 +20,18 @@ #ifndef RIPPLE_SERVER_BASEWSPEER_H_INCLUDED #define RIPPLE_SERVER_BASEWSPEER_H_INCLUDED +#include #include #include #include #include #include #include + #include #include #include -#include #include namespace ripple { @@ -508,7 +509,7 @@ template void BaseWSPeer::fail(error_code ec, String const& what) { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); cancel_timer(); if (!ec_ && ec != boost::asio::error::operation_aborted) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 3d5963cc266..8f27dfe6d02 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -20,8 +20,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -224,7 +224,7 @@ Logs::fromSeverity(beast::severities::Severity level) return lsERROR; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case kFatal: break; @@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level) case lsERROR: return kError; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case lsFATAL: break; @@ -277,7 +277,7 @@ Logs::toString(LogSeverity s) case lsFATAL: return "Fatal"; default: - assert(false); + XRPL_UNREACHABLE(); return "Unknown"; } } @@ -341,7 +341,7 @@ Logs::format( output += "ERR "; break; default: - assert(false); + XRPL_UNREACHABLE(); [[fallthrough]]; case kFatal: output += "FTL "; diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 14260b653a2..729a0a1a776 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include #include #include #include @@ -235,7 +235,7 @@ Number::operator+=(Number const& y) *this = Number{}; return *this; } - assert(isnormal() && y.isnormal()); + XRPL_ASSERT(isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -374,7 +374,7 @@ Number::operator*=(Number const& y) *this = y; return *this; } - assert(isnormal() && y.isnormal()); + XRPL_ASSERT(isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -428,7 +428,7 @@ Number::operator*=(Number const& y) std::to_string(xe)); mantissa_ = xm * zn; exponent_ = xe; - assert(isnormal() || *this == Number{}); + XRPL_ASSERT(isnormal() || *this == Number{}); return *this; } @@ -531,7 +531,7 @@ to_string(Number const& amount) negative = true; } - assert(exponent + 43 > 0); + XRPL_ASSERT(exponent + 43 > 0); ptrdiff_t const pad_prefix = 27; ptrdiff_t const pad_suffix = 23; @@ -557,7 +557,7 @@ to_string(Number const& amount) if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - assert(post_to >= post_from); + XRPL_ASSERT(post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -566,7 +566,7 @@ to_string(Number const& amount) if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - assert(post_to >= post_from); + XRPL_ASSERT(post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 53530da9d8f..9570a44ccf2 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -19,11 +19,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -48,7 +48,7 @@ class AsyncObject ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - assert(m_pending.load() == 0); + XRPL_ASSERT(m_pending.load() == 0); } /** RAII container that maintains the count of pending I/O. @@ -153,8 +153,8 @@ class ResolverAsioImpl : public ResolverAsio, ~ResolverAsioImpl() override { - assert(m_work.empty()); - assert(m_stopped); + XRPL_ASSERT(m_work.empty()); + XRPL_ASSERT(m_stopped); } //------------------------------------------------------------------------- @@ -176,8 +176,8 @@ class ResolverAsioImpl : public ResolverAsio, void start() override { - assert(m_stopped == true); - assert(m_stop_called == false); + XRPL_ASSERT(m_stopped == true); + XRPL_ASSERT(m_stop_called == false); if (m_stopped.exchange(false) == true) { @@ -217,8 +217,8 @@ class ResolverAsioImpl : public ResolverAsio, resolve(std::vector const& names, HandlerType const& handler) override { - assert(m_stop_called == false); - assert(!names.empty()); + XRPL_ASSERT(m_stop_called == false); + XRPL_ASSERT(!names.empty()); // TODO NIKB use rvalue references to construct and move // reducing cost. @@ -234,7 +234,7 @@ class ResolverAsioImpl : public ResolverAsio, // Resolver void do_stop(CompletionCounter) { - assert(m_stop_called == true); + XRPL_ASSERT(m_stop_called == true); if (m_stopped.exchange(true) == false) { @@ -379,7 +379,7 @@ class ResolverAsioImpl : public ResolverAsio, HandlerType const& handler, CompletionCounter) { - assert(!names.empty()); + XRPL_ASSERT(!names.empty()); if (m_stop_called == false) { diff --git a/src/libxrpl/basics/contract.cpp b/src/libxrpl/basics/contract.cpp index fbda83c7a63..76b98e59500 100644 --- a/src/libxrpl/basics/contract.cpp +++ b/src/libxrpl/basics/contract.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -48,6 +49,7 @@ LogicError(std::string const& s) noexcept { JLOG(debugLog().fatal()) << s; std::cerr << "Logic error: " << s << std::endl; + UNREACHABLE("LogicError", {{"message", s}}); detail::accessViolation(); } diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index f5af8bd16ec..dbf33b17b22 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include -#include #include #include #include @@ -57,7 +57,7 @@ static_assert(std::atomic::is_always_lock_free); seconds_clock_thread::~seconds_clock_thread() { - assert(thread_.joinable()); + XRPL_ASSERT(thread_.joinable()); { std::lock_guard lock(mut_); stop_ = true; diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index b33ed2f48f4..d20e53121e9 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -17,11 +17,11 @@ */ //============================================================================== +#include #include #include #include -#include #include namespace beast { @@ -304,7 +304,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) if (isNumeric(left)) { - assert(isNumeric(right)); + XRPL_ASSERT(isNumeric(right)); int const iLeft(lexicalCastThrow(left)); int const iRight(lexicalCastThrow(right)); @@ -316,7 +316,7 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) } else { - assert(!isNumeric(right)); + XRPL_ASSERT(!isNumeric(right)); int result = left.compare(right); diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index 76ae15b82d5..da5b518c379 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -400,7 +400,7 @@ class StatsDCollectorImp for (auto const& s : *keepAlive) { std::size_t const length(s.size()); - assert(!s.empty()); + XRPL_ASSERT(!s.empty()); if (!buffers.empty() && (size + length) > max_packet_size) { log(buffers); diff --git a/src/libxrpl/beast/utility/src/beast_Journal.cpp b/src/libxrpl/beast/utility/src/beast_Journal.cpp index 261e1f6ccab..08dffb45524 100644 --- a/src/libxrpl/beast/utility/src/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/src/beast_Journal.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include namespace beast { diff --git a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index 56e862ca8c0..77dbaae1da0 100644 --- a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include #include @@ -199,7 +199,7 @@ PropertyStream::Source::add(Source& source) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(source.lock_, std::adopt_lock); - assert(source.parent_ == nullptr); + XRPL_ASSERT(source.parent_ == nullptr); children_.push_back(source.item_); source.parent_ = this; } @@ -211,7 +211,7 @@ PropertyStream::Source::remove(Source& child) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(child.lock_, std::adopt_lock); - assert(child.parent_ == this); + XRPL_ASSERT(child.parent_ == this); children_.erase(children_.iterator_to(child.item_)); child.parent_ = nullptr; } diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index 1c6f28287b0..a7f7167442d 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include #include -#include #include #include @@ -270,10 +270,10 @@ RFC1751::extract(char const* s, int start, int length) unsigned char cr; unsigned long x; - assert(length <= 11); - assert(start >= 0); - assert(length >= 0); - assert(start + length <= 66); + XRPL_ASSERT(length <= 11); + XRPL_ASSERT(start >= 0); + XRPL_ASSERT(length >= 0); + XRPL_ASSERT(start + length <= 66); int const shiftR = 24 - (length + (start % 8)); cl = s[start / 8]; // get components @@ -320,10 +320,10 @@ RFC1751::insert(char* s, int x, int start, int length) unsigned long y; int shift; - assert(length <= 11); - assert(start >= 0); - assert(length >= 0); - assert(start + length <= 66); + XRPL_ASSERT(length <= 11); + XRPL_ASSERT(start >= 0); + XRPL_ASSERT(length >= 0); + XRPL_ASSERT(start + length <= 66); shift = ((8 - ((start + length) % 8)) % 8); y = (long)x << shift; diff --git a/src/libxrpl/crypto/csprng.cpp b/src/libxrpl/crypto/csprng.cpp index 480d561eacf..04c72d7260c 100644 --- a/src/libxrpl/crypto/csprng.cpp +++ b/src/libxrpl/crypto/csprng.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include #include #include #include diff --git a/src/libxrpl/json/Object.cpp b/src/libxrpl/json/Object.cpp index 179b0e31ef2..695f3a7a7d4 100644 --- a/src/libxrpl/json/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -18,8 +18,8 @@ //============================================================================== #include +#include #include -#include namespace Json { @@ -168,7 +168,7 @@ Array::append(Json::Value const& v) return; } } - assert(false); // Can't get here. + XRPL_UNREACHABLE(); // Can't get here. } void @@ -203,7 +203,7 @@ Object::set(std::string const& k, Json::Value const& v) return; } } - assert(false); // Can't get here. + XRPL_UNREACHABLE(); // Can't get here. } //------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ template void doCopyFrom(Object& to, Json::Value const& from) { - assert(from.isObjectOrNull()); + XRPL_ASSERT(from.isObjectOrNull()); auto members = from.getMemberNames(); for (auto& m : members) to[m] = from[m]; diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 5459042cddb..8a3a6d88b58 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include #include #include @@ -70,7 +70,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - assert(current >= buffer); + XRPL_ASSERT(current >= buffer); return current; } @@ -80,7 +80,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); uintToString(value, current); - assert(current >= buffer); + XRPL_ASSERT(current >= buffer); return current; } @@ -391,7 +391,7 @@ StyledWriter::writeArrayValue(const Value& value) } else // output on a single line { - assert(childValues_.size() == size); + XRPL_ASSERT(childValues_.size() == size); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -483,7 +483,7 @@ StyledWriter::indent() void StyledWriter::unindent() { - assert(int(indentString_.size()) >= indentSize_); + XRPL_ASSERT(int(indentString_.size()) >= indentSize_); indentString_.resize(indentString_.size() - indentSize_); } @@ -613,7 +613,7 @@ StyledStreamWriter::writeArrayValue(const Value& value) } else // output on a single line { - assert(childValues_.size() == size); + XRPL_ASSERT(childValues_.size() == size); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -706,7 +706,7 @@ StyledStreamWriter::indent() void StyledStreamWriter::unindent() { - assert(indentString_.size() >= indentation_.size()); + XRPL_ASSERT(indentString_.size() >= indentation_.size()); indentString_.resize(indentString_.size() - indentation_.size()); } diff --git a/src/libxrpl/protocol/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp index 7ac27041e76..9934df24a13 100644 --- a/src/libxrpl/protocol/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -109,7 +109,7 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot) // It should be impossible for expiration to be < TOTAL_TIME_SLOT_SECS, // but check just to be safe auto const expiration = auctionSlot[sfExpiration]; - assert(expiration >= TOTAL_TIME_SLOT_SECS); + XRPL_ASSERT(expiration >= TOTAL_TIME_SLOT_SECS); if (expiration >= TOTAL_TIME_SLOT_SECS) { if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; diff --git a/src/libxrpl/protocol/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp index 5f0fa631851..ab13bfc4c37 100644 --- a/src/libxrpl/protocol/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -77,7 +77,7 @@ class AccountIdCache auto ret = encodeBase58Token(TokenType::AccountID, id.data(), id.size()); - assert(ret.size() <= 38); + XRPL_ASSERT(ret.size() <= 38); { std::lock_guard lock(sl); diff --git a/src/libxrpl/protocol/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp index b0a7bcc9ed7..9139f29e83c 100644 --- a/src/libxrpl/protocol/BuildInfo.cpp +++ b/src/libxrpl/protocol/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.3.0-b1" +char const* const versionString = "2.2.0" // clang-format on #if defined(DEBUG) || defined(SANITIZER) diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 28024fab093..74e365570b8 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include namespace ripple { @@ -212,7 +212,7 @@ error_code_http_status(error_code_i code) std::string rpcErrorString(Json::Value const& jv) { - assert(RPC::contains_error(jv)); + XRPL_ASSERT(RPC::contains_error(jv)); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 87395b7e189..94b2bed7862 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -221,7 +221,7 @@ FeatureCollections::FeatureCollections() std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByName(name); if (feature) return feature->feature; @@ -303,7 +303,7 @@ FeatureCollections::registrationIsDone() size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByFeature(f); if (!feature) @@ -315,7 +315,7 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const& feature = getByIndex(i); return feature.feature; } @@ -323,7 +323,7 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - assert(readOnly); + XRPL_ASSERT(readOnly); Feature const* feature = getByFeature(f); return feature ? feature->name : to_string(f); } diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 30d97416cfa..fa22d68d935 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -26,7 +27,6 @@ #include #include -#include namespace ripple { @@ -91,7 +91,7 @@ indexHash(LedgerNameSpace space, Args const&... args) uint256 getBookBase(Book const& book) { - assert(isConsistent(book)); + XRPL_ASSERT(isConsistent(book)); auto const index = indexHash( LedgerNameSpace::BOOK_DIR, @@ -131,7 +131,7 @@ getTicketIndex(AccountID const& account, std::uint32_t ticketSeq) uint256 getTicketIndex(AccountID const& account, SeqProxy ticketSeq) { - assert(ticketSeq.isTicket()); + XRPL_ASSERT(ticketSeq.isTicket()); return getTicketIndex(account, ticketSeq.value()); } @@ -208,7 +208,7 @@ line( // There is code in SetTrust that calls us with id0 == id1, to allow users // to locate and delete such "weird" trustlines. If we remove that code, we // could enable this assert: - // assert(id0 != id1); + // XRPL_ASSERT(id0 != id1); // A trust line is shared between two accounts; while we typically think // of this as an "issuer" and a "holder" the relationship is actually fully @@ -237,7 +237,7 @@ offer(AccountID const& id, std::uint32_t seq) noexcept Keylet quality(Keylet const& k, std::uint64_t q) noexcept { - assert(k.type == ltDIR_NODE); + XRPL_ASSERT(k.type == ltDIR_NODE); // Indexes are stored in big endian format: they print as hex as stored. // Most significant bytes are first and the least significant bytes @@ -255,7 +255,7 @@ quality(Keylet const& k, std::uint64_t q) noexcept Keylet next_t::operator()(Keylet const& k) const { - assert(k.type == ltDIR_NODE); + XRPL_ASSERT(k.type == ltDIR_NODE); return {ltDIR_NODE, getQualityNext(k.key)}; } @@ -357,7 +357,7 @@ nftpage_max(AccountID const& owner) Keylet nftpage(Keylet const& k, uint256 const& token) { - assert(k.type == ltNFTOKEN_PAGE); + XRPL_ASSERT(k.type == ltNFTOKEN_PAGE); return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; } diff --git a/src/libxrpl/protocol/Keylet.cpp b/src/libxrpl/protocol/Keylet.cpp index 23847811d3b..2c0fdd974e3 100644 --- a/src/libxrpl/protocol/Keylet.cpp +++ b/src/libxrpl/protocol/Keylet.cpp @@ -25,7 +25,7 @@ namespace ripple { bool Keylet::check(STLedgerEntry const& sle) const { - assert(sle.getType() != ltANY || sle.getType() != ltCHILD); + XRPL_ASSERT(sle.getType() != ltANY || sle.getType() != ltCHILD); if (type == ltANY) return true; diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index 38b641328b0..10468514bad 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include namespace ripple { @@ -35,7 +35,7 @@ Quality::Quality(Amounts const& amount) Quality& Quality::operator++() { - assert(m_value > 0); + XRPL_ASSERT(m_value > 0); --m_value; return *this; } @@ -51,7 +51,7 @@ Quality::operator++(int) Quality& Quality::operator--() { - assert(m_value < std::numeric_limits::max()); + XRPL_ASSERT(m_value < std::numeric_limits::max()); ++m_value; return *this; } @@ -81,10 +81,10 @@ ceil_in_impl( // Clamp out if (result.out > amount.out) result.out = amount.out; - assert(result.in == limit); + XRPL_ASSERT(result.in == limit); return result; } - assert(amount.in <= limit); + XRPL_ASSERT(amount.in <= limit); return amount; } @@ -120,10 +120,10 @@ ceil_out_impl( // Clamp in if (result.in > amount.in) result.in = amount.in; - assert(result.out == limit); + XRPL_ASSERT(result.out == limit); return result; } - assert(amount.out <= limit); + XRPL_ASSERT(amount.out <= limit); return amount; } @@ -146,17 +146,17 @@ Quality composed_quality(Quality const& lhs, Quality const& rhs) { STAmount const lhs_rate(lhs.rate()); - assert(lhs_rate != beast::zero); + XRPL_ASSERT(lhs_rate != beast::zero); STAmount const rhs_rate(rhs.rate()); - assert(rhs_rate != beast::zero); + XRPL_ASSERT(rhs_rate != beast::zero); STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.issue(), true)); std::uint64_t const stored_exponent(rate.exponent() + 100); std::uint64_t const stored_mantissa(rate.mantissa()); - assert((stored_exponent > 0) && (stored_exponent <= 255)); + XRPL_ASSERT((stored_exponent > 0) && (stored_exponent <= 255)); return Quality((stored_exponent << (64 - 8)) | stored_mantissa); } diff --git a/src/libxrpl/protocol/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp index d85a49a5958..fe968c8bccc 100644 --- a/src/libxrpl/protocol/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -46,7 +46,7 @@ transferFeeAsRate(std::uint16_t fee) STAmount multiply(STAmount const& amount, Rate const& rate) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -57,7 +57,7 @@ multiply(STAmount const& amount, Rate const& rate) STAmount multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -72,7 +72,7 @@ multiplyRound( Issue const& issue, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) { @@ -85,7 +85,7 @@ multiplyRound( STAmount divide(STAmount const& amount, Rate const& rate) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -96,7 +96,7 @@ divide(STAmount const& amount, Rate const& rate) STAmount divideRound(STAmount const& amount, Rate const& rate, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; @@ -111,7 +111,7 @@ divideRound( Issue const& issue, bool roundUp) { - assert(rate.value != 0); + XRPL_ASSERT(rate.value != 0); if (rate == parityRate) return amount; diff --git a/src/libxrpl/protocol/Rules.cpp b/src/libxrpl/protocol/Rules.cpp index f47e966e138..613f882d609 100644 --- a/src/libxrpl/protocol/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -91,7 +91,7 @@ class Rules::Impl return true; if (!digest_ || !other.digest_) return false; - assert(presets_ == other.presets_); + XRPL_ASSERT(presets_ == other.presets_); return *digest_ == *other.digest_; } }; @@ -118,7 +118,7 @@ Rules::presets() const bool Rules::enabled(uint256 const& feature) const { - assert(impl_); + XRPL_ASSERT(impl_); // The functionality of the "NonFungibleTokensV1_1" amendment is // precisely the functionality of the following three amendments @@ -137,7 +137,7 @@ Rules::enabled(uint256 const& feature) const bool Rules::operator==(Rules const& other) const { - assert(impl_ && other.impl_); + XRPL_ASSERT(impl_ && other.impl_); if (impl_.get() == other.impl_.get()) return true; return *impl_ == *other.impl_; diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index d56f3983352..20513905752 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -17,8 +17,8 @@ */ //============================================================================== +#include #include -#include #include #include #include diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index 8ae43f76863..cce005a5b3f 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -80,8 +80,8 @@ STAccount::getSType() const void STAccount::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_ACCOUNT); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == STI_ACCOUNT); // Preserve the serialization behavior of an STBlob: // o If we are default (all zeros) serialize as an empty blob. diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 236603d6cb8..d23928a23de 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -70,7 +70,7 @@ getSNValue(STAmount const& amount) auto ret = static_cast(amount.mantissa()); - assert(static_cast(ret) == amount.mantissa()); + XRPL_ASSERT(static_cast(ret) == amount.mantissa()); if (amount.negative()) ret = -ret; @@ -220,7 +220,7 @@ STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(negative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -235,7 +235,7 @@ STAmount::STAmount( , mOffset(exponent) , mIsNegative(negative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); canonicalize(); } @@ -246,7 +246,7 @@ STAmount::STAmount(SField const& name, STAmount const& from) , mOffset(from.mOffset) , mIsNegative(from.mIsNegative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); canonicalize(); } @@ -258,7 +258,7 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(mantissa != 0 && negative) { - assert(mValue <= std::numeric_limits::max()); + XRPL_ASSERT(mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -374,7 +374,7 @@ STAmount::iou() const STAmount& STAmount::operator=(IOUAmount const& iou) { - assert(mIsNative == false); + XRPL_ASSERT(mIsNative == false); mOffset = iou.exponent(); mIsNegative = iou < beast::zero; if (mIsNegative) @@ -512,7 +512,7 @@ getRate(STAmount const& offerOut, STAmount const& offerIn) STAmount r = divide(offerIn, offerOut, noIssue()); if (r == beast::zero) // offer is too good return 0; - assert((r.exponent() >= -100) && (r.exponent() <= 155)); + XRPL_ASSERT((r.exponent() >= -100) && (r.exponent() <= 155)); std::uint64_t ret = r.exponent() + 100; return (ret << (64 - 8)) | r.mantissa(); } @@ -594,7 +594,7 @@ STAmount::getText() const return ret; } - assert(mOffset + 43 > 0); + XRPL_ASSERT(mOffset + 43 > 0); size_t const pad_prefix = 27; size_t const pad_suffix = 23; @@ -618,7 +618,7 @@ STAmount::getText() const if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - assert(post_to >= post_from); + XRPL_ASSERT(post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -627,7 +627,7 @@ STAmount::getText() const if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - assert(post_to >= post_from); + XRPL_ASSERT(post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), @@ -662,7 +662,7 @@ STAmount::add(Serializer& s) const { if (mIsNative) { - assert(mOffset == 0); + XRPL_ASSERT(mOffset == 0); if (!mIsNegative) s.add64(mValue | cPosNative); @@ -823,10 +823,11 @@ STAmount::canonicalize() if (mOffset > cMaxOffset) Throw("value overflow"); - assert((mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); - assert( + XRPL_ASSERT( + (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); + XRPL_ASSERT( (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset))); - assert((mValue != 0) || (mOffset != -100)); + XRPL_ASSERT((mValue != 0) || (mOffset != -100)); } void diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index b7e9c94ca24..7ebe1322323 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -17,9 +17,9 @@ */ //============================================================================== +#include #include #include -#include #include namespace ripple { @@ -30,7 +30,7 @@ STBase::STBase() : fName(&sfGeneric) STBase::STBase(SField const& n) : fName(&n) { - assert(fName); + XRPL_ASSERT(fName); } STBase& @@ -105,13 +105,13 @@ void STBase::add(Serializer& s) const { // Should never be called - assert(false); + XRPL_UNREACHABLE(); } bool STBase::isEquivalent(const STBase& t) const { - assert(getSType() == STI_NOTPRESENT); + XRPL_ASSERT(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; } @@ -125,7 +125,7 @@ void STBase::setFName(SField const& n) { fName = &n; - assert(fName); + XRPL_ASSERT(fName); } SField const& @@ -137,7 +137,7 @@ STBase::getFName() const void STBase::addFieldID(Serializer& s) const { - assert(fName->isBinary()); + XRPL_ASSERT(fName->isBinary()); s.addFieldID(fName->fieldType, fName->fieldValue); } diff --git a/src/libxrpl/protocol/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp index 63e7b4bf3da..04480575f0f 100644 --- a/src/libxrpl/protocol/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -54,8 +54,8 @@ STBlob::getText() const void STBlob::add(Serializer& s) const { - assert(getFName().isBinary()); - assert( + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT( (getFName().fieldType == STI_VL) || (getFName().fieldType == STI_ACCOUNT)); s.addVL(value_.data(), value_.size()); diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 7b7420006f9..257c8248cf7 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -196,7 +196,7 @@ Json::Value STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); - assert(ret.ec == std::errc()); + XRPL_ASSERT(ret.ec == std::errc()); str.resize(std::distance(str.data(), ret.ptr)); return str; } diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index 68d1455cb1d..aa1c5cb66f6 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -157,7 +157,7 @@ STLedgerEntry::thread( if (oldPrevTxID == txID) { // this transaction is already threaded - assert(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); + XRPL_ASSERT(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); return false; } diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index bde83ec31a1..dbb96fffbfd 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -842,7 +842,7 @@ STObject::add(Serializer& s, WhichFields whichFields) const // the type associated by rule with this field name // must be OBJECT, or the object cannot be deserialized SerializedTypeID const sType{field->getSType()}; - assert( + XRPL_ASSERT( (sType != STI_OBJECT) || (field->getFName().fieldType == STI_OBJECT)); field->addFieldID(s); diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index dec5e87eaee..b9d5e8da779 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #include diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index b658465272e..3bce80cbb73 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -208,8 +208,8 @@ STPathSet::getSType() const void STPathSet::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_PATHSET); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == STI_PATHSET); bool first = true; for (auto const& spPath : value) diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index 149186d43ce..12e844acdb6 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -137,7 +137,7 @@ STTx::getMentionedAccounts() const { if (auto sacc = dynamic_cast(&it)) { - assert(!sacc->isDefault()); + XRPL_ASSERT(!sacc->isDefault()); if (!sacc->isDefault()) list.insert(sacc->value()); } @@ -298,7 +298,7 @@ STTx::getMetaSQL( std::string rTxn = sqlBlobLiteral(rawTxn.peekData()); auto format = TxFormats::getInstance().findByType(tx_type_); - assert(format != nullptr); + XRPL_ASSERT(format != nullptr); return str( boost::format(bfTrans) % to_string(getTransactionID()) % diff --git a/src/libxrpl/protocol/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp index ca5ceb0d9ce..d5a8e20b7e8 100644 --- a/src/libxrpl/protocol/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -107,7 +107,7 @@ STValidation::isValid() const noexcept { if (!valid_) { - assert(publicKeyType(getSignerPublic()) == KeyType::secp256k1); + XRPL_ASSERT(publicKeyType(getSignerPublic()) == KeyType::secp256k1); valid_ = verifyDigest( getSignerPublic(), diff --git a/src/libxrpl/protocol/STVar.cpp b/src/libxrpl/protocol/STVar.cpp index c8466259f32..22f16f746e2 100644 --- a/src/libxrpl/protocol/STVar.cpp +++ b/src/libxrpl/protocol/STVar.cpp @@ -178,7 +178,7 @@ STVar::STVar(SerialIter& sit, SField const& name, int depth) STVar::STVar(SerializedTypeID id, SField const& name) { - assert((id == STI_NOTPRESENT) || (id == name.fieldType)); + XRPL_ASSERT((id == STI_NOTPRESENT) || (id == name.fieldType)); switch (id) { case STI_NOTPRESENT: diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index 2d8bc4ee225..b7723b22224 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -68,8 +68,8 @@ STVector256::isDefault() const void STVector256::add(Serializer& s) const { - assert(getFName().isBinary()); - assert(getFName().fieldType == STI_VECTOR256); + XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT(getFName().fieldType == STI_VECTOR256); s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8)); } diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index b99375f80dd..b54d1f63f48 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -132,7 +132,7 @@ int Serializer::addFieldID(int type, int name) { int ret = mData.size(); - assert((type > 0) && (type < 256) && (name > 0) && (name < 256)); + XRPL_ASSERT((type > 0) && (type < 256) && (name > 0) && (name < 256)); if (type < 16) { @@ -201,7 +201,7 @@ Serializer::addVL(Blob const& vector) { int ret = addEncoded(vector.size()); addRaw(vector); - assert( + XRPL_ASSERT( mData.size() == (ret + vector.size() + encodeLengthLength(vector.size()))); return ret; @@ -483,7 +483,7 @@ SerialIter::getVLDataLength() } else { - assert(lenLen == 3); + XRPL_ASSERT(lenLen == 3); int b2 = get8(); int b3 = get8(); datLen = Serializer::decodeVLLength(b1, b2, b3); diff --git a/src/libxrpl/protocol/TxMeta.cpp b/src/libxrpl/protocol/TxMeta.cpp index 253d00e8414..e6819c981c1 100644 --- a/src/libxrpl/protocol/TxMeta.cpp +++ b/src/libxrpl/protocol/TxMeta.cpp @@ -55,7 +55,7 @@ TxMeta::TxMeta(uint256 const& txid, std::uint32_t ledger, STObject const& obj) auto affectedNodes = dynamic_cast(obj.peekAtPField(sfAffectedNodes)); - assert(affectedNodes); + XRPL_ASSERT(affectedNodes); if (affectedNodes) mNodes = *affectedNodes; @@ -106,7 +106,7 @@ TxMeta::setAffectedNode( mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - assert(obj.getFName() == type); + XRPL_ASSERT(obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, node); obj.setFieldU16(sfLedgerEntryType, nodeType); } @@ -127,14 +127,14 @@ TxMeta::getAffectedAccounts() const if (index != -1) { auto inner = dynamic_cast(&it.peekAtIndex(index)); - assert(inner); + XRPL_ASSERT(inner); if (inner) { for (auto const& field : *inner) { if (auto sa = dynamic_cast(&field)) { - assert(!sa->isDefault()); + XRPL_ASSERT(!sa->isDefault()); if (!sa->isDefault()) list.insert(sa->value()); } @@ -145,7 +145,7 @@ TxMeta::getAffectedAccounts() const (field.getFName() == sfTakerGets)) { auto lim = dynamic_cast(&field); - assert(lim); + XRPL_ASSERT(lim); if (lim != nullptr) { @@ -175,7 +175,7 @@ TxMeta::getAffectedNode(SLE::ref node, SField const& type) mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - assert(obj.getFName() == type); + XRPL_ASSERT(obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, index); obj.setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType)); @@ -190,7 +190,7 @@ TxMeta::getAffectedNode(uint256 const& node) if (n.getFieldH256(sfLedgerIndex) == node) return n; } - assert(false); + XRPL_UNREACHABLE(); Throw("Affected node not found"); return *(mNodes.begin()); // Silence compiler warning. } @@ -199,7 +199,7 @@ STObject TxMeta::getAsObject() const { STObject metaData(sfTransactionMetaData); - assert(mResult != 255); + XRPL_ASSERT(mResult != 255); metaData.setFieldU8(sfTransactionResult, mResult); metaData.setFieldU32(sfTransactionIndex, mIndex); metaData.emplace_back(mNodes); @@ -213,7 +213,7 @@ TxMeta::addRaw(Serializer& s, TER result, std::uint32_t index) { mResult = TERtoInt(result); mIndex = index; - assert((mResult == 0) || ((mResult > 100) && (mResult <= 255))); + XRPL_ASSERT((mResult == 0) || ((mResult > 100) && (mResult <= 255))); mNodes.sort([](STObject const& o1, STObject const& o2) { return o1.getFieldH256(sfLedgerIndex) < o2.getFieldH256(sfLedgerIndex); diff --git a/src/libxrpl/protocol/tokens.cpp b/src/libxrpl/protocol/tokens.cpp index bec16945654..15d83937a25 100644 --- a/src/libxrpl/protocol/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -27,6 +27,7 @@ #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include -#include #include #include #include @@ -248,7 +248,7 @@ encodeBase58( iter[-1] = carry % 58; carry /= 58; } - assert(carry == 0); + XRPL_ASSERT(carry == 0); pbegin++; } @@ -298,7 +298,7 @@ decodeBase58(std::string const& s) *iter = carry % 256; carry /= 256; } - assert(carry == 0); + XRPL_ASSERT(carry == 0); ++psz; --remain; } @@ -530,7 +530,7 @@ b58_to_b256_be(std::string_view input, std::span out) ripple::b58_fast::detail::div_rem(input.size(), 10); auto const num_partial_coeffs = partial_coeff_len ? 1 : 0; auto const num_b_58_10_coeffs = num_full_coeffs + num_partial_coeffs; - assert(num_b_58_10_coeffs <= b_58_10_coeff.size()); + XRPL_ASSERT(num_b_58_10_coeffs <= b_58_10_coeff.size()); for (auto c : input.substr(0, partial_coeff_len)) { auto cur_val = ::ripple::alphabetReverse[c]; diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index b8652546841..b97d7826450 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -17,10 +17,10 @@ */ //============================================================================== +#include #include #include #include -#include namespace ripple { namespace Resource { @@ -109,14 +109,14 @@ Consumer::charge(Charge const& what) bool Consumer::warn() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return m_logic->warn(*m_entry); } bool Consumer::disconnect(beast::Journal const& j) { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); bool const d = m_logic->disconnect(*m_entry); if (d) { @@ -128,14 +128,14 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return m_logic->balance(*m_entry); } Entry& Consumer::entry() { - assert(m_entry != nullptr); + XRPL_ASSERT(m_entry != nullptr); return *m_entry; } diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index ceddc019504..1ad24ca4809 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -6086,7 +6086,7 @@ struct AMM_test : public jtx::AMMTest boost::regex_search(std::get<0>(t), match, rx); auto const poolOutIsXRP = boost::regex_search(std::get<1>(t), match, rx); - assert(!(poolInIsXRP && poolOutIsXRP)); + XRPL_ASSERT(!(poolInIsXRP && poolOutIsXRP)); auto const poolIn = getPool(std::get<0>(t), poolInIsXRP); auto const poolOut = getPool(std::get<1>(t), poolOutIsXRP); try diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 2f95fc0280b..1b838b7f0e7 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -142,7 +142,7 @@ class AmendmentTable_test final : public beast::unit_test::suite std::vector const& src, Args const&... args) { - assert(dest.capacity() >= dest.size() + src.size()); + XRPL_ASSERT(dest.capacity() >= dest.size() + src.size()); std::copy(src.begin(), src.end(), std::back_inserter(dest)); if constexpr (sizeof...(args) > 0) combine_arg(dest, args...); diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index 31b45abf43a..8c4fb9a73a4 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -2016,7 +2016,7 @@ class Check_test : public beast::unit_test::suite // This capability is enabled by the featureCheckCashMakesTrustLine // amendment. So this test executes only when that amendment is // active. - assert(features[featureCheckCashMakesTrustLine]); + XRPL_ASSERT(features[featureCheckCashMakesTrustLine]); testcase("Trust Line Creation"); diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index 9a11785b38c..7ab18982f59 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -294,7 +294,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - assert(!withDepositAuth || features[featureDepositAuth]); + XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); @@ -317,7 +317,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - assert(!withDepositAuth || features[featureDepositAuth]); + XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index e1a837a9cb2..7cd9fdddc28 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -52,7 +52,7 @@ class LedgerHistory_test : public beast::unit_test::suite { if (!prev) { - assert(!stx); + XRPL_ASSERT(!stx); return std::make_shared( create_genesis, env.app().config(), diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index 5b6df353d81..c44f55959a9 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -44,7 +44,7 @@ class LedgerLoad_test : public beast::unit_test::suite cfg->START_LEDGER = ledger; cfg->START_UP = type; cfg->TRAP_TX_HASH = trapTxHash; - assert(!dbPath.empty()); + XRPL_ASSERT(!dbPath.empty()); cfg->legacy("database_path", dbPath); return cfg; } diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 0b555a712cf..ba1f9a842d1 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -470,7 +470,7 @@ struct LedgerServer , msgHandler(env.app(), env.app().getLedgerReplayer()) , param(p) { - assert(param.initLedgers > 0); + XRPL_ASSERT(param.initLedgers > 0); createAccounts(param.initAccounts); createLedgerHistory(); app.logs().threshold(beast::severities::kWarning); @@ -499,7 +499,7 @@ struct LedgerServer sendPayments(int newTxes) { int fundedAccounts = accounts.size(); - assert(fundedAccounts >= newTxes); + XRPL_ASSERT(fundedAccounts >= newTxes); std::unordered_set senders; // somewhat random but reproducible @@ -507,7 +507,7 @@ struct LedgerServer int fromIdx = 0; int toIdx = 0; auto updateIdx = [&]() { - assert(fundedAccounts > senders.size()); + XRPL_ASSERT(fundedAccounts > senders.size()); fromIdx = (fromIdx + r) % fundedAccounts; while (senders.count(fromIdx) != 0) fromIdx = (fromIdx + 1) % fundedAccounts; diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index bf7b14c0d28..5d4307bd668 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -253,7 +253,7 @@ class Manifest_test : public beast::unit_test::suite jtx::Env env(*this); DatabaseCon::Setup setup; setup.dataDir = getDatabasePath(); - assert(!setup.useGlobalPragma); + XRPL_ASSERT(!setup.useGlobalPragma); auto dbCon = makeTestWalletDB(setup, dbName); diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index a8eae4a25ec..403b6227f54 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -152,7 +152,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(-100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ter(temBAD_AMOUNT)); } { @@ -161,7 +161,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt)); BEAST_EXPECT(channelBalance(*env.current(), chan) == reqBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); @@ -174,7 +174,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -197,7 +197,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + STAmount{1}; - assert(reqAmt <= chanAmt); + XRPL_ASSERT(reqAmt <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), @@ -248,7 +248,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + XRPL_ASSERT(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } @@ -369,7 +369,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -499,7 +499,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -518,7 +518,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -590,7 +590,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -607,7 +607,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -1736,7 +1736,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); // claim should fail if the dst was removed if (withOwnerDirFix) @@ -1822,7 +1822,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); { // claim should fail, since bob doesn't exist @@ -1959,7 +1959,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ticket::use(aliceTicketSeq++)); @@ -1977,7 +1977,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - assert(reqBal <= chanAmt); + XRPL_ASSERT(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), @@ -2011,7 +2011,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + drops(1); - assert(reqAmt <= chanAmt); + XRPL_ASSERT(reqAmt <= chanAmt); // Note that since claim() returns a tem (neither tec nor tes), // the ticket is not consumed. So we don't increment bobTicket. auto const sig = @@ -2053,7 +2053,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - assert(delta > beast::zero); + XRPL_ASSERT(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index f00a7361292..a5e38f20c63 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -271,7 +271,7 @@ class ElementComboIter std::optional const& existingCur, std::optional const& existingIss) { - assert(!has(SB::last)); + XRPL_ASSERT(!has(SB::last)); auto const acc = [&]() -> std::optional { if (!has(SB::acc)) @@ -322,14 +322,14 @@ struct ExistingElementPool jtx::Account getAccount(size_t id) { - assert(id < accounts.size()); + XRPL_ASSERT(id < accounts.size()); return accounts[id]; } ripple::Currency getCurrency(size_t id) { - assert(id < currencies.size()); + XRPL_ASSERT(id < currencies.size()); return currencies[id]; } @@ -380,7 +380,7 @@ struct ExistingElementPool { using namespace jtx; - assert(!offererIndex || offererIndex < numAct); + XRPL_ASSERT(!offererIndex || offererIndex < numAct); accounts.clear(); accounts.reserve(numAct); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index f54a88ace00..a22ba9154a9 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -145,7 +145,7 @@ struct Regression_test : public beast::unit_test::suite // Set the same key in the STTx. auto secp256r1Sig = std::make_unique(*(jt.stx)); auto pubKeyBlob = strUnHex(secp256r1PubKey); - assert(pubKeyBlob); // Hex for public key must be valid + XRPL_ASSERT(pubKeyBlob); // Hex for public key must be valid secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob); jt.stx.reset(secp256r1Sig.release()); diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index 917d23377bf..516d6093a5c 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -64,7 +64,7 @@ struct RippleCalcTestParams { if (pe.isMember(jss::account)) { - assert( + XRPL_ASSERT( !pe.isMember(jss::currency) && !pe.isMember(jss::issuer)); p.emplace_back( @@ -83,13 +83,13 @@ struct RippleCalcTestParams issuer = *parseBase58( pe[jss::issuer].asString()); else - assert(isXRP(*parseBase58( + XRPL_ASSERT(isXRP(*parseBase58( pe[jss::issuer].asString()))); p.emplace_back(std::nullopt, currency, issuer); } else { - assert(0); + XRPL_ASSERT(0); } } paths.emplace_back(std::move(p)); diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index 4f24d17601e..5b8a1ab32d9 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -4426,7 +4426,8 @@ struct XChainSim_test : public beast::unit_test::suite, c.num_create_attn_sent += sendCreateAttestations( i, bridge, create_claims); } - assert(claims.create_claims[c.claim_count].empty()); + XRPL_ASSERT( + claims.create_claims[c.claim_count].empty()); } } for (auto& [bridge, c] : counters) @@ -4705,11 +4706,11 @@ struct XChainSim_test : public beast::unit_test::suite, auto complete_cb = [&](std::vector const& signers) { auto num_attestors = signers.size(); st.env.close(); - assert( + XRPL_ASSERT( num_attestors <= std::count(cr.attested.begin(), cr.attested.end(), true)); - assert(num_attestors >= bridge_.quorum); - assert(cr.claim_id - 1 == counters.claim_count); + XRPL_ASSERT(num_attestors >= bridge_.quorum); + XRPL_ASSERT(cr.claim_id - 1 == counters.claim_count); auto r = cr.reward; auto reward = divide(r, STAmount(num_attestors), r.issue()); @@ -4741,7 +4742,7 @@ struct XChainSim_test : public beast::unit_test::suite, break; default: - assert(0); + XRPL_ASSERT(0); break; case st_completed: @@ -4905,14 +4906,14 @@ struct XChainSim_test : public beast::unit_test::suite, break; case st_attested: - assert(xfer.with_claim == WithClaim::yes); + XRPL_ASSERT(xfer.with_claim == WithClaim::yes); claim(); sm_state = st_completed; break; default: case st_completed: - assert(0); // should have been removed + XRPL_ASSERT(0); // should have been removed break; } return sm_state; diff --git a/src/test/basics/base58_test.cpp b/src/test/basics/base58_test.cpp index f204cdd0e3a..5c7aab2ee73 100644 --- a/src/test/basics/base58_test.cpp +++ b/src/test/basics/base58_test.cpp @@ -51,7 +51,7 @@ constexpr int numTokenTypeIndexes = 9; [[nodiscard]] inline auto tokenTypeAndSize(int i) -> std::tuple { - assert(i < numTokenTypeIndexes); + XRPL_ASSERT(i < numTokenTypeIndexes); switch (i) { diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 43000a1128c..659258ff43e 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -44,7 +44,7 @@ struct nonhash void operator()(void const* key, std::size_t len) noexcept { - assert(len == WIDTH); + XRPL_ASSERT(len == WIDTH); memcpy(data_.data(), key, len); } diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 200cd166031..fbd4270b7bb 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -594,7 +594,7 @@ struct NetworkHistory void createNodes() { - assert(param.numNodes <= 256); + XRPL_ASSERT(param.numNodes <= 256); UNLKeys = createPublicKeys(param.numNodes); for (int i = 0; i < param.numNodes; ++i) { diff --git a/src/test/csf/BasicNetwork.h b/src/test/csf/BasicNetwork.h index a70ee6a3613..e6903fa7e31 100644 --- a/src/test/csf/BasicNetwork.h +++ b/src/test/csf/BasicNetwork.h @@ -215,7 +215,7 @@ BasicNetwork::connect( return false; auto const result = links_.connect(to, from, link_type{true, delay, now}); (void)result; - assert(result); + XRPL_ASSERT(result); return true; } @@ -227,7 +227,7 @@ BasicNetwork::disconnect(Peer const& peer1, Peer const& peer2) return false; bool r = links_.disconnect(peer2, peer1); (void)r; - assert(r); + XRPL_ASSERT(r); return true; } diff --git a/src/test/csf/Histogram.h b/src/test/csf/Histogram.h index 2df1844a21d..e96e9b5affd 100644 --- a/src/test/csf/Histogram.h +++ b/src/test/csf/Histogram.h @@ -19,8 +19,8 @@ #ifndef RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED #define RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED +#include #include -#include #include #include #include @@ -110,7 +110,7 @@ class Histogram T percentile(float p) const { - assert(p >= 0 && p <= 1); + XRPL_ASSERT(p >= 0 && p <= 1); std::size_t pos = std::round(p * samples); if (counts_.empty()) diff --git a/src/test/csf/PeerGroup.h b/src/test/csf/PeerGroup.h index b59bfa6763c..6e8c9f64494 100644 --- a/src/test/csf/PeerGroup.h +++ b/src/test/csf/PeerGroup.h @@ -303,7 +303,7 @@ randomRankedGroups( RandomNumberDistribution sizeDist, Generator& g) { - assert(peers.size() == ranks.size()); + XRPL_ASSERT(peers.size() == ranks.size()); std::vector groups; groups.reserve(numGroups); diff --git a/src/test/csf/README.md b/src/test/csf/README.md index ff6bdc5dfac..801e514b76f 100644 --- a/src/test/csf/README.md +++ b/src/test/csf/README.md @@ -81,7 +81,7 @@ for (Peer * p : validators) sim.run(1); std::cout << (simDur.stop - simDur.start).count() << std::endl; -assert(sim.synchronized()); +XRPL_ASSERT(sim.synchronized()); ``` ### `Sim` and `PeerGroup` diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 511fb2c4b0f..a4bdd73666d 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -239,7 +239,7 @@ struct TxCollector { Tracker& tracker = it->second; // Should only validated a previously accepted Tx - assert(tracker.accepted); + XRPL_ASSERT(tracker.accepted); tracker.validated = when; validated++; @@ -501,7 +501,7 @@ struct LedgerCollector if (e.prior.id() == e.ledger.parentID()) { auto const it = ledgers_.find(e.ledger.id()); - assert(it != ledgers_.end()); + XRPL_ASSERT(it != ledgers_.end()); auto& tracker = it->second; // first time fully validated if (!tracker.fullyValidated) diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index 1c8d4eb54c6..c57394bdd92 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -345,7 +345,7 @@ struct LedgerHistoryHelper return it->second; // enforce that the new suffix has never been seen - assert(seen.emplace(s.back()).second); + XRPL_ASSERT(seen.emplace(s.back()).second); Ledger const& parent = (*this)[s.substr(0, s.size() - 1)]; return ledgers.emplace(s, oracle.accept(parent, Tx{++nextTx})) diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index c083b6df35c..83d1362ff28 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -436,7 +436,7 @@ AMM::deposit( std::optional const& flags, std::optional const& ter) { - assert(!(asset2In && maxEP)); + XRPL_ASSERT(!(asset2In && maxEP)); return deposit( account, std::nullopt, @@ -560,7 +560,7 @@ AMM::withdraw( std::optional const& maxEP, std::optional const& ter) { - assert(!(asset2Out && maxEP)); + XRPL_ASSERT(!(asset2Out && maxEP)); return withdraw( account, std::nullopt, @@ -665,7 +665,7 @@ AMM::bid(BidArg const& arg) if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - assert( + XRPL_ASSERT( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) @@ -760,7 +760,7 @@ AMM::expectAuctionSlot(auto&& cb) const if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - assert( + XRPL_ASSERT( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) diff --git a/src/test/jtx/impl/Account.cpp b/src/test/jtx/impl/Account.cpp index 9d41456ef75..9f151830f63 100644 --- a/src/test/jtx/impl/Account.cpp +++ b/src/test/jtx/impl/Account.cpp @@ -89,7 +89,7 @@ IOU Account::operator[](std::string const& s) const { auto const currency = to_currency(s); - assert(currency != noCurrency()); + XRPL_ASSERT(currency != noCurrency()); return IOU(*this, currency); } diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 6f0f9e3fc73..41f56bcc0ba 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -357,7 +357,7 @@ Env::sign_and_submit(JTx const& jt, Json::Value params) { // Use the provided parameters, and go straight // to the (RPC) client. - assert(params.isObject()); + XRPL_ASSERT(params.isObject()); if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) && !params.isMember(jss::seed) && !params.isMember(jss::seed_hex) && !params.isMember(jss::passphrase)) diff --git a/src/test/jtx/impl/Oracle.cpp b/src/test/jtx/impl/Oracle.cpp index df9483cbaae..0e2aa633f44 100644 --- a/src/test/jtx/impl/Oracle.cpp +++ b/src/test/jtx/impl/Oracle.cpp @@ -100,7 +100,7 @@ Oracle::submit( bool Oracle::exists(Env& env, AccountID const& account, std::uint32_t documentID) { - assert(account.isNonZero()); + XRPL_ASSERT(account.isNonZero()); return env.le(keylet::oracle(account, documentID)) != nullptr; } @@ -243,7 +243,7 @@ Oracle::set(UpdateArg const& arg) // assume standard currency if (s.size() == 3) return s; - assert(s.size() <= 20); + XRPL_ASSERT(s.size() <= 20); // anything else must be 160-bit hex string std::string h = strHex(s); return strHex(s).append(40 - s.size() * 2, '0'); diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 01fa5369592..078d9d7c288 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -19,8 +19,8 @@ #include #include +#include #include -#include #include #include @@ -56,7 +56,7 @@ template static std::string to_places(const T d, std::uint8_t places) { - assert(places <= std::numeric_limits::digits10); + XRPL_ASSERT(places <= std::numeric_limits::digits10); std::ostringstream oss; oss << std::setprecision(places) << std::fixed << d; diff --git a/src/test/jtx/impl/quality2.cpp b/src/test/jtx/impl/quality2.cpp index dd10b3c6117..4147b926116 100644 --- a/src/test/jtx/impl/quality2.cpp +++ b/src/test/jtx/impl/quality2.cpp @@ -28,13 +28,13 @@ namespace jtx { qualityInPercent::qualityInPercent(double percent) : qIn_(static_cast((percent / 100) * QUALITY_ONE)) { - assert(percent <= 400 && percent >= 0); + XRPL_ASSERT(percent <= 400 && percent >= 0); } qualityOutPercent::qualityOutPercent(double percent) : qOut_(static_cast((percent / 100) * QUALITY_ONE)) { - assert(percent <= 400 && percent >= 0); + XRPL_ASSERT(percent <= 400 && percent >= 0); } static void diff --git a/src/test/jtx/impl/xchain_bridge.cpp b/src/test/jtx/impl/xchain_bridge.cpp index 43b0e7c2f96..00f641d9523 100644 --- a/src/test/jtx/impl/xchain_bridge.cpp +++ b/src/test/jtx/impl/xchain_bridge.cpp @@ -316,8 +316,8 @@ claim_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - assert(fromIdx + numAtts <= rewardAccounts.size()); - assert(fromIdx + numAtts <= signers.size()); + XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); + XRPL_ASSERT(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) @@ -349,8 +349,8 @@ create_account_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - assert(fromIdx + numAtts <= rewardAccounts.size()); - assert(fromIdx + numAtts <= signers.size()); + XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); + XRPL_ASSERT(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index e185c43d157..3b6d0dec836 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -134,7 +134,7 @@ struct uniformIntDistribution static_assert( Generator::min() == 0, "If non-zero we have handle the offset"); const resultType range = b - a + 1; - assert(Generator::max() >= range); // Just for safety + XRPL_ASSERT(Generator::max() >= range); // Just for safety const resultType rejectLim = g.max() % range; resultType n; do @@ -148,7 +148,7 @@ template Integral randInt(Engine& engine, Integral min, Integral max) { - assert(max > min); + XRPL_ASSERT(max > min); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 4d9086dab10..8f07ac5b6d3 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -266,7 +266,7 @@ class Link : validator_(validator), peer_(peer), latency_(latency), up_(true) { auto sp = peer_.lock(); - assert(sp); + XRPL_ASSERT(sp); } ~Link() = default; void @@ -275,7 +275,7 @@ class Link if (!up_) return; auto sp = peer_.lock(); - assert(sp); + XRPL_ASSERT(sp); auto peer = std::dynamic_pointer_cast(sp); peer->onMessage(m, f); } @@ -293,14 +293,14 @@ class Link peerId() { auto p = peer_.lock(); - assert(p); + XRPL_ASSERT(p); return p->id(); } PeerSPtr getPeer() { auto p = peer_.lock(); - assert(p); + XRPL_ASSERT(p); return p; } @@ -376,7 +376,7 @@ class Validator { for (auto id : peers) { - assert(links_.find(id) != links_.end()); + XRPL_ASSERT(links_.find(id) != links_.end()); f(*links_[id], message_); } } @@ -429,7 +429,7 @@ class Validator linkUp(Peer::id_t id) { auto it = links_.find(id); - assert(it != links_.end()); + XRPL_ASSERT(it != links_.end()); it->second->up(true); } @@ -437,7 +437,7 @@ class Validator linkDown(Peer::id_t id) { auto it = links_.find(id); - assert(it != links_.end()); + XRPL_ASSERT(it != links_.end()); it->second->up(false); } @@ -478,7 +478,7 @@ class PeerSim : public PeerPartial, public std::enable_shared_from_this onMessage(MessageSPtr const& m, SquelchCB f) override { auto validator = m->getValidatorKey(); - assert(validator); + XRPL_ASSERT(validator); if (!squelch_.expireSquelch(*validator)) return; @@ -584,7 +584,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler deletePeer(Peer::id_t id, bool useCache = true) { auto it = peers_.find(id); - assert(it != peers_.end()); + XRPL_ASSERT(it != peers_.end()); deletePeer(id, [&](PublicKey const&, PeerWPtr) {}); if (useCache) peersCache_.emplace(std::make_pair(id, it->second)); @@ -643,7 +643,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler getSelectedPeer(PublicKey const& validator) { auto selected = slots_.getSelected(validator); - assert(selected.size()); + XRPL_ASSERT(selected.size()); return *selected.begin(); } @@ -752,7 +752,7 @@ class Network Validator& validator(std::uint16_t v) { - assert(v < validators_.size()); + XRPL_ASSERT(v < validators_.size()); return validators_[v]; } @@ -769,7 +769,7 @@ class Network std::find_if(validators_.begin(), validators_.end(), [&](auto& v) { return v.id() == validatorId; }); - assert(it != validators_.end()); + XRPL_ASSERT(it != validators_.end()); if (enable) it->linkUp(peer); else @@ -911,7 +911,7 @@ class reduce_relay_test : public beast::unit_test::suite if (res) squelch.set_squelchduration(*duration); auto sp = peerPtr.lock(); - assert(sp); + XRPL_ASSERT(sp); std::dynamic_pointer_cast(sp)->send(squelch); return sp->id(); } @@ -958,7 +958,7 @@ class reduce_relay_test : public beast::unit_test::suite [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) { - assert(key == validator); + XRPL_ASSERT(key == validator); auto p = sendSquelch(key, peerPtr, duration); squelched = true; str << p << " "; @@ -1295,7 +1295,7 @@ class reduce_relay_test : public beast::unit_test::suite return std::get(it.second) == reduce_relay::PeerState::Squelched; }); - assert(it != peers.end()); + XRPL_ASSERT(it != peers.end()); std::uint16_t unsquelched = 0; network_.overlay().deletePeer( it->first, [&](PublicKey const& key, PeerWPtr const& peer) { diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index 6dd4f8c00b8..962b2bf0a61 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -18,6 +18,7 @@ //============================================================================== #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include -#include #include #include #include @@ -112,7 +112,7 @@ class short_read_test : public beast::unit_test::suite ~Base() { // Derived class must call wait() in the destructor - assert(list_.empty()); + XRPL_ASSERT(list_.empty()); } void diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 074976e8586..7d9c2a4fcf4 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -193,7 +193,7 @@ class tx_reduce_relay_test : public beast::unit_test::suite peers.emplace_back(peer); // overlay stores week ptr to PeerImp lid_ += 2; rid_ += 2; - assert(lid_ <= 254); + XRPL_ASSERT(lid_ <= 254); } void diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 2c3bfd30d4c..36b10610064 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -51,7 +51,7 @@ class Handler_test : public beast::unit_test::suite time(std::size_t n, auto f, auto prng) -> auto { using clock = std::chrono::steady_clock; - assert(n > 0); + XRPL_ASSERT(n > 0); double sum = 0; double sum_squared = 0; std::size_t j = 0; diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index b2b9e7a55b8..800d2dec50c 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -2586,7 +2586,7 @@ class JSONRPC_test : public beast::unit_test::suite auto const signFn = get<0>(testFunc); if (signFn != nullptr) { - assert(get<1>(testFunc) == nullptr); + XRPL_ASSERT(get<1>(testFunc) == nullptr); result = signFn( req, 1, @@ -2598,7 +2598,7 @@ class JSONRPC_test : public beast::unit_test::suite else { auto const submitFn = get<1>(testFunc); - assert(submitFn != nullptr); + XRPL_ASSERT(submitFn != nullptr); result = submitFn( req, 1, diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index ac2d16ecc99..5570c953bff 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -101,7 +101,7 @@ class FetchPack_test : public beast::unit_test::suite { auto const result(t.addItem( SHAMapNodeType::tnACCOUNT_STATE, make_random_item(r))); - assert(result); + XRPL_ASSERT(result); (void)result; } } diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index 60487cadfb8..13d12c80002 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -19,6 +19,7 @@ #include +#include #include #include @@ -419,7 +420,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) buf.data(), buf.size(), recvd_size, priority); if (!recvd_size) continue; - assert(recvd_size == 1); + XRPL_ASSERT(recvd_size == 1); MessageType mt{*reinterpret_cast(buf.data())}; this->message_queue_->receive( @@ -440,7 +441,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) running_suites_.erase(s); break; default: - assert(0); // unknown message type + XRPL_ASSERT(0); // unknown message type } } } diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 7b061e10b31..5e934a1896d 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -93,7 +93,7 @@ RCLConsensus::Adaptor::Adaptor( std::numeric_limits::max() - 1)) , nUnlVote_(validatorKeys_.nodeID, j_) { - assert(valCookie_ != 0); + XRPL_ASSERT(valCookie_ != 0); JLOG(j_.info()) << "Consensus engine started (cookie: " + std::to_string(valCookie_) + ")"; @@ -143,8 +143,8 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) return std::nullopt; } - assert(!built->open() && built->isImmutable()); - assert(built->info().hash == hash); + XRPL_ASSERT(!built->open() && built->isImmutable()); + XRPL_ASSERT(built->info().hash == hash); // Notify inbound transactions of the new ledger sequence number inboundTransactions_.newRound(built->info().seq); @@ -670,8 +670,9 @@ RCLConsensus::Adaptor::doAccept( ledgerMaster_.switchLCL(built.ledger_); // Do these need to exist? - assert(ledgerMaster_.getClosedLedger()->info().hash == built.id()); - assert(app_.openLedger().current()->info().parentHash == built.id()); + XRPL_ASSERT(ledgerMaster_.getClosedLedger()->info().hash == built.id()); + XRPL_ASSERT( + app_.openLedger().current()->info().parentHash == built.id()); } //------------------------------------------------------------------------- @@ -767,7 +768,8 @@ RCLConsensus::Adaptor::buildLCL( std::shared_ptr built = [&]() { if (auto const replayData = ledgerMaster_.releaseReplay()) { - assert(replayData->parent()->info().hash == previousLedger.id()); + XRPL_ASSERT( + replayData->parent()->info().hash == previousLedger.id()); return buildLedger(*replayData, tapNONE, app_, j_); } return buildLedger( diff --git a/src/xrpld/app/consensus/RCLCxPeerPos.cpp b/src/xrpld/app/consensus/RCLCxPeerPos.cpp index 74747853a2d..01facb287e5 100644 --- a/src/xrpld/app/consensus/RCLCxPeerPos.cpp +++ b/src/xrpld/app/consensus/RCLCxPeerPos.cpp @@ -38,7 +38,8 @@ RCLCxPeerPos::RCLCxPeerPos( { // The maximum allowed size of a signature is 72 bytes; we verify // this elsewhere, but we want to be extra careful here: - assert(signature.size() != 0 && signature.size() <= signature_.capacity()); + XRPL_ASSERT( + signature.size() != 0 && signature.size() <= signature_.capacity()); if (signature.size() != 0 && signature.size() <= signature_.capacity()) signature_.assign(signature.begin(), signature.end()); diff --git a/src/xrpld/app/consensus/RCLCxTx.h b/src/xrpld/app/consensus/RCLCxTx.h index 58e58ac3b7d..7beb04f8ce8 100644 --- a/src/xrpld/app/consensus/RCLCxTx.h +++ b/src/xrpld/app/consensus/RCLCxTx.h @@ -111,7 +111,7 @@ class RCLTxSet */ RCLTxSet(std::shared_ptr m) : map_{std::move(m)} { - assert(map_); + XRPL_ASSERT(map_); } /** Constructor from a previously created MutableTxSet @@ -177,7 +177,7 @@ class RCLTxSet std::map ret; for (auto const& [k, v] : delta) { - assert((v.first && !v.second) || (v.second && !v.first)); + XRPL_ASSERT((v.first && !v.second) || (v.second && !v.first)); ret[k] = static_cast(v.first); } diff --git a/src/xrpld/app/consensus/RCLValidations.cpp b/src/xrpld/app/consensus/RCLValidations.cpp index 88e8d6c4e71..7524d9b74c8 100644 --- a/src/xrpld/app/consensus/RCLValidations.cpp +++ b/src/xrpld/app/consensus/RCLValidations.cpp @@ -49,7 +49,8 @@ RCLValidatedLedger::RCLValidatedLedger( auto const hashIndex = ledger->read(keylet::skip()); if (hashIndex) { - assert(hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); + XRPL_ASSERT( + hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); ancestors_ = hashIndex->getFieldV256(sfHashes).value(); } else @@ -142,8 +143,8 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) return std::nullopt; } - assert(!ledger->open() && ledger->isImmutable()); - assert(ledger->info().hash == hash); + XRPL_ASSERT(!ledger->open() && ledger->isImmutable()); + XRPL_ASSERT(ledger->info().hash == hash); return RCLValidatedLedger(std::move(ledger), j_); } diff --git a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp index e1ad68dff37..1518c41a7ef 100644 --- a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp +++ b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp @@ -33,7 +33,7 @@ AcceptedLedgerTx::AcceptedLedgerTx( , mMeta(txn->getTransactionID(), ledger->seq(), *met) , mAffected(mMeta.getAffectedAccounts()) { - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); Serializer s; met->add(s); @@ -76,7 +76,7 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::string AcceptedLedgerTx::getEscMeta() const { - assert(!mRawMeta.empty()); + XRPL_ASSERT(!mRawMeta.empty()); return sqlBlobLiteral(mRawMeta); } diff --git a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp index 4aed7d94bf3..c6cffbc1d64 100644 --- a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp @@ -60,7 +60,7 @@ ConsensusTransSetSF::gotNode( Serializer s(nodeData.data() + 4, nodeData.size() - 4); SerialIter sit(s.slice()); auto stx = std::make_shared(std::ref(sit)); - assert(stx->getTransactionID() == nodeHash.as_uint256()); + XRPL_ASSERT(stx->getTransactionID() == nodeHash.as_uint256()); auto const pap = &app_; app_.getJobQueue().addJob(jtTRANSACTION, "TXS->TXN", [pap, stx]() { pap->getOPs().submitTransaction(stx); @@ -92,7 +92,7 @@ ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const Serializer s; s.add32(HashPrefix::transactionID); txn->getSTransaction()->add(s); - assert(sha512Half(s.slice()) == nodeHash.as_uint256()); + XRPL_ASSERT(sha512Half(s.slice()) == nodeHash.as_uint256()); nodeData = s.peekData(); return nodeData; } diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index bcd3b6d4ba7..f36502d5209 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include @@ -381,7 +381,7 @@ Ledger::setAccepted( bool correctCloseTime) { // Used when we witnessed the consensus. - assert(!open()); + XRPL_ASSERT(!open()); info_.closeTime = closeTime; info_.closeTimeResolution = closeResolution; @@ -454,7 +454,7 @@ Ledger::read(Keylet const& k) const { if (k.key == beast::zero) { - assert(false); + XRPL_UNREACHABLE(); return nullptr; } auto const& item = stateMap_.peekItem(k.key); @@ -574,7 +574,7 @@ Ledger::rawTxInsert( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - assert(metaData); + XRPL_ASSERT(metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -591,7 +591,7 @@ Ledger::rawTxInsertWithHash( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - assert(metaData); + XRPL_ASSERT(metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -687,7 +687,7 @@ Ledger::setup() void Ledger::defaultFees(Config const& config) { - assert(fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); + XRPL_ASSERT(fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); if (fees_.base == 0) fees_.base = config.FEES.reference_fee; if (fees_.reserve == 0) @@ -883,7 +883,7 @@ Ledger::assertSensible(beast::Journal ledgerJ) const JLOG(ledgerJ.fatal()) << "ledger is not sensible" << j; - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -917,7 +917,7 @@ Ledger::updateSkipList() created = false; } - assert(hashes.size() <= 256); + XRPL_ASSERT(hashes.size() <= 256); hashes.push_back(info_.parentHash); sle->setFieldV256(sfHashes, STVector256(hashes)); sle->setFieldU32(sfLastLedgerSequence, prevIndex); @@ -942,7 +942,7 @@ Ledger::updateSkipList() hashes = static_cast(sle->getFieldV256(sfHashes)); created = false; } - assert(hashes.size() <= 256); + XRPL_ASSERT(hashes.size() <= 256); if (hashes.size() == 256) hashes.erase(hashes.begin()); hashes.push_back(info_.parentHash); @@ -1022,7 +1022,7 @@ pendSaveValidated( } } - assert(ledger->isImmutable()); + XRPL_ASSERT(ledger->isImmutable()); if (!app.pendingSaves().shouldWork(ledger->info().seq, isSynchronous)) { @@ -1099,7 +1099,7 @@ finishLoadByIndexOrHash( if (!ledger) return; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(); @@ -1140,7 +1140,7 @@ loadByHash(uint256 const& ledgerHash, Application& app, bool acquire) { std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); - assert(!ledger || ledger->info().hash == ledgerHash); + XRPL_ASSERT(!ledger || ledger->info().hash == ledgerHash); return ledger; } return {}; @@ -1152,7 +1152,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) { if (!app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions: not running in reporting mode"); } @@ -1165,7 +1165,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) dynamic_cast(&(app.getNodeStore())); if (!nodeDb) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Called flatFetchTransactions but database is not DatabaseNodeImp"); } @@ -1175,7 +1175,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) JLOG(app.journal("Ledger").debug()) << " Flat fetch time : " << ((end - start).count() / 1000000000.0) << " number of transactions " << nodestoreHashes.size(); - assert(objs.size() == nodestoreHashes.size()); + XRPL_ASSERT(objs.size() == nodestoreHashes.size()); for (size_t i = 0; i < objs.size(); ++i) { uint256& nodestoreHash = nodestoreHashes[i]; @@ -1186,21 +1186,21 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) makeSlice(obj->getData()), SHAMapHash{nodestoreHash}); if (!node) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error making SHAMap node"); } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error reading SHAMap node"); } auto txnPlusMeta = deserializeTxPlusMeta(*item); if (!txnPlusMeta.first || !txnPlusMeta.second) { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Error deserializing SHAMap node"); } @@ -1208,7 +1208,7 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) } else { - assert(false); + XRPL_UNREACHABLE(); Throw( "flatFetchTransactions : Containing SHAMap node not found"); } @@ -1221,7 +1221,7 @@ flatFetchTransactions(ReadView const& ledger, Application& app) { if (!app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); return {}; } diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 30139e2155f..9e400bb33e5 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -58,7 +58,7 @@ LedgerHistory::insert( if (!ledger->isImmutable()) LogicError("mutable Ledger in insert"); - assert(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); std::unique_lock sl(m_ledgers_by_hash.peekMutex()); @@ -99,13 +99,13 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) if (!ret) return ret; - assert(ret->info().seq == index); + XRPL_ASSERT(ret->info().seq == index); { // Add this ledger to the local tracking by index std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - assert(ret->isImmutable()); + XRPL_ASSERT(ret->isImmutable()); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); mLedgersByIndex[ret->info().seq] = ret->info().hash; return (ret->info().seq == index) ? ret : nullptr; @@ -119,8 +119,8 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (ret) { - assert(ret->isImmutable()); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->isImmutable()); + XRPL_ASSERT(ret->info().hash == hash); return ret; } @@ -129,10 +129,10 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (!ret) return ret; - assert(ret->isImmutable()); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->isImmutable()); + XRPL_ASSERT(ret->info().hash == hash); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); - assert(ret->info().hash == hash); + XRPL_ASSERT(ret->info().hash == hash); return ret; } @@ -176,7 +176,7 @@ log_metadata_difference( auto validMetaData = getMeta(validLedger, tx); auto builtMetaData = getMeta(builtLedger, tx); - assert(validMetaData || builtMetaData); + XRPL_ASSERT(validMetaData || builtMetaData); if (validMetaData && builtMetaData) { @@ -322,7 +322,7 @@ LedgerHistory::handleMismatch( std::optional const& validatedConsensusHash, Json::Value const& consensus) { - assert(built != valid); + XRPL_ASSERT(built != valid); ++mismatch_counter_; auto builtLedger = getLedgerByHash(built); @@ -337,7 +337,7 @@ LedgerHistory::handleMismatch( return; } - assert(builtLedger->info().seq == validLedger->info().seq); + XRPL_ASSERT(builtLedger->info().seq == validLedger->info().seq); if (auto stream = j_.debug()) { @@ -430,7 +430,7 @@ LedgerHistory::builtLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - assert(!hash.isZero()); + XRPL_ASSERT(!hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); @@ -470,7 +470,7 @@ LedgerHistory::validatedLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - assert(!hash.isZero()); + XRPL_ASSERT(!hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index b218b1d6e11..9869a60bd0b 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -27,8 +27,8 @@ #include #include #include +#include #include -#include #include namespace ripple { @@ -263,7 +263,7 @@ OpenLedger::apply( // If there are any transactions left, we must have // tried them in at least one final pass - assert(retries.empty() || !retry); + XRPL_ASSERT(retries.empty() || !retry); } //------------------------------------------------------------------------------ diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp index d0eddadbacb..52c88cdf3fe 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -225,7 +225,7 @@ OrderBookDB::makeBookListeners(Book const& book) ret = std::make_shared(); mListeners[book] = ret; - assert(getBookListeners(book) == ret); + XRPL_ASSERT(getBookListeners(book) == ret); } return ret; diff --git a/src/xrpld/app/ledger/TransactionStateSF.cpp b/src/xrpld/app/ledger/TransactionStateSF.cpp index fac28cd2aa8..f4fa27347f3 100644 --- a/src/xrpld/app/ledger/TransactionStateSF.cpp +++ b/src/xrpld/app/ledger/TransactionStateSF.cpp @@ -30,7 +30,7 @@ TransactionStateSF::gotNode( SHAMapNodeType type) const { - assert(type != SHAMapNodeType::tnTRANSACTION_NM); + XRPL_ASSERT(type != SHAMapNodeType::tnTRANSACTION_NM); db_.store( hotTRANSACTION_NODE, std::move(nodeData), diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 8c4a7a3f41d..f90f70e9b99 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -57,7 +57,7 @@ buildLedgerImpl( { OpenView accum(&*built); - assert(!accum.open()); + XRPL_ASSERT(!accum.open()); applyTxs(accum, built); accum.apply(*built); } @@ -75,7 +75,7 @@ buildLedgerImpl( built->unshare(); // Accept ledger - assert( + XRPL_ASSERT( built->info().seq < XRP_LEDGER_EARLIEST_FEES || built->read(keylet::fees())); built->setAccepted(closeTime, closeResolution, closeTimeCorrect); @@ -169,7 +169,7 @@ applyTransactions( // If there are any transactions left, we must have // tried them in at least one final pass - assert(txns.empty() || !certainRetry); + XRPL_ASSERT(txns.empty() || !certainRetry); return count; } diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index b98f24aed43..7d985d7e005 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -155,7 +155,7 @@ InboundLedger::init(ScopedLockType& collectionLock) JLOG(journal_.debug()) << "Acquiring ledger we already have in " << " local store. " << hash_; - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -389,7 +389,7 @@ InboundLedger::tryDB(NodeStore::Database& srcDB) { JLOG(journal_.debug()) << "Had everything locally"; complete_ = true; - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -485,11 +485,11 @@ InboundLedger::done() std::to_string(timeouts_) + " ")) << mStats.get(); - assert(complete_ || failed_); + XRPL_ASSERT(complete_ || failed_); if (complete_ && !failed_ && mLedger) { - assert( + XRPL_ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || mLedger->read(keylet::fees())); mLedger->setImmutable(); @@ -656,7 +656,7 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) // if we wind up abandoning this fetch. if (mHaveHeader && !mHaveState && !failed_) { - assert(mLedger); + XRPL_ASSERT(mLedger); if (!mLedger->stateMap().isValid()) { @@ -728,7 +728,7 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) if (mHaveHeader && !mHaveTransactions && !failed_) { - assert(mLedger); + XRPL_ASSERT(mLedger); if (!mLedger->txMap().isValid()) { @@ -994,7 +994,7 @@ InboundLedger::takeAsRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -1019,7 +1019,7 @@ InboundLedger::takeTxRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/xrpld/app/ledger/detail/InboundLedgers.cpp b/src/xrpld/app/ledger/detail/InboundLedgers.cpp index 04964d2a921..6d52ee4e2c8 100644 --- a/src/xrpld/app/ledger/detail/InboundLedgers.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedgers.cpp @@ -69,8 +69,8 @@ class InboundLedgersImp : public InboundLedgers std::uint32_t seq, InboundLedger::Reason reason) override { - assert(hash.isNonZero()); - assert( + XRPL_ASSERT(hash.isNonZero()); + XRPL_ASSERT( reason != InboundLedger::Reason::SHARD || (seq != 0 && app_.getShardStore())); @@ -144,7 +144,7 @@ class InboundLedgersImp : public InboundLedgers std::shared_ptr find(uint256 const& hash) override { - assert(hash.isNonZero()); + XRPL_ASSERT(hash.isNonZero()); std::shared_ptr ret; @@ -306,7 +306,7 @@ class InboundLedgersImp : public InboundLedgers acqs.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - assert(it.second); + XRPL_ASSERT(it.second); acqs.push_back(it); } for (auto const& it : mRecentFailures) @@ -341,7 +341,7 @@ class InboundLedgersImp : public InboundLedgers acquires.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - assert(it.second); + XRPL_ASSERT(it.second); acquires.push_back(it.second); } } diff --git a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp index 3021c691c53..62ad6d0496c 100644 --- a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -231,7 +231,7 @@ class LedgerCleanerImp : public LedgerCleaner }); if (shouldExit_) break; - assert(state_ == State::cleaning); + XRPL_ASSERT(state_ == State::cleaning); } doLedgerCleaner(); } @@ -353,7 +353,7 @@ class LedgerCleanerImp : public LedgerCleaner LedgerHash refHash = getLedgerHash(referenceLedger, refIndex); bool const nonzero(refHash.isNonZero()); - assert(nonzero); + XRPL_ASSERT(nonzero); if (nonzero) { // We found the hash and sequence of a better reference diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index e079fb3ee27..7f87091cc02 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -199,8 +199,8 @@ LedgerDeltaAcquire::tryBuild(std::shared_ptr const& parent) if (failed_ || !complete_ || !replayTemp_) return {}; - assert(parent->seq() + 1 == replayTemp_->seq()); - assert(parent->info().hash == replayTemp_->info().parentHash); + XRPL_ASSERT(parent->seq() + 1 == replayTemp_->seq()); + XRPL_ASSERT(parent->info().hash == replayTemp_->info().parentHash); // build ledger LedgerReplay replayData(parent, replayTemp_, std::move(orderedTxns_)); fullLedger_ = buildLedger(replayData, tapNONE, app_, journal_); @@ -262,7 +262,7 @@ LedgerDeltaAcquire::onLedgerBuilt( void LedgerDeltaAcquire::notify(ScopedLockType& sl) { - assert(isDone()); + XRPL_ASSERT(isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index f03004fd14c..78fbb4fdc34 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -47,13 +47,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -119,7 +119,7 @@ class ScopedUnlock */ explicit ScopedUnlock(std::unique_lock& lock) : lock_(lock) { - assert(lock_.owns_lock()); + XRPL_ASSERT(lock_.owns_lock()); lock_.unlock(); } @@ -368,7 +368,7 @@ LedgerMaster::setValidLedger(std::shared_ptr const& l) mValidLedger.set(l); mValidLedgerSign = signTime.time_since_epoch().count(); - assert( + XRPL_ASSERT( mValidLedgerSeq || !app_.getMaxDisallowedLedger() || l->info().seq + max_ledger_difference_ > app_.getMaxDisallowedLedger()); (void)max_ledger_difference_; @@ -435,7 +435,7 @@ LedgerMaster::addHeldTransaction( bool LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) { - assert(ledger); + XRPL_ASSERT(ledger); // Never jump to a candidate ledger that precedes our // last validated ledger @@ -503,7 +503,7 @@ LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) void LedgerMaster::switchLCL(std::shared_ptr const& lastClosed) { - assert(lastClosed); + XRPL_ASSERT(lastClosed); if (!lastClosed->isImmutable()) LogicError("mutable ledger in switchLCL"); @@ -623,7 +623,7 @@ LedgerMaster::isValidated(ReadView const& ledger) // This ledger's hash is not the hash of the validated ledger if (hash) { - assert(hash->isNonZero()); + XRPL_ASSERT(hash->isNonZero()); uint256 valHash = app_.getRelationalDatabase().getHashByIndex(seq); if (valHash == ledger.info().hash) @@ -964,7 +964,7 @@ LedgerMaster::setFullLedger( // A new ledger has been accepted as part of the trusted chain JLOG(m_journal.debug()) << "Ledger " << ledger->info().seq << " accepted :" << ledger->info().hash; - assert(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); ledger->setValidated(); ledger->setFull(); @@ -1429,7 +1429,7 @@ LedgerMaster::findNewLedgersToPublish( { JLOG(m_journal.fatal()) << "Ledger: " << valSeq << " does not have hash for " << seq; - assert(false); + XRPL_UNREACHABLE(); } else { @@ -1516,7 +1516,7 @@ LedgerMaster::tryAdvance() app_.getJobQueue().addJob(jtADVANCE, "advanceLedger", [this]() { std::unique_lock sl(m_mutex); - assert(!mValidLedger.empty() && mAdvanceThread); + XRPL_ASSERT(!mValidLedger.empty() && mAdvanceThread); JLOG(m_journal.trace()) << "advanceThread<"; @@ -1835,7 +1835,7 @@ LedgerMaster::walkHashBySeq( // be located easily and should contain the hash. LedgerIndex refIndex = getCandidateLedger(index); auto const refHash = hashOfSeq(*referenceLedger, refIndex, m_journal); - assert(refHash); + XRPL_ASSERT(refHash); if (refHash) { // Try the hash and sequence of a better reference ledger just found @@ -1860,7 +1860,7 @@ LedgerMaster::walkHashBySeq( *refHash, refIndex, reason)) { ledgerHash = hashOfSeq(*l, index, m_journal); - assert(ledgerHash); + XRPL_ASSERT(ledgerHash); } } } @@ -1972,7 +1972,7 @@ LedgerMaster::fetchForHistory( ScopedUnlock sul{sl}; if (auto hash = getLedgerHashForHistory(missing, reason)) { - assert(hash->isNonZero()); + XRPL_ASSERT(hash->isNonZero()); auto ledger = getLedgerByHash(*hash); if (!ledger) { @@ -1999,7 +1999,7 @@ LedgerMaster::fetchForHistory( if (ledger) { auto seq = ledger->info().seq; - assert(seq == missing); + XRPL_ASSERT(seq == missing); JLOG(m_journal.trace()) << "fetchForHistory acquired " << seq; if (reason == InboundLedger::Reason::SHARD) { @@ -2059,7 +2059,7 @@ LedgerMaster::fetchForHistory( std::uint32_t seq = missing - i; if (auto h = getLedgerHashForHistory(seq, reason)) { - assert(h->isNonZero()); + XRPL_ASSERT(h->isNonZero()); app_.getInboundLedgers().acquire(*h, seq, reason); } } @@ -2254,7 +2254,7 @@ populateFetchPack( std::uint32_t seq, bool withLeaves = true) { - assert(cnt != 0); + XRPL_ASSERT(cnt != 0); Serializer s(1024); diff --git a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index d7f29e33b3b..578a481c482 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -32,7 +32,7 @@ LedgerReplayTask::TaskParameter::TaskParameter( std::uint32_t totalNumLedgers) : reason_(r), finishHash_(finishLedgerHash), totalLedgers_(totalNumLedgers) { - assert(finishLedgerHash.isNonZero() && totalNumLedgers > 0); + XRPL_ASSERT(finishLedgerHash.isNonZero() && totalNumLedgers > 0); } bool @@ -48,7 +48,7 @@ LedgerReplayTask::TaskParameter::update( skipList_ = sList; skipList_.emplace_back(finishHash_); startHash_ = skipList_[skipList_.size() - totalLedgers_]; - assert(startHash_.isNonZero()); + XRPL_ASSERT(startHash_.isNonZero()); startSeq_ = finishSeq_ - totalLedgers_ + 1; full_ = true; return true; @@ -200,7 +200,7 @@ LedgerReplayTask::tryAdvance(ScopedLockType& sl) for (; deltaToBuild_ < deltas_.size(); ++deltaToBuild_) { auto& delta = deltas_[deltaToBuild_]; - assert(parent_->seq() + 1 == delta->ledgerSeq_); + XRPL_ASSERT(parent_->seq() + 1 == delta->ledgerSeq_); if (auto l = delta->tryBuild(parent_); l) { JLOG(journal_.debug()) @@ -289,7 +289,7 @@ LedgerReplayTask::addDelta(std::shared_ptr const& delta) JLOG(journal_.trace()) << "addDelta task " << hash_ << " deltaIndex=" << deltaToBuild_ << " totalDeltas=" << deltas_.size(); - assert( + XRPL_ASSERT( deltas_.empty() || deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_); deltas_.push_back(delta); diff --git a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp index 4aa0e4beb79..8d8d4380843 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp @@ -47,7 +47,7 @@ LedgerReplayer::replay( uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers) { - assert( + XRPL_ASSERT( finishLedgerHash.isNonZero() && totalNumLedgers > 0 && totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE); diff --git a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp index 1d1de62b61b..28621ddfeb2 100644 --- a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp @@ -139,7 +139,7 @@ SkipListAcquire::processData( std::uint32_t ledgerSeq, boost::intrusive_ptr const& item) { - assert(ledgerSeq != 0 && item); + XRPL_ASSERT(ledgerSeq != 0 && item); ScopedLockType sl(mtx_); if (isDone()) return; @@ -224,7 +224,7 @@ SkipListAcquire::onSkipListAcquired( void SkipListAcquire::notify(ScopedLockType& sl) { - assert(isDone()); + XRPL_ASSERT(isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 9d677dbe5a1..94f762a74c2 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -43,7 +43,7 @@ TimeoutCounter::TimeoutCounter( , queueJobParameter_(std::move(jobParameter)) , timer_(app_.getIOService()) { - assert((timerInterval_ > 10ms) && (timerInterval_ < 30s)); + XRPL_ASSERT((timerInterval_ > 10ms) && (timerInterval_ < 30s)); } void diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index ff6cc0584ca..69610114a80 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -613,7 +613,7 @@ class ApplicationImp : public Application, public BasicApp virtual ServerHandler& getServerHandler() override { - assert(serverHandler_); + XRPL_ASSERT(serverHandler_); return *serverHandler_; } @@ -889,35 +889,35 @@ class ApplicationImp : public Application, public BasicApp Overlay& overlay() override { - assert(overlay_); + XRPL_ASSERT(overlay_); return *overlay_; } TxQ& getTxQ() override { - assert(txQ_.get() != nullptr); + XRPL_ASSERT(txQ_.get() != nullptr); return *txQ_; } RelationalDatabase& getRelationalDatabase() override { - assert(mRelationalDatabase.get() != nullptr); + XRPL_ASSERT(mRelationalDatabase.get() != nullptr); return *mRelationalDatabase; } DatabaseCon& getWalletDB() override { - assert(mWalletDB.get() != nullptr); + XRPL_ASSERT(mWalletDB.get() != nullptr); return *mWalletDB; } ReportingETL& getReportingETL() override { - assert(reportingETL_.get() != nullptr); + XRPL_ASSERT(reportingETL_.get() != nullptr); return *reportingETL_; } @@ -932,7 +932,7 @@ class ApplicationImp : public Application, public BasicApp bool initRelationalDatabase() { - assert(mWalletDB.get() == nullptr); + XRPL_ASSERT(mWalletDB.get() == nullptr); try { @@ -1375,7 +1375,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) for (auto const& [a, vote] : amendments) { auto const f = ripple::getRegisteredFeature(a); - assert(f); + XRPL_ASSERT(f); if (f) supported.emplace_back(a, *f, vote); } @@ -1904,7 +1904,7 @@ ApplicationImp::startGenesisLedger() auto const next = std::make_shared(*genesis, timeKeeper().closeTime()); next->updateSkipList(); - assert( + XRPL_ASSERT( next->info().seq < XRP_LEDGER_EARLIEST_FEES || next->read(keylet::fees())); next->setImmutable(); @@ -1925,7 +1925,7 @@ ApplicationImp::getLastFullLedger() if (!ledger) return ledger; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(); @@ -2079,7 +2079,7 @@ ApplicationImp::loadLedgerFromFile(std::string const& name) loadLedger->stateMap().flushDirty(hotACCOUNT_NODE); - assert( + XRPL_ASSERT( loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || loadLedger->read(keylet::fees())); loadLedger->setAccepted( @@ -2179,7 +2179,7 @@ ApplicationImp::loadOldLedger( if (!loadLedger) { JLOG(m_journal.fatal()) << "Replay ledger missing/damaged"; - assert(false); + XRPL_UNREACHABLE(); return false; } } @@ -2208,21 +2208,21 @@ ApplicationImp::loadOldLedger( if (loadLedger->info().accountHash.isZero()) { JLOG(m_journal.fatal()) << "Ledger is empty."; - assert(false); + XRPL_UNREACHABLE(); return false; } if (!loadLedger->walkLedger(journal("Ledger"), true)) { JLOG(m_journal.fatal()) << "Ledger is missing nodes."; - assert(false); + XRPL_UNREACHABLE(); return false; } if (!loadLedger->assertSensible(journal("Ledger"))) { JLOG(m_journal.fatal()) << "Ledger is not sensible."; - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -2348,8 +2348,8 @@ ApplicationImp::journal(std::string const& name) bool ApplicationImp::nodeToShards() { - assert(overlay_); - assert(!config_->standalone()); + XRPL_ASSERT(overlay_); + XRPL_ASSERT(!config_->standalone()); if (config_->section(ConfigSection::shardDatabase()).empty()) { diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 5d5a79db393..bbe69398a67 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -243,7 +243,7 @@ GRPCServerImpl::CallData::forwardToP2p( } else { - assert(false); + XRPL_UNREACHABLE(); Throw( "Attempting to forward but no client_ip field in " "protobuf message"); @@ -714,7 +714,7 @@ GRPCServer::stop() GRPCServer::~GRPCServer() { - assert(!running_); + XRPL_ASSERT(!running_); } } // namespace ripple diff --git a/src/xrpld/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp index f5dd8719470..85ca9b11960 100644 --- a/src/xrpld/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -73,7 +73,7 @@ void LoadManager::start() { JLOG(journal_.debug()) << "Starting"; - assert(!thread_.joinable()); + XRPL_ASSERT(!thread_.joinable()); thread_ = std::thread{&LoadManager::run, this}; } diff --git a/src/xrpld/app/main/NodeStoreScheduler.cpp b/src/xrpld/app/main/NodeStoreScheduler.cpp index bf07e559fd3..755bffeef02 100644 --- a/src/xrpld/app/main/NodeStoreScheduler.cpp +++ b/src/xrpld/app/main/NodeStoreScheduler.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace ripple { diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index cb4e57b0f73..c2db2a659ad 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -200,7 +200,7 @@ FeeVoteImpl::doVoting( std::shared_ptr const& initialPosition) { // LCL must be flag ledger - assert(lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); + XRPL_ASSERT(lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); detail::VotableValue baseFeeVote( lastClosedLedger->fees().base, target_.reference_fee); diff --git a/src/xrpld/app/misc/HashRouter.cpp b/src/xrpld/app/misc/HashRouter.cpp index c117d20fe2b..63a53ecdfdb 100644 --- a/src/xrpld/app/misc/HashRouter.cpp +++ b/src/xrpld/app/misc/HashRouter.cpp @@ -101,7 +101,7 @@ HashRouter::getFlags(uint256 const& key) bool HashRouter::setFlags(uint256 const& key, int flags) { - assert(flags != 0); + XRPL_ASSERT(flags != 0); std::lock_guard lock(mutex_); diff --git a/src/xrpld/app/misc/NegativeUNLVote.cpp b/src/xrpld/app/misc/NegativeUNLVote.cpp index 45d72bcd2b3..8baf8a32e91 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.cpp +++ b/src/xrpld/app/misc/NegativeUNLVote.cpp @@ -89,7 +89,7 @@ NegativeUNLVote::doVoting( { auto n = choose(prevLedger->info().hash, candidates.toDisableCandidates); - assert(nidToKeyMap.count(n)); + XRPL_ASSERT(nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToDisable, initialSet); } @@ -97,7 +97,7 @@ NegativeUNLVote::doVoting( { auto n = choose( prevLedger->info().hash, candidates.toReEnableCandidates); - assert(nidToKeyMap.count(n)); + XRPL_ASSERT(nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToReEnable, initialSet); } } @@ -140,7 +140,7 @@ NegativeUNLVote::choose( uint256 const& randomPadData, std::vector const& candidates) { - assert(!candidates.empty()); + XRPL_ASSERT(!candidates.empty()); static_assert(NodeID::bytes <= uint256::bytes); NodeID randomPad = NodeID::fromVoid(randomPadData.data()); NodeID txNodeID = candidates[0]; diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 9cf5d097099..a2d5a7da789 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -104,7 +104,7 @@ class NetworkOPsImp final : public NetworkOPs FailHard f) : transaction(t), admin(a), local(l), failType(f) { - assert(local || failType == FailHard::no); + XRPL_ASSERT(local || failType == FailHard::no); } }; @@ -1215,7 +1215,7 @@ NetworkOPsImp::processTransaction( *transaction->getSTransaction(), view->rules(), app_.config()); - assert(validity == Validity::Valid); + XRPL_ASSERT(validity == Validity::Valid); // Not concerned with local checks at this point. if (validity == Validity::SigBad) @@ -1321,9 +1321,9 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) std::vector submit_held; std::vector transactions; mTransactions.swap(transactions); - assert(!transactions.empty()); + XRPL_ASSERT(!transactions.empty()); - assert(mDispatchState != DispatchState::running); + XRPL_ASSERT(mDispatchState != DispatchState::running); mDispatchState = DispatchState::running; batchLock.unlock(); @@ -1539,7 +1539,7 @@ NetworkOPsImp::getOwnerInfo( for (auto const& uDirEntry : sleNode->getFieldV256(sfIndexes)) { auto sleCur = lpLedger->read(keylet::child(uDirEntry)); - assert(sleCur); + XRPL_ASSERT(sleCur); switch (sleCur->getType()) { @@ -1566,7 +1566,7 @@ NetworkOPsImp::getOwnerInfo( case ltACCOUNT_ROOT: case ltDIR_NODE: default: - assert(false); + XRPL_UNREACHABLE(); break; } } @@ -1576,7 +1576,7 @@ NetworkOPsImp::getOwnerInfo( if (uNodeDir) { sleNode = lpLedger->read(keylet::page(root, uNodeDir)); - assert(sleNode); + XRPL_ASSERT(sleNode); } } while (uNodeDir); } @@ -1806,7 +1806,7 @@ NetworkOPsImp::switchLastClosedLedger( bool NetworkOPsImp::beginConsensus(uint256 const& networkClosed) { - assert(networkClosed.isNonZero()); + XRPL_ASSERT(networkClosed.isNonZero()); auto closingInfo = m_ledgerMaster.getCurrentLedger()->info(); @@ -1827,8 +1827,8 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed) return false; } - assert(prevLedger->info().hash == closingInfo.parentHash); - assert( + XRPL_ASSERT(prevLedger->info().hash == closingInfo.parentHash); + XRPL_ASSERT( closingInfo.parentHash == m_ledgerMaster.getClosedLedger()->info().hash); @@ -2955,7 +2955,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) lpAccepted->info().hash, alpAccepted); } - assert(alpAccepted->getLedger().get() == lpAccepted.get()); + XRPL_ASSERT(alpAccepted->getLedger().get() == lpAccepted.get()); { JLOG(m_journal.debug()) @@ -3358,7 +3358,7 @@ NetworkOPsImp::pubAccountTransaction( if (last) jvObj.set(jss::account_history_boundary, true); - assert( + XRPL_ASSERT( jvObj.isMember(jss::account_history_tx_stream) == MultiApiJson::none); for (auto& info : accountHistoryNotify) @@ -3433,7 +3433,7 @@ NetworkOPsImp::pubProposedAccountTransaction( isrListener->getApiVersion(), // [&](Json::Value const& jv) { isrListener->send(jv, true); }); - assert( + XRPL_ASSERT( jvObj.isMember(jss::account_history_tx_stream) == MultiApiJson::none); for (auto& info : accountHistoryNotify) @@ -3713,7 +3713,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) return db->newestAccountTxPage(options); } default: { - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -3909,7 +3909,7 @@ NetworkOPsImp::subAccountHistoryStart( } else { - assert(false); + XRPL_UNREACHABLE(); return; } } @@ -4017,7 +4017,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else - assert(false); + XRPL_UNREACHABLE(); return true; } @@ -4036,7 +4036,7 @@ NetworkOPsImp::acceptLedger( { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` - assert(m_standalone); + XRPL_ASSERT(m_standalone); if (!m_standalone) Throw( diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index d32556a4b29..91a4403be5d 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -281,7 +281,7 @@ SHAMapStoreImp::run() { if (app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); @@ -553,7 +553,7 @@ SHAMapStoreImp::clearSql( std::function()> const& getMinSeq, std::function const& deleteBeforeSeq) { - assert(deleteInterval_); + XRPL_ASSERT(deleteInterval_); LedgerIndex min = std::numeric_limits::max(); { @@ -618,7 +618,7 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated) { if (app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); diff --git a/src/xrpld/app/misc/detail/AMMHelpers.cpp b/src/xrpld/app/misc/detail/AMMHelpers.cpp index f10b4c15eb0..3518d0b0be7 100644 --- a/src/xrpld/app/misc/detail/AMMHelpers.cpp +++ b/src/xrpld/app/misc/detail/AMMHelpers.cpp @@ -209,7 +209,7 @@ adjustAmountsByLPTokens( return std::make_tuple(amountActual, std::nullopt, lpTokensActual); } - assert(lpTokensActual == lpTokens); + XRPL_ASSERT(lpTokensActual == lpTokens); return {amount, amount2, lpTokensActual}; } diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp index efc80cf17b6..918e2624d3c 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -145,7 +145,7 @@ std::uint16_t getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account) { using namespace std::chrono; - assert( + XRPL_ASSERT( !view.rules().enabled(fixInnerObjTemplate) || ammSle.isFieldPresent(sfAuctionSlot)); if (ammSle.isFieldPresent(sfAuctionSlot)) diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index 62b80890821..44ec7586289 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -656,7 +656,7 @@ AmendmentTableImpl::persistVote( std::string const& name, AmendmentVote vote) const { - assert(vote != AmendmentVote::obsolete); + XRPL_ASSERT(vote != AmendmentVote::obsolete); auto db = db_.checkoutDb(); voteAmendment(*db, amendment, name, vote); } diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp index a17858ceb39..b9717a3c620 100644 --- a/src/xrpld/app/misc/detail/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -390,7 +390,7 @@ ManifestCache::applyManifest(Manifest m) auto prewriteCheck = [this, &m](auto const& iter, bool checkSignature, auto const& lock) -> std::optional { - assert(lock.owns_lock()); + XRPL_ASSERT(lock.owns_lock()); (void)lock; // not used. parameter is present to ensure the mutex is // locked when the lambda is called. if (iter != map_.end() && m.sequence <= iter->second.sequence) diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index e0c3f260fe5..4f9bd6b4bf6 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -84,7 +84,7 @@ Transaction::sqlTransactionStatus(boost::optional const& status) return INCLUDED; } - assert(c == txnSqlUnknown); + XRPL_ASSERT(c == txnSqlUnknown); return INVALID; } diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 159a700cc3f..3ec8befb75a 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -52,7 +52,7 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return std::pair{baseFee + mod, feePaid + mod}; }(); - assert(baseFee.signum() > 0); + XRPL_ASSERT(baseFee.signum() > 0); if (effectiveFeePaid.signum() <= 0 || baseFee.signum() <= 0) { return FeeLevel64(0); @@ -95,7 +95,7 @@ TxQ::FeeMetrics::update( feeLevels.push_back(getFeeLevelPaid(view, *tx.first)); }); std::sort(feeLevels.begin(), feeLevels.end()); - assert(size == feeLevels.size()); + XRPL_ASSERT(size == feeLevels.size()); JLOG((timeLeap ? j_.warn() : j_.debug())) << "Ledger " << view.info().seq << " has " << size << " transactions. " @@ -247,7 +247,7 @@ TxQ::FeeMetrics::escalatedSeriesFeeLevel( auto const target = snapshot.txnsExpected; auto const multiplier = snapshot.escalationMultiplier; - assert(current > target); + XRPL_ASSERT(current > target); /* Calculate (apologies for the terrible notation) sum(n = current -> last) : multiplier * n * n / (target * target) @@ -292,7 +292,7 @@ std::pair TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) { // If the rules or flags change, preflight again - assert(pfresult); + XRPL_ASSERT(pfresult); STAmountSO stAmountSO{view.rules().enabled(fixSTAmountCanonicalize)}; NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; @@ -337,8 +337,8 @@ TxQ::TxQAccount::add(MaybeTx&& txn) auto const seqProx = txn.seqProxy; auto result = transactions.emplace(seqProx, std::move(txn)); - assert(result.second); - assert(&result.first->second != &txn); + XRPL_ASSERT(result.second); + XRPL_ASSERT(&result.first->second != &txn); return result.first->second; } @@ -448,7 +448,7 @@ TxQ::erase(TxQ::FeeMultiSet::const_iterator_type candidateIter) // so the memory can be freed. auto const found = txQAccount.remove(seqProx); (void)found; - assert(found); + XRPL_ASSERT(found); return newCandidateIter; } @@ -460,15 +460,15 @@ TxQ::eraseAndAdvance(TxQ::FeeMultiSet::const_iterator_type candidateIter) auto& txQAccount = byAccount_.at(candidateIter->account); auto const accountIter = txQAccount.transactions.find(candidateIter->seqProxy); - assert(accountIter != txQAccount.transactions.end()); + XRPL_ASSERT(accountIter != txQAccount.transactions.end()); // Note that sequence-based transactions must be applied in sequence order // from smallest to largest. But ticket-based transactions can be // applied in any order. - assert( + XRPL_ASSERT( candidateIter->seqProxy.isTicket() || accountIter == txQAccount.transactions.begin()); - assert(byFee_.iterator_to(accountIter->second) == candidateIter); + XRPL_ASSERT(byFee_.iterator_to(accountIter->second) == candidateIter); auto const accountNextIter = std::next(accountIter); // Check if the next transaction for this account is earlier in the queue, @@ -515,7 +515,7 @@ TxQ::tryClearAccountQueueUpThruTx( beast::Journal j) { SeqProxy const tSeqProx{tx.getSeqProxy()}; - assert(beginTxIter != accountIter->second.transactions.end()); + XRPL_ASSERT(beginTxIter != accountIter->second.transactions.end()); // This check is only concerned with the range from // [aSeqProxy, tSeqProxy) @@ -998,7 +998,7 @@ TxQ::apply( // o The current first thing in the queue has a Ticket and // * The tx has a Ticket that precedes it or // * txSeqProx == acctSeqProx. - assert(prevIter != txIter->end); + XRPL_ASSERT(prevIter != txIter->end); if (prevIter == txIter->end || txSeqProx < prevIter->first) { // The first Sequence number in the queue must be the @@ -1119,7 +1119,7 @@ TxQ::apply( // inserted in the middle from fouling up later transactions. auto const potentialTotalSpend = totalFee + std::min(balance - std::min(balance, reserve), potentialSpend); - assert( + XRPL_ASSERT( potentialTotalSpend > XRPAmount{0} || (potentialTotalSpend == XRPAmount{0} && multiTxn->applyView.fees().base == 0)); @@ -1152,7 +1152,7 @@ TxQ::apply( return {pcresult.ter, false}; // Too low of a fee should get caught by preclaim - assert(feeLevelPaid >= baseLevel); + XRPL_ASSERT(feeLevelPaid >= baseLevel); JLOG(j_.trace()) << "Transaction " << transactionID << " from account " << account << " has fee level of " << feeLevelPaid @@ -1277,7 +1277,7 @@ TxQ::apply( // The queue is full, and this transaction is more // valuable, so kick out the cheapest transaction. auto dropRIter = endAccount.transactions.rbegin(); - assert(dropRIter->second.account == lastRIter->account); + XRPL_ASSERT(dropRIter->second.account == lastRIter->account); JLOG(j_.info()) << "Removing last item of account " << lastRIter->account << " from queue with average fee of " << endEffectiveFeeLevel @@ -1307,7 +1307,7 @@ TxQ::apply( std::tie(accountIter, created) = byAccount_.emplace(account, TxQAccount(tx)); (void)created; - assert(created); + XRPL_ASSERT(created); } // Modify the flags for use when coming out of the queue. // These changes _may_ cause an extra `preflight`, but as long as @@ -1520,7 +1520,7 @@ TxQ::accept(Application& app, OpenView& view) // making things worse, drop the _last_ transaction for // this account. auto dropRIter = account.transactions.rbegin(); - assert( + XRPL_ASSERT( dropRIter->second.account == candidateIter->account); @@ -1553,7 +1553,7 @@ TxQ::accept(Application& app, OpenView& view) LedgerHash const& parentHash = view.info().parentHash; #if !NDEBUG auto const startingSize = byFee_.size(); - assert(parentHash != parentHash_); + XRPL_ASSERT(parentHash != parentHash_); parentHash_ = parentHash; #endif // byFee_ doesn't "own" the candidate objects inside it, so it's @@ -1575,7 +1575,7 @@ TxQ::accept(Application& app, OpenView& view) byFee_.insert(candidate); } } - assert(byFee_.size() == startingSize); + XRPL_ASSERT(byFee_.size() == startingSize); return ledgerChanged; } @@ -1734,10 +1734,10 @@ TxQ::removeFromByFee( // If the transaction we're holding replaces a transaction in the // queue, remove the transaction that is being replaced. auto deleteIter = byFee_.iterator_to((*replacedTxIter)->second); - assert(deleteIter != byFee_.end()); - assert(&(*replacedTxIter)->second == &*deleteIter); - assert(deleteIter->seqProxy == tx->getSeqProxy()); - assert(deleteIter->account == (*tx)[sfAccount]); + XRPL_ASSERT(deleteIter != byFee_.end()); + XRPL_ASSERT(&(*replacedTxIter)->second == &*deleteIter); + XRPL_ASSERT(deleteIter->seqProxy == tx->getSeqProxy()); + XRPL_ASSERT(deleteIter->account == (*tx)[sfAccount]); erase(deleteIter); } diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index a3854106a1c..e3a3b0addb2 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -276,7 +276,8 @@ ValidatorList::buildFileData( { Json::Value value(Json::objectValue); - assert(pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); + XRPL_ASSERT( + pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.rawVersion; @@ -376,7 +377,7 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) ValidatorBlobInfo& info = result.emplace_back(); info.blob = body[jss::blob].asString(); info.signature = body[jss::signature].asString(); - assert(result.size() == 1); + XRPL_ASSERT(result.size() == 1); return result; } // Treat unknown versions as if they're the latest version. This @@ -411,7 +412,7 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) info.manifest = blobInfo[jss::manifest].asString(); } } - assert(result.size() == blobs.size()); + XRPL_ASSERT(result.size() == blobs.size()); return result; } } @@ -442,7 +443,7 @@ ValidatorList::parseBlobs(protocol::TMValidatorListCollection const& body) info.manifest = blob.manifest(); } } - assert(result.size() == body.blobs_size()); + XRPL_ASSERT(result.size() == body.blobs_size()); return result; } @@ -464,7 +465,7 @@ splitMessage( { if (begin == 0 && end == 0) end = largeMsg.blobs_size(); - assert(begin < end); + XRPL_ASSERT(begin < end); if (end <= begin) return 0; @@ -498,7 +499,7 @@ splitMessageParts( if (blob.has_manifest()) smallMsg.set_manifest(blob.manifest()); - assert(Message::totalSize(smallMsg) <= maximiumMessageSize); + XRPL_ASSERT(Message::totalSize(smallMsg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(smallMsg, protocol::mtVALIDATORLIST), @@ -546,7 +547,7 @@ buildValidatorListMessage( ValidatorBlobInfo const& currentBlob, std::size_t maxSize) { - assert(messages.empty()); + XRPL_ASSERT(messages.empty()); protocol::TMValidatorList msg; auto const manifest = currentBlob.manifest ? *currentBlob.manifest : rawManifest; @@ -557,7 +558,7 @@ buildValidatorListMessage( // Override the version msg.set_version(version); - assert(Message::totalSize(msg) <= maximiumMessageSize); + XRPL_ASSERT(Message::totalSize(msg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(msg, protocol::mtVALIDATORLIST), sha512Half(msg), @@ -576,7 +577,7 @@ buildValidatorListMessage( std::map const& blobInfos, std::size_t maxSize) { - assert(messages.empty()); + XRPL_ASSERT(messages.empty()); protocol::TMValidatorListCollection msg; auto const version = rawVersion < 2 ? 2 : rawVersion; msg.set_version(version); @@ -592,7 +593,7 @@ buildValidatorListMessage( if (blobInfo.manifest) blob.set_manifest(*blobInfo.manifest); } - assert(msg.blobs_size() > 0); + XRPL_ASSERT(msg.blobs_size() > 0); if (Message::totalSize(msg) > maxSize) { // split into smaller messages @@ -621,7 +622,7 @@ ValidatorList::buildValidatorListMessages( std::vector& messages, std::size_t maxSize /*= maximiumMessageSize*/) { - assert(!blobInfos.empty()); + XRPL_ASSERT(!blobInfos.empty()); auto const& [currentSeq, currentBlob] = *blobInfos.begin(); auto numVLs = std::accumulate( messages.begin(), @@ -705,7 +706,7 @@ ValidatorList::sendValidatorList( messages); if (newPeerSequence) { - assert(!messages.empty()); + XRPL_ASSERT(!messages.empty()); // Don't send it next time. peer.setPublisherListSequence(publisherKey, newPeerSequence); @@ -721,7 +722,7 @@ ValidatorList::sendValidatorList( } // The only way sent wil be false is if the messages was too big, and // thus there will only be one entry without a message - assert(sent || messages.size() == 1); + XRPL_ASSERT(sent || messages.size() == 1); if (sent) { if (messageVersion > 1) @@ -735,7 +736,7 @@ ValidatorList::sendValidatorList( << "]"; else { - assert(numVLs == 1); + XRPL_ASSERT(numVLs == 1); JLOG(j.debug()) << "Sent validator list for " << strHex(publisherKey) << " with sequence " << newPeerSequence << " to " @@ -830,7 +831,7 @@ ValidatorList::broadcastBlobs( // be built to hold info for all of the valid VLs. std::map blobInfos; - assert( + XRPL_ASSERT( lists.current.sequence == maxSequence || lists.remaining.count(maxSequence) == 1); // Can't use overlay.foreach here because we need to modify @@ -976,7 +977,7 @@ ValidatorList::applyLists( for (auto iter = remaining.begin(); iter != remaining.end();) { auto next = std::next(iter); - assert(next == remaining.end() || next->first > iter->first); + XRPL_ASSERT(next == remaining.end() || next->first > iter->first); if (iter->first <= current.sequence || (next != remaining.end() && next->second.validFrom <= iter->second.validFrom)) @@ -1148,7 +1149,7 @@ ValidatorList::applyList( // Remove the entry in "remaining" pubCollection.remaining.erase(sequence); // Done - assert(publisher.sequence == sequence); + XRPL_ASSERT(publisher.sequence == sequence); } else { @@ -1442,7 +1443,7 @@ ValidatorList::removePublisherList( PublicKey const& publisherKey, PublisherStatus reason) { - assert( + XRPL_ASSERT( reason != PublisherStatus::available && reason != PublisherStatus::unavailable); auto const iList = publisherLists_.find(publisherKey); @@ -1629,7 +1630,7 @@ ValidatorList::getJson() const Json::Value& r = remaining.append(Json::objectValue); appendList(future, r); // Race conditions can happen, so make this check "fuzzy" - assert(future.validFrom > timeKeeper_.now() + 600s); + XRPL_ASSERT(future.validFrom > timeKeeper_.now() + 600s); } if (remaining.size()) curr[jss::remaining] = std::move(remaining); @@ -1694,7 +1695,7 @@ ValidatorList::for_each_available( { if (plCollection.status != PublisherStatus::available) continue; - assert(plCollection.maxSequence); + XRPL_ASSERT(plCollection.maxSequence); func( plCollection.rawManifest, plCollection.rawVersion, @@ -1828,21 +1829,21 @@ ValidatorList::updateTrusted( next->second.validFrom <= closeTime; ++iter, ++next) { - assert(std::next(iter) == next); + XRPL_ASSERT(std::next(iter) == next); } - assert(iter != remaining.end()); + XRPL_ASSERT(iter != remaining.end()); // Rotate the pending list in to current auto sequence = iter->first; auto& candidate = iter->second; auto& current = collection.current; - assert(candidate.validFrom <= closeTime); + XRPL_ASSERT(candidate.validFrom <= closeTime); auto const oldList = current.list; current = std::move(candidate); if (collection.status != PublisherStatus::available) collection.status = PublisherStatus::available; - assert(current.sequence == sequence); + XRPL_ASSERT(current.sequence == sequence); // If the list is expired, remove the validators so they don't // get processed in. The expiration check below will do the rest // of the work @@ -1919,7 +1920,7 @@ ValidatorList::updateTrusted( { std::optional const signingKey = validatorManifests_.getSigningKey(k); - assert(signingKey); + XRPL_ASSERT(signingKey); trustedSigningKeys_.insert(*signingKey); } } diff --git a/src/xrpld/app/misc/detail/ValidatorSite.cpp b/src/xrpld/app/misc/detail/ValidatorSite.cpp index 0c12816c1b8..299a802a967 100644 --- a/src/xrpld/app/misc/detail/ValidatorSite.cpp +++ b/src/xrpld/app/misc/detail/ValidatorSite.cpp @@ -411,7 +411,7 @@ ValidatorSite::parseJsonResponse( } auto const manifest = body[jss::manifest].asString(); - assert(version == body[jss::version].asUInt()); + XRPL_ASSERT(version == body[jss::version].asUInt()); auto const& uri = sites_[siteIdx].activeResource->uri; auto const hash = sha512Half(manifest, blobs, version); auto const applyResult = app_.validators().applyListsAndBroadcast( @@ -586,7 +586,7 @@ ValidatorSite::onSiteFetch( case status::temporary_redirect: { auto newLocation = processRedirect(res, siteIdx, lock_sites); - assert(newLocation); + XRPL_ASSERT(newLocation); // for perm redirects, also update our starting URI if (res.result() == status::moved_permanently || res.result() == status::permanent_redirect) diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index d7795af8bf0..4f38d379dd0 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -282,7 +282,7 @@ WorkBase::onResponse(error_code const& ec) return fail(ec); close(); - assert(cb_); + XRPL_ASSERT(cb_); cb_(ec, lastEndpoint_, std::move(res_)); cb_ = nullptr; } diff --git a/src/xrpld/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h index 266e5098cb6..db4c6d68133 100644 --- a/src/xrpld/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace ripple { @@ -88,7 +88,7 @@ WorkFile::run() error_code ec; auto const fileContents = getFileContents(ec, path_, megabytes(1)); - assert(cb_); + XRPL_ASSERT(cb_); cb_(ec, fileContents); cb_ = nullptr; } diff --git a/src/xrpld/app/paths/Credit.cpp b/src/xrpld/app/paths/Credit.cpp index c11f628a11d..fcead298691 100644 --- a/src/xrpld/app/paths/Credit.cpp +++ b/src/xrpld/app/paths/Credit.cpp @@ -42,8 +42,8 @@ creditLimit( result.setIssuer(account); } - assert(result.getIssuer() == account); - assert(result.getCurrency() == currency); + XRPL_ASSERT(result.getIssuer() == account); + XRPL_ASSERT(result.getCurrency() == currency); return result; } @@ -76,8 +76,8 @@ creditBalance( result.setIssuer(account); } - assert(result.getIssuer() == account); - assert(result.getCurrency() == currency); + XRPL_ASSERT(result.getIssuer() == account); + XRPL_ASSERT(result.getCurrency() == currency); return result; } diff --git a/src/xrpld/app/paths/Flow.cpp b/src/xrpld/app/paths/Flow.cpp index c21d40c33b5..caa729496f3 100644 --- a/src/xrpld/app/paths/Flow.cpp +++ b/src/xrpld/app/paths/Flow.cpp @@ -193,7 +193,7 @@ flow( flowDebugInfo)); } - assert(!srcIsXRP && !dstIsXRP); + XRPL_ASSERT(!srcIsXRP && !dstIsXRP); return finishFlow( sb, srcIssue, diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index 4cd9f7d71f7..9161d7f5695 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -158,7 +158,7 @@ PathRequest::updateComplete() { std::lock_guard sl(mIndexLock); - assert(mInProgress); + XRPL_ASSERT(mInProgress); mInProgress = false; if (fCompletion) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index 885a8ae9b47..78fb4f3c827 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -188,7 +188,8 @@ Pathfinder::Pathfinder( , app_(app) , j_(app.journal("Pathfinder")) { - assert(!uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); + XRPL_ASSERT( + !uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); } bool @@ -577,7 +578,7 @@ Pathfinder::getBestPaths( if (mCompletePaths.empty() && extraPaths.empty()) return mCompletePaths; - assert(fullLiquidityPath.empty()); + XRPL_ASSERT(fullLiquidityPath.empty()); const bool issuerIsSender = isXRP(mSrcCurrency) || (srcIssuer == mSrcAccount); @@ -638,7 +639,7 @@ Pathfinder::getBestPaths( if (path.empty()) { - assert(false); + XRPL_UNREACHABLE(); continue; } @@ -681,7 +682,7 @@ Pathfinder::getBestPaths( if (remaining > beast::zero) { - assert(fullLiquidityPath.empty()); + XRPL_ASSERT(fullLiquidityPath.empty()); JLOG(j_.info()) << "Paths could not send " << remaining << " of " << mDstAmount; } @@ -830,7 +831,7 @@ Pathfinder::addPathsForType( { case nt_SOURCE: // Source must always be at the start, so pathsOut has to be empty. - assert(pathsOut.empty()); + XRPL_ASSERT(pathsOut.empty()); pathsOut.push_back(STPath()); break; @@ -1282,7 +1283,7 @@ void fillPaths(Pathfinder::PaymentType type, PathCostList const& costs) { auto& list = mPathTable[type]; - assert(list.empty()); + XRPL_ASSERT(list.empty()); for (auto& cost : costs) list.push_back({cost.cost, makePath(cost.path)}); } diff --git a/src/xrpld/app/paths/RippleLineCache.cpp b/src/xrpld/app/paths/RippleLineCache.cpp index 0ff967c0821..a4a3dd0c33a 100644 --- a/src/xrpld/app/paths/RippleLineCache.cpp +++ b/src/xrpld/app/paths/RippleLineCache.cpp @@ -79,7 +79,7 @@ RippleLineCache::getRippleLines( // to be replaced by the full set. The full set will be built // below, and will be returned, if needed, on subsequent calls // for either value of outgoing. - assert(size <= totalLineCount_); + XRPL_ASSERT(size <= totalLineCount_); totalLineCount_ -= size; lines_.erase(otheriter); } @@ -99,7 +99,7 @@ RippleLineCache::getRippleLines( if (inserted) { - assert(it->second == nullptr); + XRPL_ASSERT(it->second == nullptr); auto lines = PathFindTrustLine::getItems(accountID, *ledger_, direction); if (lines.size()) @@ -110,7 +110,7 @@ RippleLineCache::getRippleLines( } } - assert(!it->second || (it->second->size() > 0)); + XRPL_ASSERT(!it->second || (it->second->size() > 0)); auto const size = it->second ? it->second->size() : 0; JLOG(journal_.trace()) << "getRippleLines for ledger " << ledger_->info().seq << " found " << size diff --git a/src/xrpld/app/paths/detail/AMMLiquidity.cpp b/src/xrpld/app/paths/detail/AMMLiquidity.cpp index 8215cdee593..b4800cbab30 100644 --- a/src/xrpld/app/paths/detail/AMMLiquidity.cpp +++ b/src/xrpld/app/paths/detail/AMMLiquidity.cpp @@ -77,7 +77,7 @@ AMMLiquidity::generateFibSeqOffer( 196418, 317811, 514229, 832040, 1346269}; // clang-format on - assert(!ammContext_.maxItersReached()); + XRPL_ASSERT(!ammContext_.maxItersReached()); cur.out = toAmount( getIssue(balances.out), diff --git a/src/xrpld/app/paths/detail/AmountSpec.h b/src/xrpld/app/paths/detail/AmountSpec.h index 8a1117f9920..cb275958bd0 100644 --- a/src/xrpld/app/paths/detail/AmountSpec.h +++ b/src/xrpld/app/paths/detail/AmountSpec.h @@ -125,7 +125,7 @@ template <> inline IOUAmount& get(EitherAmount& amt) { - assert(!amt.native); + XRPL_ASSERT(!amt.native); return amt.iou; } @@ -133,7 +133,7 @@ template <> inline XRPAmount& get(EitherAmount& amt) { - assert(amt.native); + XRPL_ASSERT(amt.native); return amt.xrp; } @@ -149,7 +149,7 @@ template <> inline IOUAmount const& get(EitherAmount const& amt) { - assert(!amt.native); + XRPL_ASSERT(!amt.native); return amt.iou; } @@ -157,14 +157,14 @@ template <> inline XRPAmount const& get(EitherAmount const& amt) { - assert(amt.native); + XRPL_ASSERT(amt.native); return amt.xrp; } inline AmountSpec toAmountSpec(STAmount const& amt) { - assert(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); @@ -199,7 +199,7 @@ toAmountSpec(EitherAmount const& ea, std::optional const& c) AmountSpec r; r.native = (!c || isXRP(*c)); r.currency = c; - assert(ea.native == r.native); + XRPL_ASSERT(ea.native == r.native); if (r.native) { r.xrp = ea.xrp; diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index 4fa6f140aae..2796f138c93 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -381,7 +381,7 @@ class BookOfferCrossingStep getQuality(std::optional const& limitQuality) { // It's really a programming error if the quality is missing. - assert(limitQuality); + XRPL_ASSERT(limitQuality); if (!limitQuality) Throw(tefINTERNAL, "Offer requires quality."); return *limitQuality; @@ -1109,7 +1109,7 @@ BookStep::revImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingOut < 0 " << to_string(remainingOut); - assert(0); + XRPL_ASSERT(0); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1132,7 +1132,7 @@ BookStep::fwdImp( boost::container::flat_set& ofrsToRm, TIn const& in) { - assert(cache_); + XRPL_ASSERT(cache_); TAmounts result(beast::zero, beast::zero); @@ -1151,7 +1151,7 @@ BookStep::fwdImp( TOut const& ownerGives, std::uint32_t transferRateIn, std::uint32_t transferRateOut) mutable -> bool { - assert(cache_); + XRPL_ASSERT(cache_); if (remainingIn <= beast::zero) return false; @@ -1279,7 +1279,7 @@ BookStep::fwdImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingIn < 0 " << to_string(remainingIn); - assert(0); + XRPL_ASSERT(0); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1414,7 +1414,7 @@ bookStepEqual(Step const& step, ripple::Book const& book) bool const outXRP = isXRP(book.out.currency); if (inXRP && outXRP) { - assert(0); + XRPL_ASSERT(0); return false; // no such thing as xrp/xrp book step } if (inXRP && !outXRP) diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 25e78e9c47e..2845b00dec2 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -514,7 +514,7 @@ DirectStepI::revImp( auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); - assert(static_cast(this)->verifyDstQualityIn(dstQIn)); + XRPL_ASSERT(static_cast(this)->verifyDstQualityIn(dstQIn)); Issue const srcToDstIss(currency_, redeems(srcDebtDir) ? dst_ : src_); @@ -633,7 +633,7 @@ DirectStepI::fwdImp( boost::container::flat_set& /*ofrsToRm*/, IOUAmount const& in) { - assert(cache_); + XRPL_ASSERT(cache_); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -720,7 +720,7 @@ DirectStepI::validFwd( auto const savCache = *cache_; - assert(!in.native); + XRPL_ASSERT(!in.native); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -784,7 +784,7 @@ DirectStepI::qualitiesSrcIssues( { // Charge a transfer rate when issuing and previous step redeems - assert(static_cast(this)->verifyPrevStepDebtDirection( + XRPL_ASSERT(static_cast(this)->verifyPrevStepDebtDirection( prevStepDebtDirection)); std::uint32_t const srcQOut = redeems(prevStepDebtDirection) @@ -924,7 +924,7 @@ DirectStepI::check(StrandContext const& ctx) const { if (!ctx.prevStep) { - assert(0); // prev seen book without a prev step!?! + XRPL_ASSERT(0); // prev seen book without a prev step!?! return temBAD_PATH_LOOP; } diff --git a/src/xrpld/app/paths/detail/FlowDebugInfo.h b/src/xrpld/app/paths/detail/FlowDebugInfo.h index 000db4e5714..f75aeddc4c4 100644 --- a/src/xrpld/app/paths/detail/FlowDebugInfo.h +++ b/src/xrpld/app/paths/detail/FlowDebugInfo.h @@ -89,7 +89,7 @@ struct FlowDebugInfo void pushLiquiditySrc(EitherAmount const& eIn, EitherAmount const& eOut) { - assert(!liquiditySrcIn.empty()); + XRPL_ASSERT(!liquiditySrcIn.empty()); liquiditySrcIn.back().push_back(eIn); liquiditySrcOut.back().push_back(eOut); } @@ -122,7 +122,7 @@ struct FlowDebugInfo auto i = timePoints.find(tag); if (i == timePoints.end()) { - assert(0); + XRPL_ASSERT(0); return std::chrono::duration(0); } auto const& t = i->second; diff --git a/src/xrpld/app/paths/detail/PaySteps.cpp b/src/xrpld/app/paths/detail/PaySteps.cpp index f28c1b96a7c..ae046a6a2d1 100644 --- a/src/xrpld/app/paths/detail/PaySteps.cpp +++ b/src/xrpld/app/paths/detail/PaySteps.cpp @@ -100,11 +100,11 @@ toStep( // should already be taken care of JLOG(j.error()) << "Found offer/account payment step. Aborting payment strand."; - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, std::unique_ptr{}}; } - assert( + XRPL_ASSERT( (e2->getNodeType() & STPathElement::typeCurrency) || (e2->getNodeType() & STPathElement::typeIssuer)); auto const outCurrency = e2->getNodeType() & STPathElement::typeCurrency @@ -120,7 +120,7 @@ toStep( return {temBAD_PATH, std::unique_ptr{}}; } - assert(e2->isOffer()); + XRPL_ASSERT(e2->isOffer()); if (isXRP(outCurrency)) return make_BookStepIX(ctx, curIssue); @@ -391,7 +391,7 @@ toStrand( next->getCurrency() != curIssue.currency) { // Should never happen - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, Strand{}}; } @@ -457,7 +457,7 @@ toStrand( if (!checkStrand()) { JLOG(j.warn()) << "Flow check strand failed"; - assert(0); + XRPL_ASSERT(0); return {temBAD_PATH, Strand{}}; } diff --git a/src/xrpld/app/paths/detail/StepChecks.h b/src/xrpld/app/paths/detail/StepChecks.h index 140c9d1fe46..f529d19a6f1 100644 --- a/src/xrpld/app/paths/detail/StepChecks.h +++ b/src/xrpld/app/paths/detail/StepChecks.h @@ -35,7 +35,7 @@ checkFreeze( AccountID const& dst, Currency const& currency) { - assert(src != dst); + XRPL_ASSERT(src != dst); // check freeze if (auto sle = view.read(keylet::account(dst))) diff --git a/src/xrpld/app/paths/detail/StrandFlow.h b/src/xrpld/app/paths/detail/StrandFlow.h index 329a4cc643f..402d699494a 100644 --- a/src/xrpld/app/paths/detail/StrandFlow.h +++ b/src/xrpld/app/paths/detail/StrandFlow.h @@ -171,7 +171,7 @@ flow( << "Re-executed limiting step failed. r.first: " << to_string(get(r.first)) << " maxIn: " << to_string(*maxIn); - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } } @@ -207,7 +207,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed limiting step failed"; #endif - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } } @@ -241,7 +241,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed forward pass failed"; #endif - assert(0); + XRPL_ASSERT(0); return Result{strand, std::move(ofrsToRm)}; } stepIn = r.second; @@ -493,7 +493,7 @@ class ActiveStrands { if (i >= cur_.size()) { - assert(0); + XRPL_ASSERT(0); return nullptr; } return cur_[i]; @@ -700,7 +700,7 @@ flow( flowDebugInfo->pushLiquiditySrc( EitherAmount(f.in), EitherAmount(f.out)); - assert( + XRPL_ASSERT( f.out <= remainingOut && f.sandbox && (!remainingIn || f.in <= *remainingIn)); @@ -725,7 +725,7 @@ flow( if (baseView.rules().enabled(featureFlowSortStrands)) { - assert(!best); + XRPL_ASSERT(!best); if (!f.inactive) activeStrands.push(strand); best.emplace(f.in, f.out, std::move(*f.sandbox), *strand, q); @@ -839,7 +839,7 @@ flow( // running debug builds of rippled. While this issue still needs to // be resolved, the assert is causing more harm than good at this // point. - // assert(0); + // XRPL_ASSERT(0); return {tefEXCEPTION, std::move(ofrsToRmOnFail)}; } @@ -876,7 +876,7 @@ flow( // Handles both cases 1. and 2. // fixFillOrKill amendment: // Handles 2. 1. is handled above and falls through for tfSell. - assert(remainingIn); + XRPL_ASSERT(remainingIn); if (remainingIn && *remainingIn != beast::zero) return { tecPATH_PARTIAL, diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index ac88152c9dd..57a3845c0ee 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -282,7 +282,7 @@ XRPEndpointStep::fwdImp( boost::container::flat_set& ofrsToRm, XRPAmount const& in) { - assert(cache_); + XRPL_ASSERT(cache_); auto const balance = static_cast(this)->xrpLiquid(sb); auto const result = isLast_ ? in : std::min(balance, in); @@ -310,7 +310,7 @@ XRPEndpointStep::validFwd( return {false, EitherAmount(XRPAmount(beast::zero))}; } - assert(in.native); + XRPL_ASSERT(in.native); auto const& xrpIn = in.xrp; auto const balance = static_cast(this)->xrpLiquid(sb); diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index b30c94153f7..80720343bdf 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -258,7 +258,7 @@ rangeCheckedCast(C c) c < std::numeric_limits::lowest())) { /* This should never happen */ - assert(0); + XRPL_ASSERT(0); JLOG(debugLog().error()) << "rangeCheckedCast domain error:" << " value = " << c << " min = " << std::numeric_limits::lowest() diff --git a/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp b/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp index ac998991a6d..d97b0bf1b0b 100644 --- a/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp +++ b/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp @@ -61,7 +61,7 @@ class PostgresDatabaseImp final : public PostgresDatabase #endif ) { - assert(config.reporting()); + XRPL_ASSERT(config.reporting()); #ifdef RIPPLED_REPORTING if (config.reporting() && !config.reportingReadOnly()) // use pg { @@ -169,7 +169,7 @@ loadLedgerInfos( std::vector infos; #ifdef RIPPLED_REPORTING auto log = app.journal("Ledger"); - assert(app.config().reporting()); + XRPL_ASSERT(app.config().reporting()); std::stringstream sql; sql << "SELECT ledger_hash, prev_hash, account_set_hash, trans_set_hash, " "total_coins, closing_time, prev_closing_time, close_time_res, " @@ -204,7 +204,7 @@ loadLedgerInfos( { JLOG(log.error()) << __func__ << " : Postgres response is null - sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -214,7 +214,7 @@ loadLedgerInfos( "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -234,7 +234,7 @@ loadLedgerInfos( << " : Wrong number of fields in Postgres " "response. Expected 10, but got " << res.nfields() << " . sql = " << sql.str(); - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -267,11 +267,11 @@ loadLedgerInfos( LedgerInfo info; if (!info.parentHash.parseHex(prevHash + 2)) - assert(false); + XRPL_UNREACHABLE(); if (!info.txHash.parseHex(txHash + 2)) - assert(false); + XRPL_UNREACHABLE(); if (!info.accountHash.parseHex(accountHash + 2)) - assert(false); + XRPL_UNREACHABLE(); info.drops = totalCoins; info.closeTime = time_point{duration{closeTime}}; info.parentCloseTime = time_point{duration{parentCloseTime}}; @@ -279,7 +279,7 @@ loadLedgerInfos( info.closeTimeResolution = duration{closeTimeRes}; info.seq = ledgerSeq; if (!info.hash.parseHex(hash + 2)) - assert(false); + XRPL_UNREACHABLE(); info.validated = true; infos.push_back(info); } @@ -308,7 +308,7 @@ loadLedgerHelper( infos = loadLedgerInfos(pgPool, arg, app); }, whichLedger); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (!infos.size()) return {}; return infos[0]; @@ -410,7 +410,7 @@ processAccountTxStoredProcedureResult( nodestoreHashHex.erase(0, 2); uint256 nodestoreHash; if (!nodestoreHash.parseHex(nodestoreHashHex)) - assert(false); + XRPL_UNREACHABLE(); if (nodestoreHash.isNonZero()) { @@ -419,18 +419,18 @@ processAccountTxStoredProcedureResult( } else { - assert(false); + XRPL_UNREACHABLE(); return {ret, {rpcINTERNAL, "nodestoreHash is zero"}}; } } else { - assert(false); + XRPL_UNREACHABLE(); return {ret, {rpcINTERNAL, "missing postgres fields"}}; } } - assert(nodestoreHashes.size() == ledgerSequences.size()); + XRPL_ASSERT(nodestoreHashes.size() == ledgerSequences.size()); ret.transactions = flatFetchTransactions( app, nodestoreHashes, @@ -442,13 +442,13 @@ processAccountTxStoredProcedureResult( if (result.isMember("marker")) { auto& marker = result["marker"]; - assert(marker.isMember("ledger")); - assert(marker.isMember("seq")); + XRPL_ASSERT(marker.isMember("ledger")); + XRPL_ASSERT(marker.isMember("seq")); ret.marker = { marker["ledger"].asUInt(), marker["seq"].asUInt()}; } - assert(result.isMember("ledger_index_min")); - assert(result.isMember("ledger_index_max")); + XRPL_ASSERT(result.isMember("ledger_index_min")); + XRPL_ASSERT(result.isMember("ledger_index_max")); ret.ledgerRange = { result["ledger_index_min"].asUInt(), result["ledger_index_max"].asUInt()}; @@ -599,7 +599,7 @@ PostgresDatabaseImp::writeLedgerAndTransactions( { std::stringstream msg; msg << "bulkWriteToTable : Postgres insert error: " << res.msg(); - assert(false); + XRPL_UNREACHABLE(); Throw(msg.str()); } @@ -612,7 +612,7 @@ PostgresDatabaseImp::writeLedgerAndTransactions( JLOG(j_.error()) << __func__ << "Caught exception writing to Postgres : " << e.what(); - assert(false); + XRPL_UNREACHABLE(); return false; } #else @@ -642,7 +642,7 @@ uint256 PostgresDatabaseImp::getHashByIndex(LedgerIndex ledgerIndex) { auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (infos.size()) return infos[0].hash; return {}; @@ -653,7 +653,7 @@ PostgresDatabaseImp::getHashesByIndex(LedgerIndex ledgerIndex) { LedgerHashPair p; auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - assert(infos.size() <= 1); + XRPL_ASSERT(infos.size() <= 1); if (infos.size()) { p.ledgerHash = infos[0].hash; @@ -694,7 +694,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) { JLOG(log.error()) << __func__ << " : Postgres response is null - query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -704,7 +704,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -724,7 +724,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . query = " << query; - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -736,7 +736,7 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) char const* nodestoreHash = res.c_str(i, 0); uint256 hash; if (!hash.parseHex(nodestoreHash + 2)) - assert(false); + XRPL_UNREACHABLE(); nodestoreHashes.push_back(hash); } @@ -753,7 +753,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) #ifdef RIPPLED_REPORTING if (!app_.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "called getTxHistory but not in reporting mode"); } @@ -771,7 +771,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { JLOG(j_.error()) << __func__ << " : Postgres response is null - sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -781,7 +781,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -790,7 +790,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) if (res.isNull() || res.ntuples() == 0) { JLOG(j_.debug()) << __func__ << " : Empty postgres response"; - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.ntuples() > 0) @@ -801,7 +801,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . sql = " << sql; - assert(false); + XRPL_UNREACHABLE(); return {}; } } @@ -814,7 +814,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { uint256 hash; if (!hash.parseHex(res.c_str(i, 0) + 2)) - assert(false); + XRPL_UNREACHABLE(); nodestoreHashes.push_back(hash); ledgerSequences.push_back(res.asBigInt(i, 1)); } @@ -823,7 +823,7 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) for (size_t i = 0; i < txns.size(); ++i) { auto const& [sttx, meta] = txns[i]; - assert(sttx); + XRPL_ASSERT(sttx); std::string reason; auto txn = std::make_shared(sttx, reason, app_); @@ -904,7 +904,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) JLOG(j_.error()) << __func__ << " : Postgres response is null - account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } else if (res.status() != PGRES_TUPLES_OK) @@ -914,7 +914,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -925,7 +925,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) << " : No data returned from Postgres : account = " << strHex(args.account); - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -943,7 +943,7 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) } #endif // This shouldn't happen. Postgres should return a parseable error - assert(false); + XRPL_UNREACHABLE(); return {{}, {rpcINTERNAL, "Failed to deserialize Postgres result"}}; } @@ -963,7 +963,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) JLOG(app_.journal("Transaction").error()) << __func__ << " : Postgres response is null - tx ID = " << strHex(id); - assert(false); + XRPL_UNREACHABLE(); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -974,7 +974,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - tx ID = " << strHex(id); - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -986,7 +986,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) << __func__ << " : No data returned from Postgres : tx ID = " << strHex(id); // This shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -1004,7 +1004,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) uint256 nodestoreHash; if (!nodestoreHash.parseHex( v["nodestore_hash"].asString().substr(2))) - assert(false); + XRPL_UNREACHABLE(); uint32_t ledgerSeq = v["ledger_seq"].asUInt(); if (nodestoreHash.isNonZero()) return {std::make_pair(nodestoreHash, ledgerSeq)}; @@ -1018,7 +1018,7 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) #endif // Shouldn' happen. Postgres should return the ledger range searched if // the transaction was not found - assert(false); + XRPL_UNREACHABLE(); Throw( "Transaction::Locate - Invalid Postgres response"); return {}; diff --git a/src/xrpld/app/rdb/backend/detail/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/detail/Node.cpp index 67a80b43cf3..5ab7232f6bd 100644 --- a/src/xrpld/app/rdb/backend/detail/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/detail/Node.cpp @@ -58,7 +58,7 @@ to_string(TableType type) case TableType::AccountTransactions: return "AccountTransactions"; default: - assert(false); + XRPL_UNREACHABLE(); return "Unknown"; } } @@ -201,7 +201,7 @@ saveValidatedLedger( if (!ledger->info().accountHash.isNonZero()) { JLOG(j.fatal()) << "AH is zero: " << getJson({*ledger, {}}); - assert(false); + XRPL_UNREACHABLE(); } if (ledger->info().accountHash != ledger->stateMap().getHash().as_uint256()) @@ -210,10 +210,11 @@ saveValidatedLedger( << " != " << ledger->stateMap().getHash(); JLOG(j.fatal()) << "saveAcceptedLedger: seq=" << seq << ", current=" << current; - assert(false); + XRPL_UNREACHABLE(); } - assert(ledger->info().txHash == ledger->txMap().getHash().as_uint256()); + XRPL_ASSERT( + ledger->info().txHash == ledger->txMap().getHash().as_uint256()); // Save the ledger header in the hashed object store { diff --git a/src/xrpld/app/rdb/detail/Vacuum.cpp b/src/xrpld/app/rdb/detail/Vacuum.cpp index 71129c5b5df..1bfd61f9018 100644 --- a/src/xrpld/app/rdb/detail/Vacuum.cpp +++ b/src/xrpld/app/rdb/detail/Vacuum.cpp @@ -28,7 +28,7 @@ doVacuumDB(DatabaseCon::Setup const& setup) boost::filesystem::path dbPath = setup.dataDir / TxDBName; uintmax_t const dbSize = file_size(dbPath); - assert(dbSize != static_cast(-1)); + XRPL_ASSERT(dbSize != static_cast(-1)); if (auto available = space(dbPath.parent_path()).available; available < dbSize) @@ -54,7 +54,7 @@ doVacuumDB(DatabaseCon::Setup const& setup) std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl; session << "VACUUM;"; - assert(setup.globalPragma); + XRPL_ASSERT(setup.globalPragma); for (auto const& p : *setup.globalPragma) session << p; session << "PRAGMA page_size;", soci::into(pageSize); diff --git a/src/xrpld/app/reporting/ETLHelpers.h b/src/xrpld/app/reporting/ETLHelpers.h index b11d2c4aa18..c41ebfd9fed 100644 --- a/src/xrpld/app/reporting/ETLHelpers.h +++ b/src/xrpld/app/reporting/ETLHelpers.h @@ -176,7 +176,7 @@ class ThreadSafeQueue inline std::vector getMarkers(size_t numMarkers) { - assert(numMarkers <= 256); + XRPL_ASSERT(numMarkers <= 256); unsigned char incr = 256 / numMarkers; diff --git a/src/xrpld/app/reporting/ETLSource.cpp b/src/xrpld/app/reporting/ETLSource.cpp index 8a181c62b1d..06fd8813df3 100644 --- a/src/xrpld/app/reporting/ETLSource.cpp +++ b/src/xrpld/app/reporting/ETLSource.cpp @@ -452,7 +452,7 @@ class AsyncCallData << " . prefix = " << strHex(std::string(1, prefix)) << " . nextPrefix_ = " << strHex(std::string(1, nextPrefix_)); - assert(nextPrefix_ > prefix || nextPrefix_ == 0x00); + XRPL_ASSERT(nextPrefix_ > prefix || nextPrefix_ == 0x00); cur_ = std::make_unique(); @@ -487,7 +487,7 @@ class AsyncCallData JLOG(journal_.warn()) << "AsyncCallData is_unlimited is false. Make sure " "secure_gateway is set correctly at the ETL source"; - assert(false); + XRPL_UNREACHABLE(); } std::swap(cur_, next_); @@ -589,7 +589,7 @@ ETLSource::loadInitialLedger( while (numFinished < calls.size() && !etl_.isStopping() && cq.Next(&tag, &ok)) { - assert(tag); + XRPL_ASSERT(tag); auto ptr = static_cast(tag); @@ -642,7 +642,7 @@ ETLSource::fetchLedger(uint32_t ledgerSequence, bool getObjects) "false. Make sure secure_gateway is set " "correctly on the ETL source. source = " << toString(); - assert(false); + XRPL_UNREACHABLE(); } return {status, std::move(response)}; } diff --git a/src/xrpld/app/reporting/ETLSource.h b/src/xrpld/app/reporting/ETLSource.h index 633b72afac1..cc5bc62769a 100644 --- a/src/xrpld/app/reporting/ETLSource.h +++ b/src/xrpld/app/reporting/ETLSource.h @@ -173,7 +173,7 @@ class ETLSource } else { - assert(minAndMax.size() == 2); + XRPL_ASSERT(minAndMax.size() == 2); uint32_t min = std::stoll(minAndMax[0]); uint32_t max = std::stoll(minAndMax[1]); pairs.push_back(std::make_pair(min, max)); @@ -206,7 +206,7 @@ class ETLSource JLOG(journal_.debug()) << __func__ << " : " << "Closing websocket"; - assert(ws_); + XRPL_ASSERT(ws_); close(false); } @@ -378,7 +378,7 @@ class ETLLoadBalancer { for (auto& src : sources_) { - assert(src); + XRPL_ASSERT(src); // We pick the first ETLSource encountered that is connected if (src->isConnected()) { diff --git a/src/xrpld/app/reporting/ReportingETL.cpp b/src/xrpld/app/reporting/ReportingETL.cpp index 2f6411b0808..fc500b20c10 100644 --- a/src/xrpld/app/reporting/ReportingETL.cpp +++ b/src/xrpld/app/reporting/ReportingETL.cpp @@ -59,7 +59,7 @@ ReportingETL::consumeLedgerData( size_t num = 0; while (!stopping_ && (sle = writeQueue.pop())) { - assert(sle); + XRPL_ASSERT(sle); if (!ledger->exists(sle->key())) ledger->rawInsert(sle); @@ -113,7 +113,7 @@ ReportingETL::loadInitialLedger(uint32_t startingSequence) { JLOG(journal_.fatal()) << __func__ << " : " << "Database is not empty"; - assert(false); + XRPL_UNREACHABLE(); return {}; } @@ -189,7 +189,7 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) auto& txHash = ledger->info().txHash; auto& ledgerHash = ledger->info().hash; - assert( + XRPL_ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees())); ledger->setImmutable(false); @@ -230,7 +230,7 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) { JLOG(journal_.fatal()) << __func__ << " : " << "Flushed 0 nodes from state map"; - assert(false); + XRPL_UNREACHABLE(); } if (numTxFlushed == 0) { @@ -495,7 +495,7 @@ ReportingETL::runETLPipeline(uint32_t startSequence) app_.getLedgerMaster().getLedgerBySeq(startSequence - 1)); if (!parent) { - assert(false); + XRPL_UNREACHABLE(); Throw("runETLPipeline: parent ledger is null"); } @@ -564,7 +564,7 @@ ReportingETL::runETLPipeline(uint32_t startSequence) &transformQueue]() { beast::setCurrentThreadName("rippled: ReportingETL transform"); - assert(parent); + XRPL_ASSERT(parent); parent = std::make_shared(*parent, NetClock::time_point{}); while (!writeConflict) { diff --git a/src/xrpld/app/reporting/ReportingETL.h b/src/xrpld/app/reporting/ReportingETL.h index fc15f90b43b..121b34da9a2 100644 --- a/src/xrpld/app/reporting/ReportingETL.h +++ b/src/xrpld/app/reporting/ReportingETL.h @@ -326,9 +326,9 @@ class ReportingETL start() { JLOG(journal_.info()) << "Starting reporting etl"; - assert(app_.config().reporting()); - assert(app_.config().standalone()); - assert(app_.config().reportingReadOnly() == readOnly_); + XRPL_ASSERT(app_.config().reporting()); + XRPL_ASSERT(app_.config().standalone()); + XRPL_ASSERT(app_.config().reportingReadOnly() == readOnly_); stopping_ = false; diff --git a/src/xrpld/app/tx/detail/AMMBid.cpp b/src/xrpld/app/tx/detail/AMMBid.cpp index 9de3762d2e3..17b851a2627 100644 --- a/src/xrpld/app/tx/detail/AMMBid.cpp +++ b/src/xrpld/app/tx/detail/AMMBid.cpp @@ -181,7 +181,7 @@ applyBid( } else { - assert(ammSle->isFieldPresent(sfAuctionSlot)); + XRPL_ASSERT(ammSle->isFieldPresent(sfAuctionSlot)); if (!ammSle->isFieldPresent(sfAuctionSlot)) return {tecINTERNAL, false}; } @@ -304,7 +304,7 @@ applyBid( { // Price the slot was purchased at. STAmount const pricePurchased = auctionSlot[sfPrice]; - assert(timeSlot); + XRPL_ASSERT(timeSlot); auto const fractionUsed = (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS; auto const fractionRemaining = Number(1) - fractionUsed; diff --git a/src/xrpld/app/tx/detail/AMMDeposit.cpp b/src/xrpld/app/tx/detail/AMMDeposit.cpp index 9bbf5b4a60a..e523da3d6a9 100644 --- a/src/xrpld/app/tx/detail/AMMDeposit.cpp +++ b/src/xrpld/app/tx/detail/AMMDeposit.cpp @@ -435,7 +435,7 @@ AMMDeposit::applyGuts(Sandbox& sb) if (result == tesSUCCESS) { - assert(newLPTokenBalance > beast::zero); + XRPL_ASSERT(newLPTokenBalance > beast::zero); ammSle->setFieldAmount(sfLPTokenBalance, newLPTokenBalance); // LP depositing into AMM empty state gets the auction slot // and the voting diff --git a/src/xrpld/app/tx/detail/AMMVote.cpp b/src/xrpld/app/tx/detail/AMMVote.cpp index c4b6c612c63..5d690f27c93 100644 --- a/src/xrpld/app/tx/detail/AMMVote.cpp +++ b/src/xrpld/app/tx/detail/AMMVote.cpp @@ -200,7 +200,7 @@ applyVote( } } - assert( + XRPL_ASSERT( !ctx_.view().rules().enabled(fixInnerObjTemplate) || ammSle->isFieldPresent(sfAuctionSlot)); diff --git a/src/xrpld/app/tx/detail/AMMWithdraw.cpp b/src/xrpld/app/tx/detail/AMMWithdraw.cpp index 51b512aba0a..967fd8d6697 100644 --- a/src/xrpld/app/tx/detail/AMMWithdraw.cpp +++ b/src/xrpld/app/tx/detail/AMMWithdraw.cpp @@ -711,7 +711,7 @@ AMMWithdraw::equalWithdrawLimit( tfee); frac = Number{amount2} / amount2Balance; auto const amountWithdraw = amountBalance * frac; - assert(amountWithdraw <= amount); + XRPL_ASSERT(amountWithdraw <= amount); return withdraw( view, ammAccount, diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index 969af7960eb..6a273b985b5 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -21,10 +21,10 @@ #include #include #include +#include #include #include #include -#include namespace ripple { @@ -146,7 +146,7 @@ ApplyContext::checkInvariantsHelper( TER ApplyContext::checkInvariants(TER const result, XRPAmount const fee) { - assert(isTesSuccess(result) || isTecClaim(result)); + XRPL_ASSERT(isTesSuccess(result) || isTecClaim(result)); return checkInvariantsHelper( result, diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index 909f35fc799..ba1dbef77e4 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -149,7 +149,7 @@ Change::doApply() case ttUNL_MODIFY: return applyUNLModify(); default: - assert(0); + XRPL_ASSERT(0); return tefFAILURE; } } @@ -157,7 +157,7 @@ Change::doApply() void Change::preCompute() { - assert(account_ == beast::zero); + XRPL_ASSERT(account_ == beast::zero); } void diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index 2a5145594a1..e5399303df8 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -210,7 +210,7 @@ CreateOffer::checkAcceptAsset( Issue const& issue) { // Only valid for custom currencies - assert(!isXRP(issue.currency)); + XRPL_ASSERT(!isXRP(issue.currency)); auto const issuerAccount = view.read(keylet::account(issue.account)); @@ -283,7 +283,7 @@ CreateOffer::select_path( OfferStream const& leg2) { // If we don't have any viable path, why are we here?! - assert(have_direct || have_bridge); + XRPL_ASSERT(have_direct || have_bridge); // If there's no bridged path, the direct is the best by default. if (!have_bridge) @@ -327,7 +327,7 @@ CreateOffer::bridged_cross( { auto const& takerAmount = taker.original_offer(); - assert(!isXRP(takerAmount.in) && !isXRP(takerAmount.out)); + XRPL_ASSERT(!isXRP(takerAmount.in) && !isXRP(takerAmount.out)); if (isXRP(takerAmount.in) || isXRP(takerAmount.out)) Throw("Bridging with XRP and an endpoint."); @@ -497,7 +497,7 @@ CreateOffer::bridged_cross( // Postcondition: If we aren't done, then we *must* have consumed at // least one offer fully. - assert(direct_consumed || leg1_consumed || leg2_consumed); + XRPL_ASSERT(direct_consumed || leg1_consumed || leg2_consumed); if (!direct_consumed && !leg1_consumed && !leg2_consumed) Throw( @@ -587,7 +587,7 @@ CreateOffer::direct_cross( // Postcondition: If we aren't done, then we *must* have consumed the // offer on the books fully! - assert(direct_consumed); + XRPL_ASSERT(direct_consumed); if (!direct_consumed) Throw( @@ -849,7 +849,7 @@ CreateOffer::flowCross( // remaining output. This too preserves the offer // Quality. afterCross.out -= result.actualAmountOut; - assert(afterCross.out >= beast::zero); + XRPL_ASSERT(afterCross.out >= beast::zero); if (afterCross.out < beast::zero) afterCross.out.clear(); afterCross.in = mulRound( @@ -1046,7 +1046,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // We expect the implementation of cross to succeed // or give a tec. - assert(result == tesSUCCESS || isTecClaim(result)); + XRPL_ASSERT(result == tesSUCCESS || isTecClaim(result)); if (auto stream = j_.trace()) { @@ -1064,8 +1064,8 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) return {result, true}; } - assert(saTakerGets.issue() == place_offer.in.issue()); - assert(saTakerPays.issue() == place_offer.out.issue()); + XRPL_ASSERT(saTakerGets.issue() == place_offer.in.issue()); + XRPL_ASSERT(saTakerPays.issue() == place_offer.out.issue()); if (takerAmount != place_offer) crossed = true; @@ -1093,7 +1093,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) saTakerGets = place_offer.in; } - assert(saTakerPays > zero && saTakerGets > zero); + XRPL_ASSERT(saTakerPays > zero && saTakerGets > zero); if (result != tesSUCCESS) { diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/xrpld/app/tx/detail/DeleteAccount.cpp index fb2f3fc507f..ac2f674e4a5 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/xrpld/app/tx/detail/DeleteAccount.cpp @@ -211,7 +211,7 @@ DeleteAccount::preclaim(PreclaimContext const& ctx) } auto sleAccount = ctx.view.read(keylet::account(account)); - assert(sleAccount); + XRPL_ASSERT(sleAccount); if (!sleAccount) return terNO_ACCOUNT; @@ -314,10 +314,10 @@ TER DeleteAccount::doApply() { auto src = view().peek(keylet::account(account_)); - assert(src); + XRPL_ASSERT(src); auto dst = view().peek(keylet::account(ctx_.tx[sfDestination])); - assert(dst); + XRPL_ASSERT(dst); if (!src || !dst) return tefBAD_LEDGER; @@ -337,7 +337,7 @@ DeleteAccount::doApply() return {result, SkipEntry::No}; } - assert(!"Undeletable entry should be found in preclaim."); + XRPL_ASSERT(!"Undeletable entry should be found in preclaim."); JLOG(j_.error()) << "DeleteAccount undeletable item not " "found in preclaim."; return {tecHAS_OBLIGATIONS, SkipEntry::No}; @@ -351,7 +351,7 @@ DeleteAccount::doApply() (*src)[sfBalance] = (*src)[sfBalance] - mSourceBalance; ctx_.deliver(mSourceBalance); - assert((*src)[sfBalance] == XRPAmount(0)); + XRPL_ASSERT((*src)[sfBalance] == XRPAmount(0)); // If there's still an owner directory associated with the source account // delete it. diff --git a/src/xrpld/app/tx/detail/NFTokenMint.cpp b/src/xrpld/app/tx/detail/NFTokenMint.cpp index d5c3a8707c2..108aa637026 100644 --- a/src/xrpld/app/tx/detail/NFTokenMint.cpp +++ b/src/xrpld/app/tx/detail/NFTokenMint.cpp @@ -160,7 +160,7 @@ NFTokenMint::createNFTokenID( std::memcpy(ptr, &tokenSeq, sizeof(tokenSeq)); ptr += sizeof(tokenSeq); - assert(std::distance(buf.data(), ptr) == buf.size()); + XRPL_ASSERT(std::distance(buf.data(), ptr) == buf.size()); return uint256::fromVoid(buf.data()); } diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.cpp b/src/xrpld/app/tx/detail/NFTokenUtils.cpp index 342b3805a0e..242d6f91666 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.cpp +++ b/src/xrpld/app/tx/detail/NFTokenUtils.cpp @@ -243,7 +243,7 @@ compareTokens(uint256 const& a, uint256 const& b) TER insertToken(ApplyView& view, AccountID owner, STObject&& nft) { - assert(nft.isFieldPresent(sfNFTokenID)); + XRPL_ASSERT(nft.isFieldPresent(sfNFTokenID)); // First, we need to locate the page the NFT belongs to, creating it // if necessary. This operation may fail if it is impossible to insert @@ -735,7 +735,7 @@ tokenOfferCreatePreclaim( if (nftIssuer != acctID && !(nftFlags & nft::flagTransferable)) { auto const root = view.read(keylet::account(nftIssuer)); - assert(root); + XRPL_ASSERT(root); if (auto minter = (*root)[~sfNFTokenMinter]; minter != acctID) return tefNFTOKEN_IS_NOT_TRANSFERABLE; diff --git a/src/xrpld/app/tx/detail/Offer.h b/src/xrpld/app/tx/detail/Offer.h index a6f707ba561..c5eedd02c8b 100644 --- a/src/xrpld/app/tx/detail/Offer.h +++ b/src/xrpld/app/tx/detail/Offer.h @@ -209,7 +209,7 @@ void TOffer::setFieldAmounts() { #ifdef _MSC_VER - assert(0); + XRPL_ASSERT(0); #else static_assert(sizeof(TOut) == -1, "Must be specialized"); #endif diff --git a/src/xrpld/app/tx/detail/OfferStream.cpp b/src/xrpld/app/tx/detail/OfferStream.cpp index b963195259a..12231798bf6 100644 --- a/src/xrpld/app/tx/detail/OfferStream.cpp +++ b/src/xrpld/app/tx/detail/OfferStream.cpp @@ -51,7 +51,7 @@ TOfferStreamBase::TOfferStreamBase( , tip_(view, book_) , counter_(counter) { - assert(validBook_); + XRPL_ASSERT(validBook_); } // Handle the case where a directory item with no corresponding ledger entry @@ -339,7 +339,7 @@ TOfferStreamBase::step() std::is_same_v)) return shouldRmSmallIncreasedQOffer(); } - assert(0); // xrp/xrp offer!?! should never happen + XRPL_ASSERT(0); // xrp/xrp offer!?! should never happen return false; }(); diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/xrpld/app/tx/detail/PayChan.cpp index d17736c4738..4256281ff12 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/xrpld/app/tx/detail/PayChan.cpp @@ -149,7 +149,7 @@ closeChannel( if (!sle) return tefINTERNAL; - assert((*slep)[sfAmount] >= (*slep)[sfBalance]); + XRPL_ASSERT((*slep)[sfAmount] >= (*slep)[sfBalance]); (*sle)[sfBalance] = (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance]; adjustOwnerCount(view, sle, -1, j); @@ -532,7 +532,7 @@ PayChanClaim::doApply() (*slep)[sfBalance] = ctx_.tx[sfBalance]; XRPAmount const reqDelta = reqBalance - chanBalance; - assert(reqDelta >= beast::zero); + XRPL_ASSERT(reqDelta >= beast::zero); (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta; ctx_.view().update(sled); ctx_.view().update(slep); diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 309e9d4a498..2cc37b70f4d 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -421,7 +421,7 @@ Payment::doApply() return terResult; } - assert(saDstAmount.native()); + XRPL_ASSERT(saDstAmount.native()); // Direct XRP payment. diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/xrpld/app/tx/detail/SetSignerList.cpp index 0949fbbe775..b11c962b717 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/xrpld/app/tx/detail/SetSignerList.cpp @@ -128,7 +128,7 @@ SetSignerList::doApply() default: break; } - assert(false); // Should not be possible to get here. + XRPL_UNREACHABLE(); // Should not be possible to get here. return temMALFORMED; } @@ -137,8 +137,8 @@ SetSignerList::preCompute() { // Get the quorum and operation info. auto result = determineOperation(ctx_.tx, view().flags(), j_); - assert(std::get<0>(result) == tesSUCCESS); - assert(std::get<3>(result) != unknown); + XRPL_ASSERT(std::get<0>(result) == tesSUCCESS); + XRPL_ASSERT(std::get<3>(result) != unknown); quorum_ = std::get<1>(result); signers_ = std::get<2>(result); @@ -171,8 +171,8 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) // The static_cast should always be safe since entryCount should always // be in the range from 1 to 8 (or 32 if ExpandedSignerList is enabled). // We've got a lot of room to grow. - assert(entryCount >= STTx::minMultiSigners); - assert(entryCount <= STTx::maxMultiSigners(&rules)); + XRPL_ASSERT(entryCount >= STTx::minMultiSigners); + XRPL_ASSERT(entryCount <= STTx::maxMultiSigners(&rules)); return 2 + static_cast(entryCount); } @@ -260,7 +260,7 @@ SetSignerList::validateQuorumAndSignerEntries( } // Make sure there are no duplicate signers. - assert(std::is_sorted(signers.begin(), signers.end())); + XRPL_ASSERT(std::is_sorted(signers.begin(), signers.end())); if (std::adjacent_find(signers.begin(), signers.end()) != signers.end()) { JLOG(j.trace()) << "Duplicate signers in signer list"; diff --git a/src/xrpld/app/tx/detail/Taker.cpp b/src/xrpld/app/tx/detail/Taker.cpp index 9d335de2846..0a9498e7c5a 100644 --- a/src/xrpld/app/tx/detail/Taker.cpp +++ b/src/xrpld/app/tx/detail/Taker.cpp @@ -54,24 +54,24 @@ BasicTaker::BasicTaker( , cross_type_(cross_type) , journal_(journal) { - assert(remaining_.in > beast::zero); - assert(remaining_.out > beast::zero); + XRPL_ASSERT(remaining_.in > beast::zero); + XRPL_ASSERT(remaining_.out > beast::zero); - assert(m_rate_in.value != 0); - assert(m_rate_out.value != 0); + XRPL_ASSERT(m_rate_in.value != 0); + XRPL_ASSERT(m_rate_out.value != 0); // If we are dealing with a particular flavor, make sure that it's the // flavor we expect: - assert( + XRPL_ASSERT( cross_type != CrossType::XrpToIou || (isXRP(issue_in()) && !isXRP(issue_out()))); - assert( + XRPL_ASSERT( cross_type != CrossType::IouToXrp || (!isXRP(issue_in()) && isXRP(issue_out()))); // And make sure we're not crossing XRP for XRP - assert(!isXRP(issue_in()) || !isXRP(issue_out())); + XRPL_ASSERT(!isXRP(issue_in()) || !isXRP(issue_out())); // If this is a passive order, we adjust the quality so as to prevent offers // at the same quality level from being consumed. @@ -150,7 +150,7 @@ BasicTaker::remaining_offer() const if (sell_) { - assert(remaining_.in > beast::zero); + XRPL_ASSERT(remaining_.in > beast::zero); // We scale the output based on the remaining input: return Amounts( @@ -158,7 +158,7 @@ BasicTaker::remaining_offer() const divRound(remaining_.in, quality_.rate(), issue_out_, true)); } - assert(remaining_.out > beast::zero); + XRPL_ASSERT(remaining_.out > beast::zero); // We scale the input based on the remaining output: return Amounts( @@ -424,7 +424,7 @@ BasicTaker::do_cross(Amounts offer, Quality quality, AccountID const& owner) remaining_.out -= result.order.out; remaining_.in -= result.order.in; - assert(remaining_.in >= beast::zero); + XRPL_ASSERT(remaining_.in >= beast::zero); return result; } @@ -439,10 +439,10 @@ BasicTaker::do_cross( Quality quality2, AccountID const& owner2) { - assert(!offer1.in.native()); - assert(offer1.out.native()); - assert(offer2.in.native()); - assert(!offer2.out.native()); + XRPL_ASSERT(!offer1.in.native()); + XRPL_ASSERT(offer1.out.native()); + XRPL_ASSERT(offer2.in.native()); + XRPL_ASSERT(!offer2.out.native()); // If the taker owns the first leg of the offer, then the taker's available // funds aren't the limiting factor for the input - the offer itself is. @@ -559,8 +559,8 @@ Taker::Taker( , direct_crossings_(0) , bridge_crossings_(0) { - assert(issue_in() == offer.in.issue()); - assert(issue_out() == offer.out.issue()); + XRPL_ASSERT(issue_in() == offer.in.issue()); + XRPL_ASSERT(issue_out() == offer.out.issue()); if (auto stream = journal_.debug()) { @@ -689,7 +689,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) if (cross_type() != CrossType::XrpToIou) { - assert(!isXRP(flow.order.in)); + XRPL_ASSERT(!isXRP(flow.order.in)); if (result == tesSUCCESS) result = @@ -701,7 +701,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - assert(isXRP(flow.order.in)); + XRPL_ASSERT(isXRP(flow.order.in)); if (result == tesSUCCESS) result = transferXRP(account(), offer.owner(), flow.order.in); @@ -710,7 +710,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) // Now send funds from the account whose offer we're taking if (cross_type() != CrossType::IouToXrp) { - assert(!isXRP(flow.order.out)); + XRPL_ASSERT(!isXRP(flow.order.out)); if (result == tesSUCCESS) result = redeemIOU( @@ -722,7 +722,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - assert(isXRP(flow.order.out)); + XRPL_ASSERT(isXRP(flow.order.out)); if (result == tesSUCCESS) result = transferXRP(offer.owner(), account(), flow.order.out); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 42e9f0677ab..596cae1a5ac 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -367,7 +367,7 @@ Transactor::checkPriorTxAndLastLedger(PreclaimContext const& ctx) TER Transactor::consumeSeqProxy(SLE::pointer const& sleAccount) { - assert(sleAccount); + XRPL_ASSERT(sleAccount); SeqProxy const seqProx = ctx_.tx.getSeqProxy(); if (seqProx.isSeq()) { @@ -439,7 +439,7 @@ Transactor::ticketDelete( void Transactor::preCompute() { - assert(account_ != beast::zero); + XRPL_ASSERT(account_ != beast::zero); } TER @@ -453,7 +453,7 @@ Transactor::apply() // sle must exist except for transactions // that allow zero account. - assert(sle != nullptr || account_ == beast::zero); + XRPL_ASSERT(sle != nullptr || account_ == beast::zero); if (sle) { @@ -578,8 +578,8 @@ Transactor::checkMultiSign(PreclaimContext const& ctx) // We have plans to support multiple SignerLists in the future. The // presence and defaulted value of the SignerListID field will enable that. - assert(sleAccountSigners->isFieldPresent(sfSignerListID)); - assert(sleAccountSigners->getFieldU32(sfSignerListID) == 0); + XRPL_ASSERT(sleAccountSigners->isFieldPresent(sfSignerListID)); + XRPL_ASSERT(sleAccountSigners->getFieldU32(sfSignerListID) == 0); auto accountSigners = SignerEntries::deserialize(*sleAccountSigners, ctx.j, "ledger"); @@ -802,7 +802,7 @@ Transactor::reset(XRPAmount fee) auto const balance = txnAcct->getFieldAmount(sfBalance).xrp(); // balance should have already been checked in checkFee / preFlight. - assert(balance != beast::zero && (!view().open() || balance >= fee)); + XRPL_ASSERT(balance != beast::zero && (!view().open() || balance >= fee)); // We retry/reject the transaction if the account balance is zero or we're // applying against an open ledger and the balance is less than the fee @@ -817,7 +817,7 @@ Transactor::reset(XRPAmount fee) // reject the transaction. txnAcct->setFieldAmount(sfBalance, balance - fee); TER const ter{consumeSeqProxy(txnAcct)}; - assert(isTesSuccess(ter)); + XRPL_ASSERT(isTesSuccess(ter)); if (isTesSuccess(ter)) view().update(txnAcct); @@ -849,7 +849,7 @@ Transactor::operator()() JLOG(j_.fatal()) << "Transaction serdes mismatch"; JLOG(j_.info()) << to_string(ctx_.tx.getJson(JsonOptions::none)); JLOG(j_.fatal()) << s2.getJson(JsonOptions::none); - assert(false); + XRPL_UNREACHABLE(); } } #endif @@ -866,7 +866,7 @@ Transactor::operator()() // No transaction can return temUNKNOWN from apply, // and it can't be passed in from a preclaim. - assert(result != temUNKNOWN); + XRPL_ASSERT(result != temUNKNOWN); if (auto stream = j_.trace()) stream << "preclaim result: " << transToken(result); @@ -918,7 +918,7 @@ Transactor::operator()() std::shared_ptr const& after) { if (isDelete) { - assert(before && after); + XRPL_ASSERT(before && after); if (doOffers && before && after && (before->getType() == ltOFFER) && (before->getFieldAmount(sfTakerPays) == diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/xrpld/app/tx/detail/XChainBridge.cpp index f5633903567..80afa2d4bfb 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/xrpld/app/tx/detail/XChainBridge.cpp @@ -222,7 +222,7 @@ claimHelper( auto i = signersList.find(a.keyAccount); if (i == signersList.end()) { - assert(0); // should have already been checked + XRPL_ASSERT(0); // should have already been checked continue; } weight += i->second; @@ -437,7 +437,7 @@ transferHelper( if (amt.native()) { auto const sleSrc = psb.peek(keylet::account(src)); - assert(sleSrc); + XRPL_ASSERT(sleSrc); if (!sleSrc) return tecINTERNAL; diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 9ddaa3051c4..96f78e2e848 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -228,7 +228,7 @@ invoke_preflight(PreflightContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preflight: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return {temUNKNOWN, TxConsequences{temUNKNOWN}}; } } @@ -277,7 +277,7 @@ invoke_preclaim(PreclaimContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preclaim: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return temUNKNOWN; } } @@ -293,7 +293,7 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx) } catch (UnknownTxnType const& e) { - assert(false); + XRPL_UNREACHABLE(); return XRPAmount{0}; } } @@ -305,7 +305,7 @@ TxConsequences::TxConsequences(NotTEC pfresult) , seqProx_(SeqProxy::sequence(0)) , sequencesConsumed_(0) { - assert(!isTesSuccess(pfresult)); + XRPL_ASSERT(!isTesSuccess(pfresult)); } TxConsequences::TxConsequences(STTx const& tx) @@ -352,7 +352,7 @@ invoke_apply(ApplyContext& ctx) // Should never happen JLOG(ctx.journal.fatal()) << "Unknown transaction type in apply: " << e.txnType; - assert(false); + XRPL_UNREACHABLE(); return {temUNKNOWN, false}; } } diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index fd3560b1744..1af7631b518 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -863,7 +863,7 @@ Consensus::gotTxSet( { // Our position is added to acquired_ as soon as we create it, // so this txSet must differ - assert(id != result_->position.position()); + XRPL_ASSERT(id != result_->position.position()); bool any = false; for (auto const& [nodeId, peerPos] : currPeerPositions_) { @@ -1008,7 +1008,7 @@ template void Consensus::handleWrongLedger(typename Ledger_t::ID const& lgrId) { - assert(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); + XRPL_ASSERT(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); // Stop proposing because we are out of sync leaveConsensus(); @@ -1261,7 +1261,7 @@ void Consensus::phaseEstablish() { // can only establish consensus if we already took a stance - assert(result_); + XRPL_ASSERT(result_); using namespace std::chrono; ConsensusParms const& parms = adaptor_.parms(); @@ -1309,7 +1309,7 @@ void Consensus::closeLedger() { // We should not be closing if we already have a position - assert(!result_); + XRPL_ASSERT(!result_); phase_ = ConsensusPhase::establish; JLOG(j_.debug()) << "transitioned to ConsensusPhase::establish"; @@ -1362,7 +1362,7 @@ void Consensus::updateOurPositions() { // We must have a position if we are updating it - assert(result_); + XRPL_ASSERT(result_); ConsensusParms const& parms = adaptor_.parms(); // Compute a cutoff time @@ -1546,7 +1546,7 @@ bool Consensus::haveConsensus() { // Must have a stance if we are checking for consensus - assert(result_); + XRPL_ASSERT(result_); // CHECKME: should possibly count unacquired TX sets as disagreeing int agree = 0, disagree = 0; @@ -1621,7 +1621,7 @@ void Consensus::createDisputes(TxSet_t const& o) { // Cannot create disputes without our stance - assert(result_); + XRPL_ASSERT(result_); // Only create disputes if this is a new set if (!result_->compares.emplace(o.id()).second) @@ -1642,7 +1642,7 @@ Consensus::createDisputes(TxSet_t const& o) { ++dc; // create disputed transactions (from the ledger that has them) - assert( + XRPL_ASSERT( (inThisSet && result_->txns.find(txId) && !o.find(txId)) || (!inThisSet && !result_->txns.find(txId) && o.find(txId))); @@ -1680,7 +1680,7 @@ void Consensus::updateDisputes(NodeID_t const& node, TxSet_t const& other) { // Cannot updateDisputes without our stance - assert(result_); + XRPL_ASSERT(result_); // Ensure we have created disputes against this set if we haven't seen // it before diff --git a/src/xrpld/consensus/ConsensusTypes.h b/src/xrpld/consensus/ConsensusTypes.h index da03fc4875a..65bb9a01882 100644 --- a/src/xrpld/consensus/ConsensusTypes.h +++ b/src/xrpld/consensus/ConsensusTypes.h @@ -214,7 +214,7 @@ struct ConsensusResult ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)} { - assert(txns.id() == position.position()); + XRPL_ASSERT(txns.id() == position.position()); } //! The set of transactions consensus agrees go in the ledger diff --git a/src/xrpld/consensus/LedgerTiming.h b/src/xrpld/consensus/LedgerTiming.h index 1bb5bfd730f..2ce08a89d43 100644 --- a/src/xrpld/consensus/LedgerTiming.h +++ b/src/xrpld/consensus/LedgerTiming.h @@ -82,7 +82,7 @@ getNextLedgerTimeResolution( bool previousAgree, Seq ledgerSeq) { - assert(ledgerSeq != Seq{0}); + XRPL_ASSERT(ledgerSeq != Seq{0}); using namespace std::chrono; // Find the current resolution: @@ -90,7 +90,7 @@ getNextLedgerTimeResolution( std::begin(ledgerPossibleTimeResolutions), std::end(ledgerPossibleTimeResolutions), previousResolution); - assert(iter != std::end(ledgerPossibleTimeResolutions)); + XRPL_ASSERT(iter != std::end(ledgerPossibleTimeResolutions)); // This should never happen, but just as a precaution if (iter == std::end(ledgerPossibleTimeResolutions)) diff --git a/src/xrpld/consensus/LedgerTrie.h b/src/xrpld/consensus/LedgerTrie.h index 32bae28cc07..a051b65c155 100644 --- a/src/xrpld/consensus/LedgerTrie.h +++ b/src/xrpld/consensus/LedgerTrie.h @@ -21,7 +21,9 @@ #define RIPPLE_APP_CONSENSUS_LEDGERS_TRIE_H_INCLUDED #include +#include #include + #include #include #include @@ -62,7 +64,7 @@ class SpanTip ID ancestor(Seq const& s) const { - assert(s <= seq); + XRPL_ASSERT(s <= seq); return ledger[s]; } @@ -88,7 +90,7 @@ class Span Span() : ledger_{typename Ledger::MakeGenesis{}} { // Require default ledger to be genesis seq - assert(ledger_.seq() == start_); + XRPL_ASSERT(ledger_.seq() == start_); } Span(Ledger ledger) @@ -157,7 +159,7 @@ class Span : start_{start}, end_{end}, ledger_{l} { // Spans cannot be empty - assert(start < end); + XRPL_ASSERT(start < end); } Seq @@ -230,7 +232,7 @@ struct Node [child](std::unique_ptr const& curr) { return curr.get() == child; }); - assert(it != children.end()); + XRPL_ASSERT(it != children.end()); std::swap(*it, children.back()); children.pop_back(); } @@ -338,7 +340,7 @@ struct Node // For all Seq s: if(a[s] == b[s]); for(Seq p = 0; p < s; ++p) - assert(a[p] == b[p]); + XRPL_ASSERT(a[p] == b[p]); @endcode @tparam Ledger A type representing a ledger and its history @@ -371,7 +373,7 @@ class LedgerTrie Node* curr = root.get(); // Root is always defined and is in common with all ledgers - assert(curr); + XRPL_ASSERT(curr); Seq pos = curr->span.diff(ledger); bool done = false; @@ -452,7 +454,7 @@ class LedgerTrie auto const [loc, diffSeq] = find(ledger); // There is always a place to insert - assert(loc); + XRPL_ASSERT(loc); // Node from which to start incrementing branchSupport Node* incNode = loc; @@ -487,12 +489,12 @@ class LedgerTrie newNode->tipSupport = loc->tipSupport; newNode->branchSupport = loc->branchSupport; newNode->children = std::move(loc->children); - assert(loc->children.empty()); + XRPL_ASSERT(loc->children.empty()); for (std::unique_ptr& child : newNode->children) child->parent = newNode.get(); // Loc truncates to prefix and newNode is its child - assert(prefix); + XRPL_ASSERT(prefix); loc->span = *prefix; newNode->parent = loc; loc->children.emplace_back(std::move(newNode)); @@ -545,7 +547,7 @@ class LedgerTrie loc->tipSupport -= count; auto const it = seqSupport.find(ledger.seq()); - assert(it != seqSupport.end() && it->second >= count); + XRPL_ASSERT(it != seqSupport.end() && it->second >= count); it->second -= count; if (it->second == 0) seqSupport.erase(it->first); diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index ed07858d321..1d3e95bd1a6 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -434,7 +434,7 @@ class Validations Validation const& val, std::optional> prior) { - assert(val.trusted()); + XRPL_ASSERT(val.trusted()); // Clear any prior acquiring ledger for this node if (prior) @@ -714,7 +714,7 @@ class Validations setSeqToKeep(Seq const& low, Seq const& high) { std::lock_guard lock{mutex_}; - assert(low < high); + XRPL_ASSERT(low < high); toKeep_ = {low, high}; } diff --git a/src/xrpld/core/Coro.ipp b/src/xrpld/core/Coro.ipp index a936dd896ae..c29027479dd 100644 --- a/src/xrpld/core/Coro.ipp +++ b/src/xrpld/core/Coro.ipp @@ -53,7 +53,7 @@ JobQueue::Coro::Coro( inline JobQueue::Coro::~Coro() { #ifndef NDEBUG - assert(finished_); + XRPL_ASSERT(finished_); #endif } @@ -103,7 +103,7 @@ JobQueue::Coro::resume() auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); std::lock_guard lock(mutex_); - assert(coro_); + XRPL_ASSERT(coro_); coro_(); detail::getLocalValues().release(); detail::getLocalValues().reset(saved); diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index d2f6b0a4f05..f0f07c6626d 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -96,7 +96,7 @@ class DatabaseCon std::vector const* commonPragma() const { - assert(!useGlobalPragma || globalPragma); + XRPL_ASSERT(!useGlobalPragma || globalPragma); return useGlobalPragma && globalPragma ? globalPragma.get() : nullptr; } diff --git a/src/xrpld/core/JobTypes.h b/src/xrpld/core/JobTypes.h index 2dbc45ca1b5..0911cbddbee 100644 --- a/src/xrpld/core/JobTypes.h +++ b/src/xrpld/core/JobTypes.h @@ -53,7 +53,7 @@ class JobTypes int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) { - assert(m_map.find(jt) == m_map.end()); + XRPL_ASSERT(m_map.find(jt) == m_map.end()); auto const [_, inserted] = m_map.emplace( std::piecewise_construct, @@ -61,7 +61,7 @@ class JobTypes std::forward_as_tuple( jt, name, limit, avgLatency, peakLatency)); - assert(inserted == true); + XRPL_ASSERT(inserted == true); (void)_; (void)inserted; }; @@ -138,7 +138,7 @@ class JobTypes get(JobType jt) const { Map::const_iterator const iter(m_map.find(jt)); - assert(iter != m_map.end()); + XRPL_ASSERT(iter != m_map.end()); if (iter != m_map.end()) return iter->second; diff --git a/src/xrpld/core/Pg.cpp b/src/xrpld/core/Pg.cpp index 829e17658c1..5b54d6fa262 100644 --- a/src/xrpld/core/Pg.cpp +++ b/src/xrpld/core/Pg.cpp @@ -31,11 +31,11 @@ #include #include +#include #include #include #include #include -#include #include #include #include @@ -242,7 +242,7 @@ void Pg::bulkInsert(char const* table, std::string const& records) { // https://www.postgresql.org/docs/12/libpq-copy.html#LIBPQ-COPY-SEND - assert(conn_.get()); + XRPL_ASSERT(conn_.get()); static auto copyCmd = boost::format(R"(COPY %s FROM stdin)"); auto res = query(boost::str(copyCmd % table).c_str()); if (!res || res.status() != PGRES_COPY_IN) @@ -1326,7 +1326,7 @@ applySchema( { if (currentVersion != 0 && schemaVersion != currentVersion + 1) { - assert(false); + XRPL_UNREACHABLE(); std::stringstream ss; ss << "Schema upgrade versions past initial deployment must increase " "monotonically. Versions: current, target: " diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index 07d269883e2..3be2ef3d5a7 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -266,7 +266,7 @@ Config::Config() void Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) { - assert(NODE_SIZE == 0); + XRPL_ASSERT(NODE_SIZE == 0); QUIET = bQuiet || bSilent; SILENT = bSilent; @@ -287,7 +287,7 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) return (limit == 0) || (ramSize_ < limit); }); - assert(ns != threshold.second.end()); + XRPL_ASSERT(ns != threshold.second.end()); if (ns != threshold.second.end()) NODE_SIZE = std::distance(threshold.second.begin(), ns); @@ -298,7 +298,7 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) NODE_SIZE = std::min(hc / 2, NODE_SIZE); } - assert(NODE_SIZE <= 4); + XRPL_ASSERT(NODE_SIZE <= 4); } void @@ -1009,8 +1009,8 @@ int Config::getValueFor(SizedItem item, std::optional node) const { auto const index = static_cast>(item); - assert(index < sizedItems.size()); - assert(!node || *node <= 4); + XRPL_ASSERT(index < sizedItems.size()); + XRPL_ASSERT(!node || *node <= 4); return sizedItems.at(index).second.at(node.value_or(NODE_SIZE)); } diff --git a/src/xrpld/core/detail/DatabaseCon.cpp b/src/xrpld/core/detail/DatabaseCon.cpp index c23c7491b04..ac4b6c5b7c1 100644 --- a/src/xrpld/core/detail/DatabaseCon.cpp +++ b/src/xrpld/core/detail/DatabaseCon.cpp @@ -232,7 +232,7 @@ setup_DatabaseCon(Config const& c, std::optional j) "nodes storing large amounts of history, because of the " "difficulty inherent in rebuilding corrupted data."; } - assert(result->size() == 3); + XRPL_ASSERT(result->size() == 3); return result; }(); } diff --git a/src/xrpld/core/detail/Job.cpp b/src/xrpld/core/detail/Job.cpp index 0782fd05a66..67c4d631c22 100644 --- a/src/xrpld/core/detail/Job.cpp +++ b/src/xrpld/core/detail/Job.cpp @@ -18,8 +18,8 @@ //============================================================================== #include +#include #include -#include namespace ripple { diff --git a/src/xrpld/core/detail/JobQueue.cpp b/src/xrpld/core/detail/JobQueue.cpp index 1c859d724f4..3d3a2cd0641 100644 --- a/src/xrpld/core/detail/JobQueue.cpp +++ b/src/xrpld/core/detail/JobQueue.cpp @@ -55,7 +55,7 @@ JobQueue::JobQueue( std::piecewise_construct, std::forward_as_tuple(jt.type()), std::forward_as_tuple(jt, m_collector, logs))); - assert(result.second == true); + XRPL_ASSERT(result.second == true); (void)result.second; } } @@ -80,10 +80,10 @@ JobQueue::addRefCountedJob( std::string const& name, JobFunction const& func) { - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); auto iter(m_jobData.find(type)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); if (iter == m_jobData.end()) return false; @@ -93,7 +93,7 @@ JobQueue::addRefCountedJob( // FIXME: Workaround incorrect client shutdown ordering // do not add jobs to a queue with no threads - assert( + XRPL_ASSERT( (type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) || m_workers.getNumberOfThreads() > 0); @@ -104,8 +104,8 @@ JobQueue::addRefCountedJob( auto const& job = *result.first; JobType const type(job.getType()); - assert(type != jtINVALID); - assert(m_jobSet.find(job) != m_jobSet.end()); + XRPL_ASSERT(type != jtINVALID); + XRPL_ASSERT(m_jobSet.find(job) != m_jobSet.end()); perfLog_.jobQueue(type); JobTypeData& data(getJobTypeData(type)); @@ -165,7 +165,7 @@ std::unique_ptr JobQueue::makeLoadEvent(JobType t, std::string const& name) { JobDataMap::iterator iter(m_jobData.find(t)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); if (iter == m_jobData.end()) return {}; @@ -180,7 +180,7 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed) LogicError("JobQueue::addLoadEvents() called after JobQueue stopped"); JobDataMap::iterator iter(m_jobData.find(t)); - assert(iter != m_jobData.end()); + XRPL_ASSERT(iter != m_jobData.end()); iter->second.load().addSamples(count, elapsed); } @@ -206,7 +206,7 @@ JobQueue::getJson(int c) for (auto& x : m_jobData) { - assert(x.first != jtINVALID); + XRPL_ASSERT(x.first != jtINVALID); if (x.first == jtGENERIC) continue; @@ -261,7 +261,7 @@ JobTypeData& JobQueue::getJobTypeData(JobType type) { JobDataMap::iterator c(m_jobData.find(type)); - assert(c != m_jobData.end()); + XRPL_ASSERT(c != m_jobData.end()); // NIKB: This is ugly and I hate it. We must remove jtINVALID completely // and use something sane. @@ -286,9 +286,9 @@ JobQueue::stop() std::unique_lock lock(m_mutex); cv_.wait( lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); - assert(m_processCount == 0); - assert(m_jobSet.empty()); - assert(nSuspend_ == 0); + XRPL_ASSERT(m_processCount == 0); + XRPL_ASSERT(m_jobSet.empty()); + XRPL_ASSERT(nSuspend_ == 0); stopped_ = true; } } @@ -302,28 +302,28 @@ JobQueue::isStopped() const void JobQueue::getNextJob(Job& job) { - assert(!m_jobSet.empty()); + XRPL_ASSERT(!m_jobSet.empty()); std::set::const_iterator iter; for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter) { JobType const type = iter->getType(); - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); JobTypeData& data(getJobTypeData(type)); - assert(data.running <= getJobLimit(type)); + XRPL_ASSERT(data.running <= getJobLimit(type)); // Run this job if we're running below the limit. if (data.running < getJobLimit(data.type())) { - assert(data.waiting > 0); + XRPL_ASSERT(data.waiting > 0); --data.waiting; ++data.running; break; } } - assert(iter != m_jobSet.end()); + XRPL_ASSERT(iter != m_jobSet.end()); job = *iter; m_jobSet.erase(iter); } @@ -331,14 +331,14 @@ JobQueue::getNextJob(Job& job) void JobQueue::finishJob(JobType type) { - assert(type != jtINVALID); + XRPL_ASSERT(type != jtINVALID); JobTypeData& data = getJobTypeData(type); // Queue a deferred task if possible if (data.deferred > 0) { - assert(data.running + data.waiting >= getJobLimit(type)); + XRPL_ASSERT(data.running + data.waiting >= getJobLimit(type)); --data.deferred; m_workers.addTask(); @@ -404,7 +404,7 @@ int JobQueue::getJobLimit(JobType type) { JobTypeInfo const& j(JobTypes::instance().get(type)); - assert(j.type() != jtINVALID); + XRPL_ASSERT(j.type() != jtINVALID); return j.limit(); } diff --git a/src/xrpld/core/detail/LoadEvent.cpp b/src/xrpld/core/detail/LoadEvent.cpp index ca78fdb19cc..9d076440a2c 100644 --- a/src/xrpld/core/detail/LoadEvent.cpp +++ b/src/xrpld/core/detail/LoadEvent.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { @@ -83,7 +83,7 @@ LoadEvent::start() void LoadEvent::stop() { - assert(running_); + XRPL_ASSERT(running_); auto const now = std::chrono::steady_clock::now(); diff --git a/src/xrpld/core/detail/Workers.cpp b/src/xrpld/core/detail/Workers.cpp index ff861010d95..fdba0729d5a 100644 --- a/src/xrpld/core/detail/Workers.cpp +++ b/src/xrpld/core/detail/Workers.cpp @@ -19,8 +19,8 @@ #include #include +#include #include -#include namespace ripple { @@ -119,7 +119,7 @@ Workers::stop() m_cv.wait(lk, [this] { return m_allPaused; }); lk.unlock(); - assert(numberOfCurrentlyRunningTasks() == 0); + XRPL_ASSERT(numberOfCurrentlyRunningTasks() == 0); } void diff --git a/src/xrpld/ledger/ApplyView.h b/src/xrpld/ledger/ApplyView.h index f0166cd0b38..db416b4b530 100644 --- a/src/xrpld/ledger/ApplyView.h +++ b/src/xrpld/ledger/ApplyView.h @@ -276,7 +276,7 @@ class ApplyView : public ReadView { if (key.type != ltOFFER) { - assert(!"Only Offers are appended to book directories. " + XRPL_ASSERT(!"Only Offers are appended to book directories. " "Call dirInsert() instead."); return std::nullopt; } diff --git a/src/xrpld/ledger/ReadView.h b/src/xrpld/ledger/ReadView.h index 50f1a7d98c1..9c6492812e0 100644 --- a/src/xrpld/ledger/ReadView.h +++ b/src/xrpld/ledger/ReadView.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/src/xrpld/ledger/detail/ApplyStateTable.cpp b/src/xrpld/ledger/detail/ApplyStateTable.cpp index b849365c83f..3bb174fe397 100644 --- a/src/xrpld/ledger/detail/ApplyStateTable.cpp +++ b/src/xrpld/ledger/detail/ApplyStateTable.cpp @@ -19,10 +19,10 @@ #include #include +#include #include #include #include -#include namespace ripple { namespace detail { @@ -155,7 +155,7 @@ ApplyStateTable::apply( meta.setAffectedNode(item.first, *type, nodeType); if (type == &sfDeletedNode) { - assert(origNode && curNode); + XRPL_ASSERT(origNode && curNode); threadOwners(to, meta, origNode, newMod, j); STObject prevs(sfPreviousFields); @@ -187,7 +187,7 @@ ApplyStateTable::apply( } else if (type == &sfModifiedNode) { - assert(curNode && origNode); + XRPL_ASSERT(curNode && origNode); if (curNode->isThreadedType( to.rules())) // thread transaction to node @@ -222,7 +222,7 @@ ApplyStateTable::apply( } else if (type == &sfCreatedNode) // if created, thread to owner(s) { - assert(curNode && !origNode); + XRPL_ASSERT(curNode && !origNode); threadOwners(to, meta, curNode, newMod, j); if (curNode->isThreadedType( @@ -245,7 +245,7 @@ ApplyStateTable::apply( } else { - assert(false); + XRPL_UNREACHABLE(); } } @@ -536,13 +536,13 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr const& sle) if (node.getFieldIndex(sfPreviousTxnID) == -1) { - assert(node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); + XRPL_ASSERT(node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); node.setFieldH256(sfPreviousTxnID, prevTxID); node.setFieldU32(sfPreviousTxnLgrSeq, prevLgrID); } - assert(node.getFieldH256(sfPreviousTxnID) == prevTxID); - assert(node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); + XRPL_ASSERT(node.getFieldH256(sfPreviousTxnID) == prevTxID); + XRPL_ASSERT(node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); } } @@ -557,7 +557,7 @@ ApplyStateTable::getForMod( auto miter = mods.find(key); if (miter != mods.end()) { - assert(miter->second); + XRPL_ASSERT(miter->second); return miter->second; } } @@ -613,7 +613,7 @@ ApplyStateTable::threadTx( return; } // threadItem only applied to AccountRoot - assert(sle->isThreadedType(base.rules())); + XRPL_ASSERT(sle->isThreadedType(base.rules())); threadItem(meta, sle); } diff --git a/src/xrpld/ledger/detail/ApplyView.cpp b/src/xrpld/ledger/detail/ApplyView.cpp index 735aa9906e0..2873cde37ce 100644 --- a/src/xrpld/ledger/detail/ApplyView.cpp +++ b/src/xrpld/ledger/detail/ApplyView.cpp @@ -19,8 +19,8 @@ #include #include +#include #include -#include namespace ripple { @@ -133,7 +133,7 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (directory.type != ltDIR_NODE || node->getFieldH256(sfRootIndex) != directory.key) { - assert(!"emptyDirDelete() called with wrong node type"); + XRPL_ASSERT(!"emptyDirDelete() called with wrong node type"); return false; } diff --git a/src/xrpld/ledger/detail/ApplyViewImpl.cpp b/src/xrpld/ledger/detail/ApplyViewImpl.cpp index ffbf681cd20..bb0002459d8 100644 --- a/src/xrpld/ledger/detail/ApplyViewImpl.cpp +++ b/src/xrpld/ledger/detail/ApplyViewImpl.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/xrpld/ledger/detail/BookDirs.cpp b/src/xrpld/ledger/detail/BookDirs.cpp index 58527b02ff2..302b634811a 100644 --- a/src/xrpld/ledger/detail/BookDirs.cpp +++ b/src/xrpld/ledger/detail/BookDirs.cpp @@ -30,12 +30,12 @@ BookDirs::BookDirs(ReadView const& view, Book const& book) , next_quality_(getQualityNext(root_)) , key_(view_->succ(root_, next_quality_).value_or(beast::zero)) { - assert(root_ != beast::zero); + XRPL_ASSERT(root_ != beast::zero); if (key_ != beast::zero) { if (!cdirFirst(*view_, key_, sle_, entry_, index_)) { - assert(false); + XRPL_UNREACHABLE(); } } } @@ -70,7 +70,7 @@ BookDirs::const_iterator::operator==( if (view_ == nullptr || other.view_ == nullptr) return false; - assert(view_ == other.view_ && root_ == other.root_); + XRPL_ASSERT(view_ == other.view_ && root_ == other.root_); return entry_ == other.entry_ && cur_key_ == other.cur_key_ && index_ == other.index_; } @@ -78,7 +78,7 @@ BookDirs::const_iterator::operator==( BookDirs::const_iterator::reference BookDirs::const_iterator::operator*() const { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::offer(index_)); return *cache_; @@ -89,7 +89,7 @@ BookDirs::const_iterator::operator++() { using beast::zero; - assert(index_ != zero); + XRPL_ASSERT(index_ != zero); if (!cdirNext(*view_, cur_key_, sle_, entry_, index_)) { if (index_ != 0 || @@ -102,7 +102,7 @@ BookDirs::const_iterator::operator++() } else if (!cdirFirst(*view_, cur_key_, sle_, entry_, index_)) { - assert(false); + XRPL_UNREACHABLE(); } } @@ -113,7 +113,7 @@ BookDirs::const_iterator::operator++() BookDirs::const_iterator BookDirs::const_iterator::operator++(int) { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; diff --git a/src/xrpld/ledger/detail/Directory.cpp b/src/xrpld/ledger/detail/Directory.cpp index 9153d013fd8..7fe2ffe1ba2 100644 --- a/src/xrpld/ledger/detail/Directory.cpp +++ b/src/xrpld/ledger/detail/Directory.cpp @@ -60,14 +60,14 @@ const_iterator::operator==(const_iterator const& other) const if (view_ == nullptr || other.view_ == nullptr) return false; - assert(view_ == other.view_ && root_.key == other.root_.key); + XRPL_ASSERT(view_ == other.view_ && root_.key == other.root_.key); return page_.key == other.page_.key && index_ == other.index_; } const_iterator::reference const_iterator::operator*() const { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::child(index_)); return *cache_; @@ -76,7 +76,7 @@ const_iterator::operator*() const const_iterator& const_iterator::operator++() { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); if (++it_ != std::end(*indexes_)) { index_ = *it_; @@ -90,7 +90,7 @@ const_iterator::operator++() const_iterator const_iterator::operator++(int) { - assert(index_ != beast::zero); + XRPL_ASSERT(index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; @@ -109,7 +109,7 @@ const_iterator::next_page() { page_ = keylet::page(root_, next); sle_ = view_->read(page_); - assert(sle_); + XRPL_ASSERT(sle_); indexes_ = &sle_->getFieldV256(sfIndexes); if (indexes_->empty()) { diff --git a/src/xrpld/ledger/detail/PaymentSandbox.cpp b/src/xrpld/ledger/detail/PaymentSandbox.cpp index d182d22b56c..130102771f3 100644 --- a/src/xrpld/ledger/detail/PaymentSandbox.cpp +++ b/src/xrpld/ledger/detail/PaymentSandbox.cpp @@ -20,12 +20,11 @@ #include #include #include +#include #include #include #include -#include - namespace ripple { namespace detail { @@ -49,8 +48,8 @@ DeferredCredits::credit( STAmount const& amount, STAmount const& preCreditSenderBalance) { - assert(sender != receiver); - assert(!amount.negative()); + XRPL_ASSERT(sender != receiver); + XRPL_ASSERT(!amount.negative()); auto const k = makeKey(sender, receiver, amount.getCurrency()); auto i = credits_.find(k); @@ -253,14 +252,14 @@ PaymentSandbox::adjustOwnerCountHook( void PaymentSandbox::apply(RawView& to) { - assert(!ps_); + XRPL_ASSERT(!ps_); items_.apply(to); } void PaymentSandbox::apply(PaymentSandbox& to) { - assert(ps_ == &to); + XRPL_ASSERT(ps_ == &to); items_.apply(to); tab_.apply(to.tab_); } @@ -344,7 +343,7 @@ PaymentSandbox::balanceChanges(ReadView const& view) const { // modify auto const at = after->getType(); - assert(at == before->getType()); + XRPL_ASSERT(at == before->getType()); switch (at) { case ltACCOUNT_ROOT: diff --git a/src/xrpld/ledger/detail/RawStateTable.cpp b/src/xrpld/ledger/detail/RawStateTable.cpp index 4d3732f8a45..a37a608010d 100644 --- a/src/xrpld/ledger/detail/RawStateTable.cpp +++ b/src/xrpld/ledger/detail/RawStateTable.cpp @@ -63,7 +63,7 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base { if (auto const p = dynamic_cast(&impl)) { - assert(end1_ == p->end1_ && end0_ == p->end0_); + XRPL_ASSERT(end1_ == p->end1_ && end0_ == p->end0_); return iter1_ == p->iter1_ && iter0_ == p->iter0_; } @@ -73,7 +73,7 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base void increment() override { - assert(sle1_ || sle0_); + XRPL_ASSERT(sle1_ || sle0_); if (sle1_ && !sle0_) { @@ -179,7 +179,7 @@ RawStateTable::apply(RawView& to) const bool RawStateTable::exists(ReadView const& base, Keylet const& k) const { - assert(k.key.isNonZero()); + XRPL_ASSERT(k.key.isNonZero()); auto const iter = items_.find(k.key); if (iter == items_.end()) return base.exists(k); diff --git a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp index ae84259d7ce..d06ab1f8a3c 100644 --- a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp +++ b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp @@ -80,7 +80,7 @@ template bool ReadViewFwdRange::iterator::operator==(iterator const& other) const { - assert(view_ == other.view_); + XRPL_ASSERT(view_ == other.view_); if (impl_ != nullptr && other.impl_ != nullptr) return impl_->equal(*other.impl_); diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 13ac07e5e74..3272216a105 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -22,11 +22,11 @@ #include #include #include +#include #include #include #include #include -#include #include namespace ripple { @@ -48,7 +48,7 @@ internalDirNext( uint256& entry) { auto const& svIndexes = page->getFieldV256(sfIndexes); - assert(index <= svIndexes.size()); + XRPL_ASSERT(index <= svIndexes.size()); if (index >= svIndexes.size()) { @@ -65,7 +65,7 @@ internalDirNext( else page = view.peek(keylet::page(root, next)); - assert(page); + XRPL_ASSERT(page); if (!page) return false; @@ -336,7 +336,7 @@ confineOwnerCount( << "Account " << *id << " owner count set below 0!"; } adjusted = 0; - assert(!id); + XRPL_ASSERT(!id); } } return adjusted; @@ -386,7 +386,7 @@ forEachItem( Keylet const& root, std::function const&)> const& f) { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return; @@ -416,7 +416,7 @@ forEachItemAfter( unsigned int limit, std::function const&)> const& f) { - assert(root.type == ltDIR_NODE); + XRPL_ASSERT(root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return false; @@ -678,7 +678,7 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) auto const hashIndex = ledger.read(keylet::skip()); if (hashIndex) { - assert( + XRPL_ASSERT( hashIndex->getFieldU32(sfLastLedgerSequence) == (ledger.seq() - 1)); STVector256 vec = hashIndex->getFieldV256(sfHashes); @@ -708,8 +708,8 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) if (hashIndex) { auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence); - assert(lastSeq >= seq); - assert((lastSeq & 0xff) == 0); + XRPL_ASSERT(lastSeq >= seq); + XRPL_ASSERT((lastSeq & 0xff) == 0); auto const diff = (lastSeq - seq) >> 8; STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() > diff) @@ -735,7 +735,7 @@ adjustOwnerCount( { if (!sle) return; - assert(amount != 0); + XRPL_ASSERT(amount != 0); std::uint32_t const current{sle->getFieldU32(sfOwnerCount)}; AccountID const id = (*sle)[sfAccount]; std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j); @@ -800,11 +800,11 @@ trustCreate( const bool bSetDst = saLimit.getIssuer() == uDstAccountID; const bool bSetHigh = bSrcHigh ^ bSetDst; - assert(sleAccount); + XRPL_ASSERT(sleAccount); if (!sleAccount) return tefINTERNAL; - assert( + XRPL_ASSERT( sleAccount->getAccountID(sfAccount) == (bSetHigh ? uHighAccountID : uLowAccountID)); auto const slePeer = @@ -959,17 +959,17 @@ rippleCredit( Currency const& currency = saAmount.getCurrency(); // Make sure issuer is involved. - assert(!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); + XRPL_ASSERT(!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); (void)issuer; // Disallow sending to self. - assert(uSenderID != uReceiverID); + XRPL_ASSERT(uSenderID != uReceiverID); bool const bSenderHigh = uSenderID > uReceiverID; auto const index = keylet::line(uSenderID, uReceiverID, currency); - assert(!isXRP(uSenderID) && uSenderID != noAccount()); - assert(!isXRP(uReceiverID) && uReceiverID != noAccount()); + XRPL_ASSERT(!isXRP(uSenderID) && uSenderID != noAccount()); + XRPL_ASSERT(!isXRP(uReceiverID) && uReceiverID != noAccount()); // If the line exists, modify it accordingly. if (auto const sleRippleState = view.peek(index)) @@ -1103,8 +1103,8 @@ rippleSend( { auto const issuer = saAmount.getIssuer(); - assert(!isXRP(uSenderID) && !isXRP(uReceiverID)); - assert(uSenderID != uReceiverID); + XRPL_ASSERT(!isXRP(uSenderID) && !isXRP(uReceiverID)); + XRPL_ASSERT(uSenderID != uReceiverID); if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount()) { @@ -1156,7 +1156,7 @@ accountSend( } else { - assert(saAmount >= beast::zero); + XRPL_ASSERT(saAmount >= beast::zero); } /* If we aren't sending anything or if the sender is the same as the @@ -1317,13 +1317,13 @@ issueIOU( Issue const& issue, beast::Journal j) { - assert(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); // Consistency check - assert(issue == amount.issue()); + XRPL_ASSERT(issue == amount.issue()); // Can't send to self! - assert(issue.account != account); + XRPL_ASSERT(issue.account != account); JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1413,13 +1413,13 @@ redeemIOU( Issue const& issue, beast::Journal j) { - assert(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); // Consistency check - assert(issue == amount.issue()); + XRPL_ASSERT(issue == amount.issue()); // Can't send to self! - assert(issue.account != account); + XRPL_ASSERT(issue.account != account); JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1483,10 +1483,10 @@ transferXRP( STAmount const& amount, beast::Journal j) { - assert(from != beast::zero); - assert(to != beast::zero); - assert(from != to); - assert(amount.native()); + XRPL_ASSERT(from != beast::zero); + XRPL_ASSERT(to != beast::zero); + XRPL_ASSERT(from != to); + XRPL_ASSERT(amount.native()); SLE::pointer const sender = view.peek(keylet::account(from)); SLE::pointer const receiver = view.peek(keylet::account(to)); @@ -1596,7 +1596,7 @@ cleanupOnAccountDelete( // // 3. So we verify that uDirEntry is indeed 'it'+1. Then we jam it // back to 'it' to "un-invalidate" the iterator. - assert(uDirEntry >= 1); + XRPL_ASSERT(uDirEntry >= 1); if (uDirEntry == 0) { JLOG(j.error()) diff --git a/src/xrpld/net/detail/DatabaseBody.ipp b/src/xrpld/net/detail/DatabaseBody.ipp index 76223ca6a35..bc695567214 100644 --- a/src/xrpld/net/detail/DatabaseBody.ipp +++ b/src/xrpld/net/detail/DatabaseBody.ipp @@ -89,7 +89,7 @@ DatabaseBody::reader::init( boost::system::error_code& ec) { // The connection must already be available for writing - assert(body_.conn_); + XRPL_ASSERT(body_.conn_); // The error_code specification requires that we // either set the error to some value, or set it diff --git a/src/xrpld/net/detail/DatabaseDownloader.cpp b/src/xrpld/net/detail/DatabaseDownloader.cpp index b39e6904c46..37789a196b0 100644 --- a/src/xrpld/net/detail/DatabaseDownloader.cpp +++ b/src/xrpld/net/detail/DatabaseDownloader.cpp @@ -72,7 +72,7 @@ DatabaseDownloader::closeBody(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - assert(databaseBodyParser); + XRPL_ASSERT(databaseBodyParser); databaseBodyParser->get().body().close(); } @@ -84,7 +84,7 @@ DatabaseDownloader::size(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - assert(databaseBodyParser); + XRPL_ASSERT(databaseBodyParser); return databaseBodyParser->get().body().size(); } diff --git a/src/xrpld/net/detail/HTTPStream.cpp b/src/xrpld/net/detail/HTTPStream.cpp index b94f8959ec9..4beb6a479ab 100644 --- a/src/xrpld/net/detail/HTTPStream.cpp +++ b/src/xrpld/net/detail/HTTPStream.cpp @@ -33,7 +33,7 @@ SSLStream::SSLStream( boost::asio::ip::tcp::socket& SSLStream::getStream() { - assert(stream_); + XRPL_ASSERT(stream_); return stream_->next_layer(); } @@ -126,7 +126,7 @@ RawStream::RawStream(boost::asio::io_service::strand& strand) : strand_(strand) boost::asio::ip::tcp::socket& RawStream::getStream() { - assert(stream_); + XRPL_ASSERT(stream_); return *stream_; } diff --git a/src/xrpld/net/detail/InfoSub.cpp b/src/xrpld/net/detail/InfoSub.cpp index 3dc891cb5f9..0ae58e99c46 100644 --- a/src/xrpld/net/detail/InfoSub.cpp +++ b/src/xrpld/net/detail/InfoSub.cpp @@ -145,7 +145,7 @@ InfoSub::setApiVersion(unsigned int apiVersion) unsigned int InfoSub::getApiVersion() const noexcept { - assert(apiVersion_ > 0); + XRPL_ASSERT(apiVersion_ > 0); return apiVersion_; } diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index 533878ab1b0..f91aab1f09b 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -992,7 +992,7 @@ class RPCParser parseTransactionEntry(Json::Value const& jvParams) { // Parameter count should have already been verified. - assert(jvParams.size() == 2); + XRPL_ASSERT(jvParams.size() == 2); std::string const txHash = jvParams[0u].asString(); if (txHash.length() != 64) diff --git a/src/xrpld/nodestore/Database.h b/src/xrpld/nodestore/Database.h index ad843c55d52..aeb0792ec8d 100644 --- a/src/xrpld/nodestore/Database.h +++ b/src/xrpld/nodestore/Database.h @@ -256,7 +256,7 @@ class Database [[nodiscard]] std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const noexcept { - assert(shardIndex >= earliestShardIndex_); + XRPL_ASSERT(shardIndex >= earliestShardIndex_); if (shardIndex <= earliestShardIndex_) return earliestLedgerSeq_; return 1 + (shardIndex * ledgersPerShard_); @@ -270,7 +270,7 @@ class Database [[nodiscard]] std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const noexcept { - assert(shardIndex >= earliestShardIndex_); + XRPL_ASSERT(shardIndex >= earliestShardIndex_); return (shardIndex + 1) * ledgersPerShard_; } @@ -282,7 +282,7 @@ class Database [[nodiscard]] std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept { - assert(ledgerSeq >= earliestLedgerSeq_); + XRPL_ASSERT(ledgerSeq >= earliestLedgerSeq_); return (ledgerSeq - 1) / ledgersPerShard_; } @@ -332,7 +332,7 @@ class Database void storeStats(std::uint64_t count, std::uint64_t sz) { - assert(count <= sz); + XRPL_ASSERT(count <= sz); storeCount_ += count; storeSz_ += sz; } diff --git a/src/xrpld/nodestore/backend/CassandraFactory.cpp b/src/xrpld/nodestore/backend/CassandraFactory.cpp index c53e7709587..59528ccf220 100644 --- a/src/xrpld/nodestore/backend/CassandraFactory.cpp +++ b/src/xrpld/nodestore/backend/CassandraFactory.cpp @@ -31,12 +31,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include @@ -164,7 +164,7 @@ class CassandraBackend : public Backend { if (open_) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database is already open"; return; } @@ -342,7 +342,7 @@ class CassandraBackend : public Backend { std::this_thread::sleep_for(std::chrono::seconds(1)); session_.reset(cass_session_new()); - assert(session_); + XRPL_ASSERT(session_); fut = cass_session_connect_keyspace( session_.get(), cluster, keyspace.c_str()); @@ -625,7 +625,7 @@ class CassandraBackend : public Backend numHashes)); read(*cbs[i]); } - assert(results.size() == cbs.size()); + XRPL_ASSERT(results.size() == cbs.size()); std::unique_lock lck(mtx); cv.wait(lck, [&numFinished, &numHashes]() { @@ -789,7 +789,7 @@ class CassandraBackend : public Backend void for_each(std::function)> f) override { - assert(false); + XRPL_UNREACHABLE(); Throw("not implemented"); } diff --git a/src/xrpld/nodestore/backend/MemoryFactory.cpp b/src/xrpld/nodestore/backend/MemoryFactory.cpp index 767db9d1695..8f65c367746 100644 --- a/src/xrpld/nodestore/backend/MemoryFactory.cpp +++ b/src/xrpld/nodestore/backend/MemoryFactory.cpp @@ -131,7 +131,7 @@ class MemoryBackend : public Backend Status fetch(void const* key, std::shared_ptr* pObject) override { - assert(db_); + XRPL_ASSERT(db_); uint256 const hash(uint256::fromVoid(key)); std::lock_guard _(db_->mutex); @@ -167,7 +167,7 @@ class MemoryBackend : public Backend void store(std::shared_ptr const& object) override { - assert(db_); + XRPL_ASSERT(db_); std::lock_guard _(db_->mutex); db_->table.emplace(object->getHash(), object); } @@ -187,7 +187,7 @@ class MemoryBackend : public Backend void for_each(std::function)> f) override { - assert(db_); + XRPL_ASSERT(db_); for (auto const& e : db_->table) f(e.second); } diff --git a/src/xrpld/nodestore/backend/NuDBFactory.cpp b/src/xrpld/nodestore/backend/NuDBFactory.cpp index 742bf05031b..2358426ea96 100644 --- a/src/xrpld/nodestore/backend/NuDBFactory.cpp +++ b/src/xrpld/nodestore/backend/NuDBFactory.cpp @@ -23,8 +23,8 @@ #include #include #include +#include #include -#include #include #include #include @@ -117,7 +117,7 @@ class NuDBBackend : public Backend using namespace boost::filesystem; if (db_.is_open()) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database is already open"; return; } diff --git a/src/xrpld/nodestore/backend/RocksDBFactory.cpp b/src/xrpld/nodestore/backend/RocksDBFactory.cpp index 9ba9fffe1db..9ad59057d09 100644 --- a/src/xrpld/nodestore/backend/RocksDBFactory.cpp +++ b/src/xrpld/nodestore/backend/RocksDBFactory.cpp @@ -228,7 +228,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback { if (m_db) { - assert(false); + XRPL_UNREACHABLE(); JLOG(m_journal.error()) << "database is already open"; return; } @@ -273,7 +273,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback Status fetch(void const* key, std::shared_ptr* pObject) override { - assert(m_db); + XRPL_ASSERT(m_db); pObject->reset(); Status status(ok); @@ -349,7 +349,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void storeBatch(Batch const& batch) override { - assert(m_db); + XRPL_ASSERT(m_db); rocksdb::WriteBatch wb; for (auto const& e : batch) @@ -381,7 +381,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void for_each(std::function)> f) override { - assert(m_db); + XRPL_ASSERT(m_db); rocksdb::ReadOptions const options; std::unique_ptr it(m_db->NewIterator(options)); diff --git a/src/xrpld/nodestore/detail/BatchWriter.cpp b/src/xrpld/nodestore/detail/BatchWriter.cpp index 1c5067d5bed..34147e18648 100644 --- a/src/xrpld/nodestore/detail/BatchWriter.cpp +++ b/src/xrpld/nodestore/detail/BatchWriter.cpp @@ -83,7 +83,7 @@ BatchWriter::writeBatch() std::lock_guard sl(mWriteMutex); mWriteSet.swap(set); - assert(mWriteSet.empty()); + XRPL_ASSERT(mWriteSet.empty()); mWriteLoad = set.size(); if (set.empty()) diff --git a/src/xrpld/nodestore/detail/Database.cpp b/src/xrpld/nodestore/detail/Database.cpp index 93468eb6084..e5933011d1a 100644 --- a/src/xrpld/nodestore/detail/Database.cpp +++ b/src/xrpld/nodestore/detail/Database.cpp @@ -46,7 +46,7 @@ Database::Database( , requestBundle_(get(config, "rq_bundle", 4)) , readThreads_(std::max(1, readThreads)) { - assert(readThreads != 0); + XRPL_ASSERT(readThreads != 0); if (ledgersPerShard_ == 0 || ledgersPerShard_ % 256 != 0) Throw("Invalid ledgers_per_shard"); @@ -96,7 +96,7 @@ Database::Database( for (auto it = read.begin(); it != read.end(); ++it) { - assert(!it->second.empty()); + XRPL_ASSERT(!it->second.empty()); auto const& hash = it->first; auto const& data = it->second; @@ -157,7 +157,7 @@ Database::maxLedgers(std::uint32_t shardIndex) const noexcept if (shardIndex == earliestShardIndex_) return lastLedgerSeq(shardIndex) - firstLedgerSeq(shardIndex) + 1; - assert(!"Invalid shard index"); + XRPL_ASSERT(!"Invalid shard index"); return 0; } @@ -183,7 +183,7 @@ Database::stop() while (readThreads_.load() != 0) { - assert(steady_clock::now() - start < 30s); + XRPL_ASSERT(steady_clock::now() - start < 30s); std::this_thread::yield(); } @@ -234,7 +234,7 @@ Database::importInternal(Backend& dstBackend, Database& srcDB) }; srcDB.for_each([&](std::shared_ptr nodeObject) { - assert(nodeObject); + XRPL_ASSERT(nodeObject); if (!nodeObject) // This should never happen return; @@ -377,7 +377,7 @@ Database::storeLedger( void Database::getCountsJson(Json::Value& obj) { - assert(obj.isObject()); + XRPL_ASSERT(obj.isObject()); { std::unique_lock lock(readLock_); diff --git a/src/xrpld/nodestore/detail/DatabaseNodeImp.h b/src/xrpld/nodestore/detail/DatabaseNodeImp.h index f5f5f64bd1d..3b7152b1373 100644 --- a/src/xrpld/nodestore/detail/DatabaseNodeImp.h +++ b/src/xrpld/nodestore/detail/DatabaseNodeImp.h @@ -76,7 +76,7 @@ class DatabaseNodeImp : public Database j); } - assert(backend_); + XRPL_ASSERT(backend_); } ~DatabaseNodeImp() diff --git a/src/xrpld/nodestore/detail/DatabaseShardImp.cpp b/src/xrpld/nodestore/detail/DatabaseShardImp.cpp index c7e45641d7f..c6248028b4a 100644 --- a/src/xrpld/nodestore/detail/DatabaseShardImp.cpp +++ b/src/xrpld/nodestore/detail/DatabaseShardImp.cpp @@ -233,7 +233,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (acquireIndex_ != 0) { @@ -241,7 +241,7 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) return it->second->prepare(); // Should never get here - assert(false); + XRPL_UNREACHABLE(); return std::nullopt; } @@ -325,7 +325,7 @@ DatabaseShardImp::prepareShards(std::vector const& shardIndexes) return fail("invalid shard indexes"); std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (!canAdd_) return fail("cannot be stored at this time"); @@ -417,7 +417,7 @@ void DatabaseShardImp::removePreShard(std::uint32_t shardIndex) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (preparedIndexes_.erase(shardIndex)) updatePeers(lock); @@ -429,7 +429,7 @@ DatabaseShardImp::getPreShards() RangeSet rs; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); for (auto const& shardIndex : preparedIndexes_) rs.insert(shardIndex); @@ -557,7 +557,7 @@ DatabaseShardImp::fetchLedger(uint256 const& hash, std::uint32_t ledgerSeq) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); auto const it{shards_.find(shardIndex)}; if (it == shards_.end()) @@ -661,7 +661,7 @@ DatabaseShardImp::setStored(std::shared_ptr const& ledger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (shardIndex != acquireIndex_) { @@ -766,14 +766,14 @@ void DatabaseShardImp::importDatabase(Database& source) { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); // Only the application local node store can be imported - assert(&source == &app_.getNodeStore()); + XRPL_ASSERT(&source == &app_.getNodeStore()); if (databaseImporter_.joinable()) { - assert(false); + XRPL_UNREACHABLE(); JLOG(j_.error()) << "database import already in progress"; return; } @@ -865,7 +865,7 @@ DatabaseShardImp::doImportDatabase() { std::lock_guard lock(mutex_); - assert(!databaseImportStatus_); + XRPL_ASSERT(!databaseImportStatus_); databaseImportStatus_ = std::make_unique( earliestIndex, latestIndex, 0); } @@ -1088,7 +1088,7 @@ DatabaseShardImp::getWriteLoad() const std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); auto const it{shards_.find(acquireIndex_)}; if (it == shards_.end()) @@ -1141,7 +1141,7 @@ DatabaseShardImp::storeLedger(std::shared_ptr const& srcLedger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); if (shardIndex != acquireIndex_) { @@ -1174,7 +1174,7 @@ DatabaseShardImp::sweep() std::vector> shards; { std::lock_guard lock(mutex_); - assert(init_); + XRPL_ASSERT(init_); shards.reserve(shards_.size()); for (auto const& e : shards_) @@ -1460,7 +1460,7 @@ DatabaseShardImp::findAcquireIndex( } } - assert(false); + XRPL_UNREACHABLE(); return std::nullopt; } @@ -1515,7 +1515,8 @@ DatabaseShardImp::finalizeShard( else { // Not a historical shard. Shift recent shards if necessary - assert(!boundaryIndex || shard->index() - boundaryIndex <= 1); + XRPL_ASSERT( + !boundaryIndex || shard->index() - boundaryIndex <= 1); relocateOutdatedShards(lock); // Set the appropriate recent shard index diff --git a/src/xrpld/nodestore/detail/DecodedBlob.cpp b/src/xrpld/nodestore/detail/DecodedBlob.cpp index b71f2c543b1..331a3624b00 100644 --- a/src/xrpld/nodestore/detail/DecodedBlob.cpp +++ b/src/xrpld/nodestore/detail/DecodedBlob.cpp @@ -18,9 +18,9 @@ //============================================================================== #include +#include #include #include -#include namespace ripple { namespace NodeStore { @@ -72,7 +72,7 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) std::shared_ptr DecodedBlob::createObject() { - assert(m_success); + XRPL_ASSERT(m_success); std::shared_ptr object; diff --git a/src/xrpld/nodestore/detail/EncodedBlob.h b/src/xrpld/nodestore/detail/EncodedBlob.h index 2b506a0df3f..349e741c19a 100644 --- a/src/xrpld/nodestore/detail/EncodedBlob.h +++ b/src/xrpld/nodestore/detail/EncodedBlob.h @@ -22,10 +22,10 @@ #include #include +#include #include #include #include -#include #include namespace ripple { @@ -80,7 +80,7 @@ class EncodedBlob public: explicit EncodedBlob(std::shared_ptr const& obj) : size_([&obj]() { - assert(obj); + XRPL_ASSERT(obj); if (!obj) throw std::runtime_error( @@ -100,7 +100,7 @@ class EncodedBlob ~EncodedBlob() { - assert( + XRPL_ASSERT( ((ptr_ == payload_.data()) && (size_ <= payload_.size())) || ((ptr_ != payload_.data()) && (size_ > payload_.size()))); diff --git a/src/xrpld/nodestore/detail/ManagerImp.cpp b/src/xrpld/nodestore/detail/ManagerImp.cpp index 019dd1f8122..a524f4ecca2 100644 --- a/src/xrpld/nodestore/detail/ManagerImp.cpp +++ b/src/xrpld/nodestore/detail/ManagerImp.cpp @@ -97,7 +97,7 @@ ManagerImp::erase(Factory& factory) std::find_if(list_.begin(), list_.end(), [&factory](Factory* other) { return other == &factory; }); - assert(iter != list_.end()); + XRPL_ASSERT(iter != list_.end()); list_.erase(iter); } diff --git a/src/xrpld/nodestore/detail/Shard.cpp b/src/xrpld/nodestore/detail/Shard.cpp index 8c2e9997fbf..192a6912887 100644 --- a/src/xrpld/nodestore/detail/Shard.cpp +++ b/src/xrpld/nodestore/detail/Shard.cpp @@ -711,7 +711,7 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) if (writeSQLite && !storeSQLite(ledger)) return fail("failed storing to SQLite databases"); - assert( + XRPL_ASSERT( ledger->info().seq == ledgerSeq && (ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || ledger->read(keylet::fees()))); @@ -813,7 +813,7 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) if (!open(lock)) return fail("failed to open"); - assert(state_ == ShardState::finalized); + XRPL_ASSERT(state_ == ShardState::finalized); // Allow all other threads work with the shard busy_ = false; diff --git a/src/xrpld/nodestore/detail/TaskQueue.cpp b/src/xrpld/nodestore/detail/TaskQueue.cpp index 6062138c60f..68513dbcf12 100644 --- a/src/xrpld/nodestore/detail/TaskQueue.cpp +++ b/src/xrpld/nodestore/detail/TaskQueue.cpp @@ -18,9 +18,7 @@ //============================================================================== #include - -#include - +#include namespace ripple { namespace NodeStore { @@ -59,7 +57,7 @@ TaskQueue::processTask(int instance) { std::lock_guard lock{mutex_}; - assert(!tasks_.empty()); + XRPL_ASSERT(!tasks_.empty()); task = std::move(tasks_.front()); tasks_.pop(); diff --git a/src/xrpld/overlay/Compression.h b/src/xrpld/overlay/Compression.h index 1cf13fcb185..e795029323c 100644 --- a/src/xrpld/overlay/Compression.h +++ b/src/xrpld/overlay/Compression.h @@ -64,7 +64,7 @@ decompress( JLOG(debugLog().warn()) << "decompress: invalid compression algorithm " << static_cast(algorithm); - assert(0); + XRPL_ASSERT(0); } } catch (...) @@ -99,7 +99,7 @@ compress( { JLOG(debugLog().warn()) << "compress: invalid compression algorithm" << static_cast(algorithm); - assert(0); + XRPL_ASSERT(0); } } catch (...) diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 2a8b2146a02..142ec2d4ee2 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -362,7 +362,7 @@ Slot::update( << consideredPoolSize << " selected " << *s << " " << *std::next(s, 1) << " " << *std::next(s, 2); - assert(peers_.size() >= MAX_SELECTED_PEERS); + XRPL_ASSERT(peers_.size() >= MAX_SELECTED_PEERS); // squelch peers which are not selected and // not already squelched diff --git a/src/xrpld/overlay/detail/ConnectAttempt.cpp b/src/xrpld/overlay/detail/ConnectAttempt.cpp index 6a3ebdd5b98..ac6d1d44c81 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.cpp +++ b/src/xrpld/overlay/detail/ConnectAttempt.cpp @@ -90,7 +90,7 @@ ConnectAttempt::run() void ConnectAttempt::close() { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { error_code ec; diff --git a/src/xrpld/overlay/detail/Message.cpp b/src/xrpld/overlay/detail/Message.cpp index e19d718c73d..07405fcdf64 100644 --- a/src/xrpld/overlay/detail/Message.cpp +++ b/src/xrpld/overlay/detail/Message.cpp @@ -34,7 +34,7 @@ Message::Message( auto const messageBytes = messageSize(message); - assert(messageBytes != 0); + XRPL_ASSERT(messageBytes != 0); buffer_.resize(headerBytes + messageBytes); @@ -43,7 +43,7 @@ Message::Message( if (messageBytes != 0) message.SerializeToArray(buffer_.data() + headerBytes, messageBytes); - assert(getBufferSize() == totalSize(message)); + XRPL_ASSERT(getBufferSize() == totalSize(message)); } // static diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index f033ad4e9f9..5e8056f960b 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -295,7 +295,7 @@ OverlayImpl::onHandoff( std::lock_guard lock(mutex_); { auto const result = m_peers.emplace(peer->slot(), peer); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } list_.emplace(peer.get(), peer); @@ -388,7 +388,7 @@ OverlayImpl::makeErrorResponse( void OverlayImpl::connect(beast::IP::Endpoint const& remote_endpoint) { - assert(work_); + XRPL_ASSERT(work_); auto usage = resourceManager().newOutboundEndpoint(remote_endpoint); if (usage.disconnect(journal_)) @@ -430,7 +430,7 @@ OverlayImpl::add_active(std::shared_ptr const& peer) { auto const result = m_peers.emplace(peer->slot(), peer); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -439,7 +439,7 @@ OverlayImpl::add_active(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer)); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -462,7 +462,7 @@ OverlayImpl::remove(std::shared_ptr const& slot) { std::lock_guard lock(mutex_); auto const iter = m_peers.find(slot); - assert(iter != m_peers.end()); + XRPL_ASSERT(iter != m_peers.end()); m_peers.erase(iter); } @@ -596,7 +596,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer))); - assert(result.second); + XRPL_ASSERT(result.second); (void)result.second; } @@ -607,7 +607,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) << ")"; // We just accepted this peer so we have non-zero active peers - assert(size() != 0); + XRPL_ASSERT(size() != 0); } void @@ -646,7 +646,7 @@ OverlayImpl::onManifests( // the loaded Manifest out of the optional so we need to // reload it here. mo = deserializeManifest(serialized); - assert(mo); + XRPL_ASSERT(mo); app_.getOPs().pubManifest(*mo); diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index 1934a7c94c8..e72e3230d6c 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include #include -#include #include #include #include @@ -616,7 +616,7 @@ class OverlayImpl : public Overlay, public reduce_relay::SquelchHandler { auto counts = m_traffic.getCounts(); std::lock_guard lock(m_statsMutex); - assert(counts.size() == m_stats.trafficGauges.size()); + XRPL_ASSERT(counts.size() == m_stats.trafficGauges.size()); for (std::size_t i = 0; i < counts.size(); ++i) { diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 96f793b8d80..c4844ff4544 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -575,7 +575,7 @@ PeerImp::hasRange(std::uint32_t uMin, std::uint32_t uMax) void PeerImp::close() { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { detaching_ = true; // DEPRECATED @@ -616,7 +616,7 @@ PeerImp::fail(std::string const& reason) void PeerImp::fail(std::string const& name, error_code ec) { - assert(strand_.running_in_this_thread()); + XRPL_ASSERT(strand_.running_in_this_thread()); if (socket_.is_open()) { JLOG(journal_.warn()) @@ -636,9 +636,9 @@ PeerImp::getPeerShardInfos() const void PeerImp::gracefulClose() { - assert(strand_.running_in_this_thread()); - assert(socket_.is_open()); - assert(!gracefulClose_); + XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT(socket_.is_open()); + XRPL_ASSERT(!gracefulClose_); gracefulClose_ = true; if (send_queue_.size() > 0) return; @@ -764,7 +764,7 @@ PeerImp::onShutdown(error_code ec) void PeerImp::doAccept() { - assert(read_buffer_.size() == 0); + XRPL_ASSERT(read_buffer_.size() == 0); JLOG(journal_.debug()) << "doAccept: " << remote_address_; @@ -962,7 +962,7 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred) metrics_.sent.add_message(bytes_transferred); - assert(!send_queue_.empty()); + XRPL_ASSERT(!send_queue_.empty()); send_queue_.pop(); if (!send_queue_.empty()) { @@ -2319,13 +2319,13 @@ PeerImp::onValidatorListMessage( case ListDisposition::pending: { std::lock_guard sl(recentLock_); - assert(applyResult.publisherKey); + XRPL_ASSERT(applyResult.publisherKey); auto const& pubKey = *applyResult.publisherKey; #ifndef NDEBUG if (auto const iter = publisherListSequences_.find(pubKey); iter != publisherListSequences_.end()) { - assert(iter->second < applyResult.sequence); + XRPL_ASSERT(iter->second < applyResult.sequence); } #endif publisherListSequences_[pubKey] = applyResult.sequence; @@ -2336,8 +2336,8 @@ PeerImp::onValidatorListMessage( #ifndef NDEBUG { std::lock_guard sl(recentLock_); - assert(applyResult.sequence && applyResult.publisherKey); - assert( + XRPL_ASSERT(applyResult.sequence && applyResult.publisherKey); + XRPL_ASSERT( publisherListSequences_[*applyResult.publisherKey] <= applyResult.sequence); } @@ -2350,7 +2350,7 @@ PeerImp::onValidatorListMessage( case ListDisposition::unsupported_version: break; default: - assert(false); + XRPL_UNREACHABLE(); } // Charge based on the worst result @@ -2389,7 +2389,7 @@ PeerImp::onValidatorListMessage( fee_ = Resource::feeBadData; break; default: - assert(false); + XRPL_UNREACHABLE(); } // Log based on all the results. @@ -2447,7 +2447,7 @@ PeerImp::onValidatorListMessage( << "(s) from peer " << remote_address_; break; default: - assert(false); + XRPL_UNREACHABLE(); } } } @@ -3130,7 +3130,7 @@ PeerImp::checkPropose( JLOG(p_journal_.trace()) << "Checking " << (isTrusted ? "trusted" : "UNTRUSTED") << " proposal"; - assert(packet); + XRPL_ASSERT(packet); if (!cluster() && !peerPos.checkSign()) { diff --git a/src/xrpld/overlay/detail/ProtocolMessage.h b/src/xrpld/overlay/detail/ProtocolMessage.h index b8c6a2c1cf2..dd1044d8865 100644 --- a/src/xrpld/overlay/detail/ProtocolMessage.h +++ b/src/xrpld/overlay/detail/ProtocolMessage.h @@ -24,11 +24,11 @@ #include #include #include +#include #include #include #include #include -#include #include #include #include @@ -183,7 +183,7 @@ parseMessageHeader( MessageHeader hdr; auto iter = buffersBegin(bufs); - assert(iter != buffersEnd(bufs)); + XRPL_ASSERT(iter != buffersEnd(bufs)); // Check valid header compressed message: // - 4 bits are the compression algorithm, 1st bit is always set to 1 diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index acd96695257..63260b81f71 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED #define RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED +#include #include #include @@ -172,7 +173,7 @@ class TrafficCount void addCount(category cat, bool inbound, int bytes) { - assert(cat <= category::unknown); + XRPL_ASSERT(cat <= category::unknown); if (inbound) { diff --git a/src/xrpld/overlay/detail/ZeroCopyStream.h b/src/xrpld/overlay/detail/ZeroCopyStream.h index da0f0d380d8..40a37b5845f 100644 --- a/src/xrpld/overlay/detail/ZeroCopyStream.h +++ b/src/xrpld/overlay/detail/ZeroCopyStream.h @@ -204,7 +204,7 @@ template void ZeroCopyOutputStream::BackUp(int count) { - assert(count <= commit_); + XRPL_ASSERT(count <= commit_); auto const n = commit_ - count; streambuf_.commit(n); count_ += n; diff --git a/src/xrpld/peerfinder/detail/Bootcache.cpp b/src/xrpld/peerfinder/detail/Bootcache.cpp index 9e94a12e619..3f053f049eb 100644 --- a/src/xrpld/peerfinder/detail/Bootcache.cpp +++ b/src/xrpld/peerfinder/detail/Bootcache.cpp @@ -159,7 +159,7 @@ Bootcache::on_success(beast::IP::Endpoint const& endpoint) ++entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - assert(result.second); + XRPL_ASSERT(result.second); } Entry const& entry(result.first->right); JLOG(m_journal.info()) << beast::leftw(18) << "Bootcache connect " @@ -185,7 +185,7 @@ Bootcache::on_failure(beast::IP::Endpoint const& endpoint) --entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - assert(result.second); + XRPL_ASSERT(result.second); } Entry const& entry(result.first->right); auto const n(std::abs(entry.valence())); diff --git a/src/xrpld/peerfinder/detail/Counts.h b/src/xrpld/peerfinder/detail/Counts.h index 1ea6ff976de..4d7bca15a06 100644 --- a/src/xrpld/peerfinder/detail/Counts.h +++ b/src/xrpld/peerfinder/detail/Counts.h @@ -71,7 +71,7 @@ class Counts can_activate(Slot const& s) const { // Must be handshaked and in the right state - assert(s.state() == Slot::connected || s.state() == Slot::accept); + XRPL_ASSERT(s.state() == Slot::connected || s.state() == Slot::accept); if (s.fixed() || s.reserved()) return true; @@ -262,13 +262,13 @@ class Counts switch (s.state()) { case Slot::accept: - assert(s.inbound()); + XRPL_ASSERT(s.inbound()); m_acceptCount += n; break; case Slot::connect: case Slot::connected: - assert(!s.inbound()); + XRPL_ASSERT(!s.inbound()); m_attempts += n; break; @@ -290,7 +290,7 @@ class Counts break; default: - assert(false); + XRPL_UNREACHABLE(); break; }; } diff --git a/src/xrpld/peerfinder/detail/Handouts.h b/src/xrpld/peerfinder/detail/Handouts.h index 0b54dc205fa..ca9fc217320 100644 --- a/src/xrpld/peerfinder/detail/Handouts.h +++ b/src/xrpld/peerfinder/detail/Handouts.h @@ -22,8 +22,8 @@ #include #include +#include #include -#include #include #include @@ -43,7 +43,7 @@ template std::size_t handout_one(Target& t, HopContainer& h) { - assert(!t.full()); + XRPL_ASSERT(!t.full()); for (auto it = h.begin(); it != h.end(); ++it) { auto const& e = *it; diff --git a/src/xrpld/peerfinder/detail/Livecache.h b/src/xrpld/peerfinder/detail/Livecache.h index 1583ccd96a3..b30c87f5f05 100644 --- a/src/xrpld/peerfinder/detail/Livecache.h +++ b/src/xrpld/peerfinder/detail/Livecache.h @@ -432,7 +432,7 @@ Livecache::insert(Endpoint const& ep) // but we will use it to make connections and hand it out // when redirecting. // - assert(ep.hops <= (Tuning::maxHops + 1)); + XRPL_ASSERT(ep.hops <= (Tuning::maxHops + 1)); auto result = m_cache.emplace(ep.address, ep); Element& e(result.first->second); if (result.second) @@ -530,7 +530,7 @@ template void Livecache::hops_t::insert(Element& e) { - assert(e.endpoint.hops <= Tuning::maxHops + 1); + XRPL_ASSERT(e.endpoint.hops <= Tuning::maxHops + 1); // This has security implications without a shuffle m_lists[e.endpoint.hops].push_front(e); ++m_hist[e.endpoint.hops]; @@ -540,7 +540,7 @@ template void Livecache::hops_t::reinsert(Element& e, std::uint32_t numHops) { - assert(numHops <= Tuning::maxHops + 1); + XRPL_ASSERT(numHops <= Tuning::maxHops + 1); auto& list = m_lists[e.endpoint.hops]; list.erase(list.iterator_to(e)); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index 49b71a6a545..d232f649c72 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -305,7 +305,7 @@ class Logic // Add slot to table auto const result(slots_.emplace(slot->remote_endpoint(), slot)); // Remote address must not already exist - assert(result.second); + XRPL_ASSERT(result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -340,7 +340,7 @@ class Logic // Add slot to table auto const result = slots_.emplace(slot->remote_endpoint(), slot); // Remote address must not already exist - assert(result.second); + XRPL_ASSERT(result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -363,7 +363,7 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Assign the local endpoint now that it's known slot->local_endpoint(local_endpoint); @@ -372,7 +372,7 @@ class Logic auto const iter(slots_.find(local_endpoint)); if (iter != slots_.end()) { - assert( + XRPL_ASSERT( iter->second->local_endpoint() == slot->remote_endpoint()); JLOG(m_journal.warn()) << beast::leftw(18) << "Logic dropping " @@ -398,9 +398,9 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be accepted or connected - assert( + XRPL_ASSERT( slot->state() == Slot::accept || slot->state() == Slot::connected); // Check for duplicate connection by key @@ -427,7 +427,7 @@ class Logic { [[maybe_unused]] bool const inserted = keys_.insert(key).second; // Public key must not already exist - assert(inserted); + XRPL_ASSERT(inserted); } // Change state and update counts @@ -789,10 +789,10 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - assert(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be handshaked! - assert(slot->state() == Slot::active); + XRPL_ASSERT(slot->state() == Slot::active); clock_type::time_point const now(m_clock.now()); @@ -804,7 +804,7 @@ class Logic for (auto const& ep : list) { - assert(ep.hops != 0); + XRPL_ASSERT(ep.hops != 0); slot->recent.insert(ep.address, ep.hops); @@ -957,7 +957,7 @@ class Logic break; default: - assert(false); + XRPL_UNREACHABLE(); break; } } diff --git a/src/xrpld/peerfinder/detail/SlotImp.cpp b/src/xrpld/peerfinder/detail/SlotImp.cpp index a5d13aa729e..c24cae774cc 100644 --- a/src/xrpld/peerfinder/detail/SlotImp.cpp +++ b/src/xrpld/peerfinder/detail/SlotImp.cpp @@ -64,19 +64,19 @@ void SlotImp::state(State state_) { // Must go through activate() to set active state - assert(state_ != active); + XRPL_ASSERT(state_ != active); // The state must be different - assert(state_ != m_state); + XRPL_ASSERT(state_ != m_state); // You can't transition into the initial states - assert(state_ != accept && state_ != connect); + XRPL_ASSERT(state_ != accept && state_ != connect); // Can only become connected from outbound connect state - assert(state_ != connected || (!m_inbound && m_state == connect)); + XRPL_ASSERT(state_ != connected || (!m_inbound && m_state == connect)); // Can't gracefully close on an outbound connection attempt - assert(state_ != closing || m_state != connect); + XRPL_ASSERT(state_ != closing || m_state != connect); m_state = state_; } @@ -85,7 +85,7 @@ void SlotImp::activate(clock_type::time_point const& now) { // Can only become active from the accept or connected state - assert(m_state == accept || m_state == connected); + XRPL_ASSERT(m_state == accept || m_state == connected); m_state = active; whenAcceptEndpoints = now; diff --git a/src/xrpld/perflog/detail/PerfLogImp.cpp b/src/xrpld/perflog/detail/PerfLogImp.cpp index b9691e05c23..003fb8f5a39 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.cpp +++ b/src/xrpld/perflog/detail/PerfLogImp.cpp @@ -55,7 +55,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - assert(false); + XRPL_UNREACHABLE(); } } } @@ -68,7 +68,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - assert(false); + XRPL_UNREACHABLE(); } } } @@ -330,7 +330,7 @@ PerfLogImp::rpcStart(std::string const& method, std::uint64_t const requestId) auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } @@ -352,7 +352,7 @@ PerfLogImp::rpcEnd( auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } steady_time_point startTime; @@ -366,7 +366,7 @@ PerfLogImp::rpcEnd( } else { - assert(false); + XRPL_UNREACHABLE(); } } std::lock_guard lock(counter->second.mutex); @@ -384,7 +384,7 @@ PerfLogImp::jobQueue(JobType const type) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } std::lock_guard lock(counter->second.mutex); @@ -401,7 +401,7 @@ PerfLogImp::jobStart( auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } { @@ -420,7 +420,7 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, int instance) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - assert(false); + XRPL_UNREACHABLE(); return; } { diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index 1d94a6837a8..d4b34cb8703 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RPC_STATUS_H_INCLUDED #define RIPPLE_RPC_STATUS_H_INCLUDED +#include #include #include -#include namespace ripple { namespace RPC { @@ -95,7 +95,7 @@ struct Status : public std::exception TER toTER() const { - assert(type_ == Type::TER); + XRPL_ASSERT(type_ == Type::TER); return TER::fromInt(code_); } @@ -104,7 +104,7 @@ struct Status : public std::exception error_code_i toErrorCode() const { - assert(type_ == Type::error_code_i); + XRPL_ASSERT(type_ == Type::error_code_i); return error_code_i(code_); } diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index 4bac4610229..b22333cc6e4 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -38,7 +38,7 @@ byRef(Function const& f) result = f(context); if (result.type() != Json::objectValue) { - assert(false); + XRPL_UNREACHABLE(); result = RPC::makeObjectValue(result); } @@ -50,7 +50,7 @@ template Status handle(JsonContext& context, Object& object) { - assert( + XRPL_ASSERT( context.apiVersion >= HandlerImpl::minApiVer && context.apiVersion <= HandlerImpl::maxApiVer); HandlerImpl handler(context); @@ -211,8 +211,8 @@ class HandlerTable unsigned minVer, unsigned maxVer) { - assert(minVer <= maxVer); - assert(maxVer <= RPC::apiMaximumValidVersion); + XRPL_ASSERT(minVer <= maxVer); + XRPL_ASSERT(maxVer <= RPC::apiMaximumValidVersion); return std::any_of( range.first, diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 42bd4faded5..9d021bda708 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -540,7 +540,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return {rpcNOT_SYNCED, "notSynced"}; } - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); } else { @@ -551,7 +551,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) rpcLGR_NOT_FOUND, "Reporting does not track current ledger"}; ledger = context.ledgerMaster.getCurrentLedger(); - assert(ledger->open()); + XRPL_ASSERT(ledger->open()); } else if (shortcut == LedgerShortcut::CLOSED) { @@ -559,7 +559,7 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return { rpcLGR_NOT_FOUND, "Reporting does not track closed ledger"}; ledger = context.ledgerMaster.getClosedLedger(); - assert(!ledger->open()); + XRPL_ASSERT(!ledger->open()); } else { @@ -965,7 +965,7 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{ rpcINVALID_PARAMS, "Invalid field 'type', not string."}; - assert(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); return result; } @@ -978,7 +978,7 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{rpcINVALID_PARAMS, "Invalid field 'type'."}; - assert(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); return result; } result.second = iter->second; @@ -1071,7 +1071,7 @@ getLedgerByContext(RPC::JsonContext& context) // ledger auto const refIndex = getCandidateLedger(ledgerIndex); auto refHash = hashOfSeq(*ledger, refIndex, j); - assert(refHash); + XRPL_ASSERT(refHash); ledger = ledgerMaster.getLedgerByHash(*refHash); if (!ledger) @@ -1105,7 +1105,7 @@ getLedgerByContext(RPC::JsonContext& context) neededHash = hashOfSeq(*ledger, ledgerIndex, j); } - assert(neededHash); + XRPL_ASSERT(neededHash); ledgerHash = neededHash ? *neededHash : beast::zero; // kludge } diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index 30b48807fcd..379c9724878 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -213,7 +213,7 @@ template void setVersion(Object& parent, unsigned int apiVersion, bool betaEnabled) { - assert(apiVersion != apiInvalidVersion); + XRPL_ASSERT(apiVersion != apiInvalidVersion); auto&& object = addObject(parent, jss::version); if (apiVersion == apiVersionIfUnspecified) { diff --git a/src/xrpld/rpc/detail/Role.cpp b/src/xrpld/rpc/detail/Role.cpp index 5cfe30b26e6..01240d0214b 100644 --- a/src/xrpld/rpc/detail/Role.cpp +++ b/src/xrpld/rpc/detail/Role.cpp @@ -28,7 +28,7 @@ namespace ripple { bool passwordUnrequiredOrSentCorrect(Port const& port, Json::Value const& params) { - assert(!(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); + XRPL_ASSERT(!(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); bool const passwordRequired = (!port.admin_user.empty() || !port.admin_password.empty()); diff --git a/src/xrpld/rpc/detail/ShardArchiveHandler.cpp b/src/xrpld/rpc/detail/ShardArchiveHandler.cpp index 1ab8f7767b5..23f4f62cb4e 100644 --- a/src/xrpld/rpc/detail/ShardArchiveHandler.cpp +++ b/src/xrpld/rpc/detail/ShardArchiveHandler.cpp @@ -83,7 +83,7 @@ ShardArchiveHandler::ShardArchiveHandler(Application& app) app.config().section(ConfigSection::shardDatabase()), "shard_verification_max_attempts")) { - assert(app_.getShardStore()); + XRPL_ASSERT(app_.getShardStore()); } bool @@ -135,7 +135,7 @@ ShardArchiveHandler::initFromDB(std::lock_guard const& lock) { using namespace boost::filesystem; - assert( + XRPL_ASSERT( exists(downloadDir_ / stateDBName) && is_regular_file(downloadDir_ / stateDBName)); diff --git a/src/xrpld/rpc/detail/Status.cpp b/src/xrpld/rpc/detail/Status.cpp index af212d37f14..4b3aaf65cf4 100644 --- a/src/xrpld/rpc/detail/Status.cpp +++ b/src/xrpld/rpc/detail/Status.cpp @@ -37,7 +37,7 @@ Status::codeString() const std::string s1, s2; auto success = transResultInfo(toTER(), s1, s2); - assert(success); + XRPL_ASSERT(success); (void)success; return s1 + ": " + s2; @@ -51,7 +51,7 @@ Status::codeString() const return sStr.str(); } - assert(false); + XRPL_UNREACHABLE(); return ""; } diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 1fee84c683b..99903662820 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -1034,7 +1034,7 @@ transactionSignFor( if (!preprocResult.second) return preprocResult.first; - assert(signForParams.validMultiSign()); + XRPL_ASSERT(signForParams.validMultiSign()); { std::shared_ptr account_state = diff --git a/src/xrpld/rpc/handlers/AMMInfo.cpp b/src/xrpld/rpc/handlers/AMMInfo.cpp index aad8faea213..06563b23097 100644 --- a/src/xrpld/rpc/handlers/AMMInfo.cpp +++ b/src/xrpld/rpc/handlers/AMMInfo.cpp @@ -145,14 +145,14 @@ doAMMInfo(RPC::JsonContext& context) if (context.apiVersion >= 3 && invalid(params)) return Unexpected(rpcINVALID_PARAMS); - assert( + XRPL_ASSERT( (issue1.has_value() == issue2.has_value()) && (issue1.has_value() != ammID.has_value())); auto const ammKeylet = [&]() { if (issue1 && issue2) return keylet::amm(*issue1, *issue2); - assert(ammID); + XRPL_ASSERT(ammID); return keylet::amm(*ammID); }(); auto const amm = ledger->read(ammKeylet); @@ -211,7 +211,7 @@ doAMMInfo(RPC::JsonContext& context) } if (voteSlots.size() > 0) ammResult[jss::vote_slots] = std::move(voteSlots); - assert( + XRPL_ASSERT( !ledger->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) diff --git a/src/xrpld/rpc/handlers/AccountChannels.cpp b/src/xrpld/rpc/handlers/AccountChannels.cpp index 5ae87e32a12..8a5b138047d 100644 --- a/src/xrpld/rpc/handlers/AccountChannels.cpp +++ b/src/xrpld/rpc/handlers/AccountChannels.cpp @@ -166,7 +166,7 @@ doAccountChannels(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/xrpld/rpc/handlers/AccountInfo.cpp b/src/xrpld/rpc/handlers/AccountInfo.cpp index 29b8679505d..ba53e0d554c 100644 --- a/src/xrpld/rpc/handlers/AccountInfo.cpp +++ b/src/xrpld/rpc/handlers/AccountInfo.cpp @@ -205,7 +205,7 @@ doAccountInfo(RPC::JsonContext& context) if (tx.seqProxy.isSeq()) { - assert(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT(prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::seq] = tx.seqProxy.value(); ++seqCount; @@ -215,7 +215,7 @@ doAccountInfo(RPC::JsonContext& context) } else { - assert(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT(prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::ticket] = tx.seqProxy.value(); ++ticketCount; diff --git a/src/xrpld/rpc/handlers/AccountLines.cpp b/src/xrpld/rpc/handlers/AccountLines.cpp index cace3487bb8..e9cbe57e90e 100644 --- a/src/xrpld/rpc/handlers/AccountLines.cpp +++ b/src/xrpld/rpc/handlers/AccountLines.cpp @@ -186,7 +186,7 @@ doAccountLines(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/xrpld/rpc/handlers/AccountOffers.cpp b/src/xrpld/rpc/handlers/AccountOffers.cpp index 1a3b5227ed8..09d63e78c9b 100644 --- a/src/xrpld/rpc/handlers/AccountOffers.cpp +++ b/src/xrpld/rpc/handlers/AccountOffers.cpp @@ -142,7 +142,7 @@ doAccountOffers(RPC::JsonContext& context) std::shared_ptr const& sle) { if (!sle) { - assert(false); + XRPL_UNREACHABLE(); return false; } diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/AccountTx.cpp index 4f9431ce081..b426a3cbaa1 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/AccountTx.cpp @@ -318,7 +318,7 @@ populateJsonResponse( if (auto txnsData = std::get_if(&result.transactions)) { - assert(!args.binary); + XRPL_ASSERT(!args.binary); for (auto const& [txn, txnMeta] : *txnsData) { @@ -363,13 +363,13 @@ populateJsonResponse( insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); } else - assert(false && "Missing transaction medatata"); + XRPL_ASSERT(false && "Missing transaction medatata"); } } } else { - assert(args.binary); + XRPL_ASSERT(args.binary); for (auto const& binaryData : std::get(result.transactions)) diff --git a/src/xrpld/rpc/handlers/Fee1.cpp b/src/xrpld/rpc/handlers/Fee1.cpp index da766fdbb32..e6a92a49930 100644 --- a/src/xrpld/rpc/handlers/Fee1.cpp +++ b/src/xrpld/rpc/handlers/Fee1.cpp @@ -32,7 +32,7 @@ doFee(RPC::JsonContext& context) auto result = context.app.getTxQ().doRPC(context.app); if (result.type() == Json::objectValue) return result; - assert(false); + XRPL_UNREACHABLE(); RPC::inject_error(rpcINTERNAL, context.params); return context.params; } diff --git a/src/xrpld/rpc/handlers/LedgerClosed.cpp b/src/xrpld/rpc/handlers/LedgerClosed.cpp index 9bc9315f648..2fd1f7ef118 100644 --- a/src/xrpld/rpc/handlers/LedgerClosed.cpp +++ b/src/xrpld/rpc/handlers/LedgerClosed.cpp @@ -29,7 +29,7 @@ Json::Value doLedgerClosed(RPC::JsonContext& context) { auto ledger = context.ledgerMaster.getClosedLedger(); - assert(ledger); + XRPL_ASSERT(ledger); Json::Value jvResult; jvResult[jss::ledger_index] = ledger->info().seq; diff --git a/src/xrpld/rpc/handlers/LedgerDiff.cpp b/src/xrpld/rpc/handlers/LedgerDiff.cpp index 6398be60973..65857991736 100644 --- a/src/xrpld/rpc/handlers/LedgerDiff.cpp +++ b/src/xrpld/rpc/handlers/LedgerDiff.cpp @@ -73,7 +73,7 @@ doLedgerDiffGrpc( } else { - assert(inDesired->size() > 0); + XRPL_ASSERT(inDesired->size() > 0); diff->set_key(k.data(), k.size()); if (request.include_blobs()) { diff --git a/src/xrpld/rpc/handlers/LedgerHandler.cpp b/src/xrpld/rpc/handlers/LedgerHandler.cpp index 6d695abc85f..1d81c65f23d 100644 --- a/src/xrpld/rpc/handlers/LedgerHandler.cpp +++ b/src/xrpld/rpc/handlers/LedgerHandler.cpp @@ -136,7 +136,7 @@ doLedgerGrpc(RPC::GRPCContext& context) { for (auto& i : ledger->txs) { - assert(i.first); + XRPL_ASSERT(i.first); if (request.expand()) { auto txn = response.mutable_transactions_list() @@ -212,7 +212,7 @@ doLedgerGrpc(RPC::GRPCContext& context) obj->set_key(k.data(), k.size()); if (inDesired) { - assert(inDesired->size() > 0); + XRPL_ASSERT(inDesired->size() > 0); obj->set_data(inDesired->data(), inDesired->size()); } if (inBase && inDesired) diff --git a/src/xrpld/rpc/handlers/NodeToShard.cpp b/src/xrpld/rpc/handlers/NodeToShard.cpp index 917086ab0f4..2f0cd625f29 100644 --- a/src/xrpld/rpc/handlers/NodeToShard.cpp +++ b/src/xrpld/rpc/handlers/NodeToShard.cpp @@ -78,7 +78,7 @@ doNodeToShard(RPC::JsonContext& context) else { // Shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return rpcError(rpcINTERNAL); } } diff --git a/src/xrpld/rpc/handlers/PayChanClaim.cpp b/src/xrpld/rpc/handlers/PayChanClaim.cpp index 1fecd5f1449..73a0f24e84b 100644 --- a/src/xrpld/rpc/handlers/PayChanClaim.cpp +++ b/src/xrpld/rpc/handlers/PayChanClaim.cpp @@ -58,7 +58,7 @@ doChannelAuthorize(RPC::JsonContext& context) std::optional> const keyPair = RPC::keypairForSignature(params, result, context.apiVersion); - assert(keyPair || RPC::contains_error(result)); + XRPL_ASSERT(keyPair || RPC::contains_error(result)); if (!keyPair || RPC::contains_error(result)) return result; diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index de95044b71f..a499c240bc2 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -75,7 +75,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) { if (!context.app.config().reporting()) { - assert(false); + XRPL_UNREACHABLE(); Throw( "Called doTxPostgres yet not in reporting mode"); } @@ -109,13 +109,13 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) SHAMapHash{locator.getNodestoreHash()}); if (!node) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error making SHAMap node"}}; } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error reading SHAMap node"}}; } @@ -124,7 +124,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) if (!sttx || !meta) { - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Error deserializing SHAMap node"}}; } std::string reason; @@ -156,7 +156,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) else { JLOG(context.j.error()) << "Failed to fetch from db"; - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "Containing SHAMap node not found"}}; } auto end = std::chrono::system_clock::now(); @@ -184,7 +184,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) return {res, rpcTXN_NOT_FOUND}; } // database didn't return anything. This shouldn't happen - assert(false); + XRPL_UNREACHABLE(); return {res, {rpcINTERNAL, "unexpected Postgres response"}}; } @@ -370,7 +370,7 @@ populateJsonResponse( // populate binary metadata if (auto blob = std::get_if(&result.meta)) { - assert(args.binary); + XRPL_ASSERT(args.binary); auto json_meta = (context.apiVersion > 1 ? jss::meta_blob : jss::meta); response[json_meta] = strHex(makeSlice(*blob)); diff --git a/src/xrpld/shamap/SHAMap.h b/src/xrpld/shamap/SHAMap.h index a47f1c1c2bc..4df8923ddff 100644 --- a/src/xrpld/shamap/SHAMap.h +++ b/src/xrpld/shamap/SHAMap.h @@ -32,8 +32,8 @@ #include #include #include +#include #include -#include #include #include @@ -599,7 +599,7 @@ SHAMap::setLedgerSeq(std::uint32_t lseq) inline void SHAMap::setImmutable() { - assert(state_ != SHAMapState::Invalid); + XRPL_ASSERT(state_ != SHAMapState::Invalid); state_ = SHAMapState::Immutable; } @@ -680,7 +680,7 @@ class SHAMap::const_iterator inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) { - assert(map_ != nullptr); + XRPL_ASSERT(map_ != nullptr); if (auto temp = map_->peekFirstItem(stack_)) item_ = temp->peekItem().get(); @@ -732,7 +732,7 @@ SHAMap::const_iterator::operator++(int) inline bool operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) { - assert(x.map_ == y.map_); + XRPL_ASSERT(x.map_ == y.map_); return x.item_ == y.item_; } diff --git a/src/xrpld/shamap/SHAMapItem.h b/src/xrpld/shamap/SHAMapItem.h index 1a1822456e9..e2c876006a5 100644 --- a/src/xrpld/shamap/SHAMapItem.h +++ b/src/xrpld/shamap/SHAMapItem.h @@ -25,8 +25,8 @@ #include #include #include +#include #include -#include namespace ripple { @@ -159,7 +159,7 @@ intrusive_ptr_release(SHAMapItem const* x) inline boost::intrusive_ptr make_shamapitem(uint256 const& tag, Slice data) { - assert(data.size() <= megabytes(16)); + XRPL_ASSERT(data.size() <= megabytes(16)); std::uint8_t* raw = detail::slabber.allocate(data.size()); diff --git a/src/xrpld/shamap/detail/SHAMap.cpp b/src/xrpld/shamap/detail/SHAMap.cpp index e17f9346b85..c0ab6046476 100644 --- a/src/xrpld/shamap/detail/SHAMap.cpp +++ b/src/xrpld/shamap/detail/SHAMap.cpp @@ -101,10 +101,10 @@ SHAMap::dirtyUp( // stack is a path of inner nodes up to, but not including, child // child can be an inner node or a leaf - assert( + XRPL_ASSERT( (state_ != SHAMapState::Synching) && (state_ != SHAMapState::Immutable)); - assert(child && (child->cowid() == cowid_)); + XRPL_ASSERT(child && (child->cowid() == cowid_)); while (!stack.empty()) { @@ -112,10 +112,10 @@ SHAMap::dirtyUp( std::dynamic_pointer_cast(stack.top().first); SHAMapNodeID nodeID = stack.top().second; stack.pop(); - assert(node != nullptr); + XRPL_ASSERT(node != nullptr); int branch = selectBranch(nodeID, target); - assert(branch >= 0); + XRPL_ASSERT(branch >= 0); node = unshareNode(std::move(node), nodeID); node->setChild(branch, std::move(child)); @@ -127,7 +127,7 @@ SHAMap::dirtyUp( SHAMapLeafNode* SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const { - assert(stack == nullptr || stack->empty()); + XRPL_ASSERT(stack == nullptr || stack->empty()); auto inNode = root_; SHAMapNodeID nodeID; @@ -162,7 +162,7 @@ SHAMap::findKey(uint256 const& id) const std::shared_ptr SHAMap::fetchNodeFromDB(SHAMapHash const& hash) const { - assert(backed_); + XRPL_ASSERT(backed_); auto obj = f_.db().fetchNodeObject(hash.as_uint256(), ledgerSeq_); return finishFetch(hash, obj); } @@ -172,7 +172,7 @@ SHAMap::finishFetch( SHAMapHash const& hash, std::shared_ptr const& object) const { - assert(backed_); + XRPL_ASSERT(backed_); try { @@ -360,9 +360,9 @@ SHAMap::descend( int branch, SHAMapSyncFilter* filter) const { - assert(parent->isInner()); - assert((branch >= 0) && (branch < branchFactor)); - assert(!parent->isEmptyBranch(branch)); + XRPL_ASSERT(parent->isInner()); + XRPL_ASSERT((branch >= 0) && (branch < branchFactor)); + XRPL_ASSERT(!parent->isEmptyBranch(branch)); SHAMapTreeNode* child = parent->getChildPointer(branch); @@ -430,11 +430,11 @@ std::shared_ptr SHAMap::unshareNode(std::shared_ptr node, SHAMapNodeID const& nodeID) { // make sure the node is suitable for the intended operation (copy on write) - assert(node->cowid() <= cowid_); + XRPL_ASSERT(node->cowid() <= cowid_); if (node->cowid() != cowid_) { // have a CoW - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); node = std::static_pointer_cast(node->clone(cowid_)); if (nodeID.isRoot()) root_ = node; @@ -467,7 +467,7 @@ SHAMap::belowHelper( if (!inner->isEmptyBranch(i)) { node = descendThrow(inner, i); - assert(!stack.empty()); + XRPL_ASSERT(!stack.empty()); if (node->isLeaf()) { auto n = std::static_pointer_cast(node); @@ -531,7 +531,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const if (!nextNode) { - assert(false); + XRPL_UNREACHABLE(); return no_item; } @@ -541,14 +541,14 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const // An inner node must have at least one leaf // below it, unless it's the root_ auto const leaf = static_cast(node); - assert(leaf->peekItem() || (leaf == root_.get())); + XRPL_ASSERT(leaf->peekItem() || (leaf == root_.get())); return leaf->peekItem(); } SHAMapLeafNode const* SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const { - assert(stack.empty()); + XRPL_ASSERT(stack.empty()); SHAMapLeafNode* node = firstBelow(root_, stack); if (!node) { @@ -562,13 +562,13 @@ SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const SHAMapLeafNode const* SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const { - assert(!stack.empty()); - assert(stack.top().first->isLeaf()); + XRPL_ASSERT(!stack.empty()); + XRPL_ASSERT(stack.top().first->isLeaf()); stack.pop(); while (!stack.empty()) { auto [node, nodeID] = stack.top(); - assert(!node->isLeaf()); + XRPL_ASSERT(!node->isLeaf()); auto inner = std::static_pointer_cast(node); for (auto i = selectBranch(nodeID, id) + 1; i < branchFactor; ++i) { @@ -578,7 +578,7 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const auto leaf = firstBelow(node, stack, i); if (!leaf) Throw(type_, id); - assert(leaf->isLeaf()); + XRPL_ASSERT(leaf->isLeaf()); return leaf; } } @@ -696,7 +696,7 @@ bool SHAMap::delItem(uint256 const& id) { // delete the item with this ID - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -775,8 +775,8 @@ SHAMap::addGiveItem( SHAMapNodeType type, boost::intrusive_ptr item) { - assert(state_ != SHAMapState::Immutable); - assert(type != SHAMapNodeType::tnINNER); + XRPL_ASSERT(state_ != SHAMapState::Immutable); + XRPL_ASSERT(type != SHAMapNodeType::tnINNER); // add the specified item, does not update uint256 tag = item->key(); @@ -802,7 +802,7 @@ SHAMap::addGiveItem( // easy case, we end on an inner node auto inner = std::static_pointer_cast(node); int branch = selectBranch(nodeID, tag); - assert(inner->isEmptyBranch(branch)); + XRPL_ASSERT(inner->isEmptyBranch(branch)); inner->setChild(branch, makeTypedLeaf(type, std::move(item), cowid_)); } else @@ -811,7 +811,7 @@ SHAMap::addGiveItem( // items auto leaf = std::static_pointer_cast(node); auto otherItem = leaf->peekItem(); - assert(otherItem && (tag != otherItem->key())); + XRPL_ASSERT(otherItem && (tag != otherItem->key())); node = std::make_shared(node->cowid()); @@ -829,7 +829,7 @@ SHAMap::addGiveItem( } // we can add the two leaf nodes here - assert(node->isInner()); + XRPL_ASSERT(node->isInner()); auto inner = static_cast(node.get()); inner->setChild(b1, makeTypedLeaf(type, std::move(item), cowid_)); @@ -868,7 +868,7 @@ SHAMap::updateGiveItem( // can't change the tag but can change the hash uint256 tag = item->key(); - assert(state_ != SHAMapState::Immutable); + XRPL_ASSERT(state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(tag, &stack); @@ -882,7 +882,7 @@ SHAMap::updateGiveItem( if (!node || (node->peekItem()->key() != tag)) { - assert(false); + XRPL_UNREACHABLE(); return false; } @@ -927,7 +927,7 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) if (newRoot) { root_ = newRoot; - assert(root_->getHash() == hash); + XRPL_ASSERT(root_->getHash() == hash); return true; } @@ -949,8 +949,8 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) std::shared_ptr SHAMap::writeNode(NodeObjectType t, std::shared_ptr node) const { - assert(node->cowid() == 0); - assert(backed_); + XRPL_ASSERT(node->cowid() == 0); + XRPL_ASSERT(backed_); canonicalize(node->getHash(), node); @@ -970,7 +970,7 @@ SHAMap::preFlushNode(std::shared_ptr node) const { // A shared node should never need to be flushed // because that would imply someone modified it - assert(node->cowid() != 0); + XRPL_ASSERT(node->cowid() != 0); if (node->cowid() != cowid_) { @@ -998,7 +998,7 @@ SHAMap::flushDirty(NodeObjectType t) int SHAMap::walkSubTree(bool doWrite, NodeObjectType t) { - assert(!doWrite || backed_); + XRPL_ASSERT(!doWrite || backed_); int flushed = 0; @@ -1073,7 +1073,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // flush this leaf ++flushed; - assert(node->cowid() == cowid_); + XRPL_ASSERT(node->cowid() == cowid_); child->updateHash(); child->unshare(); @@ -1106,7 +1106,7 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) stack.pop(); // Hook this inner node to its parent - assert(parent->cowid() == cowid_); + XRPL_ASSERT(parent->cowid() == cowid_); parent->shareChild(pos, node); // Continue with parent's next child, if any @@ -1150,7 +1150,7 @@ SHAMap::dump(bool hash) const auto child = inner->getChildPointer(i); if (child) { - assert(child->getHash() == inner->getChildHash(i)); + XRPL_ASSERT(child->getHash() == inner->getChildHash(i)); stack.push({child, nodeID.getChildNodeID(i)}); } } @@ -1167,7 +1167,7 @@ std::shared_ptr SHAMap::cacheLookup(SHAMapHash const& hash) const { auto ret = f_.getTreeNodeCache(ledgerSeq_)->fetch(hash.as_uint256()); - assert(!ret || !ret->cowid()); + XRPL_ASSERT(!ret || !ret->cowid()); return ret; } @@ -1176,9 +1176,9 @@ SHAMap::canonicalize( SHAMapHash const& hash, std::shared_ptr& node) const { - assert(backed_); - assert(node->cowid() == 0); - assert(node->getHash() == hash); + XRPL_ASSERT(backed_); + XRPL_ASSERT(node->cowid() == 0); + XRPL_ASSERT(node->getHash() == hash); f_.getTreeNodeCache(ledgerSeq_) ->canonicalize_replace_client(hash.as_uint256(), node); @@ -1189,8 +1189,8 @@ SHAMap::invariants() const { (void)getHash(); // update node hashes auto node = root_.get(); - assert(node != nullptr); - assert(!node->isLeaf()); + XRPL_ASSERT(node != nullptr); + XRPL_ASSERT(!node->isLeaf()); SharedPtrNodeStack stack; for (auto leaf = peekFirstItem(stack); leaf != nullptr; leaf = peekNextItem(leaf->peekItem()->key(), stack)) diff --git a/src/xrpld/shamap/detail/SHAMapDelta.cpp b/src/xrpld/shamap/detail/SHAMapDelta.cpp index 0dcb861a63f..cb7ec09be78 100644 --- a/src/xrpld/shamap/detail/SHAMapDelta.cpp +++ b/src/xrpld/shamap/detail/SHAMapDelta.cpp @@ -128,7 +128,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const // many differences throws on corrupt tables or missing nodes CAUTION: // otherMap is not locked and must be immutable - assert(isValid() && otherMap.isValid()); + XRPL_ASSERT(isValid() && otherMap.isValid()); if (getHash() == otherMap.getHash()) return true; @@ -145,7 +145,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const if (!ourNode || !otherNode) { - assert(false); + XRPL_UNREACHABLE(); Throw(type_, uint256()); } @@ -226,7 +226,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const } } else - assert(false); + XRPL_UNREACHABLE(); } return true; @@ -323,7 +323,7 @@ SHAMap::walkMapParallel( { std::shared_ptr node = std::move(nodeStack.top()); - assert(node); + XRPL_ASSERT(node); nodeStack.pop(); for (int i = 0; i < 16; ++i) diff --git a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp index 99155a6401f..f2cd02267b6 100644 --- a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp @@ -225,7 +225,7 @@ SHAMapInnerNode::updateHashDeep() void SHAMapInnerNode::serializeForWire(Serializer& s) const { - assert(!isEmpty()); + XRPL_ASSERT(!isEmpty()); // If the node is sparse, then only send non-empty branches: if (getBranchCount() < 12) @@ -249,7 +249,7 @@ SHAMapInnerNode::serializeForWire(Serializer& s) const void SHAMapInnerNode::serializeWithPrefix(Serializer& s) const { - assert(!isEmpty()); + XRPL_ASSERT(!isEmpty()); s.add32(HashPrefix::innerNode); iterChildren( @@ -274,9 +274,9 @@ SHAMapInnerNode::getString(const SHAMapNodeID& id) const void SHAMapInnerNode::setChild(int m, std::shared_ptr child) { - assert((m >= 0) && (m < branchFactor)); - assert(cowid_ != 0); - assert(child.get() != this); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); + XRPL_ASSERT(cowid_ != 0); + XRPL_ASSERT(child.get() != this); auto const dstIsBranch = [&] { if (child) @@ -303,27 +303,27 @@ SHAMapInnerNode::setChild(int m, std::shared_ptr child) hash_.zero(); - assert(getBranchCount() <= hashesAndChildren_.capacity()); + XRPL_ASSERT(getBranchCount() <= hashesAndChildren_.capacity()); } // finished modifying, now make shareable void SHAMapInnerNode::shareChild(int m, std::shared_ptr const& child) { - assert((m >= 0) && (m < branchFactor)); - assert(cowid_ != 0); - assert(child); - assert(child.get() != this); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); + XRPL_ASSERT(cowid_ != 0); + XRPL_ASSERT(child); + XRPL_ASSERT(child.get() != this); - assert(!isEmptyBranch(m)); + XRPL_ASSERT(!isEmptyBranch(m)); hashesAndChildren_.getChildren()[*getChildIndex(m)] = child; } SHAMapTreeNode* SHAMapInnerNode::getChildPointer(int branch) { - assert(branch >= 0 && branch < branchFactor); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -335,8 +335,8 @@ SHAMapInnerNode::getChildPointer(int branch) std::shared_ptr SHAMapInnerNode::getChild(int branch) { - assert(branch >= 0 && branch < branchFactor); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -348,7 +348,7 @@ SHAMapInnerNode::getChild(int branch) SHAMapHash const& SHAMapInnerNode::getChildHash(int m) const { - assert((m >= 0) && (m < branchFactor)); + XRPL_ASSERT((m >= 0) && (m < branchFactor)); if (auto const i = getChildIndex(m)) return hashesAndChildren_.getHashes()[*i]; @@ -360,12 +360,12 @@ SHAMapInnerNode::canonicalizeChild( int branch, std::shared_ptr node) { - assert(branch >= 0 && branch < branchFactor); - assert(node); - assert(!isEmptyBranch(branch)); + XRPL_ASSERT(branch >= 0 && branch < branchFactor); + XRPL_ASSERT(node); + XRPL_ASSERT(!isEmptyBranch(branch)); auto const childIndex = *getChildIndex(branch); auto [_, hashes, children] = hashesAndChildren_.getHashesAndChildren(); - assert(node->getHash() == hashes[childIndex]); + XRPL_ASSERT(node->getHash() == hashes[childIndex]); packed_spinlock sl(lock_, childIndex); std::lock_guard lock(sl); @@ -395,7 +395,7 @@ SHAMapInnerNode::invariants(bool is_root) const auto const branchCount = getBranchCount(); for (int i = 0; i < branchCount; ++i) { - assert(hashes[i].isNonZero()); + XRPL_ASSERT(hashes[i].isNonZero()); if (children[i] != nullptr) children[i]->invariants(); ++count; @@ -407,24 +407,24 @@ SHAMapInnerNode::invariants(bool is_root) const { if (hashes[i].isNonZero()) { - assert((isBranch_ & (1 << i)) != 0); + XRPL_ASSERT((isBranch_ & (1 << i)) != 0); if (children[i] != nullptr) children[i]->invariants(); ++count; } else { - assert((isBranch_ & (1 << i)) == 0); + XRPL_ASSERT((isBranch_ & (1 << i)) == 0); } } } if (!is_root) { - assert(hash_.isNonZero()); - assert(count >= 1); + XRPL_ASSERT(hash_.isNonZero()); + XRPL_ASSERT(count >= 1); } - assert((count == 0) ? hash_.isZero() : hash_.isNonZero()); + XRPL_ASSERT((count == 0) ? hash_.isZero() : hash_.isNonZero()); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp index 972919a9bda..5652f5d403b 100644 --- a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp @@ -28,7 +28,7 @@ SHAMapLeafNode::SHAMapLeafNode( std::uint32_t cowid) : SHAMapTreeNode(cowid), item_(std::move(item)) { - assert(item_->size() >= 12); + XRPL_ASSERT(item_->size() >= 12); } SHAMapLeafNode::SHAMapLeafNode( @@ -37,7 +37,7 @@ SHAMapLeafNode::SHAMapLeafNode( SHAMapHash const& hash) : SHAMapTreeNode(cowid, hash), item_(std::move(item)) { - assert(item_->size() >= 12); + XRPL_ASSERT(item_->size() >= 12); } boost::intrusive_ptr const& @@ -49,7 +49,7 @@ SHAMapLeafNode::peekItem() const bool SHAMapLeafNode::setItem(boost::intrusive_ptr item) { - assert(cowid_ != 0); + XRPL_ASSERT(cowid_ != 0); item_ = std::move(item); auto const oldHash = hash_; @@ -87,8 +87,8 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const void SHAMapLeafNode::invariants(bool) const { - assert(hash_.isNonZero()); - assert(item_ != nullptr); + XRPL_ASSERT(hash_.isNonZero()); + XRPL_ASSERT(item_ != nullptr); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapNodeID.cpp b/src/xrpld/shamap/detail/SHAMapNodeID.cpp index 5cbd095e7a9..5458781f50d 100644 --- a/src/xrpld/shamap/detail/SHAMapNodeID.cpp +++ b/src/xrpld/shamap/detail/SHAMapNodeID.cpp @@ -19,10 +19,10 @@ #include #include +#include #include #include #include -#include namespace ripple { @@ -57,8 +57,8 @@ depthMask(unsigned int depth) SHAMapNodeID::SHAMapNodeID(unsigned int depth, uint256 const& hash) : id_(hash), depth_(depth) { - assert(depth <= SHAMap::leafDepth); - assert(id_ == (id_ & depthMask(depth))); + XRPL_ASSERT(depth <= SHAMap::leafDepth); + XRPL_ASSERT(id_ == (id_ & depthMask(depth))); } std::string @@ -73,7 +73,7 @@ SHAMapNodeID::getRawString() const SHAMapNodeID SHAMapNodeID::getChildNodeID(unsigned int m) const { - assert(m < SHAMap::branchFactor); + XRPL_ASSERT(m < SHAMap::branchFactor); // A SHAMap has exactly 65 levels, so nodes must not exceed that // depth; if they do, this breaks the invariant of never allowing @@ -83,7 +83,7 @@ SHAMapNodeID::getChildNodeID(unsigned int m) const // We throw (but never assert) if the node is at level 64, since // entries at that depth are leaf nodes and have no children and even // constructing a child node from them would break the above invariant. - assert(depth_ <= SHAMap::leafDepth); + XRPL_ASSERT(depth_ <= SHAMap::leafDepth); if (depth_ >= SHAMap::leafDepth) Throw( @@ -128,14 +128,14 @@ selectBranch(SHAMapNodeID const& id, uint256 const& hash) else branch >>= 4; - assert(branch < SHAMap::branchFactor); + XRPL_ASSERT(branch < SHAMap::branchFactor); return branch; } SHAMapNodeID SHAMapNodeID::createID(int depth, uint256 const& key) { - assert((depth >= 0) && (depth < 65)); + XRPL_ASSERT((depth >= 0) && (depth < 65)); return SHAMapNodeID(depth, key & depthMask(depth)); } diff --git a/src/xrpld/shamap/detail/SHAMapSync.cpp b/src/xrpld/shamap/detail/SHAMapSync.cpp index 02d548be24e..1e2194528cd 100644 --- a/src/xrpld/shamap/detail/SHAMapSync.cpp +++ b/src/xrpld/shamap/detail/SHAMapSync.cpp @@ -316,8 +316,8 @@ SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) std::vector> SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) { - assert(root_->getHash().isNonZero()); - assert(max > 0); + XRPL_ASSERT(root_->getHash().isNonZero()); + XRPL_ASSERT(max > 0); MissingNodes mn( max, @@ -376,7 +376,7 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // This is a node we are continuing to process fullBelow = fullBelow && was; // was and still is } - assert(node); + XRPL_ASSERT(node); } } @@ -407,7 +407,7 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // Resume at the top of the stack pos = mn.stack_.top(); mn.stack_.pop(); - assert(node != nullptr); + XRPL_ASSERT(node != nullptr); } } @@ -534,11 +534,11 @@ SHAMap::addRootNode( if (root_->getHash().isNonZero()) { JLOG(journal_.trace()) << "got root node, already have one"; - assert(root_->getHash() == hash); + XRPL_ASSERT(root_->getHash() == hash); return SHAMapAddNode::duplicate(); } - assert(cowid_ >= 1); + XRPL_ASSERT(cowid_ >= 1); auto node = SHAMapTreeNode::makeFromWire(rootNode); if (!node || node->getHash() != hash) return SHAMapAddNode::invalid(); @@ -572,7 +572,7 @@ SHAMap::addKnownNode( Slice const& rawNode, SHAMapSyncFilter* filter) { - assert(!node.isRoot()); + XRPL_ASSERT(!node.isRoot()); if (!isSynching()) { @@ -589,7 +589,7 @@ SHAMap::addKnownNode( (iNodeID.getDepth() < node.getDepth())) { int branch = selectBranch(iNodeID, node.getNodeID()); - assert(branch >= 0); + XRPL_ASSERT(branch >= 0); auto inner = static_cast(iNode); if (inner->isEmptyBranch(branch)) { diff --git a/src/xrpld/shamap/detail/ShardFamily.cpp b/src/xrpld/shamap/detail/ShardFamily.cpp index aef4c6cde0a..0429e12482b 100644 --- a/src/xrpld/shamap/detail/ShardFamily.cpp +++ b/src/xrpld/shamap/detail/ShardFamily.cpp @@ -30,7 +30,7 @@ static NodeStore::Database& getShardStore(Application& app) { auto const dbPtr = app.getShardStore(); - assert(dbPtr); + XRPL_ASSERT(dbPtr); return *dbPtr; } diff --git a/src/xrpld/shamap/detail/TaggedPointer.ipp b/src/xrpld/shamap/detail/TaggedPointer.ipp index 309913c79c0..c7d47d65e6a 100644 --- a/src/xrpld/shamap/detail/TaggedPointer.ipp +++ b/src/xrpld/shamap/detail/TaggedPointer.ipp @@ -79,14 +79,14 @@ constexpr auto chunksPerBlock = [[nodiscard]] inline std::uint8_t numAllocatedChildren(std::uint8_t n) { - assert(n <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT(n <= SHAMapInnerNode::branchFactor); return *std::lower_bound(boundaries.begin(), boundaries.end(), n); } [[nodiscard]] inline std::size_t boundariesIndex(std::uint8_t numChildren) { - assert(numChildren <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT(numChildren <= SHAMapInnerNode::branchFactor); return std::distance( boundaries.begin(), std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); @@ -156,7 +156,7 @@ allocateArrays(std::uint8_t numChildren) inline void deallocateArrays(std::uint8_t boundaryIndex, void* p) { - assert(isFromArrayFuns[boundaryIndex](p)); + XRPL_ASSERT(isFromArrayFuns[boundaryIndex](p)); freeArrayFuns[boundaryIndex](p); } @@ -270,8 +270,8 @@ TaggedPointer::getChildIndex(std::uint16_t isBranch, int i) const inline TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t numChildren) { auto [tag, p] = allocateArrays(numChildren); - assert(tag < boundaries.size()); - assert( + XRPL_ASSERT(tag < boundaries.size()); + XRPL_ASSERT( (reinterpret_cast(p) & ptrMask) == reinterpret_cast(p)); tp_ = reinterpret_cast(p) + tag; @@ -283,7 +283,7 @@ inline TaggedPointer::TaggedPointer( std::uint16_t dstBranches, std::uint8_t toAllocate) { - assert(toAllocate >= popcnt16(dstBranches)); + XRPL_ASSERT(toAllocate >= popcnt16(dstBranches)); if (other.capacity() == numAllocatedChildren(toAllocate)) { @@ -428,7 +428,7 @@ inline TaggedPointer::TaggedPointer( } } // If sparse, may need to run additional constructors - assert(!dstIsDense || dstIndex == dstNumAllocated); + XRPL_ASSERT(!dstIsDense || dstIndex == dstNumAllocated); for (int i = dstIndex; i < dstNumAllocated; ++i) { new (&dstHashes[i]) SHAMapHash{}; From 3666a843c31ed1dd84cc7029995da8e44db6c721 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Thu, 27 Jun 2024 12:57:47 +0100 Subject: [PATCH 05/18] Add error message when Antithesis enabled without Debug --- include/xrpl/basics/instrumentation.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/xrpl/basics/instrumentation.h b/include/xrpl/basics/instrumentation.h index ee3e5e0e99f..7405428bdc5 100644 --- a/include/xrpl/basics/instrumentation.h +++ b/include/xrpl/basics/instrumentation.h @@ -23,8 +23,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #ifdef ENABLE_VOIDSTAR +#ifndef NDEBUG #include #else +#pragma GCC error "Antithesis instrumentation requires Debug build" +#endif +#else #define ALWAYS(cond, message, ...) #define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message&& cond) #define SOMETIMES(cond, message, ...) From c430312386044f354c266a799558bce385315ac1 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 2 Jul 2024 17:30:35 +0100 Subject: [PATCH 06/18] Move instrumentation to beast, minor improvements --- Builds/levelization/results/loops.txt | 3 -- Builds/levelization/results/ordering.txt | 41 ------------------- include/xrpl/basics/Buffer.h | 2 +- include/xrpl/basics/FeeUnits.h | 2 +- include/xrpl/basics/MathUtilities.h | 2 +- include/xrpl/basics/SlabAllocator.h | 2 +- include/xrpl/basics/Slice.h | 2 +- include/xrpl/basics/base_uint.h | 2 +- .../xrpl/basics/partitioned_unordered_map.h | 2 +- include/xrpl/basics/random.h | 2 +- include/xrpl/basics/spinlock.h | 2 +- include/xrpl/beast/asio/io_latency_probe.h | 2 +- include/xrpl/beast/clock/manual_clock.h | 2 +- include/xrpl/beast/core/LexicalCast.h | 2 +- include/xrpl/beast/net/IPAddress.h | 2 +- include/xrpl/beast/net/IPAddressV6.h | 2 +- include/xrpl/beast/utility/Journal.h | 2 +- .../utility}/instrumentation.h | 13 +++--- include/xrpl/beast/utility/rngfill.h | 2 +- include/xrpl/protocol/Issue.h | 2 +- include/xrpl/protocol/MultiApiJson.h | 2 +- include/xrpl/protocol/Rate.h | 2 +- include/xrpl/protocol/STBlob.h | 2 +- include/xrpl/protocol/STObject.h | 2 +- include/xrpl/protocol/STPathSet.h | 2 +- include/xrpl/protocol/STValidation.h | 2 +- include/xrpl/protocol/Serializer.h | 2 +- include/xrpl/protocol/detail/b58_utils.h | 2 +- include/xrpl/resource/detail/Entry.h | 2 +- include/xrpl/resource/detail/Key.h | 2 +- include/xrpl/resource/detail/Logic.h | 2 +- include/xrpl/server/detail/BaseHTTPPeer.h | 2 +- include/xrpl/server/detail/BasePeer.h | 2 +- include/xrpl/server/detail/BaseWSPeer.h | 2 +- src/libxrpl/basics/Log.cpp | 2 +- src/libxrpl/basics/Number.cpp | 2 +- src/libxrpl/basics/ResolverAsio.cpp | 2 +- src/libxrpl/basics/contract.cpp | 2 +- .../beast/clock/basic_seconds_clock.cpp | 2 +- src/libxrpl/beast/core/SemanticVersion.cpp | 2 +- src/libxrpl/beast/insight/StatsDCollector.cpp | 2 +- .../beast/utility/src/beast_Journal.cpp | 2 +- .../utility/src/beast_PropertyStream.cpp | 2 +- src/libxrpl/crypto/RFC1751.cpp | 2 +- src/libxrpl/crypto/csprng.cpp | 2 +- src/libxrpl/json/Object.cpp | 2 +- src/libxrpl/json/json_writer.cpp | 2 +- src/libxrpl/protocol/ErrorCodes.cpp | 2 +- src/libxrpl/protocol/Indexes.cpp | 2 +- src/libxrpl/protocol/Quality.cpp | 2 +- src/libxrpl/protocol/SField.cpp | 2 +- src/libxrpl/protocol/STBase.cpp | 2 +- src/libxrpl/protocol/STParsedJSON.cpp | 2 +- src/libxrpl/protocol/tokens.cpp | 2 +- src/libxrpl/resource/Consumer.cpp | 2 +- src/test/csf/Histogram.h | 2 +- src/test/jtx/impl/amount.cpp | 2 +- src/test/overlay/short_read_test.cpp | 2 +- src/test/unit_test/multi_runner.cpp | 2 +- src/xrpld/app/ledger/Ledger.cpp | 2 +- src/xrpld/app/ledger/OpenLedger.h | 2 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 2 +- src/xrpld/app/main/NodeStoreScheduler.cpp | 2 +- src/xrpld/app/misc/detail/WorkFile.h | 2 +- src/xrpld/app/tx/detail/ApplyContext.cpp | 2 +- src/xrpld/consensus/LedgerTrie.h | 2 +- src/xrpld/core/Pg.cpp | 2 +- src/xrpld/core/detail/Job.cpp | 2 +- src/xrpld/core/detail/LoadEvent.cpp | 2 +- src/xrpld/core/detail/Workers.cpp | 2 +- src/xrpld/ledger/ReadView.h | 2 +- src/xrpld/ledger/detail/ApplyStateTable.cpp | 2 +- src/xrpld/ledger/detail/ApplyView.cpp | 2 +- src/xrpld/ledger/detail/ApplyViewImpl.cpp | 2 +- src/xrpld/ledger/detail/PaymentSandbox.cpp | 2 +- src/xrpld/ledger/detail/View.cpp | 2 +- .../nodestore/backend/CassandraFactory.cpp | 2 +- src/xrpld/nodestore/backend/NuDBFactory.cpp | 2 +- src/xrpld/nodestore/detail/DecodedBlob.cpp | 2 +- src/xrpld/nodestore/detail/EncodedBlob.h | 2 +- src/xrpld/nodestore/detail/TaskQueue.cpp | 2 +- src/xrpld/overlay/detail/OverlayImpl.h | 2 +- src/xrpld/overlay/detail/ProtocolMessage.h | 2 +- src/xrpld/overlay/detail/TrafficCount.h | 2 +- src/xrpld/peerfinder/detail/Handouts.h | 2 +- src/xrpld/rpc/Status.h | 2 +- src/xrpld/shamap/SHAMap.h | 2 +- src/xrpld/shamap/SHAMapItem.h | 2 +- src/xrpld/shamap/detail/SHAMapNodeID.cpp | 2 +- 89 files changed, 92 insertions(+), 137 deletions(-) rename include/xrpl/{basics => beast/utility}/instrumentation.h (88%) diff --git a/Builds/levelization/results/loops.txt b/Builds/levelization/results/loops.txt index 78e4b1d2aca..ee7e6fd3bc6 100644 --- a/Builds/levelization/results/loops.txt +++ b/Builds/levelization/results/loops.txt @@ -4,9 +4,6 @@ Loop: test.jtx test.toplevel Loop: test.jtx test.unit_test test.unit_test == test.jtx -Loop: xrpl.basics xrpl.beast - xrpl.basics > xrpl.beast - Loop: xrpl.basics xrpl.json xrpl.json ~= xrpl.basics diff --git a/Builds/levelization/results/ordering.txt b/Builds/levelization/results/ordering.txt index 3e04572d36c..87f9b03a54e 100644 --- a/Builds/levelization/results/ordering.txt +++ b/Builds/levelization/results/ordering.txt @@ -1,21 +1,14 @@ libxrpl.basics > xrpl.basics -libxrpl.basics > xrpl.beast libxrpl.basics > xrpl.protocol -libxrpl.beast > xrpl.basics -libxrpl.beast > xrpl.beast libxrpl.crypto > xrpl.basics libxrpl.json > xrpl.basics -libxrpl.json > xrpl.beast libxrpl.json > xrpl.json libxrpl.protocol > xrpl.basics -libxrpl.protocol > xrpl.beast libxrpl.protocol > xrpl.json libxrpl.protocol > xrpl.protocol libxrpl.resource > xrpl.basics -libxrpl.resource > xrpl.beast libxrpl.resource > xrpl.resource libxrpl.server > xrpl.basics -libxrpl.server > xrpl.beast libxrpl.server > xrpl.json libxrpl.server > xrpl.protocol libxrpl.server > xrpl.server @@ -24,7 +17,6 @@ test.app > test.rpc test.app > test.toplevel test.app > test.unit_test test.app > xrpl.basics -test.app > xrpl.beast test.app > xrpld.app test.app > xrpld.core test.app > xrpld.ledger @@ -36,21 +28,17 @@ test.app > xrpl.resource test.basics > test.jtx test.basics > test.unit_test test.basics > xrpl.basics -test.basics > xrpl.beast test.basics > xrpld.perflog test.basics > xrpld.rpc test.basics > xrpl.json test.basics > xrpl.protocol test.beast > xrpl.basics -test.beast > xrpl.beast test.conditions > xrpl.basics -test.conditions > xrpl.beast test.conditions > xrpld.conditions test.consensus > test.csf test.consensus > test.toplevel test.consensus > test.unit_test test.consensus > xrpl.basics -test.consensus > xrpl.beast test.consensus > xrpld.app test.consensus > xrpld.consensus test.consensus > xrpld.ledger @@ -58,21 +46,17 @@ test.core > test.jtx test.core > test.toplevel test.core > test.unit_test test.core > xrpl.basics -test.core > xrpl.beast test.core > xrpld.core test.core > xrpld.perflog test.core > xrpl.json test.core > xrpl.server test.csf > xrpl.basics -test.csf > xrpl.beast test.csf > xrpld.consensus test.csf > xrpl.json test.csf > xrpl.protocol test.json > test.jtx -test.json > xrpl.beast test.json > xrpl.json test.jtx > xrpl.basics -test.jtx > xrpl.beast test.jtx > xrpld.app test.jtx > xrpld.consensus test.jtx > xrpld.core @@ -86,7 +70,6 @@ test.jtx > xrpl.server test.ledger > test.jtx test.ledger > test.toplevel test.ledger > xrpl.basics -test.ledger > xrpl.beast test.ledger > xrpld.app test.ledger > xrpld.core test.ledger > xrpld.ledger @@ -99,7 +82,6 @@ test.nodestore > test.jtx test.nodestore > test.toplevel test.nodestore > test.unit_test test.nodestore > xrpl.basics -test.nodestore > xrpl.beast test.nodestore > xrpld.app test.nodestore > xrpld.core test.nodestore > xrpld.nodestore @@ -108,7 +90,6 @@ test.nodestore > xrpl.protocol test.overlay > test.jtx test.overlay > test.unit_test test.overlay > xrpl.basics -test.overlay > xrpl.beast test.overlay > xrpld.app test.overlay > xrpld.overlay test.overlay > xrpld.peerfinder @@ -117,24 +98,20 @@ test.overlay > xrpl.protocol test.peerfinder > test.beast test.peerfinder > test.unit_test test.peerfinder > xrpl.basics -test.peerfinder > xrpl.beast test.peerfinder > xrpld.core test.peerfinder > xrpld.peerfinder test.peerfinder > xrpl.protocol test.protocol > test.toplevel test.protocol > xrpl.basics -test.protocol > xrpl.beast test.protocol > xrpl.json test.protocol > xrpl.protocol test.resource > test.unit_test test.resource > xrpl.basics -test.resource > xrpl.beast test.resource > xrpl.resource test.rpc > test.jtx test.rpc > test.nodestore test.rpc > test.toplevel test.rpc > xrpl.basics -test.rpc > xrpl.beast test.rpc > xrpld.app test.rpc > xrpld.core test.rpc > xrpld.net @@ -148,7 +125,6 @@ test.server > test.jtx test.server > test.toplevel test.server > test.unit_test test.server > xrpl.basics -test.server > xrpl.beast test.server > xrpld.app test.server > xrpld.core test.server > xrpld.rpc @@ -156,29 +132,22 @@ test.server > xrpl.json test.server > xrpl.server test.shamap > test.unit_test test.shamap > xrpl.basics -test.shamap > xrpl.beast test.shamap > xrpld.nodestore test.shamap > xrpld.shamap test.shamap > xrpl.protocol test.toplevel > test.csf test.toplevel > xrpl.json test.unit_test > xrpl.basics -test.unit_test > xrpl.beast -xrpl.json > xrpl.beast xrpl.protocol > xrpl.basics -xrpl.protocol > xrpl.beast xrpl.protocol > xrpl.json xrpl.resource > xrpl.basics -xrpl.resource > xrpl.beast xrpl.resource > xrpl.json xrpl.resource > xrpl.protocol xrpl.server > xrpl.basics -xrpl.server > xrpl.beast xrpl.server > xrpl.json xrpl.server > xrpl.protocol xrpld.app > test.unit_test xrpld.app > xrpl.basics -xrpld.app > xrpl.beast xrpld.app > xrpld.conditions xrpld.app > xrpld.consensus xrpld.app > xrpld.perflog @@ -188,31 +157,25 @@ xrpld.app > xrpl.resource xrpld.conditions > xrpl.basics xrpld.conditions > xrpl.protocol xrpld.consensus > xrpl.basics -xrpld.consensus > xrpl.beast xrpld.consensus > xrpl.json xrpld.consensus > xrpl.protocol xrpld.core > xrpl.basics -xrpld.core > xrpl.beast xrpld.core > xrpl.json xrpld.core > xrpl.protocol xrpld.ledger > xrpl.basics -xrpld.ledger > xrpl.beast xrpld.ledger > xrpld.core xrpld.ledger > xrpl.json xrpld.ledger > xrpl.protocol xrpld.net > xrpl.basics -xrpld.net > xrpl.beast xrpld.net > xrpl.json xrpld.net > xrpl.protocol xrpld.net > xrpl.resource xrpld.nodestore > xrpl.basics -xrpld.nodestore > xrpl.beast xrpld.nodestore > xrpld.core xrpld.nodestore > xrpld.unity xrpld.nodestore > xrpl.json xrpld.nodestore > xrpl.protocol xrpld.overlay > xrpl.basics -xrpld.overlay > xrpl.beast xrpld.overlay > xrpld.core xrpld.overlay > xrpld.peerfinder xrpld.overlay > xrpl.json @@ -220,16 +183,13 @@ xrpld.overlay > xrpl.protocol xrpld.overlay > xrpl.resource xrpld.overlay > xrpl.server xrpld.peerfinder > xrpl.basics -xrpld.peerfinder > xrpl.beast xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpl.protocol xrpld.perflog > xrpl.basics -xrpld.perflog > xrpl.beast xrpld.perflog > xrpld.nodestore xrpld.perflog > xrpl.json xrpld.perflog > xrpl.protocol xrpld.rpc > xrpl.basics -xrpld.rpc > xrpl.beast xrpld.rpc > xrpld.core xrpld.rpc > xrpld.ledger xrpld.rpc > xrpld.nodestore @@ -239,6 +199,5 @@ xrpld.rpc > xrpl.protocol xrpld.rpc > xrpl.resource xrpld.rpc > xrpl.server xrpld.shamap > xrpl.basics -xrpld.shamap > xrpl.beast xrpld.shamap > xrpld.nodestore xrpld.shamap > xrpl.protocol diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index dba09c18397..08e01b2f6be 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -21,7 +21,7 @@ #define RIPPLE_BASICS_BUFFER_H_INCLUDED #include -#include +#include #include #include #include diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 35f63d8485f..0a74d881089 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -20,7 +20,7 @@ #define BASICS_FEES_H_INCLUDED #include -#include +#include #include #include diff --git a/include/xrpl/basics/MathUtilities.h b/include/xrpl/basics/MathUtilities.h index 4e8e3751cd8..516c07f377f 100644 --- a/include/xrpl/basics/MathUtilities.h +++ b/include/xrpl/basics/MathUtilities.h @@ -43,7 +43,7 @@ namespace ripple { constexpr std::size_t calculatePercent(std::size_t count, std::size_t total) { - assert(total != 0); + assert(total != 0); // NOTE No XRPL_ASSERT here, because constexpr return ((std::min(count, total) * 100) + total - 1) / total; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index b155312b871..d247456f647 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED -#include #include +#include #include #include diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 7a04443e01e..86977d2a23a 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -21,8 +21,8 @@ #define RIPPLE_BASICS_SLICE_H_INCLUDED #include -#include #include +#include #include #include #include diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index 03302e16650..f204235ebee 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -29,9 +29,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index f6022a3b1b6..a7672a74140 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H #define RIPPLE_BASICS_PARTITIONED_UNORDERED_MAP_H -#include +#include #include #include #include diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index ea4eb431ec9..aa042979557 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED #define RIPPLE_BASICS_RANDOM_H_INCLUDED -#include +#include #include #include #include diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index fbf0995c055..b4c84e832f1 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -18,7 +18,7 @@ #ifndef RIPPLE_BASICS_SPINLOCK_H_INCLUDED #define RIPPLE_BASICS_SPINLOCK_H_INCLUDED -#include +#include #include #include #include diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index 578b1c0a40c..b38a228efbd 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -20,7 +20,7 @@ #ifndef BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED #define BEAST_ASIO_IO_LATENCY_PROBE_H_INCLUDED -#include +#include #include #include diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index a444b568667..59bbefc6a89 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -20,8 +20,8 @@ #ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED -#include #include +#include namespace beast { diff --git a/include/xrpl/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h index a7593b46378..747a3a0ae0a 100644 --- a/include/xrpl/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -20,7 +20,7 @@ #ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED #define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED -#include +#include #include #include diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 182bc9ef2ff..57019c5d099 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -20,11 +20,11 @@ #ifndef BEAST_NET_IPADDRESS_H_INCLUDED #define BEAST_NET_IPADDRESS_H_INCLUDED -#include #include #include #include #include +#include #include #include #include diff --git a/include/xrpl/beast/net/IPAddressV6.h b/include/xrpl/beast/net/IPAddressV6.h index ec2e38f60e5..83e4d6f8a32 100644 --- a/include/xrpl/beast/net/IPAddressV6.h +++ b/include/xrpl/beast/net/IPAddressV6.h @@ -20,7 +20,7 @@ #ifndef BEAST_NET_IPADDRESSV6_H_INCLUDED #define BEAST_NET_IPADDRESSV6_H_INCLUDED -#include +#include #include #include #include diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 5e4e6d09fe5..5adb416e611 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_JOURNAL_H_INCLUDED #define BEAST_UTILITY_JOURNAL_H_INCLUDED -#include +#include #include namespace beast { diff --git a/include/xrpl/basics/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h similarity index 88% rename from include/xrpl/basics/instrumentation.h rename to include/xrpl/beast/utility/instrumentation.h index 7405428bdc5..9a0beb0e5a5 100644 --- a/include/xrpl/basics/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -17,20 +17,19 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#ifndef RIPPLE_BASICS_INSTRUMENTATION_H_INCLUDED -#define RIPPLE_BASICS_INSTRUMENTATION_H_INCLUDED +#ifndef BEAST_UTILITY_INSTRUMENTATION_H_INCLUDED +#define BEAST_UTILITY_INSTRUMENTATION_H_INCLUDED #include #ifdef ENABLE_VOIDSTAR -#ifndef NDEBUG -#include -#else -#pragma GCC error "Antithesis instrumentation requires Debug build" +#ifdef NDEBUG +#error "Antithesis instrumentation requires Debug build" #endif +#include #else #define ALWAYS(cond, message, ...) -#define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message&& cond) +#define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message && (cond)) #define SOMETIMES(cond, message, ...) #define REACHABLE(message, ...) #define UNREACHABLE(message, ...) assert(message && false) diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index 9b4774af997..f049f84ee80 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -20,7 +20,7 @@ #ifndef BEAST_RANDOM_RNGFILL_H_INCLUDED #define BEAST_RANDOM_RNGFILL_H_INCLUDED -#include +#include #include #include #include diff --git a/include/xrpl/protocol/Issue.h b/include/xrpl/protocol/Issue.h index 3bdb4ba5804..16f88c0b1fa 100644 --- a/include/xrpl/protocol/Issue.h +++ b/include/xrpl/protocol/Issue.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_ISSUE_H_INCLUDED #define RIPPLE_PROTOCOL_ISSUE_H_INCLUDED -#include +#include #include #include diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index bea99ca889e..7b6a678d0fa 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/xrpl/protocol/Rate.h b/include/xrpl/protocol/Rate.h index 9315e4c742a..0910325126f 100644 --- a/include/xrpl/protocol/Rate.h +++ b/include/xrpl/protocol/Rate.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_RATE_H_INCLUDED #define RIPPLE_PROTOCOL_RATE_H_INCLUDED -#include +#include #include #include #include diff --git a/include/xrpl/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h index 105cb15a8d4..cfe4ab5af58 100644 --- a/include/xrpl/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index bd5bc5c0048..4e2094695c0 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index 80222e009ba..7792f59983f 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -21,7 +21,7 @@ #define RIPPLE_PROTOCOL_STPATHSET_H_INCLUDED #include -#include +#include #include #include #include diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index db6394d55d4..a28bcd3b6e5 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index a03a9eaf6ed..f72bd71a73a 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -25,9 +25,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index c191ea66527..bc07cac9b38 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -21,7 +21,7 @@ #define RIPPLE_PROTOCOL_B58_UTILS_H_INCLUDED #include -#include +#include #include #include diff --git a/include/xrpl/resource/detail/Entry.h b/include/xrpl/resource/detail/Entry.h index 7364c22c265..32ba77c6d35 100644 --- a/include/xrpl/resource/detail/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -21,9 +21,9 @@ #define RIPPLE_RESOURCE_ENTRY_H_INCLUDED #include -#include #include #include +#include #include #include diff --git a/include/xrpl/resource/detail/Key.h b/include/xrpl/resource/detail/Key.h index 772b1ed9191..f953d5103eb 100644 --- a/include/xrpl/resource/detail/Key.h +++ b/include/xrpl/resource/detail/Key.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_RESOURCE_KEY_H_INCLUDED #define RIPPLE_RESOURCE_KEY_H_INCLUDED -#include #include +#include #include namespace ripple { diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index 8067b714ed7..b06ebe2ff95 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -23,10 +23,10 @@ #include #include #include -#include #include #include #include +#include #include #include #include diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index d0a798d723a..d7e6da9e9e1 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -21,8 +21,8 @@ #define RIPPLE_SERVER_BASEHTTPPEER_H_INCLUDED #include -#include #include +#include #include #include #include diff --git a/include/xrpl/server/detail/BasePeer.h b/include/xrpl/server/detail/BasePeer.h index 2dbc4fb640e..97ad77f7f22 100644 --- a/include/xrpl/server/detail/BasePeer.h +++ b/include/xrpl/server/detail/BasePeer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_BASEPEER_H_INCLUDED #define RIPPLE_SERVER_BASEPEER_H_INCLUDED -#include #include +#include #include #include #include diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 2bd63053ffa..396f6151b93 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_BASEWSPEER_H_INCLUDED #define RIPPLE_SERVER_BASEWSPEER_H_INCLUDED -#include #include +#include #include #include #include diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 8f27dfe6d02..029fd8cfd62 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 729a0a1a776..8f7dccd26f9 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include #include diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 9570a44ccf2..b6351530596 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -19,9 +19,9 @@ #include #include -#include #include #include +#include #include #include #include diff --git a/src/libxrpl/basics/contract.cpp b/src/libxrpl/basics/contract.cpp index 76b98e59500..249c589ff83 100644 --- a/src/libxrpl/basics/contract.cpp +++ b/src/libxrpl/basics/contract.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index dbf33b17b22..3f3f819033b 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include #include #include diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index d20e53121e9..8ec30a4133f 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include #include #include +#include #include #include diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index da5b518c379..d5b52b92a34 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -17,7 +17,6 @@ */ //============================================================================== -#include #include #include #include @@ -26,6 +25,7 @@ #include #include #include +#include #include #include #include diff --git a/src/libxrpl/beast/utility/src/beast_Journal.cpp b/src/libxrpl/beast/utility/src/beast_Journal.cpp index 08dffb45524..5e907c8ec0c 100644 --- a/src/libxrpl/beast/utility/src/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/src/beast_Journal.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace beast { diff --git a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index 77dbaae1da0..436ec617560 100644 --- a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include #include #include #include diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index a7f7167442d..74e2dad3a09 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/crypto/csprng.cpp b/src/libxrpl/crypto/csprng.cpp index 04c72d7260c..948500734c0 100644 --- a/src/libxrpl/crypto/csprng.cpp +++ b/src/libxrpl/crypto/csprng.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include #include #include diff --git a/src/libxrpl/json/Object.cpp b/src/libxrpl/json/Object.cpp index 695f3a7a7d4..8e726f216f3 100644 --- a/src/libxrpl/json/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include #include namespace Json { diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 8a3a6d88b58..5f852b241f0 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 74e365570b8..073dabd6ec1 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index fa22d68d935..5389d12d8a9 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index 10468514bad..bdd0c84e54e 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/libxrpl/protocol/SField.cpp b/src/libxrpl/protocol/SField.cpp index 20513905752..22108f3c088 100644 --- a/src/libxrpl/protocol/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index 7ebe1322323..85607d5569d 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index b9d5e8da779..025ea164c8e 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -19,9 +19,9 @@ #include #include -#include #include #include +#include #include #include #include diff --git a/src/libxrpl/protocol/tokens.cpp b/src/libxrpl/protocol/tokens.cpp index 15d83937a25..695390e5b20 100644 --- a/src/libxrpl/protocol/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -27,8 +27,8 @@ #include -#include #include +#include #include #include diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index b97d7826450..fbe67ac7661 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/test/csf/Histogram.h b/src/test/csf/Histogram.h index e96e9b5affd..479f71cd241 100644 --- a/src/test/csf/Histogram.h +++ b/src/test/csf/Histogram.h @@ -19,7 +19,7 @@ #ifndef RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED #define RIPPLE_TEST_CSF_HISTOGRAM_H_INCLUDED -#include +#include #include #include #include diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 078d9d7c288..7232940c5f2 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -19,8 +19,8 @@ #include #include -#include #include +#include #include #include diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index 962b2bf0a61..4cda0cf1c6d 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -18,10 +18,10 @@ //============================================================================== #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 13d12c80002..223a2359a0d 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -19,8 +19,8 @@ #include -#include #include +#include #include diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index f36502d5209..19f1c62d29e 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -40,8 +40,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index 9869a60bd0b..b41113c7806 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -27,8 +27,8 @@ #include #include #include -#include #include +#include #include namespace ripple { diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 78fbb4fdc34..893a63fbf6f 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -47,8 +47,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/src/xrpld/app/main/NodeStoreScheduler.cpp b/src/xrpld/app/main/NodeStoreScheduler.cpp index 755bffeef02..f2dce5421f0 100644 --- a/src/xrpld/app/main/NodeStoreScheduler.cpp +++ b/src/xrpld/app/main/NodeStoreScheduler.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace ripple { diff --git a/src/xrpld/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h index db4c6d68133..9a7481a54cc 100644 --- a/src/xrpld/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index 6a273b985b5..147fe6932c8 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/consensus/LedgerTrie.h b/src/xrpld/consensus/LedgerTrie.h index a051b65c155..a254deed05a 100644 --- a/src/xrpld/consensus/LedgerTrie.h +++ b/src/xrpld/consensus/LedgerTrie.h @@ -21,7 +21,7 @@ #define RIPPLE_APP_CONSENSUS_LEDGERS_TRIE_H_INCLUDED #include -#include +#include #include #include diff --git a/src/xrpld/core/Pg.cpp b/src/xrpld/core/Pg.cpp index 5b54d6fa262..1e1da7d9957 100644 --- a/src/xrpld/core/Pg.cpp +++ b/src/xrpld/core/Pg.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/xrpld/core/detail/Job.cpp b/src/xrpld/core/detail/Job.cpp index 67c4d631c22..17f600a4f41 100644 --- a/src/xrpld/core/detail/Job.cpp +++ b/src/xrpld/core/detail/Job.cpp @@ -18,8 +18,8 @@ //============================================================================== #include -#include #include +#include namespace ripple { diff --git a/src/xrpld/core/detail/LoadEvent.cpp b/src/xrpld/core/detail/LoadEvent.cpp index 9d076440a2c..5f309a04281 100644 --- a/src/xrpld/core/detail/LoadEvent.cpp +++ b/src/xrpld/core/detail/LoadEvent.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/xrpld/core/detail/Workers.cpp b/src/xrpld/core/detail/Workers.cpp index fdba0729d5a..2b43ed3f1b8 100644 --- a/src/xrpld/core/detail/Workers.cpp +++ b/src/xrpld/core/detail/Workers.cpp @@ -19,8 +19,8 @@ #include #include -#include #include +#include namespace ripple { diff --git a/src/xrpld/ledger/ReadView.h b/src/xrpld/ledger/ReadView.h index 9c6492812e0..efe920805ad 100644 --- a/src/xrpld/ledger/ReadView.h +++ b/src/xrpld/ledger/ReadView.h @@ -25,9 +25,9 @@ #include #include #include -#include #include #include +#include #include #include #include diff --git a/src/xrpld/ledger/detail/ApplyStateTable.cpp b/src/xrpld/ledger/detail/ApplyStateTable.cpp index 3bb174fe397..a0107d7929d 100644 --- a/src/xrpld/ledger/detail/ApplyStateTable.cpp +++ b/src/xrpld/ledger/detail/ApplyStateTable.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/xrpld/ledger/detail/ApplyView.cpp b/src/xrpld/ledger/detail/ApplyView.cpp index 2873cde37ce..58c6d3866f2 100644 --- a/src/xrpld/ledger/detail/ApplyView.cpp +++ b/src/xrpld/ledger/detail/ApplyView.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include namespace ripple { diff --git a/src/xrpld/ledger/detail/ApplyViewImpl.cpp b/src/xrpld/ledger/detail/ApplyViewImpl.cpp index bb0002459d8..e01b8bfe3ba 100644 --- a/src/xrpld/ledger/detail/ApplyViewImpl.cpp +++ b/src/xrpld/ledger/detail/ApplyViewImpl.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/xrpld/ledger/detail/PaymentSandbox.cpp b/src/xrpld/ledger/detail/PaymentSandbox.cpp index 130102771f3..696da0e106b 100644 --- a/src/xrpld/ledger/detail/PaymentSandbox.cpp +++ b/src/xrpld/ledger/detail/PaymentSandbox.cpp @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 3272216a105..b3357fbd10d 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/nodestore/backend/CassandraFactory.cpp b/src/xrpld/nodestore/backend/CassandraFactory.cpp index 59528ccf220..14edf7cf09d 100644 --- a/src/xrpld/nodestore/backend/CassandraFactory.cpp +++ b/src/xrpld/nodestore/backend/CassandraFactory.cpp @@ -31,8 +31,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/src/xrpld/nodestore/backend/NuDBFactory.cpp b/src/xrpld/nodestore/backend/NuDBFactory.cpp index 2358426ea96..3069a955bc6 100644 --- a/src/xrpld/nodestore/backend/NuDBFactory.cpp +++ b/src/xrpld/nodestore/backend/NuDBFactory.cpp @@ -23,7 +23,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/nodestore/detail/DecodedBlob.cpp b/src/xrpld/nodestore/detail/DecodedBlob.cpp index 331a3624b00..8afc1bafe09 100644 --- a/src/xrpld/nodestore/detail/DecodedBlob.cpp +++ b/src/xrpld/nodestore/detail/DecodedBlob.cpp @@ -18,8 +18,8 @@ //============================================================================== #include -#include #include +#include #include namespace ripple { diff --git a/src/xrpld/nodestore/detail/EncodedBlob.h b/src/xrpld/nodestore/detail/EncodedBlob.h index 349e741c19a..80480f219ef 100644 --- a/src/xrpld/nodestore/detail/EncodedBlob.h +++ b/src/xrpld/nodestore/detail/EncodedBlob.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/xrpld/nodestore/detail/TaskQueue.cpp b/src/xrpld/nodestore/detail/TaskQueue.cpp index 68513dbcf12..0fdd7d8500e 100644 --- a/src/xrpld/nodestore/detail/TaskQueue.cpp +++ b/src/xrpld/nodestore/detail/TaskQueue.cpp @@ -18,7 +18,7 @@ //============================================================================== #include -#include +#include namespace ripple { namespace NodeStore { diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index e72e3230d6c..597d5117bc1 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/overlay/detail/ProtocolMessage.h b/src/xrpld/overlay/detail/ProtocolMessage.h index dd1044d8865..79bc2ae4926 100644 --- a/src/xrpld/overlay/detail/ProtocolMessage.h +++ b/src/xrpld/overlay/detail/ProtocolMessage.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index 63260b81f71..babd4db82cc 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED #define RIPPLE_OVERLAY_TRAFFIC_H_INCLUDED -#include #include +#include #include #include diff --git a/src/xrpld/peerfinder/detail/Handouts.h b/src/xrpld/peerfinder/detail/Handouts.h index ca9fc217320..f40aeb9fe23 100644 --- a/src/xrpld/peerfinder/detail/Handouts.h +++ b/src/xrpld/peerfinder/detail/Handouts.h @@ -22,8 +22,8 @@ #include #include -#include #include +#include #include #include diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index d4b34cb8703..87adebf8ee6 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_RPC_STATUS_H_INCLUDED #define RIPPLE_RPC_STATUS_H_INCLUDED -#include +#include #include #include diff --git a/src/xrpld/shamap/SHAMap.h b/src/xrpld/shamap/SHAMap.h index 4df8923ddff..8d20d39895d 100644 --- a/src/xrpld/shamap/SHAMap.h +++ b/src/xrpld/shamap/SHAMap.h @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include #include #include diff --git a/src/xrpld/shamap/SHAMapItem.h b/src/xrpld/shamap/SHAMapItem.h index e2c876006a5..3c5835d1494 100644 --- a/src/xrpld/shamap/SHAMapItem.h +++ b/src/xrpld/shamap/SHAMapItem.h @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include namespace ripple { diff --git a/src/xrpld/shamap/detail/SHAMapNodeID.cpp b/src/xrpld/shamap/detail/SHAMapNodeID.cpp index 5458781f50d..1c9187a40e5 100644 --- a/src/xrpld/shamap/detail/SHAMapNodeID.cpp +++ b/src/xrpld/shamap/detail/SHAMapNodeID.cpp @@ -19,8 +19,8 @@ #include #include -#include #include +#include #include #include From c58258bee1ac75ab8d3c8ae0b841b69c5619af91 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Fri, 12 Jul 2024 12:34:26 +0100 Subject: [PATCH 07/18] Remove XRPL_ASSERT from unit tests --- src/test/app/AMM_test.cpp | 2 +- src/test/app/AmendmentTable_test.cpp | 2 +- src/test/app/Check_test.cpp | 2 +- src/test/app/DepositAuth_test.cpp | 4 +-- src/test/app/LedgerHistory_test.cpp | 2 +- src/test/app/LedgerLoad_test.cpp | 2 +- src/test/app/LedgerReplay_test.cpp | 6 ++--- src/test/app/Manifest_test.cpp | 2 +- src/test/app/PayChan_test.cpp | 32 +++++++++++------------ src/test/app/PayStrand_test.cpp | 8 +++--- src/test/app/Regression_test.cpp | 2 +- src/test/app/TheoreticalQuality_test.cpp | 6 ++--- src/test/app/XChain_test.cpp | 14 +++++----- src/test/basics/base58_test.cpp | 2 +- src/test/basics/base_uint_test.cpp | 2 +- src/test/consensus/NegativeUNL_test.cpp | 2 +- src/test/csf/BasicNetwork.h | 4 +-- src/test/csf/Histogram.h | 2 +- src/test/csf/PeerGroup.h | 2 +- src/test/csf/README.md | 2 +- src/test/csf/collectors.h | 4 +-- src/test/csf/ledgers.h | 2 +- src/test/jtx/impl/AMM.cpp | 8 +++--- src/test/jtx/impl/Account.cpp | 2 +- src/test/jtx/impl/Env.cpp | 2 +- src/test/jtx/impl/Oracle.cpp | 4 +-- src/test/jtx/impl/amount.cpp | 2 +- src/test/jtx/impl/quality2.cpp | 4 +-- src/test/jtx/impl/xchain_bridge.cpp | 8 +++--- src/test/nodestore/DatabaseShard_test.cpp | 4 +-- src/test/overlay/reduce_relay_test.cpp | 30 ++++++++++----------- src/test/overlay/short_read_test.cpp | 2 +- src/test/overlay/tx_reduce_relay_test.cpp | 2 +- src/test/rpc/Handler_test.cpp | 2 +- src/test/rpc/JSONRPC_test.cpp | 4 +-- src/test/shamap/FetchPack_test.cpp | 2 +- src/test/unit_test/multi_runner.cpp | 4 +-- 37 files changed, 93 insertions(+), 93 deletions(-) diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 1ad24ca4809..ceddc019504 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -6086,7 +6086,7 @@ struct AMM_test : public jtx::AMMTest boost::regex_search(std::get<0>(t), match, rx); auto const poolOutIsXRP = boost::regex_search(std::get<1>(t), match, rx); - XRPL_ASSERT(!(poolInIsXRP && poolOutIsXRP)); + assert(!(poolInIsXRP && poolOutIsXRP)); auto const poolIn = getPool(std::get<0>(t), poolInIsXRP); auto const poolOut = getPool(std::get<1>(t), poolOutIsXRP); try diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 1b838b7f0e7..2f95fc0280b 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -142,7 +142,7 @@ class AmendmentTable_test final : public beast::unit_test::suite std::vector const& src, Args const&... args) { - XRPL_ASSERT(dest.capacity() >= dest.size() + src.size()); + assert(dest.capacity() >= dest.size() + src.size()); std::copy(src.begin(), src.end(), std::back_inserter(dest)); if constexpr (sizeof...(args) > 0) combine_arg(dest, args...); diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index 8c4fb9a73a4..31b45abf43a 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -2016,7 +2016,7 @@ class Check_test : public beast::unit_test::suite // This capability is enabled by the featureCheckCashMakesTrustLine // amendment. So this test executes only when that amendment is // active. - XRPL_ASSERT(features[featureCheckCashMakesTrustLine]); + assert(features[featureCheckCashMakesTrustLine]); testcase("Trust Line Creation"); diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index 7ab18982f59..9a11785b38c 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -294,7 +294,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); + assert(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); @@ -317,7 +317,7 @@ struct DepositAuth_test : public beast::unit_test::suite bool noRipplePrev, bool noRippleNext, bool withDepositAuth) { - XRPL_ASSERT(!withDepositAuth || features[featureDepositAuth]); + assert(!withDepositAuth || features[featureDepositAuth]); Env env(*this, features); diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index 7cd9fdddc28..e1a837a9cb2 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -52,7 +52,7 @@ class LedgerHistory_test : public beast::unit_test::suite { if (!prev) { - XRPL_ASSERT(!stx); + assert(!stx); return std::make_shared( create_genesis, env.app().config(), diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index c44f55959a9..5b6df353d81 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -44,7 +44,7 @@ class LedgerLoad_test : public beast::unit_test::suite cfg->START_LEDGER = ledger; cfg->START_UP = type; cfg->TRAP_TX_HASH = trapTxHash; - XRPL_ASSERT(!dbPath.empty()); + assert(!dbPath.empty()); cfg->legacy("database_path", dbPath); return cfg; } diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index ba1f9a842d1..0b555a712cf 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -470,7 +470,7 @@ struct LedgerServer , msgHandler(env.app(), env.app().getLedgerReplayer()) , param(p) { - XRPL_ASSERT(param.initLedgers > 0); + assert(param.initLedgers > 0); createAccounts(param.initAccounts); createLedgerHistory(); app.logs().threshold(beast::severities::kWarning); @@ -499,7 +499,7 @@ struct LedgerServer sendPayments(int newTxes) { int fundedAccounts = accounts.size(); - XRPL_ASSERT(fundedAccounts >= newTxes); + assert(fundedAccounts >= newTxes); std::unordered_set senders; // somewhat random but reproducible @@ -507,7 +507,7 @@ struct LedgerServer int fromIdx = 0; int toIdx = 0; auto updateIdx = [&]() { - XRPL_ASSERT(fundedAccounts > senders.size()); + assert(fundedAccounts > senders.size()); fromIdx = (fromIdx + r) % fundedAccounts; while (senders.count(fromIdx) != 0) fromIdx = (fromIdx + 1) % fundedAccounts; diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index 5d4307bd668..bf7b14c0d28 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -253,7 +253,7 @@ class Manifest_test : public beast::unit_test::suite jtx::Env env(*this); DatabaseCon::Setup setup; setup.dataDir = getDatabasePath(); - XRPL_ASSERT(!setup.useGlobalPragma); + assert(!setup.useGlobalPragma); auto dbCon = makeTestWalletDB(setup, dbName); diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index 403b6227f54..a8eae4a25ec 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -152,7 +152,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(-100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ter(temBAD_AMOUNT)); } { @@ -161,7 +161,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt)); BEAST_EXPECT(channelBalance(*env.current(), chan) == reqBal); BEAST_EXPECT(channelAmount(*env.current(), chan) == chanAmt); @@ -174,7 +174,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -197,7 +197,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + STAmount{1}; - XRPL_ASSERT(reqAmt <= chanAmt); + assert(reqAmt <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqAmt, authAmt, Slice(sig), alice.pk()), @@ -248,7 +248,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - XRPL_ASSERT(delta > beast::zero); + assert(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } @@ -369,7 +369,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -499,7 +499,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -518,7 +518,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk())); @@ -590,7 +590,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -607,7 +607,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, reqBal); env(claim(bob, chan, reqBal, std::nullopt, Slice(sig), alice.pk())); @@ -1736,7 +1736,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); // claim should fail if the dst was removed if (withOwnerDirFix) @@ -1822,7 +1822,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(50); auto reqBal = chanBal + delta; auto authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); { // claim should fail, since bob doesn't exist @@ -1959,7 +1959,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); env(claim(alice, chan, reqBal, authAmt), ticket::use(aliceTicketSeq++)); @@ -1977,7 +1977,7 @@ struct PayChan_test : public beast::unit_test::suite auto const delta = XRP(500); auto const reqBal = chanBal + delta; auto const authAmt = reqBal + XRP(100); - XRPL_ASSERT(reqBal <= chanAmt); + assert(reqBal <= chanAmt); auto const sig = signClaimAuth(alice.pk(), alice.sk(), chan, authAmt); env(claim(bob, chan, reqBal, authAmt, Slice(sig), alice.pk()), @@ -2011,7 +2011,7 @@ struct PayChan_test : public beast::unit_test::suite auto const preBob = env.balance(bob); STAmount const authAmt = chanBal + XRP(500); STAmount const reqAmt = authAmt + drops(1); - XRPL_ASSERT(reqAmt <= chanAmt); + assert(reqAmt <= chanAmt); // Note that since claim() returns a tem (neither tec nor tes), // the ticket is not consumed. So we don't increment bobTicket. auto const sig = @@ -2053,7 +2053,7 @@ struct PayChan_test : public beast::unit_test::suite BEAST_EXPECT(!channelExists(*env.current(), chan)); auto const feeDrops = env.current()->fees().base; auto const delta = chanAmt - chanBal; - XRPL_ASSERT(delta > beast::zero); + assert(delta > beast::zero); BEAST_EXPECT(env.balance(alice) == preAlice + delta); BEAST_EXPECT(env.balance(bob) == preBob - feeDrops); } diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index a5e38f20c63..f00a7361292 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -271,7 +271,7 @@ class ElementComboIter std::optional const& existingCur, std::optional const& existingIss) { - XRPL_ASSERT(!has(SB::last)); + assert(!has(SB::last)); auto const acc = [&]() -> std::optional { if (!has(SB::acc)) @@ -322,14 +322,14 @@ struct ExistingElementPool jtx::Account getAccount(size_t id) { - XRPL_ASSERT(id < accounts.size()); + assert(id < accounts.size()); return accounts[id]; } ripple::Currency getCurrency(size_t id) { - XRPL_ASSERT(id < currencies.size()); + assert(id < currencies.size()); return currencies[id]; } @@ -380,7 +380,7 @@ struct ExistingElementPool { using namespace jtx; - XRPL_ASSERT(!offererIndex || offererIndex < numAct); + assert(!offererIndex || offererIndex < numAct); accounts.clear(); accounts.reserve(numAct); diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index a22ba9154a9..f54a88ace00 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -145,7 +145,7 @@ struct Regression_test : public beast::unit_test::suite // Set the same key in the STTx. auto secp256r1Sig = std::make_unique(*(jt.stx)); auto pubKeyBlob = strUnHex(secp256r1PubKey); - XRPL_ASSERT(pubKeyBlob); // Hex for public key must be valid + assert(pubKeyBlob); // Hex for public key must be valid secp256r1Sig->setFieldVL(sfSigningPubKey, *pubKeyBlob); jt.stx.reset(secp256r1Sig.release()); diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index 516d6093a5c..917d23377bf 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -64,7 +64,7 @@ struct RippleCalcTestParams { if (pe.isMember(jss::account)) { - XRPL_ASSERT( + assert( !pe.isMember(jss::currency) && !pe.isMember(jss::issuer)); p.emplace_back( @@ -83,13 +83,13 @@ struct RippleCalcTestParams issuer = *parseBase58( pe[jss::issuer].asString()); else - XRPL_ASSERT(isXRP(*parseBase58( + assert(isXRP(*parseBase58( pe[jss::issuer].asString()))); p.emplace_back(std::nullopt, currency, issuer); } else { - XRPL_ASSERT(0); + assert(0); } } paths.emplace_back(std::move(p)); diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index 5b8a1ab32d9..7dc9d6f8312 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -4426,7 +4426,7 @@ struct XChainSim_test : public beast::unit_test::suite, c.num_create_attn_sent += sendCreateAttestations( i, bridge, create_claims); } - XRPL_ASSERT( + assert( claims.create_claims[c.claim_count].empty()); } } @@ -4706,11 +4706,11 @@ struct XChainSim_test : public beast::unit_test::suite, auto complete_cb = [&](std::vector const& signers) { auto num_attestors = signers.size(); st.env.close(); - XRPL_ASSERT( + assert( num_attestors <= std::count(cr.attested.begin(), cr.attested.end(), true)); - XRPL_ASSERT(num_attestors >= bridge_.quorum); - XRPL_ASSERT(cr.claim_id - 1 == counters.claim_count); + assert(num_attestors >= bridge_.quorum); + assert(cr.claim_id - 1 == counters.claim_count); auto r = cr.reward; auto reward = divide(r, STAmount(num_attestors), r.issue()); @@ -4742,7 +4742,7 @@ struct XChainSim_test : public beast::unit_test::suite, break; default: - XRPL_ASSERT(0); + assert(0); break; case st_completed: @@ -4906,14 +4906,14 @@ struct XChainSim_test : public beast::unit_test::suite, break; case st_attested: - XRPL_ASSERT(xfer.with_claim == WithClaim::yes); + assert(xfer.with_claim == WithClaim::yes); claim(); sm_state = st_completed; break; default: case st_completed: - XRPL_ASSERT(0); // should have been removed + assert(0); // should have been removed break; } return sm_state; diff --git a/src/test/basics/base58_test.cpp b/src/test/basics/base58_test.cpp index 5c7aab2ee73..f204cdd0e3a 100644 --- a/src/test/basics/base58_test.cpp +++ b/src/test/basics/base58_test.cpp @@ -51,7 +51,7 @@ constexpr int numTokenTypeIndexes = 9; [[nodiscard]] inline auto tokenTypeAndSize(int i) -> std::tuple { - XRPL_ASSERT(i < numTokenTypeIndexes); + assert(i < numTokenTypeIndexes); switch (i) { diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 659258ff43e..43000a1128c 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -44,7 +44,7 @@ struct nonhash void operator()(void const* key, std::size_t len) noexcept { - XRPL_ASSERT(len == WIDTH); + assert(len == WIDTH); memcpy(data_.data(), key, len); } diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index fbd4270b7bb..200cd166031 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -594,7 +594,7 @@ struct NetworkHistory void createNodes() { - XRPL_ASSERT(param.numNodes <= 256); + assert(param.numNodes <= 256); UNLKeys = createPublicKeys(param.numNodes); for (int i = 0; i < param.numNodes; ++i) { diff --git a/src/test/csf/BasicNetwork.h b/src/test/csf/BasicNetwork.h index e6903fa7e31..a70ee6a3613 100644 --- a/src/test/csf/BasicNetwork.h +++ b/src/test/csf/BasicNetwork.h @@ -215,7 +215,7 @@ BasicNetwork::connect( return false; auto const result = links_.connect(to, from, link_type{true, delay, now}); (void)result; - XRPL_ASSERT(result); + assert(result); return true; } @@ -227,7 +227,7 @@ BasicNetwork::disconnect(Peer const& peer1, Peer const& peer2) return false; bool r = links_.disconnect(peer2, peer1); (void)r; - XRPL_ASSERT(r); + assert(r); return true; } diff --git a/src/test/csf/Histogram.h b/src/test/csf/Histogram.h index 479f71cd241..82e64a3794a 100644 --- a/src/test/csf/Histogram.h +++ b/src/test/csf/Histogram.h @@ -110,7 +110,7 @@ class Histogram T percentile(float p) const { - XRPL_ASSERT(p >= 0 && p <= 1); + assert(p >= 0 && p <= 1); std::size_t pos = std::round(p * samples); if (counts_.empty()) diff --git a/src/test/csf/PeerGroup.h b/src/test/csf/PeerGroup.h index 6e8c9f64494..b59bfa6763c 100644 --- a/src/test/csf/PeerGroup.h +++ b/src/test/csf/PeerGroup.h @@ -303,7 +303,7 @@ randomRankedGroups( RandomNumberDistribution sizeDist, Generator& g) { - XRPL_ASSERT(peers.size() == ranks.size()); + assert(peers.size() == ranks.size()); std::vector groups; groups.reserve(numGroups); diff --git a/src/test/csf/README.md b/src/test/csf/README.md index 801e514b76f..ff6bdc5dfac 100644 --- a/src/test/csf/README.md +++ b/src/test/csf/README.md @@ -81,7 +81,7 @@ for (Peer * p : validators) sim.run(1); std::cout << (simDur.stop - simDur.start).count() << std::endl; -XRPL_ASSERT(sim.synchronized()); +assert(sim.synchronized()); ``` ### `Sim` and `PeerGroup` diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index a4bdd73666d..511fb2c4b0f 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -239,7 +239,7 @@ struct TxCollector { Tracker& tracker = it->second; // Should only validated a previously accepted Tx - XRPL_ASSERT(tracker.accepted); + assert(tracker.accepted); tracker.validated = when; validated++; @@ -501,7 +501,7 @@ struct LedgerCollector if (e.prior.id() == e.ledger.parentID()) { auto const it = ledgers_.find(e.ledger.id()); - XRPL_ASSERT(it != ledgers_.end()); + assert(it != ledgers_.end()); auto& tracker = it->second; // first time fully validated if (!tracker.fullyValidated) diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index c57394bdd92..1c8d4eb54c6 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -345,7 +345,7 @@ struct LedgerHistoryHelper return it->second; // enforce that the new suffix has never been seen - XRPL_ASSERT(seen.emplace(s.back()).second); + assert(seen.emplace(s.back()).second); Ledger const& parent = (*this)[s.substr(0, s.size() - 1)]; return ledgers.emplace(s, oracle.accept(parent, Tx{++nextTx})) diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 83d1362ff28..c083b6df35c 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -436,7 +436,7 @@ AMM::deposit( std::optional const& flags, std::optional const& ter) { - XRPL_ASSERT(!(asset2In && maxEP)); + assert(!(asset2In && maxEP)); return deposit( account, std::nullopt, @@ -560,7 +560,7 @@ AMM::withdraw( std::optional const& maxEP, std::optional const& ter) { - XRPL_ASSERT(!(asset2Out && maxEP)); + assert(!(asset2Out && maxEP)); return withdraw( account, std::nullopt, @@ -665,7 +665,7 @@ AMM::bid(BidArg const& arg) if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - XRPL_ASSERT( + assert( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) @@ -760,7 +760,7 @@ AMM::expectAuctionSlot(auto&& cb) const if (auto const amm = env_.current()->read(keylet::amm(asset1_.issue(), asset2_.issue()))) { - XRPL_ASSERT( + assert( !env_.current()->rules().enabled(fixInnerObjTemplate) || amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) diff --git a/src/test/jtx/impl/Account.cpp b/src/test/jtx/impl/Account.cpp index 9f151830f63..9d41456ef75 100644 --- a/src/test/jtx/impl/Account.cpp +++ b/src/test/jtx/impl/Account.cpp @@ -89,7 +89,7 @@ IOU Account::operator[](std::string const& s) const { auto const currency = to_currency(s); - XRPL_ASSERT(currency != noCurrency()); + assert(currency != noCurrency()); return IOU(*this, currency); } diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 41f56bcc0ba..6f0f9e3fc73 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -357,7 +357,7 @@ Env::sign_and_submit(JTx const& jt, Json::Value params) { // Use the provided parameters, and go straight // to the (RPC) client. - XRPL_ASSERT(params.isObject()); + assert(params.isObject()); if (!params.isMember(jss::secret) && !params.isMember(jss::key_type) && !params.isMember(jss::seed) && !params.isMember(jss::seed_hex) && !params.isMember(jss::passphrase)) diff --git a/src/test/jtx/impl/Oracle.cpp b/src/test/jtx/impl/Oracle.cpp index 0e2aa633f44..df9483cbaae 100644 --- a/src/test/jtx/impl/Oracle.cpp +++ b/src/test/jtx/impl/Oracle.cpp @@ -100,7 +100,7 @@ Oracle::submit( bool Oracle::exists(Env& env, AccountID const& account, std::uint32_t documentID) { - XRPL_ASSERT(account.isNonZero()); + assert(account.isNonZero()); return env.le(keylet::oracle(account, documentID)) != nullptr; } @@ -243,7 +243,7 @@ Oracle::set(UpdateArg const& arg) // assume standard currency if (s.size() == 3) return s; - XRPL_ASSERT(s.size() <= 20); + assert(s.size() <= 20); // anything else must be 160-bit hex string std::string h = strHex(s); return strHex(s).append(40 - s.size() * 2, '0'); diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 7232940c5f2..10252f45a8d 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -56,7 +56,7 @@ template static std::string to_places(const T d, std::uint8_t places) { - XRPL_ASSERT(places <= std::numeric_limits::digits10); + assert(places <= std::numeric_limits::digits10); std::ostringstream oss; oss << std::setprecision(places) << std::fixed << d; diff --git a/src/test/jtx/impl/quality2.cpp b/src/test/jtx/impl/quality2.cpp index 4147b926116..dd10b3c6117 100644 --- a/src/test/jtx/impl/quality2.cpp +++ b/src/test/jtx/impl/quality2.cpp @@ -28,13 +28,13 @@ namespace jtx { qualityInPercent::qualityInPercent(double percent) : qIn_(static_cast((percent / 100) * QUALITY_ONE)) { - XRPL_ASSERT(percent <= 400 && percent >= 0); + assert(percent <= 400 && percent >= 0); } qualityOutPercent::qualityOutPercent(double percent) : qOut_(static_cast((percent / 100) * QUALITY_ONE)) { - XRPL_ASSERT(percent <= 400 && percent >= 0); + assert(percent <= 400 && percent >= 0); } static void diff --git a/src/test/jtx/impl/xchain_bridge.cpp b/src/test/jtx/impl/xchain_bridge.cpp index 00f641d9523..43b0e7c2f96 100644 --- a/src/test/jtx/impl/xchain_bridge.cpp +++ b/src/test/jtx/impl/xchain_bridge.cpp @@ -316,8 +316,8 @@ claim_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); - XRPL_ASSERT(fromIdx + numAtts <= signers.size()); + assert(fromIdx + numAtts <= rewardAccounts.size()); + assert(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) @@ -349,8 +349,8 @@ create_account_attestations( std::size_t const numAtts, std::size_t const fromIdx) { - XRPL_ASSERT(fromIdx + numAtts <= rewardAccounts.size()); - XRPL_ASSERT(fromIdx + numAtts <= signers.size()); + assert(fromIdx + numAtts <= rewardAccounts.size()); + assert(fromIdx + numAtts <= signers.size()); JValueVec vec; vec.reserve(numAtts); for (auto i = fromIdx; i < fromIdx + numAtts; ++i) diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index 3b6d0dec836..e185c43d157 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -134,7 +134,7 @@ struct uniformIntDistribution static_assert( Generator::min() == 0, "If non-zero we have handle the offset"); const resultType range = b - a + 1; - XRPL_ASSERT(Generator::max() >= range); // Just for safety + assert(Generator::max() >= range); // Just for safety const resultType rejectLim = g.max() % range; resultType n; do @@ -148,7 +148,7 @@ template Integral randInt(Engine& engine, Integral min, Integral max) { - XRPL_ASSERT(max > min); + assert(max > min); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 8f07ac5b6d3..4d9086dab10 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -266,7 +266,7 @@ class Link : validator_(validator), peer_(peer), latency_(latency), up_(true) { auto sp = peer_.lock(); - XRPL_ASSERT(sp); + assert(sp); } ~Link() = default; void @@ -275,7 +275,7 @@ class Link if (!up_) return; auto sp = peer_.lock(); - XRPL_ASSERT(sp); + assert(sp); auto peer = std::dynamic_pointer_cast(sp); peer->onMessage(m, f); } @@ -293,14 +293,14 @@ class Link peerId() { auto p = peer_.lock(); - XRPL_ASSERT(p); + assert(p); return p->id(); } PeerSPtr getPeer() { auto p = peer_.lock(); - XRPL_ASSERT(p); + assert(p); return p; } @@ -376,7 +376,7 @@ class Validator { for (auto id : peers) { - XRPL_ASSERT(links_.find(id) != links_.end()); + assert(links_.find(id) != links_.end()); f(*links_[id], message_); } } @@ -429,7 +429,7 @@ class Validator linkUp(Peer::id_t id) { auto it = links_.find(id); - XRPL_ASSERT(it != links_.end()); + assert(it != links_.end()); it->second->up(true); } @@ -437,7 +437,7 @@ class Validator linkDown(Peer::id_t id) { auto it = links_.find(id); - XRPL_ASSERT(it != links_.end()); + assert(it != links_.end()); it->second->up(false); } @@ -478,7 +478,7 @@ class PeerSim : public PeerPartial, public std::enable_shared_from_this onMessage(MessageSPtr const& m, SquelchCB f) override { auto validator = m->getValidatorKey(); - XRPL_ASSERT(validator); + assert(validator); if (!squelch_.expireSquelch(*validator)) return; @@ -584,7 +584,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler deletePeer(Peer::id_t id, bool useCache = true) { auto it = peers_.find(id); - XRPL_ASSERT(it != peers_.end()); + assert(it != peers_.end()); deletePeer(id, [&](PublicKey const&, PeerWPtr) {}); if (useCache) peersCache_.emplace(std::make_pair(id, it->second)); @@ -643,7 +643,7 @@ class OverlaySim : public Overlay, public reduce_relay::SquelchHandler getSelectedPeer(PublicKey const& validator) { auto selected = slots_.getSelected(validator); - XRPL_ASSERT(selected.size()); + assert(selected.size()); return *selected.begin(); } @@ -752,7 +752,7 @@ class Network Validator& validator(std::uint16_t v) { - XRPL_ASSERT(v < validators_.size()); + assert(v < validators_.size()); return validators_[v]; } @@ -769,7 +769,7 @@ class Network std::find_if(validators_.begin(), validators_.end(), [&](auto& v) { return v.id() == validatorId; }); - XRPL_ASSERT(it != validators_.end()); + assert(it != validators_.end()); if (enable) it->linkUp(peer); else @@ -911,7 +911,7 @@ class reduce_relay_test : public beast::unit_test::suite if (res) squelch.set_squelchduration(*duration); auto sp = peerPtr.lock(); - XRPL_ASSERT(sp); + assert(sp); std::dynamic_pointer_cast(sp)->send(squelch); return sp->id(); } @@ -958,7 +958,7 @@ class reduce_relay_test : public beast::unit_test::suite [&](PublicKey const& key, PeerWPtr const& peerPtr, std::uint32_t duration) { - XRPL_ASSERT(key == validator); + assert(key == validator); auto p = sendSquelch(key, peerPtr, duration); squelched = true; str << p << " "; @@ -1295,7 +1295,7 @@ class reduce_relay_test : public beast::unit_test::suite return std::get(it.second) == reduce_relay::PeerState::Squelched; }); - XRPL_ASSERT(it != peers.end()); + assert(it != peers.end()); std::uint16_t unsquelched = 0; network_.overlay().deletePeer( it->first, [&](PublicKey const& key, PeerWPtr const& peer) { diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index 4cda0cf1c6d..bdb7b9dbfe1 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -112,7 +112,7 @@ class short_read_test : public beast::unit_test::suite ~Base() { // Derived class must call wait() in the destructor - XRPL_ASSERT(list_.empty()); + assert(list_.empty()); } void diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 7d9c2a4fcf4..074976e8586 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -193,7 +193,7 @@ class tx_reduce_relay_test : public beast::unit_test::suite peers.emplace_back(peer); // overlay stores week ptr to PeerImp lid_ += 2; rid_ += 2; - XRPL_ASSERT(lid_ <= 254); + assert(lid_ <= 254); } void diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 36b10610064..2c3bfd30d4c 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -51,7 +51,7 @@ class Handler_test : public beast::unit_test::suite time(std::size_t n, auto f, auto prng) -> auto { using clock = std::chrono::steady_clock; - XRPL_ASSERT(n > 0); + assert(n > 0); double sum = 0; double sum_squared = 0; std::size_t j = 0; diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index 800d2dec50c..b2b9e7a55b8 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -2586,7 +2586,7 @@ class JSONRPC_test : public beast::unit_test::suite auto const signFn = get<0>(testFunc); if (signFn != nullptr) { - XRPL_ASSERT(get<1>(testFunc) == nullptr); + assert(get<1>(testFunc) == nullptr); result = signFn( req, 1, @@ -2598,7 +2598,7 @@ class JSONRPC_test : public beast::unit_test::suite else { auto const submitFn = get<1>(testFunc); - XRPL_ASSERT(submitFn != nullptr); + assert(submitFn != nullptr); result = submitFn( req, 1, diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index 5570c953bff..ac2d16ecc99 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -101,7 +101,7 @@ class FetchPack_test : public beast::unit_test::suite { auto const result(t.addItem( SHAMapNodeType::tnACCOUNT_STATE, make_random_item(r))); - XRPL_ASSERT(result); + assert(result); (void)result; } } diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index 223a2359a0d..e56ec8888d9 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -420,7 +420,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) buf.data(), buf.size(), recvd_size, priority); if (!recvd_size) continue; - XRPL_ASSERT(recvd_size == 1); + assert(recvd_size == 1); MessageType mt{*reinterpret_cast(buf.data())}; this->message_queue_->receive( @@ -441,7 +441,7 @@ multi_runner_parent::multi_runner_parent() : os_(std::cout) running_suites_.erase(s); break; default: - XRPL_ASSERT(0); // unknown message type + assert(0); // unknown message type } } } From 8d7cd9c558aeea3eabe490342a926985b10c552b Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Thu, 11 Jul 2024 22:11:37 +0100 Subject: [PATCH 08/18] Give names to asserts --- include/xrpl/basics/Buffer.h | 3 +- include/xrpl/basics/FeeUnits.h | 10 +- include/xrpl/basics/SlabAllocator.h | 14 +- include/xrpl/basics/Slice.h | 4 +- include/xrpl/basics/base_uint.h | 2 + .../xrpl/basics/partitioned_unordered_map.h | 5 +- include/xrpl/basics/random.h | 2 +- include/xrpl/basics/spinlock.h | 4 +- include/xrpl/beast/asio/io_latency_probe.h | 10 +- include/xrpl/beast/clock/manual_clock.h | 8 +- .../detail/aged_unordered_container.h | 10 +- include/xrpl/beast/core/LexicalCast.h | 5 +- include/xrpl/beast/net/IPAddress.h | 2 +- include/xrpl/beast/utility/Journal.h | 4 +- include/xrpl/beast/utility/instrumentation.h | 6 +- include/xrpl/beast/utility/rngfill.h | 3 +- include/xrpl/json/detail/json_assert.h | 3 - include/xrpl/protocol/AmountConversions.h | 16 +- include/xrpl/protocol/Feature.h | 14 +- include/xrpl/protocol/Indexes.h | 3 +- include/xrpl/protocol/MultiApiJson.h | 3 + include/xrpl/protocol/Quality.h | 4 +- include/xrpl/protocol/STBitString.h | 7 +- include/xrpl/protocol/STInteger.h | 7 +- include/xrpl/protocol/STObject.h | 28 +++- include/xrpl/protocol/STPathSet.h | 8 +- include/xrpl/protocol/STValidation.h | 9 +- include/xrpl/protocol/Serializer.h | 7 +- include/xrpl/protocol/TxMeta.h | 4 +- include/xrpl/protocol/detail/b58_utils.h | 14 +- include/xrpl/resource/detail/Logic.h | 8 +- include/xrpl/server/detail/BaseWSPeer.h | 7 +- src/libxrpl/basics/Log.cpp | 8 +- src/libxrpl/basics/Number.cpp | 23 ++- src/libxrpl/basics/ResolverAsio.cpp | 34 ++-- .../beast/clock/basic_seconds_clock.cpp | 4 +- src/libxrpl/beast/core/SemanticVersion.cpp | 7 +- src/libxrpl/beast/insight/StatsDCollector.cpp | 5 +- .../utility/src/beast_PropertyStream.cpp | 8 +- src/libxrpl/crypto/RFC1751.cpp | 20 ++- src/libxrpl/json/Object.cpp | 6 +- src/libxrpl/json/json_reader.cpp | 2 +- src/libxrpl/json/json_value.cpp | 53 ++++--- src/libxrpl/json/json_writer.cpp | 20 ++- src/libxrpl/protocol/AMMCore.cpp | 4 +- src/libxrpl/protocol/AccountID.cpp | 4 +- src/libxrpl/protocol/ErrorCodes.cpp | 4 +- src/libxrpl/protocol/Feature.cpp | 16 +- src/libxrpl/protocol/Indexes.cpp | 15 +- src/libxrpl/protocol/Keylet.cpp | 4 +- src/libxrpl/protocol/Quality.cpp | 31 ++-- src/libxrpl/protocol/Rate2.cpp | 18 ++- src/libxrpl/protocol/Rules.cpp | 11 +- src/libxrpl/protocol/STAccount.cpp | 7 +- src/libxrpl/protocol/STAmount.cpp | 49 ++++-- src/libxrpl/protocol/STBase.cpp | 14 +- src/libxrpl/protocol/STBlob.cpp | 5 +- src/libxrpl/protocol/STInteger.cpp | 4 +- src/libxrpl/protocol/STLedgerEntry.cpp | 4 +- src/libxrpl/protocol/STObject.cpp | 3 +- src/libxrpl/protocol/STPathSet.cpp | 7 +- src/libxrpl/protocol/STTx.cpp | 7 +- src/libxrpl/protocol/STValidation.cpp | 4 +- src/libxrpl/protocol/STVar.cpp | 4 +- src/libxrpl/protocol/STVector256.cpp | 7 +- src/libxrpl/protocol/Serializer.cpp | 10 +- src/libxrpl/protocol/TxMeta.cpp | 34 ++-- src/libxrpl/protocol/tokens.cpp | 10 +- src/libxrpl/resource/Consumer.cpp | 16 +- src/test/app/XChain_test.cpp | 3 +- src/xrpld/app/consensus/RCLConsensus.cpp | 18 ++- src/xrpld/app/consensus/RCLCxPeerPos.cpp | 1 + src/xrpld/app/consensus/RCLCxTx.h | 7 +- src/xrpld/app/consensus/RCLValidations.cpp | 10 +- src/xrpld/app/ledger/AcceptedLedgerTx.cpp | 8 +- src/xrpld/app/ledger/ConsensusTransSetSF.cpp | 8 +- src/xrpld/app/ledger/Ledger.cpp | 63 +++++--- src/xrpld/app/ledger/LedgerHistory.cpp | 52 ++++-- src/xrpld/app/ledger/OpenLedger.h | 3 +- src/xrpld/app/ledger/OrderBookDB.cpp | 4 +- src/xrpld/app/ledger/TransactionStateSF.cpp | 4 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 10 +- src/xrpld/app/ledger/detail/InboundLedger.cpp | 29 +++- .../app/ledger/detail/InboundLedgers.cpp | 19 ++- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 8 +- .../app/ledger/detail/LedgerDeltaAcquire.cpp | 10 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 48 ++++-- .../app/ledger/detail/LedgerReplayTask.cpp | 16 +- .../app/ledger/detail/LedgerReplayer.cpp | 3 +- .../app/ledger/detail/SkipListAcquire.cpp | 6 +- .../app/ledger/detail/TimeoutCounter.cpp | 4 +- src/xrpld/app/main/Application.cpp | 63 ++++++-- src/xrpld/app/main/GRPCServer.cpp | 6 +- src/xrpld/app/main/LoadManager.cpp | 4 +- src/xrpld/app/misc/FeeVoteImpl.cpp | 4 +- src/xrpld/app/misc/HashRouter.cpp | 2 +- src/xrpld/app/misc/NegativeUNLVote.cpp | 12 +- src/xrpld/app/misc/NetworkOPs.cpp | 68 ++++++-- src/xrpld/app/misc/SHAMapStoreImp.cpp | 11 +- src/xrpld/app/misc/detail/AMMHelpers.cpp | 4 +- src/xrpld/app/misc/detail/AMMUtils.cpp | 3 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 4 +- src/xrpld/app/misc/detail/Manifest.cpp | 4 +- src/xrpld/app/misc/detail/Transaction.cpp | 5 +- src/xrpld/app/misc/detail/TxQ.cpp | 80 +++++++--- src/xrpld/app/misc/detail/ValidatorList.cpp | 104 +++++++++--- src/xrpld/app/misc/detail/ValidatorSite.cpp | 9 +- src/xrpld/app/misc/detail/WorkBase.h | 2 +- src/xrpld/app/misc/detail/WorkFile.h | 2 +- src/xrpld/app/paths/Credit.cpp | 16 +- src/xrpld/app/paths/Flow.cpp | 2 +- src/xrpld/app/paths/PathRequest.cpp | 3 +- src/xrpld/app/paths/Pathfinder.cpp | 18 ++- src/xrpld/app/paths/RippleLineCache.cpp | 12 +- src/xrpld/app/paths/detail/AMMLiquidity.cpp | 4 +- src/xrpld/app/paths/detail/AmountSpec.h | 21 ++- src/xrpld/app/paths/detail/BookStep.cpp | 19 ++- src/xrpld/app/paths/detail/DirectStep.cpp | 19 ++- src/xrpld/app/paths/detail/FlowDebugInfo.h | 9 +- src/xrpld/app/paths/detail/PaySteps.cpp | 13 +- src/xrpld/app/paths/detail/StepChecks.h | 2 +- src/xrpld/app/paths/detail/StrandFlow.h | 22 ++- .../app/paths/detail/XRPEndpointStep.cpp | 4 +- src/xrpld/app/rdb/RelationalDatabase.h | 3 +- .../rdb/backend/detail/PostgresDatabase.cpp | 148 +++++++++++++----- .../app/rdb/backend/detail/detail/Node.cpp | 9 +- src/xrpld/app/rdb/detail/Vacuum.cpp | 7 +- src/xrpld/app/reporting/ETLHelpers.h | 2 +- src/xrpld/app/reporting/ETLSource.cpp | 11 +- src/xrpld/app/reporting/ETLSource.h | 11 +- src/xrpld/app/reporting/ReportingETL.cpp | 21 ++- src/xrpld/app/reporting/ReportingETL.h | 12 +- src/xrpld/app/tx/detail/AMMBid.cpp | 6 +- src/xrpld/app/tx/detail/AMMDeposit.cpp | 4 +- src/xrpld/app/tx/detail/AMMVote.cpp | 3 +- src/xrpld/app/tx/detail/AMMWithdraw.cpp | 4 +- src/xrpld/app/tx/detail/ApplyContext.cpp | 4 +- src/xrpld/app/tx/detail/Change.cpp | 6 +- src/xrpld/app/tx/detail/CreateOffer.cpp | 40 +++-- src/xrpld/app/tx/detail/DeleteAccount.cpp | 18 ++- src/xrpld/app/tx/detail/NFTokenMint.cpp | 4 +- src/xrpld/app/tx/detail/NFTokenUtils.cpp | 7 +- src/xrpld/app/tx/detail/Offer.h | 2 +- src/xrpld/app/tx/detail/OfferStream.cpp | 7 +- src/xrpld/app/tx/detail/PayChan.cpp | 8 +- src/xrpld/app/tx/detail/Payment.cpp | 3 +- src/xrpld/app/tx/detail/SetSignerList.cpp | 26 ++- src/xrpld/app/tx/detail/Taker.cpp | 74 ++++++--- src/xrpld/app/tx/detail/Transactor.cpp | 38 +++-- src/xrpld/app/tx/detail/XChainBridge.cpp | 7 +- src/xrpld/app/tx/detail/applySteps.cpp | 13 +- src/xrpld/consensus/Consensus.h | 24 +-- src/xrpld/consensus/ConsensusTypes.h | 4 +- src/xrpld/consensus/LedgerTiming.h | 8 +- src/xrpld/consensus/LedgerTrie.h | 25 +-- src/xrpld/consensus/Validations.h | 7 +- src/xrpld/core/Coro.ipp | 4 +- src/xrpld/core/DatabaseCon.h | 5 +- src/xrpld/core/JobTypes.h | 10 +- src/xrpld/core/Pg.cpp | 4 +- src/xrpld/core/detail/Config.cpp | 18 ++- src/xrpld/core/detail/DatabaseCon.cpp | 4 +- src/xrpld/core/detail/JobQueue.cpp | 79 +++++++--- src/xrpld/core/detail/LoadEvent.cpp | 2 +- src/xrpld/core/detail/Workers.cpp | 4 +- src/xrpld/ledger/ApplyView.h | 8 +- src/xrpld/ledger/detail/ApplyStateTable.cpp | 41 +++-- src/xrpld/ledger/detail/ApplyView.cpp | 3 +- src/xrpld/ledger/detail/BookDirs.cpp | 26 ++- src/xrpld/ledger/detail/Directory.cpp | 18 ++- src/xrpld/ledger/detail/PaymentSandbox.cpp | 17 +- src/xrpld/ledger/detail/RawStateTable.cpp | 12 +- src/xrpld/ledger/detail/ReadViewFwdRange.ipp | 5 +- src/xrpld/ledger/detail/View.cpp | 87 ++++++---- src/xrpld/net/detail/DatabaseBody.ipp | 3 +- src/xrpld/net/detail/DatabaseDownloader.cpp | 9 +- src/xrpld/net/detail/HTTPStream.cpp | 4 +- src/xrpld/net/detail/InfoSub.cpp | 3 +- src/xrpld/net/detail/RPCCall.cpp | 4 +- src/xrpld/nodestore/Database.h | 16 +- .../nodestore/backend/CassandraFactory.cpp | 16 +- src/xrpld/nodestore/backend/MemoryFactory.cpp | 10 +- src/xrpld/nodestore/backend/NuDBFactory.cpp | 4 +- .../nodestore/backend/RocksDBFactory.cpp | 16 +- src/xrpld/nodestore/detail/BatchWriter.cpp | 4 +- src/xrpld/nodestore/detail/Database.cpp | 24 ++- src/xrpld/nodestore/detail/DatabaseNodeImp.h | 5 +- .../nodestore/detail/DatabaseShardImp.cpp | 67 ++++++-- src/xrpld/nodestore/detail/DecodedBlob.cpp | 4 +- src/xrpld/nodestore/detail/EncodedBlob.h | 8 +- src/xrpld/nodestore/detail/ManagerImp.cpp | 4 +- src/xrpld/nodestore/detail/Shard.cpp | 10 +- src/xrpld/nodestore/detail/TaskQueue.cpp | 4 +- src/xrpld/overlay/Compression.h | 8 +- src/xrpld/overlay/Slot.h | 4 +- src/xrpld/overlay/detail/ConnectAttempt.cpp | 4 +- src/xrpld/overlay/detail/Message.cpp | 8 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 28 +++- src/xrpld/overlay/detail/OverlayImpl.h | 4 +- src/xrpld/overlay/detail/PeerImp.cpp | 58 +++++-- src/xrpld/overlay/detail/ProtocolMessage.h | 4 +- src/xrpld/overlay/detail/TrafficCount.h | 4 +- src/xrpld/overlay/detail/ZeroCopyStream.h | 5 +- src/xrpld/peerfinder/detail/Bootcache.cpp | 8 +- src/xrpld/peerfinder/detail/Counts.h | 15 +- src/xrpld/peerfinder/detail/Handouts.h | 4 +- src/xrpld/peerfinder/detail/Livecache.h | 12 +- src/xrpld/peerfinder/detail/Logic.h | 41 +++-- src/xrpld/peerfinder/detail/SlotImp.cpp | 27 +++- src/xrpld/perflog/detail/PerfLogImp.cpp | 26 ++- src/xrpld/rpc/Status.h | 7 +- src/xrpld/rpc/detail/Handler.cpp | 13 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 25 ++- src/xrpld/rpc/detail/RPCHelpers.h | 4 +- src/xrpld/rpc/detail/Role.cpp | 4 +- src/xrpld/rpc/detail/ShardArchiveHandler.cpp | 9 +- src/xrpld/rpc/detail/Status.cpp | 4 +- src/xrpld/rpc/detail/TransactionSign.cpp | 4 +- src/xrpld/rpc/handlers/AMMInfo.cpp | 8 +- src/xrpld/rpc/handlers/AccountChannels.cpp | 2 +- src/xrpld/rpc/handlers/AccountInfo.cpp | 8 +- src/xrpld/rpc/handlers/AccountLines.cpp | 2 +- src/xrpld/rpc/handlers/AccountOffers.cpp | 2 +- src/xrpld/rpc/handlers/AccountTx.cpp | 11 +- src/xrpld/rpc/handlers/Fee1.cpp | 2 +- src/xrpld/rpc/handlers/LedgerClosed.cpp | 2 +- src/xrpld/rpc/handlers/LedgerDiff.cpp | 4 +- src/xrpld/rpc/handlers/LedgerHandler.cpp | 7 +- src/xrpld/rpc/handlers/NodeToShard.cpp | 2 +- src/xrpld/rpc/handlers/PayChanClaim.cpp | 4 +- src/xrpld/rpc/handlers/Tx.cpp | 19 ++- src/xrpld/shamap/SHAMap.h | 13 +- src/xrpld/shamap/SHAMapItem.h | 4 +- src/xrpld/shamap/detail/SHAMap.cpp | 141 ++++++++++++----- src/xrpld/shamap/detail/SHAMapDelta.cpp | 12 +- src/xrpld/shamap/detail/SHAMapInnerNode.cpp | 103 ++++++++---- src/xrpld/shamap/detail/SHAMapLeafNode.cpp | 19 ++- src/xrpld/shamap/detail/SHAMapNodeID.cpp | 23 ++- src/xrpld/shamap/detail/SHAMapSync.cpp | 25 ++- src/xrpld/shamap/detail/ShardFamily.cpp | 2 +- src/xrpld/shamap/detail/TaggedPointer.ipp | 31 +++- 241 files changed, 2521 insertions(+), 984 deletions(-) diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index 08e01b2f6be..8fd82e91255 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -113,8 +113,9 @@ class Buffer { // Ensure the slice isn't a subset of the buffer. XRPL_ASSERT( + "ripple::Buffer::operator=(Slice) : input not a subset", s.size() == 0 || size_ == 0 || s.data() < p_.get() || - s.data() >= p_.get() + size_); + s.data() >= p_.get() + size_); if (auto p = alloc(s.size())) std::memcpy(p, s.data(), s.size()); diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 0a74d881089..642a90fa723 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -417,9 +417,13 @@ mulDivU(Source1 value, Dest mul, Source2 div) { // split the asserts so if one hits, the user can tell which // without a debugger. - XRPL_ASSERT(value.value() >= 0); - XRPL_ASSERT(mul.value() >= 0); - XRPL_ASSERT(div.value() >= 0); + XRPL_ASSERT( + "ripple::feeunit::mulDivU : minimum value input", + value.value() >= 0); + XRPL_ASSERT( + "ripple::feeunit::mulDivU : minimum mul input", mul.value() >= 0); + XRPL_ASSERT( + "ripple::feeunit::mulDivU : minimum div input", div.value() >= 0); return std::nullopt; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index d247456f647..9df93dc5681 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -20,6 +20,7 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED +#include #include #include @@ -32,6 +33,7 @@ #include #include #include +#include #if BOOST_OS_LINUX #include @@ -141,7 +143,9 @@ class SlabAllocator void deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT(own(ptr)); + XRPL_ASSERT( + "ripple::SlabAllocator::SlabBlock::deallocate : own input", + own(ptr)); std::lock_guard l(m_); @@ -184,7 +188,9 @@ class SlabAllocator boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { - XRPL_ASSERT((itemAlignment_ & (itemAlignment_ - 1)) == 0); + XRPL_ASSERT( + "ripple::SlabAllocator::SlabAllocator : valid alignment", + (itemAlignment_ & (itemAlignment_ - 1)) == 0); } SlabAllocator(SlabAllocator const& other) = delete; @@ -294,7 +300,9 @@ class SlabAllocator bool deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT(ptr); + XRPL_ASSERT( + "ripple::SlabAllocator::SlabAllocator::deallocate : non-null input", + ptr); for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) { diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index 86977d2a23a..cdf56e58b21 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -103,7 +103,9 @@ class Slice std::uint8_t operator[](std::size_t i) const noexcept { - XRPL_ASSERT(i < size_); + XRPL_ASSERT( + "ripple::Slice::operator[](std::size_t) const : input within range", + i < size_); return data_[i]; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index f204235ebee..8114e496989 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -291,6 +291,7 @@ class base_uint explicit base_uint(Container const& c) { XRPL_ASSERT( + "ripple::base_uint::base_uint(Container auto) : input size match", c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); } @@ -303,6 +304,7 @@ class base_uint operator=(Container const& c) { XRPL_ASSERT( + "ripple::base_uint::operator=(Container auto) : input size match", c.size() * sizeof(typename Container::value_type) == size()); std::memcpy(data_.data(), c.data(), size()); return *this; diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index a7672a74140..606bdd92d1a 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -246,7 +246,10 @@ class partitioned_unordered_map ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); - XRPL_ASSERT(partitions_); + XRPL_ASSERT( + "ripple::partitioned_unordered_map::partitioned_unordered_map : " + "nonzero partitions", + partitions_); } std::size_t diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index aa042979557..20209231d35 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -114,7 +114,7 @@ std::enable_if_t< Integral> rand_int(Engine& engine, Integral min, Integral max) { - XRPL_ASSERT(max > min); + XRPL_ASSERT("ripple::rand_int : max over min inputs", max > min); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index b4c84e832f1..663f6c733a3 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -117,7 +117,9 @@ class packed_spinlock packed_spinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { - XRPL_ASSERT(index >= 0 && (mask_ != 0)); + XRPL_ASSERT( + "ripple::packed_spinlock::packed_spinlock : valid index and mask", + index >= 0 && (mask_ != 0)); } [[nodiscard]] bool diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index b38a228efbd..7117d2223a5 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -174,7 +174,10 @@ class io_latency_probe , m_repeat(repeat) , m_probe(probe) { - XRPL_ASSERT(m_probe); + XRPL_ASSERT( + "beast::io_latency_probe::sample_op::sample_op : non-null " + "probe input", + m_probe); m_probe->addref(); } @@ -184,7 +187,10 @@ class io_latency_probe , m_repeat(from.m_repeat) , m_probe(from.m_probe) { - XRPL_ASSERT(m_probe); + XRPL_ASSERT( + "beast::io_latency_probe::sample_op::sample_op(sample_op&&) : " + "non-null probe input", + m_probe); from.m_probe = nullptr; } diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index 59bbefc6a89..5ff4504f788 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -61,7 +61,9 @@ class manual_clock : public abstract_clock void set(time_point const& when) { - XRPL_ASSERT(!Clock::is_steady || when >= now_); + XRPL_ASSERT( + "beast::manual_clock::set(time_point) : forward input", + !Clock::is_steady || when >= now_); now_ = when; } @@ -78,7 +80,9 @@ class manual_clock : public abstract_clock void advance(std::chrono::duration const& elapsed) { - XRPL_ASSERT(!Clock::is_steady || (now_ + elapsed) >= now_); + XRPL_ASSERT( + "beast::manual_clock::advance(duration) : forward input", + !Clock::is_steady || (now_ + elapsed) >= now_); now_ += elapsed; } diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 5744f0aad21..9131351f5fb 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1329,7 +1329,10 @@ class aged_unordered_container size_type bucket(Key const& k) const { - XRPL_ASSERT(bucket_count() != 0); + XRPL_ASSERT( + "beast::detail::aged_unordered_container::bucket : nonzero bucket " + "count", + bucket_count() != 0); return m_cont.bucket(k, std::cref(m_config.hash_function())); } @@ -1470,7 +1473,10 @@ class aged_unordered_container { if (would_exceed(additional)) m_buck.resize(size() + additional, m_cont); - XRPL_ASSERT(load_factor() <= max_load_factor()); + XRPL_ASSERT( + "beast::detail::aged_unordered_container::maybe_rehash : maximum " + "load factor", + load_factor() <= max_load_factor()); } // map, set diff --git a/include/xrpl/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h index 747a3a0ae0a..f5a380ce541 100644 --- a/include/xrpl/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -160,7 +160,8 @@ struct LexicalCast bool operator()(Out& out, char const* in) const { - XRPL_ASSERT(in); + XRPL_ASSERT( + "beast::detail::LexicalCast(char const*) : non-null input", in); return LexicalCast()(out, in); } }; @@ -175,7 +176,7 @@ struct LexicalCast bool operator()(Out& out, char* in) const { - XRPL_ASSERT(in); + XRPL_ASSERT("beast::detail::LexicalCast(char*) : non-null input", in); return LexicalCast()(out, in); } }; diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index 57019c5d099..f16c204f7ff 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -96,7 +96,7 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept else if (addr.is_v6()) hash_append(h, addr.to_v6().to_bytes()); else - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("beast::hash_append : invalid address type"); } } // namespace beast diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 5adb416e611..5e5b9a6cedd 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -205,7 +205,9 @@ class Journal */ Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) { - XRPL_ASSERT(m_level < severities::kDisabled); + XRPL_ASSERT( + "beast::Journal::Stream::Stream : maximum level", + m_level < severities::kDisabled); } /** Construct or copy another Stream. */ diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index 9a0beb0e5a5..4adac878a04 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -36,11 +36,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #ifndef NDEBUG -#define XRPL_ASSERT(...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), "", {}) -#define XRPL_UNREACHABLE() UNREACHABLE("", {}) +#define XRPL_ASSERT(M, ...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), M, {}) +#define XRPL_UNREACHABLE(M) UNREACHABLE(M, {}) #else #define XRPL_ASSERT(...) -#define XRPL_UNREACHABLE() +#define XRPL_UNREACHABLE(M) #endif #endif diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index f049f84ee80..e66bfa3f466 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -42,7 +42,8 @@ rngfill(void* buffer, std::size_t bytes, Generator& g) bytes -= sizeof(v); } - XRPL_ASSERT(bytes < sizeof(result_type)); + XRPL_ASSERT( + "beast::rngfill(void*) : maximum bytes", bytes < sizeof(result_type)); #ifdef __GNUC__ // gcc 11.1 (falsely) warns about an array-bounds overflow in release mode. diff --git a/include/xrpl/json/detail/json_assert.h b/include/xrpl/json/detail/json_assert.h index 10074062d90..264bcd90f3d 100644 --- a/include/xrpl/json/detail/json_assert.h +++ b/include/xrpl/json/detail/json_assert.h @@ -22,9 +22,6 @@ #include -#define JSON_ASSERT_UNREACHABLE XRPL_UNREACHABLE() -#define JSON_ASSERT(condition) \ - XRPL_ASSERT(condition); // @todo <= change this into an exception throw #define JSON_ASSERT_MESSAGE(condition, message) \ if (!(condition)) \ ripple::Throw(message); diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index e8c7a53c131..16de1a435c3 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -59,7 +59,9 @@ toSTAmount(XRPAmount const& xrp) inline STAmount toSTAmount(XRPAmount const& xrp, Issue const& iss) { - XRPL_ASSERT(isXRP(iss.account) && isXRP(iss.currency)); + XRPL_ASSERT( + "ripple::toSTAmount : is XRP", + isXRP(iss.account) && isXRP(iss.currency)); return toSTAmount(xrp); } @@ -78,12 +80,14 @@ template <> inline IOUAmount toAmount(STAmount const& amt) { - XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::toAmount : maximum mantissa", + amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT(!isXRP(amt)); + XRPL_ASSERT("ripple::toAmount : is not XRP", !isXRP(amt)); return IOUAmount(sMant, amt.exponent()); } @@ -91,12 +95,14 @@ template <> inline XRPAmount toAmount(STAmount const& amt) { - XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::toAmount : maximum mantissa", + amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT(isXRP(amt)); + XRPL_ASSERT("ripple::toAmount : is XRP", isXRP(amt)); return XRPAmount(sMant); } diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 481efcd111b..cbaebe34131 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -151,14 +151,19 @@ class FeatureBitset : private std::bitset explicit FeatureBitset(base const& b) : base(b) { - XRPL_ASSERT(b.count() == count()); + XRPL_ASSERT( + "ripple::FeatureBitset::FeatureBitset(base) : count match", + b.count() == count()); } template explicit FeatureBitset(uint256 const& f, Fs&&... fs) { initFromFeatures(f, std::forward(fs)...); - XRPL_ASSERT(count() == (sizeof...(fs) + 1)); + XRPL_ASSERT( + "ripple::FeatureBitset::FeatureBitset(uint256) : count and " + "sizeof... do match", + count() == (sizeof...(fs) + 1)); } template @@ -166,7 +171,10 @@ class FeatureBitset : private std::bitset { for (auto const& f : fs) set(featureToBitsetIndex(f)); - XRPL_ASSERT(fs.size() == count()); + XRPL_ASSERT( + "ripple::FeatureBitset::FeatureBitset(Container auto) : count and " + "size do match", + fs.size() == count()); } auto diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index 40116d9638c..aabee9a2f9a 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -214,7 +214,8 @@ page(uint256 const& root, std::uint64_t index = 0) noexcept; inline Keylet page(Keylet const& root, std::uint64_t index = 0) noexcept { - XRPL_ASSERT(root.type == ltDIR_NODE); + XRPL_ASSERT( + "ripple::keylet::page : valid root type", root.type == ltDIR_NODE); return page(root.key, index); } /** @} */ diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 7b6a678d0fa..7d7a160ae13 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -159,6 +159,8 @@ struct MultiApiJson invoke_result_t { XRPL_ASSERT( + "ripple::detail::MultiApiJson::operator() : valid " + "version", valid(version) && index(version) >= 0 && index(version) < size); return std::invoke( fn, @@ -176,6 +178,7 @@ struct MultiApiJson -> std::invoke_result_t { XRPL_ASSERT( + "ripple::detail::MultiApiJson::operator() : valid version", valid(version) && index(version) >= 0 && index(version) < size); return std::invoke(fn, json.val[index(version)]); } diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 9fee7fd4cf8..781756b436a 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -298,7 +298,9 @@ class Quality friend double relativeDistance(Quality const& q1, Quality const& q2) { - XRPL_ASSERT(q1.m_value > 0 && q2.m_value > 0); + XRPL_ASSERT( + "ripple::Quality::relativeDistance : minimum inputs", + q1.m_value > 0 && q2.m_value > 0); if (q1.m_value == q2.m_value) // make expected common case fast return 0; diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index e810c784dc0..a8bcb3b3834 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -162,8 +162,11 @@ template void STBitString::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == getSType()); + XRPL_ASSERT( + "ripple::STBitString::add : field is binary", getFName().isBinary()); + XRPL_ASSERT( + "ripple::STBitString::add : field type match", + getFName().fieldType == getSType()); s.addBitString(value_); } diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 747d9a9dddb..733d3c8bd9b 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -110,8 +110,11 @@ template inline void STInteger::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == getSType()); + XRPL_ASSERT( + "ripple::STInteger::add : field is binary", getFName().isBinary()); + XRPL_ASSERT( + "ripple::STInteger::add : field type match", + getFName().fieldType == getSType()); s.addInteger(value_); } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 4e2094695c0..2884960ae0a 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -715,7 +715,7 @@ STObject::Proxy::assign(U&& u) t = dynamic_cast(st_->getPField(*f_, true)); else t = dynamic_cast(st_->makeFieldPresent(*f_)); - XRPL_ASSERT(t); + XRPL_ASSERT("ripple::STObject::Proxy::assign : type cast succeeded", t); *t = std::forward(u); } @@ -993,13 +993,19 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - XRPL_ASSERT(mType); - XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT( + "ripple::STObject::at(TypedField auto) : field template non-null", + mType); + XRPL_ASSERT( + "ripple::STObject::at(TypedField auto) : type not present", + b->getSType() == STI_NOTPRESENT); if (mType->style(f) == soeOPTIONAL) Throw("Missing optional field: " + f.getName()); - XRPL_ASSERT(mType->style(f) == soeDEFAULT); + XRPL_ASSERT( + "ripple::STObject::at(TypedField auto) : template style is default", + mType->style(f) == soeDEFAULT); // Used to help handle the case where value_type is a const reference, // otherwise we would return the address of a temporary. @@ -1017,11 +1023,19 @@ STObject::at(OptionaledField const& of) const auto const u = dynamic_cast(b); if (!u) { - XRPL_ASSERT(mType); - XRPL_ASSERT(b->getSType() == STI_NOTPRESENT); + XRPL_ASSERT( + "ripple::STObject::at(OptionaledField auto) : field template " + "non-null", + mType); + XRPL_ASSERT( + "ripple::STObject::at(OptionaledField auto) : type not present", + b->getSType() == STI_NOTPRESENT); if (mType->style(*of.f) == soeOPTIONAL) return std::nullopt; - XRPL_ASSERT(mType->style(*of.f) == soeDEFAULT); + XRPL_ASSERT( + "ripple::STObject::at(OptionaledField auto) : template style is " + "default", + mType->style(*of.f) == soeDEFAULT); return typename T::value_type{}; } return u->value(); diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index 7792f59983f..bbd69f7d202 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -257,7 +257,9 @@ inline STPathElement::STPathElement( is_offer_ = false; mAccountID = *account; mType |= typeAccount; - XRPL_ASSERT(mAccountID != noAccount()); + XRPL_ASSERT( + "ripple::STPathElement::STPathElement : account is set", + mAccountID != noAccount()); } if (currency) @@ -270,7 +272,9 @@ inline STPathElement::STPathElement( { mIssuerID = *issuer; mType |= typeIssuer; - XRPL_ASSERT(mIssuerID != noAccount()); + XRPL_ASSERT( + "ripple::STPathElement::STPathElement : issuer is set", + mIssuerID != noAccount()); } hash_value_ = get_hash(*this); diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index a28bcd3b6e5..f93358dfb33 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -176,7 +176,9 @@ STValidation::STValidation( Throw("Invalid signature in validation"); } - XRPL_ASSERT(nodeID_.isNonZero()); + XRPL_ASSERT( + "ripple::STValidation::STValidation(SerialIter) : nonzero node", + nodeID_.isNonZero()); } /** Construct, sign and trust a new STValidation issued by this node. @@ -199,7 +201,10 @@ STValidation::STValidation( , nodeID_(nodeID) , seenTime_(signTime) { - XRPL_ASSERT(nodeID_.isNonZero()); + XRPL_ASSERT( + "ripple::STValidation::STValidation(PublicKey, SecretKey) : nonzero " + "node", + nodeID_.isNonZero()); // First, set our own public key: if (publicKeyType(pk) != KeyType::secp256k1) diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index f72bd71a73a..aa637f92666 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -55,7 +55,9 @@ class Serializer if (size) { - XRPL_ASSERT(data != nullptr); + XRPL_ASSERT( + "ripple::Serializer::Serializer(void const*) : non-null input", + data != nullptr); std::memcpy(mData.data(), data, size); } } @@ -300,7 +302,8 @@ Serializer::addVL(Iter begin, Iter end, int len) len -= begin->size(); #endif } - XRPL_ASSERT(len == 0); + XRPL_ASSERT( + "ripple::Serializer::addVL : length matches distance", len == 0); return ret; } diff --git a/include/xrpl/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h index 32a0b3601a0..7b55836c332 100644 --- a/include/xrpl/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -116,7 +116,9 @@ class TxMeta STAmount getDeliveredAmount() const { - XRPL_ASSERT(hasDeliveredAmount()); + XRPL_ASSERT( + "ripple::TxMeta::getDeliveredAmount : non-null delivered amount", + hasDeliveredAmount()); return *mDelivered; } diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index bc07cac9b38..c6e80ba9cc4 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -126,7 +126,9 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) { // should never happen, but if it does then it seems natural to define // the a null set of numbers to be zero, so the remainder is also zero. - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::b58_fast::detail::inplace_bigint_div_rem : empty " + "numerator"); return 0; } @@ -142,8 +144,14 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) unsigned __int128 const denom128 = denom; unsigned __int128 const d = num / denom128; unsigned __int128 const r = num - (denom128 * d); - XRPL_ASSERT(d >> 64 == 0); - XRPL_ASSERT(r >> 64 == 0); + XRPL_ASSERT( + "ripple::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " + "valid division result", + d >> 64 == 0); + XRPL_ASSERT( + "ripple::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " + "valid remainder", + r >> 64 == 0); return {static_cast(d), static_cast(r)}; }; diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index b06ebe2ff95..a5b25e62f25 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -401,7 +401,9 @@ class Logic { std::lock_guard _(lock_); Entry& entry(iter->second); - XRPL_ASSERT(entry.refcount == 0); + XRPL_ASSERT( + "ripple::Resource::Logic::erase : entry not used", + entry.refcount == 0); inactive_.erase(inactive_.iterator_to(entry)); table_.erase(iter); } @@ -433,7 +435,9 @@ class Logic admin_.erase(admin_.iterator_to(entry)); break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::Resource::Logic::release : invalid entry " + "kind"); break; } inactive_.push_back(entry); diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 396f6151b93..2ab2b5236d4 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -25,14 +25,17 @@ #include #include #include +#include #include #include #include #include #include +#include #include +#include namespace ripple { @@ -509,7 +512,9 @@ template void BaseWSPeer::fail(error_code ec, String const& what) { - XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT( + "ripple::BaseWSPeer::fail : strand in this thread", + strand_.running_in_this_thread()); cancel_timer(); if (!ec_ && ec != boost::asio::error::operation_aborted) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 029fd8cfd62..6bd1a0b3d18 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -224,7 +224,7 @@ Logs::fromSeverity(beast::severities::Severity level) return lsERROR; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Logs::fromSeverity : invalid severity"); [[fallthrough]]; case kFatal: break; @@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level) case lsERROR: return kError; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Logs::toSeverity : invalid severity"); [[fallthrough]]; case lsFATAL: break; @@ -277,7 +277,7 @@ Logs::toString(LogSeverity s) case lsFATAL: return "Fatal"; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Logs::toString : invalid severity"); return "Unknown"; } } @@ -341,7 +341,7 @@ Logs::format( output += "ERR "; break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Logs::format : invalid severity"); [[fallthrough]]; case kFatal: output += "FTL "; diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 8f7dccd26f9..485414bf3c9 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -235,7 +235,9 @@ Number::operator+=(Number const& y) *this = Number{}; return *this; } - XRPL_ASSERT(isnormal() && y.isnormal()); + XRPL_ASSERT( + "ripple::Number::operator+=(Number) : is normal", + isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -374,7 +376,9 @@ Number::operator*=(Number const& y) *this = y; return *this; } - XRPL_ASSERT(isnormal() && y.isnormal()); + XRPL_ASSERT( + "ripple::Number::operator*=(Number) : is normal", + isnormal() && y.isnormal()); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -428,7 +432,9 @@ Number::operator*=(Number const& y) std::to_string(xe)); mantissa_ = xm * zn; exponent_ = xe; - XRPL_ASSERT(isnormal() || *this == Number{}); + XRPL_ASSERT( + "ripple::Number::operator*=(Number) : result is normal", + isnormal() || *this == Number{}); return *this; } @@ -531,7 +537,8 @@ to_string(Number const& amount) negative = true; } - XRPL_ASSERT(exponent + 43 > 0); + XRPL_ASSERT( + "ripple::to_string(Number) : minimum exponent", exponent + 43 > 0); ptrdiff_t const pad_prefix = 27; ptrdiff_t const pad_suffix = 23; @@ -557,7 +564,9 @@ to_string(Number const& amount) if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT( + "ripple::to_string(Number) : first distance check", + post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -566,7 +575,9 @@ to_string(Number const& amount) if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT( + "ripple::to_string(Number) : second distance check", + post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index b6351530596..915f90dd71a 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -48,7 +48,9 @@ class AsyncObject ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - XRPL_ASSERT(m_pending.load() == 0); + XRPL_ASSERT( + "ripple::AsyncObject::~AsyncObject : nothing pending", + m_pending.load() == 0); } /** RAII container that maintains the count of pending I/O. @@ -153,8 +155,11 @@ class ResolverAsioImpl : public ResolverAsio, ~ResolverAsioImpl() override { - XRPL_ASSERT(m_work.empty()); - XRPL_ASSERT(m_stopped); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::~ResolverAsioImpl : no pending work", + m_work.empty()); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::~ResolverAsioImpl : stopped", m_stopped); } //------------------------------------------------------------------------- @@ -176,8 +181,11 @@ class ResolverAsioImpl : public ResolverAsio, void start() override { - XRPL_ASSERT(m_stopped == true); - XRPL_ASSERT(m_stop_called == false); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::start : stopped", m_stopped == true); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::start : not stopping", + m_stop_called == false); if (m_stopped.exchange(false) == true) { @@ -217,8 +225,12 @@ class ResolverAsioImpl : public ResolverAsio, resolve(std::vector const& names, HandlerType const& handler) override { - XRPL_ASSERT(m_stop_called == false); - XRPL_ASSERT(!names.empty()); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::resolve : not stopping", + m_stop_called == false); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::resolve : names non-empty", + !names.empty()); // TODO NIKB use rvalue references to construct and move // reducing cost. @@ -234,7 +246,9 @@ class ResolverAsioImpl : public ResolverAsio, // Resolver void do_stop(CompletionCounter) { - XRPL_ASSERT(m_stop_called == true); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::do_stop : stopping", + m_stop_called == true); if (m_stopped.exchange(true) == false) { @@ -379,7 +393,9 @@ class ResolverAsioImpl : public ResolverAsio, HandlerType const& handler, CompletionCounter) { - XRPL_ASSERT(!names.empty()); + XRPL_ASSERT( + "ripple::ResolverAsioImpl::do_resolve : names non-empty", + !names.empty()); if (m_stop_called == false) { diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index 3f3f819033b..c9333678cf1 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -57,7 +57,9 @@ static_assert(std::atomic::is_always_lock_free); seconds_clock_thread::~seconds_clock_thread() { - XRPL_ASSERT(thread_.joinable()); + XRPL_ASSERT( + "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable", + thread_.joinable()); { std::lock_guard lock(mut_); stop_ = true; diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index 8ec30a4133f..ad7ecfc0d3b 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -304,7 +304,8 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) if (isNumeric(left)) { - XRPL_ASSERT(isNumeric(right)); + XRPL_ASSERT( + "beast::compare : both inputs numeric", isNumeric(right)); int const iLeft(lexicalCastThrow(left)); int const iRight(lexicalCastThrow(right)); @@ -316,7 +317,9 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) } else { - XRPL_ASSERT(!isNumeric(right)); + XRPL_ASSERT( + "beast::compare : both inputs non-numeric", + !isNumeric(right)); int result = left.compare(right); diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index d5b52b92a34..28dbe276a6a 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -400,7 +400,10 @@ class StatsDCollectorImp for (auto const& s : *keepAlive) { std::size_t const length(s.size()); - XRPL_ASSERT(!s.empty()); + XRPL_ASSERT( + "beast::insight::detail::StatsDCollectorImp::send_buffers : " + "non-empty payload", + !s.empty()); if (!buffers.empty() && (size + length) > max_packet_size) { log(buffers); diff --git a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index 436ec617560..57181268713 100644 --- a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -199,7 +199,9 @@ PropertyStream::Source::add(Source& source) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(source.lock_, std::adopt_lock); - XRPL_ASSERT(source.parent_ == nullptr); + XRPL_ASSERT( + "beast::PropertyStream::Source::add : null source parent", + source.parent_ == nullptr); children_.push_back(source.item_); source.parent_ = this; } @@ -211,7 +213,9 @@ PropertyStream::Source::remove(Source& child) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(child.lock_, std::adopt_lock); - XRPL_ASSERT(child.parent_ == this); + XRPL_ASSERT( + "beast::PropertyStream::Source::remove : child parent match", + child.parent_ == this); children_.erase(children_.iterator_to(child.item_)); child.parent_ = nullptr; } diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index 74e2dad3a09..6bbdc79131b 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -270,10 +270,12 @@ RFC1751::extract(char const* s, int start, int length) unsigned char cr; unsigned long x; - XRPL_ASSERT(length <= 11); - XRPL_ASSERT(start >= 0); - XRPL_ASSERT(length >= 0); - XRPL_ASSERT(start + length <= 66); + XRPL_ASSERT("ripple::RFC1751::extract : maximum length", length <= 11); + XRPL_ASSERT("ripple::RFC1751::extract : minimum start", start >= 0); + XRPL_ASSERT("ripple::RFC1751::extract : minimum length", length >= 0); + XRPL_ASSERT( + "ripple::RFC1751::extract : maximum start + length", + start + length <= 66); int const shiftR = 24 - (length + (start % 8)); cl = s[start / 8]; // get components @@ -320,10 +322,12 @@ RFC1751::insert(char* s, int x, int start, int length) unsigned long y; int shift; - XRPL_ASSERT(length <= 11); - XRPL_ASSERT(start >= 0); - XRPL_ASSERT(length >= 0); - XRPL_ASSERT(start + length <= 66); + XRPL_ASSERT("ripple::RFC1751::insert : maximum length", length <= 11); + XRPL_ASSERT("ripple::RFC1751::insert : minimum start", start >= 0); + XRPL_ASSERT("ripple::RFC1751::insert : minimum length", length >= 0); + XRPL_ASSERT( + "ripple::RFC1751::insert : maximum start + length", + start + length <= 66); shift = ((8 - ((start + length) % 8)) % 8); y = (long)x << shift; diff --git a/src/libxrpl/json/Object.cpp b/src/libxrpl/json/Object.cpp index 8e726f216f3..19cc482ffac 100644 --- a/src/libxrpl/json/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -168,7 +168,7 @@ Array::append(Json::Value const& v) return; } } - XRPL_UNREACHABLE(); // Can't get here. + XRPL_UNREACHABLE("Json::Array::append : invalid type"); // Can't get here. } void @@ -203,7 +203,7 @@ Object::set(std::string const& k, Json::Value const& v) return; } } - XRPL_UNREACHABLE(); // Can't get here. + XRPL_UNREACHABLE("Json::Object::set : invalid type"); // Can't get here. } //------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ template void doCopyFrom(Object& to, Json::Value const& from) { - XRPL_ASSERT(from.isObjectOrNull()); + XRPL_ASSERT("Json::doCopyFrom : valid input type", from.isObjectOrNull()); auto members = from.getMemberNames(); for (auto& m : members) to[m] = from[m]; diff --git a/src/libxrpl/json/json_reader.cpp b/src/libxrpl/json/json_reader.cpp index 42488b3ec87..9e4c429b82c 100644 --- a/src/libxrpl/json/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -953,7 +953,7 @@ operator>>(std::istream& sin, Value& root) Json::Reader reader; bool ok = reader.parse(sin, root); - // JSON_ASSERT( ok ); + // XRPL_ASSERT( ok ); if (!ok) ripple::Throw(reader.getFormatedErrorMessages()); diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index 155c3e1e044..a292805a64b 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -207,7 +207,7 @@ Value::Value(ValueType type) : type_(type), allocated_(0) break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::Value(ValueType) : invalid type"); } } @@ -277,7 +277,7 @@ Value::Value(const Value& other) : type_(other.type_) break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::Value(Value const&) : invalid type"); } } @@ -305,7 +305,7 @@ Value::~Value() break; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::~Value : invalid type"); } } @@ -406,7 +406,7 @@ operator<(const Value& x, const Value& y) } default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::operator<(Value, Value) : invalid type"); } return 0; // unreachable @@ -452,7 +452,7 @@ operator==(const Value& x, const Value& y) *x.value_.map_ == *y.value_.map_; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::operator==(Value, Value) : invalid type"); } return 0; // unreachable @@ -461,7 +461,7 @@ operator==(const Value& x, const Value& y) const char* Value::asCString() const { - JSON_ASSERT(type_ == stringValue); + XRPL_ASSERT("Json::Value::asCString : valid type", type_ == stringValue); return value_.string_; } @@ -493,7 +493,7 @@ Value::asString() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to string"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asString : invalid type"); } return ""; // unreachable @@ -535,7 +535,7 @@ Value::asInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to int"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asInt : invalid type"); } return 0; // unreachable; @@ -577,7 +577,7 @@ Value::asUInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to uint"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asUInt : invalid type"); } return 0; // unreachable; @@ -609,7 +609,7 @@ Value::asDouble() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to double"); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asDouble : invalid type"); } return 0; // unreachable; @@ -641,7 +641,7 @@ Value::asBool() const return value_.map_->size() != 0; default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::asBool : invalid type"); } return false; // unreachable; @@ -695,7 +695,7 @@ Value::isConvertibleTo(ValueType other) const (other == nullValue && value_.map_->size() == 0); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::isConvertible : invalid type"); } return false; // unreachable; @@ -729,7 +729,7 @@ Value::size() const return Int(value_.map_->size()); default: - JSON_ASSERT_UNREACHABLE; + XRPL_UNREACHABLE("Json::Value::size : invalid type"); } return 0; // unreachable; @@ -752,7 +752,8 @@ Value::operator bool() const void Value::clear() { - JSON_ASSERT( + XRPL_ASSERT( + "Json::Value::clear : valid type", type_ == nullValue || type_ == arrayValue || type_ == objectValue); switch (type_) @@ -770,7 +771,9 @@ Value::clear() Value& Value::operator[](UInt index) { - JSON_ASSERT(type_ == nullValue || type_ == arrayValue); + XRPL_ASSERT( + "Json::Value::operator[](UInt) : valid type", + type_ == nullValue || type_ == arrayValue); if (type_ == nullValue) *this = Value(arrayValue); @@ -789,7 +792,9 @@ Value::operator[](UInt index) const Value& Value::operator[](UInt index) const { - JSON_ASSERT(type_ == nullValue || type_ == arrayValue); + XRPL_ASSERT( + "Json::Value::operator[](UInt) const : valid type", + type_ == nullValue || type_ == arrayValue); if (type_ == nullValue) return null; @@ -812,7 +817,9 @@ Value::operator[](const char* key) Value& Value::resolveReference(const char* key, bool isStatic) { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT( + "Json::Value::resolveReference : valid type", + type_ == nullValue || type_ == objectValue); if (type_ == nullValue) *this = Value(objectValue); @@ -846,7 +853,9 @@ Value::isValidIndex(UInt index) const const Value& Value::operator[](const char* key) const { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT( + "Json::Value::operator[](const char*) const : valid type", + type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return null; @@ -906,7 +915,9 @@ Value::get(std::string const& key, const Value& defaultValue) const Value Value::removeMember(const char* key) { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT( + "Json::Value::removeMember : valid type", + type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return null; @@ -947,7 +958,9 @@ Value::isMember(std::string const& key) const Value::Members Value::getMemberNames() const { - JSON_ASSERT(type_ == nullValue || type_ == objectValue); + XRPL_ASSERT( + "Json::Value::getMemberNames : valid type", + type_ == nullValue || type_ == objectValue); if (type_ == nullValue) return Value::Members(); diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 5f852b241f0..11cfc3671e4 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -70,7 +70,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - XRPL_ASSERT(current >= buffer); + XRPL_ASSERT("Json::valueToString(Int) : buffer check", current >= buffer); return current; } @@ -80,7 +80,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); uintToString(value, current); - XRPL_ASSERT(current >= buffer); + XRPL_ASSERT("Json::valueToString(UInt) : buffer check", current >= buffer); return current; } @@ -391,7 +391,9 @@ StyledWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT(childValues_.size() == size); + XRPL_ASSERT( + "Json::StyledWriter::writeArrayValue : child size match", + childValues_.size() == size); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -483,7 +485,9 @@ StyledWriter::indent() void StyledWriter::unindent() { - XRPL_ASSERT(int(indentString_.size()) >= indentSize_); + XRPL_ASSERT( + "Json::StyledWriter::unindent : maximum indent size", + int(indentString_.size()) >= indentSize_); indentString_.resize(indentString_.size() - indentSize_); } @@ -613,7 +617,9 @@ StyledStreamWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT(childValues_.size() == size); + XRPL_ASSERT( + "Json::StyledStreamWriter::writeArrayValue : child size match", + childValues_.size() == size); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -706,7 +712,9 @@ StyledStreamWriter::indent() void StyledStreamWriter::unindent() { - XRPL_ASSERT(indentString_.size() >= indentation_.size()); + XRPL_ASSERT( + "Json::StyledStreamWriter::unindent : maximum indent size", + indentString_.size() >= indentation_.size()); indentString_.resize(indentString_.size() - indentation_.size()); } diff --git a/src/libxrpl/protocol/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp index 9934df24a13..d122f84a9e8 100644 --- a/src/libxrpl/protocol/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -109,7 +109,9 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot) // It should be impossible for expiration to be < TOTAL_TIME_SLOT_SECS, // but check just to be safe auto const expiration = auctionSlot[sfExpiration]; - XRPL_ASSERT(expiration >= TOTAL_TIME_SLOT_SECS); + XRPL_ASSERT( + "ripple::ammAuctionTimeSlot : minimum expiration", + expiration >= TOTAL_TIME_SLOT_SECS); if (expiration >= TOTAL_TIME_SLOT_SECS) { if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; diff --git a/src/libxrpl/protocol/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp index ab13bfc4c37..46ff2dee8a3 100644 --- a/src/libxrpl/protocol/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -77,7 +77,9 @@ class AccountIdCache auto ret = encodeBase58Token(TokenType::AccountID, id.data(), id.size()); - XRPL_ASSERT(ret.size() <= 38); + XRPL_ASSERT( + "ripple::detail::AccountIdCache : maximum result size", + ret.size() <= 38); { std::lock_guard lock(sl); diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 073dabd6ec1..46f2a7f69da 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -212,7 +212,9 @@ error_code_http_status(error_code_i code) std::string rpcErrorString(Json::Value const& jv) { - XRPL_ASSERT(RPC::contains_error(jv)); + XRPL_ASSERT( + "ripple::RPC::rpcErrorString : input contains an error", + RPC::contains_error(jv)); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 94b2bed7862..4700d803592 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -221,7 +221,9 @@ FeatureCollections::FeatureCollections() std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT( + "ripple::FeatureCollections::getRegisteredFeature : startup completed", + readOnly); Feature const* feature = getByName(name); if (feature) return feature->feature; @@ -303,7 +305,9 @@ FeatureCollections::registrationIsDone() size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT( + "ripple::FeatureCollections::featureToBitsetIndex : startup completed", + readOnly); Feature const* feature = getByFeature(f); if (!feature) @@ -315,7 +319,9 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT( + "ripple::FeatureCollections::bitsetIndexToFeature : startup completed", + readOnly); Feature const& feature = getByIndex(i); return feature.feature; } @@ -323,7 +329,9 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - XRPL_ASSERT(readOnly); + XRPL_ASSERT( + "ripple::FeatureCollections::featureToName : startup completed", + readOnly); Feature const* feature = getByFeature(f); return feature ? feature->name : to_string(f); } diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 5389d12d8a9..435e3ba9a61 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -91,7 +91,8 @@ indexHash(LedgerNameSpace space, Args const&... args) uint256 getBookBase(Book const& book) { - XRPL_ASSERT(isConsistent(book)); + XRPL_ASSERT( + "ripple::getBookBase : input is consistent", isConsistent(book)); auto const index = indexHash( LedgerNameSpace::BOOK_DIR, @@ -131,7 +132,7 @@ getTicketIndex(AccountID const& account, std::uint32_t ticketSeq) uint256 getTicketIndex(AccountID const& account, SeqProxy ticketSeq) { - XRPL_ASSERT(ticketSeq.isTicket()); + XRPL_ASSERT("ripple::getTicketIndex : valid input", ticketSeq.isTicket()); return getTicketIndex(account, ticketSeq.value()); } @@ -237,7 +238,8 @@ offer(AccountID const& id, std::uint32_t seq) noexcept Keylet quality(Keylet const& k, std::uint64_t q) noexcept { - XRPL_ASSERT(k.type == ltDIR_NODE); + XRPL_ASSERT( + "ripple::keylet::quality : valid input type", k.type == ltDIR_NODE); // Indexes are stored in big endian format: they print as hex as stored. // Most significant bytes are first and the least significant bytes @@ -255,7 +257,9 @@ quality(Keylet const& k, std::uint64_t q) noexcept Keylet next_t::operator()(Keylet const& k) const { - XRPL_ASSERT(k.type == ltDIR_NODE); + XRPL_ASSERT( + "ripple::keylet::next_t::operator() : valid input type", + k.type == ltDIR_NODE); return {ltDIR_NODE, getQualityNext(k.key)}; } @@ -357,7 +361,8 @@ nftpage_max(AccountID const& owner) Keylet nftpage(Keylet const& k, uint256 const& token) { - XRPL_ASSERT(k.type == ltNFTOKEN_PAGE); + XRPL_ASSERT( + "ripple::keylet::nftpage : valid input type", k.type == ltNFTOKEN_PAGE); return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; } diff --git a/src/libxrpl/protocol/Keylet.cpp b/src/libxrpl/protocol/Keylet.cpp index 2c0fdd974e3..d2550b4d18e 100644 --- a/src/libxrpl/protocol/Keylet.cpp +++ b/src/libxrpl/protocol/Keylet.cpp @@ -25,7 +25,9 @@ namespace ripple { bool Keylet::check(STLedgerEntry const& sle) const { - XRPL_ASSERT(sle.getType() != ltANY || sle.getType() != ltCHILD); + XRPL_ASSERT( + "ripple::Keylet::check : valid input type", + sle.getType() != ltANY || sle.getType() != ltCHILD); if (type == ltANY) return true; diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index bdd0c84e54e..4fc38faba4b 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -35,7 +35,7 @@ Quality::Quality(Amounts const& amount) Quality& Quality::operator++() { - XRPL_ASSERT(m_value > 0); + XRPL_ASSERT("ripple::Quality::operator++() : minimum value", m_value > 0); --m_value; return *this; } @@ -51,7 +51,9 @@ Quality::operator++(int) Quality& Quality::operator--() { - XRPL_ASSERT(m_value < std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::Quality::operator--() : maximum value", + m_value < std::numeric_limits::max()); ++m_value; return *this; } @@ -81,10 +83,12 @@ ceil_in_impl( // Clamp out if (result.out > amount.out) result.out = amount.out; - XRPL_ASSERT(result.in == limit); + XRPL_ASSERT( + "ripple::ceil_in_impl : result matches limit", result.in == limit); return result; } - XRPL_ASSERT(amount.in <= limit); + XRPL_ASSERT( + "ripple::ceil_in_impl : result inside limit", amount.in <= limit); return amount; } @@ -120,10 +124,13 @@ ceil_out_impl( // Clamp in if (result.in > amount.in) result.in = amount.in; - XRPL_ASSERT(result.out == limit); + XRPL_ASSERT( + "ripple::ceil_out_impl : result matches limit", + result.out == limit); return result; } - XRPL_ASSERT(amount.out <= limit); + XRPL_ASSERT( + "ripple::ceil_out_impl : result inside limit", amount.out <= limit); return amount; } @@ -146,17 +153,23 @@ Quality composed_quality(Quality const& lhs, Quality const& rhs) { STAmount const lhs_rate(lhs.rate()); - XRPL_ASSERT(lhs_rate != beast::zero); + XRPL_ASSERT( + "ripple::composed_quality : nonzero left input", + lhs_rate != beast::zero); STAmount const rhs_rate(rhs.rate()); - XRPL_ASSERT(rhs_rate != beast::zero); + XRPL_ASSERT( + "ripple::composed_quality : nonzero right input", + rhs_rate != beast::zero); STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.issue(), true)); std::uint64_t const stored_exponent(rate.exponent() + 100); std::uint64_t const stored_mantissa(rate.mantissa()); - XRPL_ASSERT((stored_exponent > 0) && (stored_exponent <= 255)); + XRPL_ASSERT( + "ripple::composed_quality : valid exponent", + (stored_exponent > 0) && (stored_exponent <= 255)); return Quality((stored_exponent << (64 - 8)) | stored_mantissa); } diff --git a/src/libxrpl/protocol/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp index fe968c8bccc..553ad020fc1 100644 --- a/src/libxrpl/protocol/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -46,7 +46,7 @@ transferFeeAsRate(std::uint16_t fee) STAmount multiply(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("ripple::nft::multiply : nonzero rate input", rate.value != 0); if (rate == parityRate) return amount; @@ -57,7 +57,8 @@ multiply(STAmount const& amount, Rate const& rate) STAmount multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT( + "ripple::nft::multiplyRound : nonzero rate input", rate.value != 0); if (rate == parityRate) return amount; @@ -72,7 +73,9 @@ multiplyRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT( + "ripple::nft::multiplyRound(Issue) : nonzero rate input", + rate.value != 0); if (rate == parityRate) { @@ -85,7 +88,7 @@ multiplyRound( STAmount divide(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT("ripple::nft::divide : nonzero rate input", rate.value != 0); if (rate == parityRate) return amount; @@ -96,7 +99,8 @@ divide(STAmount const& amount, Rate const& rate) STAmount divideRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT( + "ripple::nft::divideRound : nonzero rate input", rate.value != 0); if (rate == parityRate) return amount; @@ -111,7 +115,9 @@ divideRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT(rate.value != 0); + XRPL_ASSERT( + "ripple::nft::divideRound(Issue) : nonzero rate input", + rate.value != 0); if (rate == parityRate) return amount; diff --git a/src/libxrpl/protocol/Rules.cpp b/src/libxrpl/protocol/Rules.cpp index 613f882d609..99e56f26684 100644 --- a/src/libxrpl/protocol/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -91,7 +91,10 @@ class Rules::Impl return true; if (!digest_ || !other.digest_) return false; - XRPL_ASSERT(presets_ == other.presets_); + XRPL_ASSERT( + "ripple::Rules::Impl::operator==(Impl) const : input presets do " + "match", + presets_ == other.presets_); return *digest_ == *other.digest_; } }; @@ -118,7 +121,7 @@ Rules::presets() const bool Rules::enabled(uint256 const& feature) const { - XRPL_ASSERT(impl_); + XRPL_ASSERT("ripple::Rules::enabled : initialized", impl_); // The functionality of the "NonFungibleTokensV1_1" amendment is // precisely the functionality of the following three amendments @@ -137,7 +140,9 @@ Rules::enabled(uint256 const& feature) const bool Rules::operator==(Rules const& other) const { - XRPL_ASSERT(impl_ && other.impl_); + XRPL_ASSERT( + "ripple::Rules::operator==(Rules) const : both initialized", + impl_ && other.impl_); if (impl_.get() == other.impl_.get()) return true; return *impl_ == *other.impl_; diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index cce005a5b3f..f1aff698b58 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -80,8 +80,11 @@ STAccount::getSType() const void STAccount::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == STI_ACCOUNT); + XRPL_ASSERT( + "ripple::STAccount::add : field is binary", getFName().isBinary()); + XRPL_ASSERT( + "ripple::STAccount::add : valid field type", + getFName().fieldType == STI_ACCOUNT); // Preserve the serialization behavior of an STBlob: // o If we are default (all zeros) serialize as an empty blob. diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index d23928a23de..3662d7a7349 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -70,7 +70,9 @@ getSNValue(STAmount const& amount) auto ret = static_cast(amount.mantissa()); - XRPL_ASSERT(static_cast(ret) == amount.mantissa()); + XRPL_ASSERT( + "ripple::getSNValue : mantissa roundtrip", + static_cast(ret) == amount.mantissa()); if (amount.negative()) ret = -ret; @@ -220,7 +222,10 @@ STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::STAmount::STAmount(SField, std::uint64_t, bool) : maximum " + "mantissa input", + mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -235,7 +240,10 @@ STAmount::STAmount( , mOffset(exponent) , mIsNegative(negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::STAmount::STAmount(SField, Issue, std::uint64_t, int, bool) : " + "maximum mantissa input", + mValue <= std::numeric_limits::max()); canonicalize(); } @@ -246,7 +254,9 @@ STAmount::STAmount(SField const& name, STAmount const& from) , mOffset(from.mOffset) , mIsNegative(from.mIsNegative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::STAmount::STAmount(SField, STAmount) : maximum input", + mValue <= std::numeric_limits::max()); canonicalize(); } @@ -258,7 +268,10 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(mantissa != 0 && negative) { - XRPL_ASSERT(mValue <= std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::STAmount::STAmount(std::uint64_t, bool) : maximum mantissa " + "input", + mValue <= std::numeric_limits::max()); } STAmount::STAmount( @@ -374,7 +387,9 @@ STAmount::iou() const STAmount& STAmount::operator=(IOUAmount const& iou) { - XRPL_ASSERT(mIsNative == false); + XRPL_ASSERT( + "ripple::STAmount::operator=(IOUAmount) : is not XRP", + mIsNative == false); mOffset = iou.exponent(); mIsNegative = iou < beast::zero; if (mIsNegative) @@ -512,7 +527,9 @@ getRate(STAmount const& offerOut, STAmount const& offerIn) STAmount r = divide(offerIn, offerOut, noIssue()); if (r == beast::zero) // offer is too good return 0; - XRPL_ASSERT((r.exponent() >= -100) && (r.exponent() <= 155)); + XRPL_ASSERT( + "ripple::getRate : exponent inside range", + (r.exponent() >= -100) && (r.exponent() <= 155)); std::uint64_t ret = r.exponent() + 100; return (ret << (64 - 8)) | r.mantissa(); } @@ -594,7 +611,7 @@ STAmount::getText() const return ret; } - XRPL_ASSERT(mOffset + 43 > 0); + XRPL_ASSERT("ripple::STAmount::getText : minimum offset", mOffset + 43 > 0); size_t const pad_prefix = 27; size_t const pad_suffix = 23; @@ -618,7 +635,9 @@ STAmount::getText() const if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT( + "ripple::STAmount::getText : first distance check", + post_to >= post_from); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -627,7 +646,9 @@ STAmount::getText() const if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT(post_to >= post_from); + XRPL_ASSERT( + "ripple::STAmount::getText : second distance check", + post_to >= post_from); post_to = std::find_if( std::make_reverse_iterator(post_to), @@ -662,7 +683,7 @@ STAmount::add(Serializer& s) const { if (mIsNative) { - XRPL_ASSERT(mOffset == 0); + XRPL_ASSERT("ripple::STAmount::add : zero offset", mOffset == 0); if (!mIsNegative) s.add64(mValue | cPosNative); @@ -824,10 +845,14 @@ STAmount::canonicalize() Throw("value overflow"); XRPL_ASSERT( + "ripple::STAmount::canonicalize : value inside range", (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); XRPL_ASSERT( + "ripple::STAmount::canonicalize : offset inside range", (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset))); - XRPL_ASSERT((mValue != 0) || (mOffset != -100)); + XRPL_ASSERT( + "ripple::STAmount::canonicalize : value or offset set", + (mValue != 0) || (mOffset != -100)); } void diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index 85607d5569d..3242c50f20b 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -20,7 +20,6 @@ #include #include #include -#include namespace ripple { @@ -30,7 +29,7 @@ STBase::STBase() : fName(&sfGeneric) STBase::STBase(SField const& n) : fName(&n) { - XRPL_ASSERT(fName); + XRPL_ASSERT("ripple::STBase::STBase : field is set", fName); } STBase& @@ -105,13 +104,15 @@ void STBase::add(Serializer& s) const { // Should never be called - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::STBase::add : not implemented"); } bool STBase::isEquivalent(const STBase& t) const { - XRPL_ASSERT(getSType() == STI_NOTPRESENT); + XRPL_ASSERT( + "ripple::STBase::isEquivalent : type not present", + getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; } @@ -125,7 +126,7 @@ void STBase::setFName(SField const& n) { fName = &n; - XRPL_ASSERT(fName); + XRPL_ASSERT("ripple::STBase::setFName : field is set", fName); } SField const& @@ -137,7 +138,8 @@ STBase::getFName() const void STBase::addFieldID(Serializer& s) const { - XRPL_ASSERT(fName->isBinary()); + XRPL_ASSERT( + "ripple::STBase::addFieldID : field is binary", fName->isBinary()); s.addFieldID(fName->fieldType, fName->fieldValue); } diff --git a/src/libxrpl/protocol/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp index 04480575f0f..eb3b72e7ab1 100644 --- a/src/libxrpl/protocol/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -54,10 +54,11 @@ STBlob::getText() const void STBlob::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); + XRPL_ASSERT("ripple::STBlob::add : field is binary", getFName().isBinary()); XRPL_ASSERT( + "ripple::STBlob::add : valid field type", (getFName().fieldType == STI_VL) || - (getFName().fieldType == STI_ACCOUNT)); + (getFName().fieldType == STI_ACCOUNT)); s.addVL(value_.data(), value_.size()); } diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 257c8248cf7..54f6049982d 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -196,7 +196,9 @@ Json::Value STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); - XRPL_ASSERT(ret.ec == std::errc()); + XRPL_ASSERT( + "ripple::STUInt64::getJson : to_chars succeeded", + ret.ec == std::errc()); str.resize(std::distance(str.data(), ret.ptr)); return str; } diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index aa1c5cb66f6..63524b2bda7 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -157,7 +157,9 @@ STLedgerEntry::thread( if (oldPrevTxID == txID) { // this transaction is already threaded - XRPL_ASSERT(getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); + XRPL_ASSERT( + "ripple::STLedgerEntry::thread : ledger sequence match", + getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); return false; } diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index dbb96fffbfd..55e5443be5b 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -843,8 +843,9 @@ STObject::add(Serializer& s, WhichFields whichFields) const // must be OBJECT, or the object cannot be deserialized SerializedTypeID const sType{field->getSType()}; XRPL_ASSERT( + "ripple::STObject::add : valid field type", (sType != STI_OBJECT) || - (field->getFName().fieldType == STI_OBJECT)); + (field->getFName().fieldType == STI_OBJECT)); field->addFieldID(s); field->add(s); if (sType == STI_ARRAY || sType == STI_OBJECT) diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index 3bce80cbb73..899b6a11f2b 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -208,8 +208,11 @@ STPathSet::getSType() const void STPathSet::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == STI_PATHSET); + XRPL_ASSERT( + "ripple::STPathSet::add : field is binary", getFName().isBinary()); + XRPL_ASSERT( + "ripple::STPathSet::add : valid field type", + getFName().fieldType == STI_PATHSET); bool first = true; for (auto const& spPath : value) diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index 12e844acdb6..9e890ac0b7c 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -137,7 +137,9 @@ STTx::getMentionedAccounts() const { if (auto sacc = dynamic_cast(&it)) { - XRPL_ASSERT(!sacc->isDefault()); + XRPL_ASSERT( + "ripple::STTx::getMentionedAccounts : account is set", + !sacc->isDefault()); if (!sacc->isDefault()) list.insert(sacc->value()); } @@ -298,7 +300,8 @@ STTx::getMetaSQL( std::string rTxn = sqlBlobLiteral(rawTxn.peekData()); auto format = TxFormats::getInstance().findByType(tx_type_); - XRPL_ASSERT(format != nullptr); + XRPL_ASSERT( + "ripple::STTx::getMetaSQL : non-null type format", format != nullptr); return str( boost::format(bfTrans) % to_string(getTransactionID()) % diff --git a/src/libxrpl/protocol/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp index d5a8e20b7e8..19cb50d38b9 100644 --- a/src/libxrpl/protocol/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -107,7 +107,9 @@ STValidation::isValid() const noexcept { if (!valid_) { - XRPL_ASSERT(publicKeyType(getSignerPublic()) == KeyType::secp256k1); + XRPL_ASSERT( + "ripple::STValidation::isValid : valid key type", + publicKeyType(getSignerPublic()) == KeyType::secp256k1); valid_ = verifyDigest( getSignerPublic(), diff --git a/src/libxrpl/protocol/STVar.cpp b/src/libxrpl/protocol/STVar.cpp index 22f16f746e2..f74413b42d1 100644 --- a/src/libxrpl/protocol/STVar.cpp +++ b/src/libxrpl/protocol/STVar.cpp @@ -178,7 +178,9 @@ STVar::STVar(SerialIter& sit, SField const& name, int depth) STVar::STVar(SerializedTypeID id, SField const& name) { - XRPL_ASSERT((id == STI_NOTPRESENT) || (id == name.fieldType)); + XRPL_ASSERT( + "ripple::detail::STVar::STVar(SerializedTypeID) : valid type input", + (id == STI_NOTPRESENT) || (id == name.fieldType)); switch (id) { case STI_NOTPRESENT: diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index b7723b22224..240a40d4151 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -68,8 +68,11 @@ STVector256::isDefault() const void STVector256::add(Serializer& s) const { - XRPL_ASSERT(getFName().isBinary()); - XRPL_ASSERT(getFName().fieldType == STI_VECTOR256); + XRPL_ASSERT( + "ripple::STVector256::add : field is binary", getFName().isBinary()); + XRPL_ASSERT( + "ripple::STVector256::add : valid field type", + getFName().fieldType == STI_VECTOR256); s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8)); } diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index b54d1f63f48..7d30a75cc74 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -132,7 +132,9 @@ int Serializer::addFieldID(int type, int name) { int ret = mData.size(); - XRPL_ASSERT((type > 0) && (type < 256) && (name > 0) && (name < 256)); + XRPL_ASSERT( + "ripple::Serializer::addFieldID : inputs inside range", + (type > 0) && (type < 256) && (name > 0) && (name < 256)); if (type < 16) { @@ -202,8 +204,9 @@ Serializer::addVL(Blob const& vector) int ret = addEncoded(vector.size()); addRaw(vector); XRPL_ASSERT( + "ripple::Serializer::addVL : size matches expected", mData.size() == - (ret + vector.size() + encodeLengthLength(vector.size()))); + (ret + vector.size() + encodeLengthLength(vector.size()))); return ret; } @@ -483,7 +486,8 @@ SerialIter::getVLDataLength() } else { - XRPL_ASSERT(lenLen == 3); + XRPL_ASSERT( + "ripple::SerialIter::getVLDataLength : lenLen is 3", lenLen == 3); int b2 = get8(); int b3 = get8(); datLen = Serializer::decodeVLLength(b1, b2, b3); diff --git a/src/libxrpl/protocol/TxMeta.cpp b/src/libxrpl/protocol/TxMeta.cpp index e6819c981c1..1c36aef176a 100644 --- a/src/libxrpl/protocol/TxMeta.cpp +++ b/src/libxrpl/protocol/TxMeta.cpp @@ -55,7 +55,9 @@ TxMeta::TxMeta(uint256 const& txid, std::uint32_t ledger, STObject const& obj) auto affectedNodes = dynamic_cast(obj.peekAtPField(sfAffectedNodes)); - XRPL_ASSERT(affectedNodes); + XRPL_ASSERT( + "ripple::TxMeta::TxMeta(STObject) : type cast succeeded", + affectedNodes); if (affectedNodes) mNodes = *affectedNodes; @@ -106,7 +108,9 @@ TxMeta::setAffectedNode( mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - XRPL_ASSERT(obj.getFName() == type); + XRPL_ASSERT( + "ripple::TxMeta::setAffectedNode : field type match", + obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, node); obj.setFieldU16(sfLedgerEntryType, nodeType); } @@ -127,14 +131,18 @@ TxMeta::getAffectedAccounts() const if (index != -1) { auto inner = dynamic_cast(&it.peekAtIndex(index)); - XRPL_ASSERT(inner); + XRPL_ASSERT( + "ripple::getAffectedAccounts : STObject type cast succeeded", + inner); if (inner) { for (auto const& field : *inner) { if (auto sa = dynamic_cast(&field)) { - XRPL_ASSERT(!sa->isDefault()); + XRPL_ASSERT( + "ripple::getAffectedAccounts : account is set", + !sa->isDefault()); if (!sa->isDefault()) list.insert(sa->value()); } @@ -145,7 +153,10 @@ TxMeta::getAffectedAccounts() const (field.getFName() == sfTakerGets)) { auto lim = dynamic_cast(&field); - XRPL_ASSERT(lim); + XRPL_ASSERT( + "ripple::getAffectedAccounts : STAmount type cast " + "succeeded", + lim); if (lim != nullptr) { @@ -175,7 +186,9 @@ TxMeta::getAffectedNode(SLE::ref node, SField const& type) mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - XRPL_ASSERT(obj.getFName() == type); + XRPL_ASSERT( + "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match", + obj.getFName() == type); obj.setFieldH256(sfLedgerIndex, index); obj.setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType)); @@ -190,7 +203,8 @@ TxMeta::getAffectedNode(uint256 const& node) if (n.getFieldH256(sfLedgerIndex) == node) return n; } - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::TxMeta::getAffectedNode(uint256) : node not found"); Throw("Affected node not found"); return *(mNodes.begin()); // Silence compiler warning. } @@ -199,7 +213,7 @@ STObject TxMeta::getAsObject() const { STObject metaData(sfTransactionMetaData); - XRPL_ASSERT(mResult != 255); + XRPL_ASSERT("ripple::TxMeta::getAsObject : result is set", mResult != 255); metaData.setFieldU8(sfTransactionResult, mResult); metaData.setFieldU32(sfTransactionIndex, mIndex); metaData.emplace_back(mNodes); @@ -213,7 +227,9 @@ TxMeta::addRaw(Serializer& s, TER result, std::uint32_t index) { mResult = TERtoInt(result); mIndex = index; - XRPL_ASSERT((mResult == 0) || ((mResult > 100) && (mResult <= 255))); + XRPL_ASSERT( + "ripple::TxMeta::addRaw : valid TER input", + (mResult == 0) || ((mResult > 100) && (mResult <= 255))); mNodes.sort([](STObject const& o1, STObject const& o2) { return o1.getFieldH256(sfLedgerIndex) < o2.getFieldH256(sfLedgerIndex); diff --git a/src/libxrpl/protocol/tokens.cpp b/src/libxrpl/protocol/tokens.cpp index 695390e5b20..deeed6c5645 100644 --- a/src/libxrpl/protocol/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -248,7 +248,8 @@ encodeBase58( iter[-1] = carry % 58; carry /= 58; } - XRPL_ASSERT(carry == 0); + XRPL_ASSERT( + "ripple::b58_ref::detail::encodeBase58 : zero carry", carry == 0); pbegin++; } @@ -298,7 +299,8 @@ decodeBase58(std::string const& s) *iter = carry % 256; carry /= 256; } - XRPL_ASSERT(carry == 0); + XRPL_ASSERT( + "ripple::b58_ref::detail::decodeBase58 : zero carry", carry == 0); ++psz; --remain; } @@ -530,7 +532,9 @@ b58_to_b256_be(std::string_view input, std::span out) ripple::b58_fast::detail::div_rem(input.size(), 10); auto const num_partial_coeffs = partial_coeff_len ? 1 : 0; auto const num_b_58_10_coeffs = num_full_coeffs + num_partial_coeffs; - XRPL_ASSERT(num_b_58_10_coeffs <= b_58_10_coeff.size()); + XRPL_ASSERT( + "ripple::b58_fast::detail::b58_to_b256_be : maximum coeff", + num_b_58_10_coeffs <= b_58_10_coeff.size()); for (auto c : input.substr(0, partial_coeff_len)) { auto cur_val = ::ripple::alphabetReverse[c]; diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index fbe67ac7661..8049f853d8c 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -109,14 +109,18 @@ Consumer::charge(Charge const& what) bool Consumer::warn() { - XRPL_ASSERT(m_entry != nullptr); + XRPL_ASSERT( + "ripple::Resource::Consumer::warn : non-null entry", + m_entry != nullptr); return m_logic->warn(*m_entry); } bool Consumer::disconnect(beast::Journal const& j) { - XRPL_ASSERT(m_entry != nullptr); + XRPL_ASSERT( + "ripple::Resource::Consumer::disconnect : non-null entry", + m_entry != nullptr); bool const d = m_logic->disconnect(*m_entry); if (d) { @@ -128,14 +132,18 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - XRPL_ASSERT(m_entry != nullptr); + XRPL_ASSERT( + "ripple::Resource::Consumer::balance : non-null entry", + m_entry != nullptr); return m_logic->balance(*m_entry); } Entry& Consumer::entry() { - XRPL_ASSERT(m_entry != nullptr); + XRPL_ASSERT( + "ripple::Resource::Consumer::entry : non-null entry", + m_entry != nullptr); return *m_entry; } diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index 7dc9d6f8312..4f24d17601e 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -4426,8 +4426,7 @@ struct XChainSim_test : public beast::unit_test::suite, c.num_create_attn_sent += sendCreateAttestations( i, bridge, create_claims); } - assert( - claims.create_claims[c.claim_count].empty()); + assert(claims.create_claims[c.claim_count].empty()); } } for (auto& [bridge, c] : counters) diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 5e934a1896d..cbe38798c02 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -93,7 +93,9 @@ RCLConsensus::Adaptor::Adaptor( std::numeric_limits::max() - 1)) , nUnlVote_(validatorKeys_.nodeID, j_) { - XRPL_ASSERT(valCookie_ != 0); + XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::Adaptor : nonzero cookie", + valCookie_ != 0); JLOG(j_.info()) << "Consensus engine started (cookie: " + std::to_string(valCookie_) + ")"; @@ -143,8 +145,12 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) return std::nullopt; } - XRPL_ASSERT(!built->open() && built->isImmutable()); - XRPL_ASSERT(built->info().hash == hash); + XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::acquireLedger : valid ledger state", + !built->open() && built->isImmutable()); + XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::acquireLedger : ledger hash match", + built->info().hash == hash); // Notify inbound transactions of the new ledger sequence number inboundTransactions_.newRound(built->info().seq); @@ -670,8 +676,11 @@ RCLConsensus::Adaptor::doAccept( ledgerMaster_.switchLCL(built.ledger_); // Do these need to exist? - XRPL_ASSERT(ledgerMaster_.getClosedLedger()->info().hash == built.id()); XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::doAccept : ledger hash match", + ledgerMaster_.getClosedLedger()->info().hash == built.id()); + XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::doAccept : parent hash match", app_.openLedger().current()->info().parentHash == built.id()); } @@ -769,6 +778,7 @@ RCLConsensus::Adaptor::buildLCL( if (auto const replayData = ledgerMaster_.releaseReplay()) { XRPL_ASSERT( + "ripple::RCLConsensus::Adaptor::buildLCL : parent hash match", replayData->parent()->info().hash == previousLedger.id()); return buildLedger(*replayData, tapNONE, app_, j_); } diff --git a/src/xrpld/app/consensus/RCLCxPeerPos.cpp b/src/xrpld/app/consensus/RCLCxPeerPos.cpp index 01facb287e5..698c21031dd 100644 --- a/src/xrpld/app/consensus/RCLCxPeerPos.cpp +++ b/src/xrpld/app/consensus/RCLCxPeerPos.cpp @@ -39,6 +39,7 @@ RCLCxPeerPos::RCLCxPeerPos( // The maximum allowed size of a signature is 72 bytes; we verify // this elsewhere, but we want to be extra careful here: XRPL_ASSERT( + "ripple::RCLCxPeerPos::RCLCxPeerPos : valid signature size", signature.size() != 0 && signature.size() <= signature_.capacity()); if (signature.size() != 0 && signature.size() <= signature_.capacity()) diff --git a/src/xrpld/app/consensus/RCLCxTx.h b/src/xrpld/app/consensus/RCLCxTx.h index 7beb04f8ce8..79e69c02c67 100644 --- a/src/xrpld/app/consensus/RCLCxTx.h +++ b/src/xrpld/app/consensus/RCLCxTx.h @@ -111,7 +111,8 @@ class RCLTxSet */ RCLTxSet(std::shared_ptr m) : map_{std::move(m)} { - XRPL_ASSERT(map_); + XRPL_ASSERT( + "ripple::RCLTxSet::MutableTxSet::RCLTxSet : non-null input", map_); } /** Constructor from a previously created MutableTxSet @@ -177,7 +178,9 @@ class RCLTxSet std::map ret; for (auto const& [k, v] : delta) { - XRPL_ASSERT((v.first && !v.second) || (v.second && !v.first)); + XRPL_ASSERT( + "ripple::RCLTxSet::compare : either side is set", + (v.first && !v.second) || (v.second && !v.first)); ret[k] = static_cast(v.first); } diff --git a/src/xrpld/app/consensus/RCLValidations.cpp b/src/xrpld/app/consensus/RCLValidations.cpp index 7524d9b74c8..4d415251253 100644 --- a/src/xrpld/app/consensus/RCLValidations.cpp +++ b/src/xrpld/app/consensus/RCLValidations.cpp @@ -50,6 +50,8 @@ RCLValidatedLedger::RCLValidatedLedger( if (hashIndex) { XRPL_ASSERT( + "ripple::RCLValidatedLedger::RCLValidatedLedger(Ledger) : valid " + "last ledger sequence", hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); ancestors_ = hashIndex->getFieldV256(sfHashes).value(); } @@ -143,8 +145,12 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) return std::nullopt; } - XRPL_ASSERT(!ledger->open() && ledger->isImmutable()); - XRPL_ASSERT(ledger->info().hash == hash); + XRPL_ASSERT( + "ripple::RCLValidationsAdaptor::acquire : valid ledger state", + !ledger->open() && ledger->isImmutable()); + XRPL_ASSERT( + "ripple::RCLValidationsAdaptor::acquire : ledger hash match", + ledger->info().hash == hash); return RCLValidatedLedger(std::move(ledger), j_); } diff --git a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp index 1518c41a7ef..0f5036121b4 100644 --- a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp +++ b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp @@ -33,7 +33,9 @@ AcceptedLedgerTx::AcceptedLedgerTx( , mMeta(txn->getTransactionID(), ledger->seq(), *met) , mAffected(mMeta.getAffectedAccounts()) { - XRPL_ASSERT(!ledger->open()); + XRPL_ASSERT( + "ripple::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state", + !ledger->open()); Serializer s; met->add(s); @@ -76,7 +78,9 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::string AcceptedLedgerTx::getEscMeta() const { - XRPL_ASSERT(!mRawMeta.empty()); + XRPL_ASSERT( + "ripple::AcceptedLedgerTx::getEscMeta : metadata is set", + !mRawMeta.empty()); return sqlBlobLiteral(mRawMeta); } diff --git a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp index c6cffbc1d64..c31fe775c94 100644 --- a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp @@ -60,7 +60,9 @@ ConsensusTransSetSF::gotNode( Serializer s(nodeData.data() + 4, nodeData.size() - 4); SerialIter sit(s.slice()); auto stx = std::make_shared(std::ref(sit)); - XRPL_ASSERT(stx->getTransactionID() == nodeHash.as_uint256()); + XRPL_ASSERT( + "ripple::ConsensusTransSetSF::gotNode : transaction hash match", + stx->getTransactionID() == nodeHash.as_uint256()); auto const pap = &app_; app_.getJobQueue().addJob(jtTRANSACTION, "TXS->TXN", [pap, stx]() { pap->getOPs().submitTransaction(stx); @@ -92,7 +94,9 @@ ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const Serializer s; s.add32(HashPrefix::transactionID); txn->getSTransaction()->add(s); - XRPL_ASSERT(sha512Half(s.slice()) == nodeHash.as_uint256()); + XRPL_ASSERT( + "ripple::ConsensusTransSetSF::getNode : transaction hash match", + sha512Half(s.slice()) == nodeHash.as_uint256()); nodeData = s.peekData(); return nodeData; } diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 19f1c62d29e..7c72cc685f7 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -381,7 +381,7 @@ Ledger::setAccepted( bool correctCloseTime) { // Used when we witnessed the consensus. - XRPL_ASSERT(!open()); + XRPL_ASSERT("ripple::Ledger::setAccepted : valid ledger state", !open()); info_.closeTime = closeTime; info_.closeTimeResolution = closeResolution; @@ -454,7 +454,7 @@ Ledger::read(Keylet const& k) const { if (k.key == beast::zero) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Ledger::read : zero key"); return nullptr; } auto const& item = stateMap_.peekItem(k.key); @@ -574,7 +574,8 @@ Ledger::rawTxInsert( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - XRPL_ASSERT(metaData); + XRPL_ASSERT( + "ripple::Ledger::rawTxInsert : non-null metadata input", metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -591,7 +592,9 @@ Ledger::rawTxInsertWithHash( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - XRPL_ASSERT(metaData); + XRPL_ASSERT( + "ripple::Ledger::rawTxInsertWithHash : non-null metadata input", + metaData); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -687,7 +690,9 @@ Ledger::setup() void Ledger::defaultFees(Config const& config) { - XRPL_ASSERT(fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); + XRPL_ASSERT( + "ripple::Ledger::defaultFees : zero fees", + fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); if (fees_.base == 0) fees_.base = config.FEES.reference_fee; if (fees_.reserve == 0) @@ -883,7 +888,7 @@ Ledger::assertSensible(beast::Journal ledgerJ) const JLOG(ledgerJ.fatal()) << "ledger is not sensible" << j; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::Ledger::assertSensible : ledger is not sensible"); return false; } @@ -917,7 +922,9 @@ Ledger::updateSkipList() created = false; } - XRPL_ASSERT(hashes.size() <= 256); + XRPL_ASSERT( + "ripple::Ledger::updateSkipList : first maximum hashes size", + hashes.size() <= 256); hashes.push_back(info_.parentHash); sle->setFieldV256(sfHashes, STVector256(hashes)); sle->setFieldU32(sfLastLedgerSequence, prevIndex); @@ -942,7 +949,9 @@ Ledger::updateSkipList() hashes = static_cast(sle->getFieldV256(sfHashes)); created = false; } - XRPL_ASSERT(hashes.size() <= 256); + XRPL_ASSERT( + "ripple::Ledger::updateSkipList : second maximum hashes size", + hashes.size() <= 256); if (hashes.size() == 256) hashes.erase(hashes.begin()); hashes.push_back(info_.parentHash); @@ -1022,7 +1031,8 @@ pendSaveValidated( } } - XRPL_ASSERT(ledger->isImmutable()); + XRPL_ASSERT( + "ripple::pendSaveValidated : immutable ledger", ledger->isImmutable()); if (!app.pendingSaves().shouldWork(ledger->info().seq, isSynchronous)) { @@ -1100,8 +1110,9 @@ finishLoadByIndexOrHash( return; XRPL_ASSERT( + "ripple::finishLoadByIndexOrHash : valid ledger fees", ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees())); + ledger->read(keylet::fees())); ledger->setImmutable(); JLOG(j.trace()) << "Loaded ledger: " << to_string(ledger->info().hash); @@ -1140,7 +1151,9 @@ loadByHash(uint256 const& ledgerHash, Application& app, bool acquire) { std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); - XRPL_ASSERT(!ledger || ledger->info().hash == ledgerHash); + XRPL_ASSERT( + "ripple::loadByHash : ledger hash match if loaded", + !ledger || ledger->info().hash == ledgerHash); return ledger; } return {}; @@ -1152,7 +1165,8 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) { if (!app.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : not in reporting mode"); Throw( "flatFetchTransactions: not running in reporting mode"); } @@ -1165,7 +1179,8 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) dynamic_cast(&(app.getNodeStore())); if (!nodeDb) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : database is not DatabaseNodeImp"); Throw( "Called flatFetchTransactions but database is not DatabaseNodeImp"); } @@ -1175,7 +1190,9 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) JLOG(app.journal("Ledger").debug()) << " Flat fetch time : " << ((end - start).count() / 1000000000.0) << " number of transactions " << nodestoreHashes.size(); - XRPL_ASSERT(objs.size() == nodestoreHashes.size()); + XRPL_ASSERT( + "ripple::flatFetchTransactions : size match", + objs.size() == nodestoreHashes.size()); for (size_t i = 0; i < objs.size(); ++i) { uint256& nodestoreHash = nodestoreHashes[i]; @@ -1186,21 +1203,26 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) makeSlice(obj->getData()), SHAMapHash{nodestoreHash}); if (!node) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : error making SHAMap node"); Throw( "flatFetchTransactions : Error making SHAMap node"); } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : error reading SHAMap " + "node"); Throw( "flatFetchTransactions : Error reading SHAMap node"); } auto txnPlusMeta = deserializeTxPlusMeta(*item); if (!txnPlusMeta.first || !txnPlusMeta.second) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : error deserializing " + "SHAMap node"); Throw( "flatFetchTransactions : Error deserializing SHAMap node"); } @@ -1208,7 +1230,8 @@ flatFetchTransactions(Application& app, std::vector& nodestoreHashes) } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions : SHAMap node not found"); Throw( "flatFetchTransactions : Containing SHAMap node not found"); } @@ -1221,7 +1244,9 @@ flatFetchTransactions(ReadView const& ledger, Application& app) { if (!app.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::flatFetchTransactions(ReadView) : not running in " + "reporting mode"); return {}; } diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 9e400bb33e5..048a9548702 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -58,7 +58,9 @@ LedgerHistory::insert( if (!ledger->isImmutable()) LogicError("mutable Ledger in insert"); - XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT( + "ripple::LedgerHistory::insert : nonzero hash", + ledger->stateMap().getHash().isNonZero()); std::unique_lock sl(m_ledgers_by_hash.peekMutex()); @@ -99,13 +101,17 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) if (!ret) return ret; - XRPL_ASSERT(ret->info().seq == index); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerBySeq : result sequence match", + ret->info().seq == index); { // Add this ledger to the local tracking by index std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - XRPL_ASSERT(ret->isImmutable()); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerBySeq : immutable result ledger", + ret->isImmutable()); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); mLedgersByIndex[ret->info().seq] = ret->info().hash; return (ret->info().seq == index) ? ret : nullptr; @@ -119,8 +125,13 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (ret) { - XRPL_ASSERT(ret->isImmutable()); - XRPL_ASSERT(ret->info().hash == hash); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerByHash : immutable fetched ledger", + ret->isImmutable()); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerByHash : fetched ledger hash " + "match", + ret->info().hash == hash); return ret; } @@ -129,10 +140,16 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (!ret) return ret; - XRPL_ASSERT(ret->isImmutable()); - XRPL_ASSERT(ret->info().hash == hash); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerByHash : immutable loaded ledger", + ret->isImmutable()); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerByHash : loaded ledger hash match", + ret->info().hash == hash); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); - XRPL_ASSERT(ret->info().hash == hash); + XRPL_ASSERT( + "ripple::LedgerHistory::getLedgerByHash : result hash match", + ret->info().hash == hash); return ret; } @@ -176,7 +193,9 @@ log_metadata_difference( auto validMetaData = getMeta(validLedger, tx); auto builtMetaData = getMeta(builtLedger, tx); - XRPL_ASSERT(validMetaData || builtMetaData); + XRPL_ASSERT( + "ripple::log_metadata_difference : some metadata present", + validMetaData || builtMetaData); if (validMetaData && builtMetaData) { @@ -322,7 +341,9 @@ LedgerHistory::handleMismatch( std::optional const& validatedConsensusHash, Json::Value const& consensus) { - XRPL_ASSERT(built != valid); + XRPL_ASSERT( + "ripple::LedgerHistory::handleMismatch : unequal hashes", + built != valid); ++mismatch_counter_; auto builtLedger = getLedgerByHash(built); @@ -337,7 +358,9 @@ LedgerHistory::handleMismatch( return; } - XRPL_ASSERT(builtLedger->info().seq == validLedger->info().seq); + XRPL_ASSERT( + "ripple::LedgerHistory::handleMismatch : sequence match", + builtLedger->info().seq == validLedger->info().seq); if (auto stream = j_.debug()) { @@ -430,7 +453,8 @@ LedgerHistory::builtLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - XRPL_ASSERT(!hash.isZero()); + XRPL_ASSERT( + "ripple::LedgerHistory::builtLedger : nonzero hash", !hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); @@ -470,7 +494,9 @@ LedgerHistory::validatedLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - XRPL_ASSERT(!hash.isZero()); + XRPL_ASSERT( + "ripple::LedgerHistory::validatedLedger : nonzero hash", + !hash.isZero()); std::unique_lock sl(m_consensus_validated.peekMutex()); diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index b41113c7806..7ed7420eeb4 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -263,7 +263,8 @@ OpenLedger::apply( // If there are any transactions left, we must have // tried them in at least one final pass - XRPL_ASSERT(retries.empty() || !retry); + XRPL_ASSERT( + "ripple::OpenLedger::apply : valid retries", retries.empty() || !retry); } //------------------------------------------------------------------------------ diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp index 52c88cdf3fe..2a45b5d41a7 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -225,7 +225,9 @@ OrderBookDB::makeBookListeners(Book const& book) ret = std::make_shared(); mListeners[book] = ret; - XRPL_ASSERT(getBookListeners(book) == ret); + XRPL_ASSERT( + "ripple::OrderBookDB::makeBookListeners : result roundtrip lookup", + getBookListeners(book) == ret); } return ret; diff --git a/src/xrpld/app/ledger/TransactionStateSF.cpp b/src/xrpld/app/ledger/TransactionStateSF.cpp index f4fa27347f3..760e58045fe 100644 --- a/src/xrpld/app/ledger/TransactionStateSF.cpp +++ b/src/xrpld/app/ledger/TransactionStateSF.cpp @@ -30,7 +30,9 @@ TransactionStateSF::gotNode( SHAMapNodeType type) const { - XRPL_ASSERT(type != SHAMapNodeType::tnTRANSACTION_NM); + XRPL_ASSERT( + "ripple::TransactionStateSF::gotNode : valid input", + type != SHAMapNodeType::tnTRANSACTION_NM); db_.store( hotTRANSACTION_NODE, std::move(nodeData), diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index f90f70e9b99..e15efab734a 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -57,7 +57,8 @@ buildLedgerImpl( { OpenView accum(&*built); - XRPL_ASSERT(!accum.open()); + XRPL_ASSERT( + "ripple::buildLedgerImpl : valid ledger state", !accum.open()); applyTxs(accum, built); accum.apply(*built); } @@ -76,8 +77,9 @@ buildLedgerImpl( // Accept ledger XRPL_ASSERT( + "ripple::buildLedgerImpl : valid ledger fees", built->info().seq < XRP_LEDGER_EARLIEST_FEES || - built->read(keylet::fees())); + built->read(keylet::fees())); built->setAccepted(closeTime, closeResolution, closeTimeCorrect); return built; @@ -169,7 +171,9 @@ applyTransactions( // If there are any transactions left, we must have // tried them in at least one final pass - XRPL_ASSERT(txns.empty() || !certainRetry); + XRPL_ASSERT( + "ripple::applyTransactions : retry transactions", + txns.empty() || !certainRetry); return count; } diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index 7d985d7e005..38e34cb89cc 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -156,8 +156,9 @@ InboundLedger::init(ScopedLockType& collectionLock) JLOG(journal_.debug()) << "Acquiring ledger we already have in " << " local store. " << hash_; XRPL_ASSERT( + "ripple::InboundLedger::init : valid ledger fees", mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees())); mLedger->setImmutable(); if (mReason == Reason::HISTORY || mReason == Reason::SHARD) @@ -390,8 +391,9 @@ InboundLedger::tryDB(NodeStore::Database& srcDB) JLOG(journal_.debug()) << "Had everything locally"; complete_ = true; XRPL_ASSERT( + "ripple::InboundLedger::tryDB : valid ledger fees", mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees())); mLedger->setImmutable(); } } @@ -485,13 +487,16 @@ InboundLedger::done() std::to_string(timeouts_) + " ")) << mStats.get(); - XRPL_ASSERT(complete_ || failed_); + XRPL_ASSERT( + "ripple::InboundLedger::done : complete or failed", + complete_ || failed_); if (complete_ && !failed_ && mLedger) { XRPL_ASSERT( + "ripple::InboundLedger::done : valid ledger fees", mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees())); mLedger->setImmutable(); switch (mReason) { @@ -656,7 +661,10 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) // if we wind up abandoning this fetch. if (mHaveHeader && !mHaveState && !failed_) { - XRPL_ASSERT(mLedger); + XRPL_ASSERT( + "ripple::InboundLedger::trigger : non-null ledger to read state " + "from", + mLedger); if (!mLedger->stateMap().isValid()) { @@ -728,7 +736,10 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) if (mHaveHeader && !mHaveTransactions && !failed_) { - XRPL_ASSERT(mLedger); + XRPL_ASSERT( + "ripple::InboundLedger::trigger : non-null ledger to read " + "transactions from", + mLedger); if (!mLedger->txMap().isValid()) { @@ -994,7 +1005,8 @@ InboundLedger::takeAsRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::InboundLedger::takeAsRootNode : no ledger header"); return false; } @@ -1019,7 +1031,8 @@ InboundLedger::takeTxRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::InboundLedger::takeTxRootNode : no ledger header"); return false; } diff --git a/src/xrpld/app/ledger/detail/InboundLedgers.cpp b/src/xrpld/app/ledger/detail/InboundLedgers.cpp index 6d52ee4e2c8..8ebb2f99868 100644 --- a/src/xrpld/app/ledger/detail/InboundLedgers.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedgers.cpp @@ -69,10 +69,13 @@ class InboundLedgersImp : public InboundLedgers std::uint32_t seq, InboundLedger::Reason reason) override { - XRPL_ASSERT(hash.isNonZero()); XRPL_ASSERT( + "ripple::InboundLedgersImp::acquire : nonzero hash input", + hash.isNonZero()); + XRPL_ASSERT( + "ripple::InboundLedgersImp::acquire : valid reason input", reason != InboundLedger::Reason::SHARD || - (seq != 0 && app_.getShardStore())); + (seq != 0 && app_.getShardStore())); // probably not the right rule if (app_.getOPs().isNeedNetworkLedger() && @@ -144,7 +147,9 @@ class InboundLedgersImp : public InboundLedgers std::shared_ptr find(uint256 const& hash) override { - XRPL_ASSERT(hash.isNonZero()); + XRPL_ASSERT( + "ripple::InboundLedgersImp::find : nonzero input", + hash.isNonZero()); std::shared_ptr ret; @@ -306,7 +311,9 @@ class InboundLedgersImp : public InboundLedgers acqs.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - XRPL_ASSERT(it.second); + XRPL_ASSERT( + "ripple::InboundLedgersImp::getInfo : non-null ledger", + it.second); acqs.push_back(it); } for (auto const& it : mRecentFailures) @@ -341,7 +348,9 @@ class InboundLedgersImp : public InboundLedgers acquires.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - XRPL_ASSERT(it.second); + XRPL_ASSERT( + "ripple::InboundLedgersImp::gotFetchPack : non-null ledger", + it.second); acquires.push_back(it.second); } } diff --git a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp index 62ad6d0496c..1055ed60490 100644 --- a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -231,7 +231,9 @@ class LedgerCleanerImp : public LedgerCleaner }); if (shouldExit_) break; - XRPL_ASSERT(state_ == State::cleaning); + XRPL_ASSERT( + "ripple::LedgerCleanerImp::run : is cleaning", + state_ == State::cleaning); } doLedgerCleaner(); } @@ -353,7 +355,9 @@ class LedgerCleanerImp : public LedgerCleaner LedgerHash refHash = getLedgerHash(referenceLedger, refIndex); bool const nonzero(refHash.isNonZero()); - XRPL_ASSERT(nonzero); + XRPL_ASSERT( + "ripple::LedgerCleanerImp::getHash : nonzero hash", + nonzero); if (nonzero) { // We found the hash and sequence of a better reference diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index 7f87091cc02..41fc4cb0fd7 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -199,8 +199,12 @@ LedgerDeltaAcquire::tryBuild(std::shared_ptr const& parent) if (failed_ || !complete_ || !replayTemp_) return {}; - XRPL_ASSERT(parent->seq() + 1 == replayTemp_->seq()); - XRPL_ASSERT(parent->info().hash == replayTemp_->info().parentHash); + XRPL_ASSERT( + "ripple::LedgerDeltaAcquire::tryBuild : parent sequence match", + parent->seq() + 1 == replayTemp_->seq()); + XRPL_ASSERT( + "ripple::LedgerDeltaAcquire::tryBuild : parent hash match", + parent->info().hash == replayTemp_->info().parentHash); // build ledger LedgerReplay replayData(parent, replayTemp_, std::move(orderedTxns_)); fullLedger_ = buildLedger(replayData, tapNONE, app_, journal_); @@ -262,7 +266,7 @@ LedgerDeltaAcquire::onLedgerBuilt( void LedgerDeltaAcquire::notify(ScopedLockType& sl) { - XRPL_ASSERT(isDone()); + XRPL_ASSERT("ripple::LedgerDeltaAcquire::notify : is done", isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 893a63fbf6f..f10aaeba2e1 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -119,7 +119,8 @@ class ScopedUnlock */ explicit ScopedUnlock(std::unique_lock& lock) : lock_(lock) { - XRPL_ASSERT(lock_.owns_lock()); + XRPL_ASSERT( + "ripple::ScopedUnlock::ScopedUnlock : own lock", lock_.owns_lock()); lock_.unlock(); } @@ -369,8 +370,10 @@ LedgerMaster::setValidLedger(std::shared_ptr const& l) mValidLedger.set(l); mValidLedgerSign = signTime.time_since_epoch().count(); XRPL_ASSERT( + "ripple::LedgerMaster::setValidLedger : valid ledger sequence", mValidLedgerSeq || !app_.getMaxDisallowedLedger() || - l->info().seq + max_ledger_difference_ > app_.getMaxDisallowedLedger()); + l->info().seq + max_ledger_difference_ > + app_.getMaxDisallowedLedger()); (void)max_ledger_difference_; mValidLedgerSeq = l->info().seq; @@ -435,7 +438,7 @@ LedgerMaster::addHeldTransaction( bool LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) { - XRPL_ASSERT(ledger); + XRPL_ASSERT("ripple::LedgerMaster::canBeCurrent : non-null input", ledger); // Never jump to a candidate ledger that precedes our // last validated ledger @@ -503,7 +506,7 @@ LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) void LedgerMaster::switchLCL(std::shared_ptr const& lastClosed) { - XRPL_ASSERT(lastClosed); + XRPL_ASSERT("ripple::LedgerMaster::switchLCL : non-null input", lastClosed); if (!lastClosed->isImmutable()) LogicError("mutable ledger in switchLCL"); @@ -623,7 +626,9 @@ LedgerMaster::isValidated(ReadView const& ledger) // This ledger's hash is not the hash of the validated ledger if (hash) { - XRPL_ASSERT(hash->isNonZero()); + XRPL_ASSERT( + "ripple::LedgerMaster::isValidated : nonzero hash", + hash->isNonZero()); uint256 valHash = app_.getRelationalDatabase().getHashByIndex(seq); if (valHash == ledger.info().hash) @@ -964,7 +969,9 @@ LedgerMaster::setFullLedger( // A new ledger has been accepted as part of the trusted chain JLOG(m_journal.debug()) << "Ledger " << ledger->info().seq << " accepted :" << ledger->info().hash; - XRPL_ASSERT(ledger->stateMap().getHash().isNonZero()); + XRPL_ASSERT( + "ripple::LedgerMaster::setFullLedger : nonzero ledger state hash", + ledger->stateMap().getHash().isNonZero()); ledger->setValidated(); ledger->setFull(); @@ -1429,7 +1436,9 @@ LedgerMaster::findNewLedgersToPublish( { JLOG(m_journal.fatal()) << "Ledger: " << valSeq << " does not have hash for " << seq; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::LedgerMaster::findNewLedgersToPublish : ledger " + "not found"); } else { @@ -1516,7 +1525,9 @@ LedgerMaster::tryAdvance() app_.getJobQueue().addJob(jtADVANCE, "advanceLedger", [this]() { std::unique_lock sl(m_mutex); - XRPL_ASSERT(!mValidLedger.empty() && mAdvanceThread); + XRPL_ASSERT( + "ripple::LedgerMaster::tryAdvance : has valid ledger", + !mValidLedger.empty() && mAdvanceThread); JLOG(m_journal.trace()) << "advanceThread<"; @@ -1835,7 +1846,7 @@ LedgerMaster::walkHashBySeq( // be located easily and should contain the hash. LedgerIndex refIndex = getCandidateLedger(index); auto const refHash = hashOfSeq(*referenceLedger, refIndex, m_journal); - XRPL_ASSERT(refHash); + XRPL_ASSERT("ripple::LedgerMaster::walkHashBySeq : found ledger", refHash); if (refHash) { // Try the hash and sequence of a better reference ledger just found @@ -1860,7 +1871,9 @@ LedgerMaster::walkHashBySeq( *refHash, refIndex, reason)) { ledgerHash = hashOfSeq(*l, index, m_journal); - XRPL_ASSERT(ledgerHash); + XRPL_ASSERT( + "ripple::LedgerMaster::walkHashBySeq : has complete ledger", + ledgerHash); } } } @@ -1972,7 +1985,9 @@ LedgerMaster::fetchForHistory( ScopedUnlock sul{sl}; if (auto hash = getLedgerHashForHistory(missing, reason)) { - XRPL_ASSERT(hash->isNonZero()); + XRPL_ASSERT( + "ripple::LedgerMaster::fetchForHistory : found ledger", + hash->isNonZero()); auto ledger = getLedgerByHash(*hash); if (!ledger) { @@ -1999,7 +2014,9 @@ LedgerMaster::fetchForHistory( if (ledger) { auto seq = ledger->info().seq; - XRPL_ASSERT(seq == missing); + XRPL_ASSERT( + "ripple::LedgerMaster::fetchForHistory : sequence match", + seq == missing); JLOG(m_journal.trace()) << "fetchForHistory acquired " << seq; if (reason == InboundLedger::Reason::SHARD) { @@ -2059,7 +2076,10 @@ LedgerMaster::fetchForHistory( std::uint32_t seq = missing - i; if (auto h = getLedgerHashForHistory(seq, reason)) { - XRPL_ASSERT(h->isNonZero()); + XRPL_ASSERT( + "ripple::LedgerMaster::fetchForHistory : " + "prefetched ledger", + h->isNonZero()); app_.getInboundLedgers().acquire(*h, seq, reason); } } @@ -2254,7 +2274,7 @@ populateFetchPack( std::uint32_t seq, bool withLeaves = true) { - XRPL_ASSERT(cnt != 0); + XRPL_ASSERT("ripple::populateFetchPack : nonzero count input", cnt != 0); Serializer s(1024); diff --git a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index 578a481c482..0cbb5ae79fc 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -32,7 +32,9 @@ LedgerReplayTask::TaskParameter::TaskParameter( std::uint32_t totalNumLedgers) : reason_(r), finishHash_(finishLedgerHash), totalLedgers_(totalNumLedgers) { - XRPL_ASSERT(finishLedgerHash.isNonZero() && totalNumLedgers > 0); + XRPL_ASSERT( + "ripple::LedgerReplayTask::TaskParameter::TaskParameter : valid inputs", + finishLedgerHash.isNonZero() && totalNumLedgers > 0); } bool @@ -48,7 +50,9 @@ LedgerReplayTask::TaskParameter::update( skipList_ = sList; skipList_.emplace_back(finishHash_); startHash_ = skipList_[skipList_.size() - totalLedgers_]; - XRPL_ASSERT(startHash_.isNonZero()); + XRPL_ASSERT( + "ripple::LedgerReplayTask::TaskParameter::update : nonzero start hash", + startHash_.isNonZero()); startSeq_ = finishSeq_ - totalLedgers_ + 1; full_ = true; return true; @@ -200,7 +204,9 @@ LedgerReplayTask::tryAdvance(ScopedLockType& sl) for (; deltaToBuild_ < deltas_.size(); ++deltaToBuild_) { auto& delta = deltas_[deltaToBuild_]; - XRPL_ASSERT(parent_->seq() + 1 == delta->ledgerSeq_); + XRPL_ASSERT( + "ripple::LedgerReplayTask::tryAdvance : consecutive sequence", + parent_->seq() + 1 == delta->ledgerSeq_); if (auto l = delta->tryBuild(parent_); l) { JLOG(journal_.debug()) @@ -290,8 +296,10 @@ LedgerReplayTask::addDelta(std::shared_ptr const& delta) << "addDelta task " << hash_ << " deltaIndex=" << deltaToBuild_ << " totalDeltas=" << deltas_.size(); XRPL_ASSERT( + "ripple::LedgerReplayTask::addDelta : no deltas or consecutive " + "sequence", deltas_.empty() || - deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_); + deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_); deltas_.push_back(delta); } } diff --git a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp index 8d8d4380843..f4930f6aa7d 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp @@ -48,8 +48,9 @@ LedgerReplayer::replay( std::uint32_t totalNumLedgers) { XRPL_ASSERT( + "ripple::LedgerReplayer::replay : valid inputs", finishLedgerHash.isNonZero() && totalNumLedgers > 0 && - totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE); + totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE); LedgerReplayTask::TaskParameter parameter( r, finishLedgerHash, totalNumLedgers); diff --git a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp index 28621ddfeb2..dfe98a7191e 100644 --- a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp @@ -139,7 +139,9 @@ SkipListAcquire::processData( std::uint32_t ledgerSeq, boost::intrusive_ptr const& item) { - XRPL_ASSERT(ledgerSeq != 0 && item); + XRPL_ASSERT( + "ripple::SkipListAcquire::processData : valid inputs", + ledgerSeq != 0 && item); ScopedLockType sl(mtx_); if (isDone()) return; @@ -224,7 +226,7 @@ SkipListAcquire::onSkipListAcquired( void SkipListAcquire::notify(ScopedLockType& sl) { - XRPL_ASSERT(isDone()); + XRPL_ASSERT("ripple::SkipListAcquire::notify : is done", isDone()); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 94f762a74c2..272ffdf4aa4 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -43,7 +43,9 @@ TimeoutCounter::TimeoutCounter( , queueJobParameter_(std::move(jobParameter)) , timer_(app_.getIOService()) { - XRPL_ASSERT((timerInterval_ > 10ms) && (timerInterval_ < 30s)); + XRPL_ASSERT( + "ripple::TimeoutCounter::TimeoutCounter : interval input inside range", + (timerInterval_ > 10ms) && (timerInterval_ < 30s)); } void diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 69610114a80..2d829c800f7 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -613,7 +613,9 @@ class ApplicationImp : public Application, public BasicApp virtual ServerHandler& getServerHandler() override { - XRPL_ASSERT(serverHandler_); + XRPL_ASSERT( + "ripple::ApplicationImp::getServerHandler : non-null server handle", + serverHandler_); return *serverHandler_; } @@ -889,35 +891,45 @@ class ApplicationImp : public Application, public BasicApp Overlay& overlay() override { - XRPL_ASSERT(overlay_); + XRPL_ASSERT( + "ripple::ApplicationImp::overlay : non-null overlay", overlay_); return *overlay_; } TxQ& getTxQ() override { - XRPL_ASSERT(txQ_.get() != nullptr); + XRPL_ASSERT( + "ripple::ApplicationImp::getTxQ : non-null transaction queue", + txQ_.get() != nullptr); return *txQ_; } RelationalDatabase& getRelationalDatabase() override { - XRPL_ASSERT(mRelationalDatabase.get() != nullptr); + XRPL_ASSERT( + "ripple::ApplicationImp::getRelationalDatabase : non-null " + "relational database", + mRelationalDatabase.get() != nullptr); return *mRelationalDatabase; } DatabaseCon& getWalletDB() override { - XRPL_ASSERT(mWalletDB.get() != nullptr); + XRPL_ASSERT( + "ripple::ApplicationImp::getWalletDB : non-null wallet database", + mWalletDB.get() != nullptr); return *mWalletDB; } ReportingETL& getReportingETL() override { - XRPL_ASSERT(reportingETL_.get() != nullptr); + XRPL_ASSERT( + "ripple::ApplicationImp::getReportingETL : non-null reporting ETL", + reportingETL_.get() != nullptr); return *reportingETL_; } @@ -932,7 +944,10 @@ class ApplicationImp : public Application, public BasicApp bool initRelationalDatabase() { - XRPL_ASSERT(mWalletDB.get() == nullptr); + XRPL_ASSERT( + "ripple::ApplicationImp::initRelationalDatabase : null wallet " + "database", + mWalletDB.get() == nullptr); try { @@ -1375,7 +1390,8 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) for (auto const& [a, vote] : amendments) { auto const f = ripple::getRegisteredFeature(a); - XRPL_ASSERT(f); + XRPL_ASSERT( + "ripple::ApplicationImp::setup : registered feature", f); if (f) supported.emplace_back(a, *f, vote); } @@ -1905,8 +1921,9 @@ ApplicationImp::startGenesisLedger() std::make_shared(*genesis, timeKeeper().closeTime()); next->updateSkipList(); XRPL_ASSERT( + "ripple::ApplicationImp::startGenesisLedger : valid ledger fees", next->info().seq < XRP_LEDGER_EARLIEST_FEES || - next->read(keylet::fees())); + next->read(keylet::fees())); next->setImmutable(); openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger")); m_ledgerMaster->storeLedger(next); @@ -1926,8 +1943,9 @@ ApplicationImp::getLastFullLedger() return ledger; XRPL_ASSERT( + "ripple::ApplicationImp::getLastFullLedger : valid ledger fees", ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees())); + ledger->read(keylet::fees())); ledger->setImmutable(); if (getLedgerMaster().haveLedger(seq)) @@ -2080,8 +2098,9 @@ ApplicationImp::loadLedgerFromFile(std::string const& name) loadLedger->stateMap().flushDirty(hotACCOUNT_NODE); XRPL_ASSERT( + "ripple::ApplicationImp::loadLedgerFromFile : valid ledger fees", loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - loadLedger->read(keylet::fees())); + loadLedger->read(keylet::fees())); loadLedger->setAccepted( closeTime, closeTimeResolution, !closeTimeEstimated); @@ -2179,7 +2198,9 @@ ApplicationImp::loadOldLedger( if (!loadLedger) { JLOG(m_journal.fatal()) << "Replay ledger missing/damaged"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ApplicationImp::loadOldLedger : replay ledger " + "missing/damaged"); return false; } } @@ -2208,21 +2229,26 @@ ApplicationImp::loadOldLedger( if (loadLedger->info().accountHash.isZero()) { JLOG(m_journal.fatal()) << "Ledger is empty."; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ApplicationImp::loadOldLedger : ledger is empty"); return false; } if (!loadLedger->walkLedger(journal("Ledger"), true)) { JLOG(m_journal.fatal()) << "Ledger is missing nodes."; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ApplicationImp::loadOldLedger : ledger is missing " + "nodes"); return false; } if (!loadLedger->assertSensible(journal("Ledger"))) { JLOG(m_journal.fatal()) << "Ledger is not sensible."; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ApplicationImp::loadOldLedger : ledger is not " + "sensible"); return false; } @@ -2348,8 +2374,11 @@ ApplicationImp::journal(std::string const& name) bool ApplicationImp::nodeToShards() { - XRPL_ASSERT(overlay_); - XRPL_ASSERT(!config_->standalone()); + XRPL_ASSERT( + "ripple::ApplicationImp::nodeToShards : non-null overlay", overlay_); + XRPL_ASSERT( + "ripple::ApplicationImp::nodeToShards : is not standalone", + !config_->standalone()); if (config_->section(ConfigSection::shardDatabase()).empty()) { diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index bbe69398a67..8241e2d7d22 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -243,7 +243,9 @@ GRPCServerImpl::CallData::forwardToP2p( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::GRPCServerImpl::CallData::forwardToP2p : client_ip field " + "not present"); Throw( "Attempting to forward but no client_ip field in " "protobuf message"); @@ -714,7 +716,7 @@ GRPCServer::stop() GRPCServer::~GRPCServer() { - XRPL_ASSERT(!running_); + XRPL_ASSERT("ripple::GRPCServer::~GRPCServer : is not running", !running_); } } // namespace ripple diff --git a/src/xrpld/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp index 85ca9b11960..90c9b539c75 100644 --- a/src/xrpld/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -73,7 +73,9 @@ void LoadManager::start() { JLOG(journal_.debug()) << "Starting"; - XRPL_ASSERT(!thread_.joinable()); + XRPL_ASSERT( + "ripple::LoadManager::start : thread not joinable", + !thread_.joinable()); thread_ = std::thread{&LoadManager::run, this}; } diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index c2db2a659ad..07d60b208f3 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -200,7 +200,9 @@ FeeVoteImpl::doVoting( std::shared_ptr const& initialPosition) { // LCL must be flag ledger - XRPL_ASSERT(lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); + XRPL_ASSERT( + "ripple::FeeVoteImpl::doVoting : has a flag ledger", + lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); detail::VotableValue baseFeeVote( lastClosedLedger->fees().base, target_.reference_fee); diff --git a/src/xrpld/app/misc/HashRouter.cpp b/src/xrpld/app/misc/HashRouter.cpp index 63a53ecdfdb..9bafb9c4561 100644 --- a/src/xrpld/app/misc/HashRouter.cpp +++ b/src/xrpld/app/misc/HashRouter.cpp @@ -101,7 +101,7 @@ HashRouter::getFlags(uint256 const& key) bool HashRouter::setFlags(uint256 const& key, int flags) { - XRPL_ASSERT(flags != 0); + XRPL_ASSERT("ripple::HashRouter::setFlags : valid input", flags != 0); std::lock_guard lock(mutex_); diff --git a/src/xrpld/app/misc/NegativeUNLVote.cpp b/src/xrpld/app/misc/NegativeUNLVote.cpp index 8baf8a32e91..3a375851de5 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.cpp +++ b/src/xrpld/app/misc/NegativeUNLVote.cpp @@ -89,7 +89,9 @@ NegativeUNLVote::doVoting( { auto n = choose(prevLedger->info().hash, candidates.toDisableCandidates); - XRPL_ASSERT(nidToKeyMap.count(n)); + XRPL_ASSERT( + "ripple::NegativeUNLVote::doVoting : found node to disable", + nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToDisable, initialSet); } @@ -97,7 +99,9 @@ NegativeUNLVote::doVoting( { auto n = choose( prevLedger->info().hash, candidates.toReEnableCandidates); - XRPL_ASSERT(nidToKeyMap.count(n)); + XRPL_ASSERT( + "ripple::NegativeUNLVote::doVoting : found node to enable", + nidToKeyMap.count(n)); addTx(seq, nidToKeyMap.at(n), ToReEnable, initialSet); } } @@ -140,7 +144,9 @@ NegativeUNLVote::choose( uint256 const& randomPadData, std::vector const& candidates) { - XRPL_ASSERT(!candidates.empty()); + XRPL_ASSERT( + "ripple::NegativeUNLVote::choose : non-empty input", + !candidates.empty()); static_assert(NodeID::bytes <= uint256::bytes); NodeID randomPad = NodeID::fromVoid(randomPadData.data()); NodeID txNodeID = candidates[0]; diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index a2d5a7da789..b203a7b0cb9 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -104,7 +104,10 @@ class NetworkOPsImp final : public NetworkOPs FailHard f) : transaction(t), admin(a), local(l), failType(f) { - XRPL_ASSERT(local || failType == FailHard::no); + XRPL_ASSERT( + "ripple::NetworkOPsImp::TransactionStatus::TransactionStatus : " + "valid inputs", + local || failType == FailHard::no); } }; @@ -1215,7 +1218,9 @@ NetworkOPsImp::processTransaction( *transaction->getSTransaction(), view->rules(), app_.config()); - XRPL_ASSERT(validity == Validity::Valid); + XRPL_ASSERT( + "ripple::NetworkOPsImp::processTransaction : valid validity", + validity == Validity::Valid); // Not concerned with local checks at this point. if (validity == Validity::SigBad) @@ -1321,9 +1326,13 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) std::vector submit_held; std::vector transactions; mTransactions.swap(transactions); - XRPL_ASSERT(!transactions.empty()); + XRPL_ASSERT( + "ripple::NetworkOPsImp::apply : non-empty transactions", + !transactions.empty()); + XRPL_ASSERT( + "ripple::NetworkOPsImp::apply : is not running", + mDispatchState != DispatchState::running); - XRPL_ASSERT(mDispatchState != DispatchState::running); mDispatchState = DispatchState::running; batchLock.unlock(); @@ -1539,7 +1548,9 @@ NetworkOPsImp::getOwnerInfo( for (auto const& uDirEntry : sleNode->getFieldV256(sfIndexes)) { auto sleCur = lpLedger->read(keylet::child(uDirEntry)); - XRPL_ASSERT(sleCur); + XRPL_ASSERT( + "ripple::NetworkOPsImp::getOwnerInfo : non-null child SLE", + sleCur); switch (sleCur->getType()) { @@ -1566,7 +1577,9 @@ NetworkOPsImp::getOwnerInfo( case ltACCOUNT_ROOT: case ltDIR_NODE: default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NetworkOPsImp::getOwnerInfo : invalid " + "type"); break; } } @@ -1576,7 +1589,9 @@ NetworkOPsImp::getOwnerInfo( if (uNodeDir) { sleNode = lpLedger->read(keylet::page(root, uNodeDir)); - XRPL_ASSERT(sleNode); + XRPL_ASSERT( + "ripple::NetworkOPsImp::getOwnerInfo : read next page", + sleNode); } } while (uNodeDir); } @@ -1806,7 +1821,9 @@ NetworkOPsImp::switchLastClosedLedger( bool NetworkOPsImp::beginConsensus(uint256 const& networkClosed) { - XRPL_ASSERT(networkClosed.isNonZero()); + XRPL_ASSERT( + "ripple::NetworkOPsImp::beginConsensus : nonzero input", + networkClosed.isNonZero()); auto closingInfo = m_ledgerMaster.getCurrentLedger()->info(); @@ -1827,10 +1844,15 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed) return false; } - XRPL_ASSERT(prevLedger->info().hash == closingInfo.parentHash); XRPL_ASSERT( + "ripple::NetworkOPsImp::beginConsensus : prevLedger hash matches " + "parent", + prevLedger->info().hash == closingInfo.parentHash); + XRPL_ASSERT( + "ripple::NetworkOPsImp::beginConsensus : closedLedger parent matches " + "hash", closingInfo.parentHash == - m_ledgerMaster.getClosedLedger()->info().hash); + m_ledgerMaster.getClosedLedger()->info().hash); if (prevLedger->rules().enabled(featureNegativeUNL)) app_.validators().setNegativeUNL(prevLedger->negativeUNL()); @@ -2955,7 +2977,9 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) lpAccepted->info().hash, alpAccepted); } - XRPL_ASSERT(alpAccepted->getLedger().get() == lpAccepted.get()); + XRPL_ASSERT( + "ripple::NetworkOPsImp::pubLedger : accepted input", + alpAccepted->getLedger().get() == lpAccepted.get()); { JLOG(m_journal.debug()) @@ -3359,8 +3383,10 @@ NetworkOPsImp::pubAccountTransaction( jvObj.set(jss::account_history_boundary, true); XRPL_ASSERT( + "ripple::NetworkOPsImp::pubAccountTransaction : " + "account_history_tx_stream not set", jvObj.isMember(jss::account_history_tx_stream) == - MultiApiJson::none); + MultiApiJson::none); for (auto& info : accountHistoryNotify) { auto& index = info.index_; @@ -3434,8 +3460,10 @@ NetworkOPsImp::pubProposedAccountTransaction( [&](Json::Value const& jv) { isrListener->send(jv, true); }); XRPL_ASSERT( + "ripple::NetworkOPs::pubProposedAccountTransaction : " + "account_history_tx_stream not set", jvObj.isMember(jss::account_history_tx_stream) == - MultiApiJson::none); + MultiApiJson::none); for (auto& info : accountHistoryNotify) { auto& index = info.index_; @@ -3713,7 +3741,9 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) return db->newestAccountTxPage(options); } default: { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NetworkOPsImp::addAccountHistoryJob::" + "getMoreTxns : invalid database type"); return {}; } } @@ -3909,7 +3939,9 @@ NetworkOPsImp::subAccountHistoryStart( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NetworkOPsImp::subAccountHistoryStart : failed to " + "access genesis account"); return; } } @@ -4017,7 +4049,8 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NetworkOPsImp::subBook : null book listeners"); return true; } @@ -4036,7 +4069,8 @@ NetworkOPsImp::acceptLedger( { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` - XRPL_ASSERT(m_standalone); + XRPL_ASSERT( + "ripple::NetworkOPsImp::acceptLedger : is standalone", m_standalone); if (!m_standalone) Throw( diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 91a4403be5d..c76e808bebb 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -281,7 +281,8 @@ SHAMapStoreImp::run() { if (app_.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::SHAMapStoreImp::run : reporting mode not supported"); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); @@ -553,7 +554,9 @@ SHAMapStoreImp::clearSql( std::function()> const& getMinSeq, std::function const& deleteBeforeSeq) { - XRPL_ASSERT(deleteInterval_); + XRPL_ASSERT( + "ripple::SHAMapStoreImp::clearSql : nonzero delete interval", + deleteInterval_); LedgerIndex min = std::numeric_limits::max(); { @@ -618,7 +621,9 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated) { if (app_.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::SHAMapStoreImp::clearPrior : reporting mode not " + "supported"); Throw( "Reporting does not support online_delete. Remove " "online_delete info from config"); diff --git a/src/xrpld/app/misc/detail/AMMHelpers.cpp b/src/xrpld/app/misc/detail/AMMHelpers.cpp index 3518d0b0be7..9e1d56333eb 100644 --- a/src/xrpld/app/misc/detail/AMMHelpers.cpp +++ b/src/xrpld/app/misc/detail/AMMHelpers.cpp @@ -209,7 +209,9 @@ adjustAmountsByLPTokens( return std::make_tuple(amountActual, std::nullopt, lpTokensActual); } - XRPL_ASSERT(lpTokensActual == lpTokens); + XRPL_ASSERT( + "ripple::adjustAmountsByLPTokens : LP tokens match actual", + lpTokensActual == lpTokens); return {amount, amount2, lpTokensActual}; } diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp index 918e2624d3c..2a5af4708ec 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -146,8 +146,9 @@ getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account) { using namespace std::chrono; XRPL_ASSERT( + "ripple::getTradingFee : auction present", !view.rules().enabled(fixInnerObjTemplate) || - ammSle.isFieldPresent(sfAuctionSlot)); + ammSle.isFieldPresent(sfAuctionSlot)); if (ammSle.isFieldPresent(sfAuctionSlot)) { auto const& auctionSlot = diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index 44ec7586289..dfd1881baa9 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -656,7 +656,9 @@ AmendmentTableImpl::persistVote( std::string const& name, AmendmentVote vote) const { - XRPL_ASSERT(vote != AmendmentVote::obsolete); + XRPL_ASSERT( + "ripple::AmendmentTableImpl::persistVote : valid vote input", + vote != AmendmentVote::obsolete); auto db = db_.checkoutDb(); voteAmendment(*db, amendment, name, vote); } diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp index b9717a3c620..05ccd3d6cf4 100644 --- a/src/xrpld/app/misc/detail/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -390,7 +390,9 @@ ManifestCache::applyManifest(Manifest m) auto prewriteCheck = [this, &m](auto const& iter, bool checkSignature, auto const& lock) -> std::optional { - XRPL_ASSERT(lock.owns_lock()); + XRPL_ASSERT( + "ripple::ManifestCache::applyManifest::prewriteCheck : locked", + lock.owns_lock()); (void)lock; // not used. parameter is present to ensure the mutex is // locked when the lambda is called. if (iter != map_.end() && m.sequence <= iter->second.sequence) diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index 4f9bd6b4bf6..07869704d94 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -84,7 +84,10 @@ Transaction::sqlTransactionStatus(boost::optional const& status) return INCLUDED; } - XRPL_ASSERT(c == txnSqlUnknown); + XRPL_ASSERT( + "ripple::Transaction::sqlTransactionStatus : unknown transaction " + "status", + c == txnSqlUnknown); return INVALID; } diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 3ec8befb75a..2d1afbc9a38 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -52,7 +52,7 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return std::pair{baseFee + mod, feePaid + mod}; }(); - XRPL_ASSERT(baseFee.signum() > 0); + XRPL_ASSERT("ripple::getFeeLevelPaid : positive fee", baseFee.signum() > 0); if (effectiveFeePaid.signum() <= 0 || baseFee.signum() <= 0) { return FeeLevel64(0); @@ -95,7 +95,9 @@ TxQ::FeeMetrics::update( feeLevels.push_back(getFeeLevelPaid(view, *tx.first)); }); std::sort(feeLevels.begin(), feeLevels.end()); - XRPL_ASSERT(size == feeLevels.size()); + XRPL_ASSERT( + "ripple::TxQ::FeeMetrics::update : fee levels size", + size == feeLevels.size()); JLOG((timeLeap ? j_.warn() : j_.debug())) << "Ledger " << view.info().seq << " has " << size << " transactions. " @@ -247,7 +249,10 @@ TxQ::FeeMetrics::escalatedSeriesFeeLevel( auto const target = snapshot.txnsExpected; auto const multiplier = snapshot.escalationMultiplier; - XRPL_ASSERT(current > target); + XRPL_ASSERT( + "ripple::TxQ::FeeMetrics::escalatedSeriesFeeLevel : current over " + "target", + current > target); /* Calculate (apologies for the terrible notation) sum(n = current -> last) : multiplier * n * n / (target * target) @@ -292,7 +297,8 @@ std::pair TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) { // If the rules or flags change, preflight again - XRPL_ASSERT(pfresult); + XRPL_ASSERT( + "ripple::TxQ::MaybeTx::apply : preflight result is set", pfresult); STAmountSO stAmountSO{view.rules().enabled(fixSTAmountCanonicalize)}; NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; @@ -337,8 +343,11 @@ TxQ::TxQAccount::add(MaybeTx&& txn) auto const seqProx = txn.seqProxy; auto result = transactions.emplace(seqProx, std::move(txn)); - XRPL_ASSERT(result.second); - XRPL_ASSERT(&result.first->second != &txn); + XRPL_ASSERT( + "ripple::TxQ::TxQAccount::add : emplace succeeded", result.second); + XRPL_ASSERT( + "ripple::TxQ::TxQAccount::add : transaction moved", + &result.first->second != &txn); return result.first->second; } @@ -448,7 +457,7 @@ TxQ::erase(TxQ::FeeMultiSet::const_iterator_type candidateIter) // so the memory can be freed. auto const found = txQAccount.remove(seqProx); (void)found; - XRPL_ASSERT(found); + XRPL_ASSERT("ripple::TxQ::erase : account removed", found); return newCandidateIter; } @@ -460,15 +469,20 @@ TxQ::eraseAndAdvance(TxQ::FeeMultiSet::const_iterator_type candidateIter) auto& txQAccount = byAccount_.at(candidateIter->account); auto const accountIter = txQAccount.transactions.find(candidateIter->seqProxy); - XRPL_ASSERT(accountIter != txQAccount.transactions.end()); + XRPL_ASSERT( + "ripple::TxQ::eraseAndAdvance : account found", + accountIter != txQAccount.transactions.end()); // Note that sequence-based transactions must be applied in sequence order // from smallest to largest. But ticket-based transactions can be // applied in any order. XRPL_ASSERT( + "ripple::TxQ::eraseAndAdvance : ticket or sequence", candidateIter->seqProxy.isTicket() || - accountIter == txQAccount.transactions.begin()); - XRPL_ASSERT(byFee_.iterator_to(accountIter->second) == candidateIter); + accountIter == txQAccount.transactions.begin()); + XRPL_ASSERT( + "ripple::TxQ::eraseAndAdvance : found in byFee", + byFee_.iterator_to(accountIter->second) == candidateIter); auto const accountNextIter = std::next(accountIter); // Check if the next transaction for this account is earlier in the queue, @@ -515,7 +529,9 @@ TxQ::tryClearAccountQueueUpThruTx( beast::Journal j) { SeqProxy const tSeqProx{tx.getSeqProxy()}; - XRPL_ASSERT(beginTxIter != accountIter->second.transactions.end()); + XRPL_ASSERT( + "ripple::TxQ::tryClearAccountQueueUpThruTx : non-empty accounts input", + beginTxIter != accountIter->second.transactions.end()); // This check is only concerned with the range from // [aSeqProxy, tSeqProxy) @@ -998,7 +1014,8 @@ TxQ::apply( // o The current first thing in the queue has a Ticket and // * The tx has a Ticket that precedes it or // * txSeqProx == acctSeqProx. - XRPL_ASSERT(prevIter != txIter->end); + XRPL_ASSERT( + "ripple::TxQ::apply : not end", prevIter != txIter->end); if (prevIter == txIter->end || txSeqProx < prevIter->first) { // The first Sequence number in the queue must be the @@ -1120,9 +1137,10 @@ TxQ::apply( auto const potentialTotalSpend = totalFee + std::min(balance - std::min(balance, reserve), potentialSpend); XRPL_ASSERT( + "ripple::TxQ::apply : total spend check", potentialTotalSpend > XRPAmount{0} || - (potentialTotalSpend == XRPAmount{0} && - multiTxn->applyView.fees().base == 0)); + (potentialTotalSpend == XRPAmount{0} && + multiTxn->applyView.fees().base == 0)); sleBump->setFieldAmount(sfBalance, balance - potentialTotalSpend); // The transaction's sequence/ticket will be valid when the other // transactions in the queue have been processed. If the tx has a @@ -1152,7 +1170,7 @@ TxQ::apply( return {pcresult.ter, false}; // Too low of a fee should get caught by preclaim - XRPL_ASSERT(feeLevelPaid >= baseLevel); + XRPL_ASSERT("ripple::TxQ::apply : minimum fee", feeLevelPaid >= baseLevel); JLOG(j_.trace()) << "Transaction " << transactionID << " from account " << account << " has fee level of " << feeLevelPaid @@ -1277,7 +1295,9 @@ TxQ::apply( // The queue is full, and this transaction is more // valuable, so kick out the cheapest transaction. auto dropRIter = endAccount.transactions.rbegin(); - XRPL_ASSERT(dropRIter->second.account == lastRIter->account); + XRPL_ASSERT( + "ripple::TxQ::apply : cheapest transaction found", + dropRIter->second.account == lastRIter->account); JLOG(j_.info()) << "Removing last item of account " << lastRIter->account << " from queue with average fee of " << endEffectiveFeeLevel @@ -1307,7 +1327,7 @@ TxQ::apply( std::tie(accountIter, created) = byAccount_.emplace(account, TxQAccount(tx)); (void)created; - XRPL_ASSERT(created); + XRPL_ASSERT("ripple::TxQ::apply : account created", created); } // Modify the flags for use when coming out of the queue. // These changes _may_ cause an extra `preflight`, but as long as @@ -1521,8 +1541,9 @@ TxQ::accept(Application& app, OpenView& view) // this account. auto dropRIter = account.transactions.rbegin(); XRPL_ASSERT( + "ripple::TxQ::accept : account check", dropRIter->second.account == - candidateIter->account); + candidateIter->account); JLOG(j_.info()) << "Queue is nearly full, and transaction " @@ -1553,7 +1574,8 @@ TxQ::accept(Application& app, OpenView& view) LedgerHash const& parentHash = view.info().parentHash; #if !NDEBUG auto const startingSize = byFee_.size(); - XRPL_ASSERT(parentHash != parentHash_); + XRPL_ASSERT( + "ripple::TxQ::accept : new parent hash", parentHash != parentHash_); parentHash_ = parentHash; #endif // byFee_ doesn't "own" the candidate objects inside it, so it's @@ -1575,7 +1597,9 @@ TxQ::accept(Application& app, OpenView& view) byFee_.insert(candidate); } } - XRPL_ASSERT(byFee_.size() == startingSize); + XRPL_ASSERT( + "ripple::TxQ::accept : byFee size match", + byFee_.size() == startingSize); return ledgerChanged; } @@ -1734,10 +1758,18 @@ TxQ::removeFromByFee( // If the transaction we're holding replaces a transaction in the // queue, remove the transaction that is being replaced. auto deleteIter = byFee_.iterator_to((*replacedTxIter)->second); - XRPL_ASSERT(deleteIter != byFee_.end()); - XRPL_ASSERT(&(*replacedTxIter)->second == &*deleteIter); - XRPL_ASSERT(deleteIter->seqProxy == tx->getSeqProxy()); - XRPL_ASSERT(deleteIter->account == (*tx)[sfAccount]); + XRPL_ASSERT( + "ripple::TxQ::removeFromByFee : found in byFee", + deleteIter != byFee_.end()); + XRPL_ASSERT( + "ripple::TxQ::removeFromByFee : matching transaction", + &(*replacedTxIter)->second == &*deleteIter); + XRPL_ASSERT( + "ripple::TxQ::removeFromByFee : matching sequence", + deleteIter->seqProxy == tx->getSeqProxy()); + XRPL_ASSERT( + "ripple::TxQ::removeFromByFee : matching account", + deleteIter->account == (*tx)[sfAccount]); erase(deleteIter); } diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index e3a3b0addb2..adc3b870df0 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -277,6 +277,7 @@ ValidatorList::buildFileData( Json::Value value(Json::objectValue); XRPL_ASSERT( + "ripple::ValidatorList::buildFileData : valid publisher list input", pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.rawVersion; @@ -377,7 +378,9 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) ValidatorBlobInfo& info = result.emplace_back(); info.blob = body[jss::blob].asString(); info.signature = body[jss::signature].asString(); - XRPL_ASSERT(result.size() == 1); + XRPL_ASSERT( + "ripple::ValidatorList::parseBlobs : single element result", + result.size() == 1); return result; } // Treat unknown versions as if they're the latest version. This @@ -412,7 +415,10 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) info.manifest = blobInfo[jss::manifest].asString(); } } - XRPL_ASSERT(result.size() == blobs.size()); + XRPL_ASSERT( + "ripple::ValidatorList::parseBlobs(version, Jason::Value) : " + "result size matches", + result.size() == blobs.size()); return result; } } @@ -443,7 +449,10 @@ ValidatorList::parseBlobs(protocol::TMValidatorListCollection const& body) info.manifest = blob.manifest(); } } - XRPL_ASSERT(result.size() == body.blobs_size()); + XRPL_ASSERT( + "ripple::ValidatorList::parseBlobs(TMValidatorList) : result size " + "match", + result.size() == body.blobs_size()); return result; } @@ -465,7 +474,7 @@ splitMessage( { if (begin == 0 && end == 0) end = largeMsg.blobs_size(); - XRPL_ASSERT(begin < end); + XRPL_ASSERT("ripple::splitMessage : valid inputs", begin < end); if (end <= begin) return 0; @@ -499,7 +508,9 @@ splitMessageParts( if (blob.has_manifest()) smallMsg.set_manifest(blob.manifest()); - XRPL_ASSERT(Message::totalSize(smallMsg) <= maximiumMessageSize); + XRPL_ASSERT( + "ripple::splitMessageParts : maximum message size", + Message::totalSize(smallMsg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(smallMsg, protocol::mtVALIDATORLIST), @@ -547,7 +558,10 @@ buildValidatorListMessage( ValidatorBlobInfo const& currentBlob, std::size_t maxSize) { - XRPL_ASSERT(messages.empty()); + XRPL_ASSERT( + "ripple::buildValidatorListMessage(ValidatorBlobInfo) : empty messages " + "input", + messages.empty()); protocol::TMValidatorList msg; auto const manifest = currentBlob.manifest ? *currentBlob.manifest : rawManifest; @@ -558,7 +572,10 @@ buildValidatorListMessage( // Override the version msg.set_version(version); - XRPL_ASSERT(Message::totalSize(msg) <= maximiumMessageSize); + XRPL_ASSERT( + "ripple::buildValidatorListMessage(ValidatorBlobInfo) : maximum " + "message size", + Message::totalSize(msg) <= maximiumMessageSize); messages.emplace_back( std::make_shared(msg, protocol::mtVALIDATORLIST), sha512Half(msg), @@ -577,7 +594,10 @@ buildValidatorListMessage( std::map const& blobInfos, std::size_t maxSize) { - XRPL_ASSERT(messages.empty()); + XRPL_ASSERT( + "ripple::buildValidatorListMessage(std::map) : empty messages input", + messages.empty()); protocol::TMValidatorListCollection msg; auto const version = rawVersion < 2 ? 2 : rawVersion; msg.set_version(version); @@ -593,7 +613,10 @@ buildValidatorListMessage( if (blobInfo.manifest) blob.set_manifest(*blobInfo.manifest); } - XRPL_ASSERT(msg.blobs_size() > 0); + XRPL_ASSERT( + "ripple::buildValidatorListMessage(std::map) : minimum message blobs", + msg.blobs_size() > 0); if (Message::totalSize(msg) > maxSize) { // split into smaller messages @@ -622,7 +645,10 @@ ValidatorList::buildValidatorListMessages( std::vector& messages, std::size_t maxSize /*= maximiumMessageSize*/) { - XRPL_ASSERT(!blobInfos.empty()); + XRPL_ASSERT( + "ripple::ValidatorList::buildValidatorListMessages : empty messages " + "input", + !blobInfos.empty()); auto const& [currentSeq, currentBlob] = *blobInfos.begin(); auto numVLs = std::accumulate( messages.begin(), @@ -706,7 +732,10 @@ ValidatorList::sendValidatorList( messages); if (newPeerSequence) { - XRPL_ASSERT(!messages.empty()); + XRPL_ASSERT( + "ripple::ValidatorList::sendValidatorList : non-empty messages " + "input", + !messages.empty()); // Don't send it next time. peer.setPublisherListSequence(publisherKey, newPeerSequence); @@ -722,7 +751,9 @@ ValidatorList::sendValidatorList( } // The only way sent wil be false is if the messages was too big, and // thus there will only be one entry without a message - XRPL_ASSERT(sent || messages.size() == 1); + XRPL_ASSERT( + "ripple::ValidatorList::sendValidatorList : sent or one message", + sent || messages.size() == 1); if (sent) { if (messageVersion > 1) @@ -736,7 +767,10 @@ ValidatorList::sendValidatorList( << "]"; else { - XRPL_ASSERT(numVLs == 1); + XRPL_ASSERT( + "ripple::ValidatorList::sendValidatorList : one validator " + "list", + numVLs == 1); JLOG(j.debug()) << "Sent validator list for " << strHex(publisherKey) << " with sequence " << newPeerSequence << " to " @@ -832,8 +866,9 @@ ValidatorList::broadcastBlobs( std::map blobInfos; XRPL_ASSERT( + "ripple::ValidatorList::broadcastBlobs : valid sequence", lists.current.sequence == maxSequence || - lists.remaining.count(maxSequence) == 1); + lists.remaining.count(maxSequence) == 1); // Can't use overlay.foreach here because we need to modify // the peer, and foreach provides a const& for (auto& peer : overlay.getActivePeers()) @@ -977,7 +1012,9 @@ ValidatorList::applyLists( for (auto iter = remaining.begin(); iter != remaining.end();) { auto next = std::next(iter); - XRPL_ASSERT(next == remaining.end() || next->first > iter->first); + XRPL_ASSERT( + "ripple::ValidatorList::applyLists : next is valid", + next == remaining.end() || next->first > iter->first); if (iter->first <= current.sequence || (next != remaining.end() && next->second.validFrom <= iter->second.validFrom)) @@ -1149,7 +1186,9 @@ ValidatorList::applyList( // Remove the entry in "remaining" pubCollection.remaining.erase(sequence); // Done - XRPL_ASSERT(publisher.sequence == sequence); + XRPL_ASSERT( + "ripple::ValidatorList::applyList : publisher sequence match", + publisher.sequence == sequence); } else { @@ -1444,8 +1483,9 @@ ValidatorList::removePublisherList( PublisherStatus reason) { XRPL_ASSERT( + "ripple::ValidatorList::removePublisherList : valid reason input", reason != PublisherStatus::available && - reason != PublisherStatus::unavailable); + reason != PublisherStatus::unavailable); auto const iList = publisherLists_.find(publisherKey); if (iList == publisherLists_.end()) return false; @@ -1630,7 +1670,9 @@ ValidatorList::getJson() const Json::Value& r = remaining.append(Json::objectValue); appendList(future, r); // Race conditions can happen, so make this check "fuzzy" - XRPL_ASSERT(future.validFrom > timeKeeper_.now() + 600s); + XRPL_ASSERT( + "ripple::ValidatorList::getJson : minimum valid from", + future.validFrom > timeKeeper_.now() + 600s); } if (remaining.size()) curr[jss::remaining] = std::move(remaining); @@ -1695,7 +1737,9 @@ ValidatorList::for_each_available( { if (plCollection.status != PublisherStatus::available) continue; - XRPL_ASSERT(plCollection.maxSequence); + XRPL_ASSERT( + "ripple::ValidatorList::for_each_available : nonzero maxSequence", + plCollection.maxSequence); func( plCollection.rawManifest, plCollection.rawVersion, @@ -1829,21 +1873,31 @@ ValidatorList::updateTrusted( next->second.validFrom <= closeTime; ++iter, ++next) { - XRPL_ASSERT(std::next(iter) == next); + XRPL_ASSERT( + "ripple::ValidatorList::updateTrusted : sequential " + "remaining", + std::next(iter) == next); } - XRPL_ASSERT(iter != remaining.end()); + XRPL_ASSERT( + "ripple::ValidatorList::updateTrusted : non-end of " + "remaining", + iter != remaining.end()); // Rotate the pending list in to current auto sequence = iter->first; auto& candidate = iter->second; auto& current = collection.current; - XRPL_ASSERT(candidate.validFrom <= closeTime); + XRPL_ASSERT( + "ripple::ValidatorList::updateTrusted : maximum time", + candidate.validFrom <= closeTime); auto const oldList = current.list; current = std::move(candidate); if (collection.status != PublisherStatus::available) collection.status = PublisherStatus::available; - XRPL_ASSERT(current.sequence == sequence); + XRPL_ASSERT( + "ripple::ValidatorList::updateTrusted : sequence match", + current.sequence == sequence); // If the list is expired, remove the validators so they don't // get processed in. The expiration check below will do the rest // of the work @@ -1920,7 +1974,9 @@ ValidatorList::updateTrusted( { std::optional const signingKey = validatorManifests_.getSigningKey(k); - XRPL_ASSERT(signingKey); + XRPL_ASSERT( + "ripple::ValidatorList::updateTrusted : found signing key", + signingKey); trustedSigningKeys_.insert(*signingKey); } } diff --git a/src/xrpld/app/misc/detail/ValidatorSite.cpp b/src/xrpld/app/misc/detail/ValidatorSite.cpp index 299a802a967..6e3f4835878 100644 --- a/src/xrpld/app/misc/detail/ValidatorSite.cpp +++ b/src/xrpld/app/misc/detail/ValidatorSite.cpp @@ -411,7 +411,9 @@ ValidatorSite::parseJsonResponse( } auto const manifest = body[jss::manifest].asString(); - XRPL_ASSERT(version == body[jss::version].asUInt()); + XRPL_ASSERT( + "ripple::ValidatorSite::parseJsonResponse : version match", + version == body[jss::version].asUInt()); auto const& uri = sites_[siteIdx].activeResource->uri; auto const hash = sha512Half(manifest, blobs, version); auto const applyResult = app_.validators().applyListsAndBroadcast( @@ -586,7 +588,10 @@ ValidatorSite::onSiteFetch( case status::temporary_redirect: { auto newLocation = processRedirect(res, siteIdx, lock_sites); - XRPL_ASSERT(newLocation); + XRPL_ASSERT( + "ripple::ValidatorSite::onSiteFetch : non-null " + "validator", + newLocation); // for perm redirects, also update our starting URI if (res.result() == status::moved_permanently || res.result() == status::permanent_redirect) diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index 4f38d379dd0..b296565511f 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -282,7 +282,7 @@ WorkBase::onResponse(error_code const& ec) return fail(ec); close(); - XRPL_ASSERT(cb_); + XRPL_ASSERT("ripple::detail::WorkBase::onResponse : callback is set", cb_); cb_(ec, lastEndpoint_, std::move(res_)); cb_ = nullptr; } diff --git a/src/xrpld/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h index 9a7481a54cc..e7b799f879c 100644 --- a/src/xrpld/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -88,7 +88,7 @@ WorkFile::run() error_code ec; auto const fileContents = getFileContents(ec, path_, megabytes(1)); - XRPL_ASSERT(cb_); + XRPL_ASSERT("ripple::detail::WorkFile::run : callback is set", cb_); cb_(ec, fileContents); cb_ = nullptr; } diff --git a/src/xrpld/app/paths/Credit.cpp b/src/xrpld/app/paths/Credit.cpp index fcead298691..072381edaab 100644 --- a/src/xrpld/app/paths/Credit.cpp +++ b/src/xrpld/app/paths/Credit.cpp @@ -42,8 +42,12 @@ creditLimit( result.setIssuer(account); } - XRPL_ASSERT(result.getIssuer() == account); - XRPL_ASSERT(result.getCurrency() == currency); + XRPL_ASSERT( + "ripple::creditLimit : result issuer match", + result.getIssuer() == account); + XRPL_ASSERT( + "ripple::creditLimit : result currency match", + result.getCurrency() == currency); return result; } @@ -76,8 +80,12 @@ creditBalance( result.setIssuer(account); } - XRPL_ASSERT(result.getIssuer() == account); - XRPL_ASSERT(result.getCurrency() == currency); + XRPL_ASSERT( + "ripple::creditBalance : result issuer match", + result.getIssuer() == account); + XRPL_ASSERT( + "ripple::creditBalance : result currency match", + result.getCurrency() == currency); return result; } diff --git a/src/xrpld/app/paths/Flow.cpp b/src/xrpld/app/paths/Flow.cpp index caa729496f3..b50d2c69497 100644 --- a/src/xrpld/app/paths/Flow.cpp +++ b/src/xrpld/app/paths/Flow.cpp @@ -193,7 +193,7 @@ flow( flowDebugInfo)); } - XRPL_ASSERT(!srcIsXRP && !dstIsXRP); + XRPL_ASSERT("ripple::flow : neither is XRP", !srcIsXRP && !dstIsXRP); return finishFlow( sb, srcIssue, diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index 9161d7f5695..9b50b527ad2 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -158,7 +158,8 @@ PathRequest::updateComplete() { std::lock_guard sl(mIndexLock); - XRPL_ASSERT(mInProgress); + XRPL_ASSERT( + "ripple::PathRequest::updateComplete : in progress", mInProgress); mInProgress = false; if (fCompletion) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index 78fb4f3c827..a80fbc29e14 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -189,6 +189,7 @@ Pathfinder::Pathfinder( , j_(app.journal("Pathfinder")) { XRPL_ASSERT( + "ripple::Pathfinder::Pathfinder : valid inputs", !uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); } @@ -578,7 +579,9 @@ Pathfinder::getBestPaths( if (mCompletePaths.empty() && extraPaths.empty()) return mCompletePaths; - XRPL_ASSERT(fullLiquidityPath.empty()); + XRPL_ASSERT( + "ripple::Pathfinder::getBestPaths : first empty path result", + fullLiquidityPath.empty()); const bool issuerIsSender = isXRP(mSrcCurrency) || (srcIssuer == mSrcAccount); @@ -639,7 +642,8 @@ Pathfinder::getBestPaths( if (path.empty()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::Pathfinder::getBestPaths : path not found"); continue; } @@ -682,7 +686,9 @@ Pathfinder::getBestPaths( if (remaining > beast::zero) { - XRPL_ASSERT(fullLiquidityPath.empty()); + XRPL_ASSERT( + "ripple::Pathfinder::getBestPaths : second empty path result", + fullLiquidityPath.empty()); JLOG(j_.info()) << "Paths could not send " << remaining << " of " << mDstAmount; } @@ -831,7 +837,9 @@ Pathfinder::addPathsForType( { case nt_SOURCE: // Source must always be at the start, so pathsOut has to be empty. - XRPL_ASSERT(pathsOut.empty()); + XRPL_ASSERT( + "ripple::Pathfinder::addPathsForType : empty paths", + pathsOut.empty()); pathsOut.push_back(STPath()); break; @@ -1283,7 +1291,7 @@ void fillPaths(Pathfinder::PaymentType type, PathCostList const& costs) { auto& list = mPathTable[type]; - XRPL_ASSERT(list.empty()); + XRPL_ASSERT("ripple::fillPaths : empty paths", list.empty()); for (auto& cost : costs) list.push_back({cost.cost, makePath(cost.path)}); } diff --git a/src/xrpld/app/paths/RippleLineCache.cpp b/src/xrpld/app/paths/RippleLineCache.cpp index a4a3dd0c33a..be838c53eac 100644 --- a/src/xrpld/app/paths/RippleLineCache.cpp +++ b/src/xrpld/app/paths/RippleLineCache.cpp @@ -79,7 +79,9 @@ RippleLineCache::getRippleLines( // to be replaced by the full set. The full set will be built // below, and will be returned, if needed, on subsequent calls // for either value of outgoing. - XRPL_ASSERT(size <= totalLineCount_); + XRPL_ASSERT( + "ripple::RippleLineCache::getRippleLines : maximum lines", + size <= totalLineCount_); totalLineCount_ -= size; lines_.erase(otheriter); } @@ -99,7 +101,9 @@ RippleLineCache::getRippleLines( if (inserted) { - XRPL_ASSERT(it->second == nullptr); + XRPL_ASSERT( + "ripple::RippleLineCache::getRippleLines : null lines", + it->second == nullptr); auto lines = PathFindTrustLine::getItems(accountID, *ledger_, direction); if (lines.size()) @@ -110,7 +114,9 @@ RippleLineCache::getRippleLines( } } - XRPL_ASSERT(!it->second || (it->second->size() > 0)); + XRPL_ASSERT( + "ripple::RippleLineCache::getRippleLines : null or nonempty lines", + !it->second || (it->second->size() > 0)); auto const size = it->second ? it->second->size() : 0; JLOG(journal_.trace()) << "getRippleLines for ledger " << ledger_->info().seq << " found " << size diff --git a/src/xrpld/app/paths/detail/AMMLiquidity.cpp b/src/xrpld/app/paths/detail/AMMLiquidity.cpp index b4800cbab30..3df173311d3 100644 --- a/src/xrpld/app/paths/detail/AMMLiquidity.cpp +++ b/src/xrpld/app/paths/detail/AMMLiquidity.cpp @@ -77,7 +77,9 @@ AMMLiquidity::generateFibSeqOffer( 196418, 317811, 514229, 832040, 1346269}; // clang-format on - XRPL_ASSERT(!ammContext_.maxItersReached()); + XRPL_ASSERT( + "ripple::AMMLiquidity::generateFibSeqOffer : maximum iterations", + !ammContext_.maxItersReached()); cur.out = toAmount( getIssue(balances.out), diff --git a/src/xrpld/app/paths/detail/AmountSpec.h b/src/xrpld/app/paths/detail/AmountSpec.h index cb275958bd0..70fdd61f853 100644 --- a/src/xrpld/app/paths/detail/AmountSpec.h +++ b/src/xrpld/app/paths/detail/AmountSpec.h @@ -125,7 +125,8 @@ template <> inline IOUAmount& get(EitherAmount& amt) { - XRPL_ASSERT(!amt.native); + XRPL_ASSERT( + "ripple::get(EitherAmount&) : is not XRP", !amt.native); return amt.iou; } @@ -133,7 +134,7 @@ template <> inline XRPAmount& get(EitherAmount& amt) { - XRPL_ASSERT(amt.native); + XRPL_ASSERT("ripple::get(EitherAmount&) : is XRP", amt.native); return amt.xrp; } @@ -149,7 +150,9 @@ template <> inline IOUAmount const& get(EitherAmount const& amt) { - XRPL_ASSERT(!amt.native); + XRPL_ASSERT( + "ripple::get(EitherAmount const&) : is not XRP", + !amt.native); return amt.iou; } @@ -157,14 +160,17 @@ template <> inline XRPAmount const& get(EitherAmount const& amt) { - XRPL_ASSERT(amt.native); + XRPL_ASSERT( + "ripple::get(EitherAmount const&) : is XRP", amt.native); return amt.xrp; } inline AmountSpec toAmountSpec(STAmount const& amt) { - XRPL_ASSERT(amt.mantissa() < std::numeric_limits::max()); + XRPL_ASSERT( + "ripple::toAmountSpec(STAmount const&) : maximum mantissa", + amt.mantissa() < std::numeric_limits::max()); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); @@ -199,7 +205,10 @@ toAmountSpec(EitherAmount const& ea, std::optional const& c) AmountSpec r; r.native = (!c || isXRP(*c)); r.currency = c; - XRPL_ASSERT(ea.native == r.native); + XRPL_ASSERT( + "ripple::toAmountSpec(EitherAmount const&&, std::optional) : " + "matching native", + ea.native == r.native); if (r.native) { r.xrp = ea.xrp; diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index 2796f138c93..e1ffdd76996 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -381,7 +382,9 @@ class BookOfferCrossingStep getQuality(std::optional const& limitQuality) { // It's really a programming error if the quality is missing. - XRPL_ASSERT(limitQuality); + XRPL_ASSERT( + "ripple::BookOfferCrossingStep::getQuality : nonzero quality", + limitQuality); if (!limitQuality) Throw(tefINTERNAL, "Offer requires quality."); return *limitQuality; @@ -1109,7 +1112,8 @@ BookStep::revImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingOut < 0 " << to_string(remainingOut); - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::BookStep::revImp : remaining less than zero"); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1132,7 +1136,7 @@ BookStep::fwdImp( boost::container::flat_set& ofrsToRm, TIn const& in) { - XRPL_ASSERT(cache_); + XRPL_ASSERT("ripple::BookStep::fwdImp : cache is set", cache_); TAmounts result(beast::zero, beast::zero); @@ -1151,7 +1155,8 @@ BookStep::fwdImp( TOut const& ownerGives, std::uint32_t transferRateIn, std::uint32_t transferRateOut) mutable -> bool { - XRPL_ASSERT(cache_); + XRPL_ASSERT( + "ripple::BookStep::fwdImp::eachOffer : cache is set", cache_); if (remainingIn <= beast::zero) return false; @@ -1279,7 +1284,8 @@ BookStep::fwdImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingIn < 0 " << to_string(remainingIn); - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::BookStep::fwdImp : remaining less than zero"); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1414,7 +1420,8 @@ bookStepEqual(Step const& step, ripple::Book const& book) bool const outXRP = isXRP(book.out.currency); if (inXRP && outXRP) { - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::test::bookStepEqual : no XRP to XRP book step"); return false; // no such thing as xrp/xrp book step } if (inXRP && !outXRP) diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 2845b00dec2..36f7c3f4a82 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -514,7 +514,9 @@ DirectStepI::revImp( auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); - XRPL_ASSERT(static_cast(this)->verifyDstQualityIn(dstQIn)); + XRPL_ASSERT( + "ripple::DirectStepI : valid destination quality", + static_cast(this)->verifyDstQualityIn(dstQIn)); Issue const srcToDstIss(currency_, redeems(srcDebtDir) ? dst_ : src_); @@ -633,7 +635,7 @@ DirectStepI::fwdImp( boost::container::flat_set& /*ofrsToRm*/, IOUAmount const& in) { - XRPL_ASSERT(cache_); + XRPL_ASSERT("ripple::DirectStepI::fwdImp : cache is set", cache_); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -720,7 +722,7 @@ DirectStepI::validFwd( auto const savCache = *cache_; - XRPL_ASSERT(!in.native); + XRPL_ASSERT("ripple::DirectStepI::validFwd : input is not XRP", !in.native); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -784,8 +786,11 @@ DirectStepI::qualitiesSrcIssues( { // Charge a transfer rate when issuing and previous step redeems - XRPL_ASSERT(static_cast(this)->verifyPrevStepDebtDirection( - prevStepDebtDirection)); + XRPL_ASSERT( + "ripple::DirectStepI::qualitiesSrcIssues : will prevStepDebtDirection " + "issue", + static_cast(this)->verifyPrevStepDebtDirection( + prevStepDebtDirection)); std::uint32_t const srcQOut = redeems(prevStepDebtDirection) ? transferRate(sb, src_).value @@ -924,7 +929,9 @@ DirectStepI::check(StrandContext const& ctx) const { if (!ctx.prevStep) { - XRPL_ASSERT(0); // prev seen book without a prev step!?! + XRPL_UNREACHABLE( + "ripple::DirectStepI::check : prev seen book without a " + "prev step"); return temBAD_PATH_LOOP; } diff --git a/src/xrpld/app/paths/detail/FlowDebugInfo.h b/src/xrpld/app/paths/detail/FlowDebugInfo.h index f75aeddc4c4..24d011f9d10 100644 --- a/src/xrpld/app/paths/detail/FlowDebugInfo.h +++ b/src/xrpld/app/paths/detail/FlowDebugInfo.h @@ -89,7 +89,10 @@ struct FlowDebugInfo void pushLiquiditySrc(EitherAmount const& eIn, EitherAmount const& eOut) { - XRPL_ASSERT(!liquiditySrcIn.empty()); + XRPL_ASSERT( + "ripple::path::detail::FlowDebugInfo::pushLiquiditySrc : " + "non-empty liquidity source", + !liquiditySrcIn.empty()); liquiditySrcIn.back().push_back(eIn); liquiditySrcOut.back().push_back(eOut); } @@ -122,7 +125,9 @@ struct FlowDebugInfo auto i = timePoints.find(tag); if (i == timePoints.end()) { - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::path::detail::FlowDebugInfo::duration : timepoint not " + "found"); return std::chrono::duration(0); } auto const& t = i->second; diff --git a/src/xrpld/app/paths/detail/PaySteps.cpp b/src/xrpld/app/paths/detail/PaySteps.cpp index ae046a6a2d1..356888b071c 100644 --- a/src/xrpld/app/paths/detail/PaySteps.cpp +++ b/src/xrpld/app/paths/detail/PaySteps.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -100,13 +101,15 @@ toStep( // should already be taken care of JLOG(j.error()) << "Found offer/account payment step. Aborting payment strand."; - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::toStep : offer/account payment payment strand"); return {temBAD_PATH, std::unique_ptr{}}; } XRPL_ASSERT( + "ripple::toStep : currency or issuer", (e2->getNodeType() & STPathElement::typeCurrency) || - (e2->getNodeType() & STPathElement::typeIssuer)); + (e2->getNodeType() & STPathElement::typeIssuer)); auto const outCurrency = e2->getNodeType() & STPathElement::typeCurrency ? e2->getCurrency() : curIssue.currency; @@ -120,7 +123,7 @@ toStep( return {temBAD_PATH, std::unique_ptr{}}; } - XRPL_ASSERT(e2->isOffer()); + XRPL_ASSERT("ripple::toStep : is offer", e2->isOffer()); if (isXRP(outCurrency)) return make_BookStepIX(ctx, curIssue); @@ -391,7 +394,7 @@ toStrand( next->getCurrency() != curIssue.currency) { // Should never happen - XRPL_ASSERT(0); + XRPL_UNREACHABLE("ripple::toStrand : offer currency mismatch"); return {temBAD_PATH, Strand{}}; } @@ -457,7 +460,7 @@ toStrand( if (!checkStrand()) { JLOG(j.warn()) << "Flow check strand failed"; - XRPL_ASSERT(0); + XRPL_UNREACHABLE("ripple::toStrand : invalid strand"); return {temBAD_PATH, Strand{}}; } diff --git a/src/xrpld/app/paths/detail/StepChecks.h b/src/xrpld/app/paths/detail/StepChecks.h index f529d19a6f1..e5773e6a03d 100644 --- a/src/xrpld/app/paths/detail/StepChecks.h +++ b/src/xrpld/app/paths/detail/StepChecks.h @@ -35,7 +35,7 @@ checkFreeze( AccountID const& dst, Currency const& currency) { - XRPL_ASSERT(src != dst); + XRPL_ASSERT("ripple::checkFreeze : unequal input accounts", src != dst); // check freeze if (auto sle = view.read(keylet::account(dst))) diff --git a/src/xrpld/app/paths/detail/StrandFlow.h b/src/xrpld/app/paths/detail/StrandFlow.h index 402d699494a..28367aa2bcc 100644 --- a/src/xrpld/app/paths/detail/StrandFlow.h +++ b/src/xrpld/app/paths/detail/StrandFlow.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -171,7 +172,9 @@ flow( << "Re-executed limiting step failed. r.first: " << to_string(get(r.first)) << " maxIn: " << to_string(*maxIn); - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::flow : first step re-executing the " + "limiting step failed"); return Result{strand, std::move(ofrsToRm)}; } } @@ -207,7 +210,9 @@ flow( #else JLOG(j.fatal()) << "Re-executed limiting step failed"; #endif - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::flow : limiting step re-executing the " + "limiting step failed"); return Result{strand, std::move(ofrsToRm)}; } } @@ -241,7 +246,9 @@ flow( #else JLOG(j.fatal()) << "Re-executed forward pass failed"; #endif - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::flow : non-limiting step re-executing the " + "forward pass failed"); return Result{strand, std::move(ofrsToRm)}; } stepIn = r.second; @@ -493,7 +500,7 @@ class ActiveStrands { if (i >= cur_.size()) { - XRPL_ASSERT(0); + XRPL_UNREACHABLE("ripple::ActiveStrands::get : input out of range"); return nullptr; } return cur_[i]; @@ -701,8 +708,9 @@ flow( EitherAmount(f.in), EitherAmount(f.out)); XRPL_ASSERT( + "ripple::flow : remaining constraints", f.out <= remainingOut && f.sandbox && - (!remainingIn || f.in <= *remainingIn)); + (!remainingIn || f.in <= *remainingIn)); Quality const q(f.out, f.in); @@ -725,7 +733,7 @@ flow( if (baseView.rules().enabled(featureFlowSortStrands)) { - XRPL_ASSERT(!best); + XRPL_ASSERT("ripple::flow : best is unset", !best); if (!f.inactive) activeStrands.push(strand); best.emplace(f.in, f.out, std::move(*f.sandbox), *strand, q); @@ -876,7 +884,7 @@ flow( // Handles both cases 1. and 2. // fixFillOrKill amendment: // Handles 2. 1. is handled above and falls through for tfSell. - XRPL_ASSERT(remainingIn); + XRPL_ASSERT("ripple::flow : nonzero remainingIn", remainingIn); if (remainingIn && *remainingIn != beast::zero) return { tecPATH_PARTIAL, diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 57a3845c0ee..94d787a50ee 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -282,7 +282,7 @@ XRPEndpointStep::fwdImp( boost::container::flat_set& ofrsToRm, XRPAmount const& in) { - XRPL_ASSERT(cache_); + XRPL_ASSERT("ripple::XRPEndpointStep::fwdImp : cache is set", cache_); auto const balance = static_cast(this)->xrpLiquid(sb); auto const result = isLast_ ? in : std::min(balance, in); @@ -310,7 +310,7 @@ XRPEndpointStep::validFwd( return {false, EitherAmount(XRPAmount(beast::zero))}; } - XRPL_ASSERT(in.native); + XRPL_ASSERT("ripple::XRPEndpointStep::validFwd : input is XRP", in.native); auto const& xrpIn = in.xrp; auto const balance = static_cast(this)->xrpLiquid(sb); diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index 80720343bdf..7b3284002db 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -258,7 +259,7 @@ rangeCheckedCast(C c) c < std::numeric_limits::lowest())) { /* This should never happen */ - XRPL_ASSERT(0); + XRPL_UNREACHABLE("ripple::rangeCheckedCast : domain error"); JLOG(debugLog().error()) << "rangeCheckedCast domain error:" << " value = " << c << " min = " << std::numeric_limits::lowest() diff --git a/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp b/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp index d97b0bf1b0b..71433614b71 100644 --- a/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp +++ b/src/xrpld/app/rdb/backend/detail/PostgresDatabase.cpp @@ -61,7 +61,9 @@ class PostgresDatabaseImp final : public PostgresDatabase #endif ) { - XRPL_ASSERT(config.reporting()); + XRPL_ASSERT( + "ripple::PostgresDatabaseImp::PostgresDatabaseImp : reporting mode", + config.reporting()); #ifdef RIPPLED_REPORTING if (config.reporting() && !config.reportingReadOnly()) // use pg { @@ -169,7 +171,7 @@ loadLedgerInfos( std::vector infos; #ifdef RIPPLED_REPORTING auto log = app.journal("Ledger"); - XRPL_ASSERT(app.config().reporting()); + XRPL_ASSERT("ripple::loadLedgerInfos : reporting mode", config.reporting());app.config().reporting()); std::stringstream sql; sql << "SELECT ledger_hash, prev_hash, account_set_hash, trans_set_hash, " "total_coins, closing_time, prev_closing_time, close_time_res, " @@ -204,7 +206,7 @@ loadLedgerInfos( { JLOG(log.error()) << __func__ << " : Postgres response is null - sql = " << sql.str(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::loadLedgerInfos : null response"); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -214,7 +216,7 @@ loadLedgerInfos( "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql.str(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::loadLedgerInfos : unexpected response"); return {}; } @@ -234,7 +236,8 @@ loadLedgerInfos( << " : Wrong number of fields in Postgres " "response. Expected 10, but got " << res.nfields() << " . sql = " << sql.str(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::loadLedgerInfos : unexpected number of fields"); return {}; } } @@ -267,11 +270,14 @@ loadLedgerInfos( LedgerInfo info; if (!info.parentHash.parseHex(prevHash + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::loadLedgerInfos : failed to parse prevHash"); if (!info.txHash.parseHex(txHash + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::loadLedgerInfos : failed to parse txHash"); if (!info.accountHash.parseHex(accountHash + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::loadLedgerInfos : failed to parse accountHash"); info.drops = totalCoins; info.closeTime = time_point{duration{closeTime}}; info.parentCloseTime = time_point{duration{parentCloseTime}}; @@ -279,7 +285,7 @@ loadLedgerInfos( info.closeTimeResolution = duration{closeTimeRes}; info.seq = ledgerSeq; if (!info.hash.parseHex(hash + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::loadLedgerInfos : failed to parse hash"); info.validated = true; infos.push_back(info); } @@ -308,7 +314,8 @@ loadLedgerHelper( infos = loadLedgerInfos(pgPool, arg, app); }, whichLedger); - XRPL_ASSERT(infos.size() <= 1); + XRPL_ASSERT( + "ripple::loadLedgerHelper : at most one header", infos.size() <= 1); if (!infos.size()) return {}; return infos[0]; @@ -410,7 +417,9 @@ processAccountTxStoredProcedureResult( nodestoreHashHex.erase(0, 2); uint256 nodestoreHash; if (!nodestoreHash.parseHex(nodestoreHashHex)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::processAccountTxStoredProcedureResult : " + "failed to parse nodestoreHashHex"); if (nodestoreHash.isNonZero()) { @@ -419,18 +428,25 @@ processAccountTxStoredProcedureResult( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::processAccountTxStoredProcedureResult : " + "nodestoreHashHex is zero"); return {ret, {rpcINTERNAL, "nodestoreHash is zero"}}; } } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::processAccountTxStoredProcedureResult : " + "missing ledger_seq or nodestore_hash"); return {ret, {rpcINTERNAL, "missing postgres fields"}}; } } - XRPL_ASSERT(nodestoreHashes.size() == ledgerSequences.size()); + XRPL_ASSERT( + "ripple::processAccountTxStoredProcedureResult : matching " + "sizes", + nodestoreHashes.size() == ledgerSequences.size()); ret.transactions = flatFetchTransactions( app, nodestoreHashes, @@ -442,13 +458,25 @@ processAccountTxStoredProcedureResult( if (result.isMember("marker")) { auto& marker = result["marker"]; - XRPL_ASSERT(marker.isMember("ledger")); - XRPL_ASSERT(marker.isMember("seq")); + XRPL_ASSERT( + "ripple::processAccountTxStoredProcedureResult : has " + "ledger element", + marker.isMember("ledger")); + XRPL_ASSERT( + "ripple::processAccountTxStoredProcedureResult : has seq " + "element", + marker.isMember("seq")); ret.marker = { marker["ledger"].asUInt(), marker["seq"].asUInt()}; } - XRPL_ASSERT(result.isMember("ledger_index_min")); - XRPL_ASSERT(result.isMember("ledger_index_max")); + XRPL_ASSERT( + "ripple::processAccountTxStoredProcedureResult : has " + "ledger_index_min element", + result.isMember("ledger_index_min")); + XRPL_ASSERT( + "ripple::processAccountTxStoredProcedureResult : has " + "ledger_index_max element", + result.isMember("ledger_index_max")); ret.ledgerRange = { result["ledger_index_min"].asUInt(), result["ledger_index_max"].asUInt()}; @@ -599,7 +627,9 @@ PostgresDatabaseImp::writeLedgerAndTransactions( { std::stringstream msg; msg << "bulkWriteToTable : Postgres insert error: " << res.msg(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::writeLedgerAndTransactions : " + "insert error"); Throw(msg.str()); } @@ -612,7 +642,9 @@ PostgresDatabaseImp::writeLedgerAndTransactions( JLOG(j_.error()) << __func__ << "Caught exception writing to Postgres : " << e.what(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::writeLedgerAndTransactions : error " + "while writing"); return false; } #else @@ -642,7 +674,9 @@ uint256 PostgresDatabaseImp::getHashByIndex(LedgerIndex ledgerIndex) { auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - XRPL_ASSERT(infos.size() <= 1); + XRPL_ASSERT( + "ripple::PostgresDatabaseImp::getHashByIndex : at most one header", + infos.size() <= 1); if (infos.size()) return infos[0].hash; return {}; @@ -653,7 +687,9 @@ PostgresDatabaseImp::getHashesByIndex(LedgerIndex ledgerIndex) { LedgerHashPair p; auto infos = loadLedgerInfos(pgPool_, ledgerIndex, app_); - XRPL_ASSERT(infos.size() <= 1); + XRPL_ASSERT( + "ripple::PostgresDatabaseImp::getHashesByIndex : at most one header", + infos.size() <= 1); if (infos.size()) { p.ledgerHash = infos[0].hash; @@ -694,7 +730,8 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) { JLOG(log.error()) << __func__ << " : Postgres response is null - query = " << query; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHashes : null response"); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -704,7 +741,8 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - query = " << query; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHashes : unexpected response"); return {}; } @@ -724,7 +762,9 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . query = " << query; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHashes : unexpected number " + "of fields"); return {}; } } @@ -736,7 +776,9 @@ PostgresDatabaseImp::getTxHashes(LedgerIndex seq) char const* nodestoreHash = res.c_str(i, 0); uint256 hash; if (!hash.parseHex(nodestoreHash + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHashes : failed to parse " + "nodestoreHash"); nodestoreHashes.push_back(hash); } @@ -753,7 +795,9 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) #ifdef RIPPLED_REPORTING if (!app_.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : not in reporting " + "mode"); Throw( "called getTxHistory but not in reporting mode"); } @@ -771,7 +815,8 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { JLOG(j_.error()) << __func__ << " : Postgres response is null - sql = " << sql; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : null response"); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -781,7 +826,8 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - sql = " << sql; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : unexpected response"); return {}; } @@ -790,7 +836,8 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) if (res.isNull() || res.ntuples() == 0) { JLOG(j_.debug()) << __func__ << " : Empty postgres response"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : empty response"); return {}; } else if (res.ntuples() > 0) @@ -801,7 +848,9 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) << " : Wrong number of fields in Postgres " "response. Expected 1, but got " << res.nfields() << " . sql = " << sql; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : unexpected number " + "of fields"); return {}; } } @@ -814,7 +863,9 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) { uint256 hash; if (!hash.parseHex(res.c_str(i, 0) + 2)) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getTxHistory : failed to parse " + "state hash"); nodestoreHashes.push_back(hash); ledgerSequences.push_back(res.asBigInt(i, 1)); } @@ -823,7 +874,9 @@ PostgresDatabaseImp::getTxHistory(LedgerIndex startIndex) for (size_t i = 0; i < txns.size(); ++i) { auto const& [sttx, meta] = txns[i]; - XRPL_ASSERT(sttx); + XRPL_ASSERT( + "ripple::PostgresDatabaseImp::getTxHistory : non-null transaction", + sttx); std::string reason; auto txn = std::make_shared(sttx, reason, app_); @@ -904,7 +957,8 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) JLOG(j_.error()) << __func__ << " : Postgres response is null - account = " << strHex(args.account); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getAccountTx : null reponse"); return {{}, {rpcINTERNAL, "Postgres error"}}; } else if (res.status() != PGRES_TUPLES_OK) @@ -914,7 +968,8 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - account = " << strHex(args.account); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getAccountTx : unexpected reponse"); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -925,7 +980,8 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) << " : No data returned from Postgres : account = " << strHex(args.account); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getAccountTx : empty reponse"); return {{}, {rpcINTERNAL, "Postgres error"}}; } @@ -943,7 +999,8 @@ PostgresDatabaseImp::getAccountTx(AccountTxArgs const& args) } #endif // This shouldn't happen. Postgres should return a parseable error - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::getAccountTx : general error"); return {{}, {rpcINTERNAL, "Failed to deserialize Postgres result"}}; } @@ -963,7 +1020,8 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) JLOG(app_.journal("Transaction").error()) << __func__ << " : Postgres response is null - tx ID = " << strHex(id); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::locateTransaction : null response"); return {}; } else if (res.status() != PGRES_TUPLES_OK) @@ -974,7 +1032,9 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) "PGRES_TUPLES_OK but instead was " << res.status() << " - msg = " << res.msg() << " - tx ID = " << strHex(id); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::locateTransaction : unexpected " + "response"); return {}; } @@ -986,7 +1046,8 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) << __func__ << " : No data returned from Postgres : tx ID = " << strHex(id); // This shouldn't happen - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::locateTransaction : empty response"); return {}; } @@ -1004,7 +1065,9 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) uint256 nodestoreHash; if (!nodestoreHash.parseHex( v["nodestore_hash"].asString().substr(2))) - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::locateTransaction : failed " + "to parse nodestore_hash"); uint32_t ledgerSeq = v["ledger_seq"].asUInt(); if (nodestoreHash.isNonZero()) return {std::make_pair(nodestoreHash, ledgerSeq)}; @@ -1018,7 +1081,8 @@ PostgresDatabaseImp::locateTransaction(uint256 const& id) #endif // Shouldn' happen. Postgres should return the ledger range searched if // the transaction was not found - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PostgresDatabaseImp::locateTransaction : general error"); Throw( "Transaction::Locate - Invalid Postgres response"); return {}; diff --git a/src/xrpld/app/rdb/backend/detail/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/detail/Node.cpp index 5ab7232f6bd..aa4269369a9 100644 --- a/src/xrpld/app/rdb/backend/detail/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/detail/Node.cpp @@ -58,7 +58,7 @@ to_string(TableType type) case TableType::AccountTransactions: return "AccountTransactions"; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::detail::to_string : invalid TableType"); return "Unknown"; } } @@ -201,7 +201,8 @@ saveValidatedLedger( if (!ledger->info().accountHash.isNonZero()) { JLOG(j.fatal()) << "AH is zero: " << getJson({*ledger, {}}); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::detail::saveValidatedLedger : zero account hash"); } if (ledger->info().accountHash != ledger->stateMap().getHash().as_uint256()) @@ -210,10 +211,12 @@ saveValidatedLedger( << " != " << ledger->stateMap().getHash(); JLOG(j.fatal()) << "saveAcceptedLedger: seq=" << seq << ", current=" << current; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::detail::saveValidatedLedger : mismatched account hash"); } XRPL_ASSERT( + "ripple::detail::saveValidatedLedger : transaction hash match", ledger->info().txHash == ledger->txMap().getHash().as_uint256()); // Save the ledger header in the hashed object store diff --git a/src/xrpld/app/rdb/detail/Vacuum.cpp b/src/xrpld/app/rdb/detail/Vacuum.cpp index 1bfd61f9018..b7afb6c4427 100644 --- a/src/xrpld/app/rdb/detail/Vacuum.cpp +++ b/src/xrpld/app/rdb/detail/Vacuum.cpp @@ -28,7 +28,9 @@ doVacuumDB(DatabaseCon::Setup const& setup) boost::filesystem::path dbPath = setup.dataDir / TxDBName; uintmax_t const dbSize = file_size(dbPath); - XRPL_ASSERT(dbSize != static_cast(-1)); + XRPL_ASSERT( + "ripple:doVacuumDB : file_size succeeded", + dbSize != static_cast(-1)); if (auto available = space(dbPath.parent_path()).available; available < dbSize) @@ -54,7 +56,8 @@ doVacuumDB(DatabaseCon::Setup const& setup) std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl; session << "VACUUM;"; - XRPL_ASSERT(setup.globalPragma); + XRPL_ASSERT( + "ripple:doVacuumDB : non-null global pragma", setup.globalPragma); for (auto const& p : *setup.globalPragma) session << p; session << "PRAGMA page_size;", soci::into(pageSize); diff --git a/src/xrpld/app/reporting/ETLHelpers.h b/src/xrpld/app/reporting/ETLHelpers.h index c41ebfd9fed..f9b3194d085 100644 --- a/src/xrpld/app/reporting/ETLHelpers.h +++ b/src/xrpld/app/reporting/ETLHelpers.h @@ -176,7 +176,7 @@ class ThreadSafeQueue inline std::vector getMarkers(size_t numMarkers) { - XRPL_ASSERT(numMarkers <= 256); + XRPL_ASSERT("ripple::getMarkers : maximum input", numMarkers <= 256); unsigned char incr = 256 / numMarkers; diff --git a/src/xrpld/app/reporting/ETLSource.cpp b/src/xrpld/app/reporting/ETLSource.cpp index 06fd8813df3..41c9bb9d767 100644 --- a/src/xrpld/app/reporting/ETLSource.cpp +++ b/src/xrpld/app/reporting/ETLSource.cpp @@ -452,7 +452,9 @@ class AsyncCallData << " . prefix = " << strHex(std::string(1, prefix)) << " . nextPrefix_ = " << strHex(std::string(1, nextPrefix_)); - XRPL_ASSERT(nextPrefix_ > prefix || nextPrefix_ == 0x00); + XRPL_ASSERT( + "ripple::AsyncCallData::AsyncCallData : valid next prefix", + nextPrefix_ > prefix || nextPrefix_ == 0x00); cur_ = std::make_unique(); @@ -487,7 +489,8 @@ class AsyncCallData JLOG(journal_.warn()) << "AsyncCallData is_unlimited is false. Make sure " "secure_gateway is set correctly at the ETL source"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::AsyncCallData::process : false is_unlimited"); } std::swap(cur_, next_); @@ -589,7 +592,7 @@ ETLSource::loadInitialLedger( while (numFinished < calls.size() && !etl_.isStopping() && cq.Next(&tag, &ok)) { - XRPL_ASSERT(tag); + XRPL_ASSERT("ripple::ETLSource::loadInitialLedger : non-null tag", tag); auto ptr = static_cast(tag); @@ -642,7 +645,7 @@ ETLSource::fetchLedger(uint32_t ledgerSequence, bool getObjects) "false. Make sure secure_gateway is set " "correctly on the ETL source. source = " << toString(); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::ETLSource::fetchLedger : false is_unlimited"); } return {status, std::move(response)}; } diff --git a/src/xrpld/app/reporting/ETLSource.h b/src/xrpld/app/reporting/ETLSource.h index cc5bc62769a..4f5662013d4 100644 --- a/src/xrpld/app/reporting/ETLSource.h +++ b/src/xrpld/app/reporting/ETLSource.h @@ -173,7 +173,9 @@ class ETLSource } else { - XRPL_ASSERT(minAndMax.size() == 2); + XRPL_ASSERT( + "ripple::ETLSource::setValidatedRange : size is 2", + minAndMax.size() == 2); uint32_t min = std::stoll(minAndMax[0]); uint32_t max = std::stoll(minAndMax[1]); pairs.push_back(std::make_pair(min, max)); @@ -206,7 +208,7 @@ class ETLSource JLOG(journal_.debug()) << __func__ << " : " << "Closing websocket"; - XRPL_ASSERT(ws_); + XRPL_ASSERT("ripple::ETLSource::stop : non-null websocket", ws_); close(false); } @@ -378,7 +380,10 @@ class ETLLoadBalancer { for (auto& src : sources_) { - XRPL_ASSERT(src); + XRPL_ASSERT( + "ripple::ETLLoadBalancer::shouldPropagateStream : non-null " + "source", + src); // We pick the first ETLSource encountered that is connected if (src->isConnected()) { diff --git a/src/xrpld/app/reporting/ReportingETL.cpp b/src/xrpld/app/reporting/ReportingETL.cpp index fc500b20c10..c9583bcbacb 100644 --- a/src/xrpld/app/reporting/ReportingETL.cpp +++ b/src/xrpld/app/reporting/ReportingETL.cpp @@ -59,7 +59,8 @@ ReportingETL::consumeLedgerData( size_t num = 0; while (!stopping_ && (sle = writeQueue.pop())) { - XRPL_ASSERT(sle); + XRPL_ASSERT( + "ripple::ReportingETL::consumeLedgerData : non-null SLE", sle); if (!ledger->exists(sle->key())) ledger->rawInsert(sle); @@ -113,7 +114,8 @@ ReportingETL::loadInitialLedger(uint32_t startingSequence) { JLOG(journal_.fatal()) << __func__ << " : " << "Database is not empty"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ReportingETL::loadInitialLedger : non-empty database"); return {}; } @@ -190,8 +192,9 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) auto& ledgerHash = ledger->info().hash; XRPL_ASSERT( + "ripple::ReportingETL::flushLedger : valid ledger fees", ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees())); + ledger->read(keylet::fees())); ledger->setImmutable(false); auto start = std::chrono::system_clock::now(); @@ -230,7 +233,9 @@ ReportingETL::flushLedger(std::shared_ptr& ledger) { JLOG(journal_.fatal()) << __func__ << " : " << "Flushed 0 nodes from state map"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ReportingETL::flushLedger : flushed 0 nodes from state " + "map"); } if (numTxFlushed == 0) { @@ -495,7 +500,8 @@ ReportingETL::runETLPipeline(uint32_t startSequence) app_.getLedgerMaster().getLedgerBySeq(startSequence - 1)); if (!parent) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::ReportingETL::runETLPipeline : parent ledger is null"); Throw("runETLPipeline: parent ledger is null"); } @@ -564,7 +570,10 @@ ReportingETL::runETLPipeline(uint32_t startSequence) &transformQueue]() { beast::setCurrentThreadName("rippled: ReportingETL transform"); - XRPL_ASSERT(parent); + XRPL_ASSERT( + "ripple::ReportingETL::runETLPipeline::transformer : non-null " + "parent", + parent); parent = std::make_shared(*parent, NetClock::time_point{}); while (!writeConflict) { diff --git a/src/xrpld/app/reporting/ReportingETL.h b/src/xrpld/app/reporting/ReportingETL.h index 121b34da9a2..d8bbf222a5a 100644 --- a/src/xrpld/app/reporting/ReportingETL.h +++ b/src/xrpld/app/reporting/ReportingETL.h @@ -326,9 +326,15 @@ class ReportingETL start() { JLOG(journal_.info()) << "Starting reporting etl"; - XRPL_ASSERT(app_.config().reporting()); - XRPL_ASSERT(app_.config().standalone()); - XRPL_ASSERT(app_.config().reportingReadOnly() == readOnly_); + XRPL_ASSERT( + "ripple::ReportingETL::start : reporting mode", + app_.config().reporting()); + XRPL_ASSERT( + "ripple::ReportingETL::start : is standalone", + app_.config().standalone()); + XRPL_ASSERT( + "ripple::ReportingETL::start : reporting and read only", + app_.config().reportingReadOnly() == readOnly_); stopping_ = false; diff --git a/src/xrpld/app/tx/detail/AMMBid.cpp b/src/xrpld/app/tx/detail/AMMBid.cpp index 17b851a2627..87bad0a0686 100644 --- a/src/xrpld/app/tx/detail/AMMBid.cpp +++ b/src/xrpld/app/tx/detail/AMMBid.cpp @@ -181,7 +181,9 @@ applyBid( } else { - XRPL_ASSERT(ammSle->isFieldPresent(sfAuctionSlot)); + XRPL_ASSERT( + "ripple::applyBid : has auction slot", + ammSle->isFieldPresent(sfAuctionSlot)); if (!ammSle->isFieldPresent(sfAuctionSlot)) return {tecINTERNAL, false}; } @@ -304,7 +306,7 @@ applyBid( { // Price the slot was purchased at. STAmount const pricePurchased = auctionSlot[sfPrice]; - XRPL_ASSERT(timeSlot); + XRPL_ASSERT("ripple::applyBid : timeSlot is set", timeSlot); auto const fractionUsed = (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS; auto const fractionRemaining = Number(1) - fractionUsed; diff --git a/src/xrpld/app/tx/detail/AMMDeposit.cpp b/src/xrpld/app/tx/detail/AMMDeposit.cpp index e523da3d6a9..be518c03ca4 100644 --- a/src/xrpld/app/tx/detail/AMMDeposit.cpp +++ b/src/xrpld/app/tx/detail/AMMDeposit.cpp @@ -435,7 +435,9 @@ AMMDeposit::applyGuts(Sandbox& sb) if (result == tesSUCCESS) { - XRPL_ASSERT(newLPTokenBalance > beast::zero); + XRPL_ASSERT( + "ripple::AMMDeposit::applyGuts : valid new LP token balance", + newLPTokenBalance > beast::zero); ammSle->setFieldAmount(sfLPTokenBalance, newLPTokenBalance); // LP depositing into AMM empty state gets the auction slot // and the voting diff --git a/src/xrpld/app/tx/detail/AMMVote.cpp b/src/xrpld/app/tx/detail/AMMVote.cpp index 5d690f27c93..a7e3faff4b2 100644 --- a/src/xrpld/app/tx/detail/AMMVote.cpp +++ b/src/xrpld/app/tx/detail/AMMVote.cpp @@ -201,8 +201,9 @@ applyVote( } XRPL_ASSERT( + "ripple::applyVote : has auction slot", !ctx_.view().rules().enabled(fixInnerObjTemplate) || - ammSle->isFieldPresent(sfAuctionSlot)); + ammSle->isFieldPresent(sfAuctionSlot)); // Update the vote entries and the trading/discounted fee. ammSle->setFieldArray(sfVoteSlots, updatedVoteSlots); diff --git a/src/xrpld/app/tx/detail/AMMWithdraw.cpp b/src/xrpld/app/tx/detail/AMMWithdraw.cpp index 967fd8d6697..e9aaf3b83e7 100644 --- a/src/xrpld/app/tx/detail/AMMWithdraw.cpp +++ b/src/xrpld/app/tx/detail/AMMWithdraw.cpp @@ -711,7 +711,9 @@ AMMWithdraw::equalWithdrawLimit( tfee); frac = Number{amount2} / amount2Balance; auto const amountWithdraw = amountBalance * frac; - XRPL_ASSERT(amountWithdraw <= amount); + XRPL_ASSERT( + "ripple::AMMWithdraw::equalWithdrawLimit : maximum amountWithdraw", + amountWithdraw <= amount); return withdraw( view, ammAccount, diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index 147fe6932c8..d4632adb115 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -146,7 +146,9 @@ ApplyContext::checkInvariantsHelper( TER ApplyContext::checkInvariants(TER const result, XRPAmount const fee) { - XRPL_ASSERT(isTesSuccess(result) || isTecClaim(result)); + XRPL_ASSERT( + "ripple::ApplyContext::checkInvariants : is tesSUCCESS or tecCLAIM", + isTesSuccess(result) || isTecClaim(result)); return checkInvariantsHelper( result, diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index ba1dbef77e4..d5dc70bf773 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -149,7 +149,8 @@ Change::doApply() case ttUNL_MODIFY: return applyUNLModify(); default: - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::Change::doApply : invalid transaction type"); return tefFAILURE; } } @@ -157,7 +158,8 @@ Change::doApply() void Change::preCompute() { - XRPL_ASSERT(account_ == beast::zero); + XRPL_ASSERT( + "ripple::Change::preCompute : zero account", account_ == beast::zero); } void diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index e5399303df8..1ec34ee9c70 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -210,7 +210,9 @@ CreateOffer::checkAcceptAsset( Issue const& issue) { // Only valid for custom currencies - XRPL_ASSERT(!isXRP(issue.currency)); + XRPL_ASSERT( + "ripple::CreateOffer::checkAcceptAsset : input is not XRP", + !isXRP(issue.currency)); auto const issuerAccount = view.read(keylet::account(issue.account)); @@ -283,7 +285,9 @@ CreateOffer::select_path( OfferStream const& leg2) { // If we don't have any viable path, why are we here?! - XRPL_ASSERT(have_direct || have_bridge); + XRPL_ASSERT( + "ripple::CreateOffer::select_path : valid inputs", + have_direct || have_bridge); // If there's no bridged path, the direct is the best by default. if (!have_bridge) @@ -327,7 +331,9 @@ CreateOffer::bridged_cross( { auto const& takerAmount = taker.original_offer(); - XRPL_ASSERT(!isXRP(takerAmount.in) && !isXRP(takerAmount.out)); + XRPL_ASSERT( + "ripple::CreateOffer::bridged_cross : neither is XRP", + !isXRP(takerAmount.in) && !isXRP(takerAmount.out)); if (isXRP(takerAmount.in) || isXRP(takerAmount.out)) Throw("Bridging with XRP and an endpoint."); @@ -497,7 +503,9 @@ CreateOffer::bridged_cross( // Postcondition: If we aren't done, then we *must* have consumed at // least one offer fully. - XRPL_ASSERT(direct_consumed || leg1_consumed || leg2_consumed); + XRPL_ASSERT( + "ripple::CreateOffer::bridged_cross : consumed an offer", + direct_consumed || leg1_consumed || leg2_consumed); if (!direct_consumed && !leg1_consumed && !leg2_consumed) Throw( @@ -587,7 +595,9 @@ CreateOffer::direct_cross( // Postcondition: If we aren't done, then we *must* have consumed the // offer on the books fully! - XRPL_ASSERT(direct_consumed); + XRPL_ASSERT( + "ripple::CreateOffer::direct_cross : consumed an offer", + direct_consumed); if (!direct_consumed) Throw( @@ -849,7 +859,9 @@ CreateOffer::flowCross( // remaining output. This too preserves the offer // Quality. afterCross.out -= result.actualAmountOut; - XRPL_ASSERT(afterCross.out >= beast::zero); + XRPL_ASSERT( + "ripple::CreateOffer::flowCross : minimum offer", + afterCross.out >= beast::zero); if (afterCross.out < beast::zero) afterCross.out.clear(); afterCross.in = mulRound( @@ -1046,7 +1058,9 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // We expect the implementation of cross to succeed // or give a tec. - XRPL_ASSERT(result == tesSUCCESS || isTecClaim(result)); + XRPL_ASSERT( + "ripple::CreateOffer::applyGuts : result is tesSUCCESS or tecCLAIM", + result == tesSUCCESS || isTecClaim(result)); if (auto stream = j_.trace()) { @@ -1064,8 +1078,12 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) return {result, true}; } - XRPL_ASSERT(saTakerGets.issue() == place_offer.in.issue()); - XRPL_ASSERT(saTakerPays.issue() == place_offer.out.issue()); + XRPL_ASSERT( + "ripple::CreateOffer::applyGuts : taker gets issue match", + saTakerGets.issue() == place_offer.in.issue()); + XRPL_ASSERT( + "ripple::CreateOffer::applyGuts : taker pays issue match", + saTakerPays.issue() == place_offer.out.issue()); if (takerAmount != place_offer) crossed = true; @@ -1093,7 +1111,9 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) saTakerGets = place_offer.in; } - XRPL_ASSERT(saTakerPays > zero && saTakerGets > zero); + XRPL_ASSERT( + "ripple::CreateOffer::applyGuts : taker pays and gets positive", + saTakerPays > zero && saTakerGets > zero); if (result != tesSUCCESS) { diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/xrpld/app/tx/detail/DeleteAccount.cpp index ac2f674e4a5..1a97726be08 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/xrpld/app/tx/detail/DeleteAccount.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -211,7 +212,8 @@ DeleteAccount::preclaim(PreclaimContext const& ctx) } auto sleAccount = ctx.view.read(keylet::account(account)); - XRPL_ASSERT(sleAccount); + XRPL_ASSERT( + "ripple::DeleteAccount::preclaim : non-null account", sleAccount); if (!sleAccount) return terNO_ACCOUNT; @@ -314,10 +316,12 @@ TER DeleteAccount::doApply() { auto src = view().peek(keylet::account(account_)); - XRPL_ASSERT(src); + XRPL_ASSERT( + "ripple::DeleteAccount::doApply : non-null source account", src); auto dst = view().peek(keylet::account(ctx_.tx[sfDestination])); - XRPL_ASSERT(dst); + XRPL_ASSERT( + "ripple::DeleteAccount::doApply : non-null destination account", dst); if (!src || !dst) return tefBAD_LEDGER; @@ -337,7 +341,9 @@ DeleteAccount::doApply() return {result, SkipEntry::No}; } - XRPL_ASSERT(!"Undeletable entry should be found in preclaim."); + XRPL_UNREACHABLE( + "ripple::DeleteAccount::doApply : undeletable item not found " + "in preclaim"); JLOG(j_.error()) << "DeleteAccount undeletable item not " "found in preclaim."; return {tecHAS_OBLIGATIONS, SkipEntry::No}; @@ -351,7 +357,9 @@ DeleteAccount::doApply() (*src)[sfBalance] = (*src)[sfBalance] - mSourceBalance; ctx_.deliver(mSourceBalance); - XRPL_ASSERT((*src)[sfBalance] == XRPAmount(0)); + XRPL_ASSERT( + "ripple::DeleteAccount::doApply : source balance is zero", + (*src)[sfBalance] == XRPAmount(0)); // If there's still an owner directory associated with the source account // delete it. diff --git a/src/xrpld/app/tx/detail/NFTokenMint.cpp b/src/xrpld/app/tx/detail/NFTokenMint.cpp index 108aa637026..15e6522b977 100644 --- a/src/xrpld/app/tx/detail/NFTokenMint.cpp +++ b/src/xrpld/app/tx/detail/NFTokenMint.cpp @@ -160,7 +160,9 @@ NFTokenMint::createNFTokenID( std::memcpy(ptr, &tokenSeq, sizeof(tokenSeq)); ptr += sizeof(tokenSeq); - XRPL_ASSERT(std::distance(buf.data(), ptr) == buf.size()); + XRPL_ASSERT( + "ripple::NFTokenMint::createNFTokenID : data size matches the buffer", + std::distance(buf.data(), ptr) == buf.size()); return uint256::fromVoid(buf.data()); } diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.cpp b/src/xrpld/app/tx/detail/NFTokenUtils.cpp index 242d6f91666..59fd382dcf4 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.cpp +++ b/src/xrpld/app/tx/detail/NFTokenUtils.cpp @@ -243,7 +243,9 @@ compareTokens(uint256 const& a, uint256 const& b) TER insertToken(ApplyView& view, AccountID owner, STObject&& nft) { - XRPL_ASSERT(nft.isFieldPresent(sfNFTokenID)); + XRPL_ASSERT( + "ripple::nft::insertToken : has NFT token", + nft.isFieldPresent(sfNFTokenID)); // First, we need to locate the page the NFT belongs to, creating it // if necessary. This operation may fail if it is impossible to insert @@ -735,7 +737,8 @@ tokenOfferCreatePreclaim( if (nftIssuer != acctID && !(nftFlags & nft::flagTransferable)) { auto const root = view.read(keylet::account(nftIssuer)); - XRPL_ASSERT(root); + XRPL_ASSERT( + "ripple::nft::tokenOfferCreatePreclaim : non-null account", root); if (auto minter = (*root)[~sfNFTokenMinter]; minter != acctID) return tefNFTOKEN_IS_NOT_TRANSFERABLE; diff --git a/src/xrpld/app/tx/detail/Offer.h b/src/xrpld/app/tx/detail/Offer.h index c5eedd02c8b..9c6d69fd948 100644 --- a/src/xrpld/app/tx/detail/Offer.h +++ b/src/xrpld/app/tx/detail/Offer.h @@ -209,7 +209,7 @@ void TOffer::setFieldAmounts() { #ifdef _MSC_VER - XRPL_ASSERT(0); + XRPL_UNREACHABLE("ripple::TOffer::setFieldAmounts : must be specialized"); #else static_assert(sizeof(TOut) == -1, "Must be specialized"); #endif diff --git a/src/xrpld/app/tx/detail/OfferStream.cpp b/src/xrpld/app/tx/detail/OfferStream.cpp index 12231798bf6..ffaa0b2706d 100644 --- a/src/xrpld/app/tx/detail/OfferStream.cpp +++ b/src/xrpld/app/tx/detail/OfferStream.cpp @@ -51,7 +51,8 @@ TOfferStreamBase::TOfferStreamBase( , tip_(view, book_) , counter_(counter) { - XRPL_ASSERT(validBook_); + XRPL_ASSERT( + "ripple::TOfferStreamBase::TOfferStreamBase : valid book", validBook_); } // Handle the case where a directory item with no corresponding ledger entry @@ -339,7 +340,9 @@ TOfferStreamBase::step() std::is_same_v)) return shouldRmSmallIncreasedQOffer(); } - XRPL_ASSERT(0); // xrp/xrp offer!?! should never happen + XRPL_UNREACHABLE( + "rippls::TOfferStreamBase::step::rmSmallIncreasedQOffer : XRP " + "vs XRP offer"); // xrp/xrp offer!?! should never happen return false; }(); diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/xrpld/app/tx/detail/PayChan.cpp index 4256281ff12..998da5030b3 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/xrpld/app/tx/detail/PayChan.cpp @@ -149,7 +149,9 @@ closeChannel( if (!sle) return tefINTERNAL; - XRPL_ASSERT((*slep)[sfAmount] >= (*slep)[sfBalance]); + XRPL_ASSERT( + "ripple::closeChannel : minimum channel amount", + (*slep)[sfAmount] >= (*slep)[sfBalance]); (*sle)[sfBalance] = (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance]; adjustOwnerCount(view, sle, -1, j); @@ -532,7 +534,9 @@ PayChanClaim::doApply() (*slep)[sfBalance] = ctx_.tx[sfBalance]; XRPAmount const reqDelta = reqBalance - chanBalance; - XRPL_ASSERT(reqDelta >= beast::zero); + XRPL_ASSERT( + "ripple::PayChanClaim::doApply : minimum balance delta", + reqDelta >= beast::zero); (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta; ctx_.view().update(sled); ctx_.view().update(slep); diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 2cc37b70f4d..3fb2737015e 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -421,7 +421,8 @@ Payment::doApply() return terResult; } - XRPL_ASSERT(saDstAmount.native()); + XRPL_ASSERT( + "ripple::Payment::doApply : amount is XRP", saDstAmount.native()); // Direct XRP payment. diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/xrpld/app/tx/detail/SetSignerList.cpp index b11c962b717..ad0dd8836e4 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/xrpld/app/tx/detail/SetSignerList.cpp @@ -128,7 +128,10 @@ SetSignerList::doApply() default: break; } - XRPL_UNREACHABLE(); // Should not be possible to get here. + XRPL_UNREACHABLE( + "ripple::SetSignerList::doApply : invalid operation"); // Should not be + // possible to + // get here. return temMALFORMED; } @@ -137,8 +140,12 @@ SetSignerList::preCompute() { // Get the quorum and operation info. auto result = determineOperation(ctx_.tx, view().flags(), j_); - XRPL_ASSERT(std::get<0>(result) == tesSUCCESS); - XRPL_ASSERT(std::get<3>(result) != unknown); + XRPL_ASSERT( + "ripple::SetSignerList::preCompute : result is tesSUCCESS", + std::get<0>(result) == tesSUCCESS); + XRPL_ASSERT( + "ripple::SetSignerList::preCompute : result is known operation", + std::get<3>(result) != unknown); quorum_ = std::get<1>(result); signers_ = std::get<2>(result); @@ -171,8 +178,12 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) // The static_cast should always be safe since entryCount should always // be in the range from 1 to 8 (or 32 if ExpandedSignerList is enabled). // We've got a lot of room to grow. - XRPL_ASSERT(entryCount >= STTx::minMultiSigners); - XRPL_ASSERT(entryCount <= STTx::maxMultiSigners(&rules)); + XRPL_ASSERT( + "ripple::signerCountBasedOwnerCountDelta : minimum signers", + entryCount >= STTx::minMultiSigners); + XRPL_ASSERT( + "ripple::signerCountBasedOwnerCountDelta : maximum signers", + entryCount <= STTx::maxMultiSigners(&rules)); return 2 + static_cast(entryCount); } @@ -260,7 +271,10 @@ SetSignerList::validateQuorumAndSignerEntries( } // Make sure there are no duplicate signers. - XRPL_ASSERT(std::is_sorted(signers.begin(), signers.end())); + XRPL_ASSERT( + "ripple::SetSignerList::validateQuorumAndSignerEntries : sorted " + "signers", + std::is_sorted(signers.begin(), signers.end())); if (std::adjacent_find(signers.begin(), signers.end()) != signers.end()) { JLOG(j.trace()) << "Duplicate signers in signer list"; diff --git a/src/xrpld/app/tx/detail/Taker.cpp b/src/xrpld/app/tx/detail/Taker.cpp index 0a9498e7c5a..467e3a6c624 100644 --- a/src/xrpld/app/tx/detail/Taker.cpp +++ b/src/xrpld/app/tx/detail/Taker.cpp @@ -54,24 +54,36 @@ BasicTaker::BasicTaker( , cross_type_(cross_type) , journal_(journal) { - XRPL_ASSERT(remaining_.in > beast::zero); - XRPL_ASSERT(remaining_.out > beast::zero); + XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : positive remaining in", + remaining_.in > beast::zero); + XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : positive remaining out", + remaining_.out > beast::zero); - XRPL_ASSERT(m_rate_in.value != 0); - XRPL_ASSERT(m_rate_out.value != 0); + XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : nonzero rate in", + m_rate_in.value != 0); + XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : nonzero rate out", + m_rate_out.value != 0); // If we are dealing with a particular flavor, make sure that it's the // flavor we expect: XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : valid cross to IOU", cross_type != CrossType::XrpToIou || - (isXRP(issue_in()) && !isXRP(issue_out()))); + (isXRP(issue_in()) && !isXRP(issue_out()))); XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : valid cross to XRP", cross_type != CrossType::IouToXrp || - (!isXRP(issue_in()) && isXRP(issue_out()))); + (!isXRP(issue_in()) && isXRP(issue_out()))); // And make sure we're not crossing XRP for XRP - XRPL_ASSERT(!isXRP(issue_in()) || !isXRP(issue_out())); + XRPL_ASSERT( + "ripple::BasicTaker::BasicTaker : not crossing XRP for XRP", + !isXRP(issue_in()) || !isXRP(issue_out())); // If this is a passive order, we adjust the quality so as to prevent offers // at the same quality level from being consumed. @@ -150,7 +162,9 @@ BasicTaker::remaining_offer() const if (sell_) { - XRPL_ASSERT(remaining_.in > beast::zero); + XRPL_ASSERT( + "ripple::BasicTaker::remaining_offer : positive remaining in", + remaining_.in > beast::zero); // We scale the output based on the remaining input: return Amounts( @@ -158,7 +172,9 @@ BasicTaker::remaining_offer() const divRound(remaining_.in, quality_.rate(), issue_out_, true)); } - XRPL_ASSERT(remaining_.out > beast::zero); + XRPL_ASSERT( + "ripple::BasicTaker::remaining_offer : positive remaining out", + remaining_.out > beast::zero); // We scale the input based on the remaining output: return Amounts( @@ -424,7 +440,9 @@ BasicTaker::do_cross(Amounts offer, Quality quality, AccountID const& owner) remaining_.out -= result.order.out; remaining_.in -= result.order.in; - XRPL_ASSERT(remaining_.in >= beast::zero); + XRPL_ASSERT( + "ripple::BasicTaker::do_cross : minimum remaining in", + remaining_.in >= beast::zero); return result; } @@ -439,10 +457,17 @@ BasicTaker::do_cross( Quality quality2, AccountID const& owner2) { - XRPL_ASSERT(!offer1.in.native()); - XRPL_ASSERT(offer1.out.native()); - XRPL_ASSERT(offer2.in.native()); - XRPL_ASSERT(!offer2.out.native()); + XRPL_ASSERT( + "ripple::BasicTaker::do_cross : offer1 in is not XRP", + !offer1.in.native()); + XRPL_ASSERT( + "ripple::BasicTaker::do_cross : offer1 out is XRP", + offer1.out.native()); + XRPL_ASSERT( + "ripple::BasicTaker::do_cross : offer2 in is XRP", offer2.in.native()); + XRPL_ASSERT( + "ripple::BasicTaker::do_cross : offer2 out is not XRP", + !offer2.out.native()); // If the taker owns the first leg of the offer, then the taker's available // funds aren't the limiting factor for the input - the offer itself is. @@ -559,8 +584,12 @@ Taker::Taker( , direct_crossings_(0) , bridge_crossings_(0) { - XRPL_ASSERT(issue_in() == offer.in.issue()); - XRPL_ASSERT(issue_out() == offer.out.issue()); + XRPL_ASSERT( + "ripple::Taker::Taker : issue in is a match", + issue_in() == offer.in.issue()); + XRPL_ASSERT( + "ripple::Taker::Taker : issue out is a match", + issue_out() == offer.out.issue()); if (auto stream = journal_.debug()) { @@ -689,7 +718,8 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) if (cross_type() != CrossType::XrpToIou) { - XRPL_ASSERT(!isXRP(flow.order.in)); + XRPL_ASSERT( + "ripple::Taker::fill : order in is not XRP", !isXRP(flow.order.in)); if (result == tesSUCCESS) result = @@ -701,7 +731,8 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - XRPL_ASSERT(isXRP(flow.order.in)); + XRPL_ASSERT( + "ripple::Taker::fill : order in is XRP", isXRP(flow.order.in)); if (result == tesSUCCESS) result = transferXRP(account(), offer.owner(), flow.order.in); @@ -710,7 +741,9 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) // Now send funds from the account whose offer we're taking if (cross_type() != CrossType::IouToXrp) { - XRPL_ASSERT(!isXRP(flow.order.out)); + XRPL_ASSERT( + "ripple::Taker::fill : order out is not XRP", + !isXRP(flow.order.out)); if (result == tesSUCCESS) result = redeemIOU( @@ -722,7 +755,8 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - XRPL_ASSERT(isXRP(flow.order.out)); + XRPL_ASSERT( + "ripple::Taker::fill : order out is XRP", isXRP(flow.order.out)); if (result == tesSUCCESS) result = transferXRP(offer.owner(), account(), flow.order.out); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 596cae1a5ac..69195226aad 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -367,7 +367,8 @@ Transactor::checkPriorTxAndLastLedger(PreclaimContext const& ctx) TER Transactor::consumeSeqProxy(SLE::pointer const& sleAccount) { - XRPL_ASSERT(sleAccount); + XRPL_ASSERT( + "ripple::Transactor::consumeSeqProxy : non-null account", sleAccount); SeqProxy const seqProx = ctx_.tx.getSeqProxy(); if (seqProx.isSeq()) { @@ -439,7 +440,9 @@ Transactor::ticketDelete( void Transactor::preCompute() { - XRPL_ASSERT(account_ != beast::zero); + XRPL_ASSERT( + "ripple::Transactor::preCompute : nonzero account", + account_ != beast::zero); } TER @@ -453,7 +456,9 @@ Transactor::apply() // sle must exist except for transactions // that allow zero account. - XRPL_ASSERT(sle != nullptr || account_ == beast::zero); + XRPL_ASSERT( + "ripple::Transactor::apply : non-null SLE or zero account", + sle != nullptr || account_ == beast::zero); if (sle) { @@ -578,8 +583,12 @@ Transactor::checkMultiSign(PreclaimContext const& ctx) // We have plans to support multiple SignerLists in the future. The // presence and defaulted value of the SignerListID field will enable that. - XRPL_ASSERT(sleAccountSigners->isFieldPresent(sfSignerListID)); - XRPL_ASSERT(sleAccountSigners->getFieldU32(sfSignerListID) == 0); + XRPL_ASSERT( + "ripple::Transactor::checkMultiSign : has signer list ID", + sleAccountSigners->isFieldPresent(sfSignerListID)); + XRPL_ASSERT( + "ripple::Transactor::checkMultiSign : signer list ID is 0", + sleAccountSigners->getFieldU32(sfSignerListID) == 0); auto accountSigners = SignerEntries::deserialize(*sleAccountSigners, ctx.j, "ledger"); @@ -802,7 +811,9 @@ Transactor::reset(XRPAmount fee) auto const balance = txnAcct->getFieldAmount(sfBalance).xrp(); // balance should have already been checked in checkFee / preFlight. - XRPL_ASSERT(balance != beast::zero && (!view().open() || balance >= fee)); + XRPL_ASSERT( + "ripple::Transactor::reset : valid balance", + balance != beast::zero && (!view().open() || balance >= fee)); // We retry/reject the transaction if the account balance is zero or we're // applying against an open ledger and the balance is less than the fee @@ -817,7 +828,8 @@ Transactor::reset(XRPAmount fee) // reject the transaction. txnAcct->setFieldAmount(sfBalance, balance - fee); TER const ter{consumeSeqProxy(txnAcct)}; - XRPL_ASSERT(isTesSuccess(ter)); + XRPL_ASSERT( + "ripple::Transactor::reset : result is tesSUCCESS", isTesSuccess(ter)); if (isTesSuccess(ter)) view().update(txnAcct); @@ -849,7 +861,8 @@ Transactor::operator()() JLOG(j_.fatal()) << "Transaction serdes mismatch"; JLOG(j_.info()) << to_string(ctx_.tx.getJson(JsonOptions::none)); JLOG(j_.fatal()) << s2.getJson(JsonOptions::none); - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::Transactor::operator() : transaction serdes mismatch"); } } #endif @@ -866,7 +879,9 @@ Transactor::operator()() // No transaction can return temUNKNOWN from apply, // and it can't be passed in from a preclaim. - XRPL_ASSERT(result != temUNKNOWN); + XRPL_ASSERT( + "ripple::Transactor::operator() : result is not temUNKNOWN", + result != temUNKNOWN); if (auto stream = j_.trace()) stream << "preclaim result: " << transToken(result); @@ -918,7 +933,10 @@ Transactor::operator()() std::shared_ptr const& after) { if (isDelete) { - XRPL_ASSERT(before && after); + XRPL_ASSERT( + "ripple::Transactor::operator()::visit : non-null SLE " + "inputs", + before && after); if (doOffers && before && after && (before->getType() == ltOFFER) && (before->getFieldAmount(sfTakerPays) == diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/xrpld/app/tx/detail/XChainBridge.cpp index 80afa2d4bfb..61027201649 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/xrpld/app/tx/detail/XChainBridge.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -222,7 +223,9 @@ claimHelper( auto i = signersList.find(a.keyAccount); if (i == signersList.end()) { - XRPL_ASSERT(0); // should have already been checked + XRPL_UNREACHABLE( + "ripple::claimHelper : invalid inputs"); // should have already + // been checked continue; } weight += i->second; @@ -437,7 +440,7 @@ transferHelper( if (amt.native()) { auto const sleSrc = psb.peek(keylet::account(src)); - XRPL_ASSERT(sleSrc); + XRPL_ASSERT("ripple::transferHelper : non-null source account", sleSrc); if (!sleSrc) return tecINTERNAL; diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 96f78e2e848..5f0fde00f8b 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -228,7 +228,7 @@ invoke_preflight(PreflightContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preflight: " << e.txnType; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::invoke_preflight : unknown transaction type"); return {temUNKNOWN, TxConsequences{temUNKNOWN}}; } } @@ -277,7 +277,7 @@ invoke_preclaim(PreclaimContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preclaim: " << e.txnType; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::invoke_preclaim : unknown transaction type"); return temUNKNOWN; } } @@ -293,7 +293,8 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx) } catch (UnknownTxnType const& e) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::invoke_calculateBaseFee : unknown transaction type"); return XRPAmount{0}; } } @@ -305,7 +306,9 @@ TxConsequences::TxConsequences(NotTEC pfresult) , seqProx_(SeqProxy::sequence(0)) , sequencesConsumed_(0) { - XRPL_ASSERT(!isTesSuccess(pfresult)); + XRPL_ASSERT( + "ripple::TxConsequences::TxConsequences : is not tesSUCCESS", + !isTesSuccess(pfresult)); } TxConsequences::TxConsequences(STTx const& tx) @@ -352,7 +355,7 @@ invoke_apply(ApplyContext& ctx) // Should never happen JLOG(ctx.journal.fatal()) << "Unknown transaction type in apply: " << e.txnType; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::invoke_apply : unknown transaction type"); return {temUNKNOWN, false}; } } diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 1af7631b518..696779cb57a 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -863,7 +863,9 @@ Consensus::gotTxSet( { // Our position is added to acquired_ as soon as we create it, // so this txSet must differ - XRPL_ASSERT(id != result_->position.position()); + XRPL_ASSERT( + "ripple::Consensus::gotTxSet : updated transaction set", + id != result_->position.position()); bool any = false; for (auto const& [nodeId, peerPos] : currPeerPositions_) { @@ -1008,7 +1010,9 @@ template void Consensus::handleWrongLedger(typename Ledger_t::ID const& lgrId) { - XRPL_ASSERT(lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); + XRPL_ASSERT( + "ripple::Consensus::handleWrongLedger : have wrong ledger", + lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); // Stop proposing because we are out of sync leaveConsensus(); @@ -1261,7 +1265,7 @@ void Consensus::phaseEstablish() { // can only establish consensus if we already took a stance - XRPL_ASSERT(result_); + XRPL_ASSERT("ripple::Consensus::phaseEstablish : result is set", result_); using namespace std::chrono; ConsensusParms const& parms = adaptor_.parms(); @@ -1309,7 +1313,7 @@ void Consensus::closeLedger() { // We should not be closing if we already have a position - XRPL_ASSERT(!result_); + XRPL_ASSERT("ripple::Consensus::closeLedger : result is not set", !result_); phase_ = ConsensusPhase::establish; JLOG(j_.debug()) << "transitioned to ConsensusPhase::establish"; @@ -1362,7 +1366,8 @@ void Consensus::updateOurPositions() { // We must have a position if we are updating it - XRPL_ASSERT(result_); + XRPL_ASSERT( + "ripple::Consensus::updateOurPositions : result is set", result_); ConsensusParms const& parms = adaptor_.parms(); // Compute a cutoff time @@ -1546,7 +1551,7 @@ bool Consensus::haveConsensus() { // Must have a stance if we are checking for consensus - XRPL_ASSERT(result_); + XRPL_ASSERT("ripple::Consensus::haveConsensus : has result", result_); // CHECKME: should possibly count unacquired TX sets as disagreeing int agree = 0, disagree = 0; @@ -1621,7 +1626,7 @@ void Consensus::createDisputes(TxSet_t const& o) { // Cannot create disputes without our stance - XRPL_ASSERT(result_); + XRPL_ASSERT("ripple::Consensus::createDisputes : result is set", result_); // Only create disputes if this is a new set if (!result_->compares.emplace(o.id()).second) @@ -1643,8 +1648,9 @@ Consensus::createDisputes(TxSet_t const& o) ++dc; // create disputed transactions (from the ledger that has them) XRPL_ASSERT( + "ripple::Consensus::createDisputes : has disputed transactions", (inThisSet && result_->txns.find(txId) && !o.find(txId)) || - (!inThisSet && !result_->txns.find(txId) && o.find(txId))); + (!inThisSet && !result_->txns.find(txId) && o.find(txId))); Tx_t tx = inThisSet ? result_->txns.find(txId) : o.find(txId); auto txID = tx.id(); @@ -1680,7 +1686,7 @@ void Consensus::updateDisputes(NodeID_t const& node, TxSet_t const& other) { // Cannot updateDisputes without our stance - XRPL_ASSERT(result_); + XRPL_ASSERT("ripple::Consensus::updateDisputes : result is set", result_); // Ensure we have created disputes against this set if we haven't seen // it before diff --git a/src/xrpld/consensus/ConsensusTypes.h b/src/xrpld/consensus/ConsensusTypes.h index 65bb9a01882..91510d5c8b3 100644 --- a/src/xrpld/consensus/ConsensusTypes.h +++ b/src/xrpld/consensus/ConsensusTypes.h @@ -214,7 +214,9 @@ struct ConsensusResult ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)} { - XRPL_ASSERT(txns.id() == position.position()); + XRPL_ASSERT( + "ripple::ConsensusResult : valid inputs", + txns.id() == position.position()); } //! The set of transactions consensus agrees go in the ledger diff --git a/src/xrpld/consensus/LedgerTiming.h b/src/xrpld/consensus/LedgerTiming.h index 2ce08a89d43..5aae68ebb88 100644 --- a/src/xrpld/consensus/LedgerTiming.h +++ b/src/xrpld/consensus/LedgerTiming.h @@ -82,7 +82,9 @@ getNextLedgerTimeResolution( bool previousAgree, Seq ledgerSeq) { - XRPL_ASSERT(ledgerSeq != Seq{0}); + XRPL_ASSERT( + "ripple:getNextLedgerTimeResolution : valid ledger sequence", + ledgerSeq != Seq{0}); using namespace std::chrono; // Find the current resolution: @@ -90,7 +92,9 @@ getNextLedgerTimeResolution( std::begin(ledgerPossibleTimeResolutions), std::end(ledgerPossibleTimeResolutions), previousResolution); - XRPL_ASSERT(iter != std::end(ledgerPossibleTimeResolutions)); + XRPL_ASSERT( + "ripple:getNextLedgerTimeResolution : found time resolution", + iter != std::end(ledgerPossibleTimeResolutions)); // This should never happen, but just as a precaution if (iter == std::end(ledgerPossibleTimeResolutions)) diff --git a/src/xrpld/consensus/LedgerTrie.h b/src/xrpld/consensus/LedgerTrie.h index a254deed05a..b81704b1820 100644 --- a/src/xrpld/consensus/LedgerTrie.h +++ b/src/xrpld/consensus/LedgerTrie.h @@ -64,7 +64,7 @@ class SpanTip ID ancestor(Seq const& s) const { - XRPL_ASSERT(s <= seq); + XRPL_ASSERT("ripple::SpanTip::ancestor : valid input", s <= seq); return ledger[s]; } @@ -90,7 +90,8 @@ class Span Span() : ledger_{typename Ledger::MakeGenesis{}} { // Require default ledger to be genesis seq - XRPL_ASSERT(ledger_.seq() == start_); + XRPL_ASSERT( + "ripple::Span::Span : ledger is genesis", ledger_.seq() == start_); } Span(Ledger ledger) @@ -159,7 +160,7 @@ class Span : start_{start}, end_{end}, ledger_{l} { // Spans cannot be empty - XRPL_ASSERT(start < end); + XRPL_ASSERT("ripple::Span::Span : non-empty span input", start < end); } Seq @@ -232,7 +233,7 @@ struct Node [child](std::unique_ptr const& curr) { return curr.get() == child; }); - XRPL_ASSERT(it != children.end()); + XRPL_ASSERT("ripple::Node::erase : valid input", it != children.end()); std::swap(*it, children.back()); children.pop_back(); } @@ -340,7 +341,7 @@ struct Node // For all Seq s: if(a[s] == b[s]); for(Seq p = 0; p < s; ++p) - XRPL_ASSERT(a[p] == b[p]); + assert(a[p] == b[p]); @endcode @tparam Ledger A type representing a ledger and its history @@ -373,7 +374,7 @@ class LedgerTrie Node* curr = root.get(); // Root is always defined and is in common with all ledgers - XRPL_ASSERT(curr); + XRPL_ASSERT("ripple::LedgerTrie::find : non-null root", curr); Seq pos = curr->span.diff(ledger); bool done = false; @@ -454,7 +455,7 @@ class LedgerTrie auto const [loc, diffSeq] = find(ledger); // There is always a place to insert - XRPL_ASSERT(loc); + XRPL_ASSERT("ripple::LedgerTrie::insert : valid input ledger", loc); // Node from which to start incrementing branchSupport Node* incNode = loc; @@ -489,12 +490,14 @@ class LedgerTrie newNode->tipSupport = loc->tipSupport; newNode->branchSupport = loc->branchSupport; newNode->children = std::move(loc->children); - XRPL_ASSERT(loc->children.empty()); + XRPL_ASSERT( + "ripple::LedgerTrie::insert : moved-from children", + loc->children.empty()); for (std::unique_ptr& child : newNode->children) child->parent = newNode.get(); // Loc truncates to prefix and newNode is its child - XRPL_ASSERT(prefix); + XRPL_ASSERT("ripple::LedgerTrie::insert : prefix is set", prefix); loc->span = *prefix; newNode->parent = loc; loc->children.emplace_back(std::move(newNode)); @@ -547,7 +550,9 @@ class LedgerTrie loc->tipSupport -= count; auto const it = seqSupport.find(ledger.seq()); - XRPL_ASSERT(it != seqSupport.end() && it->second >= count); + XRPL_ASSERT( + "ripple::LedgerTrie::remove : valid input ledger", + it != seqSupport.end() && it->second >= count); it->second -= count; if (it->second == 0) seqSupport.erase(it->first); diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index 1d3e95bd1a6..bd79ad0fc5d 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -434,7 +434,9 @@ class Validations Validation const& val, std::optional> prior) { - XRPL_ASSERT(val.trusted()); + XRPL_ASSERT( + "ripple::Validations::updateTrie : trusted input validation", + val.trusted()); // Clear any prior acquiring ledger for this node if (prior) @@ -714,7 +716,8 @@ class Validations setSeqToKeep(Seq const& low, Seq const& high) { std::lock_guard lock{mutex_}; - XRPL_ASSERT(low < high); + XRPL_ASSERT( + "ripple::Validations::setSeqToKeep : valid inputs", low < high); toKeep_ = {low, high}; } diff --git a/src/xrpld/core/Coro.ipp b/src/xrpld/core/Coro.ipp index c29027479dd..b41985c4482 100644 --- a/src/xrpld/core/Coro.ipp +++ b/src/xrpld/core/Coro.ipp @@ -53,7 +53,7 @@ JobQueue::Coro::Coro( inline JobQueue::Coro::~Coro() { #ifndef NDEBUG - XRPL_ASSERT(finished_); + XRPL_ASSERT("ripple::JobQueue::Coro::~Coro : is finished", finished_); #endif } @@ -103,7 +103,7 @@ JobQueue::Coro::resume() auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); std::lock_guard lock(mutex_); - XRPL_ASSERT(coro_); + XRPL_ASSERT("ripple::JobQueue::Coro::resume : is runnable", coro_); coro_(); detail::getLocalValues().release(); detail::getLocalValues().reset(saved); diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index f0f07c6626d..9b85da5b8e8 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -96,7 +96,10 @@ class DatabaseCon std::vector const* commonPragma() const { - XRPL_ASSERT(!useGlobalPragma || globalPragma); + XRPL_ASSERT( + "ripple::DatabaseCon::Setup::commonPragma : consistent global " + "pragma", + !useGlobalPragma || globalPragma); return useGlobalPragma && globalPragma ? globalPragma.get() : nullptr; } diff --git a/src/xrpld/core/JobTypes.h b/src/xrpld/core/JobTypes.h index 0911cbddbee..727f09097ce 100644 --- a/src/xrpld/core/JobTypes.h +++ b/src/xrpld/core/JobTypes.h @@ -53,7 +53,9 @@ class JobTypes int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) { - XRPL_ASSERT(m_map.find(jt) == m_map.end()); + XRPL_ASSERT( + "ripple::JobTypes::JobTypes::add : unique job type input", + m_map.find(jt) == m_map.end()); auto const [_, inserted] = m_map.emplace( std::piecewise_construct, @@ -61,7 +63,9 @@ class JobTypes std::forward_as_tuple( jt, name, limit, avgLatency, peakLatency)); - XRPL_ASSERT(inserted == true); + XRPL_ASSERT( + "ripple::JobTypes::JobTypes::add : input is inserted", + inserted == true); (void)_; (void)inserted; }; @@ -138,7 +142,7 @@ class JobTypes get(JobType jt) const { Map::const_iterator const iter(m_map.find(jt)); - XRPL_ASSERT(iter != m_map.end()); + XRPL_ASSERT("ripple::JobTypes::get : valid input", iter != m_map.end()); if (iter != m_map.end()) return iter->second; diff --git a/src/xrpld/core/Pg.cpp b/src/xrpld/core/Pg.cpp index 1e1da7d9957..9835601eb08 100644 --- a/src/xrpld/core/Pg.cpp +++ b/src/xrpld/core/Pg.cpp @@ -242,7 +242,7 @@ void Pg::bulkInsert(char const* table, std::string const& records) { // https://www.postgresql.org/docs/12/libpq-copy.html#LIBPQ-COPY-SEND - XRPL_ASSERT(conn_.get()); + XRPL_ASSERT("ripple::Pg::bulkInsert : non-null connection", conn_.get()); static auto copyCmd = boost::format(R"(COPY %s FROM stdin)"); auto res = query(boost::str(copyCmd % table).c_str()); if (!res || res.status() != PGRES_COPY_IN) @@ -1326,7 +1326,7 @@ applySchema( { if (currentVersion != 0 && schemaVersion != currentVersion + 1) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::applySchema : cannot skip schema upgrade"); std::stringstream ss; ss << "Schema upgrade versions past initial deployment must increase " "monotonically. Versions: current, target: " diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index 3be2ef3d5a7..9726d9a313b 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -266,7 +266,8 @@ Config::Config() void Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) { - XRPL_ASSERT(NODE_SIZE == 0); + XRPL_ASSERT( + "ripple::Config::setupControl : node size not set", NODE_SIZE == 0); QUIET = bQuiet || bSilent; SILENT = bSilent; @@ -287,7 +288,9 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) return (limit == 0) || (ramSize_ < limit); }); - XRPL_ASSERT(ns != threshold.second.end()); + XRPL_ASSERT( + "ripple::Config::setupControl : valid node size", + ns != threshold.second.end()); if (ns != threshold.second.end()) NODE_SIZE = std::distance(threshold.second.begin(), ns); @@ -298,7 +301,8 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) NODE_SIZE = std::min(hc / 2, NODE_SIZE); } - XRPL_ASSERT(NODE_SIZE <= 4); + XRPL_ASSERT( + "ripple::Config::setupControl : node size is set", NODE_SIZE <= 4); } void @@ -1009,8 +1013,12 @@ int Config::getValueFor(SizedItem item, std::optional node) const { auto const index = static_cast>(item); - XRPL_ASSERT(index < sizedItems.size()); - XRPL_ASSERT(!node || *node <= 4); + XRPL_ASSERT( + "ripple::Config::getValueFor : valid index input", + index < sizedItems.size()); + XRPL_ASSERT( + "ripple::Config::getValueFor : unset or valid node", + !node || *node <= 4); return sizedItems.at(index).second.at(node.value_or(NODE_SIZE)); } diff --git a/src/xrpld/core/detail/DatabaseCon.cpp b/src/xrpld/core/detail/DatabaseCon.cpp index ac4b6c5b7c1..1736947a702 100644 --- a/src/xrpld/core/detail/DatabaseCon.cpp +++ b/src/xrpld/core/detail/DatabaseCon.cpp @@ -232,7 +232,9 @@ setup_DatabaseCon(Config const& c, std::optional j) "nodes storing large amounts of history, because of the " "difficulty inherent in rebuilding corrupted data."; } - XRPL_ASSERT(result->size() == 3); + XRPL_ASSERT( + "ripple::setup_DatabaseCon::globalPragma : result size is 3", + result->size() == 3); return result; }(); } diff --git a/src/xrpld/core/detail/JobQueue.cpp b/src/xrpld/core/detail/JobQueue.cpp index 3d3a2cd0641..232e9d424fd 100644 --- a/src/xrpld/core/detail/JobQueue.cpp +++ b/src/xrpld/core/detail/JobQueue.cpp @@ -55,7 +55,9 @@ JobQueue::JobQueue( std::piecewise_construct, std::forward_as_tuple(jt.type()), std::forward_as_tuple(jt, m_collector, logs))); - XRPL_ASSERT(result.second == true); + XRPL_ASSERT( + "ripple::JobQueue::JobQueue : jobs added", + result.second == true); (void)result.second; } } @@ -80,10 +82,14 @@ JobQueue::addRefCountedJob( std::string const& name, JobFunction const& func) { - XRPL_ASSERT(type != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::addRefCountedJob : valid input job type", + type != jtINVALID); auto iter(m_jobData.find(type)); - XRPL_ASSERT(iter != m_jobData.end()); + XRPL_ASSERT( + "ripple::JobQueue::addRefCountedJob : job type found in jobs", + iter != m_jobData.end()); if (iter == m_jobData.end()) return false; @@ -94,8 +100,10 @@ JobQueue::addRefCountedJob( // FIXME: Workaround incorrect client shutdown ordering // do not add jobs to a queue with no threads XRPL_ASSERT( + "ripple::JobQueue::addRefCountedJob : threads available or job " + "requires no threads", (type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) || - m_workers.getNumberOfThreads() > 0); + m_workers.getNumberOfThreads() > 0); { std::lock_guard lock(m_mutex); @@ -104,8 +112,12 @@ JobQueue::addRefCountedJob( auto const& job = *result.first; JobType const type(job.getType()); - XRPL_ASSERT(type != jtINVALID); - XRPL_ASSERT(m_jobSet.find(job) != m_jobSet.end()); + XRPL_ASSERT( + "ripple::JobQueue::addRefCountedJob : has valid job type", + type != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::addRefCountedJob : job found", + m_jobSet.find(job) != m_jobSet.end()); perfLog_.jobQueue(type); JobTypeData& data(getJobTypeData(type)); @@ -165,7 +177,9 @@ std::unique_ptr JobQueue::makeLoadEvent(JobType t, std::string const& name) { JobDataMap::iterator iter(m_jobData.find(t)); - XRPL_ASSERT(iter != m_jobData.end()); + XRPL_ASSERT( + "ripple::JobQueue::makeLoadEvent : valid job type input", + iter != m_jobData.end()); if (iter == m_jobData.end()) return {}; @@ -180,7 +194,9 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed) LogicError("JobQueue::addLoadEvents() called after JobQueue stopped"); JobDataMap::iterator iter(m_jobData.find(t)); - XRPL_ASSERT(iter != m_jobData.end()); + XRPL_ASSERT( + "ripple::JobQueue::addLoadEvents : valid job type input", + iter != m_jobData.end()); iter->second.load().addSamples(count, elapsed); } @@ -206,7 +222,8 @@ JobQueue::getJson(int c) for (auto& x : m_jobData) { - XRPL_ASSERT(x.first != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::getJson : valid job type", x.first != jtINVALID); if (x.first == jtGENERIC) continue; @@ -261,7 +278,9 @@ JobTypeData& JobQueue::getJobTypeData(JobType type) { JobDataMap::iterator c(m_jobData.find(type)); - XRPL_ASSERT(c != m_jobData.end()); + XRPL_ASSERT( + "ripple::JobQueue::getJobTypeData : valid job type input", + c != m_jobData.end()); // NIKB: This is ugly and I hate it. We must remove jtINVALID completely // and use something sane. @@ -286,9 +305,13 @@ JobQueue::stop() std::unique_lock lock(m_mutex); cv_.wait( lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); - XRPL_ASSERT(m_processCount == 0); - XRPL_ASSERT(m_jobSet.empty()); - XRPL_ASSERT(nSuspend_ == 0); + XRPL_ASSERT( + "ripple::JobQueue::stop : all processes completed", + m_processCount == 0); + XRPL_ASSERT( + "ripple::JobQueue::stop : all jobs completed", m_jobSet.empty()); + XRPL_ASSERT( + "ripple::JobQueue::stop : no coros suspended", nSuspend_ == 0); stopped_ = true; } } @@ -302,28 +325,36 @@ JobQueue::isStopped() const void JobQueue::getNextJob(Job& job) { - XRPL_ASSERT(!m_jobSet.empty()); + XRPL_ASSERT( + "ripple::JobQueue::getNextJob : non-empty jobs", !m_jobSet.empty()); std::set::const_iterator iter; for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter) { JobType const type = iter->getType(); - XRPL_ASSERT(type != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::getNextJob : valid job type", type != jtINVALID); JobTypeData& data(getJobTypeData(type)); - XRPL_ASSERT(data.running <= getJobLimit(type)); + XRPL_ASSERT( + "ripple::JobQueue::getNextJob : maximum jobs running", + data.running <= getJobLimit(type)); // Run this job if we're running below the limit. if (data.running < getJobLimit(data.type())) { - XRPL_ASSERT(data.waiting > 0); + XRPL_ASSERT( + "ripple::JobQueue::getNextJob : positive data waiting", + data.waiting > 0); --data.waiting; ++data.running; break; } } - XRPL_ASSERT(iter != m_jobSet.end()); + XRPL_ASSERT( + "ripple::JobQueue::getNextJob : found next job", + iter != m_jobSet.end()); job = *iter; m_jobSet.erase(iter); } @@ -331,14 +362,18 @@ JobQueue::getNextJob(Job& job) void JobQueue::finishJob(JobType type) { - XRPL_ASSERT(type != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::finishJob : valid input job type", + type != jtINVALID); JobTypeData& data = getJobTypeData(type); // Queue a deferred task if possible if (data.deferred > 0) { - XRPL_ASSERT(data.running + data.waiting >= getJobLimit(type)); + XRPL_ASSERT( + "ripple::JobQueue::finishJob : job limit", + data.running + data.waiting >= getJobLimit(type)); --data.deferred; m_workers.addTask(); @@ -404,7 +439,9 @@ int JobQueue::getJobLimit(JobType type) { JobTypeInfo const& j(JobTypes::instance().get(type)); - XRPL_ASSERT(j.type() != jtINVALID); + XRPL_ASSERT( + "ripple::JobQueue::getJobLimit : valid job type", + j.type() != jtINVALID); return j.limit(); } diff --git a/src/xrpld/core/detail/LoadEvent.cpp b/src/xrpld/core/detail/LoadEvent.cpp index 5f309a04281..7f9e23b7f0e 100644 --- a/src/xrpld/core/detail/LoadEvent.cpp +++ b/src/xrpld/core/detail/LoadEvent.cpp @@ -83,7 +83,7 @@ LoadEvent::start() void LoadEvent::stop() { - XRPL_ASSERT(running_); + XRPL_ASSERT("ripple::LoadEvent::stop : is running", running_); auto const now = std::chrono::steady_clock::now(); diff --git a/src/xrpld/core/detail/Workers.cpp b/src/xrpld/core/detail/Workers.cpp index 2b43ed3f1b8..2ca1a615dc1 100644 --- a/src/xrpld/core/detail/Workers.cpp +++ b/src/xrpld/core/detail/Workers.cpp @@ -119,7 +119,9 @@ Workers::stop() m_cv.wait(lk, [this] { return m_allPaused; }); lk.unlock(); - XRPL_ASSERT(numberOfCurrentlyRunningTasks() == 0); + XRPL_ASSERT( + "ripple::Workers::stop : zero running tasks", + numberOfCurrentlyRunningTasks() == 0); } void diff --git a/src/xrpld/ledger/ApplyView.h b/src/xrpld/ledger/ApplyView.h index db416b4b530..1cb63f3c3a1 100644 --- a/src/xrpld/ledger/ApplyView.h +++ b/src/xrpld/ledger/ApplyView.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace ripple { @@ -276,8 +277,11 @@ class ApplyView : public ReadView { if (key.type != ltOFFER) { - XRPL_ASSERT(!"Only Offers are appended to book directories. " - "Call dirInsert() instead."); + XRPL_UNREACHABLE( + "ripple::ApplyView::dirAppend : only Offers are appended to " + "book directories"); + // Only Offers are appended to book directories. Call dirInsert() + // instead return std::nullopt; } return dirAdd(true, directory, key.key, describe); diff --git a/src/xrpld/ledger/detail/ApplyStateTable.cpp b/src/xrpld/ledger/detail/ApplyStateTable.cpp index a0107d7929d..1da64471744 100644 --- a/src/xrpld/ledger/detail/ApplyStateTable.cpp +++ b/src/xrpld/ledger/detail/ApplyStateTable.cpp @@ -155,7 +155,10 @@ ApplyStateTable::apply( meta.setAffectedNode(item.first, *type, nodeType); if (type == &sfDeletedNode) { - XRPL_ASSERT(origNode && curNode); + XRPL_ASSERT( + "ripple::detail::ApplyStateTable::apply : valid nodes for " + "deletion", + origNode && curNode); threadOwners(to, meta, origNode, newMod, j); STObject prevs(sfPreviousFields); @@ -187,7 +190,10 @@ ApplyStateTable::apply( } else if (type == &sfModifiedNode) { - XRPL_ASSERT(curNode && origNode); + XRPL_ASSERT( + "ripple::detail::ApplyStateTable::apply : valid nodes for " + "modification", + curNode && origNode); if (curNode->isThreadedType( to.rules())) // thread transaction to node @@ -222,7 +228,10 @@ ApplyStateTable::apply( } else if (type == &sfCreatedNode) // if created, thread to owner(s) { - XRPL_ASSERT(curNode && !origNode); + XRPL_ASSERT( + "ripple::detail::ApplyStateTable::apply : valid nodes for " + "creation", + curNode && !origNode); threadOwners(to, meta, curNode, newMod, j); if (curNode->isThreadedType( @@ -245,7 +254,9 @@ ApplyStateTable::apply( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::detail::ApplyStateTable::apply : unsupported " + "operation type"); } } @@ -536,13 +547,21 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr const& sle) if (node.getFieldIndex(sfPreviousTxnID) == -1) { - XRPL_ASSERT(node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); + XRPL_ASSERT( + "ripple::ApplyStateTable::threadItem : previous ledger is not " + "set", + node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); node.setFieldH256(sfPreviousTxnID, prevTxID); node.setFieldU32(sfPreviousTxnLgrSeq, prevLgrID); } - XRPL_ASSERT(node.getFieldH256(sfPreviousTxnID) == prevTxID); - XRPL_ASSERT(node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); + XRPL_ASSERT( + "ripple::ApplyStateTable::threadItem : previous transaction is a " + "match", + node.getFieldH256(sfPreviousTxnID) == prevTxID); + XRPL_ASSERT( + "ripple::ApplyStateTable::threadItem : previous ledger is a match", + node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); } } @@ -557,7 +576,9 @@ ApplyStateTable::getForMod( auto miter = mods.find(key); if (miter != mods.end()) { - XRPL_ASSERT(miter->second); + XRPL_ASSERT( + "ripple::ApplyStateTable::getForMod : non-null result", + miter->second); return miter->second; } } @@ -613,7 +634,9 @@ ApplyStateTable::threadTx( return; } // threadItem only applied to AccountRoot - XRPL_ASSERT(sle->isThreadedType(base.rules())); + XRPL_ASSERT( + "ripple::ApplyStateTable::threadTx : SLE is threaded", + sle->isThreadedType(base.rules())); threadItem(meta, sle); } diff --git a/src/xrpld/ledger/detail/ApplyView.cpp b/src/xrpld/ledger/detail/ApplyView.cpp index 58c6d3866f2..67d8dadce8b 100644 --- a/src/xrpld/ledger/detail/ApplyView.cpp +++ b/src/xrpld/ledger/detail/ApplyView.cpp @@ -133,7 +133,8 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (directory.type != ltDIR_NODE || node->getFieldH256(sfRootIndex) != directory.key) { - XRPL_ASSERT(!"emptyDirDelete() called with wrong node type"); + XRPL_UNREACHABLE( + "ripple::ApplyView::emptyDirDelete : invalid node type"); return false; } diff --git a/src/xrpld/ledger/detail/BookDirs.cpp b/src/xrpld/ledger/detail/BookDirs.cpp index 302b634811a..c1eb040712b 100644 --- a/src/xrpld/ledger/detail/BookDirs.cpp +++ b/src/xrpld/ledger/detail/BookDirs.cpp @@ -30,12 +30,13 @@ BookDirs::BookDirs(ReadView const& view, Book const& book) , next_quality_(getQualityNext(root_)) , key_(view_->succ(root_, next_quality_).value_or(beast::zero)) { - XRPL_ASSERT(root_ != beast::zero); + XRPL_ASSERT( + "ripple::BookDirs::BookDirs : nonzero root", root_ != beast::zero); if (key_ != beast::zero) { if (!cdirFirst(*view_, key_, sle_, entry_, index_)) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::BookDirs::BookDirs : directory is empty"); } } } @@ -70,7 +71,10 @@ BookDirs::const_iterator::operator==( if (view_ == nullptr || other.view_ == nullptr) return false; - XRPL_ASSERT(view_ == other.view_ && root_ == other.root_); + XRPL_ASSERT( + "ripple::BookDirs::const_iterator::operator== : views and roots are " + "matching", + view_ == other.view_ && root_ == other.root_); return entry_ == other.entry_ && cur_key_ == other.cur_key_ && index_ == other.index_; } @@ -78,7 +82,9 @@ BookDirs::const_iterator::operator==( BookDirs::const_iterator::reference BookDirs::const_iterator::operator*() const { - XRPL_ASSERT(index_ != beast::zero); + XRPL_ASSERT( + "ripple::BookDirs::const_iterator::operator* : nonzero index", + index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::offer(index_)); return *cache_; @@ -89,7 +95,9 @@ BookDirs::const_iterator::operator++() { using beast::zero; - XRPL_ASSERT(index_ != zero); + XRPL_ASSERT( + "ripple::BookDirs::const_iterator::operator++ : nonzero index", + index_ != zero); if (!cdirNext(*view_, cur_key_, sle_, entry_, index_)) { if (index_ != 0 || @@ -102,7 +110,9 @@ BookDirs::const_iterator::operator++() } else if (!cdirFirst(*view_, cur_key_, sle_, entry_, index_)) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::BookDirs::const_iterator::operator++ : directory is " + "empty"); } } @@ -113,7 +123,9 @@ BookDirs::const_iterator::operator++() BookDirs::const_iterator BookDirs::const_iterator::operator++(int) { - XRPL_ASSERT(index_ != beast::zero); + XRPL_ASSERT( + "ripple::BookDirs::const_iterator::operator++(int) : nonzero index", + index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; diff --git a/src/xrpld/ledger/detail/Directory.cpp b/src/xrpld/ledger/detail/Directory.cpp index 7fe2ffe1ba2..93aab17d2a2 100644 --- a/src/xrpld/ledger/detail/Directory.cpp +++ b/src/xrpld/ledger/detail/Directory.cpp @@ -60,14 +60,18 @@ const_iterator::operator==(const_iterator const& other) const if (view_ == nullptr || other.view_ == nullptr) return false; - XRPL_ASSERT(view_ == other.view_ && root_.key == other.root_.key); + XRPL_ASSERT( + "ripple::const_iterator::operator== : views and roots are matching", + view_ == other.view_ && root_.key == other.root_.key); return page_.key == other.page_.key && index_ == other.index_; } const_iterator::reference const_iterator::operator*() const { - XRPL_ASSERT(index_ != beast::zero); + XRPL_ASSERT( + "ripple::const_iterator::operator* : nonzero index", + index_ != beast::zero); if (!cache_) cache_ = view_->read(keylet::child(index_)); return *cache_; @@ -76,7 +80,9 @@ const_iterator::operator*() const const_iterator& const_iterator::operator++() { - XRPL_ASSERT(index_ != beast::zero); + XRPL_ASSERT( + "ripple::const_iterator::operator++ : nonzero index", + index_ != beast::zero); if (++it_ != std::end(*indexes_)) { index_ = *it_; @@ -90,7 +96,9 @@ const_iterator::operator++() const_iterator const_iterator::operator++(int) { - XRPL_ASSERT(index_ != beast::zero); + XRPL_ASSERT( + "ripple::const_iterator::operator++(int) : nonzero index", + index_ != beast::zero); const_iterator tmp(*this); ++(*this); return tmp; @@ -109,7 +117,7 @@ const_iterator::next_page() { page_ = keylet::page(root_, next); sle_ = view_->read(page_); - XRPL_ASSERT(sle_); + XRPL_ASSERT("ripple::const_iterator::next_page : non-null SLE", sle_); indexes_ = &sle_->getFieldV256(sfIndexes); if (indexes_->empty()) { diff --git a/src/xrpld/ledger/detail/PaymentSandbox.cpp b/src/xrpld/ledger/detail/PaymentSandbox.cpp index 696da0e106b..24302180d5e 100644 --- a/src/xrpld/ledger/detail/PaymentSandbox.cpp +++ b/src/xrpld/ledger/detail/PaymentSandbox.cpp @@ -48,8 +48,12 @@ DeferredCredits::credit( STAmount const& amount, STAmount const& preCreditSenderBalance) { - XRPL_ASSERT(sender != receiver); - XRPL_ASSERT(!amount.negative()); + XRPL_ASSERT( + "ripple::detail::DeferredCredits::credit : sender is not receiver", + sender != receiver); + XRPL_ASSERT( + "ripple::detail::DeferredCredits::credit : positive amount", + !amount.negative()); auto const k = makeKey(sender, receiver, amount.getCurrency()); auto i = credits_.find(k); @@ -252,14 +256,14 @@ PaymentSandbox::adjustOwnerCountHook( void PaymentSandbox::apply(RawView& to) { - XRPL_ASSERT(!ps_); + XRPL_ASSERT("ripple::PaymentSandbox::apply : non-null sandbox", !ps_); items_.apply(to); } void PaymentSandbox::apply(PaymentSandbox& to) { - XRPL_ASSERT(ps_ == &to); + XRPL_ASSERT("ripple::PaymentSandbox::apply : matching sandbox", ps_ == &to); items_.apply(to); tab_.apply(to.tab_); } @@ -343,7 +347,10 @@ PaymentSandbox::balanceChanges(ReadView const& view) const { // modify auto const at = after->getType(); - XRPL_ASSERT(at == before->getType()); + XRPL_ASSERT( + "ripple::PaymentSandbox::balanceChanges : after and before " + "types matching", + at == before->getType()); switch (at) { case ltACCOUNT_ROOT: diff --git a/src/xrpld/ledger/detail/RawStateTable.cpp b/src/xrpld/ledger/detail/RawStateTable.cpp index a37a608010d..e202d500c6a 100644 --- a/src/xrpld/ledger/detail/RawStateTable.cpp +++ b/src/xrpld/ledger/detail/RawStateTable.cpp @@ -63,7 +63,9 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base { if (auto const p = dynamic_cast(&impl)) { - XRPL_ASSERT(end1_ == p->end1_ && end0_ == p->end0_); + XRPL_ASSERT( + "ripple::detail::RawStateTable::equal : matching end iterators", + end1_ == p->end1_ && end0_ == p->end0_); return iter1_ == p->iter1_ && iter0_ == p->iter0_; } @@ -73,7 +75,9 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base void increment() override { - XRPL_ASSERT(sle1_ || sle0_); + XRPL_ASSERT( + "ripple::detail::RawStateTable::increment : either SLE is non-null", + sle1_ || sle0_); if (sle1_ && !sle0_) { @@ -179,7 +183,9 @@ RawStateTable::apply(RawView& to) const bool RawStateTable::exists(ReadView const& base, Keylet const& k) const { - XRPL_ASSERT(k.key.isNonZero()); + XRPL_ASSERT( + "ripple::detail::RawStateTable::exists : nonzero key", + k.key.isNonZero()); auto const iter = items_.find(k.key); if (iter == items_.end()) return base.exists(k); diff --git a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp index d06ab1f8a3c..0d5ba358a3f 100644 --- a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp +++ b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp @@ -80,7 +80,10 @@ template bool ReadViewFwdRange::iterator::operator==(iterator const& other) const { - XRPL_ASSERT(view_ == other.view_); + XRPL_ASSERT( + "ripple::detail::ReadViewFwdRange::iterator::operator==(iterator) " + "const : input view match", + view_ == other.view_); if (impl_ != nullptr && other.impl_ != nullptr) return impl_->equal(*other.impl_); diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index b3357fbd10d..41ead67090e 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -48,7 +48,9 @@ internalDirNext( uint256& entry) { auto const& svIndexes = page->getFieldV256(sfIndexes); - XRPL_ASSERT(index <= svIndexes.size()); + XRPL_ASSERT( + "ripple::detail::internalDirNext : index inside range", + index <= svIndexes.size()); if (index >= svIndexes.size()) { @@ -65,7 +67,7 @@ internalDirNext( else page = view.peek(keylet::page(root, next)); - XRPL_ASSERT(page); + XRPL_ASSERT("ripple::detail::internalDirNext : non-null root", page); if (!page) return false; @@ -336,7 +338,7 @@ confineOwnerCount( << "Account " << *id << " owner count set below 0!"; } adjusted = 0; - XRPL_ASSERT(!id); + XRPL_ASSERT("ripple::confineOwnerCount : id is not set", !id); } } return adjusted; @@ -386,7 +388,8 @@ forEachItem( Keylet const& root, std::function const&)> const& f) { - XRPL_ASSERT(root.type == ltDIR_NODE); + XRPL_ASSERT( + "ripple::forEachItem : valid root type", root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return; @@ -416,7 +419,8 @@ forEachItemAfter( unsigned int limit, std::function const&)> const& f) { - XRPL_ASSERT(root.type == ltDIR_NODE); + XRPL_ASSERT( + "ripple::forEachItemAfter : valid root type", root.type == ltDIR_NODE); if (root.type != ltDIR_NODE) return false; @@ -679,8 +683,9 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) if (hashIndex) { XRPL_ASSERT( + "ripple::hashOfSeq : matching ledger sequence", hashIndex->getFieldU32(sfLastLedgerSequence) == - (ledger.seq() - 1)); + (ledger.seq() - 1)); STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() >= diff) return vec[vec.size() - diff]; @@ -708,8 +713,9 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) if (hashIndex) { auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence); - XRPL_ASSERT(lastSeq >= seq); - XRPL_ASSERT((lastSeq & 0xff) == 0); + XRPL_ASSERT("ripple::hashOfSeq : minimum last ledger", lastSeq >= seq); + XRPL_ASSERT( + "ripple::hashOfSeq : valid last ledger", (lastSeq & 0xff) == 0); auto const diff = (lastSeq - seq) >> 8; STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() > diff) @@ -735,7 +741,7 @@ adjustOwnerCount( { if (!sle) return; - XRPL_ASSERT(amount != 0); + XRPL_ASSERT("ripple::adjustOwnerCount : nonzero amount input", amount != 0); std::uint32_t const current{sle->getFieldU32(sfOwnerCount)}; AccountID const id = (*sle)[sfAccount]; std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j); @@ -800,13 +806,14 @@ trustCreate( const bool bSetDst = saLimit.getIssuer() == uDstAccountID; const bool bSetHigh = bSrcHigh ^ bSetDst; - XRPL_ASSERT(sleAccount); + XRPL_ASSERT("ripple::trustCreate : non-null SLE", sleAccount); if (!sleAccount) return tefINTERNAL; XRPL_ASSERT( + "ripple::trustCreate : matching account ID", sleAccount->getAccountID(sfAccount) == - (bSetHigh ? uHighAccountID : uLowAccountID)); + (bSetHigh ? uHighAccountID : uLowAccountID)); auto const slePeer = view.peek(keylet::account(bSetHigh ? uLowAccountID : uHighAccountID)); if (!slePeer) @@ -959,17 +966,25 @@ rippleCredit( Currency const& currency = saAmount.getCurrency(); // Make sure issuer is involved. - XRPL_ASSERT(!bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); + XRPL_ASSERT( + "ripple::rippleCredit : matching issuer or don't care", + !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); (void)issuer; // Disallow sending to self. - XRPL_ASSERT(uSenderID != uReceiverID); + XRPL_ASSERT( + "ripple::rippleCredit : sender is not receiver", + uSenderID != uReceiverID); bool const bSenderHigh = uSenderID > uReceiverID; auto const index = keylet::line(uSenderID, uReceiverID, currency); - XRPL_ASSERT(!isXRP(uSenderID) && uSenderID != noAccount()); - XRPL_ASSERT(!isXRP(uReceiverID) && uReceiverID != noAccount()); + XRPL_ASSERT( + "ripple::rippleCredit : sender is not XRP", + !isXRP(uSenderID) && uSenderID != noAccount()); + XRPL_ASSERT( + "ripple::rippleCredit : receiver is not XRP", + !isXRP(uReceiverID) && uReceiverID != noAccount()); // If the line exists, modify it accordingly. if (auto const sleRippleState = view.peek(index)) @@ -1103,8 +1118,12 @@ rippleSend( { auto const issuer = saAmount.getIssuer(); - XRPL_ASSERT(!isXRP(uSenderID) && !isXRP(uReceiverID)); - XRPL_ASSERT(uSenderID != uReceiverID); + XRPL_ASSERT( + "ripple::rippleSend : neither sender nor receiver is XRP", + !isXRP(uSenderID) && !isXRP(uReceiverID)); + XRPL_ASSERT( + "ripple::rippleSend : sender is not receiver", + uSenderID != uReceiverID); if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount()) { @@ -1156,7 +1175,8 @@ accountSend( } else { - XRPL_ASSERT(saAmount >= beast::zero); + XRPL_ASSERT( + "ripple::accountSend : minimum amount", saAmount >= beast::zero); } /* If we aren't sending anything or if the sender is the same as the @@ -1317,13 +1337,16 @@ issueIOU( Issue const& issue, beast::Journal j) { - XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT( + "ripple::issueIOU : neither account nor issuer is XRP", + !isXRP(account) && !isXRP(issue.account)); // Consistency check - XRPL_ASSERT(issue == amount.issue()); + XRPL_ASSERT("ripple::issueIOU : matching issue", issue == amount.issue()); // Can't send to self! - XRPL_ASSERT(issue.account != account); + XRPL_ASSERT( + "ripple::issueIOU : not issuer account", issue.account != account); JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1413,13 +1436,16 @@ redeemIOU( Issue const& issue, beast::Journal j) { - XRPL_ASSERT(!isXRP(account) && !isXRP(issue.account)); + XRPL_ASSERT( + "ripple::redeemIOU : neither account nor issuer is XRP", + !isXRP(account) && !isXRP(issue.account)); // Consistency check - XRPL_ASSERT(issue == amount.issue()); + XRPL_ASSERT("ripple::redeemIOU : matching issue", issue == amount.issue()); // Can't send to self! - XRPL_ASSERT(issue.account != account); + XRPL_ASSERT( + "ripple::redeemIOU : not issuer account", issue.account != account); JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1483,10 +1509,11 @@ transferXRP( STAmount const& amount, beast::Journal j) { - XRPL_ASSERT(from != beast::zero); - XRPL_ASSERT(to != beast::zero); - XRPL_ASSERT(from != to); - XRPL_ASSERT(amount.native()); + XRPL_ASSERT( + "ripple::transferXRP : nonzero from account", from != beast::zero); + XRPL_ASSERT("ripple::transferXRP : nonzero to account", to != beast::zero); + XRPL_ASSERT("ripple::transferXRP : from and to are unequal", from != to); + XRPL_ASSERT("ripple::transferXRP : amount is XRP", amount.native()); SLE::pointer const sender = view.peek(keylet::account(from)); SLE::pointer const receiver = view.peek(keylet::account(to)); @@ -1596,7 +1623,9 @@ cleanupOnAccountDelete( // // 3. So we verify that uDirEntry is indeed 'it'+1. Then we jam it // back to 'it' to "un-invalidate" the iterator. - XRPL_ASSERT(uDirEntry >= 1); + XRPL_ASSERT( + "ripple::cleanupOnAccountDelete : minimum dir entries", + uDirEntry >= 1); if (uDirEntry == 0) { JLOG(j.error()) diff --git a/src/xrpld/net/detail/DatabaseBody.ipp b/src/xrpld/net/detail/DatabaseBody.ipp index bc695567214..7cd786f4b4a 100644 --- a/src/xrpld/net/detail/DatabaseBody.ipp +++ b/src/xrpld/net/detail/DatabaseBody.ipp @@ -89,7 +89,8 @@ DatabaseBody::reader::init( boost::system::error_code& ec) { // The connection must already be available for writing - XRPL_ASSERT(body_.conn_); + XRPL_ASSERT( + "ripple::DatabaseBody::reader::init : connection is set", body_.conn_); // The error_code specification requires that we // either set the error to some value, or set it diff --git a/src/xrpld/net/detail/DatabaseDownloader.cpp b/src/xrpld/net/detail/DatabaseDownloader.cpp index 37789a196b0..f3811ab231d 100644 --- a/src/xrpld/net/detail/DatabaseDownloader.cpp +++ b/src/xrpld/net/detail/DatabaseDownloader.cpp @@ -72,7 +72,10 @@ DatabaseDownloader::closeBody(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - XRPL_ASSERT(databaseBodyParser); + XRPL_ASSERT( + "ripple::DatabaseDownloader::closeBody : DatabaseBody type cast " + "succeeded", + databaseBodyParser); databaseBodyParser->get().body().close(); } @@ -84,7 +87,9 @@ DatabaseDownloader::size(std::shared_ptr p) auto databaseBodyParser = std::dynamic_pointer_cast>(p); - XRPL_ASSERT(databaseBodyParser); + XRPL_ASSERT( + "ripple::DatabaseDownloader::size : DatabaseBody type cast succeeded", + databaseBodyParser); return databaseBodyParser->get().body().size(); } diff --git a/src/xrpld/net/detail/HTTPStream.cpp b/src/xrpld/net/detail/HTTPStream.cpp index 4beb6a479ab..c04a370f3c2 100644 --- a/src/xrpld/net/detail/HTTPStream.cpp +++ b/src/xrpld/net/detail/HTTPStream.cpp @@ -33,7 +33,7 @@ SSLStream::SSLStream( boost::asio::ip::tcp::socket& SSLStream::getStream() { - XRPL_ASSERT(stream_); + XRPL_ASSERT("ripple:: SSLStream::getStream : stream is set", stream_); return stream_->next_layer(); } @@ -126,7 +126,7 @@ RawStream::RawStream(boost::asio::io_service::strand& strand) : strand_(strand) boost::asio::ip::tcp::socket& RawStream::getStream() { - XRPL_ASSERT(stream_); + XRPL_ASSERT("ripple:: RawStream::getStream : stream is set", stream_); return *stream_; } diff --git a/src/xrpld/net/detail/InfoSub.cpp b/src/xrpld/net/detail/InfoSub.cpp index 0ae58e99c46..8936fa0c2d9 100644 --- a/src/xrpld/net/detail/InfoSub.cpp +++ b/src/xrpld/net/detail/InfoSub.cpp @@ -145,7 +145,8 @@ InfoSub::setApiVersion(unsigned int apiVersion) unsigned int InfoSub::getApiVersion() const noexcept { - XRPL_ASSERT(apiVersion_ > 0); + XRPL_ASSERT( + "ripple::InfoSub::getApiVersion : valid API version", apiVersion_ > 0); return apiVersion_; } diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index f91aab1f09b..4aef8e989ab 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -992,7 +992,9 @@ class RPCParser parseTransactionEntry(Json::Value const& jvParams) { // Parameter count should have already been verified. - XRPL_ASSERT(jvParams.size() == 2); + XRPL_ASSERT( + "ripple::RPCParser::parseTransactionEntry : valid parameter count", + jvParams.size() == 2); std::string const txHash = jvParams[0u].asString(); if (txHash.length() != 64) diff --git a/src/xrpld/nodestore/Database.h b/src/xrpld/nodestore/Database.h index aeb0792ec8d..d328520671f 100644 --- a/src/xrpld/nodestore/Database.h +++ b/src/xrpld/nodestore/Database.h @@ -256,7 +256,9 @@ class Database [[nodiscard]] std::uint32_t firstLedgerSeq(std::uint32_t shardIndex) const noexcept { - XRPL_ASSERT(shardIndex >= earliestShardIndex_); + XRPL_ASSERT( + "ripple::NodeStore::Database::firstLedgerSeq : minimum input", + shardIndex >= earliestShardIndex_); if (shardIndex <= earliestShardIndex_) return earliestLedgerSeq_; return 1 + (shardIndex * ledgersPerShard_); @@ -270,7 +272,9 @@ class Database [[nodiscard]] std::uint32_t lastLedgerSeq(std::uint32_t shardIndex) const noexcept { - XRPL_ASSERT(shardIndex >= earliestShardIndex_); + XRPL_ASSERT( + "ripple::NodeStore::Database::lastLedgerSeq : minimum input", + shardIndex >= earliestShardIndex_); return (shardIndex + 1) * ledgersPerShard_; } @@ -282,7 +286,9 @@ class Database [[nodiscard]] std::uint32_t seqToShardIndex(std::uint32_t ledgerSeq) const noexcept { - XRPL_ASSERT(ledgerSeq >= earliestLedgerSeq_); + XRPL_ASSERT( + "ripple::NodeStore::Database::seqToShardIndex : minimum input", + ledgerSeq >= earliestLedgerSeq_); return (ledgerSeq - 1) / ledgersPerShard_; } @@ -332,7 +338,9 @@ class Database void storeStats(std::uint64_t count, std::uint64_t sz) { - XRPL_ASSERT(count <= sz); + XRPL_ASSERT( + "ripple::NodeStore::Database::storeStats : valid inputs", + count <= sz); storeCount_ += count; storeSz_ += sz; } diff --git a/src/xrpld/nodestore/backend/CassandraFactory.cpp b/src/xrpld/nodestore/backend/CassandraFactory.cpp index 14edf7cf09d..58647b6a3c0 100644 --- a/src/xrpld/nodestore/backend/CassandraFactory.cpp +++ b/src/xrpld/nodestore/backend/CassandraFactory.cpp @@ -164,7 +164,9 @@ class CassandraBackend : public Backend { if (open_) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::CassandraBackend::open : database is " + "already open"); JLOG(j_.error()) << "database is already open"; return; } @@ -342,7 +344,9 @@ class CassandraBackend : public Backend { std::this_thread::sleep_for(std::chrono::seconds(1)); session_.reset(cass_session_new()); - XRPL_ASSERT(session_); + XRPL_ASSERT( + "ripple::NodeStore::CassandraBackend::open : non-null session", + session_); fut = cass_session_connect_keyspace( session_.get(), cluster, keyspace.c_str()); @@ -625,7 +629,10 @@ class CassandraBackend : public Backend numHashes)); read(*cbs[i]); } - XRPL_ASSERT(results.size() == cbs.size()); + XRPL_ASSERT( + "ripple::NodeStore::CassandraBackend::fetchBatch : results size do " + "match", + results.size() == cbs.size()); std::unique_lock lck(mtx); cv.wait(lck, [&numFinished, &numHashes]() { @@ -789,7 +796,8 @@ class CassandraBackend : public Backend void for_each(std::function)> f) override { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::CassandraBackend::for_each : not implemented"); Throw("not implemented"); } diff --git a/src/xrpld/nodestore/backend/MemoryFactory.cpp b/src/xrpld/nodestore/backend/MemoryFactory.cpp index 8f65c367746..ca9aead398f 100644 --- a/src/xrpld/nodestore/backend/MemoryFactory.cpp +++ b/src/xrpld/nodestore/backend/MemoryFactory.cpp @@ -131,7 +131,8 @@ class MemoryBackend : public Backend Status fetch(void const* key, std::shared_ptr* pObject) override { - XRPL_ASSERT(db_); + XRPL_ASSERT( + "ripple::NodeStore::MemoryBackend::fetch : non-null database", db_); uint256 const hash(uint256::fromVoid(key)); std::lock_guard _(db_->mutex); @@ -167,7 +168,8 @@ class MemoryBackend : public Backend void store(std::shared_ptr const& object) override { - XRPL_ASSERT(db_); + XRPL_ASSERT( + "ripple::NodeStore::MemoryBackend::store : non-null database", db_); std::lock_guard _(db_->mutex); db_->table.emplace(object->getHash(), object); } @@ -187,7 +189,9 @@ class MemoryBackend : public Backend void for_each(std::function)> f) override { - XRPL_ASSERT(db_); + XRPL_ASSERT( + "ripple::NodeStore::MemoryBackend::for_each : non-null database", + db_); for (auto const& e : db_->table) f(e.second); } diff --git a/src/xrpld/nodestore/backend/NuDBFactory.cpp b/src/xrpld/nodestore/backend/NuDBFactory.cpp index 3069a955bc6..6068f029f8b 100644 --- a/src/xrpld/nodestore/backend/NuDBFactory.cpp +++ b/src/xrpld/nodestore/backend/NuDBFactory.cpp @@ -117,7 +117,9 @@ class NuDBBackend : public Backend using namespace boost::filesystem; if (db_.is_open()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::NuDBBackend::open : database is already " + "open"); JLOG(j_.error()) << "database is already open"; return; } diff --git a/src/xrpld/nodestore/backend/RocksDBFactory.cpp b/src/xrpld/nodestore/backend/RocksDBFactory.cpp index 9ad59057d09..67d9eb29ad7 100644 --- a/src/xrpld/nodestore/backend/RocksDBFactory.cpp +++ b/src/xrpld/nodestore/backend/RocksDBFactory.cpp @@ -228,7 +228,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback { if (m_db) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::RocksDBBackend::open : database is already " + "open"); JLOG(m_journal.error()) << "database is already open"; return; } @@ -273,7 +275,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback Status fetch(void const* key, std::shared_ptr* pObject) override { - XRPL_ASSERT(m_db); + XRPL_ASSERT( + "ripple::NodeStore::RocksDBBackend::fetch : non-null database", + m_db); pObject->reset(); Status status(ok); @@ -349,7 +353,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void storeBatch(Batch const& batch) override { - XRPL_ASSERT(m_db); + XRPL_ASSERT( + "ripple::NodeStore::RocksDBBackend::storeBatch : non-null database", + m_db); rocksdb::WriteBatch wb; for (auto const& e : batch) @@ -381,7 +387,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void for_each(std::function)> f) override { - XRPL_ASSERT(m_db); + XRPL_ASSERT( + "ripple::NodeStore::RocksDBBackend::for_each : non-null database", + m_db); rocksdb::ReadOptions const options; std::unique_ptr it(m_db->NewIterator(options)); diff --git a/src/xrpld/nodestore/detail/BatchWriter.cpp b/src/xrpld/nodestore/detail/BatchWriter.cpp index 34147e18648..7f467dcf3ba 100644 --- a/src/xrpld/nodestore/detail/BatchWriter.cpp +++ b/src/xrpld/nodestore/detail/BatchWriter.cpp @@ -83,7 +83,9 @@ BatchWriter::writeBatch() std::lock_guard sl(mWriteMutex); mWriteSet.swap(set); - XRPL_ASSERT(mWriteSet.empty()); + XRPL_ASSERT( + "ripple::NodeStore::BatchWriter::writeBatch : writes not set", + mWriteSet.empty()); mWriteLoad = set.size(); if (set.empty()) diff --git a/src/xrpld/nodestore/detail/Database.cpp b/src/xrpld/nodestore/detail/Database.cpp index e5933011d1a..1886c5afda0 100644 --- a/src/xrpld/nodestore/detail/Database.cpp +++ b/src/xrpld/nodestore/detail/Database.cpp @@ -46,7 +46,9 @@ Database::Database( , requestBundle_(get(config, "rq_bundle", 4)) , readThreads_(std::max(1, readThreads)) { - XRPL_ASSERT(readThreads != 0); + XRPL_ASSERT( + "ripple::NodeStore::Database::Database : nonzero threads input", + readThreads != 0); if (ledgersPerShard_ == 0 || ledgersPerShard_ % 256 != 0) Throw("Invalid ledgers_per_shard"); @@ -96,7 +98,10 @@ Database::Database( for (auto it = read.begin(); it != read.end(); ++it) { - XRPL_ASSERT(!it->second.empty()); + XRPL_ASSERT( + "ripple::NodeStore::Database::Database : non-empty " + "data", + !it->second.empty()); auto const& hash = it->first; auto const& data = it->second; @@ -157,7 +162,8 @@ Database::maxLedgers(std::uint32_t shardIndex) const noexcept if (shardIndex == earliestShardIndex_) return lastLedgerSeq(shardIndex) - firstLedgerSeq(shardIndex) + 1; - XRPL_ASSERT(!"Invalid shard index"); + XRPL_UNREACHABLE( + "ripple::NodeStore::Database::maxLedgers : invalid shard index"); return 0; } @@ -183,7 +189,9 @@ Database::stop() while (readThreads_.load() != 0) { - XRPL_ASSERT(steady_clock::now() - start < 30s); + XRPL_ASSERT( + "ripple::NodeStore::Database::stop : maximum stop duration", + steady_clock::now() - start < 30s); std::this_thread::yield(); } @@ -234,7 +242,9 @@ Database::importInternal(Backend& dstBackend, Database& srcDB) }; srcDB.for_each([&](std::shared_ptr nodeObject) { - XRPL_ASSERT(nodeObject); + XRPL_ASSERT( + "ripple::NodeStore::Database::importInternal : non-null node", + nodeObject); if (!nodeObject) // This should never happen return; @@ -377,7 +387,9 @@ Database::storeLedger( void Database::getCountsJson(Json::Value& obj) { - XRPL_ASSERT(obj.isObject()); + XRPL_ASSERT( + "ripple::NodeStore::Database::getCountsJson : valid input type", + obj.isObject()); { std::unique_lock lock(readLock_); diff --git a/src/xrpld/nodestore/detail/DatabaseNodeImp.h b/src/xrpld/nodestore/detail/DatabaseNodeImp.h index 3b7152b1373..9434b0c9654 100644 --- a/src/xrpld/nodestore/detail/DatabaseNodeImp.h +++ b/src/xrpld/nodestore/detail/DatabaseNodeImp.h @@ -76,7 +76,10 @@ class DatabaseNodeImp : public Database j); } - XRPL_ASSERT(backend_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseNodeImp::DatabaseNodeImp : non-null " + "backend", + backend_); } ~DatabaseNodeImp() diff --git a/src/xrpld/nodestore/detail/DatabaseShardImp.cpp b/src/xrpld/nodestore/detail/DatabaseShardImp.cpp index c6248028b4a..57ee4d8452d 100644 --- a/src/xrpld/nodestore/detail/DatabaseShardImp.cpp +++ b/src/xrpld/nodestore/detail/DatabaseShardImp.cpp @@ -233,7 +233,10 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::prepareLedger : is " + "initialized", + init_); if (acquireIndex_ != 0) { @@ -241,7 +244,9 @@ DatabaseShardImp::prepareLedger(std::uint32_t validLedgerSeq) return it->second->prepare(); // Should never get here - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::DatabaseShardImp::prepareLedger : invalid " + "index"); return std::nullopt; } @@ -325,7 +330,9 @@ DatabaseShardImp::prepareShards(std::vector const& shardIndexes) return fail("invalid shard indexes"); std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::prepareShards : is initialized", + init_); if (!canAdd_) return fail("cannot be stored at this time"); @@ -417,7 +424,9 @@ void DatabaseShardImp::removePreShard(std::uint32_t shardIndex) { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::removePreShard : is initialized", + init_); if (preparedIndexes_.erase(shardIndex)) updatePeers(lock); @@ -429,7 +438,10 @@ DatabaseShardImp::getPreShards() RangeSet rs; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::getPreShards : is " + "initialized", + init_); for (auto const& shardIndex : preparedIndexes_) rs.insert(shardIndex); @@ -557,7 +569,10 @@ DatabaseShardImp::fetchLedger(uint256 const& hash, std::uint32_t ledgerSeq) std::shared_ptr shard; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::fetchLedger : is " + "initialized", + init_); auto const it{shards_.find(shardIndex)}; if (it == shards_.end()) @@ -661,7 +676,9 @@ DatabaseShardImp::setStored(std::shared_ptr const& ledger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::setStored : is initialized", + init_); if (shardIndex != acquireIndex_) { @@ -766,14 +783,20 @@ void DatabaseShardImp::importDatabase(Database& source) { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::importDatabase : is initialized", + init_); // Only the application local node store can be imported - XRPL_ASSERT(&source == &app_.getNodeStore()); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::importDatabase : valid input", + &source == &app_.getNodeStore()); if (databaseImporter_.joinable()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::DatabaseShardImp::importDatabase : database " + "import already in progress"); JLOG(j_.error()) << "database import already in progress"; return; } @@ -865,7 +888,10 @@ DatabaseShardImp::doImportDatabase() { std::lock_guard lock(mutex_); - XRPL_ASSERT(!databaseImportStatus_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::doImportDatabase : non-null " + "import status", + !databaseImportStatus_); databaseImportStatus_ = std::make_unique( earliestIndex, latestIndex, 0); } @@ -1088,7 +1114,10 @@ DatabaseShardImp::getWriteLoad() const std::shared_ptr shard; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::getWriteLoad : is " + "initialized", + init_); auto const it{shards_.find(acquireIndex_)}; if (it == shards_.end()) @@ -1141,7 +1170,9 @@ DatabaseShardImp::storeLedger(std::shared_ptr const& srcLedger) std::shared_ptr shard; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::storeLedger : is initialized", + init_); if (shardIndex != acquireIndex_) { @@ -1174,7 +1205,9 @@ DatabaseShardImp::sweep() std::vector> shards; { std::lock_guard lock(mutex_); - XRPL_ASSERT(init_); + XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::sweep : is initialized", + init_); shards.reserve(shards_.size()); for (auto const& e : shards_) @@ -1460,7 +1493,9 @@ DatabaseShardImp::findAcquireIndex( } } - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::NodeStore::DatabaseShardImp::findAcquireIndex : no index " + "available"); return std::nullopt; } @@ -1516,6 +1551,8 @@ DatabaseShardImp::finalizeShard( { // Not a historical shard. Shift recent shards if necessary XRPL_ASSERT( + "ripple::NodeStore::DatabaseShardImp::finalizeShard : " + "valid shard index", !boundaryIndex || shard->index() - boundaryIndex <= 1); relocateOutdatedShards(lock); diff --git a/src/xrpld/nodestore/detail/DecodedBlob.cpp b/src/xrpld/nodestore/detail/DecodedBlob.cpp index 8afc1bafe09..24a24b6a771 100644 --- a/src/xrpld/nodestore/detail/DecodedBlob.cpp +++ b/src/xrpld/nodestore/detail/DecodedBlob.cpp @@ -72,7 +72,9 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) std::shared_ptr DecodedBlob::createObject() { - XRPL_ASSERT(m_success); + XRPL_ASSERT( + "ripple::NodeStore::DecodedBlob::createObject : valid object type", + m_success); std::shared_ptr object; diff --git a/src/xrpld/nodestore/detail/EncodedBlob.h b/src/xrpld/nodestore/detail/EncodedBlob.h index 80480f219ef..270fb23de86 100644 --- a/src/xrpld/nodestore/detail/EncodedBlob.h +++ b/src/xrpld/nodestore/detail/EncodedBlob.h @@ -80,7 +80,9 @@ class EncodedBlob public: explicit EncodedBlob(std::shared_ptr const& obj) : size_([&obj]() { - XRPL_ASSERT(obj); + XRPL_ASSERT( + "ripple::NodeStore::EncodedBlob::EncodedBlob : non-null input", + obj); if (!obj) throw std::runtime_error( @@ -101,8 +103,10 @@ class EncodedBlob ~EncodedBlob() { XRPL_ASSERT( + "ripple::NodeStore::EncodedBlob::~EncodedBlob : valid payload " + "pointer", ((ptr_ == payload_.data()) && (size_ <= payload_.size())) || - ((ptr_ != payload_.data()) && (size_ > payload_.size()))); + ((ptr_ != payload_.data()) && (size_ > payload_.size()))); if (ptr_ != payload_.data()) delete[] ptr_; diff --git a/src/xrpld/nodestore/detail/ManagerImp.cpp b/src/xrpld/nodestore/detail/ManagerImp.cpp index a524f4ecca2..70436f26ade 100644 --- a/src/xrpld/nodestore/detail/ManagerImp.cpp +++ b/src/xrpld/nodestore/detail/ManagerImp.cpp @@ -97,7 +97,9 @@ ManagerImp::erase(Factory& factory) std::find_if(list_.begin(), list_.end(), [&factory](Factory* other) { return other == &factory; }); - XRPL_ASSERT(iter != list_.end()); + XRPL_ASSERT( + "ripple::NodeStore::ManagerImp::erase : valid input", + iter != list_.end()); list_.erase(iter); } diff --git a/src/xrpld/nodestore/detail/Shard.cpp b/src/xrpld/nodestore/detail/Shard.cpp index 192a6912887..43369e5e525 100644 --- a/src/xrpld/nodestore/detail/Shard.cpp +++ b/src/xrpld/nodestore/detail/Shard.cpp @@ -712,9 +712,11 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) return fail("failed storing to SQLite databases"); XRPL_ASSERT( + "ripple::NodeStore::Shard::finalize : matching ledger and valid " + "ledger fees", ledger->info().seq == ledgerSeq && - (ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees()))); + (ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || + ledger->read(keylet::fees()))); hash = ledger->info().parentHash; next = std::move(ledger); @@ -813,7 +815,9 @@ Shard::finalize(bool writeSQLite, std::optional const& referenceHash) if (!open(lock)) return fail("failed to open"); - XRPL_ASSERT(state_ == ShardState::finalized); + XRPL_ASSERT( + "ripple::NodeStore::Shard::finalize : valid shard state", + state_ == ShardState::finalized); // Allow all other threads work with the shard busy_ = false; diff --git a/src/xrpld/nodestore/detail/TaskQueue.cpp b/src/xrpld/nodestore/detail/TaskQueue.cpp index 0fdd7d8500e..b4e08837d46 100644 --- a/src/xrpld/nodestore/detail/TaskQueue.cpp +++ b/src/xrpld/nodestore/detail/TaskQueue.cpp @@ -57,7 +57,9 @@ TaskQueue::processTask(int instance) { std::lock_guard lock{mutex_}; - XRPL_ASSERT(!tasks_.empty()); + XRPL_ASSERT( + "ripple::NodeStore::TaskQueue::processTask : non-empty tasks", + !tasks_.empty()); task = std::move(tasks_.front()); tasks_.pop(); diff --git a/src/xrpld/overlay/Compression.h b/src/xrpld/overlay/Compression.h index e795029323c..7ec0821f0ef 100644 --- a/src/xrpld/overlay/Compression.h +++ b/src/xrpld/overlay/Compression.h @@ -64,7 +64,9 @@ decompress( JLOG(debugLog().warn()) << "decompress: invalid compression algorithm " << static_cast(algorithm); - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::compression::decompress : invalid compression " + "algorithm"); } } catch (...) @@ -99,7 +101,9 @@ compress( { JLOG(debugLog().warn()) << "compress: invalid compression algorithm" << static_cast(algorithm); - XRPL_ASSERT(0); + XRPL_UNREACHABLE( + "ripple::compression::compress : invalid compression " + "algorithm"); } } catch (...) diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 142ec2d4ee2..41f0ef94c50 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -362,7 +362,9 @@ Slot::update( << consideredPoolSize << " selected " << *s << " " << *std::next(s, 1) << " " << *std::next(s, 2); - XRPL_ASSERT(peers_.size() >= MAX_SELECTED_PEERS); + XRPL_ASSERT( + "ripple::reduce_relay::Slot::update : minimum peers", + peers_.size() >= MAX_SELECTED_PEERS); // squelch peers which are not selected and // not already squelched diff --git a/src/xrpld/overlay/detail/ConnectAttempt.cpp b/src/xrpld/overlay/detail/ConnectAttempt.cpp index ac6d1d44c81..48ce321b06f 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.cpp +++ b/src/xrpld/overlay/detail/ConnectAttempt.cpp @@ -90,7 +90,9 @@ ConnectAttempt::run() void ConnectAttempt::close() { - XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT( + "ripple::ConnectAttempt::close : strand in this thread", + strand_.running_in_this_thread()); if (socket_.is_open()) { error_code ec; diff --git a/src/xrpld/overlay/detail/Message.cpp b/src/xrpld/overlay/detail/Message.cpp index 07405fcdf64..777c4e2e857 100644 --- a/src/xrpld/overlay/detail/Message.cpp +++ b/src/xrpld/overlay/detail/Message.cpp @@ -34,7 +34,9 @@ Message::Message( auto const messageBytes = messageSize(message); - XRPL_ASSERT(messageBytes != 0); + XRPL_ASSERT( + "ripple::Message::Message : non-empty message input", + messageBytes != 0); buffer_.resize(headerBytes + messageBytes); @@ -43,7 +45,9 @@ Message::Message( if (messageBytes != 0) message.SerializeToArray(buffer_.data() + headerBytes, messageBytes); - XRPL_ASSERT(getBufferSize() == totalSize(message)); + XRPL_ASSERT( + "ripple::Message::Message : message size matches the buffer", + getBufferSize() == totalSize(message)); } // static diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 5e8056f960b..5a07015ac94 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -295,7 +295,9 @@ OverlayImpl::onHandoff( std::lock_guard lock(mutex_); { auto const result = m_peers.emplace(peer->slot(), peer); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::OverlayImpl::onHandoff : peer is inserted", + result.second); (void)result.second; } list_.emplace(peer.get(), peer); @@ -388,7 +390,7 @@ OverlayImpl::makeErrorResponse( void OverlayImpl::connect(beast::IP::Endpoint const& remote_endpoint) { - XRPL_ASSERT(work_); + XRPL_ASSERT("ripple::OverlayImpl::connect : work is set", work_); auto usage = resourceManager().newOutboundEndpoint(remote_endpoint); if (usage.disconnect(journal_)) @@ -430,7 +432,9 @@ OverlayImpl::add_active(std::shared_ptr const& peer) { auto const result = m_peers.emplace(peer->slot(), peer); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::OverlayImpl::add_active : peer is inserted", + result.second); (void)result.second; } @@ -439,7 +443,9 @@ OverlayImpl::add_active(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer)); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::OverlayImpl::add_active : peer ID is inserted", + result.second); (void)result.second; } @@ -462,7 +468,8 @@ OverlayImpl::remove(std::shared_ptr const& slot) { std::lock_guard lock(mutex_); auto const iter = m_peers.find(slot); - XRPL_ASSERT(iter != m_peers.end()); + XRPL_ASSERT( + "ripple::OverlayImpl::remove : valid input", iter != m_peers.end()); m_peers.erase(iter); } @@ -596,7 +603,9 @@ OverlayImpl::activate(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer))); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::OverlayImpl::activate : peer ID is inserted", + result.second); (void)result.second; } @@ -607,7 +616,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) << ")"; // We just accepted this peer so we have non-zero active peers - XRPL_ASSERT(size() != 0); + XRPL_ASSERT("ripple::OverlayImpl::activate : nonzero peers", size() != 0); } void @@ -646,7 +655,10 @@ OverlayImpl::onManifests( // the loaded Manifest out of the optional so we need to // reload it here. mo = deserializeManifest(serialized); - XRPL_ASSERT(mo); + XRPL_ASSERT( + "ripple::OverlayImpl::onManifests : manifest " + "deserialization succeeded", + mo); app_.getOPs().pubManifest(*mo); diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index 597d5117bc1..8cc4dc05573 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -616,7 +616,9 @@ class OverlayImpl : public Overlay, public reduce_relay::SquelchHandler { auto counts = m_traffic.getCounts(); std::lock_guard lock(m_statsMutex); - XRPL_ASSERT(counts.size() == m_stats.trafficGauges.size()); + XRPL_ASSERT( + "ripple::OverlayImpl::collect_metrics : counts size do match", + counts.size() == m_stats.trafficGauges.size()); for (std::size_t i = 0; i < counts.size(); ++i) { diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index c4844ff4544..dbc789f07e7 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -575,7 +575,9 @@ PeerImp::hasRange(std::uint32_t uMin, std::uint32_t uMax) void PeerImp::close() { - XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT( + "ripple::PeerImp::close : strand in this thread", + strand_.running_in_this_thread()); if (socket_.is_open()) { detaching_ = true; // DEPRECATED @@ -616,7 +618,9 @@ PeerImp::fail(std::string const& reason) void PeerImp::fail(std::string const& name, error_code ec) { - XRPL_ASSERT(strand_.running_in_this_thread()); + XRPL_ASSERT( + "ripple::PeerImp::fail : strand in this thread", + strand_.running_in_this_thread()); if (socket_.is_open()) { JLOG(journal_.warn()) @@ -636,9 +640,14 @@ PeerImp::getPeerShardInfos() const void PeerImp::gracefulClose() { - XRPL_ASSERT(strand_.running_in_this_thread()); - XRPL_ASSERT(socket_.is_open()); - XRPL_ASSERT(!gracefulClose_); + XRPL_ASSERT( + "ripple::PeerImp::gracefulClose : strand in this thread", + strand_.running_in_this_thread()); + XRPL_ASSERT( + "ripple::PeerImp::gracefulClose : socket is open", socket_.is_open()); + XRPL_ASSERT( + "ripple::PeerImp::gracefulClose : socket is not closing", + !gracefulClose_); gracefulClose_ = true; if (send_queue_.size() > 0) return; @@ -764,7 +773,9 @@ PeerImp::onShutdown(error_code ec) void PeerImp::doAccept() { - XRPL_ASSERT(read_buffer_.size() == 0); + XRPL_ASSERT( + "ripple::PeerImp::doAccept : empty read buffer", + read_buffer_.size() == 0); JLOG(journal_.debug()) << "doAccept: " << remote_address_; @@ -962,7 +973,9 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred) metrics_.sent.add_message(bytes_transferred); - XRPL_ASSERT(!send_queue_.empty()); + XRPL_ASSERT( + "ripple::PeerImp::onWriteMessage : non-empty send buffer", + !send_queue_.empty()); send_queue_.pop(); if (!send_queue_.empty()) { @@ -2319,13 +2332,18 @@ PeerImp::onValidatorListMessage( case ListDisposition::pending: { std::lock_guard sl(recentLock_); - XRPL_ASSERT(applyResult.publisherKey); + XRPL_ASSERT( + "ripple::PeerImp::onValidatorListMessage : publisher key is " + "set", + applyResult.publisherKey); auto const& pubKey = *applyResult.publisherKey; #ifndef NDEBUG if (auto const iter = publisherListSequences_.find(pubKey); iter != publisherListSequences_.end()) { - XRPL_ASSERT(iter->second < applyResult.sequence); + XRPL_ASSERT( + "ripple::PeerImp::onValidatorListMessage : lower sequence", + iter->second < applyResult.sequence); } #endif publisherListSequences_[pubKey] = applyResult.sequence; @@ -2336,10 +2354,14 @@ PeerImp::onValidatorListMessage( #ifndef NDEBUG { std::lock_guard sl(recentLock_); - XRPL_ASSERT(applyResult.sequence && applyResult.publisherKey); XRPL_ASSERT( + "ripple::PeerImp::onValidatorListMessage : nonzero sequence " + "and set publisher key", + applyResult.sequence && applyResult.publisherKey); + XRPL_ASSERT( + "ripple::PeerImp::onValidatorListMessage : maximum sequence", publisherListSequences_[*applyResult.publisherKey] <= - applyResult.sequence); + applyResult.sequence); } #endif // !NDEBUG @@ -2350,7 +2372,9 @@ PeerImp::onValidatorListMessage( case ListDisposition::unsupported_version: break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PeerImp::onValidatorListMessage : invalid best list " + "disposition"); } // Charge based on the worst result @@ -2389,7 +2413,9 @@ PeerImp::onValidatorListMessage( fee_ = Resource::feeBadData; break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PeerImp::onValidatorListMessage : invalid worst list " + "disposition"); } // Log based on all the results. @@ -2447,7 +2473,9 @@ PeerImp::onValidatorListMessage( << "(s) from peer " << remote_address_; break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PeerImp::onValidatorListMessage : invalid list " + "disposition"); } } } @@ -3130,7 +3158,7 @@ PeerImp::checkPropose( JLOG(p_journal_.trace()) << "Checking " << (isTrusted ? "trusted" : "UNTRUSTED") << " proposal"; - XRPL_ASSERT(packet); + XRPL_ASSERT("ripple::PeerImp::checkPropose : non-null packet", packet); if (!cluster() && !peerPos.checkSign()) { diff --git a/src/xrpld/overlay/detail/ProtocolMessage.h b/src/xrpld/overlay/detail/ProtocolMessage.h index 79bc2ae4926..ea2dfe5301c 100644 --- a/src/xrpld/overlay/detail/ProtocolMessage.h +++ b/src/xrpld/overlay/detail/ProtocolMessage.h @@ -183,7 +183,9 @@ parseMessageHeader( MessageHeader hdr; auto iter = buffersBegin(bufs); - XRPL_ASSERT(iter != buffersEnd(bufs)); + XRPL_ASSERT( + "ripple::detail::parseMessageHeader : non-empty buffer", + iter != buffersEnd(bufs)); // Check valid header compressed message: // - 4 bits are the compression algorithm, 1st bit is always set to 1 diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index babd4db82cc..8e9f622e3aa 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -173,7 +173,9 @@ class TrafficCount void addCount(category cat, bool inbound, int bytes) { - XRPL_ASSERT(cat <= category::unknown); + XRPL_ASSERT( + "ripple::TrafficCount::addCount : valid category input", + cat <= category::unknown); if (inbound) { diff --git a/src/xrpld/overlay/detail/ZeroCopyStream.h b/src/xrpld/overlay/detail/ZeroCopyStream.h index 40a37b5845f..54bc267e42e 100644 --- a/src/xrpld/overlay/detail/ZeroCopyStream.h +++ b/src/xrpld/overlay/detail/ZeroCopyStream.h @@ -20,6 +20,8 @@ #ifndef RIPPLE_OVERLAY_ZEROCOPYSTREAM_H_INCLUDED #define RIPPLE_OVERLAY_ZEROCOPYSTREAM_H_INCLUDED +#include + #include #include #include @@ -204,7 +206,8 @@ template void ZeroCopyOutputStream::BackUp(int count) { - XRPL_ASSERT(count <= commit_); + XRPL_ASSERT( + "ripple::ZeroCopyOutputStream::BackUp : valid input", count <= commit_); auto const n = commit_ - count; streambuf_.commit(n); count_ += n; diff --git a/src/xrpld/peerfinder/detail/Bootcache.cpp b/src/xrpld/peerfinder/detail/Bootcache.cpp index 3f053f049eb..d6aa6ad1834 100644 --- a/src/xrpld/peerfinder/detail/Bootcache.cpp +++ b/src/xrpld/peerfinder/detail/Bootcache.cpp @@ -159,7 +159,9 @@ Bootcache::on_success(beast::IP::Endpoint const& endpoint) ++entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple:PeerFinder::Bootcache::on_success : endpoint inserted", + result.second); } Entry const& entry(result.first->right); JLOG(m_journal.info()) << beast::leftw(18) << "Bootcache connect " @@ -185,7 +187,9 @@ Bootcache::on_failure(beast::IP::Endpoint const& endpoint) --entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple:PeerFinder::Bootcache::on_failure : endpoint inserted", + result.second); } Entry const& entry(result.first->right); auto const n(std::abs(entry.valence())); diff --git a/src/xrpld/peerfinder/detail/Counts.h b/src/xrpld/peerfinder/detail/Counts.h index 4d7bca15a06..bf619c5193d 100644 --- a/src/xrpld/peerfinder/detail/Counts.h +++ b/src/xrpld/peerfinder/detail/Counts.h @@ -71,7 +71,9 @@ class Counts can_activate(Slot const& s) const { // Must be handshaked and in the right state - XRPL_ASSERT(s.state() == Slot::connected || s.state() == Slot::accept); + XRPL_ASSERT( + "ripple::PeerFinder::Counts::can_activate : valid input state", + s.state() == Slot::connected || s.state() == Slot::accept); if (s.fixed() || s.reserved()) return true; @@ -262,13 +264,17 @@ class Counts switch (s.state()) { case Slot::accept: - XRPL_ASSERT(s.inbound()); + XRPL_ASSERT( + "ripple::PeerFinder::Counts::adjust : input is inbound", + s.inbound()); m_acceptCount += n; break; case Slot::connect: case Slot::connected: - XRPL_ASSERT(!s.inbound()); + XRPL_ASSERT( + "ripple::PeerFinder::Counts::adjust : input is not inbound", + !s.inbound()); m_attempts += n; break; @@ -290,7 +296,8 @@ class Counts break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PeerFinder::Counts::adjust : invalid input state"); break; }; } diff --git a/src/xrpld/peerfinder/detail/Handouts.h b/src/xrpld/peerfinder/detail/Handouts.h index f40aeb9fe23..bb8b5bb8dc5 100644 --- a/src/xrpld/peerfinder/detail/Handouts.h +++ b/src/xrpld/peerfinder/detail/Handouts.h @@ -43,7 +43,9 @@ template std::size_t handout_one(Target& t, HopContainer& h) { - XRPL_ASSERT(!t.full()); + XRPL_ASSERT( + "ripple::PeerFinder::detail::handout_one : target is not full", + !t.full()); for (auto it = h.begin(); it != h.end(); ++it) { auto const& e = *it; diff --git a/src/xrpld/peerfinder/detail/Livecache.h b/src/xrpld/peerfinder/detail/Livecache.h index b30c87f5f05..c4dd163c34c 100644 --- a/src/xrpld/peerfinder/detail/Livecache.h +++ b/src/xrpld/peerfinder/detail/Livecache.h @@ -432,7 +432,9 @@ Livecache::insert(Endpoint const& ep) // but we will use it to make connections and hand it out // when redirecting. // - XRPL_ASSERT(ep.hops <= (Tuning::maxHops + 1)); + XRPL_ASSERT( + "ripple::PeerFinder::Livecache::insert : maximum input hops", + ep.hops <= (Tuning::maxHops + 1)); auto result = m_cache.emplace(ep.address, ep); Element& e(result.first->second); if (result.second) @@ -530,7 +532,9 @@ template void Livecache::hops_t::insert(Element& e) { - XRPL_ASSERT(e.endpoint.hops <= Tuning::maxHops + 1); + XRPL_ASSERT( + "ripple::PeerFinder::Livecache::hops_t::insert : maximum input hops", + e.endpoint.hops <= Tuning::maxHops + 1); // This has security implications without a shuffle m_lists[e.endpoint.hops].push_front(e); ++m_hist[e.endpoint.hops]; @@ -540,7 +544,9 @@ template void Livecache::hops_t::reinsert(Element& e, std::uint32_t numHops) { - XRPL_ASSERT(numHops <= Tuning::maxHops + 1); + XRPL_ASSERT( + "ripple::PeerFinder::Livecache::hops_t::reinsert : maximum hops input", + numHops <= Tuning::maxHops + 1); auto& list = m_lists[e.endpoint.hops]; list.erase(list.iterator_to(e)); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index d232f649c72..5a8444a20f9 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -305,7 +305,10 @@ class Logic // Add slot to table auto const result(slots_.emplace(slot->remote_endpoint(), slot)); // Remote address must not already exist - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::new_inbound_slot : remote endpoint " + "inserted", + result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -340,7 +343,10 @@ class Logic // Add slot to table auto const result = slots_.emplace(slot->remote_endpoint(), slot); // Remote address must not already exist - XRPL_ASSERT(result.second); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::new_outbound_slot : remote endpoint " + "inserted", + result.second); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -363,7 +369,9 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::onConnected : valid slot input", + slots_.find(slot->remote_endpoint()) != slots_.end()); // Assign the local endpoint now that it's known slot->local_endpoint(local_endpoint); @@ -373,6 +381,8 @@ class Logic if (iter != slots_.end()) { XRPL_ASSERT( + "ripple::PeerFinder::Logic::onConnected : local and remote " + "endpoints do match", iter->second->local_endpoint() == slot->remote_endpoint()); JLOG(m_journal.warn()) << beast::leftw(18) << "Logic dropping " @@ -398,9 +408,12 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::activate : valid slot input", + slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be accepted or connected XRPL_ASSERT( + "ripple::PeerFinder::Logic::activate : valid slot state", slot->state() == Slot::accept || slot->state() == Slot::connected); // Check for duplicate connection by key @@ -427,7 +440,9 @@ class Logic { [[maybe_unused]] bool const inserted = keys_.insert(key).second; // Public key must not already exist - XRPL_ASSERT(inserted); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::activate : public key inserted", + inserted); } // Change state and update counts @@ -789,10 +804,14 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT(slots_.find(slot->remote_endpoint()) != slots_.end()); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::on_endpoints : valid slot input", + slots_.find(slot->remote_endpoint()) != slots_.end()); // Must be handshaked! - XRPL_ASSERT(slot->state() == Slot::active); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::on_endpoints : valid slot state", + slot->state() == Slot::active); clock_type::time_point const now(m_clock.now()); @@ -804,7 +823,9 @@ class Logic for (auto const& ep : list) { - XRPL_ASSERT(ep.hops != 0); + XRPL_ASSERT( + "ripple::PeerFinder::Logic::on_endpoints : nonzero hops", + ep.hops != 0); slot->recent.insert(ep.address, ep.hops); @@ -957,7 +978,9 @@ class Logic break; default: - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::PeerFinder::Logic::on_closed : invalid slot " + "state"); break; } } diff --git a/src/xrpld/peerfinder/detail/SlotImp.cpp b/src/xrpld/peerfinder/detail/SlotImp.cpp index c24cae774cc..d0a6ebf740b 100644 --- a/src/xrpld/peerfinder/detail/SlotImp.cpp +++ b/src/xrpld/peerfinder/detail/SlotImp.cpp @@ -64,19 +64,32 @@ void SlotImp::state(State state_) { // Must go through activate() to set active state - XRPL_ASSERT(state_ != active); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::state : input state is not active", + state_ != active); // The state must be different - XRPL_ASSERT(state_ != m_state); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::state : input state is different from " + "current", + state_ != m_state); // You can't transition into the initial states - XRPL_ASSERT(state_ != accept && state_ != connect); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::state : input state is not an initial", + state_ != accept && state_ != connect); // Can only become connected from outbound connect state - XRPL_ASSERT(state_ != connected || (!m_inbound && m_state == connect)); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::state : input state is not connected an " + "invalid state", + state_ != connected || (!m_inbound && m_state == connect)); // Can't gracefully close on an outbound connection attempt - XRPL_ASSERT(state_ != closing || m_state != connect); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::state : input state is not closing an " + "invalid state", + state_ != closing || m_state != connect); m_state = state_; } @@ -85,7 +98,9 @@ void SlotImp::activate(clock_type::time_point const& now) { // Can only become active from the accept or connected state - XRPL_ASSERT(m_state == accept || m_state == connected); + XRPL_ASSERT( + "ripple::PeerFinder::SlotImp::activate : valid state", + m_state == accept || m_state == connected); m_state = active; whenAcceptEndpoints = now; diff --git a/src/xrpld/perflog/detail/PerfLogImp.cpp b/src/xrpld/perflog/detail/PerfLogImp.cpp index 003fb8f5a39..7ce06369678 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.cpp +++ b/src/xrpld/perflog/detail/PerfLogImp.cpp @@ -55,7 +55,9 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::Counters::Counters : failed to " + "insert label"); } } } @@ -68,7 +70,9 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::Counters::Counters : failed to " + "insert job type"); } } } @@ -330,7 +334,8 @@ PerfLogImp::rpcStart(std::string const& method, std::uint64_t const requestId) auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::rpcStart : valid method input"); return; } @@ -352,7 +357,8 @@ PerfLogImp::rpcEnd( auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::rpcEnd : valid method input"); return; } steady_time_point startTime; @@ -366,7 +372,8 @@ PerfLogImp::rpcEnd( } else { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::rpcEnd : valid requestId input"); } } std::lock_guard lock(counter->second.mutex); @@ -384,7 +391,8 @@ PerfLogImp::jobQueue(JobType const type) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::jobQueue : valid job type input"); return; } std::lock_guard lock(counter->second.mutex); @@ -401,7 +409,8 @@ PerfLogImp::jobStart( auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::jobStart : valid job type input"); return; } { @@ -420,7 +429,8 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, int instance) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::perf::PerfLogImp::jobFinish : valid job type input"); return; } { diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index 87adebf8ee6..c5b157940b5 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -95,7 +95,8 @@ struct Status : public std::exception TER toTER() const { - XRPL_ASSERT(type_ == Type::TER); + XRPL_ASSERT( + "ripple::RPC::Status::toTER : type is TER", type_ == Type::TER); return TER::fromInt(code_); } @@ -104,7 +105,9 @@ struct Status : public std::exception error_code_i toErrorCode() const { - XRPL_ASSERT(type_ == Type::error_code_i); + XRPL_ASSERT( + "ripple::RPC::Status::toTER : type is error code", + type_ == Type::error_code_i); return error_code_i(code_); } diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index b22333cc6e4..4c20de519f4 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -38,7 +38,7 @@ byRef(Function const& f) result = f(context); if (result.type() != Json::objectValue) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::RPC::byRef : result is object"); result = RPC::makeObjectValue(result); } @@ -51,8 +51,9 @@ Status handle(JsonContext& context, Object& object) { XRPL_ASSERT( + "ripple::RPC::handle : valid API version", context.apiVersion >= HandlerImpl::minApiVer && - context.apiVersion <= HandlerImpl::maxApiVer); + context.apiVersion <= HandlerImpl::maxApiVer); HandlerImpl handler(context); auto status = handler.check(); @@ -211,8 +212,12 @@ class HandlerTable unsigned minVer, unsigned maxVer) { - XRPL_ASSERT(minVer <= maxVer); - XRPL_ASSERT(maxVer <= RPC::apiMaximumValidVersion); + XRPL_ASSERT( + "ripple::RPC::HandlerTable : valid API version range", + minVer <= maxVer); + XRPL_ASSERT( + "ripple::RPC::HandlerTable : valid max API version", + maxVer <= RPC::apiMaximumValidVersion); return std::any_of( range.first, diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 9d021bda708..192d3c0d74a 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -540,7 +540,8 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return {rpcNOT_SYNCED, "notSynced"}; } - XRPL_ASSERT(!ledger->open()); + XRPL_ASSERT( + "ripple::RPC::getLedger : validated is not open", !ledger->open()); } else { @@ -551,7 +552,8 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) rpcLGR_NOT_FOUND, "Reporting does not track current ledger"}; ledger = context.ledgerMaster.getCurrentLedger(); - XRPL_ASSERT(ledger->open()); + XRPL_ASSERT( + "ripple::RPC::getLedger : current is open", ledger->open()); } else if (shortcut == LedgerShortcut::CLOSED) { @@ -559,7 +561,8 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return { rpcLGR_NOT_FOUND, "Reporting does not track closed ledger"}; ledger = context.ledgerMaster.getClosedLedger(); - XRPL_ASSERT(!ledger->open()); + XRPL_ASSERT( + "ripple::RPC::getLedger : closed is not open", !ledger->open()); } else { @@ -965,7 +968,9 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{ rpcINVALID_PARAMS, "Invalid field 'type', not string."}; - XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT( + "ripple::RPC::chooseLedgerEntryType : first valid result type", + result.first.type() == RPC::Status::Type::error_code_i); return result; } @@ -978,7 +983,9 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{rpcINVALID_PARAMS, "Invalid field 'type'."}; - XRPL_ASSERT(result.first.type() == RPC::Status::Type::error_code_i); + XRPL_ASSERT( + "ripple::RPC::chooseLedgerEntryType : second valid result type", + result.first.type() == RPC::Status::Type::error_code_i); return result; } result.second = iter->second; @@ -1071,7 +1078,9 @@ getLedgerByContext(RPC::JsonContext& context) // ledger auto const refIndex = getCandidateLedger(ledgerIndex); auto refHash = hashOfSeq(*ledger, refIndex, j); - XRPL_ASSERT(refHash); + XRPL_ASSERT( + "ripple::RPC::getLedgerByContext : nonzero ledger hash", + refHash); ledger = ledgerMaster.getLedgerByHash(*refHash); if (!ledger) @@ -1105,7 +1114,9 @@ getLedgerByContext(RPC::JsonContext& context) neededHash = hashOfSeq(*ledger, ledgerIndex, j); } - XRPL_ASSERT(neededHash); + XRPL_ASSERT( + "ripple::RPC::getLedgerByContext : nonzero needed hash", + neededHash); ledgerHash = neededHash ? *neededHash : beast::zero; // kludge } diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index 379c9724878..60e6d9ed808 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -213,7 +213,9 @@ template void setVersion(Object& parent, unsigned int apiVersion, bool betaEnabled) { - XRPL_ASSERT(apiVersion != apiInvalidVersion); + XRPL_ASSERT( + "ripple::RPC::setVersion : input is valid", + apiVersion != apiInvalidVersion); auto&& object = addObject(parent, jss::version); if (apiVersion == apiVersionIfUnspecified) { diff --git a/src/xrpld/rpc/detail/Role.cpp b/src/xrpld/rpc/detail/Role.cpp index 01240d0214b..e1d17fedb31 100644 --- a/src/xrpld/rpc/detail/Role.cpp +++ b/src/xrpld/rpc/detail/Role.cpp @@ -28,7 +28,9 @@ namespace ripple { bool passwordUnrequiredOrSentCorrect(Port const& port, Json::Value const& params) { - XRPL_ASSERT(!(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); + XRPL_ASSERT( + "ripple::passwordUnrequiredOrSentCorrect : non-empty admin nets", + !(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); bool const passwordRequired = (!port.admin_user.empty() || !port.admin_password.empty()); diff --git a/src/xrpld/rpc/detail/ShardArchiveHandler.cpp b/src/xrpld/rpc/detail/ShardArchiveHandler.cpp index 23f4f62cb4e..bab25064665 100644 --- a/src/xrpld/rpc/detail/ShardArchiveHandler.cpp +++ b/src/xrpld/rpc/detail/ShardArchiveHandler.cpp @@ -83,7 +83,10 @@ ShardArchiveHandler::ShardArchiveHandler(Application& app) app.config().section(ConfigSection::shardDatabase()), "shard_verification_max_attempts")) { - XRPL_ASSERT(app_.getShardStore()); + XRPL_ASSERT( + "ripple::RPC::ShardArchiveHandler::ShardArchiveHandler : non-null " + "shard store", + app_.getShardStore()); } bool @@ -136,8 +139,10 @@ ShardArchiveHandler::initFromDB(std::lock_guard const& lock) using namespace boost::filesystem; XRPL_ASSERT( + "ripple::RPC::ShardArchiveHandler::initFromDB : valid state DB " + "path", exists(downloadDir_ / stateDBName) && - is_regular_file(downloadDir_ / stateDBName)); + is_regular_file(downloadDir_ / stateDBName)); sqlDB_ = makeArchiveDB(downloadDir_, stateDBName); diff --git a/src/xrpld/rpc/detail/Status.cpp b/src/xrpld/rpc/detail/Status.cpp index 4b3aaf65cf4..c532923949a 100644 --- a/src/xrpld/rpc/detail/Status.cpp +++ b/src/xrpld/rpc/detail/Status.cpp @@ -37,7 +37,7 @@ Status::codeString() const std::string s1, s2; auto success = transResultInfo(toTER(), s1, s2); - XRPL_ASSERT(success); + XRPL_ASSERT("ripple::RPC::codeString : valid TER result", success); (void)success; return s1 + ": " + s2; @@ -51,7 +51,7 @@ Status::codeString() const return sStr.str(); } - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::RPC::codeString : invalid type"); return ""; } diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 99903662820..5b82dd364fa 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -1034,7 +1034,9 @@ transactionSignFor( if (!preprocResult.second) return preprocResult.first; - XRPL_ASSERT(signForParams.validMultiSign()); + XRPL_ASSERT( + "ripple::RPC::transactionSignFor : valid multi-signature", + signForParams.validMultiSign()); { std::shared_ptr account_state = diff --git a/src/xrpld/rpc/handlers/AMMInfo.cpp b/src/xrpld/rpc/handlers/AMMInfo.cpp index 06563b23097..3ef0be85226 100644 --- a/src/xrpld/rpc/handlers/AMMInfo.cpp +++ b/src/xrpld/rpc/handlers/AMMInfo.cpp @@ -146,13 +146,14 @@ doAMMInfo(RPC::JsonContext& context) return Unexpected(rpcINVALID_PARAMS); XRPL_ASSERT( + "ripple::doAMMInfo : issue1 and issue2 do match", (issue1.has_value() == issue2.has_value()) && - (issue1.has_value() != ammID.has_value())); + (issue1.has_value() != ammID.has_value())); auto const ammKeylet = [&]() { if (issue1 && issue2) return keylet::amm(*issue1, *issue2); - XRPL_ASSERT(ammID); + XRPL_ASSERT("ripple::doAMMInfo::ammKeylet : ammID is set", ammID); return keylet::amm(*ammID); }(); auto const amm = ledger->read(ammKeylet); @@ -212,8 +213,9 @@ doAMMInfo(RPC::JsonContext& context) if (voteSlots.size() > 0) ammResult[jss::vote_slots] = std::move(voteSlots); XRPL_ASSERT( + "ripple::doAMMInfo : auction slot is set", !ledger->rules().enabled(fixInnerObjTemplate) || - amm->isFieldPresent(sfAuctionSlot)); + amm->isFieldPresent(sfAuctionSlot)); if (amm->isFieldPresent(sfAuctionSlot)) { auto const& auctionSlot = diff --git a/src/xrpld/rpc/handlers/AccountChannels.cpp b/src/xrpld/rpc/handlers/AccountChannels.cpp index 8a5b138047d..abff7c9114a 100644 --- a/src/xrpld/rpc/handlers/AccountChannels.cpp +++ b/src/xrpld/rpc/handlers/AccountChannels.cpp @@ -166,7 +166,7 @@ doAccountChannels(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doAccountChannels : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountInfo.cpp b/src/xrpld/rpc/handlers/AccountInfo.cpp index ba53e0d554c..3bda0e59056 100644 --- a/src/xrpld/rpc/handlers/AccountInfo.cpp +++ b/src/xrpld/rpc/handlers/AccountInfo.cpp @@ -205,7 +205,9 @@ doAccountInfo(RPC::JsonContext& context) if (tx.seqProxy.isSeq()) { - XRPL_ASSERT(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT( + "rpple::doAccountInfo : first sorted proxy", + prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::seq] = tx.seqProxy.value(); ++seqCount; @@ -215,7 +217,9 @@ doAccountInfo(RPC::JsonContext& context) } else { - XRPL_ASSERT(prevSeqProxy < tx.seqProxy); + XRPL_ASSERT( + "rpple::doAccountInfo : second sorted proxy", + prevSeqProxy < tx.seqProxy); prevSeqProxy = tx.seqProxy; jvTx[jss::ticket] = tx.seqProxy.value(); ++ticketCount; diff --git a/src/xrpld/rpc/handlers/AccountLines.cpp b/src/xrpld/rpc/handlers/AccountLines.cpp index e9cbe57e90e..98646efef69 100644 --- a/src/xrpld/rpc/handlers/AccountLines.cpp +++ b/src/xrpld/rpc/handlers/AccountLines.cpp @@ -186,7 +186,7 @@ doAccountLines(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doAccountLines : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountOffers.cpp b/src/xrpld/rpc/handlers/AccountOffers.cpp index 09d63e78c9b..c0421ccc7c2 100644 --- a/src/xrpld/rpc/handlers/AccountOffers.cpp +++ b/src/xrpld/rpc/handlers/AccountOffers.cpp @@ -142,7 +142,7 @@ doAccountOffers(RPC::JsonContext& context) std::shared_ptr const& sle) { if (!sle) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doAccountOffers : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/AccountTx.cpp index b426a3cbaa1..f9b8a33659b 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/AccountTx.cpp @@ -318,7 +318,9 @@ populateJsonResponse( if (auto txnsData = std::get_if(&result.transactions)) { - XRPL_ASSERT(!args.binary); + XRPL_ASSERT( + "ripple::populateJsonResponse : binary is not set", + !args.binary); for (auto const& [txn, txnMeta] : *txnsData) { @@ -363,13 +365,16 @@ populateJsonResponse( insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); } else - XRPL_ASSERT(false && "Missing transaction medatata"); + XRPL_UNREACHABLE( + "ripple::populateJsonResponse : missing " + "transaction medatata"); } } } else { - XRPL_ASSERT(args.binary); + XRPL_ASSERT( + "ripple::populateJsonResponse : binary is set", args.binary); for (auto const& binaryData : std::get(result.transactions)) diff --git a/src/xrpld/rpc/handlers/Fee1.cpp b/src/xrpld/rpc/handlers/Fee1.cpp index e6a92a49930..7c5ab4dc27f 100644 --- a/src/xrpld/rpc/handlers/Fee1.cpp +++ b/src/xrpld/rpc/handlers/Fee1.cpp @@ -32,7 +32,7 @@ doFee(RPC::JsonContext& context) auto result = context.app.getTxQ().doRPC(context.app); if (result.type() == Json::objectValue) return result; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doFee : invalid result type"); RPC::inject_error(rpcINTERNAL, context.params); return context.params; } diff --git a/src/xrpld/rpc/handlers/LedgerClosed.cpp b/src/xrpld/rpc/handlers/LedgerClosed.cpp index 2fd1f7ef118..4a289e004df 100644 --- a/src/xrpld/rpc/handlers/LedgerClosed.cpp +++ b/src/xrpld/rpc/handlers/LedgerClosed.cpp @@ -29,7 +29,7 @@ Json::Value doLedgerClosed(RPC::JsonContext& context) { auto ledger = context.ledgerMaster.getClosedLedger(); - XRPL_ASSERT(ledger); + XRPL_ASSERT("ripple::doLedgerClosed : non-null closed ledger", ledger); Json::Value jvResult; jvResult[jss::ledger_index] = ledger->info().seq; diff --git a/src/xrpld/rpc/handlers/LedgerDiff.cpp b/src/xrpld/rpc/handlers/LedgerDiff.cpp index 65857991736..880d12ebce6 100644 --- a/src/xrpld/rpc/handlers/LedgerDiff.cpp +++ b/src/xrpld/rpc/handlers/LedgerDiff.cpp @@ -73,7 +73,9 @@ doLedgerDiffGrpc( } else { - XRPL_ASSERT(inDesired->size() > 0); + XRPL_ASSERT( + "ripple::doLedgerDiffGrpc : non-empty desired", + inDesired->size() > 0); diff->set_key(k.data(), k.size()); if (request.include_blobs()) { diff --git a/src/xrpld/rpc/handlers/LedgerHandler.cpp b/src/xrpld/rpc/handlers/LedgerHandler.cpp index 1d81c65f23d..69e399ef6a2 100644 --- a/src/xrpld/rpc/handlers/LedgerHandler.cpp +++ b/src/xrpld/rpc/handlers/LedgerHandler.cpp @@ -136,7 +136,8 @@ doLedgerGrpc(RPC::GRPCContext& context) { for (auto& i : ledger->txs) { - XRPL_ASSERT(i.first); + XRPL_ASSERT( + "ripple::doLedgerGrpc : non-null transaction", i.first); if (request.expand()) { auto txn = response.mutable_transactions_list() @@ -212,7 +213,9 @@ doLedgerGrpc(RPC::GRPCContext& context) obj->set_key(k.data(), k.size()); if (inDesired) { - XRPL_ASSERT(inDesired->size() > 0); + XRPL_ASSERT( + "ripple::doLedgerGrpc : non-empty desired", + inDesired->size() > 0); obj->set_data(inDesired->data(), inDesired->size()); } if (inBase && inDesired) diff --git a/src/xrpld/rpc/handlers/NodeToShard.cpp b/src/xrpld/rpc/handlers/NodeToShard.cpp index 2f0cd625f29..a5b83cc1f31 100644 --- a/src/xrpld/rpc/handlers/NodeToShard.cpp +++ b/src/xrpld/rpc/handlers/NodeToShard.cpp @@ -78,7 +78,7 @@ doNodeToShard(RPC::JsonContext& context) else { // Shouldn't happen - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doNodeToShard : invalid action"); return rpcError(rpcINTERNAL); } } diff --git a/src/xrpld/rpc/handlers/PayChanClaim.cpp b/src/xrpld/rpc/handlers/PayChanClaim.cpp index 73a0f24e84b..cffce8cbcf4 100644 --- a/src/xrpld/rpc/handlers/PayChanClaim.cpp +++ b/src/xrpld/rpc/handlers/PayChanClaim.cpp @@ -58,7 +58,9 @@ doChannelAuthorize(RPC::JsonContext& context) std::optional> const keyPair = RPC::keypairForSignature(params, result, context.apiVersion); - XRPL_ASSERT(keyPair || RPC::contains_error(result)); + XRPL_ASSERT( + "ripple::doChannelAuthorize : valid keyPair or an error", + keyPair || RPC::contains_error(result)); if (!keyPair || RPC::contains_error(result)) return result; diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index a499c240bc2..d802cc7928f 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -75,7 +75,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) { if (!context.app.config().reporting()) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doTxPostgres : not in reporting mode"); Throw( "Called doTxPostgres yet not in reporting mode"); } @@ -109,13 +109,15 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) SHAMapHash{locator.getNodestoreHash()}); if (!node) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::doTxPostgres : error making SHAMap node"); return {res, {rpcINTERNAL, "Error making SHAMap node"}}; } auto item = (static_cast(node.get()))->peekItem(); if (!item) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::doTxPostgres : error reading SHAMap node"); return {res, {rpcINTERNAL, "Error reading SHAMap node"}}; } @@ -124,7 +126,8 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) if (!sttx || !meta) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::doTxPostgres : error deserializing SHAMap node"); return {res, {rpcINTERNAL, "Error deserializing SHAMap node"}}; } std::string reason; @@ -156,7 +159,8 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) else { JLOG(context.j.error()) << "Failed to fetch from db"; - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE( + "ripple::doTxPostgres : containing SHAMap node not found"); return {res, {rpcINTERNAL, "Containing SHAMap node not found"}}; } auto end = std::chrono::system_clock::now(); @@ -184,7 +188,7 @@ doTxPostgres(RPC::Context& context, TxArgs const& args) return {res, rpcTXN_NOT_FOUND}; } // database didn't return anything. This shouldn't happen - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::doTxPostgres : unexpected response"); return {res, {rpcINTERNAL, "unexpected Postgres response"}}; } @@ -370,7 +374,8 @@ populateJsonResponse( // populate binary metadata if (auto blob = std::get_if(&result.meta)) { - XRPL_ASSERT(args.binary); + XRPL_ASSERT( + "ripple::populateJsonResponse : binary is set", args.binary); auto json_meta = (context.apiVersion > 1 ? jss::meta_blob : jss::meta); response[json_meta] = strHex(makeSlice(*blob)); diff --git a/src/xrpld/shamap/SHAMap.h b/src/xrpld/shamap/SHAMap.h index 8d20d39895d..5295d1ed0a2 100644 --- a/src/xrpld/shamap/SHAMap.h +++ b/src/xrpld/shamap/SHAMap.h @@ -599,7 +599,9 @@ SHAMap::setLedgerSeq(std::uint32_t lseq) inline void SHAMap::setImmutable() { - XRPL_ASSERT(state_ != SHAMapState::Invalid); + XRPL_ASSERT( + "ripple::SHAMap::setImmutable : state is valid", + state_ != SHAMapState::Invalid); state_ = SHAMapState::Immutable; } @@ -680,7 +682,9 @@ class SHAMap::const_iterator inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) { - XRPL_ASSERT(map_ != nullptr); + XRPL_ASSERT( + "ripple::SHAMap::const_iterator::const_iterator : non-null input", + map_ != nullptr); if (auto temp = map_->peekFirstItem(stack_)) item_ = temp->peekItem().get(); @@ -732,7 +736,10 @@ SHAMap::const_iterator::operator++(int) inline bool operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) { - XRPL_ASSERT(x.map_ == y.map_); + XRPL_ASSERT( + "ripple::operator==(SHAMap::const_iterator, SHAMap::const_iterator) : " + "inputs map do match", + x.map_ == y.map_); return x.item_ == y.item_; } diff --git a/src/xrpld/shamap/SHAMapItem.h b/src/xrpld/shamap/SHAMapItem.h index 3c5835d1494..8273c03b7d9 100644 --- a/src/xrpld/shamap/SHAMapItem.h +++ b/src/xrpld/shamap/SHAMapItem.h @@ -159,7 +159,9 @@ intrusive_ptr_release(SHAMapItem const* x) inline boost::intrusive_ptr make_shamapitem(uint256 const& tag, Slice data) { - XRPL_ASSERT(data.size() <= megabytes(16)); + XRPL_ASSERT( + "ripple::make_shamapitem : maximum input size", + data.size() <= megabytes(16)); std::uint8_t* raw = detail::slabber.allocate(data.size()); diff --git a/src/xrpld/shamap/detail/SHAMap.cpp b/src/xrpld/shamap/detail/SHAMap.cpp index c0ab6046476..42413c03ce2 100644 --- a/src/xrpld/shamap/detail/SHAMap.cpp +++ b/src/xrpld/shamap/detail/SHAMap.cpp @@ -102,9 +102,12 @@ SHAMap::dirtyUp( // child can be an inner node or a leaf XRPL_ASSERT( + "ripple::SHAMap::dirtyUp : valid state", (state_ != SHAMapState::Synching) && - (state_ != SHAMapState::Immutable)); - XRPL_ASSERT(child && (child->cowid() == cowid_)); + (state_ != SHAMapState::Immutable)); + XRPL_ASSERT( + "ripple::SHAMap::dirtyUp : valid child input", + child && (child->cowid() == cowid_)); while (!stack.empty()) { @@ -112,10 +115,10 @@ SHAMap::dirtyUp( std::dynamic_pointer_cast(stack.top().first); SHAMapNodeID nodeID = stack.top().second; stack.pop(); - XRPL_ASSERT(node != nullptr); + XRPL_ASSERT("ripple::SHAMap::dirtyUp : non-null node", node != nullptr); int branch = selectBranch(nodeID, target); - XRPL_ASSERT(branch >= 0); + XRPL_ASSERT("ripple::SHAMap::dirtyUp : valid branch", branch >= 0); node = unshareNode(std::move(node), nodeID); node->setChild(branch, std::move(child)); @@ -127,7 +130,9 @@ SHAMap::dirtyUp( SHAMapLeafNode* SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const { - XRPL_ASSERT(stack == nullptr || stack->empty()); + XRPL_ASSERT( + "ripple::SHAMap::walkTowardsKey : empty stack input", + stack == nullptr || stack->empty()); auto inNode = root_; SHAMapNodeID nodeID; @@ -162,7 +167,7 @@ SHAMap::findKey(uint256 const& id) const std::shared_ptr SHAMap::fetchNodeFromDB(SHAMapHash const& hash) const { - XRPL_ASSERT(backed_); + XRPL_ASSERT("ripple::SHAMap::fetchNodeFromDB : is backed", backed_); auto obj = f_.db().fetchNodeObject(hash.as_uint256(), ledgerSeq_); return finishFetch(hash, obj); } @@ -172,7 +177,7 @@ SHAMap::finishFetch( SHAMapHash const& hash, std::shared_ptr const& object) const { - XRPL_ASSERT(backed_); + XRPL_ASSERT("ripple::SHAMap::finishFetch : is backed", backed_); try { @@ -360,9 +365,14 @@ SHAMap::descend( int branch, SHAMapSyncFilter* filter) const { - XRPL_ASSERT(parent->isInner()); - XRPL_ASSERT((branch >= 0) && (branch < branchFactor)); - XRPL_ASSERT(!parent->isEmptyBranch(branch)); + XRPL_ASSERT( + "ripple::SHAMap::descend : valid parent input", parent->isInner()); + XRPL_ASSERT( + "ripple::SHAMap::descend : valid branch input", + (branch >= 0) && (branch < branchFactor)); + XRPL_ASSERT( + "ripple::SHAMap::descend : parent branch is non-empty", + !parent->isEmptyBranch(branch)); SHAMapTreeNode* child = parent->getChildPointer(branch); @@ -430,11 +440,15 @@ std::shared_ptr SHAMap::unshareNode(std::shared_ptr node, SHAMapNodeID const& nodeID) { // make sure the node is suitable for the intended operation (copy on write) - XRPL_ASSERT(node->cowid() <= cowid_); + XRPL_ASSERT( + "ripple::SHAMap::unshareNode : node valid for cowid", + node->cowid() <= cowid_); if (node->cowid() != cowid_) { // have a CoW - XRPL_ASSERT(state_ != SHAMapState::Immutable); + XRPL_ASSERT( + "ripple::SHAMap::unshareNode : not immutable", + state_ != SHAMapState::Immutable); node = std::static_pointer_cast(node->clone(cowid_)); if (nodeID.isRoot()) root_ = node; @@ -467,7 +481,9 @@ SHAMap::belowHelper( if (!inner->isEmptyBranch(i)) { node = descendThrow(inner, i); - XRPL_ASSERT(!stack.empty()); + XRPL_ASSERT( + "ripple::SHAMap::belowHelper : non-empty stack", + !stack.empty()); if (node->isLeaf()) { auto n = std::static_pointer_cast(node); @@ -531,7 +547,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const if (!nextNode) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::SHAMap::onlyBelow : no next node"); return no_item; } @@ -541,14 +557,17 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const // An inner node must have at least one leaf // below it, unless it's the root_ auto const leaf = static_cast(node); - XRPL_ASSERT(leaf->peekItem() || (leaf == root_.get())); + XRPL_ASSERT( + "ripple::SHAMap::onlyBelow : valid inner node", + leaf->peekItem() || (leaf == root_.get())); return leaf->peekItem(); } SHAMapLeafNode const* SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const { - XRPL_ASSERT(stack.empty()); + XRPL_ASSERT( + "ripple::SHAMap::peekFirstItem : empty stack input", stack.empty()); SHAMapLeafNode* node = firstBelow(root_, stack); if (!node) { @@ -562,13 +581,18 @@ SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const SHAMapLeafNode const* SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const { - XRPL_ASSERT(!stack.empty()); - XRPL_ASSERT(stack.top().first->isLeaf()); + XRPL_ASSERT( + "ripple::SHAMap::peekNextItem : non-empty stack input", !stack.empty()); + XRPL_ASSERT( + "ripple::SHAMap::peekNextItem : stack starts with leaf", + stack.top().first->isLeaf()); stack.pop(); while (!stack.empty()) { auto [node, nodeID] = stack.top(); - XRPL_ASSERT(!node->isLeaf()); + XRPL_ASSERT( + "ripple::SHAMap::peekNextItem : another node is not leaf", + !node->isLeaf()); auto inner = std::static_pointer_cast(node); for (auto i = selectBranch(nodeID, id) + 1; i < branchFactor; ++i) { @@ -578,7 +602,9 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const auto leaf = firstBelow(node, stack, i); if (!leaf) Throw(type_, id); - XRPL_ASSERT(leaf->isLeaf()); + XRPL_ASSERT( + "ripple::SHAMap::peekNextItem : leaf is valid", + leaf->isLeaf()); return leaf; } } @@ -696,7 +722,9 @@ bool SHAMap::delItem(uint256 const& id) { // delete the item with this ID - XRPL_ASSERT(state_ != SHAMapState::Immutable); + XRPL_ASSERT( + "ripple::SHAMap::delItem : not immutable", + state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -775,8 +803,12 @@ SHAMap::addGiveItem( SHAMapNodeType type, boost::intrusive_ptr item) { - XRPL_ASSERT(state_ != SHAMapState::Immutable); - XRPL_ASSERT(type != SHAMapNodeType::tnINNER); + XRPL_ASSERT( + "ripple::SHAMap::addGiveItem : not immutable", + state_ != SHAMapState::Immutable); + XRPL_ASSERT( + "ripple::SHAMap::addGiveItem : valid type input", + type != SHAMapNodeType::tnINNER); // add the specified item, does not update uint256 tag = item->key(); @@ -802,7 +834,9 @@ SHAMap::addGiveItem( // easy case, we end on an inner node auto inner = std::static_pointer_cast(node); int branch = selectBranch(nodeID, tag); - XRPL_ASSERT(inner->isEmptyBranch(branch)); + XRPL_ASSERT( + "ripple::SHAMap::addGiveItem : inner branch is empty", + inner->isEmptyBranch(branch)); inner->setChild(branch, makeTypedLeaf(type, std::move(item), cowid_)); } else @@ -811,7 +845,9 @@ SHAMap::addGiveItem( // items auto leaf = std::static_pointer_cast(node); auto otherItem = leaf->peekItem(); - XRPL_ASSERT(otherItem && (tag != otherItem->key())); + XRPL_ASSERT( + "ripple::SHAMap::addGiveItem : non-null item", + otherItem && (tag != otherItem->key())); node = std::make_shared(node->cowid()); @@ -829,7 +865,8 @@ SHAMap::addGiveItem( } // we can add the two leaf nodes here - XRPL_ASSERT(node->isInner()); + XRPL_ASSERT( + "ripple::SHAMap::addGiveItem : node is inner", node->isInner()); auto inner = static_cast(node.get()); inner->setChild(b1, makeTypedLeaf(type, std::move(item), cowid_)); @@ -868,7 +905,9 @@ SHAMap::updateGiveItem( // can't change the tag but can change the hash uint256 tag = item->key(); - XRPL_ASSERT(state_ != SHAMapState::Immutable); + XRPL_ASSERT( + "ripple::SHAMap::updateGiveItem : not immutable", + state_ != SHAMapState::Immutable); SharedPtrNodeStack stack; walkTowardsKey(tag, &stack); @@ -882,7 +921,7 @@ SHAMap::updateGiveItem( if (!node || (node->peekItem()->key() != tag)) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::SHAMap::updateGiveItem : invalid node"); return false; } @@ -927,7 +966,9 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) if (newRoot) { root_ = newRoot; - XRPL_ASSERT(root_->getHash() == hash); + XRPL_ASSERT( + "ripple::SHAMap::fetchRoot : root hash do match", + root_->getHash() == hash); return true; } @@ -949,8 +990,9 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) std::shared_ptr SHAMap::writeNode(NodeObjectType t, std::shared_ptr node) const { - XRPL_ASSERT(node->cowid() == 0); - XRPL_ASSERT(backed_); + XRPL_ASSERT( + "ripple::SHAMap::writeNode : valid input node", node->cowid() == 0); + XRPL_ASSERT("ripple::SHAMap::writeNode : is backed", backed_); canonicalize(node->getHash(), node); @@ -970,7 +1012,8 @@ SHAMap::preFlushNode(std::shared_ptr node) const { // A shared node should never need to be flushed // because that would imply someone modified it - XRPL_ASSERT(node->cowid() != 0); + XRPL_ASSERT( + "ripple::SHAMap::preFlushNode : valid input node", node->cowid() != 0); if (node->cowid() != cowid_) { @@ -998,7 +1041,8 @@ SHAMap::flushDirty(NodeObjectType t) int SHAMap::walkSubTree(bool doWrite, NodeObjectType t) { - XRPL_ASSERT(!doWrite || backed_); + XRPL_ASSERT( + "ripple::SHAMap::walkSubTree : valid input", !doWrite || backed_); int flushed = 0; @@ -1073,7 +1117,9 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // flush this leaf ++flushed; - XRPL_ASSERT(node->cowid() == cowid_); + XRPL_ASSERT( + "ripple::SHAMap::walkSubTree : node cowid do match", + node->cowid() == cowid_); child->updateHash(); child->unshare(); @@ -1106,7 +1152,9 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) stack.pop(); // Hook this inner node to its parent - XRPL_ASSERT(parent->cowid() == cowid_); + XRPL_ASSERT( + "ripple::SHAMap::walkSubTree : parent cowid do match", + parent->cowid() == cowid_); parent->shareChild(pos, node); // Continue with parent's next child, if any @@ -1150,7 +1198,9 @@ SHAMap::dump(bool hash) const auto child = inner->getChildPointer(i); if (child) { - XRPL_ASSERT(child->getHash() == inner->getChildHash(i)); + XRPL_ASSERT( + "ripple::SHAMap::dump : child hash do match", + child->getHash() == inner->getChildHash(i)); stack.push({child, nodeID.getChildNodeID(i)}); } } @@ -1167,7 +1217,9 @@ std::shared_ptr SHAMap::cacheLookup(SHAMapHash const& hash) const { auto ret = f_.getTreeNodeCache(ledgerSeq_)->fetch(hash.as_uint256()); - XRPL_ASSERT(!ret || !ret->cowid()); + XRPL_ASSERT( + "ripple::SHAMap::cacheLookup : not fetched or zero cowid", + !ret || !ret->cowid()); return ret; } @@ -1176,9 +1228,12 @@ SHAMap::canonicalize( SHAMapHash const& hash, std::shared_ptr& node) const { - XRPL_ASSERT(backed_); - XRPL_ASSERT(node->cowid() == 0); - XRPL_ASSERT(node->getHash() == hash); + XRPL_ASSERT("ripple::SHAMap::canonicalize : is backed", backed_); + XRPL_ASSERT( + "ripple::SHAMap::canonicalize : valid node input", node->cowid() == 0); + XRPL_ASSERT( + "ripple::SHAMap::canonicalize : node hash do match", + node->getHash() == hash); f_.getTreeNodeCache(ledgerSeq_) ->canonicalize_replace_client(hash.as_uint256(), node); @@ -1189,8 +1244,10 @@ SHAMap::invariants() const { (void)getHash(); // update node hashes auto node = root_.get(); - XRPL_ASSERT(node != nullptr); - XRPL_ASSERT(!node->isLeaf()); + XRPL_ASSERT( + "ripple::SHAMap::invariants : non-null root node", node != nullptr); + XRPL_ASSERT( + "ripple::SHAMap::invariants : root node is not leaf", !node->isLeaf()); SharedPtrNodeStack stack; for (auto leaf = peekFirstItem(stack); leaf != nullptr; leaf = peekNextItem(leaf->peekItem()->key(), stack)) diff --git a/src/xrpld/shamap/detail/SHAMapDelta.cpp b/src/xrpld/shamap/detail/SHAMapDelta.cpp index cb7ec09be78..3bd1d5e27e0 100644 --- a/src/xrpld/shamap/detail/SHAMapDelta.cpp +++ b/src/xrpld/shamap/detail/SHAMapDelta.cpp @@ -128,7 +128,9 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const // many differences throws on corrupt tables or missing nodes CAUTION: // otherMap is not locked and must be immutable - XRPL_ASSERT(isValid() && otherMap.isValid()); + XRPL_ASSERT( + "ripple::SHAMap::compare : valid state and valid input", + isValid() && otherMap.isValid()); if (getHash() == otherMap.getHash()) return true; @@ -145,7 +147,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const if (!ourNode || !otherNode) { - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::SHAMap::compare : missing a node"); Throw(type_, uint256()); } @@ -226,7 +228,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const } } else - XRPL_UNREACHABLE(); + XRPL_UNREACHABLE("ripple::SHAMap::compare : invalid node"); } return true; @@ -323,7 +325,9 @@ SHAMap::walkMapParallel( { std::shared_ptr node = std::move(nodeStack.top()); - XRPL_ASSERT(node); + XRPL_ASSERT( + "ripple::SHAMap::walkMapParallel : non-null node", + node); nodeStack.pop(); for (int i = 0; i < 16; ++i) diff --git a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp index f2cd02267b6..c0963872ecc 100644 --- a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp @@ -225,7 +225,8 @@ SHAMapInnerNode::updateHashDeep() void SHAMapInnerNode::serializeForWire(Serializer& s) const { - XRPL_ASSERT(!isEmpty()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::serializeForWire : is non-empty", !isEmpty()); // If the node is sparse, then only send non-empty branches: if (getBranchCount() < 12) @@ -249,7 +250,9 @@ SHAMapInnerNode::serializeForWire(Serializer& s) const void SHAMapInnerNode::serializeWithPrefix(Serializer& s) const { - XRPL_ASSERT(!isEmpty()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::serializeWithPrefix : is non-empty", + !isEmpty()); s.add32(HashPrefix::innerNode); iterChildren( @@ -274,9 +277,14 @@ SHAMapInnerNode::getString(const SHAMapNodeID& id) const void SHAMapInnerNode::setChild(int m, std::shared_ptr child) { - XRPL_ASSERT((m >= 0) && (m < branchFactor)); - XRPL_ASSERT(cowid_ != 0); - XRPL_ASSERT(child.get() != this); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::setChild : valid branch input", + (m >= 0) && (m < branchFactor)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::setChild : nonzero cowid", cowid_ != 0); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::setChild : valid child input", + child.get() != this); auto const dstIsBranch = [&] { if (child) @@ -303,27 +311,41 @@ SHAMapInnerNode::setChild(int m, std::shared_ptr child) hash_.zero(); - XRPL_ASSERT(getBranchCount() <= hashesAndChildren_.capacity()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::setChild : maximum branch count", + getBranchCount() <= hashesAndChildren_.capacity()); } // finished modifying, now make shareable void SHAMapInnerNode::shareChild(int m, std::shared_ptr const& child) { - XRPL_ASSERT((m >= 0) && (m < branchFactor)); - XRPL_ASSERT(cowid_ != 0); - XRPL_ASSERT(child); - XRPL_ASSERT(child.get() != this); - - XRPL_ASSERT(!isEmptyBranch(m)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::shareChild : valid branch input", + (m >= 0) && (m < branchFactor)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::shareChild : nonzero cowid", cowid_ != 0); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::shareChild : non-null child input", child); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::shareChild : valid child input", + child.get() != this); + + XRPL_ASSERT( + "ripple::SHAMapInnerNode::shareChild : non-empty branch input", + !isEmptyBranch(m)); hashesAndChildren_.getChildren()[*getChildIndex(m)] = child; } SHAMapTreeNode* SHAMapInnerNode::getChildPointer(int branch) { - XRPL_ASSERT(branch >= 0 && branch < branchFactor); - XRPL_ASSERT(!isEmptyBranch(branch)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::getChildPointer : valid branch input", + branch >= 0 && branch < branchFactor); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::getChildPointer : non-empty branch input", + !isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -335,8 +357,12 @@ SHAMapInnerNode::getChildPointer(int branch) std::shared_ptr SHAMapInnerNode::getChild(int branch) { - XRPL_ASSERT(branch >= 0 && branch < branchFactor); - XRPL_ASSERT(!isEmptyBranch(branch)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::getChild : valid branch input", + branch >= 0 && branch < branchFactor); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::getChild : non-empty branch input", + !isEmptyBranch(branch)); auto const index = *getChildIndex(branch); @@ -348,7 +374,9 @@ SHAMapInnerNode::getChild(int branch) SHAMapHash const& SHAMapInnerNode::getChildHash(int m) const { - XRPL_ASSERT((m >= 0) && (m < branchFactor)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::getChildHash : valid branch input", + (m >= 0) && (m < branchFactor)); if (auto const i = getChildIndex(m)) return hashesAndChildren_.getHashes()[*i]; @@ -360,12 +388,20 @@ SHAMapInnerNode::canonicalizeChild( int branch, std::shared_ptr node) { - XRPL_ASSERT(branch >= 0 && branch < branchFactor); - XRPL_ASSERT(node); - XRPL_ASSERT(!isEmptyBranch(branch)); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::canonicalizeChild : valid branch input", + branch >= 0 && branch < branchFactor); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::canonicalizeChild : valid node input", node); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::canonicalizeChild : non-empty branch input", + !isEmptyBranch(branch)); auto const childIndex = *getChildIndex(branch); auto [_, hashes, children] = hashesAndChildren_.getHashesAndChildren(); - XRPL_ASSERT(node->getHash() == hashes[childIndex]); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::canonicalizeChild : node and branch inputs " + "hash do match", + node->getHash() == hashes[childIndex]); packed_spinlock sl(lock_, childIndex); std::lock_guard lock(sl); @@ -395,7 +431,9 @@ SHAMapInnerNode::invariants(bool is_root) const auto const branchCount = getBranchCount(); for (int i = 0; i < branchCount; ++i) { - XRPL_ASSERT(hashes[i].isNonZero()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : nonzero hash in branch", + hashes[i].isNonZero()); if (children[i] != nullptr) children[i]->invariants(); ++count; @@ -407,24 +445,35 @@ SHAMapInnerNode::invariants(bool is_root) const { if (hashes[i].isNonZero()) { - XRPL_ASSERT((isBranch_ & (1 << i)) != 0); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : valid branch when " + "nonzero hash", + (isBranch_ & (1 << i)) != 0); if (children[i] != nullptr) children[i]->invariants(); ++count; } else { - XRPL_ASSERT((isBranch_ & (1 << i)) == 0); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : valid branch when " + "zero hash", + (isBranch_ & (1 << i)) == 0); } } } if (!is_root) { - XRPL_ASSERT(hash_.isNonZero()); - XRPL_ASSERT(count >= 1); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : nonzero hash", + hash_.isNonZero()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : minimum count", count >= 1); } - XRPL_ASSERT((count == 0) ? hash_.isZero() : hash_.isNonZero()); + XRPL_ASSERT( + "ripple::SHAMapInnerNode::invariants : hash and count do match", + (count == 0) ? hash_.isZero() : hash_.isNonZero()); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp index 5652f5d403b..6c537107335 100644 --- a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp @@ -28,7 +28,10 @@ SHAMapLeafNode::SHAMapLeafNode( std::uint32_t cowid) : SHAMapTreeNode(cowid), item_(std::move(item)) { - XRPL_ASSERT(item_->size() >= 12); + XRPL_ASSERT( + "ripple::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<" + "SHAMapItem const>, std::uint32_t) : minimum input size", + item_->size() >= 12); } SHAMapLeafNode::SHAMapLeafNode( @@ -37,7 +40,11 @@ SHAMapLeafNode::SHAMapLeafNode( SHAMapHash const& hash) : SHAMapTreeNode(cowid, hash), item_(std::move(item)) { - XRPL_ASSERT(item_->size() >= 12); + XRPL_ASSERT( + "ripple::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<" + "SHAMapItem const>, std::uint32_t, SHAMapHash const&) : minimum input " + "size", + item_->size() >= 12); } boost::intrusive_ptr const& @@ -49,7 +56,7 @@ SHAMapLeafNode::peekItem() const bool SHAMapLeafNode::setItem(boost::intrusive_ptr item) { - XRPL_ASSERT(cowid_ != 0); + XRPL_ASSERT("ripple::SHAMapLeafNode::setItem : nonzero cowid", cowid_ != 0); item_ = std::move(item); auto const oldHash = hash_; @@ -87,8 +94,10 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const void SHAMapLeafNode::invariants(bool) const { - XRPL_ASSERT(hash_.isNonZero()); - XRPL_ASSERT(item_ != nullptr); + XRPL_ASSERT( + "ripple::SHAMapLeafNode::invariants : nonzero hash", hash_.isNonZero()); + XRPL_ASSERT( + "ripple::SHAMapLeafNode::invariants : non-null item", item_ != nullptr); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapNodeID.cpp b/src/xrpld/shamap/detail/SHAMapNodeID.cpp index 1c9187a40e5..f73ed803b3f 100644 --- a/src/xrpld/shamap/detail/SHAMapNodeID.cpp +++ b/src/xrpld/shamap/detail/SHAMapNodeID.cpp @@ -57,8 +57,12 @@ depthMask(unsigned int depth) SHAMapNodeID::SHAMapNodeID(unsigned int depth, uint256 const& hash) : id_(hash), depth_(depth) { - XRPL_ASSERT(depth <= SHAMap::leafDepth); - XRPL_ASSERT(id_ == (id_ & depthMask(depth))); + XRPL_ASSERT( + "ripple::SHAMapNodeID::SHAMapNodeID : maximum depth input", + depth <= SHAMap::leafDepth); + XRPL_ASSERT( + "ripple::SHAMapNodeID::SHAMapNodeID : hash and depth inputs do match", + id_ == (id_ & depthMask(depth))); } std::string @@ -73,7 +77,9 @@ SHAMapNodeID::getRawString() const SHAMapNodeID SHAMapNodeID::getChildNodeID(unsigned int m) const { - XRPL_ASSERT(m < SHAMap::branchFactor); + XRPL_ASSERT( + "ripple::SHAMapNodeID::getChildNodeID : valid branch input", + m < SHAMap::branchFactor); // A SHAMap has exactly 65 levels, so nodes must not exceed that // depth; if they do, this breaks the invariant of never allowing @@ -83,7 +89,9 @@ SHAMapNodeID::getChildNodeID(unsigned int m) const // We throw (but never assert) if the node is at level 64, since // entries at that depth are leaf nodes and have no children and even // constructing a child node from them would break the above invariant. - XRPL_ASSERT(depth_ <= SHAMap::leafDepth); + XRPL_ASSERT( + "ripple::SHAMapNodeID::getChildNodeID : maximum leaf depth", + depth_ <= SHAMap::leafDepth); if (depth_ >= SHAMap::leafDepth) Throw( @@ -128,14 +136,17 @@ selectBranch(SHAMapNodeID const& id, uint256 const& hash) else branch >>= 4; - XRPL_ASSERT(branch < SHAMap::branchFactor); + XRPL_ASSERT( + "ripple::selectBranch : maximum result", branch < SHAMap::branchFactor); return branch; } SHAMapNodeID SHAMapNodeID::createID(int depth, uint256 const& key) { - XRPL_ASSERT((depth >= 0) && (depth < 65)); + XRPL_ASSERT( + "ripple::SHAMapNodeID::createID : valid branch input", + (depth >= 0) && (depth < 65)); return SHAMapNodeID(depth, key & depthMask(depth)); } diff --git a/src/xrpld/shamap/detail/SHAMapSync.cpp b/src/xrpld/shamap/detail/SHAMapSync.cpp index 1e2194528cd..dfb0075597e 100644 --- a/src/xrpld/shamap/detail/SHAMapSync.cpp +++ b/src/xrpld/shamap/detail/SHAMapSync.cpp @@ -316,8 +316,10 @@ SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) std::vector> SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) { - XRPL_ASSERT(root_->getHash().isNonZero()); - XRPL_ASSERT(max > 0); + XRPL_ASSERT( + "ripple::SHAMap::getMissingNodes : nonzero root hash", + root_->getHash().isNonZero()); + XRPL_ASSERT("ripple::SHAMap::getMissingNodes : valid max input", max > 0); MissingNodes mn( max, @@ -376,7 +378,9 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // This is a node we are continuing to process fullBelow = fullBelow && was; // was and still is } - XRPL_ASSERT(node); + XRPL_ASSERT( + "ripple::SHAMap::getMissingNodes : first non-null node", + node); } } @@ -407,7 +411,9 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // Resume at the top of the stack pos = mn.stack_.top(); mn.stack_.pop(); - XRPL_ASSERT(node != nullptr); + XRPL_ASSERT( + "ripple::SHAMap::getMissingNodes : second non-null node", + node != nullptr); } } @@ -534,11 +540,13 @@ SHAMap::addRootNode( if (root_->getHash().isNonZero()) { JLOG(journal_.trace()) << "got root node, already have one"; - XRPL_ASSERT(root_->getHash() == hash); + XRPL_ASSERT( + "ripple::SHAMap::addRootNode : valid hash input", + root_->getHash() == hash); return SHAMapAddNode::duplicate(); } - XRPL_ASSERT(cowid_ >= 1); + XRPL_ASSERT("ripple::SHAMap::addRootNode : valid cowid", cowid_ >= 1); auto node = SHAMapTreeNode::makeFromWire(rootNode); if (!node || node->getHash() != hash) return SHAMapAddNode::invalid(); @@ -572,7 +580,8 @@ SHAMap::addKnownNode( Slice const& rawNode, SHAMapSyncFilter* filter) { - XRPL_ASSERT(!node.isRoot()); + XRPL_ASSERT( + "ripple::SHAMap::addKnownNode : valid node input", !node.isRoot()); if (!isSynching()) { @@ -589,7 +598,7 @@ SHAMap::addKnownNode( (iNodeID.getDepth() < node.getDepth())) { int branch = selectBranch(iNodeID, node.getNodeID()); - XRPL_ASSERT(branch >= 0); + XRPL_ASSERT("ripple::SHAMap::addKnownNode : valid branch", branch >= 0); auto inner = static_cast(iNode); if (inner->isEmptyBranch(branch)) { diff --git a/src/xrpld/shamap/detail/ShardFamily.cpp b/src/xrpld/shamap/detail/ShardFamily.cpp index 0429e12482b..cff6c2ebf55 100644 --- a/src/xrpld/shamap/detail/ShardFamily.cpp +++ b/src/xrpld/shamap/detail/ShardFamily.cpp @@ -30,7 +30,7 @@ static NodeStore::Database& getShardStore(Application& app) { auto const dbPtr = app.getShardStore(); - XRPL_ASSERT(dbPtr); + XRPL_ASSERT("ripple::getShardStore : non-null shard store", dbPtr); return *dbPtr; } diff --git a/src/xrpld/shamap/detail/TaggedPointer.ipp b/src/xrpld/shamap/detail/TaggedPointer.ipp index c7d47d65e6a..83ee03dd04d 100644 --- a/src/xrpld/shamap/detail/TaggedPointer.ipp +++ b/src/xrpld/shamap/detail/TaggedPointer.ipp @@ -79,14 +79,18 @@ constexpr auto chunksPerBlock = [[nodiscard]] inline std::uint8_t numAllocatedChildren(std::uint8_t n) { - XRPL_ASSERT(n <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT( + "ripple::numAllocatedChildren : valid input", + n <= SHAMapInnerNode::branchFactor); return *std::lower_bound(boundaries.begin(), boundaries.end(), n); } [[nodiscard]] inline std::size_t boundariesIndex(std::uint8_t numChildren) { - XRPL_ASSERT(numChildren <= SHAMapInnerNode::branchFactor); + XRPL_ASSERT( + "ripple::boundariesIndex : valid input", + numChildren <= SHAMapInnerNode::branchFactor); return std::distance( boundaries.begin(), std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); @@ -156,7 +160,9 @@ allocateArrays(std::uint8_t numChildren) inline void deallocateArrays(std::uint8_t boundaryIndex, void* p) { - XRPL_ASSERT(isFromArrayFuns[boundaryIndex](p)); + XRPL_ASSERT( + "ripple::deallocateArrays : valid inputs", + isFromArrayFuns[boundaryIndex](p)); freeArrayFuns[boundaryIndex](p); } @@ -270,10 +276,15 @@ TaggedPointer::getChildIndex(std::uint16_t isBranch, int i) const inline TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t numChildren) { auto [tag, p] = allocateArrays(numChildren); - XRPL_ASSERT(tag < boundaries.size()); XRPL_ASSERT( + "ripple::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " + "maximum tag", + tag < boundaries.size()); + XRPL_ASSERT( + "ripple::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " + "valid pointer", (reinterpret_cast(p) & ptrMask) == - reinterpret_cast(p)); + reinterpret_cast(p)); tp_ = reinterpret_cast(p) + tag; } @@ -283,7 +294,10 @@ inline TaggedPointer::TaggedPointer( std::uint16_t dstBranches, std::uint8_t toAllocate) { - XRPL_ASSERT(toAllocate >= popcnt16(dstBranches)); + XRPL_ASSERT( + "ripple::TaggedPointer::TaggedPointer(TaggedPointer&& ...) : minimum " + "toAllocate input", + toAllocate >= popcnt16(dstBranches)); if (other.capacity() == numAllocatedChildren(toAllocate)) { @@ -428,7 +442,10 @@ inline TaggedPointer::TaggedPointer( } } // If sparse, may need to run additional constructors - XRPL_ASSERT(!dstIsDense || dstIndex == dstNumAllocated); + XRPL_ASSERT( + "ripple::TaggedPointer::TaggedPointer(TaggedPointer&& ...) : " + "non-sparse or valid sparse", + !dstIsDense || dstIndex == dstNumAllocated); for (int i = dstIndex; i < dstNumAllocated; ++i) { new (&dstHashes[i]) SHAMapHash{}; From 0d74ac0e34a508d914d381d88a3b97132035923f Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 30 Jul 2024 13:14:29 +0100 Subject: [PATCH 09/18] Convert new asserts to XRPL_ASSERT --- src/xrpld/app/paths/detail/StrandFlow.h | 2 +- src/xrpld/app/tx/detail/InvariantCheck.cpp | 5 ++++- src/xrpld/app/tx/detail/NFTokenUtils.cpp | 4 +++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/xrpld/app/paths/detail/StrandFlow.h b/src/xrpld/app/paths/detail/StrandFlow.h index 28367aa2bcc..f5a725fc97d 100644 --- a/src/xrpld/app/paths/detail/StrandFlow.h +++ b/src/xrpld/app/paths/detail/StrandFlow.h @@ -847,7 +847,7 @@ flow( // running debug builds of rippled. While this issue still needs to // be resolved, the assert is causing more harm than good at this // point. - // XRPL_ASSERT(0); + // XRPL_UNREACHABLE(); return {tefEXCEPTION, std::move(ofrsToRmOnFail)}; } diff --git a/src/xrpld/app/tx/detail/InvariantCheck.cpp b/src/xrpld/app/tx/detail/InvariantCheck.cpp index 70210b90d75..74546c642f3 100644 --- a/src/xrpld/app/tx/detail/InvariantCheck.cpp +++ b/src/xrpld/app/tx/detail/InvariantCheck.cpp @@ -399,7 +399,10 @@ AccountRootsDeletedClean::finalize( << "Invariant failed: account deletion left behind a " << typeName << " object"; (void)enforce; - assert(enforce); + XRPL_ASSERT( + "ripple::AccountRootsDeletedClean::finalize::objectExists : " + "account deletion left no objects behind", + enforce); return true; } return false; diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.cpp b/src/xrpld/app/tx/detail/NFTokenUtils.cpp index 4d540eda9cf..2406cebf18e 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.cpp +++ b/src/xrpld/app/tx/detail/NFTokenUtils.cpp @@ -191,7 +191,9 @@ getPageForToken( : carr[0].getFieldH256(sfNFTokenID); auto np = std::make_shared(keylet::nftpage(base, tokenIDForNewPage)); - assert(np->key() > base.key); + XRPL_ASSERT( + "ripple::nft::getPageForToken : valid NFT page index", + np->key() > base.key); np->setFieldArray(sfNFTokens, narr); np->setFieldH256(sfNextPageMin, cp->key()); From 0cd3188276d4436e8d22ff84bb5c838204bc67a0 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 17 Sep 2024 17:56:33 +0100 Subject: [PATCH 10/18] Ignore formatting in external/antithesis-sdk --- external/antithesis-sdk/.clang-format | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 external/antithesis-sdk/.clang-format diff --git a/external/antithesis-sdk/.clang-format b/external/antithesis-sdk/.clang-format new file mode 100644 index 00000000000..e871ed18b43 --- /dev/null +++ b/external/antithesis-sdk/.clang-format @@ -0,0 +1,3 @@ +--- +DisableFormat: true +SortIncludes: false From 338c5b7a0ad7c8427fb4f50b09b77cfb85a55b2d Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 24 Sep 2024 16:04:03 +0100 Subject: [PATCH 11/18] Update CONTRIBUTING.md --- CONTRIBUTING.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ceca1eaa6fc..15423d87242 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -343,6 +343,49 @@ pip3 install pre-commit pre-commit install ``` +## Contracts and instrumentation + +We are using [Antithesis](https://antithesis.com/) for continuous fuzzing, +and keep a copy of [Antithesis C++ SDK](https://github.com/antithesishq/antithesis-sdk-cpp/) +in `external/antithesis-sdk`. One of the aims of fuzzing is to identify bugs +by finding external conditions which cause contracts violations inside `rippled`. +The contracts are expressed as `XRPL_ASSERT` or `XRPL_UNREACHABLE` (defined in +`include/xrpl/beast/utility/instrumentation.h`), which are effectively (outside +of Antithesis) wrappers for `assert(...)` with added name. The purpose of name +is provide contracts with stable identity which does not rely on line numbers. + +When `rippled` is built with the +Antithesis instrumentation enabled (using `voidstar` CMake option), +the `XRPL_...` contracts enable the `rippled` process to signal any violations +to the Antithesis platform during fuzzing. + +We continue to use the old style `assert` or `assert(false)` in certain +locations, where the reporting of contract violations in Antithesis platform is +either not possible or is not useful. + +For this reason: +* The locations where `assert` or `assert(false)` contracts can be used: + * `constexpr` functions + * unit tests i.e. files under `src/test` + * unit tests-related modules (files under `beast/test` and `beast/unit_test`) +* Outside of the listed locations, do not use `assert`; use `XRPL_ASSERT` instead, + giving it unique name, with the short description of the contract. +* Outside of the listed locations, do not user `assert(false)`; use + `XRPL_UNREACHABLE` instead, giving it unique name, with the description of the + condition being violated +* The contract name should start with a full name (including scope) of the + function, optionally a named lambda, followed by a colon ` : ` and a brief + (typically at most five words) description. `XRPL_UNREACHABLE` contracts + can use slightly longer descriptions. If there are multiple overloads of the + function, use common sense to balance both brevity and unambiguity of the + function name. NOTE: the purpose of name is to provide stable means of + unique identification of every contract; for this reason try to avoid elements + which can change in the most obvious refactors. +* Do not use `std::unreachable` +* Do not put contracts where they can be easily violated by an external + condition (e.g. timing, data payload before mandatory validation etc.) as + this creates bogus bug reports. + ## Unit Tests To execute all unit tests: From e0b078f4e5146c8ae9a5307cbdf56d9851c713d1 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 24 Sep 2024 17:32:09 +0100 Subject: [PATCH 12/18] Minor changes in CONTRIBUTING.md --- CONTRIBUTING.md | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 15423d87242..912b34d0493 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -352,16 +352,15 @@ by finding external conditions which cause contracts violations inside `rippled` The contracts are expressed as `XRPL_ASSERT` or `XRPL_UNREACHABLE` (defined in `include/xrpl/beast/utility/instrumentation.h`), which are effectively (outside of Antithesis) wrappers for `assert(...)` with added name. The purpose of name -is provide contracts with stable identity which does not rely on line numbers. +is to provide contracts with stable identity which does not rely on line numbers. -When `rippled` is built with the -Antithesis instrumentation enabled (using `voidstar` CMake option), -the `XRPL_...` contracts enable the `rippled` process to signal any violations -to the Antithesis platform during fuzzing. +When `rippled` is built with the Antithesis instrumentation enabled +(using `voidstar` CMake option), the `XRPL_...` contracts will report any +violations on the Antithesis platform during fuzzing. We continue to use the old style `assert` or `assert(false)` in certain -locations, where the reporting of contract violations in Antithesis platform is -either not possible or is not useful. +locations, where the reporting of contract violations on the Antithesis +platform is either not possible or not useful. For this reason: * The locations where `assert` or `assert(false)` contracts can be used: @@ -380,11 +379,11 @@ For this reason: function, use common sense to balance both brevity and unambiguity of the function name. NOTE: the purpose of name is to provide stable means of unique identification of every contract; for this reason try to avoid elements - which can change in the most obvious refactors. + which can change in some obvious refactors. * Do not use `std::unreachable` -* Do not put contracts where they can be easily violated by an external - condition (e.g. timing, data payload before mandatory validation etc.) as - this creates bogus bug reports. +* Do not put contracts where they can be violated by an external condition + (e.g. timing, data payload before mandatory validation etc.) as this creates + bogus bug reports (and causes crashes of Debug builds) ## Unit Tests To execute all unit tests: From c6a9dd508ef50777d14ed1133123ab13b48be01c Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Wed, 2 Oct 2024 13:18:36 +0100 Subject: [PATCH 13/18] Bump antithesis-sdk to 0.3.2 This is not a real version as in https://github.com/antithesishq/antithesis-sdk-cpp/tags ; it is based on version 0.3.1 but with added default constructor to antithesis::JSON similar to https://github.com/antithesishq/antithesis-sdk-cpp/pull/17 This default constructor allows us to skip the constructor parameters (including dummy `{}`) for the JSON parameter of instrumentation macros --- external/antithesis-sdk/CMakeLists.txt | 2 +- external/antithesis-sdk/antithesis_sdk.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/external/antithesis-sdk/CMakeLists.txt b/external/antithesis-sdk/CMakeLists.txt index eff594131d0..177a5026aa7 100644 --- a/external/antithesis-sdk/CMakeLists.txt +++ b/external/antithesis-sdk/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(antithesis-sdk-cpp VERSION 0.3.1 LANGUAGES CXX) +project(antithesis-sdk-cpp VERSION 0.3.2 LANGUAGES CXX) add_library(antithesis-sdk-cpp INTERFACE antithesis_sdk.h) diff --git a/external/antithesis-sdk/antithesis_sdk.h b/external/antithesis-sdk/antithesis_sdk.h index 60fb1e882f0..2689e7f13a5 100644 --- a/external/antithesis-sdk/antithesis_sdk.h +++ b/external/antithesis-sdk/antithesis_sdk.h @@ -13,7 +13,7 @@ #include namespace antithesis { - inline const char* SDK_VERSION = "0.3.1"; + inline const char* SDK_VERSION = "0.3.2"; inline const char* PROTOCOL_VERSION = "1.0.0"; struct LocalRandom { @@ -38,6 +38,7 @@ namespace antithesis { typedef std::variant ValueType; struct JSON : std::map { + JSON() : std::map() {} JSON( std::initializer_list> args) : std::map(args) {} }; From 62483d5c7e26438bf9dc1ab3b1ba4a52e62bc33e Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 1 Oct 2024 17:00:23 +0100 Subject: [PATCH 14/18] Define ASSERT consistently with other instrumentation macros This also removes XRPL_UNREACHABLE, since the default JSON constructor allows us to use UNREACHABLE macro as-is, without the extra parameter --- CONTRIBUTING.md | 28 ++- include/xrpl/basics/Buffer.h | 6 +- include/xrpl/basics/FeeUnits.h | 14 +- include/xrpl/basics/MathUtilities.h | 2 +- include/xrpl/basics/SlabAllocator.h | 19 +- include/xrpl/basics/Slice.h | 6 +- include/xrpl/basics/base_uint.h | 12 +- .../xrpl/basics/partitioned_unordered_map.h | 6 +- include/xrpl/basics/random.h | 2 +- include/xrpl/basics/spinlock.h | 6 +- include/xrpl/beast/asio/io_latency_probe.h | 12 +- include/xrpl/beast/clock/manual_clock.h | 12 +- .../detail/aged_unordered_container.h | 12 +- include/xrpl/beast/core/LexicalCast.h | 9 +- include/xrpl/beast/net/IPAddress.h | 2 +- include/xrpl/beast/utility/Journal.h | 6 +- include/xrpl/beast/utility/instrumentation.h | 36 ++-- include/xrpl/beast/utility/rngfill.h | 4 +- include/xrpl/protocol/AmountConversions.h | 22 +- include/xrpl/protocol/Feature.h | 18 +- include/xrpl/protocol/Indexes.h | 3 +- include/xrpl/protocol/MultiApiJson.h | 12 +- include/xrpl/protocol/Quality.h | 6 +- include/xrpl/protocol/STBitString.h | 9 +- include/xrpl/protocol/STInteger.h | 9 +- include/xrpl/protocol/STObject.h | 39 ++-- include/xrpl/protocol/STPathSet.h | 12 +- include/xrpl/protocol/STValidation.h | 12 +- include/xrpl/protocol/Serializer.h | 9 +- include/xrpl/protocol/TxMeta.h | 6 +- include/xrpl/protocol/detail/b58_utils.h | 20 +- include/xrpl/resource/detail/Logic.h | 8 +- include/xrpl/server/detail/BaseWSPeer.h | 6 +- src/libxrpl/basics/Log.cpp | 8 +- src/libxrpl/basics/Number.cpp | 33 ++- src/libxrpl/basics/ResolverAsio.cpp | 49 +++-- .../beast/clock/basic_seconds_clock.cpp | 6 +- src/libxrpl/beast/core/SemanticVersion.cpp | 10 +- src/libxrpl/beast/insight/StatsDCollector.cpp | 6 +- .../utility/src/beast_PropertyStream.cpp | 12 +- src/libxrpl/crypto/RFC1751.cpp | 24 +-- src/libxrpl/json/Object.cpp | 6 +- src/libxrpl/json/json_reader.cpp | 2 +- src/libxrpl/json/json_value.cpp | 68 +++--- src/libxrpl/json/json_writer.cpp | 28 +-- src/libxrpl/protocol/AMMCore.cpp | 6 +- src/libxrpl/protocol/AccountID.cpp | 6 +- src/libxrpl/protocol/ErrorCodes.cpp | 6 +- src/libxrpl/protocol/Feature.cpp | 24 +-- src/libxrpl/protocol/Indexes.cpp | 20 +- src/libxrpl/protocol/Keylet.cpp | 6 +- src/libxrpl/protocol/Quality.cpp | 42 ++-- src/libxrpl/protocol/Rate2.cpp | 22 +- src/libxrpl/protocol/Rules.cpp | 14 +- src/libxrpl/protocol/STAccount.cpp | 9 +- src/libxrpl/protocol/STAmount.cpp | 76 +++---- src/libxrpl/protocol/STBase.cpp | 15 +- src/libxrpl/protocol/STBlob.cpp | 8 +- src/libxrpl/protocol/STInteger.cpp | 6 +- src/libxrpl/protocol/STLedgerEntry.cpp | 6 +- src/libxrpl/protocol/STObject.cpp | 6 +- src/libxrpl/protocol/STPathSet.cpp | 9 +- src/libxrpl/protocol/STTx.cpp | 10 +- src/libxrpl/protocol/STValidation.cpp | 6 +- src/libxrpl/protocol/STVar.cpp | 6 +- src/libxrpl/protocol/STVector256.cpp | 9 +- src/libxrpl/protocol/Serializer.cpp | 16 +- src/libxrpl/protocol/TxMeta.cpp | 47 ++--- src/libxrpl/protocol/tokens.cpp | 14 +- src/libxrpl/resource/Consumer.cpp | 24 +-- src/xrpld/app/consensus/RCLConsensus.cpp | 36 ++-- src/xrpld/app/consensus/RCLCxPeerPos.cpp | 6 +- src/xrpld/app/consensus/RCLCxTx.h | 11 +- src/xrpld/app/consensus/RCLValidations.cpp | 24 +-- src/xrpld/app/ledger/AcceptedLedgerTx.cpp | 12 +- src/xrpld/app/ledger/ConsensusTransSetSF.cpp | 13 +- src/xrpld/app/ledger/Ledger.cpp | 51 ++--- src/xrpld/app/ledger/LedgerHistory.cpp | 76 +++---- src/xrpld/app/ledger/OpenLedger.h | 4 +- src/xrpld/app/ledger/OrderBookDB.cpp | 6 +- src/xrpld/app/ledger/TransactionStateSF.cpp | 6 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 15 +- src/xrpld/app/ledger/detail/InboundLedger.cpp | 42 ++-- .../app/ledger/detail/InboundLedgers.cpp | 25 +-- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 12 +- .../app/ledger/detail/LedgerDeltaAcquire.cpp | 14 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 69 +++--- .../app/ledger/detail/LedgerReplayTask.cpp | 27 +-- .../app/ledger/detail/LedgerReplayer.cpp | 6 +- .../app/ledger/detail/SkipListAcquire.cpp | 8 +- .../app/ledger/detail/TimeoutCounter.cpp | 6 +- src/xrpld/app/main/Application.cpp | 67 +++--- src/xrpld/app/main/GRPCServer.cpp | 2 +- src/xrpld/app/main/LoadManager.cpp | 6 +- src/xrpld/app/misc/FeeVoteImpl.cpp | 6 +- src/xrpld/app/misc/HashRouter.cpp | 2 +- src/xrpld/app/misc/NegativeUNLVote.cpp | 18 +- src/xrpld/app/misc/NetworkOPs.cpp | 89 ++++---- src/xrpld/app/misc/SHAMapStoreImp.cpp | 6 +- src/xrpld/app/misc/detail/AMMHelpers.cpp | 6 +- src/xrpld/app/misc/detail/AMMUtils.cpp | 6 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 6 +- src/xrpld/app/misc/detail/Manifest.cpp | 6 +- src/xrpld/app/misc/detail/Transaction.cpp | 6 +- src/xrpld/app/misc/detail/TxQ.cpp | 119 +++++------ src/xrpld/app/misc/detail/ValidatorList.cpp | 146 ++++++------- src/xrpld/app/misc/detail/ValidatorSite.cpp | 12 +- src/xrpld/app/misc/detail/WorkBase.h | 4 +- src/xrpld/app/misc/detail/WorkFile.h | 2 +- src/xrpld/app/paths/Credit.cpp | 24 +-- src/xrpld/app/paths/Flow.cpp | 2 +- src/xrpld/app/paths/PathRequest.cpp | 3 +- src/xrpld/app/paths/Pathfinder.cpp | 29 ++- src/xrpld/app/paths/RippleLineCache.cpp | 18 +- src/xrpld/app/paths/detail/AMMLiquidity.cpp | 6 +- src/xrpld/app/paths/detail/AmountSpec.h | 26 ++- src/xrpld/app/paths/detail/BookStep.cpp | 22 +- src/xrpld/app/paths/detail/DirectStep.cpp | 20 +- src/xrpld/app/paths/detail/FlowDebugInfo.h | 8 +- src/xrpld/app/paths/detail/PaySteps.cpp | 15 +- src/xrpld/app/paths/detail/StepChecks.h | 2 +- src/xrpld/app/paths/detail/StrandFlow.h | 20 +- .../app/paths/detail/XRPEndpointStep.cpp | 5 +- src/xrpld/app/rdb/RelationalDatabase.h | 2 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 13 +- src/xrpld/app/rdb/detail/Vacuum.cpp | 11 +- src/xrpld/app/tx/detail/AMMBid.cpp | 8 +- src/xrpld/app/tx/detail/AMMDeposit.cpp | 6 +- src/xrpld/app/tx/detail/AMMVote.cpp | 6 +- src/xrpld/app/tx/detail/AMMWithdraw.cpp | 6 +- src/xrpld/app/tx/detail/ApplyContext.cpp | 6 +- src/xrpld/app/tx/detail/Change.cpp | 7 +- src/xrpld/app/tx/detail/CreateOffer.cpp | 61 +++--- src/xrpld/app/tx/detail/DeleteAccount.cpp | 23 +- src/xrpld/app/tx/detail/InvariantCheck.cpp | 10 +- src/xrpld/app/tx/detail/NFTokenMint.cpp | 6 +- src/xrpld/app/tx/detail/NFTokenUtils.cpp | 23 +- src/xrpld/app/tx/detail/Offer.h | 2 +- src/xrpld/app/tx/detail/OfferStream.cpp | 6 +- src/xrpld/app/tx/detail/PayChan.cpp | 12 +- src/xrpld/app/tx/detail/Payment.cpp | 3 +- src/xrpld/app/tx/detail/SetSignerList.cpp | 32 +-- src/xrpld/app/tx/detail/Taker.cpp | 112 +++++----- src/xrpld/app/tx/detail/Transactor.cpp | 53 ++--- src/xrpld/app/tx/detail/XChainBridge.cpp | 6 +- src/xrpld/app/tx/detail/applySteps.cpp | 14 +- src/xrpld/consensus/Consensus.h | 40 ++-- src/xrpld/consensus/ConsensusTypes.h | 6 +- src/xrpld/consensus/LedgerTiming.h | 12 +- src/xrpld/consensus/LedgerTrie.h | 31 +-- src/xrpld/consensus/Validations.h | 9 +- src/xrpld/core/Coro.ipp | 6 +- src/xrpld/core/DatabaseCon.h | 6 +- src/xrpld/core/JobTypes.h | 33 +-- src/xrpld/core/detail/Config.cpp | 24 +-- src/xrpld/core/detail/DatabaseCon.cpp | 6 +- src/xrpld/core/detail/JobQueue.cpp | 115 +++++----- src/xrpld/core/detail/LoadEvent.cpp | 2 +- src/xrpld/core/detail/Workers.cpp | 6 +- src/xrpld/ledger/ApplyView.h | 2 +- src/xrpld/ledger/detail/ApplyStateTable.cpp | 50 ++--- src/xrpld/ledger/detail/ApplyView.cpp | 3 +- src/xrpld/ledger/detail/BookDirs.cpp | 31 ++- src/xrpld/ledger/detail/Dir.cpp | 28 +-- src/xrpld/ledger/detail/PaymentSandbox.cpp | 22 +- src/xrpld/ledger/detail/RawStateTable.cpp | 20 +- src/xrpld/ledger/detail/ReadViewFwdRange.ipp | 6 +- src/xrpld/ledger/detail/View.cpp | 115 +++++----- src/xrpld/net/detail/InfoSub.cpp | 4 +- src/xrpld/net/detail/RPCCall.cpp | 6 +- src/xrpld/nodestore/Database.h | 6 +- src/xrpld/nodestore/backend/MemoryFactory.cpp | 16 +- src/xrpld/nodestore/backend/NuDBFactory.cpp | 2 +- .../nodestore/backend/RocksDBFactory.cpp | 21 +- src/xrpld/nodestore/detail/BatchWriter.cpp | 6 +- src/xrpld/nodestore/detail/Database.cpp | 30 +-- src/xrpld/nodestore/detail/DatabaseNodeImp.h | 6 +- src/xrpld/nodestore/detail/DecodedBlob.cpp | 6 +- src/xrpld/nodestore/detail/EncodedBlob.h | 14 +- src/xrpld/nodestore/detail/ManagerImp.cpp | 6 +- src/xrpld/overlay/Compression.h | 4 +- src/xrpld/overlay/Slot.h | 6 +- src/xrpld/overlay/detail/ConnectAttempt.cpp | 6 +- src/xrpld/overlay/detail/Message.cpp | 12 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 37 ++-- src/xrpld/overlay/detail/OverlayImpl.h | 6 +- src/xrpld/overlay/detail/PeerImp.cpp | 73 +++---- src/xrpld/overlay/detail/ProtocolMessage.h | 6 +- src/xrpld/overlay/detail/TrafficCount.h | 6 +- src/xrpld/overlay/detail/ZeroCopyStream.h | 4 +- src/xrpld/peerfinder/detail/Bootcache.cpp | 12 +- src/xrpld/peerfinder/detail/Counts.h | 21 +- src/xrpld/peerfinder/detail/Handouts.h | 6 +- src/xrpld/peerfinder/detail/Livecache.h | 18 +- src/xrpld/peerfinder/detail/Logic.h | 62 +++--- src/xrpld/peerfinder/detail/SlotImp.cpp | 36 ++-- src/xrpld/perflog/detail/PerfLogImp.cpp | 18 +- src/xrpld/rpc/Status.h | 9 +- src/xrpld/rpc/detail/Handler.cpp | 20 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 36 ++-- src/xrpld/rpc/detail/RPCHelpers.h | 6 +- src/xrpld/rpc/detail/Role.cpp | 6 +- src/xrpld/rpc/detail/Status.cpp | 7 +- src/xrpld/rpc/detail/TransactionSign.cpp | 6 +- src/xrpld/rpc/handlers/AMMInfo.cpp | 16 +- src/xrpld/rpc/handlers/AccountChannels.cpp | 2 +- src/xrpld/rpc/handlers/AccountInfo.cpp | 12 +- src/xrpld/rpc/handlers/AccountLines.cpp | 2 +- src/xrpld/rpc/handlers/AccountOffers.cpp | 2 +- src/xrpld/rpc/handlers/AccountTx.cpp | 11 +- src/xrpld/rpc/handlers/Fee1.cpp | 2 +- src/xrpld/rpc/handlers/LedgerClosed.cpp | 3 +- src/xrpld/rpc/handlers/LedgerDiff.cpp | 6 +- src/xrpld/rpc/handlers/LedgerHandler.cpp | 11 +- src/xrpld/rpc/handlers/PayChanClaim.cpp | 6 +- src/xrpld/rpc/handlers/Tx.cpp | 3 +- src/xrpld/shamap/SHAMap.h | 18 +- src/xrpld/shamap/SHAMapItem.h | 6 +- src/xrpld/shamap/detail/SHAMap.cpp | 196 +++++++++--------- src/xrpld/shamap/detail/SHAMapDelta.cpp | 16 +- src/xrpld/shamap/detail/SHAMapInnerNode.cpp | 146 ++++++------- src/xrpld/shamap/detail/SHAMapLeafNode.cpp | 22 +- src/xrpld/shamap/detail/SHAMapNodeID.cpp | 34 +-- src/xrpld/shamap/detail/SHAMapSync.cpp | 33 ++- src/xrpld/shamap/detail/TaggedPointer.ipp | 44 ++-- 225 files changed, 2192 insertions(+), 2174 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 912b34d0493..001236ac706 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -349,14 +349,19 @@ We are using [Antithesis](https://antithesis.com/) for continuous fuzzing, and keep a copy of [Antithesis C++ SDK](https://github.com/antithesishq/antithesis-sdk-cpp/) in `external/antithesis-sdk`. One of the aims of fuzzing is to identify bugs by finding external conditions which cause contracts violations inside `rippled`. -The contracts are expressed as `XRPL_ASSERT` or `XRPL_UNREACHABLE` (defined in +The contracts are expressed as `ASSERT` or `UNREACHABLE` (defined in `include/xrpl/beast/utility/instrumentation.h`), which are effectively (outside of Antithesis) wrappers for `assert(...)` with added name. The purpose of name is to provide contracts with stable identity which does not rely on line numbers. When `rippled` is built with the Antithesis instrumentation enabled -(using `voidstar` CMake option), the `XRPL_...` contracts will report any -violations on the Antithesis platform during fuzzing. +(using `voidstar` CMake option) and ran on the Antithesis platform, the +contracts become +[test properties](https://antithesis.com/docs/using_antithesis/properties.html); +otherwise they are just like a regular `assert`. +To learn more about Antithesis, see +[How Antithesis Works](https://antithesis.com/docs/introduction/how_antithesis_works.html) +and [C++ SDK](https://antithesis.com/docs/using_antithesis/sdk/cpp/overview.html#) We continue to use the old style `assert` or `assert(false)` in certain locations, where the reporting of contract violations on the Antithesis @@ -367,19 +372,28 @@ For this reason: * `constexpr` functions * unit tests i.e. files under `src/test` * unit tests-related modules (files under `beast/test` and `beast/unit_test`) -* Outside of the listed locations, do not use `assert`; use `XRPL_ASSERT` instead, +* Outside of the listed locations, do not use `assert`; use `ASSERT` instead, giving it unique name, with the short description of the contract. * Outside of the listed locations, do not user `assert(false)`; use - `XRPL_UNREACHABLE` instead, giving it unique name, with the description of the + `UNREACHABLE` instead, giving it unique name, with the description of the condition being violated * The contract name should start with a full name (including scope) of the function, optionally a named lambda, followed by a colon ` : ` and a brief - (typically at most five words) description. `XRPL_UNREACHABLE` contracts + (typically at most five words) description. `UNREACHABLE` contracts can use slightly longer descriptions. If there are multiple overloads of the function, use common sense to balance both brevity and unambiguity of the function name. NOTE: the purpose of name is to provide stable means of unique identification of every contract; for this reason try to avoid elements - which can change in some obvious refactors. + which can change in some obvious refactors or when reinforcing the condition. +* Example good name for an + `UNREACHABLE` macro `"Json::operator==(Value, Value) : invalid type"`; example + good name for an `ASSERT` macro `"Json::Value::asCString : valid type"`. +* Example **bad** name + `"RFC1751::insert(char* s, int x, int start, int length) : length is greater than or equal zero"` + (missing namespace, unnecessary full function signature, description too verbose). + Good name: `"ripple::RFC1751::insert : minimum length"`. +* Do **not** rename a contract without a good reason (e.g. the name no longer + reflects the location or the condition being checked) * Do not use `std::unreachable` * Do not put contracts where they can be violated by an external condition (e.g. timing, data payload before mandatory validation etc.) as this creates diff --git a/include/xrpl/basics/Buffer.h b/include/xrpl/basics/Buffer.h index 8fd82e91255..733db0bdb72 100644 --- a/include/xrpl/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -112,10 +112,10 @@ class Buffer operator=(Slice s) { // Ensure the slice isn't a subset of the buffer. - XRPL_ASSERT( - "ripple::Buffer::operator=(Slice) : input not a subset", + ASSERT( s.size() == 0 || size_ == 0 || s.data() < p_.get() || - s.data() >= p_.get() + size_); + s.data() >= p_.get() + size_, + "ripple::Buffer::operator=(Slice) : input not a subset"); if (auto p = alloc(s.size())) std::memcpy(p, s.data(), s.size()); diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 642a90fa723..2f910295c7f 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -417,13 +417,13 @@ mulDivU(Source1 value, Dest mul, Source2 div) { // split the asserts so if one hits, the user can tell which // without a debugger. - XRPL_ASSERT( - "ripple::feeunit::mulDivU : minimum value input", - value.value() >= 0); - XRPL_ASSERT( - "ripple::feeunit::mulDivU : minimum mul input", mul.value() >= 0); - XRPL_ASSERT( - "ripple::feeunit::mulDivU : minimum div input", div.value() >= 0); + ASSERT( + value.value() >= 0, + "ripple::feeunit::mulDivU : minimum value input"); + ASSERT( + mul.value() >= 0, "ripple::feeunit::mulDivU : minimum mul input"); + ASSERT( + div.value() >= 0, "ripple::feeunit::mulDivU : minimum div input"); return std::nullopt; } diff --git a/include/xrpl/basics/MathUtilities.h b/include/xrpl/basics/MathUtilities.h index 516c07f377f..45b8fc485cc 100644 --- a/include/xrpl/basics/MathUtilities.h +++ b/include/xrpl/basics/MathUtilities.h @@ -43,7 +43,7 @@ namespace ripple { constexpr std::size_t calculatePercent(std::size_t count, std::size_t total) { - assert(total != 0); // NOTE No XRPL_ASSERT here, because constexpr + assert(total != 0); // NOTE No ASSERT here, because constexpr return ((std::min(count, total) * 100) + total - 1) / total; } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 9df93dc5681..147231299e7 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -143,9 +143,9 @@ class SlabAllocator void deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT( - "ripple::SlabAllocator::SlabBlock::deallocate : own input", - own(ptr)); + ASSERT( + own(ptr), + "ripple::SlabAllocator::SlabBlock::deallocate : own input"); std::lock_guard l(m_); @@ -188,9 +188,9 @@ class SlabAllocator boost::alignment::align_up(sizeof(Type) + extra, itemAlignment_)) , slabSize_(alloc) { - XRPL_ASSERT( - "ripple::SlabAllocator::SlabAllocator : valid alignment", - (itemAlignment_ & (itemAlignment_ - 1)) == 0); + ASSERT( + (itemAlignment_ & (itemAlignment_ - 1)) == 0, + "ripple::SlabAllocator::SlabAllocator : valid alignment"); } SlabAllocator(SlabAllocator const& other) = delete; @@ -300,9 +300,10 @@ class SlabAllocator bool deallocate(std::uint8_t* ptr) noexcept { - XRPL_ASSERT( - "ripple::SlabAllocator::SlabAllocator::deallocate : non-null input", - ptr); + ASSERT( + ptr != nullptr, + "ripple::SlabAllocator::SlabAllocator::deallocate : non-null " + "input"); for (auto slab = slabs_.load(); slab != nullptr; slab = slab->next_) { diff --git a/include/xrpl/basics/Slice.h b/include/xrpl/basics/Slice.h index cdf56e58b21..c10ca0b0e96 100644 --- a/include/xrpl/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -103,9 +103,9 @@ class Slice std::uint8_t operator[](std::size_t i) const noexcept { - XRPL_ASSERT( - "ripple::Slice::operator[](std::size_t) const : input within range", - i < size_); + ASSERT( + i < size_, + "ripple::Slice::operator[](std::size_t) const : valid input"); return data_[i]; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index 8114e496989..ea99cdf420e 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -290,9 +290,9 @@ class base_uint std::is_trivially_copyable::value>> explicit base_uint(Container const& c) { - XRPL_ASSERT( - "ripple::base_uint::base_uint(Container auto) : input size match", - c.size() * sizeof(typename Container::value_type) == size()); + ASSERT( + c.size() * sizeof(typename Container::value_type) == size(), + "ripple::base_uint::base_uint(Container auto) : input size match"); std::memcpy(data_.data(), c.data(), size()); } @@ -303,9 +303,9 @@ class base_uint base_uint&> operator=(Container const& c) { - XRPL_ASSERT( - "ripple::base_uint::operator=(Container auto) : input size match", - c.size() * sizeof(typename Container::value_type) == size()); + ASSERT( + c.size() * sizeof(typename Container::value_type) == size(), + "ripple::base_uint::operator=(Container auto) : input size match"); std::memcpy(data_.data(), c.data(), size()); return *this; } diff --git a/include/xrpl/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h index 606bdd92d1a..c8e31906dc4 100644 --- a/include/xrpl/basics/partitioned_unordered_map.h +++ b/include/xrpl/basics/partitioned_unordered_map.h @@ -246,10 +246,10 @@ class partitioned_unordered_map ? *partitions : std::thread::hardware_concurrency(); map_.resize(partitions_); - XRPL_ASSERT( + ASSERT( + partitions_ != 0, "ripple::partitioned_unordered_map::partitioned_unordered_map : " - "nonzero partitions", - partitions_); + "nonzero partitions"); } std::size_t diff --git a/include/xrpl/basics/random.h b/include/xrpl/basics/random.h index 20209231d35..41369d2a454 100644 --- a/include/xrpl/basics/random.h +++ b/include/xrpl/basics/random.h @@ -114,7 +114,7 @@ std::enable_if_t< Integral> rand_int(Engine& engine, Integral min, Integral max) { - XRPL_ASSERT("ripple::rand_int : max over min inputs", max > min); + ASSERT(max > min, "ripple::rand_int : max over min inputs"); // This should have no state and constructing it should // be very cheap. If that turns out not to be the case diff --git a/include/xrpl/basics/spinlock.h b/include/xrpl/basics/spinlock.h index 663f6c733a3..92514478c4f 100644 --- a/include/xrpl/basics/spinlock.h +++ b/include/xrpl/basics/spinlock.h @@ -117,9 +117,9 @@ class packed_spinlock packed_spinlock(std::atomic& lock, int index) : bits_(lock), mask_(static_cast(1) << index) { - XRPL_ASSERT( - "ripple::packed_spinlock::packed_spinlock : valid index and mask", - index >= 0 && (mask_ != 0)); + ASSERT( + index >= 0 && (mask_ != 0), + "ripple::packed_spinlock::packed_spinlock : valid index and mask"); } [[nodiscard]] bool diff --git a/include/xrpl/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h index 7117d2223a5..fb4f5f9f6a2 100644 --- a/include/xrpl/beast/asio/io_latency_probe.h +++ b/include/xrpl/beast/asio/io_latency_probe.h @@ -174,10 +174,10 @@ class io_latency_probe , m_repeat(repeat) , m_probe(probe) { - XRPL_ASSERT( + ASSERT( + m_probe != nullptr, "beast::io_latency_probe::sample_op::sample_op : non-null " - "probe input", - m_probe); + "probe input"); m_probe->addref(); } @@ -187,10 +187,10 @@ class io_latency_probe , m_repeat(from.m_repeat) , m_probe(from.m_probe) { - XRPL_ASSERT( + ASSERT( + m_probe != nullptr, "beast::io_latency_probe::sample_op::sample_op(sample_op&&) : " - "non-null probe input", - m_probe); + "non-null probe input"); from.m_probe = nullptr; } diff --git a/include/xrpl/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h index 5ff4504f788..505cbe27208 100644 --- a/include/xrpl/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -61,9 +61,9 @@ class manual_clock : public abstract_clock void set(time_point const& when) { - XRPL_ASSERT( - "beast::manual_clock::set(time_point) : forward input", - !Clock::is_steady || when >= now_); + ASSERT( + !Clock::is_steady || when >= now_, + "beast::manual_clock::set(time_point) : forward input"); now_ = when; } @@ -80,9 +80,9 @@ class manual_clock : public abstract_clock void advance(std::chrono::duration const& elapsed) { - XRPL_ASSERT( - "beast::manual_clock::advance(duration) : forward input", - !Clock::is_steady || (now_ + elapsed) >= now_); + ASSERT( + !Clock::is_steady || (now_ + elapsed) >= now_, + "beast::manual_clock::advance(duration) : forward input"); now_ += elapsed; } diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index 9131351f5fb..a2c5b4d3657 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1329,10 +1329,10 @@ class aged_unordered_container size_type bucket(Key const& k) const { - XRPL_ASSERT( + ASSERT( + bucket_count() != 0, "beast::detail::aged_unordered_container::bucket : nonzero bucket " - "count", - bucket_count() != 0); + "count"); return m_cont.bucket(k, std::cref(m_config.hash_function())); } @@ -1473,10 +1473,10 @@ class aged_unordered_container { if (would_exceed(additional)) m_buck.resize(size() + additional, m_cont); - XRPL_ASSERT( + ASSERT( + load_factor() <= max_load_factor(), "beast::detail::aged_unordered_container::maybe_rehash : maximum " - "load factor", - load_factor() <= max_load_factor()); + "load factor"); } // map, set diff --git a/include/xrpl/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h index f5a380ce541..0a7f2379daf 100644 --- a/include/xrpl/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -160,8 +160,9 @@ struct LexicalCast bool operator()(Out& out, char const* in) const { - XRPL_ASSERT( - "beast::detail::LexicalCast(char const*) : non-null input", in); + ASSERT( + in != nullptr, + "beast::detail::LexicalCast(char const*) : non-null input"); return LexicalCast()(out, in); } }; @@ -176,7 +177,9 @@ struct LexicalCast bool operator()(Out& out, char* in) const { - XRPL_ASSERT("beast::detail::LexicalCast(char*) : non-null input", in); + ASSERT( + in != nullptr, + "beast::detail::LexicalCast(char*) : non-null input"); return LexicalCast()(out, in); } }; diff --git a/include/xrpl/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h index f16c204f7ff..cdac4abbd9c 100644 --- a/include/xrpl/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -96,7 +96,7 @@ hash_append(Hasher& h, beast::IP::Address const& addr) noexcept else if (addr.is_v6()) hash_append(h, addr.to_v6().to_bytes()); else - XRPL_UNREACHABLE("beast::hash_append : invalid address type"); + UNREACHABLE("beast::hash_append : invalid address type"); } } // namespace beast diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index 5e5b9a6cedd..f407dee1fff 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -205,9 +205,9 @@ class Journal */ Stream(Sink& sink, Severity level) : m_sink(sink), m_level(level) { - XRPL_ASSERT( - "beast::Journal::Stream::Stream : maximum level", - m_level < severities::kDisabled); + ASSERT( + m_level < severities::kDisabled, + "beast::Journal::Stream::Stream : maximum level"); } /** Construct or copy another Stream. */ diff --git a/include/xrpl/beast/utility/instrumentation.h b/include/xrpl/beast/utility/instrumentation.h index 4adac878a04..9dfb5bc89f8 100644 --- a/include/xrpl/beast/utility/instrumentation.h +++ b/include/xrpl/beast/utility/instrumentation.h @@ -28,19 +28,31 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #endif #include #else -#define ALWAYS(cond, message, ...) -#define ALWAYS_OR_UNREACHABLE(cond, message, ...) assert(message && (cond)) -#define SOMETIMES(cond, message, ...) -#define REACHABLE(message, ...) -#define UNREACHABLE(message, ...) assert(message && false) +#define ALWAYS(cond, name, ...) assert((name) && (cond)) +#define ALWAYS_OR_UNREACHABLE(cond, name, ...) assert((name) && (cond)) +#define SOMETIMES(cond, name, ...) +#define REACHABLE(name, ...) +#define UNREACHABLE(name, ...) assert((name) && false) #endif -#ifndef NDEBUG -#define XRPL_ASSERT(M, ...) ALWAYS_OR_UNREACHABLE(((bool)(__VA_ARGS__)), M, {}) -#define XRPL_UNREACHABLE(M) UNREACHABLE(M, {}) -#else -#define XRPL_ASSERT(...) -#define XRPL_UNREACHABLE(M) -#endif +#define ASSERT ALWAYS_OR_UNREACHABLE + +// How to use the above macros: +// +// ALWAYS if it must be reached during fuzzing +// ASSERT if you expect that it might, or might not, be reached during fuzzing +// REACHABLE if it must be reached during fuzzing +// SOMETIMES a hint for the fuzzer to try to make the condition true +// UNREACHABLE if it must not be reached (in fuzzing or in normal use) +// +// NOTE: ASSERT has similar semantics as assert macro, with minor differences: +// * ASSERT must have an unique name (naming convention in CONTRIBUTING.md) +// * the condition (which comes first) must be *implicitly* convertible to bool +// * during fuzzing, the program will continue execution past a failed ASSERT +// We continue to use assert inside unit tests and in constexpr functions. +// +// NOTE: UNREACHABLE does *not* have the same semantics as std::unreachable. +// The program will continue execution past an UNREACHABLE in a Release build +// and during fuzzing (similar to ASSERT). #endif diff --git a/include/xrpl/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h index e66bfa3f466..3be6aa307b3 100644 --- a/include/xrpl/beast/utility/rngfill.h +++ b/include/xrpl/beast/utility/rngfill.h @@ -42,8 +42,8 @@ rngfill(void* buffer, std::size_t bytes, Generator& g) bytes -= sizeof(v); } - XRPL_ASSERT( - "beast::rngfill(void*) : maximum bytes", bytes < sizeof(result_type)); + ASSERT( + bytes < sizeof(result_type), "beast::rngfill(void*) : maximum bytes"); #ifdef __GNUC__ // gcc 11.1 (falsely) warns about an array-bounds overflow in release mode. diff --git a/include/xrpl/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h index 16de1a435c3..61a1a612582 100644 --- a/include/xrpl/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -59,9 +59,9 @@ toSTAmount(XRPAmount const& xrp) inline STAmount toSTAmount(XRPAmount const& xrp, Issue const& iss) { - XRPL_ASSERT( - "ripple::toSTAmount : is XRP", - isXRP(iss.account) && isXRP(iss.currency)); + ASSERT( + isXRP(iss.account) && isXRP(iss.currency), + "ripple::toSTAmount : is XRP"); return toSTAmount(xrp); } @@ -80,14 +80,14 @@ template <> inline IOUAmount toAmount(STAmount const& amt) { - XRPL_ASSERT( - "ripple::toAmount : maximum mantissa", - amt.mantissa() < std::numeric_limits::max()); + ASSERT( + amt.mantissa() < std::numeric_limits::max(), + "ripple::toAmount : maximum mantissa"); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT("ripple::toAmount : is not XRP", !isXRP(amt)); + ASSERT(!isXRP(amt), "ripple::toAmount : is not XRP"); return IOUAmount(sMant, amt.exponent()); } @@ -95,14 +95,14 @@ template <> inline XRPAmount toAmount(STAmount const& amt) { - XRPL_ASSERT( - "ripple::toAmount : maximum mantissa", - amt.mantissa() < std::numeric_limits::max()); + ASSERT( + amt.mantissa() < std::numeric_limits::max(), + "ripple::toAmount : maximum mantissa"); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); - XRPL_ASSERT("ripple::toAmount : is XRP", isXRP(amt)); + ASSERT(isXRP(amt), "ripple::toAmount : is XRP"); return XRPAmount(sMant); } diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 6ec76bfef37..15c77b8fb7f 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -151,19 +151,19 @@ class FeatureBitset : private std::bitset explicit FeatureBitset(base const& b) : base(b) { - XRPL_ASSERT( - "ripple::FeatureBitset::FeatureBitset(base) : count match", - b.count() == count()); + ASSERT( + b.count() == count(), + "ripple::FeatureBitset::FeatureBitset(base) : count match"); } template explicit FeatureBitset(uint256 const& f, Fs&&... fs) { initFromFeatures(f, std::forward(fs)...); - XRPL_ASSERT( + ASSERT( + count() == (sizeof...(fs) + 1), "ripple::FeatureBitset::FeatureBitset(uint256) : count and " - "sizeof... do match", - count() == (sizeof...(fs) + 1)); + "sizeof... do match"); } template @@ -171,10 +171,10 @@ class FeatureBitset : private std::bitset { for (auto const& f : fs) set(featureToBitsetIndex(f)); - XRPL_ASSERT( + ASSERT( + fs.size() == count(), "ripple::FeatureBitset::FeatureBitset(Container auto) : count and " - "size do match", - fs.size() == count()); + "size do match"); } auto diff --git a/include/xrpl/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h index aabee9a2f9a..b28ac1332c6 100644 --- a/include/xrpl/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -214,8 +214,7 @@ page(uint256 const& root, std::uint64_t index = 0) noexcept; inline Keylet page(Keylet const& root, std::uint64_t index = 0) noexcept { - XRPL_ASSERT( - "ripple::keylet::page : valid root type", root.type == ltDIR_NODE); + ASSERT(root.type == ltDIR_NODE, "ripple::keylet::page : valid root type"); return page(root.key, index); } /** @} */ diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 7d7a160ae13..7f7c8521f0a 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -158,10 +158,10 @@ struct MultiApiJson -> std:: invoke_result_t { - XRPL_ASSERT( + ASSERT( + valid(version) && index(version) >= 0 && index(version) < size, "ripple::detail::MultiApiJson::operator() : valid " - "version", - valid(version) && index(version) >= 0 && index(version) < size); + "version"); return std::invoke( fn, json.val[index(version)], @@ -177,9 +177,9 @@ struct MultiApiJson operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { - XRPL_ASSERT( - "ripple::detail::MultiApiJson::operator() : valid version", - valid(version) && index(version) >= 0 && index(version) < size); + ASSERT( + valid(version) && index(version) >= 0 && index(version) < size, + "ripple::detail::MultiApiJson::operator() : valid version"); return std::invoke(fn, json.val[index(version)]); } } visitor = {}; diff --git a/include/xrpl/protocol/Quality.h b/include/xrpl/protocol/Quality.h index 781756b436a..fac9dd29a43 100644 --- a/include/xrpl/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -298,9 +298,9 @@ class Quality friend double relativeDistance(Quality const& q1, Quality const& q2) { - XRPL_ASSERT( - "ripple::Quality::relativeDistance : minimum inputs", - q1.m_value > 0 && q2.m_value > 0); + ASSERT( + q1.m_value > 0 && q2.m_value > 0, + "ripple::Quality::relativeDistance : minimum inputs"); if (q1.m_value == q2.m_value) // make expected common case fast return 0; diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index a8bcb3b3834..9f2084561b5 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -162,11 +162,10 @@ template void STBitString::add(Serializer& s) const { - XRPL_ASSERT( - "ripple::STBitString::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STBitString::add : field type match", - getFName().fieldType == getSType()); + ASSERT(getFName().isBinary(), "ripple::STBitString::add : field is binary"); + ASSERT( + getFName().fieldType == getSType(), + "ripple::STBitString::add : field type match"); s.addBitString(value_); } diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index 733d3c8bd9b..8dc6b7ff1a3 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -110,11 +110,10 @@ template inline void STInteger::add(Serializer& s) const { - XRPL_ASSERT( - "ripple::STInteger::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STInteger::add : field type match", - getFName().fieldType == getSType()); + ASSERT(getFName().isBinary(), "ripple::STInteger::add : field is binary"); + ASSERT( + getFName().fieldType == getSType(), + "ripple::STInteger::add : field type match"); s.addInteger(value_); } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 2884960ae0a..e1485120c58 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -715,7 +715,8 @@ STObject::Proxy::assign(U&& u) t = dynamic_cast(st_->getPField(*f_, true)); else t = dynamic_cast(st_->makeFieldPresent(*f_)); - XRPL_ASSERT("ripple::STObject::Proxy::assign : type cast succeeded", t); + ASSERT( + t != nullptr, "ripple::STObject::Proxy::assign : type cast succeeded"); *t = std::forward(u); } @@ -993,19 +994,19 @@ STObject::at(TypedField const& f) const if (auto const u = dynamic_cast(b)) return u->value(); - XRPL_ASSERT( - "ripple::STObject::at(TypedField auto) : field template non-null", - mType); - XRPL_ASSERT( - "ripple::STObject::at(TypedField auto) : type not present", - b->getSType() == STI_NOTPRESENT); + ASSERT( + mType != nullptr, + "ripple::STObject::at(TypedField auto) : field template non-null"); + ASSERT( + b->getSType() == STI_NOTPRESENT, + "ripple::STObject::at(TypedField auto) : type not present"); if (mType->style(f) == soeOPTIONAL) Throw("Missing optional field: " + f.getName()); - XRPL_ASSERT( - "ripple::STObject::at(TypedField auto) : template style is default", - mType->style(f) == soeDEFAULT); + ASSERT( + mType->style(f) == soeDEFAULT, + "ripple::STObject::at(TypedField auto) : template style is default"); // Used to help handle the case where value_type is a const reference, // otherwise we would return the address of a temporary. @@ -1023,19 +1024,19 @@ STObject::at(OptionaledField const& of) const auto const u = dynamic_cast(b); if (!u) { - XRPL_ASSERT( + ASSERT( + mType != nullptr, "ripple::STObject::at(OptionaledField auto) : field template " - "non-null", - mType); - XRPL_ASSERT( - "ripple::STObject::at(OptionaledField auto) : type not present", - b->getSType() == STI_NOTPRESENT); + "non-null"); + ASSERT( + b->getSType() == STI_NOTPRESENT, + "ripple::STObject::at(OptionaledField auto) : type not present"); if (mType->style(*of.f) == soeOPTIONAL) return std::nullopt; - XRPL_ASSERT( + ASSERT( + mType->style(*of.f) == soeDEFAULT, "ripple::STObject::at(OptionaledField auto) : template style is " - "default", - mType->style(*of.f) == soeDEFAULT); + "default"); return typename T::value_type{}; } return u->value(); diff --git a/include/xrpl/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h index bbd69f7d202..754bb279238 100644 --- a/include/xrpl/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -257,9 +257,9 @@ inline STPathElement::STPathElement( is_offer_ = false; mAccountID = *account; mType |= typeAccount; - XRPL_ASSERT( - "ripple::STPathElement::STPathElement : account is set", - mAccountID != noAccount()); + ASSERT( + mAccountID != noAccount(), + "ripple::STPathElement::STPathElement : account is set"); } if (currency) @@ -272,9 +272,9 @@ inline STPathElement::STPathElement( { mIssuerID = *issuer; mType |= typeIssuer; - XRPL_ASSERT( - "ripple::STPathElement::STPathElement : issuer is set", - mIssuerID != noAccount()); + ASSERT( + mIssuerID != noAccount(), + "ripple::STPathElement::STPathElement : issuer is set"); } hash_value_ = get_hash(*this); diff --git a/include/xrpl/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h index f93358dfb33..69472f84e6d 100644 --- a/include/xrpl/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -176,9 +176,9 @@ STValidation::STValidation( Throw("Invalid signature in validation"); } - XRPL_ASSERT( - "ripple::STValidation::STValidation(SerialIter) : nonzero node", - nodeID_.isNonZero()); + ASSERT( + nodeID_.isNonZero(), + "ripple::STValidation::STValidation(SerialIter) : nonzero node"); } /** Construct, sign and trust a new STValidation issued by this node. @@ -201,10 +201,10 @@ STValidation::STValidation( , nodeID_(nodeID) , seenTime_(signTime) { - XRPL_ASSERT( + ASSERT( + nodeID_.isNonZero(), "ripple::STValidation::STValidation(PublicKey, SecretKey) : nonzero " - "node", - nodeID_.isNonZero()); + "node"); // First, set our own public key: if (publicKeyType(pk) != KeyType::secp256k1) diff --git a/include/xrpl/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h index aa637f92666..a7a7dabbf0e 100644 --- a/include/xrpl/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -55,9 +55,9 @@ class Serializer if (size) { - XRPL_ASSERT( - "ripple::Serializer::Serializer(void const*) : non-null input", - data != nullptr); + ASSERT( + data != nullptr, + "ripple::Serializer::Serializer(void const*) : non-null input"); std::memcpy(mData.data(), data, size); } } @@ -302,8 +302,7 @@ Serializer::addVL(Iter begin, Iter end, int len) len -= begin->size(); #endif } - XRPL_ASSERT( - "ripple::Serializer::addVL : length matches distance", len == 0); + ASSERT(len == 0, "ripple::Serializer::addVL : length matches distance"); return ret; } diff --git a/include/xrpl/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h index 7b55836c332..868efd854ff 100644 --- a/include/xrpl/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -116,9 +116,9 @@ class TxMeta STAmount getDeliveredAmount() const { - XRPL_ASSERT( - "ripple::TxMeta::getDeliveredAmount : non-null delivered amount", - hasDeliveredAmount()); + ASSERT( + hasDeliveredAmount(), + "ripple::TxMeta::getDeliveredAmount : non-null delivered amount"); return *mDelivered; } diff --git a/include/xrpl/protocol/detail/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h index 63701af37f5..960b3d8dcb6 100644 --- a/include/xrpl/protocol/detail/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -130,7 +130,7 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) { // should never happen, but if it does then it seems natural to define // the a null set of numbers to be zero, so the remainder is also zero. - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::b58_fast::detail::inplace_bigint_div_rem : empty " "numerator"); return 0; @@ -148,14 +148,14 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) unsigned __int128 const denom128 = denom; unsigned __int128 const d = num / denom128; unsigned __int128 const r = num - (denom128 * d); - XRPL_ASSERT( + ASSERT( + d >> 64 == 0, "ripple::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " - "valid division result", - d >> 64 == 0); - XRPL_ASSERT( + "valid division result"); + ASSERT( + r >> 64 == 0, "ripple::b58_fast::detail::inplace_bigint_div_rem::div_rem_64 : " - "valid remainder", - r >> 64 == 0); + "valid remainder"); return {static_cast(d), static_cast(r)}; }; @@ -178,9 +178,9 @@ inplace_bigint_div_rem(std::span numerator, std::uint64_t divisor) b58_10_to_b58_be(std::uint64_t input) { constexpr std::uint64_t B_58_10 = 430804206899405824; // 58^10; - XRPL_ASSERT( - "ripple::b58_fast::detail::b58_10_to_b58_be : valid input", - input < B_58_10); + ASSERT( + input < B_58_10, + "ripple::b58_fast::detail::b58_10_to_b58_be : valid input"); constexpr std::size_t resultSize = 10; std::array result{}; int i = 0; diff --git a/include/xrpl/resource/detail/Logic.h b/include/xrpl/resource/detail/Logic.h index a5b25e62f25..6b7830c07cd 100644 --- a/include/xrpl/resource/detail/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -401,9 +401,9 @@ class Logic { std::lock_guard _(lock_); Entry& entry(iter->second); - XRPL_ASSERT( - "ripple::Resource::Logic::erase : entry not used", - entry.refcount == 0); + ASSERT( + entry.refcount == 0, + "ripple::Resource::Logic::erase : entry not used"); inactive_.erase(inactive_.iterator_to(entry)); table_.erase(iter); } @@ -435,7 +435,7 @@ class Logic admin_.erase(admin_.iterator_to(entry)); break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::Resource::Logic::release : invalid entry " "kind"); break; diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index 2ab2b5236d4..8f3022bdf32 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -512,9 +512,9 @@ template void BaseWSPeer::fail(error_code ec, String const& what) { - XRPL_ASSERT( - "ripple::BaseWSPeer::fail : strand in this thread", - strand_.running_in_this_thread()); + ASSERT( + strand_.running_in_this_thread(), + "ripple::BaseWSPeer::fail : strand in this thread"); cancel_timer(); if (!ec_ && ec != boost::asio::error::operation_aborted) diff --git a/src/libxrpl/basics/Log.cpp b/src/libxrpl/basics/Log.cpp index 6bd1a0b3d18..873087bd217 100644 --- a/src/libxrpl/basics/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -224,7 +224,7 @@ Logs::fromSeverity(beast::severities::Severity level) return lsERROR; default: - XRPL_UNREACHABLE("ripple::Logs::fromSeverity : invalid severity"); + UNREACHABLE("ripple::Logs::fromSeverity : invalid severity"); [[fallthrough]]; case kFatal: break; @@ -250,7 +250,7 @@ Logs::toSeverity(LogSeverity level) case lsERROR: return kError; default: - XRPL_UNREACHABLE("ripple::Logs::toSeverity : invalid severity"); + UNREACHABLE("ripple::Logs::toSeverity : invalid severity"); [[fallthrough]]; case lsFATAL: break; @@ -277,7 +277,7 @@ Logs::toString(LogSeverity s) case lsFATAL: return "Fatal"; default: - XRPL_UNREACHABLE("ripple::Logs::toString : invalid severity"); + UNREACHABLE("ripple::Logs::toString : invalid severity"); return "Unknown"; } } @@ -341,7 +341,7 @@ Logs::format( output += "ERR "; break; default: - XRPL_UNREACHABLE("ripple::Logs::format : invalid severity"); + UNREACHABLE("ripple::Logs::format : invalid severity"); [[fallthrough]]; case kFatal: output += "FTL "; diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 485414bf3c9..15feebd2db7 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -235,9 +235,9 @@ Number::operator+=(Number const& y) *this = Number{}; return *this; } - XRPL_ASSERT( - "ripple::Number::operator+=(Number) : is normal", - isnormal() && y.isnormal()); + ASSERT( + isnormal() && y.isnormal(), + "ripple::Number::operator+=(Number) : is normal"); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -376,9 +376,9 @@ Number::operator*=(Number const& y) *this = y; return *this; } - XRPL_ASSERT( - "ripple::Number::operator*=(Number) : is normal", - isnormal() && y.isnormal()); + ASSERT( + isnormal() && y.isnormal(), + "ripple::Number::operator*=(Number) : is normal"); auto xm = mantissa(); auto xe = exponent(); int xn = 1; @@ -432,9 +432,9 @@ Number::operator*=(Number const& y) std::to_string(xe)); mantissa_ = xm * zn; exponent_ = xe; - XRPL_ASSERT( - "ripple::Number::operator*=(Number) : result is normal", - isnormal() || *this == Number{}); + ASSERT( + isnormal() || *this == Number{}, + "ripple::Number::operator*=(Number) : result is normal"); return *this; } @@ -537,8 +537,7 @@ to_string(Number const& amount) negative = true; } - XRPL_ASSERT( - "ripple::to_string(Number) : minimum exponent", exponent + 43 > 0); + ASSERT(exponent + 43 > 0, "ripple::to_string(Number) : minimum exponent"); ptrdiff_t const pad_prefix = 27; ptrdiff_t const pad_suffix = 23; @@ -564,9 +563,9 @@ to_string(Number const& amount) if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT( - "ripple::to_string(Number) : first distance check", - post_to >= post_from); + ASSERT( + post_to >= post_from, + "ripple::to_string(Number) : first distance check"); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -575,9 +574,9 @@ to_string(Number const& amount) if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT( - "ripple::to_string(Number) : second distance check", - post_to >= post_from); + ASSERT( + post_to >= post_from, + "ripple::to_string(Number) : second distance check"); post_to = std::find_if( std::make_reverse_iterator(post_to), diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 915f90dd71a..9191ff90baa 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -48,9 +48,9 @@ class AsyncObject ~AsyncObject() { // Destroying the object with I/O pending? Not a clean exit! - XRPL_ASSERT( - "ripple::AsyncObject::~AsyncObject : nothing pending", - m_pending.load() == 0); + ASSERT( + m_pending.load() == 0, + "ripple::AsyncObject::~AsyncObject : nothing pending"); } /** RAII container that maintains the count of pending I/O. @@ -155,11 +155,11 @@ class ResolverAsioImpl : public ResolverAsio, ~ResolverAsioImpl() override { - XRPL_ASSERT( - "ripple::ResolverAsioImpl::~ResolverAsioImpl : no pending work", - m_work.empty()); - XRPL_ASSERT( - "ripple::ResolverAsioImpl::~ResolverAsioImpl : stopped", m_stopped); + ASSERT( + m_work.empty(), + "ripple::ResolverAsioImpl::~ResolverAsioImpl : no pending work"); + ASSERT( + m_stopped, "ripple::ResolverAsioImpl::~ResolverAsioImpl : stopped"); } //------------------------------------------------------------------------- @@ -181,11 +181,10 @@ class ResolverAsioImpl : public ResolverAsio, void start() override { - XRPL_ASSERT( - "ripple::ResolverAsioImpl::start : stopped", m_stopped == true); - XRPL_ASSERT( - "ripple::ResolverAsioImpl::start : not stopping", - m_stop_called == false); + ASSERT(m_stopped == true, "ripple::ResolverAsioImpl::start : stopped"); + ASSERT( + m_stop_called == false, + "ripple::ResolverAsioImpl::start : not stopping"); if (m_stopped.exchange(false) == true) { @@ -225,12 +224,12 @@ class ResolverAsioImpl : public ResolverAsio, resolve(std::vector const& names, HandlerType const& handler) override { - XRPL_ASSERT( - "ripple::ResolverAsioImpl::resolve : not stopping", - m_stop_called == false); - XRPL_ASSERT( - "ripple::ResolverAsioImpl::resolve : names non-empty", - !names.empty()); + ASSERT( + m_stop_called == false, + "ripple::ResolverAsioImpl::resolve : not stopping"); + ASSERT( + !names.empty(), + "ripple::ResolverAsioImpl::resolve : names non-empty"); // TODO NIKB use rvalue references to construct and move // reducing cost. @@ -246,9 +245,9 @@ class ResolverAsioImpl : public ResolverAsio, // Resolver void do_stop(CompletionCounter) { - XRPL_ASSERT( - "ripple::ResolverAsioImpl::do_stop : stopping", - m_stop_called == true); + ASSERT( + m_stop_called == true, + "ripple::ResolverAsioImpl::do_stop : stopping"); if (m_stopped.exchange(true) == false) { @@ -393,9 +392,9 @@ class ResolverAsioImpl : public ResolverAsio, HandlerType const& handler, CompletionCounter) { - XRPL_ASSERT( - "ripple::ResolverAsioImpl::do_resolve : names non-empty", - !names.empty()); + ASSERT( + !names.empty(), + "ripple::ResolverAsioImpl::do_resolve : names non-empty"); if (m_stop_called == false) { diff --git a/src/libxrpl/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp index c9333678cf1..fa9a8725df5 100644 --- a/src/libxrpl/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -57,9 +57,9 @@ static_assert(std::atomic::is_always_lock_free); seconds_clock_thread::~seconds_clock_thread() { - XRPL_ASSERT( - "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable", - thread_.joinable()); + ASSERT( + thread_.joinable(), + "beast::seconds_clock_thread::~seconds_clock_thread : thread joinable"); { std::lock_guard lock(mut_); stop_ = true; diff --git a/src/libxrpl/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp index ad7ecfc0d3b..e4a5aee486a 100644 --- a/src/libxrpl/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -304,8 +304,8 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) if (isNumeric(left)) { - XRPL_ASSERT( - "beast::compare : both inputs numeric", isNumeric(right)); + ASSERT( + isNumeric(right), "beast::compare : both inputs numeric"); int const iLeft(lexicalCastThrow(left)); int const iRight(lexicalCastThrow(right)); @@ -317,9 +317,9 @@ compare(SemanticVersion const& lhs, SemanticVersion const& rhs) } else { - XRPL_ASSERT( - "beast::compare : both inputs non-numeric", - !isNumeric(right)); + ASSERT( + !isNumeric(right), + "beast::compare : both inputs non-numeric"); int result = left.compare(right); diff --git a/src/libxrpl/beast/insight/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp index 28dbe276a6a..58322fc95ed 100644 --- a/src/libxrpl/beast/insight/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -400,10 +400,10 @@ class StatsDCollectorImp for (auto const& s : *keepAlive) { std::size_t const length(s.size()); - XRPL_ASSERT( + ASSERT( + !s.empty(), "beast::insight::detail::StatsDCollectorImp::send_buffers : " - "non-empty payload", - !s.empty()); + "non-empty payload"); if (!buffers.empty() && (size + length) > max_packet_size) { log(buffers); diff --git a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index 57181268713..46c17ea4644 100644 --- a/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -199,9 +199,9 @@ PropertyStream::Source::add(Source& source) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(source.lock_, std::adopt_lock); - XRPL_ASSERT( - "beast::PropertyStream::Source::add : null source parent", - source.parent_ == nullptr); + ASSERT( + source.parent_ == nullptr, + "beast::PropertyStream::Source::add : null source parent"); children_.push_back(source.item_); source.parent_ = this; } @@ -213,9 +213,9 @@ PropertyStream::Source::remove(Source& child) std::lock_guard lk1(lock_, std::adopt_lock); std::lock_guard lk2(child.lock_, std::adopt_lock); - XRPL_ASSERT( - "beast::PropertyStream::Source::remove : child parent match", - child.parent_ == this); + ASSERT( + child.parent_ == this, + "beast::PropertyStream::Source::remove : child parent match"); children_.erase(children_.iterator_to(child.item_)); child.parent_ = nullptr; } diff --git a/src/libxrpl/crypto/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp index 6bbdc79131b..35363c862b5 100644 --- a/src/libxrpl/crypto/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -270,12 +270,12 @@ RFC1751::extract(char const* s, int start, int length) unsigned char cr; unsigned long x; - XRPL_ASSERT("ripple::RFC1751::extract : maximum length", length <= 11); - XRPL_ASSERT("ripple::RFC1751::extract : minimum start", start >= 0); - XRPL_ASSERT("ripple::RFC1751::extract : minimum length", length >= 0); - XRPL_ASSERT( - "ripple::RFC1751::extract : maximum start + length", - start + length <= 66); + ASSERT(length <= 11, "ripple::RFC1751::extract : maximum length"); + ASSERT(start >= 0, "ripple::RFC1751::extract : minimum start"); + ASSERT(length >= 0, "ripple::RFC1751::extract : minimum length"); + ASSERT( + start + length <= 66, + "ripple::RFC1751::extract : maximum start + length"); int const shiftR = 24 - (length + (start % 8)); cl = s[start / 8]; // get components @@ -322,12 +322,12 @@ RFC1751::insert(char* s, int x, int start, int length) unsigned long y; int shift; - XRPL_ASSERT("ripple::RFC1751::insert : maximum length", length <= 11); - XRPL_ASSERT("ripple::RFC1751::insert : minimum start", start >= 0); - XRPL_ASSERT("ripple::RFC1751::insert : minimum length", length >= 0); - XRPL_ASSERT( - "ripple::RFC1751::insert : maximum start + length", - start + length <= 66); + ASSERT(length <= 11, "ripple::RFC1751::insert : maximum length"); + ASSERT(start >= 0, "ripple::RFC1751::insert : minimum start"); + ASSERT(length >= 0, "ripple::RFC1751::insert : minimum length"); + ASSERT( + start + length <= 66, + "ripple::RFC1751::insert : maximum start + length"); shift = ((8 - ((start + length) % 8)) % 8); y = (long)x << shift; diff --git a/src/libxrpl/json/Object.cpp b/src/libxrpl/json/Object.cpp index 19cc482ffac..4aac046bc51 100644 --- a/src/libxrpl/json/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -168,7 +168,7 @@ Array::append(Json::Value const& v) return; } } - XRPL_UNREACHABLE("Json::Array::append : invalid type"); // Can't get here. + UNREACHABLE("Json::Array::append : invalid type"); // Can't get here. } void @@ -203,7 +203,7 @@ Object::set(std::string const& k, Json::Value const& v) return; } } - XRPL_UNREACHABLE("Json::Object::set : invalid type"); // Can't get here. + UNREACHABLE("Json::Object::set : invalid type"); // Can't get here. } //------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ template void doCopyFrom(Object& to, Json::Value const& from) { - XRPL_ASSERT("Json::doCopyFrom : valid input type", from.isObjectOrNull()); + ASSERT(from.isObjectOrNull(), "Json::doCopyFrom : valid input type"); auto members = from.getMemberNames(); for (auto& m : members) to[m] = from[m]; diff --git a/src/libxrpl/json/json_reader.cpp b/src/libxrpl/json/json_reader.cpp index 9e4c429b82c..b8744ba8ea6 100644 --- a/src/libxrpl/json/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -953,7 +953,7 @@ operator>>(std::istream& sin, Value& root) Json::Reader reader; bool ok = reader.parse(sin, root); - // XRPL_ASSERT( ok ); + // ASSERT( ok ); if (!ok) ripple::Throw(reader.getFormatedErrorMessages()); diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index a292805a64b..a2034f471c4 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -207,7 +207,7 @@ Value::Value(ValueType type) : type_(type), allocated_(0) break; default: - XRPL_UNREACHABLE("Json::Value::Value(ValueType) : invalid type"); + UNREACHABLE("Json::Value::Value(ValueType) : invalid type"); } } @@ -277,7 +277,7 @@ Value::Value(const Value& other) : type_(other.type_) break; default: - XRPL_UNREACHABLE("Json::Value::Value(Value const&) : invalid type"); + UNREACHABLE("Json::Value::Value(Value const&) : invalid type"); } } @@ -305,7 +305,7 @@ Value::~Value() break; default: - XRPL_UNREACHABLE("Json::Value::~Value : invalid type"); + UNREACHABLE("Json::Value::~Value : invalid type"); } } @@ -406,7 +406,7 @@ operator<(const Value& x, const Value& y) } default: - XRPL_UNREACHABLE("Json::operator<(Value, Value) : invalid type"); + UNREACHABLE("Json::operator<(Value, Value) : invalid type"); } return 0; // unreachable @@ -452,7 +452,7 @@ operator==(const Value& x, const Value& y) *x.value_.map_ == *y.value_.map_; default: - XRPL_UNREACHABLE("Json::operator==(Value, Value) : invalid type"); + UNREACHABLE("Json::operator==(Value, Value) : invalid type"); } return 0; // unreachable @@ -461,7 +461,7 @@ operator==(const Value& x, const Value& y) const char* Value::asCString() const { - XRPL_ASSERT("Json::Value::asCString : valid type", type_ == stringValue); + ASSERT(type_ == stringValue, "Json::Value::asCString : valid type"); return value_.string_; } @@ -493,7 +493,7 @@ Value::asString() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to string"); default: - XRPL_UNREACHABLE("Json::Value::asString : invalid type"); + UNREACHABLE("Json::Value::asString : invalid type"); } return ""; // unreachable @@ -535,7 +535,7 @@ Value::asInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to int"); default: - XRPL_UNREACHABLE("Json::Value::asInt : invalid type"); + UNREACHABLE("Json::Value::asInt : invalid type"); } return 0; // unreachable; @@ -577,7 +577,7 @@ Value::asUInt() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to uint"); default: - XRPL_UNREACHABLE("Json::Value::asUInt : invalid type"); + UNREACHABLE("Json::Value::asUInt : invalid type"); } return 0; // unreachable; @@ -609,7 +609,7 @@ Value::asDouble() const JSON_ASSERT_MESSAGE(false, "Type is not convertible to double"); default: - XRPL_UNREACHABLE("Json::Value::asDouble : invalid type"); + UNREACHABLE("Json::Value::asDouble : invalid type"); } return 0; // unreachable; @@ -641,7 +641,7 @@ Value::asBool() const return value_.map_->size() != 0; default: - XRPL_UNREACHABLE("Json::Value::asBool : invalid type"); + UNREACHABLE("Json::Value::asBool : invalid type"); } return false; // unreachable; @@ -695,7 +695,7 @@ Value::isConvertibleTo(ValueType other) const (other == nullValue && value_.map_->size() == 0); default: - XRPL_UNREACHABLE("Json::Value::isConvertible : invalid type"); + UNREACHABLE("Json::Value::isConvertible : invalid type"); } return false; // unreachable; @@ -729,7 +729,7 @@ Value::size() const return Int(value_.map_->size()); default: - XRPL_UNREACHABLE("Json::Value::size : invalid type"); + UNREACHABLE("Json::Value::size : invalid type"); } return 0; // unreachable; @@ -752,9 +752,9 @@ Value::operator bool() const void Value::clear() { - XRPL_ASSERT( - "Json::Value::clear : valid type", - type_ == nullValue || type_ == arrayValue || type_ == objectValue); + ASSERT( + type_ == nullValue || type_ == arrayValue || type_ == objectValue, + "Json::Value::clear : valid type"); switch (type_) { @@ -771,9 +771,9 @@ Value::clear() Value& Value::operator[](UInt index) { - XRPL_ASSERT( - "Json::Value::operator[](UInt) : valid type", - type_ == nullValue || type_ == arrayValue); + ASSERT( + type_ == nullValue || type_ == arrayValue, + "Json::Value::operator[](UInt) : valid type"); if (type_ == nullValue) *this = Value(arrayValue); @@ -792,9 +792,9 @@ Value::operator[](UInt index) const Value& Value::operator[](UInt index) const { - XRPL_ASSERT( - "Json::Value::operator[](UInt) const : valid type", - type_ == nullValue || type_ == arrayValue); + ASSERT( + type_ == nullValue || type_ == arrayValue, + "Json::Value::operator[](UInt) const : valid type"); if (type_ == nullValue) return null; @@ -817,9 +817,9 @@ Value::operator[](const char* key) Value& Value::resolveReference(const char* key, bool isStatic) { - XRPL_ASSERT( - "Json::Value::resolveReference : valid type", - type_ == nullValue || type_ == objectValue); + ASSERT( + type_ == nullValue || type_ == objectValue, + "Json::Value::resolveReference : valid type"); if (type_ == nullValue) *this = Value(objectValue); @@ -853,9 +853,9 @@ Value::isValidIndex(UInt index) const const Value& Value::operator[](const char* key) const { - XRPL_ASSERT( - "Json::Value::operator[](const char*) const : valid type", - type_ == nullValue || type_ == objectValue); + ASSERT( + type_ == nullValue || type_ == objectValue, + "Json::Value::operator[](const char*) const : valid type"); if (type_ == nullValue) return null; @@ -915,9 +915,9 @@ Value::get(std::string const& key, const Value& defaultValue) const Value Value::removeMember(const char* key) { - XRPL_ASSERT( - "Json::Value::removeMember : valid type", - type_ == nullValue || type_ == objectValue); + ASSERT( + type_ == nullValue || type_ == objectValue, + "Json::Value::removeMember : valid type"); if (type_ == nullValue) return null; @@ -958,9 +958,9 @@ Value::isMember(std::string const& key) const Value::Members Value::getMemberNames() const { - XRPL_ASSERT( - "Json::Value::getMemberNames : valid type", - type_ == nullValue || type_ == objectValue); + ASSERT( + type_ == nullValue || type_ == objectValue, + "Json::Value::getMemberNames : valid type"); if (type_ == nullValue) return Value::Members(); diff --git a/src/libxrpl/json/json_writer.cpp b/src/libxrpl/json/json_writer.cpp index 11cfc3671e4..3ae0dacfc2b 100644 --- a/src/libxrpl/json/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -70,7 +70,7 @@ valueToString(Int value) if (isNegative) *--current = '-'; - XRPL_ASSERT("Json::valueToString(Int) : buffer check", current >= buffer); + ASSERT(current >= buffer, "Json::valueToString(Int) : buffer check"); return current; } @@ -80,7 +80,7 @@ valueToString(UInt value) char buffer[32]; char* current = buffer + sizeof(buffer); uintToString(value, current); - XRPL_ASSERT("Json::valueToString(UInt) : buffer check", current >= buffer); + ASSERT(current >= buffer, "Json::valueToString(UInt) : buffer check"); return current; } @@ -391,9 +391,9 @@ StyledWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT( - "Json::StyledWriter::writeArrayValue : child size match", - childValues_.size() == size); + ASSERT( + childValues_.size() == size, + "Json::StyledWriter::writeArrayValue : child size match"); document_ += "[ "; for (unsigned index = 0; index < size; ++index) @@ -485,9 +485,9 @@ StyledWriter::indent() void StyledWriter::unindent() { - XRPL_ASSERT( - "Json::StyledWriter::unindent : maximum indent size", - int(indentString_.size()) >= indentSize_); + ASSERT( + int(indentString_.size()) >= indentSize_, + "Json::StyledWriter::unindent : maximum indent size"); indentString_.resize(indentString_.size() - indentSize_); } @@ -617,9 +617,9 @@ StyledStreamWriter::writeArrayValue(const Value& value) } else // output on a single line { - XRPL_ASSERT( - "Json::StyledStreamWriter::writeArrayValue : child size match", - childValues_.size() == size); + ASSERT( + childValues_.size() == size, + "Json::StyledStreamWriter::writeArrayValue : child size match"); *document_ << "[ "; for (unsigned index = 0; index < size; ++index) @@ -712,9 +712,9 @@ StyledStreamWriter::indent() void StyledStreamWriter::unindent() { - XRPL_ASSERT( - "Json::StyledStreamWriter::unindent : maximum indent size", - indentString_.size() >= indentation_.size()); + ASSERT( + indentString_.size() >= indentation_.size(), + "Json::StyledStreamWriter::unindent : maximum indent size"); indentString_.resize(indentString_.size() - indentation_.size()); } diff --git a/src/libxrpl/protocol/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp index d122f84a9e8..6661ab69a74 100644 --- a/src/libxrpl/protocol/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -109,9 +109,9 @@ ammAuctionTimeSlot(std::uint64_t current, STObject const& auctionSlot) // It should be impossible for expiration to be < TOTAL_TIME_SLOT_SECS, // but check just to be safe auto const expiration = auctionSlot[sfExpiration]; - XRPL_ASSERT( - "ripple::ammAuctionTimeSlot : minimum expiration", - expiration >= TOTAL_TIME_SLOT_SECS); + ASSERT( + expiration >= TOTAL_TIME_SLOT_SECS, + "ripple::ammAuctionTimeSlot : minimum expiration"); if (expiration >= TOTAL_TIME_SLOT_SECS) { if (auto const start = expiration - TOTAL_TIME_SLOT_SECS; diff --git a/src/libxrpl/protocol/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp index 46ff2dee8a3..8fe9ce115c4 100644 --- a/src/libxrpl/protocol/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -77,9 +77,9 @@ class AccountIdCache auto ret = encodeBase58Token(TokenType::AccountID, id.data(), id.size()); - XRPL_ASSERT( - "ripple::detail::AccountIdCache : maximum result size", - ret.size() <= 38); + ASSERT( + ret.size() <= 38, + "ripple::detail::AccountIdCache : maximum result size"); { std::lock_guard lock(sl); diff --git a/src/libxrpl/protocol/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp index 2f089f2c891..e821ee84b4f 100644 --- a/src/libxrpl/protocol/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -210,9 +210,9 @@ error_code_http_status(error_code_i code) std::string rpcErrorString(Json::Value const& jv) { - XRPL_ASSERT( - "ripple::RPC::rpcErrorString : input contains an error", - RPC::contains_error(jv)); + ASSERT( + RPC::contains_error(jv), + "ripple::RPC::rpcErrorString : input contains an error"); return jv[jss::error].asString() + jv[jss::error_message].asString(); } diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index e6e15313eda..a52d79446ab 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -221,9 +221,9 @@ FeatureCollections::FeatureCollections() std::optional FeatureCollections::getRegisteredFeature(std::string const& name) const { - XRPL_ASSERT( - "ripple::FeatureCollections::getRegisteredFeature : startup completed", - readOnly); + ASSERT( + readOnly.load(), + "ripple::FeatureCollections::getRegisteredFeature : startup completed"); Feature const* feature = getByName(name); if (feature) return feature->feature; @@ -305,9 +305,9 @@ FeatureCollections::registrationIsDone() size_t FeatureCollections::featureToBitsetIndex(uint256 const& f) const { - XRPL_ASSERT( - "ripple::FeatureCollections::featureToBitsetIndex : startup completed", - readOnly); + ASSERT( + readOnly.load(), + "ripple::FeatureCollections::featureToBitsetIndex : startup completed"); Feature const* feature = getByFeature(f); if (!feature) @@ -319,9 +319,9 @@ FeatureCollections::featureToBitsetIndex(uint256 const& f) const uint256 const& FeatureCollections::bitsetIndexToFeature(size_t i) const { - XRPL_ASSERT( - "ripple::FeatureCollections::bitsetIndexToFeature : startup completed", - readOnly); + ASSERT( + readOnly.load(), + "ripple::FeatureCollections::bitsetIndexToFeature : startup completed"); Feature const& feature = getByIndex(i); return feature.feature; } @@ -329,9 +329,9 @@ FeatureCollections::bitsetIndexToFeature(size_t i) const std::string FeatureCollections::featureToName(uint256 const& f) const { - XRPL_ASSERT( - "ripple::FeatureCollections::featureToName : startup completed", - readOnly); + ASSERT( + readOnly.load(), + "ripple::FeatureCollections::featureToName : startup completed"); Feature const* feature = getByFeature(f); return feature ? feature->name : to_string(f); } diff --git a/src/libxrpl/protocol/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp index 435e3ba9a61..bf922ef04a7 100644 --- a/src/libxrpl/protocol/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -91,8 +91,7 @@ indexHash(LedgerNameSpace space, Args const&... args) uint256 getBookBase(Book const& book) { - XRPL_ASSERT( - "ripple::getBookBase : input is consistent", isConsistent(book)); + ASSERT(isConsistent(book), "ripple::getBookBase : input is consistent"); auto const index = indexHash( LedgerNameSpace::BOOK_DIR, @@ -132,7 +131,7 @@ getTicketIndex(AccountID const& account, std::uint32_t ticketSeq) uint256 getTicketIndex(AccountID const& account, SeqProxy ticketSeq) { - XRPL_ASSERT("ripple::getTicketIndex : valid input", ticketSeq.isTicket()); + ASSERT(ticketSeq.isTicket(), "ripple::getTicketIndex : valid input"); return getTicketIndex(account, ticketSeq.value()); } @@ -209,7 +208,7 @@ line( // There is code in SetTrust that calls us with id0 == id1, to allow users // to locate and delete such "weird" trustlines. If we remove that code, we // could enable this assert: - // XRPL_ASSERT(id0 != id1); + // ASSERT(id0 != id1); // A trust line is shared between two accounts; while we typically think // of this as an "issuer" and a "holder" the relationship is actually fully @@ -238,8 +237,7 @@ offer(AccountID const& id, std::uint32_t seq) noexcept Keylet quality(Keylet const& k, std::uint64_t q) noexcept { - XRPL_ASSERT( - "ripple::keylet::quality : valid input type", k.type == ltDIR_NODE); + ASSERT(k.type == ltDIR_NODE, "ripple::keylet::quality : valid input type"); // Indexes are stored in big endian format: they print as hex as stored. // Most significant bytes are first and the least significant bytes @@ -257,9 +255,9 @@ quality(Keylet const& k, std::uint64_t q) noexcept Keylet next_t::operator()(Keylet const& k) const { - XRPL_ASSERT( - "ripple::keylet::next_t::operator() : valid input type", - k.type == ltDIR_NODE); + ASSERT( + k.type == ltDIR_NODE, + "ripple::keylet::next_t::operator() : valid input type"); return {ltDIR_NODE, getQualityNext(k.key)}; } @@ -361,8 +359,8 @@ nftpage_max(AccountID const& owner) Keylet nftpage(Keylet const& k, uint256 const& token) { - XRPL_ASSERT( - "ripple::keylet::nftpage : valid input type", k.type == ltNFTOKEN_PAGE); + ASSERT( + k.type == ltNFTOKEN_PAGE, "ripple::keylet::nftpage : valid input type"); return {ltNFTOKEN_PAGE, (k.key & ~nft::pageMask) + (token & nft::pageMask)}; } diff --git a/src/libxrpl/protocol/Keylet.cpp b/src/libxrpl/protocol/Keylet.cpp index d2550b4d18e..ab6b8ad0cf7 100644 --- a/src/libxrpl/protocol/Keylet.cpp +++ b/src/libxrpl/protocol/Keylet.cpp @@ -25,9 +25,9 @@ namespace ripple { bool Keylet::check(STLedgerEntry const& sle) const { - XRPL_ASSERT( - "ripple::Keylet::check : valid input type", - sle.getType() != ltANY || sle.getType() != ltCHILD); + ASSERT( + sle.getType() != ltANY || sle.getType() != ltCHILD, + "ripple::Keylet::check : valid input type"); if (type == ltANY) return true; diff --git a/src/libxrpl/protocol/Quality.cpp b/src/libxrpl/protocol/Quality.cpp index 4fc38faba4b..68f29fa6bac 100644 --- a/src/libxrpl/protocol/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -35,7 +35,7 @@ Quality::Quality(Amounts const& amount) Quality& Quality::operator++() { - XRPL_ASSERT("ripple::Quality::operator++() : minimum value", m_value > 0); + ASSERT(m_value > 0, "ripple::Quality::operator++() : minimum value"); --m_value; return *this; } @@ -51,9 +51,9 @@ Quality::operator++(int) Quality& Quality::operator--() { - XRPL_ASSERT( - "ripple::Quality::operator--() : maximum value", - m_value < std::numeric_limits::max()); + ASSERT( + m_value < std::numeric_limits::max(), + "ripple::Quality::operator--() : maximum value"); ++m_value; return *this; } @@ -83,12 +83,11 @@ ceil_in_impl( // Clamp out if (result.out > amount.out) result.out = amount.out; - XRPL_ASSERT( - "ripple::ceil_in_impl : result matches limit", result.in == limit); + ASSERT( + result.in == limit, "ripple::ceil_in_impl : result matches limit"); return result; } - XRPL_ASSERT( - "ripple::ceil_in_impl : result inside limit", amount.in <= limit); + ASSERT(amount.in <= limit, "ripple::ceil_in_impl : result inside limit"); return amount; } @@ -124,13 +123,12 @@ ceil_out_impl( // Clamp in if (result.in > amount.in) result.in = amount.in; - XRPL_ASSERT( - "ripple::ceil_out_impl : result matches limit", - result.out == limit); + ASSERT( + result.out == limit, + "ripple::ceil_out_impl : result matches limit"); return result; } - XRPL_ASSERT( - "ripple::ceil_out_impl : result inside limit", amount.out <= limit); + ASSERT(amount.out <= limit, "ripple::ceil_out_impl : result inside limit"); return amount; } @@ -153,23 +151,23 @@ Quality composed_quality(Quality const& lhs, Quality const& rhs) { STAmount const lhs_rate(lhs.rate()); - XRPL_ASSERT( - "ripple::composed_quality : nonzero left input", - lhs_rate != beast::zero); + ASSERT( + lhs_rate != beast::zero, + "ripple::composed_quality : nonzero left input"); STAmount const rhs_rate(rhs.rate()); - XRPL_ASSERT( - "ripple::composed_quality : nonzero right input", - rhs_rate != beast::zero); + ASSERT( + rhs_rate != beast::zero, + "ripple::composed_quality : nonzero right input"); STAmount const rate(mulRound(lhs_rate, rhs_rate, lhs_rate.issue(), true)); std::uint64_t const stored_exponent(rate.exponent() + 100); std::uint64_t const stored_mantissa(rate.mantissa()); - XRPL_ASSERT( - "ripple::composed_quality : valid exponent", - (stored_exponent > 0) && (stored_exponent <= 255)); + ASSERT( + (stored_exponent > 0) && (stored_exponent <= 255), + "ripple::composed_quality : valid exponent"); return Quality((stored_exponent << (64 - 8)) | stored_mantissa); } diff --git a/src/libxrpl/protocol/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp index 553ad020fc1..fc06920a16b 100644 --- a/src/libxrpl/protocol/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -46,7 +46,7 @@ transferFeeAsRate(std::uint16_t fee) STAmount multiply(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT("ripple::nft::multiply : nonzero rate input", rate.value != 0); + ASSERT(rate.value != 0, "ripple::nft::multiply : nonzero rate input"); if (rate == parityRate) return amount; @@ -57,8 +57,7 @@ multiply(STAmount const& amount, Rate const& rate) STAmount multiplyRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT( - "ripple::nft::multiplyRound : nonzero rate input", rate.value != 0); + ASSERT(rate.value != 0, "ripple::nft::multiplyRound : nonzero rate input"); if (rate == parityRate) return amount; @@ -73,9 +72,9 @@ multiplyRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT( - "ripple::nft::multiplyRound(Issue) : nonzero rate input", - rate.value != 0); + ASSERT( + rate.value != 0, + "ripple::nft::multiplyRound(Issue) : nonzero rate input"); if (rate == parityRate) { @@ -88,7 +87,7 @@ multiplyRound( STAmount divide(STAmount const& amount, Rate const& rate) { - XRPL_ASSERT("ripple::nft::divide : nonzero rate input", rate.value != 0); + ASSERT(rate.value != 0, "ripple::nft::divide : nonzero rate input"); if (rate == parityRate) return amount; @@ -99,8 +98,7 @@ divide(STAmount const& amount, Rate const& rate) STAmount divideRound(STAmount const& amount, Rate const& rate, bool roundUp) { - XRPL_ASSERT( - "ripple::nft::divideRound : nonzero rate input", rate.value != 0); + ASSERT(rate.value != 0, "ripple::nft::divideRound : nonzero rate input"); if (rate == parityRate) return amount; @@ -115,9 +113,9 @@ divideRound( Issue const& issue, bool roundUp) { - XRPL_ASSERT( - "ripple::nft::divideRound(Issue) : nonzero rate input", - rate.value != 0); + ASSERT( + rate.value != 0, + "ripple::nft::divideRound(Issue) : nonzero rate input"); if (rate == parityRate) return amount; diff --git a/src/libxrpl/protocol/Rules.cpp b/src/libxrpl/protocol/Rules.cpp index 99e56f26684..3edc1448d00 100644 --- a/src/libxrpl/protocol/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -91,10 +91,10 @@ class Rules::Impl return true; if (!digest_ || !other.digest_) return false; - XRPL_ASSERT( + ASSERT( + presets_ == other.presets_, "ripple::Rules::Impl::operator==(Impl) const : input presets do " - "match", - presets_ == other.presets_); + "match"); return *digest_ == *other.digest_; } }; @@ -121,7 +121,7 @@ Rules::presets() const bool Rules::enabled(uint256 const& feature) const { - XRPL_ASSERT("ripple::Rules::enabled : initialized", impl_); + ASSERT(impl_ != nullptr, "ripple::Rules::enabled : initialized"); // The functionality of the "NonFungibleTokensV1_1" amendment is // precisely the functionality of the following three amendments @@ -140,9 +140,9 @@ Rules::enabled(uint256 const& feature) const bool Rules::operator==(Rules const& other) const { - XRPL_ASSERT( - "ripple::Rules::operator==(Rules) const : both initialized", - impl_ && other.impl_); + ASSERT( + impl_ && other.impl_, + "ripple::Rules::operator==(Rules) const : both initialized"); if (impl_.get() == other.impl_.get()) return true; return *impl_ == *other.impl_; diff --git a/src/libxrpl/protocol/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp index f1aff698b58..d3d93f75601 100644 --- a/src/libxrpl/protocol/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -80,11 +80,10 @@ STAccount::getSType() const void STAccount::add(Serializer& s) const { - XRPL_ASSERT( - "ripple::STAccount::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STAccount::add : valid field type", - getFName().fieldType == STI_ACCOUNT); + ASSERT(getFName().isBinary(), "ripple::STAccount::add : field is binary"); + ASSERT( + getFName().fieldType == STI_ACCOUNT, + "ripple::STAccount::add : valid field type"); // Preserve the serialization behavior of an STBlob: // o If we are default (all zeros) serialize as an empty blob. diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 3662d7a7349..97561ffee15 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -70,9 +70,9 @@ getSNValue(STAmount const& amount) auto ret = static_cast(amount.mantissa()); - XRPL_ASSERT( - "ripple::getSNValue : mantissa roundtrip", - static_cast(ret) == amount.mantissa()); + ASSERT( + static_cast(ret) == amount.mantissa(), + "ripple::getSNValue : mantissa roundtrip"); if (amount.negative()) ret = -ret; @@ -222,10 +222,10 @@ STAmount::STAmount(SField const& name, std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(negative) { - XRPL_ASSERT( + ASSERT( + mValue <= std::numeric_limits::max(), "ripple::STAmount::STAmount(SField, std::uint64_t, bool) : maximum " - "mantissa input", - mValue <= std::numeric_limits::max()); + "mantissa input"); } STAmount::STAmount( @@ -240,10 +240,10 @@ STAmount::STAmount( , mOffset(exponent) , mIsNegative(negative) { - XRPL_ASSERT( + ASSERT( + mValue <= std::numeric_limits::max(), "ripple::STAmount::STAmount(SField, Issue, std::uint64_t, int, bool) : " - "maximum mantissa input", - mValue <= std::numeric_limits::max()); + "maximum mantissa input"); canonicalize(); } @@ -254,9 +254,9 @@ STAmount::STAmount(SField const& name, STAmount const& from) , mOffset(from.mOffset) , mIsNegative(from.mIsNegative) { - XRPL_ASSERT( - "ripple::STAmount::STAmount(SField, STAmount) : maximum input", - mValue <= std::numeric_limits::max()); + ASSERT( + mValue <= std::numeric_limits::max(), + "ripple::STAmount::STAmount(SField, STAmount) : maximum input"); canonicalize(); } @@ -268,10 +268,10 @@ STAmount::STAmount(std::uint64_t mantissa, bool negative) , mIsNative(true) , mIsNegative(mantissa != 0 && negative) { - XRPL_ASSERT( + ASSERT( + mValue <= std::numeric_limits::max(), "ripple::STAmount::STAmount(std::uint64_t, bool) : maximum mantissa " - "input", - mValue <= std::numeric_limits::max()); + "input"); } STAmount::STAmount( @@ -387,9 +387,9 @@ STAmount::iou() const STAmount& STAmount::operator=(IOUAmount const& iou) { - XRPL_ASSERT( - "ripple::STAmount::operator=(IOUAmount) : is not XRP", - mIsNative == false); + ASSERT( + mIsNative == false, + "ripple::STAmount::operator=(IOUAmount) : is not XRP"); mOffset = iou.exponent(); mIsNegative = iou < beast::zero; if (mIsNegative) @@ -527,9 +527,9 @@ getRate(STAmount const& offerOut, STAmount const& offerIn) STAmount r = divide(offerIn, offerOut, noIssue()); if (r == beast::zero) // offer is too good return 0; - XRPL_ASSERT( - "ripple::getRate : exponent inside range", - (r.exponent() >= -100) && (r.exponent() <= 155)); + ASSERT( + (r.exponent() >= -100) && (r.exponent() <= 155), + "ripple::getRate : exponent inside range"); std::uint64_t ret = r.exponent() + 100; return (ret << (64 - 8)) | r.mantissa(); } @@ -611,7 +611,7 @@ STAmount::getText() const return ret; } - XRPL_ASSERT("ripple::STAmount::getText : minimum offset", mOffset + 43 > 0); + ASSERT(mOffset + 43 > 0, "ripple::STAmount::getText : minimum offset"); size_t const pad_prefix = 27; size_t const pad_suffix = 23; @@ -635,9 +635,9 @@ STAmount::getText() const if (std::distance(pre_from, pre_to) > pad_prefix) pre_from += pad_prefix; - XRPL_ASSERT( - "ripple::STAmount::getText : first distance check", - post_to >= post_from); + ASSERT( + post_to >= post_from, + "ripple::STAmount::getText : first distance check"); pre_from = std::find_if(pre_from, pre_to, [](char c) { return c != '0'; }); @@ -646,9 +646,9 @@ STAmount::getText() const if (std::distance(post_from, post_to) > pad_suffix) post_to -= pad_suffix; - XRPL_ASSERT( - "ripple::STAmount::getText : second distance check", - post_to >= post_from); + ASSERT( + post_to >= post_from, + "ripple::STAmount::getText : second distance check"); post_to = std::find_if( std::make_reverse_iterator(post_to), @@ -683,7 +683,7 @@ STAmount::add(Serializer& s) const { if (mIsNative) { - XRPL_ASSERT("ripple::STAmount::add : zero offset", mOffset == 0); + ASSERT(mOffset == 0, "ripple::STAmount::add : zero offset"); if (!mIsNegative) s.add64(mValue | cPosNative); @@ -844,15 +844,15 @@ STAmount::canonicalize() if (mOffset > cMaxOffset) Throw("value overflow"); - XRPL_ASSERT( - "ripple::STAmount::canonicalize : value inside range", - (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue))); - XRPL_ASSERT( - "ripple::STAmount::canonicalize : offset inside range", - (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset))); - XRPL_ASSERT( - "ripple::STAmount::canonicalize : value or offset set", - (mValue != 0) || (mOffset != -100)); + ASSERT( + (mValue == 0) || ((mValue >= cMinValue) && (mValue <= cMaxValue)), + "ripple::STAmount::canonicalize : value inside range"); + ASSERT( + (mValue == 0) || ((mOffset >= cMinOffset) && (mOffset <= cMaxOffset)), + "ripple::STAmount::canonicalize : offset inside range"); + ASSERT( + (mValue != 0) || (mOffset != -100), + "ripple::STAmount::canonicalize : value or offset set"); } void diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index 3242c50f20b..cf322039d84 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -29,7 +29,7 @@ STBase::STBase() : fName(&sfGeneric) STBase::STBase(SField const& n) : fName(&n) { - XRPL_ASSERT("ripple::STBase::STBase : field is set", fName); + ASSERT(fName != nullptr, "ripple::STBase::STBase : field is set"); } STBase& @@ -104,15 +104,15 @@ void STBase::add(Serializer& s) const { // Should never be called - XRPL_UNREACHABLE("ripple::STBase::add : not implemented"); + UNREACHABLE("ripple::STBase::add : not implemented"); } bool STBase::isEquivalent(const STBase& t) const { - XRPL_ASSERT( - "ripple::STBase::isEquivalent : type not present", - getSType() == STI_NOTPRESENT); + ASSERT( + getSType() == STI_NOTPRESENT, + "ripple::STBase::isEquivalent : type not present"); return t.getSType() == STI_NOTPRESENT; } @@ -126,7 +126,7 @@ void STBase::setFName(SField const& n) { fName = &n; - XRPL_ASSERT("ripple::STBase::setFName : field is set", fName); + ASSERT(fName != nullptr, "ripple::STBase::setFName : field is set"); } SField const& @@ -138,8 +138,7 @@ STBase::getFName() const void STBase::addFieldID(Serializer& s) const { - XRPL_ASSERT( - "ripple::STBase::addFieldID : field is binary", fName->isBinary()); + ASSERT(fName->isBinary(), "ripple::STBase::addFieldID : field is binary"); s.addFieldID(fName->fieldType, fName->fieldValue); } diff --git a/src/libxrpl/protocol/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp index eb3b72e7ab1..755588138a2 100644 --- a/src/libxrpl/protocol/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -54,11 +54,11 @@ STBlob::getText() const void STBlob::add(Serializer& s) const { - XRPL_ASSERT("ripple::STBlob::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STBlob::add : valid field type", + ASSERT(getFName().isBinary(), "ripple::STBlob::add : field is binary"); + ASSERT( (getFName().fieldType == STI_VL) || - (getFName().fieldType == STI_ACCOUNT)); + (getFName().fieldType == STI_ACCOUNT), + "ripple::STBlob::add : valid field type"); s.addVL(value_.data(), value_.size()); } diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 54f6049982d..1f208e832bf 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -196,9 +196,9 @@ Json::Value STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); - XRPL_ASSERT( - "ripple::STUInt64::getJson : to_chars succeeded", - ret.ec == std::errc()); + ASSERT( + ret.ec == std::errc(), + "ripple::STUInt64::getJson : to_chars succeeded"); str.resize(std::distance(str.data(), ret.ptr)); return str; } diff --git a/src/libxrpl/protocol/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp index 63524b2bda7..2b97c3a0b72 100644 --- a/src/libxrpl/protocol/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -157,9 +157,9 @@ STLedgerEntry::thread( if (oldPrevTxID == txID) { // this transaction is already threaded - XRPL_ASSERT( - "ripple::STLedgerEntry::thread : ledger sequence match", - getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq); + ASSERT( + getFieldU32(sfPreviousTxnLgrSeq) == ledgerSeq, + "ripple::STLedgerEntry::thread : ledger sequence match"); return false; } diff --git a/src/libxrpl/protocol/STObject.cpp b/src/libxrpl/protocol/STObject.cpp index 55e5443be5b..720d22dc442 100644 --- a/src/libxrpl/protocol/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -842,10 +842,10 @@ STObject::add(Serializer& s, WhichFields whichFields) const // the type associated by rule with this field name // must be OBJECT, or the object cannot be deserialized SerializedTypeID const sType{field->getSType()}; - XRPL_ASSERT( - "ripple::STObject::add : valid field type", + ASSERT( (sType != STI_OBJECT) || - (field->getFName().fieldType == STI_OBJECT)); + (field->getFName().fieldType == STI_OBJECT), + "ripple::STObject::add : valid field type"); field->addFieldID(s); field->add(s); if (sType == STI_ARRAY || sType == STI_OBJECT) diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index 899b6a11f2b..94262e966c8 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -208,11 +208,10 @@ STPathSet::getSType() const void STPathSet::add(Serializer& s) const { - XRPL_ASSERT( - "ripple::STPathSet::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STPathSet::add : valid field type", - getFName().fieldType == STI_PATHSET); + ASSERT(getFName().isBinary(), "ripple::STPathSet::add : field is binary"); + ASSERT( + getFName().fieldType == STI_PATHSET, + "ripple::STPathSet::add : valid field type"); bool first = true; for (auto const& spPath : value) diff --git a/src/libxrpl/protocol/STTx.cpp b/src/libxrpl/protocol/STTx.cpp index 9e890ac0b7c..6079c246ba8 100644 --- a/src/libxrpl/protocol/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -137,9 +137,9 @@ STTx::getMentionedAccounts() const { if (auto sacc = dynamic_cast(&it)) { - XRPL_ASSERT( - "ripple::STTx::getMentionedAccounts : account is set", - !sacc->isDefault()); + ASSERT( + !sacc->isDefault(), + "ripple::STTx::getMentionedAccounts : account is set"); if (!sacc->isDefault()) list.insert(sacc->value()); } @@ -300,8 +300,8 @@ STTx::getMetaSQL( std::string rTxn = sqlBlobLiteral(rawTxn.peekData()); auto format = TxFormats::getInstance().findByType(tx_type_); - XRPL_ASSERT( - "ripple::STTx::getMetaSQL : non-null type format", format != nullptr); + ASSERT( + format != nullptr, "ripple::STTx::getMetaSQL : non-null type format"); return str( boost::format(bfTrans) % to_string(getTransactionID()) % diff --git a/src/libxrpl/protocol/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp index 19cb50d38b9..5820fc9f9b0 100644 --- a/src/libxrpl/protocol/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -107,9 +107,9 @@ STValidation::isValid() const noexcept { if (!valid_) { - XRPL_ASSERT( - "ripple::STValidation::isValid : valid key type", - publicKeyType(getSignerPublic()) == KeyType::secp256k1); + ASSERT( + publicKeyType(getSignerPublic()) == KeyType::secp256k1, + "ripple::STValidation::isValid : valid key type"); valid_ = verifyDigest( getSignerPublic(), diff --git a/src/libxrpl/protocol/STVar.cpp b/src/libxrpl/protocol/STVar.cpp index f74413b42d1..16b13f69fc2 100644 --- a/src/libxrpl/protocol/STVar.cpp +++ b/src/libxrpl/protocol/STVar.cpp @@ -178,9 +178,9 @@ STVar::STVar(SerialIter& sit, SField const& name, int depth) STVar::STVar(SerializedTypeID id, SField const& name) { - XRPL_ASSERT( - "ripple::detail::STVar::STVar(SerializedTypeID) : valid type input", - (id == STI_NOTPRESENT) || (id == name.fieldType)); + ASSERT( + (id == STI_NOTPRESENT) || (id == name.fieldType), + "ripple::detail::STVar::STVar(SerializedTypeID) : valid type input"); switch (id) { case STI_NOTPRESENT: diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index 240a40d4151..ce9125024d3 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -68,11 +68,10 @@ STVector256::isDefault() const void STVector256::add(Serializer& s) const { - XRPL_ASSERT( - "ripple::STVector256::add : field is binary", getFName().isBinary()); - XRPL_ASSERT( - "ripple::STVector256::add : valid field type", - getFName().fieldType == STI_VECTOR256); + ASSERT(getFName().isBinary(), "ripple::STVector256::add : field is binary"); + ASSERT( + getFName().fieldType == STI_VECTOR256, + "ripple::STVector256::add : valid field type"); s.addVL(mValue.begin(), mValue.end(), mValue.size() * (256 / 8)); } diff --git a/src/libxrpl/protocol/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp index 7d30a75cc74..e13f7ae7aa6 100644 --- a/src/libxrpl/protocol/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -132,9 +132,9 @@ int Serializer::addFieldID(int type, int name) { int ret = mData.size(); - XRPL_ASSERT( - "ripple::Serializer::addFieldID : inputs inside range", - (type > 0) && (type < 256) && (name > 0) && (name < 256)); + ASSERT( + (type > 0) && (type < 256) && (name > 0) && (name < 256), + "ripple::Serializer::addFieldID : inputs inside range"); if (type < 16) { @@ -203,10 +203,10 @@ Serializer::addVL(Blob const& vector) { int ret = addEncoded(vector.size()); addRaw(vector); - XRPL_ASSERT( - "ripple::Serializer::addVL : size matches expected", + ASSERT( mData.size() == - (ret + vector.size() + encodeLengthLength(vector.size()))); + (ret + vector.size() + encodeLengthLength(vector.size())), + "ripple::Serializer::addVL : size matches expected"); return ret; } @@ -486,8 +486,8 @@ SerialIter::getVLDataLength() } else { - XRPL_ASSERT( - "ripple::SerialIter::getVLDataLength : lenLen is 3", lenLen == 3); + ASSERT( + lenLen == 3, "ripple::SerialIter::getVLDataLength : lenLen is 3"); int b2 = get8(); int b3 = get8(); datLen = Serializer::decodeVLLength(b1, b2, b3); diff --git a/src/libxrpl/protocol/TxMeta.cpp b/src/libxrpl/protocol/TxMeta.cpp index 1c36aef176a..ea3e43240ba 100644 --- a/src/libxrpl/protocol/TxMeta.cpp +++ b/src/libxrpl/protocol/TxMeta.cpp @@ -55,9 +55,9 @@ TxMeta::TxMeta(uint256 const& txid, std::uint32_t ledger, STObject const& obj) auto affectedNodes = dynamic_cast(obj.peekAtPField(sfAffectedNodes)); - XRPL_ASSERT( - "ripple::TxMeta::TxMeta(STObject) : type cast succeeded", - affectedNodes); + ASSERT( + affectedNodes != nullptr, + "ripple::TxMeta::TxMeta(STObject) : type cast succeeded"); if (affectedNodes) mNodes = *affectedNodes; @@ -108,9 +108,9 @@ TxMeta::setAffectedNode( mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - XRPL_ASSERT( - "ripple::TxMeta::setAffectedNode : field type match", - obj.getFName() == type); + ASSERT( + obj.getFName() == type, + "ripple::TxMeta::setAffectedNode : field type match"); obj.setFieldH256(sfLedgerIndex, node); obj.setFieldU16(sfLedgerEntryType, nodeType); } @@ -131,18 +131,18 @@ TxMeta::getAffectedAccounts() const if (index != -1) { auto inner = dynamic_cast(&it.peekAtIndex(index)); - XRPL_ASSERT( - "ripple::getAffectedAccounts : STObject type cast succeeded", - inner); + ASSERT( + inner != nullptr, + "ripple::getAffectedAccounts : STObject type cast succeeded"); if (inner) { for (auto const& field : *inner) { if (auto sa = dynamic_cast(&field)) { - XRPL_ASSERT( - "ripple::getAffectedAccounts : account is set", - !sa->isDefault()); + ASSERT( + !sa->isDefault(), + "ripple::getAffectedAccounts : account is set"); if (!sa->isDefault()) list.insert(sa->value()); } @@ -153,10 +153,10 @@ TxMeta::getAffectedAccounts() const (field.getFName() == sfTakerGets)) { auto lim = dynamic_cast(&field); - XRPL_ASSERT( + ASSERT( + lim != nullptr, "ripple::getAffectedAccounts : STAmount type cast " - "succeeded", - lim); + "succeeded"); if (lim != nullptr) { @@ -186,9 +186,9 @@ TxMeta::getAffectedNode(SLE::ref node, SField const& type) mNodes.push_back(STObject(type)); STObject& obj = mNodes.back(); - XRPL_ASSERT( - "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match", - obj.getFName() == type); + ASSERT( + obj.getFName() == type, + "ripple::TxMeta::getAffectedNode(SLE::ref) : field type match"); obj.setFieldH256(sfLedgerIndex, index); obj.setFieldU16(sfLedgerEntryType, node->getFieldU16(sfLedgerEntryType)); @@ -203,8 +203,7 @@ TxMeta::getAffectedNode(uint256 const& node) if (n.getFieldH256(sfLedgerIndex) == node) return n; } - XRPL_UNREACHABLE( - "ripple::TxMeta::getAffectedNode(uint256) : node not found"); + UNREACHABLE("ripple::TxMeta::getAffectedNode(uint256) : node not found"); Throw("Affected node not found"); return *(mNodes.begin()); // Silence compiler warning. } @@ -213,7 +212,7 @@ STObject TxMeta::getAsObject() const { STObject metaData(sfTransactionMetaData); - XRPL_ASSERT("ripple::TxMeta::getAsObject : result is set", mResult != 255); + ASSERT(mResult != 255, "ripple::TxMeta::getAsObject : result is set"); metaData.setFieldU8(sfTransactionResult, mResult); metaData.setFieldU32(sfTransactionIndex, mIndex); metaData.emplace_back(mNodes); @@ -227,9 +226,9 @@ TxMeta::addRaw(Serializer& s, TER result, std::uint32_t index) { mResult = TERtoInt(result); mIndex = index; - XRPL_ASSERT( - "ripple::TxMeta::addRaw : valid TER input", - (mResult == 0) || ((mResult > 100) && (mResult <= 255))); + ASSERT( + (mResult == 0) || ((mResult > 100) && (mResult <= 255)), + "ripple::TxMeta::addRaw : valid TER input"); mNodes.sort([](STObject const& o1, STObject const& o2) { return o1.getFieldH256(sfLedgerIndex) < o2.getFieldH256(sfLedgerIndex); diff --git a/src/libxrpl/protocol/tokens.cpp b/src/libxrpl/protocol/tokens.cpp index e0a7fdc789a..de3812637cf 100644 --- a/src/libxrpl/protocol/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -248,8 +248,8 @@ encodeBase58( iter[-1] = carry % 58; carry /= 58; } - XRPL_ASSERT( - "ripple::b58_ref::detail::encodeBase58 : zero carry", carry == 0); + ASSERT( + carry == 0, "ripple::b58_ref::detail::encodeBase58 : zero carry"); pbegin++; } @@ -299,8 +299,8 @@ decodeBase58(std::string const& s) *iter = carry % 256; carry /= 256; } - XRPL_ASSERT( - "ripple::b58_ref::detail::decodeBase58 : zero carry", carry == 0); + ASSERT( + carry == 0, "ripple::b58_ref::detail::decodeBase58 : zero carry"); ++psz; --remain; } @@ -537,9 +537,9 @@ b58_to_b256_be(std::string_view input, std::span out) ripple::b58_fast::detail::div_rem(input.size(), 10); auto const num_partial_coeffs = partial_coeff_len ? 1 : 0; auto const num_b_58_10_coeffs = num_full_coeffs + num_partial_coeffs; - XRPL_ASSERT( - "ripple::b58_fast::detail::b58_to_b256_be : maximum coeff", - num_b_58_10_coeffs <= b_58_10_coeff.size()); + ASSERT( + num_b_58_10_coeffs <= b_58_10_coeff.size(), + "ripple::b58_fast::detail::b58_to_b256_be : maximum coeff"); for (auto c : input.substr(0, partial_coeff_len)) { auto cur_val = ::ripple::alphabetReverse[c]; diff --git a/src/libxrpl/resource/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp index 8049f853d8c..adabd770964 100644 --- a/src/libxrpl/resource/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -109,18 +109,18 @@ Consumer::charge(Charge const& what) bool Consumer::warn() { - XRPL_ASSERT( - "ripple::Resource::Consumer::warn : non-null entry", - m_entry != nullptr); + ASSERT( + m_entry != nullptr, + "ripple::Resource::Consumer::warn : non-null entry"); return m_logic->warn(*m_entry); } bool Consumer::disconnect(beast::Journal const& j) { - XRPL_ASSERT( - "ripple::Resource::Consumer::disconnect : non-null entry", - m_entry != nullptr); + ASSERT( + m_entry != nullptr, + "ripple::Resource::Consumer::disconnect : non-null entry"); bool const d = m_logic->disconnect(*m_entry); if (d) { @@ -132,18 +132,18 @@ Consumer::disconnect(beast::Journal const& j) int Consumer::balance() { - XRPL_ASSERT( - "ripple::Resource::Consumer::balance : non-null entry", - m_entry != nullptr); + ASSERT( + m_entry != nullptr, + "ripple::Resource::Consumer::balance : non-null entry"); return m_logic->balance(*m_entry); } Entry& Consumer::entry() { - XRPL_ASSERT( - "ripple::Resource::Consumer::entry : non-null entry", - m_entry != nullptr); + ASSERT( + m_entry != nullptr, + "ripple::Resource::Consumer::entry : non-null entry"); return *m_entry; } diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index ecad37fa788..690845c79e3 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -92,9 +92,9 @@ RCLConsensus::Adaptor::Adaptor( std::numeric_limits::max() - 1)) , nUnlVote_(validatorKeys_.nodeID, j_) { - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::Adaptor : nonzero cookie", - valCookie_ != 0); + ASSERT( + valCookie_ != 0, + "ripple::RCLConsensus::Adaptor::Adaptor : nonzero cookie"); JLOG(j_.info()) << "Consensus engine started (cookie: " + std::to_string(valCookie_) + ")"; @@ -148,12 +148,12 @@ RCLConsensus::Adaptor::acquireLedger(LedgerHash const& hash) return std::nullopt; } - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::acquireLedger : valid ledger state", - !built->open() && built->isImmutable()); - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::acquireLedger : ledger hash match", - built->info().hash == hash); + ASSERT( + !built->open() && built->isImmutable(), + "ripple::RCLConsensus::Adaptor::acquireLedger : valid ledger state"); + ASSERT( + built->info().hash == hash, + "ripple::RCLConsensus::Adaptor::acquireLedger : ledger hash match"); // Notify inbound transactions of the new ledger sequence number inboundTransactions_.newRound(built->info().seq); @@ -679,12 +679,12 @@ RCLConsensus::Adaptor::doAccept( ledgerMaster_.switchLCL(built.ledger_); // Do these need to exist? - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::doAccept : ledger hash match", - ledgerMaster_.getClosedLedger()->info().hash == built.id()); - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::doAccept : parent hash match", - app_.openLedger().current()->info().parentHash == built.id()); + ASSERT( + ledgerMaster_.getClosedLedger()->info().hash == built.id(), + "ripple::RCLConsensus::Adaptor::doAccept : ledger hash match"); + ASSERT( + app_.openLedger().current()->info().parentHash == built.id(), + "ripple::RCLConsensus::Adaptor::doAccept : parent hash match"); } //------------------------------------------------------------------------- @@ -780,9 +780,9 @@ RCLConsensus::Adaptor::buildLCL( std::shared_ptr built = [&]() { if (auto const replayData = ledgerMaster_.releaseReplay()) { - XRPL_ASSERT( - "ripple::RCLConsensus::Adaptor::buildLCL : parent hash match", - replayData->parent()->info().hash == previousLedger.id()); + ASSERT( + replayData->parent()->info().hash == previousLedger.id(), + "ripple::RCLConsensus::Adaptor::buildLCL : parent hash match"); return buildLedger(*replayData, tapNONE, app_, j_); } return buildLedger( diff --git a/src/xrpld/app/consensus/RCLCxPeerPos.cpp b/src/xrpld/app/consensus/RCLCxPeerPos.cpp index 698c21031dd..14a60a84182 100644 --- a/src/xrpld/app/consensus/RCLCxPeerPos.cpp +++ b/src/xrpld/app/consensus/RCLCxPeerPos.cpp @@ -38,9 +38,9 @@ RCLCxPeerPos::RCLCxPeerPos( { // The maximum allowed size of a signature is 72 bytes; we verify // this elsewhere, but we want to be extra careful here: - XRPL_ASSERT( - "ripple::RCLCxPeerPos::RCLCxPeerPos : valid signature size", - signature.size() != 0 && signature.size() <= signature_.capacity()); + ASSERT( + signature.size() != 0 && signature.size() <= signature_.capacity(), + "ripple::RCLCxPeerPos::RCLCxPeerPos : valid signature size"); if (signature.size() != 0 && signature.size() <= signature_.capacity()) signature_.assign(signature.begin(), signature.end()); diff --git a/src/xrpld/app/consensus/RCLCxTx.h b/src/xrpld/app/consensus/RCLCxTx.h index 79e69c02c67..0181eb03c21 100644 --- a/src/xrpld/app/consensus/RCLCxTx.h +++ b/src/xrpld/app/consensus/RCLCxTx.h @@ -111,8 +111,9 @@ class RCLTxSet */ RCLTxSet(std::shared_ptr m) : map_{std::move(m)} { - XRPL_ASSERT( - "ripple::RCLTxSet::MutableTxSet::RCLTxSet : non-null input", map_); + ASSERT( + map_ != nullptr, + "ripple::RCLTxSet::MutableTxSet::RCLTxSet : non-null input"); } /** Constructor from a previously created MutableTxSet @@ -178,9 +179,9 @@ class RCLTxSet std::map ret; for (auto const& [k, v] : delta) { - XRPL_ASSERT( - "ripple::RCLTxSet::compare : either side is set", - (v.first && !v.second) || (v.second && !v.first)); + ASSERT( + (v.first && !v.second) || (v.second && !v.first), + "ripple::RCLTxSet::compare : either side is set"); ret[k] = static_cast(v.first); } diff --git a/src/xrpld/app/consensus/RCLValidations.cpp b/src/xrpld/app/consensus/RCLValidations.cpp index f7ec49f3ae7..e620cd3de90 100644 --- a/src/xrpld/app/consensus/RCLValidations.cpp +++ b/src/xrpld/app/consensus/RCLValidations.cpp @@ -50,10 +50,10 @@ RCLValidatedLedger::RCLValidatedLedger( auto const hashIndex = ledger->read(keylet::skip()); if (hashIndex) { - XRPL_ASSERT( + ASSERT( + hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1), "ripple::RCLValidatedLedger::RCLValidatedLedger(Ledger) : valid " - "last ledger sequence", - hashIndex->getFieldU32(sfLastLedgerSequence) == (seq() - 1)); + "last ledger sequence"); ancestors_ = hashIndex->getFieldV256(sfHashes).value(); } else @@ -154,12 +154,12 @@ RCLValidationsAdaptor::acquire(LedgerHash const& hash) return std::nullopt; } - XRPL_ASSERT( - "ripple::RCLValidationsAdaptor::acquire : valid ledger state", - !ledger->open() && ledger->isImmutable()); - XRPL_ASSERT( - "ripple::RCLValidationsAdaptor::acquire : ledger hash match", - ledger->info().hash == hash); + ASSERT( + !ledger->open() && ledger->isImmutable(), + "ripple::RCLValidationsAdaptor::acquire : valid ledger state"); + ASSERT( + ledger->info().hash == hash, + "ripple::RCLValidationsAdaptor::acquire : ledger hash match"); return RCLValidatedLedger(std::move(ledger), j_); } @@ -198,9 +198,9 @@ handleNewValidation( { if (bypassAccept == BypassAccept::yes) { - XRPL_ASSERT( - "ripple::handleNewValidation : journal is available", - j.has_value()); + ASSERT( + j.has_value(), + "ripple::handleNewValidation : journal is available"); if (j.has_value()) { JLOG(j->trace()) << "Bypassing checkAccept for validation " diff --git a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp index 0f5036121b4..620ab031762 100644 --- a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp +++ b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp @@ -33,9 +33,9 @@ AcceptedLedgerTx::AcceptedLedgerTx( , mMeta(txn->getTransactionID(), ledger->seq(), *met) , mAffected(mMeta.getAffectedAccounts()) { - XRPL_ASSERT( - "ripple::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state", - !ledger->open()); + ASSERT( + !ledger->open(), + "ripple::AcceptedLedgerTx::AcceptedLedgerTx : valid ledger state"); Serializer s; met->add(s); @@ -78,9 +78,9 @@ AcceptedLedgerTx::AcceptedLedgerTx( std::string AcceptedLedgerTx::getEscMeta() const { - XRPL_ASSERT( - "ripple::AcceptedLedgerTx::getEscMeta : metadata is set", - !mRawMeta.empty()); + ASSERT( + !mRawMeta.empty(), + "ripple::AcceptedLedgerTx::getEscMeta : metadata is set"); return sqlBlobLiteral(mRawMeta); } diff --git a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp index c31fe775c94..334b6d46dbd 100644 --- a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp @@ -60,9 +60,10 @@ ConsensusTransSetSF::gotNode( Serializer s(nodeData.data() + 4, nodeData.size() - 4); SerialIter sit(s.slice()); auto stx = std::make_shared(std::ref(sit)); - XRPL_ASSERT( - "ripple::ConsensusTransSetSF::gotNode : transaction hash match", - stx->getTransactionID() == nodeHash.as_uint256()); + ASSERT( + stx->getTransactionID() == nodeHash.as_uint256(), + "ripple::ConsensusTransSetSF::gotNode : transaction hash " + "match"); auto const pap = &app_; app_.getJobQueue().addJob(jtTRANSACTION, "TXS->TXN", [pap, stx]() { pap->getOPs().submitTransaction(stx); @@ -94,9 +95,9 @@ ConsensusTransSetSF::getNode(SHAMapHash const& nodeHash) const Serializer s; s.add32(HashPrefix::transactionID); txn->getSTransaction()->add(s); - XRPL_ASSERT( - "ripple::ConsensusTransSetSF::getNode : transaction hash match", - sha512Half(s.slice()) == nodeHash.as_uint256()); + ASSERT( + sha512Half(s.slice()) == nodeHash.as_uint256(), + "ripple::ConsensusTransSetSF::getNode : transaction hash match"); nodeData = s.peekData(); return nodeData; } diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 618378d78b2..5fdc4811051 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -369,7 +369,7 @@ Ledger::setAccepted( bool correctCloseTime) { // Used when we witnessed the consensus. - XRPL_ASSERT("ripple::Ledger::setAccepted : valid ledger state", !open()); + ASSERT(!open(), "ripple::Ledger::setAccepted : valid ledger state"); info_.closeTime = closeTime; info_.closeTimeResolution = closeResolution; @@ -442,7 +442,7 @@ Ledger::read(Keylet const& k) const { if (k.key == beast::zero) { - XRPL_UNREACHABLE("ripple::Ledger::read : zero key"); + UNREACHABLE("ripple::Ledger::read : zero key"); return nullptr; } auto const& item = stateMap_.peekItem(k.key); @@ -562,8 +562,9 @@ Ledger::rawTxInsert( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - XRPL_ASSERT( - "ripple::Ledger::rawTxInsert : non-null metadata input", metaData); + ASSERT( + metaData != nullptr, + "ripple::Ledger::rawTxInsert : non-null metadata input"); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -580,9 +581,9 @@ Ledger::rawTxInsertWithHash( std::shared_ptr const& txn, std::shared_ptr const& metaData) { - XRPL_ASSERT( - "ripple::Ledger::rawTxInsertWithHash : non-null metadata input", - metaData); + ASSERT( + metaData != nullptr, + "ripple::Ledger::rawTxInsertWithHash : non-null metadata input"); // low-level - just add to table Serializer s(txn->getDataLength() + metaData->getDataLength() + 16); @@ -678,9 +679,9 @@ Ledger::setup() void Ledger::defaultFees(Config const& config) { - XRPL_ASSERT( - "ripple::Ledger::defaultFees : zero fees", - fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0); + ASSERT( + fees_.base == 0 && fees_.reserve == 0 && fees_.increment == 0, + "ripple::Ledger::defaultFees : zero fees"); if (fees_.base == 0) fees_.base = config.FEES.reference_fee; if (fees_.reserve == 0) @@ -876,7 +877,7 @@ Ledger::assertSensible(beast::Journal ledgerJ) const JLOG(ledgerJ.fatal()) << "ledger is not sensible" << j; - XRPL_UNREACHABLE("ripple::Ledger::assertSensible : ledger is not sensible"); + UNREACHABLE("ripple::Ledger::assertSensible : ledger is not sensible"); return false; } @@ -910,9 +911,9 @@ Ledger::updateSkipList() created = false; } - XRPL_ASSERT( - "ripple::Ledger::updateSkipList : first maximum hashes size", - hashes.size() <= 256); + ASSERT( + hashes.size() <= 256, + "ripple::Ledger::updateSkipList : first maximum hashes size"); hashes.push_back(info_.parentHash); sle->setFieldV256(sfHashes, STVector256(hashes)); sle->setFieldU32(sfLastLedgerSequence, prevIndex); @@ -937,9 +938,9 @@ Ledger::updateSkipList() hashes = static_cast(sle->getFieldV256(sfHashes)); created = false; } - XRPL_ASSERT( - "ripple::Ledger::updateSkipList : second maximum hashes size", - hashes.size() <= 256); + ASSERT( + hashes.size() <= 256, + "ripple::Ledger::updateSkipList : second maximum hashes size"); if (hashes.size() == 256) hashes.erase(hashes.begin()); hashes.push_back(info_.parentHash); @@ -1019,8 +1020,8 @@ pendSaveValidated( } } - XRPL_ASSERT( - "ripple::pendSaveValidated : immutable ledger", ledger->isImmutable()); + ASSERT( + ledger->isImmutable(), "ripple::pendSaveValidated : immutable ledger"); if (!app.pendingSaves().shouldWork(ledger->info().seq, isSynchronous)) { @@ -1097,10 +1098,10 @@ finishLoadByIndexOrHash( if (!ledger) return; - XRPL_ASSERT( - "ripple::finishLoadByIndexOrHash : valid ledger fees", + ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees())); + ledger->read(keylet::fees()), + "ripple::finishLoadByIndexOrHash : valid ledger fees"); ledger->setImmutable(); JLOG(j.trace()) << "Loaded ledger: " << to_string(ledger->info().hash); @@ -1139,9 +1140,9 @@ loadByHash(uint256 const& ledgerHash, Application& app, bool acquire) { std::shared_ptr ledger = loadLedgerHelper(*info, app, acquire); finishLoadByIndexOrHash(ledger, app.config(), app.journal("Ledger")); - XRPL_ASSERT( - "ripple::loadByHash : ledger hash match if loaded", - !ledger || ledger->info().hash == ledgerHash); + ASSERT( + !ledger || ledger->info().hash == ledgerHash, + "ripple::loadByHash : ledger hash match if loaded"); return ledger; } return {}; diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 048a9548702..528e80a2932 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -58,9 +58,9 @@ LedgerHistory::insert( if (!ledger->isImmutable()) LogicError("mutable Ledger in insert"); - XRPL_ASSERT( - "ripple::LedgerHistory::insert : nonzero hash", - ledger->stateMap().getHash().isNonZero()); + ASSERT( + ledger->stateMap().getHash().isNonZero(), + "ripple::LedgerHistory::insert : nonzero hash"); std::unique_lock sl(m_ledgers_by_hash.peekMutex()); @@ -101,17 +101,17 @@ LedgerHistory::getLedgerBySeq(LedgerIndex index) if (!ret) return ret; - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerBySeq : result sequence match", - ret->info().seq == index); + ASSERT( + ret->info().seq == index, + "ripple::LedgerHistory::getLedgerBySeq : result sequence match"); { // Add this ledger to the local tracking by index std::unique_lock sl(m_ledgers_by_hash.peekMutex()); - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerBySeq : immutable result ledger", - ret->isImmutable()); + ASSERT( + ret->isImmutable(), + "ripple::LedgerHistory::getLedgerBySeq : immutable result ledger"); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); mLedgersByIndex[ret->info().seq] = ret->info().hash; return (ret->info().seq == index) ? ret : nullptr; @@ -125,13 +125,14 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (ret) { - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerByHash : immutable fetched ledger", - ret->isImmutable()); - XRPL_ASSERT( + ASSERT( + ret->isImmutable(), + "ripple::LedgerHistory::getLedgerByHash : immutable fetched " + "ledger"); + ASSERT( + ret->info().hash == hash, "ripple::LedgerHistory::getLedgerByHash : fetched ledger hash " - "match", - ret->info().hash == hash); + "match"); return ret; } @@ -140,16 +141,16 @@ LedgerHistory::getLedgerByHash(LedgerHash const& hash) if (!ret) return ret; - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerByHash : immutable loaded ledger", - ret->isImmutable()); - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerByHash : loaded ledger hash match", - ret->info().hash == hash); + ASSERT( + ret->isImmutable(), + "ripple::LedgerHistory::getLedgerByHash : immutable loaded ledger"); + ASSERT( + ret->info().hash == hash, + "ripple::LedgerHistory::getLedgerByHash : loaded ledger hash match"); m_ledgers_by_hash.canonicalize_replace_client(ret->info().hash, ret); - XRPL_ASSERT( - "ripple::LedgerHistory::getLedgerByHash : result hash match", - ret->info().hash == hash); + ASSERT( + ret->info().hash == hash, + "ripple::LedgerHistory::getLedgerByHash : result hash match"); return ret; } @@ -193,9 +194,9 @@ log_metadata_difference( auto validMetaData = getMeta(validLedger, tx); auto builtMetaData = getMeta(builtLedger, tx); - XRPL_ASSERT( - "ripple::log_metadata_difference : some metadata present", - validMetaData || builtMetaData); + ASSERT( + validMetaData || builtMetaData, + "ripple::log_metadata_difference : some metadata present"); if (validMetaData && builtMetaData) { @@ -341,9 +342,9 @@ LedgerHistory::handleMismatch( std::optional const& validatedConsensusHash, Json::Value const& consensus) { - XRPL_ASSERT( - "ripple::LedgerHistory::handleMismatch : unequal hashes", - built != valid); + ASSERT( + built != valid, + "ripple::LedgerHistory::handleMismatch : unequal hashes"); ++mismatch_counter_; auto builtLedger = getLedgerByHash(built); @@ -358,9 +359,9 @@ LedgerHistory::handleMismatch( return; } - XRPL_ASSERT( - "ripple::LedgerHistory::handleMismatch : sequence match", - builtLedger->info().seq == validLedger->info().seq); + ASSERT( + builtLedger->info().seq == validLedger->info().seq, + "ripple::LedgerHistory::handleMismatch : sequence match"); if (auto stream = j_.debug()) { @@ -453,8 +454,7 @@ LedgerHistory::builtLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - XRPL_ASSERT( - "ripple::LedgerHistory::builtLedger : nonzero hash", !hash.isZero()); + ASSERT(!hash.isZero(), "ripple::LedgerHistory::builtLedger : nonzero hash"); std::unique_lock sl(m_consensus_validated.peekMutex()); @@ -494,9 +494,9 @@ LedgerHistory::validatedLedger( { LedgerIndex index = ledger->info().seq; LedgerHash hash = ledger->info().hash; - XRPL_ASSERT( - "ripple::LedgerHistory::validatedLedger : nonzero hash", - !hash.isZero()); + ASSERT( + !hash.isZero(), + "ripple::LedgerHistory::validatedLedger : nonzero hash"); std::unique_lock sl(m_consensus_validated.peekMutex()); diff --git a/src/xrpld/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h index 7ed7420eeb4..2ec355fd82f 100644 --- a/src/xrpld/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -263,8 +263,8 @@ OpenLedger::apply( // If there are any transactions left, we must have // tried them in at least one final pass - XRPL_ASSERT( - "ripple::OpenLedger::apply : valid retries", retries.empty() || !retry); + ASSERT( + retries.empty() || !retry, "ripple::OpenLedger::apply : valid retries"); } //------------------------------------------------------------------------------ diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp index 2a45b5d41a7..926728cbf4f 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -225,9 +225,9 @@ OrderBookDB::makeBookListeners(Book const& book) ret = std::make_shared(); mListeners[book] = ret; - XRPL_ASSERT( - "ripple::OrderBookDB::makeBookListeners : result roundtrip lookup", - getBookListeners(book) == ret); + ASSERT( + getBookListeners(book) == ret, + "ripple::OrderBookDB::makeBookListeners : result roundtrip lookup"); } return ret; diff --git a/src/xrpld/app/ledger/TransactionStateSF.cpp b/src/xrpld/app/ledger/TransactionStateSF.cpp index 760e58045fe..fef622945c1 100644 --- a/src/xrpld/app/ledger/TransactionStateSF.cpp +++ b/src/xrpld/app/ledger/TransactionStateSF.cpp @@ -30,9 +30,9 @@ TransactionStateSF::gotNode( SHAMapNodeType type) const { - XRPL_ASSERT( - "ripple::TransactionStateSF::gotNode : valid input", - type != SHAMapNodeType::tnTRANSACTION_NM); + ASSERT( + type != SHAMapNodeType::tnTRANSACTION_NM, + "ripple::TransactionStateSF::gotNode : valid input"); db_.store( hotTRANSACTION_NODE, std::move(nodeData), diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index e15efab734a..812f9dbbc05 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -57,8 +57,7 @@ buildLedgerImpl( { OpenView accum(&*built); - XRPL_ASSERT( - "ripple::buildLedgerImpl : valid ledger state", !accum.open()); + ASSERT(!accum.open(), "ripple::buildLedgerImpl : valid ledger state"); applyTxs(accum, built); accum.apply(*built); } @@ -76,10 +75,10 @@ buildLedgerImpl( built->unshare(); // Accept ledger - XRPL_ASSERT( - "ripple::buildLedgerImpl : valid ledger fees", + ASSERT( built->info().seq < XRP_LEDGER_EARLIEST_FEES || - built->read(keylet::fees())); + built->read(keylet::fees()), + "ripple::buildLedgerImpl : valid ledger fees"); built->setAccepted(closeTime, closeResolution, closeTimeCorrect); return built; @@ -171,9 +170,9 @@ applyTransactions( // If there are any transactions left, we must have // tried them in at least one final pass - XRPL_ASSERT( - "ripple::applyTransactions : retry transactions", - txns.empty() || !certainRetry); + ASSERT( + txns.empty() || !certainRetry, + "ripple::applyTransactions : retry transactions"); return count; } diff --git a/src/xrpld/app/ledger/detail/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp index 616b56af496..add0726719a 100644 --- a/src/xrpld/app/ledger/detail/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -120,10 +120,10 @@ InboundLedger::init(ScopedLockType& collectionLock) JLOG(journal_.debug()) << "Acquiring ledger we already have in " << " local store. " << hash_; - XRPL_ASSERT( - "ripple::InboundLedger::init : valid ledger fees", + ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees()), + "ripple::InboundLedger::init : valid ledger fees"); mLedger->setImmutable(); if (mReason == Reason::HISTORY) @@ -352,10 +352,10 @@ InboundLedger::tryDB(NodeStore::Database& srcDB) { JLOG(journal_.debug()) << "Had everything locally"; complete_ = true; - XRPL_ASSERT( - "ripple::InboundLedger::tryDB : valid ledger fees", + ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees()), + "ripple::InboundLedger::tryDB : valid ledger fees"); mLedger->setImmutable(); } } @@ -449,16 +449,16 @@ InboundLedger::done() std::to_string(timeouts_) + " ")) << mStats.get(); - XRPL_ASSERT( - "ripple::InboundLedger::done : complete or failed", - complete_ || failed_); + ASSERT( + complete_ || failed_, + "ripple::InboundLedger::done : complete or failed"); if (complete_ && !failed_ && mLedger) { - XRPL_ASSERT( - "ripple::InboundLedger::done : valid ledger fees", + ASSERT( mLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - mLedger->read(keylet::fees())); + mLedger->read(keylet::fees()), + "ripple::InboundLedger::done : valid ledger fees"); mLedger->setImmutable(); switch (mReason) { @@ -618,10 +618,10 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) // if we wind up abandoning this fetch. if (mHaveHeader && !mHaveState && !failed_) { - XRPL_ASSERT( + ASSERT( + mLedger != nullptr, "ripple::InboundLedger::trigger : non-null ledger to read state " - "from", - mLedger); + "from"); if (!mLedger->stateMap().isValid()) { @@ -693,10 +693,10 @@ InboundLedger::trigger(std::shared_ptr const& peer, TriggerReason reason) if (mHaveHeader && !mHaveTransactions && !failed_) { - XRPL_ASSERT( + ASSERT( + mLedger != nullptr, "ripple::InboundLedger::trigger : non-null ledger to read " - "transactions from", - mLedger); + "transactions from"); if (!mLedger->txMap().isValid()) { @@ -961,8 +961,7 @@ InboundLedger::takeAsRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - XRPL_UNREACHABLE( - "ripple::InboundLedger::takeAsRootNode : no ledger header"); + UNREACHABLE("ripple::InboundLedger::takeAsRootNode : no ledger header"); return false; } @@ -987,8 +986,7 @@ InboundLedger::takeTxRootNode(Slice const& data, SHAMapAddNode& san) if (!mHaveHeader) { - XRPL_UNREACHABLE( - "ripple::InboundLedger::takeTxRootNode : no ledger header"); + UNREACHABLE("ripple::InboundLedger::takeTxRootNode : no ledger header"); return false; } diff --git a/src/xrpld/app/ledger/detail/InboundLedgers.cpp b/src/xrpld/app/ledger/detail/InboundLedgers.cpp index 8e52c7bb2c8..691d8f8f07a 100644 --- a/src/xrpld/app/ledger/detail/InboundLedgers.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedgers.cpp @@ -71,9 +71,9 @@ class InboundLedgersImp : public InboundLedgers InboundLedger::Reason reason) override { auto doAcquire = [&, seq, reason]() -> std::shared_ptr { - XRPL_ASSERT( - "ripple::InboundLedgersImp::acquire::doAcquire : nonzero hash", - hash.isNonZero()); + ASSERT( + hash.isNonZero(), + "ripple::InboundLedgersImp::acquire::doAcquire : nonzero hash"); // probably not the right rule if (app_.getOPs().isNeedNetworkLedger() && @@ -163,9 +163,9 @@ class InboundLedgersImp : public InboundLedgers std::shared_ptr find(uint256 const& hash) override { - XRPL_ASSERT( - "ripple::InboundLedgersImp::find : nonzero input", - hash.isNonZero()); + ASSERT( + hash.isNonZero(), + "ripple::InboundLedgersImp::find : nonzero input"); std::shared_ptr ret; @@ -327,9 +327,9 @@ class InboundLedgersImp : public InboundLedgers acqs.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - XRPL_ASSERT( - "ripple::InboundLedgersImp::getInfo : non-null ledger", - it.second); + ASSERT( + it.second != nullptr, + "ripple::InboundLedgersImp::getInfo : non-null ledger"); acqs.push_back(it); } for (auto const& it : mRecentFailures) @@ -364,9 +364,10 @@ class InboundLedgersImp : public InboundLedgers acquires.reserve(mLedgers.size()); for (auto const& it : mLedgers) { - XRPL_ASSERT( - "ripple::InboundLedgersImp::gotFetchPack : non-null ledger", - it.second); + ASSERT( + it.second != nullptr, + "ripple::InboundLedgersImp::gotFetchPack : non-null " + "ledger"); acquires.push_back(it.second); } } diff --git a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp index 1055ed60490..7c9d0f9fd53 100644 --- a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -231,9 +231,9 @@ class LedgerCleanerImp : public LedgerCleaner }); if (shouldExit_) break; - XRPL_ASSERT( - "ripple::LedgerCleanerImp::run : is cleaning", - state_ == State::cleaning); + ASSERT( + state_ == State::cleaning, + "ripple::LedgerCleanerImp::run : is cleaning"); } doLedgerCleaner(); } @@ -355,9 +355,9 @@ class LedgerCleanerImp : public LedgerCleaner LedgerHash refHash = getLedgerHash(referenceLedger, refIndex); bool const nonzero(refHash.isNonZero()); - XRPL_ASSERT( - "ripple::LedgerCleanerImp::getHash : nonzero hash", - nonzero); + ASSERT( + nonzero, + "ripple::LedgerCleanerImp::getHash : nonzero hash"); if (nonzero) { // We found the hash and sequence of a better reference diff --git a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index 41fc4cb0fd7..6c19f6da4ea 100644 --- a/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -199,12 +199,12 @@ LedgerDeltaAcquire::tryBuild(std::shared_ptr const& parent) if (failed_ || !complete_ || !replayTemp_) return {}; - XRPL_ASSERT( - "ripple::LedgerDeltaAcquire::tryBuild : parent sequence match", - parent->seq() + 1 == replayTemp_->seq()); - XRPL_ASSERT( - "ripple::LedgerDeltaAcquire::tryBuild : parent hash match", - parent->info().hash == replayTemp_->info().parentHash); + ASSERT( + parent->seq() + 1 == replayTemp_->seq(), + "ripple::LedgerDeltaAcquire::tryBuild : parent sequence match"); + ASSERT( + parent->info().hash == replayTemp_->info().parentHash, + "ripple::LedgerDeltaAcquire::tryBuild : parent hash match"); // build ledger LedgerReplay replayData(parent, replayTemp_, std::move(orderedTxns_)); fullLedger_ = buildLedger(replayData, tapNONE, app_, journal_); @@ -266,7 +266,7 @@ LedgerDeltaAcquire::onLedgerBuilt( void LedgerDeltaAcquire::notify(ScopedLockType& sl) { - XRPL_ASSERT("ripple::LedgerDeltaAcquire::notify : is done", isDone()); + ASSERT(isDone(), "ripple::LedgerDeltaAcquire::notify : is done"); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index e573dfa7563..f935af9febe 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -117,8 +117,8 @@ class ScopedUnlock */ explicit ScopedUnlock(std::unique_lock& lock) : lock_(lock) { - XRPL_ASSERT( - "ripple::ScopedUnlock::ScopedUnlock : own lock", lock_.owns_lock()); + ASSERT( + lock_.owns_lock(), "ripple::ScopedUnlock::ScopedUnlock : own lock"); lock_.unlock(); } @@ -355,11 +355,11 @@ LedgerMaster::setValidLedger(std::shared_ptr const& l) mValidLedger.set(l); mValidLedgerSign = signTime.time_since_epoch().count(); - XRPL_ASSERT( - "ripple::LedgerMaster::setValidLedger : valid ledger sequence", + ASSERT( mValidLedgerSeq || !app_.getMaxDisallowedLedger() || l->info().seq + max_ledger_difference_ > - app_.getMaxDisallowedLedger()); + app_.getMaxDisallowedLedger(), + "ripple::LedgerMaster::setValidLedger : valid ledger sequence"); (void)max_ledger_difference_; mValidLedgerSeq = l->info().seq; @@ -424,7 +424,9 @@ LedgerMaster::addHeldTransaction( bool LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) { - XRPL_ASSERT("ripple::LedgerMaster::canBeCurrent : non-null input", ledger); + ASSERT( + ledger != nullptr, + "ripple::LedgerMaster::canBeCurrent : non-null input"); // Never jump to a candidate ledger that precedes our // last validated ledger @@ -492,7 +494,9 @@ LedgerMaster::canBeCurrent(std::shared_ptr const& ledger) void LedgerMaster::switchLCL(std::shared_ptr const& lastClosed) { - XRPL_ASSERT("ripple::LedgerMaster::switchLCL : non-null input", lastClosed); + ASSERT( + lastClosed != nullptr, + "ripple::LedgerMaster::switchLCL : non-null input"); if (!lastClosed->isImmutable()) LogicError("mutable ledger in switchLCL"); @@ -609,9 +613,9 @@ LedgerMaster::isValidated(ReadView const& ledger) // This ledger's hash is not the hash of the validated ledger if (hash) { - XRPL_ASSERT( - "ripple::LedgerMaster::isValidated : nonzero hash", - hash->isNonZero()); + ASSERT( + hash->isNonZero(), + "ripple::LedgerMaster::isValidated : nonzero hash"); uint256 valHash = app_.getRelationalDatabase().getHashByIndex(seq); if (valHash == ledger.info().hash) @@ -901,9 +905,9 @@ LedgerMaster::setFullLedger( // A new ledger has been accepted as part of the trusted chain JLOG(m_journal.debug()) << "Ledger " << ledger->info().seq << " accepted :" << ledger->info().hash; - XRPL_ASSERT( - "ripple::LedgerMaster::setFullLedger : nonzero ledger state hash", - ledger->stateMap().getHash().isNonZero()); + ASSERT( + ledger->stateMap().getHash().isNonZero(), + "ripple::LedgerMaster::setFullLedger : nonzero ledger state hash"); ledger->setValidated(); ledger->setFull(); @@ -1367,7 +1371,7 @@ LedgerMaster::findNewLedgersToPublish( { JLOG(m_journal.fatal()) << "Ledger: " << valSeq << " does not have hash for " << seq; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::LedgerMaster::findNewLedgersToPublish : ledger " "not found"); } @@ -1456,9 +1460,9 @@ LedgerMaster::tryAdvance() app_.getJobQueue().addJob(jtADVANCE, "advanceLedger", [this]() { std::unique_lock sl(m_mutex); - XRPL_ASSERT( - "ripple::LedgerMaster::tryAdvance : has valid ledger", - !mValidLedger.empty() && mAdvanceThread); + ASSERT( + !mValidLedger.empty() && mAdvanceThread, + "ripple::LedgerMaster::tryAdvance : has valid ledger"); JLOG(m_journal.trace()) << "advanceThread<"; @@ -1759,7 +1763,9 @@ LedgerMaster::walkHashBySeq( // be located easily and should contain the hash. LedgerIndex refIndex = getCandidateLedger(index); auto const refHash = hashOfSeq(*referenceLedger, refIndex, m_journal); - XRPL_ASSERT("ripple::LedgerMaster::walkHashBySeq : found ledger", refHash); + ASSERT( + refHash.has_value(), + "ripple::LedgerMaster::walkHashBySeq : found ledger"); if (refHash) { // Try the hash and sequence of a better reference ledger just found @@ -1784,9 +1790,10 @@ LedgerMaster::walkHashBySeq( *refHash, refIndex, reason)) { ledgerHash = hashOfSeq(*l, index, m_journal); - XRPL_ASSERT( - "ripple::LedgerMaster::walkHashBySeq : has complete ledger", - ledgerHash); + ASSERT( + ledgerHash.has_value(), + "ripple::LedgerMaster::walkHashBySeq : has complete " + "ledger"); } } } @@ -1898,9 +1905,9 @@ LedgerMaster::fetchForHistory( ScopedUnlock sul{sl}; if (auto hash = getLedgerHashForHistory(missing, reason)) { - XRPL_ASSERT( - "ripple::LedgerMaster::fetchForHistory : found ledger", - hash->isNonZero()); + ASSERT( + hash->isNonZero(), + "ripple::LedgerMaster::fetchForHistory : found ledger"); auto ledger = getLedgerByHash(*hash); if (!ledger) { @@ -1927,9 +1934,9 @@ LedgerMaster::fetchForHistory( if (ledger) { auto seq = ledger->info().seq; - XRPL_ASSERT( - "ripple::LedgerMaster::fetchForHistory : sequence match", - seq == missing); + ASSERT( + seq == missing, + "ripple::LedgerMaster::fetchForHistory : sequence match"); JLOG(m_journal.trace()) << "fetchForHistory acquired " << seq; setFullLedger(ledger, false, false); int fillInProgress; @@ -1970,10 +1977,10 @@ LedgerMaster::fetchForHistory( std::uint32_t seq = missing - i; if (auto h = getLedgerHashForHistory(seq, reason)) { - XRPL_ASSERT( + ASSERT( + h->isNonZero(), "ripple::LedgerMaster::fetchForHistory : " - "prefetched ledger", - h->isNonZero()); + "prefetched ledger"); app_.getInboundLedgers().acquire(*h, seq, reason); } } @@ -2159,7 +2166,7 @@ populateFetchPack( std::uint32_t seq, bool withLeaves = true) { - XRPL_ASSERT("ripple::populateFetchPack : nonzero count input", cnt != 0); + ASSERT(cnt != 0, "ripple::populateFetchPack : nonzero count input"); Serializer s(1024); diff --git a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index 0cbb5ae79fc..e03137a8b09 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -32,9 +32,10 @@ LedgerReplayTask::TaskParameter::TaskParameter( std::uint32_t totalNumLedgers) : reason_(r), finishHash_(finishLedgerHash), totalLedgers_(totalNumLedgers) { - XRPL_ASSERT( - "ripple::LedgerReplayTask::TaskParameter::TaskParameter : valid inputs", - finishLedgerHash.isNonZero() && totalNumLedgers > 0); + ASSERT( + finishLedgerHash.isNonZero() && totalNumLedgers > 0, + "ripple::LedgerReplayTask::TaskParameter::TaskParameter : valid " + "inputs"); } bool @@ -50,9 +51,9 @@ LedgerReplayTask::TaskParameter::update( skipList_ = sList; skipList_.emplace_back(finishHash_); startHash_ = skipList_[skipList_.size() - totalLedgers_]; - XRPL_ASSERT( - "ripple::LedgerReplayTask::TaskParameter::update : nonzero start hash", - startHash_.isNonZero()); + ASSERT( + startHash_.isNonZero(), + "ripple::LedgerReplayTask::TaskParameter::update : nonzero start hash"); startSeq_ = finishSeq_ - totalLedgers_ + 1; full_ = true; return true; @@ -204,9 +205,9 @@ LedgerReplayTask::tryAdvance(ScopedLockType& sl) for (; deltaToBuild_ < deltas_.size(); ++deltaToBuild_) { auto& delta = deltas_[deltaToBuild_]; - XRPL_ASSERT( - "ripple::LedgerReplayTask::tryAdvance : consecutive sequence", - parent_->seq() + 1 == delta->ledgerSeq_); + ASSERT( + parent_->seq() + 1 == delta->ledgerSeq_, + "ripple::LedgerReplayTask::tryAdvance : consecutive sequence"); if (auto l = delta->tryBuild(parent_); l) { JLOG(journal_.debug()) @@ -295,11 +296,11 @@ LedgerReplayTask::addDelta(std::shared_ptr const& delta) JLOG(journal_.trace()) << "addDelta task " << hash_ << " deltaIndex=" << deltaToBuild_ << " totalDeltas=" << deltas_.size(); - XRPL_ASSERT( - "ripple::LedgerReplayTask::addDelta : no deltas or consecutive " - "sequence", + ASSERT( deltas_.empty() || - deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_); + deltas_.back()->ledgerSeq_ + 1 == delta->ledgerSeq_, + "ripple::LedgerReplayTask::addDelta : no deltas or consecutive " + "sequence", ); deltas_.push_back(delta); } } diff --git a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp index f4930f6aa7d..7557d9ed344 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayer.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp @@ -47,10 +47,10 @@ LedgerReplayer::replay( uint256 const& finishLedgerHash, std::uint32_t totalNumLedgers) { - XRPL_ASSERT( - "ripple::LedgerReplayer::replay : valid inputs", + ASSERT( finishLedgerHash.isNonZero() && totalNumLedgers > 0 && - totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE); + totalNumLedgers <= LedgerReplayParameters::MAX_TASK_SIZE, + "ripple::LedgerReplayer::replay : valid inputs"); LedgerReplayTask::TaskParameter parameter( r, finishLedgerHash, totalNumLedgers); diff --git a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp index dfe98a7191e..3b3952a5557 100644 --- a/src/xrpld/app/ledger/detail/SkipListAcquire.cpp +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp @@ -139,9 +139,9 @@ SkipListAcquire::processData( std::uint32_t ledgerSeq, boost::intrusive_ptr const& item) { - XRPL_ASSERT( - "ripple::SkipListAcquire::processData : valid inputs", - ledgerSeq != 0 && item); + ASSERT( + ledgerSeq != 0 && item, + "ripple::SkipListAcquire::processData : valid inputs"); ScopedLockType sl(mtx_); if (isDone()) return; @@ -226,7 +226,7 @@ SkipListAcquire::onSkipListAcquired( void SkipListAcquire::notify(ScopedLockType& sl) { - XRPL_ASSERT("ripple::SkipListAcquire::notify : is done", isDone()); + ASSERT(isDone(), "ripple::SkipListAcquire::notify : is done"); std::vector toCall; std::swap(toCall, dataReadyCallbacks_); auto const good = !failed_; diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 272ffdf4aa4..4eb35bb02fb 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -43,9 +43,9 @@ TimeoutCounter::TimeoutCounter( , queueJobParameter_(std::move(jobParameter)) , timer_(app_.getIOService()) { - XRPL_ASSERT( - "ripple::TimeoutCounter::TimeoutCounter : interval input inside range", - (timerInterval_ > 10ms) && (timerInterval_ < 30s)); + ASSERT( + (timerInterval_ > 10ms) && (timerInterval_ < 30s), + "ripple::TimeoutCounter::TimeoutCounter : interval input inside range"); } void diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 550b628b483..c10862d8217 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -586,9 +586,10 @@ class ApplicationImp : public Application, public BasicApp virtual ServerHandler& getServerHandler() override { - XRPL_ASSERT( - "ripple::ApplicationImp::getServerHandler : non-null server handle", - serverHandler_); + ASSERT( + serverHandler_ != nullptr, + "ripple::ApplicationImp::getServerHandler : non-null server " + "handle"); return *serverHandler_; } @@ -794,36 +795,37 @@ class ApplicationImp : public Application, public BasicApp Overlay& overlay() override { - XRPL_ASSERT( - "ripple::ApplicationImp::overlay : non-null overlay", overlay_); + ASSERT( + overlay_ != nullptr, + "ripple::ApplicationImp::overlay : non-null overlay"); return *overlay_; } TxQ& getTxQ() override { - XRPL_ASSERT( - "ripple::ApplicationImp::getTxQ : non-null transaction queue", - txQ_.get() != nullptr); + ASSERT( + txQ_.get() != nullptr, + "ripple::ApplicationImp::getTxQ : non-null transaction queue"); return *txQ_; } RelationalDatabase& getRelationalDatabase() override { - XRPL_ASSERT( + ASSERT( + mRelationalDatabase.get() != nullptr, "ripple::ApplicationImp::getRelationalDatabase : non-null " - "relational database", - mRelationalDatabase.get() != nullptr); + "relational database"); return *mRelationalDatabase; } DatabaseCon& getWalletDB() override { - XRPL_ASSERT( - "ripple::ApplicationImp::getWalletDB : non-null wallet database", - mWalletDB.get() != nullptr); + ASSERT( + mWalletDB.get() != nullptr, + "ripple::ApplicationImp::getWalletDB : non-null wallet database"); return *mWalletDB; } @@ -838,10 +840,10 @@ class ApplicationImp : public Application, public BasicApp bool initRelationalDatabase() { - XRPL_ASSERT( + ASSERT( + mWalletDB.get() == nullptr, "ripple::ApplicationImp::initRelationalDatabase : null wallet " - "database", - mWalletDB.get() == nullptr); + "database"); try { @@ -1243,8 +1245,9 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) for (auto const& [a, vote] : amendments) { auto const f = ripple::getRegisteredFeature(a); - XRPL_ASSERT( - "ripple::ApplicationImp::setup : registered feature", f); + ASSERT( + f.has_value(), + "ripple::ApplicationImp::setup : registered feature"); if (f) supported.emplace_back(a, *f, vote); } @@ -1707,10 +1710,10 @@ ApplicationImp::startGenesisLedger() auto const next = std::make_shared(*genesis, timeKeeper().closeTime()); next->updateSkipList(); - XRPL_ASSERT( - "ripple::ApplicationImp::startGenesisLedger : valid ledger fees", + ASSERT( next->info().seq < XRP_LEDGER_EARLIEST_FEES || - next->read(keylet::fees())); + next->read(keylet::fees()), + "ripple::ApplicationImp::startGenesisLedger : valid ledger fees"); next->setImmutable(); openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger")); m_ledgerMaster->storeLedger(next); @@ -1729,10 +1732,10 @@ ApplicationImp::getLastFullLedger() if (!ledger) return ledger; - XRPL_ASSERT( - "ripple::ApplicationImp::getLastFullLedger : valid ledger fees", + ASSERT( ledger->info().seq < XRP_LEDGER_EARLIEST_FEES || - ledger->read(keylet::fees())); + ledger->read(keylet::fees()), + "ripple::ApplicationImp::getLastFullLedger : valid ledger fees"); ledger->setImmutable(); if (getLedgerMaster().haveLedger(seq)) @@ -1884,10 +1887,10 @@ ApplicationImp::loadLedgerFromFile(std::string const& name) loadLedger->stateMap().flushDirty(hotACCOUNT_NODE); - XRPL_ASSERT( - "ripple::ApplicationImp::loadLedgerFromFile : valid ledger fees", + ASSERT( loadLedger->info().seq < XRP_LEDGER_EARLIEST_FEES || - loadLedger->read(keylet::fees())); + loadLedger->read(keylet::fees()), + "ripple::ApplicationImp::loadLedgerFromFile : valid ledger fees"); loadLedger->setAccepted( closeTime, closeTimeResolution, !closeTimeEstimated); @@ -1985,7 +1988,7 @@ ApplicationImp::loadOldLedger( if (!loadLedger) { JLOG(m_journal.fatal()) << "Replay ledger missing/damaged"; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::ApplicationImp::loadOldLedger : replay ledger " "missing/damaged"); return false; @@ -2016,7 +2019,7 @@ ApplicationImp::loadOldLedger( if (loadLedger->info().accountHash.isZero()) { JLOG(m_journal.fatal()) << "Ledger is empty."; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::ApplicationImp::loadOldLedger : ledger is empty"); return false; } @@ -2024,7 +2027,7 @@ ApplicationImp::loadOldLedger( if (!loadLedger->walkLedger(journal("Ledger"), true)) { JLOG(m_journal.fatal()) << "Ledger is missing nodes."; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::ApplicationImp::loadOldLedger : ledger is missing " "nodes"); return false; @@ -2033,7 +2036,7 @@ ApplicationImp::loadOldLedger( if (!loadLedger->assertSensible(journal("Ledger"))) { JLOG(m_journal.fatal()) << "Ledger is not sensible."; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::ApplicationImp::loadOldLedger : ledger is not " "sensible"); return false; diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 2cc5c4033c4..fcf8664c50e 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -606,7 +606,7 @@ GRPCServer::stop() GRPCServer::~GRPCServer() { - XRPL_ASSERT("ripple::GRPCServer::~GRPCServer : is not running", !running_); + ASSERT(!running_, "ripple::GRPCServer::~GRPCServer : is not running"); } } // namespace ripple diff --git a/src/xrpld/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp index 90c9b539c75..181007305ef 100644 --- a/src/xrpld/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -73,9 +73,9 @@ void LoadManager::start() { JLOG(journal_.debug()) << "Starting"; - XRPL_ASSERT( - "ripple::LoadManager::start : thread not joinable", - !thread_.joinable()); + ASSERT( + !thread_.joinable(), + "ripple::LoadManager::start : thread not joinable"); thread_ = std::thread{&LoadManager::run, this}; } diff --git a/src/xrpld/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp index 07d60b208f3..7943bbe97a7 100644 --- a/src/xrpld/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -200,9 +200,9 @@ FeeVoteImpl::doVoting( std::shared_ptr const& initialPosition) { // LCL must be flag ledger - XRPL_ASSERT( - "ripple::FeeVoteImpl::doVoting : has a flag ledger", - lastClosedLedger && isFlagLedger(lastClosedLedger->seq())); + ASSERT( + lastClosedLedger && isFlagLedger(lastClosedLedger->seq()), + "ripple::FeeVoteImpl::doVoting : has a flag ledger"); detail::VotableValue baseFeeVote( lastClosedLedger->fees().base, target_.reference_fee); diff --git a/src/xrpld/app/misc/HashRouter.cpp b/src/xrpld/app/misc/HashRouter.cpp index 9bafb9c4561..44133dddf9b 100644 --- a/src/xrpld/app/misc/HashRouter.cpp +++ b/src/xrpld/app/misc/HashRouter.cpp @@ -101,7 +101,7 @@ HashRouter::getFlags(uint256 const& key) bool HashRouter::setFlags(uint256 const& key, int flags) { - XRPL_ASSERT("ripple::HashRouter::setFlags : valid input", flags != 0); + ASSERT(flags != 0, "ripple::HashRouter::setFlags : valid input"); std::lock_guard lock(mutex_); diff --git a/src/xrpld/app/misc/NegativeUNLVote.cpp b/src/xrpld/app/misc/NegativeUNLVote.cpp index 3a375851de5..b8f485c3dc0 100644 --- a/src/xrpld/app/misc/NegativeUNLVote.cpp +++ b/src/xrpld/app/misc/NegativeUNLVote.cpp @@ -89,9 +89,9 @@ NegativeUNLVote::doVoting( { auto n = choose(prevLedger->info().hash, candidates.toDisableCandidates); - XRPL_ASSERT( - "ripple::NegativeUNLVote::doVoting : found node to disable", - nidToKeyMap.count(n)); + ASSERT( + nidToKeyMap.count(n) != 0, + "ripple::NegativeUNLVote::doVoting : found node to disable"); addTx(seq, nidToKeyMap.at(n), ToDisable, initialSet); } @@ -99,9 +99,9 @@ NegativeUNLVote::doVoting( { auto n = choose( prevLedger->info().hash, candidates.toReEnableCandidates); - XRPL_ASSERT( - "ripple::NegativeUNLVote::doVoting : found node to enable", - nidToKeyMap.count(n)); + ASSERT( + nidToKeyMap.count(n) != 0, + "ripple::NegativeUNLVote::doVoting : found node to enable"); addTx(seq, nidToKeyMap.at(n), ToReEnable, initialSet); } } @@ -144,9 +144,9 @@ NegativeUNLVote::choose( uint256 const& randomPadData, std::vector const& candidates) { - XRPL_ASSERT( - "ripple::NegativeUNLVote::choose : non-empty input", - !candidates.empty()); + ASSERT( + !candidates.empty(), + "ripple::NegativeUNLVote::choose : non-empty input"); static_assert(NodeID::bytes <= uint256::bytes); NodeID randomPad = NodeID::fromVoid(randomPadData.data()); NodeID txNodeID = candidates[0]; diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 756114dc418..83272b2f622 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -103,10 +103,10 @@ class NetworkOPsImp final : public NetworkOPs FailHard f) : transaction(t), admin(a), local(l), failType(f) { - XRPL_ASSERT( + ASSERT( + local || failType == FailHard::no, "ripple::NetworkOPsImp::TransactionStatus::TransactionStatus : " - "valid inputs", - local || failType == FailHard::no); + "valid inputs"); } }; @@ -1211,9 +1211,9 @@ NetworkOPsImp::processTransaction( *transaction->getSTransaction(), view->rules(), app_.config()); - XRPL_ASSERT( - "ripple::NetworkOPsImp::processTransaction : valid validity", - validity == Validity::Valid); + ASSERT( + validity == Validity::Valid, + "ripple::NetworkOPsImp::processTransaction : valid validity"); // Not concerned with local checks at this point. if (validity == Validity::SigBad) @@ -1319,12 +1319,12 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) std::vector submit_held; std::vector transactions; mTransactions.swap(transactions); - XRPL_ASSERT( - "ripple::NetworkOPsImp::apply : non-empty transactions", - !transactions.empty()); - XRPL_ASSERT( - "ripple::NetworkOPsImp::apply : is not running", - mDispatchState != DispatchState::running); + ASSERT( + !transactions.empty(), + "ripple::NetworkOPsImp::apply : non-empty transactions"); + ASSERT( + mDispatchState != DispatchState::running, + "ripple::NetworkOPsImp::apply : is not running"); mDispatchState = DispatchState::running; @@ -1541,9 +1541,9 @@ NetworkOPsImp::getOwnerInfo( for (auto const& uDirEntry : sleNode->getFieldV256(sfIndexes)) { auto sleCur = lpLedger->read(keylet::child(uDirEntry)); - XRPL_ASSERT( - "ripple::NetworkOPsImp::getOwnerInfo : non-null child SLE", - sleCur); + ASSERT( + sleCur != nullptr, + "ripple::NetworkOPsImp::getOwnerInfo : non-null child SLE"); switch (sleCur->getType()) { @@ -1570,7 +1570,7 @@ NetworkOPsImp::getOwnerInfo( case ltACCOUNT_ROOT: case ltDIR_NODE: default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::NetworkOPsImp::getOwnerInfo : invalid " "type"); break; @@ -1582,9 +1582,9 @@ NetworkOPsImp::getOwnerInfo( if (uNodeDir) { sleNode = lpLedger->read(keylet::page(root, uNodeDir)); - XRPL_ASSERT( - "ripple::NetworkOPsImp::getOwnerInfo : read next page", - sleNode); + ASSERT( + sleNode != nullptr, + "ripple::NetworkOPsImp::getOwnerInfo : read next page"); } } while (uNodeDir); } @@ -1815,9 +1815,9 @@ NetworkOPsImp::switchLastClosedLedger( bool NetworkOPsImp::beginConsensus(uint256 const& networkClosed) { - XRPL_ASSERT( - "ripple::NetworkOPsImp::beginConsensus : nonzero input", - networkClosed.isNonZero()); + ASSERT( + networkClosed.isNonZero(), + "ripple::NetworkOPsImp::beginConsensus : nonzero input"); auto closingInfo = m_ledgerMaster.getCurrentLedger()->info(); @@ -1838,15 +1838,14 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed) return false; } - XRPL_ASSERT( + ASSERT( + prevLedger->info().hash == closingInfo.parentHash, "ripple::NetworkOPsImp::beginConsensus : prevLedger hash matches " - "parent", - prevLedger->info().hash == closingInfo.parentHash); - XRPL_ASSERT( + "parent"); + ASSERT( + closingInfo.parentHash == m_ledgerMaster.getClosedLedger()->info().hash, "ripple::NetworkOPsImp::beginConsensus : closedLedger parent matches " - "hash", - closingInfo.parentHash == - m_ledgerMaster.getClosedLedger()->info().hash); + "hash"); if (prevLedger->rules().enabled(featureNegativeUNL)) app_.validators().setNegativeUNL(prevLedger->negativeUNL()); @@ -2820,9 +2819,9 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) lpAccepted->info().hash, alpAccepted); } - XRPL_ASSERT( - "ripple::NetworkOPsImp::pubLedger : accepted input", - alpAccepted->getLedger().get() == lpAccepted.get()); + ASSERT( + alpAccepted->getLedger().get() == lpAccepted.get(), + "ripple::NetworkOPsImp::pubLedger : accepted input"); { JLOG(m_journal.debug()) @@ -3223,11 +3222,11 @@ NetworkOPsImp::pubAccountTransaction( if (last) jvObj.set(jss::account_history_boundary, true); - XRPL_ASSERT( - "ripple::NetworkOPsImp::pubAccountTransaction : " - "account_history_tx_stream not set", + ASSERT( jvObj.isMember(jss::account_history_tx_stream) == - MultiApiJson::none); + MultiApiJson::none, + "ripple::NetworkOPsImp::pubAccountTransaction : " + "account_history_tx_stream not set"); for (auto& info : accountHistoryNotify) { auto& index = info.index_; @@ -3300,11 +3299,11 @@ NetworkOPsImp::pubProposedAccountTransaction( isrListener->getApiVersion(), // [&](Json::Value const& jv) { isrListener->send(jv, true); }); - XRPL_ASSERT( - "ripple::NetworkOPs::pubProposedAccountTransaction : " - "account_history_tx_stream not set", + ASSERT( jvObj.isMember(jss::account_history_tx_stream) == - MultiApiJson::none); + MultiApiJson::none, + "ripple::NetworkOPs::pubProposedAccountTransaction : " + "account_history_tx_stream not set"); for (auto& info : accountHistoryNotify) { auto& index = info.index_; @@ -3525,7 +3524,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) return db->newestAccountTxPage(options); } default: { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::NetworkOPsImp::addAccountHistoryJob::" "getMoreTxns : invalid database type"); return {}; @@ -3723,7 +3722,7 @@ NetworkOPsImp::subAccountHistoryStart( } else { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::NetworkOPsImp::subAccountHistoryStart : failed to " "access genesis account"); return; @@ -3833,8 +3832,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else - XRPL_UNREACHABLE( - "ripple::NetworkOPsImp::subBook : null book listeners"); + UNREACHABLE("ripple::NetworkOPsImp::subBook : null book listeners"); return true; } @@ -3853,8 +3851,7 @@ NetworkOPsImp::acceptLedger( { // This code-path is exclusively used when the server is in standalone // mode via `ledger_accept` - XRPL_ASSERT( - "ripple::NetworkOPsImp::acceptLedger : is standalone", m_standalone); + ASSERT(m_standalone, "ripple::NetworkOPsImp::acceptLedger : is standalone"); if (!m_standalone) Throw( diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 712ab48c4ec..2913ebb857f 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -513,9 +513,9 @@ SHAMapStoreImp::clearSql( std::function()> const& getMinSeq, std::function const& deleteBeforeSeq) { - XRPL_ASSERT( - "ripple::SHAMapStoreImp::clearSql : nonzero delete interval", - deleteInterval_); + ASSERT( + deleteInterval_ != 0, + "ripple::SHAMapStoreImp::clearSql : nonzero delete interval"); LedgerIndex min = std::numeric_limits::max(); { diff --git a/src/xrpld/app/misc/detail/AMMHelpers.cpp b/src/xrpld/app/misc/detail/AMMHelpers.cpp index 9e1d56333eb..4e23a607502 100644 --- a/src/xrpld/app/misc/detail/AMMHelpers.cpp +++ b/src/xrpld/app/misc/detail/AMMHelpers.cpp @@ -209,9 +209,9 @@ adjustAmountsByLPTokens( return std::make_tuple(amountActual, std::nullopt, lpTokensActual); } - XRPL_ASSERT( - "ripple::adjustAmountsByLPTokens : LP tokens match actual", - lpTokensActual == lpTokens); + ASSERT( + lpTokensActual == lpTokens, + "ripple::adjustAmountsByLPTokens : LP tokens match actual"); return {amount, amount2, lpTokensActual}; } diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp index 2a5af4708ec..c91f0c56642 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -145,10 +145,10 @@ std::uint16_t getTradingFee(ReadView const& view, SLE const& ammSle, AccountID const& account) { using namespace std::chrono; - XRPL_ASSERT( - "ripple::getTradingFee : auction present", + ASSERT( !view.rules().enabled(fixInnerObjTemplate) || - ammSle.isFieldPresent(sfAuctionSlot)); + ammSle.isFieldPresent(sfAuctionSlot), + "ripple::getTradingFee : auction present"); if (ammSle.isFieldPresent(sfAuctionSlot)) { auto const& auctionSlot = diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index dfd1881baa9..a35eb72efeb 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -656,9 +656,9 @@ AmendmentTableImpl::persistVote( std::string const& name, AmendmentVote vote) const { - XRPL_ASSERT( - "ripple::AmendmentTableImpl::persistVote : valid vote input", - vote != AmendmentVote::obsolete); + ASSERT( + vote != AmendmentVote::obsolete, + "ripple::AmendmentTableImpl::persistVote : valid vote input"); auto db = db_.checkoutDb(); voteAmendment(*db, amendment, name, vote); } diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp index 05ccd3d6cf4..bf3b58cc9d9 100644 --- a/src/xrpld/app/misc/detail/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -390,9 +390,9 @@ ManifestCache::applyManifest(Manifest m) auto prewriteCheck = [this, &m](auto const& iter, bool checkSignature, auto const& lock) -> std::optional { - XRPL_ASSERT( - "ripple::ManifestCache::applyManifest::prewriteCheck : locked", - lock.owns_lock()); + ASSERT( + lock.owns_lock(), + "ripple::ManifestCache::applyManifest::prewriteCheck : locked"); (void)lock; // not used. parameter is present to ensure the mutex is // locked when the lambda is called. if (iter != map_.end() && m.sequence <= iter->second.sequence) diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index 8605e9a07d2..27cb785eb78 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -82,10 +82,10 @@ Transaction::sqlTransactionStatus(boost::optional const& status) return INCLUDED; } - XRPL_ASSERT( + ASSERT( + c == txnSqlUnknown, "ripple::Transaction::sqlTransactionStatus : unknown transaction " - "status", - c == txnSqlUnknown); + "status"); return INVALID; } diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 2d1afbc9a38..1faa9087f4f 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -52,7 +52,7 @@ getFeeLevelPaid(ReadView const& view, STTx const& tx) return std::pair{baseFee + mod, feePaid + mod}; }(); - XRPL_ASSERT("ripple::getFeeLevelPaid : positive fee", baseFee.signum() > 0); + ASSERT(baseFee.signum() > 0, "ripple::getFeeLevelPaid : positive fee"); if (effectiveFeePaid.signum() <= 0 || baseFee.signum() <= 0) { return FeeLevel64(0); @@ -95,9 +95,9 @@ TxQ::FeeMetrics::update( feeLevels.push_back(getFeeLevelPaid(view, *tx.first)); }); std::sort(feeLevels.begin(), feeLevels.end()); - XRPL_ASSERT( - "ripple::TxQ::FeeMetrics::update : fee levels size", - size == feeLevels.size()); + ASSERT( + size == feeLevels.size(), + "ripple::TxQ::FeeMetrics::update : fee levels size"); JLOG((timeLeap ? j_.warn() : j_.debug())) << "Ledger " << view.info().seq << " has " << size << " transactions. " @@ -249,10 +249,10 @@ TxQ::FeeMetrics::escalatedSeriesFeeLevel( auto const target = snapshot.txnsExpected; auto const multiplier = snapshot.escalationMultiplier; - XRPL_ASSERT( + ASSERT( + current > target, "ripple::TxQ::FeeMetrics::escalatedSeriesFeeLevel : current over " - "target", - current > target); + "target"); /* Calculate (apologies for the terrible notation) sum(n = current -> last) : multiplier * n * n / (target * target) @@ -297,8 +297,9 @@ std::pair TxQ::MaybeTx::apply(Application& app, OpenView& view, beast::Journal j) { // If the rules or flags change, preflight again - XRPL_ASSERT( - "ripple::TxQ::MaybeTx::apply : preflight result is set", pfresult); + ASSERT( + pfresult.has_value(), + "ripple::TxQ::MaybeTx::apply : preflight result is set"); STAmountSO stAmountSO{view.rules().enabled(fixSTAmountCanonicalize)}; NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; @@ -343,11 +344,10 @@ TxQ::TxQAccount::add(MaybeTx&& txn) auto const seqProx = txn.seqProxy; auto result = transactions.emplace(seqProx, std::move(txn)); - XRPL_ASSERT( - "ripple::TxQ::TxQAccount::add : emplace succeeded", result.second); - XRPL_ASSERT( - "ripple::TxQ::TxQAccount::add : transaction moved", - &result.first->second != &txn); + ASSERT(result.second, "ripple::TxQ::TxQAccount::add : emplace succeeded"); + ASSERT( + &result.first->second != &txn, + "ripple::TxQ::TxQAccount::add : transaction moved"); return result.first->second; } @@ -455,9 +455,8 @@ TxQ::erase(TxQ::FeeMultiSet::const_iterator_type candidateIter) // Now that the candidate has been removed from the // intrusive list remove it from the TxQAccount // so the memory can be freed. - auto const found = txQAccount.remove(seqProx); - (void)found; - XRPL_ASSERT("ripple::TxQ::erase : account removed", found); + [[maybe_unused]] auto const found = txQAccount.remove(seqProx); + ASSERT(found, "ripple::TxQ::erase : account removed"); return newCandidateIter; } @@ -469,20 +468,20 @@ TxQ::eraseAndAdvance(TxQ::FeeMultiSet::const_iterator_type candidateIter) auto& txQAccount = byAccount_.at(candidateIter->account); auto const accountIter = txQAccount.transactions.find(candidateIter->seqProxy); - XRPL_ASSERT( - "ripple::TxQ::eraseAndAdvance : account found", - accountIter != txQAccount.transactions.end()); + ASSERT( + accountIter != txQAccount.transactions.end(), + "ripple::TxQ::eraseAndAdvance : account found"); // Note that sequence-based transactions must be applied in sequence order // from smallest to largest. But ticket-based transactions can be // applied in any order. - XRPL_ASSERT( - "ripple::TxQ::eraseAndAdvance : ticket or sequence", + ASSERT( candidateIter->seqProxy.isTicket() || - accountIter == txQAccount.transactions.begin()); - XRPL_ASSERT( - "ripple::TxQ::eraseAndAdvance : found in byFee", - byFee_.iterator_to(accountIter->second) == candidateIter); + accountIter == txQAccount.transactions.begin(), + "ripple::TxQ::eraseAndAdvance : ticket or sequence"); + ASSERT( + byFee_.iterator_to(accountIter->second) == candidateIter, + "ripple::TxQ::eraseAndAdvance : found in byFee"); auto const accountNextIter = std::next(accountIter); // Check if the next transaction for this account is earlier in the queue, @@ -529,9 +528,9 @@ TxQ::tryClearAccountQueueUpThruTx( beast::Journal j) { SeqProxy const tSeqProx{tx.getSeqProxy()}; - XRPL_ASSERT( - "ripple::TxQ::tryClearAccountQueueUpThruTx : non-empty accounts input", - beginTxIter != accountIter->second.transactions.end()); + ASSERT( + beginTxIter != accountIter->second.transactions.end(), + "ripple::TxQ::tryClearAccountQueueUpThruTx : non-empty accounts input"); // This check is only concerned with the range from // [aSeqProxy, tSeqProxy) @@ -1014,8 +1013,7 @@ TxQ::apply( // o The current first thing in the queue has a Ticket and // * The tx has a Ticket that precedes it or // * txSeqProx == acctSeqProx. - XRPL_ASSERT( - "ripple::TxQ::apply : not end", prevIter != txIter->end); + ASSERT(prevIter != txIter->end, "ripple::TxQ::apply : not end"); if (prevIter == txIter->end || txSeqProx < prevIter->first) { // The first Sequence number in the queue must be the @@ -1136,11 +1134,11 @@ TxQ::apply( // inserted in the middle from fouling up later transactions. auto const potentialTotalSpend = totalFee + std::min(balance - std::min(balance, reserve), potentialSpend); - XRPL_ASSERT( - "ripple::TxQ::apply : total spend check", + ASSERT( potentialTotalSpend > XRPAmount{0} || (potentialTotalSpend == XRPAmount{0} && - multiTxn->applyView.fees().base == 0)); + multiTxn->applyView.fees().base == 0), + "ripple::TxQ::apply : total spend check"); sleBump->setFieldAmount(sfBalance, balance - potentialTotalSpend); // The transaction's sequence/ticket will be valid when the other // transactions in the queue have been processed. If the tx has a @@ -1170,7 +1168,7 @@ TxQ::apply( return {pcresult.ter, false}; // Too low of a fee should get caught by preclaim - XRPL_ASSERT("ripple::TxQ::apply : minimum fee", feeLevelPaid >= baseLevel); + ASSERT(feeLevelPaid >= baseLevel, "ripple::TxQ::apply : minimum fee"); JLOG(j_.trace()) << "Transaction " << transactionID << " from account " << account << " has fee level of " << feeLevelPaid @@ -1295,9 +1293,9 @@ TxQ::apply( // The queue is full, and this transaction is more // valuable, so kick out the cheapest transaction. auto dropRIter = endAccount.transactions.rbegin(); - XRPL_ASSERT( - "ripple::TxQ::apply : cheapest transaction found", - dropRIter->second.account == lastRIter->account); + ASSERT( + dropRIter->second.account == lastRIter->account, + "ripple::TxQ::apply : cheapest transaction found"); JLOG(j_.info()) << "Removing last item of account " << lastRIter->account << " from queue with average fee of " << endEffectiveFeeLevel @@ -1323,11 +1321,10 @@ TxQ::apply( if (!accountIsInQueue) { // Create a new TxQAccount object and add the byAccount lookup. - bool created; + [[maybe_unused]] bool created = false; std::tie(accountIter, created) = byAccount_.emplace(account, TxQAccount(tx)); - (void)created; - XRPL_ASSERT("ripple::TxQ::apply : account created", created); + ASSERT(created, "ripple::TxQ::apply : account created"); } // Modify the flags for use when coming out of the queue. // These changes _may_ cause an extra `preflight`, but as long as @@ -1540,10 +1537,9 @@ TxQ::accept(Application& app, OpenView& view) // making things worse, drop the _last_ transaction for // this account. auto dropRIter = account.transactions.rbegin(); - XRPL_ASSERT( - "ripple::TxQ::accept : account check", - dropRIter->second.account == - candidateIter->account); + ASSERT( + dropRIter->second.account == candidateIter->account, + "ripple::TxQ::accept : account check"); JLOG(j_.info()) << "Queue is nearly full, and transaction " @@ -1574,8 +1570,7 @@ TxQ::accept(Application& app, OpenView& view) LedgerHash const& parentHash = view.info().parentHash; #if !NDEBUG auto const startingSize = byFee_.size(); - XRPL_ASSERT( - "ripple::TxQ::accept : new parent hash", parentHash != parentHash_); + ASSERT(parentHash != parentHash_, "ripple::TxQ::accept : new parent hash"); parentHash_ = parentHash; #endif // byFee_ doesn't "own" the candidate objects inside it, so it's @@ -1597,9 +1592,9 @@ TxQ::accept(Application& app, OpenView& view) byFee_.insert(candidate); } } - XRPL_ASSERT( - "ripple::TxQ::accept : byFee size match", - byFee_.size() == startingSize); + ASSERT( + byFee_.size() == startingSize, + "ripple::TxQ::accept : byFee size match"); return ledgerChanged; } @@ -1758,18 +1753,18 @@ TxQ::removeFromByFee( // If the transaction we're holding replaces a transaction in the // queue, remove the transaction that is being replaced. auto deleteIter = byFee_.iterator_to((*replacedTxIter)->second); - XRPL_ASSERT( - "ripple::TxQ::removeFromByFee : found in byFee", - deleteIter != byFee_.end()); - XRPL_ASSERT( - "ripple::TxQ::removeFromByFee : matching transaction", - &(*replacedTxIter)->second == &*deleteIter); - XRPL_ASSERT( - "ripple::TxQ::removeFromByFee : matching sequence", - deleteIter->seqProxy == tx->getSeqProxy()); - XRPL_ASSERT( - "ripple::TxQ::removeFromByFee : matching account", - deleteIter->account == (*tx)[sfAccount]); + ASSERT( + deleteIter != byFee_.end(), + "ripple::TxQ::removeFromByFee : found in byFee"); + ASSERT( + &(*replacedTxIter)->second == &*deleteIter, + "ripple::TxQ::removeFromByFee : matching transaction"); + ASSERT( + deleteIter->seqProxy == tx->getSeqProxy(), + "ripple::TxQ::removeFromByFee : matching sequence"); + ASSERT( + deleteIter->account == (*tx)[sfAccount], + "ripple::TxQ::removeFromByFee : matching account"); erase(deleteIter); } diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index adc3b870df0..c648507e8cb 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -276,9 +276,9 @@ ValidatorList::buildFileData( { Json::Value value(Json::objectValue); - XRPL_ASSERT( - "ripple::ValidatorList::buildFileData : valid publisher list input", - pubCollection.rawVersion == 2 || pubCollection.remaining.empty()); + ASSERT( + pubCollection.rawVersion == 2 || pubCollection.remaining.empty(), + "ripple::ValidatorList::buildFileData : valid publisher list input"); auto const effectiveVersion = forceVersion ? *forceVersion : pubCollection.rawVersion; @@ -378,9 +378,9 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) ValidatorBlobInfo& info = result.emplace_back(); info.blob = body[jss::blob].asString(); info.signature = body[jss::signature].asString(); - XRPL_ASSERT( - "ripple::ValidatorList::parseBlobs : single element result", - result.size() == 1); + ASSERT( + result.size() == 1, + "ripple::ValidatorList::parseBlobs : single element result"); return result; } // Treat unknown versions as if they're the latest version. This @@ -415,10 +415,10 @@ ValidatorList::parseBlobs(std::uint32_t version, Json::Value const& body) info.manifest = blobInfo[jss::manifest].asString(); } } - XRPL_ASSERT( + ASSERT( + result.size() == blobs.size(), "ripple::ValidatorList::parseBlobs(version, Jason::Value) : " - "result size matches", - result.size() == blobs.size()); + "result size matches"); return result; } } @@ -449,10 +449,10 @@ ValidatorList::parseBlobs(protocol::TMValidatorListCollection const& body) info.manifest = blob.manifest(); } } - XRPL_ASSERT( + ASSERT( + result.size() == body.blobs_size(), "ripple::ValidatorList::parseBlobs(TMValidatorList) : result size " - "match", - result.size() == body.blobs_size()); + "match"); return result; } @@ -474,7 +474,7 @@ splitMessage( { if (begin == 0 && end == 0) end = largeMsg.blobs_size(); - XRPL_ASSERT("ripple::splitMessage : valid inputs", begin < end); + ASSERT(begin < end, "ripple::splitMessage : valid inputs"); if (end <= begin) return 0; @@ -508,9 +508,9 @@ splitMessageParts( if (blob.has_manifest()) smallMsg.set_manifest(blob.manifest()); - XRPL_ASSERT( - "ripple::splitMessageParts : maximum message size", - Message::totalSize(smallMsg) <= maximiumMessageSize); + ASSERT( + Message::totalSize(smallMsg) <= maximiumMessageSize, + "ripple::splitMessageParts : maximum message size"); messages.emplace_back( std::make_shared(smallMsg, protocol::mtVALIDATORLIST), @@ -558,10 +558,10 @@ buildValidatorListMessage( ValidatorBlobInfo const& currentBlob, std::size_t maxSize) { - XRPL_ASSERT( + ASSERT( + messages.empty(), "ripple::buildValidatorListMessage(ValidatorBlobInfo) : empty messages " - "input", - messages.empty()); + "input"); protocol::TMValidatorList msg; auto const manifest = currentBlob.manifest ? *currentBlob.manifest : rawManifest; @@ -572,10 +572,10 @@ buildValidatorListMessage( // Override the version msg.set_version(version); - XRPL_ASSERT( + ASSERT( + Message::totalSize(msg) <= maximiumMessageSize, "ripple::buildValidatorListMessage(ValidatorBlobInfo) : maximum " - "message size", - Message::totalSize(msg) <= maximiumMessageSize); + "message size"); messages.emplace_back( std::make_shared(msg, protocol::mtVALIDATORLIST), sha512Half(msg), @@ -594,10 +594,10 @@ buildValidatorListMessage( std::map const& blobInfos, std::size_t maxSize) { - XRPL_ASSERT( + ASSERT( + messages.empty(), "ripple::buildValidatorListMessage(std::map) : empty messages input", - messages.empty()); + "ValidatorBlobInfo>) : empty messages input"); protocol::TMValidatorListCollection msg; auto const version = rawVersion < 2 ? 2 : rawVersion; msg.set_version(version); @@ -613,10 +613,10 @@ buildValidatorListMessage( if (blobInfo.manifest) blob.set_manifest(*blobInfo.manifest); } - XRPL_ASSERT( + ASSERT( + msg.blobs_size() > 0, "ripple::buildValidatorListMessage(std::map) : minimum message blobs", - msg.blobs_size() > 0); + "ValidatorBlobInfo>) : minimum message blobs"); if (Message::totalSize(msg) > maxSize) { // split into smaller messages @@ -645,10 +645,10 @@ ValidatorList::buildValidatorListMessages( std::vector& messages, std::size_t maxSize /*= maximiumMessageSize*/) { - XRPL_ASSERT( + ASSERT( + !blobInfos.empty(), "ripple::ValidatorList::buildValidatorListMessages : empty messages " - "input", - !blobInfos.empty()); + "input"); auto const& [currentSeq, currentBlob] = *blobInfos.begin(); auto numVLs = std::accumulate( messages.begin(), @@ -732,10 +732,10 @@ ValidatorList::sendValidatorList( messages); if (newPeerSequence) { - XRPL_ASSERT( + ASSERT( + !messages.empty(), "ripple::ValidatorList::sendValidatorList : non-empty messages " - "input", - !messages.empty()); + "input"); // Don't send it next time. peer.setPublisherListSequence(publisherKey, newPeerSequence); @@ -751,9 +751,9 @@ ValidatorList::sendValidatorList( } // The only way sent wil be false is if the messages was too big, and // thus there will only be one entry without a message - XRPL_ASSERT( - "ripple::ValidatorList::sendValidatorList : sent or one message", - sent || messages.size() == 1); + ASSERT( + sent || messages.size() == 1, + "ripple::ValidatorList::sendValidatorList : sent or one message"); if (sent) { if (messageVersion > 1) @@ -767,10 +767,10 @@ ValidatorList::sendValidatorList( << "]"; else { - XRPL_ASSERT( + ASSERT( + numVLs == 1, "ripple::ValidatorList::sendValidatorList : one validator " - "list", - numVLs == 1); + "list"); JLOG(j.debug()) << "Sent validator list for " << strHex(publisherKey) << " with sequence " << newPeerSequence << " to " @@ -865,10 +865,10 @@ ValidatorList::broadcastBlobs( // be built to hold info for all of the valid VLs. std::map blobInfos; - XRPL_ASSERT( - "ripple::ValidatorList::broadcastBlobs : valid sequence", + ASSERT( lists.current.sequence == maxSequence || - lists.remaining.count(maxSequence) == 1); + lists.remaining.count(maxSequence) == 1, + "ripple::ValidatorList::broadcastBlobs : valid sequence"); // Can't use overlay.foreach here because we need to modify // the peer, and foreach provides a const& for (auto& peer : overlay.getActivePeers()) @@ -1012,9 +1012,9 @@ ValidatorList::applyLists( for (auto iter = remaining.begin(); iter != remaining.end();) { auto next = std::next(iter); - XRPL_ASSERT( - "ripple::ValidatorList::applyLists : next is valid", - next == remaining.end() || next->first > iter->first); + ASSERT( + next == remaining.end() || next->first > iter->first, + "ripple::ValidatorList::applyLists : next is valid"); if (iter->first <= current.sequence || (next != remaining.end() && next->second.validFrom <= iter->second.validFrom)) @@ -1186,9 +1186,9 @@ ValidatorList::applyList( // Remove the entry in "remaining" pubCollection.remaining.erase(sequence); // Done - XRPL_ASSERT( - "ripple::ValidatorList::applyList : publisher sequence match", - publisher.sequence == sequence); + ASSERT( + publisher.sequence == sequence, + "ripple::ValidatorList::applyList : publisher sequence match"); } else { @@ -1482,10 +1482,10 @@ ValidatorList::removePublisherList( PublicKey const& publisherKey, PublisherStatus reason) { - XRPL_ASSERT( - "ripple::ValidatorList::removePublisherList : valid reason input", + ASSERT( reason != PublisherStatus::available && - reason != PublisherStatus::unavailable); + reason != PublisherStatus::unavailable, + "ripple::ValidatorList::removePublisherList : valid reason input"); auto const iList = publisherLists_.find(publisherKey); if (iList == publisherLists_.end()) return false; @@ -1670,9 +1670,9 @@ ValidatorList::getJson() const Json::Value& r = remaining.append(Json::objectValue); appendList(future, r); // Race conditions can happen, so make this check "fuzzy" - XRPL_ASSERT( - "ripple::ValidatorList::getJson : minimum valid from", - future.validFrom > timeKeeper_.now() + 600s); + ASSERT( + future.validFrom > timeKeeper_.now() + 600s, + "ripple::ValidatorList::getJson : minimum valid from"); } if (remaining.size()) curr[jss::remaining] = std::move(remaining); @@ -1737,9 +1737,9 @@ ValidatorList::for_each_available( { if (plCollection.status != PublisherStatus::available) continue; - XRPL_ASSERT( - "ripple::ValidatorList::for_each_available : nonzero maxSequence", - plCollection.maxSequence); + ASSERT( + plCollection.maxSequence != 0, + "ripple::ValidatorList::for_each_available : nonzero maxSequence"); func( plCollection.rawManifest, plCollection.rawVersion, @@ -1873,31 +1873,31 @@ ValidatorList::updateTrusted( next->second.validFrom <= closeTime; ++iter, ++next) { - XRPL_ASSERT( + ASSERT( + std::next(iter) == next, "ripple::ValidatorList::updateTrusted : sequential " - "remaining", - std::next(iter) == next); + "remaining"); } - XRPL_ASSERT( + ASSERT( + iter != remaining.end(), "ripple::ValidatorList::updateTrusted : non-end of " - "remaining", - iter != remaining.end()); + "remaining"); // Rotate the pending list in to current auto sequence = iter->first; auto& candidate = iter->second; auto& current = collection.current; - XRPL_ASSERT( - "ripple::ValidatorList::updateTrusted : maximum time", - candidate.validFrom <= closeTime); + ASSERT( + candidate.validFrom <= closeTime, + "ripple::ValidatorList::updateTrusted : maximum time"); auto const oldList = current.list; current = std::move(candidate); if (collection.status != PublisherStatus::available) collection.status = PublisherStatus::available; - XRPL_ASSERT( - "ripple::ValidatorList::updateTrusted : sequence match", - current.sequence == sequence); + ASSERT( + current.sequence == sequence, + "ripple::ValidatorList::updateTrusted : sequence match"); // If the list is expired, remove the validators so they don't // get processed in. The expiration check below will do the rest // of the work @@ -1974,9 +1974,9 @@ ValidatorList::updateTrusted( { std::optional const signingKey = validatorManifests_.getSigningKey(k); - XRPL_ASSERT( - "ripple::ValidatorList::updateTrusted : found signing key", - signingKey); + ASSERT( + signingKey.has_value(), + "ripple::ValidatorList::updateTrusted : found signing key"); trustedSigningKeys_.insert(*signingKey); } } diff --git a/src/xrpld/app/misc/detail/ValidatorSite.cpp b/src/xrpld/app/misc/detail/ValidatorSite.cpp index 6e3f4835878..fd775fc9251 100644 --- a/src/xrpld/app/misc/detail/ValidatorSite.cpp +++ b/src/xrpld/app/misc/detail/ValidatorSite.cpp @@ -411,9 +411,9 @@ ValidatorSite::parseJsonResponse( } auto const manifest = body[jss::manifest].asString(); - XRPL_ASSERT( - "ripple::ValidatorSite::parseJsonResponse : version match", - version == body[jss::version].asUInt()); + ASSERT( + version == body[jss::version].asUInt(), + "ripple::ValidatorSite::parseJsonResponse : version match"); auto const& uri = sites_[siteIdx].activeResource->uri; auto const hash = sha512Half(manifest, blobs, version); auto const applyResult = app_.validators().applyListsAndBroadcast( @@ -588,10 +588,10 @@ ValidatorSite::onSiteFetch( case status::temporary_redirect: { auto newLocation = processRedirect(res, siteIdx, lock_sites); - XRPL_ASSERT( + ASSERT( + newLocation != nullptr, "ripple::ValidatorSite::onSiteFetch : non-null " - "validator", - newLocation); + "validator"); // for perm redirects, also update our starting URI if (res.result() == status::moved_permanently || res.result() == status::permanent_redirect) diff --git a/src/xrpld/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h index b296565511f..8fece4703f5 100644 --- a/src/xrpld/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -282,7 +282,9 @@ WorkBase::onResponse(error_code const& ec) return fail(ec); close(); - XRPL_ASSERT("ripple::detail::WorkBase::onResponse : callback is set", cb_); + ASSERT( + cb_ != nullptr, + "ripple::detail::WorkBase::onResponse : callback is set"); cb_(ec, lastEndpoint_, std::move(res_)); cb_ = nullptr; } diff --git a/src/xrpld/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h index e7b799f879c..1f08cacac68 100644 --- a/src/xrpld/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -88,7 +88,7 @@ WorkFile::run() error_code ec; auto const fileContents = getFileContents(ec, path_, megabytes(1)); - XRPL_ASSERT("ripple::detail::WorkFile::run : callback is set", cb_); + ASSERT(cb_ != nullptr, "ripple::detail::WorkFile::run : callback is set"); cb_(ec, fileContents); cb_ = nullptr; } diff --git a/src/xrpld/app/paths/Credit.cpp b/src/xrpld/app/paths/Credit.cpp index 072381edaab..c91fcb1b022 100644 --- a/src/xrpld/app/paths/Credit.cpp +++ b/src/xrpld/app/paths/Credit.cpp @@ -42,12 +42,12 @@ creditLimit( result.setIssuer(account); } - XRPL_ASSERT( - "ripple::creditLimit : result issuer match", - result.getIssuer() == account); - XRPL_ASSERT( - "ripple::creditLimit : result currency match", - result.getCurrency() == currency); + ASSERT( + result.getIssuer() == account, + "ripple::creditLimit : result issuer match"); + ASSERT( + result.getCurrency() == currency, + "ripple::creditLimit : result currency match"); return result; } @@ -80,12 +80,12 @@ creditBalance( result.setIssuer(account); } - XRPL_ASSERT( - "ripple::creditBalance : result issuer match", - result.getIssuer() == account); - XRPL_ASSERT( - "ripple::creditBalance : result currency match", - result.getCurrency() == currency); + ASSERT( + result.getIssuer() == account, + "ripple::creditBalance : result issuer match"); + ASSERT( + result.getCurrency() == currency, + "ripple::creditBalance : result currency match"); return result; } diff --git a/src/xrpld/app/paths/Flow.cpp b/src/xrpld/app/paths/Flow.cpp index b50d2c69497..23d9da64150 100644 --- a/src/xrpld/app/paths/Flow.cpp +++ b/src/xrpld/app/paths/Flow.cpp @@ -193,7 +193,7 @@ flow( flowDebugInfo)); } - XRPL_ASSERT("ripple::flow : neither is XRP", !srcIsXRP && !dstIsXRP); + ASSERT(!srcIsXRP && !dstIsXRP, "ripple::flow : neither is XRP"); return finishFlow( sb, srcIssue, diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index 9b50b527ad2..96b450bc573 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -158,8 +158,7 @@ PathRequest::updateComplete() { std::lock_guard sl(mIndexLock); - XRPL_ASSERT( - "ripple::PathRequest::updateComplete : in progress", mInProgress); + ASSERT(mInProgress, "ripple::PathRequest::updateComplete : in progress"); mInProgress = false; if (fCompletion) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index a80fbc29e14..c3795fbe78f 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -188,9 +188,9 @@ Pathfinder::Pathfinder( , app_(app) , j_(app.journal("Pathfinder")) { - XRPL_ASSERT( - "ripple::Pathfinder::Pathfinder : valid inputs", - !uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value())); + ASSERT( + !uSrcIssuer || isXRP(uSrcCurrency) == isXRP(uSrcIssuer.value()), + "ripple::Pathfinder::Pathfinder : valid inputs"); } bool @@ -579,9 +579,9 @@ Pathfinder::getBestPaths( if (mCompletePaths.empty() && extraPaths.empty()) return mCompletePaths; - XRPL_ASSERT( - "ripple::Pathfinder::getBestPaths : first empty path result", - fullLiquidityPath.empty()); + ASSERT( + fullLiquidityPath.empty(), + "ripple::Pathfinder::getBestPaths : first empty path result"); const bool issuerIsSender = isXRP(mSrcCurrency) || (srcIssuer == mSrcAccount); @@ -642,8 +642,7 @@ Pathfinder::getBestPaths( if (path.empty()) { - XRPL_UNREACHABLE( - "ripple::Pathfinder::getBestPaths : path not found"); + UNREACHABLE("ripple::Pathfinder::getBestPaths : path not found"); continue; } @@ -686,9 +685,9 @@ Pathfinder::getBestPaths( if (remaining > beast::zero) { - XRPL_ASSERT( - "ripple::Pathfinder::getBestPaths : second empty path result", - fullLiquidityPath.empty()); + ASSERT( + fullLiquidityPath.empty(), + "ripple::Pathfinder::getBestPaths : second empty path result"); JLOG(j_.info()) << "Paths could not send " << remaining << " of " << mDstAmount; } @@ -837,9 +836,9 @@ Pathfinder::addPathsForType( { case nt_SOURCE: // Source must always be at the start, so pathsOut has to be empty. - XRPL_ASSERT( - "ripple::Pathfinder::addPathsForType : empty paths", - pathsOut.empty()); + ASSERT( + pathsOut.empty(), + "ripple::Pathfinder::addPathsForType : empty paths"); pathsOut.push_back(STPath()); break; @@ -1291,7 +1290,7 @@ void fillPaths(Pathfinder::PaymentType type, PathCostList const& costs) { auto& list = mPathTable[type]; - XRPL_ASSERT("ripple::fillPaths : empty paths", list.empty()); + ASSERT(list.empty(), "ripple::fillPaths : empty paths"); for (auto& cost : costs) list.push_back({cost.cost, makePath(cost.path)}); } diff --git a/src/xrpld/app/paths/RippleLineCache.cpp b/src/xrpld/app/paths/RippleLineCache.cpp index be838c53eac..053546ce0be 100644 --- a/src/xrpld/app/paths/RippleLineCache.cpp +++ b/src/xrpld/app/paths/RippleLineCache.cpp @@ -79,9 +79,9 @@ RippleLineCache::getRippleLines( // to be replaced by the full set. The full set will be built // below, and will be returned, if needed, on subsequent calls // for either value of outgoing. - XRPL_ASSERT( - "ripple::RippleLineCache::getRippleLines : maximum lines", - size <= totalLineCount_); + ASSERT( + size <= totalLineCount_, + "ripple::RippleLineCache::getRippleLines : maximum lines"); totalLineCount_ -= size; lines_.erase(otheriter); } @@ -101,9 +101,9 @@ RippleLineCache::getRippleLines( if (inserted) { - XRPL_ASSERT( - "ripple::RippleLineCache::getRippleLines : null lines", - it->second == nullptr); + ASSERT( + it->second == nullptr, + "ripple::RippleLineCache::getRippleLines : null lines"); auto lines = PathFindTrustLine::getItems(accountID, *ledger_, direction); if (lines.size()) @@ -114,9 +114,9 @@ RippleLineCache::getRippleLines( } } - XRPL_ASSERT( - "ripple::RippleLineCache::getRippleLines : null or nonempty lines", - !it->second || (it->second->size() > 0)); + ASSERT( + !it->second || (it->second->size() > 0), + "ripple::RippleLineCache::getRippleLines : null or nonempty lines"); auto const size = it->second ? it->second->size() : 0; JLOG(journal_.trace()) << "getRippleLines for ledger " << ledger_->info().seq << " found " << size diff --git a/src/xrpld/app/paths/detail/AMMLiquidity.cpp b/src/xrpld/app/paths/detail/AMMLiquidity.cpp index 3df173311d3..ea25222bd08 100644 --- a/src/xrpld/app/paths/detail/AMMLiquidity.cpp +++ b/src/xrpld/app/paths/detail/AMMLiquidity.cpp @@ -77,9 +77,9 @@ AMMLiquidity::generateFibSeqOffer( 196418, 317811, 514229, 832040, 1346269}; // clang-format on - XRPL_ASSERT( - "ripple::AMMLiquidity::generateFibSeqOffer : maximum iterations", - !ammContext_.maxItersReached()); + ASSERT( + !ammContext_.maxItersReached(), + "ripple::AMMLiquidity::generateFibSeqOffer : maximum iterations"); cur.out = toAmount( getIssue(balances.out), diff --git a/src/xrpld/app/paths/detail/AmountSpec.h b/src/xrpld/app/paths/detail/AmountSpec.h index 70fdd61f853..59ca5f5d29b 100644 --- a/src/xrpld/app/paths/detail/AmountSpec.h +++ b/src/xrpld/app/paths/detail/AmountSpec.h @@ -125,8 +125,7 @@ template <> inline IOUAmount& get(EitherAmount& amt) { - XRPL_ASSERT( - "ripple::get(EitherAmount&) : is not XRP", !amt.native); + ASSERT(!amt.native, "ripple::get(EitherAmount&) : is not XRP"); return amt.iou; } @@ -134,7 +133,7 @@ template <> inline XRPAmount& get(EitherAmount& amt) { - XRPL_ASSERT("ripple::get(EitherAmount&) : is XRP", amt.native); + ASSERT(amt.native, "ripple::get(EitherAmount&) : is XRP"); return amt.xrp; } @@ -150,9 +149,9 @@ template <> inline IOUAmount const& get(EitherAmount const& amt) { - XRPL_ASSERT( - "ripple::get(EitherAmount const&) : is not XRP", - !amt.native); + ASSERT( + !amt.native, + "ripple::get(EitherAmount const&) : is not XRP"); return amt.iou; } @@ -160,17 +159,16 @@ template <> inline XRPAmount const& get(EitherAmount const& amt) { - XRPL_ASSERT( - "ripple::get(EitherAmount const&) : is XRP", amt.native); + ASSERT(amt.native, "ripple::get(EitherAmount const&) : is XRP"); return amt.xrp; } inline AmountSpec toAmountSpec(STAmount const& amt) { - XRPL_ASSERT( - "ripple::toAmountSpec(STAmount const&) : maximum mantissa", - amt.mantissa() < std::numeric_limits::max()); + ASSERT( + amt.mantissa() < std::numeric_limits::max(), + "ripple::toAmountSpec(STAmount const&) : maximum mantissa"); bool const isNeg = amt.negative(); std::int64_t const sMant = isNeg ? -std::int64_t(amt.mantissa()) : amt.mantissa(); @@ -205,10 +203,10 @@ toAmountSpec(EitherAmount const& ea, std::optional const& c) AmountSpec r; r.native = (!c || isXRP(*c)); r.currency = c; - XRPL_ASSERT( + ASSERT( + ea.native == r.native, "ripple::toAmountSpec(EitherAmount const&&, std::optional) : " - "matching native", - ea.native == r.native); + "matching native"); if (r.native) { r.xrp = ea.xrp; diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index e619d0e5aa8..01907a42714 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -381,9 +381,9 @@ class BookOfferCrossingStep getQuality(std::optional const& limitQuality) { // It's really a programming error if the quality is missing. - XRPL_ASSERT( - "ripple::BookOfferCrossingStep::getQuality : nonzero quality", - limitQuality); + ASSERT( + limitQuality.has_value(), + "ripple::BookOfferCrossingStep::getQuality : nonzero quality"); if (!limitQuality) Throw(tefINTERNAL, "Offer requires quality."); return *limitQuality; @@ -1111,8 +1111,7 @@ BookStep::revImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingOut < 0 " << to_string(remainingOut); - XRPL_UNREACHABLE( - "ripple::BookStep::revImp : remaining less than zero"); + UNREACHABLE("ripple::BookStep::revImp : remaining less than zero"); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1135,7 +1134,7 @@ BookStep::fwdImp( boost::container::flat_set& ofrsToRm, TIn const& in) { - XRPL_ASSERT("ripple::BookStep::fwdImp : cache is set", cache_); + ASSERT(cache_.has_value(), "ripple::BookStep::fwdImp : cache is set"); TAmounts result(beast::zero, beast::zero); @@ -1154,8 +1153,9 @@ BookStep::fwdImp( TOut const& ownerGives, std::uint32_t transferRateIn, std::uint32_t transferRateOut) mutable -> bool { - XRPL_ASSERT( - "ripple::BookStep::fwdImp::eachOffer : cache is set", cache_); + ASSERT( + cache_.has_value(), + "ripple::BookStep::fwdImp::eachOffer : cache is set"); if (remainingIn <= beast::zero) return false; @@ -1283,8 +1283,7 @@ BookStep::fwdImp( // something went very wrong JLOG(j_.error()) << "BookStep remainingIn < 0 " << to_string(remainingIn); - XRPL_UNREACHABLE( - "ripple::BookStep::fwdImp : remaining less than zero"); + UNREACHABLE("ripple::BookStep::fwdImp : remaining less than zero"); cache_.emplace(beast::zero, beast::zero); return {beast::zero, beast::zero}; } @@ -1419,8 +1418,7 @@ bookStepEqual(Step const& step, ripple::Book const& book) bool const outXRP = isXRP(book.out.currency); if (inXRP && outXRP) { - XRPL_UNREACHABLE( - "ripple::test::bookStepEqual : no XRP to XRP book step"); + UNREACHABLE("ripple::test::bookStepEqual : no XRP to XRP book step"); return false; // no such thing as xrp/xrp book step } if (inXRP && !outXRP) diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 36f7c3f4a82..6920c8d8752 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -514,9 +514,9 @@ DirectStepI::revImp( auto const [srcQOut, dstQIn] = qualities(sb, srcDebtDir, StrandDirection::reverse); - XRPL_ASSERT( - "ripple::DirectStepI : valid destination quality", - static_cast(this)->verifyDstQualityIn(dstQIn)); + ASSERT( + static_cast(this)->verifyDstQualityIn(dstQIn), + "ripple::DirectStepI : valid destination quality"); Issue const srcToDstIss(currency_, redeems(srcDebtDir) ? dst_ : src_); @@ -635,7 +635,7 @@ DirectStepI::fwdImp( boost::container::flat_set& /*ofrsToRm*/, IOUAmount const& in) { - XRPL_ASSERT("ripple::DirectStepI::fwdImp : cache is set", cache_); + ASSERT(cache_.has_value(), "ripple::DirectStepI::fwdImp : cache is set"); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -722,7 +722,7 @@ DirectStepI::validFwd( auto const savCache = *cache_; - XRPL_ASSERT("ripple::DirectStepI::validFwd : input is not XRP", !in.native); + ASSERT(!in.native, "ripple::DirectStepI::validFwd : input is not XRP"); auto const [maxSrcToDst, srcDebtDir] = static_cast(this)->maxFlow(sb, cache_->srcToDst); @@ -786,11 +786,11 @@ DirectStepI::qualitiesSrcIssues( { // Charge a transfer rate when issuing and previous step redeems - XRPL_ASSERT( - "ripple::DirectStepI::qualitiesSrcIssues : will prevStepDebtDirection " - "issue", + ASSERT( static_cast(this)->verifyPrevStepDebtDirection( - prevStepDebtDirection)); + prevStepDebtDirection), + "ripple::DirectStepI::qualitiesSrcIssues : will prevStepDebtDirection " + "issue"); std::uint32_t const srcQOut = redeems(prevStepDebtDirection) ? transferRate(sb, src_).value @@ -929,7 +929,7 @@ DirectStepI::check(StrandContext const& ctx) const { if (!ctx.prevStep) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::DirectStepI::check : prev seen book without a " "prev step"); return temBAD_PATH_LOOP; diff --git a/src/xrpld/app/paths/detail/FlowDebugInfo.h b/src/xrpld/app/paths/detail/FlowDebugInfo.h index 24d011f9d10..38e1a8cff5e 100644 --- a/src/xrpld/app/paths/detail/FlowDebugInfo.h +++ b/src/xrpld/app/paths/detail/FlowDebugInfo.h @@ -89,10 +89,10 @@ struct FlowDebugInfo void pushLiquiditySrc(EitherAmount const& eIn, EitherAmount const& eOut) { - XRPL_ASSERT( + ASSERT( + !liquiditySrcIn.empty(), "ripple::path::detail::FlowDebugInfo::pushLiquiditySrc : " - "non-empty liquidity source", - !liquiditySrcIn.empty()); + "non-empty liquidity source"); liquiditySrcIn.back().push_back(eIn); liquiditySrcOut.back().push_back(eOut); } @@ -125,7 +125,7 @@ struct FlowDebugInfo auto i = timePoints.find(tag); if (i == timePoints.end()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::path::detail::FlowDebugInfo::duration : timepoint not " "found"); return std::chrono::duration(0); diff --git a/src/xrpld/app/paths/detail/PaySteps.cpp b/src/xrpld/app/paths/detail/PaySteps.cpp index 356888b071c..56eae0aab3d 100644 --- a/src/xrpld/app/paths/detail/PaySteps.cpp +++ b/src/xrpld/app/paths/detail/PaySteps.cpp @@ -101,15 +101,14 @@ toStep( // should already be taken care of JLOG(j.error()) << "Found offer/account payment step. Aborting payment strand."; - XRPL_UNREACHABLE( - "ripple::toStep : offer/account payment payment strand"); + UNREACHABLE("ripple::toStep : offer/account payment payment strand"); return {temBAD_PATH, std::unique_ptr{}}; } - XRPL_ASSERT( - "ripple::toStep : currency or issuer", + ASSERT( (e2->getNodeType() & STPathElement::typeCurrency) || - (e2->getNodeType() & STPathElement::typeIssuer)); + (e2->getNodeType() & STPathElement::typeIssuer), + "ripple::toStep : currency or issuer"); auto const outCurrency = e2->getNodeType() & STPathElement::typeCurrency ? e2->getCurrency() : curIssue.currency; @@ -123,7 +122,7 @@ toStep( return {temBAD_PATH, std::unique_ptr{}}; } - XRPL_ASSERT("ripple::toStep : is offer", e2->isOffer()); + ASSERT(e2->isOffer(), "ripple::toStep : is offer"); if (isXRP(outCurrency)) return make_BookStepIX(ctx, curIssue); @@ -394,7 +393,7 @@ toStrand( next->getCurrency() != curIssue.currency) { // Should never happen - XRPL_UNREACHABLE("ripple::toStrand : offer currency mismatch"); + UNREACHABLE("ripple::toStrand : offer currency mismatch"); return {temBAD_PATH, Strand{}}; } @@ -460,7 +459,7 @@ toStrand( if (!checkStrand()) { JLOG(j.warn()) << "Flow check strand failed"; - XRPL_UNREACHABLE("ripple::toStrand : invalid strand"); + UNREACHABLE("ripple::toStrand : invalid strand"); return {temBAD_PATH, Strand{}}; } diff --git a/src/xrpld/app/paths/detail/StepChecks.h b/src/xrpld/app/paths/detail/StepChecks.h index e5773e6a03d..3c1c883ebf6 100644 --- a/src/xrpld/app/paths/detail/StepChecks.h +++ b/src/xrpld/app/paths/detail/StepChecks.h @@ -35,7 +35,7 @@ checkFreeze( AccountID const& dst, Currency const& currency) { - XRPL_ASSERT("ripple::checkFreeze : unequal input accounts", src != dst); + ASSERT(src != dst, "ripple::checkFreeze : unequal input accounts"); // check freeze if (auto sle = view.read(keylet::account(dst))) diff --git a/src/xrpld/app/paths/detail/StrandFlow.h b/src/xrpld/app/paths/detail/StrandFlow.h index f5a725fc97d..3b2fdadcf77 100644 --- a/src/xrpld/app/paths/detail/StrandFlow.h +++ b/src/xrpld/app/paths/detail/StrandFlow.h @@ -172,7 +172,7 @@ flow( << "Re-executed limiting step failed. r.first: " << to_string(get(r.first)) << " maxIn: " << to_string(*maxIn); - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::flow : first step re-executing the " "limiting step failed"); return Result{strand, std::move(ofrsToRm)}; @@ -210,7 +210,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed limiting step failed"; #endif - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::flow : limiting step re-executing the " "limiting step failed"); return Result{strand, std::move(ofrsToRm)}; @@ -246,7 +246,7 @@ flow( #else JLOG(j.fatal()) << "Re-executed forward pass failed"; #endif - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::flow : non-limiting step re-executing the " "forward pass failed"); return Result{strand, std::move(ofrsToRm)}; @@ -500,7 +500,7 @@ class ActiveStrands { if (i >= cur_.size()) { - XRPL_UNREACHABLE("ripple::ActiveStrands::get : input out of range"); + UNREACHABLE("ripple::ActiveStrands::get : input out of range"); return nullptr; } return cur_[i]; @@ -707,10 +707,10 @@ flow( flowDebugInfo->pushLiquiditySrc( EitherAmount(f.in), EitherAmount(f.out)); - XRPL_ASSERT( - "ripple::flow : remaining constraints", + ASSERT( f.out <= remainingOut && f.sandbox && - (!remainingIn || f.in <= *remainingIn)); + (!remainingIn || f.in <= *remainingIn), + "ripple::flow : remaining constraints"); Quality const q(f.out, f.in); @@ -733,7 +733,7 @@ flow( if (baseView.rules().enabled(featureFlowSortStrands)) { - XRPL_ASSERT("ripple::flow : best is unset", !best); + ASSERT(!best, "ripple::flow : best is unset"); if (!f.inactive) activeStrands.push(strand); best.emplace(f.in, f.out, std::move(*f.sandbox), *strand, q); @@ -847,7 +847,7 @@ flow( // running debug builds of rippled. While this issue still needs to // be resolved, the assert is causing more harm than good at this // point. - // XRPL_UNREACHABLE(); + // UNREACHABLE(); return {tefEXCEPTION, std::move(ofrsToRmOnFail)}; } @@ -884,7 +884,7 @@ flow( // Handles both cases 1. and 2. // fixFillOrKill amendment: // Handles 2. 1. is handled above and falls through for tfSell. - XRPL_ASSERT("ripple::flow : nonzero remainingIn", remainingIn); + ASSERT(remainingIn.has_value(), "ripple::flow : nonzero remainingIn"); if (remainingIn && *remainingIn != beast::zero) return { tecPATH_PARTIAL, diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 94d787a50ee..834dd43ae73 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -282,7 +282,8 @@ XRPEndpointStep::fwdImp( boost::container::flat_set& ofrsToRm, XRPAmount const& in) { - XRPL_ASSERT("ripple::XRPEndpointStep::fwdImp : cache is set", cache_); + ASSERT( + cache_.has_value(), "ripple::XRPEndpointStep::fwdImp : cache is set"); auto const balance = static_cast(this)->xrpLiquid(sb); auto const result = isLast_ ? in : std::min(balance, in); @@ -310,7 +311,7 @@ XRPEndpointStep::validFwd( return {false, EitherAmount(XRPAmount(beast::zero))}; } - XRPL_ASSERT("ripple::XRPEndpointStep::validFwd : input is XRP", in.native); + ASSERT(in.native, "ripple::XRPEndpointStep::validFwd : input is XRP"); auto const& xrpIn = in.xrp; auto const balance = static_cast(this)->xrpLiquid(sb); diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index c211bf6cea2..fa2d656a011 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -236,7 +236,7 @@ rangeCheckedCast(C c) c < std::numeric_limits::lowest())) { /* This should never happen */ - XRPL_UNREACHABLE("ripple::rangeCheckedCast : domain error"); + UNREACHABLE("ripple::rangeCheckedCast : domain error"); JLOG(debugLog().error()) << "rangeCheckedCast domain error:" << " value = " << c << " min = " << std::numeric_limits::lowest() diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 008ced4d39f..cd7bab3782a 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -58,7 +58,7 @@ to_string(TableType type) case TableType::AccountTransactions: return "AccountTransactions"; default: - XRPL_UNREACHABLE("ripple::detail::to_string : invalid TableType"); + UNREACHABLE("ripple::detail::to_string : invalid TableType"); return "Unknown"; } } @@ -202,8 +202,7 @@ saveValidatedLedger( if (!ledger->info().accountHash.isNonZero()) { JLOG(j.fatal()) << "AH is zero: " << getJson({*ledger, {}}); - XRPL_UNREACHABLE( - "ripple::detail::saveValidatedLedger : zero account hash"); + UNREACHABLE("ripple::detail::saveValidatedLedger : zero account hash"); } if (ledger->info().accountHash != ledger->stateMap().getHash().as_uint256()) @@ -212,13 +211,13 @@ saveValidatedLedger( << " != " << ledger->stateMap().getHash(); JLOG(j.fatal()) << "saveAcceptedLedger: seq=" << seq << ", current=" << current; - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::detail::saveValidatedLedger : mismatched account hash"); } - XRPL_ASSERT( - "ripple::detail::saveValidatedLedger : transaction hash match", - ledger->info().txHash == ledger->txMap().getHash().as_uint256()); + ASSERT( + ledger->info().txHash == ledger->txMap().getHash().as_uint256(), + "ripple::detail::saveValidatedLedger : transaction hash match"); // Save the ledger header in the hashed object store { diff --git a/src/xrpld/app/rdb/detail/Vacuum.cpp b/src/xrpld/app/rdb/detail/Vacuum.cpp index 8356962dc96..10bd95177ed 100644 --- a/src/xrpld/app/rdb/detail/Vacuum.cpp +++ b/src/xrpld/app/rdb/detail/Vacuum.cpp @@ -28,9 +28,9 @@ doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j) boost::filesystem::path dbPath = setup.dataDir / TxDBName; uintmax_t const dbSize = file_size(dbPath); - XRPL_ASSERT( - "ripple:doVacuumDB : file_size succeeded", - dbSize != static_cast(-1)); + ASSERT( + dbSize != static_cast(-1), + "ripple:doVacuumDB : file_size succeeded"); if (auto available = space(dbPath.parent_path()).available; available < dbSize) @@ -56,8 +56,9 @@ doVacuumDB(DatabaseCon::Setup const& setup, beast::Journal j) std::cout << "VACUUM beginning. page_size: " << pageSize << std::endl; session << "VACUUM;"; - XRPL_ASSERT( - "ripple:doVacuumDB : non-null global pragma", setup.globalPragma); + ASSERT( + setup.globalPragma != nullptr, + "ripple:doVacuumDB : non-null global pragma"); for (auto const& p : *setup.globalPragma) session << p; session << "PRAGMA page_size;", soci::into(pageSize); diff --git a/src/xrpld/app/tx/detail/AMMBid.cpp b/src/xrpld/app/tx/detail/AMMBid.cpp index 87bad0a0686..29ac826a5de 100644 --- a/src/xrpld/app/tx/detail/AMMBid.cpp +++ b/src/xrpld/app/tx/detail/AMMBid.cpp @@ -181,9 +181,9 @@ applyBid( } else { - XRPL_ASSERT( - "ripple::applyBid : has auction slot", - ammSle->isFieldPresent(sfAuctionSlot)); + ASSERT( + ammSle->isFieldPresent(sfAuctionSlot), + "ripple::applyBid : has auction slot"); if (!ammSle->isFieldPresent(sfAuctionSlot)) return {tecINTERNAL, false}; } @@ -306,7 +306,7 @@ applyBid( { // Price the slot was purchased at. STAmount const pricePurchased = auctionSlot[sfPrice]; - XRPL_ASSERT("ripple::applyBid : timeSlot is set", timeSlot); + ASSERT(timeSlot.has_value(), "ripple::applyBid : timeSlot is set"); auto const fractionUsed = (Number(*timeSlot) + 1) / AUCTION_SLOT_TIME_INTERVALS; auto const fractionRemaining = Number(1) - fractionUsed; diff --git a/src/xrpld/app/tx/detail/AMMDeposit.cpp b/src/xrpld/app/tx/detail/AMMDeposit.cpp index be518c03ca4..83c6b046c09 100644 --- a/src/xrpld/app/tx/detail/AMMDeposit.cpp +++ b/src/xrpld/app/tx/detail/AMMDeposit.cpp @@ -435,9 +435,9 @@ AMMDeposit::applyGuts(Sandbox& sb) if (result == tesSUCCESS) { - XRPL_ASSERT( - "ripple::AMMDeposit::applyGuts : valid new LP token balance", - newLPTokenBalance > beast::zero); + ASSERT( + newLPTokenBalance > beast::zero, + "ripple::AMMDeposit::applyGuts : valid new LP token balance"); ammSle->setFieldAmount(sfLPTokenBalance, newLPTokenBalance); // LP depositing into AMM empty state gets the auction slot // and the voting diff --git a/src/xrpld/app/tx/detail/AMMVote.cpp b/src/xrpld/app/tx/detail/AMMVote.cpp index a7e3faff4b2..1269bf4c383 100644 --- a/src/xrpld/app/tx/detail/AMMVote.cpp +++ b/src/xrpld/app/tx/detail/AMMVote.cpp @@ -200,10 +200,10 @@ applyVote( } } - XRPL_ASSERT( - "ripple::applyVote : has auction slot", + ASSERT( !ctx_.view().rules().enabled(fixInnerObjTemplate) || - ammSle->isFieldPresent(sfAuctionSlot)); + ammSle->isFieldPresent(sfAuctionSlot), + "ripple::applyVote : has auction slot"); // Update the vote entries and the trading/discounted fee. ammSle->setFieldArray(sfVoteSlots, updatedVoteSlots); diff --git a/src/xrpld/app/tx/detail/AMMWithdraw.cpp b/src/xrpld/app/tx/detail/AMMWithdraw.cpp index e9aaf3b83e7..f4460aa1f1e 100644 --- a/src/xrpld/app/tx/detail/AMMWithdraw.cpp +++ b/src/xrpld/app/tx/detail/AMMWithdraw.cpp @@ -711,9 +711,9 @@ AMMWithdraw::equalWithdrawLimit( tfee); frac = Number{amount2} / amount2Balance; auto const amountWithdraw = amountBalance * frac; - XRPL_ASSERT( - "ripple::AMMWithdraw::equalWithdrawLimit : maximum amountWithdraw", - amountWithdraw <= amount); + ASSERT( + amountWithdraw <= amount, + "ripple::AMMWithdraw::equalWithdrawLimit : maximum amountWithdraw"); return withdraw( view, ammAccount, diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index d4632adb115..925da7aaf48 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -146,9 +146,9 @@ ApplyContext::checkInvariantsHelper( TER ApplyContext::checkInvariants(TER const result, XRPAmount const fee) { - XRPL_ASSERT( - "ripple::ApplyContext::checkInvariants : is tesSUCCESS or tecCLAIM", - isTesSuccess(result) || isTecClaim(result)); + ASSERT( + isTesSuccess(result) || isTecClaim(result), + "ripple::ApplyContext::checkInvariants : is tesSUCCESS or tecCLAIM"); return checkInvariantsHelper( result, diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index d5dc70bf773..d2772d6966e 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -149,8 +149,7 @@ Change::doApply() case ttUNL_MODIFY: return applyUNLModify(); default: - XRPL_UNREACHABLE( - "ripple::Change::doApply : invalid transaction type"); + UNREACHABLE("ripple::Change::doApply : invalid transaction type"); return tefFAILURE; } } @@ -158,8 +157,8 @@ Change::doApply() void Change::preCompute() { - XRPL_ASSERT( - "ripple::Change::preCompute : zero account", account_ == beast::zero); + ASSERT( + account_ == beast::zero, "ripple::Change::preCompute : zero account"); } void diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index 1ec34ee9c70..578600621f2 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -210,9 +210,9 @@ CreateOffer::checkAcceptAsset( Issue const& issue) { // Only valid for custom currencies - XRPL_ASSERT( - "ripple::CreateOffer::checkAcceptAsset : input is not XRP", - !isXRP(issue.currency)); + ASSERT( + !isXRP(issue.currency), + "ripple::CreateOffer::checkAcceptAsset : input is not XRP"); auto const issuerAccount = view.read(keylet::account(issue.account)); @@ -285,9 +285,9 @@ CreateOffer::select_path( OfferStream const& leg2) { // If we don't have any viable path, why are we here?! - XRPL_ASSERT( - "ripple::CreateOffer::select_path : valid inputs", - have_direct || have_bridge); + ASSERT( + have_direct || have_bridge, + "ripple::CreateOffer::select_path : valid inputs"); // If there's no bridged path, the direct is the best by default. if (!have_bridge) @@ -331,9 +331,9 @@ CreateOffer::bridged_cross( { auto const& takerAmount = taker.original_offer(); - XRPL_ASSERT( - "ripple::CreateOffer::bridged_cross : neither is XRP", - !isXRP(takerAmount.in) && !isXRP(takerAmount.out)); + ASSERT( + !isXRP(takerAmount.in) && !isXRP(takerAmount.out), + "ripple::CreateOffer::bridged_cross : neither is XRP"); if (isXRP(takerAmount.in) || isXRP(takerAmount.out)) Throw("Bridging with XRP and an endpoint."); @@ -503,9 +503,9 @@ CreateOffer::bridged_cross( // Postcondition: If we aren't done, then we *must* have consumed at // least one offer fully. - XRPL_ASSERT( - "ripple::CreateOffer::bridged_cross : consumed an offer", - direct_consumed || leg1_consumed || leg2_consumed); + ASSERT( + direct_consumed || leg1_consumed || leg2_consumed, + "ripple::CreateOffer::bridged_cross : consumed an offer"); if (!direct_consumed && !leg1_consumed && !leg2_consumed) Throw( @@ -595,9 +595,9 @@ CreateOffer::direct_cross( // Postcondition: If we aren't done, then we *must* have consumed the // offer on the books fully! - XRPL_ASSERT( - "ripple::CreateOffer::direct_cross : consumed an offer", - direct_consumed); + ASSERT( + direct_consumed, + "ripple::CreateOffer::direct_cross : consumed an offer"); if (!direct_consumed) Throw( @@ -859,9 +859,9 @@ CreateOffer::flowCross( // remaining output. This too preserves the offer // Quality. afterCross.out -= result.actualAmountOut; - XRPL_ASSERT( - "ripple::CreateOffer::flowCross : minimum offer", - afterCross.out >= beast::zero); + ASSERT( + afterCross.out >= beast::zero, + "ripple::CreateOffer::flowCross : minimum offer"); if (afterCross.out < beast::zero) afterCross.out.clear(); afterCross.in = mulRound( @@ -1058,9 +1058,10 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // We expect the implementation of cross to succeed // or give a tec. - XRPL_ASSERT( - "ripple::CreateOffer::applyGuts : result is tesSUCCESS or tecCLAIM", - result == tesSUCCESS || isTecClaim(result)); + ASSERT( + result == tesSUCCESS || isTecClaim(result), + "ripple::CreateOffer::applyGuts : result is tesSUCCESS or " + "tecCLAIM"); if (auto stream = j_.trace()) { @@ -1078,12 +1079,12 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) return {result, true}; } - XRPL_ASSERT( - "ripple::CreateOffer::applyGuts : taker gets issue match", - saTakerGets.issue() == place_offer.in.issue()); - XRPL_ASSERT( - "ripple::CreateOffer::applyGuts : taker pays issue match", - saTakerPays.issue() == place_offer.out.issue()); + ASSERT( + saTakerGets.issue() == place_offer.in.issue(), + "ripple::CreateOffer::applyGuts : taker gets issue match"); + ASSERT( + saTakerPays.issue() == place_offer.out.issue(), + "ripple::CreateOffer::applyGuts : taker pays issue match"); if (takerAmount != place_offer) crossed = true; @@ -1111,9 +1112,9 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) saTakerGets = place_offer.in; } - XRPL_ASSERT( - "ripple::CreateOffer::applyGuts : taker pays and gets positive", - saTakerPays > zero && saTakerGets > zero); + ASSERT( + saTakerPays > zero && saTakerGets > zero, + "ripple::CreateOffer::applyGuts : taker pays and gets positive"); if (result != tesSUCCESS) { diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/xrpld/app/tx/detail/DeleteAccount.cpp index 1a97726be08..6525cb015fb 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/xrpld/app/tx/detail/DeleteAccount.cpp @@ -212,8 +212,9 @@ DeleteAccount::preclaim(PreclaimContext const& ctx) } auto sleAccount = ctx.view.read(keylet::account(account)); - XRPL_ASSERT( - "ripple::DeleteAccount::preclaim : non-null account", sleAccount); + ASSERT( + sleAccount != nullptr, + "ripple::DeleteAccount::preclaim : non-null account"); if (!sleAccount) return terNO_ACCOUNT; @@ -316,12 +317,14 @@ TER DeleteAccount::doApply() { auto src = view().peek(keylet::account(account_)); - XRPL_ASSERT( - "ripple::DeleteAccount::doApply : non-null source account", src); + ASSERT( + src != nullptr, + "ripple::DeleteAccount::doApply : non-null source account"); auto dst = view().peek(keylet::account(ctx_.tx[sfDestination])); - XRPL_ASSERT( - "ripple::DeleteAccount::doApply : non-null destination account", dst); + ASSERT( + dst != nullptr, + "ripple::DeleteAccount::doApply : non-null destination account"); if (!src || !dst) return tefBAD_LEDGER; @@ -341,7 +344,7 @@ DeleteAccount::doApply() return {result, SkipEntry::No}; } - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::DeleteAccount::doApply : undeletable item not found " "in preclaim"); JLOG(j_.error()) << "DeleteAccount undeletable item not " @@ -357,9 +360,9 @@ DeleteAccount::doApply() (*src)[sfBalance] = (*src)[sfBalance] - mSourceBalance; ctx_.deliver(mSourceBalance); - XRPL_ASSERT( - "ripple::DeleteAccount::doApply : source balance is zero", - (*src)[sfBalance] == XRPAmount(0)); + ASSERT( + (*src)[sfBalance] == XRPAmount(0), + "ripple::DeleteAccount::doApply : source balance is zero"); // If there's still an owner directory associated with the source account // delete it. diff --git a/src/xrpld/app/tx/detail/InvariantCheck.cpp b/src/xrpld/app/tx/detail/InvariantCheck.cpp index ecebed1c783..e7c631f166e 100644 --- a/src/xrpld/app/tx/detail/InvariantCheck.cpp +++ b/src/xrpld/app/tx/detail/InvariantCheck.cpp @@ -380,7 +380,8 @@ AccountRootsDeletedClean::finalize( // transaction processing results, however unlikely, only fail if the // feature is enabled. Enabled, or not, though, a fatal-level message will // be logged - bool const enforce = view.rules().enabled(featureInvariantsV1_1); + [[maybe_unused]] bool const enforce = + view.rules().enabled(featureInvariantsV1_1); auto const objectExists = [&view, enforce, &j](auto const& keylet) { if (auto const sle = view.read(keylet)) @@ -398,11 +399,10 @@ AccountRootsDeletedClean::finalize( JLOG(j.fatal()) << "Invariant failed: account deletion left behind a " << typeName << " object"; - (void)enforce; - XRPL_ASSERT( + ASSERT( + enforce, "ripple::AccountRootsDeletedClean::finalize::objectExists : " - "account deletion left no objects behind", - enforce); + "account deletion left no objects behind"); return true; } return false; diff --git a/src/xrpld/app/tx/detail/NFTokenMint.cpp b/src/xrpld/app/tx/detail/NFTokenMint.cpp index 15e6522b977..b903563dff7 100644 --- a/src/xrpld/app/tx/detail/NFTokenMint.cpp +++ b/src/xrpld/app/tx/detail/NFTokenMint.cpp @@ -160,9 +160,9 @@ NFTokenMint::createNFTokenID( std::memcpy(ptr, &tokenSeq, sizeof(tokenSeq)); ptr += sizeof(tokenSeq); - XRPL_ASSERT( - "ripple::NFTokenMint::createNFTokenID : data size matches the buffer", - std::distance(buf.data(), ptr) == buf.size()); + ASSERT( + std::distance(buf.data(), ptr) == buf.size(), + "ripple::NFTokenMint::createNFTokenID : data size matches the buffer"); return uint256::fromVoid(buf.data()); } diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.cpp b/src/xrpld/app/tx/detail/NFTokenUtils.cpp index ddd14efcf79..38378b7ff9e 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.cpp +++ b/src/xrpld/app/tx/detail/NFTokenUtils.cpp @@ -191,9 +191,9 @@ getPageForToken( : carr[0].getFieldH256(sfNFTokenID); auto np = std::make_shared(keylet::nftpage(base, tokenIDForNewPage)); - XRPL_ASSERT( - "ripple::nft::getPageForToken : valid NFT page index", - np->key() > base.key); + ASSERT( + np->key() > base.key, + "ripple::nft::getPageForToken : valid NFT page index"); np->setFieldArray(sfNFTokens, narr); np->setFieldH256(sfNextPageMin, cp->key()); @@ -245,9 +245,9 @@ compareTokens(uint256 const& a, uint256 const& b) TER insertToken(ApplyView& view, AccountID owner, STObject&& nft) { - XRPL_ASSERT( - "ripple::nft::insertToken : has NFT token", - nft.isFieldPresent(sfNFTokenID)); + ASSERT( + nft.isFieldPresent(sfNFTokenID), + "ripple::nft::insertToken : has NFT token"); // First, we need to locate the page the NFT belongs to, creating it // if necessary. This operation may fail if it is impossible to insert @@ -787,9 +787,9 @@ repairNFTokenDirectoryLinks(ApplyView& view, AccountID const& owner) return didRepair; } - XRPL_ASSERT( - "ripple::nft::repairNFTokenDirectoryLinks : next page is available", - nextPage); + ASSERT( + nextPage != nullptr, + "ripple::nft::repairNFTokenDirectoryLinks : next page is available"); if (nextPage->isFieldPresent(sfNextPageMin)) { didRepair = true; @@ -897,8 +897,9 @@ tokenOfferCreatePreclaim( if (nftIssuer != acctID && !(nftFlags & nft::flagTransferable)) { auto const root = view.read(keylet::account(nftIssuer)); - XRPL_ASSERT( - "ripple::nft::tokenOfferCreatePreclaim : non-null account", root); + ASSERT( + root != nullptr, + "ripple::nft::tokenOfferCreatePreclaim : non-null account"); if (auto minter = (*root)[~sfNFTokenMinter]; minter != acctID) return tefNFTOKEN_IS_NOT_TRANSFERABLE; diff --git a/src/xrpld/app/tx/detail/Offer.h b/src/xrpld/app/tx/detail/Offer.h index 9c6d69fd948..23129952c3d 100644 --- a/src/xrpld/app/tx/detail/Offer.h +++ b/src/xrpld/app/tx/detail/Offer.h @@ -209,7 +209,7 @@ void TOffer::setFieldAmounts() { #ifdef _MSC_VER - XRPL_UNREACHABLE("ripple::TOffer::setFieldAmounts : must be specialized"); + UNREACHABLE("ripple::TOffer::setFieldAmounts : must be specialized"); #else static_assert(sizeof(TOut) == -1, "Must be specialized"); #endif diff --git a/src/xrpld/app/tx/detail/OfferStream.cpp b/src/xrpld/app/tx/detail/OfferStream.cpp index ffaa0b2706d..f987be501bb 100644 --- a/src/xrpld/app/tx/detail/OfferStream.cpp +++ b/src/xrpld/app/tx/detail/OfferStream.cpp @@ -51,8 +51,8 @@ TOfferStreamBase::TOfferStreamBase( , tip_(view, book_) , counter_(counter) { - XRPL_ASSERT( - "ripple::TOfferStreamBase::TOfferStreamBase : valid book", validBook_); + ASSERT( + validBook_, "ripple::TOfferStreamBase::TOfferStreamBase : valid book"); } // Handle the case where a directory item with no corresponding ledger entry @@ -340,7 +340,7 @@ TOfferStreamBase::step() std::is_same_v)) return shouldRmSmallIncreasedQOffer(); } - XRPL_UNREACHABLE( + UNREACHABLE( "rippls::TOfferStreamBase::step::rmSmallIncreasedQOffer : XRP " "vs XRP offer"); // xrp/xrp offer!?! should never happen return false; diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/xrpld/app/tx/detail/PayChan.cpp index 998da5030b3..e240b8e7891 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/xrpld/app/tx/detail/PayChan.cpp @@ -149,9 +149,9 @@ closeChannel( if (!sle) return tefINTERNAL; - XRPL_ASSERT( - "ripple::closeChannel : minimum channel amount", - (*slep)[sfAmount] >= (*slep)[sfBalance]); + ASSERT( + (*slep)[sfAmount] >= (*slep)[sfBalance], + "ripple::closeChannel : minimum channel amount"); (*sle)[sfBalance] = (*sle)[sfBalance] + (*slep)[sfAmount] - (*slep)[sfBalance]; adjustOwnerCount(view, sle, -1, j); @@ -534,9 +534,9 @@ PayChanClaim::doApply() (*slep)[sfBalance] = ctx_.tx[sfBalance]; XRPAmount const reqDelta = reqBalance - chanBalance; - XRPL_ASSERT( - "ripple::PayChanClaim::doApply : minimum balance delta", - reqDelta >= beast::zero); + ASSERT( + reqDelta >= beast::zero, + "ripple::PayChanClaim::doApply : minimum balance delta"); (*sled)[sfBalance] = (*sled)[sfBalance] + reqDelta; ctx_.view().update(sled); ctx_.view().update(slep); diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 3fb2737015e..37af660b204 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -421,8 +421,7 @@ Payment::doApply() return terResult; } - XRPL_ASSERT( - "ripple::Payment::doApply : amount is XRP", saDstAmount.native()); + ASSERT(saDstAmount.native(), "ripple::Payment::doApply : amount is XRP"); // Direct XRP payment. diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/xrpld/app/tx/detail/SetSignerList.cpp index ad0dd8836e4..9073b7efce8 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/xrpld/app/tx/detail/SetSignerList.cpp @@ -128,7 +128,7 @@ SetSignerList::doApply() default: break; } - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::SetSignerList::doApply : invalid operation"); // Should not be // possible to // get here. @@ -140,12 +140,12 @@ SetSignerList::preCompute() { // Get the quorum and operation info. auto result = determineOperation(ctx_.tx, view().flags(), j_); - XRPL_ASSERT( - "ripple::SetSignerList::preCompute : result is tesSUCCESS", - std::get<0>(result) == tesSUCCESS); - XRPL_ASSERT( - "ripple::SetSignerList::preCompute : result is known operation", - std::get<3>(result) != unknown); + ASSERT( + std::get<0>(result) == tesSUCCESS, + "ripple::SetSignerList::preCompute : result is tesSUCCESS"); + ASSERT( + std::get<3>(result) != unknown, + "ripple::SetSignerList::preCompute : result is known operation"); quorum_ = std::get<1>(result); signers_ = std::get<2>(result); @@ -178,12 +178,12 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) // The static_cast should always be safe since entryCount should always // be in the range from 1 to 8 (or 32 if ExpandedSignerList is enabled). // We've got a lot of room to grow. - XRPL_ASSERT( - "ripple::signerCountBasedOwnerCountDelta : minimum signers", - entryCount >= STTx::minMultiSigners); - XRPL_ASSERT( - "ripple::signerCountBasedOwnerCountDelta : maximum signers", - entryCount <= STTx::maxMultiSigners(&rules)); + ASSERT( + entryCount >= STTx::minMultiSigners, + "ripple::signerCountBasedOwnerCountDelta : minimum signers"); + ASSERT( + entryCount <= STTx::maxMultiSigners(&rules), + "ripple::signerCountBasedOwnerCountDelta : maximum signers"); return 2 + static_cast(entryCount); } @@ -271,10 +271,10 @@ SetSignerList::validateQuorumAndSignerEntries( } // Make sure there are no duplicate signers. - XRPL_ASSERT( + ASSERT( + std::is_sorted(signers.begin(), signers.end()), "ripple::SetSignerList::validateQuorumAndSignerEntries : sorted " - "signers", - std::is_sorted(signers.begin(), signers.end())); + "signers"); if (std::adjacent_find(signers.begin(), signers.end()) != signers.end()) { JLOG(j.trace()) << "Duplicate signers in signer list"; diff --git a/src/xrpld/app/tx/detail/Taker.cpp b/src/xrpld/app/tx/detail/Taker.cpp index 467e3a6c624..6e4b7f5cd57 100644 --- a/src/xrpld/app/tx/detail/Taker.cpp +++ b/src/xrpld/app/tx/detail/Taker.cpp @@ -54,36 +54,36 @@ BasicTaker::BasicTaker( , cross_type_(cross_type) , journal_(journal) { - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : positive remaining in", - remaining_.in > beast::zero); - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : positive remaining out", - remaining_.out > beast::zero); - - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : nonzero rate in", - m_rate_in.value != 0); - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : nonzero rate out", - m_rate_out.value != 0); + ASSERT( + remaining_.in > beast::zero, + "ripple::BasicTaker::BasicTaker : positive remaining in"); + ASSERT( + remaining_.out > beast::zero, + "ripple::BasicTaker::BasicTaker : positive remaining out"); + + ASSERT( + m_rate_in.value != 0, + "ripple::BasicTaker::BasicTaker : nonzero rate in"); + ASSERT( + m_rate_out.value != 0, + "ripple::BasicTaker::BasicTaker : nonzero rate out"); // If we are dealing with a particular flavor, make sure that it's the // flavor we expect: - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : valid cross to IOU", + ASSERT( cross_type != CrossType::XrpToIou || - (isXRP(issue_in()) && !isXRP(issue_out()))); + (isXRP(issue_in()) && !isXRP(issue_out())), + "ripple::BasicTaker::BasicTaker : valid cross to IOU"); - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : valid cross to XRP", + ASSERT( cross_type != CrossType::IouToXrp || - (!isXRP(issue_in()) && isXRP(issue_out()))); + (!isXRP(issue_in()) && isXRP(issue_out())), + "ripple::BasicTaker::BasicTaker : valid cross to XRP"); // And make sure we're not crossing XRP for XRP - XRPL_ASSERT( - "ripple::BasicTaker::BasicTaker : not crossing XRP for XRP", - !isXRP(issue_in()) || !isXRP(issue_out())); + ASSERT( + !isXRP(issue_in()) || !isXRP(issue_out()), + "ripple::BasicTaker::BasicTaker : not crossing XRP for XRP"); // If this is a passive order, we adjust the quality so as to prevent offers // at the same quality level from being consumed. @@ -162,9 +162,9 @@ BasicTaker::remaining_offer() const if (sell_) { - XRPL_ASSERT( - "ripple::BasicTaker::remaining_offer : positive remaining in", - remaining_.in > beast::zero); + ASSERT( + remaining_.in > beast::zero, + "ripple::BasicTaker::remaining_offer : positive remaining in"); // We scale the output based on the remaining input: return Amounts( @@ -172,9 +172,9 @@ BasicTaker::remaining_offer() const divRound(remaining_.in, quality_.rate(), issue_out_, true)); } - XRPL_ASSERT( - "ripple::BasicTaker::remaining_offer : positive remaining out", - remaining_.out > beast::zero); + ASSERT( + remaining_.out > beast::zero, + "ripple::BasicTaker::remaining_offer : positive remaining out"); // We scale the input based on the remaining output: return Amounts( @@ -440,9 +440,9 @@ BasicTaker::do_cross(Amounts offer, Quality quality, AccountID const& owner) remaining_.out -= result.order.out; remaining_.in -= result.order.in; - XRPL_ASSERT( - "ripple::BasicTaker::do_cross : minimum remaining in", - remaining_.in >= beast::zero); + ASSERT( + remaining_.in >= beast::zero, + "ripple::BasicTaker::do_cross : minimum remaining in"); return result; } @@ -457,17 +457,17 @@ BasicTaker::do_cross( Quality quality2, AccountID const& owner2) { - XRPL_ASSERT( - "ripple::BasicTaker::do_cross : offer1 in is not XRP", - !offer1.in.native()); - XRPL_ASSERT( - "ripple::BasicTaker::do_cross : offer1 out is XRP", - offer1.out.native()); - XRPL_ASSERT( - "ripple::BasicTaker::do_cross : offer2 in is XRP", offer2.in.native()); - XRPL_ASSERT( - "ripple::BasicTaker::do_cross : offer2 out is not XRP", - !offer2.out.native()); + ASSERT( + !offer1.in.native(), + "ripple::BasicTaker::do_cross : offer1 in is not XRP"); + ASSERT( + offer1.out.native(), + "ripple::BasicTaker::do_cross : offer1 out is XRP"); + ASSERT( + offer2.in.native(), "ripple::BasicTaker::do_cross : offer2 in is XRP"); + ASSERT( + !offer2.out.native(), + "ripple::BasicTaker::do_cross : offer2 out is not XRP"); // If the taker owns the first leg of the offer, then the taker's available // funds aren't the limiting factor for the input - the offer itself is. @@ -584,12 +584,12 @@ Taker::Taker( , direct_crossings_(0) , bridge_crossings_(0) { - XRPL_ASSERT( - "ripple::Taker::Taker : issue in is a match", - issue_in() == offer.in.issue()); - XRPL_ASSERT( - "ripple::Taker::Taker : issue out is a match", - issue_out() == offer.out.issue()); + ASSERT( + issue_in() == offer.in.issue(), + "ripple::Taker::Taker : issue in is a match"); + ASSERT( + issue_out() == offer.out.issue(), + "ripple::Taker::Taker : issue out is a match"); if (auto stream = journal_.debug()) { @@ -718,8 +718,8 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) if (cross_type() != CrossType::XrpToIou) { - XRPL_ASSERT( - "ripple::Taker::fill : order in is not XRP", !isXRP(flow.order.in)); + ASSERT( + !isXRP(flow.order.in), "ripple::Taker::fill : order in is not XRP"); if (result == tesSUCCESS) result = @@ -731,8 +731,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - XRPL_ASSERT( - "ripple::Taker::fill : order in is XRP", isXRP(flow.order.in)); + ASSERT(isXRP(flow.order.in), "ripple::Taker::fill : order in is XRP"); if (result == tesSUCCESS) result = transferXRP(account(), offer.owner(), flow.order.in); @@ -741,9 +740,9 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) // Now send funds from the account whose offer we're taking if (cross_type() != CrossType::IouToXrp) { - XRPL_ASSERT( - "ripple::Taker::fill : order out is not XRP", - !isXRP(flow.order.out)); + ASSERT( + !isXRP(flow.order.out), + "ripple::Taker::fill : order out is not XRP"); if (result == tesSUCCESS) result = redeemIOU( @@ -755,8 +754,7 @@ Taker::fill(BasicTaker::Flow const& flow, Offer& offer) } else { - XRPL_ASSERT( - "ripple::Taker::fill : order out is XRP", isXRP(flow.order.out)); + ASSERT(isXRP(flow.order.out), "ripple::Taker::fill : order out is XRP"); if (result == tesSUCCESS) result = transferXRP(offer.owner(), account(), flow.order.out); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 48b2e95c385..652d256224e 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -367,8 +367,9 @@ Transactor::checkPriorTxAndLastLedger(PreclaimContext const& ctx) TER Transactor::consumeSeqProxy(SLE::pointer const& sleAccount) { - XRPL_ASSERT( - "ripple::Transactor::consumeSeqProxy : non-null account", sleAccount); + ASSERT( + sleAccount != nullptr, + "ripple::Transactor::consumeSeqProxy : non-null account"); SeqProxy const seqProx = ctx_.tx.getSeqProxy(); if (seqProx.isSeq()) { @@ -440,9 +441,9 @@ Transactor::ticketDelete( void Transactor::preCompute() { - XRPL_ASSERT( - "ripple::Transactor::preCompute : nonzero account", - account_ != beast::zero); + ASSERT( + account_ != beast::zero, + "ripple::Transactor::preCompute : nonzero account"); } TER @@ -456,9 +457,9 @@ Transactor::apply() // sle must exist except for transactions // that allow zero account. - XRPL_ASSERT( - "ripple::Transactor::apply : non-null SLE or zero account", - sle != nullptr || account_ == beast::zero); + ASSERT( + sle != nullptr || account_ == beast::zero, + "ripple::Transactor::apply : non-null SLE or zero account"); if (sle) { @@ -583,12 +584,12 @@ Transactor::checkMultiSign(PreclaimContext const& ctx) // We have plans to support multiple SignerLists in the future. The // presence and defaulted value of the SignerListID field will enable that. - XRPL_ASSERT( - "ripple::Transactor::checkMultiSign : has signer list ID", - sleAccountSigners->isFieldPresent(sfSignerListID)); - XRPL_ASSERT( - "ripple::Transactor::checkMultiSign : signer list ID is 0", - sleAccountSigners->getFieldU32(sfSignerListID) == 0); + ASSERT( + sleAccountSigners->isFieldPresent(sfSignerListID), + "ripple::Transactor::checkMultiSign : has signer list ID"); + ASSERT( + sleAccountSigners->getFieldU32(sfSignerListID) == 0, + "ripple::Transactor::checkMultiSign : signer list ID is 0"); auto accountSigners = SignerEntries::deserialize(*sleAccountSigners, ctx.j, "ledger"); @@ -811,9 +812,9 @@ Transactor::reset(XRPAmount fee) auto const balance = txnAcct->getFieldAmount(sfBalance).xrp(); // balance should have already been checked in checkFee / preFlight. - XRPL_ASSERT( - "ripple::Transactor::reset : valid balance", - balance != beast::zero && (!view().open() || balance >= fee)); + ASSERT( + balance != beast::zero && (!view().open() || balance >= fee), + "ripple::Transactor::reset : valid balance"); // We retry/reject the transaction if the account balance is zero or we're // applying against an open ledger and the balance is less than the fee @@ -828,8 +829,8 @@ Transactor::reset(XRPAmount fee) // reject the transaction. txnAcct->setFieldAmount(sfBalance, balance - fee); TER const ter{consumeSeqProxy(txnAcct)}; - XRPL_ASSERT( - "ripple::Transactor::reset : result is tesSUCCESS", isTesSuccess(ter)); + ASSERT( + isTesSuccess(ter), "ripple::Transactor::reset : result is tesSUCCESS"); if (isTesSuccess(ter)) view().update(txnAcct); @@ -869,7 +870,7 @@ Transactor::operator()() JLOG(j_.fatal()) << "Transaction serdes mismatch"; JLOG(j_.info()) << to_string(ctx_.tx.getJson(JsonOptions::none)); JLOG(j_.fatal()) << s2.getJson(JsonOptions::none); - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::Transactor::operator() : transaction serdes mismatch"); } } @@ -887,9 +888,9 @@ Transactor::operator()() // No transaction can return temUNKNOWN from apply, // and it can't be passed in from a preclaim. - XRPL_ASSERT( - "ripple::Transactor::operator() : result is not temUNKNOWN", - result != temUNKNOWN); + ASSERT( + result != temUNKNOWN, + "ripple::Transactor::operator() : result is not temUNKNOWN"); if (auto stream = j_.trace()) stream << "preclaim result: " << transToken(result); @@ -941,10 +942,10 @@ Transactor::operator()() std::shared_ptr const& after) { if (isDelete) { - XRPL_ASSERT( + ASSERT( + before && after, "ripple::Transactor::operator()::visit : non-null SLE " - "inputs", - before && after); + "inputs"); if (doOffers && before && after && (before->getType() == ltOFFER) && (before->getFieldAmount(sfTakerPays) == diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/xrpld/app/tx/detail/XChainBridge.cpp index 61027201649..7485ff6c4b0 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/xrpld/app/tx/detail/XChainBridge.cpp @@ -223,7 +223,7 @@ claimHelper( auto i = signersList.find(a.keyAccount); if (i == signersList.end()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::claimHelper : invalid inputs"); // should have already // been checked continue; @@ -440,7 +440,9 @@ transferHelper( if (amt.native()) { auto const sleSrc = psb.peek(keylet::account(src)); - XRPL_ASSERT("ripple::transferHelper : non-null source account", sleSrc); + ASSERT( + sleSrc != nullptr, + "ripple::transferHelper : non-null source account"); if (!sleSrc) return tecINTERNAL; diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 2e120cce894..f4219746bed 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -231,7 +231,7 @@ invoke_preflight(PreflightContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preflight: " << e.txnType; - XRPL_UNREACHABLE("ripple::invoke_preflight : unknown transaction type"); + UNREACHABLE("ripple::invoke_preflight : unknown transaction type"); return {temUNKNOWN, TxConsequences{temUNKNOWN}}; } } @@ -280,7 +280,7 @@ invoke_preclaim(PreclaimContext const& ctx) // Should never happen JLOG(ctx.j.fatal()) << "Unknown transaction type in preclaim: " << e.txnType; - XRPL_UNREACHABLE("ripple::invoke_preclaim : unknown transaction type"); + UNREACHABLE("ripple::invoke_preclaim : unknown transaction type"); return temUNKNOWN; } } @@ -296,7 +296,7 @@ invoke_calculateBaseFee(ReadView const& view, STTx const& tx) } catch (UnknownTxnType const& e) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::invoke_calculateBaseFee : unknown transaction type"); return XRPAmount{0}; } @@ -309,9 +309,9 @@ TxConsequences::TxConsequences(NotTEC pfresult) , seqProx_(SeqProxy::sequence(0)) , sequencesConsumed_(0) { - XRPL_ASSERT( - "ripple::TxConsequences::TxConsequences : is not tesSUCCESS", - !isTesSuccess(pfresult)); + ASSERT( + !isTesSuccess(pfresult), + "ripple::TxConsequences::TxConsequences : is not tesSUCCESS"); } TxConsequences::TxConsequences(STTx const& tx) @@ -358,7 +358,7 @@ invoke_apply(ApplyContext& ctx) // Should never happen JLOG(ctx.journal.fatal()) << "Unknown transaction type in apply: " << e.txnType; - XRPL_UNREACHABLE("ripple::invoke_apply : unknown transaction type"); + UNREACHABLE("ripple::invoke_apply : unknown transaction type"); return {temUNKNOWN, false}; } } diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 696779cb57a..22aab7d6ed7 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -863,9 +863,9 @@ Consensus::gotTxSet( { // Our position is added to acquired_ as soon as we create it, // so this txSet must differ - XRPL_ASSERT( - "ripple::Consensus::gotTxSet : updated transaction set", - id != result_->position.position()); + ASSERT( + id != result_->position.position(), + "ripple::Consensus::gotTxSet : updated transaction set"); bool any = false; for (auto const& [nodeId, peerPos] : currPeerPositions_) { @@ -1010,9 +1010,9 @@ template void Consensus::handleWrongLedger(typename Ledger_t::ID const& lgrId) { - XRPL_ASSERT( - "ripple::Consensus::handleWrongLedger : have wrong ledger", - lgrId != prevLedgerID_ || previousLedger_.id() != lgrId); + ASSERT( + lgrId != prevLedgerID_ || previousLedger_.id() != lgrId, + "ripple::Consensus::handleWrongLedger : have wrong ledger"); // Stop proposing because we are out of sync leaveConsensus(); @@ -1265,7 +1265,9 @@ void Consensus::phaseEstablish() { // can only establish consensus if we already took a stance - XRPL_ASSERT("ripple::Consensus::phaseEstablish : result is set", result_); + ASSERT( + result_.has_value(), + "ripple::Consensus::phaseEstablish : result is set"); using namespace std::chrono; ConsensusParms const& parms = adaptor_.parms(); @@ -1313,7 +1315,7 @@ void Consensus::closeLedger() { // We should not be closing if we already have a position - XRPL_ASSERT("ripple::Consensus::closeLedger : result is not set", !result_); + ASSERT(!result_, "ripple::Consensus::closeLedger : result is not set"); phase_ = ConsensusPhase::establish; JLOG(j_.debug()) << "transitioned to ConsensusPhase::establish"; @@ -1366,8 +1368,9 @@ void Consensus::updateOurPositions() { // We must have a position if we are updating it - XRPL_ASSERT( - "ripple::Consensus::updateOurPositions : result is set", result_); + ASSERT( + result_.has_value(), + "ripple::Consensus::updateOurPositions : result is set"); ConsensusParms const& parms = adaptor_.parms(); // Compute a cutoff time @@ -1551,7 +1554,8 @@ bool Consensus::haveConsensus() { // Must have a stance if we are checking for consensus - XRPL_ASSERT("ripple::Consensus::haveConsensus : has result", result_); + ASSERT( + result_.has_value(), "ripple::Consensus::haveConsensus : has result"); // CHECKME: should possibly count unacquired TX sets as disagreeing int agree = 0, disagree = 0; @@ -1626,7 +1630,9 @@ void Consensus::createDisputes(TxSet_t const& o) { // Cannot create disputes without our stance - XRPL_ASSERT("ripple::Consensus::createDisputes : result is set", result_); + ASSERT( + result_.has_value(), + "ripple::Consensus::createDisputes : result is set"); // Only create disputes if this is a new set if (!result_->compares.emplace(o.id()).second) @@ -1647,10 +1653,10 @@ Consensus::createDisputes(TxSet_t const& o) { ++dc; // create disputed transactions (from the ledger that has them) - XRPL_ASSERT( - "ripple::Consensus::createDisputes : has disputed transactions", + ASSERT( (inThisSet && result_->txns.find(txId) && !o.find(txId)) || - (!inThisSet && !result_->txns.find(txId) && o.find(txId))); + (!inThisSet && !result_->txns.find(txId) && o.find(txId)), + "ripple::Consensus::createDisputes : has disputed transactions"); Tx_t tx = inThisSet ? result_->txns.find(txId) : o.find(txId); auto txID = tx.id(); @@ -1686,7 +1692,9 @@ void Consensus::updateDisputes(NodeID_t const& node, TxSet_t const& other) { // Cannot updateDisputes without our stance - XRPL_ASSERT("ripple::Consensus::updateDisputes : result is set", result_); + ASSERT( + result_.has_value(), + "ripple::Consensus::updateDisputes : result is set"); // Ensure we have created disputes against this set if we haven't seen // it before diff --git a/src/xrpld/consensus/ConsensusTypes.h b/src/xrpld/consensus/ConsensusTypes.h index 91510d5c8b3..15bc858848d 100644 --- a/src/xrpld/consensus/ConsensusTypes.h +++ b/src/xrpld/consensus/ConsensusTypes.h @@ -214,9 +214,9 @@ struct ConsensusResult ConsensusResult(TxSet_t&& s, Proposal_t&& p) : txns{std::move(s)}, position{std::move(p)} { - XRPL_ASSERT( - "ripple::ConsensusResult : valid inputs", - txns.id() == position.position()); + ASSERT( + txns.id() == position.position(), + "ripple::ConsensusResult : valid inputs"); } //! The set of transactions consensus agrees go in the ledger diff --git a/src/xrpld/consensus/LedgerTiming.h b/src/xrpld/consensus/LedgerTiming.h index 5aae68ebb88..57247abe968 100644 --- a/src/xrpld/consensus/LedgerTiming.h +++ b/src/xrpld/consensus/LedgerTiming.h @@ -82,9 +82,9 @@ getNextLedgerTimeResolution( bool previousAgree, Seq ledgerSeq) { - XRPL_ASSERT( - "ripple:getNextLedgerTimeResolution : valid ledger sequence", - ledgerSeq != Seq{0}); + ASSERT( + ledgerSeq != Seq{0}, + "ripple:getNextLedgerTimeResolution : valid ledger sequence"); using namespace std::chrono; // Find the current resolution: @@ -92,9 +92,9 @@ getNextLedgerTimeResolution( std::begin(ledgerPossibleTimeResolutions), std::end(ledgerPossibleTimeResolutions), previousResolution); - XRPL_ASSERT( - "ripple:getNextLedgerTimeResolution : found time resolution", - iter != std::end(ledgerPossibleTimeResolutions)); + ASSERT( + iter != std::end(ledgerPossibleTimeResolutions), + "ripple:getNextLedgerTimeResolution : found time resolution"); // This should never happen, but just as a precaution if (iter == std::end(ledgerPossibleTimeResolutions)) diff --git a/src/xrpld/consensus/LedgerTrie.h b/src/xrpld/consensus/LedgerTrie.h index b81704b1820..ad1797d51fe 100644 --- a/src/xrpld/consensus/LedgerTrie.h +++ b/src/xrpld/consensus/LedgerTrie.h @@ -64,7 +64,7 @@ class SpanTip ID ancestor(Seq const& s) const { - XRPL_ASSERT("ripple::SpanTip::ancestor : valid input", s <= seq); + ASSERT(s <= seq, "ripple::SpanTip::ancestor : valid input"); return ledger[s]; } @@ -90,8 +90,8 @@ class Span Span() : ledger_{typename Ledger::MakeGenesis{}} { // Require default ledger to be genesis seq - XRPL_ASSERT( - "ripple::Span::Span : ledger is genesis", ledger_.seq() == start_); + ASSERT( + ledger_.seq() == start_, "ripple::Span::Span : ledger is genesis"); } Span(Ledger ledger) @@ -160,7 +160,7 @@ class Span : start_{start}, end_{end}, ledger_{l} { // Spans cannot be empty - XRPL_ASSERT("ripple::Span::Span : non-empty span input", start < end); + ASSERT(start < end, "ripple::Span::Span : non-empty span input"); } Seq @@ -233,7 +233,7 @@ struct Node [child](std::unique_ptr const& curr) { return curr.get() == child; }); - XRPL_ASSERT("ripple::Node::erase : valid input", it != children.end()); + ASSERT(it != children.end(), "ripple::Node::erase : valid input"); std::swap(*it, children.back()); children.pop_back(); } @@ -374,7 +374,7 @@ class LedgerTrie Node* curr = root.get(); // Root is always defined and is in common with all ledgers - XRPL_ASSERT("ripple::LedgerTrie::find : non-null root", curr); + ASSERT(curr != nullptr, "ripple::LedgerTrie::find : non-null root"); Seq pos = curr->span.diff(ledger); bool done = false; @@ -455,7 +455,8 @@ class LedgerTrie auto const [loc, diffSeq] = find(ledger); // There is always a place to insert - XRPL_ASSERT("ripple::LedgerTrie::insert : valid input ledger", loc); + ASSERT( + loc != nullptr, "ripple::LedgerTrie::insert : valid input ledger"); // Node from which to start incrementing branchSupport Node* incNode = loc; @@ -490,14 +491,16 @@ class LedgerTrie newNode->tipSupport = loc->tipSupport; newNode->branchSupport = loc->branchSupport; newNode->children = std::move(loc->children); - XRPL_ASSERT( - "ripple::LedgerTrie::insert : moved-from children", - loc->children.empty()); + ASSERT( + loc->children.empty(), + "ripple::LedgerTrie::insert : moved-from children"); for (std::unique_ptr& child : newNode->children) child->parent = newNode.get(); // Loc truncates to prefix and newNode is its child - XRPL_ASSERT("ripple::LedgerTrie::insert : prefix is set", prefix); + ASSERT( + prefix.has_value(), + "ripple::LedgerTrie::insert : prefix is set"); loc->span = *prefix; newNode->parent = loc; loc->children.emplace_back(std::move(newNode)); @@ -550,9 +553,9 @@ class LedgerTrie loc->tipSupport -= count; auto const it = seqSupport.find(ledger.seq()); - XRPL_ASSERT( - "ripple::LedgerTrie::remove : valid input ledger", - it != seqSupport.end() && it->second >= count); + ASSERT( + it != seqSupport.end() && it->second >= count, + "ripple::LedgerTrie::remove : valid input ledger"); it->second -= count; if (it->second == 0) seqSupport.erase(it->first); diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index bd79ad0fc5d..fec60a738bb 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -434,9 +434,9 @@ class Validations Validation const& val, std::optional> prior) { - XRPL_ASSERT( - "ripple::Validations::updateTrie : trusted input validation", - val.trusted()); + ASSERT( + val.trusted(), + "ripple::Validations::updateTrie : trusted input validation"); // Clear any prior acquiring ledger for this node if (prior) @@ -716,8 +716,7 @@ class Validations setSeqToKeep(Seq const& low, Seq const& high) { std::lock_guard lock{mutex_}; - XRPL_ASSERT( - "ripple::Validations::setSeqToKeep : valid inputs", low < high); + ASSERT(low < high, "ripple::Validations::setSeqToKeep : valid inputs"); toKeep_ = {low, high}; } diff --git a/src/xrpld/core/Coro.ipp b/src/xrpld/core/Coro.ipp index b41985c4482..a046971015e 100644 --- a/src/xrpld/core/Coro.ipp +++ b/src/xrpld/core/Coro.ipp @@ -53,7 +53,7 @@ JobQueue::Coro::Coro( inline JobQueue::Coro::~Coro() { #ifndef NDEBUG - XRPL_ASSERT("ripple::JobQueue::Coro::~Coro : is finished", finished_); + ASSERT(finished_, "ripple::JobQueue::Coro::~Coro : is finished"); #endif } @@ -103,7 +103,9 @@ JobQueue::Coro::resume() auto saved = detail::getLocalValues().release(); detail::getLocalValues().reset(&lvs_); std::lock_guard lock(mutex_); - XRPL_ASSERT("ripple::JobQueue::Coro::resume : is runnable", coro_); + ASSERT( + static_cast(coro_), + "ripple::JobQueue::Coro::resume : is runnable"); coro_(); detail::getLocalValues().release(); detail::getLocalValues().reset(saved); diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index 86cc21701ba..8efc6b599c9 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -96,10 +96,10 @@ class DatabaseCon std::vector const* commonPragma() const { - XRPL_ASSERT( + ASSERT( + !useGlobalPragma || globalPragma, "ripple::DatabaseCon::Setup::commonPragma : consistent global " - "pragma", - !useGlobalPragma || globalPragma); + "pragma"); return useGlobalPragma && globalPragma ? globalPragma.get() : nullptr; } diff --git a/src/xrpld/core/JobTypes.h b/src/xrpld/core/JobTypes.h index 6f851426b1b..5963446cd43 100644 --- a/src/xrpld/core/JobTypes.h +++ b/src/xrpld/core/JobTypes.h @@ -53,21 +53,22 @@ class JobTypes int limit, std::chrono::milliseconds avgLatency, std::chrono::milliseconds peakLatency) { - XRPL_ASSERT( - "ripple::JobTypes::JobTypes::add : unique job type input", - m_map.find(jt) == m_map.end()); - - auto const [_, inserted] = m_map.emplace( - std::piecewise_construct, - std::forward_as_tuple(jt), - std::forward_as_tuple( - jt, name, limit, avgLatency, peakLatency)); - - XRPL_ASSERT( - "ripple::JobTypes::JobTypes::add : input is inserted", - inserted == true); - (void)_; - (void)inserted; + ASSERT( + m_map.find(jt) == m_map.end(), + "ripple::JobTypes::JobTypes::add : unique job type input"); + + [[maybe_unused]] auto const inserted = + m_map + .emplace( + std::piecewise_construct, + std::forward_as_tuple(jt), + std::forward_as_tuple( + jt, name, limit, avgLatency, peakLatency)) + .second; + + ASSERT( + inserted == true, + "ripple::JobTypes::JobTypes::add : input is inserted"); }; // clang-format off @@ -141,7 +142,7 @@ class JobTypes get(JobType jt) const { Map::const_iterator const iter(m_map.find(jt)); - XRPL_ASSERT("ripple::JobTypes::get : valid input", iter != m_map.end()); + ASSERT(iter != m_map.end(), "ripple::JobTypes::get : valid input"); if (iter != m_map.end()) return iter->second; diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index cf7dd0a3581..b37a931bca0 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -266,8 +266,7 @@ Config::Config() void Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) { - XRPL_ASSERT( - "ripple::Config::setupControl : node size not set", NODE_SIZE == 0); + ASSERT(NODE_SIZE == 0, "ripple::Config::setupControl : node size not set"); QUIET = bQuiet || bSilent; SILENT = bSilent; @@ -288,9 +287,9 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) return (limit == 0) || (ramSize_ < limit); }); - XRPL_ASSERT( - "ripple::Config::setupControl : valid node size", - ns != threshold.second.end()); + ASSERT( + ns != threshold.second.end(), + "ripple::Config::setupControl : valid node size"); if (ns != threshold.second.end()) NODE_SIZE = std::distance(threshold.second.begin(), ns); @@ -301,8 +300,7 @@ Config::setupControl(bool bQuiet, bool bSilent, bool bStandalone) NODE_SIZE = std::min(hc / 2, NODE_SIZE); } - XRPL_ASSERT( - "ripple::Config::setupControl : node size is set", NODE_SIZE <= 4); + ASSERT(NODE_SIZE <= 4, "ripple::Config::setupControl : node size is set"); } void @@ -1008,12 +1006,12 @@ int Config::getValueFor(SizedItem item, std::optional node) const { auto const index = static_cast>(item); - XRPL_ASSERT( - "ripple::Config::getValueFor : valid index input", - index < sizedItems.size()); - XRPL_ASSERT( - "ripple::Config::getValueFor : unset or valid node", - !node || *node <= 4); + ASSERT( + index < sizedItems.size(), + "ripple::Config::getValueFor : valid index input"); + ASSERT( + !node || *node <= 4, + "ripple::Config::getValueFor : unset or valid node"); return sizedItems.at(index).second.at(node.value_or(NODE_SIZE)); } diff --git a/src/xrpld/core/detail/DatabaseCon.cpp b/src/xrpld/core/detail/DatabaseCon.cpp index 2cee2a3bbea..d93a66cfb83 100644 --- a/src/xrpld/core/detail/DatabaseCon.cpp +++ b/src/xrpld/core/detail/DatabaseCon.cpp @@ -231,9 +231,9 @@ setup_DatabaseCon(Config const& c, std::optional j) "nodes storing large amounts of history, because of the " "difficulty inherent in rebuilding corrupted data."; } - XRPL_ASSERT( - "ripple::setup_DatabaseCon::globalPragma : result size is 3", - result->size() == 3); + ASSERT( + result->size() == 3, + "ripple::setup_DatabaseCon::globalPragma : result size is 3"); return result; }(); } diff --git a/src/xrpld/core/detail/JobQueue.cpp b/src/xrpld/core/detail/JobQueue.cpp index 232e9d424fd..3e87dd22212 100644 --- a/src/xrpld/core/detail/JobQueue.cpp +++ b/src/xrpld/core/detail/JobQueue.cpp @@ -55,9 +55,9 @@ JobQueue::JobQueue( std::piecewise_construct, std::forward_as_tuple(jt.type()), std::forward_as_tuple(jt, m_collector, logs))); - XRPL_ASSERT( - "ripple::JobQueue::JobQueue : jobs added", - result.second == true); + ASSERT( + result.second == true, + "ripple::JobQueue::JobQueue : jobs added"); (void)result.second; } } @@ -82,14 +82,14 @@ JobQueue::addRefCountedJob( std::string const& name, JobFunction const& func) { - XRPL_ASSERT( - "ripple::JobQueue::addRefCountedJob : valid input job type", - type != jtINVALID); + ASSERT( + type != jtINVALID, + "ripple::JobQueue::addRefCountedJob : valid input job type"); auto iter(m_jobData.find(type)); - XRPL_ASSERT( - "ripple::JobQueue::addRefCountedJob : job type found in jobs", - iter != m_jobData.end()); + ASSERT( + iter != m_jobData.end(), + "ripple::JobQueue::addRefCountedJob : job type found in jobs"); if (iter == m_jobData.end()) return false; @@ -99,11 +99,11 @@ JobQueue::addRefCountedJob( // FIXME: Workaround incorrect client shutdown ordering // do not add jobs to a queue with no threads - XRPL_ASSERT( - "ripple::JobQueue::addRefCountedJob : threads available or job " - "requires no threads", + ASSERT( (type >= jtCLIENT && type <= jtCLIENT_WEBSOCKET) || - m_workers.getNumberOfThreads() > 0); + m_workers.getNumberOfThreads() > 0, + "ripple::JobQueue::addRefCountedJob : threads available or job " + "requires no threads"); { std::lock_guard lock(m_mutex); @@ -112,12 +112,12 @@ JobQueue::addRefCountedJob( auto const& job = *result.first; JobType const type(job.getType()); - XRPL_ASSERT( - "ripple::JobQueue::addRefCountedJob : has valid job type", - type != jtINVALID); - XRPL_ASSERT( - "ripple::JobQueue::addRefCountedJob : job found", - m_jobSet.find(job) != m_jobSet.end()); + ASSERT( + type != jtINVALID, + "ripple::JobQueue::addRefCountedJob : has valid job type"); + ASSERT( + m_jobSet.find(job) != m_jobSet.end(), + "ripple::JobQueue::addRefCountedJob : job found"); perfLog_.jobQueue(type); JobTypeData& data(getJobTypeData(type)); @@ -177,9 +177,9 @@ std::unique_ptr JobQueue::makeLoadEvent(JobType t, std::string const& name) { JobDataMap::iterator iter(m_jobData.find(t)); - XRPL_ASSERT( - "ripple::JobQueue::makeLoadEvent : valid job type input", - iter != m_jobData.end()); + ASSERT( + iter != m_jobData.end(), + "ripple::JobQueue::makeLoadEvent : valid job type input"); if (iter == m_jobData.end()) return {}; @@ -194,9 +194,9 @@ JobQueue::addLoadEvents(JobType t, int count, std::chrono::milliseconds elapsed) LogicError("JobQueue::addLoadEvents() called after JobQueue stopped"); JobDataMap::iterator iter(m_jobData.find(t)); - XRPL_ASSERT( - "ripple::JobQueue::addLoadEvents : valid job type input", - iter != m_jobData.end()); + ASSERT( + iter != m_jobData.end(), + "ripple::JobQueue::addLoadEvents : valid job type input"); iter->second.load().addSamples(count, elapsed); } @@ -222,8 +222,8 @@ JobQueue::getJson(int c) for (auto& x : m_jobData) { - XRPL_ASSERT( - "ripple::JobQueue::getJson : valid job type", x.first != jtINVALID); + ASSERT( + x.first != jtINVALID, "ripple::JobQueue::getJson : valid job type"); if (x.first == jtGENERIC) continue; @@ -278,9 +278,9 @@ JobTypeData& JobQueue::getJobTypeData(JobType type) { JobDataMap::iterator c(m_jobData.find(type)); - XRPL_ASSERT( - "ripple::JobQueue::getJobTypeData : valid job type input", - c != m_jobData.end()); + ASSERT( + c != m_jobData.end(), + "ripple::JobQueue::getJobTypeData : valid job type input"); // NIKB: This is ugly and I hate it. We must remove jtINVALID completely // and use something sane. @@ -305,13 +305,11 @@ JobQueue::stop() std::unique_lock lock(m_mutex); cv_.wait( lock, [this] { return m_processCount == 0 && m_jobSet.empty(); }); - XRPL_ASSERT( - "ripple::JobQueue::stop : all processes completed", - m_processCount == 0); - XRPL_ASSERT( - "ripple::JobQueue::stop : all jobs completed", m_jobSet.empty()); - XRPL_ASSERT( - "ripple::JobQueue::stop : no coros suspended", nSuspend_ == 0); + ASSERT( + m_processCount == 0, + "ripple::JobQueue::stop : all processes completed"); + ASSERT(m_jobSet.empty(), "ripple::JobQueue::stop : all jobs completed"); + ASSERT(nSuspend_ == 0, "ripple::JobQueue::stop : no coros suspended"); stopped_ = true; } } @@ -325,36 +323,35 @@ JobQueue::isStopped() const void JobQueue::getNextJob(Job& job) { - XRPL_ASSERT( - "ripple::JobQueue::getNextJob : non-empty jobs", !m_jobSet.empty()); + ASSERT(!m_jobSet.empty(), "ripple::JobQueue::getNextJob : non-empty jobs"); std::set::const_iterator iter; for (iter = m_jobSet.begin(); iter != m_jobSet.end(); ++iter) { JobType const type = iter->getType(); - XRPL_ASSERT( - "ripple::JobQueue::getNextJob : valid job type", type != jtINVALID); + ASSERT( + type != jtINVALID, "ripple::JobQueue::getNextJob : valid job type"); JobTypeData& data(getJobTypeData(type)); - XRPL_ASSERT( - "ripple::JobQueue::getNextJob : maximum jobs running", - data.running <= getJobLimit(type)); + ASSERT( + data.running <= getJobLimit(type), + "ripple::JobQueue::getNextJob : maximum jobs running"); // Run this job if we're running below the limit. if (data.running < getJobLimit(data.type())) { - XRPL_ASSERT( - "ripple::JobQueue::getNextJob : positive data waiting", - data.waiting > 0); + ASSERT( + data.waiting > 0, + "ripple::JobQueue::getNextJob : positive data waiting"); --data.waiting; ++data.running; break; } } - XRPL_ASSERT( - "ripple::JobQueue::getNextJob : found next job", - iter != m_jobSet.end()); + ASSERT( + iter != m_jobSet.end(), + "ripple::JobQueue::getNextJob : found next job"); job = *iter; m_jobSet.erase(iter); } @@ -362,18 +359,18 @@ JobQueue::getNextJob(Job& job) void JobQueue::finishJob(JobType type) { - XRPL_ASSERT( - "ripple::JobQueue::finishJob : valid input job type", - type != jtINVALID); + ASSERT( + type != jtINVALID, + "ripple::JobQueue::finishJob : valid input job type"); JobTypeData& data = getJobTypeData(type); // Queue a deferred task if possible if (data.deferred > 0) { - XRPL_ASSERT( - "ripple::JobQueue::finishJob : job limit", - data.running + data.waiting >= getJobLimit(type)); + ASSERT( + data.running + data.waiting >= getJobLimit(type), + "ripple::JobQueue::finishJob : job limit"); --data.deferred; m_workers.addTask(); @@ -439,9 +436,9 @@ int JobQueue::getJobLimit(JobType type) { JobTypeInfo const& j(JobTypes::instance().get(type)); - XRPL_ASSERT( - "ripple::JobQueue::getJobLimit : valid job type", - j.type() != jtINVALID); + ASSERT( + j.type() != jtINVALID, + "ripple::JobQueue::getJobLimit : valid job type"); return j.limit(); } diff --git a/src/xrpld/core/detail/LoadEvent.cpp b/src/xrpld/core/detail/LoadEvent.cpp index 7f9e23b7f0e..b9c1de79a33 100644 --- a/src/xrpld/core/detail/LoadEvent.cpp +++ b/src/xrpld/core/detail/LoadEvent.cpp @@ -83,7 +83,7 @@ LoadEvent::start() void LoadEvent::stop() { - XRPL_ASSERT("ripple::LoadEvent::stop : is running", running_); + ASSERT(running_, "ripple::LoadEvent::stop : is running"); auto const now = std::chrono::steady_clock::now(); diff --git a/src/xrpld/core/detail/Workers.cpp b/src/xrpld/core/detail/Workers.cpp index 2ca1a615dc1..32e6ace4402 100644 --- a/src/xrpld/core/detail/Workers.cpp +++ b/src/xrpld/core/detail/Workers.cpp @@ -119,9 +119,9 @@ Workers::stop() m_cv.wait(lk, [this] { return m_allPaused; }); lk.unlock(); - XRPL_ASSERT( - "ripple::Workers::stop : zero running tasks", - numberOfCurrentlyRunningTasks() == 0); + ASSERT( + numberOfCurrentlyRunningTasks() == 0, + "ripple::Workers::stop : zero running tasks"); } void diff --git a/src/xrpld/ledger/ApplyView.h b/src/xrpld/ledger/ApplyView.h index 1cb63f3c3a1..12626824308 100644 --- a/src/xrpld/ledger/ApplyView.h +++ b/src/xrpld/ledger/ApplyView.h @@ -277,7 +277,7 @@ class ApplyView : public ReadView { if (key.type != ltOFFER) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::ApplyView::dirAppend : only Offers are appended to " "book directories"); // Only Offers are appended to book directories. Call dirInsert() diff --git a/src/xrpld/ledger/detail/ApplyStateTable.cpp b/src/xrpld/ledger/detail/ApplyStateTable.cpp index 1da64471744..2649ac2e207 100644 --- a/src/xrpld/ledger/detail/ApplyStateTable.cpp +++ b/src/xrpld/ledger/detail/ApplyStateTable.cpp @@ -155,10 +155,10 @@ ApplyStateTable::apply( meta.setAffectedNode(item.first, *type, nodeType); if (type == &sfDeletedNode) { - XRPL_ASSERT( + ASSERT( + origNode && curNode, "ripple::detail::ApplyStateTable::apply : valid nodes for " - "deletion", - origNode && curNode); + "deletion"); threadOwners(to, meta, origNode, newMod, j); STObject prevs(sfPreviousFields); @@ -190,10 +190,10 @@ ApplyStateTable::apply( } else if (type == &sfModifiedNode) { - XRPL_ASSERT( + ASSERT( + curNode && origNode, "ripple::detail::ApplyStateTable::apply : valid nodes for " - "modification", - curNode && origNode); + "modification"); if (curNode->isThreadedType( to.rules())) // thread transaction to node @@ -228,10 +228,10 @@ ApplyStateTable::apply( } else if (type == &sfCreatedNode) // if created, thread to owner(s) { - XRPL_ASSERT( + ASSERT( + curNode && !origNode, "ripple::detail::ApplyStateTable::apply : valid nodes for " - "creation", - curNode && !origNode); + "creation"); threadOwners(to, meta, curNode, newMod, j); if (curNode->isThreadedType( @@ -254,7 +254,7 @@ ApplyStateTable::apply( } else { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::detail::ApplyStateTable::apply : unsupported " "operation type"); } @@ -547,21 +547,21 @@ ApplyStateTable::threadItem(TxMeta& meta, std::shared_ptr const& sle) if (node.getFieldIndex(sfPreviousTxnID) == -1) { - XRPL_ASSERT( + ASSERT( + node.getFieldIndex(sfPreviousTxnLgrSeq) == -1, "ripple::ApplyStateTable::threadItem : previous ledger is not " - "set", - node.getFieldIndex(sfPreviousTxnLgrSeq) == -1); + "set"); node.setFieldH256(sfPreviousTxnID, prevTxID); node.setFieldU32(sfPreviousTxnLgrSeq, prevLgrID); } - XRPL_ASSERT( + ASSERT( + node.getFieldH256(sfPreviousTxnID) == prevTxID, "ripple::ApplyStateTable::threadItem : previous transaction is a " - "match", - node.getFieldH256(sfPreviousTxnID) == prevTxID); - XRPL_ASSERT( - "ripple::ApplyStateTable::threadItem : previous ledger is a match", - node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID); + "match"); + ASSERT( + node.getFieldU32(sfPreviousTxnLgrSeq) == prevLgrID, + "ripple::ApplyStateTable::threadItem : previous ledger is a match"); } } @@ -576,9 +576,9 @@ ApplyStateTable::getForMod( auto miter = mods.find(key); if (miter != mods.end()) { - XRPL_ASSERT( - "ripple::ApplyStateTable::getForMod : non-null result", - miter->second); + ASSERT( + miter->second != nullptr, + "ripple::ApplyStateTable::getForMod : non-null result"); return miter->second; } } @@ -634,9 +634,9 @@ ApplyStateTable::threadTx( return; } // threadItem only applied to AccountRoot - XRPL_ASSERT( - "ripple::ApplyStateTable::threadTx : SLE is threaded", - sle->isThreadedType(base.rules())); + ASSERT( + sle->isThreadedType(base.rules()), + "ripple::ApplyStateTable::threadTx : SLE is threaded"); threadItem(meta, sle); } diff --git a/src/xrpld/ledger/detail/ApplyView.cpp b/src/xrpld/ledger/detail/ApplyView.cpp index 67d8dadce8b..8b491bdcb2b 100644 --- a/src/xrpld/ledger/detail/ApplyView.cpp +++ b/src/xrpld/ledger/detail/ApplyView.cpp @@ -133,8 +133,7 @@ ApplyView::emptyDirDelete(Keylet const& directory) if (directory.type != ltDIR_NODE || node->getFieldH256(sfRootIndex) != directory.key) { - XRPL_UNREACHABLE( - "ripple::ApplyView::emptyDirDelete : invalid node type"); + UNREACHABLE("ripple::ApplyView::emptyDirDelete : invalid node type"); return false; } diff --git a/src/xrpld/ledger/detail/BookDirs.cpp b/src/xrpld/ledger/detail/BookDirs.cpp index c1eb040712b..4561aa2df18 100644 --- a/src/xrpld/ledger/detail/BookDirs.cpp +++ b/src/xrpld/ledger/detail/BookDirs.cpp @@ -30,13 +30,12 @@ BookDirs::BookDirs(ReadView const& view, Book const& book) , next_quality_(getQualityNext(root_)) , key_(view_->succ(root_, next_quality_).value_or(beast::zero)) { - XRPL_ASSERT( - "ripple::BookDirs::BookDirs : nonzero root", root_ != beast::zero); + ASSERT(root_ != beast::zero, "ripple::BookDirs::BookDirs : nonzero root"); if (key_ != beast::zero) { if (!cdirFirst(*view_, key_, sle_, entry_, index_)) { - XRPL_UNREACHABLE("ripple::BookDirs::BookDirs : directory is empty"); + UNREACHABLE("ripple::BookDirs::BookDirs : directory is empty"); } } } @@ -71,10 +70,10 @@ BookDirs::const_iterator::operator==( if (view_ == nullptr || other.view_ == nullptr) return false; - XRPL_ASSERT( + ASSERT( + view_ == other.view_ && root_ == other.root_, "ripple::BookDirs::const_iterator::operator== : views and roots are " - "matching", - view_ == other.view_ && root_ == other.root_); + "matching"); return entry_ == other.entry_ && cur_key_ == other.cur_key_ && index_ == other.index_; } @@ -82,9 +81,9 @@ BookDirs::const_iterator::operator==( BookDirs::const_iterator::reference BookDirs::const_iterator::operator*() const { - XRPL_ASSERT( - "ripple::BookDirs::const_iterator::operator* : nonzero index", - index_ != beast::zero); + ASSERT( + index_ != beast::zero, + "ripple::BookDirs::const_iterator::operator* : nonzero index"); if (!cache_) cache_ = view_->read(keylet::offer(index_)); return *cache_; @@ -95,9 +94,9 @@ BookDirs::const_iterator::operator++() { using beast::zero; - XRPL_ASSERT( - "ripple::BookDirs::const_iterator::operator++ : nonzero index", - index_ != zero); + ASSERT( + index_ != zero, + "ripple::BookDirs::const_iterator::operator++ : nonzero index"); if (!cdirNext(*view_, cur_key_, sle_, entry_, index_)) { if (index_ != 0 || @@ -110,7 +109,7 @@ BookDirs::const_iterator::operator++() } else if (!cdirFirst(*view_, cur_key_, sle_, entry_, index_)) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::BookDirs::const_iterator::operator++ : directory is " "empty"); } @@ -123,9 +122,9 @@ BookDirs::const_iterator::operator++() BookDirs::const_iterator BookDirs::const_iterator::operator++(int) { - XRPL_ASSERT( - "ripple::BookDirs::const_iterator::operator++(int) : nonzero index", - index_ != beast::zero); + ASSERT( + index_ != beast::zero, + "ripple::BookDirs::const_iterator::operator++(int) : nonzero index"); const_iterator tmp(*this); ++(*this); return tmp; diff --git a/src/xrpld/ledger/detail/Dir.cpp b/src/xrpld/ledger/detail/Dir.cpp index c21989f74e2..24c88a52f09 100644 --- a/src/xrpld/ledger/detail/Dir.cpp +++ b/src/xrpld/ledger/detail/Dir.cpp @@ -60,18 +60,18 @@ const_iterator::operator==(const_iterator const& other) const if (view_ == nullptr || other.view_ == nullptr) return false; - XRPL_ASSERT( - "ripple::const_iterator::operator== : views and roots are matching", - view_ == other.view_ && root_.key == other.root_.key); + ASSERT( + view_ == other.view_ && root_.key == other.root_.key, + "ripple::const_iterator::operator== : views and roots are matching"); return page_.key == other.page_.key && index_ == other.index_; } const_iterator::reference const_iterator::operator*() const { - XRPL_ASSERT( - "ripple::const_iterator::operator* : nonzero index", - index_ != beast::zero); + ASSERT( + index_ != beast::zero, + "ripple::const_iterator::operator* : nonzero index"); if (!cache_) cache_ = view_->read(keylet::child(index_)); return *cache_; @@ -80,9 +80,9 @@ const_iterator::operator*() const const_iterator& const_iterator::operator++() { - XRPL_ASSERT( - "ripple::const_iterator::operator++ : nonzero index", - index_ != beast::zero); + ASSERT( + index_ != beast::zero, + "ripple::const_iterator::operator++ : nonzero index"); if (++it_ != std::end(*indexes_)) { index_ = *it_; @@ -96,9 +96,9 @@ const_iterator::operator++() const_iterator const_iterator::operator++(int) { - XRPL_ASSERT( - "ripple::const_iterator::operator++(int) : nonzero index", - index_ != beast::zero); + ASSERT( + index_ != beast::zero, + "ripple::const_iterator::operator++(int) : nonzero index"); const_iterator tmp(*this); ++(*this); return tmp; @@ -117,7 +117,9 @@ const_iterator::next_page() { page_ = keylet::page(root_, next); sle_ = view_->read(page_); - XRPL_ASSERT("ripple::const_iterator::next_page : non-null SLE", sle_); + ASSERT( + sle_ != nullptr, + "ripple::const_iterator::next_page : non-null SLE"); indexes_ = &sle_->getFieldV256(sfIndexes); if (indexes_->empty()) { diff --git a/src/xrpld/ledger/detail/PaymentSandbox.cpp b/src/xrpld/ledger/detail/PaymentSandbox.cpp index 24302180d5e..3400427448d 100644 --- a/src/xrpld/ledger/detail/PaymentSandbox.cpp +++ b/src/xrpld/ledger/detail/PaymentSandbox.cpp @@ -48,12 +48,12 @@ DeferredCredits::credit( STAmount const& amount, STAmount const& preCreditSenderBalance) { - XRPL_ASSERT( - "ripple::detail::DeferredCredits::credit : sender is not receiver", - sender != receiver); - XRPL_ASSERT( - "ripple::detail::DeferredCredits::credit : positive amount", - !amount.negative()); + ASSERT( + sender != receiver, + "ripple::detail::DeferredCredits::credit : sender is not receiver"); + ASSERT( + !amount.negative(), + "ripple::detail::DeferredCredits::credit : positive amount"); auto const k = makeKey(sender, receiver, amount.getCurrency()); auto i = credits_.find(k); @@ -256,14 +256,14 @@ PaymentSandbox::adjustOwnerCountHook( void PaymentSandbox::apply(RawView& to) { - XRPL_ASSERT("ripple::PaymentSandbox::apply : non-null sandbox", !ps_); + ASSERT(!ps_, "ripple::PaymentSandbox::apply : non-null sandbox"); items_.apply(to); } void PaymentSandbox::apply(PaymentSandbox& to) { - XRPL_ASSERT("ripple::PaymentSandbox::apply : matching sandbox", ps_ == &to); + ASSERT(ps_ == &to, "ripple::PaymentSandbox::apply : matching sandbox"); items_.apply(to); tab_.apply(to.tab_); } @@ -347,10 +347,10 @@ PaymentSandbox::balanceChanges(ReadView const& view) const { // modify auto const at = after->getType(); - XRPL_ASSERT( + ASSERT( + at == before->getType(), "ripple::PaymentSandbox::balanceChanges : after and before " - "types matching", - at == before->getType()); + "types matching"); switch (at) { case ltACCOUNT_ROOT: diff --git a/src/xrpld/ledger/detail/RawStateTable.cpp b/src/xrpld/ledger/detail/RawStateTable.cpp index e202d500c6a..f8c575fc520 100644 --- a/src/xrpld/ledger/detail/RawStateTable.cpp +++ b/src/xrpld/ledger/detail/RawStateTable.cpp @@ -63,9 +63,10 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base { if (auto const p = dynamic_cast(&impl)) { - XRPL_ASSERT( - "ripple::detail::RawStateTable::equal : matching end iterators", - end1_ == p->end1_ && end0_ == p->end0_); + ASSERT( + end1_ == p->end1_ && end0_ == p->end0_, + "ripple::detail::RawStateTable::equal : matching end " + "iterators"); return iter1_ == p->iter1_ && iter0_ == p->iter0_; } @@ -75,9 +76,10 @@ class RawStateTable::sles_iter_impl : public ReadView::sles_type::iter_base void increment() override { - XRPL_ASSERT( - "ripple::detail::RawStateTable::increment : either SLE is non-null", - sle1_ || sle0_); + ASSERT( + sle1_ || sle0_, + "ripple::detail::RawStateTable::increment : either SLE is " + "non-null"); if (sle1_ && !sle0_) { @@ -183,9 +185,9 @@ RawStateTable::apply(RawView& to) const bool RawStateTable::exists(ReadView const& base, Keylet const& k) const { - XRPL_ASSERT( - "ripple::detail::RawStateTable::exists : nonzero key", - k.key.isNonZero()); + ASSERT( + k.key.isNonZero(), + "ripple::detail::RawStateTable::exists : nonzero key"); auto const iter = items_.find(k.key); if (iter == items_.end()) return base.exists(k); diff --git a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp index 0d5ba358a3f..844705a3f80 100644 --- a/src/xrpld/ledger/detail/ReadViewFwdRange.ipp +++ b/src/xrpld/ledger/detail/ReadViewFwdRange.ipp @@ -80,10 +80,10 @@ template bool ReadViewFwdRange::iterator::operator==(iterator const& other) const { - XRPL_ASSERT( + ASSERT( + view_ == other.view_, "ripple::detail::ReadViewFwdRange::iterator::operator==(iterator) " - "const : input view match", - view_ == other.view_); + "const : input view match"); if (impl_ != nullptr && other.impl_ != nullptr) return impl_->equal(*other.impl_); diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 41ead67090e..83f5ee70ec6 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -48,9 +48,9 @@ internalDirNext( uint256& entry) { auto const& svIndexes = page->getFieldV256(sfIndexes); - XRPL_ASSERT( - "ripple::detail::internalDirNext : index inside range", - index <= svIndexes.size()); + ASSERT( + index <= svIndexes.size(), + "ripple::detail::internalDirNext : index inside range"); if (index >= svIndexes.size()) { @@ -67,7 +67,8 @@ internalDirNext( else page = view.peek(keylet::page(root, next)); - XRPL_ASSERT("ripple::detail::internalDirNext : non-null root", page); + ASSERT( + page != nullptr, "ripple::detail::internalDirNext : non-null root"); if (!page) return false; @@ -338,7 +339,7 @@ confineOwnerCount( << "Account " << *id << " owner count set below 0!"; } adjusted = 0; - XRPL_ASSERT("ripple::confineOwnerCount : id is not set", !id); + ASSERT(!id, "ripple::confineOwnerCount : id is not set"); } } return adjusted; @@ -388,8 +389,7 @@ forEachItem( Keylet const& root, std::function const&)> const& f) { - XRPL_ASSERT( - "ripple::forEachItem : valid root type", root.type == ltDIR_NODE); + ASSERT(root.type == ltDIR_NODE, "ripple::forEachItem : valid root type"); if (root.type != ltDIR_NODE) return; @@ -419,8 +419,8 @@ forEachItemAfter( unsigned int limit, std::function const&)> const& f) { - XRPL_ASSERT( - "ripple::forEachItemAfter : valid root type", root.type == ltDIR_NODE); + ASSERT( + root.type == ltDIR_NODE, "ripple::forEachItemAfter : valid root type"); if (root.type != ltDIR_NODE) return false; @@ -682,10 +682,10 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) auto const hashIndex = ledger.read(keylet::skip()); if (hashIndex) { - XRPL_ASSERT( - "ripple::hashOfSeq : matching ledger sequence", + ASSERT( hashIndex->getFieldU32(sfLastLedgerSequence) == - (ledger.seq() - 1)); + (ledger.seq() - 1), + "ripple::hashOfSeq : matching ledger sequence"); STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() >= diff) return vec[vec.size() - diff]; @@ -713,9 +713,8 @@ hashOfSeq(ReadView const& ledger, LedgerIndex seq, beast::Journal journal) if (hashIndex) { auto const lastSeq = hashIndex->getFieldU32(sfLastLedgerSequence); - XRPL_ASSERT("ripple::hashOfSeq : minimum last ledger", lastSeq >= seq); - XRPL_ASSERT( - "ripple::hashOfSeq : valid last ledger", (lastSeq & 0xff) == 0); + ASSERT(lastSeq >= seq, "ripple::hashOfSeq : minimum last ledger"); + ASSERT((lastSeq & 0xff) == 0, "ripple::hashOfSeq : valid last ledger"); auto const diff = (lastSeq - seq) >> 8; STVector256 vec = hashIndex->getFieldV256(sfHashes); if (vec.size() > diff) @@ -741,7 +740,7 @@ adjustOwnerCount( { if (!sle) return; - XRPL_ASSERT("ripple::adjustOwnerCount : nonzero amount input", amount != 0); + ASSERT(amount != 0, "ripple::adjustOwnerCount : nonzero amount input"); std::uint32_t const current{sle->getFieldU32(sfOwnerCount)}; AccountID const id = (*sle)[sfAccount]; std::uint32_t const adjusted = confineOwnerCount(current, amount, id, j); @@ -806,14 +805,14 @@ trustCreate( const bool bSetDst = saLimit.getIssuer() == uDstAccountID; const bool bSetHigh = bSrcHigh ^ bSetDst; - XRPL_ASSERT("ripple::trustCreate : non-null SLE", sleAccount); + ASSERT(sleAccount != nullptr, "ripple::trustCreate : non-null SLE"); if (!sleAccount) return tefINTERNAL; - XRPL_ASSERT( - "ripple::trustCreate : matching account ID", + ASSERT( sleAccount->getAccountID(sfAccount) == - (bSetHigh ? uHighAccountID : uLowAccountID)); + (bSetHigh ? uHighAccountID : uLowAccountID), + "ripple::trustCreate : matching account ID"); auto const slePeer = view.peek(keylet::account(bSetHigh ? uLowAccountID : uHighAccountID)); if (!slePeer) @@ -966,25 +965,25 @@ rippleCredit( Currency const& currency = saAmount.getCurrency(); // Make sure issuer is involved. - XRPL_ASSERT( - "ripple::rippleCredit : matching issuer or don't care", - !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer); + ASSERT( + !bCheckIssuer || uSenderID == issuer || uReceiverID == issuer, + "ripple::rippleCredit : matching issuer or don't care"); (void)issuer; // Disallow sending to self. - XRPL_ASSERT( - "ripple::rippleCredit : sender is not receiver", - uSenderID != uReceiverID); + ASSERT( + uSenderID != uReceiverID, + "ripple::rippleCredit : sender is not receiver"); bool const bSenderHigh = uSenderID > uReceiverID; auto const index = keylet::line(uSenderID, uReceiverID, currency); - XRPL_ASSERT( - "ripple::rippleCredit : sender is not XRP", - !isXRP(uSenderID) && uSenderID != noAccount()); - XRPL_ASSERT( - "ripple::rippleCredit : receiver is not XRP", - !isXRP(uReceiverID) && uReceiverID != noAccount()); + ASSERT( + !isXRP(uSenderID) && uSenderID != noAccount(), + "ripple::rippleCredit : sender is not XRP"); + ASSERT( + !isXRP(uReceiverID) && uReceiverID != noAccount(), + "ripple::rippleCredit : receiver is not XRP"); // If the line exists, modify it accordingly. if (auto const sleRippleState = view.peek(index)) @@ -1118,12 +1117,12 @@ rippleSend( { auto const issuer = saAmount.getIssuer(); - XRPL_ASSERT( - "ripple::rippleSend : neither sender nor receiver is XRP", - !isXRP(uSenderID) && !isXRP(uReceiverID)); - XRPL_ASSERT( - "ripple::rippleSend : sender is not receiver", - uSenderID != uReceiverID); + ASSERT( + !isXRP(uSenderID) && !isXRP(uReceiverID), + "ripple::rippleSend : neither sender nor receiver is XRP"); + ASSERT( + uSenderID != uReceiverID, + "ripple::rippleSend : sender is not receiver"); if (uSenderID == issuer || uReceiverID == issuer || issuer == noAccount()) { @@ -1175,8 +1174,7 @@ accountSend( } else { - XRPL_ASSERT( - "ripple::accountSend : minimum amount", saAmount >= beast::zero); + ASSERT(saAmount >= beast::zero, "ripple::accountSend : minimum amount"); } /* If we aren't sending anything or if the sender is the same as the @@ -1337,16 +1335,15 @@ issueIOU( Issue const& issue, beast::Journal j) { - XRPL_ASSERT( - "ripple::issueIOU : neither account nor issuer is XRP", - !isXRP(account) && !isXRP(issue.account)); + ASSERT( + !isXRP(account) && !isXRP(issue.account), + "ripple::issueIOU : neither account nor issuer is XRP"); // Consistency check - XRPL_ASSERT("ripple::issueIOU : matching issue", issue == amount.issue()); + ASSERT(issue == amount.issue(), "ripple::issueIOU : matching issue"); // Can't send to self! - XRPL_ASSERT( - "ripple::issueIOU : not issuer account", issue.account != account); + ASSERT(issue.account != account, "ripple::issueIOU : not issuer account"); JLOG(j.trace()) << "issueIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1436,16 +1433,15 @@ redeemIOU( Issue const& issue, beast::Journal j) { - XRPL_ASSERT( - "ripple::redeemIOU : neither account nor issuer is XRP", - !isXRP(account) && !isXRP(issue.account)); + ASSERT( + !isXRP(account) && !isXRP(issue.account), + "ripple::redeemIOU : neither account nor issuer is XRP"); // Consistency check - XRPL_ASSERT("ripple::redeemIOU : matching issue", issue == amount.issue()); + ASSERT(issue == amount.issue(), "ripple::redeemIOU : matching issue"); // Can't send to self! - XRPL_ASSERT( - "ripple::redeemIOU : not issuer account", issue.account != account); + ASSERT(issue.account != account, "ripple::redeemIOU : not issuer account"); JLOG(j.trace()) << "redeemIOU: " << to_string(account) << ": " << amount.getFullText(); @@ -1509,11 +1505,10 @@ transferXRP( STAmount const& amount, beast::Journal j) { - XRPL_ASSERT( - "ripple::transferXRP : nonzero from account", from != beast::zero); - XRPL_ASSERT("ripple::transferXRP : nonzero to account", to != beast::zero); - XRPL_ASSERT("ripple::transferXRP : from and to are unequal", from != to); - XRPL_ASSERT("ripple::transferXRP : amount is XRP", amount.native()); + ASSERT(from != beast::zero, "ripple::transferXRP : nonzero from account"); + ASSERT(to != beast::zero, "ripple::transferXRP : nonzero to account"); + ASSERT(from != to, "ripple::transferXRP : from and to are unequal"); + ASSERT(amount.native(), "ripple::transferXRP : amount is XRP"); SLE::pointer const sender = view.peek(keylet::account(from)); SLE::pointer const receiver = view.peek(keylet::account(to)); @@ -1623,9 +1618,9 @@ cleanupOnAccountDelete( // // 3. So we verify that uDirEntry is indeed 'it'+1. Then we jam it // back to 'it' to "un-invalidate" the iterator. - XRPL_ASSERT( - "ripple::cleanupOnAccountDelete : minimum dir entries", - uDirEntry >= 1); + ASSERT( + uDirEntry >= 1, + "ripple::cleanupOnAccountDelete : minimum dir entries"); if (uDirEntry == 0) { JLOG(j.error()) diff --git a/src/xrpld/net/detail/InfoSub.cpp b/src/xrpld/net/detail/InfoSub.cpp index 8936fa0c2d9..4d18bf0b8fa 100644 --- a/src/xrpld/net/detail/InfoSub.cpp +++ b/src/xrpld/net/detail/InfoSub.cpp @@ -145,8 +145,8 @@ InfoSub::setApiVersion(unsigned int apiVersion) unsigned int InfoSub::getApiVersion() const noexcept { - XRPL_ASSERT( - "ripple::InfoSub::getApiVersion : valid API version", apiVersion_ > 0); + ASSERT( + apiVersion_ > 0, "ripple::InfoSub::getApiVersion : valid API version"); return apiVersion_; } diff --git a/src/xrpld/net/detail/RPCCall.cpp b/src/xrpld/net/detail/RPCCall.cpp index 2ba61ba450e..e16a1b16b4a 100644 --- a/src/xrpld/net/detail/RPCCall.cpp +++ b/src/xrpld/net/detail/RPCCall.cpp @@ -953,9 +953,9 @@ class RPCParser parseTransactionEntry(Json::Value const& jvParams) { // Parameter count should have already been verified. - XRPL_ASSERT( - "ripple::RPCParser::parseTransactionEntry : valid parameter count", - jvParams.size() == 2); + ASSERT( + jvParams.size() == 2, + "ripple::RPCParser::parseTransactionEntry : valid parameter count"); std::string const txHash = jvParams[0u].asString(); if (txHash.length() != 64) diff --git a/src/xrpld/nodestore/Database.h b/src/xrpld/nodestore/Database.h index 92cb12c8200..04bd718104d 100644 --- a/src/xrpld/nodestore/Database.h +++ b/src/xrpld/nodestore/Database.h @@ -246,9 +246,9 @@ class Database void storeStats(std::uint64_t count, std::uint64_t sz) { - XRPL_ASSERT( - "ripple::NodeStore::Database::storeStats : valid inputs", - count <= sz); + ASSERT( + count <= sz, + "ripple::NodeStore::Database::storeStats : valid inputs"); storeCount_ += count; storeSz_ += sz; } diff --git a/src/xrpld/nodestore/backend/MemoryFactory.cpp b/src/xrpld/nodestore/backend/MemoryFactory.cpp index ca9aead398f..1b7bf79c81e 100644 --- a/src/xrpld/nodestore/backend/MemoryFactory.cpp +++ b/src/xrpld/nodestore/backend/MemoryFactory.cpp @@ -131,8 +131,9 @@ class MemoryBackend : public Backend Status fetch(void const* key, std::shared_ptr* pObject) override { - XRPL_ASSERT( - "ripple::NodeStore::MemoryBackend::fetch : non-null database", db_); + ASSERT( + db_ != nullptr, + "ripple::NodeStore::MemoryBackend::fetch : non-null database"); uint256 const hash(uint256::fromVoid(key)); std::lock_guard _(db_->mutex); @@ -168,8 +169,9 @@ class MemoryBackend : public Backend void store(std::shared_ptr const& object) override { - XRPL_ASSERT( - "ripple::NodeStore::MemoryBackend::store : non-null database", db_); + ASSERT( + db_ != nullptr, + "ripple::NodeStore::MemoryBackend::store : non-null database"); std::lock_guard _(db_->mutex); db_->table.emplace(object->getHash(), object); } @@ -189,9 +191,9 @@ class MemoryBackend : public Backend void for_each(std::function)> f) override { - XRPL_ASSERT( - "ripple::NodeStore::MemoryBackend::for_each : non-null database", - db_); + ASSERT( + db_ != nullptr, + "ripple::NodeStore::MemoryBackend::for_each : non-null database"); for (auto const& e : db_->table) f(e.second); } diff --git a/src/xrpld/nodestore/backend/NuDBFactory.cpp b/src/xrpld/nodestore/backend/NuDBFactory.cpp index 55ab68a8359..24ebffd33a2 100644 --- a/src/xrpld/nodestore/backend/NuDBFactory.cpp +++ b/src/xrpld/nodestore/backend/NuDBFactory.cpp @@ -117,7 +117,7 @@ class NuDBBackend : public Backend using namespace boost::filesystem; if (db_.is_open()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::NodeStore::NuDBBackend::open : database is already " "open"); JLOG(j_.error()) << "database is already open"; diff --git a/src/xrpld/nodestore/backend/RocksDBFactory.cpp b/src/xrpld/nodestore/backend/RocksDBFactory.cpp index 67d9eb29ad7..a4bb4ae5fb6 100644 --- a/src/xrpld/nodestore/backend/RocksDBFactory.cpp +++ b/src/xrpld/nodestore/backend/RocksDBFactory.cpp @@ -228,7 +228,7 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback { if (m_db) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::NodeStore::RocksDBBackend::open : database is already " "open"); JLOG(m_journal.error()) << "database is already open"; @@ -275,9 +275,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback Status fetch(void const* key, std::shared_ptr* pObject) override { - XRPL_ASSERT( - "ripple::NodeStore::RocksDBBackend::fetch : non-null database", - m_db); + ASSERT( + m_db != nullptr, + "ripple::NodeStore::RocksDBBackend::fetch : non-null database"); pObject->reset(); Status status(ok); @@ -353,9 +353,10 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void storeBatch(Batch const& batch) override { - XRPL_ASSERT( - "ripple::NodeStore::RocksDBBackend::storeBatch : non-null database", - m_db); + ASSERT( + m_db != nullptr, + "ripple::NodeStore::RocksDBBackend::storeBatch : non-null " + "database"); rocksdb::WriteBatch wb; for (auto const& e : batch) @@ -387,9 +388,9 @@ class RocksDBBackend : public Backend, public BatchWriter::Callback void for_each(std::function)> f) override { - XRPL_ASSERT( - "ripple::NodeStore::RocksDBBackend::for_each : non-null database", - m_db); + ASSERT( + m_db != nullptr, + "ripple::NodeStore::RocksDBBackend::for_each : non-null database"); rocksdb::ReadOptions const options; std::unique_ptr it(m_db->NewIterator(options)); diff --git a/src/xrpld/nodestore/detail/BatchWriter.cpp b/src/xrpld/nodestore/detail/BatchWriter.cpp index 7f467dcf3ba..ec360f89f31 100644 --- a/src/xrpld/nodestore/detail/BatchWriter.cpp +++ b/src/xrpld/nodestore/detail/BatchWriter.cpp @@ -83,9 +83,9 @@ BatchWriter::writeBatch() std::lock_guard sl(mWriteMutex); mWriteSet.swap(set); - XRPL_ASSERT( - "ripple::NodeStore::BatchWriter::writeBatch : writes not set", - mWriteSet.empty()); + ASSERT( + mWriteSet.empty(), + "ripple::NodeStore::BatchWriter::writeBatch : writes not set"); mWriteLoad = set.size(); if (set.empty()) diff --git a/src/xrpld/nodestore/detail/Database.cpp b/src/xrpld/nodestore/detail/Database.cpp index 82589aae33f..f9875d5062f 100644 --- a/src/xrpld/nodestore/detail/Database.cpp +++ b/src/xrpld/nodestore/detail/Database.cpp @@ -40,9 +40,9 @@ Database::Database( , requestBundle_(get(config, "rq_bundle", 4)) , readThreads_(std::max(1, readThreads)) { - XRPL_ASSERT( - "ripple::NodeStore::Database::Database : nonzero threads input", - readThreads != 0); + ASSERT( + readThreads != 0, + "ripple::NodeStore::Database::Database : nonzero threads input"); if (earliestLedgerSeq_ < 1) Throw("Invalid earliest_seq"); @@ -89,10 +89,10 @@ Database::Database( for (auto it = read.begin(); it != read.end(); ++it) { - XRPL_ASSERT( + ASSERT( + !it->second.empty(), "ripple::NodeStore::Database::Database : non-empty " - "data", - !it->second.empty()); + "data"); auto const& hash = it->first; auto const& data = it->second; @@ -166,9 +166,9 @@ Database::stop() while (readThreads_.load() != 0) { - XRPL_ASSERT( - "ripple::NodeStore::Database::stop : maximum stop duration", - steady_clock::now() - start < 30s); + ASSERT( + steady_clock::now() - start < 30s, + "ripple::NodeStore::Database::stop : maximum stop duration"); std::this_thread::yield(); } @@ -219,9 +219,9 @@ Database::importInternal(Backend& dstBackend, Database& srcDB) }; srcDB.for_each([&](std::shared_ptr nodeObject) { - XRPL_ASSERT( - "ripple::NodeStore::Database::importInternal : non-null node", - nodeObject); + ASSERT( + nodeObject != nullptr, + "ripple::NodeStore::Database::importInternal : non-null node"); if (!nodeObject) // This should never happen return; @@ -265,9 +265,9 @@ Database::fetchNodeObject( void Database::getCountsJson(Json::Value& obj) { - XRPL_ASSERT( - "ripple::NodeStore::Database::getCountsJson : valid input type", - obj.isObject()); + ASSERT( + obj.isObject(), + "ripple::NodeStore::Database::getCountsJson : valid input type"); { std::unique_lock lock(readLock_); diff --git a/src/xrpld/nodestore/detail/DatabaseNodeImp.h b/src/xrpld/nodestore/detail/DatabaseNodeImp.h index 80540e7359e..230f5dc55a4 100644 --- a/src/xrpld/nodestore/detail/DatabaseNodeImp.h +++ b/src/xrpld/nodestore/detail/DatabaseNodeImp.h @@ -76,10 +76,10 @@ class DatabaseNodeImp : public Database j); } - XRPL_ASSERT( + ASSERT( + backend_ != nullptr, "ripple::NodeStore::DatabaseNodeImp::DatabaseNodeImp : non-null " - "backend", - backend_); + "backend"); } ~DatabaseNodeImp() diff --git a/src/xrpld/nodestore/detail/DecodedBlob.cpp b/src/xrpld/nodestore/detail/DecodedBlob.cpp index 24a24b6a771..49e1ff5e3bb 100644 --- a/src/xrpld/nodestore/detail/DecodedBlob.cpp +++ b/src/xrpld/nodestore/detail/DecodedBlob.cpp @@ -72,9 +72,9 @@ DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) std::shared_ptr DecodedBlob::createObject() { - XRPL_ASSERT( - "ripple::NodeStore::DecodedBlob::createObject : valid object type", - m_success); + ASSERT( + m_success, + "ripple::NodeStore::DecodedBlob::createObject : valid object type"); std::shared_ptr object; diff --git a/src/xrpld/nodestore/detail/EncodedBlob.h b/src/xrpld/nodestore/detail/EncodedBlob.h index 270fb23de86..d99908cf4f6 100644 --- a/src/xrpld/nodestore/detail/EncodedBlob.h +++ b/src/xrpld/nodestore/detail/EncodedBlob.h @@ -80,9 +80,9 @@ class EncodedBlob public: explicit EncodedBlob(std::shared_ptr const& obj) : size_([&obj]() { - XRPL_ASSERT( - "ripple::NodeStore::EncodedBlob::EncodedBlob : non-null input", - obj); + ASSERT( + obj != nullptr, + "ripple::NodeStore::EncodedBlob::EncodedBlob : non-null input"); if (!obj) throw std::runtime_error( @@ -102,11 +102,11 @@ class EncodedBlob ~EncodedBlob() { - XRPL_ASSERT( - "ripple::NodeStore::EncodedBlob::~EncodedBlob : valid payload " - "pointer", + ASSERT( ((ptr_ == payload_.data()) && (size_ <= payload_.size())) || - ((ptr_ != payload_.data()) && (size_ > payload_.size()))); + ((ptr_ != payload_.data()) && (size_ > payload_.size())), + "ripple::NodeStore::EncodedBlob::~EncodedBlob : valid payload " + "pointer"); if (ptr_ != payload_.data()) delete[] ptr_; diff --git a/src/xrpld/nodestore/detail/ManagerImp.cpp b/src/xrpld/nodestore/detail/ManagerImp.cpp index 24c5377abb0..38f193a7d8a 100644 --- a/src/xrpld/nodestore/detail/ManagerImp.cpp +++ b/src/xrpld/nodestore/detail/ManagerImp.cpp @@ -91,9 +91,9 @@ ManagerImp::erase(Factory& factory) std::find_if(list_.begin(), list_.end(), [&factory](Factory* other) { return other == &factory; }); - XRPL_ASSERT( - "ripple::NodeStore::ManagerImp::erase : valid input", - iter != list_.end()); + ASSERT( + iter != list_.end(), + "ripple::NodeStore::ManagerImp::erase : valid input"); list_.erase(iter); } diff --git a/src/xrpld/overlay/Compression.h b/src/xrpld/overlay/Compression.h index 7ec0821f0ef..c7437badc4d 100644 --- a/src/xrpld/overlay/Compression.h +++ b/src/xrpld/overlay/Compression.h @@ -64,7 +64,7 @@ decompress( JLOG(debugLog().warn()) << "decompress: invalid compression algorithm " << static_cast(algorithm); - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::compression::decompress : invalid compression " "algorithm"); } @@ -101,7 +101,7 @@ compress( { JLOG(debugLog().warn()) << "compress: invalid compression algorithm" << static_cast(algorithm); - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::compression::compress : invalid compression " "algorithm"); } diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index 41f0ef94c50..fca6c621fa0 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -362,9 +362,9 @@ Slot::update( << consideredPoolSize << " selected " << *s << " " << *std::next(s, 1) << " " << *std::next(s, 2); - XRPL_ASSERT( - "ripple::reduce_relay::Slot::update : minimum peers", - peers_.size() >= MAX_SELECTED_PEERS); + ASSERT( + peers_.size() >= MAX_SELECTED_PEERS, + "ripple::reduce_relay::Slot::update : minimum peers"); // squelch peers which are not selected and // not already squelched diff --git a/src/xrpld/overlay/detail/ConnectAttempt.cpp b/src/xrpld/overlay/detail/ConnectAttempt.cpp index 48ce321b06f..d65366560d5 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.cpp +++ b/src/xrpld/overlay/detail/ConnectAttempt.cpp @@ -90,9 +90,9 @@ ConnectAttempt::run() void ConnectAttempt::close() { - XRPL_ASSERT( - "ripple::ConnectAttempt::close : strand in this thread", - strand_.running_in_this_thread()); + ASSERT( + strand_.running_in_this_thread(), + "ripple::ConnectAttempt::close : strand in this thread"); if (socket_.is_open()) { error_code ec; diff --git a/src/xrpld/overlay/detail/Message.cpp b/src/xrpld/overlay/detail/Message.cpp index 1ea3f540e1d..6e44f3e957c 100644 --- a/src/xrpld/overlay/detail/Message.cpp +++ b/src/xrpld/overlay/detail/Message.cpp @@ -34,9 +34,9 @@ Message::Message( auto const messageBytes = messageSize(message); - XRPL_ASSERT( - "ripple::Message::Message : non-empty message input", - messageBytes != 0); + ASSERT( + messageBytes != 0, + "ripple::Message::Message : non-empty message input"); buffer_.resize(headerBytes + messageBytes); @@ -45,9 +45,9 @@ Message::Message( if (messageBytes != 0) message.SerializeToArray(buffer_.data() + headerBytes, messageBytes); - XRPL_ASSERT( - "ripple::Message::Message : message size matches the buffer", - getBufferSize() == totalSize(message)); + ASSERT( + getBufferSize() == totalSize(message), + "ripple::Message::Message : message size matches the buffer"); } // static diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index fe2aa09c11c..3dc26ab54fa 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -294,9 +294,9 @@ OverlayImpl::onHandoff( std::lock_guard lock(mutex_); { auto const result = m_peers.emplace(peer->slot(), peer); - XRPL_ASSERT( - "ripple::OverlayImpl::onHandoff : peer is inserted", - result.second); + ASSERT( + result.second, + "ripple::OverlayImpl::onHandoff : peer is inserted"); (void)result.second; } list_.emplace(peer.get(), peer); @@ -389,7 +389,7 @@ OverlayImpl::makeErrorResponse( void OverlayImpl::connect(beast::IP::Endpoint const& remote_endpoint) { - XRPL_ASSERT("ripple::OverlayImpl::connect : work is set", work_); + ASSERT(work_.has_value(), "ripple::OverlayImpl::connect : work is set"); auto usage = resourceManager().newOutboundEndpoint(remote_endpoint); if (usage.disconnect(journal_)) @@ -431,9 +431,9 @@ OverlayImpl::add_active(std::shared_ptr const& peer) { auto const result = m_peers.emplace(peer->slot(), peer); - XRPL_ASSERT( - "ripple::OverlayImpl::add_active : peer is inserted", - result.second); + ASSERT( + result.second, + "ripple::OverlayImpl::add_active : peer is inserted"); (void)result.second; } @@ -442,9 +442,9 @@ OverlayImpl::add_active(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer)); - XRPL_ASSERT( - "ripple::OverlayImpl::add_active : peer ID is inserted", - result.second); + ASSERT( + result.second, + "ripple::OverlayImpl::add_active : peer ID is inserted"); (void)result.second; } @@ -467,8 +467,7 @@ OverlayImpl::remove(std::shared_ptr const& slot) { std::lock_guard lock(mutex_); auto const iter = m_peers.find(slot); - XRPL_ASSERT( - "ripple::OverlayImpl::remove : valid input", iter != m_peers.end()); + ASSERT(iter != m_peers.end(), "ripple::OverlayImpl::remove : valid input"); m_peers.erase(iter); } @@ -602,9 +601,9 @@ OverlayImpl::activate(std::shared_ptr const& peer) std::piecewise_construct, std::make_tuple(peer->id()), std::make_tuple(peer))); - XRPL_ASSERT( - "ripple::OverlayImpl::activate : peer ID is inserted", - result.second); + ASSERT( + result.second, + "ripple::OverlayImpl::activate : peer ID is inserted"); (void)result.second; } @@ -615,7 +614,7 @@ OverlayImpl::activate(std::shared_ptr const& peer) << ")"; // We just accepted this peer so we have non-zero active peers - XRPL_ASSERT("ripple::OverlayImpl::activate : nonzero peers", size() != 0); + ASSERT(size() != 0, "ripple::OverlayImpl::activate : nonzero peers"); } void @@ -654,10 +653,10 @@ OverlayImpl::onManifests( // the loaded Manifest out of the optional so we need to // reload it here. mo = deserializeManifest(serialized); - XRPL_ASSERT( + ASSERT( + mo.has_value(), "ripple::OverlayImpl::onManifests : manifest " - "deserialization succeeded", - mo); + "deserialization succeeded"); app_.getOPs().pubManifest(*mo); diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index 192faeb1553..63e002ddf79 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -600,9 +600,9 @@ class OverlayImpl : public Overlay, public reduce_relay::SquelchHandler { auto counts = m_traffic.getCounts(); std::lock_guard lock(m_statsMutex); - XRPL_ASSERT( - "ripple::OverlayImpl::collect_metrics : counts size do match", - counts.size() == m_stats.trafficGauges.size()); + ASSERT( + counts.size() == m_stats.trafficGauges.size(), + "ripple::OverlayImpl::collect_metrics : counts size do match"); for (std::size_t i = 0; i < counts.size(); ++i) { diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 655990661dd..00ce3d5a168 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -565,9 +565,9 @@ PeerImp::hasRange(std::uint32_t uMin, std::uint32_t uMax) void PeerImp::close() { - XRPL_ASSERT( - "ripple::PeerImp::close : strand in this thread", - strand_.running_in_this_thread()); + ASSERT( + strand_.running_in_this_thread(), + "ripple::PeerImp::close : strand in this thread"); if (socket_.is_open()) { detaching_ = true; // DEPRECATED @@ -608,9 +608,9 @@ PeerImp::fail(std::string const& reason) void PeerImp::fail(std::string const& name, error_code ec) { - XRPL_ASSERT( - "ripple::PeerImp::fail : strand in this thread", - strand_.running_in_this_thread()); + ASSERT( + strand_.running_in_this_thread(), + "ripple::PeerImp::fail : strand in this thread"); if (socket_.is_open()) { JLOG(journal_.warn()) @@ -623,14 +623,14 @@ PeerImp::fail(std::string const& name, error_code ec) void PeerImp::gracefulClose() { - XRPL_ASSERT( - "ripple::PeerImp::gracefulClose : strand in this thread", - strand_.running_in_this_thread()); - XRPL_ASSERT( - "ripple::PeerImp::gracefulClose : socket is open", socket_.is_open()); - XRPL_ASSERT( - "ripple::PeerImp::gracefulClose : socket is not closing", - !gracefulClose_); + ASSERT( + strand_.running_in_this_thread(), + "ripple::PeerImp::gracefulClose : strand in this thread"); + ASSERT( + socket_.is_open(), "ripple::PeerImp::gracefulClose : socket is open"); + ASSERT( + !gracefulClose_, + "ripple::PeerImp::gracefulClose : socket is not closing"); gracefulClose_ = true; if (send_queue_.size() > 0) return; @@ -756,9 +756,9 @@ PeerImp::onShutdown(error_code ec) void PeerImp::doAccept() { - XRPL_ASSERT( - "ripple::PeerImp::doAccept : empty read buffer", - read_buffer_.size() == 0); + ASSERT( + read_buffer_.size() == 0, + "ripple::PeerImp::doAccept : empty read buffer"); JLOG(journal_.debug()) << "doAccept: " << remote_address_; @@ -959,9 +959,9 @@ PeerImp::onWriteMessage(error_code ec, std::size_t bytes_transferred) metrics_.sent.add_message(bytes_transferred); - XRPL_ASSERT( - "ripple::PeerImp::onWriteMessage : non-empty send buffer", - !send_queue_.empty()); + ASSERT( + !send_queue_.empty(), + "ripple::PeerImp::onWriteMessage : non-empty send buffer"); send_queue_.pop(); if (!send_queue_.empty()) { @@ -2015,18 +2015,18 @@ PeerImp::onValidatorListMessage( case ListDisposition::pending: { std::lock_guard sl(recentLock_); - XRPL_ASSERT( + ASSERT( + applyResult.publisherKey.has_value(), "ripple::PeerImp::onValidatorListMessage : publisher key is " - "set", - applyResult.publisherKey); + "set"); auto const& pubKey = *applyResult.publisherKey; #ifndef NDEBUG if (auto const iter = publisherListSequences_.find(pubKey); iter != publisherListSequences_.end()) { - XRPL_ASSERT( - "ripple::PeerImp::onValidatorListMessage : lower sequence", - iter->second < applyResult.sequence); + ASSERT( + iter->second < applyResult.sequence, + "ripple::PeerImp::onValidatorListMessage : lower sequence"); } #endif publisherListSequences_[pubKey] = applyResult.sequence; @@ -2037,14 +2037,14 @@ PeerImp::onValidatorListMessage( #ifndef NDEBUG { std::lock_guard sl(recentLock_); - XRPL_ASSERT( + ASSERT( + applyResult.sequence && applyResult.publisherKey, "ripple::PeerImp::onValidatorListMessage : nonzero sequence " - "and set publisher key", - applyResult.sequence && applyResult.publisherKey); - XRPL_ASSERT( - "ripple::PeerImp::onValidatorListMessage : maximum sequence", + "and set publisher key"); + ASSERT( publisherListSequences_[*applyResult.publisherKey] <= - applyResult.sequence); + applyResult.sequence, + "ripple::PeerImp::onValidatorListMessage : maximum sequence"); } #endif // !NDEBUG @@ -2055,7 +2055,7 @@ PeerImp::onValidatorListMessage( case ListDisposition::unsupported_version: break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::PeerImp::onValidatorListMessage : invalid best list " "disposition"); } @@ -2096,7 +2096,7 @@ PeerImp::onValidatorListMessage( fee_ = Resource::feeBadData; break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::PeerImp::onValidatorListMessage : invalid worst list " "disposition"); } @@ -2156,7 +2156,7 @@ PeerImp::onValidatorListMessage( << "(s) from peer " << remote_address_; break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::PeerImp::onValidatorListMessage : invalid list " "disposition"); } @@ -2833,7 +2833,8 @@ PeerImp::checkPropose( JLOG(p_journal_.trace()) << "Checking " << (isTrusted ? "trusted" : "UNTRUSTED") << " proposal"; - XRPL_ASSERT("ripple::PeerImp::checkPropose : non-null packet", packet); + ASSERT( + packet != nullptr, "ripple::PeerImp::checkPropose : non-null packet"); if (!cluster() && !peerPos.checkSign()) { diff --git a/src/xrpld/overlay/detail/ProtocolMessage.h b/src/xrpld/overlay/detail/ProtocolMessage.h index 4d6c7c6dc12..b1e871437f3 100644 --- a/src/xrpld/overlay/detail/ProtocolMessage.h +++ b/src/xrpld/overlay/detail/ProtocolMessage.h @@ -175,9 +175,9 @@ parseMessageHeader( MessageHeader hdr; auto iter = buffersBegin(bufs); - XRPL_ASSERT( - "ripple::detail::parseMessageHeader : non-empty buffer", - iter != buffersEnd(bufs)); + ASSERT( + iter != buffersEnd(bufs), + "ripple::detail::parseMessageHeader : non-empty buffer"); // Check valid header compressed message: // - 4 bits are the compression algorithm, 1st bit is always set to 1 diff --git a/src/xrpld/overlay/detail/TrafficCount.h b/src/xrpld/overlay/detail/TrafficCount.h index c3c10d48ae9..754e2872b18 100644 --- a/src/xrpld/overlay/detail/TrafficCount.h +++ b/src/xrpld/overlay/detail/TrafficCount.h @@ -172,9 +172,9 @@ class TrafficCount void addCount(category cat, bool inbound, int bytes) { - XRPL_ASSERT( - "ripple::TrafficCount::addCount : valid category input", - cat <= category::unknown); + ASSERT( + cat <= category::unknown, + "ripple::TrafficCount::addCount : valid category input"); if (inbound) { diff --git a/src/xrpld/overlay/detail/ZeroCopyStream.h b/src/xrpld/overlay/detail/ZeroCopyStream.h index 54bc267e42e..44d8100952e 100644 --- a/src/xrpld/overlay/detail/ZeroCopyStream.h +++ b/src/xrpld/overlay/detail/ZeroCopyStream.h @@ -206,8 +206,8 @@ template void ZeroCopyOutputStream::BackUp(int count) { - XRPL_ASSERT( - "ripple::ZeroCopyOutputStream::BackUp : valid input", count <= commit_); + ASSERT( + count <= commit_, "ripple::ZeroCopyOutputStream::BackUp : valid input"); auto const n = commit_ - count; streambuf_.commit(n); count_ += n; diff --git a/src/xrpld/peerfinder/detail/Bootcache.cpp b/src/xrpld/peerfinder/detail/Bootcache.cpp index d6aa6ad1834..88fa4c6221a 100644 --- a/src/xrpld/peerfinder/detail/Bootcache.cpp +++ b/src/xrpld/peerfinder/detail/Bootcache.cpp @@ -159,9 +159,9 @@ Bootcache::on_success(beast::IP::Endpoint const& endpoint) ++entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - XRPL_ASSERT( - "ripple:PeerFinder::Bootcache::on_success : endpoint inserted", - result.second); + ASSERT( + result.second, + "ripple:PeerFinder::Bootcache::on_success : endpoint inserted"); } Entry const& entry(result.first->right); JLOG(m_journal.info()) << beast::leftw(18) << "Bootcache connect " @@ -187,9 +187,9 @@ Bootcache::on_failure(beast::IP::Endpoint const& endpoint) --entry.valence(); m_map.erase(result.first); result = m_map.insert(value_type(endpoint, entry)); - XRPL_ASSERT( - "ripple:PeerFinder::Bootcache::on_failure : endpoint inserted", - result.second); + ASSERT( + result.second, + "ripple:PeerFinder::Bootcache::on_failure : endpoint inserted"); } Entry const& entry(result.first->right); auto const n(std::abs(entry.valence())); diff --git a/src/xrpld/peerfinder/detail/Counts.h b/src/xrpld/peerfinder/detail/Counts.h index bf619c5193d..d18aa858567 100644 --- a/src/xrpld/peerfinder/detail/Counts.h +++ b/src/xrpld/peerfinder/detail/Counts.h @@ -71,9 +71,9 @@ class Counts can_activate(Slot const& s) const { // Must be handshaked and in the right state - XRPL_ASSERT( - "ripple::PeerFinder::Counts::can_activate : valid input state", - s.state() == Slot::connected || s.state() == Slot::accept); + ASSERT( + s.state() == Slot::connected || s.state() == Slot::accept, + "ripple::PeerFinder::Counts::can_activate : valid input state"); if (s.fixed() || s.reserved()) return true; @@ -264,17 +264,18 @@ class Counts switch (s.state()) { case Slot::accept: - XRPL_ASSERT( - "ripple::PeerFinder::Counts::adjust : input is inbound", - s.inbound()); + ASSERT( + s.inbound(), + "ripple::PeerFinder::Counts::adjust : input is inbound"); m_acceptCount += n; break; case Slot::connect: case Slot::connected: - XRPL_ASSERT( - "ripple::PeerFinder::Counts::adjust : input is not inbound", - !s.inbound()); + ASSERT( + !s.inbound(), + "ripple::PeerFinder::Counts::adjust : input is not " + "inbound"); m_attempts += n; break; @@ -296,7 +297,7 @@ class Counts break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::PeerFinder::Counts::adjust : invalid input state"); break; }; diff --git a/src/xrpld/peerfinder/detail/Handouts.h b/src/xrpld/peerfinder/detail/Handouts.h index bb8b5bb8dc5..aa397d79c6e 100644 --- a/src/xrpld/peerfinder/detail/Handouts.h +++ b/src/xrpld/peerfinder/detail/Handouts.h @@ -43,9 +43,9 @@ template std::size_t handout_one(Target& t, HopContainer& h) { - XRPL_ASSERT( - "ripple::PeerFinder::detail::handout_one : target is not full", - !t.full()); + ASSERT( + !t.full(), + "ripple::PeerFinder::detail::handout_one : target is not full"); for (auto it = h.begin(); it != h.end(); ++it) { auto const& e = *it; diff --git a/src/xrpld/peerfinder/detail/Livecache.h b/src/xrpld/peerfinder/detail/Livecache.h index c4dd163c34c..bf1aca2eb9d 100644 --- a/src/xrpld/peerfinder/detail/Livecache.h +++ b/src/xrpld/peerfinder/detail/Livecache.h @@ -432,9 +432,9 @@ Livecache::insert(Endpoint const& ep) // but we will use it to make connections and hand it out // when redirecting. // - XRPL_ASSERT( - "ripple::PeerFinder::Livecache::insert : maximum input hops", - ep.hops <= (Tuning::maxHops + 1)); + ASSERT( + ep.hops <= (Tuning::maxHops + 1), + "ripple::PeerFinder::Livecache::insert : maximum input hops"); auto result = m_cache.emplace(ep.address, ep); Element& e(result.first->second); if (result.second) @@ -532,9 +532,9 @@ template void Livecache::hops_t::insert(Element& e) { - XRPL_ASSERT( - "ripple::PeerFinder::Livecache::hops_t::insert : maximum input hops", - e.endpoint.hops <= Tuning::maxHops + 1); + ASSERT( + e.endpoint.hops <= Tuning::maxHops + 1, + "ripple::PeerFinder::Livecache::hops_t::insert : maximum input hops"); // This has security implications without a shuffle m_lists[e.endpoint.hops].push_front(e); ++m_hist[e.endpoint.hops]; @@ -544,9 +544,9 @@ template void Livecache::hops_t::reinsert(Element& e, std::uint32_t numHops) { - XRPL_ASSERT( - "ripple::PeerFinder::Livecache::hops_t::reinsert : maximum hops input", - numHops <= Tuning::maxHops + 1); + ASSERT( + numHops <= Tuning::maxHops + 1, + "ripple::PeerFinder::Livecache::hops_t::reinsert : maximum hops input"); auto& list = m_lists[e.endpoint.hops]; list.erase(list.iterator_to(e)); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index 8296534eda4..9d43325755b 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -304,10 +304,10 @@ class Logic // Add slot to table auto const result(slots_.emplace(slot->remote_endpoint(), slot)); // Remote address must not already exist - XRPL_ASSERT( + ASSERT( + result.second, "ripple::PeerFinder::Logic::new_inbound_slot : remote endpoint " - "inserted", - result.second); + "inserted"); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -342,10 +342,10 @@ class Logic // Add slot to table auto const result = slots_.emplace(slot->remote_endpoint(), slot); // Remote address must not already exist - XRPL_ASSERT( + ASSERT( + result.second, "ripple::PeerFinder::Logic::new_outbound_slot : remote endpoint " - "inserted", - result.second); + "inserted"); // Add to the connected address list connectedAddresses_.emplace(remote_endpoint.address()); @@ -368,9 +368,9 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT( - "ripple::PeerFinder::Logic::onConnected : valid slot input", - slots_.find(slot->remote_endpoint()) != slots_.end()); + ASSERT( + slots_.find(slot->remote_endpoint()) != slots_.end(), + "ripple::PeerFinder::Logic::onConnected : valid slot input"); // Assign the local endpoint now that it's known slot->local_endpoint(local_endpoint); @@ -379,10 +379,10 @@ class Logic auto const iter(slots_.find(local_endpoint)); if (iter != slots_.end()) { - XRPL_ASSERT( + ASSERT( + iter->second->local_endpoint() == slot->remote_endpoint(), "ripple::PeerFinder::Logic::onConnected : local and remote " - "endpoints do match", - iter->second->local_endpoint() == slot->remote_endpoint()); + "endpoints do match"); JLOG(m_journal.warn()) << beast::leftw(18) << "Logic dropping " << slot->remote_endpoint() << " as self connect"; @@ -407,13 +407,13 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT( - "ripple::PeerFinder::Logic::activate : valid slot input", - slots_.find(slot->remote_endpoint()) != slots_.end()); + ASSERT( + slots_.find(slot->remote_endpoint()) != slots_.end(), + "ripple::PeerFinder::Logic::activate : valid slot input"); // Must be accepted or connected - XRPL_ASSERT( - "ripple::PeerFinder::Logic::activate : valid slot state", - slot->state() == Slot::accept || slot->state() == Slot::connected); + ASSERT( + slot->state() == Slot::accept || slot->state() == Slot::connected, + "ripple::PeerFinder::Logic::activate : valid slot state"); // Check for duplicate connection by key if (keys_.find(key) != keys_.end()) @@ -439,9 +439,9 @@ class Logic { [[maybe_unused]] bool const inserted = keys_.insert(key).second; // Public key must not already exist - XRPL_ASSERT( - "ripple::PeerFinder::Logic::activate : public key inserted", - inserted); + ASSERT( + inserted, + "ripple::PeerFinder::Logic::activate : public key inserted"); } // Change state and update counts @@ -803,14 +803,14 @@ class Logic std::lock_guard _(lock_); // The object must exist in our table - XRPL_ASSERT( - "ripple::PeerFinder::Logic::on_endpoints : valid slot input", - slots_.find(slot->remote_endpoint()) != slots_.end()); + ASSERT( + slots_.find(slot->remote_endpoint()) != slots_.end(), + "ripple::PeerFinder::Logic::on_endpoints : valid slot input"); // Must be handshaked! - XRPL_ASSERT( - "ripple::PeerFinder::Logic::on_endpoints : valid slot state", - slot->state() == Slot::active); + ASSERT( + slot->state() == Slot::active, + "ripple::PeerFinder::Logic::on_endpoints : valid slot state"); clock_type::time_point const now(m_clock.now()); @@ -822,9 +822,9 @@ class Logic for (auto const& ep : list) { - XRPL_ASSERT( - "ripple::PeerFinder::Logic::on_endpoints : nonzero hops", - ep.hops != 0); + ASSERT( + ep.hops != 0, + "ripple::PeerFinder::Logic::on_endpoints : nonzero hops"); slot->recent.insert(ep.address, ep.hops); @@ -977,7 +977,7 @@ class Logic break; default: - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::PeerFinder::Logic::on_closed : invalid slot " "state"); break; diff --git a/src/xrpld/peerfinder/detail/SlotImp.cpp b/src/xrpld/peerfinder/detail/SlotImp.cpp index d0a6ebf740b..4cc3e577d66 100644 --- a/src/xrpld/peerfinder/detail/SlotImp.cpp +++ b/src/xrpld/peerfinder/detail/SlotImp.cpp @@ -64,32 +64,32 @@ void SlotImp::state(State state_) { // Must go through activate() to set active state - XRPL_ASSERT( - "ripple::PeerFinder::SlotImp::state : input state is not active", - state_ != active); + ASSERT( + state_ != active, + "ripple::PeerFinder::SlotImp::state : input state is not active"); // The state must be different - XRPL_ASSERT( + ASSERT( + state_ != m_state, "ripple::PeerFinder::SlotImp::state : input state is different from " - "current", - state_ != m_state); + "current"); // You can't transition into the initial states - XRPL_ASSERT( - "ripple::PeerFinder::SlotImp::state : input state is not an initial", - state_ != accept && state_ != connect); + ASSERT( + state_ != accept && state_ != connect, + "ripple::PeerFinder::SlotImp::state : input state is not an initial"); // Can only become connected from outbound connect state - XRPL_ASSERT( + ASSERT( + state_ != connected || (!m_inbound && m_state == connect), "ripple::PeerFinder::SlotImp::state : input state is not connected an " - "invalid state", - state_ != connected || (!m_inbound && m_state == connect)); + "invalid state"); // Can't gracefully close on an outbound connection attempt - XRPL_ASSERT( + ASSERT( + state_ != closing || m_state != connect, "ripple::PeerFinder::SlotImp::state : input state is not closing an " - "invalid state", - state_ != closing || m_state != connect); + "invalid state"); m_state = state_; } @@ -98,9 +98,9 @@ void SlotImp::activate(clock_type::time_point const& now) { // Can only become active from the accept or connected state - XRPL_ASSERT( - "ripple::PeerFinder::SlotImp::activate : valid state", - m_state == accept || m_state == connected); + ASSERT( + m_state == accept || m_state == connected, + "ripple::PeerFinder::SlotImp::activate : valid state"); m_state = active; whenAcceptEndpoints = now; diff --git a/src/xrpld/perflog/detail/PerfLogImp.cpp b/src/xrpld/perflog/detail/PerfLogImp.cpp index bd8f7ec9327..559bdb1743c 100644 --- a/src/xrpld/perflog/detail/PerfLogImp.cpp +++ b/src/xrpld/perflog/detail/PerfLogImp.cpp @@ -54,7 +54,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::Counters::Counters : failed to " "insert label"); } @@ -69,7 +69,7 @@ PerfLogImp::Counters::Counters( if (!inserted) { // Ensure that no other function populates this entry. - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::Counters::Counters : failed to " "insert job type"); } @@ -330,8 +330,7 @@ PerfLogImp::rpcStart(std::string const& method, std::uint64_t const requestId) auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - XRPL_UNREACHABLE( - "ripple::perf::PerfLogImp::rpcStart : valid method input"); + UNREACHABLE("ripple::perf::PerfLogImp::rpcStart : valid method input"); return; } @@ -353,8 +352,7 @@ PerfLogImp::rpcEnd( auto counter = counters_.rpc_.find(method); if (counter == counters_.rpc_.end()) { - XRPL_UNREACHABLE( - "ripple::perf::PerfLogImp::rpcEnd : valid method input"); + UNREACHABLE("ripple::perf::PerfLogImp::rpcEnd : valid method input"); return; } steady_time_point startTime; @@ -368,7 +366,7 @@ PerfLogImp::rpcEnd( } else { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::rpcEnd : valid requestId input"); } } @@ -387,7 +385,7 @@ PerfLogImp::jobQueue(JobType const type) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::jobQueue : valid job type input"); return; } @@ -405,7 +403,7 @@ PerfLogImp::jobStart( auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::jobStart : valid job type input"); return; } @@ -425,7 +423,7 @@ PerfLogImp::jobFinish(JobType const type, microseconds dur, int instance) auto counter = counters_.jq_.find(type); if (counter == counters_.jq_.end()) { - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::perf::PerfLogImp::jobFinish : valid job type input"); return; } diff --git a/src/xrpld/rpc/Status.h b/src/xrpld/rpc/Status.h index c5b157940b5..34ca69e9576 100644 --- a/src/xrpld/rpc/Status.h +++ b/src/xrpld/rpc/Status.h @@ -95,8 +95,7 @@ struct Status : public std::exception TER toTER() const { - XRPL_ASSERT( - "ripple::RPC::Status::toTER : type is TER", type_ == Type::TER); + ASSERT(type_ == Type::TER, "ripple::RPC::Status::toTER : type is TER"); return TER::fromInt(code_); } @@ -105,9 +104,9 @@ struct Status : public std::exception error_code_i toErrorCode() const { - XRPL_ASSERT( - "ripple::RPC::Status::toTER : type is error code", - type_ == Type::error_code_i); + ASSERT( + type_ == Type::error_code_i, + "ripple::RPC::Status::toTER : type is error code"); return error_code_i(code_); } diff --git a/src/xrpld/rpc/detail/Handler.cpp b/src/xrpld/rpc/detail/Handler.cpp index 0da8c01c970..f303f657172 100644 --- a/src/xrpld/rpc/detail/Handler.cpp +++ b/src/xrpld/rpc/detail/Handler.cpp @@ -38,7 +38,7 @@ byRef(Function const& f) result = f(context); if (result.type() != Json::objectValue) { - XRPL_UNREACHABLE("ripple::RPC::byRef : result is object"); + UNREACHABLE("ripple::RPC::byRef : result is object"); result = RPC::makeObjectValue(result); } @@ -50,10 +50,10 @@ template Status handle(JsonContext& context, Object& object) { - XRPL_ASSERT( - "ripple::RPC::handle : valid API version", + ASSERT( context.apiVersion >= HandlerImpl::minApiVer && - context.apiVersion <= HandlerImpl::maxApiVer); + context.apiVersion <= HandlerImpl::maxApiVer, + "ripple::RPC::handle : valid API version"); HandlerImpl handler(context); auto status = handler.check(); @@ -205,12 +205,12 @@ class HandlerTable unsigned minVer, unsigned maxVer) { - XRPL_ASSERT( - "ripple::RPC::HandlerTable : valid API version range", - minVer <= maxVer); - XRPL_ASSERT( - "ripple::RPC::HandlerTable : valid max API version", - maxVer <= RPC::apiMaximumValidVersion); + ASSERT( + minVer <= maxVer, + "ripple::RPC::HandlerTable : valid API version range"); + ASSERT( + maxVer <= RPC::apiMaximumValidVersion, + "ripple::RPC::HandlerTable : valid max API version"); return std::any_of( range.first, diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index f58cc162a4a..be91aea6f4a 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -528,22 +528,21 @@ getLedger(T& ledger, LedgerShortcut shortcut, Context& context) return {rpcNOT_SYNCED, "notSynced"}; } - XRPL_ASSERT( - "ripple::RPC::getLedger : validated is not open", !ledger->open()); + ASSERT( + !ledger->open(), "ripple::RPC::getLedger : validated is not open"); } else { if (shortcut == LedgerShortcut::CURRENT) { ledger = context.ledgerMaster.getCurrentLedger(); - XRPL_ASSERT( - "ripple::RPC::getLedger : current is open", ledger->open()); + ASSERT(ledger->open(), "ripple::RPC::getLedger : current is open"); } else if (shortcut == LedgerShortcut::CLOSED) { ledger = context.ledgerMaster.getClosedLedger(); - XRPL_ASSERT( - "ripple::RPC::getLedger : closed is not open", !ledger->open()); + ASSERT( + !ledger->open(), "ripple::RPC::getLedger : closed is not open"); } else { @@ -949,9 +948,9 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{ rpcINVALID_PARAMS, "Invalid field 'type', not string."}; - XRPL_ASSERT( - "ripple::RPC::chooseLedgerEntryType : first valid result type", - result.first.type() == RPC::Status::Type::error_code_i); + ASSERT( + result.first.type() == RPC::Status::Type::error_code_i, + "ripple::RPC::chooseLedgerEntryType : first valid result type"); return result; } @@ -964,9 +963,10 @@ chooseLedgerEntryType(Json::Value const& params) { result.first = RPC::Status{rpcINVALID_PARAMS, "Invalid field 'type'."}; - XRPL_ASSERT( - "ripple::RPC::chooseLedgerEntryType : second valid result type", - result.first.type() == RPC::Status::Type::error_code_i); + ASSERT( + result.first.type() == RPC::Status::Type::error_code_i, + "ripple::RPC::chooseLedgerEntryType : second valid result " + "type"); return result; } result.second = iter->second; @@ -1072,9 +1072,9 @@ getLedgerByContext(RPC::JsonContext& context) // ledger auto const refIndex = getCandidateLedger(ledgerIndex); auto refHash = hashOfSeq(*ledger, refIndex, j); - XRPL_ASSERT( - "ripple::RPC::getLedgerByContext : nonzero ledger hash", - refHash); + ASSERT( + refHash.has_value(), + "ripple::RPC::getLedgerByContext : nonzero ledger hash"); ledger = ledgerMaster.getLedgerByHash(*refHash); if (!ledger) @@ -1108,9 +1108,9 @@ getLedgerByContext(RPC::JsonContext& context) neededHash = hashOfSeq(*ledger, ledgerIndex, j); } - XRPL_ASSERT( - "ripple::RPC::getLedgerByContext : nonzero needed hash", - neededHash); + ASSERT( + neededHash.has_value(), + "ripple::RPC::getLedgerByContext : nonzero needed hash"); ledgerHash = neededHash ? *neededHash : beast::zero; // kludge } diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index 41d20273f11..80ab9d6a5ec 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -213,9 +213,9 @@ template void setVersion(Object& parent, unsigned int apiVersion, bool betaEnabled) { - XRPL_ASSERT( - "ripple::RPC::setVersion : input is valid", - apiVersion != apiInvalidVersion); + ASSERT( + apiVersion != apiInvalidVersion, + "ripple::RPC::setVersion : input is valid"); auto&& object = addObject(parent, jss::version); if (apiVersion == apiVersionIfUnspecified) { diff --git a/src/xrpld/rpc/detail/Role.cpp b/src/xrpld/rpc/detail/Role.cpp index e1d17fedb31..739c8f58012 100644 --- a/src/xrpld/rpc/detail/Role.cpp +++ b/src/xrpld/rpc/detail/Role.cpp @@ -28,9 +28,9 @@ namespace ripple { bool passwordUnrequiredOrSentCorrect(Port const& port, Json::Value const& params) { - XRPL_ASSERT( - "ripple::passwordUnrequiredOrSentCorrect : non-empty admin nets", - !(port.admin_nets_v4.empty() && port.admin_nets_v6.empty())); + ASSERT( + !(port.admin_nets_v4.empty() && port.admin_nets_v6.empty()), + "ripple::passwordUnrequiredOrSentCorrect : non-empty admin nets"); bool const passwordRequired = (!port.admin_user.empty() || !port.admin_password.empty()); diff --git a/src/xrpld/rpc/detail/Status.cpp b/src/xrpld/rpc/detail/Status.cpp index c532923949a..1773d3bc949 100644 --- a/src/xrpld/rpc/detail/Status.cpp +++ b/src/xrpld/rpc/detail/Status.cpp @@ -36,9 +36,8 @@ Status::codeString() const { std::string s1, s2; - auto success = transResultInfo(toTER(), s1, s2); - XRPL_ASSERT("ripple::RPC::codeString : valid TER result", success); - (void)success; + [[maybe_unused]] auto const success = transResultInfo(toTER(), s1, s2); + ASSERT(success, "ripple::RPC::codeString : valid TER result"); return s1 + ": " + s2; } @@ -51,7 +50,7 @@ Status::codeString() const return sStr.str(); } - XRPL_UNREACHABLE("ripple::RPC::codeString : invalid type"); + UNREACHABLE("ripple::RPC::codeString : invalid type"); return ""; } diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index b6bc41d1341..3539304a182 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -1030,9 +1030,9 @@ transactionSignFor( if (!preprocResult.second) return preprocResult.first; - XRPL_ASSERT( - "ripple::RPC::transactionSignFor : valid multi-signature", - signForParams.validMultiSign()); + ASSERT( + signForParams.validMultiSign(), + "ripple::RPC::transactionSignFor : valid multi-signature"); { std::shared_ptr account_state = diff --git a/src/xrpld/rpc/handlers/AMMInfo.cpp b/src/xrpld/rpc/handlers/AMMInfo.cpp index 3ef0be85226..cb4e169a083 100644 --- a/src/xrpld/rpc/handlers/AMMInfo.cpp +++ b/src/xrpld/rpc/handlers/AMMInfo.cpp @@ -145,15 +145,17 @@ doAMMInfo(RPC::JsonContext& context) if (context.apiVersion >= 3 && invalid(params)) return Unexpected(rpcINVALID_PARAMS); - XRPL_ASSERT( - "ripple::doAMMInfo : issue1 and issue2 do match", + ASSERT( (issue1.has_value() == issue2.has_value()) && - (issue1.has_value() != ammID.has_value())); + (issue1.has_value() != ammID.has_value()), + "ripple::doAMMInfo : issue1 and issue2 do match"); auto const ammKeylet = [&]() { if (issue1 && issue2) return keylet::amm(*issue1, *issue2); - XRPL_ASSERT("ripple::doAMMInfo::ammKeylet : ammID is set", ammID); + ASSERT( + ammID.has_value(), + "ripple::doAMMInfo::ammKeylet : ammID is set"); return keylet::amm(*ammID); }(); auto const amm = ledger->read(ammKeylet); @@ -212,10 +214,10 @@ doAMMInfo(RPC::JsonContext& context) } if (voteSlots.size() > 0) ammResult[jss::vote_slots] = std::move(voteSlots); - XRPL_ASSERT( - "ripple::doAMMInfo : auction slot is set", + ASSERT( !ledger->rules().enabled(fixInnerObjTemplate) || - amm->isFieldPresent(sfAuctionSlot)); + amm->isFieldPresent(sfAuctionSlot), + "ripple::doAMMInfo : auction slot is set"); if (amm->isFieldPresent(sfAuctionSlot)) { auto const& auctionSlot = diff --git a/src/xrpld/rpc/handlers/AccountChannels.cpp b/src/xrpld/rpc/handlers/AccountChannels.cpp index 2f5450cdd4c..4b9ff7e43c5 100644 --- a/src/xrpld/rpc/handlers/AccountChannels.cpp +++ b/src/xrpld/rpc/handlers/AccountChannels.cpp @@ -169,7 +169,7 @@ doAccountChannels(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - XRPL_UNREACHABLE("ripple::doAccountChannels : null SLE"); + UNREACHABLE("ripple::doAccountChannels : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountInfo.cpp b/src/xrpld/rpc/handlers/AccountInfo.cpp index e8a012f1d41..4f62eb5880a 100644 --- a/src/xrpld/rpc/handlers/AccountInfo.cpp +++ b/src/xrpld/rpc/handlers/AccountInfo.cpp @@ -214,9 +214,9 @@ doAccountInfo(RPC::JsonContext& context) if (tx.seqProxy.isSeq()) { - XRPL_ASSERT( - "rpple::doAccountInfo : first sorted proxy", - prevSeqProxy < tx.seqProxy); + ASSERT( + prevSeqProxy < tx.seqProxy, + "rpple::doAccountInfo : first sorted proxy"); prevSeqProxy = tx.seqProxy; jvTx[jss::seq] = tx.seqProxy.value(); ++seqCount; @@ -226,9 +226,9 @@ doAccountInfo(RPC::JsonContext& context) } else { - XRPL_ASSERT( - "rpple::doAccountInfo : second sorted proxy", - prevSeqProxy < tx.seqProxy); + ASSERT( + prevSeqProxy < tx.seqProxy, + "rpple::doAccountInfo : second sorted proxy"); prevSeqProxy = tx.seqProxy; jvTx[jss::ticket] = tx.seqProxy.value(); ++ticketCount; diff --git a/src/xrpld/rpc/handlers/AccountLines.cpp b/src/xrpld/rpc/handlers/AccountLines.cpp index b9f30b28cb4..e2e6ce19ded 100644 --- a/src/xrpld/rpc/handlers/AccountLines.cpp +++ b/src/xrpld/rpc/handlers/AccountLines.cpp @@ -189,7 +189,7 @@ doAccountLines(RPC::JsonContext& context) std::shared_ptr const& sleCur) { if (!sleCur) { - XRPL_UNREACHABLE("ripple::doAccountLines : null SLE"); + UNREACHABLE("ripple::doAccountLines : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountOffers.cpp b/src/xrpld/rpc/handlers/AccountOffers.cpp index 87d226bf529..86559a79f4f 100644 --- a/src/xrpld/rpc/handlers/AccountOffers.cpp +++ b/src/xrpld/rpc/handlers/AccountOffers.cpp @@ -145,7 +145,7 @@ doAccountOffers(RPC::JsonContext& context) std::shared_ptr const& sle) { if (!sle) { - XRPL_UNREACHABLE("ripple::doAccountOffers : null SLE"); + UNREACHABLE("ripple::doAccountOffers : null SLE"); return false; } diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/AccountTx.cpp index 8dbbda1d916..c721d1ebd5d 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/AccountTx.cpp @@ -306,9 +306,9 @@ populateJsonResponse( if (auto txnsData = std::get_if(&result.transactions)) { - XRPL_ASSERT( - "ripple::populateJsonResponse : binary is not set", - !args.binary); + ASSERT( + !args.binary, + "ripple::populateJsonResponse : binary is not set"); for (auto const& [txn, txnMeta] : *txnsData) { @@ -353,7 +353,7 @@ populateJsonResponse( insertNFTSyntheticInJson(jvObj, sttx, *txnMeta); } else - XRPL_UNREACHABLE( + UNREACHABLE( "ripple::populateJsonResponse : missing " "transaction medatata"); } @@ -361,8 +361,7 @@ populateJsonResponse( } else { - XRPL_ASSERT( - "ripple::populateJsonResponse : binary is set", args.binary); + ASSERT(args.binary, "ripple::populateJsonResponse : binary is set"); for (auto const& binaryData : std::get(result.transactions)) diff --git a/src/xrpld/rpc/handlers/Fee1.cpp b/src/xrpld/rpc/handlers/Fee1.cpp index 7c5ab4dc27f..de5bdc4f6ca 100644 --- a/src/xrpld/rpc/handlers/Fee1.cpp +++ b/src/xrpld/rpc/handlers/Fee1.cpp @@ -32,7 +32,7 @@ doFee(RPC::JsonContext& context) auto result = context.app.getTxQ().doRPC(context.app); if (result.type() == Json::objectValue) return result; - XRPL_UNREACHABLE("ripple::doFee : invalid result type"); + UNREACHABLE("ripple::doFee : invalid result type"); RPC::inject_error(rpcINTERNAL, context.params); return context.params; } diff --git a/src/xrpld/rpc/handlers/LedgerClosed.cpp b/src/xrpld/rpc/handlers/LedgerClosed.cpp index 4a289e004df..759f4aecd33 100644 --- a/src/xrpld/rpc/handlers/LedgerClosed.cpp +++ b/src/xrpld/rpc/handlers/LedgerClosed.cpp @@ -29,7 +29,8 @@ Json::Value doLedgerClosed(RPC::JsonContext& context) { auto ledger = context.ledgerMaster.getClosedLedger(); - XRPL_ASSERT("ripple::doLedgerClosed : non-null closed ledger", ledger); + ASSERT( + ledger != nullptr, "ripple::doLedgerClosed : non-null closed ledger"); Json::Value jvResult; jvResult[jss::ledger_index] = ledger->info().seq; diff --git a/src/xrpld/rpc/handlers/LedgerDiff.cpp b/src/xrpld/rpc/handlers/LedgerDiff.cpp index 880d12ebce6..e562197f4af 100644 --- a/src/xrpld/rpc/handlers/LedgerDiff.cpp +++ b/src/xrpld/rpc/handlers/LedgerDiff.cpp @@ -73,9 +73,9 @@ doLedgerDiffGrpc( } else { - XRPL_ASSERT( - "ripple::doLedgerDiffGrpc : non-empty desired", - inDesired->size() > 0); + ASSERT( + inDesired->size() > 0, + "ripple::doLedgerDiffGrpc : non-empty desired"); diff->set_key(k.data(), k.size()); if (request.include_blobs()) { diff --git a/src/xrpld/rpc/handlers/LedgerHandler.cpp b/src/xrpld/rpc/handlers/LedgerHandler.cpp index a1a1af88d08..54f9a8b8459 100644 --- a/src/xrpld/rpc/handlers/LedgerHandler.cpp +++ b/src/xrpld/rpc/handlers/LedgerHandler.cpp @@ -135,8 +135,9 @@ doLedgerGrpc(RPC::GRPCContext& context) { for (auto& i : ledger->txs) { - XRPL_ASSERT( - "ripple::doLedgerGrpc : non-null transaction", i.first); + ASSERT( + i.first != nullptr, + "ripple::doLedgerGrpc : non-null transaction"); if (request.expand()) { auto txn = response.mutable_transactions_list() @@ -212,9 +213,9 @@ doLedgerGrpc(RPC::GRPCContext& context) obj->set_key(k.data(), k.size()); if (inDesired) { - XRPL_ASSERT( - "ripple::doLedgerGrpc : non-empty desired", - inDesired->size() > 0); + ASSERT( + inDesired->size() > 0, + "ripple::doLedgerGrpc : non-empty desired"); obj->set_data(inDesired->data(), inDesired->size()); } if (inBase && inDesired) diff --git a/src/xrpld/rpc/handlers/PayChanClaim.cpp b/src/xrpld/rpc/handlers/PayChanClaim.cpp index cffce8cbcf4..e55191877ef 100644 --- a/src/xrpld/rpc/handlers/PayChanClaim.cpp +++ b/src/xrpld/rpc/handlers/PayChanClaim.cpp @@ -58,9 +58,9 @@ doChannelAuthorize(RPC::JsonContext& context) std::optional> const keyPair = RPC::keypairForSignature(params, result, context.apiVersion); - XRPL_ASSERT( - "ripple::doChannelAuthorize : valid keyPair or an error", - keyPair || RPC::contains_error(result)); + ASSERT( + keyPair || RPC::contains_error(result), + "ripple::doChannelAuthorize : valid keyPair or an error"); if (!keyPair || RPC::contains_error(result)) return result; diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index 056e8cba83a..b6d83e580c9 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -250,8 +250,7 @@ populateJsonResponse( // populate binary metadata if (auto blob = std::get_if(&result.meta)) { - XRPL_ASSERT( - "ripple::populateJsonResponse : binary is set", args.binary); + ASSERT(args.binary, "ripple::populateJsonResponse : binary is set"); auto json_meta = (context.apiVersion > 1 ? jss::meta_blob : jss::meta); response[json_meta] = strHex(makeSlice(*blob)); diff --git a/src/xrpld/shamap/SHAMap.h b/src/xrpld/shamap/SHAMap.h index 5295d1ed0a2..cc9a8d9e6ae 100644 --- a/src/xrpld/shamap/SHAMap.h +++ b/src/xrpld/shamap/SHAMap.h @@ -599,9 +599,9 @@ SHAMap::setLedgerSeq(std::uint32_t lseq) inline void SHAMap::setImmutable() { - XRPL_ASSERT( - "ripple::SHAMap::setImmutable : state is valid", - state_ != SHAMapState::Invalid); + ASSERT( + state_ != SHAMapState::Invalid, + "ripple::SHAMap::setImmutable : state is valid"); state_ = SHAMapState::Immutable; } @@ -682,9 +682,9 @@ class SHAMap::const_iterator inline SHAMap::const_iterator::const_iterator(SHAMap const* map) : map_(map) { - XRPL_ASSERT( - "ripple::SHAMap::const_iterator::const_iterator : non-null input", - map_ != nullptr); + ASSERT( + map_ != nullptr, + "ripple::SHAMap::const_iterator::const_iterator : non-null input"); if (auto temp = map_->peekFirstItem(stack_)) item_ = temp->peekItem().get(); @@ -736,10 +736,10 @@ SHAMap::const_iterator::operator++(int) inline bool operator==(SHAMap::const_iterator const& x, SHAMap::const_iterator const& y) { - XRPL_ASSERT( + ASSERT( + x.map_ == y.map_, "ripple::operator==(SHAMap::const_iterator, SHAMap::const_iterator) : " - "inputs map do match", - x.map_ == y.map_); + "inputs map do match"); return x.item_ == y.item_; } diff --git a/src/xrpld/shamap/SHAMapItem.h b/src/xrpld/shamap/SHAMapItem.h index 8273c03b7d9..e49762a50b2 100644 --- a/src/xrpld/shamap/SHAMapItem.h +++ b/src/xrpld/shamap/SHAMapItem.h @@ -159,9 +159,9 @@ intrusive_ptr_release(SHAMapItem const* x) inline boost::intrusive_ptr make_shamapitem(uint256 const& tag, Slice data) { - XRPL_ASSERT( - "ripple::make_shamapitem : maximum input size", - data.size() <= megabytes(16)); + ASSERT( + data.size() <= megabytes(16), + "ripple::make_shamapitem : maximum input size"); std::uint8_t* raw = detail::slabber.allocate(data.size()); diff --git a/src/xrpld/shamap/detail/SHAMap.cpp b/src/xrpld/shamap/detail/SHAMap.cpp index 13da6504fcc..11cf079320f 100644 --- a/src/xrpld/shamap/detail/SHAMap.cpp +++ b/src/xrpld/shamap/detail/SHAMap.cpp @@ -101,13 +101,12 @@ SHAMap::dirtyUp( // stack is a path of inner nodes up to, but not including, child // child can be an inner node or a leaf - XRPL_ASSERT( - "ripple::SHAMap::dirtyUp : valid state", - (state_ != SHAMapState::Synching) && - (state_ != SHAMapState::Immutable)); - XRPL_ASSERT( - "ripple::SHAMap::dirtyUp : valid child input", - child && (child->cowid() == cowid_)); + ASSERT( + (state_ != SHAMapState::Synching) && (state_ != SHAMapState::Immutable), + "ripple::SHAMap::dirtyUp : valid state"); + ASSERT( + child && (child->cowid() == cowid_), + "ripple::SHAMap::dirtyUp : valid child input"); while (!stack.empty()) { @@ -115,10 +114,10 @@ SHAMap::dirtyUp( std::dynamic_pointer_cast(stack.top().first); SHAMapNodeID nodeID = stack.top().second; stack.pop(); - XRPL_ASSERT("ripple::SHAMap::dirtyUp : non-null node", node != nullptr); + ASSERT(node != nullptr, "ripple::SHAMap::dirtyUp : non-null node"); int branch = selectBranch(nodeID, target); - XRPL_ASSERT("ripple::SHAMap::dirtyUp : valid branch", branch >= 0); + ASSERT(branch >= 0, "ripple::SHAMap::dirtyUp : valid branch"); node = unshareNode(std::move(node), nodeID); node->setChild(branch, std::move(child)); @@ -130,9 +129,9 @@ SHAMap::dirtyUp( SHAMapLeafNode* SHAMap::walkTowardsKey(uint256 const& id, SharedPtrNodeStack* stack) const { - XRPL_ASSERT( - "ripple::SHAMap::walkTowardsKey : empty stack input", - stack == nullptr || stack->empty()); + ASSERT( + stack == nullptr || stack->empty(), + "ripple::SHAMap::walkTowardsKey : empty stack input"); auto inNode = root_; SHAMapNodeID nodeID; @@ -167,7 +166,7 @@ SHAMap::findKey(uint256 const& id) const std::shared_ptr SHAMap::fetchNodeFromDB(SHAMapHash const& hash) const { - XRPL_ASSERT("ripple::SHAMap::fetchNodeFromDB : is backed", backed_); + ASSERT(backed_, "ripple::SHAMap::fetchNodeFromDB : is backed"); auto obj = f_.db().fetchNodeObject(hash.as_uint256(), ledgerSeq_); return finishFetch(hash, obj); } @@ -177,7 +176,7 @@ SHAMap::finishFetch( SHAMapHash const& hash, std::shared_ptr const& object) const { - XRPL_ASSERT("ripple::SHAMap::finishFetch : is backed", backed_); + ASSERT(backed_, "ripple::SHAMap::finishFetch : is backed"); try { @@ -365,14 +364,13 @@ SHAMap::descend( int branch, SHAMapSyncFilter* filter) const { - XRPL_ASSERT( - "ripple::SHAMap::descend : valid parent input", parent->isInner()); - XRPL_ASSERT( - "ripple::SHAMap::descend : valid branch input", - (branch >= 0) && (branch < branchFactor)); - XRPL_ASSERT( - "ripple::SHAMap::descend : parent branch is non-empty", - !parent->isEmptyBranch(branch)); + ASSERT(parent->isInner(), "ripple::SHAMap::descend : valid parent input"); + ASSERT( + (branch >= 0) && (branch < branchFactor), + "ripple::SHAMap::descend : valid branch input"); + ASSERT( + !parent->isEmptyBranch(branch), + "ripple::SHAMap::descend : parent branch is non-empty"); SHAMapTreeNode* child = parent->getChildPointer(branch); @@ -440,15 +438,15 @@ std::shared_ptr SHAMap::unshareNode(std::shared_ptr node, SHAMapNodeID const& nodeID) { // make sure the node is suitable for the intended operation (copy on write) - XRPL_ASSERT( - "ripple::SHAMap::unshareNode : node valid for cowid", - node->cowid() <= cowid_); + ASSERT( + node->cowid() <= cowid_, + "ripple::SHAMap::unshareNode : node valid for cowid"); if (node->cowid() != cowid_) { // have a CoW - XRPL_ASSERT( - "ripple::SHAMap::unshareNode : not immutable", - state_ != SHAMapState::Immutable); + ASSERT( + state_ != SHAMapState::Immutable, + "ripple::SHAMap::unshareNode : not immutable"); node = std::static_pointer_cast(node->clone(cowid_)); if (nodeID.isRoot()) root_ = node; @@ -481,9 +479,9 @@ SHAMap::belowHelper( if (!inner->isEmptyBranch(i)) { node = descendThrow(inner, i); - XRPL_ASSERT( - "ripple::SHAMap::belowHelper : non-empty stack", - !stack.empty()); + ASSERT( + !stack.empty(), + "ripple::SHAMap::belowHelper : non-empty stack"); if (node->isLeaf()) { auto n = std::static_pointer_cast(node); @@ -547,7 +545,7 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const if (!nextNode) { - XRPL_UNREACHABLE("ripple::SHAMap::onlyBelow : no next node"); + UNREACHABLE("ripple::SHAMap::onlyBelow : no next node"); return no_item; } @@ -557,17 +555,16 @@ SHAMap::onlyBelow(SHAMapTreeNode* node) const // An inner node must have at least one leaf // below it, unless it's the root_ auto const leaf = static_cast(node); - XRPL_ASSERT( - "ripple::SHAMap::onlyBelow : valid inner node", - leaf->peekItem() || (leaf == root_.get())); + ASSERT( + leaf->peekItem() || (leaf == root_.get()), + "ripple::SHAMap::onlyBelow : valid inner node"); return leaf->peekItem(); } SHAMapLeafNode const* SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const { - XRPL_ASSERT( - "ripple::SHAMap::peekFirstItem : empty stack input", stack.empty()); + ASSERT(stack.empty(), "ripple::SHAMap::peekFirstItem : empty stack input"); SHAMapLeafNode* node = firstBelow(root_, stack); if (!node) { @@ -581,18 +578,18 @@ SHAMap::peekFirstItem(SharedPtrNodeStack& stack) const SHAMapLeafNode const* SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const { - XRPL_ASSERT( - "ripple::SHAMap::peekNextItem : non-empty stack input", !stack.empty()); - XRPL_ASSERT( - "ripple::SHAMap::peekNextItem : stack starts with leaf", - stack.top().first->isLeaf()); + ASSERT( + !stack.empty(), "ripple::SHAMap::peekNextItem : non-empty stack input"); + ASSERT( + stack.top().first->isLeaf(), + "ripple::SHAMap::peekNextItem : stack starts with leaf"); stack.pop(); while (!stack.empty()) { auto [node, nodeID] = stack.top(); - XRPL_ASSERT( - "ripple::SHAMap::peekNextItem : another node is not leaf", - !node->isLeaf()); + ASSERT( + !node->isLeaf(), + "ripple::SHAMap::peekNextItem : another node is not leaf"); auto inner = std::static_pointer_cast(node); for (auto i = selectBranch(nodeID, id) + 1; i < branchFactor; ++i) { @@ -602,9 +599,9 @@ SHAMap::peekNextItem(uint256 const& id, SharedPtrNodeStack& stack) const auto leaf = firstBelow(node, stack, i); if (!leaf) Throw(type_, id); - XRPL_ASSERT( - "ripple::SHAMap::peekNextItem : leaf is valid", - leaf->isLeaf()); + ASSERT( + leaf->isLeaf(), + "ripple::SHAMap::peekNextItem : leaf is valid"); return leaf; } } @@ -722,9 +719,9 @@ bool SHAMap::delItem(uint256 const& id) { // delete the item with this ID - XRPL_ASSERT( - "ripple::SHAMap::delItem : not immutable", - state_ != SHAMapState::Immutable); + ASSERT( + state_ != SHAMapState::Immutable, + "ripple::SHAMap::delItem : not immutable"); SharedPtrNodeStack stack; walkTowardsKey(id, &stack); @@ -803,12 +800,12 @@ SHAMap::addGiveItem( SHAMapNodeType type, boost::intrusive_ptr item) { - XRPL_ASSERT( - "ripple::SHAMap::addGiveItem : not immutable", - state_ != SHAMapState::Immutable); - XRPL_ASSERT( - "ripple::SHAMap::addGiveItem : valid type input", - type != SHAMapNodeType::tnINNER); + ASSERT( + state_ != SHAMapState::Immutable, + "ripple::SHAMap::addGiveItem : not immutable"); + ASSERT( + type != SHAMapNodeType::tnINNER, + "ripple::SHAMap::addGiveItem : valid type input"); // add the specified item, does not update uint256 tag = item->key(); @@ -834,9 +831,9 @@ SHAMap::addGiveItem( // easy case, we end on an inner node auto inner = std::static_pointer_cast(node); int branch = selectBranch(nodeID, tag); - XRPL_ASSERT( - "ripple::SHAMap::addGiveItem : inner branch is empty", - inner->isEmptyBranch(branch)); + ASSERT( + inner->isEmptyBranch(branch), + "ripple::SHAMap::addGiveItem : inner branch is empty"); inner->setChild(branch, makeTypedLeaf(type, std::move(item), cowid_)); } else @@ -845,9 +842,9 @@ SHAMap::addGiveItem( // items auto leaf = std::static_pointer_cast(node); auto otherItem = leaf->peekItem(); - XRPL_ASSERT( - "ripple::SHAMap::addGiveItem : non-null item", - otherItem && (tag != otherItem->key())); + ASSERT( + otherItem && (tag != otherItem->key()), + "ripple::SHAMap::addGiveItem : non-null item"); node = std::make_shared(node->cowid()); @@ -865,8 +862,7 @@ SHAMap::addGiveItem( } // we can add the two leaf nodes here - XRPL_ASSERT( - "ripple::SHAMap::addGiveItem : node is inner", node->isInner()); + ASSERT(node->isInner(), "ripple::SHAMap::addGiveItem : node is inner"); auto inner = static_cast(node.get()); inner->setChild(b1, makeTypedLeaf(type, std::move(item), cowid_)); @@ -905,9 +901,9 @@ SHAMap::updateGiveItem( // can't change the tag but can change the hash uint256 tag = item->key(); - XRPL_ASSERT( - "ripple::SHAMap::updateGiveItem : not immutable", - state_ != SHAMapState::Immutable); + ASSERT( + state_ != SHAMapState::Immutable, + "ripple::SHAMap::updateGiveItem : not immutable"); SharedPtrNodeStack stack; walkTowardsKey(tag, &stack); @@ -921,7 +917,7 @@ SHAMap::updateGiveItem( if (!node || (node->peekItem()->key() != tag)) { - XRPL_UNREACHABLE("ripple::SHAMap::updateGiveItem : invalid node"); + UNREACHABLE("ripple::SHAMap::updateGiveItem : invalid node"); return false; } @@ -966,9 +962,9 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) if (newRoot) { root_ = newRoot; - XRPL_ASSERT( - "ripple::SHAMap::fetchRoot : root hash do match", - root_->getHash() == hash); + ASSERT( + root_->getHash() == hash, + "ripple::SHAMap::fetchRoot : root hash do match"); return true; } @@ -990,9 +986,8 @@ SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter) std::shared_ptr SHAMap::writeNode(NodeObjectType t, std::shared_ptr node) const { - XRPL_ASSERT( - "ripple::SHAMap::writeNode : valid input node", node->cowid() == 0); - XRPL_ASSERT("ripple::SHAMap::writeNode : is backed", backed_); + ASSERT(node->cowid() == 0, "ripple::SHAMap::writeNode : valid input node"); + ASSERT(backed_, "ripple::SHAMap::writeNode : is backed"); canonicalize(node->getHash(), node); @@ -1012,8 +1007,8 @@ SHAMap::preFlushNode(std::shared_ptr node) const { // A shared node should never need to be flushed // because that would imply someone modified it - XRPL_ASSERT( - "ripple::SHAMap::preFlushNode : valid input node", node->cowid() != 0); + ASSERT( + node->cowid() != 0, "ripple::SHAMap::preFlushNode : valid input node"); if (node->cowid() != cowid_) { @@ -1041,8 +1036,7 @@ SHAMap::flushDirty(NodeObjectType t) int SHAMap::walkSubTree(bool doWrite, NodeObjectType t) { - XRPL_ASSERT( - "ripple::SHAMap::walkSubTree : valid input", !doWrite || backed_); + ASSERT(!doWrite || backed_, "ripple::SHAMap::walkSubTree : valid input"); int flushed = 0; @@ -1117,9 +1111,10 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) // flush this leaf ++flushed; - XRPL_ASSERT( - "ripple::SHAMap::walkSubTree : node cowid do match", - node->cowid() == cowid_); + ASSERT( + node->cowid() == cowid_, + "ripple::SHAMap::walkSubTree : node cowid do " + "match"); child->updateHash(); child->unshare(); @@ -1152,9 +1147,9 @@ SHAMap::walkSubTree(bool doWrite, NodeObjectType t) stack.pop(); // Hook this inner node to its parent - XRPL_ASSERT( - "ripple::SHAMap::walkSubTree : parent cowid do match", - parent->cowid() == cowid_); + ASSERT( + parent->cowid() == cowid_, + "ripple::SHAMap::walkSubTree : parent cowid do match"); parent->shareChild(pos, node); // Continue with parent's next child, if any @@ -1198,9 +1193,9 @@ SHAMap::dump(bool hash) const auto child = inner->getChildPointer(i); if (child) { - XRPL_ASSERT( - "ripple::SHAMap::dump : child hash do match", - child->getHash() == inner->getChildHash(i)); + ASSERT( + child->getHash() == inner->getChildHash(i), + "ripple::SHAMap::dump : child hash do match"); stack.push({child, nodeID.getChildNodeID(i)}); } } @@ -1217,9 +1212,9 @@ std::shared_ptr SHAMap::cacheLookup(SHAMapHash const& hash) const { auto ret = f_.getTreeNodeCache()->fetch(hash.as_uint256()); - XRPL_ASSERT( - "ripple::SHAMap::cacheLookup : not found or zero cowid", - !ret || !ret->cowid()); + ASSERT( + !ret || !ret->cowid(), + "ripple::SHAMap::cacheLookup : not found or zero cowid"); return ret; } @@ -1228,12 +1223,12 @@ SHAMap::canonicalize( SHAMapHash const& hash, std::shared_ptr& node) const { - XRPL_ASSERT("ripple::SHAMap::canonicalize : is backed", backed_); - XRPL_ASSERT( - "ripple::SHAMap::canonicalize : valid node input", node->cowid() == 0); - XRPL_ASSERT( - "ripple::SHAMap::canonicalize : node hash do match", - node->getHash() == hash); + ASSERT(backed_, "ripple::SHAMap::canonicalize : is backed"); + ASSERT( + node->cowid() == 0, "ripple::SHAMap::canonicalize : valid node input"); + ASSERT( + node->getHash() == hash, + "ripple::SHAMap::canonicalize : node hash do match"); f_.getTreeNodeCache()->canonicalize_replace_client(hash.as_uint256(), node); } @@ -1243,10 +1238,9 @@ SHAMap::invariants() const { (void)getHash(); // update node hashes auto node = root_.get(); - XRPL_ASSERT( - "ripple::SHAMap::invariants : non-null root node", node != nullptr); - XRPL_ASSERT( - "ripple::SHAMap::invariants : root node is not leaf", !node->isLeaf()); + ASSERT(node != nullptr, "ripple::SHAMap::invariants : non-null root node"); + ASSERT( + !node->isLeaf(), "ripple::SHAMap::invariants : root node is not leaf"); SharedPtrNodeStack stack; for (auto leaf = peekFirstItem(stack); leaf != nullptr; leaf = peekNextItem(leaf->peekItem()->key(), stack)) diff --git a/src/xrpld/shamap/detail/SHAMapDelta.cpp b/src/xrpld/shamap/detail/SHAMapDelta.cpp index 3bd1d5e27e0..b2f62685829 100644 --- a/src/xrpld/shamap/detail/SHAMapDelta.cpp +++ b/src/xrpld/shamap/detail/SHAMapDelta.cpp @@ -128,9 +128,9 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const // many differences throws on corrupt tables or missing nodes CAUTION: // otherMap is not locked and must be immutable - XRPL_ASSERT( - "ripple::SHAMap::compare : valid state and valid input", - isValid() && otherMap.isValid()); + ASSERT( + isValid() && otherMap.isValid(), + "ripple::SHAMap::compare : valid state and valid input"); if (getHash() == otherMap.getHash()) return true; @@ -147,7 +147,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const if (!ourNode || !otherNode) { - XRPL_UNREACHABLE("ripple::SHAMap::compare : missing a node"); + UNREACHABLE("ripple::SHAMap::compare : missing a node"); Throw(type_, uint256()); } @@ -228,7 +228,7 @@ SHAMap::compare(SHAMap const& otherMap, Delta& differences, int maxCount) const } } else - XRPL_UNREACHABLE("ripple::SHAMap::compare : invalid node"); + UNREACHABLE("ripple::SHAMap::compare : invalid node"); } return true; @@ -325,9 +325,9 @@ SHAMap::walkMapParallel( { std::shared_ptr node = std::move(nodeStack.top()); - XRPL_ASSERT( - "ripple::SHAMap::walkMapParallel : non-null node", - node); + ASSERT( + node != nullptr, + "ripple::SHAMap::walkMapParallel : non-null node"); nodeStack.pop(); for (int i = 0; i < 16; ++i) diff --git a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp index c0963872ecc..2f8448d7edc 100644 --- a/src/xrpld/shamap/detail/SHAMapInnerNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapInnerNode.cpp @@ -225,8 +225,8 @@ SHAMapInnerNode::updateHashDeep() void SHAMapInnerNode::serializeForWire(Serializer& s) const { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::serializeForWire : is non-empty", !isEmpty()); + ASSERT( + !isEmpty(), "ripple::SHAMapInnerNode::serializeForWire : is non-empty"); // If the node is sparse, then only send non-empty branches: if (getBranchCount() < 12) @@ -250,9 +250,9 @@ SHAMapInnerNode::serializeForWire(Serializer& s) const void SHAMapInnerNode::serializeWithPrefix(Serializer& s) const { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::serializeWithPrefix : is non-empty", - !isEmpty()); + ASSERT( + !isEmpty(), + "ripple::SHAMapInnerNode::serializeWithPrefix : is non-empty"); s.add32(HashPrefix::innerNode); iterChildren( @@ -277,14 +277,13 @@ SHAMapInnerNode::getString(const SHAMapNodeID& id) const void SHAMapInnerNode::setChild(int m, std::shared_ptr child) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::setChild : valid branch input", - (m >= 0) && (m < branchFactor)); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::setChild : nonzero cowid", cowid_ != 0); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::setChild : valid child input", - child.get() != this); + ASSERT( + (m >= 0) && (m < branchFactor), + "ripple::SHAMapInnerNode::setChild : valid branch input"); + ASSERT(cowid_ != 0, "ripple::SHAMapInnerNode::setChild : nonzero cowid"); + ASSERT( + child.get() != this, + "ripple::SHAMapInnerNode::setChild : valid child input"); auto const dstIsBranch = [&] { if (child) @@ -311,41 +310,41 @@ SHAMapInnerNode::setChild(int m, std::shared_ptr child) hash_.zero(); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::setChild : maximum branch count", - getBranchCount() <= hashesAndChildren_.capacity()); + ASSERT( + getBranchCount() <= hashesAndChildren_.capacity(), + "ripple::SHAMapInnerNode::setChild : maximum branch count"); } // finished modifying, now make shareable void SHAMapInnerNode::shareChild(int m, std::shared_ptr const& child) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::shareChild : valid branch input", - (m >= 0) && (m < branchFactor)); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::shareChild : nonzero cowid", cowid_ != 0); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::shareChild : non-null child input", child); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::shareChild : valid child input", - child.get() != this); - - XRPL_ASSERT( - "ripple::SHAMapInnerNode::shareChild : non-empty branch input", - !isEmptyBranch(m)); + ASSERT( + (m >= 0) && (m < branchFactor), + "ripple::SHAMapInnerNode::shareChild : valid branch input"); + ASSERT(cowid_ != 0, "ripple::SHAMapInnerNode::shareChild : nonzero cowid"); + ASSERT( + child != nullptr, + "ripple::SHAMapInnerNode::shareChild : non-null child input"); + ASSERT( + child.get() != this, + "ripple::SHAMapInnerNode::shareChild : valid child input"); + + ASSERT( + !isEmptyBranch(m), + "ripple::SHAMapInnerNode::shareChild : non-empty branch input"); hashesAndChildren_.getChildren()[*getChildIndex(m)] = child; } SHAMapTreeNode* SHAMapInnerNode::getChildPointer(int branch) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::getChildPointer : valid branch input", - branch >= 0 && branch < branchFactor); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::getChildPointer : non-empty branch input", - !isEmptyBranch(branch)); + ASSERT( + branch >= 0 && branch < branchFactor, + "ripple::SHAMapInnerNode::getChildPointer : valid branch input"); + ASSERT( + !isEmptyBranch(branch), + "ripple::SHAMapInnerNode::getChildPointer : non-empty branch input"); auto const index = *getChildIndex(branch); @@ -357,12 +356,12 @@ SHAMapInnerNode::getChildPointer(int branch) std::shared_ptr SHAMapInnerNode::getChild(int branch) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::getChild : valid branch input", - branch >= 0 && branch < branchFactor); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::getChild : non-empty branch input", - !isEmptyBranch(branch)); + ASSERT( + branch >= 0 && branch < branchFactor, + "ripple::SHAMapInnerNode::getChild : valid branch input"); + ASSERT( + !isEmptyBranch(branch), + "ripple::SHAMapInnerNode::getChild : non-empty branch input"); auto const index = *getChildIndex(branch); @@ -374,9 +373,9 @@ SHAMapInnerNode::getChild(int branch) SHAMapHash const& SHAMapInnerNode::getChildHash(int m) const { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::getChildHash : valid branch input", - (m >= 0) && (m < branchFactor)); + ASSERT( + (m >= 0) && (m < branchFactor), + "ripple::SHAMapInnerNode::getChildHash : valid branch input"); if (auto const i = getChildIndex(m)) return hashesAndChildren_.getHashes()[*i]; @@ -388,20 +387,21 @@ SHAMapInnerNode::canonicalizeChild( int branch, std::shared_ptr node) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::canonicalizeChild : valid branch input", - branch >= 0 && branch < branchFactor); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::canonicalizeChild : valid node input", node); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::canonicalizeChild : non-empty branch input", - !isEmptyBranch(branch)); + ASSERT( + branch >= 0 && branch < branchFactor, + "ripple::SHAMapInnerNode::canonicalizeChild : valid branch input"); + ASSERT( + node != nullptr, + "ripple::SHAMapInnerNode::canonicalizeChild : valid node input"); + ASSERT( + !isEmptyBranch(branch), + "ripple::SHAMapInnerNode::canonicalizeChild : non-empty branch input"); auto const childIndex = *getChildIndex(branch); auto [_, hashes, children] = hashesAndChildren_.getHashesAndChildren(); - XRPL_ASSERT( + ASSERT( + node->getHash() == hashes[childIndex], "ripple::SHAMapInnerNode::canonicalizeChild : node and branch inputs " - "hash do match", - node->getHash() == hashes[childIndex]); + "hash do match"); packed_spinlock sl(lock_, childIndex); std::lock_guard lock(sl); @@ -431,9 +431,9 @@ SHAMapInnerNode::invariants(bool is_root) const auto const branchCount = getBranchCount(); for (int i = 0; i < branchCount; ++i) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::invariants : nonzero hash in branch", - hashes[i].isNonZero()); + ASSERT( + hashes[i].isNonZero(), + "ripple::SHAMapInnerNode::invariants : nonzero hash in branch"); if (children[i] != nullptr) children[i]->invariants(); ++count; @@ -445,35 +445,35 @@ SHAMapInnerNode::invariants(bool is_root) const { if (hashes[i].isNonZero()) { - XRPL_ASSERT( + ASSERT( + (isBranch_ & (1 << i)) != 0, "ripple::SHAMapInnerNode::invariants : valid branch when " - "nonzero hash", - (isBranch_ & (1 << i)) != 0); + "nonzero hash"); if (children[i] != nullptr) children[i]->invariants(); ++count; } else { - XRPL_ASSERT( + ASSERT( + (isBranch_ & (1 << i)) == 0, "ripple::SHAMapInnerNode::invariants : valid branch when " - "zero hash", - (isBranch_ & (1 << i)) == 0); + "zero hash"); } } } if (!is_root) { - XRPL_ASSERT( - "ripple::SHAMapInnerNode::invariants : nonzero hash", - hash_.isNonZero()); - XRPL_ASSERT( - "ripple::SHAMapInnerNode::invariants : minimum count", count >= 1); + ASSERT( + hash_.isNonZero(), + "ripple::SHAMapInnerNode::invariants : nonzero hash"); + ASSERT( + count >= 1, "ripple::SHAMapInnerNode::invariants : minimum count"); } - XRPL_ASSERT( - "ripple::SHAMapInnerNode::invariants : hash and count do match", - (count == 0) ? hash_.isZero() : hash_.isNonZero()); + ASSERT( + (count == 0) ? hash_.isZero() : hash_.isNonZero(), + "ripple::SHAMapInnerNode::invariants : hash and count do match"); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp index 6c537107335..f6f13cfdaab 100644 --- a/src/xrpld/shamap/detail/SHAMapLeafNode.cpp +++ b/src/xrpld/shamap/detail/SHAMapLeafNode.cpp @@ -28,10 +28,10 @@ SHAMapLeafNode::SHAMapLeafNode( std::uint32_t cowid) : SHAMapTreeNode(cowid), item_(std::move(item)) { - XRPL_ASSERT( + ASSERT( + item_->size() >= 12, "ripple::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<" - "SHAMapItem const>, std::uint32_t) : minimum input size", - item_->size() >= 12); + "SHAMapItem const>, std::uint32_t) : minimum input size"); } SHAMapLeafNode::SHAMapLeafNode( @@ -40,11 +40,11 @@ SHAMapLeafNode::SHAMapLeafNode( SHAMapHash const& hash) : SHAMapTreeNode(cowid, hash), item_(std::move(item)) { - XRPL_ASSERT( + ASSERT( + item_->size() >= 12, "ripple::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<" "SHAMapItem const>, std::uint32_t, SHAMapHash const&) : minimum input " - "size", - item_->size() >= 12); + "size"); } boost::intrusive_ptr const& @@ -56,7 +56,7 @@ SHAMapLeafNode::peekItem() const bool SHAMapLeafNode::setItem(boost::intrusive_ptr item) { - XRPL_ASSERT("ripple::SHAMapLeafNode::setItem : nonzero cowid", cowid_ != 0); + ASSERT(cowid_ != 0, "ripple::SHAMapLeafNode::setItem : nonzero cowid"); item_ = std::move(item); auto const oldHash = hash_; @@ -94,10 +94,10 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const void SHAMapLeafNode::invariants(bool) const { - XRPL_ASSERT( - "ripple::SHAMapLeafNode::invariants : nonzero hash", hash_.isNonZero()); - XRPL_ASSERT( - "ripple::SHAMapLeafNode::invariants : non-null item", item_ != nullptr); + ASSERT( + hash_.isNonZero(), "ripple::SHAMapLeafNode::invariants : nonzero hash"); + ASSERT( + item_ != nullptr, "ripple::SHAMapLeafNode::invariants : non-null item"); } } // namespace ripple diff --git a/src/xrpld/shamap/detail/SHAMapNodeID.cpp b/src/xrpld/shamap/detail/SHAMapNodeID.cpp index f73ed803b3f..82cf9436366 100644 --- a/src/xrpld/shamap/detail/SHAMapNodeID.cpp +++ b/src/xrpld/shamap/detail/SHAMapNodeID.cpp @@ -57,12 +57,12 @@ depthMask(unsigned int depth) SHAMapNodeID::SHAMapNodeID(unsigned int depth, uint256 const& hash) : id_(hash), depth_(depth) { - XRPL_ASSERT( - "ripple::SHAMapNodeID::SHAMapNodeID : maximum depth input", - depth <= SHAMap::leafDepth); - XRPL_ASSERT( - "ripple::SHAMapNodeID::SHAMapNodeID : hash and depth inputs do match", - id_ == (id_ & depthMask(depth))); + ASSERT( + depth <= SHAMap::leafDepth, + "ripple::SHAMapNodeID::SHAMapNodeID : maximum depth input"); + ASSERT( + id_ == (id_ & depthMask(depth)), + "ripple::SHAMapNodeID::SHAMapNodeID : hash and depth inputs do match"); } std::string @@ -77,9 +77,9 @@ SHAMapNodeID::getRawString() const SHAMapNodeID SHAMapNodeID::getChildNodeID(unsigned int m) const { - XRPL_ASSERT( - "ripple::SHAMapNodeID::getChildNodeID : valid branch input", - m < SHAMap::branchFactor); + ASSERT( + m < SHAMap::branchFactor, + "ripple::SHAMapNodeID::getChildNodeID : valid branch input"); // A SHAMap has exactly 65 levels, so nodes must not exceed that // depth; if they do, this breaks the invariant of never allowing @@ -89,9 +89,9 @@ SHAMapNodeID::getChildNodeID(unsigned int m) const // We throw (but never assert) if the node is at level 64, since // entries at that depth are leaf nodes and have no children and even // constructing a child node from them would break the above invariant. - XRPL_ASSERT( - "ripple::SHAMapNodeID::getChildNodeID : maximum leaf depth", - depth_ <= SHAMap::leafDepth); + ASSERT( + depth_ <= SHAMap::leafDepth, + "ripple::SHAMapNodeID::getChildNodeID : maximum leaf depth"); if (depth_ >= SHAMap::leafDepth) Throw( @@ -136,17 +136,17 @@ selectBranch(SHAMapNodeID const& id, uint256 const& hash) else branch >>= 4; - XRPL_ASSERT( - "ripple::selectBranch : maximum result", branch < SHAMap::branchFactor); + ASSERT( + branch < SHAMap::branchFactor, "ripple::selectBranch : maximum result"); return branch; } SHAMapNodeID SHAMapNodeID::createID(int depth, uint256 const& key) { - XRPL_ASSERT( - "ripple::SHAMapNodeID::createID : valid branch input", - (depth >= 0) && (depth < 65)); + ASSERT( + (depth >= 0) && (depth < 65), + "ripple::SHAMapNodeID::createID : valid branch input"); return SHAMapNodeID(depth, key & depthMask(depth)); } diff --git a/src/xrpld/shamap/detail/SHAMapSync.cpp b/src/xrpld/shamap/detail/SHAMapSync.cpp index 1e22f2e4b22..4425662415e 100644 --- a/src/xrpld/shamap/detail/SHAMapSync.cpp +++ b/src/xrpld/shamap/detail/SHAMapSync.cpp @@ -314,10 +314,10 @@ SHAMap::gmn_ProcessDeferredReads(MissingNodes& mn) std::vector> SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) { - XRPL_ASSERT( - "ripple::SHAMap::getMissingNodes : nonzero root hash", - root_->getHash().isNonZero()); - XRPL_ASSERT("ripple::SHAMap::getMissingNodes : valid max input", max > 0); + ASSERT( + root_->getHash().isNonZero(), + "ripple::SHAMap::getMissingNodes : nonzero root hash"); + ASSERT(max > 0, "ripple::SHAMap::getMissingNodes : valid max input"); MissingNodes mn( max, @@ -376,9 +376,9 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // This is a node we are continuing to process fullBelow = fullBelow && was; // was and still is } - XRPL_ASSERT( - "ripple::SHAMap::getMissingNodes : first non-null node", - node); + ASSERT( + node != nullptr, + "ripple::SHAMap::getMissingNodes : first non-null node"); } } @@ -409,9 +409,9 @@ SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter) // Resume at the top of the stack pos = mn.stack_.top(); mn.stack_.pop(); - XRPL_ASSERT( - "ripple::SHAMap::getMissingNodes : second non-null node", - node != nullptr); + ASSERT( + node != nullptr, + "ripple::SHAMap::getMissingNodes : second non-null node"); } } @@ -538,13 +538,13 @@ SHAMap::addRootNode( if (root_->getHash().isNonZero()) { JLOG(journal_.trace()) << "got root node, already have one"; - XRPL_ASSERT( - "ripple::SHAMap::addRootNode : valid hash input", - root_->getHash() == hash); + ASSERT( + root_->getHash() == hash, + "ripple::SHAMap::addRootNode : valid hash input"); return SHAMapAddNode::duplicate(); } - XRPL_ASSERT("ripple::SHAMap::addRootNode : valid cowid", cowid_ >= 1); + ASSERT(cowid_ >= 1, "ripple::SHAMap::addRootNode : valid cowid"); auto node = SHAMapTreeNode::makeFromWire(rootNode); if (!node || node->getHash() != hash) return SHAMapAddNode::invalid(); @@ -578,8 +578,7 @@ SHAMap::addKnownNode( Slice const& rawNode, SHAMapSyncFilter* filter) { - XRPL_ASSERT( - "ripple::SHAMap::addKnownNode : valid node input", !node.isRoot()); + ASSERT(!node.isRoot(), "ripple::SHAMap::addKnownNode : valid node input"); if (!isSynching()) { @@ -596,7 +595,7 @@ SHAMap::addKnownNode( (iNodeID.getDepth() < node.getDepth())) { int branch = selectBranch(iNodeID, node.getNodeID()); - XRPL_ASSERT("ripple::SHAMap::addKnownNode : valid branch", branch >= 0); + ASSERT(branch >= 0, "ripple::SHAMap::addKnownNode : valid branch"); auto inner = static_cast(iNode); if (inner->isEmptyBranch(branch)) { diff --git a/src/xrpld/shamap/detail/TaggedPointer.ipp b/src/xrpld/shamap/detail/TaggedPointer.ipp index 83ee03dd04d..f5b3c404e19 100644 --- a/src/xrpld/shamap/detail/TaggedPointer.ipp +++ b/src/xrpld/shamap/detail/TaggedPointer.ipp @@ -79,18 +79,18 @@ constexpr auto chunksPerBlock = [[nodiscard]] inline std::uint8_t numAllocatedChildren(std::uint8_t n) { - XRPL_ASSERT( - "ripple::numAllocatedChildren : valid input", - n <= SHAMapInnerNode::branchFactor); + ASSERT( + n <= SHAMapInnerNode::branchFactor, + "ripple::numAllocatedChildren : valid input"); return *std::lower_bound(boundaries.begin(), boundaries.end(), n); } [[nodiscard]] inline std::size_t boundariesIndex(std::uint8_t numChildren) { - XRPL_ASSERT( - "ripple::boundariesIndex : valid input", - numChildren <= SHAMapInnerNode::branchFactor); + ASSERT( + numChildren <= SHAMapInnerNode::branchFactor, + "ripple::boundariesIndex : valid input"); return std::distance( boundaries.begin(), std::lower_bound(boundaries.begin(), boundaries.end(), numChildren)); @@ -160,9 +160,9 @@ allocateArrays(std::uint8_t numChildren) inline void deallocateArrays(std::uint8_t boundaryIndex, void* p) { - XRPL_ASSERT( - "ripple::deallocateArrays : valid inputs", - isFromArrayFuns[boundaryIndex](p)); + ASSERT( + isFromArrayFuns[boundaryIndex](p), + "ripple::deallocateArrays : valid inputs"); freeArrayFuns[boundaryIndex](p); } @@ -276,15 +276,15 @@ TaggedPointer::getChildIndex(std::uint16_t isBranch, int i) const inline TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t numChildren) { auto [tag, p] = allocateArrays(numChildren); - XRPL_ASSERT( + ASSERT( + tag < boundaries.size(), "ripple::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " - "maximum tag", - tag < boundaries.size()); - XRPL_ASSERT( - "ripple::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " - "valid pointer", + "maximum tag"); + ASSERT( (reinterpret_cast(p) & ptrMask) == - reinterpret_cast(p)); + reinterpret_cast(p), + "ripple::TaggedPointer::TaggedPointer(RawAllocateTag, std::uint8_t) : " + "valid pointer"); tp_ = reinterpret_cast(p) + tag; } @@ -294,10 +294,10 @@ inline TaggedPointer::TaggedPointer( std::uint16_t dstBranches, std::uint8_t toAllocate) { - XRPL_ASSERT( + ASSERT( + toAllocate >= popcnt16(dstBranches), "ripple::TaggedPointer::TaggedPointer(TaggedPointer&& ...) : minimum " - "toAllocate input", - toAllocate >= popcnt16(dstBranches)); + "toAllocate input"); if (other.capacity() == numAllocatedChildren(toAllocate)) { @@ -442,10 +442,10 @@ inline TaggedPointer::TaggedPointer( } } // If sparse, may need to run additional constructors - XRPL_ASSERT( + ASSERT( + !dstIsDense || dstIndex == dstNumAllocated, "ripple::TaggedPointer::TaggedPointer(TaggedPointer&& ...) : " - "non-sparse or valid sparse", - !dstIsDense || dstIndex == dstNumAllocated); + "non-sparse or valid sparse"); for (int i = dstIndex; i < dstNumAllocated; ++i) { new (&dstHashes[i]) SHAMapHash{}; From 4b63edf9ef061fcdbee831b1c4eff210eb96f8f2 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Tue, 8 Oct 2024 15:44:50 +0100 Subject: [PATCH 15/18] Small update in cmake file --- cmake/RippledSettings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/RippledSettings.cmake b/cmake/RippledSettings.cmake index 692952b91ef..3eeebed428c 100644 --- a/cmake/RippledSettings.cmake +++ b/cmake/RippledSettings.cmake @@ -19,7 +19,7 @@ if(unity) endif() endif() if(is_clang AND is_linux) - option(voidstar "Add libvoidstar.so loader for Antithesis instrumentation." OFF) + option(voidstar "Enable Antithesis instrumentation." OFF) endif() if(is_gcc OR is_clang) option(coverage "Generates coverage info." OFF) From 400f4a44d3c3d6d475eca46eca146206288cc829 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Fri, 11 Oct 2024 12:13:33 +0100 Subject: [PATCH 16/18] Update Antithesis SDK --- external/README.md | 1 + external/antithesis-sdk/CMakeLists.txt | 5 +- .../antithesis_instrumentation.h | 2 +- external/antithesis-sdk/antithesis_sdk.h | 570 ++++++++++++++++-- 4 files changed, 534 insertions(+), 44 deletions(-) diff --git a/external/README.md b/external/README.md index 25ae577ba58..c810539fd7d 100644 --- a/external/README.md +++ b/external/README.md @@ -6,6 +6,7 @@ The Conan recipes include patches we have not yet pushed upstream. | Folder | Upstream | Description | |:----------------|:---------------------------------------------|:------------| +| `antithesis-sdk`| [Project](https://github.com/antithesishq/antithesis-sdk-cpp/) | [Antithesis](https://antithesis.com/docs/using_antithesis/sdk/cpp/overview.html) SDK for C++ | | `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 | diff --git a/external/antithesis-sdk/CMakeLists.txt b/external/antithesis-sdk/CMakeLists.txt index 177a5026aa7..b7fa22de107 100644 --- a/external/antithesis-sdk/CMakeLists.txt +++ b/external/antithesis-sdk/CMakeLists.txt @@ -1,8 +1,11 @@ cmake_minimum_required(VERSION 3.25) -project(antithesis-sdk-cpp VERSION 0.3.2 LANGUAGES CXX) + +# Note, version set explicitly by rippled project +project(antithesis-sdk-cpp VERSION 0.4.2 LANGUAGES CXX) add_library(antithesis-sdk-cpp INTERFACE antithesis_sdk.h) +# Note, both sections below created by rippled project target_include_directories(antithesis-sdk-cpp INTERFACE $ $ diff --git a/external/antithesis-sdk/antithesis_instrumentation.h b/external/antithesis-sdk/antithesis_instrumentation.h index b36fc5832ca..a2e88dbef5d 100644 --- a/external/antithesis-sdk/antithesis_instrumentation.h +++ b/external/antithesis-sdk/antithesis_instrumentation.h @@ -7,7 +7,7 @@ This header file can be used in both C and C++ programs. (The rest of the SDK wo You should include it in a single .cpp or .c file. -The instructions (such as required compiler flags) and usage guidance are found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. +The instructions (such as required compiler flags) and usage guidance are found at https://antithesis.com/docs/using_antithesis/sdk/cpp/overview.html. */ #include diff --git a/external/antithesis-sdk/antithesis_sdk.h b/external/antithesis-sdk/antithesis_sdk.h index 2689e7f13a5..f6ed8e52d33 100644 --- a/external/antithesis-sdk/antithesis_sdk.h +++ b/external/antithesis-sdk/antithesis_sdk.h @@ -2,7 +2,7 @@ // This header file contains the Antithesis C++ SDK, which enables C++ applications to integrate with the [Antithesis platform]. // -// Documentation for the SDK is found at https://antithesis.com/docs/using_antithesis/sdk/cpp_sdk.html. +// Documentation for the SDK is found at https://antithesis.com/docs/using_antithesis/sdk/cpp/overview.html. #include #include @@ -11,10 +11,11 @@ #include #include #include +#include namespace antithesis { - inline const char* SDK_VERSION = "0.3.2"; - inline const char* PROTOCOL_VERSION = "1.0.0"; + inline const char* SDK_VERSION = "0.4.0"; + inline const char* PROTOCOL_VERSION = "1.1.0"; struct LocalRandom { std::random_device device; @@ -32,14 +33,25 @@ namespace antithesis { } }; - struct JSON; - typedef std::variant BasicValueType; - typedef std::vector JSON_ARRAY; - typedef std::variant ValueType; + struct JSON; struct JSONArray; + typedef std::variant JSONValue; - struct JSON : std::map { - JSON() : std::map() {} - JSON( std::initializer_list> args) : std::map(args) {} + struct JSONArray : std::vector { + using std::vector::vector; + + template::value, bool>::type = true> + JSONArray(std::vector vals) : std::vector(vals.begin(), vals.end()) {} + }; + + struct JSON : std::map { + JSON() : std::map() {} + JSON( std::initializer_list> args) : std::map(args) {} + + JSON( std::initializer_list> args, std::vector> more_args ) : std::map(args) { + for (auto& pair : more_args) { + (*this)[pair.first] = pair.second; + } + } }; // Declarations that we expose @@ -60,7 +72,16 @@ namespace antithesis { #define SOMETIMES(cond, message, ...) #define REACHABLE(message, ...) #define UNREACHABLE(message, ...) - +#define ALWAYS_GREATER_THAN(val, threshold, message, ...) +#define ALWAYS_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) +#define SOMETIMES_GREATER_THAN(val, threshold, message, ...) +#define SOMETIMES_GREATER_THAN_OR_EQUAL_TO(val, threshold, message, ...) +#define ALWAYS_LESS_THAN(val, threshold, message, ...) +#define ALWAYS_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) +#define SOMETIMES_LESS_THAN(val, threshold, message, ...) +#define SOMETIMES_LESS_THAN_OR_EQUAL_TO(val, threshold, message, ...) +#define ALWAYS_SOME(pairs, message, ...) +#define SOMETIMES_ALL(pairs, message, ...) namespace antithesis { inline uint64_t get_random() { @@ -249,7 +270,7 @@ namespace antithesis { template inline constexpr bool always_false_v = false; - static std::ostream& operator<<(std::ostream& out, const BasicValueType& basic_value) { + static std::ostream& operator<<(std::ostream& out, const JSONValue& json) { std::visit([&](auto&& arg) { using T = std::decay_t; @@ -270,58 +291,42 @@ namespace antithesis { out << arg; } else if constexpr (std::is_same_v) { out << std::quoted(arg); + } else if constexpr (std::is_same_v) { + out << "null"; } else if constexpr (std::is_same_v) { - if (arg.empty()) { - out << "null"; - } else { - out << arg; - } - } else { - static_assert(always_false_v, "non-exhaustive BasicValueType visitor!"); - } - }, basic_value); - - return out; - } - - static std::ostream& operator<<(std::ostream& out, const ValueType& value) { - std::visit([&](auto&& arg) - { - using T = std::decay_t; - if constexpr (std::is_same_v) { out << arg; - } else if constexpr (std::is_same_v>) { + } else if constexpr (std::is_same_v) { out << '['; bool first = true; for (auto &item : arg) { - if (!first) { - out << ','; - } - first = false; - out << item; + if (!first) { + out << ','; + } + first = false; + out << item; } out << ']'; } else { - static_assert(always_false_v, "non-exhaustive ValueType visitor!"); + static_assert(always_false_v, "non-exhaustive JSONValue visitor!"); } - }, value); + }, json); return out; } static std::ostream& operator<<(std::ostream& out, const JSON& details) { - out << "{ "; + out << '{'; bool first = true; for (auto [key, value] : details) { if (!first) { - out << ", "; + out << ','; } - out << std::quoted(key) << ": " << value; + out << std::quoted(key) << ':' << value; first = false; } - out << " }"; + out << '}'; return out; } @@ -521,6 +526,203 @@ namespace antithesis { JSON json = { { name, details } }; get_lib_handler().output(json); } + + enum GuidepostType { + GUIDEPOST_MAXIMIZE, + GUIDEPOST_MINIMIZE, + GUIDEPOST_EXPLORE, + GUIDEPOST_ALL, + GUIDEPOST_NONE + }; + + inline constexpr const char* get_guidance_type_string(GuidepostType type) { + switch (type) { + case GUIDEPOST_MAXIMIZE: + case GUIDEPOST_MINIMIZE: + return "numeric"; + case GUIDEPOST_ALL: + case GUIDEPOST_NONE: + return "boolean"; + case GUIDEPOST_EXPLORE: + return "json"; + } + } + + inline constexpr bool does_guidance_maximize(GuidepostType type) { + switch (type) { + case GUIDEPOST_MAXIMIZE: + case GUIDEPOST_ALL: + return true; + case GUIDEPOST_EXPLORE: + case GUIDEPOST_MINIMIZE: + case GUIDEPOST_NONE: + return false; + } + } + + template > + struct NumericGuidepost { + const char* message; + LocationInfo location; + GuidepostType type; + // an approximation of (left - right) / 2; contains an absolute value and a sign bit + std::pair extreme_half_gap; + + NumericGuidepost(const char* message, LocationInfo&& location, GuidepostType type) : + message(message), location(std::move(location)), type(type) { + this->add_to_catalog(); + if (type == GUIDEPOST_MAXIMIZE) { + extreme_half_gap = { std::numeric_limits::max(), false }; + } else { + extreme_half_gap = { std::numeric_limits::max(), true }; + } + } + + inline void add_to_catalog() { + std::string id = make_key(message, location); + JSON catalog{ + {"antithesis_guidance", JSON{ + {"guidance_type", get_guidance_type_string(type)}, + {"message", message}, + {"id", id}, + {"location", location.to_json()}, + {"maximize", does_guidance_maximize(type)}, + {"hit", false} + }} + }; + get_lib_handler().output(catalog); + } + + std::pair compute_half_gap(NumericValue left, NumericValue right) { + // An extremely baroque way to compute (left - right) / 2, rounded toward 0, without overflowing or underflowing + if (std::is_integral_v) { + // If both numbers are odd then the gap doesn't change if we subtract 1 from both sides + // Also subtracting 1 from both sides won't underflow + if (left % 2 == 1 && right % 2 == 1) + return compute_half_gap( left - 1, right - 1); + // If one number is odd then we subtract 1 from the larger number + // This rounds the computation toward 0 but again won't underflow + if (left % 2 == 1 || right % 2 == 1) { + if (left > right) { + return compute_half_gap( left - 1, right ); + } else { + return compute_half_gap( left, right - 1 ); + } + } + // At this point both numbers are even, so the midpoint calculation is exact + NumericValue half_left = left / 2; + NumericValue half_right = right / 2; + NumericValue midpoint = half_left + half_right; + // This won't overflow or underflow because we're subtracting the midpoint + // We compute a positive value and a sign so that we don't have to do weird things with unsigned types + if (left > right) { + return { midpoint - right, true }; + } else { + return { right - midpoint, false }; + } + } else { + // If it's floating point we don't need to worry about overflowing, just do the arithmetic + return { left > right ? (left - right) / 2 : (right - left) / 2, left > right }; + } + } + + bool should_send_value(std::pair half_gap) { + if (this->type == GUIDEPOST_MAXIMIZE) { + if (half_gap.second && !extreme_half_gap.second) { + // we're positive and the extreme value isn't; always send back + return true; + } else if (!half_gap.second && extreme_half_gap.second) { + // we're negative and the extreme value is positive; never send back + return false; + } else if (half_gap.second && extreme_half_gap.second) { + // both positive; send back if our absolute value is at least as large + return half_gap.first >= extreme_half_gap.first; + } else { + // both negative; send back if our absolute value is at least as small + return half_gap.first <= extreme_half_gap.first; + } + } else { + if (half_gap.second && !extreme_half_gap.second) { + // we're positive and the extreme value isn't; never send back + return false; + } else if (!half_gap.second && extreme_half_gap.second) { + // we're negative and the extreme value is positive; always send back + return true; + } else if (half_gap.second && extreme_half_gap.second) { + // both positive; send back if our absolute value is at least as small + return half_gap.first <= extreme_half_gap.first; + } else { + // both negative; send back if our absolute value is at least as large + return half_gap.first >= extreme_half_gap.first; + } + } + } + + [[clang::always_inline]] inline void send_guidance(Value value) { + std::pair half_gap = compute_half_gap(value.first, value.second); + if (should_send_value(half_gap)) { + extreme_half_gap = half_gap; + std::string id = make_key(this->message, this->location); + JSON guidance{ + {"antithesis_guidance", JSON{ + {"guidance_type", get_guidance_type_string(this->type)}, + {"message", this->message}, + {"id", id}, + {"location", this->location.to_json()}, + {"maximize", does_guidance_maximize(this->type)}, + {"guidance_data", JSON{ + { "left", value.first }, + { "right", value.second } }}, + {"hit", true} + }} + }; + get_lib_handler().output(guidance); + } + } + }; + + template + struct BooleanGuidepost { + const char* message; + LocationInfo location; + GuidepostType type; + + BooleanGuidepost(const char* message, LocationInfo&& location, GuidepostType type) : + message(message), location(std::move(location)), type(type) { + this->add_to_catalog(); + } + + inline void add_to_catalog() { + std::string id = make_key(message, location); + JSON catalog{ + {"antithesis_guidance", JSON{ + {"guidance_type", get_guidance_type_string(type)}, + {"message", message}, + {"id", id}, + {"location", location.to_json()}, + {"maximize", does_guidance_maximize(type)}, + {"hit", false} + }} + }; + get_lib_handler().output(catalog); + } + + inline virtual void send_guidance(GuidanceType data) { + std::string id = make_key(this->message, this->location); + JSON guidance{ + {"antithesis_guidance", JSON{ + {"guidance_type", get_guidance_type_string(this->type)}, + {"message", this->message}, + {"id", id}, + {"location", location.to_json()}, + {"maximize", does_guidance_maximize(this->type)}, + {"guidance_data", data}, + {"hit", true} + }} + }; + get_lib_handler().output(guidance); + } + }; } namespace { @@ -570,10 +772,60 @@ namespace { static inline antithesis::Assertion assertion = create(); }; + + template + struct BooleanGuidanceCatalogEntry { + [[clang::always_inline]] static inline antithesis::BooleanGuidepost create() { + antithesis::LocationInfo location{ "", function_name.c_str(), file_name.c_str(), line, column }; + switch (type) { + case antithesis::GUIDEPOST_ALL: + case antithesis::GUIDEPOST_NONE: + return antithesis::BooleanGuidepost(message.c_str(), std::move(location), type); + default: + throw std::runtime_error("Can't create boolean guidepost with non-boolean type"); + } + } + + static inline antithesis::BooleanGuidepost guidepost = create(); + }; + + template + struct NumericGuidanceCatalogEntry { + [[clang::always_inline]] static inline antithesis::NumericGuidepost create() { + antithesis::LocationInfo location{ "", function_name.c_str(), file_name.c_str(), line, column }; + switch (type) { + case antithesis::GUIDEPOST_MAXIMIZE: + case antithesis::GUIDEPOST_MINIMIZE: + return antithesis::NumericGuidepost(message.c_str(), std::move(location), type); + default: + throw std::runtime_error("Can't create numeric guidepost with non-numeric type"); + } + } + + static inline antithesis::NumericGuidepost guidepost = create(); + }; } #define FIXED_STRING_FROM_C_STR(s) (fixed_string::from_c_str(s)) +#define _NL_1(foo) { #foo, foo } +#define _NL_2(foo, ...) { #foo, foo }, _NL_1(__VA_ARGS__) +#define _NL_3(foo, ...) { #foo, foo }, _NL_2(__VA_ARGS__) +#define _NL_4(foo, ...) { #foo, foo }, _NL_3(__VA_ARGS__) +#define _NL_5(foo, ...) { #foo, foo }, _NL_4(__VA_ARGS__) +#define _NL_6(foo, ...) { #foo, foo }, _NL_5(__VA_ARGS__) +#define _NL_7(foo, ...) { #foo, foo }, _NL_6(__VA_ARGS__) +#define _NL_8(foo, ...) { #foo, foo }, _NL_7(__VA_ARGS__) +#define _NL_9(foo, ...) { #foo, foo }, _NL_8(__VA_ARGS__) +#define _NL_10(foo, ...) { #foo, foo }, _NL_9(__VA_ARGS__) + +#define _ELEVENTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N + +#define _GET_NL(...) \ + _ELEVENTH_ARG(__VA_ARGS__, _NL_10, _NL_9, _NL_8, _NL_7, _NL_6, _NL_5, _NL_4, _NL_3, _NL_2, _NL_1) + +#define NAMED_LIST(...) { _GET_NL(__VA_ARGS__)(__VA_ARGS__) } + #define ANTITHESIS_ASSERT_RAW(type, cond, message, ...) ( \ CatalogEntry< \ type, \ @@ -590,6 +842,240 @@ namespace { #define REACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::REACHABLE_ASSERTION, true, message, __VA_ARGS__) #define UNREACHABLE(message, ...) ANTITHESIS_ASSERT_RAW(antithesis::UNREACHABLE_ASSERTION, false, message, __VA_ARGS__) +#define ALWAYS_GREATER_THAN(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in ALWAYS_GREATER_THAN must be of same type"); \ + CatalogEntry< \ + antithesis::ALWAYS_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left > right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MINIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define ALWAYS_GREATER_THAN_OR_EQUAL_TO(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in ALWAYS_GREATER_THAN_OR_EQUAL_TO must be of same type"); \ + CatalogEntry< \ + antithesis::ALWAYS_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left >= right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MINIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define SOMETIMES_GREATER_THAN(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in SOMETIMES_GREATER_THAN must be of same type"); \ + CatalogEntry< \ + antithesis::SOMETIMES_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left > right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MAXIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define SOMETIMES_GREATER_THAN_OR_EQUAL_TO(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in SOMETIMES_GREATER_THAN_OR_EQUAL_TO must be of same type"); \ + CatalogEntry< \ + antithesis::SOMETIMES_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left >= right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MAXIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define ALWAYS_LESS_THAN(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in ALWAYS_LESS_THAN must be of same type"); \ + CatalogEntry< \ + antithesis::ALWAYS_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left < right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MAXIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define ALWAYS_LESS_THAN_OR_EQUAL_TO(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in ALWAYS_LESS_THAN_OR_EQUAL_TO must be of same type"); \ + CatalogEntry< \ + antithesis::ALWAYS_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left <= right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MAXIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define SOMETIMES_LESS_THAN(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in SOMETIMES_LESS_THAN must be of same type"); \ + CatalogEntry< \ + antithesis::SOMETIMES_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left < right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MINIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define SOMETIMES_LESS_THAN_OR_EQUAL_TO(left, right, message, ...) \ +do { \ + static_assert(std::is_same_v, "Values compared in SOMETIMES_LESS_THAN_OR_EQUAL_TO must be of same type"); \ + CatalogEntry< \ + antithesis::SOMETIMES_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(left <= right, (antithesis::JSON(__VA_ARGS__, {{ "left", left }, { "right", right }})) ); \ + NumericGuidanceCatalogEntry< \ + decltype(left), \ + antithesis::GUIDEPOST_MINIMIZE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance({ left, right }); \ +} while (0) + +#define ALWAYS_SOME(pairs, message, ...) \ +do { \ + bool disjunction = false; \ + for (std::pair pair : pairs) { \ + if (pair.second) { \ + disjunction = true; \ + break; \ + } \ + } \ + CatalogEntry< \ + antithesis::ALWAYS_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(disjunction, (antithesis::JSON(__VA_ARGS__, pairs)) ); \ + antithesis::json json_pairs = antithesis::json(pairs); \ + BooleanGuidanceCatalogEntry< \ + decltype(json_pairs), \ + antithesis::GUIDEPOST_NONE, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance(json_pairs); \ +} while (0) + +#define SOMETIMES_ALL(pairs, message, ...) \ +do { \ + bool conjunction = true; \ + for (std::pair pair : pairs) { \ + if (!pair.second) { \ + conjunction = false; \ + break; \ + } \ + } \ + CatalogEntry< \ + antithesis::SOMETIMES_ASSERTION, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::assertion.check_assertion(conjunction, (antithesis::JSON(__VA_ARGS__, pairs)) ); \ + antithesis::json json_pairs = antithesis::json(pairs); \ + BooleanGuidanceCatalogEntry< \ + decltype(json_pairs), \ + antithesis::GUIDEPOST_ALL, \ + fixed_string(message), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().file_name()), \ + FIXED_STRING_FROM_C_STR(std::source_location::current().function_name()), \ + std::source_location::current().line(), \ + std::source_location::current().column() \ + >::guidepost.send_guidance(json_pairs); \ +} while (0) + #endif namespace antithesis { From 29abf3f521fa4a72bdf06bd2bc189fad095a1122 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Fri, 1 Mar 2024 15:53:25 -0600 Subject: [PATCH 17/18] Update clang-format settings --- .clang-format | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.clang-format b/.clang-format index 0b1b4efea07..1d0f396dd8f 100644 --- a/.clang-format +++ b/.clang-format @@ -58,6 +58,7 @@ IncludeCategories: IncludeIsMainRegex: '$' IndentCaseLabels: true IndentFunctionDeclarationAfterType: false +IndentRequiresClause: true IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false @@ -73,6 +74,7 @@ PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 200 PointerAlignment: Left ReflowComments: true +RequiresClausePosition: OwnLine SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true From 640167d2498481ba4583e2fb80a117f56b65fda5 Mon Sep 17 00:00:00 2001 From: Bronek Kozicki Date: Thu, 17 Oct 2024 11:07:56 +0000 Subject: [PATCH 18/18] Reformat code with clang-format-18 --- include/xrpl/basics/Expected.h | 53 ++-- include/xrpl/basics/FeeUnits.h | 24 +- include/xrpl/basics/IOUAmount.h | 6 +- include/xrpl/basics/Number.h | 6 +- include/xrpl/basics/XRPAmount.h | 6 +- include/xrpl/basics/base_uint.h | 3 +- include/xrpl/basics/safe_cast.h | 4 +- include/xrpl/basics/tagged_integer.h | 3 +- .../container/detail/aged_ordered_container.h | 8 +- .../detail/aged_unordered_container.h | 10 +- include/xrpl/beast/hash/xxhasher.h | 3 +- include/xrpl/beast/unit_test.h | 2 +- include/xrpl/beast/utility/Journal.h | 3 +- include/xrpl/json/json_value.h | 6 +- include/xrpl/protocol/AccountID.h | 2 +- include/xrpl/protocol/ApiVersion.h | 41 ++- include/xrpl/protocol/MultiApiJson.h | 84 +++--- include/xrpl/protocol/STAmount.h | 6 +- include/xrpl/protocol/STBase.h | 6 +- include/xrpl/protocol/STObject.h | 3 +- include/xrpl/protocol/STVector256.h | 3 +- include/xrpl/protocol/TER.h | 57 ++-- include/xrpl/protocol/digest.h | 21 +- include/xrpl/server/detail/BaseHTTPPeer.h | 4 +- src/libxrpl/basics/ResolverAsio.cpp | 6 +- src/libxrpl/beast/insight/NullCollector.cpp | 12 +- .../beast/utility/src/beast_Journal.cpp | 6 +- src/libxrpl/json/Writer.cpp | 3 +- src/libxrpl/protocol/STAmount.cpp | 3 +- src/libxrpl/protocol/STBase.cpp | 3 +- src/libxrpl/protocol/STCurrency.cpp | 3 +- src/libxrpl/protocol/STInteger.cpp | 12 +- src/libxrpl/protocol/STIssue.cpp | 3 +- src/libxrpl/protocol/STParsedJSON.cpp | 3 +- src/libxrpl/protocol/STPathSet.cpp | 3 +- src/libxrpl/protocol/STVector256.cpp | 3 +- src/test/app/NFTokenBurn_test.cpp | 3 +- src/test/app/ValidatorSite_test.cpp | 25 +- src/test/basics/IOUAmount_test.cpp | 91 +++--- src/test/basics/XRPAmount_test.cpp | 104 +++---- src/test/basics/base_uint_test.cpp | 3 +- src/test/beast/beast_Zero_test.cpp | 6 +- .../consensus/ByzantineFailureSim_test.cpp | 4 +- src/test/csf/Peer.h | 3 +- src/test/csf/collectors.h | 225 ++++++-------- src/test/jtx/TestHelpers.h | 10 +- src/test/jtx/TrustedPublisherServer.h | 12 +- src/test/jtx/amount.h | 14 +- src/test/jtx/impl/AMM.cpp | 4 +- src/test/jtx/impl/amount.cpp | 3 +- src/test/jtx/multisign.h | 5 +- src/test/overlay/reduce_relay_test.cpp | 5 +- src/test/protocol/MultiApiJson_test.cpp | 280 +++++------------- src/test/protocol/STObject_test.cpp | 276 ++++++++--------- src/xrpld/app/ledger/LedgerHistory.cpp | 58 ++-- .../app/ledger/detail/TimeoutCounter.cpp | 4 +- src/xrpld/app/main/GRPCServer.cpp | 4 +- src/xrpld/app/misc/AMMHelpers.h | 6 +- src/xrpld/app/misc/NetworkOPs.cpp | 4 +- src/xrpld/app/misc/detail/TxQ.cpp | 10 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 3 +- src/xrpld/app/paths/Pathfinder.cpp | 3 +- src/xrpld/app/paths/detail/BookStep.cpp | 3 +- src/xrpld/app/paths/detail/DirectStep.cpp | 6 +- .../app/paths/detail/XRPEndpointStep.cpp | 3 +- src/xrpld/app/rdb/RelationalDatabase.h | 4 +- src/xrpld/app/tx/detail/CancelOffer.cpp | 8 +- src/xrpld/app/tx/detail/Payment.cpp | 18 +- src/xrpld/app/tx/detail/Transactor.cpp | 6 +- src/xrpld/conditions/detail/PreimageSha256.h | 3 +- src/xrpld/consensus/Consensus.h | 10 +- src/xrpld/consensus/Validations.h | 3 +- src/xrpld/core/DatabaseCon.h | 3 +- src/xrpld/ledger/detail/View.cpp | 6 +- src/xrpld/nodestore/detail/DatabaseNodeImp.h | 3 +- .../nodestore/detail/DatabaseRotatingImp.h | 3 +- src/xrpld/overlay/detail/PeerImp.cpp | 6 +- src/xrpld/overlay/detail/ProtocolVersion.cpp | 2 +- src/xrpld/peerfinder/detail/Logic.h | 6 +- src/xrpld/rpc/detail/ServerHandler.cpp | 6 +- src/xrpld/shamap/detail/TaggedPointer.ipp | 20 +- src/xrpld/unity/rocksdb.h | 2 +- 82 files changed, 808 insertions(+), 902 deletions(-) diff --git a/include/xrpl/basics/Expected.h b/include/xrpl/basics/Expected.h index 745fa50a69f..10f188af11c 100644 --- a/include/xrpl/basics/Expected.h +++ b/include/xrpl/basics/Expected.h @@ -136,44 +136,49 @@ class [[nodiscard]] Expected public: template - requires std::convertible_to constexpr Expected(U && r) - : Base(T(std::forward(r))) + requires std::convertible_to + constexpr Expected(U&& r) : Base(T(std::forward(r))) { } template - requires std::convertible_to && - (!std::is_reference_v)constexpr Expected(Unexpected e) - : Base(E(std::move(e.value()))) + requires std::convertible_to && (!std::is_reference_v) + constexpr Expected(Unexpected e) : Base(E(std::move(e.value()))) { } - constexpr bool has_value() const + constexpr bool + has_value() const { return Base::has_value(); } - constexpr T const& value() const + constexpr T const& + value() const { return Base::value(); } - constexpr T& value() + constexpr T& + value() { return Base::value(); } - constexpr E const& error() const + constexpr E const& + error() const { return Base::error(); } - constexpr E& error() + constexpr E& + error() { return Base::error(); } - constexpr explicit operator bool() const + constexpr explicit + operator bool() const { return has_value(); } @@ -181,22 +186,26 @@ class [[nodiscard]] Expected // Add operator* and operator-> so the Expected API looks a bit more like // what std::expected is likely to look like. See: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p0323r10.html - [[nodiscard]] constexpr T& operator*() + [[nodiscard]] constexpr T& + operator*() { return this->value(); } - [[nodiscard]] constexpr T const& operator*() const + [[nodiscard]] constexpr T const& + operator*() const { return this->value(); } - [[nodiscard]] constexpr T* operator->() + [[nodiscard]] constexpr T* + operator->() { return &this->value(); } - [[nodiscard]] constexpr T const* operator->() const + [[nodiscard]] constexpr T const* + operator->() const { return &this->value(); } @@ -218,23 +227,25 @@ class [[nodiscard]] Expected } template - requires std::convertible_to && - (!std::is_reference_v)constexpr Expected(Unexpected e) - : Base(E(std::move(e.value()))) + requires std::convertible_to && (!std::is_reference_v) + constexpr Expected(Unexpected e) : Base(E(std::move(e.value()))) { } - constexpr E const& error() const + constexpr E const& + error() const { return Base::error(); } - constexpr E& error() + constexpr E& + error() { return Base::error(); } - constexpr explicit operator bool() const + constexpr explicit + operator bool() const { return Base::has_value(); } diff --git a/include/xrpl/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h index 2f910295c7f..70f2fc9fa89 100644 --- a/include/xrpl/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -84,13 +84,13 @@ class TaggedFee : private boost::totally_ordered>, protected: template static constexpr bool is_compatible_v = - std::is_arithmetic_v&& std::is_arithmetic_v&& - std::is_convertible_v; + std::is_arithmetic_v && std::is_arithmetic_v && + std::is_convertible_v; template > static constexpr bool is_compatiblefee_v = - is_compatible_v&& - std::is_same_v; + is_compatible_v && + std::is_same_v; template using enable_if_compatible_t = @@ -110,7 +110,8 @@ class TaggedFee : private boost::totally_ordered>, { } - constexpr TaggedFee& operator=(beast::Zero) + constexpr TaggedFee& + operator=(beast::Zero) { fee_ = 0; return *this; @@ -250,7 +251,8 @@ class TaggedFee : private boost::totally_ordered>, } /** Returns true if the amount is not zero */ - explicit constexpr operator bool() const noexcept + explicit constexpr + operator bool() const noexcept { return fee_ != 0; } @@ -344,8 +346,8 @@ constexpr bool can_muldiv_source_v = template > constexpr bool can_muldiv_dest_v = - can_muldiv_source_v&& // Dest is also a source - std::is_convertible_v && + can_muldiv_source_v && // Dest is also a source + std::is_convertible_v && sizeof(typename Dest::value_type) >= sizeof(std::uint64_t); template < @@ -354,8 +356,8 @@ template < class = enable_if_unit_t, class = enable_if_unit_t> constexpr bool can_muldiv_sources_v = - can_muldiv_source_v&& can_muldiv_source_v&& std:: - is_same_v; + can_muldiv_source_v && can_muldiv_source_v && + std::is_same_v; template < class Source1, @@ -365,7 +367,7 @@ template < class = enable_if_unit_t, class = enable_if_unit_t> constexpr bool can_muldiv_v = - can_muldiv_sources_v&& can_muldiv_dest_v; + can_muldiv_sources_v && can_muldiv_dest_v; // Source and Dest can be the same by default template < diff --git a/include/xrpl/basics/IOUAmount.h b/include/xrpl/basics/IOUAmount.h index 221434aa85a..e89feb123d0 100644 --- a/include/xrpl/basics/IOUAmount.h +++ b/include/xrpl/basics/IOUAmount.h @@ -82,7 +82,8 @@ class IOUAmount : private boost::totally_ordered, operator<(IOUAmount const& other) const; /** Returns true if the amount is not zero */ - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; /** Return the sign of the amount */ int @@ -109,7 +110,8 @@ inline IOUAmount::IOUAmount(std::int64_t mantissa, int exponent) normalize(); } -inline IOUAmount& IOUAmount::operator=(beast::Zero) +inline IOUAmount& +IOUAmount::operator=(beast::Zero) { // The -100 is used to allow 0 to sort less than small positive values // which will have a large negative exponent. diff --git a/include/xrpl/basics/Number.h b/include/xrpl/basics/Number.h index 30ce3f73173..5856ef325dc 100644 --- a/include/xrpl/basics/Number.h +++ b/include/xrpl/basics/Number.h @@ -88,8 +88,10 @@ class Number static constexpr Number lowest() noexcept; - explicit operator XRPAmount() const; // round to nearest, even on tie - explicit operator rep() const; // round to nearest, even on tie + explicit + operator XRPAmount() const; // round to nearest, even on tie + explicit + operator rep() const; // round to nearest, even on tie friend constexpr bool operator==(Number const& x, Number const& y) noexcept diff --git a/include/xrpl/basics/XRPAmount.h b/include/xrpl/basics/XRPAmount.h index 1d3b32f169b..9a322695168 100644 --- a/include/xrpl/basics/XRPAmount.h +++ b/include/xrpl/basics/XRPAmount.h @@ -65,7 +65,8 @@ class XRPAmount : private boost::totally_ordered, { } - constexpr XRPAmount& operator=(beast::Zero) + constexpr XRPAmount& + operator=(beast::Zero) { drops_ = 0; return *this; @@ -155,7 +156,8 @@ class XRPAmount : private boost::totally_ordered, } /** Returns true if the amount is not zero */ - explicit constexpr operator bool() const noexcept + explicit constexpr + operator bool() const noexcept { return drops_ != 0; } diff --git a/include/xrpl/basics/base_uint.h b/include/xrpl/basics/base_uint.h index ea99cdf420e..c933a7c5942 100644 --- a/include/xrpl/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -526,7 +526,8 @@ class base_uint return bytes; } - base_uint& operator=(beast::Zero) + base_uint& + operator=(beast::Zero) { data_.fill(0); return *this; diff --git a/include/xrpl/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h index e52bceca759..f193f1793f2 100644 --- a/include/xrpl/basics/safe_cast.h +++ b/include/xrpl/basics/safe_cast.h @@ -30,8 +30,8 @@ namespace ripple { template static constexpr bool is_safetocasttovalue_v = - (std::is_integral_v && std::is_integral_v)&&( - std::is_signed::value || std::is_unsigned::value) && + (std::is_integral_v && std::is_integral_v) && + (std::is_signed::value || std::is_unsigned::value) && (std::is_signed::value != std::is_signed::value ? sizeof(Dest) > sizeof(Src) : sizeof(Dest) >= sizeof(Src)); diff --git a/include/xrpl/basics/tagged_integer.h b/include/xrpl/basics/tagged_integer.h index 3ab8c534098..4629e830916 100644 --- a/include/xrpl/basics/tagged_integer.h +++ b/include/xrpl/basics/tagged_integer.h @@ -187,7 +187,8 @@ class tagged_integer return *this; } - explicit operator Int() const noexcept + explicit + operator Int() const noexcept { return m_value; } diff --git a/include/xrpl/beast/container/detail/aged_ordered_container.h b/include/xrpl/beast/container/detail/aged_ordered_container.h index 90a8ea147ae..ad807e92cfe 100644 --- a/include/xrpl/beast/container/detail/aged_ordered_container.h +++ b/include/xrpl/beast/container/detail/aged_ordered_container.h @@ -846,8 +846,9 @@ class aged_ordered_container // set template auto - insert(value_type&& value) -> typename std:: - enable_if>::type; + insert(value_type&& value) -> typename std::enable_if< + !maybe_multi && !maybe_map, + std::pair>::type; // multiset template @@ -1795,7 +1796,8 @@ template < template auto aged_ordered_container:: - insert(value_type&& value) -> typename std:: + insert(value_type&& value) -> + typename std:: enable_if>::type { typename cont_type::insert_commit_data d; diff --git a/include/xrpl/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h index a2c5b4d3657..30c8489693e 100644 --- a/include/xrpl/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -1057,8 +1057,9 @@ class aged_unordered_container // map, set template auto - insert(value_type&& value) -> typename std:: - enable_if>::type; + insert(value_type&& value) -> typename std::enable_if< + !maybe_multi && !maybe_map, + std::pair>::type; // multimap, multiset template @@ -2805,8 +2806,9 @@ aged_unordered_container< Clock, Hash, KeyEqual, - Allocator>::insert(value_type&& value) -> typename std:: - enable_if>::type + Allocator>::insert(value_type&& value) -> + typename std:: + enable_if>::type { maybe_rehash(1); typename cont_type::insert_commit_data d; diff --git a/include/xrpl/beast/hash/xxhasher.h b/include/xrpl/beast/hash/xxhasher.h index 1a6fc502321..30af05ef0a1 100644 --- a/include/xrpl/beast/hash/xxhasher.h +++ b/include/xrpl/beast/hash/xxhasher.h @@ -90,7 +90,8 @@ class xxhasher XXH3_64bits_update(state_, key, len); } - explicit operator std::size_t() noexcept + explicit + operator std::size_t() noexcept { return XXH3_64bits_digest(state_); } diff --git a/include/xrpl/beast/unit_test.h b/include/xrpl/beast/unit_test.h index eff82583ea7..bf33b205e62 100644 --- a/include/xrpl/beast/unit_test.h +++ b/include/xrpl/beast/unit_test.h @@ -34,7 +34,7 @@ #ifndef BEAST_EXPECT #define BEAST_EXPECT_S1(x) #x #define BEAST_EXPECT_S2(x) BEAST_EXPECT_S1(x) -//#define BEAST_EXPECT(cond) {expect(cond, __FILE__ ":" ## +// #define BEAST_EXPECT(cond) {expect(cond, __FILE__ ":" ## //__LINE__);}while(false){} #define BEAST_EXPECT(cond) expect(cond, __FILE__ ":" BEAST_EXPECT_S2(__LINE__)) #endif diff --git a/include/xrpl/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h index f407dee1fff..aaa53a3515d 100644 --- a/include/xrpl/beast/utility/Journal.h +++ b/include/xrpl/beast/utility/Journal.h @@ -240,7 +240,8 @@ class Journal return m_sink.active(m_level); } - explicit operator bool() const + explicit + operator bool() const { return active(); } diff --git a/include/xrpl/json/json_value.h b/include/xrpl/json/json_value.h index c2f9184d79a..e419940171e 100644 --- a/include/xrpl/json/json_value.h +++ b/include/xrpl/json/json_value.h @@ -64,7 +64,8 @@ class StaticString { } - constexpr operator const char*() const + constexpr + operator const char*() const { return str_; } @@ -296,7 +297,8 @@ class Value /** Returns false if this is an empty array, empty object, empty string, or null. */ - explicit operator bool() const; + explicit + operator bool() const; /// Remove all object members and array elements. /// \pre type() is arrayValue, objectValue, or nullValue diff --git a/include/xrpl/protocol/AccountID.h b/include/xrpl/protocol/AccountID.h index ebe7f014d9c..7edf8d388f7 100644 --- a/include/xrpl/protocol/AccountID.h +++ b/include/xrpl/protocol/AccountID.h @@ -22,7 +22,7 @@ #include // VFALCO Uncomment when the header issues are resolved -//#include +// #include #include #include #include diff --git a/include/xrpl/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h index 1cd03b0651d..dd09cf6bd1a 100644 --- a/include/xrpl/protocol/ApiVersion.h +++ b/include/xrpl/protocol/ApiVersion.h @@ -76,38 +76,35 @@ static_assert(apiMaximumValidVersion >= apiMaximumSupportedVersion); } // namespace RPC template - void - forApiVersions(Fn const& fn, Args&&... args) requires // - (maxVer >= minVer) && // - (minVer >= RPC::apiMinimumSupportedVersion) && // - (RPC::apiMaximumValidVersion >= maxVer) && - requires -{ - fn(std::integral_constant{}, - std::forward(args)...); - fn(std::integral_constant{}, - std::forward(args)...); -} +void +forApiVersions(Fn const& fn, Args&&... args) + requires // + (maxVer >= minVer) && // + (minVer >= RPC::apiMinimumSupportedVersion) && // + (RPC::apiMaximumValidVersion >= maxVer) && requires { + fn(std::integral_constant{}, + std::forward(args)...); + fn(std::integral_constant{}, + std::forward(args)...); + } { constexpr auto size = maxVer + 1 - minVer; - [&](std::index_sequence) - { + [&](std::index_sequence) { (((void)fn( std::integral_constant{}, std::forward(args)...)), ...); - } - (std::make_index_sequence{}); + }(std::make_index_sequence{}); } template void -forAllApiVersions(Fn const& fn, Args&&... args) requires requires -{ - forApiVersions< - RPC::apiMinimumSupportedVersion, - RPC::apiMaximumValidVersion>(fn, std::forward(args)...); -} +forAllApiVersions(Fn const& fn, Args&&... args) + requires requires { + forApiVersions< + RPC::apiMinimumSupportedVersion, + RPC::apiMaximumValidVersion>(fn, std::forward(args)...); + } { forApiVersions< RPC::apiMinimumSupportedVersion, diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index 7f7c8521f0a..e1f65199617 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -80,9 +80,8 @@ struct MultiApiJson } void - set(const char* key, - auto const& - v) requires std::constructible_from + set(const char* key, auto const& v) + requires std::constructible_from { for (auto& a : this->val) a[key] = v; @@ -110,7 +109,8 @@ struct MultiApiJson unsigned int Version, typename... Args, typename Fn> - requires std::same_as, MultiApiJson> auto + requires std::same_as, MultiApiJson> + auto operator()( Json& json, std::integral_constant const version, @@ -133,7 +133,8 @@ struct MultiApiJson // integral_constant version, Json only template - requires std::same_as, MultiApiJson> auto + requires std::same_as, MultiApiJson> + auto operator()( Json& json, std::integral_constant const, @@ -151,10 +152,10 @@ struct MultiApiJson typename... Args, typename Fn> requires(!some_integral_constant) && - std::convertible_to&& std::same_as< - std::remove_cvref_t, - MultiApiJson> auto - operator()(Json& json, Version version, Fn fn, Args&&... args) const + std::convertible_to && + std::same_as, MultiApiJson> + auto + operator()(Json& json, Version version, Fn fn, Args&&... args) const -> std:: invoke_result_t { @@ -172,9 +173,10 @@ struct MultiApiJson // unsigned int version, Json only template requires(!some_integral_constant) && - std::convertible_to&& std:: - same_as, MultiApiJson> auto - operator()(Json& json, Version version, Fn fn) const + std::convertible_to && + std::same_as, MultiApiJson> + auto + operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { ASSERT( @@ -187,53 +189,43 @@ struct MultiApiJson auto visit() { - return [self = this](auto... args) requires requires - { - visitor( - std::declval(), - std::declval()...); - } - { - return visitor(*self, std::forward(args)...); - }; + return [self = this](auto... args) + requires requires { + visitor( + std::declval(), + std::declval()...); + } + { return visitor(*self, std::forward(args)...); }; } auto visit() const { - return [self = this](auto... args) requires requires - { - visitor( - std::declval(), - std::declval()...); - } - { - return visitor(*self, std::forward(args)...); - }; + return [self = this](auto... args) + requires requires { + visitor( + std::declval(), + std::declval()...); + } + { return visitor(*self, std::forward(args)...); }; } template - auto - visit(Args... args) - -> std::invoke_result_t requires( - sizeof...(args) > 0) && - requires - { - visitor(*this, std::forward(args)...); - } + auto + visit(Args... args) + -> std::invoke_result_t + requires(sizeof...(args) > 0) && + requires { visitor(*this, std::forward(args)...); } { return visitor(*this, std::forward(args)...); } template - auto - visit(Args... args) const -> std:: - invoke_result_t requires( - sizeof...(args) > 0) && - requires - { - visitor(*this, std::forward(args)...); - } + auto + visit(Args... args) const + -> std::invoke_result_t + requires(sizeof...(args) > 0) && + requires { visitor(*this, std::forward(args)...); } { return visitor(*this, std::forward(args)...); } diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index 3eed0860f54..34f82d4cebb 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -197,7 +197,8 @@ class STAmount final : public STBase, public CountedObject // //-------------------------------------------------------------------------- - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; STAmount& operator+=(STAmount const&); @@ -388,7 +389,8 @@ inline STAmount::operator Number() const return iou(); } -inline STAmount& STAmount::operator=(beast::Zero) +inline STAmount& +STAmount::operator=(beast::Zero) { clear(); return *this; diff --git a/include/xrpl/protocol/STBase.h b/include/xrpl/protocol/STBase.h index e13ef6c5b3e..097341384f3 100644 --- a/include/xrpl/protocol/STBase.h +++ b/include/xrpl/protocol/STBase.h @@ -52,11 +52,13 @@ struct JsonOptions { } - [[nodiscard]] constexpr explicit operator underlying_t() const noexcept + [[nodiscard]] constexpr explicit + operator underlying_t() const noexcept { return value; } - [[nodiscard]] constexpr explicit operator bool() const noexcept + [[nodiscard]] constexpr explicit + operator bool() const noexcept { return value != 0u; } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index e1485120c58..b54ed962e58 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -539,7 +539,8 @@ class STObject::OptionalProxy : private Proxy Fields with soeDEFAULT and set to the default value will return `true` */ - explicit operator bool() const noexcept; + explicit + operator bool() const noexcept; /** Return the contained value diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index e70297a40bf..d81ddf977ff 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -65,7 +65,8 @@ class STVector256 : public STBase, public CountedObject setValue(const STVector256& v); /** Retrieve a copy of the vector we contain */ - explicit operator std::vector() const; + explicit + operator std::vector() const; std::size_t size() const; diff --git a/include/xrpl/protocol/TER.h b/include/xrpl/protocol/TER.h index aae3c7107bd..5b659249dfd 100644 --- a/include/xrpl/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -434,7 +434,8 @@ class TERSubset } // Conversion to bool. - explicit operator bool() const + explicit + operator bool() const { return code_ != tesSUCCESS; } @@ -480,60 +481,66 @@ class TERSubset // Only enabled if both arguments return int if TERtiInt is called with them. template constexpr auto -operator==(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator==(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) == TERtoInt(rhs); } template constexpr auto -operator!=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator!=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) != TERtoInt(rhs); } template constexpr auto -operator<(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator<(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) < TERtoInt(rhs); } template constexpr auto -operator<=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator<=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) <= TERtoInt(rhs); } template constexpr auto -operator>(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator>(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) > TERtoInt(rhs); } template constexpr auto -operator>=(L const& lhs, R const& rhs) -> std::enable_if_t< - std::is_same::value && - std::is_same::value, - bool> +operator>=(L const& lhs, R const& rhs) + -> std::enable_if_t< + std::is_same::value && + std::is_same::value, + bool> { return TERtoInt(lhs) >= TERtoInt(rhs); } diff --git a/include/xrpl/protocol/digest.h b/include/xrpl/protocol/digest.h index f3fc2ea5c5d..b3c7a014100 100644 --- a/include/xrpl/protocol/digest.h +++ b/include/xrpl/protocol/digest.h @@ -55,7 +55,8 @@ struct openssl_ripemd160_hasher void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[96]; @@ -77,7 +78,8 @@ struct openssl_sha512_hasher void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[216]; @@ -99,7 +101,8 @@ struct openssl_sha256_hasher void operator()(void const* data, std::size_t size) noexcept; - explicit operator result_type() noexcept; + explicit + operator result_type() noexcept; private: char ctx_[112]; @@ -144,7 +147,8 @@ struct ripesha_hasher h_(data, size); } - explicit operator result_type() noexcept + explicit + operator result_type() noexcept { auto const d0 = sha256_hasher::result_type(h_); ripemd160_hasher rh; @@ -184,18 +188,21 @@ struct basic_sha512_half_hasher h_(data, size); } - explicit operator result_type() noexcept + explicit + operator result_type() noexcept { auto const digest = sha512_hasher::result_type(h_); return result_type::fromVoid(digest.data()); } private: - inline void erase(std::false_type) + inline void + erase(std::false_type) { } - inline void erase(std::true_type) + inline void + erase(std::true_type) { secure_erase(&h_, sizeof(h_)); } diff --git a/include/xrpl/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index d7e6da9e9e1..bcdddcc711d 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -244,7 +244,7 @@ BaseHTTPPeer::close() return post( strand_, std::bind( - (void (BaseHTTPPeer::*)(void)) & BaseHTTPPeer::close, + (void(BaseHTTPPeer::*)(void)) & BaseHTTPPeer::close, impl().shared_from_this())); boost::beast::get_lowest_layer(impl().stream_).close(); } @@ -507,7 +507,7 @@ BaseHTTPPeer::close(bool graceful) return post( strand_, std::bind( - (void (BaseHTTPPeer::*)(bool)) & + (void(BaseHTTPPeer::*)(bool)) & BaseHTTPPeer::close, impl().shared_from_this(), graceful)); diff --git a/src/libxrpl/basics/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp index 9191ff90baa..efaaf80b5af 100644 --- a/src/libxrpl/basics/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -243,7 +243,8 @@ class ResolverAsioImpl : public ResolverAsio, //------------------------------------------------------------------------- // Resolver - void do_stop(CompletionCounter) + void + do_stop(CompletionCounter) { ASSERT( m_stop_called == true, @@ -343,7 +344,8 @@ class ResolverAsioImpl : public ResolverAsio, std::string(port_first, port_last)); } - void do_work(CompletionCounter) + void + do_work(CompletionCounter) { if (m_stop_called == true) return; diff --git a/src/libxrpl/beast/insight/NullCollector.cpp b/src/libxrpl/beast/insight/NullCollector.cpp index 637cd06ec3b..12ea817014e 100644 --- a/src/libxrpl/beast/insight/NullCollector.cpp +++ b/src/libxrpl/beast/insight/NullCollector.cpp @@ -41,7 +41,8 @@ class NullCounterImpl : public CounterImpl public: explicit NullCounterImpl() = default; - void increment(value_type) override + void + increment(value_type) override { } @@ -74,11 +75,13 @@ class NullGaugeImpl : public GaugeImpl public: explicit NullGaugeImpl() = default; - void set(value_type) override + void + set(value_type) override { } - void increment(difference_type) override + void + increment(difference_type) override { } @@ -94,7 +97,8 @@ class NullMeterImpl : public MeterImpl public: explicit NullMeterImpl() = default; - void increment(value_type) override + void + increment(value_type) override { } diff --git a/src/libxrpl/beast/utility/src/beast_Journal.cpp b/src/libxrpl/beast/utility/src/beast_Journal.cpp index 5e907c8ec0c..449f474739c 100644 --- a/src/libxrpl/beast/utility/src/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/src/beast_Journal.cpp @@ -34,7 +34,8 @@ class NullJournalSink : public Journal::Sink ~NullJournalSink() override = default; - bool active(severities::Severity) const override + bool + active(severities::Severity) const override { return false; } @@ -56,7 +57,8 @@ class NullJournalSink : public Journal::Sink return severities::kDisabled; } - void threshold(severities::Severity) override + void + threshold(severities::Severity) override { } diff --git a/src/libxrpl/json/Writer.cpp b/src/libxrpl/json/Writer.cpp index ba7336209e6..2f7c0b523c6 100644 --- a/src/libxrpl/json/Writer.cpp +++ b/src/libxrpl/json/Writer.cpp @@ -285,7 +285,8 @@ Writer::output(double f) impl_->output({s.data(), lengthWithoutTrailingZeros(s)}); } -void Writer::output(std::nullptr_t) +void +Writer::output(std::nullptr_t) { impl_->output("null"); } diff --git a/src/libxrpl/protocol/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp index 97561ffee15..4e754d38e6c 100644 --- a/src/libxrpl/protocol/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -671,7 +671,8 @@ STAmount::getText() const return ret; } -Json::Value STAmount::getJson(JsonOptions) const +Json::Value +STAmount::getJson(JsonOptions) const { Json::Value elem; setJson(elem); diff --git a/src/libxrpl/protocol/STBase.cpp b/src/libxrpl/protocol/STBase.cpp index cf322039d84..d93068bb053 100644 --- a/src/libxrpl/protocol/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -95,7 +95,8 @@ STBase::getText() const return std::string(); } -Json::Value STBase::getJson(JsonOptions /*options*/) const +Json::Value +STBase::getJson(JsonOptions /*options*/) const { return getText(); } diff --git a/src/libxrpl/protocol/STCurrency.cpp b/src/libxrpl/protocol/STCurrency.cpp index c8fc650135a..56ac19da114 100644 --- a/src/libxrpl/protocol/STCurrency.cpp +++ b/src/libxrpl/protocol/STCurrency.cpp @@ -50,7 +50,8 @@ STCurrency::getText() const return to_string(currency_); } -Json::Value STCurrency::getJson(JsonOptions) const +Json::Value +STCurrency::getJson(JsonOptions) const { return to_string(currency_); } diff --git a/src/libxrpl/protocol/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp index 1f208e832bf..91ac9e98d3d 100644 --- a/src/libxrpl/protocol/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -61,7 +61,8 @@ STUInt8::getText() const } template <> -Json::Value STUInt8::getJson(JsonOptions) const +Json::Value +STUInt8::getJson(JsonOptions) const { if (getFName() == sfTransactionResult) { @@ -118,7 +119,8 @@ STUInt16::getText() const } template <> -Json::Value STUInt16::getJson(JsonOptions) const +Json::Value +STUInt16::getJson(JsonOptions) const { if (getFName() == sfLedgerEntryType) { @@ -164,7 +166,8 @@ STUInt32::getText() const } template <> -Json::Value STUInt32::getJson(JsonOptions) const +Json::Value +STUInt32::getJson(JsonOptions) const { return value_; } @@ -192,7 +195,8 @@ STUInt64::getText() const } template <> -Json::Value STUInt64::getJson(JsonOptions) const +Json::Value +STUInt64::getJson(JsonOptions) const { std::string str(16, 0); auto ret = std::to_chars(str.data(), str.data() + str.size(), value_, 16); diff --git a/src/libxrpl/protocol/STIssue.cpp b/src/libxrpl/protocol/STIssue.cpp index 9dcee6498ab..00fe86b3287 100644 --- a/src/libxrpl/protocol/STIssue.cpp +++ b/src/libxrpl/protocol/STIssue.cpp @@ -65,7 +65,8 @@ STIssue::getSType() const return STI_ISSUE; } -Json::Value STIssue::getJson(JsonOptions) const +Json::Value +STIssue::getJson(JsonOptions) const { return to_json(issue_); } diff --git a/src/libxrpl/protocol/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp index 025ea164c8e..9b68a930dcd 100644 --- a/src/libxrpl/protocol/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -967,8 +967,7 @@ parseArray( Json::Value const objectFields(json[i][objectName]); std::stringstream ss; - ss << json_name << "." - << "[" << i << "]." << objectName; + ss << json_name << "." << "[" << i << "]." << objectName; auto ret = parseObject( ss.str(), objectFields, nameField, depth + 1, error); diff --git a/src/libxrpl/protocol/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp index 94262e966c8..3409299d7cb 100644 --- a/src/libxrpl/protocol/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -163,7 +163,8 @@ STPath::hasSeen( return false; } -Json::Value STPath::getJson(JsonOptions) const +Json::Value +STPath::getJson(JsonOptions) const { Json::Value ret(Json::arrayValue); diff --git a/src/libxrpl/protocol/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp index ce9125024d3..e9ea1e862de 100644 --- a/src/libxrpl/protocol/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -82,7 +82,8 @@ STVector256::isEquivalent(const STBase& t) const return v && (mValue == v->mValue); } -Json::Value STVector256::getJson(JsonOptions) const +Json::Value +STVector256::getJson(JsonOptions) const { Json::Value ret(Json::arrayValue); diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index 35a8858f868..a84ac63da9d 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -323,7 +323,8 @@ class NFTokenBurnBaseUtil_test : public beast::unit_test::suite // Otherwise either alice or minter can burn. AcctStat& burner = owner.acct == becky.acct ? *(stats[acctDist(engine)]) - : mintDist(engine) ? alice : minter; + : mintDist(engine) ? alice + : minter; if (owner.acct == burner.acct) env(token::burn(burner, nft)); diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index 4bc7f2f270d..1ec302efef8 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -78,20 +78,21 @@ class ValidatorSite_test : public beast::unit_test::suite BEAST_EXPECT(trustedSites->load(emptyCfgSites)); // load should accept valid validator site uris - std::vector cfgSites({ - "http://ripple.com/", "http://ripple.com/validators", - "http://ripple.com:8080/validators", - "http://207.261.33.37/validators", - "http://207.261.33.37:8080/validators", - "https://ripple.com/validators", - "https://ripple.com:443/validators", - "file:///etc/opt/ripple/validators.txt", - "file:///C:/Lib/validators.txt" + std::vector cfgSites( + {"http://ripple.com/", + "http://ripple.com/validators", + "http://ripple.com:8080/validators", + "http://207.261.33.37/validators", + "http://207.261.33.37:8080/validators", + "https://ripple.com/validators", + "https://ripple.com:443/validators", + "file:///etc/opt/ripple/validators.txt", + "file:///C:/Lib/validators.txt" #if !_MSC_VER - , - "file:///" + , + "file:///" #endif - }); + }); BEAST_EXPECT(trustedSites->load(cfgSites)); // load should reject validator site uris with invalid schemes diff --git a/src/test/basics/IOUAmount_test.cpp b/src/test/basics/IOUAmount_test.cpp index 6e7c662635f..e588a08dc02 100644 --- a/src/test/basics/IOUAmount_test.cpp +++ b/src/test/basics/IOUAmount_test.cpp @@ -219,55 +219,56 @@ class IOUAmount_test : public beast::unit_test::suite tinyNeg == mulRatio(tinyNeg, maxUInt - 1, maxUInt, false)); } - {// rounding - {IOUAmount one(1, 0); - auto const rup = mulRatio(one, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(one, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); - } - { - IOUAmount big(maxMantissa, maxExponent); - auto const rup = mulRatio(big, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(big, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); - } - - { - IOUAmount negOne(-1, 0); - auto const rup = mulRatio(negOne, maxUInt - 1, maxUInt, true); - auto const rdown = mulRatio(negOne, maxUInt - 1, maxUInt, false); - BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); - } -} + { // rounding + { + IOUAmount one(1, 0); + auto const rup = mulRatio(one, maxUInt - 1, maxUInt, true); + auto const rdown = mulRatio(one, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + { + IOUAmount big(maxMantissa, maxExponent); + auto const rup = mulRatio(big, maxUInt - 1, maxUInt, true); + auto const rdown = mulRatio(big, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + + { + IOUAmount negOne(-1, 0); + auto const rup = mulRatio(negOne, maxUInt - 1, maxUInt, true); + auto const rdown = + mulRatio(negOne, maxUInt - 1, maxUInt, false); + BEAST_EXPECT(rup.mantissa() - rdown.mantissa() == 1); + } + } -{ - // division by zero - IOUAmount one(1, 0); - except([&] { mulRatio(one, 1, 0, true); }); -} + { + // division by zero + IOUAmount one(1, 0); + except([&] { mulRatio(one, 1, 0, true); }); + } -{ - // overflow - IOUAmount big(maxMantissa, maxExponent); - except([&] { mulRatio(big, 2, 0, true); }); -} -} // namespace ripple + { + // overflow + IOUAmount big(maxMantissa, maxExponent); + except([&] { mulRatio(big, 2, 0, true); }); + } + } // namespace ripple -//-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- -void -run() override -{ - testZero(); - testSigNum(); - testBeastZero(); - testComparisons(); - testToString(); - testMulRatio(); -} -} -; + void + run() override + { + testZero(); + testSigNum(); + testBeastZero(); + testComparisons(); + testToString(); + testMulRatio(); + } +}; BEAST_DEFINE_TESTSUITE(IOUAmount, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/test/basics/XRPAmount_test.cpp b/src/test/basics/XRPAmount_test.cpp index c4c96dbfbde..c57890fcfa5 100644 --- a/src/test/basics/XRPAmount_test.cpp +++ b/src/test/basics/XRPAmount_test.cpp @@ -283,63 +283,67 @@ class XRPAmount_test : public beast::unit_test::suite tinyNeg == mulRatio(tinyNeg, maxUInt32 - 1, maxUInt32, false)); } - {// rounding - {XRPAmount one(1); - auto const rup = mulRatio(one, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(one, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); - } + { // rounding + { + XRPAmount one(1); + auto const rup = mulRatio(one, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(one, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } - { - XRPAmount big(maxXRP); - auto const rup = mulRatio(big, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(big, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); - } + { + XRPAmount big(maxXRP); + auto const rup = mulRatio(big, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(big, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } - { - XRPAmount negOne(-1); - auto const rup = mulRatio(negOne, maxUInt32 - 1, maxUInt32, true); - auto const rdown = mulRatio(negOne, maxUInt32 - 1, maxUInt32, false); - BEAST_EXPECT(rup.drops() - rdown.drops() == 1); - } -} + { + XRPAmount negOne(-1); + auto const rup = + mulRatio(negOne, maxUInt32 - 1, maxUInt32, true); + auto const rdown = + mulRatio(negOne, maxUInt32 - 1, maxUInt32, false); + BEAST_EXPECT(rup.drops() - rdown.drops() == 1); + } + } -{ - // division by zero - XRPAmount one(1); - except([&] { mulRatio(one, 1, 0, true); }); -} + { + // division by zero + XRPAmount one(1); + except([&] { mulRatio(one, 1, 0, true); }); + } -{ - // overflow - XRPAmount big(maxXRP); - except([&] { mulRatio(big, 2, 1, true); }); -} + { + // overflow + XRPAmount big(maxXRP); + except([&] { mulRatio(big, 2, 1, true); }); + } -{ - // underflow - XRPAmount bigNegative(minXRP + 10); - BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == minXRP); -} -} // namespace ripple + { + // underflow + XRPAmount bigNegative(minXRP + 10); + BEAST_EXPECT(mulRatio(bigNegative, 2, 1, true) == minXRP); + } + } // namespace ripple -//-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- -void -run() override -{ - testSigNum(); - testBeastZero(); - testComparisons(); - testAddSub(); - testDecimal(); - testFunctions(); - testMulRatio(); -} -} -; + void + run() override + { + testSigNum(); + testBeastZero(); + testComparisons(); + testAddSub(); + testDecimal(); + testFunctions(); + testMulRatio(); + } +}; BEAST_DEFINE_TESTSUITE(XRPAmount, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 43000a1128c..9f3194f4fbc 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -48,7 +48,8 @@ struct nonhash memcpy(data_.data(), key, len); } - explicit operator std::size_t() noexcept + explicit + operator std::size_t() noexcept { return WIDTH; } diff --git a/src/test/beast/beast_Zero_test.cpp b/src/test/beast/beast_Zero_test.cpp index b6071636255..8fd16a4d51f 100644 --- a/src/test/beast/beast_Zero_test.cpp +++ b/src/test/beast/beast_Zero_test.cpp @@ -27,7 +27,8 @@ struct adl_tester { }; -int signum(adl_tester) +int +signum(adl_tester) { return 0; } @@ -38,7 +39,8 @@ struct adl_tester2 { }; -int signum(adl_tester2) +int +signum(adl_tester2) { return 0; } diff --git a/src/test/consensus/ByzantineFailureSim_test.cpp b/src/test/consensus/ByzantineFailureSim_test.cpp index ce59adbe9f0..92dbfc0174d 100644 --- a/src/test/consensus/ByzantineFailureSim_test.cpp +++ b/src/test/consensus/ByzantineFailureSim_test.cpp @@ -66,8 +66,8 @@ class ByzantineFailureSim_test : public beast::unit_test::suite for (TrustGraph::ForkInfo const& fi : sim.trustGraph.forkablePairs(0.8)) { - std::cout << "Can fork " << PeerGroup{fi.unlA} << " " - << " " << PeerGroup{fi.unlB} << " overlap " << fi.overlap + std::cout << "Can fork " << PeerGroup{fi.unlA} << " " << " " + << PeerGroup{fi.unlB} << " overlap " << fi.overlap << " required " << fi.required << "\n"; }; diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index 5eed78569f6..2f3b460e02f 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -644,7 +644,8 @@ struct Peer } // Not interested in tracking consensus mode changes for now - void onModeChange(ConsensusMode, ConsensusMode) + void + onModeChange(ConsensusMode, ConsensusMode) { } diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 511fb2c4b0f..8dcaa035314 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -281,66 +281,62 @@ struct TxCollector if (printBreakline) { - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" - << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(36) << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } - log << std::left << std::setw(11) << "TxStats" - << "|" << std::setw(7) << "Count" - << "|" << std::setw(7) << "Per Sec" - << "|" << std::setw(15) << "Latency (sec)" << std::right - << std::setw(7) << "10-ile" << std::setw(7) << "50-ile" - << std::setw(7) << "90-ile" << std::left << std::endl; + log << std::left << std::setw(11) << "TxStats" << "|" << std::setw(7) + << "Count" << "|" << std::setw(7) << "Per Sec" << "|" + << std::setw(15) << "Latency (sec)" << std::right << std::setw(7) + << "10-ile" << std::setw(7) << "50-ile" << std::setw(7) << "90-ile" + << std::left << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); - log << std::left << std::setw(11) << "Submit " - << "|" << std::right << std::setw(7) << submitted << "|" - << std::setw(7) << std::setprecision(2) << perSec(submitted) << "|" - << std::setw(36) << "" << std::endl; + log << std::left << std::setw(11) << "Submit " << "|" << std::right + << std::setw(7) << submitted << "|" << std::setw(7) + << std::setprecision(2) << perSec(submitted) << "|" << std::setw(36) + << "" << std::endl; - log << std::left << std::setw(11) << "Accept " - << "|" << std::right << std::setw(7) << accepted << "|" - << std::setw(7) << std::setprecision(2) << perSec(accepted) << "|" - << std::setw(15) << std::left << "From Submit" << std::right - << std::setw(7) << std::setprecision(2) - << fmtS(submitToAccept.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(submitToAccept.percentile(0.5f)) + log << std::left << std::setw(11) << "Accept " << "|" << std::right + << std::setw(7) << accepted << "|" << std::setw(7) + << std::setprecision(2) << perSec(accepted) << "|" << std::setw(15) + << std::left << "From Submit" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(submitToAccept.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(submitToAccept.percentile(0.9f)) << std::endl; + << fmtS(submitToAccept.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(submitToAccept.percentile(0.9f)) + << std::endl; - log << std::left << std::setw(11) << "Validate " - << "|" << std::right << std::setw(7) << validated << "|" - << std::setw(7) << std::setprecision(2) << perSec(validated) << "|" - << std::setw(15) << std::left << "From Submit" << std::right - << std::setw(7) << std::setprecision(2) - << fmtS(submitToValidate.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(submitToValidate.percentile(0.5f)) + log << std::left << std::setw(11) << "Validate " << "|" << std::right + << std::setw(7) << validated << "|" << std::setw(7) + << std::setprecision(2) << perSec(validated) << "|" << std::setw(15) + << std::left << "From Submit" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(submitToValidate.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(submitToValidate.percentile(0.9f)) << std::endl; - - log << std::left << std::setw(11) << "Orphan" - << "|" << std::right << std::setw(7) << orphaned() << "|" - << std::setw(7) << "" - << "|" << std::setw(36) << std::endl; - - log << std::left << std::setw(11) << "Unvalidated" - << "|" << std::right << std::setw(7) << unvalidated() << "|" - << std::setw(7) << "" - << "|" << std::setw(43) << std::endl; - - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" << std::endl; + << fmtS(submitToValidate.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(submitToValidate.percentile(0.9f)) + << std::endl; + + log << std::left << std::setw(11) << "Orphan" << "|" << std::right + << std::setw(7) << orphaned() << "|" << std::setw(7) << "" << "|" + << std::setw(36) << std::endl; + + log << std::left << std::setw(11) << "Unvalidated" << "|" << std::right + << std::setw(7) << unvalidated() << "|" << std::setw(7) << "" << "|" + << std::setw(43) << std::endl; + + log << std::setw(11) << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } @@ -362,34 +358,15 @@ struct TxCollector if (printHeaders) { - log << "tag" - << "," - << "txNumSubmitted" - << "," - << "txNumAccepted" - << "," - << "txNumValidated" - << "," - << "txNumOrphaned" - << "," - << "txUnvalidated" - << "," - << "txRateSumbitted" - << "," - << "txRateAccepted" - << "," - << "txRateValidated" - << "," - << "txLatencySubmitToAccept10Pctl" - << "," - << "txLatencySubmitToAccept50Pctl" - << "," - << "txLatencySubmitToAccept90Pctl" - << "," - << "txLatencySubmitToValidatet10Pctl" - << "," - << "txLatencySubmitToValidatet50Pctl" - << "," + log << "tag" << "," << "txNumSubmitted" << "," << "txNumAccepted" + << "," << "txNumValidated" << "," << "txNumOrphaned" << "," + << "txUnvalidated" << "," << "txRateSumbitted" << "," + << "txRateAccepted" << "," << "txRateValidated" << "," + << "txLatencySubmitToAccept10Pctl" << "," + << "txLatencySubmitToAccept50Pctl" << "," + << "txLatencySubmitToAccept90Pctl" << "," + << "txLatencySubmitToValidatet10Pctl" << "," + << "txLatencySubmitToValidatet50Pctl" << "," << "txLatencySubmitToValidatet90Pctl" << std::endl; } @@ -548,52 +525,50 @@ struct LedgerCollector if (printBreakline) { - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" - << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(7) << std::setfill('-') << "-" << "-" + << std::setw(36) << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } - log << std::left << std::setw(11) << "LedgerStats" - << "|" << std::setw(7) << "Count" - << "|" << std::setw(7) << "Per Sec" + log << std::left << std::setw(11) << "LedgerStats" << "|" + << std::setw(7) << "Count" << "|" << std::setw(7) << "Per Sec" << "|" << std::setw(15) << "Latency (sec)" << std::right << std::setw(7) << "10-ile" << std::setw(7) << "50-ile" << std::setw(7) << "90-ile" << std::left << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(7) << std::setfill('-') << "-" - << "|" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(7) + << std::setfill('-') << "-" << "|" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); - log << std::left << std::setw(11) << "Accept " - << "|" << std::right << std::setw(7) << accepted << "|" - << std::setw(7) << std::setprecision(2) << perSec(accepted) << "|" - << std::setw(15) << std::left << "From Accept" << std::right - << std::setw(7) << std::setprecision(2) - << fmtS(acceptToAccept.percentile(0.1f)) << std::setw(7) - << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.5f)) + log << std::left << std::setw(11) << "Accept " << "|" << std::right + << std::setw(7) << accepted << "|" << std::setw(7) + << std::setprecision(2) << perSec(accepted) << "|" << std::setw(15) + << std::left << "From Accept" << std::right << std::setw(7) + << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.1f)) << std::setw(7) << std::setprecision(2) - << fmtS(acceptToAccept.percentile(0.9f)) << std::endl; + << fmtS(acceptToAccept.percentile(0.5f)) << std::setw(7) + << std::setprecision(2) << fmtS(acceptToAccept.percentile(0.9f)) + << std::endl; - log << std::left << std::setw(11) << "Validate " - << "|" << std::right << std::setw(7) << fullyValidated << "|" - << std::setw(7) << std::setprecision(2) << perSec(fullyValidated) - << "|" << std::setw(15) << std::left << "From Validate " - << std::right << std::setw(7) << std::setprecision(2) + log << std::left << std::setw(11) << "Validate " << "|" << std::right + << std::setw(7) << fullyValidated << "|" << std::setw(7) + << std::setprecision(2) << perSec(fullyValidated) << "|" + << std::setw(15) << std::left << "From Validate " << std::right + << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.1f)) << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.5f)) << std::setw(7) << std::setprecision(2) << fmtS(fullyValidToFullyValid.percentile(0.9f)) << std::endl; - log << std::setw(11) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(7) << std::setfill('-') << "-" - << "-" << std::setw(36) << std::setfill('-') << "-" << std::endl; + log << std::setw(11) << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(7) + << std::setfill('-') << "-" << "-" << std::setw(36) + << std::setfill('-') << "-" << std::endl; log << std::setfill(' '); } @@ -615,26 +590,14 @@ struct LedgerCollector if (printHeaders) { - log << "tag" - << "," - << "ledgerNumAccepted" - << "," - << "ledgerNumFullyValidated" - << "," - << "ledgerRateAccepted" - << "," - << "ledgerRateFullyValidated" - << "," - << "ledgerLatencyAcceptToAccept10Pctl" - << "," - << "ledgerLatencyAcceptToAccept50Pctl" - << "," - << "ledgerLatencyAcceptToAccept90Pctl" - << "," - << "ledgerLatencyFullyValidToFullyValid10Pctl" - << "," - << "ledgerLatencyFullyValidToFullyValid50Pctl" - << "," + log << "tag" << "," << "ledgerNumAccepted" << "," + << "ledgerNumFullyValidated" << "," << "ledgerRateAccepted" + << "," << "ledgerRateFullyValidated" << "," + << "ledgerLatencyAcceptToAccept10Pctl" << "," + << "ledgerLatencyAcceptToAccept50Pctl" << "," + << "ledgerLatencyAcceptToAccept90Pctl" << "," + << "ledgerLatencyFullyValidToFullyValid10Pctl" << "," + << "ledgerLatencyFullyValidToFullyValid50Pctl" << "," << "ledgerLatencyFullyValidToFullyValid90Pctl" << std::endl; } @@ -695,16 +658,16 @@ struct StreamCollector on(PeerID who, SimTime when, AcceptLedger const& e) { out << when.time_since_epoch().count() << ": Node " << who - << " accepted " - << "L" << e.ledger.id() << " " << e.ledger.txs() << "\n"; + << " accepted " << "L" << e.ledger.id() << " " << e.ledger.txs() + << "\n"; } void on(PeerID who, SimTime when, FullyValidateLedger const& e) { out << when.time_since_epoch().count() << ": Node " << who - << " fully-validated " - << "L" << e.ledger.id() << " " << e.ledger.txs() << "\n"; + << " fully-validated " << "L" << e.ledger.id() << " " + << e.ledger.txs() << "\n"; } }; diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index 800662aa05b..7165bc26970 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -39,11 +39,11 @@ namespace jtx { // when we have moved to better compilers. template auto -make_vector(Input const& input) requires requires(Input& v) -{ - std::begin(v); - std::end(v); -} +make_vector(Input const& input) + requires requires(Input& v) { + std::begin(v); + std::end(v); + } { return std::vector(std::begin(input), std::end(input)); } diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index a10b9999ad2..b786cae2846 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -217,9 +217,8 @@ class TrustedPublisherServer getList_ = [blob = blob, sig, manifest, version](int interval) { // Build the contents of a version 1 format UNL file std::stringstream l; - l << "{\"blob\":\"" << blob << "\"" - << ",\"signature\":\"" << sig << "\"" - << ",\"manifest\":\"" << manifest << "\"" + l << "{\"blob\":\"" << blob << "\"" << ",\"signature\":\"" << sig + << "\"" << ",\"manifest\":\"" << manifest << "\"" << ",\"refresh_interval\": " << interval << ",\"version\":" << version << '}'; return l.str(); @@ -254,15 +253,14 @@ class TrustedPublisherServer std::stringstream l; for (auto const& info : blobInfo) { - l << "{\"blob\":\"" << info.blob << "\"" - << ",\"signature\":\"" << info.signature << "\"},"; + l << "{\"blob\":\"" << info.blob << "\"" << ",\"signature\":\"" + << info.signature << "\"},"; } std::string blobs = l.str(); blobs.pop_back(); l.str(std::string()); l << "{\"blobs_v2\": [ " << blobs << "],\"manifest\":\"" << manifest - << "\"" - << ",\"refresh_interval\": " << interval + << "\"" << ",\"refresh_interval\": " << interval << ",\"version\":" << (version + 1) << '}'; return l.str(); }; diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index c8e0d0c3701..459ec5b5c65 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -126,7 +126,7 @@ struct PrettyAmount return amount_; } - operator STAmount const &() const + operator STAmount const&() const { return amount_; } @@ -211,7 +211,8 @@ struct XRP_t /** @} */ /** Returns None-of-XRP */ - None operator()(none_t) const + None + operator()(none_t) const { return {xrpIssue()}; } @@ -327,14 +328,17 @@ class IOU return {amountFromString(issue(), std::to_string(v)), account.name()}; } - PrettyAmount operator()(epsilon_t) const; - PrettyAmount operator()(detail::epsilon_multiple) const; + PrettyAmount + operator()(epsilon_t) const; + PrettyAmount + operator()(detail::epsilon_multiple) const; // VFALCO TODO // STAmount operator()(char const* s) const; /** Returns None-of-Issue */ - None operator()(none_t) const + None + operator()(none_t) const { return {issue()}; } diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index c083b6df35c..8c369e68527 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -42,8 +42,8 @@ static IOUAmount initialTokens(STAmount const& asset1, STAmount const& asset2) { auto const product = number(asset1) * number(asset2); - return (IOUAmount)( - product.mantissa() >= 0 ? root2(product) : root2(-product)); + return (IOUAmount)(product.mantissa() >= 0 ? root2(product) + : root2(-product)); } AMM::AMM( diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 10252f45a8d..44a21e34fbb 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -104,7 +104,8 @@ operator<<(std::ostream& os, PrettyAmount const& amount) XRP_t const XRP{}; -PrettyAmount IOU::operator()(epsilon_t) const +PrettyAmount +IOU::operator()(epsilon_t) const { return {STAmount(issue(), 1, -81), account.name()}; } diff --git a/src/test/jtx/multisign.h b/src/test/jtx/multisign.h index 3946ea14b26..44cee17b7bf 100644 --- a/src/test/jtx/multisign.h +++ b/src/test/jtx/multisign.h @@ -100,9 +100,8 @@ class msig msig(std::vector signers_); template - requires std::convertible_to explicit msig( - AccountType&& a0, - Accounts&&... aN) + requires std::convertible_to + explicit msig(AccountType&& a0, Accounts&&... aN) : msig{std::vector{ std::forward(a0), std::forward(aN)...}} diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 4d9086dab10..e0b0d006a2f 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -888,9 +888,8 @@ class reduce_relay_test : public beast::unit_test::suite printPeers(const std::string& msg, std::uint16_t validator = 0) { auto peers = network_.overlay().getPeers(network_.validator(validator)); - std::cout << msg << " " - << "num peers " << (int)network_.overlay().getNumPeers() - << std::endl; + std::cout << msg << " " << "num peers " + << (int)network_.overlay().getNumPeers() << std::endl; for (auto& [k, v] : peers) std::cout << k << ":" << (int)std::get(v) << " "; diff --git a/src/test/protocol/MultiApiJson_test.cpp b/src/test/protocol/MultiApiJson_test.cpp index 2c0b410f899..a5c37d257c4 100644 --- a/src/test/protocol/MultiApiJson_test.cpp +++ b/src/test/protocol/MultiApiJson_test.cpp @@ -105,8 +105,8 @@ struct MultiApiJson_test : beast::unit_test::suite BEAST_EXPECT(!s1.valid(0)); BEAST_EXPECT(!s1.valid(RPC::apiMaximumValidVersion + 1)); BEAST_EXPECT( - !s1.valid(std::numeric_limits::max())); + !s1.valid(std::numeric_limits< + decltype(RPC::apiMaximumValidVersion.value)>::max())); int result = 1; static_assert( @@ -165,32 +165,28 @@ struct MultiApiJson_test : beast::unit_test::suite // Several overloads we want to fail static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&, auto) {}); // missing const }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&) {}); // missing const }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // []() {}); // missing parameters }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto) {}, @@ -198,8 +194,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto, auto) {}, @@ -207,8 +202,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { forAllApiVersions( std::forward(v).visit(), // [](auto, auto, const char*) {}, @@ -218,40 +212,35 @@ struct MultiApiJson_test : beast::unit_test::suite // Sanity checks static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value const&) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value const&, auto...) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](Json::Value&, auto, auto, auto...) {}, @@ -260,8 +249,7 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // []( @@ -274,16 +262,14 @@ struct MultiApiJson_test : beast::unit_test::suite }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { forAllApiVersions( std::forward(v).visit(), // [](auto...) {}); @@ -342,45 +328,25 @@ struct MultiApiJson_test : beast::unit_test::suite // Tests of requires clause - these are expected to match static_assert([](auto&& v) { - return requires - { - v.set("name", Json::nullValue); - }; + return requires { v.set("name", Json::nullValue); }; }(x)); static_assert([](auto&& v) { - return requires - { - v.set("name", "value"); - }; - }(x)); - static_assert([](auto&& v) { - return requires - { - v.set("name", true); - }; - }(x)); - static_assert([](auto&& v) { - return requires - { - v.set("name", 42); - }; + return requires { v.set("name", "value"); }; }(x)); + static_assert( + [](auto&& v) { return requires { v.set("name", true); }; }(x)); + static_assert( + [](auto&& v) { return requires { v.set("name", 42); }; }(x)); // Tests of requires clause - these are expected NOT to match struct foo_t final { }; static_assert([](auto&& v) { - return !requires - { - v.set("name", foo_t{}); - }; + return !requires { v.set("name", foo_t{}); }; }(x)); static_assert([](auto&& v) { - return !requires - { - v.set("name", std::nullopt); - }; + return !requires { v.set("name", std::nullopt); }; }(x)); } @@ -436,8 +402,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Test different overloads static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -458,8 +423,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -476,8 +440,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -498,8 +461,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor( v, std::integral_constant{}, @@ -516,8 +478,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value&, unsigned) {}); }; }(s1)); @@ -533,10 +494,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visitor( @@ -548,8 +506,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -565,10 +522,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value const&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( s1.visitor( @@ -671,8 +625,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Several overloads we want to fail static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -681,8 +634,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( std::move(v), // cannot bind rvalue 1, @@ -691,8 +643,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -701,8 +652,7 @@ struct MultiApiJson_test : beast::unit_test::suite }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { v.visitor( v, 1, // @@ -712,74 +662,52 @@ struct MultiApiJson_test : beast::unit_test::suite // Want these to be unambiguous static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto) {}); - }; + return requires { v.visitor(v, 1, [](auto) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value&) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value&, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](Json::Value const&) {}); - }; + return requires { v.visitor(v, 1, [](Json::Value const&) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](Json::Value const&, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto...) {}); - }; + return requires { v.visitor(v, 1, [](auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor(v, 1, [](auto, auto...) {}); - }; + return requires { v.visitor(v, 1, [](auto, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { + return requires { v.visitor(v, 1, [](auto, auto, auto...) {}); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor( - v, 1, [](auto, auto, auto...) {}, ""); + return requires { + v.visitor(v, 1, [](auto, auto, auto...) {}, ""); }; }(s1)); static_assert([](auto&& v) { - return requires - { - v.visitor( - v, 1, [](auto, auto, auto, auto...) {}, ""); + return requires { + v.visitor(v, 1, [](auto, auto, auto, auto...) {}, ""); }; }(s1)); } @@ -794,8 +722,7 @@ struct MultiApiJson_test : beast::unit_test::suite // Test different overloads static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value&, std::integral_constant) { @@ -813,8 +740,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value&, std::integral_constant) { @@ -833,8 +759,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value&) {}); @@ -848,8 +773,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&) { return 0; }, [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value&) {}); @@ -864,8 +788,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 2); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value const&, @@ -883,8 +806,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value const&, @@ -903,8 +825,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit( std::integral_constant{}, [](Json::Value const&) {}); @@ -918,8 +839,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&) { return 0; }, [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()( std::integral_constant{}, [](Json::Value const&) {}); @@ -934,10 +854,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value&, unsigned) {}); - }; + return requires { v.visit(1, [](Json::Value&, unsigned) {}); }; }(s1)); BEAST_EXPECT( s1.visit( @@ -950,8 +867,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, auto) { return 0; }, [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()(1, [](Json::Value&, unsigned) {}); }; }(s1)); @@ -967,10 +883,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value&) {}); - }; + return requires { v.visit(1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visit( @@ -980,10 +893,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value const&) { return 0; }, [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { - v.visit()(1, [](Json::Value&) {}); - }; + return requires { v.visit()(1, [](Json::Value&) {}); }; }(s1)); BEAST_EXPECT( s1.visit()( @@ -994,8 +904,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto...) { return 0; }}) == 5); static_assert([](auto&& v) { - return requires - { + return requires { v.visit(1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -1010,8 +919,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&, unsigned) { return 0; }, [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { + return requires { v.visit()(1, [](Json::Value const&, unsigned) {}); }; }(std::as_const(s1))); @@ -1027,10 +935,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](auto, auto) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit(1, [](Json::Value const&) {}); - }; + return requires { v.visit(1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( std::as_const(s1).visit( @@ -1040,10 +945,7 @@ struct MultiApiJson_test : beast::unit_test::suite [](Json::Value&) { return 0; }, [](auto...) { return 0; }}) == 3); static_assert([](auto&& v) { - return requires - { - v.visit()(1, [](Json::Value const&) {}); - }; + return requires { v.visit()(1, [](Json::Value const&) {}); }; }(std::as_const(s1))); BEAST_EXPECT( std::as_const(s1).visit()( @@ -1055,83 +957,71 @@ struct MultiApiJson_test : beast::unit_test::suite // Rvalue MultivarJson visitor only binds to regular reference static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit(1, [](Json::Value&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value const&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit(1, [](Json::Value&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit( 1, [](Json::Value const&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value const&&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value const&) {}); }; }(std::move(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value const&&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit( 1, [](Json::Value const&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value const&&) {}); }; }(std::move(std::as_const(s1)))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()( 1, [](Json::Value const&) {}); }; @@ -1139,15 +1029,13 @@ struct MultiApiJson_test : beast::unit_test::suite // Missing const static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit( 1, [](Json::Value&, auto) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()( 1, [](Json::Value&, auto) {}); }; @@ -1155,28 +1043,24 @@ struct MultiApiJson_test : beast::unit_test::suite // Missing parameter static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit(1, []() {}); }; }(s1)); static_assert([](auto&& v) { - return !requires - { + return !requires { std::forward(v).visit()(1, []() {}); }; }(s1)); // Sanity checks static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit(1, [](auto...) {}); }; }(std::as_const(s1))); static_assert([](auto&& v) { - return requires - { + return requires { std::forward(v).visit()(1, [](auto...) {}); }; }(std::as_const(s1))); diff --git a/src/test/protocol/STObject_test.cpp b/src/test/protocol/STObject_test.cpp index 39a5b9c2f65..41c3800bce4 100644 --- a/src/test/protocol/STObject_test.cpp +++ b/src/test/protocol/STObject_test.cpp @@ -243,9 +243,8 @@ class STObject_test : public beast::unit_test::suite unexpected(sfGeneric.isUseful(), "sfGeneric must not be useful"); { // Try to put sfGeneric in an SOTemplate. - except([&]() { - SOTemplate elements{{sfGeneric, soeREQUIRED}}; - }); + except( + [&]() { SOTemplate elements{{sfGeneric, soeREQUIRED}}; }); } unexpected(sfInvalid.isUseful(), "sfInvalid must not be useful"); @@ -263,9 +262,8 @@ class STObject_test : public beast::unit_test::suite } { // Try to put sfInvalid in an SOTemplate. - except([&]() { - SOTemplate elements{{sfInvalid, soeREQUIRED}}; - }); + except( + [&]() { SOTemplate elements{{sfInvalid, soeREQUIRED}}; }); } { // Try to put the same SField into an SOTemplate twice. @@ -570,150 +568,152 @@ class STObject_test : public beast::unit_test::suite // STBlob and slice - {{STObject st(sfGeneric); - Buffer b(1); - BEAST_EXPECT(!b.empty()); - st[sf4] = std::move(b); - BEAST_EXPECT(b.empty()); - BEAST_EXPECT(Slice(st[sf4]).size() == 1); - st[~sf4] = std::nullopt; - BEAST_EXPECT(!~st[~sf4]); - b = Buffer{2}; - st[sf4] = Slice(b); - BEAST_EXPECT(b.size() == 2); - BEAST_EXPECT(Slice(st[sf4]).size() == 2); - st[sf5] = st[sf4]; - BEAST_EXPECT(Slice(st[sf4]).size() == 2); - BEAST_EXPECT(Slice(st[sf5]).size() == 2); - } - { - STObject st(sotOuter, sfGeneric); - BEAST_EXPECT(st[sf5] == Slice{}); - BEAST_EXPECT(!!st[~sf5]); - BEAST_EXPECT(!!~st[~sf5]); - Buffer b(1); - st[sf5] = std::move(b); - BEAST_EXPECT(b.empty()); - BEAST_EXPECT(Slice(st[sf5]).size() == 1); - st[~sf4] = std::nullopt; - BEAST_EXPECT(!~st[~sf4]); - } -} + { + { + STObject st(sfGeneric); + Buffer b(1); + BEAST_EXPECT(!b.empty()); + st[sf4] = std::move(b); + BEAST_EXPECT(b.empty()); + BEAST_EXPECT(Slice(st[sf4]).size() == 1); + st[~sf4] = std::nullopt; + BEAST_EXPECT(!~st[~sf4]); + b = Buffer{2}; + st[sf4] = Slice(b); + BEAST_EXPECT(b.size() == 2); + BEAST_EXPECT(Slice(st[sf4]).size() == 2); + st[sf5] = st[sf4]; + BEAST_EXPECT(Slice(st[sf4]).size() == 2); + BEAST_EXPECT(Slice(st[sf5]).size() == 2); + } + { + STObject st(sotOuter, sfGeneric); + BEAST_EXPECT(st[sf5] == Slice{}); + BEAST_EXPECT(!!st[~sf5]); + BEAST_EXPECT(!!~st[~sf5]); + Buffer b(1); + st[sf5] = std::move(b); + BEAST_EXPECT(b.empty()); + BEAST_EXPECT(Slice(st[sf5]).size() == 1); + st[~sf4] = std::nullopt; + BEAST_EXPECT(!~st[~sf4]); + } + } -// UDT blobs + // UDT blobs -{ - STObject st(sfGeneric); - BEAST_EXPECT(!st[~sf5]); - auto const kp = - generateKeyPair(KeyType::secp256k1, generateSeed("masterpassphrase")); - st[sf5] = kp.first; - st[~sf5] = std::nullopt; -} + { + STObject st(sfGeneric); + BEAST_EXPECT(!st[~sf5]); + auto const kp = generateKeyPair( + KeyType::secp256k1, generateSeed("masterpassphrase")); + st[sf5] = kp.first; + st[~sf5] = std::nullopt; + } -// By reference fields + // By reference fields -{ - auto const& sf = sfIndexes; - STObject st(sfGeneric); - std::vector v; - v.emplace_back(1); - v.emplace_back(2); - st[sf] = v; - st[sf] = std::move(v); - auto const& cst = st; - BEAST_EXPECT(cst[sf].size() == 2); - BEAST_EXPECT(cst[~sf]->size() == 2); - BEAST_EXPECT(cst[sf][0] == 1); - BEAST_EXPECT(cst[sf][1] == 2); - static_assert( - std::is_same const&>:: - value, - ""); -} - -// Default by reference field + { + auto const& sf = sfIndexes; + STObject st(sfGeneric); + std::vector v; + v.emplace_back(1); + v.emplace_back(2); + st[sf] = v; + st[sf] = std::move(v); + auto const& cst = st; + BEAST_EXPECT(cst[sf].size() == 2); + BEAST_EXPECT(cst[~sf]->size() == 2); + BEAST_EXPECT(cst[sf][0] == 1); + BEAST_EXPECT(cst[sf][1] == 2); + static_assert( + std::is_same< + decltype(cst[sfIndexes]), + std::vector const&>::value, + ""); + } -{ - auto const& sf1 = sfIndexes; - auto const& sf2 = sfHashes; - auto const& sf3 = sfAmendments; - SOTemplate const sot{ - {sf1, soeREQUIRED}, - {sf2, soeOPTIONAL}, - {sf3, soeDEFAULT}, - }; - - STObject st(sot, sfGeneric); - auto const& cst(st); - BEAST_EXPECT(cst[sf1].size() == 0); - BEAST_EXPECT(!cst[~sf2]); - BEAST_EXPECT(cst[sf3].size() == 0); - std::vector v; - v.emplace_back(1); - st[sf1] = v; - BEAST_EXPECT(cst[sf1].size() == 1); - BEAST_EXPECT(cst[sf1][0] == uint256{1}); - st[sf2] = v; - BEAST_EXPECT(cst[sf2].size() == 1); - BEAST_EXPECT(cst[sf2][0] == uint256{1}); - st[~sf2] = std::nullopt; - BEAST_EXPECT(!st[~sf2]); - st[sf3] = v; - BEAST_EXPECT(cst[sf3].size() == 1); - BEAST_EXPECT(cst[sf3][0] == uint256{1}); - st[sf3] = std::vector{}; - BEAST_EXPECT(cst[sf3].size() == 0); -} -} // namespace ripple + // Default by reference field -void -testMalformed() -{ - testcase("Malformed serialized forms"); + { + auto const& sf1 = sfIndexes; + auto const& sf2 = sfHashes; + auto const& sf3 = sfAmendments; + SOTemplate const sot{ + {sf1, soeREQUIRED}, + {sf2, soeOPTIONAL}, + {sf3, soeDEFAULT}, + }; - try - { - std::array const payload{ - {0xe9, 0x12, 0xab, 0xcd, 0x12, 0xfe, 0xdc}}; - SerialIter sit{makeSlice(payload)}; - auto obj = std::make_shared(sit, sfMetadata); - BEAST_EXPECT(!obj); - } - catch (std::exception const& e) - { - BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); - } + STObject st(sot, sfGeneric); + auto const& cst(st); + BEAST_EXPECT(cst[sf1].size() == 0); + BEAST_EXPECT(!cst[~sf2]); + BEAST_EXPECT(cst[sf3].size() == 0); + std::vector v; + v.emplace_back(1); + st[sf1] = v; + BEAST_EXPECT(cst[sf1].size() == 1); + BEAST_EXPECT(cst[sf1][0] == uint256{1}); + st[sf2] = v; + BEAST_EXPECT(cst[sf2].size() == 1); + BEAST_EXPECT(cst[sf2][0] == uint256{1}); + st[~sf2] = std::nullopt; + BEAST_EXPECT(!st[~sf2]); + st[sf3] = v; + BEAST_EXPECT(cst[sf3].size() == 1); + BEAST_EXPECT(cst[sf3][0] == uint256{1}); + st[sf3] = std::vector{}; + BEAST_EXPECT(cst[sf3].size() == 0); + } + } // namespace ripple - try + void + testMalformed() { - std::array const payload{{0xe2, 0xe1, 0xe2}}; - SerialIter sit{makeSlice(payload)}; - auto obj = std::make_shared(sit, sfMetadata); - BEAST_EXPECT(!obj); + testcase("Malformed serialized forms"); + + try + { + std::array const payload{ + {0xe9, 0x12, 0xab, 0xcd, 0x12, 0xfe, 0xdc}}; + SerialIter sit{makeSlice(payload)}; + auto obj = std::make_shared(sit, sfMetadata); + BEAST_EXPECT(!obj); + } + catch (std::exception const& e) + { + BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); + } + + try + { + std::array const payload{{0xe2, 0xe1, 0xe2}}; + SerialIter sit{makeSlice(payload)}; + auto obj = std::make_shared(sit, sfMetadata); + BEAST_EXPECT(!obj); + } + catch (std::exception const& e) + { + BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); + } } - catch (std::exception const& e) + + void + run() override { - BEAST_EXPECT(strcmp(e.what(), "Duplicate field detected") == 0); + // Instantiate a jtx::Env so debugLog writes are exercised. + test::jtx::Env env(*this); + + testFields(); + testSerialization(); + testParseJSONArray(); + testParseJSONArrayWithInvalidChildrenObjects(); + testParseJSONEdgeCases(); + testMalformed(); } -} - -void -run() override -{ - // Instantiate a jtx::Env so debugLog writes are exercised. - test::jtx::Env env(*this); - - testFields(); - testSerialization(); - testParseJSONArray(); - testParseJSONArrayWithInvalidChildrenObjects(); - testParseJSONEdgeCases(); - testMalformed(); -} -} -; +}; BEAST_DEFINE_TESTSUITE(STObject, protocol, ripple); -} // ripple +} // namespace ripple diff --git a/src/xrpld/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp index 528e80a2932..b12a0da0fa3 100644 --- a/src/xrpld/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -224,30 +224,30 @@ log_metadata_difference( { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and index!"; - JLOG(j.debug()) << " Built:" - << " Result: " << builtMetaData->getResult() - << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) << " Valid:" - << " Result: " << validMetaData->getResult() - << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) + << " Built:" << " Result: " << builtMetaData->getResult() + << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) + << " Valid:" << " Result: " << validMetaData->getResult() + << " Index: " << validMetaData->getIndex(); } else if (result_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result!"; - JLOG(j.debug()) << " Built:" - << " Result: " << builtMetaData->getResult(); - JLOG(j.debug()) << " Valid:" - << " Result: " << validMetaData->getResult(); + JLOG(j.debug()) + << " Built:" << " Result: " << builtMetaData->getResult(); + JLOG(j.debug()) + << " Valid:" << " Result: " << validMetaData->getResult(); } else if (index_diff) { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index!"; - JLOG(j.debug()) << " Built:" - << " Index: " << builtMetaData->getIndex(); - JLOG(j.debug()) << " Valid:" - << " Index: " << validMetaData->getIndex(); + JLOG(j.debug()) + << " Built:" << " Index: " << builtMetaData->getIndex(); + JLOG(j.debug()) + << " Valid:" << " Index: " << validMetaData->getIndex(); } } else @@ -266,12 +266,12 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different result and nodes!"; JLOG(j.debug()) - << " Built:" - << " Result: " << builtMetaData->getResult() << " Nodes:\n" + << " Built:" << " Result: " << builtMetaData->getResult() + << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" - << " Result: " << validMetaData->getResult() << " Nodes:\n" + << " Valid:" << " Result: " << validMetaData->getResult() + << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else if (index_diff) @@ -279,23 +279,21 @@ log_metadata_difference( JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different index and nodes!"; JLOG(j.debug()) - << " Built:" - << " Index: " << builtMetaData->getIndex() << " Nodes:\n" + << " Built:" << " Index: " << builtMetaData->getIndex() + << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); JLOG(j.debug()) - << " Valid:" - << " Index: " << validMetaData->getIndex() << " Nodes:\n" + << " Valid:" << " Index: " << validMetaData->getIndex() + << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } else // nodes_diff { JLOG(j.debug()) << "MISMATCH on TX " << tx << ": Different nodes!"; - JLOG(j.debug()) << " Built:" - << " Nodes:\n" + JLOG(j.debug()) << " Built:" << " Nodes:\n" << builtNodes.getJson(JsonOptions::none); - JLOG(j.debug()) << " Valid:" - << " Nodes:\n" + JLOG(j.debug()) << " Valid:" << " Nodes:\n" << validNodes.getJson(JsonOptions::none); } } @@ -352,10 +350,10 @@ LedgerHistory::handleMismatch( if (!builtLedger || !validLedger) { - JLOG(j_.error()) << "MISMATCH cannot be analyzed:" - << " builtLedger: " << to_string(built) << " -> " - << builtLedger << " validLedger: " << to_string(valid) - << " -> " << validLedger; + JLOG(j_.error()) << "MISMATCH cannot be analyzed:" << " builtLedger: " + << to_string(built) << " -> " << builtLedger + << " validLedger: " << to_string(valid) << " -> " + << validLedger; return; } diff --git a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 4eb35bb02fb..1d8efca37f9 100644 --- a/src/xrpld/app/ledger/detail/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -102,8 +102,8 @@ TimeoutCounter::invokeOnTimer() if (!progress_) { ++timeouts_; - JLOG(journal_.debug()) << "Timeout(" << timeouts_ << ") " - << " acquiring " << hash_; + JLOG(journal_.debug()) + << "Timeout(" << timeouts_ << ") " << " acquiring " << hash_; onTimer(false, sl); } else diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index fcf8664c50e..c4a1b2458c9 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -447,8 +447,8 @@ GRPCServerImpl::handleRpcs() if (!ok) { - JLOG(journal_.debug()) << "Request listener cancelled. " - << "Destroying object"; + JLOG(journal_.debug()) + << "Request listener cancelled. " << "Destroying object"; erase(ptr); } else diff --git a/src/xrpld/app/misc/AMMHelpers.h b/src/xrpld/app/misc/AMMHelpers.h index 8bf5a5c5f12..7ad0093a2e4 100644 --- a/src/xrpld/app/misc/AMMHelpers.h +++ b/src/xrpld/app/misc/AMMHelpers.h @@ -385,9 +385,9 @@ changeSpotPriceQuality( { JLOG(j.error()) << "changeSpotPriceQuality failed: " << to_string(pool.in) - << " " << to_string(pool.out) << " " - << " " << quality << " " << tfee << " " - << to_string(amounts.in) << " " << to_string(amounts.out); + << " " << to_string(pool.out) << " " << " " << quality + << " " << tfee << " " << to_string(amounts.in) << " " + << to_string(amounts.out); Throw("changeSpotPriceQuality failed"); } else diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 83272b2f622..4739160f2fe 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -3200,8 +3200,8 @@ NetworkOPsImp::pubAccountTransaction( } JLOG(m_journal.trace()) - << "pubAccountTransaction: " - << "proposed=" << iProposed << ", accepted=" << iAccepted; + << "pubAccountTransaction: " << "proposed=" << iProposed + << ", accepted=" << iAccepted; if (!notify.empty() || !accountHistoryNotify.empty()) { diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 1faa9087f4f..9f886fd2977 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -1502,11 +1502,11 @@ TxQ::accept(Application& app, OpenView& view) } else { - JLOG(j_.debug()) << "Queued transaction " << candidateIter->txID - << " failed with " << transToken(txnResult) - << ". Leave in queue." - << " Applied: " << didApply - << ". Flags: " << candidateIter->flags; + JLOG(j_.debug()) + << "Queued transaction " << candidateIter->txID + << " failed with " << transToken(txnResult) + << ". Leave in queue." << " Applied: " << didApply + << ". Flags: " << candidateIter->flags; if (account.retryPenalty && candidateIter->retriesRemaining > 2) candidateIter->retriesRemaining = 1; else diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index c648507e8cb..052cecb80b1 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -716,8 +716,7 @@ ValidatorList::sendValidatorList( beast::Journal j) { std::size_t const messageVersion = - peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation) - ? 2 + peer.supportsFeature(ProtocolFeature::ValidatorList2Propagation) ? 2 : peer.supportsFeature(ProtocolFeature::ValidatorListPropagation) ? 1 : 0; if (!messageVersion) diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index c3795fbe78f..29eeb15a6f4 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -235,8 +235,7 @@ Pathfinder::findPaths( mSource = STPathElement(account, mSrcCurrency, issuer); auto issuerString = mSrcIssuer ? to_string(*mSrcIssuer) : std::string("none"); - JLOG(j_.trace()) << "findPaths>" - << " mSrcAccount=" << mSrcAccount + JLOG(j_.trace()) << "findPaths>" << " mSrcAccount=" << mSrcAccount << " mDstAccount=" << mDstAccount << " mDstAmount=" << mDstAmount.getFullText() << " mSrcCurrency=" << mSrcCurrency diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index 01907a42714..df05cc41864 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -189,8 +189,7 @@ class BookStep : public StepImp> logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\ninIss: " << book_.in.account + ostr << name << ": " << "\ninIss: " << book_.in.account << "\noutIss: " << book_.out.account << "\ninCur: " << book_.in.currency << "\noutCur: " << book_.out.currency; diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 6920c8d8752..194e77edc2c 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -204,8 +204,7 @@ class DirectStepI : public StepImp> logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\nSrc: " << src_ << "\nDst: " << dst_; + ostr << name << ": " << "\nSrc: " << src_ << "\nDst: " << dst_; return ostr.str(); } @@ -236,7 +235,8 @@ class DirectIPaymentStep : public DirectStepI using DirectStepI::DirectStepI; using DirectStepI::check; - bool verifyPrevStepDebtDirection(DebtDirection) const + bool + verifyPrevStepDebtDirection(DebtDirection) const { // A payment doesn't care whether or not prevStepRedeems. return true; diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 834dd43ae73..ebc9510f4b2 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -132,8 +132,7 @@ class XRPEndpointStep logStringImpl(char const* name) const { std::ostringstream ostr; - ostr << name << ": " - << "\nAcc: " << acc_; + ostr << name << ": " << "\nAcc: " << acc_; return ostr.str(); } diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index fa2d656a011..a7528e2370d 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -238,8 +238,8 @@ rangeCheckedCast(C c) /* This should never happen */ UNREACHABLE("ripple::rangeCheckedCast : domain error"); JLOG(debugLog().error()) - << "rangeCheckedCast domain error:" - << " value = " << c << " min = " << std::numeric_limits::lowest() + << "rangeCheckedCast domain error:" << " value = " << c + << " min = " << std::numeric_limits::lowest() << " max: " << std::numeric_limits::max(); } diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/xrpld/app/tx/detail/CancelOffer.cpp index 11b07f06df3..30e955a8282 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/xrpld/app/tx/detail/CancelOffer.cpp @@ -34,8 +34,8 @@ CancelOffer::preflight(PreflightContext const& ctx) if (uTxFlags & tfUniversalMask) { - JLOG(ctx.j.trace()) << "Malformed transaction: " - << "Invalid flags set."; + JLOG(ctx.j.trace()) + << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } @@ -62,8 +62,8 @@ CancelOffer::preclaim(PreclaimContext const& ctx) if ((*sle)[sfSequence] <= offerSequence) { - JLOG(ctx.j.trace()) << "Malformed transaction: " - << "Sequence " << offerSequence << " is invalid."; + JLOG(ctx.j.trace()) << "Malformed transaction: " << "Sequence " + << offerSequence << " is invalid."; return temBAD_SEQUENCE; } diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 37af660b204..0567dd35246 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -56,8 +56,7 @@ Payment::preflight(PreflightContext const& ctx) if (uTxFlags & tfPaymentMask) { - JLOG(j.trace()) << "Malformed transaction: " - << "Invalid flags set."; + JLOG(j.trace()) << "Malformed transaction: " << "Invalid flags set."; return temINVALID_FLAG; } @@ -102,20 +101,19 @@ Payment::preflight(PreflightContext const& ctx) } if (bMax && maxSourceAmount <= beast::zero) { - JLOG(j.trace()) << "Malformed transaction: " - << "bad max amount: " << maxSourceAmount.getFullText(); + JLOG(j.trace()) << "Malformed transaction: " << "bad max amount: " + << maxSourceAmount.getFullText(); return temBAD_AMOUNT; } if (saDstAmount <= beast::zero) { - JLOG(j.trace()) << "Malformed transaction: " - << "bad dst amount: " << saDstAmount.getFullText(); + JLOG(j.trace()) << "Malformed transaction: " << "bad dst amount: " + << saDstAmount.getFullText(); return temBAD_AMOUNT; } if (badCurrency() == uSrcCurrency || badCurrency() == uDstCurrency) { - JLOG(j.trace()) << "Malformed transaction: " - << "Bad currency."; + JLOG(j.trace()) << "Malformed transaction: " << "Bad currency."; return temBAD_CURRENCY; } if (account == uDstAccountID && uSrcCurrency == uDstCurrency && !bPaths) @@ -445,8 +443,8 @@ Payment::doApply() { // Vote no. However the transaction might succeed, if applied in // a different order. - JLOG(j_.trace()) << "Delay transaction: Insufficient funds: " - << " " << to_string(mPriorBalance) << " / " + JLOG(j_.trace()) << "Delay transaction: Insufficient funds: " << " " + << to_string(mPriorBalance) << " / " << to_string(saDstAmount.xrp() + mmm) << " (" << to_string(reserve) << ")"; diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 652d256224e..56afbce0a08 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -226,9 +226,9 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) if (balance < feePaid) { - JLOG(ctx.j.trace()) << "Insufficient balance:" - << " balance=" << to_string(balance) - << " paid=" << to_string(feePaid); + JLOG(ctx.j.trace()) + << "Insufficient balance:" << " balance=" << to_string(balance) + << " paid=" << to_string(feePaid); if ((balance > beast::zero) && !ctx.view.open()) { diff --git a/src/xrpld/conditions/detail/PreimageSha256.h b/src/xrpld/conditions/detail/PreimageSha256.h index c0eca96b066..5185ded7a67 100644 --- a/src/xrpld/conditions/detail/PreimageSha256.h +++ b/src/xrpld/conditions/detail/PreimageSha256.h @@ -137,7 +137,8 @@ class PreimageSha256 final : public Fulfillment return {type(), cost(), fingerprint()}; } - bool validate(Slice) const override + bool + validate(Slice) const override { // Perhaps counterintuitively, the message isn't // relevant. diff --git a/src/xrpld/consensus/Consensus.h b/src/xrpld/consensus/Consensus.h index 22aab7d6ed7..7b8d03f48a7 100644 --- a/src/xrpld/consensus/Consensus.h +++ b/src/xrpld/consensus/Consensus.h @@ -1064,8 +1064,7 @@ Consensus::checkLedger() { JLOG(j_.warn()) << "View of consensus changed during " << to_string(phase_) << " status=" << to_string(phase_) - << ", " - << " mode=" << to_string(mode_.get()); + << ", " << " mode=" << to_string(mode_.get()); JLOG(j_.warn()) << prevLedgerID_ << " to " << netLgr; JLOG(j_.warn()) << Json::Compact{previousLedger_.getJson()}; JLOG(j_.debug()) << "State on consensus change " @@ -1168,8 +1167,7 @@ Consensus::shouldPause() const << "roundTime: " << result_->roundTime.read().count() << ", " << "max consensus time: " << parms.ledgerMAX_CONSENSUS.count() << ", " << "validators: " << totalValidators << ", " - << "laggards: " << laggards << ", " - << "offline: " << offline << ", " + << "laggards: " << laggards << ", " << "offline: " << offline << ", " << "quorum: " << quorum << ")"; if (!ahead || !laggards || !totalValidators || !adaptor_.validator() || @@ -1499,8 +1497,8 @@ Consensus::updateOurPositions() if (!haveCloseTimeConsensus_) { JLOG(j_.debug()) - << "No CT consensus:" - << " Proposers:" << currPeerPositions_.size() + << "No CT consensus:" << " Proposers:" + << currPeerPositions_.size() << " Mode:" << to_string(mode_.get()) << " Thresh:" << threshConsensus << " Pos:" << consensusCloseTime.time_since_epoch().count(); diff --git a/src/xrpld/consensus/Validations.h b/src/xrpld/consensus/Validations.h index fec60a738bb..765298d897a 100644 --- a/src/xrpld/consensus/Validations.h +++ b/src/xrpld/consensus/Validations.h @@ -484,8 +484,7 @@ class Validations withTrie(std::lock_guard const& lock, F&& f) { // Call current to flush any stale validations - current( - lock, [](auto) {}, [](auto, auto) {}); + current(lock, [](auto) {}, [](auto, auto) {}); checkAcquired(lock); return f(trie_); } diff --git a/src/xrpld/core/DatabaseCon.h b/src/xrpld/core/DatabaseCon.h index 8efc6b599c9..bb6f36d4d56 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/src/xrpld/core/DatabaseCon.h @@ -73,7 +73,8 @@ class LockedSociSession { return session_.get(); } - explicit operator bool() const + explicit + operator bool() const { return bool(session_); } diff --git a/src/xrpld/ledger/detail/View.cpp b/src/xrpld/ledger/detail/View.cpp index 83f5ee70ec6..ddb316e1f9a 100644 --- a/src/xrpld/ledger/detail/View.cpp +++ b/src/xrpld/ledger/detail/View.cpp @@ -262,8 +262,7 @@ accountHolds( } amount.setIssuer(issuer); } - JLOG(j.trace()) << "accountHolds:" - << " account=" << to_string(account) + JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(account) << " amount=" << amount.getFullText(); return view.balanceHook(account, issuer, amount); @@ -372,8 +371,7 @@ xrpLiquid( STAmount const amount = (balance < reserve) ? STAmount{0} : balance - reserve; - JLOG(j.trace()) << "accountHolds:" - << " account=" << to_string(id) + JLOG(j.trace()) << "accountHolds:" << " account=" << to_string(id) << " amount=" << amount.getFullText() << " fullBalance=" << fullBalance.getFullText() << " balance=" << balance.getFullText() diff --git a/src/xrpld/nodestore/detail/DatabaseNodeImp.h b/src/xrpld/nodestore/detail/DatabaseNodeImp.h index 230f5dc55a4..2ed3443da92 100644 --- a/src/xrpld/nodestore/detail/DatabaseNodeImp.h +++ b/src/xrpld/nodestore/detail/DatabaseNodeImp.h @@ -109,7 +109,8 @@ class DatabaseNodeImp : public Database store(NodeObjectType type, Blob&& data, uint256 const& hash, std::uint32_t) override; - bool isSameDB(std::uint32_t, std::uint32_t) override + bool + isSameDB(std::uint32_t, std::uint32_t) override { // only one database return true; diff --git a/src/xrpld/nodestore/detail/DatabaseRotatingImp.h b/src/xrpld/nodestore/detail/DatabaseRotatingImp.h index 0c17dc59ceb..5183aa1e2e4 100644 --- a/src/xrpld/nodestore/detail/DatabaseRotatingImp.h +++ b/src/xrpld/nodestore/detail/DatabaseRotatingImp.h @@ -62,7 +62,8 @@ class DatabaseRotatingImp : public DatabaseRotating void importDatabase(Database& source) override; - bool isSameDB(std::uint32_t, std::uint32_t) override + bool + isSameDB(std::uint32_t, std::uint32_t) override { // rotating store acts as one logical database return true; diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 00ce3d5a168..5dd64c27ea5 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -593,7 +593,7 @@ PeerImp::fail(std::string const& reason) return post( strand_, std::bind( - (void (Peer::*)(std::string const&)) & PeerImp::fail, + (void(Peer::*)(std::string const&)) & PeerImp::fail, shared_from_this(), reason)); if (journal_.active(beast::severities::kWarning) && socket_.is_open()) @@ -1239,8 +1239,8 @@ PeerImp::handleTransaction( { // If we've never been in synch, there's nothing we can do // with a transaction - JLOG(p_journal_.debug()) << "Ignoring incoming transaction: " - << "Need network ledger"; + JLOG(p_journal_.debug()) + << "Ignoring incoming transaction: " << "Need network ledger"; return; } diff --git a/src/xrpld/overlay/detail/ProtocolVersion.cpp b/src/xrpld/overlay/detail/ProtocolVersion.cpp index bd2effa6341..0fecb301f7f 100644 --- a/src/xrpld/overlay/detail/ProtocolVersion.cpp +++ b/src/xrpld/overlay/detail/ProtocolVersion.cpp @@ -45,7 +45,7 @@ constexpr ProtocolVersion const supportedProtocolList[] // ascending order and doesn't contain any duplicates. // FIXME: With C++20 we can use std::is_sorted with an appropriate comparator static_assert( - []() constexpr->bool { + []() constexpr -> bool { auto const len = std::distance( std::begin(supportedProtocolList), std::end(supportedProtocolList)); diff --git a/src/xrpld/peerfinder/detail/Logic.h b/src/xrpld/peerfinder/detail/Logic.h index 9d43325755b..41bb6789a86 100644 --- a/src/xrpld/peerfinder/detail/Logic.h +++ b/src/xrpld/peerfinder/detail/Logic.h @@ -1132,9 +1132,9 @@ class Logic } else { - JLOG(m_journal.error()) << beast::leftw(18) << "Logic failed " - << "'" << source->name() << "' fetch, " - << results.error.message(); + JLOG(m_journal.error()) + << beast::leftw(18) << "Logic failed " << "'" << source->name() + << "' fetch, " << results.error.message(); } } diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index c006111894b..ccf0c12b5ad 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -388,9 +388,9 @@ logDuration( beast::Journal& journal) { using namespace std::chrono_literals; - auto const level = (duration >= 10s) - ? journal.error() - : (duration >= 1s) ? journal.warn() : journal.debug(); + auto const level = (duration >= 10s) ? journal.error() + : (duration >= 1s) ? journal.warn() + : journal.debug(); JLOG(level) << "RPC request processing duration = " << std::chrono::duration_cast( diff --git a/src/xrpld/shamap/detail/TaggedPointer.ipp b/src/xrpld/shamap/detail/TaggedPointer.ipp index f5b3c404e19..3833ce58a11 100644 --- a/src/xrpld/shamap/detail/TaggedPointer.ipp +++ b/src/xrpld/shamap/detail/TaggedPointer.ipp @@ -55,8 +55,8 @@ constexpr size_t elementSizeBytes = constexpr size_t blockSizeBytes = kilobytes(512); template -constexpr std::array initArrayChunkSizeBytes( - std::index_sequence) +constexpr std::array +initArrayChunkSizeBytes(std::index_sequence) { return std::array{ boundaries[I] * elementSizeBytes..., @@ -66,8 +66,8 @@ constexpr auto arrayChunkSizeBytes = initArrayChunkSizeBytes(std::make_index_sequence{}); template -constexpr std::array initArrayChunksPerBlock( - std::index_sequence) +constexpr std::array +initArrayChunksPerBlock(std::index_sequence) { return std::array{ blockSizeBytes / arrayChunkSizeBytes[I]..., @@ -97,8 +97,8 @@ boundariesIndex(std::uint8_t numChildren) } template -std::array, boundaries.size()> initAllocateArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initAllocateArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ boost::singleton_pool< @@ -114,8 +114,8 @@ std::array, boundaries.size()> const allocateArrayFuns = initAllocateArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> initFreeArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initFreeArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ static_cast(boost::singleton_pool< @@ -131,8 +131,8 @@ std::array, boundaries.size()> const freeArrayFuns = initFreeArrayFuns(std::make_index_sequence{}); template -std::array, boundaries.size()> initIsFromArrayFuns( - std::index_sequence) +std::array, boundaries.size()> +initIsFromArrayFuns(std::index_sequence) { return std::array, boundaries.size()>{ boost::singleton_pool< diff --git a/src/xrpld/unity/rocksdb.h b/src/xrpld/unity/rocksdb.h index 06ccb116da1..4a71dc4b57f 100644 --- a/src/xrpld/unity/rocksdb.h +++ b/src/xrpld/unity/rocksdb.h @@ -21,7 +21,7 @@ #define RIPPLE_UNITY_ROCKSDB_H_INCLUDED #if RIPPLE_ROCKSDB_AVAILABLE -//#include +// #include #include #include #include