From 25d7c2c4ec7580db602145c258ff49463a58f14a Mon Sep 17 00:00:00 2001 From: Bart Date: Fri, 6 Feb 2026 09:12:45 -0500 Subject: [PATCH 01/16] chore: Restore unity builds (#6328) In certain cases, such as when modifying headers used by many compilation units, performing a unity build is slower than when performing a regular build with `ccache` enabled. There is also a benefit to a unity build in that it can detect things such as macro redefinitions within the group of files that are compiled together as a unit. This change therefore restores the ability to perform unity builds. However, instead of running every configuration with and without unity enabled, it is now only enabled for a single configuration to maintain lower computational use. As part of restoring the code, it became clear that currently two configurations have coverage enabled, since the check doesn't focus specifically on Debian Bookworm so it also applies to Debian Trixie. This has been fixed too in this change. --- .github/scripts/strategy-matrix/generate.py | 17 +++++++++++++++-- BUILD.md | 7 +++++++ cmake/XrplCore.cmake | 5 +++++ cmake/XrplSettings.cmake | 8 ++++++++ conanfile.py | 3 +++ src/libxrpl/net/RegisterSSLCerts.cpp | 3 +-- 6 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/scripts/strategy-matrix/generate.py b/.github/scripts/strategy-matrix/generate.py index 75847b4d9d..27eb60c005 100755 --- a/.github/scripts/strategy-matrix/generate.py +++ b/.github/scripts/strategy-matrix/generate.py @@ -196,11 +196,22 @@ def generate_strategy_matrix(all: bool, config: Config) -> list: # Enable code coverage for Debian Bookworm using GCC 15 in Debug on # linux/amd64 if ( - f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15" + f"{os['distro_name']}-{os['distro_version']}" == "debian-bookworm" + and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-15" and build_type == "Debug" and architecture["platform"] == "linux/amd64" ): - cmake_args = f"-Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 -DCMAKE_CXX_FLAGS=-O0 {cmake_args}" + cmake_args = f"{cmake_args} -Dcoverage=ON -Dcoverage_format=xml -DCODE_COVERAGE_VERBOSE=ON -DCMAKE_C_FLAGS=-O0 -DCMAKE_CXX_FLAGS=-O0" + + # Enable unity build for Ubuntu Jammy using GCC 12 in Debug on + # linux/amd64. + if ( + f"{os['distro_name']}-{os['distro_version']}" == "ubuntu-jammy" + and f"{os['compiler_name']}-{os['compiler_version']}" == "gcc-12" + and build_type == "Debug" + and architecture["platform"] == "linux/amd64" + ): + cmake_args = f"{cmake_args} -Dunity=ON" # Generate a unique name for the configuration, e.g. macos-arm64-debug # or debian-bookworm-gcc-12-amd64-release. @@ -217,6 +228,8 @@ def generate_strategy_matrix(all: bool, config: Config) -> list: config_name += f"-{build_type.lower()}" if "-Dcoverage=ON" in cmake_args: config_name += "-coverage" + if "-Dunity=ON" in cmake_args: + config_name += "-unity" # Add the configuration to the list, with the most unique fields first, # so that they are easier to identify in the GitHub Actions UI, as long diff --git a/BUILD.md b/BUILD.md index 35668aeabd..4d01700a61 100644 --- a/BUILD.md +++ b/BUILD.md @@ -575,10 +575,16 @@ See [Sanitizers docs](./docs/build/sanitizers.md) for more details. | `assert` | OFF | Enable assertions. | | `coverage` | OFF | Prepare the coverage report. | | `tests` | OFF | Build tests. | +| `unity` | OFF | Configure a unity build. | | `xrpld` | OFF | Build the xrpld application, and not just the libxrpl library. | | `werr` | OFF | Treat compilation warnings as errors | | `wextra` | OFF | Enable additional compilation warnings | +[Unity builds][5] may be faster for the first build (at the cost of much more +memory) since they concatenate sources into fewer translation units. Non-unity +builds may be faster for incremental builds, and can be helpful for detecting +`#include` omissions. + ## Troubleshooting ### Conan @@ -645,6 +651,7 @@ If you want to experiment with a new package, follow these steps: [1]: https://github.com/conan-io/conan-center-index/issues/13168 [2]: https://en.cppreference.com/w/cpp/compiler_support/20 [3]: https://docs.conan.io/en/latest/getting_started.html +[5]: https://en.wikipedia.org/wiki/Unity_build [6]: https://github.com/boostorg/beast/issues/2648 [7]: https://github.com/boostorg/beast/issues/2661 [gcovr]: https://gcovr.com/en/stable/getting-started.html diff --git a/cmake/XrplCore.cmake b/cmake/XrplCore.cmake index afefa8457d..57d0e83348 100644 --- a/cmake/XrplCore.cmake +++ b/cmake/XrplCore.cmake @@ -4,7 +4,12 @@ include(target_protobuf_sources) +# Protocol buffers cannot participate in a unity build, +# because all the generated sources +# define a bunch of `static const` variables with the same names, +# so we just build them as a separate library. add_library(xrpl.libpb) +set_target_properties(xrpl.libpb PROPERTIES UNITY_BUILD OFF) target_protobuf_sources(xrpl.libpb xrpl/proto LANGUAGE cpp IMPORT_DIRS include/xrpl/proto PROTOS include/xrpl/proto/xrpl.proto) diff --git a/cmake/XrplSettings.cmake b/cmake/XrplSettings.cmake index 0957e41918..6d332be19d 100644 --- a/cmake/XrplSettings.cmake +++ b/cmake/XrplSettings.cmake @@ -30,6 +30,14 @@ if (tests) endif () endif () +option(unity "Creates a build using UNITY support in cmake." OFF) +if (unity) + if (NOT is_ci) + set(CMAKE_UNITY_BUILD_BATCH_SIZE 15 CACHE STRING "") + endif () + set(CMAKE_UNITY_BUILD ON CACHE BOOL "Do a unity build") +endif () + if (is_clang AND is_linux) option(voidstar "Enable Antithesis instrumentation." OFF) endif () diff --git a/conanfile.py b/conanfile.py index 85406bf570..7300b537d9 100644 --- a/conanfile.py +++ b/conanfile.py @@ -23,6 +23,7 @@ class Xrpl(ConanFile): "shared": [True, False], "static": [True, False], "tests": [True, False], + "unity": [True, False], "xrpld": [True, False], } @@ -54,6 +55,7 @@ class Xrpl(ConanFile): "shared": False, "static": True, "tests": False, + "unity": False, "xrpld": False, "date/*:header_only": True, "ed25519/*:shared": False, @@ -166,6 +168,7 @@ class Xrpl(ConanFile): tc.variables["rocksdb"] = self.options.rocksdb tc.variables["BUILD_SHARED_LIBS"] = self.options.shared tc.variables["static"] = self.options.static + tc.variables["unity"] = self.options.unity tc.variables["xrpld"] = self.options.xrpld tc.generate() diff --git a/src/libxrpl/net/RegisterSSLCerts.cpp b/src/libxrpl/net/RegisterSSLCerts.cpp index 1b97a17e5c..a15472969e 100644 --- a/src/libxrpl/net/RegisterSSLCerts.cpp +++ b/src/libxrpl/net/RegisterSSLCerts.cpp @@ -85,8 +85,7 @@ registerSSLCerts(boost::asio::ssl::context& ctx, boost::system::error_code& ec, // There is a very unpleasant interaction between and // openssl x509 types (namely the former has macros that stomp // on the latter), these undefs allow this TU to be safely used in -// unity builds without messing up subsequent TUs. Although we -// no longer use unity builds, leaving the undefs here does no harm. +// unity builds without messing up subsequent TUs. #if BOOST_OS_WINDOWS #undef X509_NAME #undef X509_EXTENSIONS From 677758b1cc9d8afc190582a75160425096708f54 Mon Sep 17 00:00:00 2001 From: Bart Date: Fri, 6 Feb 2026 09:42:35 -0500 Subject: [PATCH 02/16] perf: Remove unnecessary caches (#5439) This change removes the cache in `DatabaseNodeImp` and simplifies the caching logic in `SHAMapStoreImp`. As NuDB and RocksDB internally already use caches, additional caches in the code are not very valuable or may even be unnecessary, as also confirmed during preliminary performance analyses. --- cfg/xrpld-example.cfg | 20 +-- include/xrpl/nodestore/Database.h | 4 - .../xrpl/nodestore/detail/DatabaseNodeImp.h | 32 ---- .../nodestore/detail/DatabaseRotatingImp.h | 3 - src/libxrpl/nodestore/DatabaseNodeImp.cpp | 148 +++++------------- src/libxrpl/nodestore/DatabaseRotatingImp.cpp | 6 - src/test/app/SHAMapStore_test.cpp | 18 +-- src/xrpld/app/main/Application.cpp | 4 - src/xrpld/app/misc/SHAMapStoreImp.cpp | 21 +-- src/xrpld/app/misc/SHAMapStoreImp.h | 2 - 10 files changed, 47 insertions(+), 211 deletions(-) diff --git a/cfg/xrpld-example.cfg b/cfg/xrpld-example.cfg index 93fab4a9ba..995d4e65ff 100644 --- a/cfg/xrpld-example.cfg +++ b/cfg/xrpld-example.cfg @@ -940,23 +940,7 @@ # # path Location to store the database # -# Optional keys -# -# cache_size Size of cache for database records. Default is 16384. -# Setting this value to 0 will use the default value. -# -# cache_age Length of time in minutes to keep database records -# cached. Default is 5 minutes. Setting this value to -# 0 will use the default value. -# -# Note: if neither cache_size nor cache_age is -# specified, the cache for database records will not -# be created. If only one of cache_size or cache_age -# is specified, the cache will be created using the -# default value for the unspecified parameter. -# -# Note: the cache will not be created if online_delete -# is specified. +# Optional keys for NuDB and RocksDB: # # fast_load Boolean. If set, load the last persisted ledger # from disk upon process start before syncing to @@ -964,8 +948,6 @@ # if sufficient IOPS capacity is available. # Default 0. # -# Optional keys for NuDB or RocksDB: -# # earliest_seq The default is 32570 to match the XRP ledger # network's earliest allowed sequence. Alternate # networks may set this value. Minimum value of 1. diff --git a/include/xrpl/nodestore/Database.h b/include/xrpl/nodestore/Database.h index d3dafff85d..d1f5b1bda2 100644 --- a/include/xrpl/nodestore/Database.h +++ b/include/xrpl/nodestore/Database.h @@ -133,10 +133,6 @@ public: std::uint32_t ledgerSeq, std::function const&)>&& callback); - /** Remove expired entries from the positive and negative caches. */ - virtual void - sweep() = 0; - /** Gather statistics pertaining to read and write activities. * * @param obj Json object reference into which to place counters. diff --git a/include/xrpl/nodestore/detail/DatabaseNodeImp.h b/include/xrpl/nodestore/detail/DatabaseNodeImp.h index dd6b8f9ddd..94859c4d22 100644 --- a/include/xrpl/nodestore/detail/DatabaseNodeImp.h +++ b/include/xrpl/nodestore/detail/DatabaseNodeImp.h @@ -23,32 +23,6 @@ public: beast::Journal j) : Database(scheduler, readThreads, config, j), backend_(std::move(backend)) { - std::optional cacheSize, cacheAge; - - if (config.exists("cache_size")) - { - cacheSize = get(config, "cache_size"); - if (cacheSize.value() < 0) - { - Throw("Specified negative value for cache_size"); - } - } - - if (config.exists("cache_age")) - { - cacheAge = get(config, "cache_age"); - if (cacheAge.value() < 0) - { - Throw("Specified negative value for cache_age"); - } - } - - if (cacheSize != 0 || cacheAge != 0) - { - cache_ = std::make_shared>( - "DatabaseNodeImp", cacheSize.value_or(0), std::chrono::minutes(cacheAge.value_or(0)), stopwatch(), j); - } - XRPL_ASSERT( backend_, "xrpl::NodeStore::DatabaseNodeImp::DatabaseNodeImp : non-null " @@ -103,13 +77,7 @@ public: std::uint32_t ledgerSeq, std::function const&)>&& callback) override; - void - sweep() override; - private: - // Cache for database objects. This cache is not always initialized. Check - // for null before using. - std::shared_ptr> cache_; // Persistent key/value storage std::shared_ptr backend_; diff --git a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h index e49c195d67..1a378c54c7 100644 --- a/include/xrpl/nodestore/detail/DatabaseRotatingImp.h +++ b/include/xrpl/nodestore/detail/DatabaseRotatingImp.h @@ -55,9 +55,6 @@ public: void sync() override; - void - sweep() override; - private: std::shared_ptr writableBackend_; std::shared_ptr archiveBackend_; diff --git a/src/libxrpl/nodestore/DatabaseNodeImp.cpp b/src/libxrpl/nodestore/DatabaseNodeImp.cpp index f49867514c..11152a2027 100644 --- a/src/libxrpl/nodestore/DatabaseNodeImp.cpp +++ b/src/libxrpl/nodestore/DatabaseNodeImp.cpp @@ -10,11 +10,6 @@ DatabaseNodeImp::store(NodeObjectType type, Blob&& data, uint256 const& hash, st auto obj = NodeObject::createObject(type, std::move(data), hash); backend_->store(obj); - if (cache_) - { - // After the store, replace a negative cache entry if there is one - cache_->canonicalize(hash, obj, [](std::shared_ptr const& n) { return n->getType() == hotDUMMY; }); - } } void @@ -23,77 +18,36 @@ DatabaseNodeImp::asyncFetch( std::uint32_t ledgerSeq, std::function const&)>&& callback) { - if (cache_) - { - std::shared_ptr obj = cache_->fetch(hash); - if (obj) - { - callback(obj->getType() == hotDUMMY ? nullptr : obj); - return; - } - } Database::asyncFetch(hash, ledgerSeq, std::move(callback)); } -void -DatabaseNodeImp::sweep() -{ - if (cache_) - cache_->sweep(); -} - std::shared_ptr DatabaseNodeImp::fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport& fetchReport, bool duplicate) { - std::shared_ptr nodeObject = cache_ ? cache_->fetch(hash) : nullptr; + std::shared_ptr nodeObject = nullptr; + Status status; - if (!nodeObject) + try { - JLOG(j_.trace()) << "fetchNodeObject " << hash << ": record not " << (cache_ ? "cached" : "found"); - - Status status; - - try - { - status = backend_->fetch(hash.data(), &nodeObject); - } - catch (std::exception const& e) - { - JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": Exception fetching from backend: " << e.what(); - Rethrow(); - } - - switch (status) - { - case ok: - if (cache_) - { - if (nodeObject) - cache_->canonicalize_replace_client(hash, nodeObject); - else - { - auto notFound = NodeObject::createObject(hotDUMMY, {}, hash); - cache_->canonicalize_replace_client(hash, notFound); - if (notFound->getType() != hotDUMMY) - nodeObject = notFound; - } - } - break; - case notFound: - break; - case dataCorrupt: - JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": nodestore data is corrupted"; - break; - default: - JLOG(j_.warn()) << "fetchNodeObject " << hash << ": backend returns unknown result " << status; - break; - } + status = backend_->fetch(hash.data(), &nodeObject); } - else + catch (std::exception const& e) { - JLOG(j_.trace()) << "fetchNodeObject " << hash << ": record found in cache"; - if (nodeObject->getType() == hotDUMMY) - nodeObject.reset(); + JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": Exception fetching from backend: " << e.what(); + Rethrow(); + } + + switch (status) + { + case ok: + case notFound: + break; + case dataCorrupt: + JLOG(j_.fatal()) << "fetchNodeObject " << hash << ": nodestore data is corrupted"; + break; + default: + JLOG(j_.warn()) << "fetchNodeObject " << hash << ": backend returns unknown result " << status; + break; } if (nodeObject) @@ -105,66 +59,36 @@ DatabaseNodeImp::fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport std::vector> DatabaseNodeImp::fetchBatch(std::vector const& hashes) { - std::vector> results{hashes.size()}; using namespace std::chrono; auto const before = steady_clock::now(); - std::unordered_map indexMap; - std::vector cacheMisses; - uint64_t hits = 0; - uint64_t fetches = 0; + + std::vector batch{}; + batch.reserve(hashes.size()); for (size_t i = 0; i < hashes.size(); ++i) { auto const& hash = hashes[i]; - // See if the object already exists in the cache - auto nObj = cache_ ? cache_->fetch(hash) : nullptr; - ++fetches; - if (!nObj) - { - // Try the database - indexMap[&hash] = i; - cacheMisses.push_back(&hash); - } - else - { - results[i] = nObj->getType() == hotDUMMY ? nullptr : nObj; - // It was in the cache. - ++hits; - } + batch.push_back(&hash); } - JLOG(j_.debug()) << "fetchBatch - cache hits = " << (hashes.size() - cacheMisses.size()) - << " - cache misses = " << cacheMisses.size(); - auto dbResults = backend_->fetchBatch(cacheMisses).first; - - for (size_t i = 0; i < dbResults.size(); ++i) + // Get the node objects that match the hashes from the backend. To protect + // against the backends returning fewer or more results than expected, the + // container is resized to the number of hashes. + auto results = backend_->fetchBatch(batch).first; + XRPL_ASSERT( + results.size() == hashes.size() || results.empty(), + "number of output objects either matches number of input hashes or is empty"); + results.resize(hashes.size()); + for (size_t i = 0; i < results.size(); ++i) { - auto nObj = std::move(dbResults[i]); - size_t index = indexMap[cacheMisses[i]]; - auto const& hash = hashes[index]; - - if (nObj) - { - // Ensure all threads get the same object - if (cache_) - cache_->canonicalize_replace_client(hash, nObj); - } - else + if (!results[i]) { JLOG(j_.error()) << "fetchBatch - " - << "record not found in db or cache. hash = " << strHex(hash); - if (cache_) - { - auto notFound = NodeObject::createObject(hotDUMMY, {}, hash); - cache_->canonicalize_replace_client(hash, notFound); - if (notFound->getType() != hotDUMMY) - nObj = std::move(notFound); - } + << "record not found in db. hash = " << strHex(hashes[i]); } - results[index] = std::move(nObj); } auto fetchDurationUs = std::chrono::duration_cast(steady_clock::now() - before).count(); - updateFetchMetrics(fetches, hits, fetchDurationUs); + updateFetchMetrics(hashes.size(), 0, fetchDurationUs); return results; } diff --git a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp index 2e72dca969..f25b9d068e 100644 --- a/src/libxrpl/nodestore/DatabaseRotatingImp.cpp +++ b/src/libxrpl/nodestore/DatabaseRotatingImp.cpp @@ -93,12 +93,6 @@ DatabaseRotatingImp::store(NodeObjectType type, Blob&& data, uint256 const& hash storeStats(1, nObj->getData().size()); } -void -DatabaseRotatingImp::sweep() -{ - // nothing to do -} - std::shared_ptr DatabaseRotatingImp::fetchNodeObject(uint256 const& hash, std::uint32_t, FetchReport& fetchReport, bool duplicate) { diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 91845709c5..7951da26d1 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -490,19 +490,8 @@ public: Env env(*this, envconfig(onlineDelete)); ///////////////////////////////////////////////////////////// - // Create the backend. Normally, SHAMapStoreImp handles all these - // details - auto nscfg = env.app().config().section(ConfigSection::nodeDatabase()); - - // Provide default values: - if (!nscfg.exists("cache_size")) - nscfg.set( - "cache_size", std::to_string(env.app().config().getValueFor(SizedItem::treeCacheSize, std::nullopt))); - - if (!nscfg.exists("cache_age")) - nscfg.set( - "cache_age", std::to_string(env.app().config().getValueFor(SizedItem::treeCacheAge, std::nullopt))); - + // Create NodeStore with two backends to allow online deletion of data. + // Normally, SHAMapStoreImp handles all these details. NodeStoreScheduler scheduler(env.app().getJobQueue()); std::string const writableDb = "write"; @@ -510,9 +499,8 @@ public: auto writableBackend = makeBackendRotating(env, scheduler, writableDb); auto archiveBackend = makeBackendRotating(env, scheduler, archiveDb); - // Create NodeStore with two backends to allow online deletion of - // data constexpr int readThreads = 4; + auto nscfg = env.app().config().section(ConfigSection::nodeDatabase()); auto dbr = std::make_unique( scheduler, readThreads, diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 3045097e4a..2c0d3c2b82 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -908,10 +908,6 @@ public: JLOG(m_journal.debug()) << "MasterTransaction sweep. Size before: " << oldMasterTxSize << "; size after: " << masterTxCache.size(); } - { - // Does not appear to have an associated cache. - getNodeStore().sweep(); - } { std::size_t const oldLedgerMasterCacheSize = getLedgerMaster().getFetchPackCacheSize(); diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 0ed3b8a3fc..dbdd682ef8 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -130,14 +130,6 @@ std::unique_ptr SHAMapStoreImp::makeNodeStore(int readThreads) { auto nscfg = app_.config().section(ConfigSection::nodeDatabase()); - - // Provide default values: - if (!nscfg.exists("cache_size")) - nscfg.set("cache_size", std::to_string(app_.config().getValueFor(SizedItem::treeCacheSize, std::nullopt))); - - if (!nscfg.exists("cache_age")) - nscfg.set("cache_age", std::to_string(app_.config().getValueFor(SizedItem::treeCacheAge, std::nullopt))); - std::unique_ptr db; if (deleteInterval_) @@ -226,8 +218,6 @@ SHAMapStoreImp::run() LedgerIndex lastRotated = state_db_.getState().lastRotated; netOPs_ = &app_.getOPs(); ledgerMaster_ = &app_.getLedgerMaster(); - fullBelowCache_ = &(*app_.getNodeFamily().getFullBelowCache()); - treeNodeCache_ = &(*app_.getNodeFamily().getTreeNodeCache()); if (advisoryDelete_) canDelete_ = state_db_.getCanDelete(); @@ -490,16 +480,19 @@ void SHAMapStoreImp::clearCaches(LedgerIndex validatedSeq) { ledgerMaster_->clearLedgerCachePrior(validatedSeq); - fullBelowCache_->clear(); + // Also clear the FullBelowCache so its generation counter is bumped. + // This prevents stale "full below" markers from persisting across + // backend rotation/online deletion and interfering with SHAMap sync. + app_.getNodeFamily().getFullBelowCache()->clear(); } void SHAMapStoreImp::freshenCaches() { - if (freshenCache(*treeNodeCache_)) - return; - if (freshenCache(app_.getMasterTransaction().getCache())) + if (freshenCache(*app_.getNodeFamily().getTreeNodeCache())) return; + + freshenCache(app_.getMasterTransaction().getCache()); } void diff --git a/src/xrpld/app/misc/SHAMapStoreImp.h b/src/xrpld/app/misc/SHAMapStoreImp.h index a0475e80d6..b046a78979 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.h +++ b/src/xrpld/app/misc/SHAMapStoreImp.h @@ -93,8 +93,6 @@ private: // as of run() or before NetworkOPs* netOPs_ = nullptr; LedgerMaster* ledgerMaster_ = nullptr; - FullBelowCache* fullBelowCache_ = nullptr; - TreeNodeCache* treeNodeCache_ = nullptr; static constexpr auto nodeStoreName_ = "NodeStore"; From 2305bc98a4c51550504060460d14aa43046379a1 Mon Sep 17 00:00:00 2001 From: Ayaz Salikhov Date: Fri, 6 Feb 2026 16:39:23 +0000 Subject: [PATCH 03/16] chore: Remove CODEOWNERS (#6337) --- .github/CODEOWNERS | 8 -------- 1 file changed, 8 deletions(-) delete mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS deleted file mode 100644 index bc4fe2febd..0000000000 --- a/.github/CODEOWNERS +++ /dev/null @@ -1,8 +0,0 @@ -# Allow anyone to review any change by default. -* - -# Require the rpc-reviewers team to review changes to the rpc code. -include/xrpl/protocol/ @xrplf/rpc-reviewers -src/libxrpl/protocol/ @xrplf/rpc-reviewers -src/xrpld/rpc/ @xrplf/rpc-reviewers -src/xrpld/app/misc/ @xrplf/rpc-reviewers From f5208fc85020eb96de6a2b625ccb7f53c744d07a Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 6 Feb 2026 13:37:01 -0500 Subject: [PATCH 04/16] test: Add file and line location to Env (#6276) This change uses `std::source_location` to output the file and line location of the call that triggered a failed transaction. --- src/test/app/LedgerReplay_test.cpp | 3 +- src/test/jtx/Env.h | 62 +++++++++++++++++++++++++----- src/test/jtx/Env_ss.h | 21 +++++++--- src/test/jtx/impl/Env.cpp | 33 ++++++++-------- src/test/rpc/Subscribe_test.cpp | 3 +- 5 files changed, 88 insertions(+), 34 deletions(-) diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index 8bf1a8f668..229cad21c9 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -491,8 +491,7 @@ struct LedgerServer for (int i = 0; i < newTxes; ++i) { updateIdx(); - env.apply( - pay(accounts[fromIdx], + env(pay(accounts[fromIdx], accounts[toIdx], jtx::drops(ledgerMaster.getClosedLedger()->fees().base) + jtx::XRP(param.txAmount)), jtx::seq(jtx::autofill), diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index ef6240d48a..7d7dcd2cb8 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -42,6 +43,27 @@ namespace xrpl { namespace test { namespace jtx { +/** Wrapper that captures std::source_location when implicitly constructed. + This solves the problem of combining std::source_location with variadic + templates. The std::source_location default argument is evaluated at the + call site when the wrapper is constructed via implicit conversion. + + This is a template struct that holds the value directly, allowing implicit + conversion without template argument deduction issues via CTAD. +*/ +template +struct WithSourceLocation +{ + T value; + std::source_location loc; + + // Non-explicit constructor allows implicit conversion. + // The default argument for loc is evaluated at the call site. + WithSourceLocation(T v, std::source_location l = std::source_location::current()) : value(std::move(v)), loc(l) + { + } +}; + /** Designate accounts as no-ripple in Env::fund */ template std::array @@ -522,35 +544,57 @@ public: This calls postconditions. */ virtual void - submit(JTx const& jt); + submit(JTx const& jt, std::source_location const& loc = std::source_location::current()); /** Use the submit RPC command with a provided JTx object. This calls postconditions. */ void - sign_and_submit(JTx const& jt, Json::Value params = Json::nullValue); + sign_and_submit( + JTx const& jt, + Json::Value params = Json::nullValue, + std::source_location const& loc = std::source_location::current()); /** Check expected postconditions of JTx submission. */ void - postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const& jr = Json::Value()); + postconditions( + JTx const& jt, + ParsedResult const& parsed, + Json::Value const& jr = Json::Value(), + std::source_location const& loc = std::source_location::current()); /** Apply funclets and submit. */ /** @{ */ - template + template Env& - apply(JsonValue&& jv, FN const&... fN) + apply(WithSourceLocation jv, FN const&... fN) { - submit(jt(std::forward(jv), fN...)); + submit(jt(std::move(jv.value), fN...), jv.loc); return *this; } - template + template Env& - operator()(JsonValue&& jv, FN const&... fN) + apply(WithSourceLocation jv, FN const&... fN) { - return apply(std::forward(jv), fN...); + submit(jt(std::move(jv.value), fN...), jv.loc); + return *this; + } + + template + Env& + operator()(WithSourceLocation jv, FN const&... fN) + { + return apply(std::move(jv), fN...); + } + + template + Env& + operator()(WithSourceLocation jv, FN const&... fN) + { + return apply(std::move(jv), fN...); } /** @} */ diff --git a/src/test/jtx/Env_ss.h b/src/test/jtx/Env_ss.h index 78146a04a4..9c178a1c13 100644 --- a/src/test/jtx/Env_ss.h +++ b/src/test/jtx/Env_ss.h @@ -23,19 +23,20 @@ private: SignSubmitRunner& operator=(SignSubmitRunner&&) = delete; - SignSubmitRunner(Env& env, JTx&& jt) : env_(env), jt_(jt) + SignSubmitRunner(Env& env, JTx&& jt, std::source_location loc) : env_(env), jt_(jt), loc_(loc) { } void operator()(Json::Value const& params = Json::nullValue) { - env_.sign_and_submit(jt_, params); + env_.sign_and_submit(jt_, params, loc_); } private: Env& env_; JTx const jt_; + std::source_location const loc_; }; public: @@ -47,12 +48,20 @@ public: { } - template + template SignSubmitRunner - operator()(JsonValue&& jv, FN const&... fN) + operator()(WithSourceLocation jv, FN const&... fN) { - auto jtx = env_.jt(std::forward(jv), fN...); - return SignSubmitRunner(env_, std::move(jtx)); + auto jtx = env_.jt(std::move(jv.value), fN...); + return SignSubmitRunner(env_, std::move(jtx), jv.loc); + } + + template + SignSubmitRunner + operator()(WithSourceLocation jv, FN const&... fN) + { + auto jtx = env_.jt(std::move(jv.value), fN...); + return SignSubmitRunner(env_, std::move(jtx), jv.loc); } }; diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 9971da05c4..d8bcec84ee 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -27,6 +27,7 @@ #include #include +#include namespace xrpl { namespace test { @@ -330,7 +331,7 @@ Env::parseResult(Json::Value const& jr) } void -Env::submit(JTx const& jt) +Env::submit(JTx const& jt, std::source_location const& loc) { ParsedResult parsedResult; auto const jr = [&]() { @@ -356,11 +357,11 @@ Env::submit(JTx const& jt) return Json::Value(); } }(); - return postconditions(jt, parsedResult, jr); + return postconditions(jt, parsedResult, jr, loc); } void -Env::sign_and_submit(JTx const& jt, Json::Value params) +Env::sign_and_submit(JTx const& jt, Json::Value params, std::source_location const& loc) { auto const account = lookup(jt.jv[jss::Account].asString()); auto const& passphrase = account.name(); @@ -393,25 +394,26 @@ Env::sign_and_submit(JTx const& jt, Json::Value params) test.expect(parsedResult.ter, "ter uninitialized!"); ter_ = parsedResult.ter.value_or(telENV_RPC_FAILED); - return postconditions(jt, parsedResult, jr); + return postconditions(jt, parsedResult, jr, loc); } void -Env::postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const& jr) +Env::postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const& jr, std::source_location const& loc) { auto const line = jt.testLine ? " (" + to_string(*jt.testLine) + ")" : ""; - bool bad = !test.expect(parsed.ter, "apply: No ter result!" + line); + auto const locStr = std::string("(") + loc.file_name() + ":" + to_string(loc.line()) + ")"; + bool bad = !test.expect(parsed.ter, "apply " + locStr + ": No ter result!" + line); bad = (jt.ter && parsed.ter && !test.expect( *parsed.ter == *jt.ter, - "apply: Got " + transToken(*parsed.ter) + " (" + transHuman(*parsed.ter) + "); Expected " + + "apply " + locStr + ": Got " + transToken(*parsed.ter) + " (" + transHuman(*parsed.ter) + "); Expected " + transToken(*jt.ter) + " (" + transHuman(*jt.ter) + ")" + line)); using namespace std::string_literals; bad = (jt.rpcCode && !test.expect( parsed.rpcCode == jt.rpcCode->first && parsed.rpcMessage == jt.rpcCode->second, - "apply: Got RPC result "s + + "apply " + locStr + ": Got RPC result "s + (parsed.rpcCode ? RPC::get_error_info(*parsed.rpcCode).token.c_str() : "NO RESULT") + " (" + parsed.rpcMessage + "); Expected " + RPC::get_error_info(jt.rpcCode->first).token.c_str() + " (" + jt.rpcCode->second + ")" + line)) || @@ -419,13 +421,14 @@ Env::postconditions(JTx const& jt, ParsedResult const& parsed, Json::Value const // If we have an rpcCode (just checked), then the rpcException check is // optional - the 'error' field may not be defined, but if it is, it must // match rpcError. - bad = (jt.rpcException && - !test.expect( - (jt.rpcCode && parsed.rpcError.empty()) || - (parsed.rpcError == jt.rpcException->first && - (!jt.rpcException->second || parsed.rpcException == *jt.rpcException->second)), - "apply: Got RPC result "s + parsed.rpcError + " (" + parsed.rpcException + "); Expected " + - jt.rpcException->first + " (" + jt.rpcException->second.value_or("n/a") + ")" + line)) || + bad = + (jt.rpcException && + !test.expect( + (jt.rpcCode && parsed.rpcError.empty()) || + (parsed.rpcError == jt.rpcException->first && + (!jt.rpcException->second || parsed.rpcException == *jt.rpcException->second)), + "apply " + locStr + ": Got RPC result "s + parsed.rpcError + " (" + parsed.rpcException + "); Expected " + + jt.rpcException->first + " (" + jt.rpcException->second.value_or("n/a") + ")" + line)) || bad; if (bad) { diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 4f83f81da5..cce45fb4ef 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -835,8 +835,7 @@ public: { auto& from = (i % 2 == 0) ? a : b; auto& to = (i % 2 == 0) ? b : a; - env.apply( - pay(from, to, jtx::XRP(numXRP)), + env(pay(from, to, jtx::XRP(numXRP)), jtx::seq(jtx::autofill), jtx::fee(jtx::autofill), jtx::sig(jtx::autofill)); From bf4674f42b0515f0fe81d4b523c98d68fd7269b3 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Fri, 6 Feb 2026 15:30:22 -0500 Subject: [PATCH 05/16] refactor: Fix spelling issues in tests (#6199) This change removes the `src/tests` exception from the `cspell` config and fixes all the issues that arise as a result. No functionality/test change. --- .../cspell.config.yaml => cspell.config.yaml | 35 +++++--- include/xrpl/proto/xrpl.proto | 6 +- src/test/app/AMMCalc_test.cpp | 30 +++---- src/test/app/AMMExtended_test.cpp | 8 +- src/test/app/AMM_test.cpp | 32 +++---- src/test/app/Batch_test.cpp | 2 +- src/test/app/CrossingLimits_test.cpp | 22 ++--- src/test/app/DepositAuth_test.cpp | 6 +- src/test/app/EscrowToken_test.cpp | 12 +-- src/test/app/FixNFTokenPageLinks_test.cpp | 2 +- src/test/app/LPTokenTransfer_test.cpp | 2 +- src/test/app/LoanBroker_test.cpp | 2 +- src/test/app/Loan_test.cpp | 1 + src/test/app/MPToken_test.cpp | 2 +- src/test/app/NFToken_test.cpp | 18 ++-- src/test/app/Offer_test.cpp | 86 +++++++++---------- src/test/app/PayStrand_test.cpp | 6 +- src/test/app/ReducedOffer_test.cpp | 36 ++++---- src/test/app/SHAMapStore_test.cpp | 6 +- src/test/app/TrustAndBalance_test.cpp | 10 +-- src/test/app/Vault_test.cpp | 2 +- src/test/app/XChain_test.cpp | 5 +- src/test/core/Config_test.cpp | 36 ++++---- src/test/jtx/TestHelpers.h | 2 +- src/test/jtx/impl/AMM.cpp | 42 ++++----- src/test/jtx/impl/TestHelpers.cpp | 2 +- src/test/jtx/impl/mpt.cpp | 28 +++--- src/test/jtx/mpt.h | 8 +- src/test/ledger/Directory_test.cpp | 2 +- src/test/ledger/View_test.cpp | 10 +-- src/test/overlay/compression_test.cpp | 10 +-- src/test/protocol/STAmount_test.cpp | 4 +- src/test/rpc/AccountLines_test.cpp | 2 +- src/test/rpc/AccountObjects_test.cpp | 4 +- src/test/rpc/Handler_test.cpp | 1 + src/test/rpc/LedgerEntry_test.cpp | 4 +- src/test/rpc/NoRipple_test.cpp | 4 +- src/test/rpc/Transaction_test.cpp | 4 +- 38 files changed, 256 insertions(+), 238 deletions(-) rename .config/cspell.config.yaml => cspell.config.yaml (79%) diff --git a/.config/cspell.config.yaml b/cspell.config.yaml similarity index 79% rename from .config/cspell.config.yaml rename to cspell.config.yaml index a9c621f567..b2f4a33769 100644 --- a/.config/cspell.config.yaml +++ b/cspell.config.yaml @@ -1,14 +1,13 @@ ignorePaths: - build/** - src/libxrpl/crypto - - src/test/** # Will be removed in the future - CMakeUserPresets.json - Doxyfile - docs/**/*.puml - cmake/** - LICENSE.md language: en -allowCompoundWords: true +allowCompoundWords: true # TODO (#6334) ignoreRandomStrings: true minWordLength: 5 dictionaries: @@ -16,20 +15,29 @@ dictionaries: - en_US - en_GB ignoreRegExpList: - - /[rs][1-9A-HJ-NP-Za-km-z]{25,34}/g # addresses and seeds - - /(XRPL|BEAST)_[A-Z_0-9]+_H_INCLUDED+/g # include guards - - /(XRPL|BEAST)_[A-Z_0-9]+_H+/g # include guards + - /\b[rs][1-9A-HJ-NP-Za-km-z]{25,34}/g # addresses and seeds + - /\bC[A-Z0-9]{15}/g # CTIDs + - /\b(XRPL|BEAST)_[A-Z_0-9]+_H_INCLUDED+/g # include guards + - /\b(XRPL|BEAST)_[A-Z_0-9]+_H+/g # include guards - /::[a-z:_]+/g # things from other namespaces - - /lib[a-z]+/g # libraries - - /[0-9]{4}-[0-9]{2}-[0-9]{2}[,:][A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright dates - - /[0-9]{4}[,:]?\s*[A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright years + - /\blib[a-z]+/g # libraries + - /\b[0-9]{4}-[0-9]{2}-[0-9]{2}[,:][A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright dates + - /\b[0-9]{4}[,:]?\s*[A-Za-zÀ-ÖØ-öø-ÿ.\s]+/g # copyright years - /\[[A-Za-z0-9-]+\]\(https:\/\/github.com\/[A-Za-z0-9-]+\)/g # Github usernames - /-[DWw][a-zA-Z0-9_-]+=/g # compile flags - /[\['"`]-[DWw][a-zA-Z0-9_-]+['"`\]]/g # compile flags + - ABCDEFGHIJKLMNOPQRSTUVWXYZ + - ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +overrides: + - filename: "**/*_test.cpp" # all test files + ignoreRegExpList: + - /"[^"]*"/g # double-quoted strings + - /'[^']*'/g # single-quoted strings + - /`[^`]*`/g # backtick strings suggestWords: - xprl->xrpl - - xprld->xrpld - - unsynched->unsynced + - xprld->xrpld # cspell: disable-line not sure what this problem is.... + - unsynched->unsynced # cspell: disable-line not sure what this problem is.... - synched->synced - synch->sync words: @@ -51,6 +59,7 @@ words: - Britto - Btrfs - canonicality + - changespq - checkme - choco - chrono @@ -106,12 +115,14 @@ words: - inequation - insuf - insuff + - invasively - iou - ious - isrdc - itype - jemalloc - jlog + - jtnofill - keylet - keylets - keyvadb @@ -138,6 +149,7 @@ words: - Metafuncton - misprediction - mptbalance + - MPTDEX - mptflags - mptid - mptissuance @@ -147,6 +159,7 @@ words: - mptokenissuance - mptokens - mpts + - mtgox - multisig - multisign - multisigned @@ -174,6 +187,7 @@ words: - perminute - permissioned - pointee + - populator - preauth - preauthorization - preauthorize @@ -182,6 +196,7 @@ words: - protobuf - protos - ptrs + - pushd - pyenv - qalloc - queuable diff --git a/include/xrpl/proto/xrpl.proto b/include/xrpl/proto/xrpl.proto index 613ef70a1f..0af7deb35d 100644 --- a/include/xrpl/proto/xrpl.proto +++ b/include/xrpl/proto/xrpl.proto @@ -86,9 +86,9 @@ message TMPublicKey { // you must first combine coins from one address to another. enum TransactionStatus { - tsNEW = 1; // origin node did/could not validate - tsCURRENT = 2; // scheduled to go in this ledger - tsCOMMITED = 3; // in a closed ledger + tsNEW = 1; // origin node did/could not validate + tsCURRENT = 2; // scheduled to go in this ledger + tsCOMMITTED = 3; // in a closed ledger tsREJECT_CONFLICT = 4; tsREJECT_INVALID = 5; tsREJECT_FUNDS = 6; diff --git a/src/test/app/AMMCalc_test.cpp b/src/test/app/AMMCalc_test.cpp index 7d735c2575..bc50f02d3d 100644 --- a/src/test/app/AMMCalc_test.cpp +++ b/src/test/app/AMMCalc_test.cpp @@ -23,8 +23,8 @@ class AMMCalc_test : public beast::unit_test::suite { using token_iter = boost::sregex_token_iterator; using steps = std::vector>; - using trates = std::map; - using swapargs = std::tuple; + using transfer_rates = std::map; + using swapargs = std::tuple; jtx::Account const gw{jtx::Account("gw")}; token_iter const end_; @@ -101,10 +101,10 @@ class AMMCalc_test : public beast::unit_test::suite return {{{*a1, *a2}, amm}}; } - std::optional + std::optional getTransferRate(token_iter& p) { - trates rates{}; + transfer_rates rates{}; if (p == end_) return rates; std::string str = *p; @@ -115,8 +115,8 @@ class AMMCalc_test : public beast::unit_test::suite { if (auto const rate = getRate(p++)) { - auto const [currency, trate, delimited] = *rate; - rates[currency] = trate; + auto const [currency, transferRate, delimited] = *rate; + rates[currency] = transferRate; if (delimited) break; } @@ -180,13 +180,13 @@ class AMMCalc_test : public beast::unit_test::suite auto const vp = std::get(args); STAmount sout = std::get(args); auto const fee = std::get(args); - auto const rates = std::get(args); + auto const rates = std::get(args); STAmount resultOut = sout; STAmount resultIn{}; STAmount sin{}; int limitingStep = vp.size(); STAmount limitStepOut{}; - auto trate = [&](auto const& amt) { + auto transferRate = [&](auto const& amt) { auto const currency = to_string(amt.issue().currency); return rates.find(currency) != rates.end() ? rates.at(currency) : QUALITY_ONE; }; @@ -194,7 +194,7 @@ class AMMCalc_test : public beast::unit_test::suite sin = sout; for (auto it = vp.rbegin(); it != vp.rend(); ++it) { - sout = mulratio(sin, trate(sin), QUALITY_ONE, true); + sout = mulratio(sin, transferRate(sin), QUALITY_ONE, true); auto const [amts, amm] = *it; // assume no amm limit if (amm) @@ -221,7 +221,7 @@ class AMMCalc_test : public beast::unit_test::suite for (int i = limitingStep + 1; i < vp.size(); ++i) { auto const [amts, amm] = vp[i]; - sin = mulratio(sin, QUALITY_ONE, trate(sin), false); + sin = mulratio(sin, QUALITY_ONE, transferRate(sin), false); if (amm) { sout = swapAssetIn(amts, sin, fee); @@ -243,13 +243,13 @@ class AMMCalc_test : public beast::unit_test::suite auto const vp = std::get(args); STAmount sin = std::get(args); auto const fee = std::get(args); - auto const rates = std::get(args); + auto const rates = std::get(args); STAmount resultIn = sin; STAmount resultOut{}; STAmount sout{}; int limitingStep = 0; STAmount limitStepIn{}; - auto trate = [&](auto const& amt) { + auto transferRate = [&](auto const& amt) { auto const currency = to_string(amt.issue().currency); return rates.find(currency) != rates.end() ? rates.at(currency) : QUALITY_ONE; }; @@ -257,7 +257,7 @@ class AMMCalc_test : public beast::unit_test::suite for (auto it = vp.begin(); it != vp.end(); ++it) { auto const [amts, amm] = *it; - sin = mulratio(sin, QUALITY_ONE, trate(sin), + sin = mulratio(sin, QUALITY_ONE, transferRate(sin), false); // out of the next step // assume no amm limit if (amm) @@ -283,7 +283,7 @@ class AMMCalc_test : public beast::unit_test::suite // swap out if limiting step for (int i = limitingStep - 1; i >= 0; --i) { - sout = mulratio(sin, trate(sin), QUALITY_ONE, false); + sout = mulratio(sin, transferRate(sin), QUALITY_ONE, false); auto const [amts, amm] = vp[i]; if (amm) { @@ -296,7 +296,7 @@ class AMMCalc_test : public beast::unit_test::suite } resultIn = sin; } - resultOut = mulratio(resultOut, QUALITY_ONE, trate(resultOut), true); + resultOut = mulratio(resultOut, QUALITY_ONE, transferRate(resultOut), true); std::cout << "in: " << toString(resultIn) << " out: " << toString(resultOut) << std::endl; } diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 3cc48787d5..4eecb05905 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -1701,8 +1701,8 @@ private: // This removes no ripple for carol, // different from the original test fund(env, gw, {carol}, XRP(10'000), {}, Fund::Acct); - auto const AMMXRPPool = env.current()->fees().increment * 2; - env.fund(reserve(env, 5) + ammCrtFee(env) + AMMXRPPool, bob); + auto const ammXrpPool = env.current()->fees().increment * 2; + env.fund(reserve(env, 5) + ammCrtFee(env) + ammXrpPool, bob); env.close(); env.trust(USD(1'000), alice, bob, carol); env.trust(EUR(1'000), alice, bob, carol); @@ -1718,7 +1718,7 @@ private: // tecPATH_DRY, but the entire path should not be marked as dry. // This is the second error case to test (when flowV1 is used). env(offer(bob, EUR(50), XRP(50))); - AMM ammBob(env, bob, AMMXRPPool, USD(150)); + AMM ammBob(env, bob, ammXrpPool, USD(150)); env(pay(alice, carol, USD(1'000'000)), path(~XRP, ~USD), @@ -3248,7 +3248,7 @@ private: Path const p = [&] { Path result; - result.push_back(allpe(gw, BobUSD)); + result.push_back(allPathElements(gw, BobUSD)); result.push_back(cpe(EUR.currency)); return result; }(); diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 14b97f30f1..8a60e5f667 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -975,7 +975,7 @@ private: .tokens = IOUAmount{1, -10}, .asset1In = STAmount{USD, 1, -15}, .err = ter(tecAMM_INVALID_TOKENS)}); }); - // Single deposit with eprice, tokens rounded to 0 + // Single deposit with EPrice, tokens rounded to 0 testAMM([&](AMM& amm, Env& env) { amm.deposit(DepositArg{ .asset1In = STAmount{USD, 1, -15}, .maxEP = STAmount{USD, 1, -1}, .err = ter(tecAMM_INVALID_TOKENS)}); @@ -4204,8 +4204,8 @@ private: Account const chris("chris"); Account const simon("simon"); Account const ben("ben"); - Account const nataly("nataly"); - fund(env, gw, {bob, ed, paul, dan, chris, simon, ben, nataly}, {USD(1'500'000)}, Fund::Acct); + Account const natalie("natalie"); + fund(env, gw, {bob, ed, paul, dan, chris, simon, ben, natalie}, {USD(1'500'000)}, Fund::Acct); for (int i = 0; i < 10; ++i) { ammAlice.deposit(ben, STAmount{USD, 1, -10}); @@ -4224,8 +4224,8 @@ private: ammAlice.withdrawAll(ed, USD(0)); ammAlice.deposit(paul, USD(100'000)); ammAlice.withdrawAll(paul, USD(0)); - ammAlice.deposit(nataly, USD(1'000'000)); - ammAlice.withdrawAll(nataly, USD(0)); + ammAlice.deposit(natalie, USD(1'000'000)); + ammAlice.withdrawAll(natalie, USD(0)); } // Due to round off some accounts have a tiny gain, while // other have a tiny loss. The last account to withdraw @@ -4251,11 +4251,11 @@ private: BEAST_EXPECT(expectHolding(env, ed, USD(1'500'000))); BEAST_EXPECT(expectHolding(env, paul, USD(1'500'000))); if (!features[fixAMMv1_1] && !features[fixAMMv1_3]) - BEAST_EXPECT(expectHolding(env, nataly, STAmount{USD, UINT64_C(1'500'000'000000002), -9})); + BEAST_EXPECT(expectHolding(env, natalie, STAmount{USD, UINT64_C(1'500'000'000000002), -9})); else if (features[fixAMMv1_1] && !features[fixAMMv1_3]) - BEAST_EXPECT(expectHolding(env, nataly, STAmount{USD, UINT64_C(1'500'000'000000005), -9})); + BEAST_EXPECT(expectHolding(env, natalie, STAmount{USD, UINT64_C(1'500'000'000000005), -9})); else - BEAST_EXPECT(expectHolding(env, nataly, USD(1'500'000))); + BEAST_EXPECT(expectHolding(env, natalie, USD(1'500'000))); ammAlice.withdrawAll(alice); BEAST_EXPECT(!ammAlice.ammExists()); if (!features[fixAMMv1_1]) @@ -4264,7 +4264,7 @@ private: BEAST_EXPECT(expectHolding(env, alice, STAmount{USD, UINT64_C(30'000'0000000003), -10})); else BEAST_EXPECT(expectHolding(env, alice, USD(30'000))); - // alice XRP balance is 30,000initial - 50 ammcreate fee - + // alice XRP balance is 30,000 initial - 50 AMMCreate fee - // 10drops fee BEAST_EXPECT( accountBalance(env, alice) == std::to_string(29950000000 - env.current()->fees().base.drops())); @@ -4284,8 +4284,8 @@ private: Account const chris("chris"); Account const simon("simon"); Account const ben("ben"); - Account const nataly("nataly"); - fund(env, gw, {bob, ed, paul, dan, chris, simon, ben, nataly}, XRP(2'000'000), {}, Fund::Acct); + Account const natalie("natalie"); + fund(env, gw, {bob, ed, paul, dan, chris, simon, ben, natalie}, XRP(2'000'000), {}, Fund::Acct); for (int i = 0; i < 10; ++i) { ammAlice.deposit(ben, XRPAmount{1}); @@ -4304,8 +4304,8 @@ private: ammAlice.withdrawAll(ed, XRP(0)); ammAlice.deposit(paul, XRP(100'000)); ammAlice.withdrawAll(paul, XRP(0)); - ammAlice.deposit(nataly, XRP(1'000'000)); - ammAlice.withdrawAll(nataly, XRP(0)); + ammAlice.deposit(natalie, XRP(1'000'000)); + ammAlice.withdrawAll(natalie, XRP(0)); } auto const baseFee = env.current()->fees().base.drops(); if (!features[fixAMMv1_3]) @@ -4325,8 +4325,8 @@ private: BEAST_EXPECT(accountBalance(env, carol) == std::to_string(30'000'000'000 - 20 * baseFee)); BEAST_EXPECT(accountBalance(env, ed) == xrpBalance); BEAST_EXPECT(accountBalance(env, paul) == xrpBalance); - BEAST_EXPECT(accountBalance(env, nataly) == xrpBalance); - // 30,000 initial - 50 ammcreate fee - 10drops withdraw fee + BEAST_EXPECT(accountBalance(env, natalie) == xrpBalance); + // 30,000 initial - 50 AMMCreate fee - 10drops withdraw fee BEAST_EXPECT(accountBalance(env, alice) == std::to_string(29'950'000'000 - baseFee)); } else @@ -4346,7 +4346,7 @@ private: BEAST_EXPECT(accountBalance(env, carol) == std::to_string(30'000'000'000 - 20 * baseFee - 10)); BEAST_EXPECT(accountBalance(env, ed) == (xrpBalance + drops(2)).getText()); BEAST_EXPECT(accountBalance(env, paul) == (xrpBalance + drops(3)).getText()); - BEAST_EXPECT(accountBalance(env, nataly) == (xrpBalance + drops(5)).getText()); + BEAST_EXPECT(accountBalance(env, natalie) == (xrpBalance + drops(5)).getText()); BEAST_EXPECT(accountBalance(env, alice) == std::to_string(29'950'000'000 - baseFee + 80)); } }, diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index 035a1f8a6f..72f3677e3b 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -3618,7 +3618,7 @@ class Batch_test : public beast::unit_test::suite // another transaction is part of the batch, the batch might fail // because the sequence is out of order. This is because the canonical // order of transactions is determined by the account first. So in this - // case, alice's batch comes after bobs self submitted transaction even + // case, alice's batch comes after bob's self submitted transaction even // though the payment was submitted after the batch. using namespace test::jtx; diff --git a/src/test/app/CrossingLimits_test.cpp b/src/test/app/CrossingLimits_test.cpp index e1974adee1..0451822492 100644 --- a/src/test/app/CrossingLimits_test.cpp +++ b/src/test/app/CrossingLimits_test.cpp @@ -64,15 +64,15 @@ public: int const maxConsumed = 1000; env.fund(XRP(100000000), gw, "alice", "bob", "carol"); - int const bobsOfferCount = maxConsumed + 150; - env.trust(USD(bobsOfferCount), "bob"); - env(pay(gw, "bob", USD(bobsOfferCount))); + int const bobOfferCount = maxConsumed + 150; + env.trust(USD(bobOfferCount), "bob"); + env(pay(gw, "bob", USD(bobOfferCount))); env.close(); - n_offers(env, bobsOfferCount, "bob", XRP(1), USD(1)); + n_offers(env, bobOfferCount, "bob", XRP(1), USD(1)); // Alice offers to buy Bob's offers. However she hits the offer // crossing limit, so she can't buy them all at once. - env(offer("alice", USD(bobsOfferCount), XRP(bobsOfferCount))); + env(offer("alice", USD(bobOfferCount), XRP(bobOfferCount))); env.close(); env.require(balance("alice", USD(maxConsumed))); env.require(balance("bob", USD(150))); @@ -103,19 +103,19 @@ public: // The payment engine allows 1000 offers to cross. int const maxConsumed = 1000; - int const evitasOfferCount{maxConsumed + 49}; + int const evitaOfferCount{maxConsumed + 49}; env.trust(USD(1000), "alice"); env(pay(gw, "alice", USD(1000))); env.trust(USD(1000), "carol"); env(pay(gw, "carol", USD(1))); - env.trust(USD(evitasOfferCount + 1), "evita"); - env(pay(gw, "evita", USD(evitasOfferCount + 1))); + env.trust(USD(evitaOfferCount + 1), "evita"); + env(pay(gw, "evita", USD(evitaOfferCount + 1))); // The payment engine has a limit of 1000 funded or unfunded offers. int const carolsOfferCount{700}; n_offers(env, 400, "alice", XRP(1), USD(1)); n_offers(env, carolsOfferCount, "carol", XRP(1), USD(1)); - n_offers(env, evitasOfferCount, "evita", XRP(1), USD(1)); + n_offers(env, evitaOfferCount, "evita", XRP(1), USD(1)); // Bob offers to buy 1000 XRP for 1000 USD. He takes all 400 USD from // Alice's offers, 1 USD from Carol's and then removes 599 of Carol's @@ -126,8 +126,8 @@ public: env.require(owners("alice", 1)); env.require(balance("carol", USD(0))); env.require(owners("carol", carolsOfferCount - 599)); - env.require(balance("evita", USD(evitasOfferCount + 1))); - env.require(owners("evita", evitasOfferCount + 1)); + env.require(balance("evita", USD(evitaOfferCount + 1))); + env.require(owners("evita", evitaOfferCount + 1)); // Dan offers to buy maxConsumed + 50 XRP USD. He removes all of // Carol's remaining offers as unfunded, then takes diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index 535abc6af8..0cd7e7449c 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -1237,17 +1237,17 @@ struct DepositPreauth_test : public beast::unit_test::suite auto const dp = ledgerEntryDepositPreauth(env, stock, credentials); auto const& authCred(dp[jss::result][jss::node]["AuthorizeCredentials"]); BEAST_EXPECT(authCred.isArray() && authCred.size() == credentials.size()); - std::vector> readedCreds; + std::vector> readCreds; for (auto const& o : authCred) { auto const& c(o[jss::Credential]); auto issuer = c[jss::Issuer].asString(); if (BEAST_EXPECT(pubKey2Acc.contains(issuer))) - readedCreds.emplace_back(pubKey2Acc.at(issuer), c["CredentialType"].asString()); + readCreds.emplace_back(pubKey2Acc.at(issuer), c["CredentialType"].asString()); } - BEAST_EXPECT(std::ranges::is_sorted(readedCreds)); + BEAST_EXPECT(std::ranges::is_sorted(readCreds)); env(deposit::unauthCredentials(stock, credentials)); env.close(); diff --git a/src/test/app/EscrowToken_test.cpp b/src/test/app/EscrowToken_test.cpp index b5088f247a..1f3b3bab70 100644 --- a/src/test/app/EscrowToken_test.cpp +++ b/src/test/app/EscrowToken_test.cpp @@ -752,7 +752,7 @@ struct EscrowToken_test : public beast::unit_test::suite env.trust(USD(1), bob); env.close(); - // alice cannot finish because bobs limit is too low + // alice cannot finish because bob's limit is too low env(escrow::finish(alice, alice, seq1), escrow::condition(escrow::cb1), escrow::fulfillment(escrow::fb1), @@ -789,7 +789,7 @@ struct EscrowToken_test : public beast::unit_test::suite env.trust(USD(1), bob); env.close(); - // bob can finish even if bobs limit is too low + // bob can finish even if bob's limit is too low auto const bobPreLimit = env.limit(bob, USD); env(escrow::finish(bob, alice, seq1), @@ -799,7 +799,7 @@ struct EscrowToken_test : public beast::unit_test::suite ter(tesSUCCESS)); env.close(); - // bobs limit is not changed + // bob's limit is not changed BEAST_EXPECT(env.limit(bob, USD) == bobPreLimit); } } @@ -1606,7 +1606,7 @@ struct EscrowToken_test : public beast::unit_test::suite fee(baseFee * 150)); env.close(); auto const postBobLimit = env.limit(bob, USD); - // bobs limit is NOT changed + // bob's limit is NOT changed BEAST_EXPECT(postBobLimit == preBobLimit); } } @@ -1912,7 +1912,7 @@ struct EscrowToken_test : public beast::unit_test::suite } } void - testIOUINSF(FeatureBitset features) + testIOUInsufficientFunds(FeatureBitset features) { testcase("IOU Insufficient Funds"); using namespace test::jtx; @@ -3671,7 +3671,7 @@ struct EscrowToken_test : public beast::unit_test::suite testIOULimitAmount(features); testIOURequireAuth(features); testIOUFreeze(features); - testIOUINSF(features); + testIOUInsufficientFunds(features); testIOUPrecisionLoss(features); } diff --git a/src/test/app/FixNFTokenPageLinks_test.cpp b/src/test/app/FixNFTokenPageLinks_test.cpp index 8a3b51bbf1..88f368e9cf 100644 --- a/src/test/app/FixNFTokenPageLinks_test.cpp +++ b/src/test/app/FixNFTokenPageLinks_test.cpp @@ -442,7 +442,7 @@ class FixNFTokenPageLinks_test : public beast::unit_test::suite env(ledgerStateFix::nftPageLinks(daria, alice), fee(linkFixFee)); env.close(); - // alices's last page should now be present and include no links. + // alice's last page should now be present and include no links. { auto aliceLastNFTokenPage = env.le(keylet::nftpage_max(alice)); if (!BEAST_EXPECT(aliceLastNFTokenPage)) diff --git a/src/test/app/LPTokenTransfer_test.cpp b/src/test/app/LPTokenTransfer_test.cpp index f9cfc4d5ce..055b72ebe6 100644 --- a/src/test/app/LPTokenTransfer_test.cpp +++ b/src/test/app/LPTokenTransfer_test.cpp @@ -355,7 +355,7 @@ class LPTokenTransfer_test : public jtx::AMMTest env(token::acceptSellOffer(carol, sellOfferIndex)); env.close(); - // gateway freezes bobs's USD + // gateway freezes bob's USD env(trust(gw, bob["USD"](0), tfSetFreeze)); env.close(); diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index 139350a881..58052e3fb1 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -905,7 +905,7 @@ class LoanBroker_test : public beast::unit_test::suite if (asset.holds()) { - // preclaim: AllowTrustLineClaback is not set + // preclaim: AllowTrustLineClawback is not set env(coverClawback(issuer), loanBrokerID(brokerKeylet.key), amount(vaultInfo.asset(2)), diff --git a/src/test/app/Loan_test.cpp b/src/test/app/Loan_test.cpp index f02ceddb69..5deb1f179c 100644 --- a/src/test/app/Loan_test.cpp +++ b/src/test/app/Loan_test.cpp @@ -10,6 +10,7 @@ #include #include +// cspell: words LOANTODO #include diff --git a/src/test/app/MPToken_test.cpp b/src/test/app/MPToken_test.cpp index f8d736c257..965dd86475 100644 --- a/src/test/app/MPToken_test.cpp +++ b/src/test/app/MPToken_test.cpp @@ -670,7 +670,7 @@ class MPToken_test : public beast::unit_test::suite mptAlice.set({.account = alice, .holder = bob, .flags = tfMPTLock}); if (!features[featureSingleAssetVault]) { - // Delete bobs' mptoken even though it is locked + // Delete bob's mptoken even though it is locked mptAlice.authorize({.account = bob, .flags = tfMPTUnauthorize}); mptAlice.set({.account = alice, .holder = bob, .flags = tfMPTUnlock, .err = tecOBJECT_NOT_FOUND}); diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index 2ab2e2a94c..1b9ce82d4a 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -1383,28 +1383,28 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // Set flagOnlyXRP and offers using IOUs are rejected. { - uint256 const nftOnlyXRPID{token::getNextID(env, alice, 0u, tfOnlyXRP | tfTransferable)}; + uint256 const nftOnlyXrpID{token::getNextID(env, alice, 0u, tfOnlyXRP | tfTransferable)}; env(token::mint(alice, 0u), txflags(tfOnlyXRP | tfTransferable)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); - env(token::createOffer(alice, nftOnlyXRPID, gwAUD(50)), txflags(tfSellNFToken), ter(temBAD_AMOUNT)); + env(token::createOffer(alice, nftOnlyXrpID, gwAUD(50)), txflags(tfSellNFToken), ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 2); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::createOffer(buyer, nftOnlyXRPID, gwAUD(50)), token::owner(alice), ter(temBAD_AMOUNT)); + env(token::createOffer(buyer, nftOnlyXrpID, gwAUD(50)), token::owner(alice), ter(temBAD_AMOUNT)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 1); // However offers for XRP are okay. BEAST_EXPECT(ownerCount(env, alice) == 2); - env(token::createOffer(alice, nftOnlyXRPID, XRP(60)), txflags(tfSellNFToken)); + env(token::createOffer(alice, nftOnlyXrpID, XRP(60)), txflags(tfSellNFToken)); env.close(); BEAST_EXPECT(ownerCount(env, alice) == 3); BEAST_EXPECT(ownerCount(env, buyer) == 1); - env(token::createOffer(buyer, nftOnlyXRPID, XRP(60)), token::owner(alice)); + env(token::createOffer(buyer, nftOnlyXrpID, XRP(60)), token::owner(alice)); env.close(); BEAST_EXPECT(ownerCount(env, buyer) == 2); } @@ -5155,8 +5155,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // bob now has a buy offer and a sell offer on the books. A broker // spots this and swoops in to make a profit. BEAST_EXPECT(nftCount(env, bob) == 1); - auto const bobsPriorBalance = env.balance(bob); - auto const brokersPriorBalance = env.balance(broker); + auto const bobPriorBalance = env.balance(bob); + auto const brokerPriorBalance = env.balance(broker); env(token::brokerOffers(broker, bobBuyOfferIndex, bobSellOfferIndex), token::brokerFee(XRP(1)), ter(tecCANT_ACCEPT_OWN_NFTOKEN_OFFER)); @@ -5165,8 +5165,8 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // A tec result was returned, so no state should change other // than the broker burning their transaction fee. BEAST_EXPECT(nftCount(env, bob) == 1); - BEAST_EXPECT(env.balance(bob) == bobsPriorBalance); - BEAST_EXPECT(env.balance(broker) == brokersPriorBalance - baseFee); + BEAST_EXPECT(env.balance(bob) == bobPriorBalance); + BEAST_EXPECT(env.balance(broker) == brokerPriorBalance - baseFee); } void diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 09d7e41141..4847b7edb0 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -1878,14 +1878,14 @@ public: BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "49.96666666666667"); jrr = ledgerEntryState(env, bob, gw, "USD"); - Json::Value const bobsUSD = jrr[jss::node][sfBalance.fieldName][jss::value]; + Json::Value const bobUSD = jrr[jss::node][sfBalance.fieldName][jss::value]; if (!NumberSwitchOver) { - BEAST_EXPECT(bobsUSD == "-0.966500000033334"); + BEAST_EXPECT(bobUSD == "-0.966500000033334"); } else { - BEAST_EXPECT(bobsUSD == "-0.9665000000333333"); + BEAST_EXPECT(bobUSD == "-0.9665000000333333"); } } } @@ -2265,8 +2265,8 @@ public: // The scenario: // o alice has USD but wants XRP. // o bob has XRP but wants USD. - auto const alicesXRP = env.balance(alice); - auto const bobsXRP = env.balance(bob); + auto const aliceXRP = env.balance(alice); + auto const bobXRP = env.balance(bob); env(offer(alice, xrpOffer, usdOffer)); env.close(); @@ -2276,8 +2276,8 @@ public: env.require( balance(alice, USD(0)), balance(bob, usdOffer), - balance(alice, alicesXRP + xrpOffer - fee), - balance(bob, bobsXRP - xrpOffer - fee), + balance(alice, aliceXRP + xrpOffer - fee), + balance(bob, bobXRP - xrpOffer - fee), offers(alice, 0), offers(bob, 0)); @@ -2293,13 +2293,13 @@ public: env.require(offers(alice, 0)); verifyDefaultTrustline(env, bob, USD(1)); { - auto const bobsOffers = offersOnAccount(env, bob); - BEAST_EXPECT(bobsOffers.size() == 1); - auto const& bobsOffer = *(bobsOffers.front()); + auto const bobOffers = offersOnAccount(env, bob); + BEAST_EXPECT(bobOffers.size() == 1); + auto const& bobOffer = *(bobOffers.front()); - BEAST_EXPECT(bobsOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(bobsOffer[sfTakerGets] == USD(1)); - BEAST_EXPECT(bobsOffer[sfTakerPays] == XRP(1)); + BEAST_EXPECT(bobOffer[sfLedgerEntryType] == ltOFFER); + BEAST_EXPECT(bobOffer[sfTakerGets] == USD(1)); + BEAST_EXPECT(bobOffer[sfTakerPays] == XRP(1)); } } @@ -2375,13 +2375,13 @@ public: env.require(balance(bob, EUR(999))); { - auto bobsOffers = offersOnAccount(env, bob); - if (BEAST_EXPECT(bobsOffers.size() == 1)) + auto bobOffers = offersOnAccount(env, bob); + if (BEAST_EXPECT(bobOffers.size() == 1)) { - auto const& bobsOffer = *(bobsOffers.front()); + auto const& bobOffer = *(bobOffers.front()); - BEAST_EXPECT(bobsOffer[sfTakerGets] == USD(1)); - BEAST_EXPECT(bobsOffer[sfTakerPays] == EUR(1)); + BEAST_EXPECT(bobOffer[sfTakerGets] == USD(1)); + BEAST_EXPECT(bobOffer[sfTakerPays] == EUR(1)); } } @@ -2470,22 +2470,22 @@ public: verifyDefaultTrustline(env, bob, EUR(400)); verifyDefaultTrustline(env, carol, USD(400)); { - auto const alicesOffers = offersOnAccount(env, alice); - BEAST_EXPECT(alicesOffers.size() == 1); - auto const& alicesOffer = *(alicesOffers.front()); + auto const aliceOffers = offersOnAccount(env, alice); + BEAST_EXPECT(aliceOffers.size() == 1); + auto const& aliceOffer = *(aliceOffers.front()); - BEAST_EXPECT(alicesOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(alicesOffer[sfTakerGets] == USD(600)); - BEAST_EXPECT(alicesOffer[sfTakerPays] == XRP(600)); + BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); + BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(600)); + BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(600)); } { - auto const bobsOffers = offersOnAccount(env, bob); - BEAST_EXPECT(bobsOffers.size() == 1); - auto const& bobsOffer = *(bobsOffers.front()); + auto const bobOffers = offersOnAccount(env, bob); + BEAST_EXPECT(bobOffers.size() == 1); + auto const& bobOffer = *(bobOffers.front()); - BEAST_EXPECT(bobsOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(bobsOffer[sfTakerGets] == XRP(600)); - BEAST_EXPECT(bobsOffer[sfTakerPays] == EUR(600)); + BEAST_EXPECT(bobOffer[sfLedgerEntryType] == ltOFFER); + BEAST_EXPECT(bobOffer[sfTakerGets] == XRP(600)); + BEAST_EXPECT(bobOffer[sfTakerPays] == EUR(600)); } // carol makes an offer that exactly consumes alice and bob's offers. @@ -2503,15 +2503,15 @@ public: verifyDefaultTrustline(env, carol, USD(1000)); // In pre-flow code alice's offer is left empty in the ledger. - auto const alicesOffers = offersOnAccount(env, alice); - if (alicesOffers.size() != 0) + auto const aliceOffers = offersOnAccount(env, alice); + if (aliceOffers.size() != 0) { - BEAST_EXPECT(alicesOffers.size() == 1); - auto const& alicesOffer = *(alicesOffers.front()); + BEAST_EXPECT(aliceOffers.size() == 1); + auto const& aliceOffer = *(aliceOffers.front()); - BEAST_EXPECT(alicesOffer[sfLedgerEntryType] == ltOFFER); - BEAST_EXPECT(alicesOffer[sfTakerGets] == USD(0)); - BEAST_EXPECT(alicesOffer[sfTakerPays] == XRP(0)); + BEAST_EXPECT(aliceOffer[sfLedgerEntryType] == ltOFFER); + BEAST_EXPECT(aliceOffer[sfTakerGets] == USD(0)); + BEAST_EXPECT(aliceOffer[sfTakerPays] == XRP(0)); } } @@ -3679,16 +3679,16 @@ public: // Place alice's tiny offer in the book first. Let's see what happens // when a reasonable offer crosses it. - STAmount const alicesCnyOffer{ + STAmount const aliceCnyOffer{ CNY.issue(), std::uint64_t(4926000000000000), -23}; - env(offer(alice, alicesCnyOffer, drops(1), tfPassive)); + env(offer(alice, aliceCnyOffer, drops(1), tfPassive)); env.close(); // bob places an ordinary offer - STAmount const bobsCnyStartBalance{ + STAmount const bobCnyStartBalance{ CNY.issue(), std::uint64_t(3767479960090235), -15}; - env(pay(gw, bob, bobsCnyStartBalance)); + env(pay(gw, bob, bobCnyStartBalance)); env.close(); env(offer( @@ -3697,9 +3697,9 @@ public: STAmount{CNY.issue(), std::uint64_t(1000000000000000), -20})); env.close(); - env.require(balance(alice, alicesCnyOffer)); + env.require(balance(alice, aliceCnyOffer)); env.require(balance(alice, startXrpBalance - fee - drops(1))); - env.require(balance(bob, bobsCnyStartBalance - alicesCnyOffer)); + env.require(balance(bob, bobCnyStartBalance - aliceCnyOffer)); env.require(balance(bob, startXrpBalance - (fee * 2) + drops(1))); } diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 2f3b36eae5..9b534d9284 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -73,11 +73,11 @@ equal(std::unique_ptr const& s1, DirectStepInfo const& dsi) } bool -equal(std::unique_ptr const& s1, XRPEndpointStepInfo const& xrpsi) +equal(std::unique_ptr const& s1, XRPEndpointStepInfo const& xrpStepInfo) { if (!s1) return false; - return test::xrpEndpointStepEqual(*s1, xrpsi.acc); + return test::xrpEndpointStepEqual(*s1, xrpStepInfo.acc); } bool @@ -970,7 +970,7 @@ struct PayStrand_test : public beast::unit_test::suite Path const p = [&] { Path result; - result.push_back(allpe(gw, bob["USD"])); + result.push_back(allPathElements(gw, bob["USD"])); result.push_back(cpe(EUR.currency)); return result; }(); diff --git a/src/test/app/ReducedOffer_test.cpp b/src/test/app/ReducedOffer_test.cpp index aa1473d2ee..b967096eb8 100644 --- a/src/test/app/ReducedOffer_test.cpp +++ b/src/test/app/ReducedOffer_test.cpp @@ -79,8 +79,8 @@ public: STAmount const initialRate = Quality(newOffer).rate(); std::uint32_t const bobOfferSeq = env.seq(bob); STAmount const bobInitialBalance = env.balance(bob); - STAmount const bobsFee = env.current()->fees().base; - env(offer(bob, newOffer.in, newOffer.out, tfSell), fee(bobsFee)); + STAmount const bobFee = env.current()->fees().base; + env(offer(bob, newOffer.in, newOffer.out, tfSell), fee(bobFee)); env.close(); STAmount const bobFinalBalance = env.balance(bob); @@ -100,7 +100,7 @@ public: amountFromJson(sfTakerGets, bobOffer[jss::node][sfTakerGets.jsonName]); STAmount const reducedTakerPays = amountFromJson(sfTakerPays, bobOffer[jss::node][sfTakerPays.jsonName]); - STAmount const bobGot = env.balance(bob) + bobsFee - bobInitialBalance; + STAmount const bobGot = env.balance(bob) + bobFee - bobInitialBalance; BEAST_EXPECT(reducedTakerPays < newOffer.in); BEAST_EXPECT(reducedTakerGets < newOffer.out); STAmount const inLedgerRate = Quality(Amounts{reducedTakerPays, reducedTakerGets}).rate(); @@ -141,7 +141,7 @@ public: }; // bob's offer (the new offer) is the same every time: - Amounts const bobsOffer{STAmount(XRP(1)), STAmount(USD.issue(), 1, 0)}; + Amounts const bobOffer{STAmount(XRP(1)), STAmount(USD.issue(), 1, 0)}; // alice's offer has a slightly smaller TakerPays with each // iteration. This should mean that the size of the offer bob @@ -151,10 +151,10 @@ public: mantissaReduce += 20'000'000ull) { STAmount aliceUSD{ - bobsOffer.out.issue(), bobsOffer.out.mantissa() - mantissaReduce, bobsOffer.out.exponent()}; - STAmount aliceXRP{bobsOffer.in.issue(), bobsOffer.in.mantissa() - 1}; - Amounts alicesOffer{aliceUSD, aliceXRP}; - blockedCount += exerciseOfferPair(alicesOffer, bobsOffer); + bobOffer.out.issue(), bobOffer.out.mantissa() - mantissaReduce, bobOffer.out.exponent()}; + STAmount aliceXRP{bobOffer.in.issue(), bobOffer.in.mantissa() - 1}; + Amounts aliceOffer{aliceUSD, aliceXRP}; + blockedCount += exerciseOfferPair(aliceOffer, bobOffer); } // None of the test cases should produce a potentially blocking @@ -279,9 +279,9 @@ public: STAmount bobUSD{ aliceOffer.out.issue(), aliceOffer.out.mantissa() - mantissaReduce, aliceOffer.out.exponent()}; STAmount bobXRP{aliceOffer.in.issue(), aliceOffer.in.mantissa() - 1}; - Amounts bobsOffer{bobUSD, bobXRP}; + Amounts bobOffer{bobUSD, bobXRP}; - blockedCount += exerciseOfferPair(aliceOffer, bobsOffer); + blockedCount += exerciseOfferPair(aliceOffer, bobOffer); } // None of the test cases should produce a potentially blocking @@ -333,7 +333,7 @@ public: // then we use that as evidence that bob's offer blocked the // order book. { - bool const bobsOfferGone = !offerInLedger(env, bob, bobOfferSeq); + bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq); STAmount const aliceBalanceUSD = env.balance(alice, USD); // Sanity check the ledger if alice got USD. @@ -341,11 +341,11 @@ public: { BEAST_EXPECT(aliceBalanceUSD == initialBobUSD); BEAST_EXPECT(env.balance(bob, USD) == USD(0)); - BEAST_EXPECT(bobsOfferGone); + BEAST_EXPECT(bobOfferGone); } // Track occurrences of order book blocking. - if (!bobsOfferGone && aliceBalanceUSD.signum() == 0) + if (!bobOfferGone && aliceBalanceUSD.signum() == 0) { ++blockedOrderBookCount; } @@ -423,13 +423,13 @@ public: // Examine the aftermath of alice's offer. { - bool const bobsOfferGone = !offerInLedger(env, bob, bobOfferSeq); + bool const bobOfferGone = !offerInLedger(env, bob, bobOfferSeq); STAmount aliceBalanceUSD = env.balance(alice, USD); #if 0 std::cout - << "bobs initial: " << initialBobUSD + << "bob initial: " << initialBobUSD << "; alice final: " << aliceBalanceUSD - << "; bobs offer: " << bobsOfferJson.toStyledString() + << "; bob offer: " << bobOfferJson.toStyledString() << std::endl; #endif // Sanity check the ledger if alice got USD. @@ -437,11 +437,11 @@ public: { BEAST_EXPECT(aliceBalanceUSD == initialBobUSD); BEAST_EXPECT(env.balance(bob, USD) == USD(0)); - BEAST_EXPECT(bobsOfferGone); + BEAST_EXPECT(bobOfferGone); } // Track occurrences of order book blocking. - if (!bobsOfferGone && aliceBalanceUSD.signum() == 0) + if (!bobOfferGone && aliceBalanceUSD.signum() == 0) { ++blockedOrderBookCount; } diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 7951da26d1..c671d6fc27 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -44,10 +44,10 @@ class SHAMapStore_test : public beast::unit_test::suite auto const seq = json[jss::result][jss::ledger_index].asUInt(); - std::optional oinfo = env.app().getRelationalDatabase().getLedgerInfoByIndex(seq); - if (!oinfo) + std::optional outInfo = env.app().getRelationalDatabase().getLedgerInfoByIndex(seq); + if (!outInfo) return false; - LedgerHeader const& info = oinfo.value(); + LedgerHeader const& info = outInfo.value(); std::string const outHash = to_string(info.hash); LedgerIndex const outSeq = info.seq; diff --git a/src/test/app/TrustAndBalance_test.cpp b/src/test/app/TrustAndBalance_test.cpp index b695430c7f..aa06ccbdf1 100644 --- a/src/test/app/TrustAndBalance_test.cpp +++ b/src/test/app/TrustAndBalance_test.cpp @@ -383,20 +383,20 @@ class TrustAndBalance_test : public beast::unit_test::suite jvs[jss::streams].append("transactions"); BEAST_EXPECT(wsc->invoke("subscribe", jvs)[jss::status] == "success"); - char const* invoiceid = "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89"; + char const* invoiceId = "243F6A8885A308D313198A2E03707344A4093822299F31D0082EFA98EC4E6C89"; Json::Value jv; - auto tx = env.jt(pay(env.master, alice, XRP(10000)), json(sfInvoiceID.fieldName, invoiceid)); + auto tx = env.jt(pay(env.master, alice, XRP(10000)), json(sfInvoiceID.fieldName, invoiceId)); jv[jss::tx_blob] = strHex(tx.stx->getSerializer().slice()); auto jrr = wsc->invoke("submit", jv)[jss::result]; BEAST_EXPECT(jrr[jss::status] == "success"); - BEAST_EXPECT(jrr[jss::tx_json][sfInvoiceID.fieldName] == invoiceid); + BEAST_EXPECT(jrr[jss::tx_json][sfInvoiceID.fieldName] == invoiceId); env.close(); using namespace std::chrono_literals; - BEAST_EXPECT(wsc->findMsg(2s, [invoiceid](auto const& jval) { + BEAST_EXPECT(wsc->findMsg(2s, [invoiceId](auto const& jval) { auto const& t = jval[jss::transaction]; - return t[jss::TransactionType] == jss::Payment && t[sfInvoiceID.fieldName] == invoiceid; + return t[jss::TransactionType] == jss::Payment && t[sfInvoiceID.fieldName] == invoiceId; })); BEAST_EXPECT(wsc->invoke("unsubscribe", jv)[jss::status] == "success"); diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index e39f665711..5d31c674c0 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -4578,7 +4578,7 @@ class Vault_test : public beast::unit_test::suite { testcase("VaultClawback (asset) - " + prefix + " issuer XRP clawback fails"); auto [vault, vaultKeylet] = setupVault(asset, owner, depositor, issuer); - // If the asset is XRP, clawback with amount fails as malfored + // If the asset is XRP, clawback with amount fails as malformed // when asset is specified. env(vault.clawback({ .issuer = issuer, diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index e074e03d97..2921e10ae4 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -2149,7 +2149,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj } void - testXChainAddAccountCreateNonBatchAttestation() + testXChainAddAccountCreateNonBatchAttestation() // cspell: disable-line { using namespace jtx; @@ -3417,7 +3417,7 @@ struct XChain_test : public beast::unit_test::suite, public jtx::XChainBridgeObj testXChainCommit(); testXChainAddAttestation(); testXChainAddClaimNonBatchAttestation(); - testXChainAddAccountCreateNonBatchAttestation(); + testXChainAddAccountCreateNonBatchAttestation(); // cspell: disable-line testXChainClaim(); testXChainCreateAccount(); testFeeDipsIntoReserve(); @@ -3535,6 +3535,7 @@ private: do { callback_called = false; + // cspell: ignore attns for (size_t i = 0; i < signers_attns.size(); ++i) { for (auto& [bridge, claims] : signers_attns[i]) diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index 1035be6fc0..d5f3bb556c 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -634,8 +634,8 @@ nHBu9PTL9dn2GuZtdW4U2WzBwffyX9qsQCd9CNU4Z5YG3PQfViM8 Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 @@ -645,8 +645,8 @@ trustthesevalidators.gov )xrpldConfig"); c.loadFromString(toLoad); BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[0] == "xrplvalidators.com"); - BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[1] == "trustthesevalidators.gov"); + BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); + BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[1] == "trust-these-validators.gov"); BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 1); BEAST_EXPECT( c.section(SECTION_VALIDATOR_LIST_KEYS).values()[0] == @@ -661,8 +661,8 @@ trustthesevalidators.gov Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 @@ -672,8 +672,8 @@ trustthesevalidators.gov )xrpldConfig"); c.loadFromString(toLoad); BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values().size() == 2); - BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[0] == "xrplvalidators.com"); - BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[1] == "trustthesevalidators.gov"); + BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[0] == "xrpl-validators.com"); + BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_SITES).values()[1] == "trust-these-validators.gov"); BEAST_EXPECT(c.section(SECTION_VALIDATOR_LIST_KEYS).values().size() == 1); BEAST_EXPECT( c.section(SECTION_VALIDATOR_LIST_KEYS).values()[0] == @@ -689,8 +689,8 @@ trustthesevalidators.gov Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 @@ -718,8 +718,8 @@ trustthesevalidators.gov Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 @@ -747,8 +747,8 @@ value = 2 Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 @@ -774,8 +774,8 @@ trustthesevalidators.gov Config c; std::string toLoad(R"xrpldConfig( [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov )xrpldConfig"); std::string error; auto const expectedError = "[validator_list_keys] config section is missing"; @@ -887,8 +887,8 @@ nHB1X37qrniVugfQcuBTAjswphC1drx7QjFFojJPZwKHHnt8kU7v nHUkAWDR4cB8AgPg7VXMX6et8xRTQb2KJfgv1aBEXozwrawRKgMB [validator_list_sites] -xrplvalidators.com -trustthesevalidators.gov +xrpl-validators.com +trust-these-validators.gov [validator_list_keys] 021A99A537FDEBC34E4FCA03B39BEADD04299BB19E85097EC92B15A3518801E566 diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index aea9edeb93..c0e54900f6 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -535,7 +535,7 @@ cpe(Currency const& c); // All path element STPathElement -allpe(AccountID const& a, Issue const& iss); +allPathElements(AccountID const& a, Issue const& iss); /***************************************************************/ /* Check */ diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 4d27ddf740..f920858ea5 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -253,12 +253,12 @@ AMM::expectAmmRpcInfo( } bool -AMM::expectAmmInfo(STAmount const& asset1, STAmount const& asset2, IOUAmount const& balance, Json::Value const& jvres) +AMM::expectAmmInfo(STAmount const& asset1, STAmount const& asset2, IOUAmount const& balance, Json::Value const& jvRes) const { - if (!jvres.isMember(jss::amm)) + if (!jvRes.isMember(jss::amm)) return false; - auto const& jv = jvres[jss::amm]; + auto const& jv = jvRes[jss::amm]; if (!jv.isMember(jss::amount) || !jv.isMember(jss::amount2) || !jv.isMember(jss::lp_token)) return false; STAmount asset1Info; @@ -360,26 +360,26 @@ AMM::deposit( maxEP->setJson(jv[jss::EPrice]); if (tfee) jv[jss::TradingFee] = *tfee; - std::uint32_t jvflags = 0; + std::uint32_t jvFlags = 0; if (flags) - jvflags = *flags; + jvFlags = *flags; // If including asset1In and asset2In or tokens as // deposit min amounts then must set the flags // explicitly instead of relying on this logic. - if (!(jvflags & tfDepositSubTx)) + if (!(jvFlags & tfDepositSubTx)) { if (tokens && !asset1In) - jvflags |= tfLPToken; + jvFlags |= tfLPToken; else if (tokens && asset1In) - jvflags |= tfOneAssetLPToken; + jvFlags |= tfOneAssetLPToken; else if (asset1In && asset2In) - jvflags |= tfTwoAsset; + jvFlags |= tfTwoAsset; else if (maxEP && asset1In) - jvflags |= tfLimitLPToken; + jvFlags |= tfLimitLPToken; else if (asset1In) - jvflags |= tfSingleAsset; + jvFlags |= tfSingleAsset; } - jv[jss::Flags] = jvflags; + jv[jss::Flags] = jvFlags; return deposit(account, jv, assets, seq, ter); } @@ -465,23 +465,23 @@ AMM::withdraw( STAmount const saMaxEP{*maxEP, lptIssue_}; saMaxEP.setJson(jv[jss::EPrice]); } - std::uint32_t jvflags = 0; + std::uint32_t jvFlags = 0; if (flags) - jvflags = *flags; - if (!(jvflags & tfWithdrawSubTx)) + jvFlags = *flags; + if (!(jvFlags & tfWithdrawSubTx)) { if (tokens && !asset1Out) - jvflags |= tfLPToken; + jvFlags |= tfLPToken; else if (asset1Out && asset2Out) - jvflags |= tfTwoAsset; + jvFlags |= tfTwoAsset; else if (tokens && asset1Out) - jvflags |= tfOneAssetLPToken; + jvFlags |= tfOneAssetLPToken; else if (asset1Out && maxEP) - jvflags |= tfLimitLPToken; + jvFlags |= tfLimitLPToken; else if (asset1Out) - jvflags |= tfSingleAsset; + jvFlags |= tfSingleAsset; } - jv[jss::Flags] = jvflags; + jv[jss::Flags] = jvFlags; return withdraw(account, jv, seq, assets, ter); } diff --git a/src/test/jtx/impl/TestHelpers.cpp b/src/test/jtx/impl/TestHelpers.cpp index 7155c8fd0a..d89dec456b 100644 --- a/src/test/jtx/impl/TestHelpers.cpp +++ b/src/test/jtx/impl/TestHelpers.cpp @@ -304,7 +304,7 @@ cpe(Currency const& c) // All path element STPathElement -allpe(AccountID const& a, Issue const& iss) +allPathElements(AccountID const& a, Issue const& iss) { return STPathElement( STPathElement::typeAccount | STPathElement::typeCurrency | STPathElement::typeIssuer, diff --git a/src/test/jtx/impl/mpt.cpp b/src/test/jtx/impl/mpt.cpp index 90378fae90..f505bff740 100644 --- a/src/test/jtx/impl/mpt.cpp +++ b/src/test/jtx/impl/mpt.cpp @@ -99,10 +99,10 @@ MPTTester::operator MPT() const } Json::Value -MPTTester::createjv(MPTCreate const& arg) +MPTTester::createJV(MPTCreate const& arg) { if (!arg.issuer) - Throw("MPTTester::createjv: issuer is not set"); + Throw("MPTTester::createJV: issuer is not set"); Json::Value jv; jv[sfAccount] = arg.issuer->human(); if (arg.assetScale) @@ -128,7 +128,7 @@ MPTTester::create(MPTCreate const& arg) if (id_) Throw("MPT can't be reused"); id_ = makeMptID(env_.seq(issuer_), issuer_); - Json::Value jv = createjv( + Json::Value jv = createJV( {.issuer = issuer_, .maxAmt = arg.maxAmt, .assetScale = arg.assetScale, @@ -179,11 +179,11 @@ MPTTester::create(MPTCreate const& arg) } Json::Value -MPTTester::destroyjv(MPTDestroy const& arg) +MPTTester::destroyJV(MPTDestroy const& arg) { Json::Value jv; if (!arg.issuer || !arg.id) - Throw("MPTTester::destroyjv: issuer/id is not set"); + Throw("MPTTester::destroyJV: issuer/id is not set"); jv[sfAccount] = arg.issuer->human(); jv[sfMPTokenIssuanceID] = to_string(*arg.id); jv[sfTransactionType] = jss::MPTokenIssuanceDestroy; @@ -196,7 +196,7 @@ MPTTester::destroy(MPTDestroy const& arg) { if (!arg.id && !id_) Throw("MPT has not been created"); - Json::Value jv = destroyjv({.issuer = arg.issuer ? arg.issuer : issuer_, .id = arg.id ? arg.id : id_}); + Json::Value jv = destroyJV({.issuer = arg.issuer ? arg.issuer : issuer_, .id = arg.id ? arg.id : id_}); submit(arg, jv); } @@ -210,11 +210,11 @@ MPTTester::holder(std::string const& holder_) const } Json::Value -MPTTester::authorizejv(MPTAuthorize const& arg) +MPTTester::authorizeJV(MPTAuthorize const& arg) { Json::Value jv; if (!arg.account || !arg.id) - Throw("MPTTester::authorizejv: issuer/id is not set"); + Throw("MPTTester::authorizeJV: account/id is not set"); jv[sfAccount] = arg.account->human(); jv[sfMPTokenIssuanceID] = to_string(*arg.id); if (arg.holder) @@ -229,7 +229,7 @@ MPTTester::authorize(MPTAuthorize const& arg) { if (!arg.id && !id_) Throw("MPT has not been created"); - Json::Value jv = authorizejv({ + Json::Value jv = authorizeJV({ .account = arg.account ? arg.account : issuer_, .holder = arg.holder, .id = arg.id ? arg.id : id_, @@ -289,11 +289,11 @@ MPTTester::authorizeHolders(Holders const& holders) } Json::Value -MPTTester::setjv(MPTSet const& arg) +MPTTester::setJV(MPTSet const& arg) { Json::Value jv; if (!arg.account || !arg.id) - Throw("MPTTester::setjv: issuer/id is not set"); + Throw("MPTTester::setJV: account and/or id is not set"); jv[sfAccount] = arg.account->human(); jv[sfMPTokenIssuanceID] = to_string(*arg.id); if (arg.holder) @@ -328,7 +328,7 @@ MPTTester::set(MPTSet const& arg) { if (!arg.id && !id_) Throw("MPT has not been created"); - Json::Value jv = setjv( + Json::Value jv = setJV( {.account = arg.account ? arg.account : issuer_, .holder = arg.holder, .id = arg.id ? arg.id : id_, @@ -476,7 +476,7 @@ MPTTester::pay( Throw("MPT has not been created"); auto const srcAmt = getBalance(src); auto const destAmt = getBalance(dest); - auto const outstnAmt = getBalance(issuer_); + auto const outstandingAmt = getBalance(issuer_); if (credentials) env_(jtx::pay(src, dest, mpt(amount)), ter(err.value_or(tesSUCCESS)), credentials::ids(*credentials)); @@ -505,7 +505,7 @@ MPTTester::pay( env_.require(mptbalance(*this, src, srcAmt - actual)); env_.require(mptbalance(*this, dest, destAmt + amount)); // Outstanding amount is reduced by the transfer fee if any - env_.require(mptbalance(*this, issuer_, outstnAmt - (actual - amount))); + env_.require(mptbalance(*this, issuer_, outstandingAmt - (actual - amount))); } } diff --git a/src/test/jtx/mpt.h b/src/test/jtx/mpt.h index 792d43056f..510248240d 100644 --- a/src/test/jtx/mpt.h +++ b/src/test/jtx/mpt.h @@ -177,19 +177,19 @@ public: create(MPTCreate const& arg = MPTCreate{}); static Json::Value - createjv(MPTCreate const& arg = MPTCreate{}); + createJV(MPTCreate const& arg = MPTCreate{}); void destroy(MPTDestroy const& arg = MPTDestroy{}); static Json::Value - destroyjv(MPTDestroy const& arg = MPTDestroy{}); + destroyJV(MPTDestroy const& arg = MPTDestroy{}); void authorize(MPTAuthorize const& arg = MPTAuthorize{}); static Json::Value - authorizejv(MPTAuthorize const& arg = MPTAuthorize{}); + authorizeJV(MPTAuthorize const& arg = MPTAuthorize{}); void authorizeHolders(Holders const& holders); @@ -198,7 +198,7 @@ public: set(MPTSet const& set = {}); static Json::Value - setjv(MPTSet const& set = {}); + setJV(MPTSet const& set = {}); [[nodiscard]] bool checkDomainID(std::optional expected) const; diff --git a/src/test/ledger/Directory_test.cpp b/src/test/ledger/Directory_test.cpp index 16d319671c..0774390490 100644 --- a/src/test/ledger/Directory_test.cpp +++ b/src/test/ledger/Directory_test.cpp @@ -164,7 +164,7 @@ struct Directory_test : public beast::unit_test::suite return c; }(); - // First, Alices creates a lot of trustlines, and then + // First, Alice creates a lot of trustlines, and then // deletes them in a different order: { auto cl = currencies; diff --git a/src/test/ledger/View_test.cpp b/src/test/ledger/View_test.cpp index b2cc8d7057..33813e135e 100644 --- a/src/test/ledger/View_test.cpp +++ b/src/test/ledger/View_test.cpp @@ -982,8 +982,8 @@ class GetAmendments_test : public beast::unit_test::suite BEAST_EXPECT(majorities.size() >= 2); // None of the amendments should be enabled yet. - auto enableds = getEnabledAmendments(*env.closed()); - BEAST_EXPECT(enableds.empty()); + auto enabledAmendments = getEnabledAmendments(*env.closed()); + BEAST_EXPECT(enabledAmendments.empty()); // Now wait 2 weeks modulo 256 ledgers for the amendments to be // enabled. Speed the process by closing ledgers every 80 minutes, @@ -992,12 +992,12 @@ class GetAmendments_test : public beast::unit_test::suite { using namespace std::chrono_literals; env.close(80min); - enableds = getEnabledAmendments(*env.closed()); - if (!enableds.empty()) + enabledAmendments = getEnabledAmendments(*env.closed()); + if (!enabledAmendments.empty()) break; } BEAST_EXPECT(i == 255); - BEAST_EXPECT(enableds.size() >= 2); + BEAST_EXPECT(enabledAmendments.size() >= 2); } void diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index 6dffe4e5c9..19876809d2 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -172,12 +172,12 @@ public: std::string usdTxBlob = ""; auto wsc = makeWSClient(env.app().config()); { - Json::Value jrequestUsd; - jrequestUsd[jss::secret] = toBase58(generateSeed("bob")); - jrequestUsd[jss::tx_json] = pay("bob", "alice", bob["USD"](fund / 2)); - Json::Value jreply_usd = wsc->invoke("sign", jrequestUsd); + Json::Value requestUSD; + requestUSD[jss::secret] = toBase58(generateSeed("bob")); + requestUSD[jss::tx_json] = pay("bob", "alice", bob["USD"](fund / 2)); + Json::Value replyUSD = wsc->invoke("sign", requestUSD); - usdTxBlob = toBinary(jreply_usd[jss::result][jss::tx_blob].asString()); + usdTxBlob = toBinary(replyUSD[jss::result][jss::tx_blob].asString()); } auto transaction = std::make_shared(); diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index 10e159dd8d..98bcc7b1bc 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -441,9 +441,9 @@ public: STAmount smallValue(noIssue(), (STAmount::cMinValue + STAmount::cMaxValue) / 2, STAmount::cMinOffset + 1); STAmount zeroSt(noIssue(), 0); - STAmount smallXsmall = multiply(smallValue, smallValue, noIssue()); + STAmount smallXSmall = multiply(smallValue, smallValue, noIssue()); - BEAST_EXPECT(smallXsmall == beast::zero); + BEAST_EXPECT(smallXSmall == beast::zero); STAmount bigDsmall = divide(smallValue, bigValue, noIssue()); diff --git a/src/test/rpc/AccountLines_test.cpp b/src/test/rpc/AccountLines_test.cpp index 337da27ea0..1f5f190cfa 100644 --- a/src/test/rpc/AccountLines_test.cpp +++ b/src/test/rpc/AccountLines_test.cpp @@ -380,7 +380,7 @@ public: BEAST_EXPECT(aliceLines2[jss::result][jss::lines].size() == 1); BEAST_EXPECT(!aliceLines2[jss::result].isMember(jss::marker)); - // Get account lines for beckys account, using alices SignerList as a + // Get account lines for becky's account, using alice's SignerList as a // marker. This should cause an error. Json::Value beckyLinesParams; beckyLinesParams[jss::account] = becky.human(); diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index e9c877b421..0dec2bde7f 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -17,7 +17,7 @@ namespace xrpl { namespace test { -static char const* bobs_account_objects[] = { +static char const* bob_account_objects[] = { R"json({ "Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK", "BookDirectory" : "50AD0A9E54D2B381288D535EB724E4275FFBF41580D28A925D038D7EA4C68000", @@ -254,7 +254,7 @@ public: Json::Value bobj[4]; for (int i = 0; i < 4; ++i) - Json::Reader{}.parse(bobs_account_objects[i], bobj[i]); + Json::Reader{}.parse(bob_account_objects[i], bobj[i]); // test 'unstepped' // i.e. request account objects without explicit limit/marker paging diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 189949d92c..7aeb059f56 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -8,6 +8,7 @@ #include #include #include +// cspell: words stdev namespace xrpl::test { diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index a7ae547272..aa959629b1 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -501,7 +501,7 @@ class LedgerEntry_test : public beast::unit_test::suite accountRootIndex = jrr[jss::index].asString(); } { - constexpr char alicesAcctRootBinary[]{ + constexpr char aliceAcctRootBinary[]{ "1100612200800000240000000425000000032D00000000559CE54C3B934E4" "73A995B477E92EC229F99CED5B62BF4D2ACE4DC42719103AE2F6240000002" "540BE4008114AE123A8556F3CF91154711376AFB0F894F832B3D"}; @@ -513,7 +513,7 @@ class LedgerEntry_test : public beast::unit_test::suite jvParams[jss::ledger_hash] = ledgerHash; Json::Value const jrr = env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; BEAST_EXPECT(jrr.isMember(jss::node_binary)); - BEAST_EXPECT(jrr[jss::node_binary] == alicesAcctRootBinary); + BEAST_EXPECT(jrr[jss::node_binary] == aliceAcctRootBinary); } { // Request alice's account root using the index. diff --git a/src/test/rpc/NoRipple_test.cpp b/src/test/rpc/NoRipple_test.cpp index 07b0c95e92..9cfc69ccd5 100644 --- a/src/test/rpc/NoRipple_test.cpp +++ b/src/test/rpc/NoRipple_test.cpp @@ -38,8 +38,8 @@ public: // Check no-ripple flag on sender 'gateway' Json::Value lines{env.rpc("json", "account_lines", to_string(account_gw))}; - auto const& gline0 = lines[jss::result][jss::lines][0u]; - BEAST_EXPECT(gline0[jss::no_ripple].asBool() == SetOrClear); + auto const& gwLine0 = lines[jss::result][jss::lines][0u]; + BEAST_EXPECT(gwLine0[jss::no_ripple].asBool() == SetOrClear); // Check no-ripple peer flag on destination 'alice' lines = env.rpc("json", "account_lines", to_string(account_alice)); diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index 0e212afb21..3b289d73ca 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -512,7 +512,7 @@ class Transaction_test : public beast::unit_test::suite } void - testCTIDRPC(FeatureBitset features) + testRPCsForCTID(FeatureBitset features) { testcase("CTID RPC"); @@ -804,7 +804,7 @@ public: testRangeRequest(features); testRangeCTIDRequest(features); testCTIDValidation(features); - testCTIDRPC(features); + testRPCsForCTID(features); forAllApiVersions(std::bind_front(&Transaction_test::testRequest, this, features)); } }; From db2734cbc96329f64c23ea68fadc2fc898696510 Mon Sep 17 00:00:00 2001 From: Valentin Balaschenko <13349202+vlntb@users.noreply.github.com> Date: Fri, 6 Feb 2026 21:33:42 +0000 Subject: [PATCH 06/16] refactor: Change main thread name to `xrpld-main` (#6336) This change builds on the thread-renaming PR (#6212), by renaming the main thread name to reduce ambiguity in performance monitoring tools. --- src/xrpld/app/main/Main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index 031daeb5e9..aaf7af95ab 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -323,7 +323,7 @@ run(int argc, char** argv) { using namespace std; - beast::setCurrentThreadName("main"); + beast::setCurrentThreadName("xrpld-main"); po::variables_map vm; From e11f6190b74599737f9f554da3b141f269e43803 Mon Sep 17 00:00:00 2001 From: Olek <115580134+oleks-rip@users.noreply.github.com> Date: Tue, 10 Feb 2026 14:02:53 -0500 Subject: [PATCH 07/16] fix: Update invariant checks for Permissioned Domains (#6134) --- include/xrpl/protocol/detail/features.macro | 2 +- src/test/app/Invariants_test.cpp | 636 ++++++++++++++------ src/test/app/PermissionedDomains_test.cpp | 32 +- src/test/jtx/impl/balance.cpp | 24 +- src/xrpld/app/tx/detail/InvariantCheck.cpp | 102 +++- src/xrpld/app/tx/detail/InvariantCheck.h | 6 +- 6 files changed, 555 insertions(+), 247 deletions(-) diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro index d8498ffa2f..961bc6e44c 100644 --- a/include/xrpl/protocol/detail/features.macro +++ b/include/xrpl/protocol/detail/features.macro @@ -15,7 +15,7 @@ // Add new amendments to the top of this list. // Keep it sorted in reverse chronological order. - +XRPL_FIX (PermissionedDomainInvariant, Supported::yes, VoteBehavior::DefaultNo) XRPL_FIX (ExpiredNFTokenOfferRemoval, Supported::yes, VoteBehavior::DefaultNo) XRPL_FIX (BatchInnerSigs, Supported::yes, VoteBehavior::DefaultNo) XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo) diff --git a/src/test/app/Invariants_test.cpp b/src/test/app/Invariants_test.cpp index b3fa027753..7558c951b0 100644 --- a/src/test/app/Invariants_test.cpp +++ b/src/test/app/Invariants_test.cpp @@ -36,6 +36,12 @@ class Invariants_test : public beast::unit_test::suite // changes that will cause the check to fail. using Precheck = std::function; + static FeatureBitset + defaultAmendments() + { + return xrpl::test::jtx::testable_amendments() | featureInvariantsV1_1 | featureSingleAssetVault; + } + /** Run a specific test case to put the ledger into a state that will be * detected by an invariant. Simulates the actions of a transaction that * would violate an invariant. @@ -62,10 +68,23 @@ class Invariants_test : public beast::unit_test::suite std::initializer_list ters = {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, Preclose const& preclose = {}, TxAccount setTxAccount = TxAccount::None) + { + return doInvariantCheck( + test::jtx::Env(*this, defaultAmendments()), expect_logs, precheck, fee, tx, ters, preclose, setTxAccount); + } + + void + doInvariantCheck( + test::jtx::Env&& env, + std::vector const& expect_logs, + Precheck const& precheck, + XRPAmount fee = XRPAmount{}, + STTx tx = STTx{ttACCOUNT_SET, [](STObject&) {}}, + std::initializer_list ters = {tecINVARIANT_FAILED, tefINVARIANT_FAILED}, + Preclose const& preclose = {}, + TxAccount setTxAccount = TxAccount::None) { using namespace test::jtx; - FeatureBitset amendments = testable_amendments() | featureInvariantsV1_1 | featureSingleAssetVault; - Env env{*this, amendments}; Account const A1{"A1"}; Account const A2{"A2"}; @@ -74,11 +93,28 @@ class Invariants_test : public beast::unit_test::suite BEAST_EXPECT(preclose(A1, A2, env)); env.close(); + if (setTxAccount != TxAccount::None) + tx.setAccountID(sfAccount, setTxAccount == TxAccount::A1 ? A1.id() : A2.id()); + + return doInvariantCheck(std::move(env), A1, A2, expect_logs, precheck, fee, tx, ters); + } + + void + doInvariantCheck( + test::jtx::Env&& env, + test::jtx::Account const& A1, + test::jtx::Account const& A2, + std::vector const& expect_logs, + Precheck const& precheck, + XRPAmount fee = XRPAmount{}, + STTx tx = STTx{ttACCOUNT_SET, [](STObject&) {}}, + std::initializer_list ters = {tecINVARIANT_FAILED, tefINVARIANT_FAILED}) + { + using namespace test::jtx; + OpenView ov{*env.current()}; test::StreamSink sink{beast::severities::kWarning}; beast::Journal jlog{sink}; - if (setTxAccount != TxAccount::None) - tx.setAccountID(sfAccount, setTxAccount == TxAccount::A1 ? A1.id() : A2.id()); ApplyContext ac{env.app(), ov, tx, tesSUCCESS, env.current()->fees().base, tapNONE, jlog}; BEAST_EXPECT(precheck(A1, A2, ac)); @@ -91,19 +127,21 @@ class Invariants_test : public beast::unit_test::suite for (TER const& terExpect : ters) { terActual = ac.checkInvariants(terActual, fee); - BEAST_EXPECT(terExpect == terActual); + BEAST_EXPECTS(terExpect == terActual, std::to_string(TERtoInt(terActual))); auto const messages = sink.messages().str(); - BEAST_EXPECT( - messages.starts_with("Invariant failed:") || messages.starts_with("Transaction caused an exception")); + + if (terActual != tesSUCCESS) + { + BEAST_EXPECTS( + messages.starts_with("Invariant failed:") || + messages.starts_with("Transaction caused an exception"), + messages); + } + // std::cerr << messages << '\n'; for (auto const& m : expect_logs) { - if (messages.find(m) == std::string::npos) - { - // uncomment if you want to log the invariant failure - // std::cerr << " --> " << m << std::endl; - fail(); - } + BEAST_EXPECTS(messages.find(m) != std::string::npos, m); } } } @@ -1119,86 +1157,80 @@ class Invariants_test : public beast::unit_test::suite }); } - void + static std::shared_ptr createPermissionedDomain( ApplyContext& ac, - std::shared_ptr& sle, test::jtx::Account const& A1, - test::jtx::Account const& A2) + test::jtx::Account const& A2, + std::uint32_t numCreds = 2, + std::uint32_t seq = 10) { - sle->setAccountID(sfOwner, A1); - sle->setFieldU32(sfSequence, 10); + Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), seq); + auto sle = std::make_shared(pdKeylet); - STArray credentials(sfAcceptedCredentials, 2); - for (std::size_t n = 0; n < 2; ++n) + sle->setAccountID(sfOwner, A1); + sle->setFieldU32(sfSequence, seq); + + if (numCreds) { - auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); - auto credType = "cred_type" + std::to_string(n); - cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); + // This array is sorted naturally, but if you willing to change this + // behavior don't forget to use credentials::makeSorted + STArray credentials(sfAcceptedCredentials, numCreds); + for (std::size_t n = 0; n < numCreds; ++n) + { + auto cred = STObject::makeInnerObject(sfCredential); + cred.setAccountID(sfIssuer, A2); + auto credType = "cred_type" + std::to_string(n); + cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); + credentials.push_back(std::move(cred)); + } + sle->setFieldArray(sfAcceptedCredentials, credentials); } - sle->setFieldArray(sfAcceptedCredentials, credentials); + ac.view().insert(sle); + return sle; }; void - testPermissionedDomainInvariants() + testPermissionedDomainInvariants(FeatureBitset features) { using namespace test::jtx; - testcase << "PermissionedDomain"; - doInvariantCheck( - {{"permissioned domain with no rules."}}, - [](Account const& A1, Account const&, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - slePd->setAccountID(sfOwner, A1); - slePd->setFieldU32(sfSequence, 10); + bool const fixPDEnabled = features[fixPermissionedDomainInvariant]; + std::initializer_list badTers = {tecINVARIANT_FAILED, tecINVARIANT_FAILED}; + std::initializer_list failTers = {tecINVARIANT_FAILED, tefINVARIANT_FAILED}; - ac.view().insert(slePd); - return true; + testcase << "PermissionedDomain" + std::string(fixPDEnabled ? " fix" : ""); + + doInvariantCheck( + Env(*this, features), + {{"permissioned domain with no rules."}}, + [](Account const& A1, Account const& A2, ApplyContext& ac) { + return createPermissionedDomain(ac, A1, A2, 0).get(); }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain 2"; auto constexpr tooBig = maxPermissionedDomainCredentialsArraySize + 1; doInvariantCheck( + Env(*this, features), {{"permissioned domain bad credentials size " + std::to_string(tooBig)}}, [](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - slePd->setAccountID(sfOwner, A1); - slePd->setFieldU32(sfSequence, 10); - - STArray credentials(sfAcceptedCredentials, tooBig); - for (std::size_t n = 0; n < tooBig; ++n) - { - auto cred = STObject::makeInnerObject(sfCredential); - cred.setAccountID(sfIssuer, A2); - auto credType = std::string("cred_type") + std::to_string(n); - cred.setFieldVL(sfCredentialType, Slice(credType.c_str(), credType.size())); - credentials.push_back(std::move(cred)); - } - slePd->setFieldArray(sfAcceptedCredentials, credentials); - ac.view().insert(slePd); - return true; + return !!createPermissionedDomain(ac, A1, A2, tooBig); }, XRPAmount{}, STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain 3"; doInvariantCheck( + Env(*this, features), {{"permissioned domain credentials aren't sorted"}}, [](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - slePd->setAccountID(sfOwner, A1); - slePd->setFieldU32(sfSequence, 10); + auto slePd = createPermissionedDomain(ac, A1, A2, 0); STArray credentials(sfAcceptedCredentials, 2); for (std::size_t n = 0; n < 2; ++n) @@ -1210,21 +1242,19 @@ class Invariants_test : public beast::unit_test::suite credentials.push_back(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); - ac.view().insert(slePd); + ac.view().update(slePd); return true; }, XRPAmount{}, STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain 4"; doInvariantCheck( + Env(*this, features), {{"permissioned domain credentials aren't unique"}}, [](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - slePd->setAccountID(sfOwner, A1); - slePd->setFieldU32(sfSequence, 10); + auto slePd = createPermissionedDomain(ac, A1, A2, 0); STArray credentials(sfAcceptedCredentials, 2); for (std::size_t n = 0; n < 2; ++n) @@ -1235,22 +1265,20 @@ class Invariants_test : public beast::unit_test::suite credentials.push_back(std::move(cred)); } slePd->setFieldArray(sfAcceptedCredentials, credentials); - ac.view().insert(slePd); + ac.view().update(slePd); return true; }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain Set 1"; doInvariantCheck( + Env(*this, features), {{"permissioned domain with no rules."}}, [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - // create PD - createPermissionedDomain(ac, slePd, A1, A2); + auto slePd = createPermissionedDomain(ac, A1, A2); // update PD with empty rules { @@ -1262,18 +1290,16 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain Set 2"; doInvariantCheck( + Env(*this, features), {{"permissioned domain bad credentials size " + std::to_string(tooBig)}}, [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - // create PD - createPermissionedDomain(ac, slePd, A1, A2); + auto slePd = createPermissionedDomain(ac, A1, A2); // update PD { @@ -1295,18 +1321,16 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain Set 3"; doInvariantCheck( + Env(*this, features), {{"permissioned domain credentials aren't sorted"}}, [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - // create PD - createPermissionedDomain(ac, slePd, A1, A2); + auto slePd = createPermissionedDomain(ac, A1, A2); // update PD { @@ -1327,18 +1351,16 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); testcase << "PermissionedDomain Set 4"; doInvariantCheck( + Env(*this, features), {{"permissioned domain credentials aren't unique"}}, [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - // create PD - createPermissionedDomain(ac, slePd, A1, A2); + auto slePd = createPermissionedDomain(ac, A1, A2); // update PD { @@ -1357,8 +1379,155 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : badTers); + + std::initializer_list goodTers = {tesSUCCESS, tesSUCCESS}; + + std::vector badMoreThan1{{"transaction affected more than 1 permissioned domain entry."}}; + std::vector emptyV; + std::vector badNoDomains{{"no domain objects affected by"}}; + std::vector badNotDeleted{{"domain object modified, but not deleted by "}}; + std::vector badDeleted{{"domain object deleted by"}}; + std::vector badTx{{"domain object(s) affected by an unauthorized transaction."}}; + + { + testcase << "PermissionedDomain set 2 domains "; + doInvariantCheck( + Env(*this, features), + fixPDEnabled ? badMoreThan1 : emptyV, + [](Account const& A1, Account const& A2, ApplyContext& ac) { + createPermissionedDomain(ac, A1, A2); + createPermissionedDomain(ac, A1, A2, 2, 11); + return true; + }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : goodTers); + } + + { + testcase << "PermissionedDomain del 2 domains"; + + Env env1(*this, features); + + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); + + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + std::move(env1), + A1, + A2, + fixPDEnabled ? badMoreThan1 : emptyV, + [&pd1, &pd2](Account const&, Account const&, ApplyContext& ac) { + auto sle1 = ac.view().peek({ltPERMISSIONED_DOMAIN, pd1}); + auto sle2 = ac.view().peek({ltPERMISSIONED_DOMAIN, pd2}); + ac.view().erase(sle1); + ac.view().erase(sle2); + return true; + }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_DELETE, [](STObject&) {}}, + fixPDEnabled ? failTers : goodTers); + } + + { + testcase << "PermissionedDomain set 0 domains "; + doInvariantCheck( + Env(*this, features), + fixPDEnabled ? badNoDomains : emptyV, + [](Account const&, Account const&, ApplyContext&) { return true; }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? badTers : goodTers); + } + + { + testcase << "PermissionedDomain del 0 domains"; + + Env env1(*this, features); + + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); + + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + Env(*this, features), + A1, + A2, + fixPDEnabled ? badNoDomains : emptyV, + [](Account const&, Account const&, ApplyContext&) { return true; }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_DELETE, [](STObject&) {}}, + fixPDEnabled ? badTers : goodTers); + } + + { + testcase << "PermissionedDomain set, delete domain"; + + Env env1(*this, features); + + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); + + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + std::move(env1), + A1, + A2, + fixPDEnabled ? badDeleted : emptyV, + [&pd1](Account const&, Account const&, ApplyContext& ac) { + auto sle1 = ac.view().peek({ltPERMISSIONED_DOMAIN, pd1}); + ac.view().erase(sle1); + return true; + }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_SET, [](STObject&) {}}, + fixPDEnabled ? failTers : goodTers); + } + + { + testcase << "PermissionedDomain del, create domain "; + doInvariantCheck( + Env(*this, features), + fixPDEnabled ? badNotDeleted : emptyV, + [](Account const& A1, Account const& A2, ApplyContext& ac) { + createPermissionedDomain(ac, A1, A2); + return true; + }, + XRPAmount{}, + STTx{ttPERMISSIONED_DOMAIN_DELETE, [](STObject&) {}}, + fixPDEnabled ? failTers : goodTers); + } + + { + testcase << "PermissionedDomain invalid tx"; + + doInvariantCheck( + fixPDEnabled ? badTx : emptyV, + [&](Account const& A1, Account const& A2, ApplyContext& ac) { + createPermissionedDomain(ac, A1, A2); + return true; + }, + XRPAmount{}, + STTx{ttPAYMENT, [](STObject&) {}}, + failTers); + } } void @@ -1478,13 +1647,43 @@ class Invariants_test : public beast::unit_test::suite }); } - void - testPermissionedDEX() + static std::pair + createPermissionedDomainEnv( + test::jtx::Env& env, + test::jtx::Account const& A1, + test::jtx::Account const& A2, + std::uint32_t numCreds = 2) { using namespace test::jtx; - testcase << "PermissionedDEX"; + + pdomain::Credentials credentials; + + for (std::size_t n = 0; n < numCreds; ++n) + { + auto credType = "cred_type" + std::to_string(n); + credentials.push_back({A2, credType}); + } + + std::uint32_t const seq = env.seq(A1); + env(pdomain::setTx(A1, credentials)); + uint256 key = pdomain::getNewDomain(env.meta()); + + // std::cout << "PD, acc: " << A1.id() << ", seq: " << seq << ", k: " << + // key << std::endl; + return {seq, key}; + } + + void + testPermissionedDEX(FeatureBitset features) + { + using namespace test::jtx; + + bool const fixPDEnabled = features[fixPermissionedDomainInvariant]; + + testcase << "PermissionedDEX" + std::string(fixPDEnabled ? " fix" : ""); doInvariantCheck( + Env(*this, features), {{"domain doesn't exist"}}, [](Account const& A1, Account const&, ApplyContext& ac) { Keylet const offerKey = keylet::offer(A1.id(), 10); @@ -1511,12 +1710,9 @@ class Invariants_test : public beast::unit_test::suite // missing domain ID in offer object doInvariantCheck( + Env(*this, features), {{"hybrid offer is malformed"}}, [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - createPermissionedDomain(ac, slePd, A1, A2); - Keylet const offerKey = keylet::offer(A2.id(), 10); auto sleOffer = std::make_shared(offerKey); sleOffer->setAccountID(sfAccount, A2); @@ -1531,116 +1727,154 @@ class Invariants_test : public beast::unit_test::suite return true; }, XRPAmount{}, - STTx{ttOFFER_CREATE, [&](STObject& tx) {}}, + STTx{ttOFFER_CREATE, [&](STObject&) {}}, {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); // more than one entry in sfAdditionalBooks - doInvariantCheck( - {{"hybrid offer is malformed"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - createPermissionedDomain(ac, slePd, A1, A2); + { + Env env1(*this, features); - Keylet const offerKey = keylet::offer(A2.id(), 10); - auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); - sleOffer->setFieldAmount(sfTakerGets, XRP(1)); - sleOffer->setFlag(lsfHybrid); - sleOffer->setFieldH256(sfDomainID, pdKeylet.key); + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); - STArray bookArr; - bookArr.push_back(STObject::makeInnerObject(sfBook)); - bookArr.push_back(STObject::makeInnerObject(sfBook)); - sleOffer->setFieldArray(sfAdditionalBooks, bookArr); - ac.view().insert(sleOffer); - return true; - }, - XRPAmount{}, - STTx{ttOFFER_CREATE, [&](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + std::move(env1), + A1, + A2, + {{"hybrid offer is malformed"}}, + [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(A2.id(), 10); + auto sleOffer = std::make_shared(offerKey); + sleOffer->setAccountID(sfAccount, A2); + sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setFieldAmount(sfTakerGets, XRP(1)); + sleOffer->setFlag(lsfHybrid); + sleOffer->setFieldH256(sfDomainID, pd1); + + STArray bookArr; + bookArr.push_back(STObject::makeInnerObject(sfBook)); + bookArr.push_back(STObject::makeInnerObject(sfBook)); + sleOffer->setFieldArray(sfAdditionalBooks, bookArr); + ac.view().insert(sleOffer); + return true; + }, + XRPAmount{}, + STTx{ttOFFER_CREATE, [&](STObject&) {}}, + {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + } // hybrid offer missing sfAdditionalBooks - doInvariantCheck( - {{"hybrid offer is malformed"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - createPermissionedDomain(ac, slePd, A1, A2); + { + Env env1(*this, features); - Keylet const offerKey = keylet::offer(A2.id(), 10); - auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); - sleOffer->setFieldAmount(sfTakerGets, XRP(1)); - sleOffer->setFlag(lsfHybrid); - sleOffer->setFieldH256(sfDomainID, pdKeylet.key); - ac.view().insert(sleOffer); - return true; - }, - XRPAmount{}, - STTx{ttOFFER_CREATE, [&](STObject& tx) {}}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); - doInvariantCheck( - {{"transaction consumed wrong domains"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - createPermissionedDomain(ac, slePd, A1, A2); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); - Keylet const badDomainKeylet = keylet::permissionedDomain(A1.id(), 20); - auto sleBadPd = std::make_shared(badDomainKeylet); - createPermissionedDomain(ac, sleBadPd, A1, A2); + doInvariantCheck( + std::move(env1), + A1, + A2, + {{"hybrid offer is malformed"}}, + [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(A2.id(), 10); + auto sleOffer = std::make_shared(offerKey); + sleOffer->setAccountID(sfAccount, A2); + sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setFieldAmount(sfTakerGets, XRP(1)); + sleOffer->setFlag(lsfHybrid); + sleOffer->setFieldH256(sfDomainID, pd1); + ac.view().insert(sleOffer); + return true; + }, + XRPAmount{}, + STTx{ttOFFER_CREATE, [&](STObject&) {}}, + {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + } - Keylet const offerKey = keylet::offer(A2.id(), 10); - auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); - sleOffer->setFieldAmount(sfTakerGets, XRP(1)); - sleOffer->setFieldH256(sfDomainID, pdKeylet.key); - ac.view().insert(sleOffer); - return true; - }, - XRPAmount{}, - STTx{ - ttOFFER_CREATE, - [&](STObject& tx) { - Account const A1{"A1"}; - Keylet const badDomainKey = keylet::permissionedDomain(A1.id(), 20); - tx.setFieldH256(sfDomainID, badDomainKey.key); - tx.setFieldAmount(sfTakerPays, A1["USD"](10)); - tx.setFieldAmount(sfTakerGets, XRP(1)); - }}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + { + Env env1(*this, features); - doInvariantCheck( - {{"domain transaction affected regular offers"}}, - [&](Account const& A1, Account const& A2, ApplyContext& ac) { - Keylet const pdKeylet = keylet::permissionedDomain(A1.id(), 10); - auto slePd = std::make_shared(pdKeylet); - createPermissionedDomain(ac, slePd, A1, A2); + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); - Keylet const offerKey = keylet::offer(A2.id(), 10); - auto sleOffer = std::make_shared(offerKey); - sleOffer->setAccountID(sfAccount, A2); - sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); - sleOffer->setFieldAmount(sfTakerGets, XRP(1)); - ac.view().insert(sleOffer); - return true; - }, - XRPAmount{}, - STTx{ - ttOFFER_CREATE, - [&](STObject& tx) { - Account const A1{"A1"}; - Keylet const domainKey = keylet::permissionedDomain(A1.id(), 10); - tx.setFieldH256(sfDomainID, domainKey.key); - tx.setFieldAmount(sfTakerPays, A1["USD"](10)); - tx.setFieldAmount(sfTakerGets, XRP(1)); - }}, - {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + [[maybe_unused]] auto [seq2, pd2] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + std::move(env1), + A1, + A2, + {{"transaction consumed wrong domains"}}, + [&pd1](Account const& A1, Account const& A2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(A2.id(), 10); + auto sleOffer = std::make_shared(offerKey); + sleOffer->setAccountID(sfAccount, A2); + sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setFieldAmount(sfTakerGets, XRP(1)); + sleOffer->setFieldH256(sfDomainID, pd1); + ac.view().insert(sleOffer); + return true; + }, + XRPAmount{}, + STTx{ + ttOFFER_CREATE, + [&pd2, &A1](STObject& tx) { + tx.setFieldH256(sfDomainID, pd2); + tx.setFieldAmount(sfTakerPays, A1["USD"](10)); + tx.setFieldAmount(sfTakerGets, XRP(1)); + }}, + {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + } + + { + Env env1(*this, features); + + Account const A1{"A1"}; + Account const A2{"A2"}; + env1.fund(XRP(1000), A1, A2); + env1.close(); + + [[maybe_unused]] auto [seq1, pd1] = createPermissionedDomainEnv(env1, A1, A2); + env1.close(); + + doInvariantCheck( + std::move(env1), + A1, + A2, + {{"domain transaction affected regular offers"}}, + [&](Account const& A1, Account const& A2, ApplyContext& ac) { + Keylet const offerKey = keylet::offer(A2.id(), 10); + auto sleOffer = std::make_shared(offerKey); + sleOffer->setAccountID(sfAccount, A2); + sleOffer->setFieldAmount(sfTakerPays, A1["USD"](10)); + sleOffer->setFieldAmount(sfTakerGets, XRP(1)); + ac.view().insert(sleOffer); + return true; + }, + XRPAmount{}, + STTx{ + ttOFFER_CREATE, + [&](STObject& tx) { + Account const A1{"A1"}; + tx.setFieldH256(sfDomainID, pd1); + tx.setFieldAmount(sfTakerPays, A1["USD"](10)); + tx.setFieldAmount(sfTakerGets, XRP(1)); + }}, + {tecINVARIANT_FAILED, tecINVARIANT_FAILED}); + } } Keylet @@ -3490,8 +3724,10 @@ public: testNoZeroEscrow(); testValidNewAccountRoot(); testNFTokenPageInvariants(); - testPermissionedDomainInvariants(); - testPermissionedDEX(); + testPermissionedDomainInvariants(defaultAmendments() | fixPermissionedDomainInvariant); + testPermissionedDomainInvariants(defaultAmendments() - fixPermissionedDomainInvariant); + testPermissionedDEX(defaultAmendments() | fixPermissionedDomainInvariant); + testPermissionedDEX(defaultAmendments() - fixPermissionedDomainInvariant); testNoModifiedUnmodifiableFields(); testValidPseudoAccounts(); testValidLoanBroker(); diff --git a/src/test/app/PermissionedDomains_test.cpp b/src/test/app/PermissionedDomains_test.cpp index 1a1fe9a9eb..8485202144 100644 --- a/src/test/app/PermissionedDomains_test.cpp +++ b/src/test/app/PermissionedDomains_test.cpp @@ -38,13 +38,17 @@ class PermissionedDomains_test : public beast::unit_test::suite testable_amendments() // | featurePermissionedDomains | featureCredentials}; + FeatureBitset withFix_{ + testable_amendments() // + | featurePermissionedDomains | featureCredentials}; + // Verify that each tx type can execute if the feature is enabled. void - testEnabled() + testEnabled(FeatureBitset features) { testcase("Enabled"); Account const alice("alice"); - Env env(*this, withFeature_); + Env env(*this, features); env.fund(XRP(1000), alice); pdomain::Credentials credentials{{alice, "first credential"}}; env(pdomain::setTx(alice, credentials)); @@ -237,10 +241,10 @@ class PermissionedDomains_test : public beast::unit_test::suite // Test PermissionedDomainSet void - testSet() + testSet(FeatureBitset features) { testcase("Set"); - Env env(*this, withFeature_); + Env env(*this, features); env.set_parse_failure_expected(true); int const accNum = 12; @@ -395,10 +399,10 @@ class PermissionedDomains_test : public beast::unit_test::suite // Test PermissionedDomainDelete void - testDelete() + testDelete(FeatureBitset features) { testcase("Delete"); - Env env(*this, withFeature_); + Env env(*this, features); Account const alice("alice"); env.fund(XRP(1000), alice); @@ -448,14 +452,14 @@ class PermissionedDomains_test : public beast::unit_test::suite } void - testAccountReserve() + testAccountReserve(FeatureBitset features) { // Verify that the reserve behaves as expected for creating. testcase("Account Reserve"); using namespace test::jtx; - Env env(*this, withFeature_); + Env env(*this, features); Account const alice("alice"); // Fund alice enough to exist, but not enough to meet @@ -500,12 +504,16 @@ public: void run() override { - testEnabled(); + testEnabled(withFeature_); + testEnabled(withFix_); testCredentialsDisabled(); testDisabled(); - testSet(); - testDelete(); - testAccountReserve(); + testSet(withFeature_); + testSet(withFix_); + testDelete(withFeature_); + testDelete(withFix_); + testAccountReserve(withFeature_); + testAccountReserve(withFix_); } }; diff --git a/src/test/jtx/impl/balance.cpp b/src/test/jtx/impl/balance.cpp index 9d6f5c6124..1ebeeed437 100644 --- a/src/test/jtx/impl/balance.cpp +++ b/src/test/jtx/impl/balance.cpp @@ -4,6 +4,10 @@ namespace xrpl { namespace test { namespace jtx { +#define TEST_EXPECT(cond) env.test.expect(cond, __FILE__, __LINE__) +#define TEST_EXPECTS(cond, reason) \ + ((cond) ? (env.test.pass(), true) : (env.test.fail((reason), __FILE__, __LINE__), false)) + void doBalance(Env& env, AccountID const& account, bool none, STAmount const& value, Issue const& issue) { @@ -12,11 +16,13 @@ doBalance(Env& env, AccountID const& account, bool none, STAmount const& value, auto const sle = env.le(keylet::account(account)); if (none) { - env.test.expect(!sle); + TEST_EXPECT(!sle); } - else if (env.test.expect(sle)) + else if (TEST_EXPECT(sle)) { - env.test.expect(sle->getFieldAmount(sfBalance) == value); + TEST_EXPECTS( + sle->getFieldAmount(sfBalance) == value, + sle->getFieldAmount(sfBalance).getText() + " / " + value.getText()); } } else @@ -24,15 +30,15 @@ doBalance(Env& env, AccountID const& account, bool none, STAmount const& value, auto const sle = env.le(keylet::line(account, issue)); if (none) { - env.test.expect(!sle); + TEST_EXPECT(!sle); } - else if (env.test.expect(sle)) + else if (TEST_EXPECT(sle)) { auto amount = sle->getFieldAmount(sfBalance); amount.setIssuer(issue.account); if (account > issue.account) amount.negate(); - env.test.expect(amount == value); + TEST_EXPECTS(amount == value, amount.getText()); } } } @@ -43,12 +49,12 @@ doBalance(Env& env, AccountID const& account, bool none, STAmount const& value, auto const sle = env.le(keylet::mptoken(mptIssue.getMptID(), account)); if (none) { - env.test.expect(!sle); + TEST_EXPECT(!sle); } - else if (env.test.expect(sle)) + else if (TEST_EXPECT(sle)) { STAmount const amount{mptIssue, sle->getFieldU64(sfMPTAmount)}; - env.test.expect(amount == value); + TEST_EXPECT(amount == value); } } diff --git a/src/xrpld/app/tx/detail/InvariantCheck.cpp b/src/xrpld/app/tx/detail/InvariantCheck.cpp index fe47449c36..24a37270ce 100644 --- a/src/xrpld/app/tx/detail/InvariantCheck.cpp +++ b/src/xrpld/app/tx/detail/InvariantCheck.cpp @@ -1507,7 +1507,7 @@ ValidMPTIssuance::finalize( void ValidPermissionedDomain::visitEntry( - bool, + bool isDel, std::shared_ptr const& before, std::shared_ptr const& after) { @@ -1516,39 +1516,29 @@ ValidPermissionedDomain::visitEntry( if (after && after->getType() != ltPERMISSIONED_DOMAIN) return; - auto check = [](SleStatus& sleStatus, std::shared_ptr const& sle) { + auto check = [isDel](std::vector& sleStatus, std::shared_ptr const& sle) { auto const& credentials = sle->getFieldArray(sfAcceptedCredentials); - sleStatus.credentialsSize_ = credentials.size(); auto const sorted = credentials::makeSorted(credentials); - sleStatus.isUnique_ = !sorted.empty(); + + SleStatus ss{credentials.size(), false, !sorted.empty(), isDel}; // If array have duplicates then all the other checks are invalid - sleStatus.isSorted_ = false; - - if (sleStatus.isUnique_) + if (ss.isUnique_) { unsigned i = 0; for (auto const& cred : sorted) { auto const& credTx = credentials[i++]; - sleStatus.isSorted_ = (cred.first == credTx[sfIssuer]) && (cred.second == credTx[sfCredentialType]); - if (!sleStatus.isSorted_) + ss.isSorted_ = (cred.first == credTx[sfIssuer]) && (cred.second == credTx[sfCredentialType]); + if (!ss.isSorted_) break; } } + sleStatus.emplace_back(std::move(ss)); }; - if (before) - { - sleStatus_[0] = SleStatus(); - check(*sleStatus_[0], after); - } - if (after) - { - sleStatus_[1] = SleStatus(); - check(*sleStatus_[1], after); - } + check(sleStatus_, after); } bool @@ -1559,9 +1549,6 @@ ValidPermissionedDomain::finalize( ReadView const& view, beast::Journal const& j) { - if (tx.getTxnType() != ttPERMISSIONED_DOMAIN_SET || result != tesSUCCESS) - return true; - auto check = [](SleStatus const& sleStatus, beast::Journal const& j) { if (!sleStatus.credentialsSize_) { @@ -1595,7 +1582,76 @@ ValidPermissionedDomain::finalize( return true; }; - return (sleStatus_[0] ? check(*sleStatus_[0], j) : true) && (sleStatus_[1] ? check(*sleStatus_[1], j) : true); + if (view.rules().enabled(fixPermissionedDomainInvariant)) + { + // No permissioned domains should be affected if the transaction failed + if (result != tesSUCCESS) + // If nothing changed, all is good. If there were changes, that's + // bad. + return sleStatus_.empty(); + + if (sleStatus_.size() > 1) + { + JLOG(j.fatal()) << "Invariant failed: transaction affected more " + "than 1 permissioned domain entry."; + return false; + } + + switch (tx.getTxnType()) + { + case ttPERMISSIONED_DOMAIN_SET: { + if (sleStatus_.empty()) + { + JLOG(j.fatal()) << "Invariant failed: no domain objects affected by " + "PermissionedDomainSet"; + return false; + } + + auto const& sleStatus = sleStatus_[0]; + if (sleStatus.isDelete_) + { + JLOG(j.fatal()) << "Invariant failed: domain object " + "deleted by PermissionedDomainSet"; + return false; + } + return check(sleStatus, j); + } + case ttPERMISSIONED_DOMAIN_DELETE: { + if (sleStatus_.empty()) + { + JLOG(j.fatal()) << "Invariant failed: no domain objects affected by " + "PermissionedDomainDelete"; + return false; + } + + if (!sleStatus_[0].isDelete_) + { + JLOG(j.fatal()) << "Invariant failed: domain object " + "modified, but not deleted by " + "PermissionedDomainDelete"; + return false; + } + return true; + } + default: { + if (!sleStatus_.empty()) + { + JLOG(j.fatal()) << "Invariant failed: " << sleStatus_.size() + << " domain object(s) affected by an " + "unauthorized transaction. " + << tx.getTxnType(); + return false; + } + return true; + } + } + } + else + { + if (tx.getTxnType() != ttPERMISSIONED_DOMAIN_SET || result != tesSUCCESS || sleStatus_.empty()) + return true; + return check(sleStatus_[0], j); + } } //------------------------------------------------------------------------------ diff --git a/src/xrpld/app/tx/detail/InvariantCheck.h b/src/xrpld/app/tx/detail/InvariantCheck.h index 9a20e372ba..7e9a62d9e2 100644 --- a/src/xrpld/app/tx/detail/InvariantCheck.h +++ b/src/xrpld/app/tx/detail/InvariantCheck.h @@ -449,9 +449,11 @@ class ValidPermissionedDomain struct SleStatus { std::size_t credentialsSize_{0}; - bool isSorted_ = false, isUnique_ = false; + bool isSorted_ = false; + bool isUnique_ = false; + bool isDelete_ = false; }; - std::optional sleStatus_[2]; + std::vector sleStatus_; public: void From ef284692db4588082eac8106b1f5262bf1ad7534 Mon Sep 17 00:00:00 2001 From: Jingchen Date: Wed, 11 Feb 2026 13:42:31 +0000 Subject: [PATCH 08/16] refactor: Modularize WalletDB and Manifest (#6223) This change modularizes the `WalletDB` and `Manifest`. Note that the wallet db has nothing to do with account wallets and it stores node configuration, which is why it depends on the manifest code. --- .../scripts/levelization/results/loops.txt | 5 +- .../scripts/levelization/results/ordering.txt | 18 +- cmake/XrplCore.cmake | 21 +- cmake/XrplInstall.cmake | 1 + .../xrpl/core}/PeerReservationTable.h | 0 include/xrpl/core/ServiceRegistry.h | 24 ++ include/xrpl/core/StartUpType.h | 16 ++ .../app/main => include/xrpl/rdb}/DBInit.h | 0 .../core => include/xrpl/rdb}/DatabaseCon.h | 16 +- {src/xrpld/core => include/xrpl/rdb}/SociDB.h | 0 .../misc => include/xrpl/server}/Manifest.h | 0 .../app/rdb => include/xrpl/server}/State.h | 8 +- .../app/rdb => include/xrpl/server}/Vacuum.h | 2 +- .../app/rdb => include/xrpl/server}/Wallet.h | 7 +- src/libxrpl/rdb/DatabaseCon.cpp | 92 +++++++ .../core/detail => libxrpl/rdb}/SociDB.cpp | 6 +- .../rdb/detail => libxrpl/server}/State.cpp | 2 +- .../rdb/detail => libxrpl/server}/Vacuum.cpp | 4 +- .../rdb/detail => libxrpl/server}/Wallet.cpp | 3 +- src/test/app/LedgerLoad_test.cpp | 22 +- src/test/app/Manifest_test.cpp | 6 +- src/test/app/ValidatorKeys_test.cpp | 2 +- src/test/core/SociDB_test.cpp | 3 +- src/test/nodestore/Database_test.cpp | 3 +- src/test/rpc/LedgerEntry_test.cpp | 4 +- src/xrpld/app/ledger/Ledger.cpp | 1 - src/xrpld/app/main/Application.cpp | 26 +- src/xrpld/app/main/Application.h | 14 +- src/xrpld/app/main/Main.cpp | 16 +- src/xrpld/app/main/NodeIdentity.cpp | 3 +- src/xrpld/app/misc/SHAMapStoreImp.cpp | 2 +- src/xrpld/app/misc/SHAMapStoreImp.h | 4 +- src/xrpld/app/misc/ValidatorList.h | 2 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 2 +- src/xrpld/app/misc/detail/Manifest.cpp | 7 +- src/xrpld/app/misc/detail/ValidatorKeys.cpp | 2 +- src/xrpld/app/rdb/PeerFinder.h | 3 +- src/xrpld/app/rdb/RelationalDatabase.h | 8 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 8 +- .../app/rdb/backend/detail/SQLiteDatabase.cpp | 48 ++-- .../app/rdb/detail/RelationalDatabase.cpp | 7 +- src/xrpld/core/Config.h | 8 +- src/xrpld/core/detail/Config.cpp | 146 +++++++++++ src/xrpld/core/detail/DatabaseCon.cpp | 242 ------------------ src/xrpld/overlay/detail/OverlayImpl.cpp | 2 +- .../overlay/detail/PeerReservationTable.cpp | 4 +- src/xrpld/peerfinder/detail/StoreSqdb.h | 3 +- src/xrpld/rpc/InfoSub.h | 3 +- 48 files changed, 435 insertions(+), 391 deletions(-) rename {src/xrpld/overlay => include/xrpl/core}/PeerReservationTable.h (100%) create mode 100644 include/xrpl/core/StartUpType.h rename {src/xrpld/app/main => include/xrpl/rdb}/DBInit.h (100%) rename {src/xrpld/core => include/xrpl/rdb}/DatabaseCon.h (93%) rename {src/xrpld/core => include/xrpl/rdb}/SociDB.h (100%) rename {src/xrpld/app/misc => include/xrpl/server}/Manifest.h (100%) rename {src/xrpld/app/rdb => include/xrpl/server}/State.h (91%) rename {src/xrpld/app/rdb => include/xrpl/server}/Vacuum.h (90%) rename {src/xrpld/app/rdb => include/xrpl/server}/Wallet.h (96%) create mode 100644 src/libxrpl/rdb/DatabaseCon.cpp rename src/{xrpld/core/detail => libxrpl/rdb}/SociDB.cpp (98%) rename src/{xrpld/app/rdb/detail => libxrpl/server}/State.cpp (98%) rename src/{xrpld/app/rdb/detail => libxrpl/server}/Vacuum.cpp (96%) rename src/{xrpld/app/rdb/detail => libxrpl/server}/Wallet.cpp (99%) delete mode 100644 src/xrpld/core/detail/DatabaseCon.cpp diff --git a/.github/scripts/levelization/results/loops.txt b/.github/scripts/levelization/results/loops.txt index d15843ceb0..34842d7f48 100644 --- a/.github/scripts/levelization/results/loops.txt +++ b/.github/scripts/levelization/results/loops.txt @@ -4,14 +4,11 @@ Loop: test.jtx test.toplevel Loop: test.jtx test.unit_test test.unit_test == test.jtx -Loop: xrpld.app xrpld.core - xrpld.app > xrpld.core - Loop: xrpld.app xrpld.overlay xrpld.overlay > xrpld.app Loop: xrpld.app xrpld.peerfinder - xrpld.peerfinder ~= xrpld.app + xrpld.peerfinder == xrpld.app Loop: xrpld.app xrpld.rpc xrpld.rpc > xrpld.app diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 88a3441fa1..fabc7b49ca 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -17,12 +17,15 @@ libxrpl.nodestore > xrpl.protocol libxrpl.protocol > xrpl.basics libxrpl.protocol > xrpl.json libxrpl.protocol > xrpl.protocol +libxrpl.rdb > xrpl.basics +libxrpl.rdb > xrpl.rdb libxrpl.resource > xrpl.basics libxrpl.resource > xrpl.json libxrpl.resource > xrpl.resource libxrpl.server > xrpl.basics libxrpl.server > xrpl.json libxrpl.server > xrpl.protocol +libxrpl.server > xrpl.rdb libxrpl.server > xrpl.server libxrpl.shamap > xrpl.basics libxrpl.shamap > xrpl.protocol @@ -41,7 +44,9 @@ test.app > xrpl.json test.app > xrpl.ledger test.app > xrpl.nodestore test.app > xrpl.protocol +test.app > xrpl.rdb test.app > xrpl.resource +test.app > xrpl.server test.basics > test.jtx test.basics > test.unit_test test.basics > xrpl.basics @@ -67,6 +72,7 @@ test.core > xrpl.basics test.core > xrpl.core test.core > xrpld.core test.core > xrpl.json +test.core > xrpl.rdb test.core > xrpl.server test.csf > xrpl.basics test.csf > xrpld.consensus @@ -95,8 +101,8 @@ test.nodestore > test.jtx test.nodestore > test.toplevel test.nodestore > test.unit_test test.nodestore > xrpl.basics -test.nodestore > xrpld.core test.nodestore > xrpl.nodestore +test.nodestore > xrpl.rdb test.overlay > test.jtx test.overlay > test.toplevel test.overlay > test.unit_test @@ -154,6 +160,7 @@ tests.libxrpl > xrpl.net xrpl.core > xrpl.basics xrpl.core > xrpl.json xrpl.core > xrpl.ledger +xrpl.core > xrpl.protocol xrpl.json > xrpl.basics xrpl.ledger > xrpl.basics xrpl.ledger > xrpl.protocol @@ -162,12 +169,16 @@ xrpl.nodestore > xrpl.basics xrpl.nodestore > xrpl.protocol xrpl.protocol > xrpl.basics xrpl.protocol > xrpl.json +xrpl.rdb > xrpl.basics +xrpl.rdb > xrpl.core xrpl.resource > xrpl.basics xrpl.resource > xrpl.json xrpl.resource > xrpl.protocol xrpl.server > xrpl.basics +xrpl.server > xrpl.core xrpl.server > xrpl.json xrpl.server > xrpl.protocol +xrpl.server > xrpl.rdb xrpl.shamap > xrpl.basics xrpl.shamap > xrpl.nodestore xrpl.shamap > xrpl.protocol @@ -176,12 +187,15 @@ xrpld.app > xrpl.basics xrpld.app > xrpl.core xrpld.app > xrpld.conditions xrpld.app > xrpld.consensus +xrpld.app > xrpld.core xrpld.app > xrpl.json xrpld.app > xrpl.ledger xrpld.app > xrpl.net xrpld.app > xrpl.nodestore xrpld.app > xrpl.protocol +xrpld.app > xrpl.rdb xrpld.app > xrpl.resource +xrpld.app > xrpl.server xrpld.app > xrpl.shamap xrpld.conditions > xrpl.basics xrpld.conditions > xrpl.protocol @@ -193,6 +207,7 @@ xrpld.core > xrpl.core xrpld.core > xrpl.json xrpld.core > xrpl.net xrpld.core > xrpl.protocol +xrpld.core > xrpl.rdb xrpld.overlay > xrpl.basics xrpld.overlay > xrpl.core xrpld.overlay > xrpld.core @@ -204,6 +219,7 @@ xrpld.overlay > xrpl.server xrpld.peerfinder > xrpl.basics xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpl.protocol +xrpld.peerfinder > xrpl.rdb xrpld.perflog > xrpl.basics xrpld.perflog > xrpl.core xrpld.perflog > xrpld.rpc diff --git a/cmake/XrplCore.cmake b/cmake/XrplCore.cmake index 57d0e83348..cea19db9bc 100644 --- a/cmake/XrplCore.cmake +++ b/cmake/XrplCore.cmake @@ -84,9 +84,6 @@ add_module(xrpl net) target_link_libraries(xrpl.libxrpl.net PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol xrpl.libxrpl.resource) -add_module(xrpl server) -target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol) - add_module(xrpl nodestore) target_link_libraries(xrpl.libxrpl.nodestore PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol) @@ -94,8 +91,15 @@ add_module(xrpl shamap) target_link_libraries(xrpl.libxrpl.shamap PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.crypto xrpl.libxrpl.protocol xrpl.libxrpl.nodestore) +add_module(xrpl rdb) +target_link_libraries(xrpl.libxrpl.rdb PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.core) + +add_module(xrpl server) +target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core xrpl.libxrpl.rdb) + add_module(xrpl ledger) -target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol) +target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol + xrpl.libxrpl.rdb) add_library(xrpl.libxrpl) set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) @@ -113,13 +117,14 @@ target_link_modules( core crypto json + ledger + net + nodestore protocol + rdb resource server - nodestore - shamap - net - ledger) + shamap) # All headers in libxrpl are in modules. # Uncomment this stanza if you have not yet moved new headers into a module. diff --git a/cmake/XrplInstall.cmake b/cmake/XrplInstall.cmake index 141dc56089..340dca553b 100644 --- a/cmake/XrplInstall.cmake +++ b/cmake/XrplInstall.cmake @@ -23,6 +23,7 @@ install(TARGETS common xrpl.libxrpl.core xrpl.libxrpl.crypto xrpl.libxrpl.json + xrpl.libxrpl.rdb xrpl.libxrpl.ledger xrpl.libxrpl.net xrpl.libxrpl.nodestore diff --git a/src/xrpld/overlay/PeerReservationTable.h b/include/xrpl/core/PeerReservationTable.h similarity index 100% rename from src/xrpld/overlay/PeerReservationTable.h rename to include/xrpl/core/PeerReservationTable.h diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index 7147242339..86591a815f 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -5,6 +5,8 @@ #include #include +#include + namespace xrpl { // Forward declarations @@ -18,6 +20,10 @@ namespace perf { class PerfLog; } +// This is temporary until we migrate all code to use ServiceRegistry. +class Application; + +// Forward declarations class AcceptedLedger; class AmendmentTable; class Cluster; @@ -194,6 +200,24 @@ public: virtual perf::PerfLog& getPerfLog() = 0; + + // Configuration and state + virtual bool + isStopping() const = 0; + + virtual beast::Journal + journal(std::string const& name) = 0; + + virtual boost::asio::io_context& + getIOContext() = 0; + + virtual Logs& + logs() = 0; + + // Temporary: Get the underlying Application for functions that haven't + // been migrated yet. This should be removed once all code is migrated. + virtual Application& + app() = 0; }; } // namespace xrpl diff --git a/include/xrpl/core/StartUpType.h b/include/xrpl/core/StartUpType.h new file mode 100644 index 0000000000..74a1898806 --- /dev/null +++ b/include/xrpl/core/StartUpType.h @@ -0,0 +1,16 @@ +#pragma once + +#include +#include + +namespace xrpl { + +enum class StartUpType { FRESH, NORMAL, LOAD, LOAD_FILE, REPLAY, NETWORK }; + +inline std::ostream& +operator<<(std::ostream& os, StartUpType const& type) +{ + return os << static_cast>(type); +} + +} // namespace xrpl diff --git a/src/xrpld/app/main/DBInit.h b/include/xrpl/rdb/DBInit.h similarity index 100% rename from src/xrpld/app/main/DBInit.h rename to include/xrpl/rdb/DBInit.h diff --git a/src/xrpld/core/DatabaseCon.h b/include/xrpl/rdb/DatabaseCon.h similarity index 93% rename from src/xrpld/core/DatabaseCon.h rename to include/xrpl/rdb/DatabaseCon.h index 89d582257b..37a53044e4 100644 --- a/src/xrpld/core/DatabaseCon.h +++ b/include/xrpl/rdb/DatabaseCon.h @@ -1,10 +1,9 @@ #pragma once -#include -#include -#include - #include +#include +#include +#include #include @@ -68,7 +67,7 @@ public: { explicit Setup() = default; - Config::StartUpType startUp = Config::NORMAL; + StartUpType startUp = StartUpType::NORMAL; bool standAlone = false; boost::filesystem::path dataDir; // Indicates whether or not to return the `globalPragma` @@ -105,8 +104,8 @@ public: beast::Journal journal) // Use temporary files or regular DB files? : DatabaseCon( - setup.standAlone && setup.startUp != Config::LOAD && setup.startUp != Config::LOAD_FILE && - setup.startUp != Config::REPLAY + setup.standAlone && setup.startUp != StartUpType::LOAD && setup.startUp != StartUpType::LOAD_FILE && + setup.startUp != StartUpType::REPLAY ? "" : (setup.dataDir / dbName), setup.commonPragma(), @@ -229,7 +228,4 @@ private: std::shared_ptr checkpointerFromId(std::uintptr_t id); -DatabaseCon::Setup -setup_DatabaseCon(Config const& c, std::optional j = std::nullopt); - } // namespace xrpl diff --git a/src/xrpld/core/SociDB.h b/include/xrpl/rdb/SociDB.h similarity index 100% rename from src/xrpld/core/SociDB.h rename to include/xrpl/rdb/SociDB.h diff --git a/src/xrpld/app/misc/Manifest.h b/include/xrpl/server/Manifest.h similarity index 100% rename from src/xrpld/app/misc/Manifest.h rename to include/xrpl/server/Manifest.h diff --git a/src/xrpld/app/rdb/State.h b/include/xrpl/server/State.h similarity index 91% rename from src/xrpld/app/rdb/State.h rename to include/xrpl/server/State.h index 52118b3cf8..48e11869f4 100644 --- a/src/xrpld/app/rdb/State.h +++ b/include/xrpl/server/State.h @@ -1,10 +1,8 @@ #pragma once -#include -#include -#include -#include -#include +#include +#include +#include #include diff --git a/src/xrpld/app/rdb/Vacuum.h b/include/xrpl/server/Vacuum.h similarity index 90% rename from src/xrpld/app/rdb/Vacuum.h rename to include/xrpl/server/Vacuum.h index f592b4537e..5f80eced87 100644 --- a/src/xrpld/app/rdb/Vacuum.h +++ b/include/xrpl/server/Vacuum.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/rdb/Wallet.h b/include/xrpl/server/Wallet.h similarity index 96% rename from src/xrpld/app/rdb/Wallet.h rename to include/xrpl/server/Wallet.h index 141ef53f27..dcfbada8eb 100644 --- a/src/xrpld/app/rdb/Wallet.h +++ b/include/xrpl/server/Wallet.h @@ -1,9 +1,8 @@ #pragma once -#include -#include -#include -#include +#include +#include +#include namespace xrpl { diff --git a/src/libxrpl/rdb/DatabaseCon.cpp b/src/libxrpl/rdb/DatabaseCon.cpp new file mode 100644 index 0000000000..344df85b4a --- /dev/null +++ b/src/libxrpl/rdb/DatabaseCon.cpp @@ -0,0 +1,92 @@ +#include +#include +#include +#include + +#include +#include + +#include +#include + +namespace xrpl { + +class CheckpointersCollection +{ + std::uintptr_t nextId_{0}; + // Mutex protects the CheckpointersCollection + std::mutex mutex_; + // Each checkpointer is given a unique id. All the checkpointers that are + // part of a DatabaseCon are part of this collection. When the DatabaseCon + // is destroyed, its checkpointer is removed from the collection + std::unordered_map> checkpointers_; + +public: + std::shared_ptr + fromId(std::uintptr_t id) + { + std::lock_guard l{mutex_}; + auto it = checkpointers_.find(id); + if (it != checkpointers_.end()) + return it->second; + return {}; + } + + void + erase(std::uintptr_t id) + { + std::lock_guard lock{mutex_}; + checkpointers_.erase(id); + } + + std::shared_ptr + create(std::shared_ptr const& session, JobQueue& jobQueue, Logs& logs) + { + std::lock_guard lock{mutex_}; + auto const id = nextId_++; + auto const r = makeCheckpointer(id, session, jobQueue, logs); + checkpointers_[id] = r; + return r; + } +}; + +CheckpointersCollection checkpointers; + +std::shared_ptr +checkpointerFromId(std::uintptr_t id) +{ + return checkpointers.fromId(id); +} + +DatabaseCon::~DatabaseCon() +{ + if (checkpointer_) + { + checkpointers.erase(checkpointer_->id()); + + std::weak_ptr wk(checkpointer_); + checkpointer_.reset(); + + // The references to our Checkpointer held by 'checkpointer_' and + // 'checkpointers' have been removed, so if the use count is nonzero, a + // checkpoint is currently in progress. Wait for it to end, otherwise + // creating a new DatabaseCon to the same database may fail due to the + // database being locked by our (now old) Checkpointer. + while (wk.use_count()) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + } +} + +std::unique_ptr const> DatabaseCon::Setup::globalPragma; + +void +DatabaseCon::setupCheckpointing(JobQueue* q, Logs& l) +{ + if (!q) + Throw("No JobQueue"); + checkpointer_ = checkpointers.create(session_, *q, l); +} + +} // namespace xrpl diff --git a/src/xrpld/core/detail/SociDB.cpp b/src/libxrpl/rdb/SociDB.cpp similarity index 98% rename from src/xrpld/core/detail/SociDB.cpp rename to src/libxrpl/rdb/SociDB.cpp index ff2fa1d9c1..2f8c5f1ac6 100644 --- a/src/xrpld/core/detail/SociDB.cpp +++ b/src/libxrpl/rdb/SociDB.cpp @@ -3,12 +3,10 @@ #pragma clang diagnostic ignored "-Wdeprecated" #endif -#include -#include -#include - #include #include +#include +#include #include diff --git a/src/xrpld/app/rdb/detail/State.cpp b/src/libxrpl/server/State.cpp similarity index 98% rename from src/xrpld/app/rdb/detail/State.cpp rename to src/libxrpl/server/State.cpp index ad8944e54d..4e3a1584c2 100644 --- a/src/xrpld/app/rdb/detail/State.cpp +++ b/src/libxrpl/server/State.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/xrpld/app/rdb/detail/Vacuum.cpp b/src/libxrpl/server/Vacuum.cpp similarity index 96% rename from src/xrpld/app/rdb/detail/Vacuum.cpp rename to src/libxrpl/server/Vacuum.cpp index 5aaa04f040..cb31c6fa7a 100644 --- a/src/xrpld/app/rdb/detail/Vacuum.cpp +++ b/src/libxrpl/server/Vacuum.cpp @@ -1,7 +1,9 @@ -#include +#include #include +#include + namespace xrpl { bool diff --git a/src/xrpld/app/rdb/detail/Wallet.cpp b/src/libxrpl/server/Wallet.cpp similarity index 99% rename from src/xrpld/app/rdb/detail/Wallet.cpp rename to src/libxrpl/server/Wallet.cpp index 88a5dcf985..51f1326674 100644 --- a/src/xrpld/app/rdb/detail/Wallet.cpp +++ b/src/libxrpl/server/Wallet.cpp @@ -1,4 +1,5 @@ -#include +#include +#include #include diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index f27edadd58..b4e84a3123 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -21,7 +21,7 @@ class LedgerLoad_test : public beast::unit_test::suite std::unique_ptr cfg, std::string const& dbPath, std::string const& ledger, - Config::StartUpType type, + StartUpType type, std::optional trapTxHash) { cfg->START_LEDGER = ledger; @@ -105,7 +105,7 @@ class LedgerLoad_test : public beast::unit_test::suite // create a new env with the ledger file specified for startup Env env( *this, - envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, Config::LOAD_FILE, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, sd.ledgerFile, StartUpType::LOAD_FILE, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -123,7 +123,7 @@ class LedgerLoad_test : public beast::unit_test::suite except([&] { Env env( *this, - envconfig(ledgerConfig, sd.dbPath, "", Config::LOAD_FILE, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, "", StartUpType::LOAD_FILE, std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -132,7 +132,7 @@ class LedgerLoad_test : public beast::unit_test::suite except([&] { Env env( *this, - envconfig(ledgerConfig, sd.dbPath, "badfile.json", Config::LOAD_FILE, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, "badfile.json", StartUpType::LOAD_FILE, std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -153,7 +153,7 @@ class LedgerLoad_test : public beast::unit_test::suite except([&] { Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerFileCorrupt.string(), Config::LOAD_FILE, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, ledgerFileCorrupt.string(), StartUpType::LOAD_FILE, std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -170,7 +170,7 @@ class LedgerLoad_test : public beast::unit_test::suite boost::erase_all(ledgerHash, "\""); Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::LOAD, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::LOAD, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -189,7 +189,7 @@ class LedgerLoad_test : public beast::unit_test::suite boost::erase_all(ledgerHash, "\""); Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::REPLAY, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, std::nullopt), nullptr, beast::severities::kDisabled); auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -213,7 +213,7 @@ class LedgerLoad_test : public beast::unit_test::suite boost::erase_all(ledgerHash, "\""); Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::REPLAY, sd.trapTxHash), + envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, sd.trapTxHash), nullptr, beast::severities::kDisabled); auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -241,7 +241,7 @@ class LedgerLoad_test : public beast::unit_test::suite // replay when trapTxHash is set to an invalid transaction Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::REPLAY, ~sd.trapTxHash), + envconfig(ledgerConfig, sd.dbPath, ledgerHash, StartUpType::REPLAY, ~sd.trapTxHash), nullptr, beast::severities::kDisabled); BEAST_EXPECT(false); @@ -265,7 +265,7 @@ class LedgerLoad_test : public beast::unit_test::suite // create a new env with the ledger "latest" specified for startup Env env( *this, - envconfig(ledgerConfig, sd.dbPath, "latest", Config::LOAD, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, "latest", StartUpType::LOAD, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -281,7 +281,7 @@ class LedgerLoad_test : public beast::unit_test::suite // create a new env with specific ledger index at startup Env env( *this, - envconfig(ledgerConfig, sd.dbPath, "43", Config::LOAD, std::nullopt), + envconfig(ledgerConfig, sd.dbPath, "43", StartUpType::LOAD, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index 598949f662..5b7e34ad5b 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -1,15 +1,15 @@ #include -#include -#include #include -#include #include #include #include #include #include +#include +#include +#include #include #include diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index fac8a4bb7e..c688b2661f 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -1,12 +1,12 @@ #include -#include #include #include #include #include #include +#include #include diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index 001022aa95..fe73d42b0a 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -1,9 +1,8 @@ #include -#include - #include #include +#include #include #include diff --git a/src/test/nodestore/Database_test.cpp b/src/test/nodestore/Database_test.cpp index 03f0c11990..1229923e7d 100644 --- a/src/test/nodestore/Database_test.cpp +++ b/src/test/nodestore/Database_test.cpp @@ -4,11 +4,10 @@ #include #include -#include - #include #include #include +#include namespace xrpl { diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index aa959629b1..5d12e7bb83 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -2050,7 +2050,7 @@ class LedgerEntry_test : public beast::unit_test::suite Account const bob{"bob"}; Env env{*this, envconfig([](auto cfg) { - cfg->START_UP = Config::FRESH; + cfg->START_UP = StartUpType::FRESH; return cfg; })}; @@ -2241,7 +2241,7 @@ class LedgerEntry_test : public beast::unit_test::suite Account const bob{"bob"}; Env env{*this, envconfig([](auto cfg) { - cfg->START_UP = Config::FRESH; + cfg->START_UP = StartUpType::FRESH; return cfg; })}; diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 9ad08f9894..0f1b81d53d 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 2c0d3c2b82..5f7a86e2c2 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -26,11 +25,8 @@ #include #include #include -#include #include -#include #include -#include #include #include #include @@ -40,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -49,7 +46,9 @@ #include #include #include +#include #include +#include #include #include @@ -1021,6 +1020,12 @@ private: void setMaxDisallowedLedger(); + + Application& + app() override + { + return *this; + } }; //------------------------------------------------------------------------------ @@ -1116,18 +1121,21 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) auto const startUp = config_->START_UP; JLOG(m_journal.debug()) << "startUp: " << startUp; - if (startUp == Config::FRESH) + if (startUp == StartUpType::FRESH) { JLOG(m_journal.info()) << "Starting new Ledger"; startGenesisLedger(); } - else if (startUp == Config::LOAD || startUp == Config::LOAD_FILE || startUp == Config::REPLAY) + else if (startUp == StartUpType::LOAD || startUp == StartUpType::LOAD_FILE || startUp == StartUpType::REPLAY) { JLOG(m_journal.info()) << "Loading specified Ledger"; if (!loadOldLedger( - config_->START_LEDGER, startUp == Config::REPLAY, startUp == Config::LOAD_FILE, config_->TRAP_TX_HASH)) + config_->START_LEDGER, + startUp == StartUpType::REPLAY, + startUp == StartUpType::LOAD_FILE, + config_->TRAP_TX_HASH)) { JLOG(m_journal.error()) << "The specified ledger could not be loaded."; if (config_->FAST_LOAD) @@ -1142,7 +1150,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) } } } - else if (startUp == Config::NETWORK) + else if (startUp == StartUpType::NETWORK) { // This should probably become the default once we have a stable // network. @@ -1529,7 +1537,7 @@ void ApplicationImp::startGenesisLedger() { std::vector const initialAmendments = - (config_->START_UP == Config::FRESH) ? m_amendmentTable->getDesired() : std::vector{}; + (config_->START_UP == StartUpType::FRESH) ? m_amendmentTable->getDesired() : std::vector{}; std::shared_ptr const genesis = std::make_shared(create_genesis, *config_, initialAmendments, nodeFamily_); diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 53cc264ad4..5ecc84c11c 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -1,10 +1,10 @@ #pragma once #include -#include #include #include +#include #include #include #include @@ -112,8 +112,6 @@ public: public: Application(); - virtual ~Application() = default; - virtual bool setup(boost::program_options::variables_map const& options) = 0; @@ -127,8 +125,6 @@ public: checkSigs() const = 0; virtual void checkSigs(bool) = 0; - virtual bool - isStopping() const = 0; // // --- @@ -138,14 +134,9 @@ public: virtual std::uint64_t instanceID() const = 0; - virtual Logs& - logs() = 0; virtual Config& config() = 0; - virtual boost::asio::io_context& - getIOContext() = 0; - virtual std::pair const& nodeIdentity() = 0; @@ -158,9 +149,6 @@ public: virtual bool serverOkay(std::string& reason) = 0; - virtual beast::Journal - journal(std::string const& name) = 0; - /* Returns the number of file descriptors the application needs */ virtual int fdRequired() const = 0; diff --git a/src/xrpld/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp index aaf7af95ab..7bdccd12a7 100644 --- a/src/xrpld/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -8,6 +7,7 @@ #include #include #include +#include #include #include @@ -601,7 +601,7 @@ run(int argc, char** argv) if (vm.count("start")) { - config->START_UP = Config::FRESH; + config->START_UP = StartUpType::FRESH; } if (vm.count("import")) @@ -612,7 +612,7 @@ run(int argc, char** argv) config->START_LEDGER = vm["ledger"].as(); if (vm.count("replay")) { - config->START_UP = Config::REPLAY; + config->START_UP = StartUpType::REPLAY; if (vm.count("trap_tx_hash")) { uint256 tmp = {}; @@ -631,16 +631,16 @@ run(int argc, char** argv) } } else - config->START_UP = Config::LOAD; + config->START_UP = StartUpType::LOAD; } else if (vm.count("ledgerfile")) { config->START_LEDGER = vm["ledgerfile"].as(); - config->START_UP = Config::LOAD_FILE; + config->START_UP = StartUpType::LOAD_FILE; } else if (vm.count("load") || config->FAST_LOAD) { - config->START_UP = Config::LOAD; + config->START_UP = StartUpType::LOAD; } if (vm.count("trap_tx_hash") && vm.count("replay") == 0) @@ -651,13 +651,13 @@ run(int argc, char** argv) if (vm.count("net") && !config->FAST_LOAD) { - if ((config->START_UP == Config::LOAD) || (config->START_UP == Config::REPLAY)) + if ((config->START_UP == StartUpType::LOAD) || (config->START_UP == StartUpType::REPLAY)) { std::cerr << "Net and load/replay options are incompatible" << std::endl; return -1; } - config->START_UP = Config::NETWORK; + config->START_UP = StartUpType::NETWORK; } if (vm.count("valid")) diff --git a/src/xrpld/app/main/NodeIdentity.cpp b/src/xrpld/app/main/NodeIdentity.cpp index b585b80b5b..3019caeb31 100644 --- a/src/xrpld/app/main/NodeIdentity.cpp +++ b/src/xrpld/app/main/NodeIdentity.cpp @@ -1,9 +1,10 @@ #include #include -#include #include #include +#include + namespace xrpl { std::pair diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index dbdd682ef8..7f276ca2d8 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -1,13 +1,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/SHAMapStoreImp.h b/src/xrpld/app/misc/SHAMapStoreImp.h index b046a78979..df3c16b24f 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.h +++ b/src/xrpld/app/misc/SHAMapStoreImp.h @@ -2,11 +2,11 @@ #include #include -#include -#include #include #include +#include +#include #include #include diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index 4fd610be04..f93ac8a32f 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index 2942c8bde6..3addfd2235 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -1,12 +1,12 @@ #include #include -#include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp index 952814656b..dfcbdbb3ad 100644 --- a/src/xrpld/app/misc/detail/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -1,13 +1,12 @@ -#include -#include -#include - #include #include #include #include #include #include +#include +#include +#include #include diff --git a/src/xrpld/app/misc/detail/ValidatorKeys.cpp b/src/xrpld/app/misc/detail/ValidatorKeys.cpp index 675ce4ac6f..8f24f14b40 100644 --- a/src/xrpld/app/misc/detail/ValidatorKeys.cpp +++ b/src/xrpld/app/misc/detail/ValidatorKeys.cpp @@ -1,10 +1,10 @@ -#include #include #include #include #include #include +#include namespace xrpl { ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j) diff --git a/src/xrpld/app/rdb/PeerFinder.h b/src/xrpld/app/rdb/PeerFinder.h index 2b4080255f..e5ac6dda8c 100644 --- a/src/xrpld/app/rdb/PeerFinder.h +++ b/src/xrpld/app/rdb/PeerFinder.h @@ -1,9 +1,10 @@ #pragma once #include -#include #include +#include + namespace xrpl { /** diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h index c0cc61f757..078b8fe8db 100644 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ b/src/xrpld/app/rdb/RelationalDatabase.h @@ -1,13 +1,13 @@ #pragma once #include -#include #include #include -#include #include #include +#include +#include #include #include @@ -93,13 +93,13 @@ public: /** * @brief init Creates and returns an appropriate RelationalDatabase * instance based on configuration. - * @param app Application object. + * @param registry The service registry. * @param config Config object. * @param jobQueue JobQueue object. * @return Unique pointer to the interface. */ static std::unique_ptr - init(Application& app, Config const& config, JobQueue& jobQueue); + init(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); virtual ~RelationalDatabase() = default; diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 90c95f3a2d..1e814c3589 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -5,12 +5,12 @@ #include #include #include -#include -#include #include #include #include +#include +#include #include @@ -64,8 +64,8 @@ makeLedgerDBs( tx->getSession() << boost::str( boost::format("PRAGMA cache_size=-%d;") % kilobytes(config.getValueFor(SizedItem::txnDBCache))); - if (!setup.standAlone || setup.startUp == Config::LOAD || setup.startUp == Config::LOAD_FILE || - setup.startUp == Config::REPLAY) + if (!setup.standAlone || setup.startUp == StartUpType::LOAD || setup.startUp == StartUpType::LOAD_FILE || + setup.startUp == StartUpType::REPLAY) { // Check if AccountTransactions has primary key std::string cid, name, type; diff --git a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp index d65b12dc7f..4f1430ee4c 100644 --- a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp +++ b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp @@ -3,21 +3,21 @@ #include #include #include -#include -#include #include +#include +#include namespace xrpl { class SQLiteDatabaseImp final : public SQLiteDatabase { public: - SQLiteDatabaseImp(Application& app, Config const& config, JobQueue& jobQueue) - : app_(app), useTxTables_(config.useTxTables()), j_(app_.journal("SQLiteDatabaseImp")) + SQLiteDatabaseImp(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) + : registry_(registry), useTxTables_(config.useTxTables()), j_(registry.journal("SQLiteDatabaseImp")) { DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_); - if (!makeLedgerDBs(config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, &app_.logs()})) + if (!makeLedgerDBs(config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, ®istry_.logs()})) { std::string_view constexpr error = "Failed to create ledger databases"; @@ -139,7 +139,7 @@ public: closeTransactionDB() override; private: - Application& app_; + ServiceRegistry& registry_; bool const useTxTables_; beast::Journal j_; std::unique_ptr ledgerDb_, txdb_; @@ -370,7 +370,7 @@ SQLiteDatabaseImp::saveValidatedLedger(std::shared_ptr const& ledg { if (existsLedger()) { - if (!detail::saveValidatedLedger(*ledgerDb_, txdb_, app_, ledger, current)) + if (!detail::saveValidatedLedger(*ledgerDb_, txdb_, registry_.app(), ledger, current)) return false; } @@ -506,7 +506,7 @@ SQLiteDatabaseImp::getTxHistory(LedgerIndex startIndex) if (existsTransaction()) { auto db = checkoutTransaction(); - auto const res = detail::getTxHistory(*db, app_, startIndex, 20).first; + auto const res = detail::getTxHistory(*db, registry_.app(), startIndex, 20).first; if (!res.empty()) return res; @@ -521,12 +521,12 @@ SQLiteDatabaseImp::getOldestAccountTxs(AccountTxOptions const& options) if (!useTxTables_) return {}; - LedgerMaster& ledgerMaster = app_.getLedgerMaster(); + LedgerMaster& ledgerMaster = registry_.getLedgerMaster(); if (existsTransaction()) { auto db = checkoutTransaction(); - return detail::getOldestAccountTxs(*db, app_, ledgerMaster, options, j_).first; + return detail::getOldestAccountTxs(*db, registry_.app(), ledgerMaster, options, j_).first; } return {}; @@ -538,12 +538,12 @@ SQLiteDatabaseImp::getNewestAccountTxs(AccountTxOptions const& options) if (!useTxTables_) return {}; - LedgerMaster& ledgerMaster = app_.getLedgerMaster(); + LedgerMaster& ledgerMaster = registry_.getLedgerMaster(); if (existsTransaction()) { auto db = checkoutTransaction(); - return detail::getNewestAccountTxs(*db, app_, ledgerMaster, options, j_).first; + return detail::getNewestAccountTxs(*db, registry_.app(), ledgerMaster, options, j_).first; } return {}; @@ -558,7 +558,7 @@ SQLiteDatabaseImp::getOldestAccountTxsB(AccountTxOptions const& options) if (existsTransaction()) { auto db = checkoutTransaction(); - return detail::getOldestAccountTxsB(*db, app_, options, j_).first; + return detail::getOldestAccountTxsB(*db, registry_.app(), options, j_).first; } return {}; @@ -573,7 +573,7 @@ SQLiteDatabaseImp::getNewestAccountTxsB(AccountTxOptions const& options) if (existsTransaction()) { auto db = checkoutTransaction(); - return detail::getNewestAccountTxsB(*db, app_, options, j_).first; + return detail::getNewestAccountTxsB(*db, registry_.app(), options, j_).first; } return {}; @@ -586,10 +586,9 @@ SQLiteDatabaseImp::oldestAccountTxPage(AccountTxPageOptions const& options) return {}; static std::uint32_t const page_length(200); - auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1); + auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1); AccountTxs ret; - Application& app = app_; - auto onTransaction = [&ret, &app]( + auto onTransaction = [&ret, &app = registry_.app()]( std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) { convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app); }; @@ -611,10 +610,9 @@ SQLiteDatabaseImp::newestAccountTxPage(AccountTxPageOptions const& options) return {}; static std::uint32_t const page_length(200); - auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1); + auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1); AccountTxs ret; - Application& app = app_; - auto onTransaction = [&ret, &app]( + auto onTransaction = [&ret, &app = registry_.app()]( std::uint32_t ledger_index, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) { convertBlobsToTxResult(ret, ledger_index, status, rawTxn, rawMeta, app); }; @@ -636,7 +634,7 @@ SQLiteDatabaseImp::oldestAccountTxPageB(AccountTxPageOptions const& options) return {}; static std::uint32_t const page_length(500); - auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1); + auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1); MetaTxsList ret; auto onTransaction = [&ret](std::uint32_t ledgerIndex, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) { ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex); @@ -659,7 +657,7 @@ SQLiteDatabaseImp::newestAccountTxPageB(AccountTxPageOptions const& options) return {}; static std::uint32_t const page_length(500); - auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(app_), std::placeholders::_1); + auto onUnsavedLedger = std::bind(saveLedgerAsync, std::ref(registry_.app()), std::placeholders::_1); MetaTxsList ret; auto onTransaction = [&ret](std::uint32_t ledgerIndex, std::string const& status, Blob&& rawTxn, Blob&& rawMeta) { ret.emplace_back(std::move(rawTxn), std::move(rawMeta), ledgerIndex); @@ -687,7 +685,7 @@ SQLiteDatabaseImp::getTransaction( if (existsTransaction()) { auto db = checkoutTransaction(); - return detail::getTransaction(*db, app_, id, range, ec); + return detail::getTransaction(*db, registry_.app(), id, range, ec); } return TxSearched::unknown; @@ -769,9 +767,9 @@ SQLiteDatabaseImp::closeTransactionDB() } std::unique_ptr -getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue) +getSQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) { - return std::make_unique(app, config, jobQueue); + return std::make_unique(registry, config, jobQueue); } } // namespace xrpl diff --git a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp index 2ceb15d1e7..bc65a817a4 100644 --- a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp +++ b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp @@ -1,14 +1,13 @@ -#include #include #include namespace xrpl { extern std::unique_ptr -getSQLiteDatabase(Application& app, Config const& config, JobQueue& jobQueue); +getSQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); std::unique_ptr -RelationalDatabase::init(Application& app, Config const& config, JobQueue& jobQueue) +RelationalDatabase::init(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) { bool use_sqlite = false; @@ -31,7 +30,7 @@ RelationalDatabase::init(Application& app, Config const& config, JobQueue& jobQu if (use_sqlite) { - return getSQLiteDatabase(app, config, jobQueue); + return getSQLiteDatabase(registry, config, jobQueue); } return std::unique_ptr(); diff --git a/src/xrpld/core/Config.h b/src/xrpld/core/Config.h index 86b663a212..c40d13c83a 100644 --- a/src/xrpld/core/Config.h +++ b/src/xrpld/core/Config.h @@ -4,7 +4,9 @@ #include #include #include +#include #include // VFALCO Breaks levelization +#include #include // VFALCO FIX: This include should not be here @@ -124,8 +126,7 @@ public: // Entries from [ips_fixed] config stanza std::vector IPS_FIXED; - enum StartUpType { FRESH, NORMAL, LOAD, LOAD_FILE, REPLAY, NETWORK }; - StartUpType START_UP = NORMAL; + StartUpType START_UP = StartUpType::NORMAL; bool START_VALID = false; @@ -355,4 +356,7 @@ public: FeeSetup setup_FeeVote(Section const& section); +DatabaseCon::Setup +setup_DatabaseCon(Config const& c, std::optional j = std::nullopt); + } // namespace xrpl diff --git a/src/xrpld/core/detail/Config.cpp b/src/xrpld/core/detail/Config.cpp index 0a60416af7..4a2bae7c27 100644 --- a/src/xrpld/core/detail/Config.cpp +++ b/src/xrpld/core/detail/Config.cpp @@ -1039,4 +1039,150 @@ setup_FeeVote(Section const& section) return setup; } +DatabaseCon::Setup +setup_DatabaseCon(Config const& c, std::optional j) +{ + DatabaseCon::Setup setup; + + setup.startUp = c.START_UP; + setup.standAlone = c.standalone(); + setup.dataDir = c.legacy("database_path"); + if (!setup.standAlone && setup.dataDir.empty()) + { + Throw("database_path must be set."); + } + + if (!setup.globalPragma) + { + auto const& sqlite = c.section("sqlite"); + auto result = std::make_unique>(); + result->reserve(3); + + // defaults + std::string safety_level; + std::string journal_mode = "wal"; + std::string synchronous = "normal"; + std::string temp_store = "file"; + bool showRiskWarning = false; + + if (set(safety_level, "safety_level", sqlite)) + { + if (boost::iequals(safety_level, "low")) + { + // low safety defaults + journal_mode = "memory"; + synchronous = "off"; + temp_store = "memory"; + showRiskWarning = true; + } + else if (!boost::iequals(safety_level, "high")) + { + Throw("Invalid safety_level value: " + safety_level); + } + } + + { + // #journal_mode Valid values : delete, truncate, persist, + // memory, wal, off + if (set(journal_mode, "journal_mode", sqlite) && !safety_level.empty()) + { + Throw( + "Configuration file may not define both " + "\"safety_level\" and \"journal_mode\""); + } + bool higherRisk = boost::iequals(journal_mode, "memory") || boost::iequals(journal_mode, "off"); + showRiskWarning = showRiskWarning || higherRisk; + if (higherRisk || boost::iequals(journal_mode, "delete") || boost::iequals(journal_mode, "truncate") || + boost::iequals(journal_mode, "persist") || boost::iequals(journal_mode, "wal")) + { + result->emplace_back(boost::str(boost::format(CommonDBPragmaJournal) % journal_mode)); + } + else + { + Throw("Invalid journal_mode value: " + journal_mode); + } + } + + { + // #synchronous Valid values : off, normal, full, extra + if (set(synchronous, "synchronous", sqlite) && !safety_level.empty()) + { + Throw( + "Configuration file may not define both " + "\"safety_level\" and \"synchronous\""); + } + bool higherRisk = boost::iequals(synchronous, "off"); + showRiskWarning = showRiskWarning || higherRisk; + if (higherRisk || boost::iequals(synchronous, "normal") || boost::iequals(synchronous, "full") || + boost::iequals(synchronous, "extra")) + { + result->emplace_back(boost::str(boost::format(CommonDBPragmaSync) % synchronous)); + } + else + { + Throw("Invalid synchronous value: " + synchronous); + } + } + + { + // #temp_store Valid values : default, file, memory + if (set(temp_store, "temp_store", sqlite) && !safety_level.empty()) + { + Throw( + "Configuration file may not define both " + "\"safety_level\" and \"temp_store\""); + } + bool higherRisk = boost::iequals(temp_store, "memory"); + showRiskWarning = showRiskWarning || higherRisk; + if (higherRisk || boost::iequals(temp_store, "default") || boost::iequals(temp_store, "file")) + { + result->emplace_back(boost::str(boost::format(CommonDBPragmaTemp) % temp_store)); + } + else + { + Throw("Invalid temp_store value: " + temp_store); + } + } + + if (showRiskWarning && j && c.LEDGER_HISTORY > SQLITE_TUNING_CUTOFF) + { + JLOG(j->warn()) << "reducing the data integrity guarantees from the " + "default [sqlite] behavior is not recommended for " + "nodes storing large amounts of history, because of the " + "difficulty inherent in rebuilding corrupted data."; + } + XRPL_ASSERT(result->size() == 3, "xrpl::setup_DatabaseCon::globalPragma : result size is 3"); + setup.globalPragma = std::move(result); + } + setup.useGlobalPragma = true; + + auto setPragma = [](std::string& pragma, std::string const& key, int64_t value) { + pragma = "PRAGMA " + key + "=" + std::to_string(value) + ";"; + }; + + // Lgr Pragma + setPragma(setup.lgrPragma[0], "journal_size_limit", 1582080); + + // TX Pragma + int64_t page_size = 4096; + int64_t journal_size_limit = 1582080; + if (c.exists("sqlite")) + { + auto& s = c.section("sqlite"); + set(journal_size_limit, "journal_size_limit", s); + set(page_size, "page_size", s); + if (page_size < 512 || page_size > 65536) + Throw("Invalid page_size. Must be between 512 and 65536."); + + if (page_size & (page_size - 1)) + Throw("Invalid page_size. Must be a power of 2."); + } + + setPragma(setup.txPragma[0], "page_size", page_size); + setPragma(setup.txPragma[1], "journal_size_limit", journal_size_limit); + setPragma(setup.txPragma[2], "max_page_count", 4294967294); + setPragma(setup.txPragma[3], "mmap_size", 17179869184); + + return setup; +} } // namespace xrpl diff --git a/src/xrpld/core/detail/DatabaseCon.cpp b/src/xrpld/core/detail/DatabaseCon.cpp deleted file mode 100644 index 64f87f7a39..0000000000 --- a/src/xrpld/core/detail/DatabaseCon.cpp +++ /dev/null @@ -1,242 +0,0 @@ -#include -#include - -#include -#include - -#include -#include - -#include -#include - -namespace xrpl { - -class CheckpointersCollection -{ - std::uintptr_t nextId_{0}; - // Mutex protects the CheckpointersCollection - std::mutex mutex_; - // Each checkpointer is given a unique id. All the checkpointers that are - // part of a DatabaseCon are part of this collection. When the DatabaseCon - // is destroyed, its checkpointer is removed from the collection - std::unordered_map> checkpointers_; - -public: - std::shared_ptr - fromId(std::uintptr_t id) - { - std::lock_guard l{mutex_}; - auto it = checkpointers_.find(id); - if (it != checkpointers_.end()) - return it->second; - return {}; - } - - void - erase(std::uintptr_t id) - { - std::lock_guard lock{mutex_}; - checkpointers_.erase(id); - } - - std::shared_ptr - create(std::shared_ptr const& session, JobQueue& jobQueue, Logs& logs) - { - std::lock_guard lock{mutex_}; - auto const id = nextId_++; - auto const r = makeCheckpointer(id, session, jobQueue, logs); - checkpointers_[id] = r; - return r; - } -}; - -CheckpointersCollection checkpointers; - -std::shared_ptr -checkpointerFromId(std::uintptr_t id) -{ - return checkpointers.fromId(id); -} - -DatabaseCon::~DatabaseCon() -{ - if (checkpointer_) - { - checkpointers.erase(checkpointer_->id()); - - std::weak_ptr wk(checkpointer_); - checkpointer_.reset(); - - // The references to our Checkpointer held by 'checkpointer_' and - // 'checkpointers' have been removed, so if the use count is nonzero, a - // checkpoint is currently in progress. Wait for it to end, otherwise - // creating a new DatabaseCon to the same database may fail due to the - // database being locked by our (now old) Checkpointer. - while (wk.use_count()) - { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - } - } -} - -DatabaseCon::Setup -setup_DatabaseCon(Config const& c, std::optional j) -{ - DatabaseCon::Setup setup; - - setup.startUp = c.START_UP; - setup.standAlone = c.standalone(); - setup.dataDir = c.legacy("database_path"); - if (!setup.standAlone && setup.dataDir.empty()) - { - Throw("database_path must be set."); - } - - if (!setup.globalPragma) - { - setup.globalPragma = [&c, &j]() { - auto const& sqlite = c.section("sqlite"); - auto result = std::make_unique>(); - result->reserve(3); - - // defaults - std::string safety_level; - std::string journal_mode = "wal"; - std::string synchronous = "normal"; - std::string temp_store = "file"; - bool showRiskWarning = false; - - if (set(safety_level, "safety_level", sqlite)) - { - if (boost::iequals(safety_level, "low")) - { - // low safety defaults - journal_mode = "memory"; - synchronous = "off"; - temp_store = "memory"; - showRiskWarning = true; - } - else if (!boost::iequals(safety_level, "high")) - { - Throw("Invalid safety_level value: " + safety_level); - } - } - - { - // #journal_mode Valid values : delete, truncate, persist, - // memory, wal, off - if (set(journal_mode, "journal_mode", sqlite) && !safety_level.empty()) - { - Throw( - "Configuration file may not define both " - "\"safety_level\" and \"journal_mode\""); - } - bool higherRisk = boost::iequals(journal_mode, "memory") || boost::iequals(journal_mode, "off"); - showRiskWarning = showRiskWarning || higherRisk; - if (higherRisk || boost::iequals(journal_mode, "delete") || boost::iequals(journal_mode, "truncate") || - boost::iequals(journal_mode, "persist") || boost::iequals(journal_mode, "wal")) - { - result->emplace_back(boost::str(boost::format(CommonDBPragmaJournal) % journal_mode)); - } - else - { - Throw("Invalid journal_mode value: " + journal_mode); - } - } - - { - // #synchronous Valid values : off, normal, full, extra - if (set(synchronous, "synchronous", sqlite) && !safety_level.empty()) - { - Throw( - "Configuration file may not define both " - "\"safety_level\" and \"synchronous\""); - } - bool higherRisk = boost::iequals(synchronous, "off"); - showRiskWarning = showRiskWarning || higherRisk; - if (higherRisk || boost::iequals(synchronous, "normal") || boost::iequals(synchronous, "full") || - boost::iequals(synchronous, "extra")) - { - result->emplace_back(boost::str(boost::format(CommonDBPragmaSync) % synchronous)); - } - else - { - Throw("Invalid synchronous value: " + synchronous); - } - } - - { - // #temp_store Valid values : default, file, memory - if (set(temp_store, "temp_store", sqlite) && !safety_level.empty()) - { - Throw( - "Configuration file may not define both " - "\"safety_level\" and \"temp_store\""); - } - bool higherRisk = boost::iequals(temp_store, "memory"); - showRiskWarning = showRiskWarning || higherRisk; - if (higherRisk || boost::iequals(temp_store, "default") || boost::iequals(temp_store, "file")) - { - result->emplace_back(boost::str(boost::format(CommonDBPragmaTemp) % temp_store)); - } - else - { - Throw("Invalid temp_store value: " + temp_store); - } - } - - if (showRiskWarning && j && c.LEDGER_HISTORY > SQLITE_TUNING_CUTOFF) - { - JLOG(j->warn()) << "reducing the data integrity guarantees from the " - "default [sqlite] behavior is not recommended for " - "nodes storing large amounts of history, because of the " - "difficulty inherent in rebuilding corrupted data."; - } - XRPL_ASSERT(result->size() == 3, "xrpl::setup_DatabaseCon::globalPragma : result size is 3"); - return result; - }(); - } - setup.useGlobalPragma = true; - - auto setPragma = [](std::string& pragma, std::string const& key, int64_t value) { - pragma = "PRAGMA " + key + "=" + std::to_string(value) + ";"; - }; - - // Lgr Pragma - setPragma(setup.lgrPragma[0], "journal_size_limit", 1582080); - - // TX Pragma - int64_t page_size = 4096; - int64_t journal_size_limit = 1582080; - if (c.exists("sqlite")) - { - auto& s = c.section("sqlite"); - set(journal_size_limit, "journal_size_limit", s); - set(page_size, "page_size", s); - if (page_size < 512 || page_size > 65536) - Throw("Invalid page_size. Must be between 512 and 65536."); - - if (page_size & (page_size - 1)) - Throw("Invalid page_size. Must be a power of 2."); - } - - setPragma(setup.txPragma[0], "page_size", page_size); - setPragma(setup.txPragma[1], "journal_size_limit", journal_size_limit); - setPragma(setup.txPragma[2], "max_page_count", 4294967294); - setPragma(setup.txPragma[3], "mmap_size", 17179869184); - - return setup; -} - -std::unique_ptr const> DatabaseCon::Setup::globalPragma; - -void -DatabaseCon::setupCheckpointing(JobQueue* q, Logs& l) -{ - if (!q) - Throw("No JobQueue"); - checkpointer_ = checkpointers.create(session_, *q, l); -} - -} // namespace xrpl diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 350631b8e6..6ac6e454d2 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/overlay/detail/PeerReservationTable.cpp b/src/xrpld/overlay/detail/PeerReservationTable.cpp index 1e3452ca17..27d9df1129 100644 --- a/src/xrpld/overlay/detail/PeerReservationTable.cpp +++ b/src/xrpld/overlay/detail/PeerReservationTable.cpp @@ -1,10 +1,10 @@ #include -#include -#include +#include #include #include #include +#include #include #include diff --git a/src/xrpld/peerfinder/detail/StoreSqdb.h b/src/xrpld/peerfinder/detail/StoreSqdb.h index f5461d489a..b945ae970b 100644 --- a/src/xrpld/peerfinder/detail/StoreSqdb.h +++ b/src/xrpld/peerfinder/detail/StoreSqdb.h @@ -1,9 +1,10 @@ #pragma once #include -#include #include +#include + namespace xrpl { namespace PeerFinder { diff --git a/src/xrpld/rpc/InfoSub.h b/src/xrpld/rpc/InfoSub.h index 7d4d4f06c8..d49e401bd3 100644 --- a/src/xrpld/rpc/InfoSub.h +++ b/src/xrpld/rpc/InfoSub.h @@ -1,12 +1,11 @@ #pragma once -#include - #include #include #include #include #include +#include namespace xrpl { From 9f17d103480182c785ee4f76458728cb987f1178 Mon Sep 17 00:00:00 2001 From: Jingchen Date: Wed, 11 Feb 2026 16:22:01 +0000 Subject: [PATCH 09/16] refactor: Modularize RelationalDB (#6224) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The rdb module was not properly designed, which is fixed in this change. The module had three classes: 1) The abstract class `RelationalDB`. 2) The abstract class `SQLiteDatabase`, which inherited from `RelationalDB` and added some pure virtual methods. 3) The concrete class `SQLiteDatabaseImp`, which inherited from `SQLiteDatabase` and implemented all methods. The updated code simplifies this as follows: * The `SQLiteDatabaseImp` has become `SQLiteDatabase`, and * The former `SQLiteDatabase `has merged with `RelationalDatabase`. --- .../scripts/levelization/results/ordering.txt | 3 + include/xrpl/protocol/LedgerShortcut.h | 22 + include/xrpl/protocol/TxSearched.h | 7 + include/xrpl/rdb/RelationalDatabase.h | 475 ++++++++++++++++++ src/test/app/SHAMapStore_test.cpp | 8 +- src/test/rpc/Transaction_test.cpp | 6 +- src/xrpld/app/ledger/Ledger.cpp | 8 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 2 +- src/xrpld/app/main/Application.cpp | 13 +- src/xrpld/app/misc/SHAMapStoreImp.cpp | 17 +- src/xrpld/app/misc/Transaction.h | 3 +- src/xrpld/app/misc/detail/AccountTxPaging.h | 2 +- src/xrpld/app/misc/detail/Transaction.cpp | 11 +- src/xrpld/app/rdb/RelationalDatabase.h | 226 --------- src/xrpld/app/rdb/backend/SQLiteDatabase.h | 298 +++++++++-- src/xrpld/app/rdb/backend/detail/Node.cpp | 2 +- src/xrpld/app/rdb/backend/detail/Node.h | 3 +- .../app/rdb/backend/detail/SQLiteDatabase.cpp | 296 +++-------- .../app/rdb/detail/RelationalDatabase.cpp | 39 -- src/xrpld/overlay/detail/OverlayImpl.cpp | 2 +- .../overlay/detail/PeerReservationTable.cpp | 3 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 2 +- src/xrpld/rpc/detail/RPCLedgerHelpers.h | 3 +- src/xrpld/rpc/handlers/AccountTx.cpp | 16 +- src/xrpld/rpc/handlers/GetCounts.cpp | 11 +- src/xrpld/rpc/handlers/Tx.cpp | 3 +- src/xrpld/rpc/handlers/TxHistory.cpp | 2 +- 27 files changed, 862 insertions(+), 621 deletions(-) create mode 100644 include/xrpl/protocol/LedgerShortcut.h create mode 100644 include/xrpl/protocol/TxSearched.h create mode 100644 include/xrpl/rdb/RelationalDatabase.h delete mode 100644 src/xrpld/app/rdb/RelationalDatabase.h diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index fabc7b49ca..85f2457ea3 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -171,6 +171,7 @@ xrpl.protocol > xrpl.basics xrpl.protocol > xrpl.json xrpl.rdb > xrpl.basics xrpl.rdb > xrpl.core +xrpl.rdb > xrpl.protocol xrpl.resource > xrpl.basics xrpl.resource > xrpl.json xrpl.resource > xrpl.protocol @@ -214,6 +215,7 @@ xrpld.overlay > xrpld.core xrpld.overlay > xrpld.peerfinder xrpld.overlay > xrpl.json xrpld.overlay > xrpl.protocol +xrpld.overlay > xrpl.rdb xrpld.overlay > xrpl.resource xrpld.overlay > xrpl.server xrpld.peerfinder > xrpl.basics @@ -232,6 +234,7 @@ xrpld.rpc > xrpl.ledger xrpld.rpc > xrpl.net xrpld.rpc > xrpl.nodestore xrpld.rpc > xrpl.protocol +xrpld.rpc > xrpl.rdb xrpld.rpc > xrpl.resource xrpld.rpc > xrpl.server xrpld.shamap > xrpl.shamap diff --git a/include/xrpl/protocol/LedgerShortcut.h b/include/xrpl/protocol/LedgerShortcut.h new file mode 100644 index 0000000000..68c31c4c3c --- /dev/null +++ b/include/xrpl/protocol/LedgerShortcut.h @@ -0,0 +1,22 @@ +#pragma once + +namespace xrpl { + +/** + * @brief Enumeration of ledger shortcuts for specifying which ledger to use. + * + * These shortcuts provide a convenient way to reference commonly used ledgers + * without needing to specify their exact hash or sequence number. + */ +enum class LedgerShortcut { + /** The current working ledger (open, not yet closed) */ + Current, + + /** The most recently closed ledger (may not be validated) */ + Closed, + + /** The most recently validated ledger */ + Validated +}; + +} // namespace xrpl diff --git a/include/xrpl/protocol/TxSearched.h b/include/xrpl/protocol/TxSearched.h new file mode 100644 index 0000000000..e085bff315 --- /dev/null +++ b/include/xrpl/protocol/TxSearched.h @@ -0,0 +1,7 @@ +#pragma once + +namespace xrpl { + +enum class TxSearched { all, some, unknown }; + +} diff --git a/include/xrpl/rdb/RelationalDatabase.h b/include/xrpl/rdb/RelationalDatabase.h new file mode 100644 index 0000000000..b80c6c8331 --- /dev/null +++ b/include/xrpl/rdb/RelationalDatabase.h @@ -0,0 +1,475 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace xrpl { + +class Transaction; +class Ledger; + +struct LedgerHashPair +{ + uint256 ledgerHash; + uint256 parentHash; +}; + +struct LedgerRange +{ + uint32_t min; + uint32_t max; +}; + +class RelationalDatabase +{ +public: + struct CountMinMax + { + std::size_t numberOfRows; + LedgerIndex minLedgerSequence; + LedgerIndex maxLedgerSequence; + }; + + struct AccountTxMarker + { + std::uint32_t ledgerSeq = 0; + std::uint32_t txnSeq = 0; + }; + + struct AccountTxOptions + { + AccountID const& account; + std::uint32_t minLedger; + std::uint32_t maxLedger; + std::uint32_t offset; + std::uint32_t limit; + bool bUnlimited; + }; + + struct AccountTxPageOptions + { + AccountID const& account; + std::uint32_t minLedger; + std::uint32_t maxLedger; + std::optional marker; + std::uint32_t limit; + bool bAdmin; + }; + + using AccountTx = std::pair, std::shared_ptr>; + using AccountTxs = std::vector; + using txnMetaLedgerType = std::tuple; + using MetaTxsList = std::vector; + + using LedgerSequence = uint32_t; + using LedgerHash = uint256; + using LedgerSpecifier = std::variant; + + struct AccountTxArgs + { + AccountID account; + std::optional ledger; + bool binary = false; + bool forward = false; + uint32_t limit = 0; + std::optional marker; + }; + + struct AccountTxResult + { + std::variant transactions; + LedgerRange ledgerRange; + uint32_t limit; + std::optional marker; + }; + + virtual ~RelationalDatabase() = default; + + /** + * @brief getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers + * table. + * @return Ledger sequence or no value if no ledgers exist. + */ + virtual std::optional + getMinLedgerSeq() = 0; + + /** + * @brief getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers + * table. + * @return Ledger sequence or none if no ledgers exist. + */ + virtual std::optional + getMaxLedgerSeq() = 0; + + /** + * @brief getLedgerInfoByIndex Returns a ledger by its sequence. + * @param ledgerSeq Ledger sequence. + * @return The ledger if found, otherwise no value. + */ + virtual std::optional + getLedgerInfoByIndex(LedgerIndex ledgerSeq) = 0; + + /** + * @brief getNewestLedgerInfo Returns the info of the newest saved ledger. + * @return Ledger info if found, otherwise no value. + */ + virtual std::optional + getNewestLedgerInfo() = 0; + + /** + * @brief getLedgerInfoByHash Returns the info of the ledger with given + * hash. + * @param ledgerHash Hash of the ledger. + * @return Ledger if found, otherwise no value. + */ + virtual std::optional + getLedgerInfoByHash(uint256 const& ledgerHash) = 0; + + /** + * @brief getHashByIndex Returns the hash of the ledger with the given + * sequence. + * @param ledgerIndex Ledger sequence. + * @return Hash of the ledger. + */ + virtual uint256 + getHashByIndex(LedgerIndex ledgerIndex) = 0; + + /** + * @brief getHashesByIndex Returns the hashes of the ledger and its parent + * as specified by the ledgerIndex. + * @param ledgerIndex Ledger sequence. + * @return Struct LedgerHashPair which contains hashes of the ledger and + * its parent. + */ + virtual std::optional + getHashesByIndex(LedgerIndex ledgerIndex) = 0; + + /** + * @brief getHashesByIndex Returns hashes of each ledger and its parent for + * all ledgers within the provided range. + * @param minSeq Minimum ledger sequence. + * @param maxSeq Maximum ledger sequence. + * @return Container that maps the sequence number of a found ledger to the + * struct LedgerHashPair which contains the hashes of the ledger and + * its parent. + */ + virtual std::map + getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) = 0; + + /** + * @brief getTxHistory Returns the 20 most recent transactions starting from + * the given number. + * @param startIndex First number of returned entry. + * @return Vector of shared pointers to transactions sorted in + * descending order by ledger sequence. + */ + virtual std::vector> + getTxHistory(LedgerIndex startIndex) = 0; + + /** + * @brief getTransactionsMinLedgerSeq Returns the minimum ledger sequence + * stored in the Transactions table. + * @return Ledger sequence or no value if no ledgers exist. + */ + virtual std::optional + getTransactionsMinLedgerSeq() = 0; + + /** + * @brief getAccountTransactionsMinLedgerSeq Returns the minimum ledger + * sequence stored in the AccountTransactions table. + * @return Ledger sequence or no value if no ledgers exist. + */ + virtual std::optional + getAccountTransactionsMinLedgerSeq() = 0; + + /** + * @brief deleteTransactionByLedgerSeq Deletes transactions from the ledger + * with the given sequence. + * @param ledgerSeq Ledger sequence. + */ + virtual void + deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) = 0; + + /** + * @brief deleteBeforeLedgerSeq Deletes all ledgers with a sequence number + * less than or equal to the given ledger sequence. + * @param ledgerSeq Ledger sequence. + */ + virtual void + deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + + /** + * @brief deleteTransactionsBeforeLedgerSeq Deletes all transactions with + * a sequence number less than or equal to the given ledger + * sequence. + * @param ledgerSeq Ledger sequence. + */ + virtual void + deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + + /** + * @brief deleteAccountTransactionsBeforeLedgerSeq Deletes all account + * transactions with a sequence number less than or equal to the + * given ledger sequence. + * @param ledgerSeq Ledger sequence. + */ + virtual void + deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + + /** + * @brief getTransactionCount Returns the number of transactions. + * @return Number of transactions. + */ + virtual std::size_t + getTransactionCount() = 0; + + /** + * @brief getAccountTransactionCount Returns the number of account + * transactions. + * @return Number of account transactions. + */ + virtual std::size_t + getAccountTransactionCount() = 0; + + /** + * @brief getLedgerCountMinMax Returns the minimum ledger sequence, + * maximum ledger sequence and total number of saved ledgers. + * @return Struct CountMinMax which contains the minimum sequence, + * maximum sequence and number of ledgers. + */ + virtual struct CountMinMax + getLedgerCountMinMax() = 0; + + /** + * @brief saveValidatedLedger Saves a ledger into the database. + * @param ledger The ledger. + * @param current True if the ledger is current. + * @return True if saving was successful. + */ + virtual bool + saveValidatedLedger(std::shared_ptr const& ledger, bool current) = 0; + + /** + * @brief getLimitedOldestLedgerInfo Returns the info of the oldest ledger + * whose sequence number is greater than or equal to the given + * sequence number. + * @param ledgerFirstIndex Minimum ledger sequence. + * @return Ledger info if found, otherwise no value. + */ + virtual std::optional + getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) = 0; + + /** + * @brief getLimitedNewestLedgerInfo Returns the info of the newest ledger + * whose sequence number is greater than or equal to the given + * sequence number. + * @param ledgerFirstIndex Minimum ledger sequence. + * @return Ledger info if found, otherwise no value. + */ + virtual std::optional + getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) = 0; + + /** + * @brief getOldestAccountTxs Returns the oldest transactions for the + * account that matches the given criteria starting from the provided + * offset. + * @param options Struct AccountTxOptions which contains the criteria to + * match: the account, ledger search range, the offset of the first + * entry to return, the number of transactions to return, a flag if + * this number is unlimited. + * @return Vector of pairs of found transactions and their metadata + * sorted in ascending order by account sequence. + */ + virtual AccountTxs + getOldestAccountTxs(AccountTxOptions const& options) = 0; + + /** + * @brief getNewestAccountTxs Returns the newest transactions for the + * account that matches the given criteria starting from the provided + * offset. + * @param options Struct AccountTxOptions which contains the criteria to + * match: the account, the ledger search range, the offset of the + * first entry to return, the number of transactions to return, a + * flag if this number unlimited. + * @return Vector of pairs of found transactions and their metadata + * sorted in descending order by account sequence. + */ + virtual AccountTxs + getNewestAccountTxs(AccountTxOptions const& options) = 0; + + /** + * @brief getOldestAccountTxsB Returns the oldest transactions in binary + * form for the account that matches the given criteria starting from + * the provided offset. + * @param options Struct AccountTxOptions which contains the criteria to + * match: the account, the ledger search range, the offset of the + * first entry to return, the number of transactions to return, a + * flag if this number unlimited. + * @return Vector of tuples of found transactions, their metadata and + * account sequences sorted in ascending order by account sequence. + */ + virtual MetaTxsList + getOldestAccountTxsB(AccountTxOptions const& options) = 0; + + /** + * @brief getNewestAccountTxsB Returns the newest transactions in binary + * form for the account that matches the given criteria starting from + * the provided offset. + * @param options Struct AccountTxOptions which contains the criteria to + * match: the account, the ledger search range, the offset of the + * first entry to return, the number of transactions to return, a + * flag if this number is unlimited. + * @return Vector of tuples of found transactions, their metadata and + * account sequences sorted in descending order by account + * sequence. + */ + virtual MetaTxsList + getNewestAccountTxsB(AccountTxOptions const& options) = 0; + + /** + * @brief oldestAccountTxPage Returns the oldest transactions for the + * account that matches the given criteria starting from the + * provided marker. + * @param options Struct AccountTxPageOptions which contains the criteria to + * match: the account, the ledger search range, the marker of first + * returned entry, the number of transactions to return, a flag if + * this number is unlimited. + * @return Vector of pairs of found transactions and their metadata + * sorted in ascending order by account sequence and a marker + * for the next search if the search was not finished. + */ + virtual std::pair> + oldestAccountTxPage(AccountTxPageOptions const& options) = 0; + + /** + * @brief newestAccountTxPage Returns the newest transactions for the + * account that matches the given criteria starting from the provided + * marker. + * @param options Struct AccountTxPageOptions which contains the criteria to + * match: the account, the ledger search range, the marker of the + * first returned entry, the number of transactions to return, a flag + * if this number unlimited. + * @return Vector of pairs of found transactions and their metadata + * sorted in descending order by account sequence and a marker + * for the next search if the search was not finished. + */ + virtual std::pair> + newestAccountTxPage(AccountTxPageOptions const& options) = 0; + + /** + * @brief oldestAccountTxPageB Returns the oldest transactions in binary + * form for the account that matches the given criteria starting from + * the provided marker. + * @param options Struct AccountTxPageOptions which contains criteria to + * match: the account, the ledger search range, the marker of the + * first returned entry, the number of transactions to return, a flag + * if this number unlimited. + * @return Vector of tuples of found transactions, their metadata and + * account sequences sorted in ascending order by account + * sequence and a marker for the next search if the search was not + * finished. + */ + virtual std::pair> + oldestAccountTxPageB(AccountTxPageOptions const& options) = 0; + + /** + * @brief newestAccountTxPageB Returns the newest transactions in binary + * form for the account that matches the given criteria starting from + * the provided marker. + * @param options Struct AccountTxPageOptions which contains the criteria to + * match: the account, the ledger search range, the marker of the + * first returned entry, the number of transactions to return, a flag + * if this number is unlimited. + * @return Vector of tuples of found transactions, their metadata and + * account sequences sorted in descending order by account + * sequence and a marker for the next search if the search was not + * finished. + */ + virtual std::pair> + newestAccountTxPageB(AccountTxPageOptions const& options) = 0; + + /** + * @brief getTransaction Returns the transaction with the given hash. If a + * range is provided but the transaction is not found, then check if + * all ledgers in the range are present in the database. + * @param id Hash of the transaction. + * @param range Range of ledgers to check, if present. + * @param ec Default error code value. + * @return Transaction and its metadata if found, otherwise TxSearched::all + * if a range is provided and all ledgers from the range are present + * in the database, TxSearched::some if a range is provided and not + * all ledgers are present, TxSearched::unknown if the range is not + * provided or a deserializing error occurred. In the last case the + * error code is returned via the ec parameter, in other cases the + * default error code is not changed. + */ + virtual std::variant + getTransaction(uint256 const& id, std::optional> const& range, error_code_i& ec) = 0; + + /** + * @brief getKBUsedAll Returns the amount of space used by all databases. + * @return Space in kilobytes. + */ + virtual uint32_t + getKBUsedAll() = 0; + + /** + * @brief getKBUsedLedger Returns the amount of space space used by the + * ledger database. + * @return Space in kilobytes. + */ + virtual uint32_t + getKBUsedLedger() = 0; + + /** + * @brief getKBUsedTransaction Returns the amount of space used by the + * transaction database. + * @return Space in kilobytes. + */ + virtual uint32_t + getKBUsedTransaction() = 0; + + /** + * @brief Closes the ledger database + */ + virtual void + closeLedgerDB() = 0; + + /** + * @brief Closes the transaction database + */ + virtual void + closeTransactionDB() = 0; +}; + +template +T +rangeCheckedCast(C c) +{ + if ((c > std::numeric_limits::max()) || (!std::numeric_limits::is_signed && c < 0) || + (std::numeric_limits::is_signed && std::numeric_limits::is_signed && + c < std::numeric_limits::lowest())) + { + // This should never happen + // LCOV_EXCL_START + UNREACHABLE("xrpl::rangeCheckedCast : domain error"); + JLOG(debugLog().error()) << "rangeCheckedCast domain error:" + << " value = " << c << " min = " << std::numeric_limits::lowest() + << " max: " << std::numeric_limits::max(); + // LCOV_EXCL_STOP + } + + return static_cast(c); +} + +} // namespace xrpl diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index c671d6fc27..9e0a971685 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -91,8 +91,7 @@ class SHAMapStore_test : public beast::unit_test::suite void ledgerCheck(jtx::Env& env, int const rows, int const first) { - auto const [actualRows, actualFirst, actualLast] = - dynamic_cast(&env.app().getRelationalDatabase())->getLedgerCountMinMax(); + auto const [actualRows, actualFirst, actualLast] = env.app().getRelationalDatabase().getLedgerCountMinMax(); BEAST_EXPECT(actualRows == rows); BEAST_EXPECT(actualFirst == first); @@ -102,14 +101,13 @@ class SHAMapStore_test : public beast::unit_test::suite void transactionCheck(jtx::Env& env, int const rows) { - BEAST_EXPECT(dynamic_cast(&env.app().getRelationalDatabase())->getTransactionCount() == rows); + BEAST_EXPECT(env.app().getRelationalDatabase().getTransactionCount() == rows); } void accountTransactionCheck(jtx::Env& env, int const rows) { - BEAST_EXPECT( - dynamic_cast(&env.app().getRelationalDatabase())->getAccountTransactionCount() == rows); + BEAST_EXPECT(env.app().getRelationalDatabase().getAccountTransactionCount() == rows); } int diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index 3b289d73ca..acc8bccf61 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -108,8 +108,7 @@ class Transaction_test : public beast::unit_test::suite auto const deletedLedger = (startLegSeq + endLegSeq) / 2; { // Remove one of the ledgers from the database directly - dynamic_cast(&env.app().getRelationalDatabase()) - ->deleteTransactionByLedgerSeq(deletedLedger); + env.app().getRelationalDatabase().deleteTransactionByLedgerSeq(deletedLedger); } for (int deltaEndSeq = 0; deltaEndSeq < 2; ++deltaEndSeq) @@ -320,8 +319,7 @@ class Transaction_test : public beast::unit_test::suite auto const deletedLedger = (startLegSeq + endLegSeq) / 2; { // Remove one of the ledgers from the database directly - dynamic_cast(&env.app().getRelationalDatabase()) - ->deleteTransactionByLedgerSeq(deletedLedger); + env.app().getRelationalDatabase().deleteTransactionByLedgerSeq(deletedLedger); } for (int deltaEndSeq = 0; deltaEndSeq < 2; ++deltaEndSeq) diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 0f1b81d53d..0f44601679 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -4,7 +4,6 @@ #include #include #include -#include #include #include @@ -22,6 +21,7 @@ #include #include #include +#include #include #include @@ -904,11 +904,9 @@ saveValidatedLedger(Application& app, std::shared_ptr const& ledge return true; } - auto const db = dynamic_cast(&app.getRelationalDatabase()); - if (!db) - Throw("Failed to get relational database"); + auto& db = app.getRelationalDatabase(); - auto const res = db->saveValidatedLedger(ledger, current); + auto const res = db.saveValidatedLedger(ledger, current); // Clients can now trust the database for // information about this ledger sequence. diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index c4299c1b63..1fd1a8a8b2 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 5f7a86e2c2..7a59d586e0 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -191,7 +191,7 @@ public: boost::asio::steady_timer sweepTimer_; boost::asio::steady_timer entropyTimer_; - std::unique_ptr mRelationalDatabase; + std::optional relationalDatabase_; std::unique_ptr mWalletDB; std::unique_ptr overlay_; std::optional trapTxID_; @@ -730,10 +730,10 @@ public: getRelationalDatabase() override { XRPL_ASSERT( - mRelationalDatabase, + relationalDatabase_, "xrpl::ApplicationImp::getRelationalDatabase : non-null " "relational database"); - return *mRelationalDatabase; + return *relationalDatabase_; } DatabaseCon& @@ -761,7 +761,7 @@ public: try { - mRelationalDatabase = RelationalDatabase::init(*this, *config_, *m_jobQueue); + relationalDatabase_.emplace(setup_RelationalDatabase(*this, *config_, *m_jobQueue)); // wallet database auto setup = setup_DatabaseCon(*config_, m_journal); @@ -872,7 +872,8 @@ public: void doSweep() { - if (!config_->standalone() && !getRelationalDatabase().transactionDbHasSpace(*config_)) + XRPL_ASSERT(relationalDatabase_, "xrpl::ApplicationImp::doSweep : non-null relational database"); + if (!config_->standalone() && !relationalDatabase_->transactionDbHasSpace(*config_)) { signalStop("Out of transaction DB space"); } diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index 7f276ca2d8..c963d18d2c 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -507,16 +507,13 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated) if (healthWait() == stopping) return; - SQLiteDatabase* const db = dynamic_cast(&app_.getRelationalDatabase()); - - if (!db) - Throw("Failed to get relational database"); + auto& db = app_.getRelationalDatabase(); clearSql( lastRotated, "Ledgers", - [db]() -> std::optional { return db->getMinLedgerSeq(); }, - [db](LedgerIndex min) -> void { db->deleteBeforeLedgerSeq(min); }); + [&db]() -> std::optional { return db.getMinLedgerSeq(); }, + [&db](LedgerIndex min) -> void { db.deleteBeforeLedgerSeq(min); }); if (healthWait() == stopping) return; @@ -526,16 +523,16 @@ SHAMapStoreImp::clearPrior(LedgerIndex lastRotated) clearSql( lastRotated, "Transactions", - [&db]() -> std::optional { return db->getTransactionsMinLedgerSeq(); }, - [&db](LedgerIndex min) -> void { db->deleteTransactionsBeforeLedgerSeq(min); }); + [&db]() -> std::optional { return db.getTransactionsMinLedgerSeq(); }, + [&db](LedgerIndex min) -> void { db.deleteTransactionsBeforeLedgerSeq(min); }); if (healthWait() == stopping) return; clearSql( lastRotated, "AccountTransactions", - [&db]() -> std::optional { return db->getAccountTransactionsMinLedgerSeq(); }, - [&db](LedgerIndex min) -> void { db->deleteAccountTransactionsBeforeLedgerSeq(min); }); + [&db]() -> std::optional { return db.getAccountTransactionsMinLedgerSeq(); }, + [&db](LedgerIndex min) -> void { db.deleteAccountTransactionsBeforeLedgerSeq(min); }); if (healthWait() == stopping) return; } diff --git a/src/xrpld/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h index 22f3e9d1fd..0a51e1c021 100644 --- a/src/xrpld/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -35,8 +36,6 @@ enum TransStatus { INCOMPLETE = 8 // needs more signatures }; -enum class TxSearched { all, some, unknown }; - // This class is for constructing and examining transactions. // Transactions are static so manipulation functions are unnecessary. class Transaction : public std::enable_shared_from_this, public CountedObject diff --git a/src/xrpld/app/misc/detail/AccountTxPaging.h b/src/xrpld/app/misc/detail/AccountTxPaging.h index 6dff5c481b..209ca67ab6 100644 --- a/src/xrpld/app/misc/detail/AccountTxPaging.h +++ b/src/xrpld/app/misc/detail/AccountTxPaging.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index 61a2a36695..8ffbc47b08 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -2,13 +2,13 @@ #include #include #include -#include #include #include #include #include #include +#include namespace xrpl { @@ -113,14 +113,9 @@ Transaction::load( std::optional> const& range, error_code_i& ec) { - auto const db = dynamic_cast(&app.getRelationalDatabase()); + auto& db = app.getRelationalDatabase(); - if (!db) - { - Throw("Failed to get relational database"); - } - - return db->getTransaction(id, range, ec); + return db.getTransaction(id, range, ec); } // options 1 to include the date of the transaction diff --git a/src/xrpld/app/rdb/RelationalDatabase.h b/src/xrpld/app/rdb/RelationalDatabase.h deleted file mode 100644 index 078b8fe8db..0000000000 --- a/src/xrpld/app/rdb/RelationalDatabase.h +++ /dev/null @@ -1,226 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -namespace xrpl { - -struct LedgerHashPair -{ - uint256 ledgerHash; - uint256 parentHash; -}; - -struct LedgerRange -{ - uint32_t min; - uint32_t max; -}; - -class RelationalDatabase -{ -public: - struct CountMinMax - { - std::size_t numberOfRows; - LedgerIndex minLedgerSequence; - LedgerIndex maxLedgerSequence; - }; - - struct AccountTxMarker - { - std::uint32_t ledgerSeq = 0; - std::uint32_t txnSeq = 0; - }; - - struct AccountTxOptions - { - AccountID const& account; - std::uint32_t minLedger; - std::uint32_t maxLedger; - std::uint32_t offset; - std::uint32_t limit; - bool bUnlimited; - }; - - struct AccountTxPageOptions - { - AccountID const& account; - std::uint32_t minLedger; - std::uint32_t maxLedger; - std::optional marker; - std::uint32_t limit; - bool bAdmin; - }; - - using AccountTx = std::pair, std::shared_ptr>; - using AccountTxs = std::vector; - using txnMetaLedgerType = std::tuple; - using MetaTxsList = std::vector; - - using LedgerSequence = uint32_t; - using LedgerHash = uint256; - using LedgerShortcut = RPC::LedgerShortcut; - using LedgerSpecifier = std::variant; - - struct AccountTxArgs - { - AccountID account; - std::optional ledger; - bool binary = false; - bool forward = false; - uint32_t limit = 0; - std::optional marker; - }; - - struct AccountTxResult - { - std::variant transactions; - LedgerRange ledgerRange; - uint32_t limit; - std::optional marker; - }; - - /** - * @brief init Creates and returns an appropriate RelationalDatabase - * instance based on configuration. - * @param registry The service registry. - * @param config Config object. - * @param jobQueue JobQueue object. - * @return Unique pointer to the interface. - */ - static std::unique_ptr - init(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); - - virtual ~RelationalDatabase() = default; - - /** - * @brief getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers - * table. - * @return Ledger sequence or no value if no ledgers exist. - */ - virtual std::optional - getMinLedgerSeq() = 0; - - /** - * @brief getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers - * table. - * @return Ledger sequence or none if no ledgers exist. - */ - virtual std::optional - getMaxLedgerSeq() = 0; - - /** - * @brief getLedgerInfoByIndex Returns a ledger by its sequence. - * @param ledgerSeq Ledger sequence. - * @return The ledger if found, otherwise no value. - */ - virtual std::optional - getLedgerInfoByIndex(LedgerIndex ledgerSeq) = 0; - - /** - * @brief getNewestLedgerInfo Returns the info of the newest saved ledger. - * @return Ledger info if found, otherwise no value. - */ - virtual std::optional - getNewestLedgerInfo() = 0; - - /** - * @brief getLedgerInfoByHash Returns the info of the ledger with given - * hash. - * @param ledgerHash Hash of the ledger. - * @return Ledger if found, otherwise no value. - */ - virtual std::optional - getLedgerInfoByHash(uint256 const& ledgerHash) = 0; - - /** - * @brief getHashByIndex Returns the hash of the ledger with the given - * sequence. - * @param ledgerIndex Ledger sequence. - * @return Hash of the ledger. - */ - virtual uint256 - getHashByIndex(LedgerIndex ledgerIndex) = 0; - - /** - * @brief getHashesByIndex Returns the hashes of the ledger and its parent - * as specified by the ledgerIndex. - * @param ledgerIndex Ledger sequence. - * @return Struct LedgerHashPair which contains hashes of the ledger and - * its parent. - */ - virtual std::optional - getHashesByIndex(LedgerIndex ledgerIndex) = 0; - - /** - * @brief getHashesByIndex Returns hashes of each ledger and its parent for - * all ledgers within the provided range. - * @param minSeq Minimum ledger sequence. - * @param maxSeq Maximum ledger sequence. - * @return Container that maps the sequence number of a found ledger to the - * struct LedgerHashPair which contains the hashes of the ledger and - * its parent. - */ - virtual std::map - getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) = 0; - - /** - * @brief getTxHistory Returns the 20 most recent transactions starting from - * the given number. - * @param startIndex First number of returned entry. - * @return Vector of shared pointers to transactions sorted in - * descending order by ledger sequence. - */ - virtual std::vector> - getTxHistory(LedgerIndex startIndex) = 0; - - /** - * @brief ledgerDbHasSpace Checks if the ledger database has available - * space. - * @param config Config object. - * @return True if space is available. - */ - virtual bool - ledgerDbHasSpace(Config const& config) = 0; - - /** - * @brief transactionDbHasSpace Checks if the transaction database has - * available space. - * @param config Config object. - * @return True if space is available. - */ - virtual bool - transactionDbHasSpace(Config const& config) = 0; -}; - -template -T -rangeCheckedCast(C c) -{ - if ((c > std::numeric_limits::max()) || (!std::numeric_limits::is_signed && c < 0) || - (std::numeric_limits::is_signed && std::numeric_limits::is_signed && - c < std::numeric_limits::lowest())) - { - // This should never happen - // LCOV_EXCL_START - UNREACHABLE("xrpl::rangeCheckedCast : domain error"); - JLOG(debugLog().error()) << "rangeCheckedCast domain error:" - << " value = " << c << " min = " << std::numeric_limits::lowest() - << " max: " << std::numeric_limits::max(); - // LCOV_EXCL_STOP - } - - return static_cast(c); -} - -} // namespace xrpl diff --git a/src/xrpld/app/rdb/backend/SQLiteDatabase.h b/src/xrpld/app/rdb/backend/SQLiteDatabase.h index b6dcb2534b..b79b66787e 100644 --- a/src/xrpld/app/rdb/backend/SQLiteDatabase.h +++ b/src/xrpld/app/rdb/backend/SQLiteDatabase.h @@ -1,43 +1,130 @@ #pragma once -#include +#include + +#include namespace xrpl { -class SQLiteDatabase : public RelationalDatabase +class Config; +class JobQueue; +class ServiceRegistry; + +class SQLiteDatabase final : public RelationalDatabase { public: + /** + * @brief getMinLedgerSeq Returns the minimum ledger sequence in the Ledgers + * table. + * @return Ledger sequence or no value if no ledgers exist. + */ + std::optional + getMinLedgerSeq() override; + + /** + * @brief getMaxLedgerSeq Returns the maximum ledger sequence in the Ledgers + * table. + * @return Ledger sequence or none if no ledgers exist. + */ + std::optional + getMaxLedgerSeq() override; + + /** + * @brief getLedgerInfoByIndex Returns a ledger by its sequence. + * @param ledgerSeq Ledger sequence. + * @return The ledger if found, otherwise no value. + */ + std::optional + getLedgerInfoByIndex(LedgerIndex ledgerSeq) override; + + /** + * @brief getNewestLedgerInfo Returns the info of the newest saved ledger. + * @return Ledger info if found, otherwise no value. + */ + std::optional + getNewestLedgerInfo() override; + + /** + * @brief getLedgerInfoByHash Returns the info of the ledger with given + * hash. + * @param ledgerHash Hash of the ledger. + * @return Ledger if found, otherwise no value. + */ + std::optional + getLedgerInfoByHash(uint256 const& ledgerHash) override; + + /** + * @brief getHashByIndex Returns the hash of the ledger with the given + * sequence. + * @param ledgerIndex Ledger sequence. + * @return Hash of the ledger. + */ + uint256 + getHashByIndex(LedgerIndex ledgerIndex) override; + + /** + * @brief getHashesByIndex Returns the hashes of the ledger and its parent + * as specified by the ledgerIndex. + * @param ledgerIndex Ledger sequence. + * @return Struct LedgerHashPair which contains hashes of the ledger and + * its parent. + */ + std::optional + getHashesByIndex(LedgerIndex ledgerIndex) override; + + /** + * @brief getHashesByIndex Returns hashes of each ledger and its parent for + * all ledgers within the provided range. + * @param minSeq Minimum ledger sequence. + * @param maxSeq Maximum ledger sequence. + * @return Container that maps the sequence number of a found ledger to the + * struct LedgerHashPair which contains the hashes of the ledger and + * its parent. + */ + std::map + getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override; + + /** + * @brief getTxHistory Returns the 20 most recent transactions starting from + * the given number. + * @param startIndex First number of returned entry. + * @return Vector of shared pointers to transactions sorted in + * descending order by ledger sequence. + */ + std::vector> + getTxHistory(LedgerIndex startIndex) override; + /** * @brief getTransactionsMinLedgerSeq Returns the minimum ledger sequence * stored in the Transactions table. * @return Ledger sequence or no value if no ledgers exist. */ - virtual std::optional - getTransactionsMinLedgerSeq() = 0; + std::optional + getTransactionsMinLedgerSeq() override; /** * @brief getAccountTransactionsMinLedgerSeq Returns the minimum ledger * sequence stored in the AccountTransactions table. * @return Ledger sequence or no value if no ledgers exist. */ - virtual std::optional - getAccountTransactionsMinLedgerSeq() = 0; + std::optional + getAccountTransactionsMinLedgerSeq() override; /** * @brief deleteTransactionByLedgerSeq Deletes transactions from the ledger * with the given sequence. * @param ledgerSeq Ledger sequence. */ - virtual void - deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) = 0; + void + deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override; /** * @brief deleteBeforeLedgerSeq Deletes all ledgers with a sequence number * less than or equal to the given ledger sequence. * @param ledgerSeq Ledger sequence. */ - virtual void - deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + void + deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override; /** * @brief deleteTransactionsBeforeLedgerSeq Deletes all transactions with @@ -45,8 +132,8 @@ public: * sequence. * @param ledgerSeq Ledger sequence. */ - virtual void - deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + void + deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override; /** * @brief deleteAccountTransactionsBeforeLedgerSeq Deletes all account @@ -54,23 +141,23 @@ public: * given ledger sequence. * @param ledgerSeq Ledger sequence. */ - virtual void - deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) = 0; + void + deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override; /** * @brief getTransactionCount Returns the number of transactions. * @return Number of transactions. */ - virtual std::size_t - getTransactionCount() = 0; + std::size_t + getTransactionCount() override; /** * @brief getAccountTransactionCount Returns the number of account * transactions. * @return Number of account transactions. */ - virtual std::size_t - getAccountTransactionCount() = 0; + std::size_t + getAccountTransactionCount() override; /** * @brief getLedgerCountMinMax Returns the minimum ledger sequence, @@ -78,8 +165,8 @@ public: * @return Struct CountMinMax which contains the minimum sequence, * maximum sequence and number of ledgers. */ - virtual struct CountMinMax - getLedgerCountMinMax() = 0; + CountMinMax + getLedgerCountMinMax() override; /** * @brief saveValidatedLedger Saves a ledger into the database. @@ -87,8 +174,8 @@ public: * @param current True if the ledger is current. * @return True if saving was successful. */ - virtual bool - saveValidatedLedger(std::shared_ptr const& ledger, bool current) = 0; + bool + saveValidatedLedger(std::shared_ptr const& ledger, bool current) override; /** * @brief getLimitedOldestLedgerInfo Returns the info of the oldest ledger @@ -97,8 +184,8 @@ public: * @param ledgerFirstIndex Minimum ledger sequence. * @return Ledger info if found, otherwise no value. */ - virtual std::optional - getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) = 0; + std::optional + getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override; /** * @brief getLimitedNewestLedgerInfo Returns the info of the newest ledger @@ -107,8 +194,8 @@ public: * @param ledgerFirstIndex Minimum ledger sequence. * @return Ledger info if found, otherwise no value. */ - virtual std::optional - getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) = 0; + std::optional + getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override; /** * @brief getOldestAccountTxs Returns the oldest transactions for the @@ -121,8 +208,8 @@ public: * @return Vector of pairs of found transactions and their metadata * sorted in ascending order by account sequence. */ - virtual AccountTxs - getOldestAccountTxs(AccountTxOptions const& options) = 0; + AccountTxs + getOldestAccountTxs(AccountTxOptions const& options) override; /** * @brief getNewestAccountTxs Returns the newest transactions for the @@ -135,8 +222,8 @@ public: * @return Vector of pairs of found transactions and their metadata * sorted in descending order by account sequence. */ - virtual AccountTxs - getNewestAccountTxs(AccountTxOptions const& options) = 0; + AccountTxs + getNewestAccountTxs(AccountTxOptions const& options) override; /** * @brief getOldestAccountTxsB Returns the oldest transactions in binary @@ -149,8 +236,8 @@ public: * @return Vector of tuples of found transactions, their metadata and * account sequences sorted in ascending order by account sequence. */ - virtual MetaTxsList - getOldestAccountTxsB(AccountTxOptions const& options) = 0; + MetaTxsList + getOldestAccountTxsB(AccountTxOptions const& options) override; /** * @brief getNewestAccountTxsB Returns the newest transactions in binary @@ -164,8 +251,8 @@ public: * account sequences sorted in descending order by account * sequence. */ - virtual MetaTxsList - getNewestAccountTxsB(AccountTxOptions const& options) = 0; + MetaTxsList + getNewestAccountTxsB(AccountTxOptions const& options) override; /** * @brief oldestAccountTxPage Returns the oldest transactions for the @@ -179,8 +266,8 @@ public: * sorted in ascending order by account sequence and a marker * for the next search if the search was not finished. */ - virtual std::pair> - oldestAccountTxPage(AccountTxPageOptions const& options) = 0; + std::pair> + oldestAccountTxPage(AccountTxPageOptions const& options) override; /** * @brief newestAccountTxPage Returns the newest transactions for the @@ -194,8 +281,8 @@ public: * sorted in descending order by account sequence and a marker * for the next search if the search was not finished. */ - virtual std::pair> - newestAccountTxPage(AccountTxPageOptions const& options) = 0; + std::pair> + newestAccountTxPage(AccountTxPageOptions const& options) override; /** * @brief oldestAccountTxPageB Returns the oldest transactions in binary @@ -210,8 +297,8 @@ public: * sequence and a marker for the next search if the search was not * finished. */ - virtual std::pair> - oldestAccountTxPageB(AccountTxPageOptions const& options) = 0; + std::pair> + oldestAccountTxPageB(AccountTxPageOptions const& options) override; /** * @brief newestAccountTxPageB Returns the newest transactions in binary @@ -226,8 +313,8 @@ public: * sequence and a marker for the next search if the search was not * finished. */ - virtual std::pair> - newestAccountTxPageB(AccountTxPageOptions const& options) = 0; + std::pair> + newestAccountTxPageB(AccountTxPageOptions const& options) override; /** * @brief getTransaction Returns the transaction with the given hash. If a @@ -244,43 +331,146 @@ public: * error code is returned via the ec parameter, in other cases the * default error code is not changed. */ - virtual std::variant - getTransaction(uint256 const& id, std::optional> const& range, error_code_i& ec) = 0; + std::variant + getTransaction(uint256 const& id, std::optional> const& range, error_code_i& ec) + override; /** * @brief getKBUsedAll Returns the amount of space used by all databases. * @return Space in kilobytes. */ - virtual uint32_t - getKBUsedAll() = 0; + std::uint32_t + getKBUsedAll() override; /** * @brief getKBUsedLedger Returns the amount of space space used by the * ledger database. * @return Space in kilobytes. */ - virtual uint32_t - getKBUsedLedger() = 0; + std::uint32_t + getKBUsedLedger() override; /** * @brief getKBUsedTransaction Returns the amount of space used by the * transaction database. * @return Space in kilobytes. */ - virtual uint32_t - getKBUsedTransaction() = 0; + std::uint32_t + getKBUsedTransaction() override; /** * @brief Closes the ledger database */ - virtual void - closeLedgerDB() = 0; + void + closeLedgerDB() override; /** * @brief Closes the transaction database */ - virtual void - closeTransactionDB() = 0; + void + closeTransactionDB() override; + + SQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); + + SQLiteDatabase(SQLiteDatabase const&) = delete; + SQLiteDatabase(SQLiteDatabase&& rhs) noexcept; + + SQLiteDatabase& + operator=(SQLiteDatabase const&) = delete; + SQLiteDatabase& + operator=(SQLiteDatabase&& rhs) = delete; + + /** + * @brief ledgerDbHasSpace Checks if the ledger database has available + * space. + * @param config Config object. + * @return True if space is available. + */ + bool + ledgerDbHasSpace(Config const& config); + + /** + * @brief transactionDbHasSpace Checks if the transaction database has + * available space. + * @param config Config object. + * @return True if space is available. + */ + bool + transactionDbHasSpace(Config const& config); + +private: + ServiceRegistry& registry_; + bool const useTxTables_; + beast::Journal j_; + std::unique_ptr ledgerDb_, txdb_; + + /** + * @brief makeLedgerDBs Opens ledger and transaction databases for the node + * store, and stores their descriptors in private member variables. + * @param config Config object. + * @param setup Path to the databases and other opening parameters. + * @param checkpointerSetup Checkpointer parameters. + * @return True if node databases opened successfully. + */ + bool + makeLedgerDBs( + Config const& config, + DatabaseCon::Setup const& setup, + DatabaseCon::CheckpointerSetup const& checkpointerSetup); + + /** + * @brief existsLedger Checks if the node store ledger database exists. + * @return True if the node store ledger database exists. + */ + bool + existsLedger() + { + return static_cast(ledgerDb_); + } + + /** + * @brief existsTransaction Checks if the node store transaction database + * exists. + * @return True if the node store transaction database exists. + */ + bool + existsTransaction() + { + return static_cast(txdb_); + } + + /** + * @brief checkoutTransaction Checks out and returns node store ledger + * database. + * @return Session to the node store ledger database. + */ + auto + checkoutLedger() + { + return ledgerDb_->checkoutDb(); + } + + /** + * @brief checkoutTransaction Checks out and returns the node store + * transaction database. + * @return Session to the node store transaction database. + */ + auto + checkoutTransaction() + { + return txdb_->checkoutDb(); + } }; +/** + * @brief setup_RelationalDatabase Creates and returns a SQLiteDatabase + * instance based on configuration. + * @param registry The service registry. + * @param config Config object. + * @param jobQueue JobQueue object. + * @return SQLiteDatabase instance. + */ +SQLiteDatabase +setup_RelationalDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); + } // namespace xrpl diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 1e814c3589..328d07c0ab 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -3,13 +3,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/rdb/backend/detail/Node.h b/src/xrpld/app/rdb/backend/detail/Node.h index 69c4894bbc..cb49a373bd 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.h +++ b/src/xrpld/app/rdb/backend/detail/Node.h @@ -1,9 +1,10 @@ #pragma once #include -#include #include +#include + namespace xrpl { namespace detail { diff --git a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp index 4f1430ee4c..6c3e76a86f 100644 --- a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp +++ b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp @@ -10,200 +10,8 @@ namespace xrpl { -class SQLiteDatabaseImp final : public SQLiteDatabase -{ -public: - SQLiteDatabaseImp(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) - : registry_(registry), useTxTables_(config.useTxTables()), j_(registry.journal("SQLiteDatabaseImp")) - { - DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_); - if (!makeLedgerDBs(config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, ®istry_.logs()})) - { - std::string_view constexpr error = "Failed to create ledger databases"; - - JLOG(j_.fatal()) << error; - Throw(error.data()); - } - } - - std::optional - getMinLedgerSeq() override; - - std::optional - getTransactionsMinLedgerSeq() override; - - std::optional - getAccountTransactionsMinLedgerSeq() override; - - std::optional - getMaxLedgerSeq() override; - - void - deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) override; - - void - deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) override; - - void - deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override; - - void - deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) override; - - std::size_t - getTransactionCount() override; - - std::size_t - getAccountTransactionCount() override; - - RelationalDatabase::CountMinMax - getLedgerCountMinMax() override; - - bool - saveValidatedLedger(std::shared_ptr const& ledger, bool current) override; - - std::optional - getLedgerInfoByIndex(LedgerIndex ledgerSeq) override; - - std::optional - getNewestLedgerInfo() override; - - std::optional - getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) override; - - std::optional - getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) override; - - std::optional - getLedgerInfoByHash(uint256 const& ledgerHash) override; - - uint256 - getHashByIndex(LedgerIndex ledgerIndex) override; - - std::optional - getHashesByIndex(LedgerIndex ledgerIndex) override; - - std::map - getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) override; - - std::vector> - getTxHistory(LedgerIndex startIndex) override; - - AccountTxs - getOldestAccountTxs(AccountTxOptions const& options) override; - - AccountTxs - getNewestAccountTxs(AccountTxOptions const& options) override; - - MetaTxsList - getOldestAccountTxsB(AccountTxOptions const& options) override; - - MetaTxsList - getNewestAccountTxsB(AccountTxOptions const& options) override; - - std::pair> - oldestAccountTxPage(AccountTxPageOptions const& options) override; - - std::pair> - newestAccountTxPage(AccountTxPageOptions const& options) override; - - std::pair> - oldestAccountTxPageB(AccountTxPageOptions const& options) override; - - std::pair> - newestAccountTxPageB(AccountTxPageOptions const& options) override; - - std::variant - getTransaction(uint256 const& id, std::optional> const& range, error_code_i& ec) - override; - - bool - ledgerDbHasSpace(Config const& config) override; - - bool - transactionDbHasSpace(Config const& config) override; - - std::uint32_t - getKBUsedAll() override; - - std::uint32_t - getKBUsedLedger() override; - - std::uint32_t - getKBUsedTransaction() override; - - void - closeLedgerDB() override; - - void - closeTransactionDB() override; - -private: - ServiceRegistry& registry_; - bool const useTxTables_; - beast::Journal j_; - std::unique_ptr ledgerDb_, txdb_; - - /** - * @brief makeLedgerDBs Opens ledger and transaction databases for the node - * store, and stores their descriptors in private member variables. - * @param config Config object. - * @param setup Path to the databases and other opening parameters. - * @param checkpointerSetup Checkpointer parameters. - * @return True if node databases opened successfully. - */ - bool - makeLedgerDBs( - Config const& config, - DatabaseCon::Setup const& setup, - DatabaseCon::CheckpointerSetup const& checkpointerSetup); - - /** - * @brief existsLedger Checks if the node store ledger database exists. - * @return True if the node store ledger database exists. - */ - bool - existsLedger() - { - return static_cast(ledgerDb_); - } - - /** - * @brief existsTransaction Checks if the node store transaction database - * exists. - * @return True if the node store transaction database exists. - */ - bool - existsTransaction() - { - return static_cast(txdb_); - } - - /** - * @brief checkoutTransaction Checks out and returns node store ledger - * database. - * @return Session to the node store ledger database. - */ - auto - checkoutLedger() - { - return ledgerDb_->checkoutDb(); - } - - /** - * @brief checkoutTransaction Checks out and returns the node store - * transaction database. - * @return Session to the node store transaction database. - */ - auto - checkoutTransaction() - { - return txdb_->checkoutDb(); - } -}; - bool -SQLiteDatabaseImp::makeLedgerDBs( +SQLiteDatabase::makeLedgerDBs( Config const& config, DatabaseCon::Setup const& setup, DatabaseCon::CheckpointerSetup const& checkpointerSetup) @@ -215,7 +23,7 @@ SQLiteDatabaseImp::makeLedgerDBs( } std::optional -SQLiteDatabaseImp::getMinLedgerSeq() +SQLiteDatabase::getMinLedgerSeq() { /* if databases exists, use it */ if (existsLedger()) @@ -229,7 +37,7 @@ SQLiteDatabaseImp::getMinLedgerSeq() } std::optional -SQLiteDatabaseImp::getTransactionsMinLedgerSeq() +SQLiteDatabase::getTransactionsMinLedgerSeq() { if (!useTxTables_) return {}; @@ -244,7 +52,7 @@ SQLiteDatabaseImp::getTransactionsMinLedgerSeq() } std::optional -SQLiteDatabaseImp::getAccountTransactionsMinLedgerSeq() +SQLiteDatabase::getAccountTransactionsMinLedgerSeq() { if (!useTxTables_) return {}; @@ -259,7 +67,7 @@ SQLiteDatabaseImp::getAccountTransactionsMinLedgerSeq() } std::optional -SQLiteDatabaseImp::getMaxLedgerSeq() +SQLiteDatabase::getMaxLedgerSeq() { if (existsLedger()) { @@ -271,7 +79,7 @@ SQLiteDatabaseImp::getMaxLedgerSeq() } void -SQLiteDatabaseImp::deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) +SQLiteDatabase::deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) { if (!useTxTables_) return; @@ -285,7 +93,7 @@ SQLiteDatabaseImp::deleteTransactionByLedgerSeq(LedgerIndex ledgerSeq) } void -SQLiteDatabaseImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) +SQLiteDatabase::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) { if (existsLedger()) { @@ -296,7 +104,7 @@ SQLiteDatabaseImp::deleteBeforeLedgerSeq(LedgerIndex ledgerSeq) } void -SQLiteDatabaseImp::deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) +SQLiteDatabase::deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) { if (!useTxTables_) return; @@ -310,7 +118,7 @@ SQLiteDatabaseImp::deleteTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) } void -SQLiteDatabaseImp::deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) +SQLiteDatabase::deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSeq) { if (!useTxTables_) return; @@ -324,7 +132,7 @@ SQLiteDatabaseImp::deleteAccountTransactionsBeforeLedgerSeq(LedgerIndex ledgerSe } std::size_t -SQLiteDatabaseImp::getTransactionCount() +SQLiteDatabase::getTransactionCount() { if (!useTxTables_) return 0; @@ -339,7 +147,7 @@ SQLiteDatabaseImp::getTransactionCount() } std::size_t -SQLiteDatabaseImp::getAccountTransactionCount() +SQLiteDatabase::getAccountTransactionCount() { if (!useTxTables_) return 0; @@ -354,7 +162,7 @@ SQLiteDatabaseImp::getAccountTransactionCount() } RelationalDatabase::CountMinMax -SQLiteDatabaseImp::getLedgerCountMinMax() +SQLiteDatabase::getLedgerCountMinMax() { if (existsLedger()) { @@ -366,7 +174,7 @@ SQLiteDatabaseImp::getLedgerCountMinMax() } bool -SQLiteDatabaseImp::saveValidatedLedger(std::shared_ptr const& ledger, bool current) +SQLiteDatabase::saveValidatedLedger(std::shared_ptr const& ledger, bool current) { if (existsLedger()) { @@ -378,7 +186,7 @@ SQLiteDatabaseImp::saveValidatedLedger(std::shared_ptr const& ledg } std::optional -SQLiteDatabaseImp::getLedgerInfoByIndex(LedgerIndex ledgerSeq) +SQLiteDatabase::getLedgerInfoByIndex(LedgerIndex ledgerSeq) { if (existsLedger()) { @@ -393,7 +201,7 @@ SQLiteDatabaseImp::getLedgerInfoByIndex(LedgerIndex ledgerSeq) } std::optional -SQLiteDatabaseImp::getNewestLedgerInfo() +SQLiteDatabase::getNewestLedgerInfo() { if (existsLedger()) { @@ -408,7 +216,7 @@ SQLiteDatabaseImp::getNewestLedgerInfo() } std::optional -SQLiteDatabaseImp::getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) +SQLiteDatabase::getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) { if (existsLedger()) { @@ -423,7 +231,7 @@ SQLiteDatabaseImp::getLimitedOldestLedgerInfo(LedgerIndex ledgerFirstIndex) } std::optional -SQLiteDatabaseImp::getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) +SQLiteDatabase::getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) { if (existsLedger()) { @@ -438,7 +246,7 @@ SQLiteDatabaseImp::getLimitedNewestLedgerInfo(LedgerIndex ledgerFirstIndex) } std::optional -SQLiteDatabaseImp::getLedgerInfoByHash(uint256 const& ledgerHash) +SQLiteDatabase::getLedgerInfoByHash(uint256 const& ledgerHash) { if (existsLedger()) { @@ -453,7 +261,7 @@ SQLiteDatabaseImp::getLedgerInfoByHash(uint256 const& ledgerHash) } uint256 -SQLiteDatabaseImp::getHashByIndex(LedgerIndex ledgerIndex) +SQLiteDatabase::getHashByIndex(LedgerIndex ledgerIndex) { if (existsLedger()) { @@ -468,7 +276,7 @@ SQLiteDatabaseImp::getHashByIndex(LedgerIndex ledgerIndex) } std::optional -SQLiteDatabaseImp::getHashesByIndex(LedgerIndex ledgerIndex) +SQLiteDatabase::getHashesByIndex(LedgerIndex ledgerIndex) { if (existsLedger()) { @@ -483,7 +291,7 @@ SQLiteDatabaseImp::getHashesByIndex(LedgerIndex ledgerIndex) } std::map -SQLiteDatabaseImp::getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) +SQLiteDatabase::getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) { if (existsLedger()) { @@ -498,7 +306,7 @@ SQLiteDatabaseImp::getHashesByIndex(LedgerIndex minSeq, LedgerIndex maxSeq) } std::vector> -SQLiteDatabaseImp::getTxHistory(LedgerIndex startIndex) +SQLiteDatabase::getTxHistory(LedgerIndex startIndex) { if (!useTxTables_) return {}; @@ -516,7 +324,7 @@ SQLiteDatabaseImp::getTxHistory(LedgerIndex startIndex) } RelationalDatabase::AccountTxs -SQLiteDatabaseImp::getOldestAccountTxs(AccountTxOptions const& options) +SQLiteDatabase::getOldestAccountTxs(AccountTxOptions const& options) { if (!useTxTables_) return {}; @@ -533,7 +341,7 @@ SQLiteDatabaseImp::getOldestAccountTxs(AccountTxOptions const& options) } RelationalDatabase::AccountTxs -SQLiteDatabaseImp::getNewestAccountTxs(AccountTxOptions const& options) +SQLiteDatabase::getNewestAccountTxs(AccountTxOptions const& options) { if (!useTxTables_) return {}; @@ -550,7 +358,7 @@ SQLiteDatabaseImp::getNewestAccountTxs(AccountTxOptions const& options) } RelationalDatabase::MetaTxsList -SQLiteDatabaseImp::getOldestAccountTxsB(AccountTxOptions const& options) +SQLiteDatabase::getOldestAccountTxsB(AccountTxOptions const& options) { if (!useTxTables_) return {}; @@ -565,7 +373,7 @@ SQLiteDatabaseImp::getOldestAccountTxsB(AccountTxOptions const& options) } RelationalDatabase::MetaTxsList -SQLiteDatabaseImp::getNewestAccountTxsB(AccountTxOptions const& options) +SQLiteDatabase::getNewestAccountTxsB(AccountTxOptions const& options) { if (!useTxTables_) return {}; @@ -580,7 +388,7 @@ SQLiteDatabaseImp::getNewestAccountTxsB(AccountTxOptions const& options) } std::pair> -SQLiteDatabaseImp::oldestAccountTxPage(AccountTxPageOptions const& options) +SQLiteDatabase::oldestAccountTxPage(AccountTxPageOptions const& options) { if (!useTxTables_) return {}; @@ -604,7 +412,7 @@ SQLiteDatabaseImp::oldestAccountTxPage(AccountTxPageOptions const& options) } std::pair> -SQLiteDatabaseImp::newestAccountTxPage(AccountTxPageOptions const& options) +SQLiteDatabase::newestAccountTxPage(AccountTxPageOptions const& options) { if (!useTxTables_) return {}; @@ -628,7 +436,7 @@ SQLiteDatabaseImp::newestAccountTxPage(AccountTxPageOptions const& options) } std::pair> -SQLiteDatabaseImp::oldestAccountTxPageB(AccountTxPageOptions const& options) +SQLiteDatabase::oldestAccountTxPageB(AccountTxPageOptions const& options) { if (!useTxTables_) return {}; @@ -651,7 +459,7 @@ SQLiteDatabaseImp::oldestAccountTxPageB(AccountTxPageOptions const& options) } std::pair> -SQLiteDatabaseImp::newestAccountTxPageB(AccountTxPageOptions const& options) +SQLiteDatabase::newestAccountTxPageB(AccountTxPageOptions const& options) { if (!useTxTables_) return {}; @@ -674,7 +482,7 @@ SQLiteDatabaseImp::newestAccountTxPageB(AccountTxPageOptions const& options) } std::variant -SQLiteDatabaseImp::getTransaction( +SQLiteDatabase::getTransaction( uint256 const& id, std::optional> const& range, error_code_i& ec) @@ -692,7 +500,7 @@ SQLiteDatabaseImp::getTransaction( } bool -SQLiteDatabaseImp::ledgerDbHasSpace(Config const& config) +SQLiteDatabase::ledgerDbHasSpace(Config const& config) { if (existsLedger()) { @@ -704,7 +512,7 @@ SQLiteDatabaseImp::ledgerDbHasSpace(Config const& config) } bool -SQLiteDatabaseImp::transactionDbHasSpace(Config const& config) +SQLiteDatabase::transactionDbHasSpace(Config const& config) { if (!useTxTables_) return true; @@ -719,7 +527,7 @@ SQLiteDatabaseImp::transactionDbHasSpace(Config const& config) } std::uint32_t -SQLiteDatabaseImp::getKBUsedAll() +SQLiteDatabase::getKBUsedAll() { if (existsLedger()) { @@ -730,7 +538,7 @@ SQLiteDatabaseImp::getKBUsedAll() } std::uint32_t -SQLiteDatabaseImp::getKBUsedLedger() +SQLiteDatabase::getKBUsedLedger() { if (existsLedger()) { @@ -741,7 +549,7 @@ SQLiteDatabaseImp::getKBUsedLedger() } std::uint32_t -SQLiteDatabaseImp::getKBUsedTransaction() +SQLiteDatabase::getKBUsedTransaction() { if (!useTxTables_) return 0; @@ -755,21 +563,43 @@ SQLiteDatabaseImp::getKBUsedTransaction() } void -SQLiteDatabaseImp::closeLedgerDB() +SQLiteDatabase::closeLedgerDB() { ledgerDb_.reset(); } void -SQLiteDatabaseImp::closeTransactionDB() +SQLiteDatabase::closeTransactionDB() { txdb_.reset(); } -std::unique_ptr -getSQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) +SQLiteDatabase::SQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) + : registry_(registry), useTxTables_(config.useTxTables()), j_(registry.journal("SQLiteDatabase")) { - return std::make_unique(registry, config, jobQueue); + DatabaseCon::Setup const setup = setup_DatabaseCon(config, j_); + if (!makeLedgerDBs(config, setup, DatabaseCon::CheckpointerSetup{&jobQueue, ®istry_.logs()})) + { + std::string_view constexpr error = "Failed to create ledger databases"; + + JLOG(j_.fatal()) << error; + Throw(error.data()); + } +} + +SQLiteDatabase::SQLiteDatabase(SQLiteDatabase&& rhs) noexcept + : registry_(rhs.registry_) + , useTxTables_(rhs.useTxTables_) + , j_(rhs.j_) + , ledgerDb_(std::move(rhs.ledgerDb_)) + , txdb_(std::move(rhs.txdb_)) +{ +} + +SQLiteDatabase +setup_RelationalDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) +{ + return {registry, config, jobQueue}; } } // namespace xrpl diff --git a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp index bc65a817a4..e69de29bb2 100644 --- a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp +++ b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp @@ -1,39 +0,0 @@ -#include -#include - -namespace xrpl { - -extern std::unique_ptr -getSQLiteDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue); - -std::unique_ptr -RelationalDatabase::init(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) -{ - bool use_sqlite = false; - - Section const& rdb_section{config.section(SECTION_RELATIONAL_DB)}; - if (!rdb_section.empty()) - { - if (boost::iequals(get(rdb_section, "backend"), "sqlite")) - { - use_sqlite = true; - } - else - { - Throw("Invalid rdb_section backend value: " + get(rdb_section, "backend")); - } - } - else - { - use_sqlite = true; - } - - if (use_sqlite) - { - return getSQLiteDatabase(registry, config, jobQueue); - } - - return std::unique_ptr(); -} - -} // namespace xrpl diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 6ac6e454d2..549bff024e 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/overlay/detail/PeerReservationTable.cpp b/src/xrpld/overlay/detail/PeerReservationTable.cpp index 27d9df1129..78f29ad155 100644 --- a/src/xrpld/overlay/detail/PeerReservationTable.cpp +++ b/src/xrpld/overlay/detail/PeerReservationTable.cpp @@ -1,9 +1,8 @@ -#include - #include #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 0c4cffd8ac..4a0339b763 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.h b/src/xrpld/rpc/detail/RPCLedgerHelpers.h index 6ea6e3cb78..b2d9df809f 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.h +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.h @@ -7,6 +7,7 @@ #include #include +#include #include @@ -19,8 +20,6 @@ namespace RPC { struct JsonContext; -enum class LedgerShortcut { Current, Closed, Validated }; - /** * @brief Retrieves a ledger by its hash. * diff --git a/src/xrpld/rpc/handlers/AccountTx.cpp b/src/xrpld/rpc/handlers/AccountTx.cpp index fbd1a4d08d..8fe43433d3 100644 --- a/src/xrpld/rpc/handlers/AccountTx.cpp +++ b/src/xrpld/rpc/handlers/AccountTx.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -26,8 +27,6 @@ using TxnsDataBinary = RelationalDatabase::MetaTxsList; using TxnDataBinary = RelationalDatabase::txnMetaLedgerType; using AccountTxArgs = RelationalDatabase::AccountTxArgs; using AccountTxResult = RelationalDatabase::AccountTxResult; - -using LedgerShortcut = RelationalDatabase::LedgerShortcut; using LedgerSpecifier = RelationalDatabase::LedgerSpecifier; // parses args into a ledger specifier, or returns a Json object on error @@ -208,22 +207,19 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args) args.limit, isUnlimited(context.role)}; - auto const db = dynamic_cast(&context.app.getRelationalDatabase()); - - if (!db) - Throw("Failed to get relational database"); + auto& db = context.app.getRelationalDatabase(); if (args.binary) { if (args.forward) { - auto [tx, marker] = db->oldestAccountTxPageB(options); + auto [tx, marker] = db.oldestAccountTxPageB(options); result.transactions = tx; result.marker = marker; } else { - auto [tx, marker] = db->newestAccountTxPageB(options); + auto [tx, marker] = db.newestAccountTxPageB(options); result.transactions = tx; result.marker = marker; } @@ -232,13 +228,13 @@ doAccountTxHelp(RPC::Context& context, AccountTxArgs const& args) { if (args.forward) { - auto [tx, marker] = db->oldestAccountTxPage(options); + auto [tx, marker] = db.oldestAccountTxPage(options); result.transactions = tx; result.marker = marker; } else { - auto [tx, marker] = db->newestAccountTxPage(options); + auto [tx, marker] = db.newestAccountTxPage(options); result.transactions = tx; result.marker = marker; } diff --git a/src/xrpld/rpc/handlers/GetCounts.cpp b/src/xrpld/rpc/handlers/GetCounts.cpp index 2a59be2747..360389ba3a 100644 --- a/src/xrpld/rpc/handlers/GetCounts.cpp +++ b/src/xrpld/rpc/handlers/GetCounts.cpp @@ -49,22 +49,19 @@ getCountsJson(Application& app, int minObjectCount) if (app.config().useTxTables()) { - auto const db = dynamic_cast(&app.getRelationalDatabase()); + auto& db = app.getRelationalDatabase(); - if (!db) - Throw("Failed to get relational database"); - - auto dbKB = db->getKBUsedAll(); + auto dbKB = db.getKBUsedAll(); if (dbKB > 0) ret[jss::dbKBTotal] = dbKB; - dbKB = db->getKBUsedLedger(); + dbKB = db.getKBUsedLedger(); if (dbKB > 0) ret[jss::dbKBLedger] = dbKB; - dbKB = db->getKBUsedTransaction(); + dbKB = db.getKBUsedTransaction(); if (dbKB > 0) ret[jss::dbKBTransaction] = dbKB; diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index 5d8778d619..2f8d71c2c8 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -3,18 +3,19 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include #include #include +#include #include diff --git a/src/xrpld/rpc/handlers/TxHistory.cpp b/src/xrpld/rpc/handlers/TxHistory.cpp index 00894647eb..02ff6fb43c 100644 --- a/src/xrpld/rpc/handlers/TxHistory.cpp +++ b/src/xrpld/rpc/handlers/TxHistory.cpp @@ -2,13 +2,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include namespace xrpl { From 11e8d1f8a206f0c5379ba78bc3aa044adf5a63d7 Mon Sep 17 00:00:00 2001 From: Pratik Mankawde <3397372+pratikmankawde@users.noreply.github.com> Date: Thu, 12 Feb 2026 11:11:26 +0000 Subject: [PATCH 10/16] chore: Fix `gcov` lib coverage build failure on macOS (#6350) For coverage builds, we try to link against the `gcov` library (specific to the environment). But as macOS doesn't have this library and thus doesn't have the coverage tools to generate reports, the coverage builds on that platform were failing on linking. We actually don't need to explicitly force this linking, as the `CodeCoverage` file already has correct detection logic (currently on lines 177-193), which is invoked when the `--coverage` flag is provided: * AppleClang: Uses `xcrun -f llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`. * Clang: Finds `llvm-cov` to set `GCOV_TOOL="llvm-cov gcov"`. * GCC: Finds `gcov` to set `GCOV_TOOL="gcov"`. The `GCOV_TOOL` is then passed to `gcovr` on line 416, so the correct tool is used for processing coverage data. This change therefore removes the `gcov` suffix from lines 473 and 475 in the `CodeCoverage.cmake` file. --- cmake/CodeCoverage.cmake | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 0178d68cc0..fcc4d44133 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -466,11 +466,6 @@ function (add_code_coverage_to_target name scope) target_compile_options(${name} ${scope} $<$:${COVERAGE_CXX_COMPILER_FLAGS}> $<$:${COVERAGE_C_COMPILER_FLAGS}>) - target_link_libraries( - ${name} - ${scope} - $<$:${COVERAGE_CXX_LINKER_FLAGS} - gcov> - $<$:${COVERAGE_C_LINKER_FLAGS} - gcov>) + target_link_libraries(${name} ${scope} $<$:${COVERAGE_CXX_LINKER_FLAGS}> + $<$:${COVERAGE_C_LINKER_FLAGS}>) endfunction () # add_code_coverage_to_target From 5edd3566f7c971f7e2a26668eee6edc34c7519b7 Mon Sep 17 00:00:00 2001 From: Jingchen Date: Thu, 12 Feb 2026 18:15:03 +0000 Subject: [PATCH 11/16] refactor: Modularize the NetworkOPs interface (#6225) This change moves the NetworkOPs interface into `libxrpl` and it leaves its implementation in `xrpld`. --- .../scripts/levelization/results/loops.txt | 2 +- .../scripts/levelization/results/ordering.txt | 4 + cmake/XrplCore.cmake | 3 +- .../rpc => include/xrpl/server}/InfoSub.h | 1 + .../misc => include/xrpl/server}/NetworkOPs.h | 25 +- .../rpc/detail => libxrpl/server}/InfoSub.cpp | 2 +- src/test/app/Batch_test.cpp | 2 +- src/test/jtx/Env_test.cpp | 2 +- src/test/jtx/impl/Env.cpp | 2 +- src/test/rpc/AmendmentBlocked_test.cpp | 2 +- src/test/rpc/ServerInfo_test.cpp | 2 +- src/test/rpc/Subscribe_test.cpp | 2 +- src/test/server/ServerStatus_test.cpp | 2 +- src/xrpld/app/consensus/RCLConsensus.cpp | 2 +- src/xrpld/app/ledger/BookListeners.h | 3 +- src/xrpld/app/ledger/ConsensusTransSetSF.cpp | 2 +- src/xrpld/app/ledger/OrderBookDB.cpp | 2 +- .../app/ledger/detail/InboundLedgers.cpp | 2 +- .../app/ledger/detail/InboundTransactions.cpp | 2 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 2 +- .../app/ledger/detail/TransactionAcquire.cpp | 3 +- src/xrpld/app/main/Application.cpp | 2 +- src/xrpld/app/main/GRPCServer.h | 2 +- src/xrpld/app/main/LoadManager.cpp | 2 +- src/xrpld/app/misc/NetworkOPs.cpp | 286 +++++++++--------- src/xrpld/app/misc/SHAMapStoreImp.cpp | 2 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 2 +- src/xrpld/app/misc/make_NetworkOPs.h | 32 ++ src/xrpld/app/paths/PathRequest.cpp | 2 +- src/xrpld/app/paths/PathRequest.h | 2 +- src/xrpld/app/rdb/backend/SQLiteDatabase.h | 12 +- .../app/rdb/backend/detail/SQLiteDatabase.cpp | 16 +- .../app/rdb/detail/RelationalDatabase.cpp | 0 src/xrpld/app/tx/detail/Change.cpp | 2 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 2 +- src/xrpld/overlay/detail/PeerImp.cpp | 2 +- src/xrpld/rpc/Context.h | 2 +- src/xrpld/rpc/RPCSub.h | 3 +- src/xrpld/rpc/detail/Handler.h | 2 +- src/xrpld/rpc/detail/RPCHandler.cpp | 4 +- src/xrpld/rpc/detail/RPCHelpers.h | 2 +- src/xrpld/rpc/detail/RPCLedgerHelpers.h | 3 +- src/xrpld/rpc/detail/ServerHandler.cpp | 2 +- src/xrpld/rpc/detail/TransactionSign.h | 3 +- src/xrpld/rpc/detail/WSInfoSub.h | 2 +- src/xrpld/rpc/handlers/BookOffers.cpp | 2 +- src/xrpld/rpc/handlers/ConsensusInfo.cpp | 2 +- src/xrpld/rpc/handlers/FetchInfo.cpp | 2 +- src/xrpld/rpc/handlers/GetCounts.cpp | 2 +- src/xrpld/rpc/handlers/LedgerAccept.cpp | 2 +- src/xrpld/rpc/handlers/LedgerClosed.cpp | 2 +- src/xrpld/rpc/handlers/LedgerCurrent.cpp | 2 +- src/xrpld/rpc/handlers/OwnerInfo.cpp | 2 +- src/xrpld/rpc/handlers/ServerInfo.cpp | 2 +- src/xrpld/rpc/handlers/ServerState.cpp | 2 +- src/xrpld/rpc/handlers/Subscribe.cpp | 2 +- src/xrpld/rpc/handlers/Tx.cpp | 2 +- src/xrpld/rpc/handlers/Unsubscribe.cpp | 2 +- 58 files changed, 260 insertions(+), 224 deletions(-) rename {src/xrpld/rpc => include/xrpl/server}/InfoSub.h (99%) rename {src/xrpld/app/misc => include/xrpl/server}/NetworkOPs.h (92%) rename src/{xrpld/rpc/detail => libxrpl/server}/InfoSub.cpp (98%) create mode 100644 src/xrpld/app/misc/make_NetworkOPs.h delete mode 100644 src/xrpld/app/rdb/detail/RelationalDatabase.cpp diff --git a/.github/scripts/levelization/results/loops.txt b/.github/scripts/levelization/results/loops.txt index 34842d7f48..7914704f9d 100644 --- a/.github/scripts/levelization/results/loops.txt +++ b/.github/scripts/levelization/results/loops.txt @@ -5,7 +5,7 @@ Loop: test.jtx test.unit_test test.unit_test == test.jtx Loop: xrpld.app xrpld.overlay - xrpld.overlay > xrpld.app + xrpld.overlay ~= xrpld.app Loop: xrpld.app xrpld.peerfinder xrpld.peerfinder == xrpld.app diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 85f2457ea3..1de6f803f3 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -137,6 +137,7 @@ test.rpc > xrpld.rpc test.rpc > xrpl.json test.rpc > xrpl.protocol test.rpc > xrpl.resource +test.rpc > xrpl.server test.server > test.jtx test.server > test.toplevel test.server > test.unit_test @@ -178,8 +179,11 @@ xrpl.resource > xrpl.protocol xrpl.server > xrpl.basics xrpl.server > xrpl.core xrpl.server > xrpl.json +xrpl.server > xrpl.ledger xrpl.server > xrpl.protocol xrpl.server > xrpl.rdb +xrpl.server > xrpl.resource +xrpl.server > xrpl.shamap xrpl.shamap > xrpl.basics xrpl.shamap > xrpl.nodestore xrpl.shamap > xrpl.protocol diff --git a/cmake/XrplCore.cmake b/cmake/XrplCore.cmake index cea19db9bc..ba14899bd9 100644 --- a/cmake/XrplCore.cmake +++ b/cmake/XrplCore.cmake @@ -95,7 +95,8 @@ add_module(xrpl rdb) target_link_libraries(xrpl.libxrpl.rdb PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.core) add_module(xrpl server) -target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core xrpl.libxrpl.rdb) +target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core xrpl.libxrpl.rdb + xrpl.libxrpl.resource) add_module(xrpl ledger) target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol diff --git a/src/xrpld/rpc/InfoSub.h b/include/xrpl/server/InfoSub.h similarity index 99% rename from src/xrpld/rpc/InfoSub.h rename to include/xrpl/server/InfoSub.h index d49e401bd3..1a7222bf5d 100644 --- a/src/xrpld/rpc/InfoSub.h +++ b/include/xrpl/server/InfoSub.h @@ -131,6 +131,7 @@ public: virtual bool subPeerStatus(ref ispListener) = 0; + virtual bool unsubPeerStatus(std::uint64_t uListener) = 0; virtual void diff --git a/src/xrpld/app/misc/NetworkOPs.h b/include/xrpl/server/NetworkOPs.h similarity index 92% rename from src/xrpld/app/misc/NetworkOPs.h rename to include/xrpl/server/NetworkOPs.h index 66c915008a..cfe0021c07 100644 --- a/src/xrpld/app/misc/NetworkOPs.h +++ b/include/xrpl/server/NetworkOPs.h @@ -1,13 +1,13 @@ #pragma once -#include -#include -#include - #include +#include #include #include +#include #include +#include +#include #include @@ -23,6 +23,7 @@ class LedgerMaster; class Transaction; class ValidatorKeys; class CanonicalTXSet; +class RCLCxPeerPos; // This is the primary interface into the "client" portion of the program. // Code that wants to do normal operations on the network such as @@ -245,20 +246,4 @@ public: stateAccounting(Json::Value& obj) = 0; }; -//------------------------------------------------------------------------------ - -std::unique_ptr -make_NetworkOPs( - Application& app, - NetworkOPs::clock_type& clock, - bool standalone, - std::size_t minPeerCount, - bool start_valid, - JobQueue& job_queue, - LedgerMaster& ledgerMaster, - ValidatorKeys const& validatorKeys, - boost::asio::io_context& io_svc, - beast::Journal journal, - beast::insight::Collector::ptr const& collector); - } // namespace xrpl diff --git a/src/xrpld/rpc/detail/InfoSub.cpp b/src/libxrpl/server/InfoSub.cpp similarity index 98% rename from src/xrpld/rpc/detail/InfoSub.cpp rename to src/libxrpl/server/InfoSub.cpp index 27e3a65b2f..c413f5d257 100644 --- a/src/xrpld/rpc/detail/InfoSub.cpp +++ b/src/libxrpl/server/InfoSub.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index 72f3677e3b..133f10cd28 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index 0f43691b86..f0a46ba55c 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -1,6 +1,5 @@ #include -#include #include #include @@ -8,6 +7,7 @@ #include #include #include +#include #include diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index d8bcec84ee..3fdfa2bf2a 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/src/test/rpc/AmendmentBlocked_test.cpp b/src/test/rpc/AmendmentBlocked_test.cpp index 73a8c6d299..fc1e21a0b6 100644 --- a/src/test/rpc/AmendmentBlocked_test.cpp +++ b/src/test/rpc/AmendmentBlocked_test.cpp @@ -1,10 +1,10 @@ #include #include -#include #include #include +#include namespace xrpl { diff --git a/src/test/rpc/ServerInfo_test.cpp b/src/test/rpc/ServerInfo_test.cpp index 054c3e563a..c38844e8a6 100644 --- a/src/test/rpc/ServerInfo_test.cpp +++ b/src/test/rpc/ServerInfo_test.cpp @@ -1,10 +1,10 @@ #include -#include #include #include #include +#include #include diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index cce45fb4ef..759b02dcc7 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -4,13 +4,13 @@ #include #include -#include #include #include #include #include #include +#include #include diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index ccfdf2fd2b..5a91ad4b03 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -5,12 +5,12 @@ #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 35f8eec1a3..4ebd1a502f 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include #include @@ -25,6 +24,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/BookListeners.h b/src/xrpld/app/ledger/BookListeners.h index 036e988749..3ed267448b 100644 --- a/src/xrpld/app/ledger/BookListeners.h +++ b/src/xrpld/app/ledger/BookListeners.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include #include #include diff --git a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp index 6a8dbd3d7d..a99960fd3a 100644 --- a/src/xrpld/app/ledger/ConsensusTransSetSF.cpp +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -8,6 +7,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp index 81a3bf5e4a..6450544f92 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -2,12 +2,12 @@ #include #include #include -#include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/ledger/detail/InboundLedgers.cpp b/src/xrpld/app/ledger/detail/InboundLedgers.cpp index 626f58b686..5441e2dc95 100644 --- a/src/xrpld/app/ledger/detail/InboundLedgers.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedgers.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/InboundTransactions.cpp b/src/xrpld/app/ledger/detail/InboundTransactions.cpp index 36ebb7bd9e..9e877465a5 100644 --- a/src/xrpld/app/ledger/detail/InboundTransactions.cpp +++ b/src/xrpld/app/ledger/detail/InboundTransactions.cpp @@ -2,12 +2,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 1fd1a8a8b2..f8ef91a83f 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/TransactionAcquire.cpp b/src/xrpld/app/ledger/detail/TransactionAcquire.cpp index f838a912eb..06cd6a2696 100644 --- a/src/xrpld/app/ledger/detail/TransactionAcquire.cpp +++ b/src/xrpld/app/ledger/detail/TransactionAcquire.cpp @@ -3,7 +3,8 @@ #include #include #include -#include + +#include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 7a59d586e0..3f7b6c5596 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -18,11 +18,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/main/GRPCServer.h b/src/xrpld/app/main/GRPCServer.h index fdac2b6484..1b41722fff 100644 --- a/src/xrpld/app/main/GRPCServer.h +++ b/src/xrpld/app/main/GRPCServer.h @@ -3,13 +3,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp index d1336b20d9..5e3b572e1d 100644 --- a/src/xrpld/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -1,10 +1,10 @@ #include #include #include -#include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 7da26ada40..9e60a8bdc0 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -14,12 +15,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include @@ -197,7 +198,7 @@ class NetworkOPsImp final : public NetworkOPs public: NetworkOPsImp( - Application& app, + ServiceRegistry& registry, NetworkOPs::clock_type& clock, bool standalone, std::size_t minPeerCount, @@ -208,7 +209,7 @@ public: boost::asio::io_context& io_svc, beast::Journal journal, beast::insight::Collector::ptr const& collector) - : app_(app) + : registry_(registry) , m_journal(journal) , m_localTX(make_LocalTxs()) , mMode(start_valid ? OperatingMode::FULL : OperatingMode::DISCONNECTED) @@ -216,14 +217,16 @@ public: , clusterTimer_(io_svc) , accountHistoryTxTimer_(io_svc) , mConsensus( - app, - make_FeeVote(setup_FeeVote(app_.config().section("voting")), app_.logs().journal("FeeVote")), + registry_.app(), + make_FeeVote( + setup_FeeVote(registry_.app().config().section("voting")), + registry_.logs().journal("FeeVote")), ledgerMaster, *m_localTX, - app.getInboundTransactions(), + registry.getInboundTransactions(), beast::get_abstract_clock(), validatorKeys, - app_.logs().journal("LedgerConsensus")) + registry_.logs().journal("LedgerConsensus")) , validatorPK_(validatorKeys.keys ? validatorKeys.keys->publicKey : decltype(validatorPK_){}) , validatorMasterPK_(validatorKeys.keys ? validatorKeys.keys->masterPublicKey : decltype(validatorMasterPK_){}) , m_ledgerMaster(ledgerMaster) @@ -665,7 +668,7 @@ private: void setAccountHistoryJobTimer(SubAccountHistoryInfoWeak subInfo); - Application& app_; + ServiceRegistry& registry_; beast::Journal m_journal; std::unique_ptr m_localTX; @@ -847,7 +850,7 @@ NetworkOPsImp::getHostId(bool forAdmin) // For non-admin uses hash the node public key into a // single RFC1751 word: static std::string const shroudedHostId = [this]() { - auto const& id = app_.nodeIdentity(); + auto const& id = registry_.app().nodeIdentity(); return RFC1751::getWordFromBlob(id.first.data(), id.first.size()); }(); @@ -861,7 +864,7 @@ NetworkOPsImp::setStateTimer() setHeartbeatTimer(); // Only do this work if a cluster is configured - if (app_.cluster().size() != 0) + if (registry_.cluster().size() != 0) setClusterTimer(); } @@ -932,13 +935,13 @@ NetworkOPsImp::processHeartbeatTimer() { RclConsensusLogger clog("Heartbeat Timer", mConsensus.validating(), m_journal); { - std::unique_lock lock{app_.getMasterMutex()}; + std::unique_lock lock{registry_.app().getMasterMutex()}; // VFALCO NOTE This is for diagnosing a crash on exit - LoadManager& mgr(app_.getLoadManager()); + LoadManager& mgr(registry_.getLoadManager()); mgr.heartbeat(); - std::size_t const numPeers = app_.overlay().size(); + std::size_t const numPeers = registry_.overlay().size(); // do we have sufficient peers? If not, we are disconnected. if (numPeers < minPeerCount_) @@ -990,7 +993,7 @@ NetworkOPsImp::processHeartbeatTimer() CLOG(clog.ss()) << ". "; } - mConsensus.timerEntry(app_.timeKeeper().closeTime(), clog.ss()); + mConsensus.timerEntry(registry_.timeKeeper().closeTime(), clog.ss()); CLOG(clog.ss()) << "consensus phase " << to_string(mLastConsensusPhase); ConsensusPhase const currPhase = mConsensus.phase(); @@ -1008,16 +1011,16 @@ NetworkOPsImp::processHeartbeatTimer() void NetworkOPsImp::processClusterTimer() { - if (app_.cluster().size() == 0) + if (registry_.cluster().size() == 0) return; using namespace std::chrono_literals; - bool const update = app_.cluster().update( - app_.nodeIdentity().first, + bool const update = registry_.cluster().update( + registry_.app().nodeIdentity().first, "", - (m_ledgerMaster.getValidatedLedgerAge() <= 4min) ? app_.getFeeTrack().getLocalFee() : 0, - app_.timeKeeper().now()); + (m_ledgerMaster.getValidatedLedgerAge() <= 4min) ? registry_.getFeeTrack().getLocalFee() : 0, + registry_.timeKeeper().now()); if (!update) { @@ -1027,7 +1030,7 @@ NetworkOPsImp::processClusterTimer() } protocol::TMCluster cluster; - app_.cluster().for_each([&cluster](ClusterNode const& node) { + registry_.cluster().for_each([&cluster](ClusterNode const& node) { protocol::TMClusterNode& n = *cluster.add_clusternodes(); n.set_publickey(toBase58(TokenType::NodePublic, node.identity())); n.set_reporttime(node.getReportTime().time_since_epoch().count()); @@ -1036,14 +1039,14 @@ NetworkOPsImp::processClusterTimer() n.set_nodename(node.name()); }); - Resource::Gossip gossip = app_.getResourceManager().exportConsumers(); + Resource::Gossip gossip = registry_.getResourceManager().exportConsumers(); for (auto& item : gossip.items) { protocol::TMLoadSource& node = *cluster.add_loadsources(); node.set_name(to_string(item.address)); node.set_cost(item.balance); } - app_.overlay().foreach(send_if(std::make_shared(cluster, protocol::mtCLUSTER), peer_in_cluster())); + registry_.overlay().foreach(send_if(std::make_shared(cluster, protocol::mtCLUSTER), peer_in_cluster())); setClusterTimer(); } @@ -1088,7 +1091,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) auto const trans = sterilize(*iTrans); auto const txid = trans->getTransactionID(); - auto const flags = app_.getHashRouter().getFlags(txid); + auto const flags = registry_.getHashRouter().getFlags(txid); if ((flags & HashRouterFlags::BAD) != HashRouterFlags::UNDEFINED) { @@ -1098,8 +1101,8 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) try { - auto const [validity, reason] = - checkValidity(app_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules(), app_.config()); + auto const [validity, reason] = checkValidity( + registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules(), registry_.app().config()); if (validity != Validity::Valid) { @@ -1116,7 +1119,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) std::string reason; - auto tx = std::make_shared(trans, reason, app_); + auto tx = std::make_shared(trans, reason, registry_.app()); m_job_queue.addJob(jtTRANSACTION, "SubmitTxn", [this, tx]() { auto t = tx; @@ -1127,7 +1130,7 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) bool NetworkOPsImp::preProcessTransaction(std::shared_ptr& transaction) { - auto const newFlags = app_.getHashRouter().getFlags(transaction->getID()); + auto const newFlags = registry_.getHashRouter().getFlags(transaction->getID()); if ((newFlags & HashRouterFlags::BAD) != HashRouterFlags::UNDEFINED) { @@ -1148,14 +1151,15 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr& transaction) { transaction->setStatus(INVALID); transaction->setResult(temINVALID_FLAG); - app_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD); + registry_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD); return false; } // NOTE ximinez - I think this check is redundant, // but I'm not 100% sure yet. // If so, only cost is looking up HashRouter flags. - auto const [validity, reason] = checkValidity(app_.getHashRouter(), sttx, view->rules(), app_.config()); + auto const [validity, reason] = + checkValidity(registry_.getHashRouter(), sttx, view->rules(), registry_.app().config()); XRPL_ASSERT(validity == Validity::Valid, "xrpl::NetworkOPsImp::processTransaction : valid validity"); // Not concerned with local checks at this point. @@ -1164,12 +1168,12 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr& transaction) JLOG(m_journal.info()) << "Transaction has bad signature: " << reason; transaction->setStatus(INVALID); transaction->setResult(temBAD_SIGNATURE); - app_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD); + registry_.getHashRouter().setFlags(transaction->getID(), HashRouterFlags::BAD); return false; } // canonicalize can change our pointer - app_.getMasterTransaction().canonicalize(&transaction); + registry_.getMasterTransaction().canonicalize(&transaction); return true; } @@ -1265,7 +1269,7 @@ NetworkOPsImp::processTransactionSet(CanonicalTXSet const& set) for (auto const& [_, tx] : set) { std::string reason; - auto transaction = std::make_shared(tx, reason, app_); + auto transaction = std::make_shared(tx, reason, registry_.app()); if (transaction->getStatus() == INVALID) { @@ -1273,7 +1277,7 @@ NetworkOPsImp::processTransactionSet(CanonicalTXSet const& set) { JLOG(m_journal.trace()) << "Exception checking transaction: " << reason; } - app_.getHashRouter().setFlags(tx->getTransactionID(), HashRouterFlags::BAD); + registry_.getHashRouter().setFlags(tx->getTransactionID(), HashRouterFlags::BAD); continue; } @@ -1347,13 +1351,13 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) batchLock.unlock(); { - std::unique_lock masterLock{app_.getMasterMutex(), std::defer_lock}; + std::unique_lock masterLock{registry_.app().getMasterMutex(), std::defer_lock}; bool changed = false; { std::unique_lock ledgerLock{m_ledgerMaster.peekMutex(), std::defer_lock}; std::lock(masterLock, ledgerLock); - app_.openLedger().modify([&](OpenView& view, beast::Journal j) { + registry_.openLedger().modify([&](OpenView& view, beast::Journal j) { for (TransactionStatus& e : transactions) { // we check before adding to the batch @@ -1364,7 +1368,8 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) if (e.failType == FailHard::yes) flags |= tapFAIL_HARD; - auto const result = app_.getTxQ().apply(app_, view, e.transaction->getSTransaction(), flags, j); + auto const result = + registry_.getTxQ().apply(registry_.app(), view, e.transaction->getSTransaction(), flags, j); e.result = result.ter; e.applied = result.applied; changed = changed || result.applied; @@ -1379,7 +1384,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) if (auto const l = m_ledgerMaster.getValidatedLedger()) validatedLedgerIndex = l->header().seq; - auto newOL = app_.openLedger().current(); + auto newOL = registry_.openLedger().current(); for (TransactionStatus& e : transactions) { e.transaction->clearSubmitResult(); @@ -1393,7 +1398,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) e.transaction->setResult(e.result); if (isTemMalformed(e.result)) - app_.getHashRouter().setFlags(e.transaction->getID(), HashRouterFlags::BAD); + registry_.getHashRouter().setFlags(e.transaction->getID(), HashRouterFlags::BAD); #ifdef DEBUG if (e.result != tesSUCCESS) @@ -1427,7 +1432,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) batchLock.lock(); std::string reason; auto const trans = sterilize(*txNext); - auto t = std::make_shared(trans, reason, app_); + auto t = std::make_shared(trans, reason, registry_.app()); if (t->getApplying()) break; submit_held.emplace_back(t, false, false, FailHard::no); @@ -1479,7 +1484,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) // up!) // if (e.local || (ledgersLeft && ledgersLeft <= LocalTxs::holdLedgers) || - app_.getHashRouter().setFlags(e.transaction->getID(), HashRouterFlags::HELD)) + registry_.getHashRouter().setFlags(e.transaction->getID(), HashRouterFlags::HELD)) { // transaction should be held JLOG(m_journal.debug()) << "Transaction should be held: " << e.result; @@ -1513,7 +1518,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) (e.result == terQUEUED)) && !enforceFailHard) { - auto const toSkip = app_.getHashRouter().shouldRelay(e.transaction->getID()); + auto const toSkip = registry_.getHashRouter().shouldRelay(e.transaction->getID()); if (auto const sttx = *(e.transaction->getSTransaction()); toSkip && // Skip relaying if it's an inner batch txn. The flag should // only be set if the Batch feature is enabled. If Batch is @@ -1527,10 +1532,10 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) sttx.add(s); tx.set_rawtransaction(s.data(), s.size()); tx.set_status(protocol::tsCURRENT); - tx.set_receivetimestamp(app_.timeKeeper().now().time_since_epoch().count()); + tx.set_receivetimestamp(registry_.timeKeeper().now().time_since_epoch().count()); tx.set_deferred(e.result == terQUEUED); // FIXME: This should be when we received it - app_.overlay().relay(e.transaction->getID(), tx, *toSkip); + registry_.overlay().relay(e.transaction->getID(), tx, *toSkip); e.transaction->setBroadcast(); } } @@ -1538,7 +1543,7 @@ NetworkOPsImp::apply(std::unique_lock& batchLock) if (validatedLedgerIndex) { auto [fee, accountSeq, availableSeq] = - app_.getTxQ().getTxRequiredFeeAndSeq(*newOL, e.transaction->getSTransaction()); + registry_.getTxQ().getTxRequiredFeeAndSeq(*newOL, e.transaction->getSTransaction()); e.transaction->setCurrentLedgerState(*validatedLedgerIndex, fee, accountSeq, availableSeq); } } @@ -1713,7 +1718,7 @@ NetworkOPsImp::checkLastClosedLedger(Overlay::PeerSequence const& peerList, uint //------------------------------------------------------------------------- // Determine preferred last closed ledger - auto& validations = app_.getValidations(); + auto& validations = registry_.getValidations(); JLOG(m_journal.debug()) << "ValidationTrie " << Json::Compact(validations.getJsonTrie()); // Will rely on peer LCL if no trusted validations exist @@ -1758,7 +1763,7 @@ NetworkOPsImp::checkLastClosedLedger(Overlay::PeerSequence const& peerList, uint auto consensus = m_ledgerMaster.getLedgerByHash(closedLedger); if (!consensus) - consensus = app_.getInboundLedgers().acquire(closedLedger, 0, InboundLedger::Reason::CONSENSUS); + consensus = registry_.getInboundLedgers().acquire(closedLedger, 0, InboundLedger::Reason::CONSENSUS); if (consensus && (!m_ledgerMaster.canBeCurrent(consensus) || @@ -1799,7 +1804,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr const& newLC clearNeedNetworkLedger(); // Update fee computations. - app_.getTxQ().processClosedLedger(app_, *newLCL, true); + registry_.getTxQ().processClosedLedger(registry_.app(), *newLCL, true); // Caller must own master lock { @@ -1807,14 +1812,14 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr const& newLC // open ledger. Then apply local tx. auto retries = m_localTX->getTxSet(); - auto const lastVal = app_.getLedgerMaster().getValidatedLedger(); + auto const lastVal = registry_.getLedgerMaster().getValidatedLedger(); std::optional rules; if (lastVal) - rules = makeRulesGivenLedger(*lastVal, app_.config().features); + rules = makeRulesGivenLedger(*lastVal, registry_.app().config().features); else - rules.emplace(app_.config().features); - app_.openLedger().accept( - app_, + rules.emplace(registry_.app().config().features); + registry_.openLedger().accept( + registry_.app(), *rules, newLCL, OrderedTxs({}), @@ -1824,7 +1829,7 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr const& newLC "jump", [&](OpenView& view, beast::Journal j) { // Stuff the ledger with transactions from the queue. - return app_.getTxQ().accept(app_, view); + return registry_.getTxQ().accept(registry_.app(), view); }); } @@ -1833,11 +1838,11 @@ NetworkOPsImp::switchLastClosedLedger(std::shared_ptr const& newLC protocol::TMStatusChange s; s.set_newevent(protocol::neSWITCHED_LEDGER); s.set_ledgerseq(newLCL->header().seq); - s.set_networktime(app_.timeKeeper().now().time_since_epoch().count()); + s.set_networktime(registry_.timeKeeper().now().time_since_epoch().count()); s.set_ledgerhashprevious(newLCL->header().parentHash.begin(), newLCL->header().parentHash.size()); s.set_ledgerhash(newLCL->header().hash.begin(), newLCL->header().hash.size()); - app_.overlay().foreach(send_always(std::make_shared(s, protocol::mtSTATUS_CHANGE))); + registry_.overlay().foreach(send_always(std::make_shared(s, protocol::mtSTATUS_CHANGE))); } bool @@ -1874,23 +1879,23 @@ NetworkOPsImp::beginConsensus(uint256 const& networkClosed, std::unique_ptrnegativeUNL()); - TrustChanges const changes = app_.validators().updateTrusted( - app_.getValidations().getCurrentNodeIDs(), + registry_.validators().setNegativeUNL(prevLedger->negativeUNL()); + TrustChanges const changes = registry_.validators().updateTrusted( + registry_.getValidations().getCurrentNodeIDs(), closingInfo.parentCloseTime, *this, - app_.overlay(), - app_.getHashRouter()); + registry_.overlay(), + registry_.getHashRouter()); if (!changes.added.empty() || !changes.removed.empty()) { - app_.getValidations().trustChanged(changes.added, changes.removed); + registry_.getValidations().trustChanged(changes.added, changes.removed); // Update the AmendmentTable so it tracks the current validators. - app_.getAmendmentTable().trustChanged(app_.validators().getQuorumKeys().second); + registry_.getAmendmentTable().trustChanged(registry_.validators().getQuorumKeys().second); } mConsensus.startRound( - app_.timeKeeper().closeTime(), networkClosed, prevLedger, changes.removed, changes.added, clog); + registry_.timeKeeper().closeTime(), networkClosed, prevLedger, changes.removed, changes.added, clog); ConsensusPhase const currPhase = mConsensus.phase(); if (mLastConsensusPhase != currPhase) @@ -1925,7 +1930,7 @@ NetworkOPsImp::processTrustedProposal(RCLCxPeerPos peerPos) return false; } - return mConsensus.peerProposal(app_.timeKeeper().closeTime(), peerPos); + return mConsensus.peerProposal(registry_.timeKeeper().closeTime(), peerPos); } void @@ -1939,11 +1944,11 @@ NetworkOPsImp::mapComplete(std::shared_ptr const& map, bool fromAcquire) protocol::TMHaveTransactionSet msg; msg.set_hash(map->getHash().as_uint256().begin(), 256 / 8); msg.set_status(protocol::tsHAVE); - app_.overlay().foreach(send_always(std::make_shared(msg, protocol::mtHAVE_SET))); + registry_.overlay().foreach(send_always(std::make_shared(msg, protocol::mtHAVE_SET))); // We acquired it because consensus asked us to if (fromAcquire) - mConsensus.gotTxSet(app_.timeKeeper().closeTime(), RCLTxSet{map}); + mConsensus.gotTxSet(registry_.timeKeeper().closeTime(), RCLTxSet{map}); } void @@ -1951,7 +1956,7 @@ NetworkOPsImp::endConsensus(std::unique_ptr const& clog) { uint256 deadLedger = m_ledgerMaster.getClosedLedger()->header().parentHash; - for (auto const& it : app_.overlay().getActivePeers()) + for (auto const& it : registry_.overlay().getActivePeers()) { if (it && (it->getClosedLedgerHash() == deadLedger)) { @@ -1961,7 +1966,7 @@ NetworkOPsImp::endConsensus(std::unique_ptr const& clog) } uint256 networkClosed; - bool ledgerChange = checkLastClosedLedger(app_.overlay().getActivePeers(), networkClosed); + bool ledgerChange = checkLastClosedLedger(registry_.overlay().getActivePeers(), networkClosed); if (networkClosed.isZero()) { @@ -1990,7 +1995,8 @@ NetworkOPsImp::endConsensus(std::unique_ptr const& clog) // Note: Do not go to FULL if we don't have the previous ledger // check if the ledger is bad enough to go to CONNECTED -- TODO auto current = m_ledgerMaster.getCurrentLedger(); - if (app_.timeKeeper().now() < (current->header().parentCloseTime + 2 * current->header().closeTimeResolution)) + if (registry_.timeKeeper().now() < + (current->header().parentCloseTime + 2 * current->header().closeTimeResolution)) { setMode(OperatingMode::FULL); } @@ -2096,9 +2102,9 @@ NetworkOPsImp::pubServer() Json::Value jvObj(Json::objectValue); ServerFeeSummary f{ - app_.openLedger().current()->fees().base, - app_.getTxQ().getMetrics(*app_.openLedger().current()), - app_.getFeeTrack()}; + registry_.openLedger().current()->fees().base, + registry_.getTxQ().getMetrics(*registry_.openLedger().current()), + registry_.getFeeTrack()}; jvObj[jss::type] = "serverStatus"; jvObj[jss::server_status] = strOperatingMode(); @@ -2189,7 +2195,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr const& val) jvObj[jss::flags] = val->getFlags(); jvObj[jss::signing_time] = *(*val)[~sfSigningTime]; jvObj[jss::data] = strHex(val->getSerializer().slice()); - jvObj[jss::network_id] = app_.config().NETWORK_ID; + jvObj[jss::network_id] = registry_.app().config().NETWORK_ID; if (auto version = (*val)[~sfServerVersion]) jvObj[jss::server_version] = std::to_string(*version); @@ -2200,7 +2206,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr const& val) if (auto hash = (*val)[~sfValidatedHash]) jvObj[jss::validated_hash] = strHex(*hash); - auto const masterKey = app_.validatorManifests().getMasterKey(signerPublic); + auto const masterKey = registry_.validatorManifests().getMasterKey(signerPublic); if (masterKey != signerPublic) jvObj[jss::master_key] = toBase58(TokenType::NodePublic, masterKey); @@ -2307,12 +2313,12 @@ NetworkOPsImp::setMode(OperatingMode om) using namespace std::chrono_literals; if (om == OperatingMode::CONNECTED) { - if (app_.getLedgerMaster().getValidatedLedgerAge() < 1min) + if (registry_.getLedgerMaster().getValidatedLedgerAge() < 1min) om = OperatingMode::SYNCING; } else if (om == OperatingMode::SYNCING) { - if (app_.getLedgerMaster().getValidatedLedgerAge() >= 1min) + if (registry_.getLedgerMaster().getValidatedLedgerAge() >= 1min) om = OperatingMode::CONNECTED; } @@ -2344,7 +2350,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr const& val, std::str else pendingValidations_.insert(val->getLedgerHash()); scope_unlock unlock(lock); - handleNewValidation(app_, val, source, bypassAccept, m_journal); + handleNewValidation(registry_.app(), val, source, bypassAccept, m_journal); } catch (std::exception const& e) { @@ -2366,7 +2372,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr const& val, std::str JLOG(m_journal.debug()) << [this, &val]() -> auto { std::stringstream ss; ss << "VALIDATION: " << val->render() << " master_key: "; - auto master = app_.validators().getTrustedKey(val->getSignerPublic()); + auto master = registry_.validators().getTrustedKey(val->getSignerPublic()); if (master) { ss << toBase58(TokenType::NodePublic, *master); @@ -2380,7 +2386,7 @@ NetworkOPsImp::recvValidation(std::shared_ptr const& val, std::str // We will always relay trusted validations; if configured, we will // also relay all untrusted validations. - return app_.config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted(); + return registry_.app().config().RELAY_UNTRUSTED_VALIDATIONS == 1 || val->isTrusted(); } Json::Value @@ -2422,7 +2428,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) "One or more unsupported amendments have reached majority. " "Upgrade to the latest version before they are activated " "to avoid being amendment blocked."; - if (auto const expected = app_.getAmendmentTable().firstUnsupportedExpected()) + if (auto const expected = registry_.getAmendmentTable().firstUnsupportedExpected()) { auto& d = w[jss::details] = Json::objectValue; d[jss::expected_date] = expected->time_since_epoch().count(); @@ -2439,8 +2445,8 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) info[jss::hostid] = getHostId(admin); // domain: if configured with a domain, report it: - if (!app_.config().SERVER_DOMAIN.empty()) - info[jss::server_domain] = app_.config().SERVER_DOMAIN; + if (!registry_.app().config().SERVER_DOMAIN.empty()) + info[jss::server_domain] = registry_.app().config().SERVER_DOMAIN; info[jss::build_version] = BuildInfo::getVersionString(); @@ -2451,11 +2457,11 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (needNetworkLedger_) info[jss::network_ledger] = "waiting"; - info[jss::validation_quorum] = static_cast(app_.validators().quorum()); + info[jss::validation_quorum] = static_cast(registry_.validators().quorum()); if (admin) { - switch (app_.config().NODE_SIZE) + switch (registry_.app().config().NODE_SIZE) { case 0: info[jss::node_size] = "tiny"; @@ -2474,7 +2480,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) break; } - auto when = app_.validators().expires(); + auto when = registry_.validators().expires(); if (!human) { @@ -2487,7 +2493,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) { auto& x = (info[jss::validator_list] = Json::objectValue); - x[jss::count] = static_cast(app_.validators().count()); + x[jss::count] = static_cast(registry_.validators().count()); if (when) { @@ -2500,7 +2506,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) { x[jss::expiration] = to_string(*when); - if (*when > app_.timeKeeper().now()) + if (*when > registry_.timeKeeper().now()) x[jss::status] = "active"; else x[jss::status] = "expired"; @@ -2525,11 +2531,12 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) } #endif } - info[jss::io_latency_ms] = static_cast(app_.getIOLatency().count()); + info[jss::io_latency_ms] = static_cast(registry_.app().getIOLatency().count()); if (admin) { - if (auto const localPubKey = app_.validators().localPublicKey(); localPubKey && app_.getValidationPublicKey()) + if (auto const localPubKey = registry_.validators().localPublicKey(); + localPubKey && registry_.app().getValidationPublicKey()) { info[jss::pubkey_validator] = toBase58(TokenType::NodePublic, localPubKey.value()); } @@ -2541,17 +2548,17 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (counters) { - info[jss::counters] = app_.getPerfLog().countersJson(); + info[jss::counters] = registry_.getPerfLog().countersJson(); Json::Value nodestore(Json::objectValue); - app_.getNodeStore().getCountsJson(nodestore); + registry_.getNodeStore().getCountsJson(nodestore); info[jss::counters][jss::nodestore] = nodestore; - info[jss::current_activities] = app_.getPerfLog().currentJson(); + info[jss::current_activities] = registry_.getPerfLog().currentJson(); } - info[jss::pubkey_node] = toBase58(TokenType::NodePublic, app_.nodeIdentity().first); + info[jss::pubkey_node] = toBase58(TokenType::NodePublic, registry_.app().nodeIdentity().first); - info[jss::complete_ledgers] = app_.getLedgerMaster().getCompleteLedgers(); + info[jss::complete_ledgers] = registry_.getLedgerMaster().getCompleteLedgers(); if (amendmentBlocked_) info[jss::amendment_blocked] = true; @@ -2561,7 +2568,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (fp != 0) info[jss::fetch_pack] = Json::UInt(fp); - info[jss::peers] = Json::UInt(app_.overlay().size()); + info[jss::peers] = Json::UInt(registry_.overlay().size()); Json::Value lastClose = Json::objectValue; lastClose[jss::proposers] = Json::UInt(mConsensus.prevProposers()); @@ -2582,13 +2589,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (admin) info[jss::load] = m_job_queue.getJson(); - if (auto const netid = app_.overlay().networkID()) + if (auto const netid = registry_.overlay().networkID()) info[jss::network_id] = static_cast(*netid); - auto const escalationMetrics = app_.getTxQ().getMetrics(*app_.openLedger().current()); + auto const escalationMetrics = registry_.getTxQ().getMetrics(*registry_.openLedger().current()); - auto const loadFactorServer = app_.getFeeTrack().getLoadFactor(); - auto const loadBaseServer = app_.getFeeTrack().getLoadBase(); + auto const loadFactorServer = registry_.getFeeTrack().getLoadFactor(); + auto const loadBaseServer = registry_.getFeeTrack().getLoadBase(); /* Scale the escalated fee level to unitless "load factor". In practice, this just strips the units, but it will continue to work correctly if either base value ever changes. */ @@ -2622,13 +2629,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) if (admin) { - std::uint32_t fee = app_.getFeeTrack().getLocalFee(); + std::uint32_t fee = registry_.getFeeTrack().getLocalFee(); if (fee != loadBaseServer) info[jss::load_factor_local] = static_cast(fee) / loadBaseServer; - fee = app_.getFeeTrack().getRemoteFee(); + fee = registry_.getFeeTrack().getRemoteFee(); if (fee != loadBaseServer) info[jss::load_factor_net] = static_cast(fee) / loadBaseServer; - fee = app_.getFeeTrack().getClusterFee(); + fee = registry_.getFeeTrack().getClusterFee(); if (fee != loadBaseServer) info[jss::load_factor_cluster] = static_cast(fee) / loadBaseServer; } @@ -2669,7 +2676,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) l[jss::reserve_base_xrp] = lpClosed->fees().reserve.decimalXRP(); l[jss::reserve_inc_xrp] = lpClosed->fees().increment.decimalXRP(); - if (auto const closeOffset = app_.timeKeeper().closeOffset(); std::abs(closeOffset.count()) >= 60) + if (auto const closeOffset = registry_.timeKeeper().closeOffset(); std::abs(closeOffset.count()) >= 60) l[jss::close_time_offset] = static_cast(closeOffset.count()); constexpr std::chrono::seconds highAgeThreshold{1000000}; @@ -2681,7 +2688,7 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) else { auto lCloseTime = lpClosed->header().closeTime; - auto closeTime = app_.timeKeeper().closeTime(); + auto closeTime = registry_.timeKeeper().closeTime(); if (lCloseTime <= closeTime) { using namespace std::chrono_literals; @@ -2705,16 +2712,16 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) accounting_.json(info); info[jss::uptime] = UptimeClock::now().time_since_epoch().count(); - info[jss::jq_trans_overflow] = std::to_string(app_.overlay().getJqTransOverflow()); - info[jss::peer_disconnects] = std::to_string(app_.overlay().getPeerDisconnect()); - info[jss::peer_disconnects_resources] = std::to_string(app_.overlay().getPeerDisconnectCharges()); + info[jss::jq_trans_overflow] = std::to_string(registry_.overlay().getJqTransOverflow()); + info[jss::peer_disconnects] = std::to_string(registry_.overlay().getPeerDisconnect()); + info[jss::peer_disconnects_resources] = std::to_string(registry_.overlay().getPeerDisconnectCharges()); // This array must be sorted in increasing order. static constexpr std::array protocols{"http", "https", "peer", "ws", "ws2", "wss", "wss2"}; static_assert(std::is_sorted(std::begin(protocols), std::end(protocols))); { Json::Value ports{Json::arrayValue}; - for (auto const& port : app_.getServerHandler().setup().ports) + for (auto const& port : registry_.getServerHandler().setup().ports) { // Don't publish admin ports for non-admin users if (!admin && @@ -2738,9 +2745,9 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) } } - if (app_.config().exists(SECTION_PORT_GRPC)) + if (registry_.app().config().exists(SECTION_PORT_GRPC)) { - auto const& grpcSection = app_.config().section(SECTION_PORT_GRPC); + auto const& grpcSection = registry_.app().config().section(SECTION_PORT_GRPC); auto const optPort = grpcSection.get("port"); if (optPort && grpcSection.get("ip")) { @@ -2759,13 +2766,13 @@ NetworkOPsImp::getServerInfo(bool human, bool admin, bool counters) void NetworkOPsImp::clearLedgerFetch() { - app_.getInboundLedgers().clearFailures(); + registry_.getInboundLedgers().clearFailures(); } Json::Value NetworkOPsImp::getLedgerFetchInfo() { - return app_.getInboundLedgers().getInfo(); + return registry_.getInboundLedgers().getInfo(); } void @@ -2814,11 +2821,11 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) // Ledgers are published only when they acquire sufficient validations // Holes are filled across connection loss or other catastrophe - std::shared_ptr alpAccepted = app_.getAcceptedLedgerCache().fetch(lpAccepted->header().hash); + std::shared_ptr alpAccepted = registry_.getAcceptedLedgerCache().fetch(lpAccepted->header().hash); if (!alpAccepted) { - alpAccepted = std::make_shared(lpAccepted, app_); - app_.getAcceptedLedgerCache().canonicalize_replace_client(lpAccepted->header().hash, alpAccepted); + alpAccepted = std::make_shared(lpAccepted, registry_.app()); + registry_.getAcceptedLedgerCache().canonicalize_replace_client(lpAccepted->header().hash, alpAccepted); } XRPL_ASSERT(alpAccepted->getLedger().get() == lpAccepted.get(), "xrpl::NetworkOPsImp::pubLedger : accepted input"); @@ -2837,7 +2844,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) jvObj[jss::ledger_hash] = to_string(lpAccepted->header().hash); jvObj[jss::ledger_time] = Json::Value::UInt(lpAccepted->header().closeTime.time_since_epoch().count()); - jvObj[jss::network_id] = app_.config().NETWORK_ID; + jvObj[jss::network_id] = registry_.app().config().NETWORK_ID; if (!lpAccepted->rules().enabled(featureXRPFees)) jvObj[jss::fee_ref] = Config::FEE_UNITS_DEPRECATED; @@ -2849,7 +2856,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) if (mMode >= OperatingMode::SYNCING) { - jvObj[jss::validated_ledgers] = app_.getLedgerMaster().getCompleteLedgers(); + jvObj[jss::validated_ledgers] = registry_.getLedgerMaster().getCompleteLedgers(); } auto it = mStreamMaps[sLedger].begin(); @@ -2917,9 +2924,9 @@ void NetworkOPsImp::reportFeeChange() { ServerFeeSummary f{ - app_.openLedger().current()->fees().base, - app_.getTxQ().getMetrics(*app_.openLedger().current()), - app_.getFeeTrack()}; + registry_.openLedger().current()->fees().base, + registry_.getTxQ().getMetrics(*registry_.openLedger().current()), + registry_.getFeeTrack()}; // only schedule the job if something has changed if (f != mLastFeeSummary) @@ -2980,7 +2987,7 @@ NetworkOPsImp::transJson( lookup.second && lookup.second->isFieldPresent(sfTransactionIndex)) { uint32_t const txnSeq = lookup.second->getFieldU32(sfTransactionIndex); - uint32_t netID = app_.config().NETWORK_ID; + uint32_t netID = registry_.app().config().NETWORK_ID; if (transaction->isFieldPresent(sfNetworkID)) netID = transaction->getFieldU32(sfNetworkID); @@ -3018,7 +3025,7 @@ NetworkOPsImp::transJson( // If the offer create is not self funded then add the owner balance if (account != amount.issue().account) { - auto const ownerFunds = accountFunds(*ledger, account, amount, fhIGNORE_FREEZE, app_.journal("View")); + auto const ownerFunds = accountFunds(*ledger, account, amount, fhIGNORE_FREEZE, registry_.journal("View")); jvObj[jss::transaction][jss::owner_funds] = ownerFunds.getText(); } } @@ -3095,7 +3102,7 @@ NetworkOPsImp::pubValidatedTransaction( } if (transaction.getResult() == tesSUCCESS) - app_.getOrderBookDB().processTxn(ledger, transaction, jvObj); + registry_.getOrderBookDB().processTxn(ledger, transaction, jvObj); pubAccountTransaction(ledger, transaction, last); } @@ -3381,7 +3388,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) static auto const databaseType = [&]() -> DatabaseType { // Use a dynamic_cast to return DatabaseType::None // on failure. - if (dynamic_cast(&app_.getRelationalDatabase())) + if (dynamic_cast(®istry_.getRelationalDatabase())) { return DatabaseType::Sqlite; } @@ -3403,7 +3410,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) // LCOV_EXCL_STOP } - app_.getJobQueue().addJob(jtCLIENT_ACCT_HIST, "HistTxStream", [this, dbType = databaseType, subInfo]() { + registry_.getJobQueue().addJob(jtCLIENT_ACCT_HIST, "HistTxStream", [this, dbType = databaseType, subInfo]() { auto const& accountId = subInfo.index_->accountId_; auto& lastLedgerSeq = subInfo.index_->historyLastLedgerSeq_; auto& txHistoryIndex = subInfo.index_->historyTxIndex_; @@ -3478,7 +3485,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) switch (dbType) { case Sqlite: { - auto db = static_cast(&app_.getRelationalDatabase()); + auto db = static_cast(®istry_.getRelationalDatabase()); RelationalDatabase::AccountTxPageOptions options{accountId, minLedger, maxLedger, marker, 0, true}; return db->newestAccountTxPage(options); } @@ -3519,7 +3526,8 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) auto haveRange = [&]() -> bool { std::uint32_t validatedMin = UINT_MAX; std::uint32_t validatedMax = 0; - auto haveSomeValidatedLedgers = app_.getLedgerMaster().getValidatedRange(validatedMin, validatedMax); + auto haveSomeValidatedLedgers = + registry_.getLedgerMaster().getValidatedRange(validatedMin, validatedMax); return haveSomeValidatedLedgers && validatedMin <= startLedgerSeq && lastLedgerSeq <= validatedMax; }(); @@ -3564,7 +3572,7 @@ NetworkOPsImp::addAccountHistoryJob(SubAccountHistoryInfoWeak subInfo) send(rpcError(rpcINTERNAL), true); return; } - auto curTxLedger = app_.getLedgerMaster().getLedgerBySeq(tx->getLedger()); + auto curTxLedger = registry_.getLedgerMaster().getLedgerBySeq(tx->getLedger()); if (!curTxLedger) { // LCOV_EXCL_START @@ -3704,7 +3712,7 @@ NetworkOPsImp::subAccountHistory(InfoSub::ref isrListener, AccountID const& acco simIterator->second.emplace(isrListener->getSeq(), ahi); } - auto const ledger = app_.getLedgerMaster().getValidatedLedger(); + auto const ledger = registry_.getLedgerMaster().getValidatedLedger(); if (ledger) { subAccountHistoryStart(ledger, ahi); @@ -3758,7 +3766,7 @@ NetworkOPsImp::unsubAccountHistoryInternal(std::uint64_t seq, AccountID const& a bool NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) { - if (auto listeners = app_.getOrderBookDB().makeBookListeners(book)) + if (auto listeners = registry_.getOrderBookDB().makeBookListeners(book)) listeners->addSubscriber(isrListener); else { @@ -3772,7 +3780,7 @@ NetworkOPsImp::subBook(InfoSub::ref isrListener, Book const& book) bool NetworkOPsImp::unsubBook(std::uint64_t uSeq, Book const& book) { - if (auto listeners = app_.getOrderBookDB().getBookListeners(book)) + if (auto listeners = registry_.getOrderBookDB().getBookListeners(book)) listeners->removeSubscriber(uSeq); return true; @@ -3791,7 +3799,7 @@ NetworkOPsImp::acceptLedger(std::optional consensusDe // FIXME Could we improve on this and remove the need for a specialized // API in Consensus? beginConsensus(m_ledgerMaster.getClosedLedger()->header().hash, {}); - mConsensus.simulate(app_.timeKeeper().closeTime(), consensusDelay); + mConsensus.simulate(registry_.timeKeeper().closeTime(), consensusDelay); return m_ledgerMaster.getCurrentLedger()->header().seq; } @@ -3809,12 +3817,12 @@ NetworkOPsImp::subLedger(InfoSub::ref isrListener, Json::Value& jvResult) jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped(); jvResult[jss::reserve_base] = lpClosed->fees().reserve.jsonClipped(); jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped(); - jvResult[jss::network_id] = app_.config().NETWORK_ID; + jvResult[jss::network_id] = registry_.app().config().NETWORK_ID; } if ((mMode >= OperatingMode::SYNCING) && !isNeedNetworkLedger()) { - jvResult[jss::validated_ledgers] = app_.getLedgerMaster().getCompleteLedgers(); + jvResult[jss::validated_ledgers] = registry_.getLedgerMaster().getCompleteLedgers(); } std::lock_guard sl(mSubLock); @@ -3873,13 +3881,13 @@ NetworkOPsImp::subServer(InfoSub::ref isrListener, Json::Value& jvResult, bool a // CHECKME: is it necessary to provide a random number here? beast::rngfill(uRandom.begin(), uRandom.size(), crypto_prng()); - auto const& feeTrack = app_.getFeeTrack(); + auto const& feeTrack = registry_.getFeeTrack(); jvResult[jss::random] = to_string(uRandom); jvResult[jss::server_status] = strOperatingMode(admin); jvResult[jss::load_base] = feeTrack.getLoadBase(); jvResult[jss::load_factor] = feeTrack.getLoadFactor(); jvResult[jss::hostid] = getHostId(admin); - jvResult[jss::pubkey_node] = toBase58(TokenType::NodePublic, app_.nodeIdentity().first); + jvResult[jss::pubkey_node] = toBase58(TokenType::NodePublic, registry_.app().nodeIdentity().first); std::lock_guard sl(mSubLock); return mStreamMaps[sServer].emplace(isrListener->getSeq(), isrListener).second; @@ -4065,7 +4073,7 @@ NetworkOPsImp::getBookPage( STAmount saDirRate; auto const rate = transferRate(view, book.out.account); - auto viewJ = app_.journal("View"); + auto viewJ = registry_.journal("View"); while (!bDone && iLimit-- > 0) { @@ -4413,7 +4421,7 @@ NetworkOPsImp::StateAccounting::json(Json::Value& obj) const std::unique_ptr make_NetworkOPs( - Application& app, + ServiceRegistry& registry, NetworkOPs::clock_type& clock, bool standalone, std::size_t minPeerCount, @@ -4426,7 +4434,7 @@ make_NetworkOPs( beast::insight::Collector::ptr const& collector) { return std::make_unique( - app, + registry, clock, standalone, minPeerCount, diff --git a/src/xrpld/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp index c963d18d2c..8de47207a6 100644 --- a/src/xrpld/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index 0edd0de9be..3a46d2baa1 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -13,6 +12,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/app/misc/make_NetworkOPs.h b/src/xrpld/app/misc/make_NetworkOPs.h new file mode 100644 index 0000000000..7dce966f04 --- /dev/null +++ b/src/xrpld/app/misc/make_NetworkOPs.h @@ -0,0 +1,32 @@ +#pragma once + +#include +#include +#include +#include +#include + +#include + +#include + +namespace xrpl { + +class LedgerMaster; +class ValidatorKeys; + +std::unique_ptr +make_NetworkOPs( + ServiceRegistry& registry, + NetworkOPs::clock_type& clock, + bool standalone, + std::size_t minPeerCount, + bool start_valid, + JobQueue& job_queue, + LedgerMaster& ledgerMaster, + ValidatorKeys const& validatorKeys, + boost::asio::io_context& io_svc, + beast::Journal journal, + beast::insight::Collector::ptr const& collector); + +} // namespace xrpl diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index e2a3e14485..53a4e03752 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/paths/PathRequest.h b/src/xrpld/app/paths/PathRequest.h index 864d2cb932..09e97e4497 100644 --- a/src/xrpld/app/paths/PathRequest.h +++ b/src/xrpld/app/paths/PathRequest.h @@ -3,11 +3,11 @@ #include #include #include -#include #include #include #include +#include #include #include diff --git a/src/xrpld/app/rdb/backend/SQLiteDatabase.h b/src/xrpld/app/rdb/backend/SQLiteDatabase.h index b79b66787e..963ec1da72 100644 --- a/src/xrpld/app/rdb/backend/SQLiteDatabase.h +++ b/src/xrpld/app/rdb/backend/SQLiteDatabase.h @@ -2,7 +2,11 @@ #include +#include #include +#include +#include +#include namespace xrpl { @@ -378,7 +382,7 @@ public: SQLiteDatabase& operator=(SQLiteDatabase const&) = delete; SQLiteDatabase& - operator=(SQLiteDatabase&& rhs) = delete; + operator=(SQLiteDatabase&&) = delete; /** * @brief ledgerDbHasSpace Checks if the ledger database has available @@ -400,7 +404,7 @@ public: private: ServiceRegistry& registry_; - bool const useTxTables_; + bool useTxTables_; beast::Journal j_; std::unique_ptr ledgerDb_, txdb_; @@ -464,7 +468,9 @@ private: /** * @brief setup_RelationalDatabase Creates and returns a SQLiteDatabase - * instance based on configuration. + * instance based on configuration. It's recommended to use it as + * a singleton, but it's not enforced (e.g. if you have more than one + * database). * @param registry The service registry. * @param config Config object. * @param jobQueue JobQueue object. diff --git a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp index 6c3e76a86f..93d7662917 100644 --- a/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp +++ b/src/xrpld/app/rdb/backend/detail/SQLiteDatabase.cpp @@ -499,6 +499,13 @@ SQLiteDatabase::getTransaction( return TxSearched::unknown; } +SQLiteDatabase::SQLiteDatabase(SQLiteDatabase&& rhs) noexcept + : registry_(rhs.registry_), useTxTables_(rhs.useTxTables_), j_(rhs.j_) +{ + std::exchange(ledgerDb_, std::move(rhs.ledgerDb_)); + std::exchange(txdb_, std::move(rhs.txdb_)); +} + bool SQLiteDatabase::ledgerDbHasSpace(Config const& config) { @@ -587,15 +594,6 @@ SQLiteDatabase::SQLiteDatabase(ServiceRegistry& registry, Config const& config, } } -SQLiteDatabase::SQLiteDatabase(SQLiteDatabase&& rhs) noexcept - : registry_(rhs.registry_) - , useTxTables_(rhs.useTxTables_) - , j_(rhs.j_) - , ledgerDb_(std::move(rhs.ledgerDb_)) - , txdb_(std::move(rhs.txdb_)) -{ -} - SQLiteDatabase setup_RelationalDatabase(ServiceRegistry& registry, Config const& config, JobQueue& jobQueue) { diff --git a/src/xrpld/app/rdb/detail/RelationalDatabase.cpp b/src/xrpld/app/rdb/detail/RelationalDatabase.cpp deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index dbef2eadf9..67c7db68c5 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 549bff024e..ceefab24f1 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 0664f64256..d66a57bae6 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/Context.h b/src/xrpld/rpc/Context.h index 7ff02a9e8b..e77d9adeb3 100644 --- a/src/xrpld/rpc/Context.h +++ b/src/xrpld/rpc/Context.h @@ -1,10 +1,10 @@ #pragma once -#include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/RPCSub.h b/src/xrpld/rpc/RPCSub.h index 53c46139cb..e89f8f34e4 100644 --- a/src/xrpld/rpc/RPCSub.h +++ b/src/xrpld/rpc/RPCSub.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include #include diff --git a/src/xrpld/rpc/detail/Handler.h b/src/xrpld/rpc/detail/Handler.h index f6fadd9cbd..664fd04ab8 100644 --- a/src/xrpld/rpc/detail/Handler.h +++ b/src/xrpld/rpc/detail/Handler.h @@ -1,12 +1,12 @@ #pragma once #include -#include #include #include #include #include +#include namespace Json { class Object; diff --git a/src/xrpld/rpc/detail/RPCHandler.cpp b/src/xrpld/rpc/detail/RPCHandler.cpp index 93cb58a117..159649e6d7 100644 --- a/src/xrpld/rpc/detail/RPCHandler.cpp +++ b/src/xrpld/rpc/detail/RPCHandler.cpp @@ -2,10 +2,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -18,6 +16,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/xrpld/rpc/detail/RPCHelpers.h b/src/xrpld/rpc/detail/RPCHelpers.h index 1b5e06ce42..b0dc839404 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.h +++ b/src/xrpld/rpc/detail/RPCHelpers.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.h b/src/xrpld/rpc/detail/RPCLedgerHelpers.h index b2d9df809f..81877e6f49 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.h +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include #include @@ -8,6 +8,7 @@ #include #include +#include #include diff --git a/src/xrpld/rpc/detail/ServerHandler.cpp b/src/xrpld/rpc/detail/ServerHandler.cpp index d40965ec79..9c18143eb4 100644 --- a/src/xrpld/rpc/detail/ServerHandler.cpp +++ b/src/xrpld/rpc/detail/ServerHandler.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/rpc/detail/TransactionSign.h b/src/xrpld/rpc/detail/TransactionSign.h index cc85d67815..8d064d65d5 100644 --- a/src/xrpld/rpc/detail/TransactionSign.h +++ b/src/xrpld/rpc/detail/TransactionSign.h @@ -1,10 +1,11 @@ #pragma once #include -#include #include #include +#include + namespace xrpl { // Forward declarations diff --git a/src/xrpld/rpc/detail/WSInfoSub.h b/src/xrpld/rpc/detail/WSInfoSub.h index 8ed5ff8d6d..4042cd5479 100644 --- a/src/xrpld/rpc/detail/WSInfoSub.h +++ b/src/xrpld/rpc/detail/WSInfoSub.h @@ -1,10 +1,10 @@ #pragma once -#include #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/handlers/BookOffers.cpp b/src/xrpld/rpc/handlers/BookOffers.cpp index 1a79bdcdd2..ff49bf2290 100644 --- a/src/xrpld/rpc/handlers/BookOffers.cpp +++ b/src/xrpld/rpc/handlers/BookOffers.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -12,6 +11,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/ConsensusInfo.cpp b/src/xrpld/rpc/handlers/ConsensusInfo.cpp index 386ff99458..f9c5a97785 100644 --- a/src/xrpld/rpc/handlers/ConsensusInfo.cpp +++ b/src/xrpld/rpc/handlers/ConsensusInfo.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/FetchInfo.cpp b/src/xrpld/rpc/handlers/FetchInfo.cpp index 0a54042820..f25f18acf7 100644 --- a/src/xrpld/rpc/handlers/FetchInfo.cpp +++ b/src/xrpld/rpc/handlers/FetchInfo.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/GetCounts.cpp b/src/xrpld/rpc/handlers/GetCounts.cpp index 360389ba3a..54600d4761 100644 --- a/src/xrpld/rpc/handlers/GetCounts.cpp +++ b/src/xrpld/rpc/handlers/GetCounts.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/LedgerAccept.cpp b/src/xrpld/rpc/handlers/LedgerAccept.cpp index abf5780629..c7a828863a 100644 --- a/src/xrpld/rpc/handlers/LedgerAccept.cpp +++ b/src/xrpld/rpc/handlers/LedgerAccept.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include #include +#include #include diff --git a/src/xrpld/rpc/handlers/LedgerClosed.cpp b/src/xrpld/rpc/handlers/LedgerClosed.cpp index 3b93e0734f..e26019cca6 100644 --- a/src/xrpld/rpc/handlers/LedgerClosed.cpp +++ b/src/xrpld/rpc/handlers/LedgerClosed.cpp @@ -1,9 +1,9 @@ #include -#include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/LedgerCurrent.cpp b/src/xrpld/rpc/handlers/LedgerCurrent.cpp index c5ca962751..861080c5f2 100644 --- a/src/xrpld/rpc/handlers/LedgerCurrent.cpp +++ b/src/xrpld/rpc/handlers/LedgerCurrent.cpp @@ -1,9 +1,9 @@ #include -#include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/OwnerInfo.cpp b/src/xrpld/rpc/handlers/OwnerInfo.cpp index bbab938cfb..b92d3c7d0a 100644 --- a/src/xrpld/rpc/handlers/OwnerInfo.cpp +++ b/src/xrpld/rpc/handlers/OwnerInfo.cpp @@ -1,11 +1,11 @@ #include -#include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/ServerInfo.cpp b/src/xrpld/rpc/handlers/ServerInfo.cpp index 70b92c99bd..1086760bf6 100644 --- a/src/xrpld/rpc/handlers/ServerInfo.cpp +++ b/src/xrpld/rpc/handlers/ServerInfo.cpp @@ -1,10 +1,10 @@ -#include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/ServerState.cpp b/src/xrpld/rpc/handlers/ServerState.cpp index e2adbc8ff2..603b9f9c51 100644 --- a/src/xrpld/rpc/handlers/ServerState.cpp +++ b/src/xrpld/rpc/handlers/ServerState.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/Subscribe.cpp b/src/xrpld/rpc/handlers/Subscribe.cpp index c1f506e623..574da255d2 100644 --- a/src/xrpld/rpc/handlers/Subscribe.cpp +++ b/src/xrpld/rpc/handlers/Subscribe.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -12,6 +11,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index 2f8d71c2c8..d2d7bed04d 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/rpc/handlers/Unsubscribe.cpp b/src/xrpld/rpc/handlers/Unsubscribe.cpp index 24c4cd51a5..da5cd8eecb 100644 --- a/src/xrpld/rpc/handlers/Unsubscribe.cpp +++ b/src/xrpld/rpc/handlers/Unsubscribe.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include namespace xrpl { From cd218346ff561f531871dc45e49927fa2d19903c Mon Sep 17 00:00:00 2001 From: nuxtreact Date: Fri, 13 Feb 2026 03:55:27 +0800 Subject: [PATCH 12/16] chore: Fix minor issues in comments (#6346) --- docs/CodingStyle.md | 4 ++-- src/xrpld/app/tx/detail/XChainBridge.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CodingStyle.md b/docs/CodingStyle.md index 3c26709047..2788f7b210 100644 --- a/docs/CodingStyle.md +++ b/docs/CodingStyle.md @@ -17,8 +17,8 @@ guideline is to maintain the standards that are used in those libraries. ## Guidelines If you want to do something contrary to these guidelines, understand -why you're doing it. Think, use common sense, and consider that this -your changes will probably need to be maintained long after you've +why you're doing it. Think, use common sense, and consider that these +changes will probably need to be maintained long after you've moved on to other projects. - Use white space and blank lines to guide the eye and keep your intent clear. diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/xrpld/app/tx/detail/XChainBridge.cpp index beeab41f67..f4abb9145b 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/xrpld/app/tx/detail/XChainBridge.cpp @@ -556,7 +556,7 @@ struct FinalizeClaimHelperResult the fields mean. The individual ters need to be returned instead of an overall ter because the caller needs this information if the attestation list changed or not. - */ +*/ FinalizeClaimHelperResult finalizeClaimHelper( From ac0ad3627f8fbcf5b2e9147405f7eff94d02976a Mon Sep 17 00:00:00 2001 From: Jingchen Date: Fri, 13 Feb 2026 15:34:37 +0000 Subject: [PATCH 13/16] refactor: Modularize `HashRouter`, `Conditions`, and `OrderBookDB` (#6226) This change modularizes additional components by moving code to `libxrpl`. --- .../scripts/levelization/results/ordering.txt | 12 ++- cmake/XrplCore.cmake | 14 ++- cmake/XrplInstall.cmake | 1 + .../xrpl}/conditions/Condition.h | 3 +- .../xrpl}/conditions/Fulfillment.h | 3 +- .../xrpl}/conditions/detail/PreimageSha256.h | 7 +- .../xrpl}/conditions/detail/error.h | 0 .../xrpl}/conditions/detail/utils.h | 3 +- .../misc => include/xrpl/core}/HashRouter.h | 3 - include/xrpl/core/ServiceRegistry.h | 7 ++ .../xrpl}/ledger/AcceptedLedgerTx.h | 8 +- .../xrpl}/ledger/BookListeners.h | 0 include/xrpl/ledger/OrderBookDB.h | 93 +++++++++++++++++++ include/xrpl/server/NetworkOPs.h | 3 +- .../conditions}/Condition.cpp | 6 +- .../conditions}/Fulfillment.cpp | 9 +- .../detail => libxrpl/conditions}/error.cpp | 3 +- .../app/misc => libxrpl/core}/HashRouter.cpp | 37 +------- .../ledger/AcceptedLedgerTx.cpp | 4 +- .../app => libxrpl}/ledger/BookListeners.cpp | 2 +- src/test/app/Batch_test.cpp | 2 +- src/test/app/HashRouter_test.cpp | 3 +- src/test/app/NetworkOPs_test.cpp | 2 +- src/test/conditions/PreimageSha256_test.cpp | 7 +- src/xrpld/app/consensus/RCLConsensus.cpp | 2 +- src/xrpld/app/ledger/AcceptedLedger.cpp | 2 +- src/xrpld/app/ledger/AcceptedLedger.h | 6 +- src/xrpld/app/ledger/Ledger.cpp | 2 +- src/xrpld/app/ledger/OrderBookDB.h | 75 --------------- .../{OrderBookDB.cpp => OrderBookDBImpl.cpp} | 51 ++++++---- src/xrpld/app/ledger/OrderBookDBImpl.h | 93 +++++++++++++++++++ src/xrpld/app/ledger/detail/LedgerMaster.cpp | 2 +- src/xrpld/app/ledger/detail/OpenLedger.cpp | 2 +- src/xrpld/app/main/Application.cpp | 14 +-- src/xrpld/app/main/Application.h | 7 -- src/xrpld/app/misc/AmendmentTable.h | 3 +- src/xrpld/app/misc/NetworkOPs.cpp | 6 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 16 ++-- src/xrpld/app/misc/detail/Transaction.cpp | 2 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 2 +- .../app/misc/detail/setup_HashRouter.cpp | 42 +++++++++ src/xrpld/app/misc/setup_HashRouter.h | 17 ++++ src/xrpld/app/paths/Pathfinder.cpp | 2 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 2 +- src/xrpld/app/tx/detail/AMMCreate.cpp | 2 +- src/xrpld/app/tx/detail/Batch.cpp | 1 + src/xrpld/app/tx/detail/Batch.h | 1 - src/xrpld/app/tx/detail/CancelCheck.cpp | 2 +- src/xrpld/app/tx/detail/CashCheck.cpp | 2 +- src/xrpld/app/tx/detail/CreateOffer.cpp | 2 +- src/xrpld/app/tx/detail/CreateTicket.cpp | 1 + src/xrpld/app/tx/detail/CreateTicket.h | 1 - src/xrpld/app/tx/detail/Escrow.cpp | 6 +- src/xrpld/app/tx/detail/SetAccount.cpp | 1 - src/xrpld/app/tx/detail/Transactor.cpp | 3 +- src/xrpld/app/tx/detail/apply.cpp | 3 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 2 +- src/xrpld/overlay/detail/PeerImp.cpp | 2 +- src/xrpld/overlay/detail/PeerImp.h | 2 +- src/xrpld/rpc/handlers/Simulate.cpp | 2 +- 60 files changed, 385 insertions(+), 228 deletions(-) rename {src/xrpld => include/xrpl}/conditions/Condition.h (98%) rename {src/xrpld => include/xrpl}/conditions/Fulfillment.h (98%) rename {src/xrpld => include/xrpl}/conditions/detail/PreimageSha256.h (95%) rename {src/xrpld => include/xrpl}/conditions/detail/error.h (100%) rename {src/xrpld => include/xrpl}/conditions/detail/utils.h (98%) rename {src/xrpld/app/misc => include/xrpl/core}/HashRouter.h (99%) rename {src/xrpld/app => include/xrpl}/ledger/AcceptedLedgerTx.h (92%) rename {src/xrpld/app => include/xrpl}/ledger/BookListeners.h (100%) create mode 100644 include/xrpl/ledger/OrderBookDB.h rename src/{xrpld/conditions/detail => libxrpl/conditions}/Condition.cpp (97%) rename src/{xrpld/conditions/detail => libxrpl/conditions}/Fulfillment.cpp (94%) rename src/{xrpld/conditions/detail => libxrpl/conditions}/error.cpp (98%) rename src/{xrpld/app/misc => libxrpl/core}/HashRouter.cpp (69%) rename src/{xrpld/app => libxrpl}/ledger/AcceptedLedgerTx.cpp (96%) rename src/{xrpld/app => libxrpl}/ledger/BookListeners.cpp (95%) delete mode 100644 src/xrpld/app/ledger/OrderBookDB.h rename src/xrpld/app/ledger/{OrderBookDB.cpp => OrderBookDBImpl.cpp} (84%) create mode 100644 src/xrpld/app/ledger/OrderBookDBImpl.h create mode 100644 src/xrpld/app/misc/detail/setup_HashRouter.cpp create mode 100644 src/xrpld/app/misc/setup_HashRouter.h diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 1de6f803f3..5f8812c49b 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -1,4 +1,6 @@ libxrpl.basics > xrpl.basics +libxrpl.conditions > xrpl.basics +libxrpl.conditions > xrpl.conditions libxrpl.core > xrpl.basics libxrpl.core > xrpl.core libxrpl.crypto > xrpl.basics @@ -56,7 +58,7 @@ test.basics > xrpl.json test.basics > xrpl.protocol test.beast > xrpl.basics test.conditions > xrpl.basics -test.conditions > xrpld.conditions +test.conditions > xrpl.conditions test.consensus > test.csf test.consensus > test.toplevel test.consensus > test.unit_test @@ -158,6 +160,8 @@ test.unit_test > xrpl.basics tests.libxrpl > xrpl.basics tests.libxrpl > xrpl.json tests.libxrpl > xrpl.net +xrpl.conditions > xrpl.basics +xrpl.conditions > xrpl.protocol xrpl.core > xrpl.basics xrpl.core > xrpl.json xrpl.core > xrpl.ledger @@ -165,6 +169,7 @@ xrpl.core > xrpl.protocol xrpl.json > xrpl.basics xrpl.ledger > xrpl.basics xrpl.ledger > xrpl.protocol +xrpl.ledger > xrpl.server xrpl.net > xrpl.basics xrpl.nodestore > xrpl.basics xrpl.nodestore > xrpl.protocol @@ -179,7 +184,6 @@ xrpl.resource > xrpl.protocol xrpl.server > xrpl.basics xrpl.server > xrpl.core xrpl.server > xrpl.json -xrpl.server > xrpl.ledger xrpl.server > xrpl.protocol xrpl.server > xrpl.rdb xrpl.server > xrpl.resource @@ -189,8 +193,8 @@ xrpl.shamap > xrpl.nodestore xrpl.shamap > xrpl.protocol xrpld.app > test.unit_test xrpld.app > xrpl.basics +xrpld.app > xrpl.conditions xrpld.app > xrpl.core -xrpld.app > xrpld.conditions xrpld.app > xrpld.consensus xrpld.app > xrpld.core xrpld.app > xrpl.json @@ -202,8 +206,6 @@ xrpld.app > xrpl.rdb xrpld.app > xrpl.resource xrpld.app > xrpl.server xrpld.app > xrpl.shamap -xrpld.conditions > xrpl.basics -xrpld.conditions > xrpl.protocol xrpld.consensus > xrpl.basics xrpld.consensus > xrpl.json xrpld.consensus > xrpl.protocol diff --git a/cmake/XrplCore.cmake b/cmake/XrplCore.cmake index ba14899bd9..3380ca85cd 100644 --- a/cmake/XrplCore.cmake +++ b/cmake/XrplCore.cmake @@ -98,9 +98,18 @@ add_module(xrpl server) target_link_libraries(xrpl.libxrpl.server PUBLIC xrpl.libxrpl.protocol xrpl.libxrpl.core xrpl.libxrpl.rdb xrpl.libxrpl.resource) +add_module(xrpl conditions) +target_link_libraries(xrpl.libxrpl.conditions PUBLIC xrpl.libxrpl.server) + add_module(xrpl ledger) -target_link_libraries(xrpl.libxrpl.ledger PUBLIC xrpl.libxrpl.basics xrpl.libxrpl.json xrpl.libxrpl.protocol - xrpl.libxrpl.rdb) +target_link_libraries( + xrpl.libxrpl.ledger + PUBLIC xrpl.libxrpl.basics + xrpl.libxrpl.json + xrpl.libxrpl.protocol + xrpl.libxrpl.rdb + xrpl.libxrpl.server + xrpl.libxrpl.conditions) add_library(xrpl.libxrpl) set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) @@ -115,6 +124,7 @@ target_link_modules( PUBLIC basics beast + conditions core crypto json diff --git a/cmake/XrplInstall.cmake b/cmake/XrplInstall.cmake index 340dca553b..d2fef5d488 100644 --- a/cmake/XrplInstall.cmake +++ b/cmake/XrplInstall.cmake @@ -20,6 +20,7 @@ install(TARGETS common xrpl.libxrpl xrpl.libxrpl.basics xrpl.libxrpl.beast + xrpl.libxrpl.conditions xrpl.libxrpl.core xrpl.libxrpl.crypto xrpl.libxrpl.json diff --git a/src/xrpld/conditions/Condition.h b/include/xrpl/conditions/Condition.h similarity index 98% rename from src/xrpld/conditions/Condition.h rename to include/xrpl/conditions/Condition.h index 50872e75ef..6b306a3982 100644 --- a/src/xrpld/conditions/Condition.h +++ b/include/xrpl/conditions/Condition.h @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include #include #include diff --git a/src/xrpld/conditions/Fulfillment.h b/include/xrpl/conditions/Fulfillment.h similarity index 98% rename from src/xrpld/conditions/Fulfillment.h rename to include/xrpl/conditions/Fulfillment.h index 840e9f9993..04d0b2aa1e 100644 --- a/src/xrpld/conditions/Fulfillment.h +++ b/include/xrpl/conditions/Fulfillment.h @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include namespace xrpl { namespace cryptoconditions { diff --git a/src/xrpld/conditions/detail/PreimageSha256.h b/include/xrpl/conditions/detail/PreimageSha256.h similarity index 95% rename from src/xrpld/conditions/detail/PreimageSha256.h rename to include/xrpl/conditions/detail/PreimageSha256.h index f3ce1a03e0..8726473c2d 100644 --- a/src/xrpld/conditions/detail/PreimageSha256.h +++ b/include/xrpl/conditions/detail/PreimageSha256.h @@ -1,11 +1,10 @@ #pragma once -#include -#include -#include - #include #include +#include +#include +#include #include #include diff --git a/src/xrpld/conditions/detail/error.h b/include/xrpl/conditions/detail/error.h similarity index 100% rename from src/xrpld/conditions/detail/error.h rename to include/xrpl/conditions/detail/error.h diff --git a/src/xrpld/conditions/detail/utils.h b/include/xrpl/conditions/detail/utils.h similarity index 98% rename from src/xrpld/conditions/detail/utils.h rename to include/xrpl/conditions/detail/utils.h index 2a4187718b..17d93d43b5 100644 --- a/src/xrpld/conditions/detail/utils.h +++ b/include/xrpl/conditions/detail/utils.h @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include #include diff --git a/src/xrpld/app/misc/HashRouter.h b/include/xrpl/core/HashRouter.h similarity index 99% rename from src/xrpld/app/misc/HashRouter.h rename to include/xrpl/core/HashRouter.h index ad6da520bd..dfc57081ee 100644 --- a/src/xrpld/app/misc/HashRouter.h +++ b/include/xrpl/core/HashRouter.h @@ -251,7 +251,4 @@ private: beast::aged_unordered_map> suppressionMap_; }; -HashRouter::Setup -setup_HashRouter(Config const&); - } // namespace xrpl diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index 86591a815f..fabf61f9e4 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -214,6 +214,13 @@ public: virtual Logs& logs() = 0; + virtual std::optional const& + trapTxID() const = 0; + + /** Retrieve the "wallet database" */ + virtual DatabaseCon& + getWalletDB() = 0; + // Temporary: Get the underlying Application for functions that haven't // been migrated yet. This should be removed once all code is migrated. virtual Application& diff --git a/src/xrpld/app/ledger/AcceptedLedgerTx.h b/include/xrpl/ledger/AcceptedLedgerTx.h similarity index 92% rename from src/xrpld/app/ledger/AcceptedLedgerTx.h rename to include/xrpl/ledger/AcceptedLedgerTx.h index 6c936bbcf2..d07016b860 100644 --- a/src/xrpld/app/ledger/AcceptedLedgerTx.h +++ b/include/xrpl/ledger/AcceptedLedgerTx.h @@ -1,15 +1,15 @@ #pragma once -#include - +#include +#include #include +#include +#include #include namespace xrpl { -class Logs; - /** A transaction that is in a closed ledger. diff --git a/src/xrpld/app/ledger/BookListeners.h b/include/xrpl/ledger/BookListeners.h similarity index 100% rename from src/xrpld/app/ledger/BookListeners.h rename to include/xrpl/ledger/BookListeners.h diff --git a/include/xrpl/ledger/OrderBookDB.h b/include/xrpl/ledger/OrderBookDB.h new file mode 100644 index 0000000000..3d689607bf --- /dev/null +++ b/include/xrpl/ledger/OrderBookDB.h @@ -0,0 +1,93 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace xrpl { + +/** Tracks order books in the ledger. + + This interface provides access to order book information, including: + - Which order books exist in the ledger + - Querying order books by issue + - Managing order book subscriptions + + The order book database is updated as ledgers are accepted and provides + efficient lookup of order book information for pathfinding and client + subscriptions. +*/ +class OrderBookDB +{ +public: + virtual ~OrderBookDB() = default; + + /** Initialize or update the order book database with a new ledger. + + This method should be called when a new ledger is accepted to update + the order book database with the current state of all order books. + + @param ledger The ledger to scan for order books + */ + virtual void + setup(std::shared_ptr const& ledger) = 0; + + /** Add an order book to track. + + @param book The order book to add + */ + virtual void + addOrderBook(Book const& book) = 0; + + /** Get all order books that want a specific issue. + + Returns a list of all order books where the taker pays the specified + issue. This is useful for pathfinding to find all possible next hops + from a given currency. + + @param issue The issue to search for + @param domain Optional domain restriction for the order book + @return Vector of books that want this issue + */ + virtual std::vector + getBooksByTakerPays(Issue const& issue, std::optional const& domain = std::nullopt) = 0; + + /** Get the count of order books that want a specific issue. + + @param issue The issue to search for + @param domain Optional domain restriction for the order book + @return Number of books that want this issue + */ + virtual int + getBookSize(Issue const& issue, std::optional const& domain = std::nullopt) = 0; + + /** Check if an order book to XRP exists for the given issue. + + @param issue The issue to check + @param domain Optional domain restriction for the order book + @return true if a book from this issue to XRP exists + */ + virtual bool + isBookToXRP(Issue const& issue, std::optional domain = std::nullopt) = 0; + + virtual void + processTxn( + std::shared_ptr const& ledger, + AcceptedLedgerTx const& alTx, + MultiApiJson const& jvObj) = 0; + + virtual BookListeners::pointer + getBookListeners(Book const&) = 0; + virtual BookListeners::pointer + makeBookListeners(Book const&) = 0; +}; + +} // namespace xrpl diff --git a/include/xrpl/server/NetworkOPs.h b/include/xrpl/server/NetworkOPs.h index cfe0021c07..ce55f667f7 100644 --- a/include/xrpl/server/NetworkOPs.h +++ b/include/xrpl/server/NetworkOPs.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -19,6 +18,8 @@ namespace xrpl { // Master operational handler, server sequencer, network tracker class Peer; +class STTx; +class ReadView; class LedgerMaster; class Transaction; class ValidatorKeys; diff --git a/src/xrpld/conditions/detail/Condition.cpp b/src/libxrpl/conditions/Condition.cpp similarity index 97% rename from src/xrpld/conditions/detail/Condition.cpp rename to src/libxrpl/conditions/Condition.cpp index 9cac75121d..30beba3402 100644 --- a/src/xrpld/conditions/detail/Condition.cpp +++ b/src/libxrpl/conditions/Condition.cpp @@ -1,6 +1,6 @@ -#include -#include -#include +#include +#include +#include namespace xrpl { namespace cryptoconditions { diff --git a/src/xrpld/conditions/detail/Fulfillment.cpp b/src/libxrpl/conditions/Fulfillment.cpp similarity index 94% rename from src/xrpld/conditions/detail/Fulfillment.cpp rename to src/libxrpl/conditions/Fulfillment.cpp index 9ecaa44ab8..11581a8705 100644 --- a/src/xrpld/conditions/detail/Fulfillment.cpp +++ b/src/libxrpl/conditions/Fulfillment.cpp @@ -1,9 +1,8 @@ -#include -#include -#include -#include - #include +#include +#include +#include +#include namespace xrpl { namespace cryptoconditions { diff --git a/src/xrpld/conditions/detail/error.cpp b/src/libxrpl/conditions/error.cpp similarity index 98% rename from src/xrpld/conditions/detail/error.cpp rename to src/libxrpl/conditions/error.cpp index 04c8d03fbb..3124be6fdd 100644 --- a/src/xrpld/conditions/detail/error.cpp +++ b/src/libxrpl/conditions/error.cpp @@ -1,6 +1,5 @@ -#include - #include +#include #include diff --git a/src/xrpld/app/misc/HashRouter.cpp b/src/libxrpl/core/HashRouter.cpp similarity index 69% rename from src/xrpld/app/misc/HashRouter.cpp rename to src/libxrpl/core/HashRouter.cpp index eca46c9872..dff1394f77 100644 --- a/src/xrpld/app/misc/HashRouter.cpp +++ b/src/libxrpl/core/HashRouter.cpp @@ -1,5 +1,4 @@ -#include -#include +#include namespace xrpl { @@ -108,38 +107,4 @@ HashRouter::shouldRelay(uint256 const& key) -> std::optional( - "HashRouter hold time must be at least 12 seconds (the " - "approximate validation time for three ledgers)."); - setup.holdTime = seconds(tmp); - } - if (set(tmp, "relay_time", section)) - { - if (tmp < 8) - Throw( - "HashRouter relay time must be at least 8 seconds (the " - "approximate validation time for two ledgers)."); - setup.relayTime = seconds(tmp); - } - if (setup.relayTime > setup.holdTime) - { - Throw("HashRouter relay time must be less than or equal to hold time"); - } - - return setup; -} - } // namespace xrpl diff --git a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp b/src/libxrpl/ledger/AcceptedLedgerTx.cpp similarity index 96% rename from src/xrpld/app/ledger/AcceptedLedgerTx.cpp rename to src/libxrpl/ledger/AcceptedLedgerTx.cpp index 2ef05e511d..3f35f7cbc2 100644 --- a/src/xrpld/app/ledger/AcceptedLedgerTx.cpp +++ b/src/libxrpl/ledger/AcceptedLedgerTx.cpp @@ -1,7 +1,7 @@ -#include - #include #include +#include +#include #include #include diff --git a/src/xrpld/app/ledger/BookListeners.cpp b/src/libxrpl/ledger/BookListeners.cpp similarity index 95% rename from src/xrpld/app/ledger/BookListeners.cpp rename to src/libxrpl/ledger/BookListeners.cpp index 4d72c6f3b3..9ba25b783a 100644 --- a/src/xrpld/app/ledger/BookListeners.cpp +++ b/src/libxrpl/ledger/BookListeners.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index 133f10cd28..a4e00f26db 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -2,11 +2,11 @@ #include #include -#include #include #include #include +#include #include #include #include diff --git a/src/test/app/HashRouter_test.cpp b/src/test/app/HashRouter_test.cpp index 03bb28e35a..753922a67d 100644 --- a/src/test/app/HashRouter_test.cpp +++ b/src/test/app/HashRouter_test.cpp @@ -1,8 +1,9 @@ -#include +#include #include #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/app/NetworkOPs_test.cpp b/src/test/app/NetworkOPs_test.cpp index ffca1ed79d..a4bdae9101 100644 --- a/src/test/app/NetworkOPs_test.cpp +++ b/src/test/app/NetworkOPs_test.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include namespace xrpl { namespace test { diff --git a/src/test/conditions/PreimageSha256_test.cpp b/src/test/conditions/PreimageSha256_test.cpp index 71ba526be3..c3508758a7 100644 --- a/src/test/conditions/PreimageSha256_test.cpp +++ b/src/test/conditions/PreimageSha256_test.cpp @@ -1,12 +1,11 @@ -#include -#include -#include - #include #include #include #include #include +#include +#include +#include #include #include diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index 4ebd1a502f..ad581585b1 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include #include @@ -21,6 +20,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/AcceptedLedger.cpp b/src/xrpld/app/ledger/AcceptedLedger.cpp index 89806c2337..7ad43b2d81 100644 --- a/src/xrpld/app/ledger/AcceptedLedger.cpp +++ b/src/xrpld/app/ledger/AcceptedLedger.cpp @@ -4,7 +4,7 @@ namespace xrpl { -AcceptedLedger::AcceptedLedger(std::shared_ptr const& ledger, Application& app) : mLedger(ledger) +AcceptedLedger::AcceptedLedger(std::shared_ptr const& ledger) : mLedger(ledger) { transactions_.reserve(256); diff --git a/src/xrpld/app/ledger/AcceptedLedger.h b/src/xrpld/app/ledger/AcceptedLedger.h index c0f186c781..23cee6ce35 100644 --- a/src/xrpld/app/ledger/AcceptedLedger.h +++ b/src/xrpld/app/ledger/AcceptedLedger.h @@ -1,6 +1,8 @@ #pragma once -#include +#include +#include +#include namespace xrpl { @@ -23,7 +25,7 @@ namespace xrpl { class AcceptedLedger : public CountedObject { public: - AcceptedLedger(std::shared_ptr const& ledger, Application& app); + AcceptedLedger(std::shared_ptr const& ledger); std::shared_ptr const& getLedger() const diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index 0f44601679..d75e4dd22e 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -3,13 +3,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/OrderBookDB.h b/src/xrpld/app/ledger/OrderBookDB.h deleted file mode 100644 index da604d7e22..0000000000 --- a/src/xrpld/app/ledger/OrderBookDB.h +++ /dev/null @@ -1,75 +0,0 @@ -#pragma once - -#include -#include -#include - -#include -#include - -#include -#include - -namespace xrpl { - -class OrderBookDB -{ -public: - explicit OrderBookDB(Application& app); - - void - setup(std::shared_ptr const& ledger); - void - update(std::shared_ptr const& ledger); - - void - addOrderBook(Book const&); - - /** @return a list of all orderbooks that want this issuerID and currencyID. - */ - std::vector - getBooksByTakerPays(Issue const&, std::optional const& domain = std::nullopt); - - /** @return a count of all orderbooks that want this issuerID and - currencyID. */ - int - getBookSize(Issue const&, std::optional const& domain = std::nullopt); - - bool - isBookToXRP(Issue const&, std::optional domain = std::nullopt); - - BookListeners::pointer - getBookListeners(Book const&); - BookListeners::pointer - makeBookListeners(Book const&); - - // see if this txn effects any orderbook - void - processTxn(std::shared_ptr const& ledger, AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj); - -private: - Application& app_; - - // Maps order books by "issue in" to "issue out": - hardened_hash_map> allBooks_; - - hardened_hash_map, hardened_hash_set> domainBooks_; - - // does an order book to XRP exist - hash_set xrpBooks_; - - // does an order book to XRP exist - hash_set> xrpDomainBooks_; - - std::recursive_mutex mLock; - - using BookToListenersMap = hash_map; - - BookToListenersMap mListeners; - - std::atomic seq_; - - beast::Journal const j_; -}; - -} // namespace xrpl diff --git a/src/xrpld/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDBImpl.cpp similarity index 84% rename from src/xrpld/app/ledger/OrderBookDB.cpp rename to src/xrpld/app/ledger/OrderBookDBImpl.cpp index 6450544f92..62c03fb7ca 100644 --- a/src/xrpld/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDBImpl.cpp @@ -1,6 +1,5 @@ #include -#include -#include +#include #include #include @@ -11,14 +10,25 @@ namespace xrpl { -OrderBookDB::OrderBookDB(Application& app) : app_(app), seq_(0), j_(app.journal("OrderBookDB")) +OrderBookDBImpl::OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config) + : registry_(registry) + , pathSearchMax_(config.pathSearchMax) + , standalone_(config.standalone) + , seq_(0) + , j_(registry.journal("OrderBookDB")) { } -void -OrderBookDB::setup(std::shared_ptr const& ledger) +std::unique_ptr +make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config) { - if (!app_.config().standalone() && app_.getOPs().isNeedNetworkLedger()) + return std::make_unique(registry, config); +} + +void +OrderBookDBImpl::setup(std::shared_ptr const& ledger) +{ + if (!standalone_ && registry_.getOPs().isNeedNetworkLedger()) { JLOG(j_.warn()) << "Eliding full order book update: no ledger"; return; @@ -40,19 +50,20 @@ OrderBookDB::setup(std::shared_ptr const& ledger) JLOG(j_.debug()) << "Full order book update: " << seq << " to " << ledger->seq(); - if (app_.config().PATH_SEARCH_MAX != 0) + if (pathSearchMax_ != 0) { - if (app_.config().standalone()) + if (standalone_) update(ledger); else - app_.getJobQueue().addJob(jtUPDATE_PF, "OrderBookUpd", [this, ledger]() { update(ledger); }); + registry_.getJobQueue().addJob( + jtUPDATE_PF, "OrderBookUpd" + std::to_string(ledger->seq()), [this, ledger]() { update(ledger); }); } } void -OrderBookDB::update(std::shared_ptr const& ledger) +OrderBookDBImpl::update(std::shared_ptr const& ledger) { - if (app_.config().PATH_SEARCH_MAX == 0) + if (pathSearchMax_ == 0) return; // pathfinding has been disabled // A newer full update job is pending @@ -79,7 +90,7 @@ OrderBookDB::update(std::shared_ptr const& ledger) { for (auto& sle : ledger->sles) { - if (app_.isStopping()) + if (registry_.isStopping()) { JLOG(j_.info()) << "Update halted because the process is stopping"; seq_.store(0); @@ -143,11 +154,11 @@ OrderBookDB::update(std::shared_ptr const& ledger) xrpDomainBooks_.swap(xrpDomainBooks); } - app_.getLedgerMaster().newOrderBookDB(); + registry_.getLedgerMaster().newOrderBookDB(); } void -OrderBookDB::addOrderBook(Book const& book) +OrderBookDBImpl::addOrderBook(Book const& book) { bool toXRP = isXRP(book.out); @@ -166,7 +177,7 @@ OrderBookDB::addOrderBook(Book const& book) // return list of all orderbooks that want this issuerID and currencyID std::vector -OrderBookDB::getBooksByTakerPays(Issue const& issue, std::optional const& domain) +OrderBookDBImpl::getBooksByTakerPays(Issue const& issue, std::optional const& domain) { std::vector ret; @@ -194,7 +205,7 @@ OrderBookDB::getBooksByTakerPays(Issue const& issue, std::optional cons } int -OrderBookDB::getBookSize(Issue const& issue, std::optional const& domain) +OrderBookDBImpl::getBookSize(Issue const& issue, std::optional const& domain) { std::lock_guard sl(mLock); @@ -213,7 +224,7 @@ OrderBookDB::getBookSize(Issue const& issue, std::optional const& domai } bool -OrderBookDB::isBookToXRP(Issue const& issue, std::optional domain) +OrderBookDBImpl::isBookToXRP(Issue const& issue, std::optional domain) { std::lock_guard sl(mLock); if (domain) @@ -222,7 +233,7 @@ OrderBookDB::isBookToXRP(Issue const& issue, std::optional domain) } BookListeners::pointer -OrderBookDB::makeBookListeners(Book const& book) +OrderBookDBImpl::makeBookListeners(Book const& book) { std::lock_guard sl(mLock); auto ret = getBookListeners(book); @@ -242,7 +253,7 @@ OrderBookDB::makeBookListeners(Book const& book) } BookListeners::pointer -OrderBookDB::getBookListeners(Book const& book) +OrderBookDBImpl::getBookListeners(Book const& book) { BookListeners::pointer ret; std::lock_guard sl(mLock); @@ -257,7 +268,7 @@ OrderBookDB::getBookListeners(Book const& book) // Based on the meta, send the meta to the streams that are listening. // We need to determine which streams a given meta effects. void -OrderBookDB::processTxn( +OrderBookDBImpl::processTxn( std::shared_ptr const& ledger, AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj) diff --git a/src/xrpld/app/ledger/OrderBookDBImpl.h b/src/xrpld/app/ledger/OrderBookDBImpl.h new file mode 100644 index 0000000000..69739451c4 --- /dev/null +++ b/src/xrpld/app/ledger/OrderBookDBImpl.h @@ -0,0 +1,93 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace xrpl { + +/** Configuration for OrderBookDB */ +struct OrderBookDBConfig +{ + int pathSearchMax; + bool standalone; +}; + +/** Create an OrderBookDB instance. + + @param registry Service registry for accessing other services + @param config Configuration parameters + @return A new OrderBookDB instance +*/ +std::unique_ptr +make_OrderBookDB(ServiceRegistry& registry, OrderBookDBConfig const& config); + +class OrderBookDBImpl final : public OrderBookDB +{ +public: + OrderBookDBImpl(ServiceRegistry& registry, OrderBookDBConfig const& config); + + // OrderBookDB interface implementation + void + setup(std::shared_ptr const& ledger) override; + + void + addOrderBook(Book const& book) override; + + std::vector + getBooksByTakerPays(Issue const& issue, std::optional const& domain = std::nullopt) override; + + int + getBookSize(Issue const& issue, std::optional const& domain = std::nullopt) override; + + bool + isBookToXRP(Issue const& issue, std::optional domain = std::nullopt) override; + + // OrderBookDBImpl-specific methods + void + update(std::shared_ptr const& ledger); + + // see if this txn effects any orderbook + void + processTxn(std::shared_ptr const& ledger, AcceptedLedgerTx const& alTx, MultiApiJson const& jvObj) + override; + + BookListeners::pointer + getBookListeners(Book const&) override; + BookListeners::pointer + makeBookListeners(Book const&) override; + +private: + ServiceRegistry& registry_; + int const pathSearchMax_; + bool const standalone_; + + // Maps order books by "issue in" to "issue out": + hardened_hash_map> allBooks_; + + hardened_hash_map, hardened_hash_set> domainBooks_; + + // does an order book to XRP exist + hash_set xrpBooks_; + + // does an order book to XRP exist + hash_set> xrpDomainBooks_; + + std::recursive_mutex mLock; + + using BookToListenersMap = hash_map; + + BookToListenersMap mListeners; + + std::atomic seq_; + + beast::Journal const j_; +}; + +} // namespace xrpl diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index f8ef91a83f..5538ebcb96 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -24,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/ledger/detail/OpenLedger.cpp b/src/xrpld/app/ledger/detail/OpenLedger.cpp index 698862d4da..d621285619 100644 --- a/src/xrpld/app/ledger/detail/OpenLedger.cpp +++ b/src/xrpld/app/ledger/detail/OpenLedger.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 3f7b6c5596..4612479b78 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include #include #include @@ -16,13 +16,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -164,8 +165,7 @@ public: std::unique_ptr m_nodeStore; NodeFamily nodeFamily_; - // VFALCO TODO Make OrderBookDB abstract - OrderBookDB m_orderBookDB; + std::unique_ptr m_orderBookDB; std::unique_ptr m_pathRequests; std::unique_ptr m_ledgerMaster; std::unique_ptr ledgerCleaner_; @@ -296,7 +296,7 @@ public: , nodeFamily_(*this, *m_collectorManager) - , m_orderBookDB(*this) + , m_orderBookDB(make_OrderBookDB(*this, {config_->PATH_SEARCH_MAX, config_->standalone()})) , m_pathRequests( std::make_unique(*this, logs_->journal("PathRequest"), m_collectorManager->collector())) @@ -613,7 +613,7 @@ public: OrderBookDB& getOrderBookDB() override { - return m_orderBookDB; + return *m_orderBookDB; } PathRequests& @@ -1170,7 +1170,7 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) m_ledgerMaster->setLedgerRangePresent(forcedRange->first, forcedRange->second); } - m_orderBookDB.setup(getLedgerMaster().getCurrentLedger()); + m_orderBookDB->setup(getLedgerMaster().getCurrentLedger()); nodeIdentity_ = getNodeIdentity(*this, cmdline); diff --git a/src/xrpld/app/main/Application.h b/src/xrpld/app/main/Application.h index 5ecc84c11c..a0fea69171 100644 --- a/src/xrpld/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -153,17 +153,10 @@ public: virtual int fdRequired() const = 0; - /** Retrieve the "wallet database" */ - virtual DatabaseCon& - getWalletDB() = 0; - /** Ensure that a newly-started validator does not sign proposals older * than the last ledger it persisted. */ virtual LedgerIndex getMaxDisallowedLedger() = 0; - - virtual std::optional const& - trapTxID() const = 0; }; std::unique_ptr diff --git a/src/xrpld/app/misc/AmendmentTable.h b/src/xrpld/app/misc/AmendmentTable.h index 94ac9608a7..bfef818b0a 100644 --- a/src/xrpld/app/misc/AmendmentTable.h +++ b/src/xrpld/app/misc/AmendmentTable.h @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -163,7 +164,7 @@ public: std::unique_ptr make_AmendmentTable( - Application& app, + ServiceRegistry& registry, std::chrono::seconds majorityTime, std::vector const& supported, Section const& enabled, diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 9e60a8bdc0..8732f9610d 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -7,13 +7,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include @@ -39,9 +37,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -2824,7 +2824,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) std::shared_ptr alpAccepted = registry_.getAcceptedLedgerCache().fetch(lpAccepted->header().hash); if (!alpAccepted) { - alpAccepted = std::make_shared(lpAccepted, registry_.app()); + alpAccepted = std::make_shared(lpAccepted); registry_.getAcceptedLedgerCache().canonicalize_replace_client(lpAccepted->header().hash, alpAccepted); } diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index 3addfd2235..767a3d87f9 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -1,7 +1,7 @@ -#include #include #include +#include #include #include #include @@ -400,7 +400,7 @@ private: public: AmendmentTableImpl( - Application& app, + ServiceRegistry& registry, std::chrono::seconds majorityTime, std::vector const& supported, Section const& enabled, @@ -461,13 +461,17 @@ public: //------------------------------------------------------------------------------ AmendmentTableImpl::AmendmentTableImpl( - Application& app, + ServiceRegistry& registry, std::chrono::seconds majorityTime, std::vector const& supported, Section const& enabled, Section const& vetoed, beast::Journal journal) - : lastUpdateSeq_(0), majorityTime_(majorityTime), unsupportedEnabled_(false), j_(journal), db_(app.getWalletDB()) + : lastUpdateSeq_(0) + , majorityTime_(majorityTime) + , unsupportedEnabled_(false) + , j_(journal) + , db_(registry.getWalletDB()) { std::lock_guard lock(mutex_); @@ -957,14 +961,14 @@ AmendmentTableImpl::getJson(uint256 const& amendmentID, bool isAdmin) const std::unique_ptr make_AmendmentTable( - Application& app, + ServiceRegistry& registry, std::chrono::seconds majorityTime, std::vector const& supported, Section const& enabled, Section const& vetoed, beast::Journal journal) { - return std::make_unique(app, majorityTime, supported, enabled, vetoed, journal); + return std::make_unique(registry, majorityTime, supported, enabled, vetoed, journal); } } // namespace xrpl diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index 8ffbc47b08..d45c49c3c4 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -1,11 +1,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index 3a46d2baa1..4730df4983 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -1,4 +1,3 @@ -#include #include #include @@ -6,6 +5,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/misc/detail/setup_HashRouter.cpp b/src/xrpld/app/misc/detail/setup_HashRouter.cpp new file mode 100644 index 0000000000..a0e63dd67e --- /dev/null +++ b/src/xrpld/app/misc/detail/setup_HashRouter.cpp @@ -0,0 +1,42 @@ +#include +#include + +#include + +namespace xrpl { + +HashRouter::Setup +setup_HashRouter(Config const& config) +{ + using namespace std::chrono; + + HashRouter::Setup setup; + auto const& section = config.section("hashrouter"); + + std::int32_t tmp{}; + + if (set(tmp, "hold_time", section)) + { + if (tmp < 12) + Throw( + "HashRouter hold time must be at least 12 seconds (the " + "approximate validation time for three ledgers)."); + setup.holdTime = seconds(tmp); + } + if (set(tmp, "relay_time", section)) + { + if (tmp < 8) + Throw( + "HashRouter relay time must be at least 8 seconds (the " + "approximate validation time for two ledgers)."); + setup.relayTime = seconds(tmp); + } + if (setup.relayTime > setup.holdTime) + { + Throw("HashRouter relay time must be less than or equal to hold time"); + } + + return setup; +} + +} // namespace xrpl diff --git a/src/xrpld/app/misc/setup_HashRouter.h b/src/xrpld/app/misc/setup_HashRouter.h new file mode 100644 index 0000000000..3054233b89 --- /dev/null +++ b/src/xrpld/app/misc/setup_HashRouter.h @@ -0,0 +1,17 @@ +#ifndef XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED +#define XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED + +#include + +namespace xrpl { + +// Forward declaration +class Config; + +/** Create HashRouter setup from configuration */ +HashRouter::Setup +setup_HashRouter(Config const& config); + +} // namespace xrpl + +#endif diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index b64ce0cc20..ea4fa2013a 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 328d07c0ab..01e036731c 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -203,7 +203,7 @@ saveValidatedLedger( aLedger = app.getAcceptedLedgerCache().fetch(ledger->header().hash); if (!aLedger) { - aLedger = std::make_shared(ledger, app); + aLedger = std::make_shared(ledger); app.getAcceptedLedgerCache().canonicalize_replace_client(ledger->header().hash, aLedger); } } diff --git a/src/xrpld/app/tx/detail/AMMCreate.cpp b/src/xrpld/app/tx/detail/AMMCreate.cpp index 4634ac79e0..aa75a18e30 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.cpp +++ b/src/xrpld/app/tx/detail/AMMCreate.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/Batch.cpp b/src/xrpld/app/tx/detail/Batch.cpp index 34b08beb2f..81f39193cb 100644 --- a/src/xrpld/app/tx/detail/Batch.cpp +++ b/src/xrpld/app/tx/detail/Batch.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/tx/detail/Batch.h b/src/xrpld/app/tx/detail/Batch.h index 8af8b2e020..17abec38c3 100644 --- a/src/xrpld/app/tx/detail/Batch.h +++ b/src/xrpld/app/tx/detail/Batch.h @@ -1,7 +1,6 @@ #pragma once #include -#include #include #include diff --git a/src/xrpld/app/tx/detail/CancelCheck.cpp b/src/xrpld/app/tx/detail/CancelCheck.cpp index 4ac04e9ffb..086a126eb4 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.cpp +++ b/src/xrpld/app/tx/detail/CancelCheck.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/CashCheck.cpp b/src/xrpld/app/tx/detail/CashCheck.cpp index 9deee006d9..2cc25924a1 100644 --- a/src/xrpld/app/tx/detail/CashCheck.cpp +++ b/src/xrpld/app/tx/detail/CashCheck.cpp @@ -1,9 +1,9 @@ -#include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index fab406189b..666023233d 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -1,10 +1,10 @@ -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/CreateTicket.cpp b/src/xrpld/app/tx/detail/CreateTicket.cpp index e6965ca1cf..eb42904a0b 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.cpp +++ b/src/xrpld/app/tx/detail/CreateTicket.cpp @@ -1,6 +1,7 @@ #include #include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/CreateTicket.h b/src/xrpld/app/tx/detail/CreateTicket.h index 2a6e1bb8cc..dd424e3756 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.h +++ b/src/xrpld/app/tx/detail/CreateTicket.h @@ -1,6 +1,5 @@ #pragma once -#include #include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/xrpld/app/tx/detail/Escrow.cpp index 80d1f6c9da..dea9d3aa2b 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/xrpld/app/tx/detail/Escrow.cpp @@ -1,11 +1,11 @@ -#include #include #include -#include -#include #include #include +#include +#include +#include #include #include #include diff --git a/src/xrpld/app/tx/detail/SetAccount.cpp b/src/xrpld/app/tx/detail/SetAccount.cpp index beca60c06b..41804c9211 100644 --- a/src/xrpld/app/tx/detail/SetAccount.cpp +++ b/src/xrpld/app/tx/detail/SetAccount.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index b3b5d8b9bc..a7bb7992fb 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -1,11 +1,9 @@ -#include #include #include #include #include #include #include -#include #include #include @@ -15,6 +13,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/tx/detail/apply.cpp b/src/xrpld/app/tx/detail/apply.cpp index 7babc415d5..1c7a509007 100644 --- a/src/xrpld/app/tx/detail/apply.cpp +++ b/src/xrpld/app/tx/detail/apply.cpp @@ -1,8 +1,9 @@ -#include #include #include #include +#include +#include #include #include diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index ceefab24f1..5b9f142001 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -15,6 +14,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index d66a57bae6..ec641487a8 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/overlay/detail/PeerImp.h b/src/xrpld/overlay/detail/PeerImp.h index 65a6112159..d88314a9a5 100644 --- a/src/xrpld/overlay/detail/PeerImp.h +++ b/src/xrpld/overlay/detail/PeerImp.h @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/Simulate.cpp index f44fc57261..58b40e2048 100644 --- a/src/xrpld/rpc/handlers/Simulate.cpp +++ b/src/xrpld/rpc/handlers/Simulate.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -10,6 +9,7 @@ #include #include +#include #include #include #include From 958d8f375453d80bb1aa4c293b5102c045a3e4b4 Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Mon, 16 Feb 2026 19:31:18 +0000 Subject: [PATCH 14/16] chore: Update clang-format to 21.1.8 (#6352) --- .gitignore | 3 + .pre-commit-config.yaml | 2 +- CONTRIBUTING.md | 2 +- include/xrpl/basics/IntrusivePointer.ipp | 6 +- .../xrpl/basics/SharedWeakCachePointer.ipp | 3 +- include/xrpl/basics/SlabAllocator.h | 2 +- include/xrpl/protocol/Feature.h | 2 +- include/xrpl/protocol/IOUAmount.h | 6 +- include/xrpl/protocol/MPTAmount.h | 3 +- include/xrpl/protocol/MultiApiJson.h | 4 +- include/xrpl/protocol/STAmount.h | 6 +- include/xrpl/protocol/STBitString.h | 3 +- include/xrpl/protocol/STInteger.h | 3 +- include/xrpl/protocol/STObject.h | 18 +- include/xrpl/protocol/STVector256.h | 3 +- include/xrpl/protocol/TER.h | 42 ++- include/xrpl/server/detail/BaseHTTPPeer.h | 4 +- include/xrpl/server/detail/BaseWSPeer.h | 5 +- src/libxrpl/basics/Number.cpp | 3 +- src/libxrpl/json/json_value.cpp | 3 +- src/libxrpl/protocol/Feature.cpp | 2 +- src/libxrpl/protocol/digest.cpp | 9 +- src/libxrpl/server/JSONRPCUtil.cpp | 4 +- src/libxrpl/server/Wallet.cpp | 5 +- src/libxrpl/shamap/SHAMapDelta.cpp | 65 ++-- src/test/app/AMM_test.cpp | 63 ++-- src/test/app/LedgerMaster_test.cpp | 10 +- src/test/app/Manifest_test.cpp | 11 +- src/test/app/Oracle_test.cpp | 304 ++++++++++-------- src/test/app/Vault_test.cpp | 30 +- src/test/beast/IPEndpoint_test.cpp | 6 +- src/test/core/Config_test.cpp | 38 +-- src/test/jtx/impl/amount.cpp | 3 +- src/test/jtx/impl/mpt.cpp | 6 +- src/test/overlay/compression_test.cpp | 5 +- src/test/protocol/STParsedJSON_test.cpp | 75 +++-- src/test/rpc/AccountObjects_test.cpp | 5 +- src/test/rpc/Feature_test.cpp | 6 +- src/test/rpc/GRPCTestClientBase.h | 9 +- src/test/rpc/LedgerEntry_test.cpp | 37 ++- src/test/shamap/SHAMap_test.cpp | 120 ++++--- .../app/ledger/detail/LedgerReplayTask.cpp | 7 +- src/xrpld/app/main/Application.cpp | 82 ++--- src/xrpld/app/main/GRPCServer.cpp | 84 ++--- src/xrpld/app/misc/CanonicalTXSet.cpp | 5 +- src/xrpld/app/misc/ValidatorList.h | 15 +- src/xrpld/app/misc/detail/LendingHelpers.cpp | 29 +- src/xrpld/app/misc/detail/Manifest.cpp | 11 +- src/xrpld/app/misc/detail/ValidatorList.cpp | 15 +- src/xrpld/app/rdb/backend/detail/Node.cpp | 25 +- src/xrpld/app/tx/detail/ApplyContext.h | 11 +- src/xrpld/app/tx/detail/DepositPreauth.cpp | 5 +- src/xrpld/overlay/Slot.h | 25 +- src/xrpld/overlay/detail/ConnectAttempt.cpp | 10 +- src/xrpld/overlay/detail/OverlayImpl.cpp | 5 +- src/xrpld/overlay/detail/OverlayImpl.h | 3 +- src/xrpld/overlay/detail/PeerImp.cpp | 3 +- src/xrpld/rpc/detail/RPCLedgerHelpers.cpp | 5 +- src/xrpld/rpc/handlers/LedgerEntry.cpp | 14 +- src/xrpld/shamap/NodeFamily.cpp | 28 +- 60 files changed, 741 insertions(+), 577 deletions(-) diff --git a/.gitignore b/.gitignore index 2692d707e7..a1c2f034d1 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,6 @@ DerivedData /.augment /.claude /CLAUDE.md + +# clangd cache +/.cache diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 79a3e4e7ec..9117fe0d3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: args: [--assume-in-merge] - repo: https://github.com/pre-commit/mirrors-clang-format - rev: 7d85583be209cb547946c82fbe51f4bc5dd1d017 # frozen: v18.1.8 + rev: 75ca4ad908dc4a99f57921f29b7e6c1521e10b26 # frozen: v21.1.8 hooks: - id: clang-format args: [--style=file] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 808d553e17..a928065ef2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -219,7 +219,7 @@ coherent rather than a set of _thou shalt not_ commandments. ## Formatting -All code must conform to `clang-format` version 18, +All code must conform to `clang-format` version 21, according to the settings in [`.clang-format`](./.clang-format), unless the result would be unreasonably difficult to read or maintain. To demarcate lines that should be left as-is, surround them with comments like diff --git a/include/xrpl/basics/IntrusivePointer.ipp b/include/xrpl/basics/IntrusivePointer.ipp index d52aa6299f..de57e61ba6 100644 --- a/include/xrpl/basics/IntrusivePointer.ipp +++ b/include/xrpl/basics/IntrusivePointer.ipp @@ -208,7 +208,8 @@ SharedIntrusive::operator->() const noexcept } template -SharedIntrusive::operator bool() const noexcept +SharedIntrusive:: +operator bool() const noexcept { return bool(unsafeGetRawPtr()); } @@ -503,7 +504,8 @@ SharedWeakUnion::getStrong() const } template -SharedWeakUnion::operator bool() const noexcept +SharedWeakUnion:: +operator bool() const noexcept { return bool(get()); } diff --git a/include/xrpl/basics/SharedWeakCachePointer.ipp b/include/xrpl/basics/SharedWeakCachePointer.ipp index 6e7514ffae..7eb3789de5 100644 --- a/include/xrpl/basics/SharedWeakCachePointer.ipp +++ b/include/xrpl/basics/SharedWeakCachePointer.ipp @@ -63,7 +63,8 @@ SharedWeakCachePointer::getStrong() const } template -SharedWeakCachePointer::operator bool() const noexcept +SharedWeakCachePointer:: +operator bool() const noexcept { return !!std::get_if>(&combo_); } diff --git a/include/xrpl/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h index 2578afdc5a..84beef2d20 100644 --- a/include/xrpl/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -215,7 +215,7 @@ public: // clang-format off if (!buf) [[unlikely]] return nullptr; - // clang-format on + // clang-format on #if BOOST_OS_LINUX // When allocating large blocks, attempt to leverage Linux's diff --git a/include/xrpl/protocol/Feature.h b/include/xrpl/protocol/Feature.h index 6d674fbef2..34d78fc50b 100644 --- a/include/xrpl/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -296,7 +296,7 @@ public: friend FeatureBitset operator^(FeatureBitset const& lhs, uint256 const& rhs) { - return lhs ^ FeatureBitset { rhs }; + return lhs ^ FeatureBitset{rhs}; } friend FeatureBitset diff --git a/include/xrpl/protocol/IOUAmount.h b/include/xrpl/protocol/IOUAmount.h index 52c2272da0..608c80d982 100644 --- a/include/xrpl/protocol/IOUAmount.h +++ b/include/xrpl/protocol/IOUAmount.h @@ -110,7 +110,8 @@ IOUAmount::operator=(beast::Zero) return *this; } -inline IOUAmount::operator Number() const +inline IOUAmount:: +operator Number() const { return Number{mantissa_, exponent_}; } @@ -140,7 +141,8 @@ IOUAmount::operator<(IOUAmount const& other) const return Number{*this} < Number{other}; } -inline IOUAmount::operator bool() const noexcept +inline IOUAmount:: +operator bool() const noexcept { return mantissa_ != 0; } diff --git a/include/xrpl/protocol/MPTAmount.h b/include/xrpl/protocol/MPTAmount.h index 66027185b3..5c1642ae5c 100644 --- a/include/xrpl/protocol/MPTAmount.h +++ b/include/xrpl/protocol/MPTAmount.h @@ -93,7 +93,8 @@ MPTAmount::operator=(beast::Zero) } /** Returns true if the amount is not zero */ -constexpr MPTAmount::operator bool() const noexcept +constexpr MPTAmount:: +operator bool() const noexcept { return value_ != 0; } diff --git a/include/xrpl/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h index ad7a6b8f0d..b884771b50 100644 --- a/include/xrpl/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -107,7 +107,7 @@ struct MultiApiJson // unsigned int version, extra arguments template requires(!some_integral_constant) && std::convertible_to && - std::same_as, MultiApiJson> + std::same_as, MultiApiJson> auto operator()(Json& json, Version version, Fn fn, Args&&... args) const -> std::invoke_result_t @@ -122,7 +122,7 @@ struct MultiApiJson // unsigned int version, Json only template requires(!some_integral_constant) && std::convertible_to && - std::same_as, MultiApiJson> + std::same_as, MultiApiJson> auto operator()(Json& json, Version version, Fn fn) const -> std::invoke_result_t { diff --git a/include/xrpl/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h index df2b1c19a0..ea727d02e3 100644 --- a/include/xrpl/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -480,12 +480,14 @@ STAmount::zeroed() const return STAmount(mAsset); } -inline STAmount::operator bool() const noexcept +inline STAmount:: +operator bool() const noexcept { return *this != beast::zero; } -inline STAmount::operator Number() const +inline STAmount:: +operator Number() const { if (native()) return xrp(); diff --git a/include/xrpl/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h index e8b6e7282b..dca2670ffc 100644 --- a/include/xrpl/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -169,7 +169,8 @@ STBitString::value() const } template -STBitString::operator value_type() const +STBitString:: +operator value_type() const { return value_; } diff --git a/include/xrpl/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h index b5c4dbf6cf..f4bbd6e73d 100644 --- a/include/xrpl/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -134,7 +134,8 @@ STInteger::setValue(Integer v) } template -inline STInteger::operator Integer() const +inline STInteger:: +operator Integer() const { return value_; } diff --git a/include/xrpl/protocol/STObject.h b/include/xrpl/protocol/STObject.h index 5d5d829c99..c9102f2470 100644 --- a/include/xrpl/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -147,9 +147,12 @@ public: int getCount() const; - bool setFlag(std::uint32_t); - bool clearFlag(std::uint32_t); - bool isFlag(std::uint32_t) const; + bool + setFlag(std::uint32_t); + bool + clearFlag(std::uint32_t); + bool + isFlag(std::uint32_t) const; std::uint32_t getFlags() const; @@ -799,7 +802,8 @@ STObject::ValueProxy::operator-=(U const& u) } template -STObject::ValueProxy::operator value_type() const +STObject::ValueProxy:: +operator value_type() const { return this->value(); } @@ -812,13 +816,15 @@ STObject::ValueProxy::ValueProxy(STObject* st, TypedField const* f) : Prox //------------------------------------------------------------------------------ template -STObject::OptionalProxy::operator bool() const noexcept +STObject::OptionalProxy:: +operator bool() const noexcept { return engaged(); } template -STObject::OptionalProxy::operator typename STObject::OptionalProxy::optional_type() const +STObject::OptionalProxy:: +operator typename STObject::OptionalProxy::optional_type() const { return optional_value(); } diff --git a/include/xrpl/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h index c83d981bfc..8e63953e22 100644 --- a/include/xrpl/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -135,7 +135,8 @@ STVector256::setValue(STVector256 const& v) } /** Retrieve a copy of the vector we contain */ -inline STVector256::operator std::vector() const +inline STVector256:: +operator std::vector() const { return mValue; } diff --git a/include/xrpl/protocol/TER.h b/include/xrpl/protocol/TER.h index 52001ce72b..3c1faccf6d 100644 --- a/include/xrpl/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -484,60 +484,54 @@ public: // 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/server/detail/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h index ab85cb7c89..78ad4cff4f 100644 --- a/include/xrpl/server/detail/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -218,7 +218,7 @@ void BaseHTTPPeer::close() { if (!strand_.running_in_this_thread()) - return post(strand_, std::bind((void(BaseHTTPPeer::*)(void)) & BaseHTTPPeer::close, impl().shared_from_this())); + return post(strand_, std::bind((void (BaseHTTPPeer::*)(void))&BaseHTTPPeer::close, impl().shared_from_this())); boost::beast::get_lowest_layer(impl().stream_).close(); } @@ -436,7 +436,7 @@ BaseHTTPPeer::close(bool graceful) return post( strand_, std::bind( - (void(BaseHTTPPeer::*)(bool)) & BaseHTTPPeer::close, + (void (BaseHTTPPeer::*)(bool))&BaseHTTPPeer::close, impl().shared_from_this(), graceful)); diff --git a/include/xrpl/server/detail/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h index ab985dfac5..723e48d950 100644 --- a/include/xrpl/server/detail/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -178,8 +178,9 @@ BaseWSPeer::run() impl().ws_.control_callback(control_callback_); start_timer(); close_on_timer_ = true; - impl().ws_.set_option(boost::beast::websocket::stream_base::decorator( - [](auto& res) { res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString()); })); + impl().ws_.set_option(boost::beast::websocket::stream_base::decorator([](auto& res) { + res.set(boost::beast::http::field::server, BuildInfo::getFullVersionString()); + })); impl().ws_.async_accept( request_, bind_executor( diff --git a/src/libxrpl/basics/Number.cpp b/src/libxrpl/basics/Number.cpp index 1651e8aba2..30dd60698e 100644 --- a/src/libxrpl/basics/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -773,7 +773,8 @@ Number::operator/=(Number const& y) return *this; } -Number::operator rep() const +Number:: +operator rep() const { rep drops = mantissa(); int offset = exponent(); diff --git a/src/libxrpl/json/json_value.cpp b/src/libxrpl/json/json_value.cpp index edbbafc1eb..a7692c7683 100644 --- a/src/libxrpl/json/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -777,7 +777,8 @@ Value::size() const return 0; // unreachable; } -Value::operator bool() const +Value:: +operator bool() const { if (isNull()) return false; diff --git a/src/libxrpl/protocol/Feature.cpp b/src/libxrpl/protocol/Feature.cpp index 834341f8d6..149888a3a8 100644 --- a/src/libxrpl/protocol/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -89,7 +89,7 @@ class FeatureCollections }; // Intermediate types to help with readability - template + template using feature_hashed_unique = boost::multi_index:: hashed_unique, boost::multi_index::member>; diff --git a/src/libxrpl/protocol/digest.cpp b/src/libxrpl/protocol/digest.cpp index aa5600dde0..0e03882c3c 100644 --- a/src/libxrpl/protocol/digest.cpp +++ b/src/libxrpl/protocol/digest.cpp @@ -21,7 +21,8 @@ openssl_ripemd160_hasher::operator()(void const* data, std::size_t size) noexcep RIPEMD160_Update(ctx, data, size); } -openssl_ripemd160_hasher::operator result_type() noexcept +openssl_ripemd160_hasher:: +operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); result_type digest; @@ -45,7 +46,8 @@ openssl_sha512_hasher::operator()(void const* data, std::size_t size) noexcept SHA512_Update(ctx, data, size); } -openssl_sha512_hasher::operator result_type() noexcept +openssl_sha512_hasher:: +operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); result_type digest; @@ -69,7 +71,8 @@ openssl_sha256_hasher::operator()(void const* data, std::size_t size) noexcept SHA256_Update(ctx, data, size); } -openssl_sha256_hasher::operator result_type() noexcept +openssl_sha256_hasher:: +operator result_type() noexcept { auto const ctx = reinterpret_cast(ctx_); result_type digest; diff --git a/src/libxrpl/server/JSONRPCUtil.cpp b/src/libxrpl/server/JSONRPCUtil.cpp index 634bb07850..d32a579d8d 100644 --- a/src/libxrpl/server/JSONRPCUtil.cpp +++ b/src/libxrpl/server/JSONRPCUtil.cpp @@ -19,9 +19,7 @@ getHTTPHeaderTimestamp() char buffer[96]; time_t now; time(&now); - struct tm now_gmt - { - }; + struct tm now_gmt{}; #ifndef _MSC_VER gmtime_r(&now, &now_gmt); #else diff --git a/src/libxrpl/server/Wallet.cpp b/src/libxrpl/server/Wallet.cpp index 51f1326674..6b7c285b3e 100644 --- a/src/libxrpl/server/Wallet.cpp +++ b/src/libxrpl/server/Wallet.cpp @@ -124,8 +124,9 @@ getNodeIdentity(soci::session& session) auto [newpublicKey, newsecretKey] = randomKeyPair(KeyType::secp256k1); session << str( - boost::format("INSERT INTO NodeIdentity (PublicKey,PrivateKey) " - "VALUES ('%s','%s');") % + boost::format( + "INSERT INTO NodeIdentity (PublicKey,PrivateKey) " + "VALUES ('%s','%s');") % toBase58(TokenType::NodePublic, newpublicKey) % toBase58(TokenType::NodePrivate, newsecretKey)); return {newpublicKey, newsecretKey}; diff --git a/src/libxrpl/shamap/SHAMapDelta.cpp b/src/libxrpl/shamap/SHAMapDelta.cpp index d8aabcc67c..1335fd0532 100644 --- a/src/libxrpl/shamap/SHAMapDelta.cpp +++ b/src/libxrpl/shamap/SHAMapDelta.cpp @@ -276,45 +276,46 @@ SHAMap::walkMapParallel(std::vector& missingNodes, int maxMis nodeStacks[rootChildIndex].push(intr_ptr::static_pointer_cast(child)); JLOG(journal_.debug()) << "starting worker " << rootChildIndex; - workers.push_back(std::thread( - [&m, &missingNodes, &maxMissing, &exceptions, this]( - std::stack> nodeStack) { - try - { - while (!nodeStack.empty()) + workers.push_back( + std::thread( + [&m, &missingNodes, &maxMissing, &exceptions, this]( + std::stack> nodeStack) { + try { - intr_ptr::SharedPtr node = std::move(nodeStack.top()); - XRPL_ASSERT(node, "xrpl::SHAMap::walkMapParallel : non-null node"); - nodeStack.pop(); - - for (int i = 0; i < 16; ++i) + while (!nodeStack.empty()) { - if (node->isEmptyBranch(i)) - continue; - intr_ptr::SharedPtr nextNode = descendNoStore(*node, i); + intr_ptr::SharedPtr node = std::move(nodeStack.top()); + XRPL_ASSERT(node, "xrpl::SHAMap::walkMapParallel : non-null node"); + nodeStack.pop(); - if (nextNode) + for (int i = 0; i < 16; ++i) { - if (nextNode->isInner()) - nodeStack.push(intr_ptr::static_pointer_cast(nextNode)); - } - else - { - std::lock_guard l{m}; - missingNodes.emplace_back(type_, node->getChildHash(i)); - if (--maxMissing <= 0) - return; + if (node->isEmptyBranch(i)) + continue; + intr_ptr::SharedPtr nextNode = descendNoStore(*node, i); + + if (nextNode) + { + if (nextNode->isInner()) + nodeStack.push(intr_ptr::static_pointer_cast(nextNode)); + } + else + { + std::lock_guard l{m}; + missingNodes.emplace_back(type_, node->getChildHash(i)); + if (--maxMissing <= 0) + return; + } } } } - } - catch (SHAMapMissingNode const& e) - { - std::lock_guard l(m); - exceptions.push_back(e); - } - }, - std::move(nodeStacks[rootChildIndex]))); + catch (SHAMapMissingNode const& e) + { + std::lock_guard l(m); + exceptions.push_back(e); + } + }, + std::move(nodeStacks[rootChildIndex]))); } for (std::thread& worker : workers) diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 8a60e5f667..82ea2f6f70 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -955,13 +955,17 @@ private: // Equal deposit limit, tokens rounded to 0 testAMM( [&](AMM& amm, Env& env) { - amm.deposit(DepositArg{ - .asset1In = STAmount{USD, 1, -15}, .asset2In = XRPAmount{1}, .err = ter(tecAMM_INVALID_TOKENS)}); + amm.deposit( + DepositArg{ + .asset1In = STAmount{USD, 1, -15}, + .asset2In = XRPAmount{1}, + .err = ter(tecAMM_INVALID_TOKENS)}); }, {.pool = {{USD(1'000'000), XRP(1'000'000)}}, .features = {features - fixAMMv1_3}}); testAMM([&](AMM& amm, Env& env) { - amm.deposit(DepositArg{ - .asset1In = STAmount{USD, 1, -15}, .asset2In = XRPAmount{1}, .err = ter(tecAMM_INVALID_TOKENS)}); + amm.deposit( + DepositArg{ + .asset1In = STAmount{USD, 1, -15}, .asset2In = XRPAmount{1}, .err = ter(tecAMM_INVALID_TOKENS)}); }); // Single deposit by asset, tokens rounded to 0 @@ -971,14 +975,18 @@ private: // Single deposit by tokens, tokens rounded to 0 testAMM([&](AMM& amm, Env& env) { - amm.deposit(DepositArg{ - .tokens = IOUAmount{1, -10}, .asset1In = STAmount{USD, 1, -15}, .err = ter(tecAMM_INVALID_TOKENS)}); + amm.deposit( + DepositArg{ + .tokens = IOUAmount{1, -10}, .asset1In = STAmount{USD, 1, -15}, .err = ter(tecAMM_INVALID_TOKENS)}); }); // Single deposit with EPrice, tokens rounded to 0 testAMM([&](AMM& amm, Env& env) { - amm.deposit(DepositArg{ - .asset1In = STAmount{USD, 1, -15}, .maxEP = STAmount{USD, 1, -1}, .err = ter(tecAMM_INVALID_TOKENS)}); + amm.deposit( + DepositArg{ + .asset1In = STAmount{USD, 1, -15}, + .maxEP = STAmount{USD, 1, -1}, + .err = ter(tecAMM_INVALID_TOKENS)}); }); } @@ -1556,10 +1564,14 @@ private: ammAlice.withdraw(carol, std::nullopt, STAmount{USD, 1, -9}, std::nullopt, ter(tecAMM_INVALID_TOKENS)); ammAlice.withdraw(carol, std::nullopt, XRPAmount{1}, std::nullopt, ter(tecAMM_INVALID_TOKENS)); ammAlice.withdraw(WithdrawArg{.tokens = IOUAmount{1, -10}, .err = ter(tecAMM_INVALID_TOKENS)}); - ammAlice.withdraw(WithdrawArg{ - .asset1Out = STAmount{USD, 1, -15}, .asset2Out = XRPAmount{1}, .err = ter(tecAMM_INVALID_TOKENS)}); - ammAlice.withdraw(WithdrawArg{ - .tokens = IOUAmount{1, -10}, .asset1Out = STAmount{USD, 1, -15}, .err = ter(tecAMM_INVALID_TOKENS)}); + ammAlice.withdraw( + WithdrawArg{ + .asset1Out = STAmount{USD, 1, -15}, .asset2Out = XRPAmount{1}, .err = ter(tecAMM_INVALID_TOKENS)}); + ammAlice.withdraw( + WithdrawArg{ + .tokens = IOUAmount{1, -10}, + .asset1Out = STAmount{USD, 1, -15}, + .err = ter(tecAMM_INVALID_TOKENS)}); }); } @@ -6150,11 +6162,12 @@ private: // tfTwoAsset withdraw mode testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(WithdrawArg{ - .account = alice, - .asset1Out = STAmount{GBP, 3'500}, - .asset2Out = STAmount{EUR, 15'000}, - .flags = tfTwoAsset}); + ammAlice.withdraw( + WithdrawArg{ + .account = alice, + .asset1Out = STAmount{GBP, 3'500}, + .asset2Out = STAmount{EUR, 15'000}, + .flags = tfTwoAsset}); invariant(ammAlice, env, "with3", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6198,8 +6211,12 @@ private: // tfOneAssetLPToken mode testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(WithdrawArg{ - .account = alice, .tokens = 1'000, .asset1Out = STAmount{GBP, 100}, .flags = tfOneAssetLPToken}); + ammAlice.withdraw( + WithdrawArg{ + .account = alice, + .tokens = 1'000, + .asset1Out = STAmount{GBP, 100}, + .flags = tfOneAssetLPToken}); invariant(ammAlice, env, "with6", false); }, {{GBP(7'000), EUR(30'000)}}, @@ -6210,8 +6227,12 @@ private: // tfLimitLPToken mode testAMM( [&](AMM& ammAlice, Env& env) { - ammAlice.withdraw(WithdrawArg{ - .account = alice, .asset1Out = STAmount{GBP, 100}, .maxEP = IOUAmount{2}, .flags = tfLimitLPToken}); + ammAlice.withdraw( + WithdrawArg{ + .account = alice, + .asset1Out = STAmount{GBP, 100}, + .maxEP = IOUAmount{2}, + .flags = tfLimitLPToken}); invariant(ammAlice, env, "with7", true); }, {{GBP(7'000), EUR(30'000)}}, diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index eb346288c2..50a8a2ed02 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -79,8 +79,9 @@ class LedgerMaster_test : public beast::unit_test::suite auto result = env.app().getLedgerMaster().txnIdFromIndex(startLegSeq, txnIndex); BEAST_EXPECT( *result == - uint256("277F4FD89C20B92457FEF05FF63F6405563AD0563C73D967A29727" - "72679ADC65")); + uint256( + "277F4FD89C20B92457FEF05FF63F6405563AD0563C73D967A29727" + "72679ADC65")); } // success (second tx) { @@ -88,8 +89,9 @@ class LedgerMaster_test : public beast::unit_test::suite auto result = env.app().getLedgerMaster().txnIdFromIndex(startLegSeq + 1, txnIndex); BEAST_EXPECT( *result == - uint256("293DF7335EBBAF4420D52E70ABF470EB4C5792CAEA2F91F76193C2" - "819F538FDE")); + uint256( + "293DF7335EBBAF4420D52E70ABF470EB4C5792CAEA2F91F76193C2" + "819F538FDE")); } } diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index 5b7e34ad5b..5adb677152 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -250,11 +250,12 @@ public: if (inManifests.size() == loadedManifests.size()) { - BEAST_EXPECT(std::equal( - inManifests.begin(), - inManifests.end(), - loadedManifests.begin(), - [](Manifest const* lhs, Manifest const* rhs) { return *lhs == *rhs; })); + BEAST_EXPECT( + std::equal( + inManifests.begin(), + inManifests.end(), + loadedManifests.begin(), + [](Manifest const* lhs, Manifest const* rhs) { return *lhs == *rhs; })); } else { diff --git a/src/test/app/Oracle_test.cpp b/src/test/app/Oracle_test.cpp index 66a8969164..d3bf8a885a 100644 --- a/src/test/app/Oracle_test.cpp +++ b/src/test/app/Oracle_test.cpp @@ -47,17 +47,18 @@ private: env.fund(env.current()->fees().accountReserve(1) + env.current()->fees().base * 2, owner); Oracle oracle(env, {.owner = owner, .fee = static_cast(env.current()->fees().base.drops())}); BEAST_EXPECT(oracle.exists()); - oracle.set(UpdateArg{ - .series = - { - {"XRP", "EUR", 740, 1}, - {"XRP", "GBP", 740, 1}, - {"XRP", "CNY", 740, 1}, - {"XRP", "CAD", 740, 1}, - {"XRP", "AUD", 740, 1}, - }, - .fee = static_cast(env.current()->fees().base.drops()), - .err = ter(tecINSUFFICIENT_RESERVE)}); + oracle.set( + UpdateArg{ + .series = + { + {"XRP", "EUR", 740, 1}, + {"XRP", "GBP", 740, 1}, + {"XRP", "CNY", 740, 1}, + {"XRP", "CAD", 740, 1}, + {"XRP", "AUD", 740, 1}, + }, + .fee = static_cast(env.current()->fees().base.drops()), + .err = ter(tecINSUFFICIENT_RESERVE)}); } { @@ -70,42 +71,49 @@ private: oracle.set(CreateArg{.flags = tfSellNFToken, .fee = baseFee, .err = ter(temINVALID_FLAG)}); // Duplicate token pair - oracle.set(CreateArg{ - .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", 750, 1}}, .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", 750, 1}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); // Price is not included - oracle.set(CreateArg{ - .series = {{"XRP", "USD", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .series = {{"XRP", "USD", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); // Token pair is in update and delete - oracle.set(CreateArg{ - .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", std::nullopt, 1}}, - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .series = {{"XRP", "USD", 740, 1}, {"XRP", "USD", std::nullopt, 1}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); // Token pair is in add and delete - oracle.set(CreateArg{ - .series = {{"XRP", "EUR", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .series = {{"XRP", "EUR", 740, 1}, {"XRP", "EUR", std::nullopt, 1}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); // Array of token pair is 0 or exceeds 10 - oracle.set(CreateArg{ - .series = - {{"XRP", "US1", 740, 1}, - {"XRP", "US2", 750, 1}, - {"XRP", "US3", 740, 1}, - {"XRP", "US4", 750, 1}, - {"XRP", "US5", 740, 1}, - {"XRP", "US6", 750, 1}, - {"XRP", "US7", 740, 1}, - {"XRP", "US8", 750, 1}, - {"XRP", "US9", 740, 1}, - {"XRP", "U10", 750, 1}, - {"XRP", "U11", 740, 1}}, - .fee = baseFee, - .err = ter(temARRAY_TOO_LARGE)}); + oracle.set( + CreateArg{ + .series = + {{"XRP", "US1", 740, 1}, + {"XRP", "US2", 750, 1}, + {"XRP", "US3", 740, 1}, + {"XRP", "US4", 750, 1}, + {"XRP", "US5", 740, 1}, + {"XRP", "US6", 750, 1}, + {"XRP", "US7", 740, 1}, + {"XRP", "US8", 750, 1}, + {"XRP", "US9", 740, 1}, + {"XRP", "U10", 750, 1}, + {"XRP", "U11", 740, 1}}, + .fee = baseFee, + .err = ter(temARRAY_TOO_LARGE)}); oracle.set(CreateArg{.series = {}, .fee = baseFee, .err = ter(temARRAY_EMPTY)}); } @@ -116,22 +124,23 @@ private: env.fund(XRP(1'000), owner); Oracle oracle(env, CreateArg{.owner = owner, .series = {{{"XRP", "USD", 740, 1}}}, .fee = baseFee}); - oracle.set(UpdateArg{ - .series = - { - {"XRP", "US1", 740, 1}, - {"XRP", "US2", 750, 1}, - {"XRP", "US3", 740, 1}, - {"XRP", "US4", 750, 1}, - {"XRP", "US5", 740, 1}, - {"XRP", "US6", 750, 1}, - {"XRP", "US7", 740, 1}, - {"XRP", "US8", 750, 1}, - {"XRP", "US9", 740, 1}, - {"XRP", "U10", 750, 1}, - }, - .fee = baseFee, - .err = ter(tecARRAY_TOO_LARGE)}); + oracle.set( + UpdateArg{ + .series = + { + {"XRP", "US1", 740, 1}, + {"XRP", "US2", 750, 1}, + {"XRP", "US3", 740, 1}, + {"XRP", "US4", 750, 1}, + {"XRP", "US5", 740, 1}, + {"XRP", "US6", 750, 1}, + {"XRP", "US7", 740, 1}, + {"XRP", "US8", 750, 1}, + {"XRP", "US9", 740, 1}, + {"XRP", "U10", 750, 1}, + }, + .fee = baseFee, + .err = ter(tecARRAY_TOO_LARGE)}); } { @@ -141,26 +150,33 @@ private: Oracle oracle(env, {.owner = owner, .fee = baseFee}, false); // Asset class or provider not included on create - oracle.set(CreateArg{ - .assetClass = std::nullopt, .provider = "provider", .fee = baseFee, .err = ter(temMALFORMED)}); - oracle.set(CreateArg{ - .assetClass = "currency", - .provider = std::nullopt, - .uri = "URI", - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .assetClass = std::nullopt, .provider = "provider", .fee = baseFee, .err = ter(temMALFORMED)}); + oracle.set( + CreateArg{ + .assetClass = "currency", + .provider = std::nullopt, + .uri = "URI", + .fee = baseFee, + .err = ter(temMALFORMED)}); // Asset class or provider are included on update // and don't match the current values oracle.set(CreateArg{.fee = static_cast(env.current()->fees().base.drops())}); BEAST_EXPECT(oracle.exists()); - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, .provider = "provider1", .fee = baseFee, .err = ter(temMALFORMED)}); - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .assetClass = "currency1", - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .provider = "provider1", + .fee = baseFee, + .err = ter(temMALFORMED)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .assetClass = "currency1", + .fee = baseFee, + .err = ter(temMALFORMED)}); } { @@ -214,31 +230,35 @@ private: BEAST_EXPECT(oracle.exists()); env.close(seconds(400)); // Less than the last close time - 300s - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = static_cast(closeTime() - 301), - .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .lastUpdateTime = static_cast(closeTime() - 301), + .fee = baseFee, + .err = ter(tecINVALID_UPDATE_TIME)}); // Greater than last close time + 300s - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = static_cast(closeTime() + 311), - .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .lastUpdateTime = static_cast(closeTime() + 311), + .fee = baseFee, + .err = ter(tecINVALID_UPDATE_TIME)}); oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 1}}, .fee = baseFee}); BEAST_EXPECT(oracle.expectLastUpdateTime(static_cast(testStartTime.count() + 450))); // Less than the previous lastUpdateTime - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = static_cast(449), - .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .lastUpdateTime = static_cast(449), + .fee = baseFee, + .err = ter(tecINVALID_UPDATE_TIME)}); // Less than the epoch time - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = static_cast(epoch_offset.count() - 1), - .fee = baseFee, - .err = ter(tecINVALID_UPDATE_TIME)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .lastUpdateTime = static_cast(epoch_offset.count() - 1), + .fee = baseFee, + .err = ter(tecINVALID_UPDATE_TIME)}); } { @@ -248,13 +268,17 @@ private: env.fund(XRP(1'000), owner); Oracle oracle(env, {.owner = owner, .fee = baseFee}); BEAST_EXPECT(oracle.exists()); - oracle.set(UpdateArg{ - .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, - .fee = baseFee, - .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, + .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); // delete all token pairs - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", std::nullopt, std::nullopt}}, .fee = baseFee, .err = ter(tecARRAY_EMPTY)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", std::nullopt, std::nullopt}}, + .fee = baseFee, + .err = ter(tecARRAY_EMPTY)}); } { @@ -285,21 +309,24 @@ private: auto const baseFee = static_cast(env.current()->fees().base.drops()); env.fund(XRP(1'000), owner); Oracle oracle(env, {.owner = owner, .fee = baseFee}); - oracle.set(UpdateArg{ - .series = {{"XRP", "EUR", std::nullopt, std::nullopt}, {"XRP", "EUR", 740, 1}}, - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "EUR", std::nullopt, std::nullopt}, {"XRP", "EUR", 740, 1}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); // Delete token pair that doesn't exist in this oracle - oracle.set(UpdateArg{ - .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, - .fee = baseFee, - .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, + .err = ter(tecTOKEN_PAIR_NOT_FOUND)}); // Delete token pair in oracle, which is not in the ledger - oracle.set(UpdateArg{ - .documentID = 10, - .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, - .fee = baseFee, - .err = ter(temMALFORMED)}); + oracle.set( + UpdateArg{ + .documentID = 10, + .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee, + .err = ter(temMALFORMED)}); } { @@ -521,28 +548,30 @@ private: BEAST_EXPECT(ownerCount(env, owner) == count); // owner count is increased by 1 since the number of pairs is 6 - oracle.set(UpdateArg{ - .series = - { - {"BTC", "USD", 741, 2}, - {"ETH", "EUR", 710, 2}, - {"YAN", "EUR", 710, 2}, - {"CAN", "EUR", 710, 2}, - }, - .fee = baseFee}); + oracle.set( + UpdateArg{ + .series = + { + {"BTC", "USD", 741, 2}, + {"ETH", "EUR", 710, 2}, + {"YAN", "EUR", 710, 2}, + {"CAN", "EUR", 710, 2}, + }, + .fee = baseFee}); count += 1; BEAST_EXPECT(ownerCount(env, owner) == count); // update two pairs and delete four oracle.set(UpdateArg{.series = {{"BTC", "USD", std::nullopt, std::nullopt}}, .fee = baseFee}); - oracle.set(UpdateArg{ - .series = - {{"XRP", "USD", 742, 2}, - {"XRP", "EUR", 711, 2}, - {"ETH", "EUR", std::nullopt, std::nullopt}, - {"YAN", "EUR", std::nullopt, std::nullopt}, - {"CAN", "EUR", std::nullopt, std::nullopt}}, - .fee = baseFee}); + oracle.set( + UpdateArg{ + .series = + {{"XRP", "USD", 742, 2}, + {"XRP", "EUR", 711, 2}, + {"ETH", "EUR", std::nullopt, std::nullopt}, + {"YAN", "EUR", std::nullopt, std::nullopt}, + {"CAN", "EUR", std::nullopt, std::nullopt}}, + .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 742, 2}, {"XRP", "EUR", 711, 2}})); // owner count is decreased by 1 since the number of pairs is 2 count -= 1; @@ -638,10 +667,12 @@ private: BEAST_EXPECT(oracle.exists()); // Update - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, .msig = msig(becky), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, .msig = msig(zelda), .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, .msig = msig(becky), .fee = baseFee, .err = ter(tefBAD_QUORUM)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, .msig = msig(zelda), .fee = baseFee, .err = ter(tefBAD_SIGNATURE)}); oracle.set(UpdateArg{.series = {{"XRP", "USD", 741, 1}}, .msig = msig(becky, bogie), .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 741, 1}})); // remove the signer list @@ -652,11 +683,12 @@ private: env(signers(alice, 2, {{zelda, 1}, {bob, 1}, {ed, 2}}), sig(alie)); env.close(); // old list fails - oracle.set(UpdateArg{ - .series = {{"XRP", "USD", 740, 1}}, - .msig = msig(becky, bogie), - .fee = baseFee, - .err = ter(tefBAD_SIGNATURE)}); + oracle.set( + UpdateArg{ + .series = {{"XRP", "USD", 740, 1}}, + .msig = msig(becky, bogie), + .fee = baseFee, + .err = ter(tefBAD_SIGNATURE)}); // updated list succeeds oracle.set(UpdateArg{.series = {{"XRP", "USD", 7412, 2}}, .msig = msig(zelda, bob), .fee = baseFee}); BEAST_EXPECT(oracle.expectPrice({{"XRP", "USD", 7412, 2}})); diff --git a/src/test/app/Vault_test.cpp b/src/test/app/Vault_test.cpp index 5d31c674c0..cf86ab6033 100644 --- a/src/test/app/Vault_test.cpp +++ b/src/test/app/Vault_test.cpp @@ -969,13 +969,14 @@ class Vault_test : public beast::unit_test::suite { using namespace test::jtx; - auto testCase = [this](std::function test) { + auto testCase = [this]( + std::function test) { Env env{*this, testable_amendments() | featureSingleAssetVault}; Account issuer{"issuer"}; Account owner{"owner"}; @@ -1255,13 +1256,14 @@ class Vault_test : public beast::unit_test::suite { using namespace test::jtx; - auto testCase = [this](std::function test) { + auto testCase = [this]( + std::function test) { Env env{*this, testable_amendments() | featureSingleAssetVault}; Account issuer{"issuer"}; Account owner{"owner"}; diff --git a/src/test/beast/IPEndpoint_test.cpp b/src/test/beast/IPEndpoint_test.cpp index 67e3f8ed7d..7ce5271383 100644 --- a/src/test/beast/IPEndpoint_test.cpp +++ b/src/test/beast/IPEndpoint_test.cpp @@ -334,9 +334,9 @@ public: #if BOOST_OS_WINDOWS // windows asio bugs...false positives - shouldParseEPV4("255", {{ 0, 0, 0, 255 }}, 0, "0.0.0.255"); - shouldParseEPV4("512", {{ 0, 0, 2, 0 }}, 0, "0.0.2.0"); - shouldParseEPV4("1.2.3:80", {{ 1, 2, 0, 3 }}, 80, "1.2.0.3:80"); + shouldParseEPV4("255", {{0, 0, 0, 255}}, 0, "0.0.0.255"); + shouldParseEPV4("512", {{0, 0, 2, 0}}, 0, "0.0.2.0"); + shouldParseEPV4("1.2.3:80", {{1, 2, 0, 3}}, 80, "1.2.0.3:80"); #else failParseEP("255"); failParseEP("512"); diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index d5f3bb556c..2e7fc8635f 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -1116,23 +1116,24 @@ trust-these-validators.gov Config cfg; /* NOTE: this string includes some explicit * space chars in order to verify proper trimming */ - std::string toLoad(R"( + std::string toLoad( + R"( [port_rpc])" - "\x20" - R"( + "\x20" + R"( # comment # indented comment )" - "\x20\x20" - R"( + "\x20\x20" + R"( [ips])" - "\x20" - R"( + "\x20" + R"( r.ripple.com 51235 [ips_fixed])" - "\x20\x20" - R"( + "\x20\x20" + R"( # COMMENT s1.ripple.com 51235 s2.ripple.com 51235 @@ -1156,23 +1157,24 @@ r.ripple.com 51235 Config cfg; /* NOTE: this string includes some explicit * space chars in order to verify proper trimming */ - std::string toLoad(R"( + std::string toLoad( + R"( [port_rpc])" - "\x20" - R"( + "\x20" + R"( # comment # indented comment )" - "\x20\x20" - R"( + "\x20\x20" + R"( [ips])" - "\x20" - R"( + "\x20" + R"( r.ripple.com:51235 [ips_fixed])" - "\x20\x20" - R"( + "\x20\x20" + R"( # COMMENT s1.ripple.com:51235 s2.ripple.com 51235 diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 73dad7f48e..258b948967 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -28,7 +28,8 @@ operator<<(std::ostream&& os, } #endif -PrettyAmount::operator AnyAmount() const +PrettyAmount:: +operator AnyAmount() const { return {amount_}; } diff --git a/src/test/jtx/impl/mpt.cpp b/src/test/jtx/impl/mpt.cpp index f505bff740..c934d21ff5 100644 --- a/src/test/jtx/impl/mpt.cpp +++ b/src/test/jtx/impl/mpt.cpp @@ -91,7 +91,8 @@ MPTTester::MPTTester(MPTInitDef const& arg) { } -MPTTester::operator MPT() const +MPTTester:: +operator MPT() const { if (!id_) Throw("MPT has not been created"); @@ -534,7 +535,8 @@ MPTTester::mpt(std::int64_t amount) const return xrpl::test::jtx::MPT(issuer_.name(), *id_)(amount); } -MPTTester::operator Asset() const +MPTTester:: +operator Asset() const { if (!id_) Throw("MPT has not been created"); diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index 19876809d2..a5fbef69cf 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -108,8 +108,9 @@ public: BEAST_EXPECT(proto1->ParseFromArray(decompressed.data(), decompressedSize)); auto uncompressed = m.getBuffer(Compressed::Off); - BEAST_EXPECT(std::equal( - uncompressed.begin() + xrpl::compression::headerBytes, uncompressed.end(), decompressed.begin())); + BEAST_EXPECT( + std::equal( + uncompressed.begin() + xrpl::compression::headerBytes, uncompressed.end(), decompressed.begin())); } std::shared_ptr diff --git a/src/test/protocol/STParsedJSON_test.cpp b/src/test/protocol/STParsedJSON_test.cpp index 0ef7878cdc..5b8be83499 100644 --- a/src/test/protocol/STParsedJSON_test.cpp +++ b/src/test/protocol/STParsedJSON_test.cpp @@ -2003,8 +2003,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const goodJson(R"({"CloseResolution":19,"Method":250,)" - R"("TransactionResult":"tecFROZEN"})"); + std::string const goodJson( + R"({"CloseResolution":19,"Method":250,)" + R"("TransactionResult":"tecFROZEN"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(goodJson, jv))) @@ -2019,10 +2020,12 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const goodJson(R"({"CloseResolution":19,"Method":"250",)" - R"("TransactionResult":"tecFROZEN"})"); - std::string const expectedJson(R"({"CloseResolution":19,"Method":250,)" - R"("TransactionResult":"tecFROZEN"})"); + std::string const goodJson( + R"({"CloseResolution":19,"Method":"250",)" + R"("TransactionResult":"tecFROZEN"})"); + std::string const expectedJson( + R"({"CloseResolution":19,"Method":250,)" + R"("TransactionResult":"tecFROZEN"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(goodJson, jv))) @@ -2040,10 +2043,12 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const goodJson(R"({"CloseResolution":"19","Method":"250",)" - R"("TransactionResult":"tecFROZEN"})"); - std::string const expectedJson(R"({"CloseResolution":19,"Method":250,)" - R"("TransactionResult":"tecFROZEN"})"); + std::string const goodJson( + R"({"CloseResolution":"19","Method":"250",)" + R"("TransactionResult":"tecFROZEN"})"); + std::string const expectedJson( + R"({"CloseResolution":19,"Method":250,)" + R"("TransactionResult":"tecFROZEN"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(goodJson, jv))) @@ -2061,8 +2066,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":250,)" - R"("TransactionResult":"terQUEUED"})"); + std::string const json( + R"({"CloseResolution":19,"Method":250,)" + R"("TransactionResult":"terQUEUED"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2076,8 +2082,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":"pony",)" - R"("TransactionResult":"tesSUCCESS"})"); + std::string const json( + R"({"CloseResolution":19,"Method":"pony",)" + R"("TransactionResult":"tesSUCCESS"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2091,8 +2098,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":3294967296,)" - R"("TransactionResult":"tesSUCCESS"})"); + std::string const json( + R"({"CloseResolution":19,"Method":3294967296,)" + R"("TransactionResult":"tesSUCCESS"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2106,8 +2114,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":-10,"Method":42,)" - R"("TransactionResult":"tesSUCCESS"})"); + std::string const json( + R"({"CloseResolution":-10,"Method":42,)" + R"("TransactionResult":"tesSUCCESS"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2121,8 +2130,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":3.141592653,)" - R"("TransactionResult":"tesSUCCESS"})"); + std::string const json( + R"({"CloseResolution":19,"Method":3.141592653,)" + R"("TransactionResult":"tesSUCCESS"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2136,10 +2146,12 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const goodJson(R"({"CloseResolution":19,"Method":250,)" - R"("TransferFee":"65535"})"); - std::string const expectedJson(R"({"CloseResolution":19,"Method":250,)" - R"("TransferFee":65535})"); + std::string const goodJson( + R"({"CloseResolution":19,"Method":250,)" + R"("TransferFee":"65535"})"); + std::string const expectedJson( + R"({"CloseResolution":19,"Method":250,)" + R"("TransferFee":65535})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(goodJson, jv))) @@ -2154,8 +2166,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":250,)" - R"("TransferFee":"65536"})"); + std::string const json( + R"({"CloseResolution":19,"Method":250,)" + R"("TransferFee":"65536"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2169,8 +2182,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":250,)" - R"("TransferFee":"Payment"})"); + std::string const json( + R"({"CloseResolution":19,"Method":250,)" + R"("TransferFee":"Payment"})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) @@ -2184,8 +2198,9 @@ class STParsedJSON_test : public beast::unit_test::suite } { - std::string const json(R"({"CloseResolution":19,"Method":250,)" - R"("TransferFee":true})"); + std::string const json( + R"({"CloseResolution":19,"Method":250,)" + R"("TransferFee":true})"); Json::Value jv; if (BEAST_EXPECT(parseJSONString(json, jv))) diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index 0dec2bde7f..ab9fcf084e 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -769,8 +769,9 @@ public: // xchain_create_account_claim_id should be present on the door // account (Account::master) to collect the signatures until a // quorum is reached - scEnv(test::jtx::create_account_attestation( - x.scAttester, x.jvb, x.mcCarol, amt, x.reward, x.payees[0], true, 1, x.scuAlice, x.signers[0])); + scEnv( + test::jtx::create_account_attestation( + x.scAttester, x.jvb, x.mcCarol, amt, x.reward, x.payees[0], true, 1, x.scuAlice, x.signers[0])); scEnv.close(); auto scEnvAcctObjs = [&](Account const& acct, char const* type) { diff --git a/src/test/rpc/Feature_test.cpp b/src/test/rpc/Feature_test.cpp index 21596634e3..c12988816e 100644 --- a/src/test/rpc/Feature_test.cpp +++ b/src/test/rpc/Feature_test.cpp @@ -162,9 +162,9 @@ class Feature_test : public beast::unit_test::suite BEAST_EXPECTS(jrr[jss::status] == jss::success, "status"); jrr.removeMember(jss::status); BEAST_EXPECT(jrr.size() == 1); - BEAST_EXPECT( - jrr.isMember("12523DF04B553A0B1AD74F42DDB741DE8DC06A03FC089A0EF197E" - "2A87F1D8107")); + BEAST_EXPECT(jrr.isMember( + "12523DF04B553A0B1AD74F42DDB741DE8DC06A03FC089A0EF197E" + "2A87F1D8107")); auto feature = *(jrr.begin()); BEAST_EXPECTS(feature[jss::name] == "fixAMMOverflowOffer", "name"); diff --git a/src/test/rpc/GRPCTestClientBase.h b/src/test/rpc/GRPCTestClientBase.h index 3c39cd1747..475c9da43b 100644 --- a/src/test/rpc/GRPCTestClientBase.h +++ b/src/test/rpc/GRPCTestClientBase.h @@ -12,9 +12,12 @@ namespace test { struct GRPCTestClientBase { explicit GRPCTestClientBase(std::string const& port) - : stub_(org::xrpl::rpc::v1::XRPLedgerAPIService::NewStub(grpc::CreateChannel( - beast::IP::Endpoint(boost::asio::ip::make_address(getEnvLocalhostAddr()), std::stoi(port)).to_string(), - grpc::InsecureChannelCredentials()))) + : stub_( + org::xrpl::rpc::v1::XRPLedgerAPIService::NewStub( + grpc::CreateChannel( + beast::IP::Endpoint(boost::asio::ip::make_address(getEnvLocalhostAddr()), std::stoi(port)) + .to_string(), + grpc::InsecureChannelCredentials()))) { } diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index 5d12e7bb83..a66badf54b 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -581,17 +581,21 @@ class LedgerEntry_test : public beast::unit_test::suite // Create Amendments vector (enabled amendments) std::vector enabledAmendments; enabledAmendments.push_back( - uint256::fromVoid("42426C4D4F1009EE67080A9B7965B44656D7" - "714D104A72F9B4369F97ABF044EE")); + uint256::fromVoid( + "42426C4D4F1009EE67080A9B7965B44656D7" + "714D104A72F9B4369F97ABF044EE")); enabledAmendments.push_back( - uint256::fromVoid("4C97EBA926031A7CF7D7B36FDE3ED66DDA54" - "21192D63DE53FFB46E43B9DC8373")); + uint256::fromVoid( + "4C97EBA926031A7CF7D7B36FDE3ED66DDA54" + "21192D63DE53FFB46E43B9DC8373")); enabledAmendments.push_back( - uint256::fromVoid("03BDC0099C4E14163ADA272C1B6F6FABB448" - "CC3E51F522F978041E4B57D9158C")); + uint256::fromVoid( + "03BDC0099C4E14163ADA272C1B6F6FABB448" + "CC3E51F522F978041E4B57D9158C")); enabledAmendments.push_back( - uint256::fromVoid("35291ADD2D79EB6991343BDA0912269C817D" - "0F094B02226C1C14AD2858962ED4")); + uint256::fromVoid( + "35291ADD2D79EB6991343BDA0912269C817D" + "0F094B02226C1C14AD2858962ED4")); sle->setFieldV256(sfAmendments, STVector256(enabledAmendments)); // Create Majorities array @@ -600,16 +604,18 @@ class LedgerEntry_test : public beast::unit_test::suite auto majority1 = STObject::makeInnerObject(sfMajority); majority1.setFieldH256( sfAmendment, - uint256::fromVoid("7BB62DC13EC72B775091E9C71BF8CF97E122" - "647693B50C5E87A80DFD6FCFAC50")); + uint256::fromVoid( + "7BB62DC13EC72B775091E9C71BF8CF97E122" + "647693B50C5E87A80DFD6FCFAC50")); majority1.setFieldU32(sfCloseTime, 779561310); majorities.push_back(std::move(majority1)); auto majority2 = STObject::makeInnerObject(sfMajority); majority2.setFieldH256( sfAmendment, - uint256::fromVoid("755C971C29971C9F20C6F080F2ED96F87884" - "E40AD19554A5EBECDCEC8A1F77FE")); + uint256::fromVoid( + "755C971C29971C9F20C6F080F2ED96F87884" + "E40AD19554A5EBECDCEC8A1F77FE")); majority2.setFieldU32(sfCloseTime, 779561310); majorities.push_back(std::move(majority2)); @@ -1449,9 +1455,10 @@ class LedgerEntry_test : public beast::unit_test::suite sle->setFieldArray(sfDisabledValidators, disabledValidators); sle->setFieldH256( sfPreviousTxnID, - uint256::fromVoid("8D47FFE664BE6C335108DF689537625855A6" - "A95160CC6D351341B9" - "2624D9C5E3")); + uint256::fromVoid( + "8D47FFE664BE6C335108DF689537625855A6" + "A95160CC6D351341B9" + "2624D9C5E3")); sle->setFieldU32(sfPreviousTxnLgrSeq, 91442944); view.rawInsert(sle); diff --git a/src/test/shamap/SHAMap_test.cpp b/src/test/shamap/SHAMap_test.cpp index c91cc63749..d33a53b9b3 100644 --- a/src/test/shamap/SHAMap_test.cpp +++ b/src/test/shamap/SHAMap_test.cpp @@ -196,40 +196,56 @@ public: testcase("build/tear unbacked"); { constexpr std::array keys{ - uint256("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92881fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92691fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92791fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b91891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b99891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("f22891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8")}; + uint256( + "b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92881fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92691fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92791fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b91891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b99891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "f22891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8")}; constexpr std::array hashes{ - uint256("B7387CFEA0465759ADC718E8C42B52D2309D179B326E239EB5075C" - "64B6281F7F"), - uint256("FBC195A9592A54AB44010274163CB6BA95F497EC5BA0A883184546" - "7FB2ECE266"), - uint256("4E7D2684B65DFD48937FFB775E20175C43AF0C94066F7D5679F51A" - "E756795B75"), - uint256("7A2F312EB203695FFD164E038E281839EEF06A1B99BFC263F3CECC" - "6C74F93E07"), - uint256("395A6691A372387A703FB0F2C6D2C405DAF307D0817F8F0E207596" - "462B0E3A3E"), - uint256("D044C0A696DE3169CC70AE216A1564D69DE96582865796142CE7D9" - "8A84D9DDE4"), - uint256("76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF9" - "4361143615"), - uint256("DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0" - "2BBE7230E5")}; + uint256( + "B7387CFEA0465759ADC718E8C42B52D2309D179B326E239EB5075C" + "64B6281F7F"), + uint256( + "FBC195A9592A54AB44010274163CB6BA95F497EC5BA0A883184546" + "7FB2ECE266"), + uint256( + "4E7D2684B65DFD48937FFB775E20175C43AF0C94066F7D5679F51A" + "E756795B75"), + uint256( + "7A2F312EB203695FFD164E038E281839EEF06A1B99BFC263F3CECC" + "6C74F93E07"), + uint256( + "395A6691A372387A703FB0F2C6D2C405DAF307D0817F8F0E207596" + "462B0E3A3E"), + uint256( + "D044C0A696DE3169CC70AE216A1564D69DE96582865796142CE7D9" + "8A84D9DDE4"), + uint256( + "76DCC77C4027309B5A91AD164083264D70B77B5E43E08AEDA5EBF9" + "4361143615"), + uint256( + "DF4220E93ADC6F5569063A01B4DC79F8DB9553B6A3222ADE23DEA0" + "2BBE7230E5")}; SHAMap map(SHAMapType::FREE, f); if (!backed) @@ -258,22 +274,30 @@ public: { constexpr std::array keys{ - uint256("f22891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b99891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92881fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92791fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b92691fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("b91891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8"), - uint256("292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" - "5a772c6ca8")}; + uint256( + "f22891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b99891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92881fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92791fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b92691fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "b91891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8"), + uint256( + "292891fe4ef6cee585fdc6fda1e09eb4d386363158ec3321b8123e" + "5a772c6ca8")}; tests::TestNodeFamily tf{journal}; SHAMap map{SHAMapType::FREE, tf}; diff --git a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index b7d788e15a..273e3792d3 100644 --- a/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -72,9 +72,10 @@ LedgerReplayTask::LedgerReplayTask( , inboundLedgers_(inboundLedgers) , replayer_(replayer) , parameter_(parameter) - , maxTimeouts_(std::max( - LedgerReplayParameters::TASK_MAX_TIMEOUTS_MINIMUM, - parameter.totalLedgers_ * LedgerReplayParameters::TASK_MAX_TIMEOUTS_MULTIPLIER)) + , maxTimeouts_( + std::max( + LedgerReplayParameters::TASK_MAX_TIMEOUTS_MINIMUM, + parameter.totalLedgers_ * LedgerReplayParameters::TASK_MAX_TIMEOUTS_MULTIPLIER)) , skipListAcquirer_(skipListAcquirer) { JLOG(journal_.trace()) << "Create " << hash_; diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index 4612479b78..c2a5437b70 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -243,42 +243,44 @@ public: , m_journal(logs_->journal("Application")) // PerfLog must be started before any other threads are launched. - , perfLog_(perf::make_PerfLog( - perf::setup_PerfLog(config_->section("perf"), config_->CONFIG_DIR), - *this, - logs_->journal("PerfLog"), - [this] { signalStop("PerfLog"); })) + , perfLog_( + perf::make_PerfLog( + perf::setup_PerfLog(config_->section("perf"), config_->CONFIG_DIR), + *this, + logs_->journal("PerfLog"), + [this] { signalStop("PerfLog"); })) , m_txMaster(*this) , m_collectorManager(make_CollectorManager(config_->section(SECTION_INSIGHT), logs_->journal("Collector"))) - , m_jobQueue(std::make_unique( - [](std::unique_ptr const& config) { - if (config->standalone() && !config->FORCE_MULTI_THREAD) - return 1; + , m_jobQueue( + std::make_unique( + [](std::unique_ptr const& config) { + if (config->standalone() && !config->FORCE_MULTI_THREAD) + return 1; - if (config->WORKERS) - return config->WORKERS; + if (config->WORKERS) + return config->WORKERS; - auto count = static_cast(std::thread::hardware_concurrency()); + auto count = static_cast(std::thread::hardware_concurrency()); - // Be more aggressive about the number of threads to use - // for the job queue if the server is configured as - // "large" or "huge" if there are enough cores. - if (config->NODE_SIZE >= 4 && count >= 16) - count = 6 + std::min(count, 8); - else if (config->NODE_SIZE >= 3 && count >= 8) - count = 4 + std::min(count, 6); - else - count = 2 + std::min(count, 4); + // Be more aggressive about the number of threads to use + // for the job queue if the server is configured as + // "large" or "huge" if there are enough cores. + if (config->NODE_SIZE >= 4 && count >= 16) + count = 6 + std::min(count, 8); + else if (config->NODE_SIZE >= 3 && count >= 8) + count = 4 + std::min(count, 6); + else + count = 2 + std::min(count, 4); - return count; - }(config_), - m_collectorManager->group("jobq"), - logs_->journal("JobQueue"), - *logs_, - *perfLog_)) + return count; + }(config_), + m_collectorManager->group("jobq"), + logs_->journal("JobQueue"), + *logs_, + *perfLog_)) , m_nodeStoreScheduler(*m_jobQueue) @@ -301,11 +303,12 @@ public: , m_pathRequests( std::make_unique(*this, logs_->journal("PathRequest"), m_collectorManager->collector())) - , m_ledgerMaster(std::make_unique( - *this, - stopwatch(), - m_collectorManager->collector(), - logs_->journal("LedgerMaster"))) + , m_ledgerMaster( + std::make_unique( + *this, + stopwatch(), + m_collectorManager->collector(), + logs_->journal("LedgerMaster"))) , ledgerCleaner_(make_LedgerCleaner(*this, logs_->journal("LedgerCleaner"))) @@ -349,13 +352,14 @@ public: , publisherManifests_(std::make_unique(logs_->journal("ManifestCache"))) - , validators_(std::make_unique( - *validatorManifests_, - *publisherManifests_, - *timeKeeper_, - config_->legacy("database_path"), - logs_->journal("ValidatorList"), - config_->VALIDATION_QUORUM)) + , validators_( + std::make_unique( + *validatorManifests_, + *publisherManifests_, + *timeKeeper_, + config_->legacy("database_path"), + logs_->journal("ValidatorList"), + config_->VALIDATION_QUORUM)) , validatorSites_(std::make_unique(*this)) diff --git a/src/xrpld/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp index 9b07728eb8..5160a6779e 100644 --- a/src/xrpld/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -430,58 +430,62 @@ GRPCServerImpl::setupListeners() { using cd = CallData; - addToRequests(std::make_shared( - service_, - *cq_, - app_, - &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedger, - doLedgerGrpc, - &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedger, - RPC::NO_CONDITION, - Resource::feeMediumBurdenRPC, - secureGatewayIPs_)); + addToRequests( + std::make_shared( + service_, + *cq_, + app_, + &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedger, + doLedgerGrpc, + &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedger, + RPC::NO_CONDITION, + Resource::feeMediumBurdenRPC, + secureGatewayIPs_)); } { using cd = CallData; - addToRequests(std::make_shared( - service_, - *cq_, - app_, - &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerData, - doLedgerDataGrpc, - &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerData, - RPC::NO_CONDITION, - Resource::feeMediumBurdenRPC, - secureGatewayIPs_)); + addToRequests( + std::make_shared( + service_, + *cq_, + app_, + &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerData, + doLedgerDataGrpc, + &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerData, + RPC::NO_CONDITION, + Resource::feeMediumBurdenRPC, + secureGatewayIPs_)); } { using cd = CallData; - addToRequests(std::make_shared( - service_, - *cq_, - app_, - &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerDiff, - doLedgerDiffGrpc, - &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerDiff, - RPC::NO_CONDITION, - Resource::feeMediumBurdenRPC, - secureGatewayIPs_)); + addToRequests( + std::make_shared( + service_, + *cq_, + app_, + &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerDiff, + doLedgerDiffGrpc, + &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerDiff, + RPC::NO_CONDITION, + Resource::feeMediumBurdenRPC, + secureGatewayIPs_)); } { using cd = CallData; - addToRequests(std::make_shared( - service_, - *cq_, - app_, - &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerEntry, - doLedgerEntryGrpc, - &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerEntry, - RPC::NO_CONDITION, - Resource::feeMediumBurdenRPC, - secureGatewayIPs_)); + addToRequests( + std::make_shared( + service_, + *cq_, + app_, + &org::xrpl::rpc::v1::XRPLedgerAPIService::AsyncService::RequestGetLedgerEntry, + doLedgerEntryGrpc, + &org::xrpl::rpc::v1::XRPLedgerAPIService::Stub::GetLedgerEntry, + RPC::NO_CONDITION, + Resource::feeMediumBurdenRPC, + secureGatewayIPs_)); } return requests; } diff --git a/src/xrpld/app/misc/CanonicalTXSet.cpp b/src/xrpld/app/misc/CanonicalTXSet.cpp index 6e6102afe7..b9d1a45aa0 100644 --- a/src/xrpld/app/misc/CanonicalTXSet.cpp +++ b/src/xrpld/app/misc/CanonicalTXSet.cpp @@ -32,8 +32,9 @@ CanonicalTXSet::accountKey(AccountID const& account) void CanonicalTXSet::insert(std::shared_ptr const& txn) { - map_.insert(std::make_pair( - Key(accountKey(txn->getAccountID(sfAccount)), txn->getSeqProxy(), txn->getTransactionID()), txn)); + map_.insert( + std::make_pair( + Key(accountKey(txn->getAccountID(sfAccount)), txn->getSeqProxy(), txn->getTransactionID()), txn)); } std::shared_ptr diff --git a/src/xrpld/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h index f93ac8a32f..dd8eecc259 100644 --- a/src/xrpld/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -596,13 +596,14 @@ public: May be called concurrently */ void - for_each_available(std::function const& blobInfos, - PublicKey const& pubKey, - std::size_t maxSequence, - uint256 const& hash)> func) const; + for_each_available( + std::function const& blobInfos, + PublicKey const& pubKey, + std::size_t maxSequence, + uint256 const& hash)> func) const; /** Returns the current valid list for the given publisher key, if available, as a Json object. diff --git a/src/xrpld/app/misc/detail/LendingHelpers.cpp b/src/xrpld/app/misc/detail/LendingHelpers.cpp index 106eeb9301..c0fd4c36d8 100644 --- a/src/xrpld/app/misc/detail/LendingHelpers.cpp +++ b/src/xrpld/app/misc/detail/LendingHelpers.cpp @@ -328,23 +328,24 @@ doPayment( "xrpl::detail::doPayment", "fee outstanding stays valid"); - return LoanPaymentParts{// Principal paid is straightforward - it's the tracked delta - .principalPaid = payment.trackedPrincipalDelta, + return LoanPaymentParts{ + // Principal paid is straightforward - it's the tracked delta + .principalPaid = payment.trackedPrincipalDelta, - // Interest paid combines: - // 1. Tracked interest from the amortization schedule - // (derived from the tracked deltas) - // 2. Untracked interest (e.g., late payment penalties) - .interestPaid = payment.trackedInterestPart() + payment.untrackedInterest, + // Interest paid combines: + // 1. Tracked interest from the amortization schedule + // (derived from the tracked deltas) + // 2. Untracked interest (e.g., late payment penalties) + .interestPaid = payment.trackedInterestPart() + payment.untrackedInterest, - // Value change represents how the loan's total value changed beyond - // normal amortization. - .valueChange = payment.untrackedInterest, + // Value change represents how the loan's total value changed beyond + // normal amortization. + .valueChange = payment.untrackedInterest, - // Fee paid combines: - // 1. Tracked management fees from the amortization schedule - // 2. Untracked fees (e.g., late payment fees, service fees) - .feePaid = payment.trackedManagementFeeDelta + payment.untrackedManagementFee}; + // Fee paid combines: + // 1. Tracked management fees from the amortization schedule + // 2. Untracked fees (e.g., late payment fees, service fees) + .feePaid = payment.trackedManagementFeeDelta + payment.untrackedManagementFee}; } /* Simulates an overpayment to validate it won't break the loan's amortization. diff --git a/src/xrpld/app/misc/detail/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp index dfcbdbb3ad..12c76d50e8 100644 --- a/src/xrpld/app/misc/detail/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -523,11 +523,12 @@ ManifestCache::load( if (!configRevocation.empty()) { std::string revocationStr; - revocationStr.reserve(std::accumulate( - configRevocation.cbegin(), - configRevocation.cend(), - std::size_t(0), - [](std::size_t init, std::string const& s) { return init + s.size(); })); + revocationStr.reserve( + std::accumulate( + configRevocation.cbegin(), + configRevocation.cend(), + std::size_t(0), + [](std::size_t init, std::string const& s) { return init + s.size(); })); for (auto const& line : configRevocation) revocationStr += boost::algorithm::trim_copy(line); diff --git a/src/xrpld/app/misc/detail/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp index 4730df4983..eb47e7eaf3 100644 --- a/src/xrpld/app/misc/detail/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -1595,13 +1595,14 @@ ValidatorList::for_each_listed(std::function func) } void -ValidatorList::for_each_available(std::function const& blobInfos, - PublicKey const& pubKey, - std::size_t maxSequence, - uint256 const& hash)> func) const +ValidatorList::for_each_available( + std::function const& blobInfos, + PublicKey const& pubKey, + std::size_t maxSequence, + uint256 const& hash)> func) const { std::shared_lock read_lock{mutex_}; diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 01e036731c..7680689e0a 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -555,8 +555,9 @@ std::pair>, int> getTxHistory(soci::session& session, Application& app, LedgerIndex startIndex, int quantity) { std::string sql = boost::str( - boost::format("SELECT LedgerSeq, Status, RawTxn " - "FROM Transactions ORDER BY LedgerSeq DESC LIMIT %u,%u;") % + boost::format( + "SELECT LedgerSeq, Status, RawTxn " + "FROM Transactions ORDER BY LedgerSeq DESC LIMIT %u,%u;") % startIndex % quantity); std::vector> txs; @@ -658,18 +659,20 @@ transactionsSQL( if (count) sql = boost::str( - boost::format("SELECT %s FROM AccountTransactions " - "WHERE Account = '%s' %s %s LIMIT %u, %u;") % + boost::format( + "SELECT %s FROM AccountTransactions " + "WHERE Account = '%s' %s %s LIMIT %u, %u;") % selection % toBase58(options.account) % maxClause % minClause % options.offset % numberOfResults); else sql = boost::str( - boost::format("SELECT %s FROM " - "AccountTransactions INNER JOIN Transactions " - "ON Transactions.TransID = AccountTransactions.TransID " - "WHERE Account = '%s' %s %s " - "ORDER BY AccountTransactions.LedgerSeq %s, " - "AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s " - "LIMIT %u, %u;") % + boost::format( + "SELECT %s FROM " + "AccountTransactions INNER JOIN Transactions " + "ON Transactions.TransID = AccountTransactions.TransID " + "WHERE Account = '%s' %s %s " + "ORDER BY AccountTransactions.LedgerSeq %s, " + "AccountTransactions.TxnSeq %s, AccountTransactions.TransID %s " + "LIMIT %u, %u;") % selection % toBase58(options.account) % maxClause % minClause % (descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") % (descending ? "DESC" : "ASC") % options.offset % numberOfResults); JLOG(j.trace()) << "txSQL query: " << sql; diff --git a/src/xrpld/app/tx/detail/ApplyContext.h b/src/xrpld/app/tx/detail/ApplyContext.h index 45345df265..d2208c13a1 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.h +++ b/src/xrpld/app/tx/detail/ApplyContext.h @@ -90,11 +90,12 @@ public: /** Visit unapplied changes. */ void - visit(std::function const& before, - std::shared_ptr const& after)> const& func); + visit( + std::function const& before, + std::shared_ptr const& after)> const& func); void destroyXRP(XRPAmount const& fee) diff --git a/src/xrpld/app/tx/detail/DepositPreauth.cpp b/src/xrpld/app/tx/detail/DepositPreauth.cpp index 4636bdb359..023833212c 100644 --- a/src/xrpld/app/tx/detail/DepositPreauth.cpp +++ b/src/xrpld/app/tx/detail/DepositPreauth.cpp @@ -120,8 +120,9 @@ DepositPreauth::preclaim(PreclaimContext const& ctx) else if (ctx.tx.isFieldPresent(sfUnauthorizeCredentials)) { // Verify that the Preauth entry is in the ledger. - if (!ctx.view.exists(keylet::depositPreauth( - account, credentials::makeSorted(ctx.tx.getFieldArray(sfUnauthorizeCredentials))))) + if (!ctx.view.exists( + keylet::depositPreauth( + account, credentials::makeSorted(ctx.tx.getFieldArray(sfUnauthorizeCredentials))))) return tecNO_ENTRY; } return tesSUCCESS; diff --git a/src/xrpld/overlay/Slot.h b/src/xrpld/overlay/Slot.h index f3fd919648..d0f2c62174 100644 --- a/src/xrpld/overlay/Slot.h +++ b/src/xrpld/overlay/Slot.h @@ -492,13 +492,15 @@ Slot::getPeers() const auto r = std::unordered_map>(); for (auto const& [id, info] : peers_) - r.emplace(std::make_pair( - id, - std::move(std::make_tuple( - info.state, - info.count, - epoch(info.expire).count(), - epoch(info.lastMessage).count())))); + r.emplace( + std::make_pair( + id, + std::move( + std::make_tuple( + info.state, + info.count, + epoch(info.expire).count(), + epoch(info.lastMessage).count())))); return r; } @@ -724,10 +726,11 @@ Slots::updateSlotAndSquelch( if (it == slots_.end()) { JLOG(journal_.trace()) << "updateSlotAndSquelch: new slot " << Slice(validator); - auto it = slots_ - .emplace(std::make_pair( - validator, Slot(handler_, logs_.journal("Slot"), maxSelectedPeers_))) - .first; + auto it = + slots_ + .emplace( + std::make_pair(validator, Slot(handler_, logs_.journal("Slot"), maxSelectedPeers_))) + .first; it->second.update(validator, id, type, callback); } else diff --git a/src/xrpld/overlay/detail/ConnectAttempt.cpp b/src/xrpld/overlay/detail/ConnectAttempt.cpp index 8de737f46d..61fb9d704a 100644 --- a/src/xrpld/overlay/detail/ConnectAttempt.cpp +++ b/src/xrpld/overlay/detail/ConnectAttempt.cpp @@ -180,8 +180,9 @@ ConnectAttempt::setTimer(ConnectionStep step) try { timer_.expires_after(connectTimeout); - timer_.async_wait(boost::asio::bind_executor( - strand_, std::bind(&ConnectAttempt::onTimer, shared_from_this(), std::placeholders::_1))); + timer_.async_wait( + boost::asio::bind_executor( + strand_, std::bind(&ConnectAttempt::onTimer, shared_from_this(), std::placeholders::_1))); } catch (std::exception const& ex) { @@ -218,8 +219,9 @@ ConnectAttempt::setTimer(ConnectionStep step) // call to expires_after cancels previous timer stepTimer_.expires_after(stepTimeout); - stepTimer_.async_wait(boost::asio::bind_executor( - strand_, std::bind(&ConnectAttempt::onTimer, shared_from_this(), std::placeholders::_1))); + stepTimer_.async_wait( + boost::asio::bind_executor( + strand_, std::bind(&ConnectAttempt::onTimer, shared_from_this(), std::placeholders::_1))); JLOG(journal_.trace()) << "setTimer: " << stepToString(step) << " timeout=" << stepTimeout.count() << "s"; } diff --git a/src/xrpld/overlay/detail/OverlayImpl.cpp b/src/xrpld/overlay/detail/OverlayImpl.cpp index 5b9f142001..29cab0ee6d 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.cpp +++ b/src/xrpld/overlay/detail/OverlayImpl.cpp @@ -60,8 +60,9 @@ void OverlayImpl::Timer::async_wait() { timer_.expires_after(std::chrono::seconds(1)); - timer_.async_wait(boost::asio::bind_executor( - overlay_.strand_, std::bind(&Timer::on_timer, shared_from_this(), std::placeholders::_1))); + timer_.async_wait( + boost::asio::bind_executor( + overlay_.strand_, std::bind(&Timer::on_timer, shared_from_this(), std::placeholders::_1))); } void diff --git a/src/xrpld/overlay/detail/OverlayImpl.h b/src/xrpld/overlay/detail/OverlayImpl.h index 19fff6a29a..ca20ed6733 100644 --- a/src/xrpld/overlay/detail/OverlayImpl.h +++ b/src/xrpld/overlay/detail/OverlayImpl.h @@ -191,7 +191,8 @@ public: std::size_t& disabled, std::size_t& enabledInSkip) const; - void checkTracking(std::uint32_t) override; + void + checkTracking(std::uint32_t) override; std::shared_ptr findPeerByShortID(Peer::id_t const& id) const override; diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index ec641487a8..20f68a215b 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -532,8 +532,7 @@ void PeerImp::fail(std::string const& reason) { if (!strand_.running_in_this_thread()) - return post( - strand_, std::bind((void(Peer::*)(std::string const&)) & PeerImp::fail, shared_from_this(), reason)); + return post(strand_, std::bind((void (Peer::*)(std::string const&))&PeerImp::fail, shared_from_this(), reason)); if (!socket_.is_open()) return; diff --git a/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp b/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp index 2f3326a8e1..18acdd3fe1 100644 --- a/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCLedgerHelpers.cpp @@ -355,8 +355,9 @@ getOrAcquireLedger(RPC::JsonContext const& context) if ((hasHash + hasIndex) != 1) { return Unexpected( - RPC::make_param_error("Exactly one of 'ledger_hash' or " - "'ledger_index' can be specified.")); + RPC::make_param_error( + "Exactly one of 'ledger_hash' or " + "'ledger_index' can be specified.")); } if (hasHash) diff --git a/src/xrpld/rpc/handlers/LedgerEntry.cpp b/src/xrpld/rpc/handlers/LedgerEntry.cpp index 440ed11c18..489e0c87ca 100644 --- a/src/xrpld/rpc/handlers/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/LedgerEntry.cpp @@ -200,16 +200,18 @@ parseAuthorizeCredentials(Json::Value const& jv) std::uint32_t const n = jv.size(); if (n > maxCredentialsArraySize) { - return Unexpected(LedgerEntryHelpers::malformedError( - "malformedAuthorizedCredentials", - "Invalid field '" + std::string(jss::authorized_credentials) + "', array too long.")); + return Unexpected( + LedgerEntryHelpers::malformedError( + "malformedAuthorizedCredentials", + "Invalid field '" + std::string(jss::authorized_credentials) + "', array too long.")); } if (n == 0) { - return Unexpected(LedgerEntryHelpers::malformedError( - "malformedAuthorizedCredentials", - "Invalid field '" + std::string(jss::authorized_credentials) + "', array empty.")); + return Unexpected( + LedgerEntryHelpers::malformedError( + "malformedAuthorizedCredentials", + "Invalid field '" + std::string(jss::authorized_credentials) + "', array empty.")); } STArray arr(sfAuthorizeCredentials, n); diff --git a/src/xrpld/shamap/NodeFamily.cpp b/src/xrpld/shamap/NodeFamily.cpp index a05e89dc84..a0821ea202 100644 --- a/src/xrpld/shamap/NodeFamily.cpp +++ b/src/xrpld/shamap/NodeFamily.cpp @@ -10,19 +10,21 @@ NodeFamily::NodeFamily(Application& app, CollectorManager& cm) : app_(app) , db_(app.getNodeStore()) , j_(app.journal("NodeFamily")) - , fbCache_(std::make_shared( - "Node family full below cache", - stopwatch(), - app.journal("NodeFamilyFulLBelowCache"), - cm.collector(), - fullBelowTargetSize, - fullBelowExpiration)) - , tnCache_(std::make_shared( - "Node family tree node cache", - app.config().getValueFor(SizedItem::treeCacheSize), - std::chrono::seconds(app.config().getValueFor(SizedItem::treeCacheAge)), - stopwatch(), - j_)) + , fbCache_( + std::make_shared( + "Node family full below cache", + stopwatch(), + app.journal("NodeFamilyFulLBelowCache"), + cm.collector(), + fullBelowTargetSize, + fullBelowExpiration)) + , tnCache_( + std::make_shared( + "Node family tree node cache", + app.config().getValueFor(SizedItem::treeCacheSize), + std::chrono::seconds(app.config().getValueFor(SizedItem::treeCacheAge)), + stopwatch(), + j_)) { } From 36240116a540c8e52b92bd186641bffda147e4c1 Mon Sep 17 00:00:00 2001 From: Jingchen Date: Tue, 17 Feb 2026 16:29:53 +0000 Subject: [PATCH 15/16] refactor: Decouple app/tx from `Application` and `Config` (#6227) This change decouples app/tx from `Application` and `Config` to clear the way to moving transactors to `libxrpl`. --- .../scripts/levelization/results/ordering.txt | 1 + include/xrpl/core/NetworkIDService.h | 33 +++++++++++++++++++ include/xrpl/core/ServiceRegistry.h | 4 +++ src/test/app/NetworkID_test.cpp | 7 ++-- src/test/app/tx/apply_test.cpp | 8 ++--- src/test/jtx/impl/Env.cpp | 3 +- src/test/rpc/Subscribe_test.cpp | 13 +++++--- src/test/rpc/Transaction_test.cpp | 11 ++++--- src/xrpld/app/ledger/detail/BuildLedger.cpp | 1 + src/xrpld/app/main/Application.cpp | 10 ++++++ src/xrpld/app/misc/NetworkOPs.cpp | 16 ++++----- src/xrpld/app/misc/detail/AccountTxPaging.cpp | 3 +- src/xrpld/app/misc/setup_HashRouter.h | 5 +-- src/xrpld/app/rdb/backend/detail/Node.cpp | 3 +- src/xrpld/app/tx/apply.h | 8 ++--- src/xrpld/app/tx/applySteps.h | 12 +++---- src/xrpld/app/tx/detail/AMMCreate.cpp | 2 +- src/xrpld/app/tx/detail/ApplyContext.cpp | 4 +-- src/xrpld/app/tx/detail/ApplyContext.h | 12 +++---- src/xrpld/app/tx/detail/Batch.cpp | 2 +- src/xrpld/app/tx/detail/CancelCheck.cpp | 2 +- src/xrpld/app/tx/detail/CancelOffer.cpp | 2 +- src/xrpld/app/tx/detail/CashCheck.cpp | 2 +- src/xrpld/app/tx/detail/Change.cpp | 10 +++--- src/xrpld/app/tx/detail/CreateCheck.cpp | 2 +- src/xrpld/app/tx/detail/CreateOffer.cpp | 8 ++--- src/xrpld/app/tx/detail/CreateTicket.cpp | 2 +- src/xrpld/app/tx/detail/DeleteAccount.cpp | 24 +++++++------- src/xrpld/app/tx/detail/Escrow.cpp | 6 ++-- src/xrpld/app/tx/detail/PayChan.cpp | 6 ++-- src/xrpld/app/tx/detail/Payment.cpp | 2 +- src/xrpld/app/tx/detail/SetRegularKey.cpp | 2 +- src/xrpld/app/tx/detail/SetSignerList.cpp | 17 +++++----- src/xrpld/app/tx/detail/SetSignerList.h | 2 +- src/xrpld/app/tx/detail/SetTrust.cpp | 2 +- src/xrpld/app/tx/detail/Transactor.cpp | 21 ++++++------ src/xrpld/app/tx/detail/Transactor.h | 24 +++++++------- src/xrpld/app/tx/detail/apply.cpp | 27 +++++++-------- src/xrpld/app/tx/detail/applySteps.cpp | 23 ++++++------- src/xrpld/core/NetworkIDServiceImpl.h | 32 ++++++++++++++++++ .../core/detail/NetworkIDServiceImpl.cpp | 16 +++++++++ src/xrpld/overlay/detail/PeerImp.cpp | 4 +-- src/xrpld/rpc/detail/TransactionSign.cpp | 5 +-- src/xrpld/rpc/handlers/Simulate.cpp | 3 +- src/xrpld/rpc/handlers/Submit.cpp | 4 +-- src/xrpld/rpc/handlers/Tx.cpp | 5 +-- 46 files changed, 256 insertions(+), 155 deletions(-) create mode 100644 include/xrpl/core/NetworkIDService.h create mode 100644 src/xrpld/core/NetworkIDServiceImpl.h create mode 100644 src/xrpld/core/detail/NetworkIDServiceImpl.cpp diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 5f8812c49b..30dc2be043 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -83,6 +83,7 @@ test.csf > xrpl.protocol test.json > test.jtx test.json > xrpl.json test.jtx > xrpl.basics +test.jtx > xrpl.core test.jtx > xrpld.app test.jtx > xrpld.core test.jtx > xrpld.rpc diff --git a/include/xrpl/core/NetworkIDService.h b/include/xrpl/core/NetworkIDService.h new file mode 100644 index 0000000000..d12fa42055 --- /dev/null +++ b/include/xrpl/core/NetworkIDService.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +namespace xrpl { + +/** Service that provides access to the network ID. + + This service provides read-only access to the network ID configured + for this server. The network ID identifies which network (mainnet, + testnet, devnet, or custom network) this server is configured to + connect to. + + Well-known network IDs: + - 0: Mainnet + - 1: Testnet + - 2: Devnet + - 1025+: Custom networks (require NetworkID field in transactions) +*/ +class NetworkIDService +{ +public: + virtual ~NetworkIDService() = default; + + /** Get the configured network ID + * + * @return The network ID this server is configured for + */ + virtual std::uint32_t + getNetworkID() const noexcept = 0; +}; + +} // namespace xrpl diff --git a/include/xrpl/core/ServiceRegistry.h b/include/xrpl/core/ServiceRegistry.h index fabf61f9e4..1a2e33d5ee 100644 --- a/include/xrpl/core/ServiceRegistry.h +++ b/include/xrpl/core/ServiceRegistry.h @@ -41,6 +41,7 @@ class LoadFeeTrack; class LoadManager; class ManifestCache; class NetworkOPs; +class NetworkIDService; class OpenLedger; class OrderBookDB; class Overlay; @@ -99,6 +100,9 @@ public: virtual CachedSLEs& cachedSLEs() = 0; + virtual NetworkIDService& + getNetworkIDService() = 0; + // Protocol and validation services virtual AmendmentTable& getAmendmentTable() = 0; diff --git a/src/test/app/NetworkID_test.cpp b/src/test/app/NetworkID_test.cpp index 5fddc8f641..6b306f63fb 100644 --- a/src/test/app/NetworkID_test.cpp +++ b/src/test/app/NetworkID_test.cpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace xrpl { @@ -58,7 +59,7 @@ public: // test mainnet { test::jtx::Env env{*this, makeNetworkConfig(0)}; - BEAST_EXPECT(env.app().config().NETWORK_ID == 0); + BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 0); // try to submit a txn without network id, this should work Json::Value jv; @@ -81,7 +82,7 @@ public: // NetworkID { test::jtx::Env env{*this, makeNetworkConfig(1024)}; - BEAST_EXPECT(env.app().config().NETWORK_ID == 1024); + BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 1024); // try to submit a txn without network id, this should work Json::Value jv; @@ -101,7 +102,7 @@ public: // absent networkid { test::jtx::Env env{*this, makeNetworkConfig(1025)}; - BEAST_EXPECT(env.app().config().NETWORK_ID == 1025); + BEAST_EXPECT(env.app().getNetworkIDService().getNetworkID() == 1025); { env.fund(XRP(200), alice); // try to submit a txn without network id, this should not work diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index fada168112..eb684175de 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -38,12 +38,8 @@ public: { test::jtx::Env fully_canonical(*this, test::jtx::testable_amendments()); - Validity valid = checkValidity( - fully_canonical.app().getHashRouter(), - tx, - fully_canonical.current()->rules(), - fully_canonical.app().config()) - .first; + Validity valid = + checkValidity(fully_canonical.app().getHashRouter(), tx, fully_canonical.current()->rules()).first; if (valid == Validity::Valid) fail("Non-Fully canonical signature was permitted"); } diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 3fdfa2bf2a..636894c0d5 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -526,7 +527,7 @@ Env::autofill(JTx& jt) if (jt.fill_netid) { - uint32_t networkID = app().config().NETWORK_ID; + uint32_t networkID = app().getNetworkIDService().getNetworkID(); if (!jv.isMember(jss::NetworkID) && networkID > 1024) jv[jss::NetworkID] = std::to_string(networkID); } diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 759b02dcc7..99f664f42e 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -106,7 +107,7 @@ public: BEAST_EXPECT(jv.isMember(jss::id) && jv[jss::id] == 5); } BEAST_EXPECT(jv[jss::result][jss::ledger_index] == 2); - BEAST_EXPECT(jv[jss::result][jss::network_id] == env.app().config().NETWORK_ID); + BEAST_EXPECT(jv[jss::result][jss::network_id] == env.app().getNetworkIDService().getNetworkID()); } { @@ -115,7 +116,8 @@ public: // Check stream update BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) { - return jv[jss::ledger_index] == 3 && jv[jss::network_id] == env.app().config().NETWORK_ID; + return jv[jss::ledger_index] == 3 && + jv[jss::network_id] == env.app().getNetworkIDService().getNetworkID(); })); } @@ -125,7 +127,8 @@ public: // Check stream update BEAST_EXPECT(wsc->findMsg(5s, [&](auto const& jv) { - return jv[jss::ledger_index] == 4 && jv[jss::network_id] == env.app().config().NETWORK_ID; + return jv[jss::ledger_index] == 4 && + jv[jss::network_id] == env.app().getNetworkIDService().getNetworkID(); })); } @@ -451,7 +454,7 @@ public: if (!jv.isMember(jss::validated_hash)) return false; - uint32_t netID = env.app().config().NETWORK_ID; + uint32_t netID = env.app().getNetworkIDService().getNetworkID(); if (!jv.isMember(jss::network_id) || jv[jss::network_id] != netID) return false; @@ -510,7 +513,7 @@ public: jv[jss::streams][0u] = "ledger"; jr = env.rpc("json", "subscribe", to_string(jv))[jss::result]; BEAST_EXPECT(jr[jss::status] == "success"); - BEAST_EXPECT(jr[jss::network_id] == env.app().config().NETWORK_ID); + BEAST_EXPECT(jr[jss::network_id] == env.app().getNetworkIDService().getNetworkID()); jr = env.rpc("json", "unsubscribe", to_string(jv))[jss::result]; BEAST_EXPECT(jr[jss::status] == "success"); diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index acc8bccf61..731caee429 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -247,7 +248,7 @@ class Transaction_test : public beast::unit_test::suite char const* EXCESSIVE = RPC::get_error_info(rpcEXCESSIVE_LGR_RANGE).token; Env env{*this, makeNetworkConfig(11111)}; - uint32_t netID = env.app().config().NETWORK_ID; + uint32_t netID = env.app().getNetworkIDService().getNetworkID(); auto const alice = Account("alice"); env.fund(XRP(1000), alice); @@ -520,7 +521,7 @@ class Transaction_test : public beast::unit_test::suite for (uint32_t netID : {11111, 65535, 65536}) { Env env{*this, makeNetworkConfig(netID)}; - BEAST_EXPECT(netID == env.app().config().NETWORK_ID); + BEAST_EXPECT(netID == env.app().getNetworkIDService().getNetworkID()); auto const alice = Account("alice"); auto const bob = Account("bob"); @@ -550,7 +551,7 @@ class Transaction_test : public beast::unit_test::suite // test querying with mixed case ctid { Env env{*this, makeNetworkConfig(11111)}; - std::uint32_t const netID = env.app().config().NETWORK_ID; + std::uint32_t const netID = env.app().getNetworkIDService().getNetworkID(); Account const alice = Account("alice"); Account const bob = Account("bob"); @@ -591,7 +592,7 @@ class Transaction_test : public beast::unit_test::suite for (uint32_t netID : {2, 1024, 65535, 65536}) { Env env{*this, makeNetworkConfig(netID)}; - BEAST_EXPECT(netID == env.app().config().NETWORK_ID); + BEAST_EXPECT(netID == env.app().getNetworkIDService().getNetworkID()); auto const alice = Account("alice"); auto const bob = Account("bob"); @@ -623,7 +624,7 @@ class Transaction_test : public beast::unit_test::suite // test the wrong network ID was submitted { Env env{*this, makeNetworkConfig(21337)}; - uint32_t netID = env.app().config().NETWORK_ID; + uint32_t netID = env.app().getNetworkIDService().getNetworkID(); auto const alice = Account("alice"); auto const bob = Account("bob"); diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 1414441b35..8321190add 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index c2a5437b70..f53ca9e36b 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -158,6 +159,7 @@ public: NodeCache m_tempNodeCache; CachedSLEs cachedSLEs_; + std::unique_ptr networkIDService_; std::optional> nodeIdentity_; ValidatorKeys const validatorKeys_; @@ -290,6 +292,8 @@ public: , cachedSLEs_("Cached SLEs", 0, std::chrono::minutes(1), stopwatch(), logs_->journal("CachedSLEs")) + , networkIDService_(std::make_unique(config_->NETWORK_ID)) + , validatorKeys_(*config_, m_journal) , m_resourceManager(Resource::make_Manager(m_collectorManager->collector(), logs_->journal("Resource"))) @@ -632,6 +636,12 @@ public: return cachedSLEs_; } + NetworkIDService& + getNetworkIDService() override + { + return *networkIDService_; + } + AmendmentTable& getAmendmentTable() override { diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 8732f9610d..44543e8910 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -1101,8 +1102,8 @@ NetworkOPsImp::submitTransaction(std::shared_ptr const& iTrans) try { - auto const [validity, reason] = checkValidity( - registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules(), registry_.app().config()); + auto const [validity, reason] = + checkValidity(registry_.getHashRouter(), *trans, m_ledgerMaster.getValidatedRules()); if (validity != Validity::Valid) { @@ -1158,8 +1159,7 @@ NetworkOPsImp::preProcessTransaction(std::shared_ptr& transaction) // NOTE ximinez - I think this check is redundant, // but I'm not 100% sure yet. // If so, only cost is looking up HashRouter flags. - auto const [validity, reason] = - checkValidity(registry_.getHashRouter(), sttx, view->rules(), registry_.app().config()); + auto const [validity, reason] = checkValidity(registry_.getHashRouter(), sttx, view->rules()); XRPL_ASSERT(validity == Validity::Valid, "xrpl::NetworkOPsImp::processTransaction : valid validity"); // Not concerned with local checks at this point. @@ -2195,7 +2195,7 @@ NetworkOPsImp::pubValidation(std::shared_ptr const& val) jvObj[jss::flags] = val->getFlags(); jvObj[jss::signing_time] = *(*val)[~sfSigningTime]; jvObj[jss::data] = strHex(val->getSerializer().slice()); - jvObj[jss::network_id] = registry_.app().config().NETWORK_ID; + jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID(); if (auto version = (*val)[~sfServerVersion]) jvObj[jss::server_version] = std::to_string(*version); @@ -2844,7 +2844,7 @@ NetworkOPsImp::pubLedger(std::shared_ptr const& lpAccepted) jvObj[jss::ledger_hash] = to_string(lpAccepted->header().hash); jvObj[jss::ledger_time] = Json::Value::UInt(lpAccepted->header().closeTime.time_since_epoch().count()); - jvObj[jss::network_id] = registry_.app().config().NETWORK_ID; + jvObj[jss::network_id] = registry_.getNetworkIDService().getNetworkID(); if (!lpAccepted->rules().enabled(featureXRPFees)) jvObj[jss::fee_ref] = Config::FEE_UNITS_DEPRECATED; @@ -2987,7 +2987,7 @@ NetworkOPsImp::transJson( lookup.second && lookup.second->isFieldPresent(sfTransactionIndex)) { uint32_t const txnSeq = lookup.second->getFieldU32(sfTransactionIndex); - uint32_t netID = registry_.app().config().NETWORK_ID; + uint32_t netID = registry_.getNetworkIDService().getNetworkID(); if (transaction->isFieldPresent(sfNetworkID)) netID = transaction->getFieldU32(sfNetworkID); @@ -3817,7 +3817,7 @@ NetworkOPsImp::subLedger(InfoSub::ref isrListener, Json::Value& jvResult) jvResult[jss::fee_base] = lpClosed->fees().base.jsonClipped(); jvResult[jss::reserve_base] = lpClosed->fees().reserve.jsonClipped(); jvResult[jss::reserve_inc] = lpClosed->fees().increment.jsonClipped(); - jvResult[jss::network_id] = registry_.app().config().NETWORK_ID; + jvResult[jss::network_id] = registry_.getNetworkIDService().getNetworkID(); } if ((mMode >= OperatingMode::SYNCING) && !isNeedNetworkLedger()) diff --git a/src/xrpld/app/misc/detail/AccountTxPaging.cpp b/src/xrpld/app/misc/detail/AccountTxPaging.cpp index e3fc2de4f8..63457f00ac 100644 --- a/src/xrpld/app/misc/detail/AccountTxPaging.cpp +++ b/src/xrpld/app/misc/detail/AccountTxPaging.cpp @@ -3,6 +3,7 @@ #include #include +#include #include namespace xrpl { @@ -30,7 +31,7 @@ convertBlobsToTxResult( Transaction::sqlTransactionStatus(status), ledger_index, metaset->getAsObject().getFieldU32(sfTransactionIndex), - app.config().NETWORK_ID); + app.getNetworkIDService().getNetworkID()); else tr->setStatus(Transaction::sqlTransactionStatus(status), ledger_index); diff --git a/src/xrpld/app/misc/setup_HashRouter.h b/src/xrpld/app/misc/setup_HashRouter.h index 3054233b89..9b767d0170 100644 --- a/src/xrpld/app/misc/setup_HashRouter.h +++ b/src/xrpld/app/misc/setup_HashRouter.h @@ -1,5 +1,4 @@ -#ifndef XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED -#define XRPLD_APP_MISC_SETUP_HASHROUTER_H_INCLUDED +#pragma once #include @@ -13,5 +12,3 @@ HashRouter::Setup setup_HashRouter(Config const& config); } // namespace xrpl - -#endif diff --git a/src/xrpld/app/rdb/backend/detail/Node.cpp b/src/xrpld/app/rdb/backend/detail/Node.cpp index 7680689e0a..e6e8062674 100644 --- a/src/xrpld/app/rdb/backend/detail/Node.cpp +++ b/src/xrpld/app/rdb/backend/detail/Node.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -306,7 +307,7 @@ saveValidatedLedger( acceptedLedgerTx->getTxn()->getMetaSQL(seq, acceptedLedgerTx->getEscMeta()) + ";"); app.getMasterTransaction().inLedger( - transactionID, seq, acceptedLedgerTx->getTxnSeq(), app.config().NETWORK_ID); + transactionID, seq, acceptedLedgerTx->getTxnSeq(), app.getNetworkIDService().getNetworkID()); } tr.commit(); diff --git a/src/xrpld/app/tx/apply.h b/src/xrpld/app/tx/apply.h index c3ff4f905e..c21e7c1925 100644 --- a/src/xrpld/app/tx/apply.h +++ b/src/xrpld/app/tx/apply.h @@ -11,8 +11,8 @@ namespace xrpl { -class Application; class HashRouter; +class ServiceRegistry; /** Describes the pre-processing validity of a transaction. @@ -41,7 +41,7 @@ enum class Validity { @see Validity */ std::pair -checkValidity(HashRouter& router, STTx const& tx, Rules const& rules, Config const& config); +checkValidity(HashRouter& router, STTx const& tx, Rules const& rules); /** Sets the validity of a given transaction in the cache. @@ -97,7 +97,7 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity); whether or not the transaction was applied. */ ApplyResult -apply(Application& app, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal journal); +apply(ServiceRegistry& registry, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal journal); /** Enum class for return value from `applyTransaction` @@ -121,7 +121,7 @@ enum class ApplyTransactionResult { */ ApplyTransactionResult applyTransaction( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& tx, bool retryAssured, diff --git a/src/xrpld/app/tx/applySteps.h b/src/xrpld/app/tx/applySteps.h index ef87d352f3..7699ed2493 100644 --- a/src/xrpld/app/tx/applySteps.h +++ b/src/xrpld/app/tx/applySteps.h @@ -5,7 +5,7 @@ namespace xrpl { -class Application; +class ServiceRegistry; class STTx; class TxQ; @@ -240,11 +240,11 @@ public: */ /** @{ */ PreflightResult -preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j); +preflight(ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j); PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, uint256 const& parentBatchId, STTx const& tx, @@ -281,7 +281,7 @@ preflight( this transaction. */ PreclaimResult -preclaim(PreflightResult const& preflightResult, Application& app, OpenView const& view); +preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, OpenView const& view); /** Compute only the expected base fee for a transaction. @@ -323,7 +323,7 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx); @param preclaimResult The result of a previous call to `preclaim` for the transaction. - @param app The current running `Application`. + @param registry The service registry. @param view The open ledger that the transaction will attempt to be applied to. @@ -333,6 +333,6 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx); whether or not the transaction was applied. */ ApplyResult -doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view); +doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenView& view); } // namespace xrpl diff --git a/src/xrpld/app/tx/detail/AMMCreate.cpp b/src/xrpld/app/tx/detail/AMMCreate.cpp index aa75a18e30..1131d21fd2 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.cpp +++ b/src/xrpld/app/tx/detail/AMMCreate.cpp @@ -272,7 +272,7 @@ applyCreate(ApplyContext& ctx_, Sandbox& sb, AccountID const& account_, beast::J Book const book{issueIn, issueOut, std::nullopt}; auto const dir = keylet::quality(keylet::book(book), uRate); if (auto const bookExisted = static_cast(sb.read(dir)); !bookExisted) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); }; addOrderBook(amount.issue(), amount2.issue(), getRate(amount2, amount)); addOrderBook(amount2.issue(), amount.issue(), getRate(amount, amount2)); diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/xrpld/app/tx/detail/ApplyContext.cpp index c5b4d31cec..71cb5cd936 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/xrpld/app/tx/detail/ApplyContext.cpp @@ -8,7 +8,7 @@ namespace xrpl { ApplyContext::ApplyContext( - Application& app_, + ServiceRegistry& registry_, OpenView& base, std::optional const& parentBatchId, STTx const& tx_, @@ -16,7 +16,7 @@ ApplyContext::ApplyContext( XRPAmount baseFee_, ApplyFlags flags, beast::Journal journal_) - : app(app_) + : registry(registry_) , tx(tx_) , preclaimResult(preclaimResult_) , baseFee(baseFee_) diff --git a/src/xrpld/app/tx/detail/ApplyContext.h b/src/xrpld/app/tx/detail/ApplyContext.h index d2208c13a1..9e382556c2 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.h +++ b/src/xrpld/app/tx/detail/ApplyContext.h @@ -1,9 +1,7 @@ #pragma once -#include -#include - #include +#include #include #include #include @@ -17,7 +15,7 @@ class ApplyContext { public: explicit ApplyContext( - Application& app, + ServiceRegistry& registry, OpenView& base, std::optional const& parentBatchId, STTx const& tx, @@ -27,19 +25,19 @@ public: beast::Journal journal = beast::Journal{beast::Journal::getNullSink()}); explicit ApplyContext( - Application& app, + ServiceRegistry& registry, OpenView& base, STTx const& tx, TER preclaimResult, XRPAmount baseFee, ApplyFlags flags, beast::Journal journal = beast::Journal{beast::Journal::getNullSink()}) - : ApplyContext(app, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal) + : ApplyContext(registry, base, std::nullopt, tx, preclaimResult, baseFee, flags, journal) { XRPL_ASSERT((flags & tapBATCH) == 0, "Batch apply flag should not be set"); } - Application& app; + ServiceRegistry& registry; STTx const& tx; TER const preclaimResult; XRPAmount const baseFee; diff --git a/src/xrpld/app/tx/detail/Batch.cpp b/src/xrpld/app/tx/detail/Batch.cpp index 81f39193cb..f7f0d7ac60 100644 --- a/src/xrpld/app/tx/detail/Batch.cpp +++ b/src/xrpld/app/tx/detail/Batch.cpp @@ -296,7 +296,7 @@ Batch::preflight(PreflightContext const& ctx) } auto const innerAccount = stx.getAccountID(sfAccount); - if (auto const preflightResult = xrpl::preflight(ctx.app, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j); + if (auto const preflightResult = xrpl::preflight(ctx.registry, ctx.rules, parentBatchId, stx, tapBATCH, ctx.j); preflightResult.ter != tesSUCCESS) { JLOG(ctx.j.debug()) << "BatchTrace[" << parentBatchId << "]: " diff --git a/src/xrpld/app/tx/detail/CancelCheck.cpp b/src/xrpld/app/tx/detail/CancelCheck.cpp index 086a126eb4..7936b3b9ed 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.cpp +++ b/src/xrpld/app/tx/detail/CancelCheck.cpp @@ -62,7 +62,7 @@ CancelCheck::doApply() AccountID const srcId{sleCheck->getAccountID(sfAccount)}; AccountID const dstId{sleCheck->getAccountID(sfDestination)}; - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // If the check is not written to self (and it shouldn't be), remove the // check from the destination account root. diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/xrpld/app/tx/detail/CancelOffer.cpp index 1dc9ad0bde..3b690cb730 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/xrpld/app/tx/detail/CancelOffer.cpp @@ -54,7 +54,7 @@ CancelOffer::doApply() if (auto sleOffer = view().peek(keylet::offer(account_, offerSequence))) { JLOG(j_.debug()) << "Trying to cancel offer #" << offerSequence; - return offerDelete(view(), sleOffer, ctx_.app.journal("View")); + return offerDelete(view(), sleOffer, ctx_.registry.journal("View")); } JLOG(j_.debug()) << "Offer #" << offerSequence << " can't be found."; diff --git a/src/xrpld/app/tx/detail/CashCheck.cpp b/src/xrpld/app/tx/detail/CashCheck.cpp index 2cc25924a1..633ab1133a 100644 --- a/src/xrpld/app/tx/detail/CashCheck.cpp +++ b/src/xrpld/app/tx/detail/CashCheck.cpp @@ -228,7 +228,7 @@ CashCheck::doApply() // // If it is not a check to self (as should be the case), then there's // work to do... - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); auto const optDeliverMin = ctx_.tx[~sfDeliverMin]; if (srcId != account_) diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/xrpld/app/tx/detail/Change.cpp index 67c7db68c5..478377a818 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/xrpld/app/tx/detail/Change.cpp @@ -1,5 +1,3 @@ -#include -#include #include #include @@ -195,7 +193,7 @@ Change::applyAmendment() entry[sfAmendment] = amendment; entry[sfCloseTime] = view().parentCloseTime().time_since_epoch().count(); - if (!ctx_.app.getAmendmentTable().isSupported(amendment)) + if (!ctx_.registry.getAmendmentTable().isSupported(amendment)) { JLOG(j_.warn()) << "Unsupported amendment " << amendment << " received a majority."; } @@ -206,12 +204,12 @@ Change::applyAmendment() amendments.push_back(amendment); amendmentObject->setFieldV256(sfAmendments, amendments); - ctx_.app.getAmendmentTable().enable(amendment); + ctx_.registry.getAmendmentTable().enable(amendment); - if (!ctx_.app.getAmendmentTable().isSupported(amendment)) + if (!ctx_.registry.getAmendmentTable().isSupported(amendment)) { JLOG(j_.error()) << "Unsupported amendment " << amendment << " activated: server blocked."; - ctx_.app.getOPs().setAmendmentBlocked(); + ctx_.registry.getOPs().setAmendmentBlocked(); } } diff --git a/src/xrpld/app/tx/detail/CreateCheck.cpp b/src/xrpld/app/tx/detail/CreateCheck.cpp index d10863df46..7511f2df2e 100644 --- a/src/xrpld/app/tx/detail/CreateCheck.cpp +++ b/src/xrpld/app/tx/detail/CreateCheck.cpp @@ -164,7 +164,7 @@ CreateCheck::doApply() view().insert(sleCheck); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // If it's not a self-send (and it shouldn't be), add Check to the // destination's owner directory. if (dstAccountId != account_) diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/xrpld/app/tx/detail/CreateOffer.cpp index 666023233d..d40109f571 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/xrpld/app/tx/detail/CreateOffer.cpp @@ -144,7 +144,7 @@ CreateOffer::preclaim(PreclaimContext const& ctx) std::uint32_t const uAccountSequence = sleCreator->getFieldU32(sfSequence); - auto viewJ = ctx.app.journal("View"); + auto viewJ = ctx.registry.journal("View"); if (isGlobalFrozen(ctx.view, uPaysIssuerID) || isGlobalFrozen(ctx.view, uGetsIssuerID)) { @@ -489,7 +489,7 @@ CreateOffer::applyHybrid( bookArr.push_back(std::move(bookInfo)); if (!bookExists) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); sleOffer->setFieldArray(sfAdditionalBooks, bookArr); return tesSUCCESS; @@ -523,7 +523,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) // end up on the books. auto uRate = getRate(saTakerGets, saTakerPays); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); TER result = tesSUCCESS; @@ -825,7 +825,7 @@ CreateOffer::applyGuts(Sandbox& sb, Sandbox& sbCancel) sb.insert(sleOffer); if (!bookExisted) - ctx_.app.getOrderBookDB().addOrderBook(book); + ctx_.registry.getOrderBookDB().addOrderBook(book); JLOG(j_.debug()) << "final result: success"; diff --git a/src/xrpld/app/tx/detail/CreateTicket.cpp b/src/xrpld/app/tx/detail/CreateTicket.cpp index eb42904a0b..1ce067087c 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.cpp +++ b/src/xrpld/app/tx/detail/CreateTicket.cpp @@ -68,7 +68,7 @@ CreateTicket::doApply() return tecINSUFFICIENT_RESERVE; } - beast::Journal viewJ{ctx_.app.journal("View")}; + beast::Journal viewJ{ctx_.registry.journal("View")}; // The starting ticket sequence is the same as the current account // root sequence. Before we got here to doApply(), the transaction diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/xrpld/app/tx/detail/DeleteAccount.cpp index 18961469a3..5d2d2e85a7 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/xrpld/app/tx/detail/DeleteAccount.cpp @@ -51,7 +51,7 @@ DeleteAccount::calculateBaseFee(ReadView const& view, STTx const& tx) namespace { // Define a function pointer type that can be used to delete ledger node types. using DeleterFuncPtr = TER (*)( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -61,7 +61,7 @@ using DeleterFuncPtr = TER (*)( // Local function definitions that provides signature compatibility. TER offerDelete( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -73,19 +73,19 @@ offerDelete( TER removeSignersFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, AccountID const& account, uint256 const& delIndex, std::shared_ptr const& sleDel, beast::Journal j) { - return SetSignerList::removeFromLedger(app, view, account, j); + return SetSignerList::removeFromLedger(registry, view, account, j); } TER removeTicketFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -97,7 +97,7 @@ removeTicketFromLedger( TER removeDepositPreauthFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const&, uint256 const& delIndex, @@ -109,7 +109,7 @@ removeDepositPreauthFromLedger( TER removeNFTokenOfferFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -124,7 +124,7 @@ removeNFTokenOfferFromLedger( TER removeDIDFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -136,7 +136,7 @@ removeDIDFromLedger( TER removeOracleFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const&, @@ -148,7 +148,7 @@ removeOracleFromLedger( TER removeCredentialFromLedger( - Application&, + ServiceRegistry&, ApplyView& view, AccountID const&, uint256 const&, @@ -160,7 +160,7 @@ removeCredentialFromLedger( TER removeDelegateFromLedger( - Application& app, + ServiceRegistry&, ApplyView& view, AccountID const& account, uint256 const& delIndex, @@ -351,7 +351,7 @@ DeleteAccount::doApply() std::shared_ptr& sleItem) -> std::pair { if (auto deleter = nonObligationDeleter(nodeType)) { - TER const result{deleter(ctx_.app, view(), account_, dirEntry, sleItem, j_)}; + TER const result{deleter(ctx_.registry, view(), account_, dirEntry, sleItem, j_)}; return {result, SkipEntry::No}; } diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/xrpld/app/tx/detail/Escrow.cpp index dea9d3aa2b..2014dcc926 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/xrpld/app/tx/detail/Escrow.cpp @@ -544,7 +544,7 @@ EscrowFinish::preflightSigValidated(PreflightContext const& ctx) if (cb && fb) { - auto& router = ctx.app.getHashRouter(); + auto& router = ctx.registry.getHashRouter(); auto const id = ctx.tx.getTransactionID(); auto const flags = router.getFlags(id); @@ -900,7 +900,7 @@ EscrowFinish::doApply() // Check cryptocondition fulfillment { auto const id = ctx_.tx.getTransactionID(); - auto flags = ctx_.app.getHashRouter().getFlags(id); + auto flags = ctx_.registry.getHashRouter().getFlags(id); auto const cb = ctx_.tx[~sfCondition]; @@ -920,7 +920,7 @@ EscrowFinish::doApply() else flags = SF_CF_INVALID; - ctx_.app.getHashRouter().setFlags(id, flags); + ctx_.registry.getHashRouter().setFlags(id, flags); // LCOV_EXCL_STOP } diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/xrpld/app/tx/detail/PayChan.cpp index baa8770e53..860784ecba 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/xrpld/app/tx/detail/PayChan.cpp @@ -310,7 +310,7 @@ PayChanFund::doApply() auto const cancelAfter = (*slep)[~sfCancelAfter]; auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count(); if ((cancelAfter && closeTime >= *cancelAfter) || (expiration && closeTime >= *expiration)) - return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View")); + return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View")); } if (src != txAccount) @@ -456,7 +456,7 @@ PayChanClaim::doApply() auto const cancelAfter = (*slep)[~sfCancelAfter]; auto const closeTime = ctx_.view().header().parentCloseTime.time_since_epoch().count(); if ((cancelAfter && closeTime >= *cancelAfter) || (curExpiration && closeTime >= *curExpiration)) - return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View")); + return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View")); } if (txAccount != src && txAccount != dst) @@ -513,7 +513,7 @@ PayChanClaim::doApply() { // Channel will close immediately if dry or the receiver closes if (dst == txAccount || (*slep)[sfBalance] == (*slep)[sfAmount]) - return closeChannel(slep, ctx_.view(), k.key, ctx_.app.journal("View")); + return closeChannel(slep, ctx_.view(), k.key, ctx_.registry.journal("View")); auto const settleExpiration = ctx_.view().header().parentCloseTime.time_since_epoch().count() + (*slep)[sfSettleDelay]; diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/xrpld/app/tx/detail/Payment.cpp index 390548b7ef..19b2d8acc2 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/xrpld/app/tx/detail/Payment.cpp @@ -414,7 +414,7 @@ Payment::doApply() account_, ctx_.tx.getFieldPathSet(sfPaths), ctx_.tx[~sfDomainID], - ctx_.app.logs(), + ctx_.registry.logs(), &rcInput); // VFALCO NOTE We might not need to apply, depending // on the TER. But always applying *should* diff --git a/src/xrpld/app/tx/detail/SetRegularKey.cpp b/src/xrpld/app/tx/detail/SetRegularKey.cpp index 14302c67c4..a7f2acfbfe 100644 --- a/src/xrpld/app/tx/detail/SetRegularKey.cpp +++ b/src/xrpld/app/tx/detail/SetRegularKey.cpp @@ -47,7 +47,7 @@ SetRegularKey::doApply() if (!sle) return tefINTERNAL; // LCOV_EXCL_LINE - if (!minimumFee(ctx_.app, ctx_.baseFee, view().fees(), view().flags())) + if (!minimumFee(ctx_.registry, ctx_.baseFee, view().fees(), view().flags())) sle->setFlag(lsfPasswordSpent); if (ctx_.tx.isFieldPresent(sfRegularKey)) diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/xrpld/app/tx/detail/SetSignerList.cpp index 1864e82b99..f6a65d2711 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/xrpld/app/tx/detail/SetSignerList.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include #include #include #include @@ -151,7 +151,7 @@ signerCountBasedOwnerCountDelta(std::size_t entryCount, Rules const& rules) static TER removeSignersFromLedger( - Application& app, + ServiceRegistry& registry, ApplyView& view, Keylet const& accountKeylet, Keylet const& ownerDirKeylet, @@ -187,7 +187,7 @@ removeSignersFromLedger( // LCOV_EXCL_STOP } - adjustOwnerCount(view, view.peek(accountKeylet), removeFromOwnerCount, app.journal("View")); + adjustOwnerCount(view, view.peek(accountKeylet), removeFromOwnerCount, registry.journal("View")); view.erase(signers); @@ -195,13 +195,13 @@ removeSignersFromLedger( } TER -SetSignerList::removeFromLedger(Application& app, ApplyView& view, AccountID const& account, beast::Journal j) +SetSignerList::removeFromLedger(ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j) { auto const accountKeylet = keylet::account(account); auto const ownerDirKeylet = keylet::ownerDir(account); auto const signerListKeylet = keylet::signers(account); - return removeSignersFromLedger(app, view, accountKeylet, ownerDirKeylet, signerListKeylet, j); + return removeSignersFromLedger(registry, view, accountKeylet, ownerDirKeylet, signerListKeylet, j); } NotTEC @@ -273,7 +273,8 @@ SetSignerList::replaceSignerList() // This may be either a create or a replace. Preemptively remove any // old signer list. May reduce the reserve, so this is done before // checking the reserve. - if (TER const ter = removeSignersFromLedger(ctx_.app, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_)) + if (TER const ter = + removeSignersFromLedger(ctx_.registry, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_)) return ter; auto const sle = view().peek(accountKeylet); @@ -299,7 +300,7 @@ SetSignerList::replaceSignerList() view().insert(signerList); writeSignersToSLE(signerList, flags); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); // Add the signer list to the account's directory. auto const page = ctx_.view().dirInsert(ownerDirKeylet, signerListKeylet, describeOwnerDir(account_)); @@ -332,7 +333,7 @@ SetSignerList::destroySignerList() auto const ownerDirKeylet = keylet::ownerDir(account_); auto const signerListKeylet = keylet::signers(account_); - return removeSignersFromLedger(ctx_.app, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_); + return removeSignersFromLedger(ctx_.registry, view(), accountKeylet, ownerDirKeylet, signerListKeylet, j_); } void diff --git a/src/xrpld/app/tx/detail/SetSignerList.h b/src/xrpld/app/tx/detail/SetSignerList.h index efd8e508f9..cac9ce1288 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.h +++ b/src/xrpld/app/tx/detail/SetSignerList.h @@ -44,7 +44,7 @@ public: // Interface used by DeleteAccount static TER - removeFromLedger(Application& app, ApplyView& view, AccountID const& account, beast::Journal j); + removeFromLedger(ServiceRegistry& registry, ApplyView& view, AccountID const& account, beast::Journal j); private: static std::tuple, Operation> diff --git a/src/xrpld/app/tx/detail/SetTrust.cpp b/src/xrpld/app/tx/detail/SetTrust.cpp index ce8ca05a09..ada6524008 100644 --- a/src/xrpld/app/tx/detail/SetTrust.cpp +++ b/src/xrpld/app/tx/detail/SetTrust.cpp @@ -352,7 +352,7 @@ SetTrust::doApply() bool const bSetDeepFreeze = (uTxFlags & tfSetDeepFreeze); bool const bClearDeepFreeze = (uTxFlags & tfClearDeepFreeze); - auto viewJ = ctx_.app.journal("View"); + auto viewJ = ctx_.registry.journal("View"); SLE::pointer sleDst = view().peek(keylet::account(uDstAccountID)); diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index a7bb7992fb..129c06fdd5 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -32,7 +33,7 @@ preflight0(PreflightContext const& ctx, std::uint32_t flagMask) if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID)) { - uint32_t nodeNID = ctx.app.config().NETWORK_ID; + uint32_t nodeNID = ctx.registry.getNetworkIDService().getNetworkID(); std::optional txNID = ctx.tx[~sfNetworkID]; if (nodeNID <= 1024) @@ -204,7 +205,7 @@ Transactor::preflight2(PreflightContext const& ctx) // Do not add any checks after this point that are relevant for // batch inner transactions. They will be skipped. - auto const sigValid = checkValidity(ctx.app.getHashRouter(), ctx.tx, ctx.rules, ctx.app.config()); + auto const sigValid = checkValidity(ctx.registry.getHashRouter(), ctx.tx, ctx.rules); if (sigValid.first == Validity::SigBad) { // LCOV_EXCL_START JLOG(ctx.j.debug()) << "preflight2: bad signature. " << sigValid.second; @@ -303,9 +304,9 @@ Transactor::calculateOwnerReserveFee(ReadView const& view, STTx const& tx) } XRPAmount -Transactor::minimumFee(Application& app, XRPAmount baseFee, Fees const& fees, ApplyFlags flags) +Transactor::minimumFee(ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags) { - return scaleFeeLoad(baseFee, app.getFeeTrack(), fees, flags & tapUNLIMITED); + return scaleFeeLoad(baseFee, registry.getFeeTrack(), fees, flags & tapUNLIMITED); } TER @@ -331,7 +332,7 @@ Transactor::checkFee(PreclaimContext const& ctx, XRPAmount baseFee) // Only check fee is sufficient when the ledger is open. if (ctx.view.open()) { - auto const feeDue = minimumFee(ctx.app, baseFee, ctx.view.fees(), ctx.flags); + auto const feeDue = minimumFee(ctx.registry, baseFee, ctx.view.fees(), ctx.flags); if (feePaid < feeDue) { @@ -1071,7 +1072,7 @@ Transactor::operator()() } #endif - if (auto const& trap = ctx_.app.trapTxID(); trap && *trap == ctx_.tx.getTransactionID()) + if (auto const& trap = ctx_.registry.trapTxID(); trap && *trap == ctx_.tx.getTransactionID()) { trapTransaction(*trap); } @@ -1172,16 +1173,16 @@ Transactor::operator()() // If necessary, remove any offers found unfunded during processing if ((result == tecOVERSIZE) || (result == tecKILLED)) - removeUnfundedOffers(view(), removedOffers, ctx_.app.journal("View")); + removeUnfundedOffers(view(), removedOffers, ctx_.registry.journal("View")); if (result == tecEXPIRED) - removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.app.journal("View")); + removeExpiredNFTokenOffers(view(), expiredNFTokenOffers, ctx_.registry.journal("View")); if (result == tecINCOMPLETE) - removeDeletedTrustLines(view(), removedTrustLines, ctx_.app.journal("View")); + removeDeletedTrustLines(view(), removedTrustLines, ctx_.registry.journal("View")); if (result == tecEXPIRED) - removeExpiredCredentials(view(), expiredCredentials, ctx_.app.journal("View")); + removeExpiredCredentials(view(), expiredCredentials, ctx_.registry.journal("View")); applied = isTecClaim(result); } diff --git a/src/xrpld/app/tx/detail/Transactor.h b/src/xrpld/app/tx/detail/Transactor.h index e06086a55d..5cb95843d5 100644 --- a/src/xrpld/app/tx/detail/Transactor.h +++ b/src/xrpld/app/tx/detail/Transactor.h @@ -14,7 +14,7 @@ namespace xrpl { struct PreflightContext { public: - Application& app; + ServiceRegistry& registry; STTx const& tx; Rules const rules; ApplyFlags flags; @@ -22,24 +22,24 @@ public: beast::Journal const j; PreflightContext( - Application& app_, + ServiceRegistry& registry_, STTx const& tx_, uint256 parentBatchId_, Rules const& rules_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_), tx(tx_), rules(rules_), flags(flags_), parentBatchId(parentBatchId_), j(j_) + : registry(registry_), tx(tx_), rules(rules_), flags(flags_), parentBatchId(parentBatchId_), j(j_) { XRPL_ASSERT((flags_ & tapBATCH) == tapBATCH, "Batch apply flag should be set"); } PreflightContext( - Application& app_, + ServiceRegistry& registry_, STTx const& tx_, Rules const& rules_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_), tx(tx_), rules(rules_), flags(flags_), j(j_) + : registry(registry_), tx(tx_), rules(rules_), flags(flags_), j(j_) { XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set"); } @@ -52,7 +52,7 @@ public: struct PreclaimContext { public: - Application& app; + ServiceRegistry& registry; ReadView const& view; TER preflightResult; ApplyFlags flags; @@ -61,14 +61,14 @@ public: beast::Journal const j; PreclaimContext( - Application& app_, + ServiceRegistry& registry_, ReadView const& view_, TER preflightResult_, STTx const& tx_, ApplyFlags flags_, std::optional parentBatchId_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : app(app_) + : registry(registry_) , view(view_) , preflightResult(preflightResult_) , flags(flags_) @@ -82,13 +82,13 @@ public: } PreclaimContext( - Application& app_, + ServiceRegistry& registry_, ReadView const& view_, TER preflightResult_, STTx const& tx_, ApplyFlags flags_, beast::Journal j_ = beast::Journal{beast::Journal::getNullSink()}) - : PreclaimContext(app_, view_, preflightResult_, tx_, flags_, std::nullopt, j_) + : PreclaimContext(registry_, view_, preflightResult_, tx_, flags_, std::nullopt, j_) { XRPL_ASSERT((flags_ & tapBATCH) == 0, "Batch apply flag should not be set"); } @@ -225,14 +225,14 @@ protected: /** Compute the minimum fee required to process a transaction with a given baseFee based on the current server load. - @param app The application hosting the server + @param registry The service registry. @param baseFee The base fee of a candidate transaction @see xrpl::calculateBaseFee @param fees Fee settings from the current ledger @param flags Transaction processing fees */ static XRPAmount - minimumFee(Application& app, XRPAmount baseFee, Fees const& fees, ApplyFlags flags); + minimumFee(ServiceRegistry& registry, XRPAmount baseFee, Fees const& fees, ApplyFlags flags); // Returns the fee in fee units, not scaled for load. static XRPAmount diff --git a/src/xrpld/app/tx/detail/apply.cpp b/src/xrpld/app/tx/detail/apply.cpp index 1c7a509007..0f7d2eb2a3 100644 --- a/src/xrpld/app/tx/detail/apply.cpp +++ b/src/xrpld/app/tx/detail/apply.cpp @@ -19,7 +19,7 @@ constexpr HashRouterFlags SF_LOCALGOOD = HashRouterFlags::PRIVATE4; // Local ch //------------------------------------------------------------------------------ std::pair -checkValidity(HashRouter& router, STTx const& tx, Rules const& rules, Config const& config) +checkValidity(HashRouter& router, STTx const& tx, Rules const& rules) { auto const id = tx.getTransactionID(); auto const flags = router.getFlags(id); @@ -108,32 +108,33 @@ forceValidity(HashRouter& router, uint256 const& txid, Validity validity) template ApplyResult -apply(Application& app, OpenView& view, PreflightChecks&& preflightChecks) +apply(ServiceRegistry& registry, OpenView& view, PreflightChecks&& preflightChecks) { NumberSO stNumberSO{view.rules().enabled(fixUniversalNumber)}; - return doApply(preclaim(preflightChecks(), app, view), app, view); + return doApply(preclaim(preflightChecks(), registry, view), registry, view); } ApplyResult -apply(Application& app, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal j) +apply(ServiceRegistry& registry, OpenView& view, STTx const& tx, ApplyFlags flags, beast::Journal j) { - return apply(app, view, [&]() mutable { return preflight(app, view.rules(), tx, flags, j); }); + return apply(registry, view, [&]() mutable { return preflight(registry, view.rules(), tx, flags, j); }); } ApplyResult apply( - Application& app, + ServiceRegistry& registry, OpenView& view, uint256 const& parentBatchId, STTx const& tx, ApplyFlags flags, beast::Journal j) { - return apply(app, view, [&]() mutable { return preflight(app, view.rules(), parentBatchId, tx, flags, j); }); + return apply( + registry, view, [&]() mutable { return preflight(registry, view.rules(), parentBatchId, tx, flags, j); }); } static bool -applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchTxn, beast::Journal j) +applyBatchTransactions(ServiceRegistry& registry, OpenView& batchView, STTx const& batchTxn, beast::Journal j) { XRPL_ASSERT( batchTxn.getTxnType() == ttBATCH && batchTxn.getFieldArray(sfRawTransactions).size() != 0, @@ -142,10 +143,10 @@ applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchT auto const parentBatchId = batchTxn.getTransactionID(); auto const mode = batchTxn.getFlags(); - auto applyOneTransaction = [&app, &j, &parentBatchId, &batchView](STTx&& tx) { + auto applyOneTransaction = [®istry, &j, &parentBatchId, &batchView](STTx&& tx) { OpenView perTxBatchView(batch_view, batchView); - auto const ret = apply(app, perTxBatchView, parentBatchId, tx, tapBATCH, j); + auto const ret = apply(registry, perTxBatchView, parentBatchId, tx, tapBATCH, j); XRPL_ASSERT( ret.applied == (isTesSuccess(ret.ter) || isTecClaim(ret.ter)), "Inner transaction should not be applied"); @@ -189,7 +190,7 @@ applyBatchTransactions(Application& app, OpenView& batchView, STTx const& batchT ApplyTransactionResult applyTransaction( - Application& app, + ServiceRegistry& registry, OpenView& view, STTx const& txn, bool retryAssured, @@ -204,7 +205,7 @@ applyTransaction( try { - auto const result = apply(app, view, txn, flags, j); + auto const result = apply(registry, view, txn, flags, j); if (result.applied) { @@ -216,7 +217,7 @@ applyTransaction( { OpenView wholeBatchView(batch_view, view); - if (applyBatchTransactions(app, wholeBatchView, txn, j)) + if (applyBatchTransactions(registry, wholeBatchView, txn, j)) wholeBatchView.apply(view); } diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 06f0db1a79..412b717428 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -14,6 +14,7 @@ // DO NOT INCLUDE TRANSACTOR HEADER FILES HERE. // See the instructions at the top of transactions.macro instead. +#include #include #include @@ -292,9 +293,9 @@ invoke_apply(ApplyContext& ctx) } PreflightResult -preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j) +preflight(ServiceRegistry& registry, Rules const& rules, STTx const& tx, ApplyFlags flags, beast::Journal j) { - PreflightContext const pfCtx(app, tx, rules, flags, j); + PreflightContext const pfCtx(registry, tx, rules, flags, j); try { return {pfCtx, invoke_preflight(pfCtx)}; @@ -308,14 +309,14 @@ preflight(Application& app, Rules const& rules, STTx const& tx, ApplyFlags flags PreflightResult preflight( - Application& app, + ServiceRegistry& registry, Rules const& rules, uint256 const& parentBatchId, STTx const& tx, ApplyFlags flags, beast::Journal j) { - PreflightContext const pfCtx(app, tx, parentBatchId, rules, flags, j); + PreflightContext const pfCtx(registry, tx, parentBatchId, rules, flags, j); try { return {pfCtx, invoke_preflight(pfCtx)}; @@ -328,7 +329,7 @@ preflight( } PreclaimResult -preclaim(PreflightResult const& preflightResult, Application& app, OpenView const& view) +preclaim(PreflightResult const& preflightResult, ServiceRegistry& registry, OpenView const& view) { std::optional ctx; if (preflightResult.rules != view.rules()) @@ -336,18 +337,18 @@ preclaim(PreflightResult const& preflightResult, Application& app, OpenView cons auto secondFlight = [&]() { if (preflightResult.parentBatchId) return preflight( - app, + registry, view.rules(), preflightResult.parentBatchId.value(), preflightResult.tx, preflightResult.flags, preflightResult.j); - return preflight(app, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j); + return preflight(registry, view.rules(), preflightResult.tx, preflightResult.flags, preflightResult.j); }(); ctx.emplace( - app, + registry, view, secondFlight.ter, secondFlight.tx, @@ -358,7 +359,7 @@ preclaim(PreflightResult const& preflightResult, Application& app, OpenView cons else { ctx.emplace( - app, + registry, view, preflightResult.ter, preflightResult.tx, @@ -393,7 +394,7 @@ calculateDefaultBaseFee(ReadView const& view, STTx const& tx) } ApplyResult -doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) +doApply(PreclaimResult const& preclaimResult, ServiceRegistry& registry, OpenView& view) { if (preclaimResult.view.seq() != view.seq()) { @@ -406,7 +407,7 @@ doApply(PreclaimResult const& preclaimResult, Application& app, OpenView& view) if (!preclaimResult.likelyToClaimFee) return {preclaimResult.ter, false}; ApplyContext ctx( - app, + registry, view, preclaimResult.parentBatchId, preclaimResult.tx, diff --git a/src/xrpld/core/NetworkIDServiceImpl.h b/src/xrpld/core/NetworkIDServiceImpl.h new file mode 100644 index 0000000000..1176f8d4ac --- /dev/null +++ b/src/xrpld/core/NetworkIDServiceImpl.h @@ -0,0 +1,32 @@ +#pragma once + +#include + +#include + +namespace xrpl { + +// Forward declaration +class Config; + +/** Implementation of NetworkIDService that reads from Config. + + This class provides a NetworkIDService interface that wraps + the network ID from the application Config. It caches the + network ID at construction time. +*/ +class NetworkIDServiceImpl final : public NetworkIDService +{ +public: + explicit NetworkIDServiceImpl(std::uint32_t networkID); + + ~NetworkIDServiceImpl() override = default; + + std::uint32_t + getNetworkID() const noexcept override; + +private: + std::uint32_t networkID_; +}; + +} // namespace xrpl diff --git a/src/xrpld/core/detail/NetworkIDServiceImpl.cpp b/src/xrpld/core/detail/NetworkIDServiceImpl.cpp new file mode 100644 index 0000000000..839eb0c464 --- /dev/null +++ b/src/xrpld/core/detail/NetworkIDServiceImpl.cpp @@ -0,0 +1,16 @@ +#include +#include + +namespace xrpl { + +NetworkIDServiceImpl::NetworkIDServiceImpl(std::uint32_t networkID) : networkID_(networkID) +{ +} + +std::uint32_t +NetworkIDServiceImpl::getNetworkID() const noexcept +{ + return networkID_; +} + +} // namespace xrpl diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index 20f68a215b..ca7364c756 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -2722,8 +2722,8 @@ PeerImp::checkTransaction( if (checkSignature) { // Check the signature before handing off to the job queue. - if (auto [valid, validReason] = checkValidity( - app_.getHashRouter(), *stx, app_.getLedgerMaster().getValidatedRules(), app_.config()); + if (auto [valid, validReason] = + checkValidity(app_.getHashRouter(), *stx, app_.getLedgerMaster().getValidatedRules()); valid != Validity::Valid) { if (!validReason.empty()) diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 5e71d2c427..6f7d80b2a6 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -466,7 +467,7 @@ transactionPreProcessImpl( if (!tx_json.isMember(jss::NetworkID)) { - auto const networkId = app.config().NETWORK_ID; + auto const networkId = app.getNetworkIDService().getNetworkID(); if (networkId > 1024) tx_json[jss::NetworkID] = to_string(networkId); } @@ -637,7 +638,7 @@ transactionConstructImpl(std::shared_ptr const& stTx, Rules const& r auto sttxNew = std::make_shared(sit); if (!app.checkSigs()) forceValidity(app.getHashRouter(), sttxNew->getTransactionID(), Validity::SigGoodOnly); - if (checkValidity(app.getHashRouter(), *sttxNew, rules, app.config()).first != Validity::Valid) + if (checkValidity(app.getHashRouter(), *sttxNew, rules).first != Validity::Valid) { ret.first = RPC::make_error(rpcINTERNAL, "Invalid signature."); return ret; diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/Simulate.cpp index 58b40e2048..120dbfa2e5 100644 --- a/src/xrpld/rpc/handlers/Simulate.cpp +++ b/src/xrpld/rpc/handlers/Simulate.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -128,7 +129,7 @@ autofillTx(Json::Value& tx_json, RPC::JsonContext& context) if (!tx_json.isMember(jss::NetworkID)) { - auto const networkId = context.app.config().NETWORK_ID; + auto const networkId = context.app.getNetworkIDService().getNetworkID(); if (networkId > 1024) tx_json[jss::NetworkID] = to_string(networkId); } diff --git a/src/xrpld/rpc/handlers/Submit.cpp b/src/xrpld/rpc/handlers/Submit.cpp index 577501d581..5b29d35f50 100644 --- a/src/xrpld/rpc/handlers/Submit.cpp +++ b/src/xrpld/rpc/handlers/Submit.cpp @@ -76,8 +76,8 @@ doSubmit(RPC::JsonContext& context) { if (!context.app.checkSigs()) forceValidity(context.app.getHashRouter(), stTx->getTransactionID(), Validity::SigGoodOnly); - auto [validity, reason] = checkValidity( - context.app.getHashRouter(), *stTx, context.ledgerMaster.getCurrentLedger()->rules(), context.app.config()); + auto [validity, reason] = + checkValidity(context.app.getHashRouter(), *stTx, context.ledgerMaster.getCurrentLedger()->rules()); if (validity != Validity::Valid) { jvResult[jss::error] = "invalidTransaction"; diff --git a/src/xrpld/rpc/handlers/Tx.cpp b/src/xrpld/rpc/handlers/Tx.cpp index d2d7bed04d..e78a31d73c 100644 --- a/src/xrpld/rpc/handlers/Tx.cpp +++ b/src/xrpld/rpc/handlers/Tx.cpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -147,7 +148,7 @@ doTxHelp(RPC::Context& context, TxArgs args) { uint32_t lgrSeq = ledger->header().seq; uint32_t txnIdx = meta->getAsObject().getFieldU32(sfTransactionIndex); - uint32_t netID = context.app.config().NETWORK_ID; + uint32_t netID = context.app.getNetworkIDService().getNetworkID(); if (txnIdx <= 0xFFFFU && netID < 0xFFFFU && lgrSeq < 0x0FFF'FFFFUL) result.ctid = RPC::encodeCTID(lgrSeq, (uint32_t)txnIdx, (uint32_t)netID); @@ -267,7 +268,7 @@ doTxJson(RPC::JsonContext& context) return rpcError(rpcINVALID_PARAMS); auto const [lgr_seq, txn_idx, net_id] = *ctid; - if (net_id != context.app.config().NETWORK_ID) + if (net_id != context.app.getNetworkIDService().getNetworkID()) { std::stringstream out; out << "Wrong network. You should submit this request to a node " From 0976b2b68b64972af8e6e7c497900b5bce9fe22f Mon Sep 17 00:00:00 2001 From: Jingchen Date: Tue, 17 Feb 2026 18:10:07 +0000 Subject: [PATCH 16/16] refactor: Modularize app/tx (#6228) --- .../scripts/levelization/results/ordering.txt | 22 +++- cmake/XrplCore.cmake | 7 +- cmake/XrplInstall.cmake | 1 + .../xrpl/ledger}/AmendmentTable.h | 9 +- include/xrpl/protocol/Protocol.h | 10 ++ .../xrpl/protocol/detail/transactions.macro | 124 +++++++++--------- .../xrpl/server}/LoadFeeTrack.h | 0 .../detail => include/xrpl/tx}/ApplyContext.h | 0 .../xrpl/tx}/InvariantCheck.h | 0 .../xrpl/tx}/SignerEntries.h | 3 +- .../detail => include/xrpl/tx}/Transactor.h | 5 +- {src/xrpld/app => include/xrpl}/tx/apply.h | 4 +- .../app => include/xrpl}/tx/applySteps.h | 0 .../xrpl/tx/paths}/BookTip.h | 0 .../app => include/xrpl/tx}/paths/Flow.h | 5 +- .../detail => include/xrpl/tx/paths}/Offer.h | 0 .../xrpl/tx/paths}/OfferStream.h | 5 +- .../xrpl/tx}/paths/RippleCalc.h | 0 .../xrpl/tx}/paths/detail/AmountSpec.h | 0 .../xrpl/tx}/paths/detail/FlatSets.h | 0 .../xrpl/tx}/paths/detail/FlowDebugInfo.h | 3 +- .../xrpl/tx}/paths/detail/Steps.h | 3 +- .../xrpl/tx}/paths/detail/StrandFlow.h | 15 +-- .../xrpl/tx/transactors/AMM}/AMMBid.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMClawback.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMContext.h | 0 .../xrpl/tx/transactors/AMM}/AMMCreate.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMDelete.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMDeposit.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMHelpers.h | 0 .../xrpl/tx/transactors/AMM}/AMMUtils.h | 0 .../xrpl/tx/transactors/AMM}/AMMVote.h | 2 +- .../xrpl/tx/transactors/AMM}/AMMWithdraw.h | 3 +- .../xrpl/tx/transactors}/Batch.h | 3 +- .../xrpl/tx/transactors}/Change.h | 2 +- .../xrpl/tx/transactors/Check}/CancelCheck.h | 2 +- .../xrpl/tx/transactors/Check}/CashCheck.h | 2 +- .../xrpl/tx/transactors/Check}/CreateCheck.h | 2 +- .../xrpl/tx/transactors}/Clawback.h | 2 +- .../xrpl/tx/transactors}/CreateTicket.h | 2 +- .../xrpl/tx/transactors}/Credentials.h | 2 +- .../xrpl/tx/transactors}/DID.h | 2 +- .../tx/transactors/Delegate}/DelegateSet.h | 2 +- .../tx/transactors/Delegate}/DelegateUtils.h | 0 .../xrpl/tx/transactors}/DeleteAccount.h | 2 +- .../xrpl/tx/transactors}/DeleteOracle.h | 2 +- .../xrpl/tx/transactors}/DepositPreauth.h | 2 +- .../xrpl/tx/transactors}/Escrow.h | 2 +- .../xrpl/tx/transactors}/LedgerStateFix.h | 2 +- .../tx/transactors/Lending}/LendingHelpers.h | 0 .../Lending}/LoanBrokerCoverClawback.h | 2 +- .../Lending}/LoanBrokerCoverDeposit.h | 2 +- .../Lending}/LoanBrokerCoverWithdraw.h | 2 +- .../transactors/Lending}/LoanBrokerDelete.h | 2 +- .../tx/transactors/Lending}/LoanBrokerSet.h | 2 +- .../xrpl/tx/transactors/Lending}/LoanDelete.h | 2 +- .../xrpl/tx/transactors/Lending}/LoanManage.h | 2 +- .../xrpl/tx/transactors/Lending}/LoanPay.h | 2 +- .../xrpl/tx/transactors/Lending}/LoanSet.h | 4 +- .../tx/transactors/MPT}/MPTokenAuthorize.h | 2 +- .../transactors/MPT}/MPTokenIssuanceCreate.h | 3 +- .../transactors/MPT}/MPTokenIssuanceDestroy.h | 2 +- .../tx/transactors/MPT}/MPTokenIssuanceSet.h | 2 +- .../tx/transactors/NFT}/NFTokenAcceptOffer.h | 2 +- .../xrpl/tx/transactors/NFT}/NFTokenBurn.h | 2 +- .../tx/transactors/NFT}/NFTokenCancelOffer.h | 2 +- .../tx/transactors/NFT}/NFTokenCreateOffer.h | 2 +- .../xrpl/tx/transactors/NFT}/NFTokenMint.h | 5 +- .../xrpl/tx/transactors/NFT}/NFTokenModify.h | 2 +- .../xrpl/tx/transactors/NFT}/NFTokenUtils.h | 3 +- .../xrpl/tx/transactors/Offer}/CancelOffer.h | 3 +- .../xrpl/tx/transactors/Offer}/CreateOffer.h | 3 +- .../xrpl/tx/transactors}/PayChan.h | 2 +- .../xrpl/tx/transactors}/Payment.h | 2 +- .../tx/transactors}/PermissionedDEXHelpers.h | 0 .../PermissionedDomainDelete.h | 2 +- .../PermissionedDomainSet.h | 2 +- .../xrpl/tx/transactors}/SetAccount.h | 3 +- .../xrpl/tx/transactors}/SetOracle.h | 2 +- .../xrpl/tx/transactors}/SetRegularKey.h | 2 +- .../xrpl/tx/transactors}/SetSignerList.h | 5 +- .../xrpl/tx/transactors}/SetTrust.h | 3 +- .../tx/transactors/Vault}/VaultClawback.h | 2 +- .../xrpl/tx/transactors/Vault}/VaultCreate.h | 2 +- .../xrpl/tx/transactors/Vault}/VaultDelete.h | 2 +- .../xrpl/tx/transactors/Vault}/VaultDeposit.h | 2 +- .../xrpl/tx/transactors/Vault}/VaultSet.h | 2 +- .../tx/transactors/Vault}/VaultWithdraw.h | 2 +- .../xrpl/tx/transactors}/XChainBridge.h | 3 +- src/libxrpl/protocol/Protocol.cpp | 15 +++ .../server}/LoadFeeTrack.cpp | 3 +- .../tx/detail => libxrpl/tx}/ApplyContext.cpp | 5 +- .../detail => libxrpl/tx}/InvariantCheck.cpp | 11 +- .../detail => libxrpl/tx}/SignerEntries.cpp | 4 +- .../tx/detail => libxrpl/tx}/Transactor.cpp | 13 +- .../app/tx/detail => libxrpl/tx}/apply.cpp | 5 +- .../tx/detail => libxrpl/tx}/applySteps.cpp | 2 +- .../detail => libxrpl/tx/paths}/BookTip.cpp | 2 +- src/{xrpld/app => libxrpl/tx}/paths/Flow.cpp | 11 +- .../tx/paths}/OfferStream.cpp | 5 +- .../app => libxrpl/tx}/paths/RippleCalc.cpp | 7 +- .../tx/transactors/AMM}/AMMBid.cpp | 7 +- .../tx/transactors/AMM}/AMMClawback.cpp | 9 +- .../tx/transactors/AMM}/AMMCreate.cpp | 7 +- .../tx/transactors/AMM}/AMMDelete.cpp | 5 +- .../tx/transactors/AMM}/AMMDeposit.cpp | 7 +- .../tx/transactors/AMM}/AMMHelpers.cpp | 2 +- .../tx/transactors/AMM}/AMMUtils.cpp | 5 +- .../tx/transactors/AMM}/AMMVote.cpp | 5 +- .../tx/transactors/AMM}/AMMWithdraw.cpp | 7 +- .../tx/transactors}/Batch.cpp | 5 +- .../tx/transactors}/Change.cpp | 5 +- .../tx/transactors/Check}/CancelCheck.cpp | 3 +- .../tx/transactors/Check}/CashCheck.cpp | 5 +- .../tx/transactors/Check}/CreateCheck.cpp | 3 +- .../tx/transactors}/Clawback.cpp | 3 +- .../tx/transactors}/CreateTicket.cpp | 3 +- .../tx/transactors}/Credentials.cpp | 3 +- .../detail => libxrpl/tx/transactors}/DID.cpp | 3 +- .../tx/transactors/Delegate}/DelegateSet.cpp | 3 +- .../transactors/Delegate}/DelegateUtils.cpp | 3 +- .../tx/transactors}/DeleteAccount.cpp | 15 +-- .../tx/transactors}/DeleteOracle.cpp | 3 +- .../tx/transactors}/DepositPreauth.cpp | 3 +- .../tx/transactors}/Escrow.cpp | 5 +- .../tx/transactors}/LedgerStateFix.cpp | 5 +- .../transactors/Lending}/LendingHelpers.cpp | 4 +- .../Lending}/LoanBrokerCoverClawback.cpp | 5 +- .../Lending}/LoanBrokerCoverDeposit.cpp | 5 +- .../Lending}/LoanBrokerCoverWithdraw.cpp | 7 +- .../transactors/Lending}/LoanBrokerDelete.cpp | 5 +- .../tx/transactors/Lending}/LoanBrokerSet.cpp | 5 +- .../tx/transactors/Lending}/LoanDelete.cpp | 5 +- .../tx/transactors/Lending}/LoanManage.cpp | 5 +- .../tx/transactors/Lending}/LoanPay.cpp | 7 +- .../tx/transactors/Lending}/LoanSet.cpp | 5 +- .../tx/transactors/MPT}/MPTokenAuthorize.cpp | 3 +- .../MPT}/MPTokenIssuanceCreate.cpp | 3 +- .../MPT}/MPTokenIssuanceDestroy.cpp | 3 +- .../transactors/MPT}/MPTokenIssuanceSet.cpp | 5 +- .../transactors/NFT}/NFTokenAcceptOffer.cpp | 5 +- .../tx/transactors/NFT}/NFTokenBurn.cpp | 5 +- .../transactors/NFT}/NFTokenCancelOffer.cpp | 5 +- .../transactors/NFT}/NFTokenCreateOffer.cpp | 5 +- .../tx/transactors/NFT}/NFTokenMint.cpp | 3 +- .../tx/transactors/NFT}/NFTokenModify.cpp | 5 +- .../tx/transactors/NFT}/NFTokenUtils.cpp | 3 +- .../tx/transactors/Offer}/CancelOffer.cpp | 3 +- .../tx/transactors/Offer}/CreateOffer.cpp | 7 +- .../tx/transactors}/PayChan.cpp | 3 +- .../tx/transactors}/Payment.cpp | 9 +- .../PermissionedDEXHelpers.cpp | 3 +- .../PermissionedDomainDelete.cpp | 3 +- .../PermissionedDomainSet.cpp | 3 +- .../tx/transactors}/SetAccount.cpp | 5 +- .../tx/transactors}/SetOracle.cpp | 3 +- .../tx/transactors}/SetRegularKey.cpp | 3 +- .../tx/transactors}/SetSignerList.cpp | 3 +- .../tx/transactors}/SetTrust.cpp | 5 +- .../tx/transactors/Vault}/VaultClawback.cpp | 4 +- .../tx/transactors/Vault}/VaultCreate.cpp | 7 +- .../tx/transactors/Vault}/VaultDelete.cpp | 3 +- .../tx/transactors/Vault}/VaultDeposit.cpp | 5 +- .../tx/transactors/Vault}/VaultSet.cpp | 3 +- .../tx/transactors/Vault}/VaultWithdraw.cpp | 3 +- .../tx/transactors}/XChainBridge.cpp | 9 +- src/test/app/AMMCalc_test.cpp | 3 +- src/test/app/AMMClawback_test.cpp | 3 +- src/test/app/AMMExtended_test.cpp | 8 +- src/test/app/AMM_test.cpp | 9 +- src/test/app/AmendmentTable_test.cpp | 2 +- src/test/app/Batch_test.cpp | 4 +- src/test/app/EscrowToken_test.cpp | 3 +- src/test/app/Escrow_test.cpp | 3 +- src/test/app/FeeVote_test.cpp | 2 +- src/test/app/FixNFTokenPageLinks_test.cpp | 5 +- src/test/app/Flow_test.cpp | 4 +- src/test/app/Invariants_test.cpp | 5 +- src/test/app/LedgerHistory_test.cpp | 2 +- src/test/app/LendingHelpers_test.cpp | 9 +- src/test/app/LoadFeeTrack_test.cpp | 2 +- src/test/app/LoanBroker_test.cpp | 3 +- src/test/app/Loan_test.cpp | 10 +- src/test/app/NFTokenAuth_test.cpp | 2 +- src/test/app/NFTokenBurn_test.cpp | 3 +- src/test/app/NFTokenDir_test.cpp | 3 +- src/test/app/NFToken_test.cpp | 3 +- src/test/app/OfferStream_test.cpp | 3 +- src/test/app/PayStrand_test.cpp | 6 +- src/test/app/PermissionedDEX_test.cpp | 3 +- src/test/app/PermissionedDomains_test.cpp | 3 +- src/test/app/PseudoTx_test.cpp | 3 +- src/test/app/Regression_test.cpp | 2 +- src/test/app/TheoreticalQuality_test.cpp | 9 +- src/test/app/TxQ_test.cpp | 4 +- src/test/app/tx/apply_test.cpp | 3 +- src/test/consensus/NegativeUNL_test.cpp | 2 +- src/test/jtx/impl/AMM.cpp | 5 +- src/test/jtx/impl/ledgerStateFixes.cpp | 3 +- src/test/jtx/impl/token.cpp | 3 +- src/test/rpc/AccountObjects_test.cpp | 3 +- src/test/rpc/AccountSet_test.cpp | 3 +- src/test/rpc/Feature_test.cpp | 3 +- src/test/rpc/JSONRPC_test.cpp | 2 +- src/test/rpc/LedgerEntry_test.cpp | 3 +- src/test/rpc/Subscribe_test.cpp | 2 +- src/test/server/ServerStatus_test.cpp | 2 +- src/xrpld/app/consensus/RCLConsensus.cpp | 4 +- src/xrpld/app/ledger/Ledger.cpp | 10 +- src/xrpld/app/ledger/Ledger.h | 5 - src/xrpld/app/ledger/OrderBookDBImpl.cpp | 3 +- src/xrpld/app/ledger/detail/BuildLedger.cpp | 2 +- src/xrpld/app/ledger/detail/LedgerCleaner.cpp | 2 +- src/xrpld/app/ledger/detail/LedgerMaster.cpp | 4 +- src/xrpld/app/ledger/detail/OpenLedger.cpp | 2 +- src/xrpld/app/main/Application.cpp | 7 +- src/xrpld/app/main/LoadManager.cpp | 2 +- src/xrpld/app/misc/AmendmentTableImpl.h | 18 +++ src/xrpld/app/misc/NetworkOPs.cpp | 7 +- src/xrpld/app/misc/TxQ.h | 3 +- src/xrpld/app/misc/detail/AmendmentTable.cpp | 4 +- src/xrpld/app/misc/detail/Transaction.cpp | 2 +- src/xrpld/app/misc/detail/TxQ.cpp | 2 +- src/xrpld/app/paths/AMMLiquidity.h | 7 +- src/xrpld/app/paths/PathRequest.cpp | 4 +- src/xrpld/app/paths/Pathfinder.cpp | 2 +- src/xrpld/app/paths/detail/BookStep.cpp | 8 +- src/xrpld/app/paths/detail/DirectStep.cpp | 2 +- src/xrpld/app/paths/detail/PaySteps.cpp | 3 +- .../app/paths/detail/XRPEndpointStep.cpp | 4 +- src/xrpld/overlay/detail/PeerImp.cpp | 4 +- src/xrpld/rpc/detail/LegacyPathFind.cpp | 2 +- src/xrpld/rpc/detail/RPCHelpers.cpp | 2 +- src/xrpld/rpc/detail/TransactionSign.cpp | 4 +- src/xrpld/rpc/detail/TransactionSign.h | 2 +- src/xrpld/rpc/handlers/AMMInfo.cpp | 2 +- src/xrpld/rpc/handlers/AccountObjects.cpp | 2 +- src/xrpld/rpc/handlers/Feature1.cpp | 2 +- src/xrpld/rpc/handlers/LedgerHandler.cpp | 2 +- src/xrpld/rpc/handlers/NoRippleCheck.cpp | 2 +- src/xrpld/rpc/handlers/Peers.cpp | 2 +- src/xrpld/rpc/handlers/Simulate.cpp | 2 +- src/xrpld/rpc/handlers/Submit.cpp | 2 +- 243 files changed, 486 insertions(+), 548 deletions(-) rename {src/xrpld/app/misc => include/xrpl/ledger}/AmendmentTable.h (97%) rename {src/xrpld/app/misc => include/xrpl/server}/LoadFeeTrack.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx}/ApplyContext.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx}/InvariantCheck.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx}/SignerEntries.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx}/Transactor.h (99%) rename {src/xrpld/app => include/xrpl}/tx/apply.h (98%) rename {src/xrpld/app => include/xrpl}/tx/applySteps.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/paths}/BookTip.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/Flow.h (95%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/paths}/Offer.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/paths}/OfferStream.h (98%) rename {src/xrpld/app => include/xrpl/tx}/paths/RippleCalc.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/AmountSpec.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/FlatSets.h (100%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/FlowDebugInfo.h (99%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/Steps.h (99%) rename {src/xrpld/app => include/xrpl/tx}/paths/detail/StrandFlow.h (98%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMBid.h (98%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMClawback.h (97%) rename {src/xrpld/app/paths => include/xrpl/tx/transactors/AMM}/AMMContext.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMCreate.h (98%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMDelete.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMDeposit.h (99%) rename {src/xrpld/app/misc => include/xrpl/tx/transactors/AMM}/AMMHelpers.h (100%) rename {src/xrpld/app/misc => include/xrpl/tx/transactors/AMM}/AMMUtils.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMVote.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/AMM}/AMMWithdraw.h (99%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Batch.h (96%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Change.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Check}/CancelCheck.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Check}/CashCheck.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Check}/CreateCheck.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Clawback.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/CreateTicket.h (98%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Credentials.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/DID.h (95%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Delegate}/DelegateSet.h (92%) rename {src/xrpld/app/misc => include/xrpl/tx/transactors/Delegate}/DelegateUtils.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/DeleteAccount.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/DeleteOracle.h (95%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/DepositPreauth.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Escrow.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/LedgerStateFix.h (92%) rename {src/xrpld/app/misc => include/xrpl/tx/transactors/Lending}/LendingHelpers.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanBrokerCoverClawback.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanBrokerCoverDeposit.h (92%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanBrokerCoverWithdraw.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanBrokerDelete.h (92%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanBrokerSet.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanDelete.h (92%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanManage.h (96%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanPay.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Lending}/LoanSet.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/MPT}/MPTokenAuthorize.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/MPT}/MPTokenIssuanceCreate.h (96%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/MPT}/MPTokenIssuanceDestroy.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/MPT}/MPTokenIssuanceSet.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenAcceptOffer.h (95%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenBurn.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenCancelOffer.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenCreateOffer.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenMint.h (89%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenModify.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/NFT}/NFTokenUtils.h (98%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Offer}/CancelOffer.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Offer}/CreateOffer.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/PayChan.h (97%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/Payment.h (95%) rename {src/xrpld/app/misc => include/xrpl/tx/transactors}/PermissionedDEXHelpers.h (100%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/PermissionedDomain}/PermissionedDomainDelete.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/PermissionedDomain}/PermissionedDomainSet.h (92%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/SetAccount.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/SetOracle.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/SetRegularKey.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/SetSignerList.h (94%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/SetTrust.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultClawback.h (93%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultCreate.h (92%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultDelete.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultDeposit.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultSet.h (91%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors/Vault}/VaultWithdraw.h (90%) rename {src/xrpld/app/tx/detail => include/xrpl/tx/transactors}/XChainBridge.h (99%) create mode 100644 src/libxrpl/protocol/Protocol.cpp rename src/{xrpld/app/misc/detail => libxrpl/server}/LoadFeeTrack.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/ApplyContext.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/InvariantCheck.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/SignerEntries.cpp (95%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/Transactor.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/apply.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx}/applySteps.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/paths}/BookTip.cpp (97%) rename src/{xrpld/app => libxrpl/tx}/paths/Flow.cpp (95%) rename src/{xrpld/app/tx/detail => libxrpl/tx/paths}/OfferStream.cpp (99%) rename src/{xrpld/app => libxrpl/tx}/paths/RippleCalc.cpp (96%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMBid.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMClawback.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMCreate.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMDelete.cpp (92%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMDeposit.cpp (99%) rename src/{xrpld/app/misc/detail => libxrpl/tx/transactors/AMM}/AMMHelpers.cpp (99%) rename src/{xrpld/app/misc/detail => libxrpl/tx/transactors/AMM}/AMMUtils.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMVote.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/AMM}/AMMWithdraw.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Batch.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Change.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Check}/CancelCheck.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Check}/CashCheck.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Check}/CreateCheck.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Clawback.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/CreateTicket.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Credentials.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/DID.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Delegate}/DelegateSet.cpp (98%) rename src/{xrpld/app/misc/detail => libxrpl/tx/transactors/Delegate}/DelegateUtils.cpp (95%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/DeleteAccount.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/DeleteOracle.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/DepositPreauth.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Escrow.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/LedgerStateFix.cpp (94%) rename src/{xrpld/app/misc/detail => libxrpl/tx/transactors/Lending}/LendingHelpers.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanBrokerCoverClawback.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanBrokerCoverDeposit.cpp (96%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanBrokerCoverWithdraw.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanBrokerDelete.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanBrokerSet.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanDelete.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanManage.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanPay.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Lending}/LoanSet.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/MPT}/MPTokenAuthorize.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/MPT}/MPTokenIssuanceCreate.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/MPT}/MPTokenIssuanceDestroy.cpp (96%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/MPT}/MPTokenIssuanceSet.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenAcceptOffer.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenBurn.cpp (96%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenCancelOffer.cpp (95%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenCreateOffer.cpp (94%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenMint.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenModify.cpp (93%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/NFT}/NFTokenUtils.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Offer}/CancelOffer.cpp (96%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Offer}/CreateOffer.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/PayChan.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/Payment.cpp (99%) rename src/{xrpld/app/misc => libxrpl/tx/transactors/PermissionedDomain}/PermissionedDEXHelpers.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/PermissionedDomain}/PermissionedDomainDelete.cpp (95%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/PermissionedDomain}/PermissionedDomainSet.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/SetAccount.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/SetOracle.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/SetRegularKey.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/SetSignerList.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/SetTrust.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultClawback.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultCreate.cpp (97%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultDelete.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultDeposit.cpp (98%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultSet.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors/Vault}/VaultWithdraw.cpp (99%) rename src/{xrpld/app/tx/detail => libxrpl/tx/transactors}/XChainBridge.cpp (99%) create mode 100644 src/xrpld/app/misc/AmendmentTableImpl.h diff --git a/.github/scripts/levelization/results/ordering.txt b/.github/scripts/levelization/results/ordering.txt index 30dc2be043..d4d07eee94 100644 --- a/.github/scripts/levelization/results/ordering.txt +++ b/.github/scripts/levelization/results/ordering.txt @@ -32,6 +32,14 @@ libxrpl.server > xrpl.server libxrpl.shamap > xrpl.basics libxrpl.shamap > xrpl.protocol libxrpl.shamap > xrpl.shamap +libxrpl.tx > xrpl.basics +libxrpl.tx > xrpl.conditions +libxrpl.tx > xrpl.core +libxrpl.tx > xrpl.json +libxrpl.tx > xrpl.ledger +libxrpl.tx > xrpl.protocol +libxrpl.tx > xrpl.server +libxrpl.tx > xrpl.tx test.app > test.jtx test.app > test.rpc test.app > test.toplevel @@ -49,6 +57,7 @@ test.app > xrpl.protocol test.app > xrpl.rdb test.app > xrpl.resource test.app > xrpl.server +test.app > xrpl.tx test.basics > test.jtx test.basics > test.unit_test test.basics > xrpl.basics @@ -67,6 +76,7 @@ test.consensus > xrpld.app test.consensus > xrpld.consensus test.consensus > xrpl.json test.consensus > xrpl.ledger +test.consensus > xrpl.tx test.core > test.jtx test.core > test.toplevel test.core > test.unit_test @@ -93,6 +103,7 @@ test.jtx > xrpl.net test.jtx > xrpl.protocol test.jtx > xrpl.resource test.jtx > xrpl.server +test.jtx > xrpl.tx test.ledger > test.jtx test.ledger > test.toplevel test.ledger > xrpl.basics @@ -138,9 +149,11 @@ test.rpc > xrpld.core test.rpc > xrpld.overlay test.rpc > xrpld.rpc test.rpc > xrpl.json +test.rpc > xrpl.ledger test.rpc > xrpl.protocol test.rpc > xrpl.resource test.rpc > xrpl.server +test.rpc > xrpl.tx test.server > test.jtx test.server > test.toplevel test.server > test.unit_test @@ -171,6 +184,7 @@ xrpl.json > xrpl.basics xrpl.ledger > xrpl.basics xrpl.ledger > xrpl.protocol xrpl.ledger > xrpl.server +xrpl.ledger > xrpl.shamap xrpl.net > xrpl.basics xrpl.nodestore > xrpl.basics xrpl.nodestore > xrpl.protocol @@ -192,9 +206,12 @@ xrpl.server > xrpl.shamap xrpl.shamap > xrpl.basics xrpl.shamap > xrpl.nodestore xrpl.shamap > xrpl.protocol +xrpl.tx > xrpl.basics +xrpl.tx > xrpl.core +xrpl.tx > xrpl.ledger +xrpl.tx > xrpl.protocol xrpld.app > test.unit_test xrpld.app > xrpl.basics -xrpld.app > xrpl.conditions xrpld.app > xrpl.core xrpld.app > xrpld.consensus xrpld.app > xrpld.core @@ -207,6 +224,7 @@ xrpld.app > xrpl.rdb xrpld.app > xrpl.resource xrpld.app > xrpl.server xrpld.app > xrpl.shamap +xrpld.app > xrpl.tx xrpld.consensus > xrpl.basics xrpld.consensus > xrpl.json xrpld.consensus > xrpl.protocol @@ -225,6 +243,7 @@ xrpld.overlay > xrpl.protocol xrpld.overlay > xrpl.rdb xrpld.overlay > xrpl.resource xrpld.overlay > xrpl.server +xrpld.overlay > xrpl.tx xrpld.peerfinder > xrpl.basics xrpld.peerfinder > xrpld.core xrpld.peerfinder > xrpl.protocol @@ -244,4 +263,5 @@ xrpld.rpc > xrpl.protocol xrpld.rpc > xrpl.rdb xrpld.rpc > xrpl.resource xrpld.rpc > xrpl.server +xrpld.rpc > xrpl.tx xrpld.shamap > xrpl.shamap diff --git a/cmake/XrplCore.cmake b/cmake/XrplCore.cmake index 3380ca85cd..9a847bfcb9 100644 --- a/cmake/XrplCore.cmake +++ b/cmake/XrplCore.cmake @@ -109,8 +109,12 @@ target_link_libraries( xrpl.libxrpl.protocol xrpl.libxrpl.rdb xrpl.libxrpl.server + xrpl.libxrpl.shamap xrpl.libxrpl.conditions) +add_module(xrpl tx) +target_link_libraries(xrpl.libxrpl.tx PUBLIC xrpl.libxrpl.ledger) + add_library(xrpl.libxrpl) set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) @@ -135,7 +139,8 @@ target_link_modules( rdb resource server - shamap) + shamap + tx) # All headers in libxrpl are in modules. # Uncomment this stanza if you have not yet moved new headers into a module. diff --git a/cmake/XrplInstall.cmake b/cmake/XrplInstall.cmake index d2fef5d488..b8cf4fd32f 100644 --- a/cmake/XrplInstall.cmake +++ b/cmake/XrplInstall.cmake @@ -32,6 +32,7 @@ install(TARGETS common xrpl.libxrpl.resource xrpl.libxrpl.server xrpl.libxrpl.shamap + xrpl.libxrpl.tx antithesis-sdk-cpp EXPORT XrplExports LIBRARY DESTINATION lib diff --git a/src/xrpld/app/misc/AmendmentTable.h b/include/xrpl/ledger/AmendmentTable.h similarity index 97% rename from src/xrpld/app/misc/AmendmentTable.h rename to include/xrpl/ledger/AmendmentTable.h index bfef818b0a..017fcd3846 100644 --- a/src/xrpld/app/misc/AmendmentTable.h +++ b/include/xrpl/ledger/AmendmentTable.h @@ -1,17 +1,18 @@ #pragma once -#include -#include - -#include +#include +#include #include #include #include +#include #include namespace xrpl { +class ServiceRegistry; + /** The amendment table stores the list of enabled and potential amendments. Individuals amendments are voted on by validators during the consensus process. diff --git a/include/xrpl/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h index dfb2b9dfe8..2879aecda9 100644 --- a/include/xrpl/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -253,6 +253,16 @@ std::uint8_t constexpr maxAssetCheckDepth = 5; /** A ledger index. */ using LedgerIndex = std::uint32_t; +std::uint32_t constexpr FLAG_LEDGER_INTERVAL = 256; + +/** Returns true if the given ledgerIndex is a voting ledgerIndex */ +bool +isVotingLedger(LedgerIndex seq); + +/** Returns true if the given ledgerIndex is a flag ledgerIndex */ +bool +isFlagLedger(LedgerIndex seq); + /** A transaction identifier. The value is computed as the hash of the canonicalized, serialized transaction object. diff --git a/include/xrpl/protocol/detail/transactions.macro b/include/xrpl/protocol/detail/transactions.macro index bc7eefedb5..b696a1d1c2 100644 --- a/include/xrpl/protocol/detail/transactions.macro +++ b/include/xrpl/protocol/detail/transactions.macro @@ -8,11 +8,11 @@ * To ease maintenance, you may replace any unneeded values with "..." * e.g. #define TRANSACTION(tag, value, name, ...) * - * You must define a transactor class in the `ripple` namespace named `name`, + * You must define a transactor class in the `xrpl` namespace named `name`, * and include its header alongside the TRANSACTOR definition using this * format: * #if TRANSACTION_INCLUDE - * # include + * # include * #endif * * The `privileges` parameter of the TRANSACTION macro is a bitfield @@ -22,7 +22,7 @@ /** This transaction type executes a payment. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttPAYMENT, 0, Payment, Delegation::delegable, @@ -42,7 +42,7 @@ TRANSACTION(ttPAYMENT, 0, Payment, /** This transaction type creates an escrow object. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttESCROW_CREATE, 1, EscrowCreate, Delegation::delegable, @@ -73,7 +73,7 @@ TRANSACTION(ttESCROW_FINISH, 2, EscrowFinish, /** This transaction type adjusts various account settings. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttACCOUNT_SET, 3, AccountSet, Delegation::notDelegable, @@ -94,7 +94,7 @@ TRANSACTION(ttACCOUNT_SET, 3, AccountSet, /** This transaction type cancels an existing escrow. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttESCROW_CANCEL, 4, EscrowCancel, Delegation::delegable, @@ -107,7 +107,7 @@ TRANSACTION(ttESCROW_CANCEL, 4, EscrowCancel, /** This transaction type sets or clears an account's "regular key". */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttREGULAR_KEY_SET, 5, SetRegularKey, Delegation::notDelegable, @@ -121,7 +121,7 @@ TRANSACTION(ttREGULAR_KEY_SET, 5, SetRegularKey, /** This transaction type creates an offer to trade one asset for another. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttOFFER_CREATE, 7, OfferCreate, Delegation::delegable, @@ -137,7 +137,7 @@ TRANSACTION(ttOFFER_CREATE, 7, OfferCreate, /** This transaction type cancels existing offers to trade one asset for another. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttOFFER_CANCEL, 8, OfferCancel, Delegation::delegable, @@ -151,7 +151,7 @@ TRANSACTION(ttOFFER_CANCEL, 8, OfferCancel, /** This transaction type creates a new set of tickets. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttTICKET_CREATE, 10, TicketCreate, Delegation::delegable, @@ -167,7 +167,7 @@ TRANSACTION(ttTICKET_CREATE, 10, TicketCreate, // The SignerEntries are optional because a SignerList is deleted by // setting the SignerQuorum to zero and omitting SignerEntries. #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttSIGNER_LIST_SET, 12, SignerListSet, Delegation::notDelegable, @@ -180,7 +180,7 @@ TRANSACTION(ttSIGNER_LIST_SET, 12, SignerListSet, /** This transaction type creates a new unidirectional XRP payment channel. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttPAYCHAN_CREATE, 13, PaymentChannelCreate, Delegation::delegable, @@ -222,7 +222,7 @@ TRANSACTION(ttPAYCHAN_CLAIM, 15, PaymentChannelClaim, /** This transaction type creates a new check. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, Delegation::delegable, @@ -238,7 +238,7 @@ TRANSACTION(ttCHECK_CREATE, 16, CheckCreate, /** This transaction type cashes an existing check. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttCHECK_CASH, 17, CheckCash, Delegation::delegable, @@ -252,7 +252,7 @@ TRANSACTION(ttCHECK_CASH, 17, CheckCash, /** This transaction type cancels an existing check. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, Delegation::delegable, @@ -264,7 +264,7 @@ TRANSACTION(ttCHECK_CANCEL, 18, CheckCancel, /** This transaction type grants or revokes authorization to transfer funds. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, Delegation::delegable, @@ -279,7 +279,7 @@ TRANSACTION(ttDEPOSIT_PREAUTH, 19, DepositPreauth, /** This transaction type modifies a trustline between two accounts. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttTRUST_SET, 20, TrustSet, Delegation::delegable, @@ -293,7 +293,7 @@ TRANSACTION(ttTRUST_SET, 20, TrustSet, /** This transaction type deletes an existing account. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, Delegation::notDelegable, @@ -309,7 +309,7 @@ TRANSACTION(ttACCOUNT_DELETE, 21, AccountDelete, /** This transaction mints a new NFT. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_MINT, 25, NFTokenMint, Delegation::delegable, @@ -327,7 +327,7 @@ TRANSACTION(ttNFTOKEN_MINT, 25, NFTokenMint, /** This transaction burns (i.e. destroys) an existing NFT. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_BURN, 26, NFTokenBurn, Delegation::delegable, @@ -340,7 +340,7 @@ TRANSACTION(ttNFTOKEN_BURN, 26, NFTokenBurn, /** This transaction creates a new offer to buy or sell an NFT. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_CREATE_OFFER, 27, NFTokenCreateOffer, Delegation::delegable, @@ -356,7 +356,7 @@ TRANSACTION(ttNFTOKEN_CREATE_OFFER, 27, NFTokenCreateOffer, /** This transaction cancels an existing offer to buy or sell an existing NFT. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_CANCEL_OFFER, 28, NFTokenCancelOffer, Delegation::delegable, @@ -368,7 +368,7 @@ TRANSACTION(ttNFTOKEN_CANCEL_OFFER, 28, NFTokenCancelOffer, /** This transaction accepts an existing offer to buy or sell an existing NFT. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer, Delegation::delegable, @@ -382,7 +382,7 @@ TRANSACTION(ttNFTOKEN_ACCEPT_OFFER, 29, NFTokenAcceptOffer, /** This transaction claws back issued tokens. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttCLAWBACK, 30, Clawback, Delegation::delegable, @@ -395,7 +395,7 @@ TRANSACTION(ttCLAWBACK, 30, Clawback, /** This transaction claws back tokens from an AMM pool. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_CLAWBACK, 31, AMMClawback, Delegation::delegable, @@ -410,7 +410,7 @@ TRANSACTION(ttAMM_CLAWBACK, 31, AMMClawback, /** This transaction type creates an AMM instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_CREATE, 35, AMMCreate, Delegation::delegable, @@ -424,7 +424,7 @@ TRANSACTION(ttAMM_CREATE, 35, AMMCreate, /** This transaction type deposits into an AMM instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, Delegation::delegable, @@ -442,7 +442,7 @@ TRANSACTION(ttAMM_DEPOSIT, 36, AMMDeposit, /** This transaction type withdraws from an AMM instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, Delegation::delegable, @@ -459,7 +459,7 @@ TRANSACTION(ttAMM_WITHDRAW, 37, AMMWithdraw, /** This transaction type votes for the trading fee */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_VOTE, 38, AMMVote, Delegation::delegable, @@ -473,7 +473,7 @@ TRANSACTION(ttAMM_VOTE, 38, AMMVote, /** This transaction type bids for the auction slot */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_BID, 39, AMMBid, Delegation::delegable, @@ -489,7 +489,7 @@ TRANSACTION(ttAMM_BID, 39, AMMBid, /** This transaction type deletes AMM in the empty state */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMM_DELETE, 40, AMMDelete, Delegation::delegable, @@ -502,7 +502,7 @@ TRANSACTION(ttAMM_DELETE, 40, AMMDelete, /** This transactions creates a crosschain sequence number */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttXCHAIN_CREATE_CLAIM_ID, 41, XChainCreateClaimID, Delegation::delegable, @@ -617,7 +617,7 @@ TRANSACTION(ttXCHAIN_CREATE_BRIDGE, 48, XChainCreateBridge, /** This transaction type creates or updates a DID */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttDID_SET, 49, DIDSet, Delegation::delegable, @@ -638,7 +638,7 @@ TRANSACTION(ttDID_DELETE, 50, DIDDelete, /** This transaction type creates an Oracle instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttORACLE_SET, 51, OracleSet, Delegation::delegable, @@ -655,7 +655,7 @@ TRANSACTION(ttORACLE_SET, 51, OracleSet, /** This transaction type deletes an Oracle instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttORACLE_DELETE, 52, OracleDelete, Delegation::delegable, @@ -667,7 +667,7 @@ TRANSACTION(ttORACLE_DELETE, 52, OracleDelete, /** This transaction type fixes a problem in the ledger state */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix, Delegation::delegable, @@ -680,7 +680,7 @@ TRANSACTION(ttLEDGER_STATE_FIX, 53, LedgerStateFix, /** This transaction type creates a MPTokensIssuance instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_CREATE, 54, MPTokenIssuanceCreate, Delegation::delegable, @@ -697,7 +697,7 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_CREATE, 54, MPTokenIssuanceCreate, /** This transaction type destroys a MPTokensIssuance instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_DESTROY, 55, MPTokenIssuanceDestroy, Delegation::delegable, @@ -709,7 +709,7 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_DESTROY, 55, MPTokenIssuanceDestroy, /** This transaction type sets flags on a MPTokensIssuance or MPToken instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttMPTOKEN_ISSUANCE_SET, 56, MPTokenIssuanceSet, Delegation::delegable, @@ -726,7 +726,7 @@ TRANSACTION(ttMPTOKEN_ISSUANCE_SET, 56, MPTokenIssuanceSet, /** This transaction type authorizes a MPToken instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttMPTOKEN_AUTHORIZE, 57, MPTokenAuthorize, Delegation::delegable, @@ -739,7 +739,7 @@ TRANSACTION(ttMPTOKEN_AUTHORIZE, 57, MPTokenAuthorize, /** This transaction type create an Credential instance */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttCREDENTIAL_CREATE, 58, CredentialCreate, Delegation::delegable, @@ -775,7 +775,7 @@ TRANSACTION(ttCREDENTIAL_DELETE, 60, CredentialDelete, /** This transaction type modify a NFToken */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttNFTOKEN_MODIFY, 61, NFTokenModify, Delegation::delegable, @@ -789,7 +789,7 @@ TRANSACTION(ttNFTOKEN_MODIFY, 61, NFTokenModify, /** This transaction type creates or modifies a Permissioned Domain */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttPERMISSIONED_DOMAIN_SET, 62, PermissionedDomainSet, Delegation::delegable, @@ -802,7 +802,7 @@ TRANSACTION(ttPERMISSIONED_DOMAIN_SET, 62, PermissionedDomainSet, /** This transaction type deletes a Permissioned Domain */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttPERMISSIONED_DOMAIN_DELETE, 63, PermissionedDomainDelete, Delegation::delegable, @@ -814,7 +814,7 @@ TRANSACTION(ttPERMISSIONED_DOMAIN_DELETE, 63, PermissionedDomainDelete, /** This transaction type delegates authorized account specified permissions */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttDELEGATE_SET, 64, DelegateSet, Delegation::notDelegable, @@ -827,7 +827,7 @@ TRANSACTION(ttDELEGATE_SET, 64, DelegateSet, /** This transaction creates a single asset vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_CREATE, 65, VaultCreate, Delegation::delegable, @@ -845,7 +845,7 @@ TRANSACTION(ttVAULT_CREATE, 65, VaultCreate, /** This transaction updates a single asset vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_SET, 66, VaultSet, Delegation::delegable, @@ -860,7 +860,7 @@ TRANSACTION(ttVAULT_SET, 66, VaultSet, /** This transaction deletes a single asset vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_DELETE, 67, VaultDelete, Delegation::delegable, @@ -872,7 +872,7 @@ TRANSACTION(ttVAULT_DELETE, 67, VaultDelete, /** This transaction trades assets for shares with a vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_DEPOSIT, 68, VaultDeposit, Delegation::delegable, @@ -885,7 +885,7 @@ TRANSACTION(ttVAULT_DEPOSIT, 68, VaultDeposit, /** This transaction trades shares for assets with a vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_WITHDRAW, 69, VaultWithdraw, Delegation::delegable, @@ -900,7 +900,7 @@ TRANSACTION(ttVAULT_WITHDRAW, 69, VaultWithdraw, /** This transaction claws back tokens from a vault. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttVAULT_CLAWBACK, 70, VaultClawback, Delegation::delegable, @@ -914,7 +914,7 @@ TRANSACTION(ttVAULT_CLAWBACK, 70, VaultClawback, /** This transaction type batches together transactions. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttBATCH, 71, Batch, Delegation::notDelegable, @@ -929,7 +929,7 @@ TRANSACTION(ttBATCH, 71, Batch, /** This transaction creates and updates a Loan Broker */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet, Delegation::delegable, @@ -946,7 +946,7 @@ TRANSACTION(ttLOAN_BROKER_SET, 74, LoanBrokerSet, /** This transaction deletes a Loan Broker */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_BROKER_DELETE, 75, LoanBrokerDelete, Delegation::delegable, @@ -957,7 +957,7 @@ TRANSACTION(ttLOAN_BROKER_DELETE, 75, LoanBrokerDelete, /** This transaction deposits First Loss Capital into a Loan Broker */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_BROKER_COVER_DEPOSIT, 76, LoanBrokerCoverDeposit, Delegation::delegable, @@ -969,7 +969,7 @@ TRANSACTION(ttLOAN_BROKER_COVER_DEPOSIT, 76, LoanBrokerCoverDeposit, /** This transaction withdraws First Loss Capital from a Loan Broker */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_BROKER_COVER_WITHDRAW, 77, LoanBrokerCoverWithdraw, Delegation::delegable, @@ -984,7 +984,7 @@ TRANSACTION(ttLOAN_BROKER_COVER_WITHDRAW, 77, LoanBrokerCoverWithdraw, /** This transaction claws back First Loss Capital from a Loan Broker to the issuer of the capital */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_BROKER_COVER_CLAWBACK, 78, LoanBrokerCoverClawback, Delegation::delegable, @@ -996,7 +996,7 @@ TRANSACTION(ttLOAN_BROKER_COVER_CLAWBACK, 78, LoanBrokerCoverClawback, /** This transaction creates a Loan */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_SET, 80, LoanSet, Delegation::delegable, @@ -1023,7 +1023,7 @@ TRANSACTION(ttLOAN_SET, 80, LoanSet, /** This transaction deletes an existing Loan */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_DELETE, 81, LoanDelete, Delegation::delegable, @@ -1034,7 +1034,7 @@ TRANSACTION(ttLOAN_DELETE, 81, LoanDelete, /** This transaction is used to change the delinquency status of an existing Loan */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_MANAGE, 82, LoanManage, Delegation::delegable, @@ -1048,7 +1048,7 @@ TRANSACTION(ttLOAN_MANAGE, 82, LoanManage, /** The Borrower uses this transaction to make a Payment on the Loan. */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttLOAN_PAY, 84, LoanPay, Delegation::delegable, @@ -1063,7 +1063,7 @@ TRANSACTION(ttLOAN_PAY, 84, LoanPay, For details, see: https://xrpl.org/amendments.html */ #if TRANSACTION_INCLUDE -# include +# include #endif TRANSACTION(ttAMENDMENT, 100, EnableAmendment, Delegation::notDelegable, diff --git a/src/xrpld/app/misc/LoadFeeTrack.h b/include/xrpl/server/LoadFeeTrack.h similarity index 100% rename from src/xrpld/app/misc/LoadFeeTrack.h rename to include/xrpl/server/LoadFeeTrack.h diff --git a/src/xrpld/app/tx/detail/ApplyContext.h b/include/xrpl/tx/ApplyContext.h similarity index 100% rename from src/xrpld/app/tx/detail/ApplyContext.h rename to include/xrpl/tx/ApplyContext.h diff --git a/src/xrpld/app/tx/detail/InvariantCheck.h b/include/xrpl/tx/InvariantCheck.h similarity index 100% rename from src/xrpld/app/tx/detail/InvariantCheck.h rename to include/xrpl/tx/InvariantCheck.h diff --git a/src/xrpld/app/tx/detail/SignerEntries.h b/include/xrpl/tx/SignerEntries.h similarity index 97% rename from src/xrpld/app/tx/detail/SignerEntries.h rename to include/xrpl/tx/SignerEntries.h index fe01d6b1ee..1e9c5fcb53 100644 --- a/src/xrpld/app/tx/detail/SignerEntries.h +++ b/include/xrpl/tx/SignerEntries.h @@ -1,11 +1,10 @@ #pragma once -#include // NotTEC - #include // #include // beast::Journal #include // temMALFORMED #include // AccountID +#include // NotTEC #include #include diff --git a/src/xrpld/app/tx/detail/Transactor.h b/include/xrpl/tx/Transactor.h similarity index 99% rename from src/xrpld/app/tx/detail/Transactor.h rename to include/xrpl/tx/Transactor.h index 5cb95843d5..b4f155f42d 100644 --- a/src/xrpld/app/tx/detail/Transactor.h +++ b/include/xrpl/tx/Transactor.h @@ -1,12 +1,11 @@ #pragma once -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/apply.h b/include/xrpl/tx/apply.h similarity index 98% rename from src/xrpld/app/tx/apply.h rename to include/xrpl/tx/apply.h index c21e7c1925..dbba0807f0 100644 --- a/src/xrpld/app/tx/apply.h +++ b/include/xrpl/tx/apply.h @@ -1,11 +1,9 @@ #pragma once -#include -#include - #include #include #include +#include #include diff --git a/src/xrpld/app/tx/applySteps.h b/include/xrpl/tx/applySteps.h similarity index 100% rename from src/xrpld/app/tx/applySteps.h rename to include/xrpl/tx/applySteps.h diff --git a/src/xrpld/app/tx/detail/BookTip.h b/include/xrpl/tx/paths/BookTip.h similarity index 100% rename from src/xrpld/app/tx/detail/BookTip.h rename to include/xrpl/tx/paths/BookTip.h diff --git a/src/xrpld/app/paths/Flow.h b/include/xrpl/tx/paths/Flow.h similarity index 95% rename from src/xrpld/app/paths/Flow.h rename to include/xrpl/tx/paths/Flow.h index 1a46ce221a..32e8c3611b 100644 --- a/src/xrpld/app/paths/Flow.h +++ b/include/xrpl/tx/paths/Flow.h @@ -1,9 +1,8 @@ #pragma once -#include -#include - #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Offer.h b/include/xrpl/tx/paths/Offer.h similarity index 100% rename from src/xrpld/app/tx/detail/Offer.h rename to include/xrpl/tx/paths/Offer.h diff --git a/src/xrpld/app/tx/detail/OfferStream.h b/include/xrpl/tx/paths/OfferStream.h similarity index 98% rename from src/xrpld/app/tx/detail/OfferStream.h rename to include/xrpl/tx/paths/OfferStream.h index 2f6bda3fab..df96a1b6da 100644 --- a/src/xrpld/app/tx/detail/OfferStream.h +++ b/include/xrpl/tx/paths/OfferStream.h @@ -1,12 +1,11 @@ #pragma once -#include -#include - #include #include #include #include +#include +#include #include diff --git a/src/xrpld/app/paths/RippleCalc.h b/include/xrpl/tx/paths/RippleCalc.h similarity index 100% rename from src/xrpld/app/paths/RippleCalc.h rename to include/xrpl/tx/paths/RippleCalc.h diff --git a/src/xrpld/app/paths/detail/AmountSpec.h b/include/xrpl/tx/paths/detail/AmountSpec.h similarity index 100% rename from src/xrpld/app/paths/detail/AmountSpec.h rename to include/xrpl/tx/paths/detail/AmountSpec.h diff --git a/src/xrpld/app/paths/detail/FlatSets.h b/include/xrpl/tx/paths/detail/FlatSets.h similarity index 100% rename from src/xrpld/app/paths/detail/FlatSets.h rename to include/xrpl/tx/paths/detail/FlatSets.h diff --git a/src/xrpld/app/paths/detail/FlowDebugInfo.h b/include/xrpl/tx/paths/detail/FlowDebugInfo.h similarity index 99% rename from src/xrpld/app/paths/detail/FlowDebugInfo.h rename to include/xrpl/tx/paths/detail/FlowDebugInfo.h index d7b97a49d4..dc0ba17d4e 100644 --- a/src/xrpld/app/paths/detail/FlowDebugInfo.h +++ b/include/xrpl/tx/paths/detail/FlowDebugInfo.h @@ -1,10 +1,9 @@ #pragma once -#include - #include #include #include +#include #include diff --git a/src/xrpld/app/paths/detail/Steps.h b/include/xrpl/tx/paths/detail/Steps.h similarity index 99% rename from src/xrpld/app/paths/detail/Steps.h rename to include/xrpl/tx/paths/detail/Steps.h index 580b8c487e..762d5ebe5d 100644 --- a/src/xrpld/app/paths/detail/Steps.h +++ b/include/xrpl/tx/paths/detail/Steps.h @@ -1,13 +1,12 @@ #pragma once -#include - #include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/paths/detail/StrandFlow.h b/include/xrpl/tx/paths/detail/StrandFlow.h similarity index 98% rename from src/xrpld/app/paths/detail/StrandFlow.h rename to include/xrpl/tx/paths/detail/StrandFlow.h index aa3d00a822..01d77b73f0 100644 --- a/src/xrpld/app/paths/detail/StrandFlow.h +++ b/include/xrpl/tx/paths/detail/StrandFlow.h @@ -1,18 +1,17 @@ #pragma once -#include -#include -#include -#include -#include -#include -#include - #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/AMMBid.h b/include/xrpl/tx/transactors/AMM/AMMBid.h similarity index 98% rename from src/xrpld/app/tx/detail/AMMBid.h rename to include/xrpl/tx/transactors/AMM/AMMBid.h index 83ea6e0729..b80bfe3bef 100644 --- a/src/xrpld/app/tx/detail/AMMBid.h +++ b/include/xrpl/tx/transactors/AMM/AMMBid.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMClawback.h b/include/xrpl/tx/transactors/AMM/AMMClawback.h similarity index 97% rename from src/xrpld/app/tx/detail/AMMClawback.h rename to include/xrpl/tx/transactors/AMM/AMMClawback.h index 3da3c44605..2bfccfa202 100644 --- a/src/xrpld/app/tx/detail/AMMClawback.h +++ b/include/xrpl/tx/transactors/AMM/AMMClawback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { class Sandbox; diff --git a/src/xrpld/app/paths/AMMContext.h b/include/xrpl/tx/transactors/AMM/AMMContext.h similarity index 100% rename from src/xrpld/app/paths/AMMContext.h rename to include/xrpl/tx/transactors/AMM/AMMContext.h diff --git a/src/xrpld/app/tx/detail/AMMCreate.h b/include/xrpl/tx/transactors/AMM/AMMCreate.h similarity index 98% rename from src/xrpld/app/tx/detail/AMMCreate.h rename to include/xrpl/tx/transactors/AMM/AMMCreate.h index 6f9fd77a2f..5deaa129ed 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.h +++ b/include/xrpl/tx/transactors/AMM/AMMCreate.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMDelete.h b/include/xrpl/tx/transactors/AMM/AMMDelete.h similarity index 94% rename from src/xrpld/app/tx/detail/AMMDelete.h rename to include/xrpl/tx/transactors/AMM/AMMDelete.h index 20c8f87262..1c0996f8a2 100644 --- a/src/xrpld/app/tx/detail/AMMDelete.h +++ b/include/xrpl/tx/transactors/AMM/AMMDelete.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMDeposit.h b/include/xrpl/tx/transactors/AMM/AMMDeposit.h similarity index 99% rename from src/xrpld/app/tx/detail/AMMDeposit.h rename to include/xrpl/tx/transactors/AMM/AMMDeposit.h index 45c7995438..287d46ff07 100644 --- a/src/xrpld/app/tx/detail/AMMDeposit.h +++ b/include/xrpl/tx/transactors/AMM/AMMDeposit.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/AMMHelpers.h b/include/xrpl/tx/transactors/AMM/AMMHelpers.h similarity index 100% rename from src/xrpld/app/misc/AMMHelpers.h rename to include/xrpl/tx/transactors/AMM/AMMHelpers.h diff --git a/src/xrpld/app/misc/AMMUtils.h b/include/xrpl/tx/transactors/AMM/AMMUtils.h similarity index 100% rename from src/xrpld/app/misc/AMMUtils.h rename to include/xrpl/tx/transactors/AMM/AMMUtils.h diff --git a/src/xrpld/app/tx/detail/AMMVote.h b/include/xrpl/tx/transactors/AMM/AMMVote.h similarity index 97% rename from src/xrpld/app/tx/detail/AMMVote.h rename to include/xrpl/tx/transactors/AMM/AMMVote.h index 2bc3da2301..ab04b30993 100644 --- a/src/xrpld/app/tx/detail/AMMVote.h +++ b/include/xrpl/tx/transactors/AMM/AMMVote.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMWithdraw.h b/include/xrpl/tx/transactors/AMM/AMMWithdraw.h similarity index 99% rename from src/xrpld/app/tx/detail/AMMWithdraw.h rename to include/xrpl/tx/transactors/AMM/AMMWithdraw.h index 246c66100c..c15bb68644 100644 --- a/src/xrpld/app/tx/detail/AMMWithdraw.h +++ b/include/xrpl/tx/transactors/AMM/AMMWithdraw.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Batch.h b/include/xrpl/tx/transactors/Batch.h similarity index 96% rename from src/xrpld/app/tx/detail/Batch.h rename to include/xrpl/tx/transactors/Batch.h index 17abec38c3..0861deb094 100644 --- a/src/xrpld/app/tx/detail/Batch.h +++ b/include/xrpl/tx/transactors/Batch.h @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Change.h b/include/xrpl/tx/transactors/Change.h similarity index 93% rename from src/xrpld/app/tx/detail/Change.h rename to include/xrpl/tx/transactors/Change.h index 683b054ccb..1bf63ff0db 100644 --- a/src/xrpld/app/tx/detail/Change.h +++ b/include/xrpl/tx/transactors/Change.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CancelCheck.h b/include/xrpl/tx/transactors/Check/CancelCheck.h similarity index 90% rename from src/xrpld/app/tx/detail/CancelCheck.h rename to include/xrpl/tx/transactors/Check/CancelCheck.h index f125b9af5b..8a0e42c7ca 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.h +++ b/include/xrpl/tx/transactors/Check/CancelCheck.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CashCheck.h b/include/xrpl/tx/transactors/Check/CashCheck.h similarity index 90% rename from src/xrpld/app/tx/detail/CashCheck.h rename to include/xrpl/tx/transactors/Check/CashCheck.h index 50a4f8a63a..138790cf34 100644 --- a/src/xrpld/app/tx/detail/CashCheck.h +++ b/include/xrpl/tx/transactors/Check/CashCheck.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CreateCheck.h b/include/xrpl/tx/transactors/Check/CreateCheck.h similarity index 90% rename from src/xrpld/app/tx/detail/CreateCheck.h rename to include/xrpl/tx/transactors/Check/CreateCheck.h index b80536fe02..98950b68f2 100644 --- a/src/xrpld/app/tx/detail/CreateCheck.h +++ b/include/xrpl/tx/transactors/Check/CreateCheck.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Clawback.h b/include/xrpl/tx/transactors/Clawback.h similarity index 91% rename from src/xrpld/app/tx/detail/Clawback.h rename to include/xrpl/tx/transactors/Clawback.h index 427edb25b4..7451266461 100644 --- a/src/xrpld/app/tx/detail/Clawback.h +++ b/include/xrpl/tx/transactors/Clawback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CreateTicket.h b/include/xrpl/tx/transactors/CreateTicket.h similarity index 98% rename from src/xrpld/app/tx/detail/CreateTicket.h rename to include/xrpl/tx/transactors/CreateTicket.h index dd424e3756..867ad99c12 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.h +++ b/include/xrpl/tx/transactors/CreateTicket.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Credentials.h b/include/xrpl/tx/transactors/Credentials.h similarity index 97% rename from src/xrpld/app/tx/detail/Credentials.h rename to include/xrpl/tx/transactors/Credentials.h index 02bccde198..8c96f40526 100644 --- a/src/xrpld/app/tx/detail/Credentials.h +++ b/include/xrpl/tx/transactors/Credentials.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DID.h b/include/xrpl/tx/transactors/DID.h similarity index 95% rename from src/xrpld/app/tx/detail/DID.h rename to include/xrpl/tx/transactors/DID.h index a00039a999..8ab80bc694 100644 --- a/src/xrpld/app/tx/detail/DID.h +++ b/include/xrpl/tx/transactors/DID.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DelegateSet.h b/include/xrpl/tx/transactors/Delegate/DelegateSet.h similarity index 92% rename from src/xrpld/app/tx/detail/DelegateSet.h rename to include/xrpl/tx/transactors/Delegate/DelegateSet.h index 2120674557..d5ea0f13cc 100644 --- a/src/xrpld/app/tx/detail/DelegateSet.h +++ b/include/xrpl/tx/transactors/Delegate/DelegateSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/DelegateUtils.h b/include/xrpl/tx/transactors/Delegate/DelegateUtils.h similarity index 100% rename from src/xrpld/app/misc/DelegateUtils.h rename to include/xrpl/tx/transactors/Delegate/DelegateUtils.h diff --git a/src/xrpld/app/tx/detail/DeleteAccount.h b/include/xrpl/tx/transactors/DeleteAccount.h similarity index 93% rename from src/xrpld/app/tx/detail/DeleteAccount.h rename to include/xrpl/tx/transactors/DeleteAccount.h index 742d1f4257..f55888ee00 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.h +++ b/include/xrpl/tx/transactors/DeleteAccount.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DeleteOracle.h b/include/xrpl/tx/transactors/DeleteOracle.h similarity index 95% rename from src/xrpld/app/tx/detail/DeleteOracle.h rename to include/xrpl/tx/transactors/DeleteOracle.h index 7d7cc340cb..7140a9096a 100644 --- a/src/xrpld/app/tx/detail/DeleteOracle.h +++ b/include/xrpl/tx/transactors/DeleteOracle.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DepositPreauth.h b/include/xrpl/tx/transactors/DepositPreauth.h similarity index 93% rename from src/xrpld/app/tx/detail/DepositPreauth.h rename to include/xrpl/tx/transactors/DepositPreauth.h index f1afac3b18..24050da600 100644 --- a/src/xrpld/app/tx/detail/DepositPreauth.h +++ b/include/xrpl/tx/transactors/DepositPreauth.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Escrow.h b/include/xrpl/tx/transactors/Escrow.h similarity index 97% rename from src/xrpld/app/tx/detail/Escrow.h rename to include/xrpl/tx/transactors/Escrow.h index cb99dcae06..0fd627e5a9 100644 --- a/src/xrpld/app/tx/detail/Escrow.h +++ b/include/xrpl/tx/transactors/Escrow.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LedgerStateFix.h b/include/xrpl/tx/transactors/LedgerStateFix.h similarity index 92% rename from src/xrpld/app/tx/detail/LedgerStateFix.h rename to include/xrpl/tx/transactors/LedgerStateFix.h index 66fe124cff..728f8c651d 100644 --- a/src/xrpld/app/tx/detail/LedgerStateFix.h +++ b/include/xrpl/tx/transactors/LedgerStateFix.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/LendingHelpers.h b/include/xrpl/tx/transactors/Lending/LendingHelpers.h similarity index 100% rename from src/xrpld/app/misc/LendingHelpers.h rename to include/xrpl/tx/transactors/Lending/LendingHelpers.h diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverClawback.h b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverClawback.h similarity index 93% rename from src/xrpld/app/tx/detail/LoanBrokerCoverClawback.h rename to include/xrpl/tx/transactors/Lending/LoanBrokerCoverClawback.h index 139d50696a..b1e539392f 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverClawback.h +++ b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverClawback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.h b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.h similarity index 92% rename from src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.h rename to include/xrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.h index 3f683c6a62..8dda417443 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.h +++ b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.h b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.h similarity index 93% rename from src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.h rename to include/xrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.h index 50d0b98fa5..52b14bfb67 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.h +++ b/include/xrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerDelete.h b/include/xrpl/tx/transactors/Lending/LoanBrokerDelete.h similarity index 92% rename from src/xrpld/app/tx/detail/LoanBrokerDelete.h rename to include/xrpl/tx/transactors/Lending/LoanBrokerDelete.h index cb44277f55..b9c9851c41 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerDelete.h +++ b/include/xrpl/tx/transactors/Lending/LoanBrokerDelete.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerSet.h b/include/xrpl/tx/transactors/Lending/LoanBrokerSet.h similarity index 93% rename from src/xrpld/app/tx/detail/LoanBrokerSet.h rename to include/xrpl/tx/transactors/Lending/LoanBrokerSet.h index cda452bebe..ce1e069791 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerSet.h +++ b/include/xrpl/tx/transactors/Lending/LoanBrokerSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanDelete.h b/include/xrpl/tx/transactors/Lending/LoanDelete.h similarity index 92% rename from src/xrpld/app/tx/detail/LoanDelete.h rename to include/xrpl/tx/transactors/Lending/LoanDelete.h index 37889d31fb..ff78d7db60 100644 --- a/src/xrpld/app/tx/detail/LoanDelete.h +++ b/include/xrpl/tx/transactors/Lending/LoanDelete.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanManage.h b/include/xrpl/tx/transactors/Lending/LoanManage.h similarity index 96% rename from src/xrpld/app/tx/detail/LoanManage.h rename to include/xrpl/tx/transactors/Lending/LoanManage.h index 44b2b62b3d..26ed041ac7 100644 --- a/src/xrpld/app/tx/detail/LoanManage.h +++ b/include/xrpl/tx/transactors/Lending/LoanManage.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanPay.h b/include/xrpl/tx/transactors/Lending/LoanPay.h similarity index 94% rename from src/xrpld/app/tx/detail/LoanPay.h rename to include/xrpl/tx/transactors/Lending/LoanPay.h index c947b1b6f8..2e3cce75ed 100644 --- a/src/xrpld/app/tx/detail/LoanPay.h +++ b/include/xrpl/tx/transactors/Lending/LoanPay.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanSet.h b/include/xrpl/tx/transactors/Lending/LoanSet.h similarity index 93% rename from src/xrpld/app/tx/detail/LoanSet.h rename to include/xrpl/tx/transactors/Lending/LoanSet.h index e4bb79a36d..e9916b9d6b 100644 --- a/src/xrpld/app/tx/detail/LoanSet.h +++ b/include/xrpl/tx/transactors/Lending/LoanSet.h @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenAuthorize.h b/include/xrpl/tx/transactors/MPT/MPTokenAuthorize.h similarity index 94% rename from src/xrpld/app/tx/detail/MPTokenAuthorize.h rename to include/xrpl/tx/transactors/MPT/MPTokenAuthorize.h index c887b70fa8..1f53dfc42d 100644 --- a/src/xrpld/app/tx/detail/MPTokenAuthorize.h +++ b/include/xrpl/tx/transactors/MPT/MPTokenAuthorize.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceCreate.h similarity index 96% rename from src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h rename to include/xrpl/tx/transactors/MPT/MPTokenIssuanceCreate.h index 56c20ed551..0ebde22a37 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.h +++ b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceCreate.h @@ -1,9 +1,8 @@ #pragma once -#include - #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.h similarity index 91% rename from src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h rename to include/xrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.h index 89243944d0..c4a448032a 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.h +++ b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceSet.h b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceSet.h similarity index 93% rename from src/xrpld/app/tx/detail/MPTokenIssuanceSet.h rename to include/xrpl/tx/transactors/MPT/MPTokenIssuanceSet.h index 68794ca48c..dccd4e4cee 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceSet.h +++ b/include/xrpl/tx/transactors/MPT/MPTokenIssuanceSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.h b/include/xrpl/tx/transactors/NFT/NFTokenAcceptOffer.h similarity index 95% rename from src/xrpld/app/tx/detail/NFTokenAcceptOffer.h rename to include/xrpl/tx/transactors/NFT/NFTokenAcceptOffer.h index 549c38d33b..d876a70362 100644 --- a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenAcceptOffer.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenBurn.h b/include/xrpl/tx/transactors/NFT/NFTokenBurn.h similarity index 90% rename from src/xrpld/app/tx/detail/NFTokenBurn.h rename to include/xrpl/tx/transactors/NFT/NFTokenBurn.h index c2bc300ab8..8737997f03 100644 --- a/src/xrpld/app/tx/detail/NFTokenBurn.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenBurn.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenCancelOffer.h b/include/xrpl/tx/transactors/NFT/NFTokenCancelOffer.h similarity index 91% rename from src/xrpld/app/tx/detail/NFTokenCancelOffer.h rename to include/xrpl/tx/transactors/NFT/NFTokenCancelOffer.h index b1801ede25..bb8cd4c216 100644 --- a/src/xrpld/app/tx/detail/NFTokenCancelOffer.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenCancelOffer.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenCreateOffer.h b/include/xrpl/tx/transactors/NFT/NFTokenCreateOffer.h similarity index 91% rename from src/xrpld/app/tx/detail/NFTokenCreateOffer.h rename to include/xrpl/tx/transactors/NFT/NFTokenCreateOffer.h index ed54338f49..a48e53589d 100644 --- a/src/xrpld/app/tx/detail/NFTokenCreateOffer.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenCreateOffer.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenMint.h b/include/xrpl/tx/transactors/NFT/NFTokenMint.h similarity index 89% rename from src/xrpld/app/tx/detail/NFTokenMint.h rename to include/xrpl/tx/transactors/NFT/NFTokenMint.h index 52981ef467..c3a7db4581 100644 --- a/src/xrpld/app/tx/detail/NFTokenMint.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenMint.h @@ -1,9 +1,8 @@ #pragma once -#include -#include - #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenModify.h b/include/xrpl/tx/transactors/NFT/NFTokenModify.h similarity index 90% rename from src/xrpld/app/tx/detail/NFTokenModify.h rename to include/xrpl/tx/transactors/NFT/NFTokenModify.h index f755746f1f..a64df65783 100644 --- a/src/xrpld/app/tx/detail/NFTokenModify.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenModify.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.h b/include/xrpl/tx/transactors/NFT/NFTokenUtils.h similarity index 98% rename from src/xrpld/app/tx/detail/NFTokenUtils.h rename to include/xrpl/tx/transactors/NFT/NFTokenUtils.h index 44d3cfb956..4e4150a369 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.h +++ b/include/xrpl/tx/transactors/NFT/NFTokenUtils.h @@ -1,12 +1,11 @@ #pragma once -#include - #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CancelOffer.h b/include/xrpl/tx/transactors/Offer/CancelOffer.h similarity index 91% rename from src/xrpld/app/tx/detail/CancelOffer.h rename to include/xrpl/tx/transactors/Offer/CancelOffer.h index 30a7129fb4..6107c3211f 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.h +++ b/include/xrpl/tx/transactors/Offer/CancelOffer.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CreateOffer.h b/include/xrpl/tx/transactors/Offer/CreateOffer.h similarity index 97% rename from src/xrpld/app/tx/detail/CreateOffer.h rename to include/xrpl/tx/transactors/Offer/CreateOffer.h index 14f82c501e..cb15d08ace 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.h +++ b/include/xrpl/tx/transactors/Offer/CreateOffer.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/PayChan.h b/include/xrpl/tx/transactors/PayChan.h similarity index 97% rename from src/xrpld/app/tx/detail/PayChan.h rename to include/xrpl/tx/transactors/PayChan.h index 8748ec9383..cc23f029f2 100644 --- a/src/xrpld/app/tx/detail/PayChan.h +++ b/include/xrpl/tx/transactors/PayChan.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Payment.h b/include/xrpl/tx/transactors/Payment.h similarity index 95% rename from src/xrpld/app/tx/detail/Payment.h rename to include/xrpl/tx/transactors/Payment.h index 192f2b0edb..bc5bc4fee3 100644 --- a/src/xrpld/app/tx/detail/Payment.h +++ b/include/xrpl/tx/transactors/Payment.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/PermissionedDEXHelpers.h b/include/xrpl/tx/transactors/PermissionedDEXHelpers.h similarity index 100% rename from src/xrpld/app/misc/PermissionedDEXHelpers.h rename to include/xrpl/tx/transactors/PermissionedDEXHelpers.h diff --git a/src/xrpld/app/tx/detail/PermissionedDomainDelete.h b/include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.h similarity index 91% rename from src/xrpld/app/tx/detail/PermissionedDomainDelete.h rename to include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.h index 294fb794ae..b5c72413a2 100644 --- a/src/xrpld/app/tx/detail/PermissionedDomainDelete.h +++ b/include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/PermissionedDomainSet.h b/include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.h similarity index 92% rename from src/xrpld/app/tx/detail/PermissionedDomainSet.h rename to include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.h index 824104e50d..acf9194ee2 100644 --- a/src/xrpld/app/tx/detail/PermissionedDomainSet.h +++ b/include/xrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetAccount.h b/include/xrpl/tx/transactors/SetAccount.h similarity index 94% rename from src/xrpld/app/tx/detail/SetAccount.h rename to include/xrpl/tx/transactors/SetAccount.h index db59826347..3abfcb43bb 100644 --- a/src/xrpld/app/tx/detail/SetAccount.h +++ b/include/xrpl/tx/transactors/SetAccount.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetOracle.h b/include/xrpl/tx/transactors/SetOracle.h similarity index 94% rename from src/xrpld/app/tx/detail/SetOracle.h rename to include/xrpl/tx/transactors/SetOracle.h index 6b47a5397e..be1a7b8821 100644 --- a/src/xrpld/app/tx/detail/SetOracle.h +++ b/include/xrpl/tx/transactors/SetOracle.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetRegularKey.h b/include/xrpl/tx/transactors/SetRegularKey.h similarity index 90% rename from src/xrpld/app/tx/detail/SetRegularKey.h rename to include/xrpl/tx/transactors/SetRegularKey.h index bc712b319a..bb1dd48a68 100644 --- a/src/xrpld/app/tx/detail/SetRegularKey.h +++ b/include/xrpl/tx/transactors/SetRegularKey.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetSignerList.h b/include/xrpl/tx/transactors/SetSignerList.h similarity index 94% rename from src/xrpld/app/tx/detail/SetSignerList.h rename to include/xrpl/tx/transactors/SetSignerList.h index cac9ce1288..f0c6c276e9 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.h +++ b/include/xrpl/tx/transactors/SetSignerList.h @@ -1,10 +1,9 @@ #pragma once -#include -#include - #include #include +#include +#include #include #include diff --git a/src/xrpld/app/tx/detail/SetTrust.h b/include/xrpl/tx/transactors/SetTrust.h similarity index 93% rename from src/xrpld/app/tx/detail/SetTrust.h rename to include/xrpl/tx/transactors/SetTrust.h index 1081567a66..47ec26b6ad 100644 --- a/src/xrpld/app/tx/detail/SetTrust.h +++ b/include/xrpl/tx/transactors/SetTrust.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultClawback.h b/include/xrpl/tx/transactors/Vault/VaultClawback.h similarity index 93% rename from src/xrpld/app/tx/detail/VaultClawback.h rename to include/xrpl/tx/transactors/Vault/VaultClawback.h index c93289e641..131a1d87e7 100644 --- a/src/xrpld/app/tx/detail/VaultClawback.h +++ b/include/xrpl/tx/transactors/Vault/VaultClawback.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultCreate.h b/include/xrpl/tx/transactors/Vault/VaultCreate.h similarity index 92% rename from src/xrpld/app/tx/detail/VaultCreate.h rename to include/xrpl/tx/transactors/Vault/VaultCreate.h index 20b18f5cc2..cc35cd765b 100644 --- a/src/xrpld/app/tx/detail/VaultCreate.h +++ b/include/xrpl/tx/transactors/Vault/VaultCreate.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultDelete.h b/include/xrpl/tx/transactors/Vault/VaultDelete.h similarity index 90% rename from src/xrpld/app/tx/detail/VaultDelete.h rename to include/xrpl/tx/transactors/Vault/VaultDelete.h index 8d1f214885..f881a692fd 100644 --- a/src/xrpld/app/tx/detail/VaultDelete.h +++ b/include/xrpl/tx/transactors/Vault/VaultDelete.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultDeposit.h b/include/xrpl/tx/transactors/Vault/VaultDeposit.h similarity index 90% rename from src/xrpld/app/tx/detail/VaultDeposit.h rename to include/xrpl/tx/transactors/Vault/VaultDeposit.h index 6c63308407..0943596f20 100644 --- a/src/xrpld/app/tx/detail/VaultDeposit.h +++ b/include/xrpl/tx/transactors/Vault/VaultDeposit.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultSet.h b/include/xrpl/tx/transactors/Vault/VaultSet.h similarity index 91% rename from src/xrpld/app/tx/detail/VaultSet.h rename to include/xrpl/tx/transactors/Vault/VaultSet.h index 1e8a15291e..fb69f132b1 100644 --- a/src/xrpld/app/tx/detail/VaultSet.h +++ b/include/xrpl/tx/transactors/Vault/VaultSet.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultWithdraw.h b/include/xrpl/tx/transactors/Vault/VaultWithdraw.h similarity index 90% rename from src/xrpld/app/tx/detail/VaultWithdraw.h rename to include/xrpl/tx/transactors/Vault/VaultWithdraw.h index f832c206f8..ffe14a7141 100644 --- a/src/xrpld/app/tx/detail/VaultWithdraw.h +++ b/include/xrpl/tx/transactors/Vault/VaultWithdraw.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/XChainBridge.h b/include/xrpl/tx/transactors/XChainBridge.h similarity index 99% rename from src/xrpld/app/tx/detail/XChainBridge.h rename to include/xrpl/tx/transactors/XChainBridge.h index 3d0c250f24..0a2fccc18b 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.h +++ b/include/xrpl/tx/transactors/XChainBridge.h @@ -1,8 +1,7 @@ #pragma once -#include - #include +#include namespace xrpl { diff --git a/src/libxrpl/protocol/Protocol.cpp b/src/libxrpl/protocol/Protocol.cpp new file mode 100644 index 0000000000..6f86f49fc6 --- /dev/null +++ b/src/libxrpl/protocol/Protocol.cpp @@ -0,0 +1,15 @@ +#include + +namespace xrpl { +bool +isVotingLedger(LedgerIndex seq) +{ + return seq % FLAG_LEDGER_INTERVAL == 0; +} + +bool +isFlagLedger(LedgerIndex seq) +{ + return seq % FLAG_LEDGER_INTERVAL == 0; +} +} // namespace xrpl diff --git a/src/xrpld/app/misc/detail/LoadFeeTrack.cpp b/src/libxrpl/server/LoadFeeTrack.cpp similarity index 98% rename from src/xrpld/app/misc/detail/LoadFeeTrack.cpp rename to src/libxrpl/server/LoadFeeTrack.cpp index 91a40c6a9d..e3867f36f5 100644 --- a/src/xrpld/app/misc/detail/LoadFeeTrack.cpp +++ b/src/libxrpl/server/LoadFeeTrack.cpp @@ -1,9 +1,8 @@ -#include - #include #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/ApplyContext.cpp b/src/libxrpl/tx/ApplyContext.cpp similarity index 97% rename from src/xrpld/app/tx/detail/ApplyContext.cpp rename to src/libxrpl/tx/ApplyContext.cpp index 71cb5cd936..1258d36a50 100644 --- a/src/xrpld/app/tx/detail/ApplyContext.cpp +++ b/src/libxrpl/tx/ApplyContext.cpp @@ -1,9 +1,8 @@ -#include -#include - #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/InvariantCheck.cpp b/src/libxrpl/tx/InvariantCheck.cpp similarity index 99% rename from src/xrpld/app/tx/detail/InvariantCheck.cpp rename to src/libxrpl/tx/InvariantCheck.cpp index 24a37270ce..c1ba2ac4ea 100644 --- a/src/xrpld/app/tx/detail/InvariantCheck.cpp +++ b/src/libxrpl/tx/InvariantCheck.cpp @@ -1,9 +1,3 @@ -#include -#include -#include -#include -#include - #include #include #include @@ -21,6 +15,11 @@ #include #include #include +#include +#include +#include +#include +#include #include #include diff --git a/src/xrpld/app/tx/detail/SignerEntries.cpp b/src/libxrpl/tx/SignerEntries.cpp similarity index 95% rename from src/xrpld/app/tx/detail/SignerEntries.cpp rename to src/libxrpl/tx/SignerEntries.cpp index 3526148638..aca1f2c19a 100644 --- a/src/xrpld/app/tx/detail/SignerEntries.cpp +++ b/src/libxrpl/tx/SignerEntries.cpp @@ -1,8 +1,8 @@ -#include - #include #include #include +#include +#include #include #include diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/libxrpl/tx/Transactor.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Transactor.cpp rename to src/libxrpl/tx/Transactor.cpp index 129c06fdd5..3545004efa 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/libxrpl/tx/Transactor.cpp @@ -1,10 +1,3 @@ -#include -#include -#include -#include -#include -#include - #include #include #include @@ -17,6 +10,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/apply.cpp b/src/libxrpl/tx/apply.cpp similarity index 99% rename from src/xrpld/app/tx/detail/apply.cpp rename to src/libxrpl/tx/apply.cpp index 0f7d2eb2a3..2d2df75173 100644 --- a/src/xrpld/app/tx/detail/apply.cpp +++ b/src/libxrpl/tx/apply.cpp @@ -1,11 +1,10 @@ -#include -#include - #include #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/libxrpl/tx/applySteps.cpp similarity index 99% rename from src/xrpld/app/tx/detail/applySteps.cpp rename to src/libxrpl/tx/applySteps.cpp index 412b717428..3d5c1486f4 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/libxrpl/tx/applySteps.cpp @@ -1,4 +1,4 @@ -#include +#include #pragma push_macro("TRANSACTION") #undef TRANSACTION diff --git a/src/xrpld/app/tx/detail/BookTip.cpp b/src/libxrpl/tx/paths/BookTip.cpp similarity index 97% rename from src/xrpld/app/tx/detail/BookTip.cpp rename to src/libxrpl/tx/paths/BookTip.cpp index 61010c0caa..f00da6d7c7 100644 --- a/src/xrpld/app/tx/detail/BookTip.cpp +++ b/src/libxrpl/tx/paths/BookTip.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/Flow.cpp b/src/libxrpl/tx/paths/Flow.cpp similarity index 95% rename from src/xrpld/app/paths/Flow.cpp rename to src/libxrpl/tx/paths/Flow.cpp index 1f6d29bfb9..d1c25a353c 100644 --- a/src/xrpld/app/paths/Flow.cpp +++ b/src/libxrpl/tx/paths/Flow.cpp @@ -1,13 +1,12 @@ -#include -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/OfferStream.cpp b/src/libxrpl/tx/paths/OfferStream.cpp similarity index 99% rename from src/xrpld/app/tx/detail/OfferStream.cpp rename to src/libxrpl/tx/paths/OfferStream.cpp index 9f013de607..ee74d94d7d 100644 --- a/src/xrpld/app/tx/detail/OfferStream.cpp +++ b/src/libxrpl/tx/paths/OfferStream.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/RippleCalc.cpp b/src/libxrpl/tx/paths/RippleCalc.cpp similarity index 96% rename from src/xrpld/app/paths/RippleCalc.cpp rename to src/libxrpl/tx/paths/RippleCalc.cpp index 0667e1971c..ba40e031cc 100644 --- a/src/xrpld/app/paths/RippleCalc.cpp +++ b/src/libxrpl/tx/paths/RippleCalc.cpp @@ -1,10 +1,9 @@ -#include -#include -#include - #include #include #include +#include +#include +#include namespace xrpl { namespace path { diff --git a/src/xrpld/app/tx/detail/AMMBid.cpp b/src/libxrpl/tx/transactors/AMM/AMMBid.cpp similarity index 98% rename from src/xrpld/app/tx/detail/AMMBid.cpp rename to src/libxrpl/tx/transactors/AMM/AMMBid.cpp index 1d0c30c1f0..b54fb34be9 100644 --- a/src/xrpld/app/tx/detail/AMMBid.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMBid.cpp @@ -1,13 +1,12 @@ -#include -#include -#include - #include #include #include #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMClawback.cpp b/src/libxrpl/tx/transactors/AMM/AMMClawback.cpp similarity index 97% rename from src/xrpld/app/tx/detail/AMMClawback.cpp rename to src/libxrpl/tx/transactors/AMM/AMMClawback.cpp index 6da899c578..19aebecb27 100644 --- a/src/xrpld/app/tx/detail/AMMClawback.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMClawback.cpp @@ -1,14 +1,13 @@ -#include -#include -#include -#include - #include #include #include #include #include #include +#include +#include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/AMMCreate.cpp b/src/libxrpl/tx/transactors/AMM/AMMCreate.cpp similarity index 98% rename from src/xrpld/app/tx/detail/AMMCreate.cpp rename to src/libxrpl/tx/transactors/AMM/AMMCreate.cpp index 1131d21fd2..432fb716b7 100644 --- a/src/xrpld/app/tx/detail/AMMCreate.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMCreate.cpp @@ -1,7 +1,3 @@ -#include -#include -#include - #include #include #include @@ -9,6 +5,9 @@ #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMDelete.cpp b/src/libxrpl/tx/transactors/AMM/AMMDelete.cpp similarity index 92% rename from src/xrpld/app/tx/detail/AMMDelete.cpp rename to src/libxrpl/tx/transactors/AMM/AMMDelete.cpp index f810f57758..d11e8f225c 100644 --- a/src/xrpld/app/tx/detail/AMMDelete.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMDelete.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMDeposit.cpp b/src/libxrpl/tx/transactors/AMM/AMMDeposit.cpp similarity index 99% rename from src/xrpld/app/tx/detail/AMMDeposit.cpp rename to src/libxrpl/tx/transactors/AMM/AMMDeposit.cpp index af4ce51894..83917246c6 100644 --- a/src/xrpld/app/tx/detail/AMMDeposit.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMDeposit.cpp @@ -1,12 +1,11 @@ -#include -#include -#include - #include #include #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/detail/AMMHelpers.cpp b/src/libxrpl/tx/transactors/AMM/AMMHelpers.cpp similarity index 99% rename from src/xrpld/app/misc/detail/AMMHelpers.cpp rename to src/libxrpl/tx/transactors/AMM/AMMHelpers.cpp index ff3474f33d..28e1b8adf7 100644 --- a/src/xrpld/app/misc/detail/AMMHelpers.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMHelpers.cpp @@ -1,4 +1,4 @@ -#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/detail/AMMUtils.cpp b/src/libxrpl/tx/transactors/AMM/AMMUtils.cpp similarity index 99% rename from src/xrpld/app/misc/detail/AMMUtils.cpp rename to src/libxrpl/tx/transactors/AMM/AMMUtils.cpp index 36a40f1709..0ae1903928 100644 --- a/src/xrpld/app/misc/detail/AMMUtils.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMUtils.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMVote.cpp b/src/libxrpl/tx/transactors/AMM/AMMVote.cpp similarity index 98% rename from src/xrpld/app/tx/detail/AMMVote.cpp rename to src/libxrpl/tx/transactors/AMM/AMMVote.cpp index 05b23233a4..2ef281b70f 100644 --- a/src/xrpld/app/tx/detail/AMMVote.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMVote.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/AMMWithdraw.cpp b/src/libxrpl/tx/transactors/AMM/AMMWithdraw.cpp similarity index 99% rename from src/xrpld/app/tx/detail/AMMWithdraw.cpp rename to src/libxrpl/tx/transactors/AMM/AMMWithdraw.cpp index 58d1e066d6..bf00223660 100644 --- a/src/xrpld/app/tx/detail/AMMWithdraw.cpp +++ b/src/libxrpl/tx/transactors/AMM/AMMWithdraw.cpp @@ -1,11 +1,10 @@ -#include -#include -#include - #include #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Batch.cpp b/src/libxrpl/tx/transactors/Batch.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Batch.cpp rename to src/libxrpl/tx/transactors/Batch.cpp index f7f0d7ac60..faa756a56f 100644 --- a/src/xrpld/app/tx/detail/Batch.cpp +++ b/src/libxrpl/tx/transactors/Batch.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -9,6 +6,8 @@ #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Change.cpp b/src/libxrpl/tx/transactors/Change.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Change.cpp rename to src/libxrpl/tx/transactors/Change.cpp index 478377a818..eea3da6072 100644 --- a/src/xrpld/app/tx/detail/Change.cpp +++ b/src/libxrpl/tx/transactors/Change.cpp @@ -1,12 +1,11 @@ -#include -#include - #include +#include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/CancelCheck.cpp b/src/libxrpl/tx/transactors/Check/CancelCheck.cpp similarity index 98% rename from src/xrpld/app/tx/detail/CancelCheck.cpp rename to src/libxrpl/tx/transactors/Check/CancelCheck.cpp index 7936b3b9ed..c9a947ae6a 100644 --- a/src/xrpld/app/tx/detail/CancelCheck.cpp +++ b/src/libxrpl/tx/transactors/Check/CancelCheck.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -7,6 +5,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CashCheck.cpp b/src/libxrpl/tx/transactors/Check/CashCheck.cpp similarity index 99% rename from src/xrpld/app/tx/detail/CashCheck.cpp rename to src/libxrpl/tx/transactors/Check/CashCheck.cpp index 633ab1133a..2f5b371c65 100644 --- a/src/xrpld/app/tx/detail/CashCheck.cpp +++ b/src/libxrpl/tx/transactors/Check/CashCheck.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -8,6 +5,8 @@ #include #include #include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/CreateCheck.cpp b/src/libxrpl/tx/transactors/Check/CreateCheck.cpp similarity index 99% rename from src/xrpld/app/tx/detail/CreateCheck.cpp rename to src/libxrpl/tx/transactors/Check/CreateCheck.cpp index 7511f2df2e..8f3a0dbdb0 100644 --- a/src/xrpld/app/tx/detail/CreateCheck.cpp +++ b/src/libxrpl/tx/transactors/Check/CreateCheck.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Clawback.cpp b/src/libxrpl/tx/transactors/Clawback.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Clawback.cpp rename to src/libxrpl/tx/transactors/Clawback.cpp index ad4a2f24d0..4fddd26a67 100644 --- a/src/xrpld/app/tx/detail/Clawback.cpp +++ b/src/libxrpl/tx/transactors/Clawback.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CreateTicket.cpp b/src/libxrpl/tx/transactors/CreateTicket.cpp similarity index 98% rename from src/xrpld/app/tx/detail/CreateTicket.cpp rename to src/libxrpl/tx/transactors/CreateTicket.cpp index 1ce067087c..de61e58b41 100644 --- a/src/xrpld/app/tx/detail/CreateTicket.cpp +++ b/src/libxrpl/tx/transactors/CreateTicket.cpp @@ -1,10 +1,9 @@ -#include - #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Credentials.cpp b/src/libxrpl/tx/transactors/Credentials.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Credentials.cpp rename to src/libxrpl/tx/transactors/Credentials.cpp index fc3019308a..2dccdf3c15 100644 --- a/src/xrpld/app/tx/detail/Credentials.cpp +++ b/src/libxrpl/tx/transactors/Credentials.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -7,6 +5,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/DID.cpp b/src/libxrpl/tx/transactors/DID.cpp similarity index 99% rename from src/xrpld/app/tx/detail/DID.cpp rename to src/libxrpl/tx/transactors/DID.cpp index 7219dcf60e..216be7ba75 100644 --- a/src/xrpld/app/tx/detail/DID.cpp +++ b/src/libxrpl/tx/transactors/DID.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DelegateSet.cpp b/src/libxrpl/tx/transactors/Delegate/DelegateSet.cpp similarity index 98% rename from src/xrpld/app/tx/detail/DelegateSet.cpp rename to src/libxrpl/tx/transactors/Delegate/DelegateSet.cpp index 8dba3ef72e..b2020a60b0 100644 --- a/src/xrpld/app/tx/detail/DelegateSet.cpp +++ b/src/libxrpl/tx/transactors/Delegate/DelegateSet.cpp @@ -1,10 +1,9 @@ -#include - #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/detail/DelegateUtils.cpp b/src/libxrpl/tx/transactors/Delegate/DelegateUtils.cpp similarity index 95% rename from src/xrpld/app/misc/detail/DelegateUtils.cpp rename to src/libxrpl/tx/transactors/Delegate/DelegateUtils.cpp index 74ec55cdee..eceb73503f 100644 --- a/src/xrpld/app/misc/detail/DelegateUtils.cpp +++ b/src/libxrpl/tx/transactors/Delegate/DelegateUtils.cpp @@ -1,6 +1,5 @@ -#include - #include +#include namespace xrpl { NotTEC diff --git a/src/xrpld/app/tx/detail/DeleteAccount.cpp b/src/libxrpl/tx/transactors/DeleteAccount.cpp similarity index 97% rename from src/xrpld/app/tx/detail/DeleteAccount.cpp rename to src/libxrpl/tx/transactors/DeleteAccount.cpp index 5d2d2e85a7..9b05bb3aa5 100644 --- a/src/xrpld/app/tx/detail/DeleteAccount.cpp +++ b/src/libxrpl/tx/transactors/DeleteAccount.cpp @@ -1,11 +1,3 @@ -#include -#include -#include -#include -#include -#include -#include - #include #include #include @@ -16,6 +8,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DeleteOracle.cpp b/src/libxrpl/tx/transactors/DeleteOracle.cpp similarity index 97% rename from src/xrpld/app/tx/detail/DeleteOracle.cpp rename to src/libxrpl/tx/transactors/DeleteOracle.cpp index 9b62bffb5f..8f8a29f8a2 100644 --- a/src/xrpld/app/tx/detail/DeleteOracle.cpp +++ b/src/libxrpl/tx/transactors/DeleteOracle.cpp @@ -1,9 +1,8 @@ -#include - #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/DepositPreauth.cpp b/src/libxrpl/tx/transactors/DepositPreauth.cpp similarity index 99% rename from src/xrpld/app/tx/detail/DepositPreauth.cpp rename to src/libxrpl/tx/transactors/DepositPreauth.cpp index 023833212c..a72628b5be 100644 --- a/src/xrpld/app/tx/detail/DepositPreauth.cpp +++ b/src/libxrpl/tx/transactors/DepositPreauth.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/Escrow.cpp b/src/libxrpl/tx/transactors/Escrow.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Escrow.cpp rename to src/libxrpl/tx/transactors/Escrow.cpp index 2014dcc926..aff6d07cc3 100644 --- a/src/xrpld/app/tx/detail/Escrow.cpp +++ b/src/libxrpl/tx/transactors/Escrow.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -14,6 +11,8 @@ #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LedgerStateFix.cpp b/src/libxrpl/tx/transactors/LedgerStateFix.cpp similarity index 94% rename from src/xrpld/app/tx/detail/LedgerStateFix.cpp rename to src/libxrpl/tx/transactors/LedgerStateFix.cpp index 43001e2fbf..28028b6f2b 100644 --- a/src/xrpld/app/tx/detail/LedgerStateFix.cpp +++ b/src/libxrpl/tx/transactors/LedgerStateFix.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/detail/LendingHelpers.cpp b/src/libxrpl/tx/transactors/Lending/LendingHelpers.cpp similarity index 99% rename from src/xrpld/app/misc/detail/LendingHelpers.cpp rename to src/libxrpl/tx/transactors/Lending/LendingHelpers.cpp index c0fd4c36d8..13bb321974 100644 --- a/src/xrpld/app/misc/detail/LendingHelpers.cpp +++ b/src/libxrpl/tx/transactors/Lending/LendingHelpers.cpp @@ -1,6 +1,6 @@ -#include +#include // DO NOT REMOVE forces header file include to sort first -#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverClawback.cpp b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverClawback.cpp similarity index 98% rename from src/xrpld/app/tx/detail/LoanBrokerCoverClawback.cpp rename to src/libxrpl/tx/transactors/Lending/LoanBrokerCoverClawback.cpp index 7038752f8b..819ae54895 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverClawback.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverClawback.cpp @@ -1,8 +1,7 @@ -#include +#include // -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.cpp b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.cpp similarity index 96% rename from src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.cpp rename to src/libxrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.cpp index 3dd513414e..d112959fea 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverDeposit.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverDeposit.cpp @@ -1,8 +1,7 @@ -#include +#include // -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.cpp b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.cpp similarity index 97% rename from src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.cpp rename to src/libxrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.cpp index f2c8f28a84..43ff3659ef 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerCoverWithdraw.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanBrokerCoverWithdraw.cpp @@ -1,10 +1,9 @@ -#include +#include // -#include -#include - #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerDelete.cpp b/src/libxrpl/tx/transactors/Lending/LoanBrokerDelete.cpp similarity index 97% rename from src/xrpld/app/tx/detail/LoanBrokerDelete.cpp rename to src/libxrpl/tx/transactors/Lending/LoanBrokerDelete.cpp index 7c8b6c1f64..45227144fa 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerDelete.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanBrokerDelete.cpp @@ -1,8 +1,7 @@ -#include +#include // -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanBrokerSet.cpp b/src/libxrpl/tx/transactors/Lending/LoanBrokerSet.cpp similarity index 98% rename from src/xrpld/app/tx/detail/LoanBrokerSet.cpp rename to src/libxrpl/tx/transactors/Lending/LoanBrokerSet.cpp index 9553402f15..cf1cbaa610 100644 --- a/src/xrpld/app/tx/detail/LoanBrokerSet.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanBrokerSet.cpp @@ -1,8 +1,7 @@ -#include +#include // -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanDelete.cpp b/src/libxrpl/tx/transactors/Lending/LoanDelete.cpp similarity index 97% rename from src/xrpld/app/tx/detail/LoanDelete.cpp rename to src/libxrpl/tx/transactors/Lending/LoanDelete.cpp index d975834d29..fb7f0f8cd4 100644 --- a/src/xrpld/app/tx/detail/LoanDelete.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanDelete.cpp @@ -1,8 +1,7 @@ -#include +#include // -#include - #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanManage.cpp b/src/libxrpl/tx/transactors/Lending/LoanManage.cpp similarity index 99% rename from src/xrpld/app/tx/detail/LoanManage.cpp rename to src/libxrpl/tx/transactors/Lending/LoanManage.cpp index 8d0a79686c..6f524010d4 100644 --- a/src/xrpld/app/tx/detail/LoanManage.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanManage.cpp @@ -1,9 +1,8 @@ -#include +#include // -#include - #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/LoanPay.cpp b/src/libxrpl/tx/transactors/Lending/LoanPay.cpp similarity index 99% rename from src/xrpld/app/tx/detail/LoanPay.cpp rename to src/libxrpl/tx/transactors/Lending/LoanPay.cpp index 744e81d67d..089c862fbb 100644 --- a/src/xrpld/app/tx/detail/LoanPay.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanPay.cpp @@ -1,12 +1,11 @@ -#include +#include // -#include -#include - #include #include #include #include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/LoanSet.cpp b/src/libxrpl/tx/transactors/Lending/LoanSet.cpp similarity index 99% rename from src/xrpld/app/tx/detail/LoanSet.cpp rename to src/libxrpl/tx/transactors/Lending/LoanSet.cpp index b7105f5df8..06209d9354 100644 --- a/src/xrpld/app/tx/detail/LoanSet.cpp +++ b/src/libxrpl/tx/transactors/Lending/LoanSet.cpp @@ -1,9 +1,8 @@ -#include +#include // -#include - #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp b/src/libxrpl/tx/transactors/MPT/MPTokenAuthorize.cpp similarity index 98% rename from src/xrpld/app/tx/detail/MPTokenAuthorize.cpp rename to src/libxrpl/tx/transactors/MPT/MPTokenAuthorize.cpp index 1eb9a0359a..75d51f39a5 100644 --- a/src/xrpld/app/tx/detail/MPTokenAuthorize.cpp +++ b/src/libxrpl/tx/transactors/MPT/MPTokenAuthorize.cpp @@ -1,9 +1,8 @@ -#include - #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceCreate.cpp similarity index 98% rename from src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp rename to src/libxrpl/tx/transactors/MPT/MPTokenIssuanceCreate.cpp index 9a9dc6a11c..b135113499 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceCreate.cpp +++ b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceCreate.cpp @@ -1,8 +1,7 @@ -#include - #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.cpp similarity index 96% rename from src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp rename to src/libxrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.cpp index cec06c5494..acdd004bae 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceDestroy.cpp +++ b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceDestroy.cpp @@ -1,8 +1,7 @@ -#include - #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceSet.cpp similarity index 98% rename from src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp rename to src/libxrpl/tx/transactors/MPT/MPTokenIssuanceSet.cpp index cf3b15ed78..5bad3906a0 100644 --- a/src/xrpld/app/tx/detail/MPTokenIssuanceSet.cpp +++ b/src/libxrpl/tx/transactors/MPT/MPTokenIssuanceSet.cpp @@ -1,9 +1,8 @@ -#include -#include - #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenAcceptOffer.cpp similarity index 99% rename from src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenAcceptOffer.cpp index 349dc2c1ea..57f20fe124 100644 --- a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenAcceptOffer.cpp @@ -1,10 +1,9 @@ -#include -#include - #include #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenBurn.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenBurn.cpp similarity index 96% rename from src/xrpld/app/tx/detail/NFTokenBurn.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenBurn.cpp index a6146dcc4e..3aee6e26b3 100644 --- a/src/xrpld/app/tx/detail/NFTokenBurn.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenBurn.cpp @@ -1,9 +1,8 @@ -#include -#include - #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenCancelOffer.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenCancelOffer.cpp similarity index 95% rename from src/xrpld/app/tx/detail/NFTokenCancelOffer.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenCancelOffer.cpp index f691a1b816..24f2b8687a 100644 --- a/src/xrpld/app/tx/detail/NFTokenCancelOffer.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenCancelOffer.cpp @@ -1,9 +1,8 @@ -#include -#include - #include #include #include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenCreateOffer.cpp similarity index 94% rename from src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenCreateOffer.cpp index fdf2444ebc..ecf106baaf 100644 --- a/src/xrpld/app/tx/detail/NFTokenCreateOffer.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenCreateOffer.cpp @@ -1,9 +1,8 @@ -#include -#include - #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenMint.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenMint.cpp similarity index 99% rename from src/xrpld/app/tx/detail/NFTokenMint.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenMint.cpp index b00001e8fc..c03e351b0e 100644 --- a/src/xrpld/app/tx/detail/NFTokenMint.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenMint.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/NFTokenModify.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenModify.cpp similarity index 93% rename from src/xrpld/app/tx/detail/NFTokenModify.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenModify.cpp index 15be2d196a..316bcb0f27 100644 --- a/src/xrpld/app/tx/detail/NFTokenModify.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenModify.cpp @@ -1,8 +1,7 @@ -#include -#include - #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/NFTokenUtils.cpp b/src/libxrpl/tx/transactors/NFT/NFTokenUtils.cpp similarity index 99% rename from src/xrpld/app/tx/detail/NFTokenUtils.cpp rename to src/libxrpl/tx/transactors/NFT/NFTokenUtils.cpp index 5581182204..638ee99e36 100644 --- a/src/xrpld/app/tx/detail/NFTokenUtils.cpp +++ b/src/libxrpl/tx/transactors/NFT/NFTokenUtils.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -7,6 +5,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/tx/detail/CancelOffer.cpp b/src/libxrpl/tx/transactors/Offer/CancelOffer.cpp similarity index 96% rename from src/xrpld/app/tx/detail/CancelOffer.cpp rename to src/libxrpl/tx/transactors/Offer/CancelOffer.cpp index 3b690cb730..3e5d2441e1 100644 --- a/src/xrpld/app/tx/detail/CancelOffer.cpp +++ b/src/libxrpl/tx/transactors/Offer/CancelOffer.cpp @@ -1,8 +1,7 @@ -#include - #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/CreateOffer.cpp b/src/libxrpl/tx/transactors/Offer/CreateOffer.cpp similarity index 99% rename from src/xrpld/app/tx/detail/CreateOffer.cpp rename to src/libxrpl/tx/transactors/Offer/CreateOffer.cpp index d40109f571..4b820014af 100644 --- a/src/xrpld/app/tx/detail/CreateOffer.cpp +++ b/src/libxrpl/tx/transactors/Offer/CreateOffer.cpp @@ -1,7 +1,3 @@ -#include -#include -#include - #include #include #include @@ -11,6 +7,9 @@ #include #include #include +#include +#include +#include namespace xrpl { TxConsequences diff --git a/src/xrpld/app/tx/detail/PayChan.cpp b/src/libxrpl/tx/transactors/PayChan.cpp similarity index 99% rename from src/xrpld/app/tx/detail/PayChan.cpp rename to src/libxrpl/tx/transactors/PayChan.cpp index 860784ecba..168b89a0f8 100644 --- a/src/xrpld/app/tx/detail/PayChan.cpp +++ b/src/libxrpl/tx/transactors/PayChan.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -12,6 +10,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/Payment.cpp b/src/libxrpl/tx/transactors/Payment.cpp similarity index 99% rename from src/xrpld/app/tx/detail/Payment.cpp rename to src/libxrpl/tx/transactors/Payment.cpp index 19b2d8acc2..68a81e0d81 100644 --- a/src/xrpld/app/tx/detail/Payment.cpp +++ b/src/libxrpl/tx/transactors/Payment.cpp @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include #include #include @@ -10,6 +5,10 @@ #include #include #include +#include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/PermissionedDEXHelpers.cpp b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDEXHelpers.cpp similarity index 97% rename from src/xrpld/app/misc/PermissionedDEXHelpers.cpp rename to src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDEXHelpers.cpp index f88c2ab9d4..891e18ef69 100644 --- a/src/xrpld/app/misc/PermissionedDEXHelpers.cpp +++ b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDEXHelpers.cpp @@ -1,6 +1,5 @@ -#include - #include +#include namespace xrpl { namespace permissioned_dex { diff --git a/src/xrpld/app/tx/detail/PermissionedDomainDelete.cpp b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.cpp similarity index 95% rename from src/xrpld/app/tx/detail/PermissionedDomainDelete.cpp rename to src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.cpp index f979637e27..1d54405688 100644 --- a/src/xrpld/app/tx/detail/PermissionedDomainDelete.cpp +++ b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainDelete.cpp @@ -1,7 +1,6 @@ -#include - #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/PermissionedDomainSet.cpp b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.cpp similarity index 98% rename from src/xrpld/app/tx/detail/PermissionedDomainSet.cpp rename to src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.cpp index 19f68426d1..60400f480a 100644 --- a/src/xrpld/app/tx/detail/PermissionedDomainSet.cpp +++ b/src/libxrpl/tx/transactors/PermissionedDomain/PermissionedDomainSet.cpp @@ -1,9 +1,8 @@ -#include - #include #include #include #include +#include #include diff --git a/src/xrpld/app/tx/detail/SetAccount.cpp b/src/libxrpl/tx/transactors/SetAccount.cpp similarity index 99% rename from src/xrpld/app/tx/detail/SetAccount.cpp rename to src/libxrpl/tx/transactors/SetAccount.cpp index 41804c9211..fad6d1e318 100644 --- a/src/xrpld/app/tx/detail/SetAccount.cpp +++ b/src/libxrpl/tx/transactors/SetAccount.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -8,6 +5,8 @@ #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetOracle.cpp b/src/libxrpl/tx/transactors/SetOracle.cpp similarity index 99% rename from src/xrpld/app/tx/detail/SetOracle.cpp rename to src/libxrpl/tx/transactors/SetOracle.cpp index 73ef1c7ae2..f7ca6a7563 100644 --- a/src/xrpld/app/tx/detail/SetOracle.cpp +++ b/src/libxrpl/tx/transactors/SetOracle.cpp @@ -1,11 +1,10 @@ -#include - #include #include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetRegularKey.cpp b/src/libxrpl/tx/transactors/SetRegularKey.cpp similarity index 97% rename from src/xrpld/app/tx/detail/SetRegularKey.cpp rename to src/libxrpl/tx/transactors/SetRegularKey.cpp index a7f2acfbfe..0e68406f0d 100644 --- a/src/xrpld/app/tx/detail/SetRegularKey.cpp +++ b/src/libxrpl/tx/transactors/SetRegularKey.cpp @@ -1,8 +1,7 @@ -#include - #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/SetSignerList.cpp b/src/libxrpl/tx/transactors/SetSignerList.cpp similarity index 99% rename from src/xrpld/app/tx/detail/SetSignerList.cpp rename to src/libxrpl/tx/transactors/SetSignerList.cpp index f6a65d2711..8d736391c0 100644 --- a/src/xrpld/app/tx/detail/SetSignerList.cpp +++ b/src/libxrpl/tx/transactors/SetSignerList.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -9,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/app/tx/detail/SetTrust.cpp b/src/libxrpl/tx/transactors/SetTrust.cpp similarity index 99% rename from src/xrpld/app/tx/detail/SetTrust.cpp rename to src/libxrpl/tx/transactors/SetTrust.cpp index ada6524008..2d1e94b967 100644 --- a/src/xrpld/app/tx/detail/SetTrust.cpp +++ b/src/libxrpl/tx/transactors/SetTrust.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -9,6 +6,8 @@ #include #include #include +#include +#include namespace { diff --git a/src/xrpld/app/tx/detail/VaultClawback.cpp b/src/libxrpl/tx/transactors/Vault/VaultClawback.cpp similarity index 99% rename from src/xrpld/app/tx/detail/VaultClawback.cpp rename to src/libxrpl/tx/transactors/Vault/VaultClawback.cpp index 5aa63fac1a..bbd68907de 100644 --- a/src/xrpld/app/tx/detail/VaultClawback.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultClawback.cpp @@ -1,5 +1,3 @@ -#include -// #include #include #include @@ -9,6 +7,8 @@ #include #include #include +#include +#include #include diff --git a/src/xrpld/app/tx/detail/VaultCreate.cpp b/src/libxrpl/tx/transactors/Vault/VaultCreate.cpp similarity index 97% rename from src/xrpld/app/tx/detail/VaultCreate.cpp rename to src/libxrpl/tx/transactors/Vault/VaultCreate.cpp index 6711a7e13f..c911c496ff 100644 --- a/src/xrpld/app/tx/detail/VaultCreate.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultCreate.cpp @@ -1,7 +1,3 @@ -#include -#include -#include - #include #include #include @@ -14,6 +10,9 @@ #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultDelete.cpp b/src/libxrpl/tx/transactors/Vault/VaultDelete.cpp similarity index 99% rename from src/xrpld/app/tx/detail/VaultDelete.cpp rename to src/libxrpl/tx/transactors/Vault/VaultDelete.cpp index f5c388762f..7d8bf35e5f 100644 --- a/src/xrpld/app/tx/detail/VaultDelete.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultDelete.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -7,6 +5,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultDeposit.cpp b/src/libxrpl/tx/transactors/Vault/VaultDeposit.cpp similarity index 98% rename from src/xrpld/app/tx/detail/VaultDeposit.cpp rename to src/libxrpl/tx/transactors/Vault/VaultDeposit.cpp index d5fc0e4ad6..6f6b425227 100644 --- a/src/xrpld/app/tx/detail/VaultDeposit.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultDeposit.cpp @@ -1,6 +1,3 @@ -#include -#include - #include #include #include @@ -12,6 +9,8 @@ #include #include #include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultSet.cpp b/src/libxrpl/tx/transactors/Vault/VaultSet.cpp similarity index 99% rename from src/xrpld/app/tx/detail/VaultSet.cpp rename to src/libxrpl/tx/transactors/Vault/VaultSet.cpp index c0aaf5bac6..5257a3089b 100644 --- a/src/xrpld/app/tx/detail/VaultSet.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultSet.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -9,6 +7,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/VaultWithdraw.cpp b/src/libxrpl/tx/transactors/Vault/VaultWithdraw.cpp similarity index 99% rename from src/xrpld/app/tx/detail/VaultWithdraw.cpp rename to src/libxrpl/tx/transactors/Vault/VaultWithdraw.cpp index 88616e34f8..4d0a3c20a5 100644 --- a/src/xrpld/app/tx/detail/VaultWithdraw.cpp +++ b/src/libxrpl/tx/transactors/Vault/VaultWithdraw.cpp @@ -1,5 +1,3 @@ -#include - #include #include #include @@ -9,6 +7,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/tx/detail/XChainBridge.cpp b/src/libxrpl/tx/transactors/XChainBridge.cpp similarity index 99% rename from src/xrpld/app/tx/detail/XChainBridge.cpp rename to src/libxrpl/tx/transactors/XChainBridge.cpp index f4abb9145b..25b0e000db 100644 --- a/src/xrpld/app/tx/detail/XChainBridge.cpp +++ b/src/libxrpl/tx/transactors/XChainBridge.cpp @@ -1,8 +1,3 @@ -#include -#include -#include -#include - #include #include #include @@ -23,6 +18,10 @@ #include #include #include +#include +#include +#include +#include #include #include diff --git a/src/test/app/AMMCalc_test.cpp b/src/test/app/AMMCalc_test.cpp index bc50f02d3d..87a73689dc 100644 --- a/src/test/app/AMMCalc_test.cpp +++ b/src/test/app/AMMCalc_test.cpp @@ -1,8 +1,7 @@ #include -#include - #include +#include #include diff --git a/src/test/app/AMMClawback_test.cpp b/src/test/app/AMMClawback_test.cpp index 65cf7f0a60..bea57c139d 100644 --- a/src/test/app/AMMClawback_test.cpp +++ b/src/test/app/AMMClawback_test.cpp @@ -2,9 +2,8 @@ #include #include -#include - #include +#include namespace xrpl { namespace test { diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 4eecb05905..421a278fd2 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -5,15 +5,15 @@ #include #include -#include -#include #include -#include -#include #include #include #include +#include +#include +#include +#include #include #include diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index 82ea2f6f70..bd6a405750 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -6,15 +6,14 @@ #include #include -#include -#include -#include -#include - #include #include #include #include +#include +#include +#include +#include #include diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 1e4b096927..1c2cba15cc 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -1,13 +1,13 @@ #include #include -#include #include #include #include #include #include +#include #include #include #include diff --git a/src/test/app/Batch_test.cpp b/src/test/app/Batch_test.cpp index a4e00f26db..3df9ba5a5a 100644 --- a/src/test/app/Batch_test.cpp +++ b/src/test/app/Batch_test.cpp @@ -3,8 +3,6 @@ #include #include -#include -#include #include #include @@ -14,6 +12,8 @@ #include #include #include +#include +#include namespace xrpl { namespace test { diff --git a/src/test/app/EscrowToken_test.cpp b/src/test/app/EscrowToken_test.cpp index 1f3b3bab70..86f8f13d90 100644 --- a/src/test/app/EscrowToken_test.cpp +++ b/src/test/app/EscrowToken_test.cpp @@ -1,7 +1,5 @@ #include -#include - #include #include #include @@ -9,6 +7,7 @@ #include #include #include +#include #include #include diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 652049270f..23c123409c 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -1,12 +1,11 @@ #include -#include - #include #include #include #include #include +#include #include #include diff --git a/src/test/app/FeeVote_test.cpp b/src/test/app/FeeVote_test.cpp index 15dd385d65..177c2a0bbe 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/app/FixNFTokenPageLinks_test.cpp b/src/test/app/FixNFTokenPageLinks_test.cpp index 88f368e9cf..c64fdaaced 100644 --- a/src/test/app/FixNFTokenPageLinks_test.cpp +++ b/src/test/app/FixNFTokenPageLinks_test.cpp @@ -1,10 +1,9 @@ #include -#include -#include - #include #include +#include +#include namespace xrpl { diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 551bd117d8..fb60cd20ad 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -1,14 +1,14 @@ #include #include -#include -#include #include #include #include #include #include +#include +#include namespace xrpl { namespace test { diff --git a/src/test/app/Invariants_test.cpp b/src/test/app/Invariants_test.cpp index 7558c951b0..d602d42883 100644 --- a/src/test/app/Invariants_test.cpp +++ b/src/test/app/Invariants_test.cpp @@ -2,9 +2,6 @@ #include #include -#include -#include - #include #include #include @@ -17,6 +14,8 @@ #include #include #include +#include +#include #include diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index eeca551f35..ddd9ebfdb4 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -3,11 +3,11 @@ #include #include -#include #include #include #include +#include #include #include diff --git a/src/test/app/LendingHelpers_test.cpp b/src/test/app/LendingHelpers_test.cpp index 58e4c5aaa4..e06d8ccbd1 100644 --- a/src/test/app/LendingHelpers_test.cpp +++ b/src/test/app/LendingHelpers_test.cpp @@ -5,13 +5,12 @@ #include #include -#include -#include -#include -#include - #include #include +#include +#include +#include +#include #include #include diff --git a/src/test/app/LoadFeeTrack_test.cpp b/src/test/app/LoadFeeTrack_test.cpp index 61174fc9e9..fed76288ef 100644 --- a/src/test/app/LoadFeeTrack_test.cpp +++ b/src/test/app/LoadFeeTrack_test.cpp @@ -1,8 +1,8 @@ -#include #include #include #include +#include namespace xrpl { diff --git a/src/test/app/LoanBroker_test.cpp b/src/test/app/LoanBroker_test.cpp index 58052e3fb1..b480e9535a 100644 --- a/src/test/app/LoanBroker_test.cpp +++ b/src/test/app/LoanBroker_test.cpp @@ -1,8 +1,7 @@ #include -#include - #include +#include namespace xrpl { namespace test { diff --git a/src/test/app/Loan_test.cpp b/src/test/app/Loan_test.cpp index 5deb1f179c..86ae41a2f3 100644 --- a/src/test/app/Loan_test.cpp +++ b/src/test/app/Loan_test.cpp @@ -3,14 +3,12 @@ #include #include -#include -#include -#include -#include - #include #include -// cspell: words LOANTODO +#include +#include +#include +#include #include diff --git a/src/test/app/NFTokenAuth_test.cpp b/src/test/app/NFTokenAuth_test.cpp index 1e7afc9bb0..899aea7cd5 100644 --- a/src/test/app/NFTokenAuth_test.cpp +++ b/src/test/app/NFTokenAuth_test.cpp @@ -1,6 +1,6 @@ #include -#include +#include namespace xrpl { diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index 915bb6ec79..7d6d07936d 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -1,9 +1,8 @@ #include -#include - #include #include +#include #include diff --git a/src/test/app/NFTokenDir_test.cpp b/src/test/app/NFTokenDir_test.cpp index 65bd97ec32..d6e2dab430 100644 --- a/src/test/app/NFTokenDir_test.cpp +++ b/src/test/app/NFTokenDir_test.cpp @@ -1,10 +1,9 @@ #include -#include - #include #include #include +#include #include diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index 1b9ce82d4a..7efbfbbd4c 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -1,10 +1,9 @@ #include -#include - #include #include #include +#include #include diff --git a/src/test/app/OfferStream_test.cpp b/src/test/app/OfferStream_test.cpp index 218653a5d4..becb190513 100644 --- a/src/test/app/OfferStream_test.cpp +++ b/src/test/app/OfferStream_test.cpp @@ -1,6 +1,5 @@ -#include - #include +#include namespace xrpl { diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index 9b534d9284..93cc8caf47 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -1,9 +1,6 @@ #include #include -#include -#include -#include #include #include @@ -11,6 +8,9 @@ #include #include #include +#include +#include +#include #include diff --git a/src/test/app/PermissionedDEX_test.cpp b/src/test/app/PermissionedDEX_test.cpp index 7a55866780..2129d2c2c4 100644 --- a/src/test/app/PermissionedDEX_test.cpp +++ b/src/test/app/PermissionedDEX_test.cpp @@ -2,8 +2,6 @@ #include #include -#include - #include #include #include @@ -18,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/src/test/app/PermissionedDomains_test.cpp b/src/test/app/PermissionedDomains_test.cpp index 8485202144..ec969a105c 100644 --- a/src/test/app/PermissionedDomains_test.cpp +++ b/src/test/app/PermissionedDomains_test.cpp @@ -1,9 +1,8 @@ #include -#include - #include #include +#include #include #include diff --git a/src/test/app/PseudoTx_test.cpp b/src/test/app/PseudoTx_test.cpp index 29e13888c3..aa16df8e9c 100644 --- a/src/test/app/PseudoTx_test.cpp +++ b/src/test/app/PseudoTx_test.cpp @@ -1,8 +1,7 @@ #include -#include - #include +#include #include #include diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index 052b334ef5..a4d387dec1 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -3,13 +3,13 @@ #include #include -#include #include #include #include #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index 1f626ad477..b6b44625cc 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -1,16 +1,15 @@ #include #include -#include -#include -#include -#include - #include #include #include #include #include +#include +#include +#include +#include namespace xrpl { namespace test { diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 13feceb74e..44b0c1ca3e 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -6,13 +6,13 @@ #include #include -#include #include -#include #include #include #include +#include +#include namespace xrpl { diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index eb684175de..44074baf03 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -2,10 +2,9 @@ #include -#include - #include #include +#include namespace xrpl { diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 9e77f158a3..b8599744bf 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -4,10 +4,10 @@ #include #include #include -#include #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index f920858ea5..9049b5400c 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -1,13 +1,12 @@ #include #include -#include -#include - #include #include #include #include +#include +#include namespace xrpl { namespace test { diff --git a/src/test/jtx/impl/ledgerStateFixes.cpp b/src/test/jtx/impl/ledgerStateFixes.cpp index f1e6b6eda1..04860a5e3a 100644 --- a/src/test/jtx/impl/ledgerStateFixes.cpp +++ b/src/test/jtx/impl/ledgerStateFixes.cpp @@ -1,9 +1,8 @@ #include -#include - #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/jtx/impl/token.cpp b/src/test/jtx/impl/token.cpp index 172bd75bc7..613e0710d4 100644 --- a/src/test/jtx/impl/token.cpp +++ b/src/test/jtx/impl/token.cpp @@ -1,10 +1,9 @@ #include #include -#include - #include #include +#include namespace xrpl { namespace test { diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index ab9fcf084e..664e96bbef 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -2,13 +2,12 @@ #include #include -#include - #include #include #include #include #include +#include #include diff --git a/src/test/rpc/AccountSet_test.cpp b/src/test/rpc/AccountSet_test.cpp index 2e238773f9..03fe4e3ede 100644 --- a/src/test/rpc/AccountSet_test.cpp +++ b/src/test/rpc/AccountSet_test.cpp @@ -1,12 +1,11 @@ #include -#include - #include #include #include #include #include +#include namespace xrpl { diff --git a/src/test/rpc/Feature_test.cpp b/src/test/rpc/Feature_test.cpp index c12988816e..c9afb38d3b 100644 --- a/src/test/rpc/Feature_test.cpp +++ b/src/test/rpc/Feature_test.cpp @@ -1,7 +1,6 @@ #include -#include - +#include #include #include diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index f0329748e1..b82719261b 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -1,7 +1,6 @@ #include #include -#include #include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index a66badf54b..68b869cbfc 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -5,8 +5,6 @@ #include #include -#include - #include #include #include @@ -15,6 +13,7 @@ #include #include + namespace xrpl { namespace test { diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 99f664f42e..f6c5690856 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -3,7 +3,6 @@ #include #include -#include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index 5a91ad4b03..d84b750c87 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -4,12 +4,12 @@ #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp index ad581585b1..3ed55a893f 100644 --- a/src/xrpld/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include #include @@ -21,9 +19,11 @@ #include #include #include +#include #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp index d75e4dd22e..566dce4720 100644 --- a/src/xrpld/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -878,18 +878,12 @@ Ledger::updateSkipList() bool Ledger::isFlagLedger() const { - return header_.seq % FLAG_LEDGER_INTERVAL == 0; + return ::xrpl::isFlagLedger(header_.seq); } bool Ledger::isVotingLedger() const { - return (header_.seq + 1) % FLAG_LEDGER_INTERVAL == 0; -} - -bool -isFlagLedger(LedgerIndex seq) -{ - return seq % FLAG_LEDGER_INTERVAL == 0; + return ::xrpl::isVotingLedger(header_.seq + 1); } static bool diff --git a/src/xrpld/app/ledger/Ledger.h b/src/xrpld/app/ledger/Ledger.h index cbfbc0030f..cfa82074a1 100644 --- a/src/xrpld/app/ledger/Ledger.h +++ b/src/xrpld/app/ledger/Ledger.h @@ -391,11 +391,6 @@ private: /** A ledger wrapped in a CachedView. */ using CachedLedger = CachedView; -std::uint32_t constexpr FLAG_LEDGER_INTERVAL = 256; -/** Returns true if the given ledgerIndex is a flag ledgerIndex */ -bool -isFlagLedger(LedgerIndex seq); - //------------------------------------------------------------------------------ // // API diff --git a/src/xrpld/app/ledger/OrderBookDBImpl.cpp b/src/xrpld/app/ledger/OrderBookDBImpl.cpp index 62c03fb7ca..5c9d46edb1 100644 --- a/src/xrpld/app/ledger/OrderBookDBImpl.cpp +++ b/src/xrpld/app/ledger/OrderBookDBImpl.cpp @@ -1,12 +1,11 @@ #include #include -#include -#include #include #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/ledger/detail/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp index 8321190add..688363c102 100644 --- a/src/xrpld/app/ledger/detail/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -4,9 +4,9 @@ #include #include #include -#include #include +#include namespace xrpl { diff --git a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp index f54c79f9c0..69ab17ba0e 100644 --- a/src/xrpld/app/ledger/detail/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -1,10 +1,10 @@ #include #include #include -#include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/ledger/detail/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp index 5538ebcb96..c6bd3963b4 100644 --- a/src/xrpld/app/ledger/detail/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -5,8 +5,6 @@ #include #include #include -#include -#include #include #include #include @@ -23,12 +21,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/ledger/detail/OpenLedger.cpp b/src/xrpld/app/ledger/detail/OpenLedger.cpp index d621285619..bc7223f6d9 100644 --- a/src/xrpld/app/ledger/detail/OpenLedger.cpp +++ b/src/xrpld/app/ledger/detail/OpenLedger.cpp @@ -1,13 +1,13 @@ #include #include #include -#include #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp index f53ca9e36b..292ee0b462 100644 --- a/src/xrpld/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -15,8 +15,6 @@ #include #include #include -#include -#include #include #include #include @@ -25,7 +23,7 @@ #include #include #include -#include +#include #include #include #include @@ -42,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +49,9 @@ #include #include #include +#include #include +#include #include #include diff --git a/src/xrpld/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp index 5e3b572e1d..d9da8e5159 100644 --- a/src/xrpld/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -1,9 +1,9 @@ #include #include -#include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/AmendmentTableImpl.h b/src/xrpld/app/misc/AmendmentTableImpl.h new file mode 100644 index 0000000000..fe7c067d5a --- /dev/null +++ b/src/xrpld/app/misc/AmendmentTableImpl.h @@ -0,0 +1,18 @@ +#pragma once + +#include + +#include + +namespace xrpl { + +std::unique_ptr +make_AmendmentTable( + ServiceRegistry& registry, + std::chrono::seconds majorityTime, + std::vector const& supported, + Section const& enabled, + Section const& vetoed, + beast::Journal journal); + +} // namespace xrpl diff --git a/src/xrpld/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp index 44543e8910..e26a339d94 100644 --- a/src/xrpld/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -10,9 +10,7 @@ #include #include #include -#include #include -#include #include #include #include @@ -20,9 +18,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -42,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +51,8 @@ #include #include #include +#include +#include #include #include diff --git a/src/xrpld/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h index b50ff1a0b5..a779741223 100644 --- a/src/xrpld/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -1,13 +1,12 @@ #pragma once -#include - #include #include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/misc/detail/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp index 767a3d87f9..f7d662368e 100644 --- a/src/xrpld/app/misc/detail/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -1,7 +1,5 @@ -#include -#include - #include +#include #include #include #include diff --git a/src/xrpld/app/misc/detail/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp index d45c49c3c4..04fb762ef2 100644 --- a/src/xrpld/app/misc/detail/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/app/misc/detail/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp index 61741b73f0..e109e16834 100644 --- a/src/xrpld/app/misc/detail/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -1,12 +1,12 @@ #include #include #include -#include #include #include #include #include +#include #include #include diff --git a/src/xrpld/app/paths/AMMLiquidity.h b/src/xrpld/app/paths/AMMLiquidity.h index 441c3b6e3d..5c3ff2a8e6 100644 --- a/src/xrpld/app/paths/AMMLiquidity.h +++ b/src/xrpld/app/paths/AMMLiquidity.h @@ -1,13 +1,12 @@ #pragma once -#include -#include -#include - #include #include #include #include +#include +#include +#include namespace xrpl { diff --git a/src/xrpld/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp index 53a4e03752..02f2f1313b 100644 --- a/src/xrpld/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -1,9 +1,7 @@ #include -#include #include #include #include -#include #include #include #include @@ -13,7 +11,9 @@ #include #include #include +#include #include +#include #include #include diff --git a/src/xrpld/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp index ea4fa2013a..980803f305 100644 --- a/src/xrpld/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -10,6 +9,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/app/paths/detail/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp index b9c8aa4e67..a3c559940f 100644 --- a/src/xrpld/app/paths/detail/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -1,9 +1,5 @@ -#include #include #include -#include -#include -#include #include #include @@ -14,6 +10,10 @@ #include #include #include +#include +#include +#include +#include #include diff --git a/src/xrpld/app/paths/detail/DirectStep.cpp b/src/xrpld/app/paths/detail/DirectStep.cpp index 806204bae2..e4617708fc 100644 --- a/src/xrpld/app/paths/detail/DirectStep.cpp +++ b/src/xrpld/app/paths/detail/DirectStep.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/app/paths/detail/PaySteps.cpp b/src/xrpld/app/paths/detail/PaySteps.cpp index e891fb6321..6f8d1e93ac 100644 --- a/src/xrpld/app/paths/detail/PaySteps.cpp +++ b/src/xrpld/app/paths/detail/PaySteps.cpp @@ -1,10 +1,9 @@ -#include - #include #include #include #include #include +#include #include diff --git a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp index 60f95a9b0b..1f1b908e64 100644 --- a/src/xrpld/app/paths/detail/XRPEndpointStep.cpp +++ b/src/xrpld/app/paths/detail/XRPEndpointStep.cpp @@ -1,6 +1,4 @@ -#include #include -#include #include #include @@ -9,6 +7,8 @@ #include #include #include +#include +#include #include diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index ca7364c756..91d64e26d4 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -3,10 +3,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -19,7 +17,9 @@ #include #include #include +#include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/LegacyPathFind.cpp b/src/xrpld/rpc/detail/LegacyPathFind.cpp index 9d9b7e138c..b0fa07d676 100644 --- a/src/xrpld/rpc/detail/LegacyPathFind.cpp +++ b/src/xrpld/rpc/detail/LegacyPathFind.cpp @@ -1,10 +1,10 @@ #include -#include #include #include #include #include +#include namespace xrpl { namespace RPC { diff --git a/src/xrpld/rpc/detail/RPCHelpers.cpp b/src/xrpld/rpc/detail/RPCHelpers.cpp index 4a0339b763..3edc7de97e 100644 --- a/src/xrpld/rpc/detail/RPCHelpers.cpp +++ b/src/xrpld/rpc/detail/RPCHelpers.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/src/xrpld/rpc/detail/TransactionSign.cpp b/src/xrpld/rpc/detail/TransactionSign.cpp index 6f7d80b2a6..123123f36b 100644 --- a/src/xrpld/rpc/detail/TransactionSign.cpp +++ b/src/xrpld/rpc/detail/TransactionSign.cpp @@ -4,8 +4,6 @@ #include #include #include -#include // Validity::Valid -#include #include #include #include @@ -20,6 +18,8 @@ #include #include #include +#include // Validity::Valid +#include #include #include diff --git a/src/xrpld/rpc/detail/TransactionSign.h b/src/xrpld/rpc/detail/TransactionSign.h index 8d064d65d5..a12f60617d 100644 --- a/src/xrpld/rpc/detail/TransactionSign.h +++ b/src/xrpld/rpc/detail/TransactionSign.h @@ -1,9 +1,9 @@ #pragma once -#include #include #include +#include #include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/AMMInfo.cpp b/src/xrpld/rpc/handlers/AMMInfo.cpp index 74e6f8944d..e4234096ee 100644 --- a/src/xrpld/rpc/handlers/AMMInfo.cpp +++ b/src/xrpld/rpc/handlers/AMMInfo.cpp @@ -1,5 +1,4 @@ #include -#include #include #include @@ -7,6 +6,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/rpc/handlers/AccountObjects.cpp b/src/xrpld/rpc/handlers/AccountObjects.cpp index d9906efd70..7ef30255bc 100644 --- a/src/xrpld/rpc/handlers/AccountObjects.cpp +++ b/src/xrpld/rpc/handlers/AccountObjects.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -12,6 +11,7 @@ #include #include #include +#include #include diff --git a/src/xrpld/rpc/handlers/Feature1.cpp b/src/xrpld/rpc/handlers/Feature1.cpp index 6f9d440185..bd1e501506 100644 --- a/src/xrpld/rpc/handlers/Feature1.cpp +++ b/src/xrpld/rpc/handlers/Feature1.cpp @@ -1,8 +1,8 @@ #include #include -#include #include +#include #include #include #include diff --git a/src/xrpld/rpc/handlers/LedgerHandler.cpp b/src/xrpld/rpc/handlers/LedgerHandler.cpp index 343d21e3f5..d0572f42b2 100644 --- a/src/xrpld/rpc/handlers/LedgerHandler.cpp +++ b/src/xrpld/rpc/handlers/LedgerHandler.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -9,6 +8,7 @@ #include #include #include +#include namespace xrpl { namespace RPC { diff --git a/src/xrpld/rpc/handlers/NoRippleCheck.cpp b/src/xrpld/rpc/handlers/NoRippleCheck.cpp index 23ce82ef72..61e3bd61bd 100644 --- a/src/xrpld/rpc/handlers/NoRippleCheck.cpp +++ b/src/xrpld/rpc/handlers/NoRippleCheck.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -11,6 +10,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/Peers.cpp b/src/xrpld/rpc/handlers/Peers.cpp index 5232070b2b..b343c4050b 100644 --- a/src/xrpld/rpc/handlers/Peers.cpp +++ b/src/xrpld/rpc/handlers/Peers.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -7,6 +6,7 @@ #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/Simulate.cpp b/src/xrpld/rpc/handlers/Simulate.cpp index 120dbfa2e5..c35322a35e 100644 --- a/src/xrpld/rpc/handlers/Simulate.cpp +++ b/src/xrpld/rpc/handlers/Simulate.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include namespace xrpl { diff --git a/src/xrpld/rpc/handlers/Submit.cpp b/src/xrpld/rpc/handlers/Submit.cpp index 5b29d35f50..2911d0ca45 100644 --- a/src/xrpld/rpc/handlers/Submit.cpp +++ b/src/xrpld/rpc/handlers/Submit.cpp @@ -1,12 +1,12 @@ #include #include -#include #include #include #include #include #include +#include namespace xrpl {