diff --git a/.clang-format b/.clang-format index ba409869bd3..0b1b4efea07 100644 --- a/.clang-format +++ b/.clang-format @@ -45,9 +45,11 @@ DisableFormat: false ExperimentalAutoDetectBinPacking: false ForEachMacros: [ Q_FOREACH, BOOST_FOREACH ] IncludeCategories: - - Regex: '^<(BeastConfig)' + - Regex: '^<(test)/' Priority: 0 - - Regex: '^<(ripple)/' + - Regex: '^<(xrpld)/' + Priority: 1 + - Regex: '^<(xrpl)/' Priority: 2 - Regex: '^<(boost)/' Priority: 3 diff --git a/.codecov.yml b/.codecov.yml index 3e6f09d58ae..6df3786197f 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -33,5 +33,5 @@ slack_app: false ignore: - "src/test/" - - "src/ripple/beast/test/" - - "src/ripple/beast/unit_test/" + - "include/xrpl/beast/test/" + - "include/xrpl/beast/unit_test/" diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index de2d90d36ec..514f90fc5f5 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -6,3 +6,7 @@ e2384885f5f630c8f0ffe4bf21a169b433a16858 241b9ddde9e11beb7480600fd5ed90e1ef109b21 760f16f56835663d9286bd29294d074de26a7ba6 0eebe6a5f4246fced516d52b83ec4e7f47373edd +2189cc950c0cebb89e4e2fa3b2d8817205bf7cef +b9d007813378ad0ff45660dc07285b823c7e9855 +fe9a5365b8a52d4acc42eb27369247e6f238a4f9 +9a93577314e6a8d4b4a8368cc9d2b15a5d8303e8 diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml index 8c915ec00ff..e86b7b257a5 100644 --- a/.github/workflows/clang-format.yml +++ b/.github/workflows/clang-format.yml @@ -19,10 +19,8 @@ jobs: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add sudo apt-get update sudo apt-get install clang-format-${CLANG_VERSION} - - name: Format src/ripple - run: find src/ripple -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i - - name: Format src/test - run: find src/test -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -print0 | xargs -0 clang-format-${CLANG_VERSION} -i + - name: Format sources + run: find include src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-${CLANG_VERSION} -i {} + - name: Check for differences id: assert run: | diff --git a/BUILD.md b/BUILD.md index 60ee31d42d1..0b9ef40e61b 100644 --- a/BUILD.md +++ b/BUILD.md @@ -36,9 +36,15 @@ See [System Requirements](https://xrpl.org/system-requirements.html). Building rippled generally requires git, Python, Conan, CMake, and a C++ compiler. Some guidance on setting up such a [C++ development environment can be found here](./docs/build/environment.md). - [Python 3.7](https://www.python.org/downloads/) -- [Conan 1.55](https://conan.io/downloads.html) +- [Conan 1.60](https://conan.io/downloads.html)[^1] - [CMake 3.16](https://cmake.org/download/) +[^1]: It is possible to build with Conan 2.x, +but the instructions are significantly different, +which is why we are not recommending it yet. +Notably, the `conan profile update` command is removed in 2.x. +Profiles must be edited by hand. + `rippled` is written in the C++20 dialect and includes the `` header. The [minimum compiler versions][2] required are: @@ -67,9 +73,6 @@ Here are [sample instructions for setting up a C++ development environment on ma Windows is not recommended for production use at this time. - Additionally, 32-bit Windows development is not supported. -- Visual Studio 2022 is not yet supported. - - rippled generally requires [Boost][] 1.77, which Conan cannot build with VS 2022. - - Until rippled is updated for compatibility with later versions of Boost, Windows developers may need to use Visual Studio 2019. [Boost]: https://www.boost.org/ @@ -104,6 +107,20 @@ then you will need to choose the `libstdc++11` ABI: conan profile update settings.compiler.libcxx=libstdc++11 default ``` + +Ensure inter-operability between `boost::string_view` and `std::string_view` types: + +``` +conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_BEAST_USE_STD_STRING_VIEW"]' default +conan profile update 'env.CXXFLAGS="-DBOOST_BEAST_USE_STD_STRING_VIEW"' default +``` + +If you have other flags in the `conf.tools.build` or `env.CXXFLAGS` sections, make sure to retain the existing flags and append the new ones. You can check them with: +``` +conan profile show default +``` + + **Windows** developers may need to use the x64 native build tools. An easy way to do that is to run the shortcut "x64 Native Tools Command Prompt" for the version of Visual Studio that you have installed. @@ -144,21 +161,30 @@ It does not explicitly link the C++ standard library, which allows you to statically link it with GCC, if you want. ``` + # Conan 1.x conan export external/snappy snappy/1.1.10@ + # Conan 2.x + conan export --version 1.1.10 external/snappy ``` Export our [Conan recipe for RocksDB](./external/rocksdb). It does not override paths to dependencies when building with Visual Studio. ``` + # Conan 1.x conan export external/rocksdb rocksdb/6.29.5@ + # Conan 2.x + conan export --version 6.29.5 external/rocksdb ``` Export our [Conan recipe for SOCI](./external/soci). It patches their CMake to correctly import its dependencies. ``` + # Conan 1.x conan export external/soci soci/4.0.3@ + # Conan 2.x + conan export --version 4.0.3 external/soci ``` ### Build and Test @@ -196,13 +222,13 @@ It patches their CMake to correctly import its dependencies. generated by the first. You can pass the build type on the command line with `--settings build_type=$BUILD_TYPE` or in the profile itself, under the section `[settings]` with the key `build_type`. - + If you are using a Microsoft Visual C++ compiler, then you will need to ensure consistency between the `build_type` setting and the `compiler.runtime` setting. - + When `build_type` is `Release`, `compiler.runtime` should be `MT`. - + When `build_type` is `Debug`, `compiler.runtime` should be `MTd`. ``` diff --git a/Builds/CMake/RippledCore.cmake b/Builds/CMake/RippledCore.cmake deleted file mode 100644 index 6b7b2aae683..00000000000 --- a/Builds/CMake/RippledCore.cmake +++ /dev/null @@ -1,1212 +0,0 @@ -#[===================================================================[ - xrpl_core - core functionality, useable by some client software perhaps -#]===================================================================] - -include(target_protobuf_sources) - -file (GLOB_RECURSE rb_headers - src/ripple/beast/*.h) - -# Protocol buffers cannot participate in a unity build, -# because all the generated sources -# define a bunch of `static const` variables with the same names, -# so we just build them as a separate library. -add_library(xrpl.libpb) -target_protobuf_sources(xrpl.libpb ripple/proto - LANGUAGE cpp - IMPORT_DIRS src/ripple/proto - PROTOS src/ripple/proto/ripple.proto -) - -file(GLOB_RECURSE protos "src/ripple/proto/org/*.proto") -target_protobuf_sources(xrpl.libpb ripple/proto - LANGUAGE cpp - IMPORT_DIRS src/ripple/proto - PROTOS "${protos}" -) -target_protobuf_sources(xrpl.libpb ripple/proto - LANGUAGE grpc - IMPORT_DIRS src/ripple/proto - PROTOS "${protos}" - PLUGIN protoc-gen-grpc=$ - GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc -) - -target_compile_options(xrpl.libpb - PUBLIC - $<$:-wd4996> - $<$: - --system-header-prefix="google/protobuf" - -Wno-deprecated-dynamic-exception-spec - > - PRIVATE - $<$:-wd4065> - $<$>:-Wno-deprecated-declarations> -) - -target_link_libraries(xrpl.libpb - PUBLIC - protobuf::libprotobuf - gRPC::grpc++ -) - -add_library (xrpl_core - ${rb_headers}) ## headers added here for benefit of IDEs -if (unity) - set_target_properties(xrpl_core PROPERTIES UNITY_BUILD ON) -endif () - -add_library(libxrpl INTERFACE) -target_link_libraries(libxrpl INTERFACE xrpl_core) -add_library(xrpl::libxrpl ALIAS libxrpl) - -#[===============================[ - beast/legacy FILES: - TODO: review these sources for removal or replacement -#]===============================] -# BEGIN LIBXRPL SOURCES -target_sources (xrpl_core PRIVATE - src/ripple/beast/clock/basic_seconds_clock.cpp - src/ripple/beast/core/CurrentThreadName.cpp - src/ripple/beast/core/SemanticVersion.cpp - src/ripple/beast/insight/impl/Collector.cpp - src/ripple/beast/insight/impl/Groups.cpp - src/ripple/beast/insight/impl/Hook.cpp - src/ripple/beast/insight/impl/Metric.cpp - src/ripple/beast/insight/impl/NullCollector.cpp - src/ripple/beast/insight/impl/StatsDCollector.cpp - src/ripple/beast/net/impl/IPAddressConversion.cpp - src/ripple/beast/net/impl/IPAddressV4.cpp - src/ripple/beast/net/impl/IPAddressV6.cpp - src/ripple/beast/net/impl/IPEndpoint.cpp - src/ripple/beast/utility/src/beast_Journal.cpp - src/ripple/beast/utility/src/beast_PropertyStream.cpp) - -#[===============================[ - core sources -#]===============================] -target_sources (xrpl_core PRIVATE - #[===============================[ - main sources: - subdir: basics - #]===============================] - src/ripple/basics/impl/Archive.cpp - src/ripple/basics/impl/base64.cpp - src/ripple/basics/impl/BasicConfig.cpp - src/ripple/basics/impl/contract.cpp - src/ripple/basics/impl/CountedObject.cpp - src/ripple/basics/impl/FileUtilities.cpp - src/ripple/basics/impl/IOUAmount.cpp - src/ripple/basics/impl/Log.cpp - src/ripple/basics/impl/make_SSLContext.cpp - src/ripple/basics/impl/mulDiv.cpp - src/ripple/basics/impl/Number.cpp - src/ripple/basics/impl/partitioned_unordered_map.cpp - src/ripple/basics/impl/ResolverAsio.cpp - src/ripple/basics/impl/StringUtilities.cpp - src/ripple/basics/impl/UptimeClock.cpp - #[===============================[ - main sources: - subdir: json - #]===============================] - src/ripple/json/impl/JsonPropertyStream.cpp - src/ripple/json/impl/Object.cpp - src/ripple/json/impl/Output.cpp - src/ripple/json/impl/Writer.cpp - src/ripple/json/impl/json_reader.cpp - src/ripple/json/impl/json_value.cpp - src/ripple/json/impl/json_valueiterator.cpp - src/ripple/json/impl/json_writer.cpp - src/ripple/json/impl/to_string.cpp - #[===============================[ - main sources: - subdir: protocol - #]===============================] - src/ripple/protocol/impl/AccountID.cpp - src/ripple/protocol/impl/AMMCore.cpp - src/ripple/protocol/impl/Book.cpp - src/ripple/protocol/impl/BuildInfo.cpp - src/ripple/protocol/impl/ErrorCodes.cpp - src/ripple/protocol/impl/Feature.cpp - src/ripple/protocol/impl/Indexes.cpp - src/ripple/protocol/impl/InnerObjectFormats.cpp - src/ripple/protocol/impl/Issue.cpp - src/ripple/protocol/impl/STIssue.cpp - src/ripple/protocol/impl/Keylet.cpp - src/ripple/protocol/impl/LedgerFormats.cpp - src/ripple/protocol/impl/LedgerHeader.cpp - src/ripple/protocol/impl/PublicKey.cpp - src/ripple/protocol/impl/Quality.cpp - src/ripple/protocol/impl/QualityFunction.cpp - src/ripple/protocol/impl/RPCErr.cpp - src/ripple/protocol/impl/Rate2.cpp - src/ripple/protocol/impl/Rules.cpp - src/ripple/protocol/impl/SField.cpp - src/ripple/protocol/impl/SOTemplate.cpp - src/ripple/protocol/impl/STAccount.cpp - src/ripple/protocol/impl/STAmount.cpp - src/ripple/protocol/impl/STArray.cpp - src/ripple/protocol/impl/STBase.cpp - src/ripple/protocol/impl/STBlob.cpp - src/ripple/protocol/impl/STCurrency.cpp - src/ripple/protocol/impl/STInteger.cpp - src/ripple/protocol/impl/STLedgerEntry.cpp - src/ripple/protocol/impl/STObject.cpp - src/ripple/protocol/impl/STParsedJSON.cpp - src/ripple/protocol/impl/STPathSet.cpp - src/ripple/protocol/impl/STXChainBridge.cpp - src/ripple/protocol/impl/STTx.cpp - src/ripple/protocol/impl/XChainAttestations.cpp - src/ripple/protocol/impl/STValidation.cpp - src/ripple/protocol/impl/STVar.cpp - src/ripple/protocol/impl/STVector256.cpp - src/ripple/protocol/impl/SecretKey.cpp - src/ripple/protocol/impl/Seed.cpp - src/ripple/protocol/impl/Serializer.cpp - src/ripple/protocol/impl/Sign.cpp - src/ripple/protocol/impl/TER.cpp - src/ripple/protocol/impl/TxFormats.cpp - src/ripple/protocol/impl/TxMeta.cpp - src/ripple/protocol/impl/UintTypes.cpp - src/ripple/protocol/impl/digest.cpp - src/ripple/protocol/impl/tokens.cpp - src/ripple/protocol/impl/NFTSyntheticSerializer.cpp - src/ripple/protocol/impl/NFTokenID.cpp - src/ripple/protocol/impl/NFTokenOfferID.cpp - #[===============================[ - main sources: - subdir: resource - #]===============================] - src/ripple/resource/impl/Charge.cpp - src/ripple/resource/impl/Consumer.cpp - src/ripple/resource/impl/Fees.cpp - src/ripple/resource/impl/ResourceManager.cpp - #[===============================[ - main sources: - subdir: server - #]===============================] - src/ripple/server/impl/JSONRPCUtil.cpp - src/ripple/server/impl/Port.cpp - #[===============================[ - main sources: - subdir: crypto - #]===============================] - src/ripple/crypto/impl/RFC1751.cpp - src/ripple/crypto/impl/csprng.cpp - src/ripple/crypto/impl/secure_erase.cpp) -# END LIBXRPL SOURCES - -add_library (Ripple::xrpl_core ALIAS xrpl_core) -target_include_directories (xrpl_core - PUBLIC - $ - $) - -target_compile_definitions(xrpl_core - PUBLIC - BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT - BOOST_CONTAINER_FWD_BAD_DEQUE - HAS_UNCAUGHT_EXCEPTIONS=1) -target_compile_options (xrpl_core - PUBLIC - $<$:-Wno-maybe-uninitialized>) -target_link_libraries (xrpl_core - PUBLIC - date::date - ed25519::ed25519 - LibArchive::LibArchive - OpenSSL::Crypto - Ripple::boost - Ripple::opts - Ripple::syslibs - secp256k1::secp256k1 - xrpl.libpb - xxHash::xxhash) -#[=================================[ - main/core headers installation -#]=================================] -# BEGIN LIBXRPL HEADERS -install ( - FILES - src/ripple/basics/Archive.h - src/ripple/basics/BasicConfig.h - src/ripple/basics/Blob.h - src/ripple/basics/Buffer.h - src/ripple/basics/ByteUtilities.h - src/ripple/basics/CompressionAlgorithms.h - src/ripple/basics/CountedObject.h - src/ripple/basics/DecayingSample.h - src/ripple/basics/Expected.h - src/ripple/basics/FeeUnits.h - src/ripple/basics/FileUtilities.h - src/ripple/basics/IOUAmount.h - src/ripple/basics/KeyCache.h - src/ripple/basics/LocalValue.h - src/ripple/basics/Log.h - src/ripple/basics/MathUtilities.h - src/ripple/basics/Number.h - src/ripple/basics/PerfLog.h - src/ripple/basics/README.md - src/ripple/basics/RangeSet.h - src/ripple/basics/Resolver.h - src/ripple/basics/ResolverAsio.h - src/ripple/basics/SHAMapHash.h - src/ripple/basics/Slice.h - src/ripple/basics/StringUtilities.h - src/ripple/basics/TaggedCache.h - src/ripple/basics/ThreadSafetyAnalysis.h - src/ripple/basics/ToString.h - src/ripple/basics/UnorderedContainers.h - src/ripple/basics/UptimeClock.h - src/ripple/basics/XRPAmount.h - src/ripple/basics/algorithm.h - src/ripple/basics/base64.h - src/ripple/basics/base_uint.h - src/ripple/basics/chrono.h - src/ripple/basics/comparators.h - src/ripple/basics/contract.h - src/ripple/basics/hardened_hash.h - src/ripple/basics/join.h - src/ripple/basics/make_SSLContext.h - src/ripple/basics/mulDiv.h - src/ripple/basics/partitioned_unordered_map.h - src/ripple/basics/random.h - src/ripple/basics/safe_cast.h - src/ripple/basics/scope.h - src/ripple/basics/spinlock.h - src/ripple/basics/strHex.h - src/ripple/basics/tagged_integer.h - DESTINATION include/ripple/basics) -install ( - FILES - src/ripple/crypto/RFC1751.h - src/ripple/crypto/csprng.h - src/ripple/crypto/secure_erase.h - DESTINATION include/ripple/crypto) -install ( - FILES - src/ripple/json/JsonPropertyStream.h - src/ripple/json/Object.h - src/ripple/json/Output.h - src/ripple/json/Writer.h - src/ripple/json/json_forwards.h - src/ripple/json/json_reader.h - src/ripple/json/json_value.h - src/ripple/json/json_writer.h - src/ripple/json/to_string.h - DESTINATION include/ripple/json) -install ( - FILES - src/ripple/json/impl/json_assert.h - DESTINATION include/ripple/json/impl) -install ( - FILES - src/ripple/protocol/AccountID.h - src/ripple/protocol/AMMCore.h - src/ripple/protocol/AmountConversions.h - src/ripple/protocol/ApiVersion.h - src/ripple/protocol/Book.h - src/ripple/protocol/BuildInfo.h - src/ripple/protocol/ErrorCodes.h - src/ripple/protocol/Feature.h - src/ripple/protocol/Fees.h - src/ripple/protocol/HashPrefix.h - src/ripple/protocol/Indexes.h - src/ripple/protocol/InnerObjectFormats.h - src/ripple/protocol/Issue.h - src/ripple/protocol/json_get_or_throw.h - src/ripple/protocol/Keylet.h - src/ripple/protocol/KeyType.h - src/ripple/protocol/KnownFormats.h - src/ripple/protocol/LedgerFormats.h - src/ripple/protocol/LedgerHeader.h - src/ripple/protocol/MultiApiJson.h - src/ripple/protocol/NFTSyntheticSerializer.h - src/ripple/protocol/NFTokenID.h - src/ripple/protocol/NFTokenOfferID.h - src/ripple/protocol/NFTSyntheticSerializer.h - src/ripple/protocol/Protocol.h - src/ripple/protocol/PublicKey.h - src/ripple/protocol/Quality.h - src/ripple/protocol/QualityFunction.h - src/ripple/protocol/Rate.h - src/ripple/protocol/RPCErr.h - src/ripple/protocol/Rules.h - src/ripple/protocol/SecretKey.h - src/ripple/protocol/Seed.h - src/ripple/protocol/SeqProxy.h - src/ripple/protocol/Serializer.h - src/ripple/protocol/SField.h - src/ripple/protocol/Sign.h - src/ripple/protocol/SOTemplate.h - src/ripple/protocol/STAccount.h - src/ripple/protocol/STAmount.h - src/ripple/protocol/STArray.h - src/ripple/protocol/STBase.h - src/ripple/protocol/STBitString.h - src/ripple/protocol/STBlob.h - src/ripple/protocol/STCurrency.h - src/ripple/protocol/STExchange.h - src/ripple/protocol/STInteger.h - src/ripple/protocol/STIssue.h - src/ripple/protocol/STLedgerEntry.h - src/ripple/protocol/STObject.h - src/ripple/protocol/STParsedJSON.h - src/ripple/protocol/STPathSet.h - src/ripple/protocol/STTx.h - src/ripple/protocol/STValidation.h - src/ripple/protocol/STVector256.h - src/ripple/protocol/STXChainBridge.h - src/ripple/protocol/SystemParameters.h - src/ripple/protocol/TER.h - src/ripple/protocol/TxFlags.h - src/ripple/protocol/TxFormats.h - src/ripple/protocol/TxMeta.h - src/ripple/protocol/UintTypes.h - src/ripple/protocol/XChainAttestations.h - src/ripple/protocol/digest.h - src/ripple/protocol/jss.h - src/ripple/protocol/nft.h - src/ripple/protocol/nftPageMask.h - src/ripple/protocol/serialize.h - src/ripple/protocol/tokens.h - DESTINATION include/ripple/protocol) -install ( - FILES - src/ripple/protocol/impl/STVar.h - src/ripple/protocol/impl/b58_utils.h - src/ripple/protocol/impl/secp256k1.h - src/ripple/protocol/impl/token_errors.h - DESTINATION include/ripple/protocol/impl) -install ( - FILES - src/ripple/resource/Charge.h - src/ripple/resource/Consumer.h - src/ripple/resource/Disposition.h - src/ripple/resource/Fees.h - src/ripple/resource/Gossip.h - src/ripple/resource/ResourceManager.h - src/ripple/resource/Types.h - DESTINATION include/ripple/resource) -install ( - FILES - src/ripple/resource/impl/Entry.h - src/ripple/resource/impl/Import.h - src/ripple/resource/impl/Key.h - src/ripple/resource/impl/Kind.h - src/ripple/resource/impl/Logic.h - src/ripple/resource/impl/Tuning.h - DESTINATION include/ripple/resource/impl) -install ( - FILES - src/ripple/server/Handoff.h - src/ripple/server/Port.h - src/ripple/server/Server.h - src/ripple/server/Session.h - src/ripple/server/SimpleWriter.h - src/ripple/server/Writer.h - src/ripple/server/WSSession.h - DESTINATION include/ripple/server) -install ( - FILES - src/ripple/server/impl/BaseHTTPPeer.h - src/ripple/server/impl/BasePeer.h - src/ripple/server/impl/BaseWSPeer.h - src/ripple/server/impl/Door.h - src/ripple/server/impl/JSONRPCUtil.h - src/ripple/server/impl/LowestLayer.h - src/ripple/server/impl/PlainHTTPPeer.h - src/ripple/server/impl/PlainWSPeer.h - src/ripple/server/impl/ServerImpl.h - src/ripple/server/impl/SSLHTTPPeer.h - src/ripple/server/impl/SSLWSPeer.h - src/ripple/server/impl/io_list.h - DESTINATION include/ripple/server/impl) -#[===================================[ - beast/legacy headers installation -#]===================================] -install ( - FILES - src/ripple/beast/clock/abstract_clock.h - src/ripple/beast/clock/basic_seconds_clock.h - src/ripple/beast/clock/manual_clock.h - DESTINATION include/ripple/beast/clock) -install ( - FILES - src/ripple/beast/core/CurrentThreadName.h - src/ripple/beast/core/LexicalCast.h - src/ripple/beast/core/List.h - src/ripple/beast/core/SemanticVersion.h - DESTINATION include/ripple/beast/core) -install ( - FILES - src/ripple/beast/hash/hash_append.h - src/ripple/beast/hash/uhash.h - src/ripple/beast/hash/xxhasher.h - DESTINATION include/ripple/beast/hash) -install ( - FILES - src/ripple/beast/net/IPAddress.h - src/ripple/beast/net/IPAddressConversion.h - src/ripple/beast/net/IPAddressV4.h - src/ripple/beast/net/IPAddressV6.h - src/ripple/beast/net/IPEndpoint.h - DESTINATION include/ripple/beast/net) -install ( - FILES - src/ripple/beast/rfc2616.h - src/ripple/beast/type_name.h - src/ripple/beast/unit_test.h - src/ripple/beast/xor_shift_engine.h - DESTINATION include/ripple/beast) -install ( - FILES - src/ripple/beast/unit_test/amount.h - src/ripple/beast/unit_test/dstream.h - src/ripple/beast/unit_test/global_suites.h - src/ripple/beast/unit_test/match.h - src/ripple/beast/unit_test/recorder.h - src/ripple/beast/unit_test/reporter.h - src/ripple/beast/unit_test/results.h - src/ripple/beast/unit_test/runner.h - src/ripple/beast/unit_test/suite_info.h - src/ripple/beast/unit_test/suite_list.h - src/ripple/beast/unit_test/suite.h - src/ripple/beast/unit_test/thread.h - DESTINATION include/ripple/beast/unit_test) -install ( - FILES - src/ripple/beast/unit_test/detail/const_container.h - DESTINATION include/ripple/beast/unit_test/detail) -install ( - FILES - src/ripple/beast/utility/Journal.h - src/ripple/beast/utility/PropertyStream.h - src/ripple/beast/utility/WrappedSink.h - src/ripple/beast/utility/Zero.h - src/ripple/beast/utility/rngfill.h - DESTINATION include/ripple/beast/utility) -# END LIBXRPL HEADERS -#[===================================================================[ - rippled executable -#]===================================================================] - -#[=========================================================[ - this one header is added as source just to keep older - versions of cmake happy. cmake 3.10+ allows - add_executable with no sources -#]=========================================================] -add_executable (rippled src/ripple/app/main/Application.h) -if (unity) - set_target_properties(rippled PROPERTIES UNITY_BUILD ON) -endif () -if (tests) - target_compile_definitions(rippled PUBLIC ENABLE_TESTS) -endif() -# BEGIN XRPLD SOURCES -target_sources (rippled PRIVATE - #[===============================[ - main sources: - subdir: app - #]===============================] - src/ripple/app/consensus/RCLConsensus.cpp - src/ripple/app/consensus/RCLCxPeerPos.cpp - src/ripple/app/consensus/RCLValidations.cpp - src/ripple/app/ledger/AcceptedLedger.cpp - src/ripple/app/ledger/AcceptedLedgerTx.cpp - src/ripple/app/ledger/AccountStateSF.cpp - src/ripple/app/ledger/BookListeners.cpp - src/ripple/app/ledger/ConsensusTransSetSF.cpp - src/ripple/app/ledger/Ledger.cpp - src/ripple/app/ledger/LedgerHistory.cpp - src/ripple/app/ledger/OrderBookDB.cpp - src/ripple/app/ledger/TransactionStateSF.cpp - src/ripple/app/ledger/impl/BuildLedger.cpp - src/ripple/app/ledger/impl/InboundLedger.cpp - src/ripple/app/ledger/impl/InboundLedgers.cpp - src/ripple/app/ledger/impl/InboundTransactions.cpp - src/ripple/app/ledger/impl/LedgerCleaner.cpp - src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp - src/ripple/app/ledger/impl/LedgerMaster.cpp - src/ripple/app/ledger/impl/LedgerReplay.cpp - src/ripple/app/ledger/impl/LedgerReplayer.cpp - src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp - src/ripple/app/ledger/impl/LedgerReplayTask.cpp - src/ripple/app/ledger/impl/LedgerToJson.cpp - src/ripple/app/ledger/impl/LocalTxs.cpp - src/ripple/app/ledger/impl/OpenLedger.cpp - src/ripple/app/ledger/impl/SkipListAcquire.cpp - src/ripple/app/ledger/impl/TimeoutCounter.cpp - src/ripple/app/ledger/impl/TransactionAcquire.cpp - src/ripple/app/ledger/impl/TransactionMaster.cpp - src/ripple/app/main/Application.cpp - src/ripple/app/main/BasicApp.cpp - src/ripple/app/main/CollectorManager.cpp - src/ripple/app/main/GRPCServer.cpp - src/ripple/app/main/LoadManager.cpp - src/ripple/app/main/Main.cpp - src/ripple/app/main/NodeIdentity.cpp - src/ripple/app/main/NodeStoreScheduler.cpp - src/ripple/app/reporting/ReportingETL.cpp - src/ripple/app/reporting/ETLSource.cpp - src/ripple/app/reporting/P2pProxy.cpp - src/ripple/app/misc/impl/AMMHelpers.cpp - src/ripple/app/misc/impl/AMMUtils.cpp - src/ripple/app/misc/CanonicalTXSet.cpp - src/ripple/app/misc/FeeVoteImpl.cpp - src/ripple/app/misc/HashRouter.cpp - src/ripple/app/misc/NegativeUNLVote.cpp - src/ripple/app/misc/NetworkOPs.cpp - src/ripple/app/misc/SHAMapStoreImp.cpp - src/ripple/app/misc/detail/impl/WorkSSL.cpp - src/ripple/app/misc/impl/AccountTxPaging.cpp - src/ripple/app/misc/impl/AmendmentTable.cpp - src/ripple/app/misc/impl/DeliverMax.cpp - src/ripple/app/misc/impl/LoadFeeTrack.cpp - src/ripple/app/misc/impl/Manifest.cpp - src/ripple/app/misc/impl/Transaction.cpp - src/ripple/app/misc/impl/TxQ.cpp - src/ripple/app/misc/impl/ValidatorKeys.cpp - src/ripple/app/misc/impl/ValidatorList.cpp - src/ripple/app/misc/impl/ValidatorSite.cpp - src/ripple/app/paths/AccountCurrencies.cpp - src/ripple/app/paths/Credit.cpp - src/ripple/app/paths/Flow.cpp - src/ripple/app/paths/PathRequest.cpp - src/ripple/app/paths/PathRequests.cpp - src/ripple/app/paths/Pathfinder.cpp - src/ripple/app/paths/RippleCalc.cpp - src/ripple/app/paths/RippleLineCache.cpp - src/ripple/app/paths/TrustLine.cpp - src/ripple/app/paths/impl/AMMLiquidity.cpp - src/ripple/app/paths/impl/AMMOffer.cpp - src/ripple/app/paths/impl/BookStep.cpp - src/ripple/app/paths/impl/DirectStep.cpp - src/ripple/app/paths/impl/PaySteps.cpp - src/ripple/app/paths/impl/XRPEndpointStep.cpp - src/ripple/app/rdb/backend/detail/impl/Node.cpp - src/ripple/app/rdb/backend/detail/impl/Shard.cpp - src/ripple/app/rdb/backend/impl/PostgresDatabase.cpp - src/ripple/app/rdb/backend/impl/SQLiteDatabase.cpp - src/ripple/app/rdb/impl/Download.cpp - src/ripple/app/rdb/impl/PeerFinder.cpp - src/ripple/app/rdb/impl/RelationalDatabase.cpp - src/ripple/app/rdb/impl/ShardArchive.cpp - src/ripple/app/rdb/impl/State.cpp - src/ripple/app/rdb/impl/UnitaryShard.cpp - src/ripple/app/rdb/impl/Vacuum.cpp - src/ripple/app/rdb/impl/Wallet.cpp - src/ripple/app/tx/impl/AMMBid.cpp - src/ripple/app/tx/impl/AMMCreate.cpp - src/ripple/app/tx/impl/AMMDelete.cpp - src/ripple/app/tx/impl/AMMDeposit.cpp - src/ripple/app/tx/impl/AMMVote.cpp - src/ripple/app/tx/impl/AMMWithdraw.cpp - src/ripple/app/tx/impl/ApplyContext.cpp - src/ripple/app/tx/impl/BookTip.cpp - src/ripple/app/tx/impl/CancelCheck.cpp - src/ripple/app/tx/impl/CancelOffer.cpp - src/ripple/app/tx/impl/CashCheck.cpp - src/ripple/app/tx/impl/Change.cpp - src/ripple/app/tx/impl/Clawback.cpp - src/ripple/app/tx/impl/CreateCheck.cpp - src/ripple/app/tx/impl/CreateOffer.cpp - src/ripple/app/tx/impl/CreateTicket.cpp - src/ripple/app/tx/impl/DeleteAccount.cpp - src/ripple/app/tx/impl/DeleteOracle.cpp - src/ripple/app/tx/impl/DepositPreauth.cpp - src/ripple/app/tx/impl/DID.cpp - src/ripple/app/tx/impl/Escrow.cpp - src/ripple/app/tx/impl/InvariantCheck.cpp - src/ripple/app/tx/impl/NFTokenAcceptOffer.cpp - src/ripple/app/tx/impl/NFTokenBurn.cpp - src/ripple/app/tx/impl/NFTokenCancelOffer.cpp - src/ripple/app/tx/impl/NFTokenCreateOffer.cpp - src/ripple/app/tx/impl/NFTokenMint.cpp - src/ripple/app/tx/impl/OfferStream.cpp - src/ripple/app/tx/impl/PayChan.cpp - src/ripple/app/tx/impl/Payment.cpp - src/ripple/app/tx/impl/SetAccount.cpp - src/ripple/app/tx/impl/SetOracle.cpp - src/ripple/app/tx/impl/SetRegularKey.cpp - src/ripple/app/tx/impl/SetSignerList.cpp - src/ripple/app/tx/impl/SetTrust.cpp - src/ripple/app/tx/impl/XChainBridge.cpp - src/ripple/app/tx/impl/SignerEntries.cpp - src/ripple/app/tx/impl/Taker.cpp - src/ripple/app/tx/impl/Transactor.cpp - src/ripple/app/tx/impl/apply.cpp - src/ripple/app/tx/impl/applySteps.cpp - src/ripple/app/tx/impl/details/NFTokenUtils.cpp - #[===============================[ - main sources: - subdir: conditions - #]===============================] - src/ripple/conditions/impl/Condition.cpp - src/ripple/conditions/impl/Fulfillment.cpp - src/ripple/conditions/impl/error.cpp - #[===============================[ - main sources: - subdir: core - #]===============================] - src/ripple/core/impl/Config.cpp - src/ripple/core/impl/DatabaseCon.cpp - src/ripple/core/impl/Job.cpp - src/ripple/core/impl/JobQueue.cpp - src/ripple/core/impl/LoadEvent.cpp - src/ripple/core/impl/LoadMonitor.cpp - src/ripple/core/impl/SociDB.cpp - src/ripple/core/impl/Workers.cpp - src/ripple/core/Pg.cpp - #[===============================[ - main sources: - subdir: consensus - #]===============================] - src/ripple/consensus/Consensus.cpp - #[===============================[ - main sources: - subdir: ledger - #]===============================] - src/ripple/ledger/impl/ApplyStateTable.cpp - src/ripple/ledger/impl/ApplyView.cpp - src/ripple/ledger/impl/ApplyViewBase.cpp - src/ripple/ledger/impl/ApplyViewImpl.cpp - src/ripple/ledger/impl/BookDirs.cpp - src/ripple/ledger/impl/CachedView.cpp - src/ripple/ledger/impl/Directory.cpp - src/ripple/ledger/impl/OpenView.cpp - src/ripple/ledger/impl/PaymentSandbox.cpp - src/ripple/ledger/impl/RawStateTable.cpp - src/ripple/ledger/impl/ReadView.cpp - src/ripple/ledger/impl/View.cpp - #[===============================[ - main sources: - subdir: net - #]===============================] - src/ripple/net/impl/DatabaseDownloader.cpp - src/ripple/net/impl/HTTPClient.cpp - src/ripple/net/impl/HTTPDownloader.cpp - src/ripple/net/impl/HTTPStream.cpp - src/ripple/net/impl/InfoSub.cpp - src/ripple/net/impl/RPCCall.cpp - src/ripple/net/impl/RPCSub.cpp - src/ripple/net/impl/RegisterSSLCerts.cpp - #[===============================[ - main sources: - subdir: nodestore - #]===============================] - src/ripple/nodestore/backend/CassandraFactory.cpp - src/ripple/nodestore/backend/MemoryFactory.cpp - src/ripple/nodestore/backend/NuDBFactory.cpp - src/ripple/nodestore/backend/NullFactory.cpp - src/ripple/nodestore/backend/RocksDBFactory.cpp - src/ripple/nodestore/impl/BatchWriter.cpp - src/ripple/nodestore/impl/Database.cpp - src/ripple/nodestore/impl/DatabaseNodeImp.cpp - src/ripple/nodestore/impl/DatabaseRotatingImp.cpp - src/ripple/nodestore/impl/DatabaseShardImp.cpp - src/ripple/nodestore/impl/DeterministicShard.cpp - src/ripple/nodestore/impl/DecodedBlob.cpp - src/ripple/nodestore/impl/DummyScheduler.cpp - src/ripple/nodestore/impl/ManagerImp.cpp - src/ripple/nodestore/impl/NodeObject.cpp - src/ripple/nodestore/impl/Shard.cpp - src/ripple/nodestore/impl/ShardInfo.cpp - src/ripple/nodestore/impl/TaskQueue.cpp - #[===============================[ - main sources: - subdir: overlay - #]===============================] - src/ripple/overlay/impl/Cluster.cpp - src/ripple/overlay/impl/ConnectAttempt.cpp - src/ripple/overlay/impl/Handshake.cpp - src/ripple/overlay/impl/Message.cpp - src/ripple/overlay/impl/OverlayImpl.cpp - src/ripple/overlay/impl/PeerImp.cpp - src/ripple/overlay/impl/PeerReservationTable.cpp - src/ripple/overlay/impl/PeerSet.cpp - src/ripple/overlay/impl/ProtocolVersion.cpp - src/ripple/overlay/impl/TrafficCount.cpp - src/ripple/overlay/impl/TxMetrics.cpp - #[===============================[ - main sources: - subdir: peerfinder - #]===============================] - src/ripple/peerfinder/impl/Bootcache.cpp - src/ripple/peerfinder/impl/Endpoint.cpp - src/ripple/peerfinder/impl/PeerfinderConfig.cpp - src/ripple/peerfinder/impl/PeerfinderManager.cpp - src/ripple/peerfinder/impl/SlotImp.cpp - src/ripple/peerfinder/impl/SourceStrings.cpp - #[===============================[ - main sources: - subdir: rpc - #]===============================] - src/ripple/rpc/handlers/AccountChannels.cpp - src/ripple/rpc/handlers/AccountCurrenciesHandler.cpp - src/ripple/rpc/handlers/AccountInfo.cpp - src/ripple/rpc/handlers/AccountLines.cpp - src/ripple/rpc/handlers/AccountObjects.cpp - src/ripple/rpc/handlers/AccountOffers.cpp - src/ripple/rpc/handlers/AccountTx.cpp - src/ripple/rpc/handlers/AMMInfo.cpp - src/ripple/rpc/handlers/BlackList.cpp - src/ripple/rpc/handlers/BookOffers.cpp - src/ripple/rpc/handlers/CanDelete.cpp - src/ripple/rpc/handlers/Connect.cpp - src/ripple/rpc/handlers/ConsensusInfo.cpp - src/ripple/rpc/handlers/CrawlShards.cpp - src/ripple/rpc/handlers/DepositAuthorized.cpp - src/ripple/rpc/handlers/DownloadShard.cpp - src/ripple/rpc/handlers/Feature1.cpp - src/ripple/rpc/handlers/Fee1.cpp - src/ripple/rpc/handlers/FetchInfo.cpp - src/ripple/rpc/handlers/GatewayBalances.cpp - src/ripple/rpc/handlers/GetCounts.cpp - src/ripple/rpc/handlers/GetAggregatePrice.cpp - src/ripple/rpc/handlers/LedgerAccept.cpp - src/ripple/rpc/handlers/LedgerCleanerHandler.cpp - src/ripple/rpc/handlers/LedgerClosed.cpp - src/ripple/rpc/handlers/LedgerCurrent.cpp - src/ripple/rpc/handlers/LedgerData.cpp - src/ripple/rpc/handlers/LedgerDiff.cpp - src/ripple/rpc/handlers/LedgerEntry.cpp - src/ripple/rpc/handlers/LedgerHandler.cpp - src/ripple/rpc/handlers/LedgerHeader.cpp - src/ripple/rpc/handlers/LedgerRequest.cpp - src/ripple/rpc/handlers/LogLevel.cpp - src/ripple/rpc/handlers/LogRotate.cpp - src/ripple/rpc/handlers/Manifest.cpp - src/ripple/rpc/handlers/NFTOffers.cpp - src/ripple/rpc/handlers/NodeToShard.cpp - src/ripple/rpc/handlers/NoRippleCheck.cpp - src/ripple/rpc/handlers/OwnerInfo.cpp - src/ripple/rpc/handlers/PathFind.cpp - src/ripple/rpc/handlers/PayChanClaim.cpp - src/ripple/rpc/handlers/Peers.cpp - src/ripple/rpc/handlers/Ping.cpp - src/ripple/rpc/handlers/Print.cpp - src/ripple/rpc/handlers/Random.cpp - src/ripple/rpc/handlers/Reservations.cpp - src/ripple/rpc/handlers/RipplePathFind.cpp - src/ripple/rpc/handlers/ServerInfo.cpp - src/ripple/rpc/handlers/ServerState.cpp - src/ripple/rpc/handlers/SignFor.cpp - src/ripple/rpc/handlers/SignHandler.cpp - src/ripple/rpc/handlers/Stop.cpp - src/ripple/rpc/handlers/Submit.cpp - src/ripple/rpc/handlers/SubmitMultiSigned.cpp - src/ripple/rpc/handlers/Subscribe.cpp - src/ripple/rpc/handlers/TransactionEntry.cpp - src/ripple/rpc/handlers/Tx.cpp - src/ripple/rpc/handlers/TxHistory.cpp - src/ripple/rpc/handlers/TxReduceRelay.cpp - src/ripple/rpc/handlers/UnlList.cpp - src/ripple/rpc/handlers/Unsubscribe.cpp - src/ripple/rpc/handlers/ValidationCreate.cpp - src/ripple/rpc/handlers/ValidatorInfo.cpp - src/ripple/rpc/handlers/ValidatorListSites.cpp - src/ripple/rpc/handlers/Validators.cpp - src/ripple/rpc/handlers/WalletPropose.cpp - src/ripple/rpc/impl/DeliveredAmount.cpp - src/ripple/rpc/impl/Handler.cpp - src/ripple/rpc/impl/LegacyPathFind.cpp - src/ripple/rpc/impl/RPCHandler.cpp - src/ripple/rpc/impl/RPCHelpers.cpp - src/ripple/rpc/impl/Role.cpp - src/ripple/rpc/impl/ServerHandler.cpp - src/ripple/rpc/impl/ShardArchiveHandler.cpp - src/ripple/rpc/impl/ShardVerificationScheduler.cpp - src/ripple/rpc/impl/Status.cpp - src/ripple/rpc/impl/TransactionSign.cpp - #[===============================[ - main sources: - subdir: perflog - #]===============================] - src/ripple/perflog/impl/PerfLogImp.cpp - #[===============================[ - main sources: - subdir: shamap - #]===============================] - src/ripple/shamap/impl/NodeFamily.cpp - src/ripple/shamap/impl/SHAMap.cpp - src/ripple/shamap/impl/SHAMapDelta.cpp - src/ripple/shamap/impl/SHAMapInnerNode.cpp - src/ripple/shamap/impl/SHAMapLeafNode.cpp - src/ripple/shamap/impl/SHAMapNodeID.cpp - src/ripple/shamap/impl/SHAMapSync.cpp - src/ripple/shamap/impl/SHAMapTreeNode.cpp - src/ripple/shamap/impl/ShardFamily.cpp) -# END XRPLD SOURCES - - #[===============================[ - test sources: - subdir: app - #]===============================] -if (tests) - target_sources (rippled PRIVATE - src/test/app/AccountDelete_test.cpp - src/test/app/AccountTxPaging_test.cpp - src/test/app/AmendmentTable_test.cpp - src/test/app/AMM_test.cpp - src/test/app/AMMCalc_test.cpp - src/test/app/AMMExtended_test.cpp - src/test/app/Check_test.cpp - src/test/app/Clawback_test.cpp - src/test/app/CrossingLimits_test.cpp - src/test/app/DeliverMin_test.cpp - src/test/app/DepositAuth_test.cpp - src/test/app/Discrepancy_test.cpp - src/test/app/DID_test.cpp - src/test/app/DNS_test.cpp - src/test/app/Escrow_test.cpp - src/test/app/FeeVote_test.cpp - src/test/app/Flow_test.cpp - src/test/app/Freeze_test.cpp - src/test/app/HashRouter_test.cpp - src/test/app/LedgerHistory_test.cpp - src/test/app/LedgerLoad_test.cpp - src/test/app/LedgerMaster_test.cpp - src/test/app/LedgerReplay_test.cpp - src/test/app/LoadFeeTrack_test.cpp - src/test/app/Manifest_test.cpp - src/test/app/MultiSign_test.cpp - src/test/app/NetworkID_test.cpp - src/test/app/NFToken_test.cpp - src/test/app/NFTokenBurn_test.cpp - src/test/app/NFTokenDir_test.cpp - src/test/app/OfferStream_test.cpp - src/test/app/Offer_test.cpp - src/test/app/Oracle_test.cpp - src/test/app/OversizeMeta_test.cpp - src/test/app/Path_test.cpp - src/test/app/PayChan_test.cpp - src/test/app/PayStrand_test.cpp - src/test/app/PseudoTx_test.cpp - src/test/app/RCLCensorshipDetector_test.cpp - src/test/app/RCLValidations_test.cpp - src/test/app/ReducedOffer_test.cpp - src/test/app/Regression_test.cpp - src/test/app/SHAMapStore_test.cpp - src/test/app/XChain_test.cpp - src/test/app/SetAuth_test.cpp - src/test/app/SetRegularKey_test.cpp - src/test/app/SetTrust_test.cpp - src/test/app/Taker_test.cpp - src/test/app/TheoreticalQuality_test.cpp - src/test/app/Ticket_test.cpp - src/test/app/Transaction_ordering_test.cpp - src/test/app/TrustAndBalance_test.cpp - src/test/app/TxQ_test.cpp - src/test/app/ValidatorKeys_test.cpp - src/test/app/ValidatorList_test.cpp - src/test/app/ValidatorSite_test.cpp - src/test/app/tx/apply_test.cpp - #[===============================[ - test sources: - subdir: basics - #]===============================] - src/test/basics/Buffer_test.cpp - src/test/basics/DetectCrash_test.cpp - src/test/basics/Expected_test.cpp - src/test/basics/FileUtilities_test.cpp - src/test/basics/IOUAmount_test.cpp - src/test/basics/KeyCache_test.cpp - src/test/basics/Number_test.cpp - src/test/basics/PerfLog_test.cpp - src/test/basics/RangeSet_test.cpp - src/test/basics/scope_test.cpp - src/test/basics/Slice_test.cpp - src/test/basics/StringUtilities_test.cpp - src/test/basics/TaggedCache_test.cpp - src/test/basics/XRPAmount_test.cpp - src/test/basics/base58_test.cpp - src/test/basics/base64_test.cpp - src/test/basics/base_uint_test.cpp - src/test/basics/contract_test.cpp - src/test/basics/FeeUnits_test.cpp - src/test/basics/hardened_hash_test.cpp - src/test/basics/join_test.cpp - src/test/basics/mulDiv_test.cpp - src/test/basics/tagged_integer_test.cpp - #[===============================[ - test sources: - subdir: beast - #]===============================] - src/test/beast/IPEndpoint_test.cpp - src/test/beast/LexicalCast_test.cpp - src/test/beast/SemanticVersion_test.cpp - src/test/beast/aged_associative_container_test.cpp - src/test/beast/beast_CurrentThreadName_test.cpp - src/test/beast/beast_Journal_test.cpp - src/test/beast/beast_PropertyStream_test.cpp - src/test/beast/beast_Zero_test.cpp - src/test/beast/beast_abstract_clock_test.cpp - src/test/beast/beast_basic_seconds_clock_test.cpp - src/test/beast/beast_io_latency_probe_test.cpp - src/test/beast/define_print.cpp - #[===============================[ - test sources: - subdir: conditions - #]===============================] - src/test/conditions/PreimageSha256_test.cpp - #[===============================[ - test sources: - subdir: consensus - #]===============================] - src/test/consensus/ByzantineFailureSim_test.cpp - src/test/consensus/Consensus_test.cpp - src/test/consensus/DistributedValidatorsSim_test.cpp - src/test/consensus/LedgerTiming_test.cpp - src/test/consensus/LedgerTrie_test.cpp - src/test/consensus/NegativeUNL_test.cpp - src/test/consensus/ScaleFreeSim_test.cpp - src/test/consensus/Validations_test.cpp - #[===============================[ - test sources: - subdir: core - #]===============================] - src/test/core/ClosureCounter_test.cpp - src/test/core/Config_test.cpp - src/test/core/Coroutine_test.cpp - src/test/core/CryptoPRNG_test.cpp - src/test/core/JobQueue_test.cpp - src/test/core/SociDB_test.cpp - src/test/core/Workers_test.cpp - #[===============================[ - test sources: - subdir: csf - #]===============================] - src/test/csf/BasicNetwork_test.cpp - src/test/csf/Digraph_test.cpp - src/test/csf/Histogram_test.cpp - src/test/csf/Scheduler_test.cpp - src/test/csf/impl/Sim.cpp - src/test/csf/impl/ledgers.cpp - #[===============================[ - test sources: - subdir: json - #]===============================] - src/test/json/Object_test.cpp - src/test/json/Output_test.cpp - src/test/json/Writer_test.cpp - src/test/json/json_value_test.cpp - #[===============================[ - test sources: - subdir: jtx - #]===============================] - src/test/jtx/Env_test.cpp - src/test/jtx/WSClient_test.cpp - src/test/jtx/impl/Account.cpp - src/test/jtx/impl/AMM.cpp - src/test/jtx/impl/AMMTest.cpp - src/test/jtx/impl/Env.cpp - src/test/jtx/impl/JSONRPCClient.cpp - src/test/jtx/impl/Oracle.cpp - src/test/jtx/impl/TestHelpers.cpp - src/test/jtx/impl/WSClient.cpp - src/test/jtx/impl/acctdelete.cpp - src/test/jtx/impl/account_txn_id.cpp - src/test/jtx/impl/amount.cpp - src/test/jtx/impl/attester.cpp - src/test/jtx/impl/balance.cpp - src/test/jtx/impl/check.cpp - src/test/jtx/impl/delivermin.cpp - src/test/jtx/impl/deposit.cpp - src/test/jtx/impl/did.cpp - src/test/jtx/impl/envconfig.cpp - src/test/jtx/impl/fee.cpp - src/test/jtx/impl/flags.cpp - src/test/jtx/impl/invoice_id.cpp - src/test/jtx/impl/jtx_json.cpp - src/test/jtx/impl/last_ledger_sequence.cpp - src/test/jtx/impl/memo.cpp - src/test/jtx/impl/multisign.cpp - src/test/jtx/impl/offer.cpp - src/test/jtx/impl/owners.cpp - src/test/jtx/impl/paths.cpp - src/test/jtx/impl/pay.cpp - src/test/jtx/impl/quality2.cpp - src/test/jtx/impl/rate.cpp - src/test/jtx/impl/regkey.cpp - src/test/jtx/impl/sendmax.cpp - src/test/jtx/impl/seq.cpp - src/test/jtx/impl/xchain_bridge.cpp - src/test/jtx/impl/sig.cpp - src/test/jtx/impl/tag.cpp - src/test/jtx/impl/ticket.cpp - src/test/jtx/impl/token.cpp - src/test/jtx/impl/trust.cpp - src/test/jtx/impl/txflags.cpp - src/test/jtx/impl/utility.cpp - - #[===============================[ - test sources: - subdir: ledger - #]===============================] - src/test/ledger/BookDirs_test.cpp - src/test/ledger/Directory_test.cpp - src/test/ledger/Invariants_test.cpp - src/test/ledger/PaymentSandbox_test.cpp - src/test/ledger/PendingSaves_test.cpp - src/test/ledger/SkipList_test.cpp - src/test/ledger/View_test.cpp - #[===============================[ - test sources: - subdir: net - #]===============================] - src/test/net/DatabaseDownloader_test.cpp - #[===============================[ - test sources: - subdir: nodestore - #]===============================] - src/test/nodestore/Backend_test.cpp - src/test/nodestore/Basics_test.cpp - src/test/nodestore/DatabaseShard_test.cpp - src/test/nodestore/Database_test.cpp - src/test/nodestore/Timing_test.cpp - src/test/nodestore/import_test.cpp - src/test/nodestore/varint_test.cpp - #[===============================[ - test sources: - subdir: overlay - #]===============================] - src/test/overlay/ProtocolVersion_test.cpp - src/test/overlay/cluster_test.cpp - src/test/overlay/short_read_test.cpp - src/test/overlay/compression_test.cpp - src/test/overlay/reduce_relay_test.cpp - src/test/overlay/handshake_test.cpp - src/test/overlay/tx_reduce_relay_test.cpp - #[===============================[ - test sources: - subdir: peerfinder - #]===============================] - src/test/peerfinder/Livecache_test.cpp - src/test/peerfinder/PeerFinder_test.cpp - #[===============================[ - test sources: - subdir: protocol - #]===============================] - src/test/protocol/ApiVersion_test.cpp - src/test/protocol/BuildInfo_test.cpp - src/test/protocol/InnerObjectFormats_test.cpp - src/test/protocol/Issue_test.cpp - src/test/protocol/Hooks_test.cpp - src/test/protocol/Memo_test.cpp - src/test/protocol/MultiApiJson_test.cpp - src/test/protocol/PublicKey_test.cpp - src/test/protocol/Quality_test.cpp - src/test/protocol/STAccount_test.cpp - src/test/protocol/STAmount_test.cpp - src/test/protocol/STObject_test.cpp - src/test/protocol/STTx_test.cpp - src/test/protocol/STValidation_test.cpp - src/test/protocol/SecretKey_test.cpp - src/test/protocol/Seed_test.cpp - src/test/protocol/SeqProxy_test.cpp - src/test/protocol/TER_test.cpp - src/test/protocol/types_test.cpp - #[===============================[ - test sources: - subdir: resource - #]===============================] - src/test/resource/Logic_test.cpp - #[===============================[ - test sources: - subdir: rpc - #]===============================] - src/test/rpc/AccountCurrencies_test.cpp - src/test/rpc/AccountInfo_test.cpp - src/test/rpc/AccountLinesRPC_test.cpp - src/test/rpc/AccountObjects_test.cpp - src/test/rpc/AccountOffers_test.cpp - src/test/rpc/AccountSet_test.cpp - src/test/rpc/AccountTx_test.cpp - src/test/rpc/AmendmentBlocked_test.cpp - src/test/rpc/AMMInfo_test.cpp - src/test/rpc/Book_test.cpp - src/test/rpc/DepositAuthorized_test.cpp - src/test/rpc/DeliveredAmount_test.cpp - src/test/rpc/Feature_test.cpp - src/test/rpc/GatewayBalances_test.cpp - src/test/rpc/GetAggregatePrice_test.cpp - src/test/rpc/GetCounts_test.cpp - src/test/rpc/JSONRPC_test.cpp - src/test/rpc/KeyGeneration_test.cpp - src/test/rpc/LedgerClosed_test.cpp - src/test/rpc/LedgerData_test.cpp - src/test/rpc/LedgerHeader_test.cpp - src/test/rpc/LedgerRPC_test.cpp - src/test/rpc/LedgerRequestRPC_test.cpp - src/test/rpc/ManifestRPC_test.cpp - src/test/rpc/NodeToShardRPC_test.cpp - src/test/rpc/NoRippleCheck_test.cpp - src/test/rpc/NoRipple_test.cpp - src/test/rpc/OwnerInfo_test.cpp - src/test/rpc/Peers_test.cpp - src/test/rpc/ReportingETL_test.cpp - src/test/rpc/Roles_test.cpp - src/test/rpc/RPCCall_test.cpp - src/test/rpc/RPCOverload_test.cpp - src/test/rpc/RobustTransaction_test.cpp - src/test/rpc/ServerInfo_test.cpp - src/test/rpc/ShardArchiveHandler_test.cpp - src/test/rpc/Status_test.cpp - src/test/rpc/Subscribe_test.cpp - src/test/rpc/Transaction_test.cpp - src/test/rpc/TransactionEntry_test.cpp - src/test/rpc/TransactionHistory_test.cpp - src/test/rpc/ValidatorInfo_test.cpp - src/test/rpc/ValidatorRPC_test.cpp - src/test/rpc/Version_test.cpp - src/test/rpc/Handler_test.cpp - #[===============================[ - test sources: - subdir: server - #]===============================] - src/test/server/ServerStatus_test.cpp - src/test/server/Server_test.cpp - #[===============================[ - test sources: - subdir: shamap - #]===============================] - src/test/shamap/FetchPack_test.cpp - src/test/shamap/SHAMapSync_test.cpp - src/test/shamap/SHAMap_test.cpp - #[===============================[ - test sources: - subdir: unit_test - #]===============================] - src/test/unit_test/multi_runner.cpp) -endif () #tests - -target_link_libraries (rippled - Ripple::boost - Ripple::opts - Ripple::libs - Ripple::xrpl_core - ) -exclude_if_included (rippled) -# define a macro for tests that might need to -# be exluded or run differently in CI environment -if (is_ci) - target_compile_definitions(rippled PRIVATE RIPPLED_RUNNING_IN_CI) -endif () - -if(reporting) -set_target_properties(rippled PROPERTIES OUTPUT_NAME rippled-reporting) -get_target_property(BIN_NAME rippled OUTPUT_NAME) -message(STATUS "Reporting mode build: rippled renamed ${BIN_NAME}") - target_compile_definitions(rippled PRIVATE RIPPLED_REPORTING) -endif() - -# any files that don't play well with unity should be added here -if (tests) - set_source_files_properties( - # these two seem to produce conflicts in beast teardown template methods - src/test/rpc/ValidatorRPC_test.cpp - src/test/rpc/ShardArchiveHandler_test.cpp - PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE) -endif () #tests diff --git a/Builds/CMake/RippledMultiConfig.cmake b/Builds/CMake/RippledMultiConfig.cmake deleted file mode 100644 index 6df48a3d964..00000000000 --- a/Builds/CMake/RippledMultiConfig.cmake +++ /dev/null @@ -1,39 +0,0 @@ -#[===================================================================[ - multiconfig misc -#]===================================================================] - -if (is_multiconfig) - # This code finds all source files in the src subdirectory for inclusion - # in the IDE file tree as non-compiled sources. Since this file list will - # have some overlap with files we have already added to our targets to - # be compiled, we explicitly remove any of these target source files from - # this list. - file (GLOB_RECURSE all_sources RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - CONFIGURE_DEPENDS - src/*.* Builds/*.md docs/*.md src/*.md Builds/*.cmake) - file(GLOB md_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} CONFIGURE_DEPENDS - *.md) - LIST(APPEND all_sources ${md_files}) - foreach (_target secp256k1::secp256k1 ed25519::ed25519 xrpl_core rippled) - get_target_property (_type ${_target} TYPE) - if(_type STREQUAL "INTERFACE_LIBRARY") - continue() - endif() - get_target_property (_src ${_target} SOURCES) - list (REMOVE_ITEM all_sources ${_src}) - endforeach () - target_sources (rippled PRIVATE ${all_sources}) - set_property ( - SOURCE ${all_sources} - APPEND - PROPERTY HEADER_FILE_ONLY true) - if (MSVC) - set_property( - DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - PROPERTY VS_STARTUP_PROJECT rippled) - endif () - - group_sources(src) - group_sources(docs) - group_sources(Builds) -endif () diff --git a/Builds/CMake/RippledVersion.cmake b/Builds/CMake/RippledVersion.cmake deleted file mode 100644 index 936852af58b..00000000000 --- a/Builds/CMake/RippledVersion.cmake +++ /dev/null @@ -1,15 +0,0 @@ -#[===================================================================[ - read version from source -#]===================================================================] - -file (STRINGS src/ripple/protocol/impl/BuildInfo.cpp BUILD_INFO) -foreach (line_ ${BUILD_INFO}) - if (line_ MATCHES "versionString[ ]*=[ ]*\"(.+)\"") - set (rippled_version ${CMAKE_MATCH_1}) - endif () -endforeach () -if (rippled_version) - message (STATUS "rippled version: ${rippled_version}") -else () - message (FATAL_ERROR "unable to determine rippled version") -endif () diff --git a/Builds/levelization/levelization.sh b/Builds/levelization/levelization.sh index 34487f7464a..f8f21bb9d23 100755 --- a/Builds/levelization/levelization.sh +++ b/Builds/levelization/levelization.sh @@ -18,7 +18,7 @@ mkdir results includes="$( pwd )/results/rawincludes.txt" pushd ../.. echo Raw includes: -grep -r '#include.*/.*\.h' src/ripple/ src/test/ | \ +grep -r '#include.*/.*\.h' include src | \ grep -v boost | tee ${includes} popd pushd results diff --git a/Builds/levelization/results/loops.txt b/Builds/levelization/results/loops.txt index cb137f497cb..ee7e6fd3bc6 100644 --- a/Builds/levelization/results/loops.txt +++ b/Builds/levelization/results/loops.txt @@ -1,51 +1,51 @@ -Loop: ripple.app ripple.core - ripple.app > ripple.core +Loop: test.jtx test.toplevel + test.toplevel > test.jtx -Loop: ripple.app ripple.ledger - ripple.app > ripple.ledger +Loop: test.jtx test.unit_test + test.unit_test == test.jtx -Loop: ripple.app ripple.net - ripple.app > ripple.net +Loop: xrpl.basics xrpl.json + xrpl.json ~= xrpl.basics -Loop: ripple.app ripple.nodestore - ripple.app > ripple.nodestore +Loop: xrpld.app xrpld.core + xrpld.app > xrpld.core -Loop: ripple.app ripple.overlay - ripple.overlay ~= ripple.app +Loop: xrpld.app xrpld.ledger + xrpld.app > xrpld.ledger -Loop: ripple.app ripple.peerfinder - ripple.app > ripple.peerfinder +Loop: xrpld.app xrpld.net + xrpld.app > xrpld.net -Loop: ripple.app ripple.rpc - ripple.rpc > ripple.app +Loop: xrpld.app xrpld.nodestore + xrpld.app > xrpld.nodestore -Loop: ripple.app ripple.shamap - ripple.app > ripple.shamap +Loop: xrpld.app xrpld.overlay + xrpld.overlay ~= xrpld.app -Loop: ripple.basics ripple.core - ripple.core > ripple.basics +Loop: xrpld.app xrpld.peerfinder + xrpld.app > xrpld.peerfinder -Loop: ripple.basics ripple.json - ripple.json ~= ripple.basics +Loop: xrpld.app xrpld.rpc + xrpld.rpc > xrpld.app -Loop: ripple.basics ripple.protocol - ripple.protocol > ripple.basics +Loop: xrpld.app xrpld.shamap + xrpld.app > xrpld.shamap -Loop: ripple.core ripple.net - ripple.net > ripple.core +Loop: xrpld.core xrpld.net + xrpld.net > xrpld.core -Loop: ripple.net ripple.rpc - ripple.rpc > ripple.net +Loop: xrpld.core xrpld.perflog + xrpld.perflog ~= xrpld.core -Loop: ripple.nodestore ripple.overlay - ripple.overlay ~= ripple.nodestore +Loop: xrpld.net xrpld.rpc + xrpld.rpc > xrpld.net -Loop: ripple.overlay ripple.rpc - ripple.rpc ~= ripple.overlay +Loop: xrpld.nodestore xrpld.overlay + xrpld.overlay ~= xrpld.nodestore -Loop: test.jtx test.toplevel - test.toplevel > test.jtx +Loop: xrpld.overlay xrpld.rpc + xrpld.rpc ~= xrpld.overlay -Loop: test.jtx test.unit_test - test.unit_test == test.jtx +Loop: xrpld.perflog xrpld.rpc + xrpld.rpc ~= xrpld.perflog diff --git a/Builds/levelization/results/ordering.txt b/Builds/levelization/results/ordering.txt index ed54065d03e..87f9b03a54e 100644 --- a/Builds/levelization/results/ordering.txt +++ b/Builds/levelization/results/ordering.txt @@ -1,229 +1,203 @@ -ripple.app > ripple.basics -ripple.app > ripple.beast -ripple.app > ripple.conditions -ripple.app > ripple.consensus -ripple.app > ripple.crypto -ripple.app > ripple.json -ripple.app > ripple.protocol -ripple.app > ripple.resource -ripple.app > test.unit_test -ripple.basics > ripple.beast -ripple.conditions > ripple.basics -ripple.conditions > ripple.protocol -ripple.consensus > ripple.basics -ripple.consensus > ripple.beast -ripple.consensus > ripple.json -ripple.consensus > ripple.protocol -ripple.core > ripple.beast -ripple.core > ripple.json -ripple.core > ripple.protocol -ripple.crypto > ripple.basics -ripple.json > ripple.beast -ripple.ledger > ripple.basics -ripple.ledger > ripple.beast -ripple.ledger > ripple.core -ripple.ledger > ripple.json -ripple.ledger > ripple.protocol -ripple.net > ripple.basics -ripple.net > ripple.beast -ripple.net > ripple.json -ripple.net > ripple.protocol -ripple.net > ripple.resource -ripple.nodestore > ripple.basics -ripple.nodestore > ripple.beast -ripple.nodestore > ripple.core -ripple.nodestore > ripple.json -ripple.nodestore > ripple.protocol -ripple.nodestore > ripple.unity -ripple.overlay > ripple.basics -ripple.overlay > ripple.beast -ripple.overlay > ripple.core -ripple.overlay > ripple.json -ripple.overlay > ripple.peerfinder -ripple.overlay > ripple.protocol -ripple.overlay > ripple.resource -ripple.overlay > ripple.server -ripple.peerfinder > ripple.basics -ripple.peerfinder > ripple.beast -ripple.peerfinder > ripple.core -ripple.peerfinder > ripple.protocol -ripple.perflog > ripple.basics -ripple.perflog > ripple.beast -ripple.perflog > ripple.core -ripple.perflog > ripple.json -ripple.perflog > ripple.nodestore -ripple.perflog > ripple.protocol -ripple.perflog > ripple.rpc -ripple.protocol > ripple.beast -ripple.protocol > ripple.crypto -ripple.protocol > ripple.json -ripple.resource > ripple.basics -ripple.resource > ripple.beast -ripple.resource > ripple.json -ripple.resource > ripple.protocol -ripple.rpc > ripple.basics -ripple.rpc > ripple.beast -ripple.rpc > ripple.core -ripple.rpc > ripple.crypto -ripple.rpc > ripple.json -ripple.rpc > ripple.ledger -ripple.rpc > ripple.nodestore -ripple.rpc > ripple.protocol -ripple.rpc > ripple.resource -ripple.rpc > ripple.server -ripple.rpc > ripple.shamap -ripple.server > ripple.basics -ripple.server > ripple.beast -ripple.server > ripple.crypto -ripple.server > ripple.json -ripple.server > ripple.protocol -ripple.shamap > ripple.basics -ripple.shamap > ripple.beast -ripple.shamap > ripple.crypto -ripple.shamap > ripple.nodestore -ripple.shamap > ripple.protocol -test.app > ripple.app -test.app > ripple.basics -test.app > ripple.beast -test.app > ripple.core -test.app > ripple.json -test.app > ripple.ledger -test.app > ripple.overlay -test.app > ripple.protocol -test.app > ripple.resource -test.app > ripple.rpc +libxrpl.basics > xrpl.basics +libxrpl.basics > xrpl.protocol +libxrpl.crypto > xrpl.basics +libxrpl.json > xrpl.basics +libxrpl.json > xrpl.json +libxrpl.protocol > xrpl.basics +libxrpl.protocol > xrpl.json +libxrpl.protocol > xrpl.protocol +libxrpl.resource > xrpl.basics +libxrpl.resource > xrpl.resource +libxrpl.server > xrpl.basics +libxrpl.server > xrpl.json +libxrpl.server > xrpl.protocol +libxrpl.server > xrpl.server test.app > test.jtx test.app > test.rpc test.app > test.toplevel test.app > test.unit_test -test.basics > ripple.basics -test.basics > ripple.beast -test.basics > ripple.json -test.basics > ripple.protocol -test.basics > ripple.rpc +test.app > xrpl.basics +test.app > xrpld.app +test.app > xrpld.core +test.app > xrpld.ledger +test.app > xrpld.overlay +test.app > xrpld.rpc +test.app > xrpl.json +test.app > xrpl.protocol +test.app > xrpl.resource test.basics > test.jtx test.basics > test.unit_test -test.beast > ripple.basics -test.beast > ripple.beast -test.conditions > ripple.basics -test.conditions > ripple.beast -test.conditions > ripple.conditions -test.consensus > ripple.app -test.consensus > ripple.basics -test.consensus > ripple.beast -test.consensus > ripple.consensus -test.consensus > ripple.ledger +test.basics > xrpl.basics +test.basics > xrpld.perflog +test.basics > xrpld.rpc +test.basics > xrpl.json +test.basics > xrpl.protocol +test.beast > xrpl.basics +test.conditions > xrpl.basics +test.conditions > xrpld.conditions test.consensus > test.csf test.consensus > test.toplevel test.consensus > test.unit_test -test.core > ripple.basics -test.core > ripple.beast -test.core > ripple.core -test.core > ripple.crypto -test.core > ripple.json -test.core > ripple.server +test.consensus > xrpl.basics +test.consensus > xrpld.app +test.consensus > xrpld.consensus +test.consensus > xrpld.ledger test.core > test.jtx test.core > test.toplevel test.core > test.unit_test -test.csf > ripple.basics -test.csf > ripple.beast -test.csf > ripple.consensus -test.csf > ripple.json -test.csf > ripple.protocol -test.json > ripple.beast -test.json > ripple.json +test.core > xrpl.basics +test.core > xrpld.core +test.core > xrpld.perflog +test.core > xrpl.json +test.core > xrpl.server +test.csf > xrpl.basics +test.csf > xrpld.consensus +test.csf > xrpl.json +test.csf > xrpl.protocol test.json > test.jtx -test.jtx > ripple.app -test.jtx > ripple.basics -test.jtx > ripple.beast -test.jtx > ripple.consensus -test.jtx > ripple.core -test.jtx > ripple.json -test.jtx > ripple.ledger -test.jtx > ripple.net -test.jtx > ripple.protocol -test.jtx > ripple.resource -test.jtx > ripple.rpc -test.jtx > ripple.server -test.ledger > ripple.app -test.ledger > ripple.basics -test.ledger > ripple.beast -test.ledger > ripple.core -test.ledger > ripple.ledger -test.ledger > ripple.protocol +test.json > xrpl.json +test.jtx > xrpl.basics +test.jtx > xrpld.app +test.jtx > xrpld.consensus +test.jtx > xrpld.core +test.jtx > xrpld.ledger +test.jtx > xrpld.net +test.jtx > xrpld.rpc +test.jtx > xrpl.json +test.jtx > xrpl.protocol +test.jtx > xrpl.resource +test.jtx > xrpl.server test.ledger > test.jtx test.ledger > test.toplevel -test.net > ripple.net +test.ledger > xrpl.basics +test.ledger > xrpld.app +test.ledger > xrpld.core +test.ledger > xrpld.ledger +test.ledger > xrpl.protocol test.net > test.jtx test.net > test.toplevel test.net > test.unit_test -test.nodestore > ripple.app -test.nodestore > ripple.basics -test.nodestore > ripple.beast -test.nodestore > ripple.core -test.nodestore > ripple.nodestore -test.nodestore > ripple.protocol -test.nodestore > ripple.unity +test.net > xrpld.net test.nodestore > test.jtx test.nodestore > test.toplevel test.nodestore > test.unit_test -test.overlay > ripple.app -test.overlay > ripple.basics -test.overlay > ripple.beast -test.overlay > ripple.overlay -test.overlay > ripple.peerfinder -test.overlay > ripple.protocol -test.overlay > ripple.shamap +test.nodestore > xrpl.basics +test.nodestore > xrpld.app +test.nodestore > xrpld.core +test.nodestore > xrpld.nodestore +test.nodestore > xrpld.unity +test.nodestore > xrpl.protocol test.overlay > test.jtx test.overlay > test.unit_test -test.peerfinder > ripple.basics -test.peerfinder > ripple.beast -test.peerfinder > ripple.core -test.peerfinder > ripple.peerfinder -test.peerfinder > ripple.protocol +test.overlay > xrpl.basics +test.overlay > xrpld.app +test.overlay > xrpld.overlay +test.overlay > xrpld.peerfinder +test.overlay > xrpld.shamap +test.overlay > xrpl.protocol test.peerfinder > test.beast test.peerfinder > test.unit_test -test.protocol > ripple.basics -test.protocol > ripple.beast -test.protocol > ripple.crypto -test.protocol > ripple.json -test.protocol > ripple.protocol +test.peerfinder > xrpl.basics +test.peerfinder > xrpld.core +test.peerfinder > xrpld.peerfinder +test.peerfinder > xrpl.protocol test.protocol > test.toplevel -test.resource > ripple.basics -test.resource > ripple.beast -test.resource > ripple.resource +test.protocol > xrpl.basics +test.protocol > xrpl.json +test.protocol > xrpl.protocol test.resource > test.unit_test -test.rpc > ripple.app -test.rpc > ripple.basics -test.rpc > ripple.beast -test.rpc > ripple.core -test.rpc > ripple.json -test.rpc > ripple.net -test.rpc > ripple.nodestore -test.rpc > ripple.overlay -test.rpc > ripple.protocol -test.rpc > ripple.resource -test.rpc > ripple.rpc +test.resource > xrpl.basics +test.resource > xrpl.resource test.rpc > test.jtx test.rpc > test.nodestore test.rpc > test.toplevel -test.server > ripple.app -test.server > ripple.basics -test.server > ripple.beast -test.server > ripple.core -test.server > ripple.json -test.server > ripple.rpc -test.server > ripple.server +test.rpc > xrpl.basics +test.rpc > xrpld.app +test.rpc > xrpld.core +test.rpc > xrpld.net +test.rpc > xrpld.nodestore +test.rpc > xrpld.overlay +test.rpc > xrpld.rpc +test.rpc > xrpl.json +test.rpc > xrpl.protocol +test.rpc > xrpl.resource test.server > test.jtx test.server > test.toplevel test.server > test.unit_test -test.shamap > ripple.basics -test.shamap > ripple.beast -test.shamap > ripple.nodestore -test.shamap > ripple.protocol -test.shamap > ripple.shamap +test.server > xrpl.basics +test.server > xrpld.app +test.server > xrpld.core +test.server > xrpld.rpc +test.server > xrpl.json +test.server > xrpl.server test.shamap > test.unit_test -test.toplevel > ripple.json +test.shamap > xrpl.basics +test.shamap > xrpld.nodestore +test.shamap > xrpld.shamap +test.shamap > xrpl.protocol test.toplevel > test.csf -test.unit_test > ripple.basics -test.unit_test > ripple.beast +test.toplevel > xrpl.json +test.unit_test > xrpl.basics +xrpl.protocol > xrpl.basics +xrpl.protocol > xrpl.json +xrpl.resource > xrpl.basics +xrpl.resource > xrpl.json +xrpl.resource > xrpl.protocol +xrpl.server > xrpl.basics +xrpl.server > xrpl.json +xrpl.server > xrpl.protocol +xrpld.app > test.unit_test +xrpld.app > xrpl.basics +xrpld.app > xrpld.conditions +xrpld.app > xrpld.consensus +xrpld.app > xrpld.perflog +xrpld.app > xrpl.json +xrpld.app > xrpl.protocol +xrpld.app > xrpl.resource +xrpld.conditions > xrpl.basics +xrpld.conditions > xrpl.protocol +xrpld.consensus > xrpl.basics +xrpld.consensus > xrpl.json +xrpld.consensus > xrpl.protocol +xrpld.core > xrpl.basics +xrpld.core > xrpl.json +xrpld.core > xrpl.protocol +xrpld.ledger > xrpl.basics +xrpld.ledger > xrpld.core +xrpld.ledger > xrpl.json +xrpld.ledger > xrpl.protocol +xrpld.net > xrpl.basics +xrpld.net > xrpl.json +xrpld.net > xrpl.protocol +xrpld.net > xrpl.resource +xrpld.nodestore > xrpl.basics +xrpld.nodestore > xrpld.core +xrpld.nodestore > xrpld.unity +xrpld.nodestore > xrpl.json +xrpld.nodestore > xrpl.protocol +xrpld.overlay > xrpl.basics +xrpld.overlay > xrpld.core +xrpld.overlay > xrpld.peerfinder +xrpld.overlay > xrpl.json +xrpld.overlay > xrpl.protocol +xrpld.overlay > xrpl.resource +xrpld.overlay > xrpl.server +xrpld.peerfinder > xrpl.basics +xrpld.peerfinder > xrpld.core +xrpld.peerfinder > xrpl.protocol +xrpld.perflog > xrpl.basics +xrpld.perflog > xrpld.nodestore +xrpld.perflog > xrpl.json +xrpld.perflog > xrpl.protocol +xrpld.rpc > xrpl.basics +xrpld.rpc > xrpld.core +xrpld.rpc > xrpld.ledger +xrpld.rpc > xrpld.nodestore +xrpld.rpc > xrpld.shamap +xrpld.rpc > xrpl.json +xrpld.rpc > xrpl.protocol +xrpld.rpc > xrpl.resource +xrpld.rpc > xrpl.server +xrpld.shamap > xrpl.basics +xrpld.shamap > xrpld.nodestore +xrpld.shamap > xrpl.protocol diff --git a/CMakeLists.txt b/CMakeLists.txt index dcb493e5293..a69583f9cbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ endif() # Fix "unrecognized escape" issues when passing CMAKE_MODULE_PATH on Windows. file(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -project(rippled) +project(xrpl) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -81,7 +81,6 @@ find_package(lz4 REQUIRED) find_package(LibArchive REQUIRED) find_package(SOCI REQUIRED) find_package(SQLite3 REQUIRED) -find_package(Snappy REQUIRED) option(rocksdb "Enable RocksDB" ON) if(rocksdb) @@ -129,9 +128,7 @@ if(coverage) include(RippledCov) endif() -### - +set(PROJECT_EXPORT_SET RippleExports) include(RippledCore) include(RippledInstall) -include(RippledMultiConfig) include(RippledValidatorKeys) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed4656651cf..5355878fa79 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -119,6 +119,16 @@ this: You can format individual files in place by running `clang-format -i ...` from any directory within this project. +There is a Continuous Integration job that runs clang-format on pull requests. If the code doesn't comply, a patch file that corrects auto-fixable formatting issues is generated. + +To download the patch file: + +1. Next to `clang-format / check (pull_request) Failing after #s` -> click **Details** to open the details page. +2. Left menu -> click **Summary** +3. Scroll down to near the bottom-right under `Artifacts` -> click **clang-format.patch** +4. Download the zip file and extract it to your local git repository. Run `git apply [patch-file-name]`. +5. Commit and push. + You can install a pre-commit hook to automatically run `clang-format` before every commit: ``` pip3 install pre-commit @@ -197,15 +207,39 @@ existing maintainer without a vote. ## Current Maintainers +Maintainers are users with admin access to the repo. Maintainers do not typically approve or deny pull requests. + +* [intelliot](https://github.com/intelliot) (Ripple) * [JoelKatz](https://github.com/JoelKatz) (Ripple) -* [manojsdoshi](https://github.com/manojsdoshi) (Ripple) -* [n3tc4t](https://github.com/n3tc4t) (XRPL Labs) * [nixer89](https://github.com/nixer89) (XRP Ledger Foundation) -* [RichardAH](https://github.com/RichardAH) (XRPL Labs + XRP Ledger Foundation) -* [seelabs](https://github.com/seelabs) (Ripple) * [Silkjaer](https://github.com/Silkjaer) (XRP Ledger Foundation) * [WietseWind](https://github.com/WietseWind) (XRPL Labs + XRP Ledger Foundation) + +## Current Code Reviewers + +Code Reviewers are developers who have the ability to review and approve source code changes. + +* [HowardHinnant](https://github.com/HowardHinnant) (Ripple) +* [scottschurr](https://github.com/scottschurr) (Ripple) +* [seelabs](https://github.com/seelabs) (Ripple) * [Ed Hennis](https://github.com/ximinez) (Ripple) +* [mvadari](https://github.com/mvadari) (Ripple) +* [thejohnfreeman](https://github.com/thejohnfreeman) (Ripple) +* [Bronek](https://github.com/Bronek) (Ripple) +* [manojsdoshi](https://github.com/manojsdoshi) (Ripple) +* [godexsoft](https://github.com/godexsoft) (Ripple) +* [mDuo13](https://github.com/mDuo13) (Ripple) +* [ckniffen](https://github.com/ckniffen) (Ripple) +* [arihantkothari](https://github.com/arihantkothari) (Ripple) +* [pwang200](https://github.com/pwang200) (Ripple) +* [sophiax851](https://github.com/sophiax851) (Ripple) +* [shawnxie999](https://github.com/shawnxie999) (Ripple) +* [gregtatcam](https://github.com/gregtatcam) (Ripple) +* [mtrippled](https://github.com/mtrippled) (Ripple) +* [ckeshava](https://github.com/ckeshava) (Ripple) +* [nbougalis](https://github.com/nbougalis) None +* [RichardAH](https://github.com/RichardAH) (XRPL Labs + XRP Ledger Foundation) +* [dangell7](https://github.com/dangell7) (XRPL Labs) [1]: https://docs.github.com/en/get-started/quickstart/contributing-to-projects diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 7c924209ef3..cfc0e618cfe 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -6,6 +6,95 @@ This document contains the release notes for `rippled`, the reference server imp Have new ideas? Need help with setting up your node? [Please open an issue here](https://github.com/xrplf/rippled/issues/new/choose). +# Version 2.2.0 + +Version 2.2.0 of `rippled`, the reference server implementation of the XRP Ledger protocol, is now available. This release adds performance optimizations, several bug fixes, and introduces the `featurePriceOracle`, `fixEmptyDID`, `fixXChainRewardRounding`, `fixPreviousTxnID`, and `fixAMMv1_1` amendments. + +[Sign Up for Future Release Announcements](https://groups.google.com/g/ripple-server) + + + +## Action Required + +Five new amendments are now open for voting according to the XRP Ledger's [amendment process](https://xrpl.org/amendments.html), which enables protocol changes following two weeks of >80% support from trusted validators. + +If you operate an XRP Ledger server, upgrade to version 2.2.0 by June 17, 2024 to ensure service continuity. The exact time that protocol changes take effect depends on the voting decisions of the decentralized network. + +If you operate a Clio server, Clio needs to be updated to 2.1.2 before updating to rippled 2.2.0. Clio will be blocked if it is not updated. + +## Changelog + +### Amendments and New Features +(These are changes which may impact or be useful to end users. For example, you may be able to update your code/workflow to take advantage of these changes.) + +- **featurePriceOracle** amendment: Implements a price oracle as defined in the [XLS-47](https://github.com/XRPLF/XRPL-Standards/blob/master/XLS-47d-PriceOracles/README.md) spec. A Price Oracle is used to bring real-world data, such as market prices, onto the blockchain, enabling dApps to access and utilize information that resides outside the blockchain. [#4789](https://github.com/XRPLF/rippled/pull/4789) + +- **fixEmptyDID** amendment: Modifies the behavior of the DID amendment: adds an additional check to ensure that DIDs are non-empty when created, and returns a `tecEMPTY_DID` error if the DID would be empty. [#4950](https://github.com/XRPLF/rippled/pull/4950) + +- **fixXChainRewardRounding** amendment: Modifies the behavior of the XChainBridge amendment: fixes rounding so reward shares are always rounded down, even when the `fixUniversalNumber` amendment is active. [#4933](https://github.com/XRPLF/rippled/pull/4933) + +- **fixPreviousTxnID** amendment: Adds `PreviousTxnID` and `PreviousTxnLgrSequence` as fields to all ledger entries that did not already have them included (`DirectoryNode`, `Amendments`, `FeeSettings`, `NegativeUNL`, and `AMM`). Existing ledger entries will gain the fields whenever transactions modify those entries. [#4751](https://github.com/XRPLF/rippled/pull/4751). + +- **fixAMMv1_1** amendment: Fixes AMM offer rounding and low quality order book offers from blocking the AMM. [#4983](https://github.com/XRPLF/rippled/pull/4983) + +- Add a non-admin version of `feature` API method. [#4781](https://github.com/XRPLF/rippled/pull/4781) + +### Bug Fixes and Performance Improvements +(These are behind-the-scenes improvements, such as internal changes to the code, which are not expected to impact end users.) + +- Optimize the base58 encoder and decoder. The algorithm is now about 10 times faster for encoding and 15 times faster for decoding. [#4327](https://github.com/XRPLF/rippled/pull/4327) + +- Optimize the `account_tx` SQL query. [#4955](https://github.com/XRPLF/rippled/pull/4955) + +- Don't reach consensus as quickly if no other proposals are seen. [#4763](https://github.com/XRPLF/rippled/pull/4763) + +- Fix a potential deadlock in the database module. [#4989](https://github.com/XRPLF/rippled/pull/4989) + +- Enforce no duplicate slots from incoming connections. [#4944](https://github.com/XRPLF/rippled/pull/4944) + +- Fix an order book update variable swap. [#4890](https://github.com/XRPLF/rippled/pull/4890) + +### Docs and Build System + +- Add unit test to raise the test coverage of the AMM. [#4971](https://github.com/XRPLF/rippled/pull/4971) + +- Improve test coverage reporting. [#4977](https://github.com/XRPLF/rippled/pull/4977) + +### GitHub + +The public source code repository for `rippled` is hosted on GitHub at . + +We welcome all contributions and invite everyone to join the community of XRP Ledger developers to help build the Internet of Value. + + +## Credits + +The following people contributed directly to this release: + +Alex Kremer +Alloy Networks <45832257+alloynetworks@users.noreply.github.com> +Bronek Kozicki +Chenna Keshava +Denis Angell +Ed Hennis +Gregory Tsipenyuk +Howard Hinnant +John Freeman +Mark Travis +Mayukha Vadari +Michael Legleux +Nik Bougalis +Olek <115580134+oleks-rip@users.noreply.github.com> +Scott Determan +Snoppy + +Bug Bounties and Responsible Disclosures: + +We welcome reviews of the `rippled` code and urge researchers to responsibly disclose any issues they may find. + +To report a bug, please send a detailed report to: + + ## Version 2.1.1 The `rippled` 2.1.1 release fixes a critical bug in the integration of AMMs with the payment engine. diff --git a/bin/physical.sh b/bin/physical.sh new file mode 100755 index 00000000000..c2c5aad68db --- /dev/null +++ b/bin/physical.sh @@ -0,0 +1,218 @@ +#!/bin/bash + +set -o errexit + +marker_base=985c80fbc6131f3a8cedd0da7e8af98dfceb13c7 +marker_commit=${1:-${marker_base}} + +if [ $(git merge-base ${marker_commit} ${marker_base}) != ${marker_base} ]; then + echo "first marker commit not an ancestor: ${marker_commit}" + exit 1 +fi + +if [ $(git merge-base ${marker_commit} HEAD) != $(git rev-parse --verify ${marker_commit}) ]; then + echo "given marker commit not an ancestor: ${marker_commit}" + exit 1 +fi + +if [ -e Builds/CMake ]; then + echo move CMake + git mv Builds/CMake cmake + git add --update . + git commit -m 'Move CMake directory' --author 'Pretty Printer ' +fi + +if [ -e src/ripple ]; then + + echo move protocol buffers + mkdir -p include/xrpl + if [ -e src/ripple/proto ]; then + git mv src/ripple/proto include/xrpl + fi + + extract_list() { + git show ${marker_commit}:Builds/CMake/RippledCore.cmake | \ + awk "/END ${1}/ { p = 0 } p && /src\/ripple/; /BEGIN ${1}/ { p = 1 }" | \ + sed -e 's#src/ripple/##' -e 's#[^a-z]\+$##' + } + + move_files() { + oldroot="$1"; shift + newroot="$1"; shift + detail="$1"; shift + files=("$@") + for file in ${files[@]}; do + if [ ! -e ${oldroot}/${file} ]; then + continue + fi + dir=$(dirname ${file}) + if [ $(basename ${dir}) == 'details' ]; then + dir=$(dirname ${dir}) + fi + if [ $(basename ${dir}) == 'impl' ]; then + dir="$(dirname ${dir})/${detail}" + fi + mkdir -p ${newroot}/${dir} + git mv ${oldroot}/${file} ${newroot}/${dir} + done + } + + echo move libxrpl headers + files=$(extract_list 'LIBXRPL HEADERS') + files+=( + basics/SlabAllocator.h + + beast/asio/io_latency_probe.h + beast/container/aged_container.h + beast/container/aged_container_utility.h + beast/container/aged_map.h + beast/container/aged_multimap.h + beast/container/aged_multiset.h + beast/container/aged_set.h + beast/container/aged_unordered_map.h + beast/container/aged_unordered_multimap.h + beast/container/aged_unordered_multiset.h + beast/container/aged_unordered_set.h + beast/container/detail/aged_associative_container.h + beast/container/detail/aged_container_iterator.h + beast/container/detail/aged_ordered_container.h + beast/container/detail/aged_unordered_container.h + beast/container/detail/empty_base_optimization.h + beast/core/LockFreeStack.h + beast/insight/Collector.h + beast/insight/Counter.h + beast/insight/CounterImpl.h + beast/insight/Event.h + beast/insight/EventImpl.h + beast/insight/Gauge.h + beast/insight/GaugeImpl.h + beast/insight/Group.h + beast/insight/Groups.h + beast/insight/Hook.h + beast/insight/HookImpl.h + beast/insight/Insight.h + beast/insight/Meter.h + beast/insight/MeterImpl.h + beast/insight/NullCollector.h + beast/insight/StatsDCollector.h + beast/test/fail_counter.h + beast/test/fail_stream.h + beast/test/pipe_stream.h + beast/test/sig_wait.h + beast/test/string_iostream.h + beast/test/string_istream.h + beast/test/string_ostream.h + beast/test/test_allocator.h + beast/test/yield_to.h + beast/utility/hash_pair.h + beast/utility/maybe_const.h + beast/utility/temp_dir.h + + # included by only json/impl/json_assert.h + json/json_errors.h + + protocol/PayChan.h + protocol/RippleLedgerHash.h + protocol/messages.h + protocol/st.h + ) + files+=( + basics/README.md + crypto/README.md + json/README.md + protocol/README.md + resource/README.md + ) + move_files src/ripple include/xrpl detail ${files[@]} + + echo move libxrpl sources + files=$(extract_list 'LIBXRPL SOURCES') + move_files src/ripple src/libxrpl "" ${files[@]} + + echo check leftovers + dirs=$(cd include/xrpl; ls -d */) + dirs=$(cd src/ripple; ls -d ${dirs} 2>/dev/null || true) + files="$(cd src/ripple; find ${dirs} -type f)" + if [ -n "${files}" ]; then + echo "leftover files:" + echo ${files} + exit + fi + + echo remove empty directories + empty_dirs="$(cd src/ripple; find ${dirs} -depth -type d)" + for dir in ${empty_dirs[@]}; do + if [ -e ${dir} ]; then + rmdir ${dir} + fi + done + + echo move xrpld sources + files=$( + extract_list 'XRPLD SOURCES' + cd src/ripple + find * -regex '.*\.\(h\|ipp\|md\|pu\|uml\|png\)' + ) + move_files src/ripple src/xrpld detail ${files[@]} + + files="$(cd src/ripple; find . -type f)" + if [ -n "${files}" ]; then + echo "leftover files:" + echo ${files} + exit + fi + +fi + +rm -rf src/ripple + +echo rename .hpp to .h +find include src -name '*.hpp' -exec bash -c 'f="{}"; git mv "${f}" "${f%hpp}h"' \; + +echo move PerfLog.h +if [ -e include/xrpl/basics/PerfLog.h ]; then + git mv include/xrpl/basics/PerfLog.h src/xrpld/perflog +fi + +# Make sure all protobuf includes have the correct prefix. +protobuf_replace='s:^#include\s*["<].*org/xrpl\([^">]\+\)[">]:#include :' +# Make sure first-party includes use angle brackets and .h extension. +ripple_replace='s:include\s*["<]ripple/\(.*\)\.h\(pp\)\?[">]:include :' +beast_replace='s:include\s*:#include :" \ + -e "s:^#include ' +find include src -type f \( -name '*.cpp' -o -name '*.h' -o -name '*.ipp' \) -exec clang-format-10 -i {} + +git add --update . +git commit -m 'Rewrite includes' --author 'Pretty Printer ' +./Builds/levelization/levelization.sh +git add --update . +git commit -m 'Recompute loops' --author 'Pretty Printer ' diff --git a/Builds/CMake/CMakeFuncs.cmake b/cmake/CMakeFuncs.cmake similarity index 100% rename from Builds/CMake/CMakeFuncs.cmake rename to cmake/CMakeFuncs.cmake diff --git a/Builds/CMake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake similarity index 100% rename from Builds/CMake/CodeCoverage.cmake rename to cmake/CodeCoverage.cmake diff --git a/Builds/CMake/RippleConfig.cmake b/cmake/RippleConfig.cmake similarity index 100% rename from Builds/CMake/RippleConfig.cmake rename to cmake/RippleConfig.cmake diff --git a/Builds/CMake/RippledCompiler.cmake b/cmake/RippledCompiler.cmake similarity index 100% rename from Builds/CMake/RippledCompiler.cmake rename to cmake/RippledCompiler.cmake diff --git a/cmake/RippledCore.cmake b/cmake/RippledCore.cmake new file mode 100644 index 00000000000..9af3303f662 --- /dev/null +++ b/cmake/RippledCore.cmake @@ -0,0 +1,146 @@ +#[===================================================================[ + Exported targets. +#]===================================================================] + +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) +target_protobuf_sources(xrpl.libpb xrpl/proto + LANGUAGE cpp + IMPORT_DIRS include/xrpl/proto + PROTOS include/xrpl/proto/ripple.proto +) + +file(GLOB_RECURSE protos "include/xrpl/proto/org/*.proto") +target_protobuf_sources(xrpl.libpb xrpl/proto + LANGUAGE cpp + IMPORT_DIRS include/xrpl/proto + PROTOS "${protos}" +) +target_protobuf_sources(xrpl.libpb xrpl/proto + LANGUAGE grpc + IMPORT_DIRS include/xrpl/proto + PROTOS "${protos}" + PLUGIN protoc-gen-grpc=$ + GENERATE_EXTENSIONS .grpc.pb.h .grpc.pb.cc +) + +target_compile_options(xrpl.libpb + PUBLIC + $<$:-wd4996> + $<$: + --system-header-prefix="google/protobuf" + -Wno-deprecated-dynamic-exception-spec + > + PRIVATE + $<$:-wd4065> + $<$>:-Wno-deprecated-declarations> +) + +target_link_libraries(xrpl.libpb + PUBLIC + protobuf::libprotobuf + gRPC::grpc++ +) + +add_library(xrpl.libxrpl) +set_target_properties(xrpl.libxrpl PROPERTIES OUTPUT_NAME xrpl) +if(unity) + set_target_properties(xrpl.libxrpl PROPERTIES UNITY_BUILD ON) +endif() + +add_library(xrpl::libxrpl ALIAS xrpl.libxrpl) + +file(GLOB_RECURSE sources CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/libxrpl/*.cpp" +) +target_sources(xrpl.libxrpl PRIVATE ${sources}) + +target_include_directories(xrpl.libxrpl + PUBLIC + $ + $) + +target_compile_definitions(xrpl.libxrpl + PUBLIC + BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT + BOOST_CONTAINER_FWD_BAD_DEQUE + HAS_UNCAUGHT_EXCEPTIONS=1) + +target_compile_options(xrpl.libxrpl + PUBLIC + $<$:-Wno-maybe-uninitialized> +) + +target_link_libraries(xrpl.libxrpl + PUBLIC + LibArchive::LibArchive + OpenSSL::Crypto + Ripple::boost + Ripple::opts + Ripple::syslibs + absl::random_random + date::date + ed25519::ed25519 + secp256k1::secp256k1 + xrpl.libpb + xxHash::xxhash +) + +add_executable(rippled) +if(unity) + set_target_properties(rippled PROPERTIES UNITY_BUILD ON) +endif() +if(tests) + target_compile_definitions(rippled PUBLIC ENABLE_TESTS) +endif() +target_include_directories(rippled + PRIVATE + $ +) + +file(GLOB_RECURSE sources CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/xrpld/*.cpp" +) +target_sources(rippled PRIVATE ${sources}) + +if(tests) + file(GLOB_RECURSE sources CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/src/test/*.cpp" + ) + target_sources(rippled PRIVATE ${sources}) +endif() + +target_link_libraries(rippled + Ripple::boost + Ripple::opts + Ripple::libs + xrpl.libxrpl +) +exclude_if_included(rippled) +# define a macro for tests that might need to +# be exluded or run differently in CI environment +if(is_ci) + target_compile_definitions(rippled PRIVATE RIPPLED_RUNNING_IN_CI) +endif () + +if(reporting) + set(suffix -reporting) + set_target_properties(rippled PROPERTIES OUTPUT_NAME rippled-reporting) + get_target_property(BIN_NAME rippled OUTPUT_NAME) + message(STATUS "Reporting mode build: rippled renamed ${BIN_NAME}") + target_compile_definitions(rippled PRIVATE RIPPLED_REPORTING) +endif() + +# any files that don't play well with unity should be added here +if(tests) + set_source_files_properties( + # these two seem to produce conflicts in beast teardown template methods + src/test/rpc/ValidatorRPC_test.cpp + src/test/rpc/ShardArchiveHandler_test.cpp + PROPERTIES SKIP_UNITY_BUILD_INCLUSION TRUE) +endif() diff --git a/Builds/CMake/RippledCov.cmake b/cmake/RippledCov.cmake similarity index 100% rename from Builds/CMake/RippledCov.cmake rename to cmake/RippledCov.cmake diff --git a/Builds/CMake/RippledDocs.cmake b/cmake/RippledDocs.cmake similarity index 98% rename from Builds/CMake/RippledDocs.cmake rename to cmake/RippledDocs.cmake index e7c42942a77..a9b8b283bf0 100644 --- a/Builds/CMake/RippledDocs.cmake +++ b/cmake/RippledDocs.cmake @@ -25,8 +25,7 @@ file(GLOB_RECURSE doxygen_input src/ripple/*.cpp src/ripple/*.md src/test/*.h - src/test/*.md - Builds/*/README.md) + src/test/*.md) list(APPEND doxygen_input README.md RELEASENOTES.md diff --git a/Builds/CMake/RippledInstall.cmake b/cmake/RippledInstall.cmake similarity index 77% rename from Builds/CMake/RippledInstall.cmake rename to cmake/RippledInstall.cmake index b9dd44cfc2c..d92cecc24eb 100644 --- a/Builds/CMake/RippledInstall.cmake +++ b/cmake/RippledInstall.cmake @@ -8,14 +8,19 @@ install ( opts ripple_syslibs ripple_boost - xrpl_core xrpl.libpb + xrpl.libxrpl EXPORT RippleExports LIBRARY DESTINATION lib ARCHIVE DESTINATION lib RUNTIME DESTINATION bin INCLUDES DESTINATION include) +install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/xrpl" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +) + install (EXPORT RippleExports FILE RippleTargets.cmake NAMESPACE Ripple:: @@ -31,7 +36,7 @@ if (is_root_project) set_target_properties(rippled PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON) install ( FILES - ${CMAKE_CURRENT_SOURCE_DIR}/Builds/CMake/RippleConfig.cmake + ${CMAKE_CURRENT_SOURCE_DIR}/cmake/RippleConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/RippleConfigVersion.cmake DESTINATION lib/cmake/ripple) # sample configs should not overwrite existing files @@ -49,3 +54,17 @@ if (is_root_project) copy_if_not_exists(\"${CMAKE_CURRENT_SOURCE_DIR}/cfg/validators-example.txt\" etc validators.txt) ") endif () + +if(NOT WIN32) + install( + CODE "file(CREATE_LINK xrpl \ + \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/ripple SYMBOLIC)" + ) +endif() + +if(NOT WIN32) + install( + CODE "file(CREATE_LINK rippled${suffix} \ + \${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/xrpld${suffix} SYMBOLIC)" + ) +endif() diff --git a/Builds/CMake/RippledInterface.cmake b/cmake/RippledInterface.cmake similarity index 100% rename from Builds/CMake/RippledInterface.cmake rename to cmake/RippledInterface.cmake diff --git a/Builds/CMake/RippledSanity.cmake b/cmake/RippledSanity.cmake similarity index 100% rename from Builds/CMake/RippledSanity.cmake rename to cmake/RippledSanity.cmake diff --git a/Builds/CMake/RippledSettings.cmake b/cmake/RippledSettings.cmake similarity index 100% rename from Builds/CMake/RippledSettings.cmake rename to cmake/RippledSettings.cmake diff --git a/Builds/CMake/RippledValidatorKeys.cmake b/cmake/RippledValidatorKeys.cmake similarity index 100% rename from Builds/CMake/RippledValidatorKeys.cmake rename to cmake/RippledValidatorKeys.cmake diff --git a/cmake/RippledVersion.cmake b/cmake/RippledVersion.cmake new file mode 100644 index 00000000000..fda3cb6ff7b --- /dev/null +++ b/cmake/RippledVersion.cmake @@ -0,0 +1,15 @@ +#[===================================================================[ + read version from source +#]===================================================================] + +file(STRINGS src/libxrpl/protocol/BuildInfo.cpp BUILD_INFO) +foreach(line_ ${BUILD_INFO}) + if(line_ MATCHES "versionString[ ]*=[ ]*\"(.+)\"") + set(rippled_version ${CMAKE_MATCH_1}) + endif() +endforeach() +if(rippled_version) + message(STATUS "rippled version: ${rippled_version}") +else() + message(FATAL_ERROR "unable to determine rippled version") +endif() diff --git a/Builds/CMake/deps/Boost.cmake b/cmake/deps/Boost.cmake similarity index 100% rename from Builds/CMake/deps/Boost.cmake rename to cmake/deps/Boost.cmake diff --git a/Builds/CMake/target_protobuf_sources.cmake b/cmake/target_protobuf_sources.cmake similarity index 100% rename from Builds/CMake/target_protobuf_sources.cmake rename to cmake/target_protobuf_sources.cmake diff --git a/conanfile.py b/conanfile.py index e61728039fc..68b0a7cd405 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,19 +24,14 @@ class Xrpl(ConanFile): } requires = [ - 'boost/1.82.0', 'date/3.0.1', 'grpc/1.50.1', 'libarchive/3.6.2', - 'lz4/1.9.3', 'nudb/2.0.8', 'openssl/1.1.1u', - 'protobuf/3.21.9', - 'snappy/1.1.10', 'soci/4.0.3', - 'sqlite3/3.42.0', - 'zlib/1.2.13', 'xxhash/0.8.2', + 'zlib/1.2.13', ] tool_requires = [ @@ -55,47 +50,47 @@ class Xrpl(ConanFile): 'tests': True, 'unity': False, - 'cassandra-cpp-driver:shared': False, - 'cassandra-cpp-driver:use_atomic': None, - 'date:header_only': True, - 'grpc:shared': False, - 'grpc:secure': True, - 'libarchive:shared': False, - 'libarchive:with_acl': False, - 'libarchive:with_bzip2': False, - 'libarchive:with_cng': False, - 'libarchive:with_expat': False, - 'libarchive:with_iconv': False, - 'libarchive:with_libxml2': False, - 'libarchive:with_lz4': True, - 'libarchive:with_lzma': False, - 'libarchive:with_lzo': False, - 'libarchive:with_nettle': False, - 'libarchive:with_openssl': False, - 'libarchive:with_pcreposix': False, - 'libarchive:with_xattr': False, - 'libarchive:with_zlib': False, - 'libpq:shared': False, - 'lz4:shared': False, - 'openssl:shared': False, - 'protobuf:shared': False, - 'protobuf:with_zlib': True, - 'rocksdb:enable_sse': False, - 'rocksdb:lite': False, - 'rocksdb:shared': False, - 'rocksdb:use_rtti': True, - 'rocksdb:with_jemalloc': False, - 'rocksdb:with_lz4': True, - 'rocksdb:with_snappy': True, - 'snappy:shared': False, - 'soci:shared': False, - 'soci:with_sqlite3': True, - 'soci:with_boost': True, - 'xxhash:shared': False, + 'cassandra-cpp-driver/*:shared': False, + 'cassandra-cpp-driver/*:use_atomic': None, + 'date/*:header_only': True, + 'grpc/*:shared': False, + 'grpc/*:secure': True, + 'libarchive/*:shared': False, + 'libarchive/*:with_acl': False, + 'libarchive/*:with_bzip2': False, + 'libarchive/*:with_cng': False, + 'libarchive/*:with_expat': False, + 'libarchive/*:with_iconv': False, + 'libarchive/*:with_libxml2': False, + 'libarchive/*:with_lz4': True, + 'libarchive/*:with_lzma': False, + 'libarchive/*:with_lzo': False, + 'libarchive/*:with_nettle': False, + 'libarchive/*:with_openssl': False, + 'libarchive/*:with_pcreposix': False, + 'libarchive/*:with_xattr': False, + 'libarchive/*:with_zlib': False, + 'libpq/*:shared': False, + 'lz4/*:shared': False, + 'openssl/*:shared': False, + 'protobuf/*:shared': False, + 'protobuf/*:with_zlib': True, + 'rocksdb/*:enable_sse': False, + 'rocksdb/*:lite': False, + 'rocksdb/*:shared': False, + 'rocksdb/*:use_rtti': True, + 'rocksdb/*:with_jemalloc': False, + 'rocksdb/*:with_lz4': True, + 'rocksdb/*:with_snappy': True, + 'snappy/*:shared': False, + 'soci/*:shared': False, + 'soci/*:with_sqlite3': True, + 'soci/*:with_boost': True, + 'xxhash/*:shared': False, } def set_version(self): - path = f'{self.recipe_folder}/src/ripple/protocol/impl/BuildInfo.cpp' + path = f'{self.recipe_folder}/src/libxrpl/protocol/BuildInfo.cpp' regex = r'versionString\s?=\s?\"(.*)\"' with open(path, 'r') as file: matches = (re.search(regex, line) for line in file) @@ -107,6 +102,10 @@ def configure(self): self.options['boost'].visibility = 'global' def requirements(self): + self.requires('boost/1.82.0', force=True) + self.requires('lz4/1.9.3', force=True) + self.requires('protobuf/3.21.9', force=True) + self.requires('sqlite3/3.42.0', force=True) if self.options.jemalloc: self.requires('jemalloc/5.3.0') if self.options.reporting: @@ -116,7 +115,13 @@ def requirements(self): self.requires('rocksdb/6.29.5') exports_sources = ( - 'CMakeLists.txt', 'Builds/*', 'bin/getRippledInfo', 'src/*', 'cfg/*', 'external/*' + 'CMakeLists.txt', + 'bin/getRippledInfo', + 'cfg/*', + 'cmake/*', + 'external/*', + 'include/*', + 'src/*', ) def layout(self): @@ -153,7 +158,8 @@ def package(self): def package_info(self): libxrpl = self.cpp_info.components['libxrpl'] libxrpl.libs = [ - 'xrpl_core', + 'xrpl', + 'xrpl.libpb', 'ed25519', 'secp256k1', ] @@ -162,8 +168,17 @@ def package_info(self): libxrpl.includedirs = ['include', 'include/ripple/proto'] libxrpl.requires = [ 'boost::boost', - 'openssl::crypto', 'date::date', 'grpc::grpc++', + 'libarchive::libarchive', + 'lz4::lz4', + 'nudb::nudb', + 'openssl::crypto', + 'protobuf::libprotobuf', + 'soci::soci', + 'sqlite3::sqlite', 'xxhash::xxhash', + 'zlib::zlib', ] + if self.options.rocksdb: + libxrpl.requires.append('rocksdb::librocksdb') diff --git a/src/ripple/basics/Archive.h b/include/xrpl/basics/Archive.h similarity index 100% rename from src/ripple/basics/Archive.h rename to include/xrpl/basics/Archive.h diff --git a/src/ripple/basics/BasicConfig.h b/include/xrpl/basics/BasicConfig.h similarity index 99% rename from src/ripple/basics/BasicConfig.h rename to include/xrpl/basics/BasicConfig.h index db293979f13..8f522cdd2f2 100644 --- a/src/ripple/basics/BasicConfig.h +++ b/include/xrpl/basics/BasicConfig.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_BASICCONFIG_H_INCLUDED #define RIPPLE_BASICS_BASICCONFIG_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/Blob.h b/include/xrpl/basics/Blob.h similarity index 100% rename from src/ripple/basics/Blob.h rename to include/xrpl/basics/Blob.h diff --git a/src/ripple/basics/Buffer.h b/include/xrpl/basics/Buffer.h similarity index 99% rename from src/ripple/basics/Buffer.h rename to include/xrpl/basics/Buffer.h index 706b8b627f1..25ae8ca315c 100644 --- a/src/ripple/basics/Buffer.h +++ b/include/xrpl/basics/Buffer.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_BUFFER_H_INCLUDED #define RIPPLE_BASICS_BUFFER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/ByteUtilities.h b/include/xrpl/basics/ByteUtilities.h similarity index 100% rename from src/ripple/basics/ByteUtilities.h rename to include/xrpl/basics/ByteUtilities.h diff --git a/src/ripple/basics/CompressionAlgorithms.h b/include/xrpl/basics/CompressionAlgorithms.h similarity index 99% rename from src/ripple/basics/CompressionAlgorithms.h rename to include/xrpl/basics/CompressionAlgorithms.h index eef2608916d..4defd5a4904 100644 --- a/src/ripple/basics/CompressionAlgorithms.h +++ b/include/xrpl/basics/CompressionAlgorithms.h @@ -20,7 +20,7 @@ #ifndef RIPPLED_COMPRESSIONALGORITHMS_H_INCLUDED #define RIPPLED_COMPRESSIONALGORITHMS_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/CountedObject.h b/include/xrpl/basics/CountedObject.h similarity index 99% rename from src/ripple/basics/CountedObject.h rename to include/xrpl/basics/CountedObject.h index 690841fe1ef..9ea76aa3bd0 100644 --- a/src/ripple/basics/CountedObject.h +++ b/include/xrpl/basics/CountedObject.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_COUNTEDOBJECT_H_INCLUDED #define RIPPLE_BASICS_COUNTEDOBJECT_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/DecayingSample.h b/include/xrpl/basics/DecayingSample.h similarity index 100% rename from src/ripple/basics/DecayingSample.h rename to include/xrpl/basics/DecayingSample.h diff --git a/src/ripple/basics/Expected.h b/include/xrpl/basics/Expected.h similarity index 99% rename from src/ripple/basics/Expected.h rename to include/xrpl/basics/Expected.h index bb699579b17..745fa50a69f 100644 --- a/src/ripple/basics/Expected.h +++ b/include/xrpl/basics/Expected.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_EXPECTED_H_INCLUDED #define RIPPLE_BASICS_EXPECTED_H_INCLUDED -#include +#include #include diff --git a/src/ripple/basics/FeeUnits.h b/include/xrpl/basics/FeeUnits.h similarity index 99% rename from src/ripple/basics/FeeUnits.h rename to include/xrpl/basics/FeeUnits.h index 35e0ff24d05..9d5e6e216a4 100644 --- a/src/ripple/basics/FeeUnits.h +++ b/include/xrpl/basics/FeeUnits.h @@ -19,7 +19,7 @@ #ifndef BASICS_FEES_H_INCLUDED #define BASICS_FEES_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/FileUtilities.h b/include/xrpl/basics/FileUtilities.h similarity index 100% rename from src/ripple/basics/FileUtilities.h rename to include/xrpl/basics/FileUtilities.h diff --git a/src/ripple/basics/IOUAmount.h b/include/xrpl/basics/IOUAmount.h similarity index 97% rename from src/ripple/basics/IOUAmount.h rename to include/xrpl/basics/IOUAmount.h index 2380a7d15e1..221434aa85a 100644 --- a/src/ripple/basics/IOUAmount.h +++ b/include/xrpl/basics/IOUAmount.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_BASICS_IOUAMOUNT_H_INCLUDED #define RIPPLE_BASICS_IOUAMOUNT_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/basics/KeyCache.h b/include/xrpl/basics/KeyCache.h similarity index 94% rename from src/ripple/basics/KeyCache.h rename to include/xrpl/basics/KeyCache.h index d8fa4910ab9..1439a8b3344 100644 --- a/src/ripple/basics/KeyCache.h +++ b/include/xrpl/basics/KeyCache.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_KEYCACHE_H #define RIPPLE_BASICS_KEYCACHE_H -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/basics/LocalValue.h b/include/xrpl/basics/LocalValue.h similarity index 100% rename from src/ripple/basics/LocalValue.h rename to include/xrpl/basics/LocalValue.h diff --git a/src/ripple/basics/Log.h b/include/xrpl/basics/Log.h similarity index 98% rename from src/ripple/basics/Log.h rename to include/xrpl/basics/Log.h index 929225c0433..0117f2f9aab 100644 --- a/src/ripple/basics/Log.h +++ b/include/xrpl/basics/Log.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_LOG_H_INCLUDED #define RIPPLE_BASICS_LOG_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/basics/MathUtilities.h b/include/xrpl/basics/MathUtilities.h similarity index 100% rename from src/ripple/basics/MathUtilities.h rename to include/xrpl/basics/MathUtilities.h diff --git a/src/ripple/basics/Number.h b/include/xrpl/basics/Number.h similarity index 93% rename from src/ripple/basics/Number.h rename to include/xrpl/basics/Number.h index 48cea443ee3..30ce3f73173 100644 --- a/src/ripple/basics/Number.h +++ b/include/xrpl/basics/Number.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_NUMBER_H_INCLUDED #define RIPPLE_BASICS_NUMBER_H_INCLUDED -#include +#include #include #include #include @@ -387,6 +387,26 @@ class saveNumberRoundMode operator=(saveNumberRoundMode const&) = delete; }; +// saveNumberRoundMode doesn't do quite enough for us. What we want is a +// Number::RoundModeGuard that sets the new mode and restores the old mode +// when it leaves scope. Since Number doesn't have that facility, we'll +// build it here. +class NumberRoundModeGuard +{ + saveNumberRoundMode saved_; + +public: + explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept + : saved_{Number::setround(mode)} + { + } + + NumberRoundModeGuard(NumberRoundModeGuard const&) = delete; + + NumberRoundModeGuard& + operator=(NumberRoundModeGuard const&) = delete; +}; + } // namespace ripple #endif // RIPPLE_BASICS_NUMBER_H_INCLUDED diff --git a/src/ripple/basics/README.md b/include/xrpl/basics/README.md similarity index 100% rename from src/ripple/basics/README.md rename to include/xrpl/basics/README.md diff --git a/src/ripple/basics/RangeSet.h b/include/xrpl/basics/RangeSet.h similarity index 99% rename from src/ripple/basics/RangeSet.h rename to include/xrpl/basics/RangeSet.h index 3a9e470ddfb..0ffed2db1e2 100644 --- a/src/ripple/basics/RangeSet.h +++ b/include/xrpl/basics/RangeSet.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_RANGESET_H_INCLUDED #define RIPPLE_BASICS_RANGESET_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/basics/Resolver.h b/include/xrpl/basics/Resolver.h similarity index 98% rename from src/ripple/basics/Resolver.h rename to include/xrpl/basics/Resolver.h index abf04005707..6cba352e0a0 100644 --- a/src/ripple/basics/Resolver.h +++ b/include/xrpl/basics/Resolver.h @@ -23,7 +23,7 @@ #include #include -#include +#include namespace ripple { diff --git a/src/ripple/basics/ResolverAsio.h b/include/xrpl/basics/ResolverAsio.h similarity index 94% rename from src/ripple/basics/ResolverAsio.h rename to include/xrpl/basics/ResolverAsio.h index 191cdc097ad..51fcbdfb0d8 100644 --- a/src/ripple/basics/ResolverAsio.h +++ b/include/xrpl/basics/ResolverAsio.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_RESOLVERASIO_H_INCLUDED #define RIPPLE_BASICS_RESOLVERASIO_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/basics/SHAMapHash.h b/include/xrpl/basics/SHAMapHash.h similarity index 98% rename from src/ripple/basics/SHAMapHash.h rename to include/xrpl/basics/SHAMapHash.h index 796510ba182..7e93ead78d3 100644 --- a/src/ripple/basics/SHAMapHash.h +++ b/include/xrpl/basics/SHAMapHash.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_SHAMAP_HASH_H_INCLUDED #define RIPPLE_BASICS_SHAMAP_HASH_H_INCLUDED -#include +#include #include diff --git a/src/ripple/basics/SlabAllocator.h b/include/xrpl/basics/SlabAllocator.h similarity index 99% rename from src/ripple/basics/SlabAllocator.h rename to include/xrpl/basics/SlabAllocator.h index ece96d0b873..5c4cba343cf 100644 --- a/src/ripple/basics/SlabAllocator.h +++ b/include/xrpl/basics/SlabAllocator.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED #define RIPPLE_BASICS_SLABALLOCATOR_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/basics/Slice.h b/include/xrpl/basics/Slice.h similarity index 98% rename from src/ripple/basics/Slice.h rename to include/xrpl/basics/Slice.h index 0ba6a94b62b..00126f8882d 100644 --- a/src/ripple/basics/Slice.h +++ b/include/xrpl/basics/Slice.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_SLICE_H_INCLUDED #define RIPPLE_BASICS_SLICE_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/basics/StringUtilities.h b/include/xrpl/basics/StringUtilities.h similarity index 95% rename from src/ripple/basics/StringUtilities.h rename to include/xrpl/basics/StringUtilities.h index 8af81a37403..23d60e2db49 100644 --- a/src/ripple/basics/StringUtilities.h +++ b/include/xrpl/basics/StringUtilities.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_STRINGUTILITIES_H_INCLUDED #define RIPPLE_BASICS_STRINGUTILITIES_H_INCLUDED -#include -#include +#include +#include #include #include @@ -110,7 +110,7 @@ strUnHex(std::string const& strSrc) } inline std::optional -strViewUnHex(boost::string_view const& strSrc) +strViewUnHex(std::string_view strSrc) { return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend()); } @@ -150,7 +150,7 @@ to_uint64(std::string const& s); doesn't check whether the TLD is valid. */ bool -isProperlyFormedTomlDomain(std::string const& domain); +isProperlyFormedTomlDomain(std::string_view domain); } // namespace ripple diff --git a/src/ripple/basics/TaggedCache.h b/include/xrpl/basics/TaggedCache.h similarity index 99% rename from src/ripple/basics/TaggedCache.h rename to include/xrpl/basics/TaggedCache.h index 6765ff16bee..1fcdc3707b6 100644 --- a/src/ripple/basics/TaggedCache.h +++ b/include/xrpl/basics/TaggedCache.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_BASICS_TAGGEDCACHE_H_INCLUDED #define RIPPLE_BASICS_TAGGEDCACHE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/basics/ThreadSafetyAnalysis.h b/include/xrpl/basics/ThreadSafetyAnalysis.h similarity index 100% rename from src/ripple/basics/ThreadSafetyAnalysis.h rename to include/xrpl/basics/ThreadSafetyAnalysis.h diff --git a/src/ripple/basics/ToString.h b/include/xrpl/basics/ToString.h similarity index 100% rename from src/ripple/basics/ToString.h rename to include/xrpl/basics/ToString.h diff --git a/src/ripple/basics/UnorderedContainers.h b/include/xrpl/basics/UnorderedContainers.h similarity index 94% rename from src/ripple/basics/UnorderedContainers.h rename to include/xrpl/basics/UnorderedContainers.h index e929ebec898..b689a1b6ac8 100644 --- a/src/ripple/basics/UnorderedContainers.h +++ b/include/xrpl/basics/UnorderedContainers.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_BASICS_UNORDEREDCONTAINERS_H_INCLUDED #define RIPPLE_BASICS_UNORDEREDCONTAINERS_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/basics/UptimeClock.h b/include/xrpl/basics/UptimeClock.h similarity index 100% rename from src/ripple/basics/UptimeClock.h rename to include/xrpl/basics/UptimeClock.h diff --git a/src/ripple/basics/XRPAmount.h b/include/xrpl/basics/XRPAmount.h similarity index 97% rename from src/ripple/basics/XRPAmount.h rename to include/xrpl/basics/XRPAmount.h index 08f82b1752e..1d3b32f169b 100644 --- a/src/ripple/basics/XRPAmount.h +++ b/include/xrpl/basics/XRPAmount.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_BASICS_XRPAMOUNT_H_INCLUDED #define RIPPLE_BASICS_XRPAMOUNT_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/basics/algorithm.h b/include/xrpl/basics/algorithm.h similarity index 100% rename from src/ripple/basics/algorithm.h rename to include/xrpl/basics/algorithm.h diff --git a/src/ripple/basics/base64.h b/include/xrpl/basics/base64.h similarity index 98% rename from src/ripple/basics/base64.h rename to include/xrpl/basics/base64.h index 05a61133f83..515a7584e56 100644 --- a/src/ripple/basics/base64.h +++ b/include/xrpl/basics/base64.h @@ -73,7 +73,7 @@ base64_encode(std::string const& s) } std::string -base64_decode(std::string const& data); +base64_decode(std::string_view data); } // namespace ripple diff --git a/src/ripple/basics/base_uint.h b/include/xrpl/basics/base_uint.h similarity index 98% rename from src/ripple/basics/base_uint.h rename to include/xrpl/basics/base_uint.h index 8b15b082647..2b44d3072ee 100644 --- a/src/ripple/basics/base_uint.h +++ b/include/xrpl/basics/base_uint.h @@ -25,12 +25,12 @@ #ifndef RIPPLE_BASICS_BASE_UINT_H_INCLUDED #define RIPPLE_BASICS_BASE_UINT_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/basics/chrono.h b/include/xrpl/basics/chrono.h similarity index 96% rename from src/ripple/basics/chrono.h rename to include/xrpl/basics/chrono.h index ea82f928b7e..d739b6bf44b 100644 --- a/src/ripple/basics/chrono.h +++ b/include/xrpl/basics/chrono.h @@ -22,9 +22,9 @@ #include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/basics/comparators.h b/include/xrpl/basics/comparators.h similarity index 100% rename from src/ripple/basics/comparators.h rename to include/xrpl/basics/comparators.h diff --git a/src/ripple/basics/contract.h b/include/xrpl/basics/contract.h similarity index 98% rename from src/ripple/basics/contract.h rename to include/xrpl/basics/contract.h index 80aeee7a387..bdfc8aac362 100644 --- a/src/ripple/basics/contract.h +++ b/include/xrpl/basics/contract.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_CONTRACT_H_INCLUDED #define RIPPLE_BASICS_CONTRACT_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/hardened_hash.h b/include/xrpl/basics/hardened_hash.h similarity index 97% rename from src/ripple/basics/hardened_hash.h rename to include/xrpl/basics/hardened_hash.h index bc20409286e..0b77b0a07a8 100644 --- a/src/ripple/basics/hardened_hash.h +++ b/include/xrpl/basics/hardened_hash.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED #define RIPPLE_BASICS_HARDENED_HASH_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/join.h b/include/xrpl/basics/join.h similarity index 100% rename from src/ripple/basics/join.h rename to include/xrpl/basics/join.h diff --git a/src/ripple/basics/make_SSLContext.h b/include/xrpl/basics/make_SSLContext.h similarity index 100% rename from src/ripple/basics/make_SSLContext.h rename to include/xrpl/basics/make_SSLContext.h diff --git a/src/ripple/basics/mulDiv.h b/include/xrpl/basics/mulDiv.h similarity index 100% rename from src/ripple/basics/mulDiv.h rename to include/xrpl/basics/mulDiv.h diff --git a/src/ripple/basics/partitioned_unordered_map.h b/include/xrpl/basics/partitioned_unordered_map.h similarity index 100% rename from src/ripple/basics/partitioned_unordered_map.h rename to include/xrpl/basics/partitioned_unordered_map.h diff --git a/src/ripple/basics/random.h b/include/xrpl/basics/random.h similarity index 99% rename from src/ripple/basics/random.h rename to include/xrpl/basics/random.h index 3af8be54109..87b303bf6d5 100644 --- a/src/ripple/basics/random.h +++ b/include/xrpl/basics/random.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_RANDOM_H_INCLUDED #define RIPPLE_BASICS_RANDOM_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/basics/safe_cast.h b/include/xrpl/basics/safe_cast.h similarity index 100% rename from src/ripple/basics/safe_cast.h rename to include/xrpl/basics/safe_cast.h diff --git a/src/ripple/basics/scope.h b/include/xrpl/basics/scope.h similarity index 100% rename from src/ripple/basics/scope.h rename to include/xrpl/basics/scope.h diff --git a/src/ripple/basics/spinlock.h b/include/xrpl/basics/spinlock.h similarity index 100% rename from src/ripple/basics/spinlock.h rename to include/xrpl/basics/spinlock.h diff --git a/src/ripple/basics/strHex.h b/include/xrpl/basics/strHex.h similarity index 100% rename from src/ripple/basics/strHex.h rename to include/xrpl/basics/strHex.h diff --git a/src/ripple/basics/tagged_integer.h b/include/xrpl/basics/tagged_integer.h similarity index 99% rename from src/ripple/basics/tagged_integer.h rename to include/xrpl/basics/tagged_integer.h index fe11f882726..3ab8c534098 100644 --- a/src/ripple/basics/tagged_integer.h +++ b/include/xrpl/basics/tagged_integer.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED #define BEAST_UTILITY_TAGGED_INTEGER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/beast/asio/io_latency_probe.h b/include/xrpl/beast/asio/io_latency_probe.h similarity index 100% rename from src/ripple/beast/asio/io_latency_probe.h rename to include/xrpl/beast/asio/io_latency_probe.h diff --git a/src/ripple/beast/clock/abstract_clock.h b/include/xrpl/beast/clock/abstract_clock.h similarity index 100% rename from src/ripple/beast/clock/abstract_clock.h rename to include/xrpl/beast/clock/abstract_clock.h diff --git a/src/ripple/beast/clock/basic_seconds_clock.h b/include/xrpl/beast/clock/basic_seconds_clock.h similarity index 100% rename from src/ripple/beast/clock/basic_seconds_clock.h rename to include/xrpl/beast/clock/basic_seconds_clock.h diff --git a/src/ripple/beast/clock/manual_clock.h b/include/xrpl/beast/clock/manual_clock.h similarity index 98% rename from src/ripple/beast/clock/manual_clock.h rename to include/xrpl/beast/clock/manual_clock.h index 808b0071006..97be8e79b90 100644 --- a/src/ripple/beast/clock/manual_clock.h +++ b/include/xrpl/beast/clock/manual_clock.h @@ -20,7 +20,7 @@ #ifndef BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED #define BEAST_CHRONO_MANUAL_CLOCK_H_INCLUDED -#include +#include #include namespace beast { diff --git a/src/ripple/beast/container/aged_container.h b/include/xrpl/beast/container/aged_container.h similarity index 100% rename from src/ripple/beast/container/aged_container.h rename to include/xrpl/beast/container/aged_container.h diff --git a/src/ripple/beast/container/aged_container_utility.h b/include/xrpl/beast/container/aged_container_utility.h similarity index 97% rename from src/ripple/beast/container/aged_container_utility.h rename to include/xrpl/beast/container/aged_container_utility.h index dc57c229fb5..b64cefbf5ad 100644 --- a/src/ripple/beast/container/aged_container_utility.h +++ b/include/xrpl/beast/container/aged_container_utility.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED #define BEAST_CONTAINER_AGED_CONTAINER_UTILITY_H_INCLUDED -#include +#include #include diff --git a/src/ripple/beast/container/aged_map.h b/include/xrpl/beast/container/aged_map.h similarity index 95% rename from src/ripple/beast/container/aged_map.h rename to include/xrpl/beast/container/aged_map.h index f675846fa64..5b56cde9625 100644 --- a/src/ripple/beast/container/aged_map.h +++ b/include/xrpl/beast/container/aged_map.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_MAP_H_INCLUDED #define BEAST_CONTAINER_AGED_MAP_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_multimap.h b/include/xrpl/beast/container/aged_multimap.h similarity index 95% rename from src/ripple/beast/container/aged_multimap.h rename to include/xrpl/beast/container/aged_multimap.h index b4668851c3d..aa6c01f5b32 100644 --- a/src/ripple/beast/container/aged_multimap.h +++ b/include/xrpl/beast/container/aged_multimap.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED #define BEAST_CONTAINER_AGED_MULTIMAP_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_multiset.h b/include/xrpl/beast/container/aged_multiset.h similarity index 95% rename from src/ripple/beast/container/aged_multiset.h rename to include/xrpl/beast/container/aged_multiset.h index 6d62bcbeb36..d43cc8d5a70 100644 --- a/src/ripple/beast/container/aged_multiset.h +++ b/include/xrpl/beast/container/aged_multiset.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED #define BEAST_CONTAINER_AGED_MULTISET_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_set.h b/include/xrpl/beast/container/aged_set.h similarity index 95% rename from src/ripple/beast/container/aged_set.h rename to include/xrpl/beast/container/aged_set.h index 0a9d82f6cb2..aa31a47af4a 100644 --- a/src/ripple/beast/container/aged_set.h +++ b/include/xrpl/beast/container/aged_set.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_SET_H_INCLUDED #define BEAST_CONTAINER_AGED_SET_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_unordered_map.h b/include/xrpl/beast/container/aged_unordered_map.h similarity index 95% rename from src/ripple/beast/container/aged_unordered_map.h rename to include/xrpl/beast/container/aged_unordered_map.h index 1b6a147ef03..b466c87b3ff 100644 --- a/src/ripple/beast/container/aged_unordered_map.h +++ b/include/xrpl/beast/container/aged_unordered_map.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED #define BEAST_CONTAINER_AGED_UNORDERED_MAP_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_unordered_multimap.h b/include/xrpl/beast/container/aged_unordered_multimap.h similarity index 96% rename from src/ripple/beast/container/aged_unordered_multimap.h rename to include/xrpl/beast/container/aged_unordered_multimap.h index 1298cd51d0e..e64c8415c61 100644 --- a/src/ripple/beast/container/aged_unordered_multimap.h +++ b/include/xrpl/beast/container/aged_unordered_multimap.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED #define BEAST_CONTAINER_AGED_UNORDERED_MULTIMAP_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_unordered_multiset.h b/include/xrpl/beast/container/aged_unordered_multiset.h similarity index 95% rename from src/ripple/beast/container/aged_unordered_multiset.h rename to include/xrpl/beast/container/aged_unordered_multiset.h index 5e9f682aa6b..499dc7d6780 100644 --- a/src/ripple/beast/container/aged_unordered_multiset.h +++ b/include/xrpl/beast/container/aged_unordered_multiset.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED #define BEAST_CONTAINER_AGED_UNORDERED_MULTISET_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/aged_unordered_set.h b/include/xrpl/beast/container/aged_unordered_set.h similarity index 95% rename from src/ripple/beast/container/aged_unordered_set.h rename to include/xrpl/beast/container/aged_unordered_set.h index adb411c344c..45fc6cd0ed8 100644 --- a/src/ripple/beast/container/aged_unordered_set.h +++ b/include/xrpl/beast/container/aged_unordered_set.h @@ -20,7 +20,7 @@ #ifndef BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED #define BEAST_CONTAINER_AGED_UNORDERED_SET_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/container/detail/aged_associative_container.h b/include/xrpl/beast/container/detail/aged_associative_container.h similarity index 100% rename from src/ripple/beast/container/detail/aged_associative_container.h rename to include/xrpl/beast/container/detail/aged_associative_container.h diff --git a/src/ripple/beast/container/detail/aged_container_iterator.h b/include/xrpl/beast/container/detail/aged_container_iterator.h similarity index 100% rename from src/ripple/beast/container/detail/aged_container_iterator.h rename to include/xrpl/beast/container/detail/aged_container_iterator.h diff --git a/src/ripple/beast/container/detail/aged_ordered_container.h b/include/xrpl/beast/container/detail/aged_ordered_container.h similarity index 99% rename from src/ripple/beast/container/detail/aged_ordered_container.h rename to include/xrpl/beast/container/detail/aged_ordered_container.h index 10dca962b13..90a8ea147ae 100644 --- a/src/ripple/beast/container/detail/aged_ordered_container.h +++ b/include/xrpl/beast/container/detail/aged_ordered_container.h @@ -20,11 +20,11 @@ #ifndef BEAST_CONTAINER_DETAIL_AGED_ORDERED_CONTAINER_H_INCLUDED #define BEAST_CONTAINER_DETAIL_AGED_ORDERED_CONTAINER_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/beast/container/detail/aged_unordered_container.h b/include/xrpl/beast/container/detail/aged_unordered_container.h similarity index 99% rename from src/ripple/beast/container/detail/aged_unordered_container.h rename to include/xrpl/beast/container/detail/aged_unordered_container.h index fcdccd2a637..45efb3f5561 100644 --- a/src/ripple/beast/container/detail/aged_unordered_container.h +++ b/include/xrpl/beast/container/detail/aged_unordered_container.h @@ -20,11 +20,11 @@ #ifndef BEAST_CONTAINER_DETAIL_AGED_UNORDERED_CONTAINER_H_INCLUDED #define BEAST_CONTAINER_DETAIL_AGED_UNORDERED_CONTAINER_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/beast/container/detail/empty_base_optimization.h b/include/xrpl/beast/container/detail/empty_base_optimization.h similarity index 100% rename from src/ripple/beast/container/detail/empty_base_optimization.h rename to include/xrpl/beast/container/detail/empty_base_optimization.h diff --git a/src/ripple/beast/core/CurrentThreadName.h b/include/xrpl/beast/core/CurrentThreadName.h similarity index 100% rename from src/ripple/beast/core/CurrentThreadName.h rename to include/xrpl/beast/core/CurrentThreadName.h diff --git a/src/ripple/beast/core/LexicalCast.h b/include/xrpl/beast/core/LexicalCast.h similarity index 75% rename from src/ripple/beast/core/LexicalCast.h rename to include/xrpl/beast/core/LexicalCast.h index f4c78341b91..e0fa24ca9f5 100644 --- a/src/ripple/beast/core/LexicalCast.h +++ b/include/xrpl/beast/core/LexicalCast.h @@ -20,6 +20,7 @@ #ifndef BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED #define BEAST_MODULE_CORE_TEXT_LEXICALCAST_H_INCLUDED +#include #include #include #include @@ -64,9 +65,9 @@ struct LexicalCast } }; -// Parse std::string to number -template -struct LexicalCast +// Parse a std::string_view into a number +template +struct LexicalCast { explicit LexicalCast() = default; @@ -78,7 +79,7 @@ struct LexicalCast std::enable_if_t< std::is_integral_v && !std::is_same_v, bool> - operator()(Integral& out, std::string const& in) const + operator()(Integral& out, std::string_view in) const { auto first = in.data(); auto last = in.data() + in.size(); @@ -92,20 +93,23 @@ struct LexicalCast } bool - operator()(bool& out, std::string in) const + operator()(bool& out, std::string_view in) const { + std::string result; + // Convert the input to lowercase - std::transform(in.begin(), in.end(), in.begin(), [](auto c) { - return std::tolower(static_cast(c)); - }); + std::transform( + in.begin(), in.end(), std::back_inserter(result), [](auto c) { + return std::tolower(static_cast(c)); + }); - if (in == "1" || in == "true") + if (result == "1" || result == "true") { out = true; return true; } - if (in == "0" || in == "false") + if (result == "0" || result == "false") { out = false; return true; @@ -114,9 +118,38 @@ struct LexicalCast return false; } }; - //------------------------------------------------------------------------------ +// Parse boost library's string_view to number or boolean value +// Note: As of Jan 2024, Boost contains three different types of string_view +// (boost::core::basic_string_view, boost::string_ref and +// boost::string_view). The below template specialization is included because +// it is used in the handshake.cpp file +template +struct LexicalCast> +{ + explicit LexicalCast() = default; + + bool + operator()(Out& out, boost::core::basic_string_view in) const + { + return LexicalCast()(out, in); + } +}; + +// Parse std::string to number or boolean value +template +struct LexicalCast +{ + explicit LexicalCast() = default; + + bool + operator()(Out& out, std::string in) const + { + return LexicalCast()(out, in); + } +}; + // Conversion from null terminated char const* template struct LexicalCast @@ -126,7 +159,8 @@ struct LexicalCast bool operator()(Out& out, char const* in) const { - return LexicalCast()(out, in); + assert(in); + return LexicalCast()(out, in); } }; @@ -140,7 +174,8 @@ struct LexicalCast bool operator()(Out& out, char* in) const { - return LexicalCast()(out, in); + assert(in); + return LexicalCast()(out, in); } }; diff --git a/src/ripple/beast/core/List.h b/include/xrpl/beast/core/List.h similarity index 100% rename from src/ripple/beast/core/List.h rename to include/xrpl/beast/core/List.h diff --git a/src/ripple/beast/core/LockFreeStack.h b/include/xrpl/beast/core/LockFreeStack.h similarity index 100% rename from src/ripple/beast/core/LockFreeStack.h rename to include/xrpl/beast/core/LockFreeStack.h diff --git a/src/ripple/beast/core/SemanticVersion.h b/include/xrpl/beast/core/SemanticVersion.h similarity index 100% rename from src/ripple/beast/core/SemanticVersion.h rename to include/xrpl/beast/core/SemanticVersion.h diff --git a/src/ripple/beast/hash/hash_append.h b/include/xrpl/beast/hash/hash_append.h similarity index 100% rename from src/ripple/beast/hash/hash_append.h rename to include/xrpl/beast/hash/hash_append.h diff --git a/src/ripple/beast/hash/uhash.h b/include/xrpl/beast/hash/uhash.h similarity index 95% rename from src/ripple/beast/hash/uhash.h rename to include/xrpl/beast/hash/uhash.h index 921ea3c9840..ab3eaad0392 100644 --- a/src/ripple/beast/hash/uhash.h +++ b/include/xrpl/beast/hash/uhash.h @@ -21,8 +21,8 @@ #ifndef BEAST_HASH_UHASH_H_INCLUDED #define BEAST_HASH_UHASH_H_INCLUDED -#include -#include +#include +#include namespace beast { diff --git a/src/ripple/beast/hash/xxhasher.h b/include/xrpl/beast/hash/xxhasher.h similarity index 100% rename from src/ripple/beast/hash/xxhasher.h rename to include/xrpl/beast/hash/xxhasher.h diff --git a/src/ripple/beast/insight/Collector.h b/include/xrpl/beast/insight/Collector.h similarity index 95% rename from src/ripple/beast/insight/Collector.h rename to include/xrpl/beast/insight/Collector.h index a71b1092c85..eab2bd7d70c 100644 --- a/src/ripple/beast/insight/Collector.h +++ b/include/xrpl/beast/insight/Collector.h @@ -20,11 +20,11 @@ #ifndef BEAST_INSIGHT_COLLECTOR_H_INCLUDED #define BEAST_INSIGHT_COLLECTOR_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/beast/insight/Counter.h b/include/xrpl/beast/insight/Counter.h similarity index 98% rename from src/ripple/beast/insight/Counter.h rename to include/xrpl/beast/insight/Counter.h index 069505e4ce5..3f3a251de89 100644 --- a/src/ripple/beast/insight/Counter.h +++ b/include/xrpl/beast/insight/Counter.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_COUNTER_H_INCLUDED #define BEAST_INSIGHT_COUNTER_H_INCLUDED -#include +#include #include diff --git a/src/ripple/beast/insight/CounterImpl.h b/include/xrpl/beast/insight/CounterImpl.h similarity index 100% rename from src/ripple/beast/insight/CounterImpl.h rename to include/xrpl/beast/insight/CounterImpl.h diff --git a/src/ripple/beast/insight/Event.h b/include/xrpl/beast/insight/Event.h similarity index 98% rename from src/ripple/beast/insight/Event.h rename to include/xrpl/beast/insight/Event.h index 5319a9a6677..407dd233e95 100644 --- a/src/ripple/beast/insight/Event.h +++ b/include/xrpl/beast/insight/Event.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_EVENT_H_INCLUDED #define BEAST_INSIGHT_EVENT_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/insight/EventImpl.h b/include/xrpl/beast/insight/EventImpl.h similarity index 100% rename from src/ripple/beast/insight/EventImpl.h rename to include/xrpl/beast/insight/EventImpl.h diff --git a/src/ripple/beast/insight/Gauge.h b/include/xrpl/beast/insight/Gauge.h similarity index 98% rename from src/ripple/beast/insight/Gauge.h rename to include/xrpl/beast/insight/Gauge.h index 76f84080766..b1e8bedfac2 100644 --- a/src/ripple/beast/insight/Gauge.h +++ b/include/xrpl/beast/insight/Gauge.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_GAUGE_H_INCLUDED #define BEAST_INSIGHT_GAUGE_H_INCLUDED -#include +#include #include diff --git a/src/ripple/beast/insight/GaugeImpl.h b/include/xrpl/beast/insight/GaugeImpl.h similarity index 100% rename from src/ripple/beast/insight/GaugeImpl.h rename to include/xrpl/beast/insight/GaugeImpl.h diff --git a/src/ripple/beast/insight/Group.h b/include/xrpl/beast/insight/Group.h similarity index 97% rename from src/ripple/beast/insight/Group.h rename to include/xrpl/beast/insight/Group.h index a37656b81a5..f11b1397c8b 100644 --- a/src/ripple/beast/insight/Group.h +++ b/include/xrpl/beast/insight/Group.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_GROUP_H_INCLUDED #define BEAST_INSIGHT_GROUP_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/insight/Groups.h b/include/xrpl/beast/insight/Groups.h similarity index 95% rename from src/ripple/beast/insight/Groups.h rename to include/xrpl/beast/insight/Groups.h index 817ad87bd1a..456deb79073 100644 --- a/src/ripple/beast/insight/Groups.h +++ b/include/xrpl/beast/insight/Groups.h @@ -20,8 +20,8 @@ #ifndef BEAST_INSIGHT_GROUPS_H_INCLUDED #define BEAST_INSIGHT_GROUPS_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/beast/insight/Hook.h b/include/xrpl/beast/insight/Hook.h similarity index 97% rename from src/ripple/beast/insight/Hook.h rename to include/xrpl/beast/insight/Hook.h index 04647f4b632..affa42bb828 100644 --- a/src/ripple/beast/insight/Hook.h +++ b/include/xrpl/beast/insight/Hook.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_HOOK_H_INCLUDED #define BEAST_INSIGHT_HOOK_H_INCLUDED -#include +#include #include diff --git a/src/ripple/beast/insight/HookImpl.h b/include/xrpl/beast/insight/HookImpl.h similarity index 100% rename from src/ripple/beast/insight/HookImpl.h rename to include/xrpl/beast/insight/HookImpl.h diff --git a/src/ripple/beast/insight/Insight.h b/include/xrpl/beast/insight/Insight.h similarity index 66% rename from src/ripple/beast/insight/Insight.h rename to include/xrpl/beast/insight/Insight.h index f34f7317483..1c2c1375a28 100644 --- a/src/ripple/beast/insight/Insight.h +++ b/include/xrpl/beast/insight/Insight.h @@ -20,18 +20,18 @@ #ifndef BEAST_INSIGHT_H_INCLUDED #define BEAST_INSIGHT_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/src/ripple/beast/insight/Meter.h b/include/xrpl/beast/insight/Meter.h similarity index 98% rename from src/ripple/beast/insight/Meter.h rename to include/xrpl/beast/insight/Meter.h index 376dcae0521..febd5cb3dc4 100644 --- a/src/ripple/beast/insight/Meter.h +++ b/include/xrpl/beast/insight/Meter.h @@ -22,7 +22,7 @@ #include -#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/MeterImpl.h b/include/xrpl/beast/insight/MeterImpl.h similarity index 100% rename from src/ripple/beast/insight/MeterImpl.h rename to include/xrpl/beast/insight/MeterImpl.h diff --git a/src/ripple/beast/insight/NullCollector.h b/include/xrpl/beast/insight/NullCollector.h similarity index 97% rename from src/ripple/beast/insight/NullCollector.h rename to include/xrpl/beast/insight/NullCollector.h index db98153836e..4379c3ceb98 100644 --- a/src/ripple/beast/insight/NullCollector.h +++ b/include/xrpl/beast/insight/NullCollector.h @@ -20,7 +20,7 @@ #ifndef BEAST_INSIGHT_NULLCOLLECTOR_H_INCLUDED #define BEAST_INSIGHT_NULLCOLLECTOR_H_INCLUDED -#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/StatsDCollector.h b/include/xrpl/beast/insight/StatsDCollector.h similarity index 93% rename from src/ripple/beast/insight/StatsDCollector.h rename to include/xrpl/beast/insight/StatsDCollector.h index d95aee04d0b..78195048d7f 100644 --- a/src/ripple/beast/insight/StatsDCollector.h +++ b/include/xrpl/beast/insight/StatsDCollector.h @@ -20,10 +20,10 @@ #ifndef BEAST_INSIGHT_STATSDCOLLECTOR_H_INCLUDED #define BEAST_INSIGHT_STATSDCOLLECTOR_H_INCLUDED -#include +#include -#include -#include +#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/net/IPAddress.h b/include/xrpl/beast/net/IPAddress.h similarity index 94% rename from src/ripple/beast/net/IPAddress.h rename to include/xrpl/beast/net/IPAddress.h index d8820ec40b5..f3a1a7348f2 100644 --- a/src/ripple/beast/net/IPAddress.h +++ b/include/xrpl/beast/net/IPAddress.h @@ -20,10 +20,10 @@ #ifndef BEAST_NET_IPADDRESS_H_INCLUDED #define BEAST_NET_IPADDRESS_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/beast/net/IPAddressConversion.h b/include/xrpl/beast/net/IPAddressConversion.h similarity index 98% rename from src/ripple/beast/net/IPAddressConversion.h rename to include/xrpl/beast/net/IPAddressConversion.h index e37dd5b6c61..982a8e50f26 100644 --- a/src/ripple/beast/net/IPAddressConversion.h +++ b/include/xrpl/beast/net/IPAddressConversion.h @@ -20,7 +20,7 @@ #ifndef BEAST_NET_IPADDRESSCONVERSION_H_INCLUDED #define BEAST_NET_IPADDRESSCONVERSION_H_INCLUDED -#include +#include #include diff --git a/src/ripple/beast/net/IPAddressV4.h b/include/xrpl/beast/net/IPAddressV4.h similarity index 97% rename from src/ripple/beast/net/IPAddressV4.h rename to include/xrpl/beast/net/IPAddressV4.h index 2c6f6a8cced..7711a970dec 100644 --- a/src/ripple/beast/net/IPAddressV4.h +++ b/include/xrpl/beast/net/IPAddressV4.h @@ -20,7 +20,7 @@ #ifndef BEAST_NET_IPADDRESSV4_H_INCLUDED #define BEAST_NET_IPADDRESSV4_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/beast/net/IPAddressV6.h b/include/xrpl/beast/net/IPAddressV6.h similarity index 100% rename from src/ripple/beast/net/IPAddressV6.h rename to include/xrpl/beast/net/IPAddressV6.h diff --git a/src/ripple/beast/net/IPEndpoint.h b/include/xrpl/beast/net/IPEndpoint.h similarity index 97% rename from src/ripple/beast/net/IPEndpoint.h rename to include/xrpl/beast/net/IPEndpoint.h index 19ce36dcc3b..e66e7f4caae 100644 --- a/src/ripple/beast/net/IPEndpoint.h +++ b/include/xrpl/beast/net/IPEndpoint.h @@ -20,9 +20,9 @@ #ifndef BEAST_NET_IPENDPOINT_H_INCLUDED #define BEAST_NET_IPENDPOINT_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/beast/rfc2616.h b/include/xrpl/beast/rfc2616.h similarity index 100% rename from src/ripple/beast/rfc2616.h rename to include/xrpl/beast/rfc2616.h diff --git a/src/ripple/beast/test/fail_counter.h b/include/xrpl/beast/test/fail_counter.h similarity index 98% rename from src/ripple/beast/test/fail_counter.h rename to include/xrpl/beast/test/fail_counter.h index 8a11602e22d..d0cae77ddad 100644 --- a/src/ripple/beast/test/fail_counter.h +++ b/include/xrpl/beast/test/fail_counter.h @@ -8,8 +8,8 @@ #ifndef BEAST_TEST_FAIL_COUNTER_HPP #define BEAST_TEST_FAIL_COUNTER_HPP +#include #include -#include namespace beast { namespace test { diff --git a/src/ripple/beast/test/fail_stream.h b/include/xrpl/beast/test/fail_stream.h similarity index 94% rename from src/ripple/beast/test/fail_stream.h rename to include/xrpl/beast/test/fail_stream.h index a1465f006ca..161e73ef091 100644 --- a/src/ripple/beast/test/fail_stream.h +++ b/include/xrpl/beast/test/fail_stream.h @@ -8,13 +8,13 @@ #ifndef BEAST_TEST_FAIL_STREAM_HPP #define BEAST_TEST_FAIL_STREAM_HPP +#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include namespace beast { namespace test { diff --git a/src/ripple/beast/test/pipe_stream.h b/include/xrpl/beast/test/pipe_stream.h similarity index 97% rename from src/ripple/beast/test/pipe_stream.h rename to include/xrpl/beast/test/pipe_stream.h index 1aaaadfa4ff..762419a539a 100644 --- a/src/ripple/beast/test/pipe_stream.h +++ b/include/xrpl/beast/test/pipe_stream.h @@ -8,17 +8,17 @@ #ifndef BEAST_TEST_PIPE_STREAM_HPP #define BEAST_TEST_PIPE_STREAM_HPP +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/src/ripple/beast/test/sig_wait.h b/include/xrpl/beast/test/sig_wait.h similarity index 100% rename from src/ripple/beast/test/sig_wait.h rename to include/xrpl/beast/test/sig_wait.h diff --git a/src/ripple/beast/test/string_iostream.h b/include/xrpl/beast/test/string_iostream.h similarity index 95% rename from src/ripple/beast/test/string_iostream.h rename to include/xrpl/beast/test/string_iostream.h index 56f741be068..bed6299a2bc 100644 --- a/src/ripple/beast/test/string_iostream.h +++ b/include/xrpl/beast/test/string_iostream.h @@ -8,14 +8,14 @@ #ifndef BEAST_TEST_STRING_IOSTREAM_HPP #define BEAST_TEST_STRING_IOSTREAM_HPP +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include #include namespace beast { diff --git a/src/ripple/beast/test/string_istream.h b/include/xrpl/beast/test/string_istream.h similarity index 95% rename from src/ripple/beast/test/string_istream.h rename to include/xrpl/beast/test/string_istream.h index 81f35469905..83cb3cfef5d 100644 --- a/src/ripple/beast/test/string_istream.h +++ b/include/xrpl/beast/test/string_istream.h @@ -8,13 +8,13 @@ #ifndef BEAST_TEST_STRING_ISTREAM_HPP #define BEAST_TEST_STRING_ISTREAM_HPP +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include #include namespace beast { diff --git a/src/ripple/beast/test/string_ostream.h b/include/xrpl/beast/test/string_ostream.h similarity index 94% rename from src/ripple/beast/test/string_ostream.h rename to include/xrpl/beast/test/string_ostream.h index 4cca9e7fce0..9edf69be88f 100644 --- a/src/ripple/beast/test/string_ostream.h +++ b/include/xrpl/beast/test/string_ostream.h @@ -8,14 +8,14 @@ #ifndef BEAST_TEST_STRING_OSTREAM_HPP #define BEAST_TEST_STRING_OSTREAM_HPP +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include #include namespace beast { diff --git a/src/ripple/beast/test/test_allocator.h b/include/xrpl/beast/test/test_allocator.h similarity index 100% rename from src/ripple/beast/test/test_allocator.h rename to include/xrpl/beast/test/test_allocator.h diff --git a/src/ripple/beast/test/yield_to.h b/include/xrpl/beast/test/yield_to.h similarity index 100% rename from src/ripple/beast/test/yield_to.h rename to include/xrpl/beast/test/yield_to.h diff --git a/src/ripple/beast/type_name.h b/include/xrpl/beast/type_name.h similarity index 100% rename from src/ripple/beast/type_name.h rename to include/xrpl/beast/type_name.h diff --git a/src/ripple/beast/unit_test.h b/include/xrpl/beast/unit_test.h similarity index 75% rename from src/ripple/beast/unit_test.h rename to include/xrpl/beast/unit_test.h index 70747ea341b..eff82583ea7 100644 --- a/src/ripple/beast/unit_test.h +++ b/include/xrpl/beast/unit_test.h @@ -20,16 +20,16 @@ #ifndef BEAST_UNIT_TEST_H_INCLUDED #define BEAST_UNIT_TEST_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifndef BEAST_EXPECT #define BEAST_EXPECT_S1(x) #x diff --git a/src/ripple/beast/unit_test/amount.h b/include/xrpl/beast/unit_test/amount.h similarity index 100% rename from src/ripple/beast/unit_test/amount.h rename to include/xrpl/beast/unit_test/amount.h diff --git a/src/ripple/beast/unit_test/detail/const_container.h b/include/xrpl/beast/unit_test/detail/const_container.h similarity index 100% rename from src/ripple/beast/unit_test/detail/const_container.h rename to include/xrpl/beast/unit_test/detail/const_container.h diff --git a/src/ripple/beast/unit_test/dstream.h b/include/xrpl/beast/unit_test/dstream.h similarity index 100% rename from src/ripple/beast/unit_test/dstream.h rename to include/xrpl/beast/unit_test/dstream.h diff --git a/src/ripple/beast/unit_test/global_suites.h b/include/xrpl/beast/unit_test/global_suites.h similarity index 95% rename from src/ripple/beast/unit_test/global_suites.h rename to include/xrpl/beast/unit_test/global_suites.h index 3fcdcc052bf..64bbbc7a268 100644 --- a/src/ripple/beast/unit_test/global_suites.h +++ b/include/xrpl/beast/unit_test/global_suites.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_GLOBAL_SUITES_HPP #define BEAST_UNIT_TEST_GLOBAL_SUITES_HPP -#include +#include namespace beast { namespace unit_test { diff --git a/src/ripple/beast/unit_test/match.h b/include/xrpl/beast/unit_test/match.h similarity index 98% rename from src/ripple/beast/unit_test/match.h rename to include/xrpl/beast/unit_test/match.h index 306bc569982..e8e12bd5568 100644 --- a/src/ripple/beast/unit_test/match.h +++ b/include/xrpl/beast/unit_test/match.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_MATCH_HPP #define BEAST_UNIT_TEST_MATCH_HPP -#include +#include #include namespace beast { diff --git a/src/ripple/beast/unit_test/recorder.h b/include/xrpl/beast/unit_test/recorder.h similarity index 94% rename from src/ripple/beast/unit_test/recorder.h rename to include/xrpl/beast/unit_test/recorder.h index 439e194c335..fbe6ab6c10d 100644 --- a/src/ripple/beast/unit_test/recorder.h +++ b/include/xrpl/beast/unit_test/recorder.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_RECORDER_HPP #define BEAST_UNIT_TEST_RECORDER_HPP -#include -#include +#include +#include namespace beast { namespace unit_test { diff --git a/src/ripple/beast/unit_test/reporter.h b/include/xrpl/beast/unit_test/reporter.h similarity index 98% rename from src/ripple/beast/unit_test/reporter.h rename to include/xrpl/beast/unit_test/reporter.h index 76b65a8b1e5..956def1c30d 100644 --- a/src/ripple/beast/unit_test/reporter.h +++ b/include/xrpl/beast/unit_test/reporter.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_REPORTER_HPP #define BEAST_UNIT_TEST_REPORTER_HPP -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/results.h b/include/xrpl/beast/unit_test/results.h similarity index 98% rename from src/ripple/beast/unit_test/results.h rename to include/xrpl/beast/unit_test/results.h index dd43fb17a72..96fedc9b75f 100644 --- a/src/ripple/beast/unit_test/results.h +++ b/include/xrpl/beast/unit_test/results.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_RESULTS_HPP #define BEAST_UNIT_TEST_RESULTS_HPP -#include +#include #include #include diff --git a/src/ripple/beast/unit_test/runner.h b/include/xrpl/beast/unit_test/runner.h similarity index 99% rename from src/ripple/beast/unit_test/runner.h rename to include/xrpl/beast/unit_test/runner.h index bdee7aee5a8..6330f2c8c81 100644 --- a/src/ripple/beast/unit_test/runner.h +++ b/include/xrpl/beast/unit_test/runner.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_RUNNER_H_INCLUDED #define BEAST_UNIT_TEST_RUNNER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/suite.h b/include/xrpl/beast/unit_test/suite.h similarity index 99% rename from src/ripple/beast/unit_test/suite.h rename to include/xrpl/beast/unit_test/suite.h index 23c4c4fad1f..d49730d4d5f 100644 --- a/src/ripple/beast/unit_test/suite.h +++ b/include/xrpl/beast/unit_test/suite.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_SUITE_HPP #define BEAST_UNIT_TEST_SUITE_HPP -#include +#include #include #include #include @@ -646,7 +646,7 @@ suite::run(runner& r) #define BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Class, Module, Library, Priority) #else -#include +#include #define BEAST_DEFINE_TESTSUITE(Class, Module, Library) \ BEAST_DEFINE_TESTSUITE_INSERT(Class, Module, Library, false, 0) #define BEAST_DEFINE_TESTSUITE_MANUAL(Class, Module, Library) \ diff --git a/src/ripple/beast/unit_test/suite_info.h b/include/xrpl/beast/unit_test/suite_info.h similarity index 100% rename from src/ripple/beast/unit_test/suite_info.h rename to include/xrpl/beast/unit_test/suite_info.h diff --git a/src/ripple/beast/unit_test/suite_list.h b/include/xrpl/beast/unit_test/suite_list.h similarity index 94% rename from src/ripple/beast/unit_test/suite_list.h rename to include/xrpl/beast/unit_test/suite_list.h index a1aed563c71..5856b4c7dba 100644 --- a/src/ripple/beast/unit_test/suite_list.h +++ b/include/xrpl/beast/unit_test/suite_list.h @@ -8,8 +8,8 @@ #ifndef BEAST_UNIT_TEST_SUITE_LIST_HPP #define BEAST_UNIT_TEST_SUITE_LIST_HPP -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/beast/unit_test/thread.h b/include/xrpl/beast/unit_test/thread.h similarity index 98% rename from src/ripple/beast/unit_test/thread.h rename to include/xrpl/beast/unit_test/thread.h index 8b2d024a840..e94108f7879 100644 --- a/src/ripple/beast/unit_test/thread.h +++ b/include/xrpl/beast/unit_test/thread.h @@ -8,7 +8,7 @@ #ifndef BEAST_UNIT_TEST_THREAD_HPP #define BEAST_UNIT_TEST_THREAD_HPP -#include +#include #include #include #include diff --git a/src/ripple/beast/utility/Journal.h b/include/xrpl/beast/utility/Journal.h similarity index 100% rename from src/ripple/beast/utility/Journal.h rename to include/xrpl/beast/utility/Journal.h diff --git a/src/ripple/beast/utility/PropertyStream.h b/include/xrpl/beast/utility/PropertyStream.h similarity index 99% rename from src/ripple/beast/utility/PropertyStream.h rename to include/xrpl/beast/utility/PropertyStream.h index dbcc8a2d793..5eaf70453e8 100644 --- a/src/ripple/beast/utility/PropertyStream.h +++ b/include/xrpl/beast/utility/PropertyStream.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED #define BEAST_UTILITY_PROPERTYSTREAM_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/beast/utility/WrappedSink.h b/include/xrpl/beast/utility/WrappedSink.h similarity index 98% rename from src/ripple/beast/utility/WrappedSink.h rename to include/xrpl/beast/utility/WrappedSink.h index ba714248a06..f22455a52c4 100644 --- a/src/ripple/beast/utility/WrappedSink.h +++ b/include/xrpl/beast/utility/WrappedSink.h @@ -20,7 +20,7 @@ #ifndef BEAST_UTILITY_WRAPPEDSINK_H_INCLUDED #define BEAST_UTILITY_WRAPPEDSINK_H_INCLUDED -#include +#include namespace beast { diff --git a/src/ripple/beast/utility/Zero.h b/include/xrpl/beast/utility/Zero.h similarity index 100% rename from src/ripple/beast/utility/Zero.h rename to include/xrpl/beast/utility/Zero.h diff --git a/src/ripple/beast/utility/hash_pair.h b/include/xrpl/beast/utility/hash_pair.h similarity index 100% rename from src/ripple/beast/utility/hash_pair.h rename to include/xrpl/beast/utility/hash_pair.h diff --git a/src/ripple/beast/utility/maybe_const.h b/include/xrpl/beast/utility/maybe_const.h similarity index 100% rename from src/ripple/beast/utility/maybe_const.h rename to include/xrpl/beast/utility/maybe_const.h diff --git a/src/ripple/beast/utility/rngfill.h b/include/xrpl/beast/utility/rngfill.h similarity index 100% rename from src/ripple/beast/utility/rngfill.h rename to include/xrpl/beast/utility/rngfill.h diff --git a/src/ripple/beast/utility/temp_dir.h b/include/xrpl/beast/utility/temp_dir.h similarity index 100% rename from src/ripple/beast/utility/temp_dir.h rename to include/xrpl/beast/utility/temp_dir.h diff --git a/src/ripple/beast/xor_shift_engine.h b/include/xrpl/beast/xor_shift_engine.h similarity index 100% rename from src/ripple/beast/xor_shift_engine.h rename to include/xrpl/beast/xor_shift_engine.h diff --git a/src/ripple/crypto/README.md b/include/xrpl/crypto/README.md similarity index 100% rename from src/ripple/crypto/README.md rename to include/xrpl/crypto/README.md diff --git a/src/ripple/crypto/RFC1751.h b/include/xrpl/crypto/RFC1751.h similarity index 100% rename from src/ripple/crypto/RFC1751.h rename to include/xrpl/crypto/RFC1751.h diff --git a/src/ripple/crypto/csprng.h b/include/xrpl/crypto/csprng.h similarity index 100% rename from src/ripple/crypto/csprng.h rename to include/xrpl/crypto/csprng.h diff --git a/src/ripple/crypto/secure_erase.h b/include/xrpl/crypto/secure_erase.h similarity index 100% rename from src/ripple/crypto/secure_erase.h rename to include/xrpl/crypto/secure_erase.h diff --git a/src/ripple/json/JsonPropertyStream.h b/include/xrpl/json/JsonPropertyStream.h similarity index 96% rename from src/ripple/json/JsonPropertyStream.h rename to include/xrpl/json/JsonPropertyStream.h index 0f25e59eb59..fdc21971978 100644 --- a/src/ripple/json/JsonPropertyStream.h +++ b/include/xrpl/json/JsonPropertyStream.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_JSON_JSONPROPERTYSTREAM_H_INCLUDED #define RIPPLE_JSON_JSONPROPERTYSTREAM_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/json/Object.h b/include/xrpl/json/Object.h similarity index 99% rename from src/ripple/json/Object.h rename to include/xrpl/json/Object.h index 04501033335..ec60e562028 100644 --- a/src/ripple/json/Object.h +++ b/include/xrpl/json/Object.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_JSON_OBJECT_H_INCLUDED #define RIPPLE_JSON_OBJECT_H_INCLUDED -#include +#include #include namespace Json { diff --git a/src/ripple/json/Output.h b/include/xrpl/json/Output.h similarity index 99% rename from src/ripple/json/Output.h rename to include/xrpl/json/Output.h index 74aaa65269d..96905c20ba9 100644 --- a/src/ripple/json/Output.h +++ b/include/xrpl/json/Output.h @@ -22,6 +22,7 @@ #include #include +#include namespace Json { diff --git a/src/ripple/json/README.md b/include/xrpl/json/README.md similarity index 100% rename from src/ripple/json/README.md rename to include/xrpl/json/README.md diff --git a/src/ripple/json/Writer.h b/include/xrpl/json/Writer.h similarity index 98% rename from src/ripple/json/Writer.h rename to include/xrpl/json/Writer.h index 5801caf8514..882e944093e 100644 --- a/src/ripple/json/Writer.h +++ b/include/xrpl/json/Writer.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_JSON_WRITER_H_INCLUDED #define RIPPLE_JSON_WRITER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace Json { diff --git a/src/ripple/json/impl/json_assert.h b/include/xrpl/json/detail/json_assert.h similarity index 97% rename from src/ripple/json/impl/json_assert.h rename to include/xrpl/json/detail/json_assert.h index b7297e016c6..c401ccf7200 100644 --- a/src/ripple/json/impl/json_assert.h +++ b/include/xrpl/json/detail/json_assert.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_JSON_JSON_ASSERT_H_INCLUDED #define RIPPLE_JSON_JSON_ASSERT_H_INCLUDED -#include +#include #define JSON_ASSERT_UNREACHABLE assert(false) #define JSON_ASSERT(condition) \ diff --git a/src/ripple/json/json_errors.h b/include/xrpl/json/json_errors.h similarity index 100% rename from src/ripple/json/json_errors.h rename to include/xrpl/json/json_errors.h diff --git a/src/ripple/json/json_forwards.h b/include/xrpl/json/json_forwards.h similarity index 100% rename from src/ripple/json/json_forwards.h rename to include/xrpl/json/json_forwards.h diff --git a/src/ripple/json/json_reader.h b/include/xrpl/json/json_reader.h similarity index 98% rename from src/ripple/json/json_reader.h rename to include/xrpl/json/json_reader.h index caa657eb765..6fb07c318d8 100644 --- a/src/ripple/json/json_reader.h +++ b/include/xrpl/json/json_reader.h @@ -22,8 +22,8 @@ #define CPPTL_JSON_READER_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/json/json_value.h b/include/xrpl/json/json_value.h similarity index 99% rename from src/ripple/json/json_value.h rename to include/xrpl/json/json_value.h index c8312e51448..c2f9184d79a 100644 --- a/src/ripple/json/json_value.h +++ b/include/xrpl/json/json_value.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_JSON_JSON_VALUE_H_INCLUDED #define RIPPLE_JSON_JSON_VALUE_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/json/json_writer.h b/include/xrpl/json/json_writer.h similarity index 99% rename from src/ripple/json/json_writer.h rename to include/xrpl/json/json_writer.h index d1ddcd4decf..86a5ecd984a 100644 --- a/src/ripple/json/json_writer.h +++ b/include/xrpl/json/json_writer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_JSON_JSON_WRITER_H_INCLUDED #define RIPPLE_JSON_JSON_WRITER_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/json/to_string.h b/include/xrpl/json/to_string.h similarity index 100% rename from src/ripple/json/to_string.h rename to include/xrpl/json/to_string.h diff --git a/src/ripple/proto/README.md b/include/xrpl/proto/README.md similarity index 100% rename from src/ripple/proto/README.md rename to include/xrpl/proto/README.md diff --git a/src/ripple/proto/org/xrpl/rpc/v1/README.md b/include/xrpl/proto/org/xrpl/rpc/v1/README.md similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/README.md rename to include/xrpl/proto/org/xrpl/rpc/v1/README.md diff --git a/src/ripple/proto/org/xrpl/rpc/v1/get_ledger.proto b/include/xrpl/proto/org/xrpl/rpc/v1/get_ledger.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/get_ledger.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/get_ledger.proto diff --git a/src/ripple/proto/org/xrpl/rpc/v1/get_ledger_data.proto b/include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_data.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/get_ledger_data.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_data.proto diff --git a/src/ripple/proto/org/xrpl/rpc/v1/get_ledger_diff.proto b/include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_diff.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/get_ledger_diff.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_diff.proto diff --git a/src/ripple/proto/org/xrpl/rpc/v1/get_ledger_entry.proto b/include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_entry.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/get_ledger_entry.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/get_ledger_entry.proto diff --git a/src/ripple/proto/org/xrpl/rpc/v1/ledger.proto b/include/xrpl/proto/org/xrpl/rpc/v1/ledger.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/ledger.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/ledger.proto diff --git a/src/ripple/proto/org/xrpl/rpc/v1/xrp_ledger.proto b/include/xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.proto similarity index 100% rename from src/ripple/proto/org/xrpl/rpc/v1/xrp_ledger.proto rename to include/xrpl/proto/org/xrpl/rpc/v1/xrp_ledger.proto diff --git a/src/ripple/proto/ripple.proto b/include/xrpl/proto/ripple.proto similarity index 100% rename from src/ripple/proto/ripple.proto rename to include/xrpl/proto/ripple.proto diff --git a/src/ripple/protocol/AMMCore.h b/include/xrpl/protocol/AMMCore.h similarity index 95% rename from src/ripple/protocol/AMMCore.h rename to include/xrpl/protocol/AMMCore.h index 816bf86214b..32988af5fc7 100644 --- a/src/ripple/protocol/AMMCore.h +++ b/include/xrpl/protocol/AMMCore.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_PROTOCOL_AMMCORE_H_INCLUDED #define RIPPLE_PROTOCOL_AMMCORE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/AccountID.h b/include/xrpl/protocol/AccountID.h similarity index 95% rename from src/ripple/protocol/AccountID.h rename to include/xrpl/protocol/AccountID.h index 27e1f452293..ebe7f014d9c 100644 --- a/src/ripple/protocol/AccountID.h +++ b/include/xrpl/protocol/AccountID.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_PROTOCOL_ACCOUNTID_H_INCLUDED #define RIPPLE_PROTOCOL_ACCOUNTID_H_INCLUDED -#include +#include // VFALCO Uncomment when the header issues are resolved //#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/AmountConversions.h b/include/xrpl/protocol/AmountConversions.h similarity index 98% rename from src/ripple/protocol/AmountConversions.h rename to include/xrpl/protocol/AmountConversions.h index dc0defe6972..0348e3c975d 100644 --- a/src/ripple/protocol/AmountConversions.h +++ b/include/xrpl/protocol/AmountConversions.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_AMOUNTCONVERSION_H_INCLUDED #define RIPPLE_PROTOCOL_AMOUNTCONVERSION_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/ApiVersion.h b/include/xrpl/protocol/ApiVersion.h similarity index 100% rename from src/ripple/protocol/ApiVersion.h rename to include/xrpl/protocol/ApiVersion.h diff --git a/src/ripple/protocol/Book.h b/include/xrpl/protocol/Book.h similarity index 98% rename from src/ripple/protocol/Book.h rename to include/xrpl/protocol/Book.h index 609989062c0..164a5ccfa99 100644 --- a/src/ripple/protocol/Book.h +++ b/include/xrpl/protocol/Book.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_BOOK_H_INCLUDED #define RIPPLE_PROTOCOL_BOOK_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/BuildInfo.h b/include/xrpl/protocol/BuildInfo.h similarity index 100% rename from src/ripple/protocol/BuildInfo.h rename to include/xrpl/protocol/BuildInfo.h diff --git a/src/ripple/protocol/ErrorCodes.h b/include/xrpl/protocol/ErrorCodes.h similarity index 99% rename from src/ripple/protocol/ErrorCodes.h rename to include/xrpl/protocol/ErrorCodes.h index ad849f2b4ef..6d5590ec605 100644 --- a/src/ripple/protocol/ErrorCodes.h +++ b/include/xrpl/protocol/ErrorCodes.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_ERRORCODES_H_INCLUDED #define RIPPLE_PROTOCOL_ERRORCODES_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/Feature.h b/include/xrpl/protocol/Feature.h similarity index 95% rename from src/ripple/protocol/Feature.h rename to include/xrpl/protocol/Feature.h index b8788a74de7..49f94b88d86 100644 --- a/src/ripple/protocol/Feature.h +++ b/include/xrpl/protocol/Feature.h @@ -20,10 +20,11 @@ #ifndef RIPPLE_PROTOCOL_FEATURE_H_INCLUDED #define RIPPLE_PROTOCOL_FEATURE_H_INCLUDED -#include +#include #include #include #include +#include #include #include @@ -67,6 +68,11 @@ namespace ripple { enum class VoteBehavior : int { Obsolete = -1, DefaultNo = 0, DefaultYes }; +enum class AmendmentSupport : int { Retired = -1, Supported = 0, Unsupported }; + +/** All amendments libxrpl knows about. */ +std::map const& +allAmendments(); namespace detail { @@ -74,7 +80,7 @@ namespace detail { // Feature.cpp. Because it's only used to reserve storage, and determine how // large to make the FeatureBitset, it MAY be larger. It MUST NOT be less than // the actual number of amendments. A LogicError on startup will verify this. -static constexpr std::size_t numFeatures = 73; +static constexpr std::size_t numFeatures = 77; /** Amendments that this server supports and the default voting behavior. Whether they are enabled depends on the Rules defined in the validated @@ -359,7 +365,11 @@ extern uint256 const featurePriceOracle; extern uint256 const fixEmptyDID; extern uint256 const fixXChainRewardRounding; extern uint256 const fixPreviousTxnID; -extern uint256 const fixAMMRounding; +extern uint256 const fixAMMv1_1; +extern uint256 const featureNFTokenMintOffer; +extern uint256 const fixReducedOffersV2; +extern uint256 const fixEnforceNFTokenTrustline; +extern uint256 const fixInnerObjTemplate2; } // namespace ripple diff --git a/src/ripple/protocol/Fees.h b/include/xrpl/protocol/Fees.h similarity index 98% rename from src/ripple/protocol/Fees.h rename to include/xrpl/protocol/Fees.h index d155b869d1d..7b4671a91d9 100644 --- a/src/ripple/protocol/Fees.h +++ b/include/xrpl/protocol/Fees.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_FEES_H_INCLUDED #define RIPPLE_PROTOCOL_FEES_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/HashPrefix.h b/include/xrpl/protocol/HashPrefix.h similarity index 98% rename from src/ripple/protocol/HashPrefix.h rename to include/xrpl/protocol/HashPrefix.h index 409f9de9b51..0979756b6e1 100644 --- a/src/ripple/protocol/HashPrefix.h +++ b/include/xrpl/protocol/HashPrefix.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED #define RIPPLE_PROTOCOL_HASHPREFIX_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/Indexes.h b/include/xrpl/protocol/Indexes.h similarity index 95% rename from src/ripple/protocol/Indexes.h rename to include/xrpl/protocol/Indexes.h index d83599f892f..d57525121de 100644 --- a/src/ripple/protocol/Indexes.h +++ b/include/xrpl/protocol/Indexes.h @@ -20,15 +20,15 @@ #ifndef RIPPLE_PROTOCOL_INDEXES_H_INCLUDED #define RIPPLE_PROTOCOL_INDEXES_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/InnerObjectFormats.h b/include/xrpl/protocol/InnerObjectFormats.h similarity index 97% rename from src/ripple/protocol/InnerObjectFormats.h rename to include/xrpl/protocol/InnerObjectFormats.h index 33a155d03cb..06ca5af385c 100644 --- a/src/ripple/protocol/InnerObjectFormats.h +++ b/include/xrpl/protocol/InnerObjectFormats.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_INNER_OBJECT_FORMATS_H_INCLUDED #define RIPPLE_PROTOCOL_INNER_OBJECT_FORMATS_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/Issue.h b/include/xrpl/protocol/Issue.h similarity index 97% rename from src/ripple/protocol/Issue.h rename to include/xrpl/protocol/Issue.h index 1956b942e2b..a18502f2138 100644 --- a/src/ripple/protocol/Issue.h +++ b/include/xrpl/protocol/Issue.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_ISSUE_H_INCLUDED #define RIPPLE_PROTOCOL_ISSUE_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/protocol/KeyType.h b/include/xrpl/protocol/KeyType.h similarity index 100% rename from src/ripple/protocol/KeyType.h rename to include/xrpl/protocol/KeyType.h diff --git a/src/ripple/protocol/Keylet.h b/include/xrpl/protocol/Keylet.h similarity index 95% rename from src/ripple/protocol/Keylet.h rename to include/xrpl/protocol/Keylet.h index 1c08ce855c6..d3bda103314 100644 --- a/src/ripple/protocol/Keylet.h +++ b/include/xrpl/protocol/Keylet.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_KEYLET_H_INCLUDED #define RIPPLE_PROTOCOL_KEYLET_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/KnownFormats.h b/include/xrpl/protocol/KnownFormats.h similarity index 98% rename from src/ripple/protocol/KnownFormats.h rename to include/xrpl/protocol/KnownFormats.h index b59742259ad..5f5a04be1b3 100644 --- a/src/ripple/protocol/KnownFormats.h +++ b/include/xrpl/protocol/KnownFormats.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED #define RIPPLE_PROTOCOL_KNOWNFORMATS_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/LedgerFormats.h b/include/xrpl/protocol/LedgerFormats.h similarity index 99% rename from src/ripple/protocol/LedgerFormats.h rename to include/xrpl/protocol/LedgerFormats.h index e0ea7bf6f46..0ee6c992d8d 100644 --- a/src/ripple/protocol/LedgerFormats.h +++ b/include/xrpl/protocol/LedgerFormats.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_LEDGERFORMATS_H_INCLUDED #define RIPPLE_PROTOCOL_LEDGERFORMATS_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/LedgerHeader.h b/include/xrpl/protocol/LedgerHeader.h similarity index 93% rename from src/ripple/protocol/LedgerHeader.h rename to include/xrpl/protocol/LedgerHeader.h index 2adcfcfd209..663eb709be2 100644 --- a/src/ripple/protocol/LedgerHeader.h +++ b/include/xrpl/protocol/LedgerHeader.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_PROTOCOL_LEDGERHEADER_H_INCLUDED #define RIPPLE_PROTOCOL_LEDGERHEADER_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/MultiApiJson.h b/include/xrpl/protocol/MultiApiJson.h similarity index 99% rename from src/ripple/protocol/MultiApiJson.h rename to include/xrpl/protocol/MultiApiJson.h index b6d1843ae69..4514c54ea34 100644 --- a/src/ripple/protocol/MultiApiJson.h +++ b/include/xrpl/protocol/MultiApiJson.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_JSON_MULTIAPIJSON_H_INCLUDED #define RIPPLE_JSON_MULTIAPIJSON_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/protocol/NFTSyntheticSerializer.h b/include/xrpl/protocol/NFTSyntheticSerializer.h similarity index 92% rename from src/ripple/protocol/NFTSyntheticSerializer.h rename to include/xrpl/protocol/NFTSyntheticSerializer.h index f9a0cd50a46..e57b3ff71c9 100644 --- a/src/ripple/protocol/NFTSyntheticSerializer.h +++ b/include/xrpl/protocol/NFTSyntheticSerializer.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_NFTSYNTHETICSERIALIZER_H_INCLUDED #define RIPPLE_PROTOCOL_NFTSYNTHETICSERIALIZER_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/NFTokenID.h b/include/xrpl/protocol/NFTokenID.h similarity index 92% rename from src/ripple/protocol/NFTokenID.h rename to include/xrpl/protocol/NFTokenID.h index f29713aba7b..b9ea75d2036 100644 --- a/src/ripple/protocol/NFTokenID.h +++ b/include/xrpl/protocol/NFTokenID.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_NFTOKENID_H_INCLUDED #define RIPPLE_PROTOCOL_NFTOKENID_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/NFTokenOfferID.h b/include/xrpl/protocol/NFTokenOfferID.h similarity index 92% rename from src/ripple/protocol/NFTokenOfferID.h rename to include/xrpl/protocol/NFTokenOfferID.h index 777324f4243..9645b0b34da 100644 --- a/src/ripple/protocol/NFTokenOfferID.h +++ b/include/xrpl/protocol/NFTokenOfferID.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_NFTOKENOFFERID_H_INCLUDED #define RIPPLE_PROTOCOL_NFTOKENOFFERID_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/PayChan.h b/include/xrpl/protocol/PayChan.h similarity index 90% rename from src/ripple/protocol/PayChan.h rename to include/xrpl/protocol/PayChan.h index 216835de270..8344120ccd6 100644 --- a/src/ripple/protocol/PayChan.h +++ b/include/xrpl/protocol/PayChan.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_PAYCHAN_H_INCLUDED #define RIPPLE_PROTOCOL_PAYCHAN_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/Protocol.h b/include/xrpl/protocol/Protocol.h similarity index 98% rename from src/ripple/protocol/Protocol.h rename to include/xrpl/protocol/Protocol.h index bd723627494..8d8a71dfef8 100644 --- a/src/ripple/protocol/Protocol.h +++ b/include/xrpl/protocol/Protocol.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_PROTOCOL_H_INCLUDED #define RIPPLE_PROTOCOL_PROTOCOL_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/PublicKey.h b/include/xrpl/protocol/PublicKey.h similarity index 96% rename from src/ripple/protocol/PublicKey.h rename to include/xrpl/protocol/PublicKey.h index 9cf1a456953..c68656877c9 100644 --- a/src/ripple/protocol/PublicKey.h +++ b/include/xrpl/protocol/PublicKey.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_PROTOCOL_PUBLICKEY_H_INCLUDED #define RIPPLE_PROTOCOL_PUBLICKEY_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/Quality.h b/include/xrpl/protocol/Quality.h similarity index 66% rename from src/ripple/protocol/Quality.h rename to include/xrpl/protocol/Quality.h index 840d8d444e1..1ee2cc9f686 100644 --- a/src/ripple/protocol/Quality.h +++ b/include/xrpl/protocol/Quality.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_QUALITY_H_INCLUDED #define RIPPLE_PROTOCOL_QUALITY_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -181,71 +181,71 @@ class Quality Math is avoided if the result is exact. The output is clamped to prevent money creation. */ - Amounts + [[nodiscard]] Amounts ceil_in(Amounts const& amount, STAmount const& limit) const; template - TAmounts - ceil_in(TAmounts const& amount, In const& limit) const - { - if (amount.in <= limit) - return amount; - - // Use the existing STAmount implementation for now, but consider - // replacing with code specific to IOUAMount and XRPAmount - Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out)); - STAmount stLim(toSTAmount(limit)); - auto const stRes = ceil_in(stAmt, stLim); - return TAmounts( - toAmount(stRes.in), toAmount(stRes.out)); - } + [[nodiscard]] TAmounts + ceil_in(TAmounts const& amount, In const& limit) const; + + // Some of the underlying rounding functions called by ceil_in() ignored + // low order bits that could influence rounding decisions. This "strict" + // method uses underlying functions that pay attention to all the bits. + [[nodiscard]] Amounts + ceil_in_strict(Amounts const& amount, STAmount const& limit, bool roundUp) + const; + + template + [[nodiscard]] TAmounts + ceil_in_strict( + TAmounts const& amount, + In const& limit, + bool roundUp) const; /** Returns the scaled amount with out capped. Math is avoided if the result is exact. The input is clamped to prevent money creation. */ - Amounts + [[nodiscard]] Amounts ceil_out(Amounts const& amount, STAmount const& limit) const; template - TAmounts - ceil_out(TAmounts const& amount, Out const& limit) const - { - if (amount.out <= limit) - return amount; - - // Use the existing STAmount implementation for now, but consider - // replacing with code specific to IOUAMount and XRPAmount - Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out)); - STAmount stLim(toSTAmount(limit)); - auto const stRes = ceil_out(stAmt, stLim); - return TAmounts( - toAmount(stRes.in), toAmount(stRes.out)); - } + [[nodiscard]] TAmounts + ceil_out(TAmounts const& amount, Out const& limit) const; - Amounts + // Some of the underlying rounding functions called by ceil_out() ignored + // low order bits that could influence rounding decisions. This "strict" + // method uses underlying functions that pay attention to all the bits. + [[nodiscard]] Amounts ceil_out_strict(Amounts const& amount, STAmount const& limit, bool roundUp) const; template - TAmounts + [[nodiscard]] TAmounts ceil_out_strict( TAmounts const& amount, Out const& limit, - bool roundUp) const - { - if (amount.out <= limit) - return amount; - - // Use the existing STAmount implementation for now, but consider - // replacing with code specific to IOUAMount and XRPAmount - Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out)); - STAmount stLim(toSTAmount(limit)); - auto const stRes = ceil_out_strict(stAmt, stLim, roundUp); - return TAmounts( - toAmount(stRes.in), toAmount(stRes.out)); - } + bool roundUp) const; +private: + // The ceil_in and ceil_out methods that deal in TAmount all convert + // their arguments to STAoumout and convert the result back to TAmount. + // This helper function takes care of all the conversion operations. + template < + class In, + class Out, + class Lim, + typename FnPtr, + std::same_as... Round> + [[nodiscard]] TAmounts + ceil_TAmounts_helper( + TAmounts const& amount, + Lim const& limit, + Lim const& limit_cmp, + FnPtr ceil_function, + Round... round) const; + +public: /** Returns `true` if lhs is lower quality than `rhs`. Lower quality means the taker receives a worse deal. Higher quality is better for the taker. @@ -327,6 +327,84 @@ class Quality } }; +template < + class In, + class Out, + class Lim, + typename FnPtr, + std::same_as... Round> +TAmounts +Quality::ceil_TAmounts_helper( + TAmounts const& amount, + Lim const& limit, + Lim const& limit_cmp, + FnPtr ceil_function, + Round... roundUp) const +{ + if (limit_cmp <= limit) + return amount; + + // Use the existing STAmount implementation for now, but consider + // replacing with code specific to IOUAMount and XRPAmount + Amounts stAmt(toSTAmount(amount.in), toSTAmount(amount.out)); + STAmount stLim(toSTAmount(limit)); + Amounts const stRes = ((*this).*ceil_function)(stAmt, stLim, roundUp...); + return TAmounts(toAmount(stRes.in), toAmount(stRes.out)); +} + +template +TAmounts +Quality::ceil_in(TAmounts const& amount, In const& limit) const +{ + // Construct a function pointer to the function we want to call. + static constexpr Amounts (Quality::*ceil_in_fn_ptr)( + Amounts const&, STAmount const&) const = &Quality::ceil_in; + + return ceil_TAmounts_helper(amount, limit, amount.in, ceil_in_fn_ptr); +} + +template +TAmounts +Quality::ceil_in_strict( + TAmounts const& amount, + In const& limit, + bool roundUp) const +{ + // Construct a function pointer to the function we want to call. + static constexpr Amounts (Quality::*ceil_in_fn_ptr)( + Amounts const&, STAmount const&, bool) const = &Quality::ceil_in_strict; + + return ceil_TAmounts_helper( + amount, limit, amount.in, ceil_in_fn_ptr, roundUp); +} + +template +TAmounts +Quality::ceil_out(TAmounts const& amount, Out const& limit) const +{ + // Construct a function pointer to the function we want to call. + static constexpr Amounts (Quality::*ceil_out_fn_ptr)( + Amounts const&, STAmount const&) const = &Quality::ceil_out; + + return ceil_TAmounts_helper(amount, limit, amount.out, ceil_out_fn_ptr); +} + +template +TAmounts +Quality::ceil_out_strict( + TAmounts const& amount, + Out const& limit, + bool roundUp) const +{ + // Construct a function pointer to the function we want to call. + static constexpr Amounts (Quality::*ceil_out_fn_ptr)( + Amounts const&, STAmount const&, bool) const = + &Quality::ceil_out_strict; + + return ceil_TAmounts_helper( + amount, limit, amount.out, ceil_out_fn_ptr, roundUp); +} + /** Calculate the quality of a two-hop path given the two hops. @param lhs The first leg of the path: input to intermediate. @param rhs The second leg of the path: intermediate to output. diff --git a/src/ripple/protocol/QualityFunction.h b/include/xrpl/protocol/QualityFunction.h similarity index 96% rename from src/ripple/protocol/QualityFunction.h rename to include/xrpl/protocol/QualityFunction.h index 5e08bdf8cd3..f7184881489 100644 --- a/src/ripple/protocol/QualityFunction.h +++ b/include/xrpl/protocol/QualityFunction.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_QUALITYFUNCTION_H_INCLUDED #define RIPPLE_PROTOCOL_QUALITYFUNCTION_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/README.md b/include/xrpl/protocol/README.md similarity index 100% rename from src/ripple/protocol/README.md rename to include/xrpl/protocol/README.md diff --git a/src/ripple/protocol/RPCErr.h b/include/xrpl/protocol/RPCErr.h similarity index 97% rename from src/ripple/protocol/RPCErr.h rename to include/xrpl/protocol/RPCErr.h index e49e96b3df1..cb106b2f0da 100644 --- a/src/ripple/protocol/RPCErr.h +++ b/include/xrpl/protocol/RPCErr.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_NET_RPCERR_H_INCLUDED #define RIPPLE_NET_RPCERR_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/Rate.h b/include/xrpl/protocol/Rate.h similarity index 98% rename from src/ripple/protocol/Rate.h rename to include/xrpl/protocol/Rate.h index 3524eabb627..b065acb2316 100644 --- a/src/ripple/protocol/Rate.h +++ b/include/xrpl/protocol/Rate.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_RATE_H_INCLUDED #define RIPPLE_PROTOCOL_RATE_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/protocol/RippleLedgerHash.h b/include/xrpl/protocol/RippleLedgerHash.h similarity index 97% rename from src/ripple/protocol/RippleLedgerHash.h rename to include/xrpl/protocol/RippleLedgerHash.h index 2a7b5728342..19ba803b823 100644 --- a/src/ripple/protocol/RippleLedgerHash.h +++ b/include/xrpl/protocol/RippleLedgerHash.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_RIPPLELEDGERHASH_H_INCLUDED #define RIPPLE_PROTOCOL_RIPPLELEDGERHASH_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/Rules.h b/include/xrpl/protocol/Rules.h similarity index 96% rename from src/ripple/protocol/Rules.h rename to include/xrpl/protocol/Rules.h index f8ff8c00c0c..6b22d01afe0 100644 --- a/src/ripple/protocol/Rules.h +++ b/include/xrpl/protocol/Rules.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_LEDGER_RULES_H_INCLUDED #define RIPPLE_LEDGER_RULES_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/SField.h b/include/xrpl/protocol/SField.h similarity index 99% rename from src/ripple/protocol/SField.h rename to include/xrpl/protocol/SField.h index 727d531ff40..15aa2272d75 100644 --- a/src/ripple/protocol/SField.h +++ b/include/xrpl/protocol/SField.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_SFIELD_H_INCLUDED #define RIPPLE_PROTOCOL_SFIELD_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/protocol/SOTemplate.h b/include/xrpl/protocol/SOTemplate.h similarity index 98% rename from src/ripple/protocol/SOTemplate.h rename to include/xrpl/protocol/SOTemplate.h index 609c2d2c80b..c0fcfb64358 100644 --- a/src/ripple/protocol/SOTemplate.h +++ b/include/xrpl/protocol/SOTemplate.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_SOTEMPLATE_H_INCLUDED #define RIPPLE_PROTOCOL_SOTEMPLATE_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/STAccount.h b/include/xrpl/protocol/STAccount.h similarity index 96% rename from src/ripple/protocol/STAccount.h rename to include/xrpl/protocol/STAccount.h index c44327fe566..537a336e5db 100644 --- a/src/ripple/protocol/STAccount.h +++ b/include/xrpl/protocol/STAccount.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_STACCOUNT_H_INCLUDED #define RIPPLE_PROTOCOL_STACCOUNT_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/STAmount.h b/include/xrpl/protocol/STAmount.h similarity index 97% rename from src/ripple/protocol/STAmount.h rename to include/xrpl/protocol/STAmount.h index 1de1568ae03..3eed0860f54 100644 --- a/src/ripple/protocol/STAmount.h +++ b/include/xrpl/protocol/STAmount.h @@ -20,16 +20,16 @@ #ifndef RIPPLE_PROTOCOL_STAMOUNT_H_INCLUDED #define RIPPLE_PROTOCOL_STAMOUNT_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STArray.h b/include/xrpl/protocol/STArray.h similarity index 98% rename from src/ripple/protocol/STArray.h rename to include/xrpl/protocol/STArray.h index 8c3833d3fc8..7fa2ecad834 100644 --- a/src/ripple/protocol/STArray.h +++ b/include/xrpl/protocol/STArray.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_STARRAY_H_INCLUDED #define RIPPLE_PROTOCOL_STARRAY_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STBase.h b/include/xrpl/protocol/STBase.h similarity index 98% rename from src/ripple/protocol/STBase.h rename to include/xrpl/protocol/STBase.h index ec8c34a9ddd..e13ef6c5b3e 100644 --- a/src/ripple/protocol/STBase.h +++ b/include/xrpl/protocol/STBase.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_STBASE_H_INCLUDED #define RIPPLE_PROTOCOL_STBASE_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/STBitString.h b/include/xrpl/protocol/STBitString.h similarity index 97% rename from src/ripple/protocol/STBitString.h rename to include/xrpl/protocol/STBitString.h index decdfa64861..7dc92303e72 100644 --- a/src/ripple/protocol/STBitString.h +++ b/include/xrpl/protocol/STBitString.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_STBITSTRING_H_INCLUDED #define RIPPLE_PROTOCOL_STBITSTRING_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STBlob.h b/include/xrpl/protocol/STBlob.h similarity index 95% rename from src/ripple/protocol/STBlob.h rename to include/xrpl/protocol/STBlob.h index 3b2731be7f0..bdedbd92105 100644 --- a/src/ripple/protocol/STBlob.h +++ b/include/xrpl/protocol/STBlob.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_STBLOB_H_INCLUDED #define RIPPLE_PROTOCOL_STBLOB_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/STCurrency.h b/include/xrpl/protocol/STCurrency.h similarity index 94% rename from src/ripple/protocol/STCurrency.h rename to include/xrpl/protocol/STCurrency.h index f855c24832e..3383137fb3a 100644 --- a/src/ripple/protocol/STCurrency.h +++ b/include/xrpl/protocol/STCurrency.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_PROTOCOL_STCURRENCY_H_INCLUDED #define RIPPLE_PROTOCOL_STCURRENCY_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STExchange.h b/include/xrpl/protocol/STExchange.h similarity index 93% rename from src/ripple/protocol/STExchange.h rename to include/xrpl/protocol/STExchange.h index e22d75b08ee..e1a1215dbdd 100644 --- a/src/ripple/protocol/STExchange.h +++ b/include/xrpl/protocol/STExchange.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_PROTOCOL_STEXCHANGE_H_INCLUDED #define RIPPLE_PROTOCOL_STEXCHANGE_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/STInteger.h b/include/xrpl/protocol/STInteger.h similarity index 98% rename from src/ripple/protocol/STInteger.h rename to include/xrpl/protocol/STInteger.h index aaf0f8c904e..6bae2cc3152 100644 --- a/src/ripple/protocol/STInteger.h +++ b/include/xrpl/protocol/STInteger.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_STINTEGER_H_INCLUDED #define RIPPLE_PROTOCOL_STINTEGER_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STIssue.h b/include/xrpl/protocol/STIssue.h similarity index 94% rename from src/ripple/protocol/STIssue.h rename to include/xrpl/protocol/STIssue.h index 223798a8911..a0dfbd4faec 100644 --- a/src/ripple/protocol/STIssue.h +++ b/include/xrpl/protocol/STIssue.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_PROTOCOL_STISSUE_H_INCLUDED #define RIPPLE_PROTOCOL_STISSUE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STLedgerEntry.h b/include/xrpl/protocol/STLedgerEntry.h similarity index 97% rename from src/ripple/protocol/STLedgerEntry.h rename to include/xrpl/protocol/STLedgerEntry.h index 6fd50aa154e..6a57b32451a 100644 --- a/src/ripple/protocol/STLedgerEntry.h +++ b/include/xrpl/protocol/STLedgerEntry.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_STLEDGERENTRY_H_INCLUDED #define RIPPLE_PROTOCOL_STLEDGERENTRY_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STObject.h b/include/xrpl/protocol/STObject.h similarity index 97% rename from src/ripple/protocol/STObject.h rename to include/xrpl/protocol/STObject.h index 38678f67a55..b3cef83de5f 100644 --- a/src/ripple/protocol/STObject.h +++ b/include/xrpl/protocol/STObject.h @@ -20,20 +20,20 @@ #ifndef RIPPLE_PROTOCOL_STOBJECT_H_INCLUDED #define RIPPLE_PROTOCOL_STOBJECT_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -44,7 +44,6 @@ namespace ripple { class STArray; -class Rules; inline void throwFieldNotFound(SField const& field) @@ -105,7 +104,7 @@ class STObject : public STBase, public CountedObject explicit STObject(SField const& name); static STObject - makeInnerObject(SField const& name, Rules const& rules); + makeInnerObject(SField const& name); iterator begin() const; diff --git a/src/ripple/protocol/STParsedJSON.h b/include/xrpl/protocol/STParsedJSON.h similarity index 98% rename from src/ripple/protocol/STParsedJSON.h rename to include/xrpl/protocol/STParsedJSON.h index 11cba574027..d2052bf1f4c 100644 --- a/src/ripple/protocol/STParsedJSON.h +++ b/include/xrpl/protocol/STParsedJSON.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_STPARSEDJSON_H_INCLUDED #define RIPPLE_PROTOCOL_STPARSEDJSON_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/STPathSet.h b/include/xrpl/protocol/STPathSet.h similarity index 98% rename from src/ripple/protocol/STPathSet.h rename to include/xrpl/protocol/STPathSet.h index 8102bc76eb0..473086368fb 100644 --- a/src/ripple/protocol/STPathSet.h +++ b/include/xrpl/protocol/STPathSet.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_PROTOCOL_STPATHSET_H_INCLUDED #define RIPPLE_PROTOCOL_STPATHSET_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/STTx.h b/include/xrpl/protocol/STTx.h similarity index 94% rename from src/ripple/protocol/STTx.h rename to include/xrpl/protocol/STTx.h index e166eb20dd4..08b9a1bad10 100644 --- a/src/ripple/protocol/STTx.h +++ b/include/xrpl/protocol/STTx.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_PROTOCOL_STTX_H_INCLUDED #define RIPPLE_PROTOCOL_STTX_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/STValidation.h b/include/xrpl/protocol/STValidation.h similarity index 97% rename from src/ripple/protocol/STValidation.h rename to include/xrpl/protocol/STValidation.h index edd922e7bfa..6cae0971f51 100644 --- a/src/ripple/protocol/STValidation.h +++ b/include/xrpl/protocol/STValidation.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_PROTOCOL_STVALIDATION_H_INCLUDED #define RIPPLE_PROTOCOL_STVALIDATION_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/STVector256.h b/include/xrpl/protocol/STVector256.h similarity index 97% rename from src/ripple/protocol/STVector256.h rename to include/xrpl/protocol/STVector256.h index bf4a1cbec44..e70297a40bf 100644 --- a/src/ripple/protocol/STVector256.h +++ b/include/xrpl/protocol/STVector256.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_STVECTOR256_H_INCLUDED #define RIPPLE_PROTOCOL_STVECTOR256_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/STXChainBridge.h b/include/xrpl/protocol/STXChainBridge.h similarity index 97% rename from src/ripple/protocol/STXChainBridge.h rename to include/xrpl/protocol/STXChainBridge.h index 537a1d160b2..38db1912c70 100644 --- a/src/ripple/protocol/STXChainBridge.h +++ b/include/xrpl/protocol/STXChainBridge.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_STXCHAINBRIDGE_H_INCLUDED #define RIPPLE_PROTOCOL_STXCHAINBRIDGE_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/SecretKey.h b/include/xrpl/protocol/SecretKey.h similarity index 95% rename from src/ripple/protocol/SecretKey.h rename to include/xrpl/protocol/SecretKey.h index 824ae9b1e0f..67dc9c4ca59 100644 --- a/src/ripple/protocol/SecretKey.h +++ b/include/xrpl/protocol/SecretKey.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_PROTOCOL_SECRETKEY_H_INCLUDED #define RIPPLE_PROTOCOL_SECRETKEY_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/Seed.h b/include/xrpl/protocol/Seed.h similarity index 96% rename from src/ripple/protocol/Seed.h rename to include/xrpl/protocol/Seed.h index 2ebc64970f0..1d0a736db8a 100644 --- a/src/ripple/protocol/Seed.h +++ b/include/xrpl/protocol/Seed.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_SEED_H_INCLUDED #define RIPPLE_PROTOCOL_SEED_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/SeqProxy.h b/include/xrpl/protocol/SeqProxy.h similarity index 100% rename from src/ripple/protocol/SeqProxy.h rename to include/xrpl/protocol/SeqProxy.h diff --git a/src/ripple/protocol/Serializer.h b/include/xrpl/protocol/Serializer.h similarity index 96% rename from src/ripple/protocol/Serializer.h rename to include/xrpl/protocol/Serializer.h index e3ef00eaf65..b85e8eb013d 100644 --- a/src/ripple/protocol/Serializer.h +++ b/include/xrpl/protocol/Serializer.h @@ -20,15 +20,15 @@ #ifndef RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED #define RIPPLE_PROTOCOL_SERIALIZER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/Sign.h b/include/xrpl/protocol/Sign.h similarity index 95% rename from src/ripple/protocol/Sign.h rename to include/xrpl/protocol/Sign.h index 6af29530486..30fbb26244b 100644 --- a/src/ripple/protocol/Sign.h +++ b/include/xrpl/protocol/Sign.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_SIGN_H_INCLUDED #define RIPPLE_PROTOCOL_SIGN_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/SystemParameters.h b/include/xrpl/protocol/SystemParameters.h similarity index 97% rename from src/ripple/protocol/SystemParameters.h rename to include/xrpl/protocol/SystemParameters.h index bc2f7136ff9..c99944193ae 100644 --- a/src/ripple/protocol/SystemParameters.h +++ b/include/xrpl/protocol/SystemParameters.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_SYSTEMPARAMETERS_H_INCLUDED #define RIPPLE_PROTOCOL_SYSTEMPARAMETERS_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/protocol/TER.h b/include/xrpl/protocol/TER.h similarity index 99% rename from src/ripple/protocol/TER.h rename to include/xrpl/protocol/TER.h index 41c23a2d6a8..335ef8de39a 100644 --- a/src/ripple/protocol/TER.h +++ b/include/xrpl/protocol/TER.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_TER_H_INCLUDED #define RIPPLE_PROTOCOL_TER_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/protocol/TxFlags.h b/include/xrpl/protocol/TxFlags.h similarity index 100% rename from src/ripple/protocol/TxFlags.h rename to include/xrpl/protocol/TxFlags.h diff --git a/src/ripple/protocol/TxFormats.h b/include/xrpl/protocol/TxFormats.h similarity index 99% rename from src/ripple/protocol/TxFormats.h rename to include/xrpl/protocol/TxFormats.h index b5afa470f38..bd5dffd94e9 100644 --- a/src/ripple/protocol/TxFormats.h +++ b/include/xrpl/protocol/TxFormats.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_TXFORMATS_H_INCLUDED #define RIPPLE_PROTOCOL_TXFORMATS_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/protocol/TxMeta.h b/include/xrpl/protocol/TxMeta.h similarity index 95% rename from src/ripple/protocol/TxMeta.h rename to include/xrpl/protocol/TxMeta.h index 0a6578b1930..7932a4c55a3 100644 --- a/src/ripple/protocol/TxMeta.h +++ b/include/xrpl/protocol/TxMeta.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_TX_TRANSACTIONMETA_H_INCLUDED #define RIPPLE_APP_TX_TRANSACTIONMETA_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/UintTypes.h b/include/xrpl/protocol/UintTypes.h similarity index 95% rename from src/ripple/protocol/UintTypes.h rename to include/xrpl/protocol/UintTypes.h index 6fb685551f8..a0a8069f669 100644 --- a/src/ripple/protocol/UintTypes.h +++ b/include/xrpl/protocol/UintTypes.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED #define RIPPLE_PROTOCOL_UINTTYPES_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { namespace detail { diff --git a/src/ripple/protocol/XChainAttestations.h b/include/xrpl/protocol/XChainAttestations.h similarity index 97% rename from src/ripple/protocol/XChainAttestations.h rename to include/xrpl/protocol/XChainAttestations.h index b99a0b59a4b..721950ca9c1 100644 --- a/src/ripple/protocol/XChainAttestations.h +++ b/include/xrpl/protocol/XChainAttestations.h @@ -20,16 +20,16 @@ #ifndef RIPPLE_PROTOCOL_STXATTESTATIONS_H_INCLUDED #define RIPPLE_PROTOCOL_STXATTESTATIONS_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/STVar.h b/include/xrpl/protocol/detail/STVar.h similarity index 97% rename from src/ripple/protocol/impl/STVar.h rename to include/xrpl/protocol/detail/STVar.h index 73863edbbe0..bee48aa53f6 100644 --- a/src/ripple/protocol/impl/STVar.h +++ b/include/xrpl/protocol/detail/STVar.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_STVAR_H_INCLUDED #define RIPPLE_PROTOCOL_STVAR_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/b58_utils.h b/include/xrpl/protocol/detail/b58_utils.h similarity index 99% rename from src/ripple/protocol/impl/b58_utils.h rename to include/xrpl/protocol/detail/b58_utils.h index c3bb0c03750..f21b416042b 100644 --- a/src/ripple/protocol/impl/b58_utils.h +++ b/include/xrpl/protocol/detail/b58_utils.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_B58_UTILS_H_INCLUDED #define RIPPLE_PROTOCOL_B58_UTILS_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/protocol/impl/secp256k1.h b/include/xrpl/protocol/detail/secp256k1.h similarity index 100% rename from src/ripple/protocol/impl/secp256k1.h rename to include/xrpl/protocol/detail/secp256k1.h diff --git a/src/ripple/protocol/impl/token_errors.h b/include/xrpl/protocol/detail/token_errors.h similarity index 100% rename from src/ripple/protocol/impl/token_errors.h rename to include/xrpl/protocol/detail/token_errors.h diff --git a/src/ripple/protocol/digest.h b/include/xrpl/protocol/digest.h similarity index 98% rename from src/ripple/protocol/digest.h rename to include/xrpl/protocol/digest.h index 6507057dcdc..f3fc2ea5c5d 100644 --- a/src/ripple/protocol/digest.h +++ b/include/xrpl/protocol/digest.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_PROTOCOL_DIGEST_H_INCLUDED #define RIPPLE_PROTOCOL_DIGEST_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/json_get_or_throw.h b/include/xrpl/protocol/json_get_or_throw.h similarity index 95% rename from src/ripple/protocol/json_get_or_throw.h rename to include/xrpl/protocol/json_get_or_throw.h index 86bd5924d3e..5277ee86484 100644 --- a/src/ripple/protocol/json_get_or_throw.h +++ b/include/xrpl/protocol/json_get_or_throw.h @@ -1,11 +1,11 @@ #ifndef PROTOCOL_GET_OR_THROW_H_ #define PROTOCOL_GET_OR_THROW_H_ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/jss.h b/include/xrpl/protocol/jss.h similarity index 99% rename from src/ripple/protocol/jss.h rename to include/xrpl/protocol/jss.h index b5f3d1fcb5d..a46e15f39ef 100644 --- a/src/ripple/protocol/jss.h +++ b/include/xrpl/protocol/jss.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_JSONFIELDS_H_INCLUDED #define RIPPLE_PROTOCOL_JSONFIELDS_H_INCLUDED -#include +#include namespace ripple { namespace jss { diff --git a/src/ripple/protocol/messages.h b/include/xrpl/protocol/messages.h similarity index 97% rename from src/ripple/protocol/messages.h rename to include/xrpl/protocol/messages.h index e9c9cf60b21..640305185ad 100644 --- a/src/ripple/protocol/messages.h +++ b/include/xrpl/protocol/messages.h @@ -31,6 +31,6 @@ #undef TYPE_BOOL #endif -#include +#include #endif diff --git a/src/ripple/protocol/nft.h b/include/xrpl/protocol/nft.h similarity index 97% rename from src/ripple/protocol/nft.h rename to include/xrpl/protocol/nft.h index 2df8e0b89ce..839d872a63a 100644 --- a/src/ripple/protocol/nft.h +++ b/include/xrpl/protocol/nft.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_NFT_H_INCLUDED #define RIPPLE_PROTOCOL_NFT_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/nftPageMask.h b/include/xrpl/protocol/nftPageMask.h similarity index 97% rename from src/ripple/protocol/nftPageMask.h rename to include/xrpl/protocol/nftPageMask.h index a4890b460cd..1f8c39aa138 100644 --- a/src/ripple/protocol/nftPageMask.h +++ b/include/xrpl/protocol/nftPageMask.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_PROTOCOL_NFT_PAGE_MASK_H_INCLUDED #define RIPPLE_PROTOCOL_NFT_PAGE_MASK_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/serialize.h b/include/xrpl/protocol/serialize.h similarity index 92% rename from src/ripple/protocol/serialize.h rename to include/xrpl/protocol/serialize.h index 93c59acfd0a..6d171c5e86b 100644 --- a/src/ripple/protocol/serialize.h +++ b/include/xrpl/protocol/serialize.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_SERIALIZE_H_INCLUDED #define RIPPLE_PROTOCOL_SERIALIZE_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/st.h b/include/xrpl/protocol/st.h similarity index 66% rename from src/ripple/protocol/st.h rename to include/xrpl/protocol/st.h index 7d43ef75f15..7b0e3a3b2df 100644 --- a/src/ripple/protocol/st.h +++ b/include/xrpl/protocol/st.h @@ -20,20 +20,20 @@ #ifndef RIPPLE_PROTOCOL_ST_H_INCLUDED #define RIPPLE_PROTOCOL_ST_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif diff --git a/src/ripple/protocol/tokens.h b/include/xrpl/protocol/tokens.h similarity index 97% rename from src/ripple/protocol/tokens.h rename to include/xrpl/protocol/tokens.h index f51c3f96f95..f0c4e79d43a 100644 --- a/src/ripple/protocol/tokens.h +++ b/include/xrpl/protocol/tokens.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PROTOCOL_TOKENS_H_INCLUDED #define RIPPLE_PROTOCOL_TOKENS_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/resource/Charge.h b/include/xrpl/resource/Charge.h similarity index 100% rename from src/ripple/resource/Charge.h rename to include/xrpl/resource/Charge.h diff --git a/src/ripple/resource/Consumer.h b/include/xrpl/resource/Consumer.h similarity index 96% rename from src/ripple/resource/Consumer.h rename to include/xrpl/resource/Consumer.h index 34fb02ee68f..00e4ad2c5f5 100644 --- a/src/ripple/resource/Consumer.h +++ b/include/xrpl/resource/Consumer.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RESOURCE_CONSUMER_H_INCLUDED #define RIPPLE_RESOURCE_CONSUMER_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/Disposition.h b/include/xrpl/resource/Disposition.h similarity index 100% rename from src/ripple/resource/Disposition.h rename to include/xrpl/resource/Disposition.h diff --git a/src/ripple/resource/Fees.h b/include/xrpl/resource/Fees.h similarity index 98% rename from src/ripple/resource/Fees.h rename to include/xrpl/resource/Fees.h index d3fd5f72c49..d3750ec8282 100644 --- a/src/ripple/resource/Fees.h +++ b/include/xrpl/resource/Fees.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_RESOURCE_FEES_H_INCLUDED #define RIPPLE_RESOURCE_FEES_H_INCLUDED -#include +#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/Gossip.h b/include/xrpl/resource/Gossip.h similarity index 97% rename from src/ripple/resource/Gossip.h rename to include/xrpl/resource/Gossip.h index 742fad640af..6e2a86ecd7c 100644 --- a/src/ripple/resource/Gossip.h +++ b/include/xrpl/resource/Gossip.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_RESOURCE_GOSSIP_H_INCLUDED #define RIPPLE_RESOURCE_GOSSIP_H_INCLUDED -#include +#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/README.md b/include/xrpl/resource/README.md similarity index 100% rename from src/ripple/resource/README.md rename to include/xrpl/resource/README.md diff --git a/src/ripple/resource/ResourceManager.h b/include/xrpl/resource/ResourceManager.h similarity index 88% rename from src/ripple/resource/ResourceManager.h rename to include/xrpl/resource/ResourceManager.h index 7471a37ab35..b33b141ee05 100644 --- a/src/ripple/resource/ResourceManager.h +++ b/include/xrpl/resource/ResourceManager.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_RESOURCE_MANAGER_H_INCLUDED #define RIPPLE_RESOURCE_MANAGER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { @@ -49,7 +49,7 @@ class Manager : public beast::PropertyStream::Source newInboundEndpoint( beast::IP::Endpoint const& address, bool const proxy, - boost::string_view const& forwardedFor) = 0; + std::string_view forwardedFor) = 0; /** Create a new endpoint keyed by outbound IP address and port. */ virtual Consumer diff --git a/src/ripple/resource/Types.h b/include/xrpl/resource/Types.h similarity index 100% rename from src/ripple/resource/Types.h rename to include/xrpl/resource/Types.h diff --git a/src/ripple/resource/impl/Entry.h b/include/xrpl/resource/detail/Entry.h similarity index 93% rename from src/ripple/resource/impl/Entry.h rename to include/xrpl/resource/detail/Entry.h index 126f2546456..d4f32080d9d 100644 --- a/src/ripple/resource/impl/Entry.h +++ b/include/xrpl/resource/detail/Entry.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_RESOURCE_ENTRY_H_INCLUDED #define RIPPLE_RESOURCE_ENTRY_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/resource/impl/Import.h b/include/xrpl/resource/detail/Import.h similarity index 95% rename from src/ripple/resource/impl/Import.h rename to include/xrpl/resource/detail/Import.h index 4eae3fafea0..52315644969 100644 --- a/src/ripple/resource/impl/Import.h +++ b/include/xrpl/resource/detail/Import.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_RESOURCE_IMPORT_H_INCLUDED #define RIPPLE_RESOURCE_IMPORT_H_INCLUDED -#include -#include +#include +#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/impl/Key.h b/include/xrpl/resource/detail/Key.h similarity index 95% rename from src/ripple/resource/impl/Key.h rename to include/xrpl/resource/detail/Key.h index 929c13eebf6..3df2dce039d 100644 --- a/src/ripple/resource/impl/Key.h +++ b/include/xrpl/resource/detail/Key.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_RESOURCE_KEY_H_INCLUDED #define RIPPLE_RESOURCE_KEY_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/resource/impl/Kind.h b/include/xrpl/resource/detail/Kind.h similarity index 100% rename from src/ripple/resource/impl/Kind.h rename to include/xrpl/resource/detail/Kind.h diff --git a/src/ripple/resource/impl/Logic.h b/include/xrpl/resource/detail/Logic.h similarity index 97% rename from src/ripple/resource/impl/Logic.h rename to include/xrpl/resource/detail/Logic.h index 07d89403b6a..a57e529e0a2 100644 --- a/src/ripple/resource/impl/Logic.h +++ b/include/xrpl/resource/detail/Logic.h @@ -20,17 +20,17 @@ #ifndef RIPPLE_RESOURCE_LOGIC_H_INCLUDED #define RIPPLE_RESOURCE_LOGIC_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/resource/impl/Tuning.h b/include/xrpl/resource/detail/Tuning.h similarity index 100% rename from src/ripple/resource/impl/Tuning.h rename to include/xrpl/resource/detail/Tuning.h diff --git a/src/ripple/server/Handoff.h b/include/xrpl/server/Handoff.h similarity index 98% rename from src/ripple/server/Handoff.h rename to include/xrpl/server/Handoff.h index 2b80d6179d6..f57c9ef57ec 100644 --- a/src/ripple/server/Handoff.h +++ b/include/xrpl/server/Handoff.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_SERVER_HANDOFF_H_INCLUDED #define RIPPLE_SERVER_HANDOFF_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/server/Port.h b/include/xrpl/server/Port.h similarity index 98% rename from src/ripple/server/Port.h rename to include/xrpl/server/Port.h index 9dccfdf9c08..4ab56efb459 100644 --- a/src/ripple/server/Port.h +++ b/include/xrpl/server/Port.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_PORT_H_INCLUDED #define RIPPLE_SERVER_PORT_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/server/Server.h b/include/xrpl/server/Server.h similarity index 90% rename from src/ripple/server/Server.h rename to include/xrpl/server/Server.h index a149e34fbfb..e8157c03c6c 100644 --- a/src/ripple/server/Server.h +++ b/include/xrpl/server/Server.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_SERVER_SERVER_H_INCLUDED #define RIPPLE_SERVER_SERVER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/server/Session.h b/include/xrpl/server/Session.h similarity index 96% rename from src/ripple/server/Session.h rename to include/xrpl/server/Session.h index 3b22c06b00b..25cf1ad747d 100644 --- a/src/ripple/server/Session.h +++ b/include/xrpl/server/Session.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_SERVER_SESSION_H_INCLUDED #define RIPPLE_SERVER_SESSION_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/SimpleWriter.h b/include/xrpl/server/SimpleWriter.h similarity index 98% rename from src/ripple/server/SimpleWriter.h rename to include/xrpl/server/SimpleWriter.h index 03582c00114..0e3f63b0d9d 100644 --- a/src/ripple/server/SimpleWriter.h +++ b/include/xrpl/server/SimpleWriter.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_SERVER_SIMPLEWRITER_H_INCLUDED #define RIPPLE_SERVER_SIMPLEWRITER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/server/WSSession.h b/include/xrpl/server/WSSession.h similarity index 97% rename from src/ripple/server/WSSession.h rename to include/xrpl/server/WSSession.h index 812099108a5..d739afcefb7 100644 --- a/src/ripple/server/WSSession.h +++ b/include/xrpl/server/WSSession.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_SERVER_WSSESSION_H_INCLUDED #define RIPPLE_SERVER_WSSESSION_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/server/Writer.h b/include/xrpl/server/Writer.h similarity index 100% rename from src/ripple/server/Writer.h rename to include/xrpl/server/Writer.h diff --git a/src/ripple/server/impl/BaseHTTPPeer.h b/include/xrpl/server/detail/BaseHTTPPeer.h similarity index 98% rename from src/ripple/server/impl/BaseHTTPPeer.h rename to include/xrpl/server/detail/BaseHTTPPeer.h index a6bbd18e1aa..171eb7134e1 100644 --- a/src/ripple/server/impl/BaseHTTPPeer.h +++ b/include/xrpl/server/detail/BaseHTTPPeer.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_SERVER_BASEHTTPPEER_H_INCLUDED #define RIPPLE_SERVER_BASEHTTPPEER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/BasePeer.h b/include/xrpl/server/detail/BasePeer.h similarity index 95% rename from src/ripple/server/impl/BasePeer.h rename to include/xrpl/server/detail/BasePeer.h index bc5375b87f7..a90eaabf6e4 100644 --- a/src/ripple/server/impl/BasePeer.h +++ b/include/xrpl/server/detail/BasePeer.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_SERVER_BASEPEER_H_INCLUDED #define RIPPLE_SERVER_BASEPEER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/BaseWSPeer.h b/include/xrpl/server/detail/BaseWSPeer.h similarity index 98% rename from src/ripple/server/impl/BaseWSPeer.h rename to include/xrpl/server/detail/BaseWSPeer.h index fd1722df003..4c4049a8b9b 100644 --- a/src/ripple/server/impl/BaseWSPeer.h +++ b/include/xrpl/server/detail/BaseWSPeer.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_SERVER_BASEWSPEER_H_INCLUDED #define RIPPLE_SERVER_BASEWSPEER_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/Door.h b/include/xrpl/server/detail/Door.h similarity index 98% rename from src/ripple/server/impl/Door.h rename to include/xrpl/server/detail/Door.h index 94f39719569..20bdf421e38 100644 --- a/src/ripple/server/impl/Door.h +++ b/include/xrpl/server/detail/Door.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_SERVER_DOOR_H_INCLUDED #define RIPPLE_SERVER_DOOR_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/JSONRPCUtil.h b/include/xrpl/server/detail/JSONRPCUtil.h similarity index 95% rename from src/ripple/server/impl/JSONRPCUtil.h rename to include/xrpl/server/detail/JSONRPCUtil.h index d6b67e123c4..7eb00096263 100644 --- a/src/ripple/server/impl/JSONRPCUtil.h +++ b/include/xrpl/server/detail/JSONRPCUtil.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_JSONRPCUTIL_H_INCLUDED #define RIPPLE_SERVER_JSONRPCUTIL_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/server/impl/LowestLayer.h b/include/xrpl/server/detail/LowestLayer.h similarity index 100% rename from src/ripple/server/impl/LowestLayer.h rename to include/xrpl/server/detail/LowestLayer.h diff --git a/src/ripple/server/impl/PlainHTTPPeer.h b/include/xrpl/server/detail/PlainHTTPPeer.h similarity index 97% rename from src/ripple/server/impl/PlainHTTPPeer.h rename to include/xrpl/server/detail/PlainHTTPPeer.h index 4c593ce9cb6..d4b24c01313 100644 --- a/src/ripple/server/impl/PlainHTTPPeer.h +++ b/include/xrpl/server/detail/PlainHTTPPeer.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_SERVER_PLAINHTTPPEER_H_INCLUDED #define RIPPLE_SERVER_PLAINHTTPPEER_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/server/impl/PlainWSPeer.h b/include/xrpl/server/detail/PlainWSPeer.h similarity index 98% rename from src/ripple/server/impl/PlainWSPeer.h rename to include/xrpl/server/detail/PlainWSPeer.h index 504b38baac7..8bcddee7e77 100644 --- a/src/ripple/server/impl/PlainWSPeer.h +++ b/include/xrpl/server/detail/PlainWSPeer.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_SERVER_PLAINWSPEER_H_INCLUDED #define RIPPLE_SERVER_PLAINWSPEER_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/server/impl/SSLHTTPPeer.h b/include/xrpl/server/detail/SSLHTTPPeer.h similarity index 98% rename from src/ripple/server/impl/SSLHTTPPeer.h rename to include/xrpl/server/detail/SSLHTTPPeer.h index 8b5b4e38c4e..db6af46b5b3 100644 --- a/src/ripple/server/impl/SSLHTTPPeer.h +++ b/include/xrpl/server/detail/SSLHTTPPeer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_SSLHTTPPEER_H_INCLUDED #define RIPPLE_SERVER_SSLHTTPPEER_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/SSLWSPeer.h b/include/xrpl/server/detail/SSLWSPeer.h similarity index 97% rename from src/ripple/server/impl/SSLWSPeer.h rename to include/xrpl/server/detail/SSLWSPeer.h index 28c3184fce6..9c88b275397 100644 --- a/src/ripple/server/impl/SSLWSPeer.h +++ b/include/xrpl/server/detail/SSLWSPeer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_SERVER_SSLWSPEER_H_INCLUDED #define RIPPLE_SERVER_SSLWSPEER_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/ServerImpl.h b/include/xrpl/server/detail/ServerImpl.h similarity index 96% rename from src/ripple/server/impl/ServerImpl.h rename to include/xrpl/server/detail/ServerImpl.h index a3abf78914e..00a9a263846 100644 --- a/src/ripple/server/impl/ServerImpl.h +++ b/include/xrpl/server/detail/ServerImpl.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_SERVER_SERVERIMPL_H_INCLUDED #define RIPPLE_SERVER_SERVERIMPL_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/server/impl/io_list.h b/include/xrpl/server/detail/io_list.h similarity index 100% rename from src/ripple/server/impl/io_list.h rename to include/xrpl/server/detail/io_list.h diff --git a/src/ripple/basics/impl/Archive.cpp b/src/libxrpl/basics/Archive.cpp similarity index 98% rename from src/ripple/basics/impl/Archive.cpp rename to src/libxrpl/basics/Archive.cpp index 73e14a93606..e5672bd953f 100644 --- a/src/ripple/basics/impl/Archive.cpp +++ b/src/libxrpl/basics/Archive.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/impl/BasicConfig.cpp b/src/libxrpl/basics/BasicConfig.cpp similarity index 98% rename from src/ripple/basics/impl/BasicConfig.cpp rename to src/libxrpl/basics/BasicConfig.cpp index f557d2e6d46..932eea346f6 100644 --- a/src/ripple/basics/impl/BasicConfig.cpp +++ b/src/libxrpl/basics/BasicConfig.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/impl/CountedObject.cpp b/src/libxrpl/basics/CountedObject.cpp similarity index 97% rename from src/ripple/basics/impl/CountedObject.cpp rename to src/libxrpl/basics/CountedObject.cpp index 5b25091632d..c18152938a9 100644 --- a/src/ripple/basics/impl/CountedObject.cpp +++ b/src/libxrpl/basics/CountedObject.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/ripple/basics/impl/FileUtilities.cpp b/src/libxrpl/basics/FileUtilities.cpp similarity index 98% rename from src/ripple/basics/impl/FileUtilities.cpp rename to src/libxrpl/basics/FileUtilities.cpp index be60a3e5c3d..e1331433553 100644 --- a/src/ripple/basics/impl/FileUtilities.cpp +++ b/src/libxrpl/basics/FileUtilities.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/basics/impl/IOUAmount.cpp b/src/libxrpl/basics/IOUAmount.cpp similarity index 99% rename from src/ripple/basics/impl/IOUAmount.cpp rename to src/libxrpl/basics/IOUAmount.cpp index e3c3411057b..a24e1b917f7 100644 --- a/src/ripple/basics/impl/IOUAmount.cpp +++ b/src/libxrpl/basics/IOUAmount.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/basics/impl/Log.cpp b/src/libxrpl/basics/Log.cpp similarity index 99% rename from src/ripple/basics/impl/Log.cpp rename to src/libxrpl/basics/Log.cpp index c023bc16485..3d5963cc266 100644 --- a/src/ripple/basics/impl/Log.cpp +++ b/src/libxrpl/basics/Log.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/ripple/basics/impl/Number.cpp b/src/libxrpl/basics/Number.cpp similarity index 99% rename from src/ripple/basics/impl/Number.cpp rename to src/libxrpl/basics/Number.cpp index 9b3247536f9..14260b653a2 100644 --- a/src/ripple/basics/impl/Number.cpp +++ b/src/libxrpl/basics/Number.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/basics/impl/ResolverAsio.cpp b/src/libxrpl/basics/ResolverAsio.cpp similarity index 98% rename from src/ripple/basics/impl/ResolverAsio.cpp rename to src/libxrpl/basics/ResolverAsio.cpp index f75a390304b..53530da9d8f 100644 --- a/src/ripple/basics/impl/ResolverAsio.cpp +++ b/src/libxrpl/basics/ResolverAsio.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/basics/impl/StringUtilities.cpp b/src/libxrpl/basics/StringUtilities.cpp similarity index 92% rename from src/ripple/basics/impl/StringUtilities.cpp rename to src/libxrpl/basics/StringUtilities.cpp index bebbe1ef80b..cd9bdfbd030 100644 --- a/src/ripple/basics/impl/StringUtilities.cpp +++ b/src/libxrpl/basics/StringUtilities.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -120,7 +120,7 @@ to_uint64(std::string const& s) } bool -isProperlyFormedTomlDomain(std::string const& domain) +isProperlyFormedTomlDomain(std::string_view domain) { // The domain must be between 4 and 128 characters long if (domain.size() < 4 || domain.size() > 128) @@ -143,7 +143,7 @@ isProperlyFormedTomlDomain(std::string const& domain) , boost::regex_constants::optimize); - return boost::regex_match(domain, re); + return boost::regex_match(domain.begin(), domain.end(), re); } } // namespace ripple diff --git a/src/ripple/basics/impl/UptimeClock.cpp b/src/libxrpl/basics/UptimeClock.cpp similarity index 98% rename from src/ripple/basics/impl/UptimeClock.cpp rename to src/libxrpl/basics/UptimeClock.cpp index 2dacaef46bf..4394d02f783 100644 --- a/src/ripple/basics/impl/UptimeClock.cpp +++ b/src/libxrpl/basics/UptimeClock.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/basics/impl/base64.cpp b/src/libxrpl/basics/base64.cpp similarity index 99% rename from src/ripple/basics/impl/base64.cpp rename to src/libxrpl/basics/base64.cpp index 39b615100e5..a8b4e352992 100644 --- a/src/ripple/basics/impl/base64.cpp +++ b/src/libxrpl/basics/base64.cpp @@ -54,7 +54,7 @@ */ -#include +#include #include #include @@ -242,7 +242,7 @@ base64_encode(std::uint8_t const* data, std::size_t len) } std::string -base64_decode(std::string const& data) +base64_decode(std::string_view data) { std::string dest; dest.resize(base64::decoded_size(data.size())); diff --git a/src/ripple/basics/impl/contract.cpp b/src/libxrpl/basics/contract.cpp similarity index 95% rename from src/ripple/basics/impl/contract.cpp rename to src/libxrpl/basics/contract.cpp index 3a50db38010..fbda83c7a63 100644 --- a/src/ripple/basics/impl/contract.cpp +++ b/src/libxrpl/basics/contract.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/impl/make_SSLContext.cpp b/src/libxrpl/basics/make_SSLContext.cpp similarity index 99% rename from src/ripple/basics/impl/make_SSLContext.cpp rename to src/libxrpl/basics/make_SSLContext.cpp index 7d72d9e08b4..4a9ea321d54 100644 --- a/src/ripple/basics/impl/make_SSLContext.cpp +++ b/src/libxrpl/basics/make_SSLContext.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/basics/impl/mulDiv.cpp b/src/libxrpl/basics/mulDiv.cpp similarity index 97% rename from src/ripple/basics/impl/mulDiv.cpp rename to src/libxrpl/basics/mulDiv.cpp index 6dd01c71fe7..7f9ffa45267 100644 --- a/src/ripple/basics/impl/mulDiv.cpp +++ b/src/libxrpl/basics/mulDiv.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/ripple/basics/impl/partitioned_unordered_map.cpp b/src/libxrpl/basics/partitioned_unordered_map.cpp similarity index 91% rename from src/ripple/basics/impl/partitioned_unordered_map.cpp rename to src/libxrpl/basics/partitioned_unordered_map.cpp index 3ced32eddff..a6d02cd2c6f 100644 --- a/src/ripple/basics/impl/partitioned_unordered_map.cpp +++ b/src/libxrpl/basics/partitioned_unordered_map.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/beast/clock/basic_seconds_clock.cpp b/src/libxrpl/beast/clock/basic_seconds_clock.cpp similarity index 98% rename from src/ripple/beast/clock/basic_seconds_clock.cpp rename to src/libxrpl/beast/clock/basic_seconds_clock.cpp index 7c55a3f8bc0..f5af8bd16ec 100644 --- a/src/ripple/beast/clock/basic_seconds_clock.cpp +++ b/src/libxrpl/beast/clock/basic_seconds_clock.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/ripple/beast/core/CurrentThreadName.cpp b/src/libxrpl/beast/core/CurrentThreadName.cpp similarity index 98% rename from src/ripple/beast/core/CurrentThreadName.cpp rename to src/libxrpl/beast/core/CurrentThreadName.cpp index 80d275a1fff..71b5d21fec3 100644 --- a/src/ripple/beast/core/CurrentThreadName.cpp +++ b/src/libxrpl/beast/core/CurrentThreadName.cpp @@ -21,7 +21,7 @@ */ //============================================================================== -#include +#include #include //------------------------------------------------------------------------------ diff --git a/src/ripple/beast/core/SemanticVersion.cpp b/src/libxrpl/beast/core/SemanticVersion.cpp similarity index 98% rename from src/ripple/beast/core/SemanticVersion.cpp rename to src/libxrpl/beast/core/SemanticVersion.cpp index 9d127a09513..b33ed2f48f4 100644 --- a/src/ripple/beast/core/SemanticVersion.cpp +++ b/src/libxrpl/beast/core/SemanticVersion.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/beast/insight/impl/Collector.cpp b/src/libxrpl/beast/insight/Collector.cpp similarity index 96% rename from src/ripple/beast/insight/impl/Collector.cpp rename to src/libxrpl/beast/insight/Collector.cpp index e0f0e6ec644..4fdf6de984d 100644 --- a/src/ripple/beast/insight/impl/Collector.cpp +++ b/src/libxrpl/beast/insight/Collector.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/impl/Groups.cpp b/src/libxrpl/beast/insight/Groups.cpp similarity index 96% rename from src/ripple/beast/insight/impl/Groups.cpp rename to src/libxrpl/beast/insight/Groups.cpp index 7877034b97a..fcf7e65787e 100644 --- a/src/ripple/beast/insight/impl/Groups.cpp +++ b/src/libxrpl/beast/insight/Groups.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/beast/insight/impl/Hook.cpp b/src/libxrpl/beast/insight/Hook.cpp similarity index 96% rename from src/ripple/beast/insight/impl/Hook.cpp rename to src/libxrpl/beast/insight/Hook.cpp index 53ae6475aad..62538846349 100644 --- a/src/ripple/beast/insight/impl/Hook.cpp +++ b/src/libxrpl/beast/insight/Hook.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/impl/Metric.cpp b/src/libxrpl/beast/insight/Metric.cpp similarity index 87% rename from src/ripple/beast/insight/impl/Metric.cpp rename to src/libxrpl/beast/insight/Metric.cpp index aa38e2f8166..64a4082fcec 100644 --- a/src/ripple/beast/insight/impl/Metric.cpp +++ b/src/libxrpl/beast/insight/Metric.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/impl/NullCollector.cpp b/src/libxrpl/beast/insight/NullCollector.cpp similarity index 98% rename from src/ripple/beast/insight/impl/NullCollector.cpp rename to src/libxrpl/beast/insight/NullCollector.cpp index b859de552a2..637cd06ec3b 100644 --- a/src/ripple/beast/insight/impl/NullCollector.cpp +++ b/src/libxrpl/beast/insight/NullCollector.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace beast { namespace insight { diff --git a/src/ripple/beast/insight/impl/StatsDCollector.cpp b/src/libxrpl/beast/insight/StatsDCollector.cpp similarity index 98% rename from src/ripple/beast/insight/impl/StatsDCollector.cpp rename to src/libxrpl/beast/insight/StatsDCollector.cpp index 6949a7f86e7..76ae15b82d5 100644 --- a/src/ripple/beast/insight/impl/StatsDCollector.cpp +++ b/src/libxrpl/beast/insight/StatsDCollector.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/beast/net/impl/IPAddressConversion.cpp b/src/libxrpl/beast/net/IPAddressConversion.cpp similarity index 97% rename from src/ripple/beast/net/impl/IPAddressConversion.cpp rename to src/libxrpl/beast/net/IPAddressConversion.cpp index 6353c50dfba..2ab84c37015 100644 --- a/src/ripple/beast/net/impl/IPAddressConversion.cpp +++ b/src/libxrpl/beast/net/IPAddressConversion.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace beast { namespace IP { diff --git a/src/ripple/beast/net/impl/IPAddressV4.cpp b/src/libxrpl/beast/net/IPAddressV4.cpp similarity index 97% rename from src/ripple/beast/net/impl/IPAddressV4.cpp rename to src/libxrpl/beast/net/IPAddressV4.cpp index 7e428c4228e..83541479878 100644 --- a/src/ripple/beast/net/impl/IPAddressV4.cpp +++ b/src/libxrpl/beast/net/IPAddressV4.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/ripple/beast/net/impl/IPAddressV6.cpp b/src/libxrpl/beast/net/IPAddressV6.cpp similarity index 94% rename from src/ripple/beast/net/impl/IPAddressV6.cpp rename to src/libxrpl/beast/net/IPAddressV6.cpp index 07dd2baaee5..f90a6d066b0 100644 --- a/src/ripple/beast/net/impl/IPAddressV6.cpp +++ b/src/libxrpl/beast/net/IPAddressV6.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace beast { namespace IP { diff --git a/src/ripple/beast/net/impl/IPEndpoint.cpp b/src/libxrpl/beast/net/IPEndpoint.cpp similarity index 99% rename from src/ripple/beast/net/impl/IPEndpoint.cpp rename to src/libxrpl/beast/net/IPEndpoint.cpp index 4ad71262c27..490777111bd 100644 --- a/src/ripple/beast/net/impl/IPEndpoint.cpp +++ b/src/libxrpl/beast/net/IPEndpoint.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace beast { diff --git a/src/ripple/beast/utility/src/beast_Journal.cpp b/src/libxrpl/beast/utility/src/beast_Journal.cpp similarity index 98% rename from src/ripple/beast/utility/src/beast_Journal.cpp rename to src/libxrpl/beast/utility/src/beast_Journal.cpp index 7c332bf6b52..261e1f6ccab 100644 --- a/src/ripple/beast/utility/src/beast_Journal.cpp +++ b/src/libxrpl/beast/utility/src/beast_Journal.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace beast { diff --git a/src/ripple/beast/utility/src/beast_PropertyStream.cpp b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp similarity index 99% rename from src/ripple/beast/utility/src/beast_PropertyStream.cpp rename to src/libxrpl/beast/utility/src/beast_PropertyStream.cpp index ecd707e9554..56e862ca8c0 100644 --- a/src/ripple/beast/utility/src/beast_PropertyStream.cpp +++ b/src/libxrpl/beast/utility/src/beast_PropertyStream.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/crypto/impl/RFC1751.cpp b/src/libxrpl/crypto/RFC1751.cpp similarity index 99% rename from src/ripple/crypto/impl/RFC1751.cpp rename to src/libxrpl/crypto/RFC1751.cpp index 6b6b2c31fb1..1c6f28287b0 100644 --- a/src/ripple/crypto/impl/RFC1751.cpp +++ b/src/libxrpl/crypto/RFC1751.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/crypto/impl/csprng.cpp b/src/libxrpl/crypto/csprng.cpp similarity index 97% rename from src/ripple/crypto/impl/csprng.cpp rename to src/libxrpl/crypto/csprng.cpp index 04b3b3fc385..480d561eacf 100644 --- a/src/ripple/crypto/impl/csprng.cpp +++ b/src/libxrpl/crypto/csprng.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/crypto/impl/secure_erase.cpp b/src/libxrpl/crypto/secure_erase.cpp similarity index 96% rename from src/ripple/crypto/impl/secure_erase.cpp rename to src/libxrpl/crypto/secure_erase.cpp index 8299ed7a6c9..93f189d519c 100644 --- a/src/ripple/crypto/impl/secure_erase.cpp +++ b/src/libxrpl/crypto/secure_erase.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace ripple { diff --git a/src/ripple/json/impl/JsonPropertyStream.cpp b/src/libxrpl/json/JsonPropertyStream.cpp similarity index 97% rename from src/ripple/json/impl/JsonPropertyStream.cpp rename to src/libxrpl/json/JsonPropertyStream.cpp index 3083deeeee2..19387013b58 100644 --- a/src/ripple/json/impl/JsonPropertyStream.cpp +++ b/src/libxrpl/json/JsonPropertyStream.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/json/impl/Object.cpp b/src/libxrpl/json/Object.cpp similarity index 98% rename from src/ripple/json/impl/Object.cpp rename to src/libxrpl/json/Object.cpp index a855fc31a2c..179b0e31ef2 100644 --- a/src/ripple/json/impl/Object.cpp +++ b/src/libxrpl/json/Object.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace Json { diff --git a/src/ripple/json/impl/Output.cpp b/src/libxrpl/json/Output.cpp similarity index 97% rename from src/ripple/json/impl/Output.cpp rename to src/libxrpl/json/Output.cpp index b32e9ad5a67..c24c75b32dd 100644 --- a/src/ripple/json/impl/Output.cpp +++ b/src/libxrpl/json/Output.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace Json { diff --git a/src/ripple/json/impl/Writer.cpp b/src/libxrpl/json/Writer.cpp similarity index 99% rename from src/ripple/json/impl/Writer.cpp rename to src/libxrpl/json/Writer.cpp index 44d106aa336..ba7336209e6 100644 --- a/src/ripple/json/impl/Writer.cpp +++ b/src/libxrpl/json/Writer.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/json/impl/json_reader.cpp b/src/libxrpl/json/json_reader.cpp similarity index 99% rename from src/ripple/json/impl/json_reader.cpp rename to src/libxrpl/json/json_reader.cpp index 001049bcdbc..42488b3ec87 100644 --- a/src/ripple/json/impl/json_reader.cpp +++ b/src/libxrpl/json/json_reader.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/ripple/json/impl/json_value.cpp b/src/libxrpl/json/json_value.cpp similarity index 99% rename from src/ripple/json/impl/json_value.cpp rename to src/libxrpl/json/json_value.cpp index 024ad2c88a0..155c3e1e044 100644 --- a/src/ripple/json/impl/json_value.cpp +++ b/src/libxrpl/json/json_value.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace Json { diff --git a/src/ripple/json/impl/json_valueiterator.cpp b/src/libxrpl/json/json_valueiterator.cpp similarity index 99% rename from src/ripple/json/impl/json_valueiterator.cpp rename to src/libxrpl/json/json_valueiterator.cpp index 355bfad23cd..c1a1bcc56a0 100644 --- a/src/ripple/json/impl/json_valueiterator.cpp +++ b/src/libxrpl/json/json_valueiterator.cpp @@ -19,7 +19,7 @@ // included by json_value.cpp -#include +#include namespace Json { diff --git a/src/ripple/json/impl/json_writer.cpp b/src/libxrpl/json/json_writer.cpp similarity index 99% rename from src/ripple/json/impl/json_writer.cpp rename to src/libxrpl/json/json_writer.cpp index 4d696ab55bc..5459042cddb 100644 --- a/src/ripple/json/impl/json_writer.cpp +++ b/src/libxrpl/json/json_writer.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/json/impl/to_string.cpp b/src/libxrpl/json/to_string.cpp similarity index 94% rename from src/ripple/json/impl/to_string.cpp rename to src/libxrpl/json/to_string.cpp index b965417721e..7bf58241201 100644 --- a/src/ripple/json/impl/to_string.cpp +++ b/src/libxrpl/json/to_string.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace Json { diff --git a/src/ripple/protocol/impl/AMMCore.cpp b/src/libxrpl/protocol/AMMCore.cpp similarity index 94% rename from src/ripple/protocol/impl/AMMCore.cpp rename to src/libxrpl/protocol/AMMCore.cpp index b774ee4ee3b..7ac27041e76 100644 --- a/src/ripple/protocol/impl/AMMCore.cpp +++ b/src/libxrpl/protocol/AMMCore.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/AccountID.cpp b/src/libxrpl/protocol/AccountID.cpp similarity index 96% rename from src/ripple/protocol/impl/AccountID.cpp rename to src/libxrpl/protocol/AccountID.cpp index c615807cf84..5f0fa631851 100644 --- a/src/ripple/protocol/impl/AccountID.cpp +++ b/src/libxrpl/protocol/AccountID.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/Book.cpp b/src/libxrpl/protocol/Book.cpp similarity index 97% rename from src/ripple/protocol/impl/Book.cpp rename to src/libxrpl/protocol/Book.cpp index 3ad22675d1b..c096dba2b4e 100644 --- a/src/ripple/protocol/impl/Book.cpp +++ b/src/libxrpl/protocol/Book.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/BuildInfo.cpp b/src/libxrpl/protocol/BuildInfo.cpp similarity index 95% rename from src/ripple/protocol/impl/BuildInfo.cpp rename to src/libxrpl/protocol/BuildInfo.cpp index 64718e8176d..b0a7bcc9ed7 100644 --- a/src/ripple/protocol/impl/BuildInfo.cpp +++ b/src/libxrpl/protocol/BuildInfo.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include @@ -33,7 +33,7 @@ namespace BuildInfo { // and follow the format described at http://semver.org/ //------------------------------------------------------------------------------ // clang-format off -char const* const versionString = "2.2.0-rc1" +char const* const versionString = "2.3.0-b1" // clang-format on #if defined(DEBUG) || defined(SANITIZER) diff --git a/src/ripple/protocol/impl/ErrorCodes.cpp b/src/libxrpl/protocol/ErrorCodes.cpp similarity index 99% rename from src/ripple/protocol/impl/ErrorCodes.cpp rename to src/libxrpl/protocol/ErrorCodes.cpp index 3af48891c78..28024fab093 100644 --- a/src/ripple/protocol/impl/ErrorCodes.cpp +++ b/src/libxrpl/protocol/ErrorCodes.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/Feature.cpp b/src/libxrpl/protocol/Feature.cpp similarity index 93% rename from src/ripple/protocol/impl/Feature.cpp rename to src/libxrpl/protocol/Feature.cpp index 8c8ff403e3f..8a978955086 100644 --- a/src/ripple/protocol/impl/Feature.cpp +++ b/src/libxrpl/protocol/Feature.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include +#include -#include -#include -#include +#include +#include +#include #include #include #include @@ -116,6 +116,7 @@ class FeatureCollections // name, index, and uint256 feature identifier boost::multi_index::multi_index_container features; + std::map all; std::map supported; std::size_t upVotes = 0; std::size_t downVotes = 0; @@ -179,6 +180,13 @@ class FeatureCollections std::string featureToName(uint256 const& f) const; + /** All amendments that are registered within the table. */ + std::map const& + allAmendments() const + { + return all; + } + /** Amendments that this server supports. Whether they are enabled depends on the Rules defined in the validated ledger */ @@ -251,6 +259,14 @@ FeatureCollections::registerFeature( features.emplace_back(name, f); + auto const getAmendmentSupport = [=]() { + if (vote == VoteBehavior::Obsolete) + return AmendmentSupport::Retired; + return support == Supported::yes ? AmendmentSupport::Supported + : AmendmentSupport::Unsupported; + }; + all.emplace(name, getAmendmentSupport()); + if (support == Supported::yes) { supported.emplace(name, vote); @@ -266,6 +282,9 @@ FeatureCollections::registerFeature( check( supported.size() <= features.size(), "More supported features than defined features"); + check( + features.size() == all.size(), + "The 'all' features list is populated incorrectly"); return f; } else @@ -313,6 +332,13 @@ static FeatureCollections featureCollections; } // namespace +/** All amendments libxrpl knows of. */ +std::map const& +allAmendments() +{ + return featureCollections.allAmendments(); +} + /** Amendments that this server supports. Whether they are enabled depends on the Rules defined in the validated ledger */ @@ -466,7 +492,11 @@ REGISTER_FEATURE(PriceOracle, Supported::yes, VoteBehavior::De REGISTER_FIX (fixEmptyDID, Supported::yes, VoteBehavior::DefaultNo); REGISTER_FIX (fixXChainRewardRounding, Supported::yes, VoteBehavior::DefaultNo); REGISTER_FIX (fixPreviousTxnID, Supported::yes, VoteBehavior::DefaultNo); -REGISTER_FIX (fixAMMRounding, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixAMMv1_1, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FEATURE(NFTokenMintOffer, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixReducedOffersV2, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixEnforceNFTokenTrustline, Supported::yes, VoteBehavior::DefaultNo); +REGISTER_FIX (fixInnerObjTemplate2, Supported::yes, VoteBehavior::DefaultNo); // The following amendments are obsolete, but must remain supported // because they could potentially get enabled. diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/libxrpl/protocol/Indexes.cpp similarity index 97% rename from src/ripple/protocol/impl/Indexes.cpp rename to src/libxrpl/protocol/Indexes.cpp index 0ee52aab297..30d97416cfa 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/libxrpl/protocol/Indexes.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/InnerObjectFormats.cpp b/src/libxrpl/protocol/InnerObjectFormats.cpp similarity index 97% rename from src/ripple/protocol/impl/InnerObjectFormats.cpp rename to src/libxrpl/protocol/InnerObjectFormats.cpp index edebc57477e..6d7b855d199 100644 --- a/src/ripple/protocol/impl/InnerObjectFormats.cpp +++ b/src/libxrpl/protocol/InnerObjectFormats.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/Issue.cpp b/src/libxrpl/protocol/Issue.cpp similarity index 94% rename from src/ripple/protocol/impl/Issue.cpp rename to src/libxrpl/protocol/Issue.cpp index 623ce24bb15..70d2c013d7b 100644 --- a/src/ripple/protocol/impl/Issue.cpp +++ b/src/libxrpl/protocol/Issue.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/Keylet.cpp b/src/libxrpl/protocol/Keylet.cpp similarity index 94% rename from src/ripple/protocol/impl/Keylet.cpp rename to src/libxrpl/protocol/Keylet.cpp index 2488e8b45b6..23847811d3b 100644 --- a/src/ripple/protocol/impl/Keylet.cpp +++ b/src/libxrpl/protocol/Keylet.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/LedgerFormats.cpp b/src/libxrpl/protocol/LedgerFormats.cpp similarity index 99% rename from src/ripple/protocol/impl/LedgerFormats.cpp rename to src/libxrpl/protocol/LedgerFormats.cpp index 4f117a5d60d..9401c00278b 100644 --- a/src/ripple/protocol/impl/LedgerFormats.cpp +++ b/src/libxrpl/protocol/LedgerFormats.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/impl/LedgerHeader.cpp b/src/libxrpl/protocol/LedgerHeader.cpp similarity index 98% rename from src/ripple/protocol/impl/LedgerHeader.cpp rename to src/libxrpl/protocol/LedgerHeader.cpp index 6d13db224fd..284c4dc0557 100644 --- a/src/ripple/protocol/impl/LedgerHeader.cpp +++ b/src/libxrpl/protocol/LedgerHeader.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/NFTSyntheticSerializer.cpp b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp similarity index 89% rename from src/ripple/protocol/impl/NFTSyntheticSerializer.cpp rename to src/libxrpl/protocol/NFTSyntheticSerializer.cpp index e34397ada6a..03c9e79e265 100644 --- a/src/ripple/protocol/impl/NFTSyntheticSerializer.cpp +++ b/src/libxrpl/protocol/NFTSyntheticSerializer.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/NFTokenID.cpp b/src/libxrpl/protocol/NFTokenID.cpp similarity index 99% rename from src/ripple/protocol/impl/NFTokenID.cpp rename to src/libxrpl/protocol/NFTokenID.cpp index ea6ab984c19..72fb8b87bbe 100644 --- a/src/ripple/protocol/impl/NFTokenID.cpp +++ b/src/libxrpl/protocol/NFTokenID.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/NFTokenOfferID.cpp b/src/libxrpl/protocol/NFTokenOfferID.cpp similarity index 92% rename from src/ripple/protocol/impl/NFTokenOfferID.cpp rename to src/libxrpl/protocol/NFTokenOfferID.cpp index c9c3118cf2a..3d761e6b939 100644 --- a/src/ripple/protocol/impl/NFTokenOfferID.cpp +++ b/src/libxrpl/protocol/NFTokenOfferID.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { @@ -31,7 +31,8 @@ canHaveNFTokenOfferID( return false; TxType const tt = serializedTx->getTxnType(); - if (tt != ttNFTOKEN_CREATE_OFFER) + if (!(tt == ttNFTOKEN_MINT && serializedTx->isFieldPresent(sfAmount)) && + tt != ttNFTOKEN_CREATE_OFFER) return false; // if the transaction failed nothing could have been delivered. diff --git a/src/ripple/protocol/impl/PublicKey.cpp b/src/libxrpl/protocol/PublicKey.cpp similarity index 97% rename from src/ripple/protocol/impl/PublicKey.cpp rename to src/libxrpl/protocol/PublicKey.cpp index 22cb351e61c..fdab288cea0 100644 --- a/src/ripple/protocol/impl/PublicKey.cpp +++ b/src/libxrpl/protocol/PublicKey.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/Quality.cpp b/src/libxrpl/protocol/Quality.cpp similarity index 87% rename from src/ripple/protocol/impl/Quality.cpp rename to src/libxrpl/protocol/Quality.cpp index f7b9d6b3c41..38b641328b0 100644 --- a/src/ripple/protocol/impl/Quality.cpp +++ b/src/libxrpl/protocol/Quality.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include @@ -64,13 +64,20 @@ Quality::operator--(int) return prev; } -Amounts -Quality::ceil_in(Amounts const& amount, STAmount const& limit) const +template +static Amounts +ceil_in_impl( + Amounts const& amount, + STAmount const& limit, + bool roundUp, + Quality const& quality) { if (amount.in > limit) { Amounts result( - limit, divRound(limit, rate(), amount.out.issue(), true)); + limit, + DivRoundFunc(limit, quality.rate(), amount.out.issue(), roundUp)); // Clamp out if (result.out > amount.out) result.out = amount.out; @@ -81,6 +88,21 @@ Quality::ceil_in(Amounts const& amount, STAmount const& limit) const return amount; } +Amounts +Quality::ceil_in(Amounts const& amount, STAmount const& limit) const +{ + return ceil_in_impl(amount, limit, /* roundUp */ true, *this); +} + +Amounts +Quality::ceil_in_strict( + Amounts const& amount, + STAmount const& limit, + bool roundUp) const +{ + return ceil_in_impl(amount, limit, roundUp, *this); +} + template static Amounts diff --git a/src/ripple/protocol/impl/QualityFunction.cpp b/src/libxrpl/protocol/QualityFunction.cpp similarity index 95% rename from src/ripple/protocol/impl/QualityFunction.cpp rename to src/libxrpl/protocol/QualityFunction.cpp index 29270928480..64e5a36989c 100644 --- a/src/ripple/protocol/impl/QualityFunction.cpp +++ b/src/libxrpl/protocol/QualityFunction.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include +#include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/RPCErr.cpp b/src/libxrpl/protocol/RPCErr.cpp similarity index 94% rename from src/ripple/protocol/impl/RPCErr.cpp rename to src/libxrpl/protocol/RPCErr.cpp index ec0474fe8b0..e9ca3c3c1e6 100644 --- a/src/ripple/protocol/impl/RPCErr.cpp +++ b/src/libxrpl/protocol/RPCErr.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/Rate2.cpp b/src/libxrpl/protocol/Rate2.cpp similarity index 97% rename from src/ripple/protocol/impl/Rate2.cpp rename to src/libxrpl/protocol/Rate2.cpp index 340b6719bca..d85a49a5958 100644 --- a/src/ripple/protocol/impl/Rate2.cpp +++ b/src/libxrpl/protocol/Rate2.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/Rules.cpp b/src/libxrpl/protocol/Rules.cpp similarity index 97% rename from src/ripple/protocol/impl/Rules.cpp rename to src/libxrpl/protocol/Rules.cpp index e65a9678f65..f47e966e138 100644 --- a/src/ripple/protocol/impl/Rules.cpp +++ b/src/libxrpl/protocol/Rules.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/protocol/impl/SField.cpp b/src/libxrpl/protocol/SField.cpp similarity index 99% rename from src/ripple/protocol/impl/SField.cpp rename to src/libxrpl/protocol/SField.cpp index 6d034db75ef..d56f3983352 100644 --- a/src/ripple/protocol/impl/SField.cpp +++ b/src/libxrpl/protocol/SField.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/SOTemplate.cpp b/src/libxrpl/protocol/SOTemplate.cpp similarity index 98% rename from src/ripple/protocol/impl/SOTemplate.cpp rename to src/libxrpl/protocol/SOTemplate.cpp index 8457b759126..d75261c0a64 100644 --- a/src/ripple/protocol/impl/SOTemplate.cpp +++ b/src/libxrpl/protocol/SOTemplate.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STAccount.cpp b/src/libxrpl/protocol/STAccount.cpp similarity index 98% rename from src/ripple/protocol/impl/STAccount.cpp rename to src/libxrpl/protocol/STAccount.cpp index 5881ae5b264..8ae43f76863 100644 --- a/src/ripple/protocol/impl/STAccount.cpp +++ b/src/libxrpl/protocol/STAccount.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include diff --git a/src/ripple/protocol/impl/STAmount.cpp b/src/libxrpl/protocol/STAmount.cpp similarity index 97% rename from src/ripple/protocol/impl/STAmount.cpp rename to src/libxrpl/protocol/STAmount.cpp index 201bcb6b681..236603d6cb8 100644 --- a/src/ripple/protocol/impl/STAmount.cpp +++ b/src/libxrpl/protocol/STAmount.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -1367,26 +1367,6 @@ canonicalizeRoundStrict( namespace { -// saveNumberRoundMode doesn't do quite enough for us. What we want is a -// Number::RoundModeGuard that sets the new mode and restores the old mode -// when it leaves scope. Since Number doesn't have that facility, we'll -// build it here. -class NumberRoundModeGuard -{ - saveNumberRoundMode saved_; - -public: - explicit NumberRoundModeGuard(Number::rounding_mode mode) noexcept - : saved_{Number::setround(mode)} - { - } - - NumberRoundModeGuard(NumberRoundModeGuard const&) = delete; - - NumberRoundModeGuard& - operator=(NumberRoundModeGuard const&) = delete; -}; - // We need a class that has an interface similar to NumberRoundModeGuard // but does nothing. class DontAffectNumberRoundMode diff --git a/src/ripple/protocol/impl/STArray.cpp b/src/libxrpl/protocol/STArray.cpp similarity index 96% rename from src/ripple/protocol/impl/STArray.cpp rename to src/libxrpl/protocol/STArray.cpp index 7ee3da1ff1a..0dea9c7665e 100644 --- a/src/ripple/protocol/impl/STArray.cpp +++ b/src/libxrpl/protocol/STArray.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STBase.cpp b/src/libxrpl/protocol/STBase.cpp similarity index 98% rename from src/ripple/protocol/impl/STBase.cpp rename to src/libxrpl/protocol/STBase.cpp index b49b65bf25d..b7e9c94ca24 100644 --- a/src/ripple/protocol/impl/STBase.cpp +++ b/src/libxrpl/protocol/STBase.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/STBlob.cpp b/src/libxrpl/protocol/STBlob.cpp similarity index 96% rename from src/ripple/protocol/impl/STBlob.cpp rename to src/libxrpl/protocol/STBlob.cpp index 871c535e9dd..63e7b4bf3da 100644 --- a/src/ripple/protocol/impl/STBlob.cpp +++ b/src/libxrpl/protocol/STBlob.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STCurrency.cpp b/src/libxrpl/protocol/STCurrency.cpp similarity index 96% rename from src/ripple/protocol/impl/STCurrency.cpp rename to src/libxrpl/protocol/STCurrency.cpp index d2bc1b3bea7..c8fc650135a 100644 --- a/src/ripple/protocol/impl/STCurrency.cpp +++ b/src/libxrpl/protocol/STCurrency.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include +#include +#include -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STInteger.cpp b/src/libxrpl/protocol/STInteger.cpp similarity index 93% rename from src/ripple/protocol/impl/STInteger.cpp rename to src/libxrpl/protocol/STInteger.cpp index 2b154e369e4..7b7420006f9 100644 --- a/src/ripple/protocol/impl/STInteger.cpp +++ b/src/libxrpl/protocol/STInteger.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/impl/STIssue.cpp b/src/libxrpl/protocol/STIssue.cpp similarity index 93% rename from src/ripple/protocol/impl/STIssue.cpp rename to src/libxrpl/protocol/STIssue.cpp index 356af438659..9dcee6498ab 100644 --- a/src/ripple/protocol/impl/STIssue.cpp +++ b/src/libxrpl/protocol/STIssue.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/STLedgerEntry.cpp b/src/libxrpl/protocol/STLedgerEntry.cpp similarity index 93% rename from src/ripple/protocol/impl/STLedgerEntry.cpp rename to src/libxrpl/protocol/STLedgerEntry.cpp index 10ec5627aa3..68d1455cb1d 100644 --- a/src/ripple/protocol/impl/STLedgerEntry.cpp +++ b/src/libxrpl/protocol/STLedgerEntry.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/STObject.cpp b/src/libxrpl/protocol/STObject.cpp similarity index 95% rename from src/ripple/protocol/impl/STObject.cpp rename to src/libxrpl/protocol/STObject.cpp index dbcb47e8794..bde83ec31a1 100644 --- a/src/ripple/protocol/impl/STObject.cpp +++ b/src/libxrpl/protocol/STObject.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { @@ -61,10 +61,19 @@ STObject::STObject(SerialIter& sit, SField const& name, int depth) noexcept( } STObject -STObject::makeInnerObject(SField const& name, Rules const& rules) +STObject::makeInnerObject(SField const& name) { STObject obj{name}; - if (rules.enabled(fixInnerObjTemplate)) + + // The if is complicated because inner object templates were added in + // two phases: + // 1. If there are no available Rules, then always apply the template. + // 2. fixInnerObjTemplate added templates to two AMM inner objects. + // 3. fixInnerObjTemplate2 added templates to all remaining inner objects. + std::optional const& rules = getCurrentTransactionRules(); + bool const isAMMObj = name == sfAuctionSlot || name == sfVoteEntry; + if (!rules || (rules->enabled(fixInnerObjTemplate) && isAMMObj) || + (rules->enabled(fixInnerObjTemplate2) && !isAMMObj)) { if (SOTemplate const* elements = InnerObjectFormats::getInstance().findSOTemplateBySField(name)) diff --git a/src/ripple/protocol/impl/STParsedJSON.cpp b/src/libxrpl/protocol/STParsedJSON.cpp similarity index 97% rename from src/ripple/protocol/impl/STParsedJSON.cpp rename to src/libxrpl/protocol/STParsedJSON.cpp index 6727fe7388c..dec5e87eaee 100644 --- a/src/ripple/protocol/impl/STParsedJSON.cpp +++ b/src/libxrpl/protocol/STParsedJSON.cpp @@ -17,29 +17,29 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/STPathSet.cpp b/src/libxrpl/protocol/STPathSet.cpp similarity index 96% rename from src/ripple/protocol/impl/STPathSet.cpp rename to src/libxrpl/protocol/STPathSet.cpp index cc1e367ba45..b658465272e 100644 --- a/src/ripple/protocol/impl/STPathSet.cpp +++ b/src/libxrpl/protocol/STPathSet.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STTx.cpp b/src/libxrpl/protocol/STTx.cpp similarity index 96% rename from src/ripple/protocol/impl/STTx.cpp rename to src/libxrpl/protocol/STTx.cpp index 51fb11ad761..149186d43ce 100644 --- a/src/ripple/protocol/impl/STTx.cpp +++ b/src/libxrpl/protocol/STTx.cpp @@ -17,22 +17,22 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/STValidation.cpp b/src/libxrpl/protocol/STValidation.cpp similarity index 95% rename from src/ripple/protocol/impl/STValidation.cpp rename to src/libxrpl/protocol/STValidation.cpp index e62a81733bd..ca5ceb0d9ce 100644 --- a/src/ripple/protocol/impl/STValidation.cpp +++ b/src/libxrpl/protocol/STValidation.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STVar.cpp b/src/libxrpl/protocol/STVar.cpp similarity index 90% rename from src/ripple/protocol/impl/STVar.cpp rename to src/libxrpl/protocol/STVar.cpp index adda165901f..c8466259f32 100644 --- a/src/ripple/protocol/impl/STVar.cpp +++ b/src/libxrpl/protocol/STVar.cpp @@ -17,23 +17,23 @@ */ //============================================================================== -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace detail { diff --git a/src/ripple/protocol/impl/STVector256.cpp b/src/libxrpl/protocol/STVector256.cpp similarity index 94% rename from src/ripple/protocol/impl/STVector256.cpp rename to src/libxrpl/protocol/STVector256.cpp index 0ef1295b16a..2d8bc4ee225 100644 --- a/src/ripple/protocol/impl/STVector256.cpp +++ b/src/libxrpl/protocol/STVector256.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/STXChainBridge.cpp b/src/libxrpl/protocol/STXChainBridge.cpp similarity index 93% rename from src/ripple/protocol/impl/STXChainBridge.cpp rename to src/libxrpl/protocol/STXChainBridge.cpp index 8ff19ca7e3b..2347e63379a 100644 --- a/src/ripple/protocol/impl/STXChainBridge.cpp +++ b/src/libxrpl/protocol/STXChainBridge.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/protocol/impl/SecretKey.cpp b/src/libxrpl/protocol/SecretKey.cpp similarity index 97% rename from src/ripple/protocol/impl/SecretKey.cpp rename to src/libxrpl/protocol/SecretKey.cpp index e83068610c9..474c37ac802 100644 --- a/src/ripple/protocol/impl/SecretKey.cpp +++ b/src/libxrpl/protocol/SecretKey.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/protocol/impl/Seed.cpp b/src/libxrpl/protocol/Seed.cpp similarity index 89% rename from src/ripple/protocol/impl/Seed.cpp rename to src/libxrpl/protocol/Seed.cpp index 49da20a429d..453b4593bfb 100644 --- a/src/ripple/protocol/impl/Seed.cpp +++ b/src/libxrpl/protocol/Seed.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/Serializer.cpp b/src/libxrpl/protocol/Serializer.cpp similarity index 98% rename from src/ripple/protocol/impl/Serializer.cpp rename to src/libxrpl/protocol/Serializer.cpp index 42f79cfc518..b99375f80dd 100644 --- a/src/ripple/protocol/impl/Serializer.cpp +++ b/src/libxrpl/protocol/Serializer.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/impl/Sign.cpp b/src/libxrpl/protocol/Sign.cpp similarity index 99% rename from src/ripple/protocol/impl/Sign.cpp rename to src/libxrpl/protocol/Sign.cpp index b6313827f91..32645c3762c 100644 --- a/src/ripple/protocol/impl/Sign.cpp +++ b/src/libxrpl/protocol/Sign.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/protocol/impl/TER.cpp b/src/libxrpl/protocol/TER.cpp similarity index 99% rename from src/ripple/protocol/impl/TER.cpp rename to src/libxrpl/protocol/TER.cpp index 93bc60a98ba..f452b05464e 100644 --- a/src/ripple/protocol/impl/TER.cpp +++ b/src/libxrpl/protocol/TER.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include diff --git a/src/ripple/protocol/impl/TxFormats.cpp b/src/libxrpl/protocol/TxFormats.cpp similarity index 98% rename from src/ripple/protocol/impl/TxFormats.cpp rename to src/libxrpl/protocol/TxFormats.cpp index d2bdd4f8aa7..71c333dc497 100644 --- a/src/ripple/protocol/impl/TxFormats.cpp +++ b/src/libxrpl/protocol/TxFormats.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include +#include -#include -#include -#include +#include +#include +#include namespace ripple { @@ -333,6 +333,9 @@ TxFormats::TxFormats() {sfTransferFee, soeOPTIONAL}, {sfIssuer, soeOPTIONAL}, {sfURI, soeOPTIONAL}, + {sfAmount, soeOPTIONAL}, + {sfDestination, soeOPTIONAL}, + {sfExpiration, soeOPTIONAL}, }, commonFields); diff --git a/src/ripple/protocol/impl/TxMeta.cpp b/src/libxrpl/protocol/TxMeta.cpp similarity index 97% rename from src/ripple/protocol/impl/TxMeta.cpp rename to src/libxrpl/protocol/TxMeta.cpp index 20fa61de2a8..253d00e8414 100644 --- a/src/ripple/protocol/impl/TxMeta.cpp +++ b/src/libxrpl/protocol/TxMeta.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/impl/UintTypes.cpp b/src/libxrpl/protocol/UintTypes.cpp similarity index 95% rename from src/ripple/protocol/impl/UintTypes.cpp rename to src/libxrpl/protocol/UintTypes.cpp index 821e81238b0..c57bcc153a3 100644 --- a/src/ripple/protocol/impl/UintTypes.cpp +++ b/src/libxrpl/protocol/UintTypes.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/protocol/impl/XChainAttestations.cpp b/src/libxrpl/protocol/XChainAttestations.cpp similarity index 95% rename from src/ripple/protocol/impl/XChainAttestations.cpp rename to src/libxrpl/protocol/XChainAttestations.cpp index 591b20ad5a0..82e73445693 100644 --- a/src/ripple/protocol/impl/XChainAttestations.cpp +++ b/src/libxrpl/protocol/XChainAttestations.cpp @@ -17,23 +17,23 @@ */ //============================================================================== -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -203,7 +203,8 @@ AttestationClaim::AttestationClaim(Json::Value const& v) STObject AttestationClaim::toSTObject() const { - STObject o{sfXChainClaimAttestationCollectionElement}; + STObject o = + STObject::makeInnerObject(sfXChainClaimAttestationCollectionElement); addHelper(o); o[sfXChainClaimID] = claimID; if (dst) @@ -345,7 +346,8 @@ AttestationCreateAccount::AttestationCreateAccount( STObject AttestationCreateAccount::toSTObject() const { - STObject o{sfXChainCreateAccountAttestationCollectionElement}; + STObject o = STObject::makeInnerObject( + sfXChainCreateAccountAttestationCollectionElement); addHelper(o); o[sfXChainAccountCreateCount] = createCount; @@ -497,7 +499,7 @@ XChainClaimAttestation::XChainClaimAttestation( STObject XChainClaimAttestation::toSTObject() const { - STObject o{sfXChainClaimProofSig}; + STObject o = STObject::makeInnerObject(sfXChainClaimProofSig); o[sfAttestationSignerAccount] = STAccount{sfAttestationSignerAccount, keyAccount}; o[sfPublicKey] = publicKey; @@ -609,7 +611,7 @@ XChainCreateAccountAttestation::XChainCreateAccountAttestation( STObject XChainCreateAccountAttestation::toSTObject() const { - STObject o{sfXChainCreateAccountProofSig}; + STObject o = STObject::makeInnerObject(sfXChainCreateAccountProofSig); o[sfAttestationSignerAccount] = STAccount{sfAttestationSignerAccount, keyAccount}; diff --git a/src/ripple/protocol/impl/digest.cpp b/src/libxrpl/protocol/digest.cpp similarity index 98% rename from src/ripple/protocol/impl/digest.cpp rename to src/libxrpl/protocol/digest.cpp index 444a71fb863..237e7aa49f0 100644 --- a/src/ripple/protocol/impl/digest.cpp +++ b/src/libxrpl/protocol/digest.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include #include #include diff --git a/src/ripple/protocol/impl/tokens.cpp b/src/libxrpl/protocol/tokens.cpp similarity index 99% rename from src/ripple/protocol/impl/tokens.cpp rename to src/libxrpl/protocol/tokens.cpp index 8445eec38ca..bec16945654 100644 --- a/src/ripple/protocol/impl/tokens.cpp +++ b/src/libxrpl/protocol/tokens.cpp @@ -25,11 +25,11 @@ * file COPYING or http://www.opensource.org/licenses/mit-license.php. */ -#include +#include -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/resource/impl/Charge.cpp b/src/libxrpl/resource/Charge.cpp similarity index 98% rename from src/ripple/resource/impl/Charge.cpp rename to src/libxrpl/resource/Charge.cpp index 21cf2af3ef6..deec6b34eb6 100644 --- a/src/ripple/resource/impl/Charge.cpp +++ b/src/libxrpl/resource/Charge.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace ripple { diff --git a/src/ripple/resource/impl/Consumer.cpp b/src/libxrpl/resource/Consumer.cpp similarity index 96% rename from src/ripple/resource/impl/Consumer.cpp rename to src/libxrpl/resource/Consumer.cpp index 34edbbfcc71..b8652546841 100644 --- a/src/ripple/resource/impl/Consumer.cpp +++ b/src/libxrpl/resource/Consumer.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/resource/impl/Fees.cpp b/src/libxrpl/resource/Fees.cpp similarity index 98% rename from src/ripple/resource/impl/Fees.cpp rename to src/libxrpl/resource/Fees.cpp index 0752e49ca48..13ae38bc6ad 100644 --- a/src/ripple/resource/impl/Fees.cpp +++ b/src/libxrpl/resource/Fees.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { namespace Resource { diff --git a/src/ripple/resource/impl/ResourceManager.cpp b/src/libxrpl/resource/ResourceManager.cpp similarity index 92% rename from src/ripple/resource/impl/ResourceManager.cpp rename to src/libxrpl/resource/ResourceManager.cpp index 1a7e74ec1f8..d73ca090024 100644 --- a/src/ripple/resource/impl/ResourceManager.cpp +++ b/src/libxrpl/resource/ResourceManager.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -77,14 +77,13 @@ class ManagerImp : public Manager newInboundEndpoint( beast::IP::Endpoint const& address, bool const proxy, - boost::string_view const& forwardedFor) override + std::string_view forwardedFor) override { if (!proxy) return newInboundEndpoint(address); boost::system::error_code ec; - auto const proxiedIp = - boost::asio::ip::make_address(forwardedFor.to_string(), ec); + auto const proxiedIp = boost::asio::ip::make_address(forwardedFor, ec); if (ec) { journal_.warn() diff --git a/src/ripple/server/impl/JSONRPCUtil.cpp b/src/libxrpl/server/JSONRPCUtil.cpp similarity index 95% rename from src/ripple/server/impl/JSONRPCUtil.cpp rename to src/libxrpl/server/JSONRPCUtil.cpp index 12d12829ca9..ce173b1e9eb 100644 --- a/src/ripple/server/impl/JSONRPCUtil.cpp +++ b/src/libxrpl/server/JSONRPCUtil.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/server/impl/Port.cpp b/src/libxrpl/server/Port.cpp similarity index 98% rename from src/ripple/server/impl/Port.cpp rename to src/libxrpl/server/Port.cpp index 1b869f6a5da..0554c8082a0 100644 --- a/src/ripple/server/impl/Port.cpp +++ b/src/libxrpl/server/Port.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/AMMHelpers.h b/src/ripple/app/misc/AMMHelpers.h deleted file mode 100644 index 7bdaf23d69f..00000000000 --- a/src/ripple/app/misc/AMMHelpers.h +++ /dev/null @@ -1,416 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2023 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED -#define RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -namespace ripple { - -/** Calculate LP Tokens given AMM pool reserves. - * @param asset1 AMM one side of the pool reserve - * @param asset2 AMM another side of the pool reserve - * @return LP Tokens as IOU - */ -STAmount -ammLPTokens( - STAmount const& asset1, - STAmount const& asset2, - Issue const& lptIssue); - -/** Calculate LP Tokens given asset's deposit amount. - * @param asset1Balance current AMM asset1 balance - * @param asset1Deposit requested asset1 deposit amount - * @param lptAMMBalance AMM LPT balance - * @param tfee trading fee in basis points - * @return tokens - */ -STAmount -lpTokensIn( - STAmount const& asset1Balance, - STAmount const& asset1Deposit, - STAmount const& lptAMMBalance, - std::uint16_t tfee); - -/** Calculate asset deposit given LP Tokens. - * @param asset1Balance current AMM asset1 balance - * @param lpTokens LP Tokens - * @param lptAMMBalance AMM LPT balance - * @param tfee trading fee in basis points - * @return - */ -STAmount -ammAssetIn( - STAmount const& asset1Balance, - STAmount const& lptAMMBalance, - STAmount const& lpTokens, - std::uint16_t tfee); - -/** Calculate LP Tokens given asset's withdraw amount. Return 0 - * if can't calculate. - * @param asset1Balance current AMM asset1 balance - * @param asset1Withdraw requested asset1 withdraw amount - * @param lptAMMBalance AMM LPT balance - * @param tfee trading fee in basis points - * @return tokens out amount - */ -STAmount -lpTokensOut( - STAmount const& asset1Balance, - STAmount const& asset1Withdraw, - STAmount const& lptAMMBalance, - std::uint16_t tfee); - -/** Calculate asset withdrawal by tokens - * @param assetBalance balance of the asset being withdrawn - * @param lptAMMBalance total AMM Tokens balance - * @param lpTokens LP Tokens balance - * @param tfee trading fee in basis points - * @return calculated asset amount - */ -STAmount -withdrawByTokens( - STAmount const& assetBalance, - STAmount const& lptAMMBalance, - STAmount const& lpTokens, - std::uint16_t tfee); - -/** Check if the relative distance between the qualities - * is within the requested distance. - * @param calcQuality calculated quality - * @param reqQuality requested quality - * @param dist requested relative distance - * @return true if within dist, false otherwise - */ -inline bool -withinRelativeDistance( - Quality const& calcQuality, - Quality const& reqQuality, - Number const& dist) -{ - if (calcQuality == reqQuality) - return true; - auto const [min, max] = std::minmax(calcQuality, reqQuality); - // Relative distance is (max - min)/max. Can't use basic operations - // on Quality. Have to use Quality::rate() instead, which - // is inverse of quality: (1/max.rate - 1/min.rate)/(1/max.rate) - return ((min.rate() - max.rate()) / min.rate()) < dist; -} - -/** Check if the relative distance between the amounts - * is within the requested distance. - * @param calc calculated amount - * @param req requested amount - * @param dist requested relative distance - * @return true if within dist, false otherwise - */ -// clang-format off -template - requires( - std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v) -bool -withinRelativeDistance(Amt const& calc, Amt const& req, Number const& dist) -{ - if (calc == req) - return true; - auto const [min, max] = std::minmax(calc, req); - return ((max - min) / max) < dist; -} -// clang-format on - -/** Finds takerPays (i) and takerGets (o) such that given pool composition - * poolGets(I) and poolPays(O): (O - o) / (I + i) = quality. - * Where takerGets is calculated as the swapAssetIn (see below). - * The above equation produces the quadratic equation: - * i^2*(1-fee) + i*I*(2-fee) + I^2 - I*O/quality, - * which is solved for i, and o is found with swapAssetIn(). - * @param pool AMM pool balances - * @param quality requested quality - * @param tfee trading fee in basis points - * @return seated in/out amounts if the quality can be changed - */ -template -std::optional> -changeSpotPriceQuality( - TAmounts const& pool, - Quality const& quality, - std::uint16_t tfee) -{ - auto const f = feeMult(tfee); // 1 - fee - auto const& a = f; - auto const b = pool.in * (1 + f); - Number const c = pool.in * pool.in - pool.in * pool.out * quality.rate(); - if (auto const res = b * b - 4 * a * c; res < 0) - return std::nullopt; - else if (auto const nTakerPaysPropose = (-b + root2(res)) / (2 * a); - nTakerPaysPropose > 0) - { - auto const nTakerPays = [&]() { - // The fee might make the AMM offer quality less than CLOB quality. - // Therefore, AMM offer has to satisfy this constraint: o / i >= q. - // Substituting o with swapAssetIn() gives: - // i <= O / q - I / (1 - fee). - auto const nTakerPaysConstraint = - pool.out * quality.rate() - pool.in / f; - if (nTakerPaysPropose > nTakerPaysConstraint) - return nTakerPaysConstraint; - return nTakerPaysPropose; - }(); - if (nTakerPays <= 0) - return std::nullopt; - auto const takerPays = toAmount( - getIssue(pool.in), nTakerPays, Number::rounding_mode::upward); - // should not fail - if (auto const amounts = - TAmounts{ - takerPays, swapAssetIn(pool, takerPays, tfee)}; - Quality{amounts} < quality && - !withinRelativeDistance(Quality{amounts}, quality, Number(1, -7))) - Throw("changeSpotPriceQuality failed"); - else - return amounts; - } - return std::nullopt; -} - -/** AMM pool invariant - the product (A * B) after swap in/out has to remain - * at least the same: (A + in) * (B - out) >= A * B - * XRP round-off may result in a smaller product after swap in/out. - * To address this: - * - if on swapIn the out is XRP then the amount is round-off - * downward, making the product slightly larger since out - * value is reduced. - * - if on swapOut the in is XRP then the amount is round-off - * upward, making the product slightly larger since in - * value is increased. - */ - -/** Swap assetIn into the pool and swap out a proportional amount - * of the other asset. Implements AMM Swap in. - * @see [XLS30d:AMM - * Swap](https://github.com/XRPLF/XRPL-Standards/discussions/78) - * @param pool current AMM pool balances - * @param assetIn amount to swap in - * @param tfee trading fee in basis points - * @return - */ -template -TOut -swapAssetIn( - TAmounts const& pool, - TIn const& assetIn, - std::uint16_t tfee) -{ - if (auto const& rules = getCurrentTransactionRules(); - rules && rules->enabled(fixAMMRounding)) - { - // set rounding to always favor the amm. Clip to zero. - // calculate: - // pool.out - - // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - // and explicitly set the rounding modes - // Favoring the amm means we should: - // minimize: - // pool.out - - // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - // maximize: - // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - // (pool.in * pool.out) - // minimize: - // (pool.in + assetIn * feeMult(tfee)), - // minimize: - // assetIn * feeMult(tfee) - // feeMult is: (1-fee), fee is tfee/100000 - // minimize: - // 1-fee - // maximize: - // fee - saveNumberRoundMode _{Number::getround()}; - - Number::setround(Number::upward); - auto const numerator = pool.in * pool.out; - auto const fee = getFee(tfee); - - Number::setround(Number::downward); - auto const denom = pool.in + assetIn * (1 - fee); - - if (denom.signum() <= 0) - return toAmount(getIssue(pool.out), 0); - - Number::setround(Number::upward); - auto const ratio = numerator / denom; - - Number::setround(Number::downward); - auto const swapOut = pool.out - ratio; - - if (swapOut.signum() < 0) - return toAmount(getIssue(pool.out), 0); - - return toAmount( - getIssue(pool.out), swapOut, Number::rounding_mode::downward); - } - else - { - return toAmount( - getIssue(pool.out), - pool.out - - (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), - Number::rounding_mode::downward); - } -} - -/** Swap assetOut out of the pool and swap in a proportional amount - * of the other asset. Implements AMM Swap out. - * @see [XLS30d:AMM - * Swap](https://github.com/XRPLF/XRPL-Standards/discussions/78) - * @param pool current AMM pool balances - * @param assetOut amount to swap out - * @param tfee trading fee in basis points - * @return - */ -template -TIn -swapAssetOut( - TAmounts const& pool, - TOut const& assetOut, - std::uint16_t tfee) -{ - if (auto const& rules = getCurrentTransactionRules(); - rules && rules->enabled(fixAMMRounding)) - { - // set rounding to always favor the amm. Clip to zero. - // calculate: - // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / - // (1-tfee/100000) - // maximize: - // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) - // maximize: - // (pool.in * pool.out) / (pool.out - assetOut) - // maximize: - // (pool.in * pool.out) - // minimize - // (pool.out - assetOut) - // minimize: - // (1-tfee/100000) - // maximize: - // tfee/100000 - - saveNumberRoundMode _{Number::getround()}; - - Number::setround(Number::upward); - auto const numerator = pool.in * pool.out; - - Number::setround(Number::downward); - auto const denom = pool.out - assetOut; - if (denom.signum() <= 0) - { - return toMaxAmount(getIssue(pool.in)); - } - - Number::setround(Number::upward); - auto const ratio = numerator / denom; - auto const numerator2 = ratio - pool.in; - auto const fee = getFee(tfee); - - Number::setround(Number::downward); - auto const feeMult = 1 - fee; - - Number::setround(Number::upward); - auto const swapIn = numerator2 / feeMult; - if (swapIn.signum() < 0) - return toAmount(getIssue(pool.in), 0); - - return toAmount( - getIssue(pool.in), swapIn, Number::rounding_mode::upward); - } - else - { - return toAmount( - getIssue(pool.in), - ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / - feeMult(tfee), - Number::rounding_mode::upward); - } -} - -/** Return square of n. - */ -Number -square(Number const& n); - -/** Adjust LP tokens to deposit/withdraw. - * Amount type keeps 16 digits. Maintaining the LP balance by adding - * deposited tokens or subtracting withdrawn LP tokens from LP balance - * results in losing precision in LP balance. I.e. the resulting LP balance - * is less than the actual sum of LP tokens. To adjust for this, subtract - * old tokens balance from the new one for deposit or vice versa for - * withdraw to cancel out the precision loss. - * @param lptAMMBalance LPT AMM Balance - * @param lpTokens LP tokens to deposit or withdraw - * @param isDeposit true if deposit, false if withdraw - */ -STAmount -adjustLPTokens( - STAmount const& lptAMMBalance, - STAmount const& lpTokens, - bool isDeposit); - -/** Calls adjustLPTokens() and adjusts deposit or withdraw amounts if - * the adjusted LP tokens are less than the provided LP tokens. - * @param amountBalance asset1 pool balance - * @param amount asset1 to deposit or withdraw - * @param amount2 asset2 to deposit or withdraw - * @param lptAMMBalance LPT AMM Balance - * @param lpTokens LP tokens to deposit or withdraw - * @param tfee trading fee in basis points - * @param isDeposit true if deposit, false if withdraw - * @return - */ -std::tuple, STAmount> -adjustAmountsByLPTokens( - STAmount const& amountBalance, - STAmount const& amount, - std::optional const& amount2, - STAmount const& lptAMMBalance, - STAmount const& lpTokens, - std::uint16_t tfee, - bool isDeposit); - -/** Positive solution for quadratic equation: - * x = (-b + sqrt(b**2 + 4*a*c))/(2*a) - */ -Number -solveQuadraticEq(Number const& a, Number const& b, Number const& c); - -} // namespace ripple - -#endif // RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED diff --git a/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp b/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp deleted file mode 100644 index 22eca2dffdd..00000000000 --- a/src/ripple/app/tx/impl/NFTokenCreateOffer.cpp +++ /dev/null @@ -1,287 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2021 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#include -#include -#include -#include -#include -#include -#include - -namespace ripple { - -NotTEC -NFTokenCreateOffer::preflight(PreflightContext const& ctx) -{ - if (!ctx.rules.enabled(featureNonFungibleTokensV1)) - return temDISABLED; - - if (auto const ret = preflight1(ctx); !isTesSuccess(ret)) - return ret; - - auto const txFlags = ctx.tx.getFlags(); - bool const isSellOffer = txFlags & tfSellNFToken; - - if (txFlags & tfNFTokenCreateOfferMask) - return temINVALID_FLAG; - - auto const account = ctx.tx[sfAccount]; - auto const nftFlags = nft::getFlags(ctx.tx[sfNFTokenID]); - - { - STAmount const amount = ctx.tx[sfAmount]; - - if (amount.negative() && ctx.rules.enabled(fixNFTokenNegOffer)) - // An offer for a negative amount makes no sense. - return temBAD_AMOUNT; - - if (!isXRP(amount)) - { - if (nftFlags & nft::flagOnlyXRP) - return temBAD_AMOUNT; - - if (!amount) - return temBAD_AMOUNT; - } - - // If this is an offer to buy, you must offer something; if it's an - // offer to sell, you can ask for nothing. - if (!isSellOffer && !amount) - return temBAD_AMOUNT; - } - - if (auto exp = ctx.tx[~sfExpiration]; exp == 0) - return temBAD_EXPIRATION; - - auto const owner = ctx.tx[~sfOwner]; - - // The 'Owner' field must be present when offering to buy, but can't - // be present when selling (it's implicit): - if (owner.has_value() == isSellOffer) - return temMALFORMED; - - if (owner && owner == account) - return temMALFORMED; - - if (auto dest = ctx.tx[~sfDestination]) - { - // Some folks think it makes sense for a buy offer to specify a - // specific broker using the Destination field. This change doesn't - // deserve it's own amendment, so we're piggy-backing on - // fixNFTokenNegOffer. - // - // Prior to fixNFTokenNegOffer any use of the Destination field on - // a buy offer was malformed. - if (!isSellOffer && !ctx.rules.enabled(fixNFTokenNegOffer)) - return temMALFORMED; - - // The destination can't be the account executing the transaction. - if (dest == account) - return temMALFORMED; - } - - return preflight2(ctx); -} - -TER -NFTokenCreateOffer::preclaim(PreclaimContext const& ctx) -{ - if (hasExpired(ctx.view, ctx.tx[~sfExpiration])) - return tecEXPIRED; - - auto const nftokenID = ctx.tx[sfNFTokenID]; - bool const isSellOffer = ctx.tx.isFlag(tfSellNFToken); - - if (!nft::findToken( - ctx.view, ctx.tx[isSellOffer ? sfAccount : sfOwner], nftokenID)) - return tecNO_ENTRY; - - auto const nftFlags = nft::getFlags(nftokenID); - auto const issuer = nft::getIssuer(nftokenID); - auto const amount = ctx.tx[sfAmount]; - - if (!(nftFlags & nft::flagCreateTrustLines) && !amount.native() && - nft::getTransferFee(nftokenID)) - { - if (!ctx.view.exists(keylet::account(issuer))) - return tecNO_ISSUER; - - if (!ctx.view.exists(keylet::line(issuer, amount.issue()))) - return tecNO_LINE; - - if (isFrozen( - ctx.view, issuer, amount.getCurrency(), amount.getIssuer())) - return tecFROZEN; - } - - if (issuer != ctx.tx[sfAccount] && !(nftFlags & nft::flagTransferable)) - { - auto const root = ctx.view.read(keylet::account(issuer)); - assert(root); - - if (auto minter = (*root)[~sfNFTokenMinter]; - minter != ctx.tx[sfAccount]) - return tefNFTOKEN_IS_NOT_TRANSFERABLE; - } - - if (isFrozen( - ctx.view, - ctx.tx[sfAccount], - amount.getCurrency(), - amount.getIssuer())) - return tecFROZEN; - - // If this is an offer to buy the token, the account must have the - // needed funds at hand; but note that funds aren't reserved and the - // offer may later become unfunded. - if (!isSellOffer) - { - // After this amendment, we allow an IOU issuer to make a buy offer - // using their own currency. - if (ctx.view.rules().enabled(fixNonFungibleTokensV1_2)) - { - if (accountFunds( - ctx.view, - ctx.tx[sfAccount], - amount, - FreezeHandling::fhZERO_IF_FROZEN, - ctx.j) - .signum() <= 0) - return tecUNFUNDED_OFFER; - } - else if ( - accountHolds( - ctx.view, - ctx.tx[sfAccount], - amount.getCurrency(), - amount.getIssuer(), - FreezeHandling::fhZERO_IF_FROZEN, - ctx.j) - .signum() <= 0) - return tecUNFUNDED_OFFER; - } - - if (auto const destination = ctx.tx[~sfDestination]) - { - // If a destination is specified, the destination must already be in - // the ledger. - auto const sleDst = ctx.view.read(keylet::account(*destination)); - - if (!sleDst) - return tecNO_DST; - - // check if the destination has disallowed incoming offers - if (ctx.view.rules().enabled(featureDisallowIncoming)) - { - // flag cannot be set unless amendment is enabled but - // out of an abundance of caution check anyway - - if (sleDst->getFlags() & lsfDisallowIncomingNFTokenOffer) - return tecNO_PERMISSION; - } - } - - if (auto const owner = ctx.tx[~sfOwner]) - { - // Check if the owner (buy offer) has disallowed incoming offers - if (ctx.view.rules().enabled(featureDisallowIncoming)) - { - auto const sleOwner = ctx.view.read(keylet::account(*owner)); - - // defensively check - // it should not be possible to specify owner that doesn't exist - if (!sleOwner) - return tecNO_TARGET; - - if (sleOwner->getFlags() & lsfDisallowIncomingNFTokenOffer) - return tecNO_PERMISSION; - } - } - - return tesSUCCESS; -} - -TER -NFTokenCreateOffer::doApply() -{ - if (auto const acct = view().read(keylet::account(ctx_.tx[sfAccount])); - mPriorBalance < view().fees().accountReserve((*acct)[sfOwnerCount] + 1)) - return tecINSUFFICIENT_RESERVE; - - auto const nftokenID = ctx_.tx[sfNFTokenID]; - - auto const offerID = - keylet::nftoffer(account_, ctx_.tx.getSeqProxy().value()); - - // Create the offer: - { - // Token offers are always added to the owner's owner directory: - auto const ownerNode = view().dirInsert( - keylet::ownerDir(account_), offerID, describeOwnerDir(account_)); - - if (!ownerNode) - return tecDIR_FULL; - - bool const isSellOffer = ctx_.tx.isFlag(tfSellNFToken); - - // Token offers are also added to the token's buy or sell offer - // directory - auto const offerNode = view().dirInsert( - isSellOffer ? keylet::nft_sells(nftokenID) - : keylet::nft_buys(nftokenID), - offerID, - [&nftokenID, isSellOffer](std::shared_ptr const& sle) { - (*sle)[sfFlags] = - isSellOffer ? lsfNFTokenSellOffers : lsfNFTokenBuyOffers; - (*sle)[sfNFTokenID] = nftokenID; - }); - - if (!offerNode) - return tecDIR_FULL; - - std::uint32_t sleFlags = 0; - - if (isSellOffer) - sleFlags |= lsfSellNFToken; - - auto offer = std::make_shared(offerID); - (*offer)[sfOwner] = account_; - (*offer)[sfNFTokenID] = nftokenID; - (*offer)[sfAmount] = ctx_.tx[sfAmount]; - (*offer)[sfFlags] = sleFlags; - (*offer)[sfOwnerNode] = *ownerNode; - (*offer)[sfNFTokenOfferNode] = *offerNode; - - if (auto const expiration = ctx_.tx[~sfExpiration]) - (*offer)[sfExpiration] = *expiration; - - if (auto const destination = ctx_.tx[~sfDestination]) - (*offer)[sfDestination] = *destination; - - view().insert(offer); - } - - // Update owner count. - adjustOwnerCount(view(), view().peek(keylet::account(account_)), 1, j_); - - return tesSUCCESS; -} - -} // namespace ripple diff --git a/src/test/app/AMMCalc_test.cpp b/src/test/app/AMMCalc_test.cpp index cdb57c3b4c0..058cdfd1d2d 100644 --- a/src/test/app/AMMCalc_test.cpp +++ b/src/test/app/AMMCalc_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include @@ -413,13 +413,18 @@ class AMMCalc_test : public beast::unit_test::suite // 10 is AMM trading fee else if (*p == "changespq") { + Env env(*this); if (auto const pool = getAmounts(++p)) { if (auto const offer = getAmounts(p)) { auto const fee = getFee(p); if (auto const ammOffer = changeSpotPriceQuality( - pool->first, Quality{offer->first}, fee); + pool->first, + Quality{offer->first}, + fee, + env.current()->rules(), + beast::Journal(beast::Journal::getNullSink())); ammOffer) std::cout << "amm offer: " << toString(ammOffer->in) diff --git a/src/test/app/AMMExtended_test.cpp b/src/test/app/AMMExtended_test.cpp index 8dd915c8d91..96053b93b44 100644 --- a/src/test/app/AMMExtended_test.cpp +++ b/src/test/app/AMMExtended_test.cpp @@ -16,25 +16,25 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -94,7 +94,7 @@ struct AMMExtended_test : public jtx::AMMTest sendmax(BTC(1'000)), txflags(tfPartialPayment)); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammCarol.expectBalances( STAmount{BTC, UINT64_C(1'001'000000374812), -12}, @@ -233,7 +233,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'100), USD(10'000)}}, 0, std::nullopt, - tweakedFeatures); + {tweakedFeatures}); // Immediate or Cancel - cross as much as possible // and add nothing on the books. @@ -257,7 +257,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'100), USD(10'000)}}, 0, std::nullopt, - tweakedFeatures); + {tweakedFeatures}); // tfPassive -- place the offer without crossing it. testAMM( @@ -274,7 +274,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'100), USD(10'000)}}, 0, std::nullopt, - tweakedFeatures); + {tweakedFeatures}); // tfPassive -- cross only offers of better quality. testAMM( @@ -296,7 +296,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(11'000), USD(9'000)}}, 0, std::nullopt, - tweakedFeatures); + {tweakedFeatures}); } } @@ -430,7 +430,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'000), USD(10'000)}}, 0, std::nullopt, - features); + {features}); } void @@ -453,7 +453,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'000), USD(10'100)}}, 0, std::nullopt, - features); + {features}); } void @@ -477,7 +477,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'100), USD(10'000)}}, 0, std::nullopt, - features); + {features}); } void @@ -643,7 +643,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(9'900), USD(10'100)}}, 0, std::nullopt, - features); + {features}); } void @@ -720,7 +720,7 @@ struct AMMExtended_test : public jtx::AMMTest auto const jrr = env.rpc("json", "submit", to_string(payment)); BEAST_EXPECT(jrr[jss::result][jss::status] == "success"); BEAST_EXPECT(jrr[jss::result][jss::engine_result] == "tesSUCCESS"); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( STAmount(XTS, UINT64_C(101'010101010101), -12), @@ -952,7 +952,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'000), USD(10'100)}}, 0, std::nullopt, - features); + {features}); // Reverse the order, so the offer in the books is to sell XRP // in return for USD. @@ -973,7 +973,7 @@ struct AMMExtended_test : public jtx::AMMTest {{XRP(10'100), USD(10'000)}}, 0, std::nullopt, - features); + {features}); { // Bridged crossing. @@ -1291,17 +1291,34 @@ struct AMMExtended_test : public jtx::AMMTest env(offer(cam, B_BUX(30), A_BUX(30))); // AMM is consumed up to the first cam Offer quality - BEAST_EXPECT(ammCarol.expectBalances( - STAmount{A_BUX, UINT64_C(309'3541659651605), -13}, - STAmount{B_BUX, UINT64_C(320'0215509984417), -13}, - ammCarol.tokens())); - BEAST_EXPECT(expectOffers( - env, - cam, - 1, - {{Amounts{ - STAmount{B_BUX, UINT64_C(20'0215509984417), -13}, - STAmount{A_BUX, UINT64_C(20'0215509984417), -13}}}})); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT(ammCarol.expectBalances( + STAmount{A_BUX, UINT64_C(309'3541659651605), -13}, + STAmount{B_BUX, UINT64_C(320'0215509984417), -13}, + ammCarol.tokens())); + BEAST_EXPECT(expectOffers( + env, + cam, + 1, + {{Amounts{ + STAmount{B_BUX, UINT64_C(20'0215509984417), -13}, + STAmount{A_BUX, UINT64_C(20'0215509984417), -13}}}})); + } + else + { + BEAST_EXPECT(ammCarol.expectBalances( + STAmount{A_BUX, UINT64_C(309'3541659651604), -13}, + STAmount{B_BUX, UINT64_C(320'0215509984419), -13}, + ammCarol.tokens())); + BEAST_EXPECT(expectOffers( + env, + cam, + 1, + {{Amounts{ + STAmount{B_BUX, UINT64_C(20'0215509984419), -13}, + STAmount{A_BUX, UINT64_C(20'0215509984419), -13}}}})); + } } void @@ -1427,7 +1444,7 @@ struct AMMExtended_test : public jtx::AMMTest using namespace jtx; FeatureBitset const all{supported_amendments()}; testRmFundedOffer(all); - testRmFundedOffer(all - fixAMMRounding); + testRmFundedOffer(all - fixAMMv1_1); testEnforceNoRipple(all); testFillModes(all); testOfferCrossWithXRP(all); @@ -1441,28 +1458,17 @@ struct AMMExtended_test : public jtx::AMMTest testOfferCreateThenCross(all); testSellFlagExceedLimit(all); testGatewayCrossCurrency(all); - testGatewayCrossCurrency(all - fixAMMRounding); - // testPartialCross - // testXRPDirectCross - // testDirectCross + testGatewayCrossCurrency(all - fixAMMv1_1); testBridgedCross(all); - // testSellOffer testSellWithFillOrKill(all); testTransferRateOffer(all); testSelfIssueOffer(all); testBadPathAssert(all); testSellFlagBasic(all); testDirectToDirectPath(all); - // testSelfCrossLowQualityOffer - // testOfferInScaling - // testOfferInScalingWithXferRate - // testOfferThresholdWithReducedFunds - // testTinyOffer - // testSelfPayXferFeeOffer - // testSelfPayXferFeeOffer + testDirectToDirectPath(all - fixAMMv1_1); testRequireAuth(all); testMissingAuth(all); - // testRCSmoketest } void @@ -2317,7 +2323,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 77.2727USD with 75.5555GBP and pays 25% tr fee // on 75.5555GBP @@ -2364,7 +2370,7 @@ struct AMMExtended_test : public jtx::AMMTest env(offer(alice, EUR(100), USD(100))); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // 95.2380USD is swapped in for 100EUR BEAST_EXPECT(amm.expectBalances( @@ -2417,7 +2423,7 @@ struct AMMExtended_test : public jtx::AMMTest env(pay(gw, dan, USD(1'000))); AMM ammDan(env, dan, USD(1'000), EUR(1'050)); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice -> bob -> gw -> carol. $50 should have transfer fee; // $10, no fee @@ -2486,7 +2492,7 @@ struct AMMExtended_test : public jtx::AMMTest // alice buys 107.1428USD with 120GBP and pays 25% tr fee on 120GBP // 1,000 - 120*1.25 = 850GBP BEAST_EXPECT(expectLine(env, alice, GBP(850))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // 120GBP is swapped in for 107.1428USD BEAST_EXPECT(amm.expectBalances( @@ -2575,7 +2581,7 @@ struct AMMExtended_test : public jtx::AMMTest env.close(); BEAST_EXPECT(expectLine(env, alice, GBP(850))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 107.1428EUR with 120GBP and pays 25% tr fee on // 120GBP 1,000 - 120*1.25 = 850GBP 120GBP is swapped in for @@ -2692,7 +2698,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 28.125USD with 24GBP and pays 25% tr fee // on 24GBP @@ -2749,7 +2755,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 70.4210EUR with 70.4210GBP via the offer // and pays 25% tr fee on 70.4210GBP @@ -2841,7 +2847,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 53.3322EUR with 56.3368GBP via the amm // and pays 25% tr fee on 56.3368GBP @@ -2919,7 +2925,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // alice buys 53.3322EUR with 107.5308GBP // 25% on 86.0246GBP is paid in tr fee @@ -2990,7 +2996,7 @@ struct AMMExtended_test : public jtx::AMMTest txflags(tfNoRippleDirect | tfPartialPayment | tfLimitQuality)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // 108.1481GBP is swapped in for 97.5935EUR BEAST_EXPECT(amm1.expectBalances( @@ -3163,8 +3169,12 @@ struct AMMExtended_test : public jtx::AMMTest // Alice offers to buy 1000 XRP for 1000 USD. She takes Bob's first // offer, removes 999 more as unfunded, then hits the step limit. env(offer(alice, USD(1'000), XRP(1'000))); - env.require( - balance(alice, STAmount{USD, UINT64_C(2'050126257867561), -15})); + if (!features[fixAMMv1_1]) + env.require(balance( + alice, STAmount{USD, UINT64_C(2'050126257867561), -15})); + else + env.require(balance( + alice, STAmount{USD, UINT64_C(2'050125257867587), -15})); env.require(owners(alice, 2)); env.require(balance(bob, USD(0))); env.require(owners(bob, 1'001)); @@ -3270,7 +3280,7 @@ struct AMMExtended_test : public jtx::AMMTest env(offer(bob, XRP(100), USD(100))); env(offer(bob, XRP(1'000), USD(100))); AMM ammDan(env, dan, XRP(1'000), USD(1'100)); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { env(pay(alice, carol, USD(10'000)), paths(XRP), @@ -4080,9 +4090,9 @@ struct AMMExtended_test : public jtx::AMMTest testBookStep(all); testBookStep(all | ownerPaysFee); testTransferRate(all | ownerPaysFee); - testTransferRate((all - fixAMMRounding) | ownerPaysFee); + testTransferRate((all - fixAMMv1_1) | ownerPaysFee); testTransferRateNoOwnerFee(all); - testTransferRateNoOwnerFee(all - fixAMMRounding); + testTransferRateNoOwnerFee(all - fixAMMv1_1); testLimitQuality(); testXRPPathLoop(); } @@ -4093,6 +4103,7 @@ struct AMMExtended_test : public jtx::AMMTest using namespace jtx; FeatureBitset const all{supported_amendments()}; testStepLimit(all); + testStepLimit(all - fixAMMv1_1); } void @@ -4101,7 +4112,7 @@ struct AMMExtended_test : public jtx::AMMTest using namespace jtx; FeatureBitset const all{supported_amendments()}; test_convert_all_of_an_asset(all); - test_convert_all_of_an_asset(all - fixAMMRounding); + test_convert_all_of_an_asset(all - fixAMMv1_1); } void diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index ecf68c9ae62..ceddc019504 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -16,27 +16,30 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include + namespace ripple { namespace test { @@ -2213,33 +2216,64 @@ struct AMM_test : public jtx::AMMTest IOUAmount{10'000'000, 0})); }); + auto const all = supported_amendments(); // Withdraw with EPrice limit. - testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdraw(carol, USD(100), std::nullopt, IOUAmount{520, 0}); - BEAST_EXPECT( - ammAlice.expectBalances( - XRPAmount(11'000'000'000), - STAmount{USD, UINT64_C(9'372'781065088757), -12}, - IOUAmount{10'153'846'15384616, -8}) && - ammAlice.expectLPTokens( - carol, IOUAmount{153'846'15384616, -8})); - ammAlice.withdrawAll(carol); - BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); + ammAlice.withdraw( + carol, USD(100), std::nullopt, IOUAmount{520, 0}); + if (!env.current()->rules().enabled(fixAMMv1_1)) + BEAST_EXPECT( + ammAlice.expectBalances( + XRPAmount(11'000'000'000), + STAmount{USD, UINT64_C(9'372'781065088757), -12}, + IOUAmount{10'153'846'15384616, -8}) && + ammAlice.expectLPTokens( + carol, IOUAmount{153'846'15384616, -8})); + else + BEAST_EXPECT( + ammAlice.expectBalances( + XRPAmount(11'000'000'000), + STAmount{USD, UINT64_C(9'372'781065088769), -12}, + IOUAmount{10'153'846'15384616, -8}) && + ammAlice.expectLPTokens( + carol, IOUAmount{153'846'15384616, -8})); + ammAlice.withdrawAll(carol); + BEAST_EXPECT(ammAlice.expectLPTokens(carol, IOUAmount{0})); + }, + std::nullopt, + 0, + std::nullopt, + {all, all - fixAMMv1_1}); // Withdraw with EPrice limit. AssetOut is 0. - testAMM([&](AMM& ammAlice, Env&) { - ammAlice.deposit(carol, 1'000'000); - ammAlice.withdraw(carol, USD(0), std::nullopt, IOUAmount{520, 0}); - BEAST_EXPECT( - ammAlice.expectBalances( - XRPAmount(11'000'000'000), - STAmount{USD, UINT64_C(9'372'781065088757), -12}, - IOUAmount{10'153'846'15384616, -8}) && - ammAlice.expectLPTokens( - carol, IOUAmount{153'846'15384616, -8})); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + ammAlice.deposit(carol, 1'000'000); + ammAlice.withdraw( + carol, USD(0), std::nullopt, IOUAmount{520, 0}); + if (!env.current()->rules().enabled(fixAMMv1_1)) + BEAST_EXPECT( + ammAlice.expectBalances( + XRPAmount(11'000'000'000), + STAmount{USD, UINT64_C(9'372'781065088757), -12}, + IOUAmount{10'153'846'15384616, -8}) && + ammAlice.expectLPTokens( + carol, IOUAmount{153'846'15384616, -8})); + else + BEAST_EXPECT( + ammAlice.expectBalances( + XRPAmount(11'000'000'000), + STAmount{USD, UINT64_C(9'372'781065088769), -12}, + IOUAmount{10'153'846'15384616, -8}) && + ammAlice.expectLPTokens( + carol, IOUAmount{153'846'15384616, -8})); + }, + std::nullopt, + 0, + std::nullopt, + {all, all - fixAMMv1_1}); // IOU to IOU + transfer fee { @@ -2902,20 +2936,40 @@ struct AMM_test : public jtx::AMMTest ammAlice.withdraw(ed, tokens, USD(0)); } // carol, bob, and ed pay ~0.99USD in fees. - BEAST_EXPECT( - env.balance(carol, USD) == - STAmount(USD, UINT64_C(29'499'00572620545), -11)); - BEAST_EXPECT( - env.balance(bob, USD) == - STAmount(USD, UINT64_C(18'999'00572616195), -11)); - BEAST_EXPECT( - env.balance(ed, USD) == - STAmount(USD, UINT64_C(18'999'00572611841), -11)); - // USD pool is slightly higher because of the fees. - BEAST_EXPECT(ammAlice.expectBalances( - XRP(13'000), - STAmount(USD, UINT64_C(13'002'98282151419), -11), - ammTokens)); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'499'00572620545), -11)); + BEAST_EXPECT( + env.balance(bob, USD) == + STAmount(USD, UINT64_C(18'999'00572616195), -11)); + BEAST_EXPECT( + env.balance(ed, USD) == + STAmount(USD, UINT64_C(18'999'00572611841), -11)); + // USD pool is slightly higher because of the fees. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount(USD, UINT64_C(13'002'98282151419), -11), + ammTokens)); + } + else + { + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'499'00572620544), -11)); + BEAST_EXPECT( + env.balance(bob, USD) == + STAmount(USD, UINT64_C(18'999'00572616194), -11)); + BEAST_EXPECT( + env.balance(ed, USD) == + STAmount(USD, UINT64_C(18'999'0057261184), -10)); + // USD pool is slightly higher because of the fees. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount(USD, UINT64_C(13'002'98282151422), -11), + ammTokens)); + } ammTokens = ammAlice.getLPTokensBalance(); // Trade with the fee for (int i = 0; i < 10; ++i) @@ -2926,36 +2980,69 @@ struct AMM_test : public jtx::AMMTest // dan pays ~9.94USD, which is ~10 times more in fees than // carol, bob, ed. the discounted fee is 10 times less // than the trading fee. - BEAST_EXPECT( - env.balance(dan, USD) == - STAmount(USD, UINT64_C(19'490'056722744), -9)); - // USD pool gains more in dan's fees. - BEAST_EXPECT(ammAlice.expectBalances( - XRP(13'000), - STAmount{USD, UINT64_C(13'012'92609877019), -11}, - ammTokens)); - // Discounted fee payment - ammAlice.deposit(carol, USD(100)); - ammTokens = ammAlice.getLPTokensBalance(); - BEAST_EXPECT(ammAlice.expectBalances( - XRP(13'000), - STAmount{USD, UINT64_C(13'112'92609877019), -11}, - ammTokens)); - env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); - env.close(); - // carol pays 100000 drops in fees - // 99900668XRP swapped in for 100USD - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{13'100'000'668}, - STAmount{USD, UINT64_C(13'012'92609877019), -11}, - ammTokens)); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT( + env.balance(dan, USD) == + STAmount(USD, UINT64_C(19'490'056722744), -9)); + // USD pool gains more in dan's fees. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount{USD, UINT64_C(13'012'92609877019), -11}, + ammTokens)); + // Discounted fee payment + ammAlice.deposit(carol, USD(100)); + ammTokens = ammAlice.getLPTokensBalance(); + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount{USD, UINT64_C(13'112'92609877019), -11}, + ammTokens)); + env(pay(carol, bob, USD(100)), + path(~USD), + sendmax(XRP(110))); + env.close(); + // carol pays 100000 drops in fees + // 99900668XRP swapped in for 100USD + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'100'000'668}, + STAmount{USD, UINT64_C(13'012'92609877019), -11}, + ammTokens)); + } + else + { + BEAST_EXPECT( + env.balance(dan, USD) == + STAmount(USD, UINT64_C(19'490'05672274399), -11)); + // USD pool gains more in dan's fees. + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount{USD, UINT64_C(13'012'92609877023), -11}, + ammTokens)); + // Discounted fee payment + ammAlice.deposit(carol, USD(100)); + ammTokens = ammAlice.getLPTokensBalance(); + BEAST_EXPECT(ammAlice.expectBalances( + XRP(13'000), + STAmount{USD, UINT64_C(13'112'92609877023), -11}, + ammTokens)); + env(pay(carol, bob, USD(100)), + path(~USD), + sendmax(XRP(110))); + env.close(); + // carol pays 100000 drops in fees + // 99900668XRP swapped in for 100USD + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{13'100'000'668}, + STAmount{USD, UINT64_C(13'012'92609877023), -11}, + ammTokens)); + } // Payment with the trading fee env(pay(alice, carol, XRP(100)), path(~XRP), sendmax(USD(110))); env.close(); // alice pays ~1.011USD in fees, which is ~10 times more // than carol's fee // 100.099431529USD swapped in for 100XRP - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'668}, @@ -2966,16 +3053,21 @@ struct AMM_test : public jtx::AMMTest { BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'668}, - STAmount{USD, UINT64_C(13'114'03663047265), -11}, + STAmount{USD, UINT64_C(13'114'03663047269), -11}, ammTokens)); } // Auction slot expired, no discounted fee env.close(seconds(TOTAL_TIME_SLOT_SECS + 1)); // clock is parent's based env.close(); - BEAST_EXPECT( - env.balance(carol, USD) == - STAmount(USD, UINT64_C(29'399'00572620545), -11)); + if (!features[fixAMMv1_1]) + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'399'00572620545), -11)); + else + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'399'00572620544), -11)); ammTokens = ammAlice.getLPTokensBalance(); for (int i = 0; i < 10; ++i) { @@ -2984,7 +3076,7 @@ struct AMM_test : public jtx::AMMTest } // carol pays ~9.94USD in fees, which is ~10 times more in // trading fees vs discounted fee. - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT( env.balance(carol, USD) == @@ -2998,10 +3090,10 @@ struct AMM_test : public jtx::AMMTest { BEAST_EXPECT( env.balance(carol, USD) == - STAmount(USD, UINT64_C(29'389'06197177127), -11)); + STAmount(USD, UINT64_C(29'389'06197177124), -11)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{13'000'000'668}, - STAmount{USD, UINT64_C(13'123'98038490683), -11}, + STAmount{USD, UINT64_C(13'123'98038490689), -11}, ammTokens)); } env(pay(carol, bob, USD(100)), path(~USD), sendmax(XRP(110))); @@ -3009,7 +3101,7 @@ struct AMM_test : public jtx::AMMTest // carol pays ~1.008XRP in trading fee, which is // ~10 times more than the discounted fee. // 99.815876XRP is swapped in for 100USD - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(13'100'824'790), @@ -3020,14 +3112,14 @@ struct AMM_test : public jtx::AMMTest { BEAST_EXPECT(ammAlice.expectBalances( XRPAmount(13'100'824'790), - STAmount{USD, UINT64_C(13'023'98038490683), -11}, + STAmount{USD, UINT64_C(13'023'98038490689), -11}, ammTokens)); } }, std::nullopt, 1'000, std::nullopt, - features); + {features}); // Bid tiny amount testAMM( @@ -3111,7 +3203,7 @@ struct AMM_test : public jtx::AMMTest IOUAmount{1'004'487'562112089, -9})); // Bob pays the full fee ~0.1USD env(pay(bob, alice, XRP(10)), path(~XRP), sendmax(USD(11))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(amm.expectBalances( XRPAmount{1'000'010'011}, @@ -3520,19 +3612,22 @@ struct AMM_test : public jtx::AMMTest XRPAmount(10'030'082'730), STAmount(EUR, UINT64_C(9'970'007498125468), -12), ammEUR_XRP.tokens())); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammUSD_EUR.expectBalances( STAmount(USD, UINT64_C(9'970'097277662122), -12), STAmount(EUR, UINT64_C(10'029'99250187452), -11), ammUSD_EUR.tokens())); - BEAST_EXPECT(expectOffers( - env, - alice, - 1, - {{Amounts{ - XRPAmount(30'201'749), - STAmount(USD, UINT64_C(29'90272233787818), -14)}}})); + + // fixReducedOffersV2 changes the expected results slightly. + Amounts const expectedAmounts = + env.closed()->rules().enabled(fixReducedOffersV2) + ? Amounts{XRPAmount(30'201'749), STAmount(USD, UINT64_C(29'90272233787816), -14)} + : Amounts{ + XRPAmount(30'201'749), + STAmount(USD, UINT64_C(29'90272233787818), -14)}; + + BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}})); } else { @@ -3540,13 +3635,16 @@ struct AMM_test : public jtx::AMMTest STAmount(USD, UINT64_C(9'970'097277662172), -12), STAmount(EUR, UINT64_C(10'029'99250187452), -11), ammUSD_EUR.tokens())); - BEAST_EXPECT(expectOffers( - env, - alice, - 1, - {{Amounts{ - XRPAmount(30'201'749), - STAmount(USD, UINT64_C(29'9027223378284), -13)}}})); + + // fixReducedOffersV2 changes the expected results slightly. + Amounts const expectedAmounts = + env.closed()->rules().enabled(fixReducedOffersV2) + ? Amounts{XRPAmount(30'201'749), STAmount(USD, UINT64_C(29'90272233782839), -14)} + : Amounts{ + XRPAmount(30'201'749), + STAmount(USD, UINT64_C(29'90272233782840), -14)}; + + BEAST_EXPECT(expectOffers(env, alice, 1, {{expectedAmounts}})); } // Initial 30,000 + 100 BEAST_EXPECT(expectLine(env, carol, STAmount{USD, 30'100})); @@ -3621,7 +3719,7 @@ struct AMM_test : public jtx::AMMTest sendmax(XRP(200)), txflags(tfPartialPayment)); env.close(); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( XRP(10'100), USD(10'000), ammAlice.tokens())); @@ -3692,10 +3790,15 @@ struct AMM_test : public jtx::AMMTest {features}); // Offer crossing IOU/IOU and transfer rate + // Single path AMM offer testAMM( [&](AMM& ammAlice, Env& env) { env(rate(gw, 1.25)); env.close(); + // This offer succeeds to cross pre- and post-amendment + // because the strand's out amount is small enough to match + // limitQuality value and limitOut() function in StrandFlow + // doesn't require an adjustment to out value. env(offer(carol, EUR(100), GBP(100))); env.close(); // No transfer fee @@ -3711,6 +3814,195 @@ struct AMM_test : public jtx::AMMTest 0, std::nullopt, {features}); + // Single-path AMM offer + testAMM( + [&](AMM& amm, Env& env) { + env(rate(gw, 1.001)); + env.close(); + env(offer(carol, XRP(100), USD(55))); + env.close(); + if (!features[fixAMMv1_1]) + { + // Pre-amendment the transfer fee is not taken into + // account when calculating the limit out based on + // limitQuality. Carol pays 0.1% on the takerGets, which + // lowers the overall quality. AMM offer is generated based + // on higher limit out, which generates a larger offer + // with lower quality. Consequently, the offer fails + // to cross. + BEAST_EXPECT( + amm.expectBalances(XRP(1'000), USD(500), amm.tokens())); + BEAST_EXPECT(expectOffers( + env, carol, 1, {{Amounts{XRP(100), USD(55)}}})); + } + else + { + // Post-amendment the transfer fee is taken into account + // when calculating the limit out based on limitQuality. + // This increases the limitQuality and decreases + // the limit out. Consequently, AMM offer size is decreased, + // and the quality is increased, matching the overall + // quality. + // AMM offer ~50USD/91XRP + BEAST_EXPECT(amm.expectBalances( + XRPAmount(909'090'909), + STAmount{USD, UINT64_C(550'000000055), -9}, + amm.tokens())); + // Offer ~91XRP/49.99USD + BEAST_EXPECT(expectOffers( + env, + carol, + 1, + {{Amounts{ + XRPAmount{9'090'909}, + STAmount{USD, 4'99999995, -8}}}})); + // Carol pays 0.1% fee on ~50USD =~ 0.05USD + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(29'949'94999999494), -11)); + } + }, + {{XRP(1'000), USD(500)}}, + 0, + std::nullopt, + {features}); + testAMM( + [&](AMM& amm, Env& env) { + env(rate(gw, 1.001)); + env.close(); + env(offer(carol, XRP(10), USD(5.5))); + env.close(); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT(amm.expectBalances( + XRP(990), + STAmount{USD, UINT64_C(505'050505050505), -12}, + amm.tokens())); + BEAST_EXPECT(expectOffers(env, carol, 0)); + } + else + { + BEAST_EXPECT(amm.expectBalances( + XRP(990), + STAmount{USD, UINT64_C(505'0505050505051), -13}, + amm.tokens())); + BEAST_EXPECT(expectOffers(env, carol, 0)); + } + }, + {{XRP(1'000), USD(500)}}, + 0, + std::nullopt, + {features}); + // Multi-path AMM offer + testAMM( + [&](AMM& ammAlice, Env& env) { + Account const ed("ed"); + fund( + env, + gw, + {bob, ed}, + XRP(30'000), + {GBP(2'000), EUR(2'000)}, + Fund::Acct); + env(rate(gw, 1.25)); + env.close(); + // The auto-bridge is worse quality than AMM, is not consumed + // first and initially forces multi-path AMM offer generation. + // Multi-path AMM offers are consumed until their quality + // is less than the auto-bridge offers quality. Auto-bridge + // offers are consumed afterward. Then the behavior is + // different pre-amendment and post-amendment. + env(offer(bob, GBP(10), XRP(10)), txflags(tfPassive)); + env(offer(ed, XRP(10), EUR(10)), txflags(tfPassive)); + env.close(); + env(offer(carol, EUR(100), GBP(100))); + env.close(); + if (!features[fixAMMv1_1]) + { + // After the auto-bridge offers are consumed, single path + // AMM offer is generated with the limit out not taking + // into consideration the transfer fee. This results + // in an overall lower quality offer than the limit quality + // and the single path AMM offer fails to consume. + // Total consumed ~37.06GBP/39.32EUR + BEAST_EXPECT(ammAlice.expectBalances( + STAmount{GBP, UINT64_C(1'037'06583722133), -11}, + STAmount{EUR, UINT64_C(1'060'684828792831), -12}, + ammAlice.tokens())); + // Consumed offer ~49.32EUR/49.32GBP + BEAST_EXPECT(expectOffers( + env, + carol, + 1, + {Amounts{ + STAmount{EUR, UINT64_C(50'684828792831), -12}, + STAmount{GBP, UINT64_C(50'684828792831), -12}}})); + BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, ed, 0)); + + // Initial 30,000 - ~47.06(offers = 37.06(AMM) + 10(LOB)) + // * 1.25 + // = 58.825 = ~29941.17 + // carol bought ~72.93EUR at the cost of ~70.68GBP + // the offer is partially consumed + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{GBP, UINT64_C(29'941'16770347333), -11})); + // Initial 30,000 + ~49.3(offers = 39.3(AMM) + 10(LOB)) + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{EUR, UINT64_C(30'049'31517120716), -11})); + } + else + { + // After the auto-bridge offers are consumed, single path + // AMM offer is generated with the limit out taking + // into consideration the transfer fee. This results + // in an overall quality offer matching the limit quality + // and the single path AMM offer is consumed. More + // liquidity is consumed overall in post-amendment. + // Total consumed ~60.68GBP/62.93EUR + BEAST_EXPECT(ammAlice.expectBalances( + STAmount{GBP, UINT64_C(1'060'684828792832), -12}, + STAmount{EUR, UINT64_C(1'037'06583722134), -11}, + ammAlice.tokens())); + // Consumed offer ~72.93EUR/72.93GBP + BEAST_EXPECT(expectOffers( + env, + carol, + 1, + {Amounts{ + STAmount{EUR, UINT64_C(27'06583722134028), -14}, + STAmount{GBP, UINT64_C(27'06583722134028), -14}}})); + BEAST_EXPECT(expectOffers(env, bob, 0)); + BEAST_EXPECT(expectOffers(env, ed, 0)); + + // Initial 30,000 - ~70.68(offers = 60.68(AMM) + 10(LOB)) + // * 1.25 + // = 88.35 = ~29911.64 + // carol bought ~72.93EUR at the cost of ~70.68GBP + // the offer is partially consumed + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{GBP, UINT64_C(29'911'64396400896), -11})); + // Initial 30,000 + ~72.93(offers = 62.93(AMM) + 10(LOB)) + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{EUR, UINT64_C(30'072'93416277865), -11})); + } + // Initial 2000 + 10 = 2010 + BEAST_EXPECT(expectLine(env, bob, GBP(2'010))); + // Initial 2000 - 10 * 1.25 = 1987.5 + BEAST_EXPECT(expectLine(env, ed, EUR(1'987.5))); + }, + {{GBP(1'000), EUR(1'100)}}, + 0, + std::nullopt, + {features}); // Payment and transfer fee // Scenario: @@ -3833,7 +4125,7 @@ struct AMM_test : public jtx::AMMTest path(~USD), path(~ETH, ~EUR, ~USD), sendmax(XRP(200))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // XRP-ETH-EUR-USD // This path provides ~26.06USD/26.2XRP @@ -3914,7 +4206,7 @@ struct AMM_test : public jtx::AMMTest path(~EUR, ~BTC, ~USD), path(~ETH, ~EUR, ~BTC, ~USD), sendmax(XRP(200))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // XRP-EUR-BTC-USD path provides ~17.8USD/~18.7XRP // XRP-ETH-EUR-BTC-USD path provides ~82.2USD/82.4XRP @@ -3981,7 +4273,7 @@ struct AMM_test : public jtx::AMMTest path(~XRP, ~USD), sendmax(EUR(400)), txflags(tfPartialPayment | tfNoRippleDirect)); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // Carol gets ~29.91USD because of the AMM offers limit BEAST_EXPECT(ammAlice.expectBalances( @@ -4028,7 +4320,7 @@ struct AMM_test : public jtx::AMMTest txflags(tfPartialPayment | tfNoRippleDirect)); BEAST_EXPECT(ammAlice.expectBalances( XRPAmount{10'101'010'102}, USD(9'900), ammAlice.tokens())); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { // Carol gets ~100USD BEAST_EXPECT(expectLine( @@ -4060,17 +4352,33 @@ struct AMM_test : public jtx::AMMTest env(offer(bob, XRP(100), USD(100.001))); AMM ammAlice(env, alice, XRP(10'000), USD(10'100)); env(offer(carol, USD(100), XRP(100))); - BEAST_EXPECT(ammAlice.expectBalances( - XRPAmount{10'049'825'373}, - STAmount{USD, UINT64_C(10'049'92586949302), -11}, - ammAlice.tokens())); - BEAST_EXPECT(expectOffers( - env, - bob, - 1, - {{{XRPAmount{50'074'629}, - STAmount{USD, UINT64_C(50'07513050698), -11}}}})); - BEAST_EXPECT(expectLine(env, carol, USD(30'100))); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{10'049'825'373}, + STAmount{USD, UINT64_C(10'049'92586949302), -11}, + ammAlice.tokens())); + BEAST_EXPECT(expectOffers( + env, + bob, + 1, + {{{XRPAmount{50'074'629}, + STAmount{USD, UINT64_C(50'07513050698), -11}}}})); + } + else + { + BEAST_EXPECT(ammAlice.expectBalances( + XRPAmount{10'049'825'372}, + STAmount{USD, UINT64_C(10'049'92587049303), -11}, + ammAlice.tokens())); + BEAST_EXPECT(expectOffers( + env, + bob, + 1, + {{{XRPAmount{50'074'628}, + STAmount{USD, UINT64_C(50'07512950697), -11}}}})); + BEAST_EXPECT(expectLine(env, carol, USD(30'100))); + } } // Individually frozen account @@ -4342,7 +4650,7 @@ struct AMM_test : public jtx::AMMTest // Execute with CLOB offer prep( [&](Env& env) { - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) env(offer( LP1, XRPAmount{18'095'133}, @@ -4352,7 +4660,7 @@ struct AMM_test : public jtx::AMMTest env(offer( LP1, XRPAmount{18'095'132}, - STAmount{TST, UINT64_C(1'68737984885387), -14}), + STAmount{TST, UINT64_C(1'68737976189735), -14}), txflags(tfPassive)); }, [&](Env& env) { @@ -4479,8 +4787,11 @@ struct AMM_test : public jtx::AMMTest auto const tokensFee = ammAlice.withdraw( carol, USD(100), std::nullopt, IOUAmount{520, 0}); // carol withdraws ~1,443.44USD - auto const balanceAfterWithdraw = - STAmount(USD, UINT64_C(30'443'43891402715), -11); + auto const balanceAfterWithdraw = [&]() { + if (!features[fixAMMv1_1]) + return STAmount(USD, UINT64_C(30'443'43891402715), -11); + return STAmount(USD, UINT64_C(30'443'43891402714), -11); + }(); BEAST_EXPECT(env.balance(carol, USD) == balanceAfterWithdraw); // Set to original pool size auto const deposit = balanceAfterWithdraw - USD(29'000); @@ -4489,12 +4800,22 @@ struct AMM_test : public jtx::AMMTest ammAlice.vote(alice, 0); BEAST_EXPECT(ammAlice.expectTradingFee(0)); auto const tokensNoFee = ammAlice.withdraw(carol, deposit); - BEAST_EXPECT( - env.balance(carol, USD) == - STAmount(USD, UINT64_C(30'443'43891402717), -11)); + if (!features[fixAMMv1_1]) + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(30'443'43891402717), -11)); + else + BEAST_EXPECT( + env.balance(carol, USD) == + STAmount(USD, UINT64_C(30'443'43891402716), -11)); // carol pays ~4008 LPTokens in fees or ~0.5% of the no-fee // LPTokens - BEAST_EXPECT(tokensNoFee == IOUAmount(746'579'80779913, -8)); + if (!features[fixAMMv1_1]) + BEAST_EXPECT( + tokensNoFee == IOUAmount(746'579'80779913, -8)); + else + BEAST_EXPECT( + tokensNoFee == IOUAmount(746'579'80779912, -8)); BEAST_EXPECT(tokensFee == IOUAmount(750'588'23529411, -8)); }, std::nullopt, @@ -4584,7 +4905,7 @@ struct AMM_test : public jtx::AMMTest {{Amounts{ STAmount{EUR, UINT64_C(5'025125628140703), -15}, STAmount{USD, UINT64_C(5'025125628140703), -15}}}})); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(ammAlice.expectBalances( STAmount{USD, UINT64_C(1'004'974874371859), -12}, @@ -4624,7 +4945,7 @@ struct AMM_test : public jtx::AMMTest sendmax(EUR(15)), txflags(tfNoRippleDirect)); BEAST_EXPECT(expectLine(env, ed, USD(2'010))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(expectLine(env, bob, EUR(1'990))); BEAST_EXPECT(ammAlice.expectBalances( @@ -4661,7 +4982,7 @@ struct AMM_test : public jtx::AMMTest sendmax(EUR(15)), txflags(tfNoRippleDirect)); BEAST_EXPECT(expectLine(env, ed, USD(2'010))); - if (!features[fixAMMRounding]) + if (!features[fixAMMv1_1]) { BEAST_EXPECT(expectLine( env, @@ -4677,10 +4998,10 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine( env, bob, - STAmount{EUR, UINT64_C(1'989'987453007616), -12})); + STAmount{EUR, UINT64_C(1'989'987453007628), -12})); BEAST_EXPECT(ammAlice.expectBalances( USD(1'000), - STAmount{EUR, UINT64_C(1'005'012546992384), -12}, + STAmount{EUR, UINT64_C(1'005'012546992372), -12}, ammAlice.tokens())); } BEAST_EXPECT(expectOffers(env, carol, 0)); @@ -4744,74 +5065,101 @@ struct AMM_test : public jtx::AMMTest } void - testAdjustedTokens() + testAdjustedTokens(FeatureBitset features) { testcase("Adjusted Deposit/Withdraw Tokens"); using namespace jtx; // Deposit/Withdraw in USD - testAMM([&](AMM& ammAlice, Env& env) { - Account const bob("bob"); - Account const ed("ed"); - Account const paul("paul"); - Account const dan("dan"); - 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); - for (int i = 0; i < 10; ++i) - { - ammAlice.deposit(ben, STAmount{USD, 1, -10}); - ammAlice.withdrawAll(ben, USD(0)); - ammAlice.deposit(simon, USD(0.1)); - ammAlice.withdrawAll(simon, USD(0)); - ammAlice.deposit(chris, USD(1)); - ammAlice.withdrawAll(chris, USD(0)); - ammAlice.deposit(dan, USD(10)); - ammAlice.withdrawAll(dan, USD(0)); - ammAlice.deposit(bob, USD(100)); - ammAlice.withdrawAll(bob, USD(0)); - ammAlice.deposit(carol, USD(1'000)); - ammAlice.withdrawAll(carol, USD(0)); - ammAlice.deposit(ed, USD(10'000)); - 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)); - } - // Due to round off some accounts have a tiny gain, while - // other have a tiny loss. The last account to withdraw - // gets everything in the pool. - BEAST_EXPECT(ammAlice.expectBalances( - XRP(10'000), - STAmount{USD, UINT64_C(10'000'0000000013), -10}, - IOUAmount{10'000'000})); - BEAST_EXPECT(expectLine(env, ben, USD(1'500'000))); - BEAST_EXPECT(expectLine(env, simon, USD(1'500'000))); - BEAST_EXPECT(expectLine(env, chris, USD(1'500'000))); - BEAST_EXPECT(expectLine(env, dan, USD(1'500'000))); - BEAST_EXPECT(expectLine( - env, carol, STAmount{USD, UINT64_C(30'000'00000000001), -11})); - BEAST_EXPECT(expectLine(env, ed, USD(1'500'000))); - BEAST_EXPECT(expectLine(env, paul, USD(1'500'000))); - BEAST_EXPECT(expectLine( - env, nataly, STAmount{USD, UINT64_C(1'500'000'000000002), -9})); - ammAlice.withdrawAll(alice); - BEAST_EXPECT(!ammAlice.ammExists()); - BEAST_EXPECT(expectLine( - env, alice, STAmount{USD, UINT64_C(30'000'0000000013), -10})); - // alice XRP balance is 30,000initial - 50 ammcreate fee - - // 10drops fee - BEAST_EXPECT(accountBalance(env, alice) == "29949999990"); - }); + testAMM( + [&](AMM& ammAlice, Env& env) { + Account const bob("bob"); + Account const ed("ed"); + Account const paul("paul"); + Account const dan("dan"); + 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); + for (int i = 0; i < 10; ++i) + { + ammAlice.deposit(ben, STAmount{USD, 1, -10}); + ammAlice.withdrawAll(ben, USD(0)); + ammAlice.deposit(simon, USD(0.1)); + ammAlice.withdrawAll(simon, USD(0)); + ammAlice.deposit(chris, USD(1)); + ammAlice.withdrawAll(chris, USD(0)); + ammAlice.deposit(dan, USD(10)); + ammAlice.withdrawAll(dan, USD(0)); + ammAlice.deposit(bob, USD(100)); + ammAlice.withdrawAll(bob, USD(0)); + ammAlice.deposit(carol, USD(1'000)); + ammAlice.withdrawAll(carol, USD(0)); + ammAlice.deposit(ed, USD(10'000)); + 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)); + } + // Due to round off some accounts have a tiny gain, while + // other have a tiny loss. The last account to withdraw + // gets everything in the pool. + if (!features[fixAMMv1_1]) + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'000), + STAmount{USD, UINT64_C(10'000'0000000013), -10}, + IOUAmount{10'000'000})); + else + BEAST_EXPECT(ammAlice.expectBalances( + XRP(10'000), USD(10'000), IOUAmount{10'000'000})); + BEAST_EXPECT(expectLine(env, ben, USD(1'500'000))); + BEAST_EXPECT(expectLine(env, simon, USD(1'500'000))); + BEAST_EXPECT(expectLine(env, chris, USD(1'500'000))); + BEAST_EXPECT(expectLine(env, dan, USD(1'500'000))); + if (!features[fixAMMv1_1]) + BEAST_EXPECT(expectLine( + env, + carol, + STAmount{USD, UINT64_C(30'000'00000000001), -11})); + else + BEAST_EXPECT(expectLine(env, carol, USD(30'000))); + BEAST_EXPECT(expectLine(env, ed, USD(1'500'000))); + BEAST_EXPECT(expectLine(env, paul, USD(1'500'000))); + if (!features[fixAMMv1_1]) + BEAST_EXPECT(expectLine( + env, + nataly, + STAmount{USD, UINT64_C(1'500'000'000000002), -9})); + else + BEAST_EXPECT(expectLine( + env, + nataly, + STAmount{USD, UINT64_C(1'500'000'000000005), -9})); + ammAlice.withdrawAll(alice); + BEAST_EXPECT(!ammAlice.ammExists()); + if (!features[fixAMMv1_1]) + BEAST_EXPECT(expectLine( + env, + alice, + STAmount{USD, UINT64_C(30'000'0000000013), -10})); + else + BEAST_EXPECT(expectLine(env, alice, USD(30'000))); + // alice XRP balance is 30,000initial - 50 ammcreate fee - + // 10drops fee + BEAST_EXPECT(accountBalance(env, alice) == "29949999990"); + }, + std::nullopt, + 0, + std::nullopt, + {features}); // Same as above but deposit/withdraw in XRP testAMM([&](AMM& ammAlice, Env& env) { @@ -5192,35 +5540,69 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(!amm->expectBalances( USD(1'000), ETH(1'000), amm->tokens())); } - if (i == 2 && !features[fixAMMRounding]) + if (i == 2 && !features[fixAMMv1_1]) { if (rates.first == 1.5) { - BEAST_EXPECT(expectOffers( - env, - ed, - 1, - {{Amounts{ - STAmount{ - ETH, UINT64_C(378'6327949540823), -13}, - STAmount{ - USD, - UINT64_C(283'9745962155617), - -13}}}})); + if (!features[fixAMMv1_1]) + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, + UINT64_C(378'6327949540823), + -13}, + STAmount{ + USD, + UINT64_C(283'9745962155617), + -13}}}})); + else + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, + UINT64_C(378'6327949540813), + -13}, + STAmount{ + USD, + UINT64_C(283'974596215561), + -12}}}})); } else { - BEAST_EXPECT(expectOffers( - env, - ed, - 1, - {{Amounts{ - STAmount{ - ETH, UINT64_C(325'299461620749), -12}, - STAmount{ - USD, - UINT64_C(243'9745962155617), - -13}}}})); + if (!features[fixAMMv1_1]) + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, + UINT64_C(325'299461620749), + -12}, + STAmount{ + USD, + UINT64_C(243'9745962155617), + -13}}}})); + else + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, + UINT64_C(325'299461620748), + -12}, + STAmount{ + USD, + UINT64_C(243'974596215561), + -12}}}})); } } else if (i == 2) @@ -5292,29 +5674,71 @@ struct AMM_test : public jtx::AMMTest { if (rates.first == 1.5) { - BEAST_EXPECT(expectOffers( - env, ed, 1, {{Amounts{ETH(400), USD(250)}}})); - BEAST_EXPECT(expectOffers( - env, - alice, - 1, - {{Amounts{ - STAmount{USD, UINT64_C(40'5694150420947), -13}, - STAmount{ETH, UINT64_C(64'91106406735152), -14}, - }}})); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT(expectOffers( + env, ed, 1, {{Amounts{ETH(400), USD(250)}}})); + BEAST_EXPECT(expectOffers( + env, + alice, + 1, + {{Amounts{ + STAmount{ + USD, UINT64_C(40'5694150420947), -13}, + STAmount{ + ETH, UINT64_C(64'91106406735152), -14}, + }}})); + } + else + { + // Ed offer is partially crossed. + // The updated rounding makes limitQuality + // work if both amendments are enabled + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, UINT64_C(335'0889359326475), -13}, + STAmount{ + USD, UINT64_C(209'4305849579047), -13}, + }}})); + BEAST_EXPECT(expectOffers(env, alice, 0)); + } } else { - // Ed offer is partially crossed. - BEAST_EXPECT(expectOffers( - env, - ed, - 1, - {{Amounts{ - STAmount{ETH, UINT64_C(335'0889359326485), -13}, - STAmount{USD, UINT64_C(209'4305849579053), -13}, - }}})); - BEAST_EXPECT(expectOffers(env, alice, 0)); + if (!features[fixAMMv1_1]) + { + // Ed offer is partially crossed. + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, UINT64_C(335'0889359326485), -13}, + STAmount{ + USD, UINT64_C(209'4305849579053), -13}, + }}})); + BEAST_EXPECT(expectOffers(env, alice, 0)); + } + else + { + // Ed offer is partially crossed. + BEAST_EXPECT(expectOffers( + env, + ed, + 1, + {{Amounts{ + STAmount{ + ETH, UINT64_C(335'0889359326475), -13}, + STAmount{ + USD, UINT64_C(209'4305849579047), -13}, + }}})); + BEAST_EXPECT(expectOffers(env, alice, 0)); + } } } } @@ -5361,7 +5785,7 @@ struct AMM_test : public jtx::AMMTest BEAST_EXPECT(expectLine(env, bob, USD(2'100))); - if (i == 2 && !features[fixAMMRounding]) + if (i == 2 && !features[fixAMMv1_1]) { if (rates.first == 1.5) { @@ -5557,6 +5981,222 @@ struct AMM_test : public jtx::AMMTest false); } + void + testFixChangeSpotPriceQuality(FeatureBitset features) + { + testcase("Fix changeSpotPriceQuality"); + using namespace jtx; + + enum class Status { + SucceedShouldSucceedResize, // Succeed in pre-fix because + // error allowance, succeed post-fix + // because of offer resizing + FailShouldSucceed, // Fail in pre-fix due to rounding, + // succeed after fix because of XRP + // side is generated first + SucceedShouldFail, // Succeed in pre-fix, fail after fix + // due to small quality difference + Fail, // Both fail because the quality can't be matched + Succeed // Both succeed + }; + using enum Status; + auto const xrpIouAmounts10_100 = + TAmounts{XRPAmount{10}, IOUAmount{100}}; + auto const iouXrpAmounts10_100 = + TAmounts{IOUAmount{10}, XRPAmount{100}}; + // clang-format off + std::vector> tests = { + //Pool In , Pool Out, Quality , Fee, Status + {"0.001519763260828713", "1558701", Quality{5414253689393440221}, 1000, FailShouldSucceed}, + {"0.01099814367603737", "1892611", Quality{5482264816516900274}, 1000, FailShouldSucceed}, + {"0.78", "796599", Quality{5630392334958379008}, 1000, FailShouldSucceed}, + {"105439.2955578965", "49398693", Quality{5910869983721805038}, 400, FailShouldSucceed}, + {"12408293.23445213", "4340810521", Quality{5911611095910090752}, 997, FailShouldSucceed}, + {"1892611", "0.01099814367603737", Quality{6703103457950430139}, 1000, FailShouldSucceed}, + {"423028.8508101858", "3392804520", Quality{5837920340654162816}, 600, FailShouldSucceed}, + {"44565388.41001027", "73890647", Quality{6058976634606450001}, 1000, FailShouldSucceed}, + {"66831.68494832662", "16", Quality{6346111134641742975}, 0, FailShouldSucceed}, + {"675.9287302203422", "1242632304", Quality{5625960929244093294}, 300, FailShouldSucceed}, + {"7047.112186735699", "1649845866", Quality{5696855348026306945}, 504, FailShouldSucceed}, + {"840236.4402981238", "47419053", Quality{5982561601648018688}, 499, FailShouldSucceed}, + {"992715.618909774", "189445631733", Quality{5697835648288106944}, 815, SucceedShouldSucceedResize}, + {"504636667521", "185545883.9506651", Quality{6343802275337659280}, 503, SucceedShouldSucceedResize}, + {"992706.7218636649", "189447316000", Quality{5697835648288106944}, 797, SucceedShouldSucceedResize}, + {"1.068737911388205", "127860278877", Quality{5268604356368739396}, 293, SucceedShouldSucceedResize}, + {"17932506.56880419", "189308.6043676173", Quality{6206460598195440068}, 311, SucceedShouldSucceedResize}, + {"1.066379294658174", "128042251493", Quality{5268559341368739328}, 270, SucceedShouldSucceedResize}, + {"350131413924", "1576879.110907892", Quality{6487411636539049449}, 650, Fail}, + {"422093460", "2.731797662057464", Quality{6702911108534394924}, 1000, Fail}, + {"76128132223", "367172.7148422662", Quality{6487263463413514240}, 548, Fail}, + {"132701839250", "280703770.7695443", Quality{6273750681188885075}, 562, Fail}, + {"994165.7604612011", "189551302411", Quality{5697835592690668727}, 815, Fail}, + {"45053.33303227917", "86612695359", Quality{5625695218943638190}, 500, Fail}, + {"199649.077043865", "14017933007", Quality{5766034667318524880}, 324, Fail}, + {"27751824831.70903", "78896950", Quality{6272538159621630432}, 500, Fail}, + {"225.3731275781907", "156431793648", Quality{5477818047604078924}, 989, Fail}, + {"199649.077043865", "14017933007", Quality{5766036094462806309}, 324, Fail}, + {"3.590272027140361", "20677643641", Quality{5406056147042156356}, 808, Fail}, + {"1.070884664490231", "127604712776", Quality{5268620608623825741}, 293, Fail}, + {"3272.448829820197", "6275124076", Quality{5625710328924117902}, 81, Fail}, + {"0.009059512633902926", "7994028", Quality{5477511954775533172}, 1000, Fail}, + {"1", "1.0", Quality{0}, 100, Fail}, + {"1.0", "1", Quality{0}, 100, Fail}, + {"10", "10.0", Quality{xrpIouAmounts10_100}, 100, Fail}, + {"10.0", "10", Quality{iouXrpAmounts10_100}, 100, Fail}, + {"69864389131", "287631.4543025075", Quality{6487623473313516078}, 451, Succeed}, + {"4328342973", "12453825.99247381", Quality{6272522264364865181}, 997, Succeed}, + {"32347017", "7003.93031579449", Quality{6347261126087916670}, 1000, Succeed}, + {"61697206161", "36631.4583206413", Quality{6558965195382476659}, 500, Succeed}, + {"1654524979", "7028.659825511603", Quality{6487551345110052981}, 504, Succeed}, + {"88621.22277293179", "5128418948", Quality{5766347291552869205}, 380, Succeed}, + {"1892611", "0.01099814367603737", Quality{6703102780512015436}, 1000, Succeed}, + {"4542.639373338766", "24554809", Quality{5838994982188783710}, 0, Succeed}, + {"5132932546", "88542.99750172683", Quality{6419203342950054537}, 380, Succeed}, + {"78929964.1549083", "1506494795", Quality{5986890029845558688}, 589, Succeed}, + {"10096561906", "44727.72453735605", Quality{6487455290284644551}, 250, Succeed}, + {"5092.219565514988", "8768257694", Quality{5626349534958379008}, 503, Succeed}, + {"1819778294", "8305.084302902864", Quality{6487429398998540860}, 415, Succeed}, + {"6970462.633911943", "57359281", Quality{6054087899185946624}, 850, Succeed}, + {"3983448845", "2347.543644281467", Quality{6558965195382476659}, 856, Succeed}, + // This is a tiny offer 12drops/19321952e-15 it succeeds pre-amendment because of the error allowance. + // Post amendment it is resized to 11drops/17711789e-15 but the quality is still less than + // the target quality and the offer fails. + {"771493171", "1.243473020567508", Quality{6707566798038544272}, 100, SucceedShouldFail}, + }; + // clang-format on + + boost::regex rx("^\\d+$"); + boost::smatch match; + // tests that succeed should have the same amounts pre-fix and post-fix + std::vector> successAmounts; + Env env(*this, features); + auto rules = env.current()->rules(); + CurrentTransactionRulesGuard rg(rules); + for (auto const& t : tests) + { + auto getPool = [&](std::string const& v, bool isXRP) { + if (isXRP) + return amountFromString(xrpIssue(), v); + return amountFromString(noIssue(), v); + }; + auto const& quality = std::get(t); + auto const tfee = std::get(t); + auto const status = std::get(t); + auto const poolInIsXRP = + boost::regex_search(std::get<0>(t), match, rx); + auto const poolOutIsXRP = + boost::regex_search(std::get<1>(t), match, rx); + assert(!(poolInIsXRP && poolOutIsXRP)); + auto const poolIn = getPool(std::get<0>(t), poolInIsXRP); + auto const poolOut = getPool(std::get<1>(t), poolOutIsXRP); + try + { + auto const amounts = changeSpotPriceQuality( + Amounts{poolIn, poolOut}, + quality, + tfee, + env.current()->rules(), + env.journal); + if (amounts) + { + if (status == SucceedShouldSucceedResize) + { + if (!features[fixAMMv1_1]) + BEAST_EXPECT(Quality{*amounts} < quality); + else + BEAST_EXPECT(Quality{*amounts} >= quality); + } + else if (status == Succeed) + { + if (!features[fixAMMv1_1]) + BEAST_EXPECT( + Quality{*amounts} >= quality || + withinRelativeDistance( + Quality{*amounts}, quality, Number{1, -7})); + else + BEAST_EXPECT(Quality{*amounts} >= quality); + } + else if (status == FailShouldSucceed) + { + BEAST_EXPECT( + features[fixAMMv1_1] && + Quality{*amounts} >= quality); + } + else if (status == SucceedShouldFail) + { + BEAST_EXPECT( + !features[fixAMMv1_1] && + Quality{*amounts} < quality && + withinRelativeDistance( + Quality{*amounts}, quality, Number{1, -7})); + } + } + else + { + // Fails pre- and post-amendment because the quality can't + // be matched. Verify by generating a tiny offer, which + // doesn't match the quality. Exclude zero quality since + // no offer is generated in this case. + if (status == Fail && quality != Quality{0}) + { + auto tinyOffer = [&]() { + if (isXRP(poolIn)) + { + auto const takerPays = STAmount{xrpIssue(), 1}; + return Amounts{ + takerPays, + swapAssetIn( + Amounts{poolIn, poolOut}, + takerPays, + tfee)}; + } + else if (isXRP(poolOut)) + { + auto const takerGets = STAmount{xrpIssue(), 1}; + return Amounts{ + swapAssetOut( + Amounts{poolIn, poolOut}, + takerGets, + tfee), + takerGets}; + } + auto const takerPays = toAmount( + getIssue(poolIn), Number{1, -10} * poolIn); + return Amounts{ + takerPays, + swapAssetIn( + Amounts{poolIn, poolOut}, takerPays, tfee)}; + }(); + BEAST_EXPECT(Quality(tinyOffer) < quality); + } + else if (status == FailShouldSucceed) + { + BEAST_EXPECT(!features[fixAMMv1_1]); + } + else if (status == SucceedShouldFail) + { + BEAST_EXPECT(features[fixAMMv1_1]); + } + } + } + catch (std::runtime_error const& e) + { + BEAST_EXPECT( + !strcmp(e.what(), "changeSpotPriceQuality failed")); + BEAST_EXPECT( + !features[fixAMMv1_1] && status == FailShouldSucceed); + } + } + + // Test negative discriminant + { + // b**2 - 4 * a * c -> 1 * 1 - 4 * 1 * 1 = -3 + auto const res = + solveQuadraticEqSmallest(Number{1}, Number{1}, Number{1}); + BEAST_EXPECT(!res.has_value()); + } + } + void testMalformed() { @@ -5895,18 +6535,14 @@ struct AMM_test : public jtx::AMMTest txflags(tfPartialPayment)); env.close(); - auto const failUsdGH = features[fixAMMRounding] - ? input.failUsdGHr - : input.failUsdGH; - auto const failUsdBIT = features[fixAMMRounding] - ? input.failUsdBITr - : input.failUsdBIT; - auto const goodUsdGH = features[fixAMMRounding] - ? input.goodUsdGHr - : input.goodUsdGH; - auto const goodUsdBIT = features[fixAMMRounding] - ? input.goodUsdBITr - : input.goodUsdBIT; + auto const failUsdGH = + features[fixAMMv1_1] ? input.failUsdGHr : input.failUsdGH; + auto const failUsdBIT = + features[fixAMMv1_1] ? input.failUsdBITr : input.failUsdBIT; + auto const goodUsdGH = + features[fixAMMv1_1] ? input.goodUsdGHr : input.goodUsdGH; + auto const goodUsdBIT = + features[fixAMMv1_1] ? input.goodUsdBITr : input.goodUsdBIT; if (!features[fixAMMOverflowOffer]) { BEAST_EXPECT(amm.expectBalances( @@ -5977,7 +6613,253 @@ struct AMM_test : public jtx::AMMTest {{xrpPool, iouPool}}, 889, std::nullopt, - {jtx::supported_amendments() | fixAMMRounding}); + {jtx::supported_amendments() | fixAMMv1_1}); + } + + void + testFixAMMOfferBlockedByLOB(FeatureBitset features) + { + testcase("AMM Offer Blocked By LOB"); + using namespace jtx; + + // Low quality LOB offer blocks AMM liquidity + + // USD/XRP crosses AMM + { + Env env(*this, features); + + fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); + // This offer blocks AMM offer in pre-amendment + env(offer(alice, XRP(1), USD(0.01))); + env.close(); + + AMM amm(env, gw, XRP(200'000), USD(100'000)); + + // The offer doesn't cross AMM in pre-amendment code + // It crosses AMM in post-amendment code + env(offer(carol, USD(0.49), XRP(1))); + env.close(); + + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT(amm.expectBalances( + XRP(200'000), USD(100'000), amm.tokens())); + BEAST_EXPECT(expectOffers( + env, alice, 1, {{Amounts{XRP(1), USD(0.01)}}})); + // Carol's offer is blocked by alice's offer + BEAST_EXPECT(expectOffers( + env, carol, 1, {{Amounts{USD(0.49), XRP(1)}}})); + } + else + { + BEAST_EXPECT(amm.expectBalances( + XRPAmount(200'000'980'005), USD(99'999.51), amm.tokens())); + BEAST_EXPECT(expectOffers( + env, alice, 1, {{Amounts{XRP(1), USD(0.01)}}})); + // Carol's offer crosses AMM + BEAST_EXPECT(expectOffers(env, carol, 0)); + } + } + + // There is no blocking offer, the same AMM liquidity is consumed + // pre- and post-amendment. + { + Env env(*this, features); + + fund(env, gw, {alice, carol}, XRP(1'000'000), {USD(1'000'000)}); + // There is no blocking offer + // env(offer(alice, XRP(1), USD(0.01))); + + AMM amm(env, gw, XRP(200'000), USD(100'000)); + + // The offer crosses AMM + env(offer(carol, USD(0.49), XRP(1))); + env.close(); + + // The same result as with the blocking offer + BEAST_EXPECT(amm.expectBalances( + XRPAmount(200'000'980'005), USD(99'999.51), amm.tokens())); + // Carol's offer crosses AMM + BEAST_EXPECT(expectOffers(env, carol, 0)); + } + + // XRP/USD crosses AMM + { + Env env(*this, features); + fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(1'000)}); + + // This offer blocks AMM offer in pre-amendment + // It crosses AMM in post-amendment code + env(offer(bob, USD(1), XRPAmount(500))); + env.close(); + AMM amm(env, alice, XRP(1'000), USD(500)); + env(offer(carol, XRP(100), USD(55))); + env.close(); + if (!features[fixAMMv1_1]) + { + BEAST_EXPECT( + amm.expectBalances(XRP(1'000), USD(500), amm.tokens())); + BEAST_EXPECT(expectOffers( + env, bob, 1, {{Amounts{USD(1), XRPAmount(500)}}})); + BEAST_EXPECT(expectOffers( + env, carol, 1, {{Amounts{XRP(100), USD(55)}}})); + } + else + { + BEAST_EXPECT(amm.expectBalances( + XRPAmount(909'090'909), + STAmount{USD, UINT64_C(550'000000055), -9}, + amm.tokens())); + BEAST_EXPECT(expectOffers( + env, + carol, + 1, + {{Amounts{ + XRPAmount{9'090'909}, + STAmount{USD, 4'99999995, -8}}}})); + BEAST_EXPECT(expectOffers( + env, bob, 1, {{Amounts{USD(1), XRPAmount(500)}}})); + } + } + + // There is no blocking offer, the same AMM liquidity is consumed + // pre- and post-amendment. + { + Env env(*this, features); + fund(env, gw, {alice, carol, bob}, XRP(10'000), {USD(1'000)}); + + AMM amm(env, alice, XRP(1'000), USD(500)); + env(offer(carol, XRP(100), USD(55))); + env.close(); + BEAST_EXPECT(amm.expectBalances( + XRPAmount(909'090'909), + STAmount{USD, UINT64_C(550'000000055), -9}, + amm.tokens())); + BEAST_EXPECT(expectOffers( + env, + carol, + 1, + {{Amounts{ + XRPAmount{9'090'909}, STAmount{USD, 4'99999995, -8}}}})); + } + } + + void + testLPTokenBalance(FeatureBitset features) + { + using namespace jtx; + + // Last Liquidity Provider is the issuer of one token + { + Env env(*this, features); + fund( + env, + gw, + {alice, carol}, + XRP(1'000'000'000), + {USD(1'000'000'000)}); + AMM amm(env, gw, XRP(2), USD(1)); + amm.deposit(alice, IOUAmount{1'876123487565916, -15}); + amm.deposit(carol, IOUAmount{1'000'000}); + amm.withdrawAll(alice); + amm.withdrawAll(carol); + auto const lpToken = getAccountLines( + env, gw, amm.lptIssue())[jss::lines][0u][jss::balance]; + auto const lpTokenBalance = + amm.ammRpcInfo()[jss::amm][jss::lp_token][jss::value]; + BEAST_EXPECT( + lpToken == "1414.213562373095" && + lpTokenBalance == "1414.213562373"); + if (!features[fixAMMv1_1]) + { + amm.withdrawAll(gw, std::nullopt, ter(tecAMM_BALANCE)); + BEAST_EXPECT(amm.ammExists()); + } + else + { + amm.withdrawAll(gw); + BEAST_EXPECT(!amm.ammExists()); + } + } + + // Last Liquidity Provider is the issuer of two tokens, or not + // the issuer + for (auto const& lp : {gw, bob}) + { + Env env(*this, features); + auto const ABC = gw["ABC"]; + fund( + env, + gw, + {alice, carol, bob}, + XRP(1'000), + {USD(1'000'000'000), ABC(1'000'000'000'000)}); + AMM amm(env, lp, ABC(2'000'000), USD(1)); + amm.deposit(alice, IOUAmount{1'876123487565916, -15}); + amm.deposit(carol, IOUAmount{1'000'000}); + amm.withdrawAll(alice); + amm.withdrawAll(carol); + auto const lpToken = getAccountLines( + env, lp, amm.lptIssue())[jss::lines][0u][jss::balance]; + auto const lpTokenBalance = + amm.ammRpcInfo()[jss::amm][jss::lp_token][jss::value]; + BEAST_EXPECT( + lpToken == "1414.213562373095" && + lpTokenBalance == "1414.213562373"); + if (!features[fixAMMv1_1]) + { + amm.withdrawAll(lp, std::nullopt, ter(tecAMM_BALANCE)); + BEAST_EXPECT(amm.ammExists()); + } + else + { + amm.withdrawAll(lp); + BEAST_EXPECT(!amm.ammExists()); + } + } + + // More than one Liquidity Provider + // XRP/IOU + { + Env env(*this, features); + fund(env, gw, {alice}, XRP(1'000), {USD(1'000)}); + AMM amm(env, gw, XRP(10), USD(10)); + amm.deposit(alice, 1'000); + auto res = + isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + BEAST_EXPECT(res && !res.value()); + res = + isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice); + BEAST_EXPECT(res && !res.value()); + } + // IOU/IOU, issuer of both IOU + { + Env env(*this, features); + fund(env, gw, {alice}, XRP(1'000), {USD(1'000), EUR(1'000)}); + AMM amm(env, gw, EUR(10), USD(10)); + amm.deposit(alice, 1'000); + auto res = + isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + BEAST_EXPECT(res && !res.value()); + res = + isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), alice); + BEAST_EXPECT(res && !res.value()); + } + // IOU/IOU, issuer of one IOU + { + Env env(*this, features); + Account const gw1("gw1"); + auto const YAN = gw1["YAN"]; + fund(env, gw, {gw1}, XRP(1'000), {USD(1'000)}); + fund(env, gw1, {gw}, XRP(1'000), {YAN(1'000)}, Fund::IOUOnly); + AMM amm(env, gw1, YAN(10), USD(10)); + amm.deposit(gw, 1'000); + auto res = + isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw); + BEAST_EXPECT(res && !res.value()); + res = isOnlyLiquidityProvider(*env.current(), amm.lptIssue(), gw1); + BEAST_EXPECT(res && !res.value()); + } } void @@ -5994,29 +6876,38 @@ struct AMM_test : public jtx::AMMTest testFeeVote(); testInvalidBid(); testBid(all); - testBid(all - fixAMMRounding); + testBid(all - fixAMMv1_1); testInvalidAMMPayment(); testBasicPaymentEngine(all); - testBasicPaymentEngine(all - fixAMMRounding); + testBasicPaymentEngine(all - fixAMMv1_1); + testBasicPaymentEngine(all - fixReducedOffersV2); + testBasicPaymentEngine(all - fixAMMv1_1 - fixReducedOffersV2); testAMMTokens(); testAmendment(); testFlags(); testRippling(); testAMMAndCLOB(all); - testAMMAndCLOB(all - fixAMMRounding); + testAMMAndCLOB(all - fixAMMv1_1); testTradingFee(all); - testTradingFee(all - fixAMMRounding); - testAdjustedTokens(); + testTradingFee(all - fixAMMv1_1); + testAdjustedTokens(all); + testAdjustedTokens(all - fixAMMv1_1); testAutoDelete(); testClawback(); testAMMID(); testSelection(all); - testSelection(all - fixAMMRounding); + testSelection(all - fixAMMv1_1); testFixDefaultInnerObj(); testMalformed(); testFixOverflowOffer(all); - testFixOverflowOffer(all - fixAMMRounding); + testFixOverflowOffer(all - fixAMMv1_1); testSwapRounding(); + testFixChangeSpotPriceQuality(all); + testFixChangeSpotPriceQuality(all - fixAMMv1_1); + testFixAMMOfferBlockedByLOB(all); + testFixAMMOfferBlockedByLOB(all - fixAMMv1_1); + testLPTokenBalance(all); + testLPTokenBalance(all - fixAMMv1_1); } }; diff --git a/src/test/app/AccountDelete_test.cpp b/src/test/app/AccountDelete_test.cpp index fbd631f444a..5fbb0ba38b1 100644 --- a/src/test/app/AccountDelete_test.cpp +++ b/src/test/app/AccountDelete_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/AccountTxPaging_test.cpp b/src/test/app/AccountTxPaging_test.cpp index d3969e279b7..680e006a74f 100644 --- a/src/test/app/AccountTxPaging_test.cpp +++ b/src/test/app/AccountTxPaging_test.cpp @@ -16,15 +16,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/app/AmendmentTable_test.cpp b/src/test/app/AmendmentTable_test.cpp index 238e05ba523..2f95fc0280b 100644 --- a/src/test/app/AmendmentTable_test.cpp +++ b/src/test/app/AmendmentTable_test.cpp @@ -17,21 +17,21 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/Check_test.cpp b/src/test/app/Check_test.cpp index 8f0c0ec46b8..31b45abf43a 100644 --- a/src/test/app/Check_test.cpp +++ b/src/test/app/Check_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/Clawback_test.cpp b/src/test/app/Clawback_test.cpp index 630e4836d8e..a6909bb2f62 100644 --- a/src/test/app/Clawback_test.cpp +++ b/src/test/app/Clawback_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/CrossingLimits_test.cpp b/src/test/app/CrossingLimits_test.cpp index 09cca1e82af..6f6a7eb3e7f 100644 --- a/src/test/app/CrossingLimits_test.cpp +++ b/src/test/app/CrossingLimits_test.cpp @@ -15,9 +15,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/DID_test.cpp b/src/test/app/DID_test.cpp index 82e77a20264..20734518887 100644 --- a/src/test/app/DID_test.cpp +++ b/src/test/app/DID_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/app/DNS_test.cpp b/src/test/app/DNS_test.cpp index 6ae4bc8d64a..7a39c5f0790 100644 --- a/src/test/app/DNS_test.cpp +++ b/src/test/app/DNS_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include #include diff --git a/src/test/app/DeliverMin_test.cpp b/src/test/app/DeliverMin_test.cpp index 316d95ba740..3c62a47a4a4 100644 --- a/src/test/app/DeliverMin_test.cpp +++ b/src/test/app/DeliverMin_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/DepositAuth_test.cpp b/src/test/app/DepositAuth_test.cpp index f10633c5e46..9a11785b38c 100644 --- a/src/test/app/DepositAuth_test.cpp +++ b/src/test/app/DepositAuth_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/app/Discrepancy_test.cpp b/src/test/app/Discrepancy_test.cpp index c89432f9115..1eaa1ad86dd 100644 --- a/src/test/app/Discrepancy_test.cpp +++ b/src/test/app/Discrepancy_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/Escrow_test.cpp b/src/test/app/Escrow_test.cpp index 083764fd371..813f26da736 100644 --- a/src/test/app/Escrow_test.cpp +++ b/src/test/app/Escrow_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#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 ad38aefb20a..289ce2a713e 100644 --- a/src/test/app/FeeVote_test.cpp +++ b/src/test/app/FeeVote_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/Flow_test.cpp b/src/test/app/Flow_test.cpp index 920f7a6e058..9d1257d16bf 100644 --- a/src/test/app/Flow_test.cpp +++ b/src/test/app/Flow_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { @@ -506,7 +506,6 @@ struct Flow_test : public beast::unit_test::suite // Without limits, the 0.4 USD would produce 1000 EUR in the forward // pass. This test checks that the payment produces 1 EUR, as // expected. - Env env(*this, features); env.fund(XRP(10000), alice, bob, carol, gw); env.trust(USD(1000), alice, bob, carol); @@ -515,17 +514,52 @@ struct Flow_test : public beast::unit_test::suite env(pay(gw, alice, USD(1000))); env(pay(gw, bob, EUR(1000))); + Keylet const bobUsdOffer = keylet::offer(bob, env.seq(bob)); env(offer(bob, USD(1), drops(2)), txflags(tfPassive)); env(offer(bob, drops(1), EUR(1000)), txflags(tfPassive)); + bool const reducedOffersV2 = features[fixReducedOffersV2]; + + // With reducedOffersV2, it is not allowed to accept less than + // USD(0.5) of bob's USD offer. If we provide 1 drop for less + // than USD(0.5), then the remaining fractional offer would + // block the order book. + TER const expectedTER = + reducedOffersV2 ? TER(tecPATH_DRY) : TER(tesSUCCESS); env(pay(alice, carol, EUR(1)), path(~XRP, ~EUR), sendmax(USD(0.4)), - txflags(tfNoRippleDirect | tfPartialPayment)); + txflags(tfNoRippleDirect | tfPartialPayment), + ter(expectedTER)); + + if (!reducedOffersV2) + { + env.require(balance(carol, EUR(1))); + env.require(balance(bob, USD(0.4))); + env.require(balance(bob, EUR(999))); - env.require(balance(carol, EUR(1))); - env.require(balance(bob, USD(0.4))); - env.require(balance(bob, EUR(999))); + // Show that bob's USD offer is now a blocker. + std::shared_ptr const usdOffer = env.le(bobUsdOffer); + if (BEAST_EXPECT(usdOffer)) + { + std::uint64_t const bookRate = [&usdOffer]() { + // Extract the least significant 64 bits from the + // book page. That's where the quality is stored. + std::string bookDirStr = + to_string(usdOffer->at(sfBookDirectory)); + bookDirStr.erase(0, 48); + return std::stoull(bookDirStr, nullptr, 16); + }(); + std::uint64_t const actualRate = getRate( + usdOffer->at(sfTakerGets), usdOffer->at(sfTakerPays)); + + // We expect the actual rate of the offer to be worse + // (larger) than the rate of the book page holding the + // offer. This is a defect which is corrected by + // fixReducedOffersV2. + BEAST_EXPECT(actualRate > bookRate); + } + } } } @@ -1375,9 +1409,11 @@ struct Flow_test : public beast::unit_test::suite { using namespace jtx; FeatureBitset const ownerPaysFee{featureOwnerPaysFee}; + FeatureBitset const reducedOffersV2(fixReducedOffersV2); testLineQuality(features); testFalseDry(features); + testBookStep(features - reducedOffersV2); testDirectStep(features); testBookStep(features); testDirectStep(features | ownerPaysFee); diff --git a/src/test/app/Freeze_test.cpp b/src/test/app/Freeze_test.cpp index cb4653c086d..0c54f0e1f39 100644 --- a/src/test/app/Freeze_test.cpp +++ b/src/test/app/Freeze_test.cpp @@ -16,12 +16,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/HashRouter_test.cpp b/src/test/app/HashRouter_test.cpp index f45692aa819..571690f20bb 100644 --- a/src/test/app/HashRouter_test.cpp +++ b/src/test/app/HashRouter_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/LedgerHistory_test.cpp b/src/test/app/LedgerHistory_test.cpp index 880cbea5980..e1a837a9cb2 100644 --- a/src/test/app/LedgerHistory_test.cpp +++ b/src/test/app/LedgerHistory_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include namespace ripple { namespace test { diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index f06e7d0bf01..5b6df353d81 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -17,12 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -36,10 +38,12 @@ class LedgerLoad_test : public beast::unit_test::suite std::unique_ptr cfg, std::string const& dbPath, std::string const& ledger, - Config::StartUpType type) + Config::StartUpType type, + std::optional trapTxHash) { cfg->START_LEDGER = ledger; cfg->START_UP = type; + cfg->TRAP_TX_HASH = trapTxHash; assert(!dbPath.empty()); cfg->legacy("database_path", dbPath); return cfg; @@ -52,6 +56,7 @@ class LedgerLoad_test : public beast::unit_test::suite std::string ledgerFile{}; Json::Value ledger{}; Json::Value hashes{}; + uint256 trapTxHash{}; }; SetupData @@ -94,6 +99,16 @@ class LedgerLoad_test : public beast::unit_test::suite }(); BEAST_EXPECT(retval.hashes.size() == 41); + retval.trapTxHash = [&]() { + auto const txs = env.rpc( + "ledger", + std::to_string(41), + "tx")[jss::result][jss::ledger][jss::transactions]; + BEAST_EXPECT(txs.isArray() && txs.size() > 0); + uint256 tmp; + BEAST_EXPECT(tmp.parseHex(txs[0u][jss::hash].asString())); + return tmp; + }(); // write this ledger data to a file. std::ofstream o(retval.ledgerFile, std::ios::out | std::ios::trunc); @@ -112,7 +127,11 @@ class LedgerLoad_test : public beast::unit_test::suite Env env( *this, envconfig( - ledgerConfig, sd.dbPath, sd.ledgerFile, Config::LOAD_FILE), + ledgerConfig, + sd.dbPath, + sd.ledgerFile, + Config::LOAD_FILE, + std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -132,7 +151,12 @@ class LedgerLoad_test : public beast::unit_test::suite except([&] { Env env( *this, - envconfig(ledgerConfig, sd.dbPath, "", Config::LOAD_FILE), + envconfig( + ledgerConfig, + sd.dbPath, + "", + Config::LOAD_FILE, + std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -142,7 +166,11 @@ class LedgerLoad_test : public beast::unit_test::suite Env env( *this, envconfig( - ledgerConfig, sd.dbPath, "badfile.json", Config::LOAD_FILE), + ledgerConfig, + sd.dbPath, + "badfile.json", + Config::LOAD_FILE, + std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -172,7 +200,8 @@ class LedgerLoad_test : public beast::unit_test::suite ledgerConfig, sd.dbPath, ledgerFileCorrupt.string(), - Config::LOAD_FILE), + Config::LOAD_FILE, + std::nullopt), nullptr, beast::severities::kDisabled); }); @@ -189,7 +218,12 @@ class LedgerLoad_test : public beast::unit_test::suite boost::erase_all(ledgerHash, "\""); Env env( *this, - envconfig(ledgerConfig, sd.dbPath, ledgerHash, Config::LOAD), + envconfig( + ledgerConfig, + sd.dbPath, + ledgerHash, + Config::LOAD, + std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -199,6 +233,103 @@ class LedgerLoad_test : public beast::unit_test::suite sd.ledger[jss::ledger][jss::accountState].size()); } + void + testReplay(SetupData const& sd) + { + testcase("Load and replay by hash"); + using namespace test::jtx; + + // create a new env with the ledger hash specified for startup + auto ledgerHash = to_string(sd.hashes[sd.hashes.size() - 1]); + boost::erase_all(ledgerHash, "\""); + Env env( + *this, + envconfig( + ledgerConfig, + sd.dbPath, + ledgerHash, + Config::REPLAY, + std::nullopt), + nullptr, + beast::severities::kDisabled); + auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; + BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97); + // in replace mode do not automatically accept the ledger being replayed + + env.close(); + auto const closed = env.rpc("ledger", "current", "full")[jss::result]; + BEAST_EXPECT(closed[jss::ledger][jss::accountState].size() == 98); + BEAST_EXPECT( + closed[jss::ledger][jss::accountState].size() <= + sd.ledger[jss::ledger][jss::accountState].size()); + } + + void + testReplayTx(SetupData const& sd) + { + testcase("Load and replay transaction by hash"); + using namespace test::jtx; + + // create a new env with the ledger hash specified for startup + auto ledgerHash = to_string(sd.hashes[sd.hashes.size() - 1]); + boost::erase_all(ledgerHash, "\""); + Env env( + *this, + envconfig( + ledgerConfig, + sd.dbPath, + ledgerHash, + Config::REPLAY, + sd.trapTxHash), + nullptr, + beast::severities::kDisabled); + auto const jrb = env.rpc("ledger", "current", "full")[jss::result]; + BEAST_EXPECT(jrb[jss::ledger][jss::accountState].size() == 97); + // in replace mode do not automatically accept the ledger being replayed + + env.close(); + auto const closed = env.rpc("ledger", "current", "full")[jss::result]; + BEAST_EXPECT(closed[jss::ledger][jss::accountState].size() == 98); + BEAST_EXPECT( + closed[jss::ledger][jss::accountState].size() <= + sd.ledger[jss::ledger][jss::accountState].size()); + } + + void + testReplayTxFail(SetupData const& sd) + { + testcase("Load and replay transaction by hash failure"); + using namespace test::jtx; + + // create a new env with the ledger hash specified for startup + auto ledgerHash = to_string(sd.hashes[sd.hashes.size() - 1]); + boost::erase_all(ledgerHash, "\""); + try + { + // will throw an exception, because we cannot load a ledger for + // replay when trapTxHash is set to an invalid transaction + Env env( + *this, + envconfig( + ledgerConfig, + sd.dbPath, + ledgerHash, + Config::REPLAY, + ~sd.trapTxHash), + nullptr, + beast::severities::kDisabled); + BEAST_EXPECT(false); + } + catch (std::runtime_error const&) + { + BEAST_EXPECT(true); + } + catch (...) + { + BEAST_EXPECT(false); + } + } + void testLoadLatest(SetupData const& sd) { @@ -208,7 +339,8 @@ 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), + envconfig( + ledgerConfig, sd.dbPath, "latest", Config::LOAD, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -226,7 +358,8 @@ 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), + envconfig( + ledgerConfig, sd.dbPath, "43", Config::LOAD, std::nullopt), nullptr, beast::severities::kDisabled); auto jrb = env.rpc("ledger", "current", "full")[jss::result]; @@ -246,6 +379,9 @@ class LedgerLoad_test : public beast::unit_test::suite testLoad(sd); testBadFiles(sd); testLoadByHash(sd); + testReplay(sd); + testReplayTx(sd); + testReplayTxFail(sd); testLoadLatest(sd); testLoadIndex(sd); } diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index 87639c42fcd..d53d27b3185 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include #include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/LedgerReplay_test.cpp b/src/test/app/LedgerReplay_test.cpp index aee24cd7d57..0b555a712cf 100644 --- a/src/test/app/LedgerReplay_test.cpp +++ b/src/test/app/LedgerReplay_test.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #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 f8e73cebd16..fa7489bf1bb 100644 --- a/src/test/app/LoadFeeTrack_test.cpp +++ b/src/test/app/LoadFeeTrack_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/Manifest_test.cpp b/src/test/app/Manifest_test.cpp index b72623309e9..bf7b14c0d28 100644 --- a/src/test/app/Manifest_test.cpp +++ b/src/test/app/Manifest_test.cpp @@ -17,20 +17,20 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include namespace ripple { namespace test { diff --git a/src/test/app/MultiSign_test.cpp b/src/test/app/MultiSign_test.cpp index 0e151b38d0a..77d85d9011b 100644 --- a/src/test/app/MultiSign_test.cpp +++ b/src/test/app/MultiSign_test.cpp @@ -15,10 +15,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/NFTokenBurn_test.cpp b/src/test/app/NFTokenBurn_test.cpp index abd9ed56e83..8219889b4be 100644 --- a/src/test/app/NFTokenBurn_test.cpp +++ b/src/test/app/NFTokenBurn_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include diff --git a/src/test/app/NFTokenDir_test.cpp b/src/test/app/NFTokenDir_test.cpp index e9addfa83f7..23e4c671526 100644 --- a/src/test/app/NFTokenDir_test.cpp +++ b/src/test/app/NFTokenDir_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include #include @@ -185,7 +185,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; accounts.reserve(seeds.size()); - for (std::string_view const& seed : seeds) + for (std::string_view seed : seeds) { Account const& account = accounts.emplace_back( Account::base58Seed, std::string(seed)); @@ -409,7 +409,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; accounts.reserve(seeds.size()); - for (std::string_view const& seed : seeds) + for (std::string_view seed : seeds) { Account const& account = accounts.emplace_back( Account::base58Seed, std::string(seed)); @@ -659,7 +659,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; accounts.reserve(seeds.size()); - for (std::string_view const& seed : seeds) + for (std::string_view seed : seeds) { Account const& account = accounts.emplace_back(Account::base58Seed, std::string(seed)); @@ -840,7 +840,7 @@ class NFTokenDir_test : public beast::unit_test::suite // Create accounts for all of the seeds and fund those accounts. std::vector accounts; accounts.reserve(seeds.size()); - for (std::string_view const& seed : seeds) + for (std::string_view seed : seeds) { Account const& account = accounts.emplace_back(Account::base58Seed, std::string(seed)); diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index 8740b521132..9c0e09d6711 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include #include @@ -3171,6 +3171,26 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite ter(tecNO_PERMISSION)); env.close(); } + + // minter mint and offer to buyer + if (features[featureNFTokenMintOffer]) + { + // enable flag + env(fset(buyer, asfDisallowIncomingNFTokenOffer)); + // a sell offer from the minter to the buyer should be rejected + env(token::mint(minter), + token::amount(drops(1)), + token::destination(buyer), + ter(tecNO_PERMISSION)); + env.close(); + + // disable flag + env(fclear(buyer, asfDisallowIncomingNFTokenOffer)); + env(token::mint(minter), + token::amount(drops(1)), + token::destination(buyer)); + env.close(); + } } void @@ -6306,7 +6326,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } // When an account mints and burns a batch of NFTokens using tickets, - // see if the the account can be deleted. + // see if the account can be deleted. { Env env{*this, features}; @@ -6566,6 +6586,281 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } } + void + testFeatMintWithOffer(FeatureBitset features) + { + testcase("NFTokenMint with Create NFTokenOffer"); + + using namespace test::jtx; + + if (!features[featureNFTokenMintOffer]) + { + Env env{*this, features}; + Account const alice("alice"); + Account const buyer("buyer"); + + env.fund(XRP(10000), alice, buyer); + env.close(); + + env(token::mint(alice), + token::amount(XRP(10000)), + ter(temDISABLED)); + env.close(); + + env(token::mint(alice), + token::destination("buyer"), + ter(temDISABLED)); + env.close(); + + env(token::mint(alice), + token::expiration(lastClose(env) + 25), + ter(temDISABLED)); + env.close(); + + return; + } + + // The remaining tests assume featureNFTokenMintOffer is enabled. + { + Env env{*this, features}; + Account const alice("alice"); + Account const buyer{"buyer"}; + Account const gw("gw"); + Account const issuer("issuer"); + Account const minter("minter"); + Account const bob("bob"); + IOU const gwAUD(gw["AUD"]); + + env.fund(XRP(10000), alice, buyer, gw, issuer, minter); + env.close(); + + { + // Destination field specified but Amount field not specified + env(token::mint(alice), + token::destination(buyer), + ter(temMALFORMED)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // Expiration field specified but Amount field not specified + env(token::mint(alice), + token::expiration(lastClose(env) + 25), + ter(temMALFORMED)); + env.close(); + BEAST_EXPECT(ownerCount(env, buyer) == 0); + } + + { + // The destination may not be the account submitting the + // transaction. + env(token::mint(alice), + token::amount(XRP(1000)), + token::destination(alice), + ter(temMALFORMED)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // The destination must be an account already established in the + // ledger. + env(token::mint(alice), + token::amount(XRP(1000)), + token::destination(Account("demon")), + ter(tecNO_DST)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + } + + { + // Set a bad expiration. + env(token::mint(alice), + token::amount(XRP(1000)), + token::expiration(0), + ter(temBAD_EXPIRATION)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // The new NFTokenOffer may not have passed its expiration time. + env(token::mint(alice), + token::amount(XRP(1000)), + token::expiration(lastClose(env)), + ter(tecEXPIRED)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + } + + { + // Set an invalid amount. + env(token::mint(alice), + token::amount(buyer["USD"](1)), + txflags(tfOnlyXRP), + ter(temBAD_AMOUNT)); + env(token::mint(alice), + token::amount(buyer["USD"](0)), + ter(temBAD_AMOUNT)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // Issuer (alice) must have a trust line for the offered funds. + env(token::mint(alice), + token::amount(gwAUD(1000)), + txflags(tfTransferable), + token::xferFee(10), + ter(tecNO_LINE)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // If the IOU issuer and the NFToken issuer are the same, + // then that issuer does not need a trust line to accept their + // fee. + env(token::mint(gw), + token::amount(gwAUD(1000)), + txflags(tfTransferable), + token::xferFee(10)); + env.close(); + + // Give alice the needed trust line, but freeze it. + env(trust(gw, alice["AUD"](999), tfSetFreeze)); + env.close(); + + // Issuer (alice) must have a trust line for the offered funds + // and the trust line may not be frozen. + env(token::mint(alice), + token::amount(gwAUD(1000)), + txflags(tfTransferable), + token::xferFee(10), + ter(tecFROZEN)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // Seller (alice) must have a trust line may not be frozen. + env(token::mint(alice), + token::amount(gwAUD(1000)), + ter(tecFROZEN)); + env.close(); + BEAST_EXPECT(ownerCount(env, alice) == 0); + + // Unfreeze alice's trustline. + env(trust(gw, alice["AUD"](999), tfClearFreeze)); + env.close(); + } + + { + // check reserve + auto const acctReserve = + env.current()->fees().accountReserve(0); + auto const incReserve = env.current()->fees().increment; + + env.fund(acctReserve + incReserve, bob); + env.close(); + + // doesn't have reserve for 2 objects (NFTokenPage, Offer) + env(token::mint(bob), + token::amount(XRP(0)), + ter(tecINSUFFICIENT_RESERVE)); + env.close(); + + // have reserve for NFTokenPage, Offer + env(pay(env.master, bob, incReserve + drops(10))); + env.close(); + env(token::mint(bob), token::amount(XRP(0))); + env.close(); + + // doesn't have reserve for Offer + env(pay(env.master, bob, drops(10))); + env.close(); + env(token::mint(bob), + token::amount(XRP(0)), + ter(tecINSUFFICIENT_RESERVE)); + env.close(); + + // have reserve for Offer + env(pay(env.master, bob, incReserve + drops(10))); + env.close(); + env(token::mint(bob), token::amount(XRP(0))); + env.close(); + } + + // Amount field specified + BEAST_EXPECT(ownerCount(env, alice) == 0); + env(token::mint(alice), token::amount(XRP(10))); + BEAST_EXPECT(ownerCount(env, alice) == 2); + env.close(); + + // Amount field and Destination field, Expiration field specified + env(token::mint(alice), + token::amount(XRP(10)), + token::destination(buyer), + token::expiration(lastClose(env) + 25)); + env.close(); + + // With TransferFee field + env(trust(alice, gwAUD(1000))); + env.close(); + env(token::mint(alice), + token::amount(gwAUD(1)), + token::destination(buyer), + token::expiration(lastClose(env) + 25), + txflags(tfTransferable), + token::xferFee(10)); + env.close(); + + // Can be canceled by the issuer. + env(token::mint(alice), + token::amount(XRP(10)), + token::destination(buyer), + token::expiration(lastClose(env) + 25)); + uint256 const offerAliceSellsToBuyer = + keylet::nftoffer(alice, env.seq(alice)).key; + env(token::cancelOffer(alice, {offerAliceSellsToBuyer})); + env.close(); + + // Can be canceled by the buyer. + env(token::mint(buyer), + token::amount(XRP(10)), + token::destination(alice), + token::expiration(lastClose(env) + 25)); + uint256 const offerBuyerSellsToAlice = + keylet::nftoffer(buyer, env.seq(buyer)).key; + env(token::cancelOffer(alice, {offerBuyerSellsToAlice})); + env.close(); + + env(token::setMinter(issuer, minter)); + env.close(); + + // Minter will have offer not issuer + BEAST_EXPECT(ownerCount(env, minter) == 0); + BEAST_EXPECT(ownerCount(env, issuer) == 0); + env(token::mint(minter), + token::issuer(issuer), + token::amount(drops(1))); + env.close(); + BEAST_EXPECT(ownerCount(env, minter) == 2); + BEAST_EXPECT(ownerCount(env, issuer) == 0); + } + + // Test sell offers with a destination with and without + // fixNFTokenNegOffer. + for (auto const& tweakedFeatures : + {features - fixNFTokenNegOffer - featureNonFungibleTokensV1_1, + features | fixNFTokenNegOffer}) + { + Env env{*this, tweakedFeatures}; + Account const alice("alice"); + + env.fund(XRP(1000000), alice); + + TER const offerCreateTER = tweakedFeatures[fixNFTokenNegOffer] + ? static_cast(temBAD_AMOUNT) + : static_cast(tesSUCCESS); + + // Make offers with negative amounts for the NFTs + env(token::mint(alice), + token::amount(XRP(-2)), + ter(offerCreateTER)); + env.close(); + } + } + void testTxJsonMetaFields(FeatureBitset features) { @@ -6796,6 +7091,15 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); verifyNFTokenIDsInCancelOffer({nftId}); } + + if (features[featureNFTokenMintOffer]) + { + uint256 const aliceMintWithOfferIndex1 = + keylet::nftoffer(alice, env.seq(alice)).key; + env(token::mint(alice), token::amount(XRP(0))); + env.close(); + verifyNFTokenOfferID(aliceMintWithOfferIndex1); + } } void @@ -7112,6 +7416,334 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite } } + void + testUnaskedForAutoTrustline(FeatureBitset features) + { + testcase("Test fix unasked for auto-trustline."); + + using namespace test::jtx; + + Account const issuer{"issuer"}; + Account const becky{"becky"}; + Account const cheri{"cheri"}; + Account const gw("gw"); + IOU const gwAUD(gw["AUD"]); + + // This test case covers issue... + // https://github.com/XRPLF/rippled/issues/4925 + // + // For an NFToken with a transfer fee, the issuer must be able to + // accept the transfer fee or else a transfer should fail. If the + // NFToken is transferred for a non-XRP asset, then the issuer must + // have a trustline to that asset to receive the fee. + // + // This test looks at a situation where issuer would get a trustline + // for the fee without the issuer's consent. Here are the steps: + // 1. Issuer has a trustline (i.e., USD) + // 2. Issuer mints NFToken with transfer fee. + // 3. Becky acquires the NFToken, paying with XRP. + // 4. Becky creates offer to sell NFToken for USD(100). + // 5. Issuer deletes trustline for USD. + // 6. Carol buys NFToken from Becky for USD(100). + // 7. The transfer fee from Carol's purchase re-establishes issuer's + // USD trustline. + // + // The fixEnforceNFTokenTrustline amendment addresses this oversight. + // + // We run this test case both with and without + // fixEnforceNFTokenTrustline enabled so we can see the change + // in behavior. + // + // In both cases we remove the fixRemoveNFTokenAutoTrustLine amendment. + // Otherwise we can't create NFTokens with tfTrustLine enabled. + FeatureBitset const localFeatures = + features - fixRemoveNFTokenAutoTrustLine; + for (FeatureBitset feats : + {localFeatures - fixEnforceNFTokenTrustline, + localFeatures | fixEnforceNFTokenTrustline}) + { + Env env{*this, feats}; + env.fund(XRP(1000), issuer, becky, cheri, gw); + env.close(); + + // Set trust lines so becky and cheri can use gw's currency. + env(trust(becky, gwAUD(1000))); + env(trust(cheri, gwAUD(1000))); + env.close(); + env(pay(gw, cheri, gwAUD(500))); + env.close(); + + // issuer creates two NFTs: one with and one without AutoTrustLine. + std::uint16_t xferFee = 5000; // 5% + uint256 const nftAutoTrustID{token::getNextID( + env, issuer, 0u, tfTransferable | tfTrustLine, xferFee)}; + env(token::mint(issuer, 0u), + token::xferFee(xferFee), + txflags(tfTransferable | tfTrustLine)); + env.close(); + + uint256 const nftNoAutoTrustID{ + token::getNextID(env, issuer, 0u, tfTransferable, xferFee)}; + env(token::mint(issuer, 0u), + token::xferFee(xferFee), + txflags(tfTransferable)); + env.close(); + + // becky buys the nfts for 1 drop each. + { + uint256 const beckyBuyOfferIndex1 = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftAutoTrustID, drops(1)), + token::owner(issuer)); + + uint256 const beckyBuyOfferIndex2 = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), + token::owner(issuer)); + + env.close(); + env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex1)); + env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex2)); + env.close(); + } + + // becky creates offers to sell the nfts for AUD. + uint256 const beckyAutoTrustOfferIndex = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftAutoTrustID, gwAUD(100)), + txflags(tfSellNFToken)); + env.close(); + + // Creating an offer for the NFToken without tfTrustLine fails + // because issuer does not have a trust line for AUD. + env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), + txflags(tfSellNFToken), + ter(tecNO_LINE)); + env.close(); + + // issuer creates a trust line. Now the offer create for the + // NFToken without tfTrustLine succeeds. + BEAST_EXPECT(ownerCount(env, issuer) == 0); + env(trust(issuer, gwAUD(1000))); + env.close(); + BEAST_EXPECT(ownerCount(env, issuer) == 1); + + uint256 const beckyNoAutoTrustOfferIndex = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftNoAutoTrustID, gwAUD(100)), + txflags(tfSellNFToken)); + env.close(); + + // Now that the offers are in place, issuer removes the trustline. + BEAST_EXPECT(ownerCount(env, issuer) == 1); + env(trust(issuer, gwAUD(0))); + env.close(); + BEAST_EXPECT(ownerCount(env, issuer) == 0); + + // cheri attempts to accept becky's offers. Behavior with the + // AutoTrustline NFT is uniform: issuer gets a new trust line. + env(token::acceptSellOffer(cheri, beckyAutoTrustOfferIndex)); + env.close(); + + // Here's evidence that issuer got the new AUD trust line. + BEAST_EXPECT(ownerCount(env, issuer) == 1); + BEAST_EXPECT(env.balance(issuer, gwAUD) == gwAUD(5)); + + // issuer once again removes the trust line for AUD. + env(pay(issuer, gw, gwAUD(5))); + env.close(); + BEAST_EXPECT(ownerCount(env, issuer) == 0); + + // cheri attempts to accept the NoAutoTrustLine NFT. Behavior + // depends on whether fixEnforceNFTokenTrustline is enabled. + if (feats[fixEnforceNFTokenTrustline]) + { + // With fixEnforceNFTokenTrustline cheri can't accept the + // offer because issuer could not get their transfer fee + // without the appropriate trustline. + env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex), + ter(tecNO_LINE)); + env.close(); + + // But if issuer re-establishes the trustline then the offer + // can be accepted. + env(trust(issuer, gwAUD(1000))); + env.close(); + BEAST_EXPECT(ownerCount(env, issuer) == 1); + + env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex)); + env.close(); + } + else + { + // Without fixEnforceNFTokenTrustline the offer just works + // and issuer gets a trustline that they did not request. + env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex)); + env.close(); + } + BEAST_EXPECT(ownerCount(env, issuer) == 1); + BEAST_EXPECT(env.balance(issuer, gwAUD) == gwAUD(5)); + } // for feats + } + + void + testNFTIssuerIsIOUIssuer(FeatureBitset features) + { + testcase("Test fix NFT issuer is IOU issuer"); + + using namespace test::jtx; + + Account const issuer{"issuer"}; + Account const becky{"becky"}; + Account const cheri{"cheri"}; + IOU const isISU(issuer["ISU"]); + + // This test case covers issue... + // https://github.com/XRPLF/rippled/issues/4941 + // + // If an NFToken has a transfer fee then, when an offer is accepted, + // a portion of the sale price goes to the issuer. + // + // It is possible for an issuer to issue both an IOU (for remittances) + // and NFTokens. If the issuer's IOU is used to pay for the transfer + // of one of the issuer's NFTokens, then paying the fee for that + // transfer will fail with a tecNO_LINE. + // + // The problem occurs because the NFT code looks for a trust line to + // pay the transfer fee. However the issuer of an IOU does not need + // a trust line to accept their own issuance and, in fact, is not + // allowed to have a trust line to themselves. + // + // This test looks at a situation where transfer of an NFToken is + // prevented by this bug: + // 1. Issuer issues an IOU (e.g, isISU). + // 2. Becky and Cheri get trust lines for, and acquire, some isISU. + // 3. Issuer mints NFToken with transfer fee. + // 4. Becky acquires the NFToken, paying with XRP. + // 5. Becky attempts to create an offer to sell the NFToken for + // isISU(100). The attempt fails with `tecNO_LINE`. + // + // The featureNFTokenMintOffer amendment addresses this oversight. + // + // We remove the fixRemoveNFTokenAutoTrustLine amendment. Otherwise + // we can't create NFTokens with tfTrustLine enabled. + FeatureBitset const localFeatures = + features - fixRemoveNFTokenAutoTrustLine; + + Env env{*this, localFeatures}; + env.fund(XRP(1000), issuer, becky, cheri); + env.close(); + + // Set trust lines so becky and cheri can use isISU. + env(trust(becky, isISU(1000))); + env(trust(cheri, isISU(1000))); + env.close(); + env(pay(issuer, cheri, isISU(500))); + env.close(); + + // issuer creates two NFTs: one with and one without AutoTrustLine. + std::uint16_t xferFee = 5000; // 5% + uint256 const nftAutoTrustID{token::getNextID( + env, issuer, 0u, tfTransferable | tfTrustLine, xferFee)}; + env(token::mint(issuer, 0u), + token::xferFee(xferFee), + txflags(tfTransferable | tfTrustLine)); + env.close(); + + uint256 const nftNoAutoTrustID{ + token::getNextID(env, issuer, 0u, tfTransferable, xferFee)}; + env(token::mint(issuer, 0u), + token::xferFee(xferFee), + txflags(tfTransferable)); + env.close(); + + // becky buys the nfts for 1 drop each. + { + uint256 const beckyBuyOfferIndex1 = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftAutoTrustID, drops(1)), + token::owner(issuer)); + + uint256 const beckyBuyOfferIndex2 = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftNoAutoTrustID, drops(1)), + token::owner(issuer)); + + env.close(); + env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex1)); + env(token::acceptBuyOffer(issuer, beckyBuyOfferIndex2)); + env.close(); + } + + // Behavior from here down diverges significantly based on + // featureNFTokenMintOffer. + if (!localFeatures[featureNFTokenMintOffer]) + { + // Without featureNFTokenMintOffer becky simply can't + // create an offer for a non-tfTrustLine NFToken that would + // pay the transfer fee in issuer's own IOU. + env(token::createOffer(becky, nftNoAutoTrustID, isISU(100)), + txflags(tfSellNFToken), + ter(tecNO_LINE)); + env.close(); + + // And issuer can't create a trust line to themselves. + env(trust(issuer, isISU(1000)), ter(temDST_IS_SRC)); + env.close(); + + // However if the NFToken has the tfTrustLine flag set, + // then becky can create the offer. + uint256 const beckyAutoTrustOfferIndex = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftAutoTrustID, isISU(100)), + txflags(tfSellNFToken)); + env.close(); + + // And cheri can accept the offer. + env(token::acceptSellOffer(cheri, beckyAutoTrustOfferIndex)); + env.close(); + + // We verify that issuer got their transfer fee by seeing that + // ISU(5) has disappeared out of cheri's and becky's balances. + BEAST_EXPECT(env.balance(becky, isISU) == isISU(95)); + BEAST_EXPECT(env.balance(cheri, isISU) == isISU(400)); + } + else + { + // With featureNFTokenMintOffer things go better. + // becky creates offers to sell the nfts for ISU. + uint256 const beckyNoAutoTrustOfferIndex = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftNoAutoTrustID, isISU(100)), + txflags(tfSellNFToken)); + env.close(); + uint256 const beckyAutoTrustOfferIndex = + keylet::nftoffer(becky, env.seq(becky)).key; + env(token::createOffer(becky, nftAutoTrustID, isISU(100)), + txflags(tfSellNFToken)); + env.close(); + + // cheri accepts becky's offers. Behavior is uniform: + // issuer gets paid. + env(token::acceptSellOffer(cheri, beckyAutoTrustOfferIndex)); + env.close(); + + // We verify that issuer got their transfer fee by seeing that + // ISU(5) has disappeared out of cheri's and becky's balances. + BEAST_EXPECT(env.balance(becky, isISU) == isISU(95)); + BEAST_EXPECT(env.balance(cheri, isISU) == isISU(400)); + + env(token::acceptSellOffer(cheri, beckyNoAutoTrustOfferIndex)); + env.close(); + + // We verify that issuer got their transfer fee by seeing that + // an additional ISU(5) has disappeared out of cheri's and + // becky's balances. + BEAST_EXPECT(env.balance(becky, isISU) == isISU(190)); + BEAST_EXPECT(env.balance(cheri, isISU) == isISU(300)); + } + } + void testWithFeats(FeatureBitset features) { @@ -7144,8 +7776,11 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite testIOUWithTransferFee(features); testBrokeredSaleToSelf(features); testFixNFTokenRemint(features); + testFeatMintWithOffer(features); testTxJsonMetaFields(features); testFixNFTokenBuyerReserve(features); + testUnaskedForAutoTrustline(features); + testNFTIssuerIsIOUIssuer(features); } public: @@ -7156,15 +7791,17 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite static FeatureBitset const all{supported_amendments()}; static FeatureBitset const fixNFTDir{fixNFTokenDirV1}; - static std::array const feats{ + static std::array const feats{ all - fixNFTDir - fixNonFungibleTokensV1_2 - fixNFTokenRemint - - fixNFTokenReserve, + fixNFTokenReserve - featureNFTokenMintOffer, all - disallowIncoming - fixNonFungibleTokensV1_2 - - fixNFTokenRemint - fixNFTokenReserve, + fixNFTokenRemint - fixNFTokenReserve - featureNFTokenMintOffer, all - fixNonFungibleTokensV1_2 - fixNFTokenRemint - - fixNFTokenReserve, - all - fixNFTokenRemint - fixNFTokenReserve, - all - fixNFTokenReserve, + fixNFTokenReserve - featureNFTokenMintOffer, + all - fixNFTokenRemint - fixNFTokenReserve - + featureNFTokenMintOffer, + all - fixNFTokenReserve - featureNFTokenMintOffer, + all - featureNFTokenMintOffer, all}; if (BEAST_EXPECT(instance < feats.size())) @@ -7217,12 +7854,21 @@ class NFTokenWOTokenReserve_test : public NFTokenBaseUtil_test } }; +class NFTokenWOMintOffer_test : public NFTokenBaseUtil_test +{ + void + run() override + { + NFTokenBaseUtil_test::run(5); + } +}; + class NFTokenAllFeatures_test : public NFTokenBaseUtil_test { void run() override { - NFTokenBaseUtil_test::run(5, true); + NFTokenBaseUtil_test::run(6, true); } }; @@ -7231,6 +7877,7 @@ BEAST_DEFINE_TESTSUITE_PRIO(NFTokenDisallowIncoming, tx, ripple, 2); BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOfixV1, tx, ripple, 2); BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOTokenRemint, tx, ripple, 2); BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOTokenReserve, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(NFTokenWOMintOffer, tx, ripple, 2); BEAST_DEFINE_TESTSUITE_PRIO(NFTokenAllFeatures, tx, ripple, 2); } // namespace ripple diff --git a/src/test/app/NetworkID_test.cpp b/src/test/app/NetworkID_test.cpp index 8d1b891345d..2f02a1fd7d2 100644 --- a/src/test/app/NetworkID_test.cpp +++ b/src/test/app/NetworkID_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/OfferStream_test.cpp b/src/test/app/OfferStream_test.cpp index ce25481cde8..bf712503687 100644 --- a/src/test/app/OfferStream_test.cpp +++ b/src/test/app/OfferStream_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/app/Offer_test.cpp b/src/test/app/Offer_test.cpp index 95ffd9f3aee..2b4245a1ae4 100644 --- a/src/test/app/Offer_test.cpp +++ b/src/test/app/Offer_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include #include #include #include +#include +#include +#include namespace ripple { namespace test { @@ -1387,78 +1387,106 @@ class OfferBaseUtil_test : public beast::unit_test::suite using namespace jtx; - Env env{*this, features}; + // This is one of the few tests where fixReducedOffersV2 changes the + // results. So test both with and without fixReducedOffersV2. + for (FeatureBitset localFeatures : + {features - fixReducedOffersV2, features | fixReducedOffersV2}) + { + Env env{*this, localFeatures}; - auto const gw = Account{"gateway"}; - auto const alice = Account{"alice"}; - auto const bob = Account{"bob"}; - auto const USD = gw["USD"]; - auto const BTC = gw["BTC"]; + auto const gw = Account{"gateway"}; + auto const alice = Account{"alice"}; + auto const bob = Account{"bob"}; + auto const USD = gw["USD"]; + auto const BTC = gw["BTC"]; - // these *interesting* amounts were taken - // from the original JS test that was ported here - auto const gw_initial_balance = drops(1149999730); - auto const alice_initial_balance = drops(499946999680); - auto const bob_initial_balance = drops(10199999920); - auto const small_amount = - STAmount{bob["USD"].issue(), UINT64_C(2710505431213761), -33}; + // these *interesting* amounts were taken + // from the original JS test that was ported here + auto const gw_initial_balance = drops(1149999730); + auto const alice_initial_balance = drops(499946999680); + auto const bob_initial_balance = drops(10199999920); + auto const small_amount = + STAmount{bob["USD"].issue(), UINT64_C(2710505431213761), -33}; - env.fund(gw_initial_balance, gw); - env.fund(alice_initial_balance, alice); - env.fund(bob_initial_balance, bob); + env.fund(gw_initial_balance, gw); + env.fund(alice_initial_balance, alice); + env.fund(bob_initial_balance, bob); - env(rate(gw, 1.005)); + env(rate(gw, 1.005)); - env(trust(alice, USD(500))); - env(trust(bob, USD(50))); - env(trust(gw, alice["USD"](100))); + env(trust(alice, USD(500))); + env(trust(bob, USD(50))); + env(trust(gw, alice["USD"](100))); - env(pay(gw, alice, alice["USD"](50))); - env(pay(gw, bob, small_amount)); + env(pay(gw, alice, alice["USD"](50))); + env(pay(gw, bob, small_amount)); - env(offer(alice, USD(50), XRP(150000))); + env(offer(alice, USD(50), XRP(150000))); - // unfund the offer - env(pay(alice, gw, USD(100))); + // unfund the offer + env(pay(alice, gw, USD(100))); - // drop the trust line (set to 0) - env(trust(gw, alice["USD"](0))); + // drop the trust line (set to 0) + env(trust(gw, alice["USD"](0))); - // verify balances - auto jrr = ledgerEntryState(env, alice, gw, "USD"); - BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "50"); + // verify balances + auto jrr = ledgerEntryState(env, alice, gw, "USD"); + BEAST_EXPECT( + jrr[jss::node][sfBalance.fieldName][jss::value] == "50"); - jrr = ledgerEntryState(env, bob, gw, "USD"); - BEAST_EXPECT( - jrr[jss::node][sfBalance.fieldName][jss::value] == - "-2710505431213761e-33"); + jrr = ledgerEntryState(env, bob, gw, "USD"); + BEAST_EXPECT( + jrr[jss::node][sfBalance.fieldName][jss::value] == + "-2710505431213761e-33"); - // create crossing offer - env(offer(bob, XRP(2000), USD(1))); + // create crossing offer + std::uint32_t const bobOfferSeq = env.seq(bob); + env(offer(bob, XRP(2000), USD(1))); - // verify balances again. - // - // NOTE : - // Here a difference in the rounding modes of our two offer crossing - // algorithms becomes apparent. The old offer crossing would consume - // small_amount and transfer no XRP. The new offer crossing transfers - // a single drop, rather than no drops. - auto const crossingDelta = - features[featureFlowCross] ? drops(1) : drops(0); + if (localFeatures[featureFlowCross] && + localFeatures[fixReducedOffersV2]) + { + // With the rounding introduced by fixReducedOffersV2, bob's + // offer does not cross alice's offer and goes straight into + // the ledger. + jrr = ledgerEntryState(env, bob, gw, "USD"); + BEAST_EXPECT( + jrr[jss::node][sfBalance.fieldName][jss::value] == + "-2710505431213761e-33"); + + Json::Value const bobOffer = + ledgerEntryOffer(env, bob, bobOfferSeq)[jss::node]; + BEAST_EXPECT(bobOffer[sfTakerGets.jsonName][jss::value] == "1"); + BEAST_EXPECT(bobOffer[sfTakerPays.jsonName] == "2000000000"); + return; + } - jrr = ledgerEntryState(env, alice, gw, "USD"); - BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "50"); - BEAST_EXPECT( - env.balance(alice, xrpIssue()) == - alice_initial_balance - env.current()->fees().base * 3 - - crossingDelta); + // verify balances again. + // + // NOTE: + // Here a difference in the rounding modes of our two offer + // crossing algorithms becomes apparent. The old offer crossing + // would consume small_amount and transfer no XRP. The new offer + // crossing transfers a single drop, rather than no drops. + auto const crossingDelta = + localFeatures[featureFlowCross] ? drops(1) : drops(0); + + jrr = ledgerEntryState(env, alice, gw, "USD"); + BEAST_EXPECT( + jrr[jss::node][sfBalance.fieldName][jss::value] == "50"); + BEAST_EXPECT( + env.balance(alice, xrpIssue()) == + alice_initial_balance - env.current()->fees().base * 3 - + crossingDelta); - jrr = ledgerEntryState(env, bob, gw, "USD"); - BEAST_EXPECT(jrr[jss::node][sfBalance.fieldName][jss::value] == "0"); - BEAST_EXPECT( - env.balance(bob, xrpIssue()) == - bob_initial_balance - env.current()->fees().base * 2 + - crossingDelta); + jrr = ledgerEntryState(env, bob, gw, "USD"); + BEAST_EXPECT( + jrr[jss::node][sfBalance.fieldName][jss::value] == "0"); + BEAST_EXPECT( + env.balance(bob, xrpIssue()) == + bob_initial_balance - env.current()->fees().base * 2 + + crossingDelta); + } } void @@ -5439,12 +5467,12 @@ class Offer_manual_test : public OfferBaseUtil_test } }; -BEAST_DEFINE_TESTSUITE_PRIO(OfferBaseUtil, tx, ripple, 4); -BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFlowCross, tx, ripple, 4); -BEAST_DEFINE_TESTSUITE_PRIO(OfferWTakerDryOffer, tx, ripple, 4); -BEAST_DEFINE_TESTSUITE_PRIO(OfferWOSmallQOffers, tx, ripple, 4); -BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFillOrKill, tx, ripple, 4); -BEAST_DEFINE_TESTSUITE_PRIO(OfferAllFeatures, tx, ripple, 4); +BEAST_DEFINE_TESTSUITE_PRIO(OfferBaseUtil, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFlowCross, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(OfferWTakerDryOffer, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(OfferWOSmallQOffers, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(OfferWOFillOrKill, tx, ripple, 2); +BEAST_DEFINE_TESTSUITE_PRIO(OfferAllFeatures, tx, ripple, 2); BEAST_DEFINE_TESTSUITE_MANUAL_PRIO(Offer_manual, tx, ripple, 20); } // namespace test diff --git a/src/test/app/Oracle_test.cpp b/src/test/app/Oracle_test.cpp index f5488c793a1..c2f3c271265 100644 --- a/src/test/app/Oracle_test.cpp +++ b/src/test/app/Oracle_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { @@ -163,7 +163,7 @@ struct Oracle_test : public beast::unit_test::suite env.fund(XRP(1'000), owner); Oracle oracle(env, {.owner = owner}, false); - // Symbol class or provider not included on create + // Asset class or provider not included on create oracle.set(CreateArg{ .assetClass = std::nullopt, .provider = "provider", @@ -174,7 +174,7 @@ struct Oracle_test : public beast::unit_test::suite .uri = "URI", .err = ter(temMALFORMED)}); - // Symbol class or provider are included on update + // Asset class or provider are included on update // and don't match the current values oracle.set(CreateArg{}); BEAST_EXPECT(oracle.exists()); @@ -194,7 +194,7 @@ struct Oracle_test : public beast::unit_test::suite Oracle oracle(env, {.owner = owner}, false); // Fields too long - // Symbol class + // Asset class std::string assetClass(17, '0'); oracle.set( CreateArg{.assetClass = assetClass, .err = ter(temMALFORMED)}); @@ -203,6 +203,13 @@ struct Oracle_test : public beast::unit_test::suite oracle.set(CreateArg{.provider = large, .err = ter(temMALFORMED)}); // URI oracle.set(CreateArg{.uri = large, .err = ter(temMALFORMED)}); + // Empty field + // Asset class + oracle.set(CreateArg{.assetClass = "", .err = ter(temMALFORMED)}); + // provider + oracle.set(CreateArg{.provider = "", .err = ter(temMALFORMED)}); + // URI + oracle.set(CreateArg{.uri = "", .err = ter(temMALFORMED)}); } { @@ -224,6 +231,12 @@ struct Oracle_test : public beast::unit_test::suite // Invalid update time using namespace std::chrono; Env env(*this); + auto closeTime = [&]() { + return duration_cast( + env.current()->info().closeTime.time_since_epoch() - + 10'000s) + .count(); + }; env.fund(XRP(1'000), owner); Oracle oracle(env, {.owner = owner}); BEAST_EXPECT(oracle.exists()); @@ -231,20 +244,25 @@ struct Oracle_test : public beast::unit_test::suite // Less than the last close time - 300s oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = testStartTime.count() + 400 - 301, + .lastUpdateTime = static_cast(closeTime() - 301), .err = ter(tecINVALID_UPDATE_TIME)}); // Greater than last close time + 300s oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = testStartTime.count() + 400 + 301, + .lastUpdateTime = static_cast(closeTime() + 311), .err = ter(tecINVALID_UPDATE_TIME)}); oracle.set(UpdateArg{.series = {{"XRP", "USD", 740, 1}}}); - BEAST_EXPECT( - oracle.expectLastUpdateTime(testStartTime.count() + 450)); + BEAST_EXPECT(oracle.expectLastUpdateTime( + static_cast(testStartTime.count() + 450))); // Less than the previous lastUpdateTime oracle.set(UpdateArg{ .series = {{"XRP", "USD", 740, 1}}, - .lastUpdateTime = testStartTime.count() + 449, + .lastUpdateTime = static_cast(449), + .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), .err = ter(tecINVALID_UPDATE_TIME)}); } @@ -284,6 +302,38 @@ struct Oracle_test : public beast::unit_test::suite .series = {{"USD", "BTC", 740, maxPriceScale + 1}}, .err = ter(temMALFORMED)}); } + + { + // Updating token pair to add and delete + Env env(*this); + env.fund(XRP(1'000), owner); + Oracle oracle(env, {.owner = owner}); + oracle.set(UpdateArg{ + .series = + {{"XRP", "EUR", std::nullopt, std::nullopt}, + {"XRP", "EUR", 740, 1}}, + .err = ter(temMALFORMED)}); + // Delete token pair that doesn't exist in this oracle + oracle.set(UpdateArg{ + .series = {{"XRP", "EUR", std::nullopt, std::nullopt}}, + .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}}, + .err = ter(temMALFORMED)}); + } + + { + // Bad fee + Env env(*this); + env.fund(XRP(1'000), owner); + Oracle oracle( + env, {.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); + Oracle oracle1(env, {.owner = owner}); + oracle.set( + UpdateArg{.owner = owner, .fee = -1, .err = ter(temBAD_FEE)}); + } } void @@ -356,13 +406,19 @@ struct Oracle_test : public beast::unit_test::suite {.owner = bad, .seq = seq(1), .err = ter(terNO_ACCOUNT)}); } - // Invalid Sequence + // Invalid DocumentID oracle.remove({.documentID = 2, .err = ter(tecNO_ENTRY)}); // Invalid owner Account const invalid("invalid"); env.fund(XRP(1'000), invalid); oracle.remove({.owner = invalid, .err = ter(tecNO_ENTRY)}); + + // Invalid flags + oracle.remove({.flags = tfSellNFToken, .err = ter(temINVALID_FLAG)}); + + // Bad fee + oracle.remove({.fee = -1, .err = ter(temBAD_FEE)}); } void @@ -622,50 +678,6 @@ struct Oracle_test : public beast::unit_test::suite } } - void - testLedgerEntry() - { - testcase("Ledger Entry"); - using namespace jtx; - - Env env(*this); - std::vector accounts; - std::vector oracles; - for (int i = 0; i < 10; ++i) - { - Account const owner(std::string("owner") + std::to_string(i)); - env.fund(XRP(1'000), owner); - // different accounts can have the same asset pair - Oracle oracle(env, {.owner = owner, .documentID = i}); - accounts.push_back(owner.id()); - oracles.push_back(oracle.documentID()); - // same account can have different asset pair - Oracle oracle1(env, {.owner = owner, .documentID = i + 10}); - accounts.push_back(owner.id()); - oracles.push_back(oracle1.documentID()); - } - for (int i = 0; i < accounts.size(); ++i) - { - auto const jv = [&]() { - // document id is uint32 - if (i % 2) - return Oracle::ledgerEntry(env, accounts[i], oracles[i]); - // document id is string - return Oracle::ledgerEntry( - env, accounts[i], std::to_string(oracles[i])); - }(); - try - { - BEAST_EXPECT( - jv[jss::node][jss::Owner] == to_string(accounts[i])); - } - catch (...) - { - fail(); - } - } - } - public: void run() override @@ -683,7 +695,6 @@ struct Oracle_test : public beast::unit_test::suite all - featureMultiSignReserve - featureExpandedSignerList, all - featureExpandedSignerList}) testMultisig(features); - testLedgerEntry(); } }; diff --git a/src/test/app/OversizeMeta_test.cpp b/src/test/app/OversizeMeta_test.cpp index 554033eb531..0a7f42e1801 100644 --- a/src/test/app/OversizeMeta_test.cpp +++ b/src/test/app/OversizeMeta_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/Path_test.cpp b/src/test/app/Path_test.cpp index 0f9916cbcff..1db15388ff0 100644 --- a/src/test/app/Path_test.cpp +++ b/src/test/app/Path_test.cpp @@ -17,25 +17,25 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include #include namespace ripple { diff --git a/src/test/app/PayChan_test.cpp b/src/test/app/PayChan_test.cpp index a479e43b170..a8eae4a25ec 100644 --- a/src/test/app/PayChan_test.cpp +++ b/src/test/app/PayChan_test.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/PayStrand_test.cpp b/src/test/app/PayStrand_test.cpp index ae17b8e0d43..f00a7361292 100644 --- a/src/test/app/PayStrand_test.cpp +++ b/src/test/app/PayStrand_test.cpp @@ -15,20 +15,20 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/PseudoTx_test.cpp b/src/test/app/PseudoTx_test.cpp index 78ca7cc05b1..238041a17bc 100644 --- a/src/test/app/PseudoTx_test.cpp +++ b/src/test/app/PseudoTx_test.cpp @@ -15,11 +15,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/app/RCLCensorshipDetector_test.cpp b/src/test/app/RCLCensorshipDetector_test.cpp index 12bb3bbba3f..b5440b90903 100644 --- a/src/test/app/RCLCensorshipDetector_test.cpp +++ b/src/test/app/RCLCensorshipDetector_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/app/RCLValidations_test.cpp b/src/test/app/RCLValidations_test.cpp index 0380795a8ae..540d98bc1f1 100644 --- a/src/test/app/RCLValidations_test.cpp +++ b/src/test/app/RCLValidations_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/ReducedOffer_test.cpp b/src/test/app/ReducedOffer_test.cpp index f82efcb7fc8..a070051e435 100644 --- a/src/test/app/ReducedOffer_test.cpp +++ b/src/test/app/ReducedOffer_test.cpp @@ -17,10 +17,12 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include + +#include namespace ripple { namespace test { @@ -56,13 +58,11 @@ class ReducedOffer_test : public beast::unit_test::suite static void cleanupOldOffers( jtx::Env& env, - jtx::Account const& acct1, - jtx::Account const& acct2, - std::uint32_t acct1OfferSeq, - std::uint32_t acct2OfferSeq) + std::initializer_list> + list) { - env(offer_cancel(acct1, acct1OfferSeq)); - env(offer_cancel(acct2, acct2OfferSeq)); + for (auto [acct, offerSeq] : list) + env(offer_cancel(acct, offerSeq)); env.close(); } @@ -180,7 +180,8 @@ class ReducedOffer_test : public beast::unit_test::suite // In preparation for the next iteration make sure the two // offers are gone from the ledger. - cleanupOldOffers(env, alice, bob, aliceOfferSeq, bobOfferSeq); + cleanupOldOffers( + env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); return badRate; }; @@ -279,7 +280,7 @@ class ReducedOffer_test : public beast::unit_test::suite // If the in-ledger offer was not consumed then further // results are meaningless. cleanupOldOffers( - env, alice, bob, aliceOfferSeq, bobOfferSeq); + env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); return 1; } // alice's offer should still be in the ledger, but reduced in @@ -337,7 +338,8 @@ class ReducedOffer_test : public beast::unit_test::suite // In preparation for the next iteration make sure the two // offers are gone from the ledger. - cleanupOldOffers(env, alice, bob, aliceOfferSeq, bobOfferSeq); + cleanupOldOffers( + env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); return badRate; }; @@ -452,7 +454,7 @@ class ReducedOffer_test : public beast::unit_test::suite // In preparation for the next iteration clean up any // leftover offers. cleanupOldOffers( - env, alice, bob, aliceOfferSeq, bobOfferSeq); + env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); // Zero out alice's and bob's USD balances. if (STAmount const aliceBalance = env.balance(alice, USD); @@ -573,7 +575,8 @@ class ReducedOffer_test : public beast::unit_test::suite // In preparation for the next iteration clean up any // leftover offers. - cleanupOldOffers(env, alice, bob, aliceOfferSeq, bobOfferSeq); + cleanupOldOffers( + env, {{alice, aliceOfferSeq}, {bob, bobOfferSeq}}); // Zero out alice's and bob's IOU balances. auto zeroBalance = [&env, &gw]( @@ -606,6 +609,185 @@ class ReducedOffer_test : public beast::unit_test::suite } } + Amounts + jsonOfferToAmounts(Json::Value const& json) + { + STAmount const in = + amountFromJson(sfTakerPays, json[sfTakerPays.jsonName]); + STAmount const out = + amountFromJson(sfTakerGets, json[sfTakerGets.jsonName]); + return {in, out}; + } + + void + testSellPartialCrossOldXrpIouQChange() + { + // This test case was motivated by Issue #4937. It recreates + // the specific failure identified in that issue and samples some other + // cases in the same vicinity to make sure that the new behavior makes + // sense. + testcase("exercise tfSell partial cross old XRP/IOU offer Q change"); + + using namespace jtx; + + Account const gw("gateway"); + Account const alice("alice"); + Account const bob("bob"); + Account const carol("carol"); + auto const USD = gw["USD"]; + + // Make one test run without fixReducedOffersV2 and one with. + for (FeatureBitset features : + {supported_amendments() - fixReducedOffersV2, + supported_amendments() | fixReducedOffersV2}) + { + // Make sure none of the offers we generate are under funded. + Env env{*this, features}; + env.fund(XRP(10'000'000), gw, alice, bob, carol); + env.close(); + + env(trust(alice, USD(10'000'000))); + env(trust(bob, USD(10'000'000))); + env(trust(carol, USD(10'000'000))); + env.close(); + + env(pay(gw, alice, USD(10'000'000))); + env(pay(gw, bob, USD(10'000'000))); + env(pay(gw, carol, USD(10'000'000))); + env.close(); + + // Lambda that: + // 1. Exercises one offer trio, + // 2. Collects the results, and + // 3. Cleans up for the next offer trio. + auto exerciseOfferTrio = + [this, &env, &alice, &bob, &carol, &USD]( + Amounts const& carolOffer) -> unsigned int { + // alice submits an offer that may become a blocker. + std::uint32_t const aliceOfferSeq = env.seq(alice); + static Amounts const aliceInitialOffer(USD(2), drops(3382562)); + env(offer(alice, aliceInitialOffer.in, aliceInitialOffer.out)); + env.close(); + STAmount const initialRate = + Quality(jsonOfferToAmounts(ledgerEntryOffer( + env, alice, aliceOfferSeq)[jss::node])) + .rate(); + + // bob submits an offer that is more desirable than alice's + std::uint32_t const bobOfferSeq = env.seq(bob); + env(offer(bob, USD(0.97086565812384), drops(1642020))); + env.close(); + + // Now carol's offer consumes bob's and partially crosses + // alice's. The tfSell flag is important. + std::uint32_t const carolOfferSeq = env.seq(carol); + env(offer(carol, carolOffer.in, carolOffer.out), + txflags(tfSell)); + env.close(); + + // carol's offer should not have made it into the ledger and + // bob's offer should be fully consumed. + if (!BEAST_EXPECT( + !offerInLedger(env, carol, carolOfferSeq) && + !offerInLedger(env, bob, bobOfferSeq))) + { + // If carol's or bob's offers are still in the ledger then + // further results are meaningless. + cleanupOldOffers( + env, + {{alice, aliceOfferSeq}, + {bob, bobOfferSeq}, + {carol, carolOfferSeq}}); + return 1; + } + // alice's offer should still be in the ledger, but reduced in + // size. + unsigned int badRate = 1; + { + Json::Value aliceOffer = + ledgerEntryOffer(env, alice, aliceOfferSeq); + + Amounts aliceReducedOffer = + jsonOfferToAmounts(aliceOffer[jss::node]); + + BEAST_EXPECT(aliceReducedOffer.in < aliceInitialOffer.in); + BEAST_EXPECT(aliceReducedOffer.out < aliceInitialOffer.out); + STAmount const inLedgerRate = + Quality(aliceReducedOffer).rate(); + badRate = inLedgerRate > initialRate ? 1 : 0; + + // If the inLedgerRate is less than initial rate, then + // incrementing the mantissa of the reduced TakerGets + // should result in a rate higher than initial. Check + // this to verify that the largest allowable TakerGets + // was computed. + if (badRate == 0) + { + STAmount const tweakedTakerGets( + aliceReducedOffer.in.issue(), + aliceReducedOffer.in.mantissa() + 1, + aliceReducedOffer.in.exponent(), + aliceReducedOffer.in.negative()); + STAmount const tweakedRate = + Quality( + Amounts{aliceReducedOffer.in, tweakedTakerGets}) + .rate(); + BEAST_EXPECT(tweakedRate > initialRate); + } +#if 0 + std::cout << "Placed rate: " << initialRate + << "; in-ledger rate: " << inLedgerRate + << "; TakerPays: " << aliceReducedOffer.in + << "; TakerGets: " << aliceReducedOffer.out + << std::endl; +// #else + std::string_view filler = badRate ? "**" : " "; + std::cout << "| " << aliceReducedOffer.in << "` | `" + << aliceReducedOffer.out << "` | `" << initialRate + << "` | " << filler << "`" << inLedgerRate << "`" + << filler << std::endl; +#endif + } + + // In preparation for the next iteration make sure all three + // offers are gone from the ledger. + cleanupOldOffers( + env, + {{alice, aliceOfferSeq}, + {bob, bobOfferSeq}, + {carol, carolOfferSeq}}); + return badRate; + }; + + constexpr int loopCount = 100; + unsigned int blockedCount = 0; + { + STAmount increaseGets = USD(0); + STAmount const step(increaseGets.issue(), 1, -8); + for (unsigned int i = 0; i < loopCount; ++i) + { + blockedCount += exerciseOfferTrio( + Amounts(drops(1642020), USD(1) + increaseGets)); + increaseGets += step; + } + } + + // If fixReducedOffersV2 is enabled, then none of the test cases + // should produce a potentially blocking rate. + // + // Also verify that if fixReducedOffersV2 is not enabled then + // some of the test cases produced a potentially blocking rate. + if (features[fixReducedOffersV2]) + { + BEAST_EXPECT(blockedCount == 0); + } + else + { + BEAST_EXPECT(blockedCount > 80); + } + } + } + void run() override { @@ -613,6 +795,7 @@ class ReducedOffer_test : public beast::unit_test::suite testPartialCrossOldXrpIouQChange(); testUnderFundedXrpIouQChange(); testUnderFundedIouIouQChange(); + testSellPartialCrossOldXrpIouQChange(); } }; diff --git a/src/test/app/Regression_test.cpp b/src/test/app/Regression_test.cpp index f743a30f079..f54a88ace00 100644 --- a/src/test/app/Regression_test.cpp +++ b/src/test/app/Regression_test.cpp @@ -15,13 +15,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/SHAMapStore_test.cpp b/src/test/app/SHAMapStore_test.cpp index 8a47b186957..376cb4eb7ba 100644 --- a/src/test/app/SHAMapStore_test.cpp +++ b/src/test/app/SHAMapStore_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/SetAuth_test.cpp b/src/test/app/SetAuth_test.cpp index 8066ef0dacf..adb909314d3 100644 --- a/src/test/app/SetAuth_test.cpp +++ b/src/test/app/SetAuth_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/SetRegularKey_test.cpp b/src/test/app/SetRegularKey_test.cpp index 799b7797b85..024d8de137b 100644 --- a/src/test/app/SetRegularKey_test.cpp +++ b/src/test/app/SetRegularKey_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/app/SetTrust_test.cpp b/src/test/app/SetTrust_test.cpp index 599ac1917f9..57e18d712f8 100644 --- a/src/test/app/SetTrust_test.cpp +++ b/src/test/app/SetTrust_test.cpp @@ -16,9 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { @@ -29,6 +29,144 @@ class SetTrust_test : public beast::unit_test::suite FeatureBitset const disallowIncoming{featureDisallowIncoming}; public: + void + testTrustLineDelete() + { + testcase( + "Test deletion of trust lines: revert trust line limit to zero"); + + using namespace jtx; + Env env(*this); + + Account const alice = Account{"alice"}; + Account const becky = Account{"becky"}; + + env.fund(XRP(10000), becky, alice); + env.close(); + + // becky wants to hold at most 50 tokens of alice["USD"] + // becky is the customer, alice is the issuer + // becky can be sent at most 50 tokens of alice's USD + env(trust(becky, alice["USD"](50))); + env.close(); + + // Since the settings of the trust lines are non-default for both + // alice and becky, both of them will be charged an owner reserve + // Irrespective of whether the issuer or the customer initiated + // the trust-line creation, both will be charged + env.require(lines(alice, 1)); + env.require(lines(becky, 1)); + + // Fetch the trust-lines via RPC for verification + Json::Value jv; + jv["account"] = becky.human(); + auto beckyLines = env.rpc("json", "account_lines", to_string(jv)); + + jv["account"] = alice.human(); + auto aliceLines = env.rpc("json", "account_lines", to_string(jv)); + + BEAST_EXPECT(aliceLines[jss::result][jss::lines].size() == 1); + BEAST_EXPECT(beckyLines[jss::result][jss::lines].size() == 1); + + // reset the trust line limits to zero + env(trust(becky, alice["USD"](0))); + env.close(); + + // the reset of the trust line limits deletes the trust-line + // this occurs despite the authorization of the trust-line by the + // issuer(alice, in this unit test) + env.require(lines(becky, 0)); + env.require(lines(alice, 0)); + + // second verification check via RPC calls + jv["account"] = becky.human(); + beckyLines = env.rpc("json", "account_lines", to_string(jv)); + + jv["account"] = alice.human(); + aliceLines = env.rpc("json", "account_lines", to_string(jv)); + + BEAST_EXPECT(aliceLines[jss::result][jss::lines].size() == 0); + BEAST_EXPECT(beckyLines[jss::result][jss::lines].size() == 0); + + // additionally, verify that account_objects is an empty array + jv["account"] = becky.human(); + auto const beckyObj = env.rpc("json", "account_objects", to_string(jv)); + BEAST_EXPECT(beckyObj[jss::result][jss::account_objects].size() == 0); + + jv["account"] = alice.human(); + auto const aliceObj = env.rpc("json", "account_objects", to_string(jv)); + BEAST_EXPECT(aliceObj[jss::result][jss::account_objects].size() == 0); + } + + void + testTrustLineResetWithAuthFlag() + { + testcase( + "Reset trust line limit with Authorised Lines: Verify " + "deletion of trust lines"); + + using namespace jtx; + Env env(*this); + + Account const alice = Account{"alice"}; + Account const becky = Account{"becky"}; + + env.fund(XRP(10000), becky, alice); + env.close(); + + // alice wants to ensure that all holders of her tokens are authorised + env(fset(alice, asfRequireAuth)); + env.close(); + + // becky wants to hold at most 50 tokens of alice["USD"] + // becky is the customer, alice is the issuer + // becky can be sent at most 50 tokens of alice's USD + env(trust(becky, alice["USD"](50))); + env.close(); + + // alice authorizes becky to hold alice["USD"] tokens + env(trust(alice, alice["USD"](0), becky, tfSetfAuth)); + env.close(); + + // Since the settings of the trust lines are non-default for both + // alice and becky, both of them will be charged an owner reserve + // Irrespective of whether the issuer or the customer initiated + // the trust-line creation, both will be charged + env.require(lines(alice, 1)); + env.require(lines(becky, 1)); + + // Fetch the trust-lines via RPC for verification + Json::Value jv; + jv["account"] = becky.human(); + auto beckyLines = env.rpc("json", "account_lines", to_string(jv)); + + jv["account"] = alice.human(); + auto aliceLines = env.rpc("json", "account_lines", to_string(jv)); + + BEAST_EXPECT(aliceLines[jss::result][jss::lines].size() == 1); + BEAST_EXPECT(beckyLines[jss::result][jss::lines].size() == 1); + + // reset the trust line limits to zero + env(trust(becky, alice["USD"](0))); + env.close(); + + // the reset of the trust line limits deletes the trust-line + // this occurs despite the authorization of the trust-line by the + // issuer(alice, in this unit test) + env.require(lines(becky, 0)); + env.require(lines(alice, 0)); + + // second verification check via RPC calls + jv["account"] = becky.human(); + beckyLines = env.rpc("json", "account_lines", to_string(jv)); + + jv["account"] = alice.human(); + aliceLines = env.rpc("json", "account_lines", to_string(jv)); + + BEAST_EXPECT(aliceLines[jss::result][jss::lines].size() == 0); + BEAST_EXPECT(beckyLines[jss::result][jss::lines].size() == 0); + } + void testFreeTrustlines( FeatureBitset features, @@ -203,6 +341,100 @@ class SetTrust_test : public beast::unit_test::suite env(trust(alice, gw["USD"](100), tfSetfAuth), ter(tefNO_AUTH_REQUIRED)); } + void + testExceedTrustLineLimit() + { + testcase( + "Ensure that trust line limits are respected in payment " + "transactions"); + + using namespace jtx; + Env env{*this}; + + auto const gw = Account{"gateway"}; + auto const alice = Account{"alice"}; + env.fund(XRP(10000), gw, alice); + + // alice wants to hold at most 100 of gw's USD tokens + env(trust(alice, gw["USD"](100))); + env.close(); + + // send a payment for a large quantity through the trust line + env(pay(gw, alice, gw["USD"](200)), ter(tecPATH_PARTIAL)); + env.close(); + + // on the other hand, smaller payments should succeed + env(pay(gw, alice, gw["USD"](20))); + env.close(); + } + + void + testAuthFlagTrustLines() + { + testcase( + "Ensure that authorised trust lines do not allow payments " + "from unauthorised counter-parties"); + + using namespace jtx; + Env env{*this}; + + auto const bob = Account{"bob"}; + auto const alice = Account{"alice"}; + env.fund(XRP(10000), bob, alice); + + // alice wants to ensure that all holders of her tokens are authorised + env(fset(alice, asfRequireAuth)); + env.close(); + + // create a trust line from bob to alice. bob wants to hold at most + // 100 of alice's USD tokens. Note: alice hasn't authorised this + // trust line yet. + env(trust(bob, alice["USD"](100))); + env.close(); + + // send a payment from alice to bob, validate that the payment fails + env(pay(alice, bob, alice["USD"](10)), ter(tecPATH_DRY)); + env.close(); + } + + void + testTrustLineLimitsWithRippling() + { + testcase( + "Check that trust line limits are respected in conjunction " + "with rippling feature"); + + using namespace jtx; + Env env{*this}; + + auto const bob = Account{"bob"}; + auto const alice = Account{"alice"}; + env.fund(XRP(10000), bob, alice); + + // create a trust line from bob to alice. bob wants to hold at most + // 100 of alice's USD tokens. + env(trust(bob, alice["USD"](100))); + env.close(); + + // archetypical payment transaction from alice to bob must succeed + env(pay(alice, bob, alice["USD"](20)), ter(tesSUCCESS)); + env.close(); + + // Issued tokens are fungible. i.e. alice's USD is identical to bob's + // USD + env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS)); + env.close(); + + // bob cannot place alice in his debt i.e. alice's balance of the USD + // tokens cannot go below zero. + env(pay(bob, alice, bob["USD"](11)), ter(tecPATH_PARTIAL)); + env.close(); + + // payments that respect the trust line limits of alice should succeed + env(pay(bob, alice, bob["USD"](10)), ter(tesSUCCESS)); + env.close(); + } + void testModifyQualityOfTrustline( FeatureBitset features, @@ -402,6 +634,11 @@ class SetTrust_test : public beast::unit_test::suite testModifyQualityOfTrustline(features, true, false); testModifyQualityOfTrustline(features, true, true); testDisallowIncoming(features); + testTrustLineResetWithAuthFlag(); + testTrustLineDelete(); + testExceedTrustLineLimit(); + testAuthFlagTrustLines(); + testTrustLineLimitsWithRippling(); } public: diff --git a/src/test/app/Taker_test.cpp b/src/test/app/Taker_test.cpp index 0b69b25f24b..89e44b2b98b 100644 --- a/src/test/app/Taker_test.cpp +++ b/src/test/app/Taker_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/app/TheoreticalQuality_test.cpp b/src/test/app/TheoreticalQuality_test.cpp index ae537a45657..917d23377bf 100644 --- a/src/test/app/TheoreticalQuality_test.cpp +++ b/src/test/app/TheoreticalQuality_test.cpp @@ -17,20 +17,20 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/Ticket_test.cpp b/src/test/app/Ticket_test.cpp index b50059711ec..9467390502c 100644 --- a/src/test/app/Ticket_test.cpp +++ b/src/test/app/Ticket_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { diff --git a/src/test/app/Transaction_ordering_test.cpp b/src/test/app/Transaction_ordering_test.cpp index 0353df90663..928fcdb8389 100644 --- a/src/test/app/Transaction_ordering_test.cpp +++ b/src/test/app/Transaction_ordering_test.cpp @@ -15,9 +15,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/app/TrustAndBalance_test.cpp b/src/test/app/TrustAndBalance_test.cpp index 5b0c1d6480e..bf7c8629b69 100644 --- a/src/test/app/TrustAndBalance_test.cpp +++ b/src/test/app/TrustAndBalance_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/TxQ_test.cpp b/src/test/app/TxQ_test.cpp index 086bb787d68..e7b70203c91 100644 --- a/src/test/app/TxQ_test.cpp +++ b/src/test/app/TxQ_test.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/app/ValidatorKeys_test.cpp b/src/test/app/ValidatorKeys_test.cpp index 99bd6188261..9281ec4bd77 100644 --- a/src/test/app/ValidatorKeys_test.cpp +++ b/src/test/app/ValidatorKeys_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include diff --git a/src/test/app/ValidatorList_test.cpp b/src/test/app/ValidatorList_test.cpp index 638c2060d32..05989c0f601 100644 --- a/src/test/app/ValidatorList_test.cpp +++ b/src/test/app/ValidatorList_test.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/test/app/ValidatorSite_test.cpp b/src/test/app/ValidatorSite_test.cpp index 00512d157ec..4bc7f2f270d 100644 --- a/src/test/app/ValidatorSite_test.cpp +++ b/src/test/app/ValidatorSite_test.cpp @@ -17,25 +17,25 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include #include #include -#include -#include -#include namespace ripple { namespace test { diff --git a/src/test/app/XChain_test.cpp b/src/test/app/XChain_test.cpp index a0837782a9c..4f24d17601e 100644 --- a/src/test/app/XChain_test.cpp +++ b/src/test/app/XChain_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/app/tx/apply_test.cpp b/src/test/app/tx/apply_test.cpp index 61a512805a4..df76e839a71 100644 --- a/src/test/app/tx/apply_test.cpp +++ b/src/test/app/tx/apply_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { diff --git a/src/test/basics/Buffer_test.cpp b/src/test/basics/Buffer_test.cpp index 45d2147a054..da8bcc8f12c 100644 --- a/src/test/basics/Buffer_test.cpp +++ b/src/test/basics/Buffer_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/basics/DetectCrash_test.cpp b/src/test/basics/DetectCrash_test.cpp index 70f0bdb83be..1ae761f34a4 100644 --- a/src/test/basics/DetectCrash_test.cpp +++ b/src/test/basics/DetectCrash_test.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include diff --git a/src/test/basics/Expected_test.cpp b/src/test/basics/Expected_test.cpp index b89b9f6d309..d60809aee1f 100644 --- a/src/test/basics/Expected_test.cpp +++ b/src/test/basics/Expected_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #if BOOST_VERSION >= 107500 #include // Not part of boost before version 1.75 #endif // BOOST_VERSION diff --git a/src/test/basics/FeeUnits_test.cpp b/src/test/basics/FeeUnits_test.cpp index 3ded5812947..6608a072621 100644 --- a/src/test/basics/FeeUnits_test.cpp +++ b/src/test/basics/FeeUnits_test.cpp @@ -16,9 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/basics/FileUtilities_test.cpp b/src/test/basics/FileUtilities_test.cpp index 2a9710f8e95..2b84998da7c 100644 --- a/src/test/basics/FileUtilities_test.cpp +++ b/src/test/basics/FileUtilities_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { diff --git a/src/test/basics/IOUAmount_test.cpp b/src/test/basics/IOUAmount_test.cpp index a5f7d0456ad..6e7c662635f 100644 --- a/src/test/basics/IOUAmount_test.cpp +++ b/src/test/basics/IOUAmount_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/basics/KeyCache_test.cpp b/src/test/basics/KeyCache_test.cpp index 7f3f13e272d..eab0e87d0a7 100644 --- a/src/test/basics/KeyCache_test.cpp +++ b/src/test/basics/KeyCache_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/basics/Number_test.cpp b/src/test/basics/Number_test.cpp index 8c12ff7c5e4..cf626354e0f 100644 --- a/src/test/basics/Number_test.cpp +++ b/src/test/basics/Number_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/test/basics/PerfLog_test.cpp b/src/test/basics/PerfLog_test.cpp index f0a6645195b..756988cbdac 100644 --- a/src/test/basics/PerfLog_test.cpp +++ b/src/test/basics/PerfLog_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/basics/RangeSet_test.cpp b/src/test/basics/RangeSet_test.cpp index ccf76fad0d4..e0136ab8907 100644 --- a/src/test/basics/RangeSet_test.cpp +++ b/src/test/basics/RangeSet_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { class RangeSet_test : public beast::unit_test::suite diff --git a/src/test/basics/Slice_test.cpp b/src/test/basics/Slice_test.cpp index fb88315bd98..a169de98539 100644 --- a/src/test/basics/Slice_test.cpp +++ b/src/test/basics/Slice_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/basics/StringUtilities_test.cpp b/src/test/basics/StringUtilities_test.cpp index 6146a3dcd41..cf916c62651 100644 --- a/src/test/basics/StringUtilities_test.cpp +++ b/src/test/basics/StringUtilities_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/basics/TaggedCache_test.cpp b/src/test/basics/TaggedCache_test.cpp index 6a5b4429996..6fbba1a4795 100644 --- a/src/test/basics/TaggedCache_test.cpp +++ b/src/test/basics/TaggedCache_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/basics/XRPAmount_test.cpp b/src/test/basics/XRPAmount_test.cpp index 37c827180de..c4c96dbfbde 100644 --- a/src/test/basics/XRPAmount_test.cpp +++ b/src/test/basics/XRPAmount_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/basics/base58_test.cpp b/src/test/basics/base58_test.cpp index 6f3d495d7a9..f204cdd0e3a 100644 --- a/src/test/basics/base58_test.cpp +++ b/src/test/basics/base58_test.cpp @@ -19,9 +19,9 @@ #ifndef _MSC_VER -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/test/basics/base64_test.cpp b/src/test/basics/base64_test.cpp index d9622a8c28a..b6d67c7c069 100644 --- a/src/test/basics/base64_test.cpp +++ b/src/test/basics/base64_test.cpp @@ -26,8 +26,8 @@ // Official repository: https://github.com/boostorg/beast // -#include -#include +#include +#include namespace ripple { diff --git a/src/test/basics/base_uint_test.cpp b/src/test/basics/base_uint_test.cpp index 9b1f7696dd5..43000a1128c 100644 --- a/src/test/basics/base_uint_test.cpp +++ b/src/test/basics/base_uint_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/test/basics/contract_test.cpp b/src/test/basics/contract_test.cpp index 58844ba97f8..99f118794ee 100644 --- a/src/test/basics/contract_test.cpp +++ b/src/test/basics/contract_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace ripple { diff --git a/src/test/basics/hardened_hash_test.cpp b/src/test/basics/hardened_hash_test.cpp index 9296b7faf02..343894e52b0 100644 --- a/src/test/basics/hardened_hash_test.cpp +++ b/src/test/basics/hardened_hash_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include #include diff --git a/src/test/basics/join_test.cpp b/src/test/basics/join_test.cpp index 730fcb69343..1b094828243 100644 --- a/src/test/basics/join_test.cpp +++ b/src/test/basics/join_test.cpp @@ -19,8 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/basics/mulDiv_test.cpp b/src/test/basics/mulDiv_test.cpp index f51b91fecf4..47332fd45ba 100644 --- a/src/test/basics/mulDiv_test.cpp +++ b/src/test/basics/mulDiv_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/basics/scope_test.cpp b/src/test/basics/scope_test.cpp index 414e67b5c7e..654f7e0a11b 100644 --- a/src/test/basics/scope_test.cpp +++ b/src/test/basics/scope_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/basics/tagged_integer_test.cpp b/src/test/basics/tagged_integer_test.cpp index dd9d9022dde..22cdc5ad53f 100644 --- a/src/test/basics/tagged_integer_test.cpp +++ b/src/test/basics/tagged_integer_test.cpp @@ -18,8 +18,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace ripple { diff --git a/src/test/beast/IPEndpointCommon.h b/src/test/beast/IPEndpointCommon.h index bf8e7613fe5..aa2c1e597fb 100644 --- a/src/test/beast/IPEndpointCommon.h +++ b/src/test/beast/IPEndpointCommon.h @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace beast { namespace IP { diff --git a/src/test/beast/IPEndpoint_test.cpp b/src/test/beast/IPEndpoint_test.cpp index 1a29ddefa43..1ad49443dc3 100644 --- a/src/test/beast/IPEndpoint_test.cpp +++ b/src/test/beast/IPEndpoint_test.cpp @@ -20,13 +20,13 @@ // MODULES: ../impl/IPEndpoint.cpp ../impl/IPAddressV4.cpp // ../impl/IPAddressV6.cpp -#include -#include -#include +#include +#include +#include +#include #include #include #include -#include #include namespace beast { diff --git a/src/test/beast/LexicalCast_test.cpp b/src/test/beast/LexicalCast_test.cpp index 680dc6d69ac..22638f27e6e 100644 --- a/src/test/beast/LexicalCast_test.cpp +++ b/src/test/beast/LexicalCast_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace beast { diff --git a/src/test/beast/SemanticVersion_test.cpp b/src/test/beast/SemanticVersion_test.cpp index 5026f0fbae7..2f24a0c8926 100644 --- a/src/test/beast/SemanticVersion_test.cpp +++ b/src/test/beast/SemanticVersion_test.cpp @@ -16,8 +16,8 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include +#include +#include namespace beast { class SemanticVersion_test : public unit_test::suite diff --git a/src/test/beast/aged_associative_container_test.cpp b/src/test/beast/aged_associative_container_test.cpp index be17240811d..e5736764e06 100644 --- a/src/test/beast/aged_associative_container_test.cpp +++ b/src/test/beast/aged_associative_container_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/beast/beast_CurrentThreadName_test.cpp b/src/test/beast/beast_CurrentThreadName_test.cpp index 6e46808f4b2..653b0a89618 100644 --- a/src/test/beast/beast_CurrentThreadName_test.cpp +++ b/src/test/beast/beast_CurrentThreadName_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/beast/beast_Journal_test.cpp b/src/test/beast/beast_Journal_test.cpp index 9d3567c277d..6f1652381a0 100644 --- a/src/test/beast/beast_Journal_test.cpp +++ b/src/test/beast/beast_Journal_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace beast { diff --git a/src/test/beast/beast_PropertyStream_test.cpp b/src/test/beast/beast_PropertyStream_test.cpp index 2c4d32ce459..e91f527d3c9 100644 --- a/src/test/beast/beast_PropertyStream_test.cpp +++ b/src/test/beast/beast_PropertyStream_test.cpp @@ -16,8 +16,8 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include +#include +#include namespace beast { class PropertyStream_test : public unit_test::suite diff --git a/src/test/beast/beast_Zero_test.cpp b/src/test/beast/beast_Zero_test.cpp index 42b07343741..b6071636255 100644 --- a/src/test/beast/beast_Zero_test.cpp +++ b/src/test/beast/beast_Zero_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include +#include -#include +#include namespace beast { diff --git a/src/test/beast/beast_abstract_clock_test.cpp b/src/test/beast/beast_abstract_clock_test.cpp index eba9a3d77b1..a026df26376 100644 --- a/src/test/beast/beast_abstract_clock_test.cpp +++ b/src/test/beast/beast_abstract_clock_test.cpp @@ -19,9 +19,9 @@ // MODULES: ../impl/chrono_io.cpp -#include -#include -#include +#include +#include +#include #include #include #include diff --git a/src/test/beast/beast_basic_seconds_clock_test.cpp b/src/test/beast/beast_basic_seconds_clock_test.cpp index 5e55aab598b..f3926634dc4 100644 --- a/src/test/beast/beast_basic_seconds_clock_test.cpp +++ b/src/test/beast/beast_basic_seconds_clock_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include +#include -#include +#include namespace beast { diff --git a/src/test/beast/beast_io_latency_probe_test.cpp b/src/test/beast/beast_io_latency_probe_test.cpp index 32206ced7f7..96228194304 100644 --- a/src/test/beast/beast_io_latency_probe_test.cpp +++ b/src/test/beast/beast_io_latency_probe_test.cpp @@ -16,10 +16,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include +#include +#include -#include +#include #include #include diff --git a/src/test/beast/define_print.cpp b/src/test/beast/define_print.cpp index 3f527907a3f..0d36cd76982 100644 --- a/src/test/beast/define_print.cpp +++ b/src/test/beast/define_print.cpp @@ -5,9 +5,9 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include -#include -#include +#include +#include +#include #include // Include this .cpp in your project to gain access to the printing suite diff --git a/src/test/conditions/PreimageSha256_test.cpp b/src/test/conditions/PreimageSha256_test.cpp index cf4bc8c7c1e..9a6840b11c3 100644 --- a/src/test/conditions/PreimageSha256_test.cpp +++ b/src/test/conditions/PreimageSha256_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/consensus/ByzantineFailureSim_test.cpp b/src/test/consensus/ByzantineFailureSim_test.cpp index a907b7c224e..ce59adbe9f0 100644 --- a/src/test/consensus/ByzantineFailureSim_test.cpp +++ b/src/test/consensus/ByzantineFailureSim_test.cpp @@ -16,9 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include #include +#include +#include #include namespace ripple { diff --git a/src/test/consensus/Consensus_test.cpp b/src/test/consensus/Consensus_test.cpp index 5c7dc2626fe..88280994c10 100644 --- a/src/test/consensus/Consensus_test.cpp +++ b/src/test/consensus/Consensus_test.cpp @@ -16,12 +16,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include namespace ripple { @@ -806,7 +806,7 @@ class Consensus_test : public beast::unit_test::suite on(csf::PeerID who, csf::SimTime, csf::FullyValidateLedger const& e) { using namespace std::chrono; - // As soon as the the fastC node fully validates C, disconnect + // As soon as the fastC node fully validates C, disconnect // ALL c nodes from the network. The fast C node needs to disconnect // as well to prevent it from relaying the validations it did see if (who == groupCfast[0]->id && diff --git a/src/test/consensus/DistributedValidatorsSim_test.cpp b/src/test/consensus/DistributedValidatorsSim_test.cpp index ef1ae8b8722..3abac36b4f1 100644 --- a/src/test/consensus/DistributedValidatorsSim_test.cpp +++ b/src/test/consensus/DistributedValidatorsSim_test.cpp @@ -16,9 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include #include +#include +#include #include #include diff --git a/src/test/consensus/LedgerTiming_test.cpp b/src/test/consensus/LedgerTiming_test.cpp index 98b0548bf11..95e27f5c854 100644 --- a/src/test/consensus/LedgerTiming_test.cpp +++ b/src/test/consensus/LedgerTiming_test.cpp @@ -16,8 +16,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/consensus/LedgerTrie_test.cpp b/src/test/consensus/LedgerTrie_test.cpp index 3feb3b09959..6f13db43be2 100644 --- a/src/test/consensus/LedgerTrie_test.cpp +++ b/src/test/consensus/LedgerTrie_test.cpp @@ -16,10 +16,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include namespace ripple { diff --git a/src/test/consensus/NegativeUNL_test.cpp b/src/test/consensus/NegativeUNL_test.cpp index 8cbb57444bd..200cd166031 100644 --- a/src/test/consensus/NegativeUNL_test.cpp +++ b/src/test/consensus/NegativeUNL_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/consensus/ScaleFreeSim_test.cpp b/src/test/consensus/ScaleFreeSim_test.cpp index 4fe911eacf4..3e3cec97618 100644 --- a/src/test/consensus/ScaleFreeSim_test.cpp +++ b/src/test/consensus/ScaleFreeSim_test.cpp @@ -16,10 +16,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include #include #include +#include +#include #include namespace ripple { diff --git a/src/test/consensus/Validations_test.cpp b/src/test/consensus/Validations_test.cpp index 7dc2086e55c..0279d6330cc 100644 --- a/src/test/consensus/Validations_test.cpp +++ b/src/test/consensus/Validations_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/core/ClosureCounter_test.cpp b/src/test/core/ClosureCounter_test.cpp index c4199a0b06e..83d2fdb6e4a 100644 --- a/src/test/core/ClosureCounter_test.cpp +++ b/src/test/core/ClosureCounter_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include #include diff --git a/src/test/core/Config_test.cpp b/src/test/core/Config_test.cpp index c991f3b11a2..3cf77fba2ef 100644 --- a/src/test/core/Config_test.cpp +++ b/src/test/core/Config_test.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include namespace ripple { namespace detail { diff --git a/src/test/core/Coroutine_test.cpp b/src/test/core/Coroutine_test.cpp index 6d1e5e33304..0fdc5a4f49a 100644 --- a/src/test/core/Coroutine_test.cpp +++ b/src/test/core/Coroutine_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include +#include +#include #include #include #include -#include namespace ripple { namespace test { diff --git a/src/test/core/CryptoPRNG_test.cpp b/src/test/core/CryptoPRNG_test.cpp index 11bf9b7a161..303a2176315 100644 --- a/src/test/core/CryptoPRNG_test.cpp +++ b/src/test/core/CryptoPRNG_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include +#include +#include +#include #include #include #include -#include namespace ripple { diff --git a/src/test/core/JobQueue_test.cpp b/src/test/core/JobQueue_test.cpp index cba0217675c..42338063db3 100644 --- a/src/test/core/JobQueue_test.cpp +++ b/src/test/core/JobQueue_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/core/SociDB_test.cpp b/src/test/core/SociDB_test.cpp index c0365ad9ae7..82d0cbe9035 100644 --- a/src/test/core/SociDB_test.cpp +++ b/src/test/core/SociDB_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include -#include namespace ripple { class SociDB_test final : public TestSuite diff --git a/src/test/core/Workers_test.cpp b/src/test/core/Workers_test.cpp index 155dd14f030..3fac4808f9f 100644 --- a/src/test/core/Workers_test.cpp +++ b/src/test/core/Workers_test.cpp @@ -17,11 +17,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/csf/BasicNetwork.h b/src/test/csf/BasicNetwork.h index 3ce159a2333..a70ee6a3613 100644 --- a/src/test/csf/BasicNetwork.h +++ b/src/test/csf/BasicNetwork.h @@ -51,7 +51,7 @@ namespace csf { at either end of the connection will not be delivered. When creating the Peer set, the caller needs to provide a - Scheduler object for managing the the timing and delivery + Scheduler object for managing the timing and delivery of messages. After constructing the network, and establishing connections, the caller uses the scheduler's step_* functions to drive messages through the network. diff --git a/src/test/csf/BasicNetwork_test.cpp b/src/test/csf/BasicNetwork_test.cpp index f3b18216ac7..61660ae4c4e 100644 --- a/src/test/csf/BasicNetwork_test.cpp +++ b/src/test/csf/BasicNetwork_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include #include #include +#include +#include #include namespace ripple { diff --git a/src/test/csf/Digraph_test.cpp b/src/test/csf/Digraph_test.cpp index ac2063e49f2..80319445caf 100644 --- a/src/test/csf/Digraph_test.cpp +++ b/src/test/csf/Digraph_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include namespace ripple { diff --git a/src/test/csf/Histogram_test.cpp b/src/test/csf/Histogram_test.cpp index bf392ec8ac1..ea8b864780a 100644 --- a/src/test/csf/Histogram_test.cpp +++ b/src/test/csf/Histogram_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/csf/Peer.h b/src/test/csf/Peer.h index 6d3008f7348..5eed78569f6 100644 --- a/src/test/csf/Peer.h +++ b/src/test/csf/Peer.h @@ -19,13 +19,6 @@ #ifndef RIPPLE_TEST_CSF_PEER_H_INCLUDED #define RIPPLE_TEST_CSF_PEER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -33,6 +26,13 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/csf/PeerGroup.h b/src/test/csf/PeerGroup.h index 1f3421a4adb..b59bfa6763c 100644 --- a/src/test/csf/PeerGroup.h +++ b/src/test/csf/PeerGroup.h @@ -19,9 +19,9 @@ #ifndef RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED #define RIPPLE_TEST_CSF_PEERGROUP_H_INCLUDED -#include #include #include +#include #include namespace ripple { diff --git a/src/test/csf/Proposal.h b/src/test/csf/Proposal.h index d1cee16c1a7..1d70464bab5 100644 --- a/src/test/csf/Proposal.h +++ b/src/test/csf/Proposal.h @@ -19,10 +19,10 @@ #ifndef RIPPLE_TEST_CSF_PROPOSAL_H_INCLUDED #define RIPPLE_TEST_CSF_PROPOSAL_H_INCLUDED -#include #include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/csf/Scheduler.h b/src/test/csf/Scheduler.h index 2dc24222b26..62dff86402b 100644 --- a/src/test/csf/Scheduler.h +++ b/src/test/csf/Scheduler.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_CSF_SCHEDULER_H_INCLUDED #define RIPPLE_TEST_CSF_SCHEDULER_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/test/csf/Scheduler_test.cpp b/src/test/csf/Scheduler_test.cpp index ac9fab2534b..931150bbeb2 100644 --- a/src/test/csf/Scheduler_test.cpp +++ b/src/test/csf/Scheduler_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include diff --git a/src/test/csf/SimTime.h b/src/test/csf/SimTime.h index 2e18a5f9ee5..930338108e1 100644 --- a/src/test/csf/SimTime.h +++ b/src/test/csf/SimTime.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TEST_CSF_SIMTIME_H_INCLUDED #define RIPPLE_TEST_CSF_SIMTIME_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/test/csf/TrustGraph.h b/src/test/csf/TrustGraph.h index 31bb8534037..649f210646f 100644 --- a/src/test/csf/TrustGraph.h +++ b/src/test/csf/TrustGraph.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_CSF_UNL_H_INCLUDED #define RIPPLE_TEST_CSF_UNL_H_INCLUDED -#include #include +#include #include #include diff --git a/src/test/csf/Tx.h b/src/test/csf/Tx.h index 7f3645a59e6..b21481dcbf9 100644 --- a/src/test/csf/Tx.h +++ b/src/test/csf/Tx.h @@ -18,8 +18,8 @@ //============================================================================== #ifndef RIPPLE_TEST_CSF_TX_H_INCLUDED #define RIPPLE_TEST_CSF_TX_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/test/csf/Validation.h b/src/test/csf/Validation.h index aacb155fb1f..57c2bc66681 100644 --- a/src/test/csf/Validation.h +++ b/src/test/csf/Validation.h @@ -19,8 +19,8 @@ #ifndef RIPPLE_TEST_CSF_VALIDATION_H_INCLUDED #define RIPPLE_TEST_CSF_VALIDATION_H_INCLUDED -#include #include +#include #include #include diff --git a/src/test/csf/collectors.h b/src/test/csf/collectors.h index 352aa4cb8c2..511fb2c4b0f 100644 --- a/src/test/csf/collectors.h +++ b/src/test/csf/collectors.h @@ -19,10 +19,10 @@ #ifndef RIPPLE_TEST_CSF_COLLECTORS_H_INCLUDED #define RIPPLE_TEST_CSF_COLLECTORS_H_INCLUDED -#include #include #include #include +#include #include #include diff --git a/src/test/csf/events.h b/src/test/csf/events.h index cdda88cd094..37d1b4b0bd7 100644 --- a/src/test/csf/events.h +++ b/src/test/csf/events.h @@ -19,11 +19,11 @@ #ifndef RIPPLE_TEST_CSF_EVENTS_H_INCLUDED #define RIPPLE_TEST_CSF_EVENTS_H_INCLUDED -#include #include #include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/csf/impl/ledgers.cpp b/src/test/csf/impl/ledgers.cpp index ccc767008a7..775ec2e58b1 100644 --- a/src/test/csf/impl/ledgers.cpp +++ b/src/test/csf/impl/ledgers.cpp @@ -16,8 +16,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include #include +#include #include diff --git a/src/test/csf/ledgers.h b/src/test/csf/ledgers.h index 987c5e706c6..1c8d4eb54c6 100644 --- a/src/test/csf/ledgers.h +++ b/src/test/csf/ledgers.h @@ -19,16 +19,16 @@ #ifndef RIPPLE_TEST_CSF_LEDGERS_H_INCLUDED #define RIPPLE_TEST_CSF_LEDGERS_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include namespace ripple { namespace test { diff --git a/src/test/csf/timers.h b/src/test/csf/timers.h index b2a2b5a2da5..7e5d88c6696 100644 --- a/src/test/csf/timers.h +++ b/src/test/csf/timers.h @@ -19,10 +19,10 @@ #ifndef RIPPLE_TEST_CSF_TIMERS_H_INCLUDED #define RIPPLE_TEST_CSF_TIMERS_H_INCLUDED -#include -#include #include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/json/Object_test.cpp b/src/test/json/Object_test.cpp index bfdb6427059..4a64d6538a3 100644 --- a/src/test/json/Object_test.cpp +++ b/src/test/json/Object_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace Json { diff --git a/src/test/json/Output_test.cpp b/src/test/json/Output_test.cpp index 670f9c191f0..ddc5f08992b 100644 --- a/src/test/json/Output_test.cpp +++ b/src/test/json/Output_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace Json { diff --git a/src/test/json/TestOutputSuite.h b/src/test/json/TestOutputSuite.h index 0634f42a796..a4f36dac4ee 100644 --- a/src/test/json/TestOutputSuite.h +++ b/src/test/json/TestOutputSuite.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED #define RIPPLE_RPC_TESTOUTPUTSUITE_H_INCLUDED -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/json/Writer_test.cpp b/src/test/json/Writer_test.cpp index 99450ffeec5..97d4297c926 100644 --- a/src/test/json/Writer_test.cpp +++ b/src/test/json/Writer_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace Json { diff --git a/src/test/json/json_value_test.cpp b/src/test/json/json_value_test.cpp index 543a91a8a06..dacc22cc014 100644 --- a/src/test/json/json_value_test.cpp +++ b/src/test/json/json_value_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/jtx.h b/src/test/jtx.h index e6651fc1f0d..a3255ef3af9 100644 --- a/src/test/jtx.h +++ b/src/test/jtx.h @@ -22,7 +22,6 @@ // Convenience header that includes everything -#include #include #include #include @@ -66,5 +65,6 @@ #include #include #include +#include #endif diff --git a/src/test/jtx/AMM.h b/src/test/jtx/AMM.h index b98065a077e..77b9c8c9ec6 100644 --- a/src/test/jtx/AMM.h +++ b/src/test/jtx/AMM.h @@ -20,15 +20,15 @@ #ifndef RIPPLE_TEST_JTX_AMM_H_INCLUDED #define RIPPLE_TEST_JTX_AMM_H_INCLUDED -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include namespace ripple { namespace test { @@ -174,7 +174,8 @@ class AMM std::optional issue1 = std::nullopt, std::optional issue2 = std::nullopt, std::optional const& ammAccount = std::nullopt, - bool ignoreParams = false) const; + bool ignoreParams = false, + unsigned apiVersion = RPC::apiInvalidVersion) const; /** Verify the AMM balances. */ diff --git a/src/test/jtx/AMMTest.h b/src/test/jtx/AMMTest.h index 7831713382f..0481dc98a49 100644 --- a/src/test/jtx/AMMTest.h +++ b/src/test/jtx/AMMTest.h @@ -19,11 +19,11 @@ #ifndef RIPPLE_TEST_JTX_AMMTEST_H_INCLUDED #define RIPPLE_TEST_JTX_AMMTEST_H_INCLUDED -#include -#include #include #include #include +#include +#include namespace ripple { namespace test { @@ -84,7 +84,7 @@ class AMMTestBase : public beast::unit_test::suite std::optional> const& pool = std::nullopt, std::uint16_t tfee = 0, std::optional const& ter = std::nullopt, - std::optional const& features = std::nullopt); + std::vector const& features = {supported_amendments()}); }; class AMMTest : public jtx::AMMTestBase diff --git a/src/test/jtx/AbstractClient.h b/src/test/jtx/AbstractClient.h index 672ce422f0e..b447b9dedb1 100644 --- a/src/test/jtx/AbstractClient.h +++ b/src/test/jtx/AbstractClient.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TEST_ABSTRACTCLIENT_H_INCLUDED #define RIPPLE_TEST_ABSTRACTCLIENT_H_INCLUDED -#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/Account.h b/src/test/jtx/Account.h index cca92e76fe0..bcf117d9357 100644 --- a/src/test/jtx/Account.h +++ b/src/test/jtx/Account.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_TEST_JTX_ACCOUNT_H_INCLUDED #define RIPPLE_TEST_JTX_ACCOUNT_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/test/jtx/CaptureLogs.h b/src/test/jtx/CaptureLogs.h index 9a64396ab7f..62bf25bda90 100644 --- a/src/test/jtx/CaptureLogs.h +++ b/src/test/jtx/CaptureLogs.h @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/CheckMessageLogs.h b/src/test/jtx/CheckMessageLogs.h index 66f5f7e106c..dc3253278cd 100644 --- a/src/test/jtx/CheckMessageLogs.h +++ b/src/test/jtx/CheckMessageLogs.h @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index 0f21bff9fb6..2c5f2f37062 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -20,25 +20,6 @@ #ifndef RIPPLE_TEST_JTX_ENV_H_INCLUDED #define RIPPLE_TEST_JTX_ENV_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -48,6 +29,25 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/jtx/Env_test.cpp b/src/test/jtx/Env_test.cpp index 5c08469e0b8..691f96c2591 100644 --- a/src/test/jtx/Env_test.cpp +++ b/src/test/jtx/Env_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/jtx/JSONRPCClient.h b/src/test/jtx/JSONRPCClient.h index bfd3154579e..bbffc726694 100644 --- a/src/test/jtx/JSONRPCClient.h +++ b/src/test/jtx/JSONRPCClient.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TEST_HTTPCLIENT_H_INCLUDED #define RIPPLE_TEST_HTTPCLIENT_H_INCLUDED -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/JTx.h b/src/test/jtx/JTx.h index 2eeb6ccf8f4..a5a4a9eb1b9 100644 --- a/src/test/jtx/JTx.h +++ b/src/test/jtx/JTx.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_TEST_JTX_JTX_H_INCLUDED #define RIPPLE_TEST_JTX_JTX_H_INCLUDED -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include #include diff --git a/src/test/jtx/ManualTimeKeeper.h b/src/test/jtx/ManualTimeKeeper.h index f3adb29b5f0..86477bf99f6 100644 --- a/src/test/jtx/ManualTimeKeeper.h +++ b/src/test/jtx/ManualTimeKeeper.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TEST_MANUALTIMEKEEPER_H_INCLUDED #define RIPPLE_TEST_MANUALTIMEKEEPER_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/test/jtx/Oracle.h b/src/test/jtx/Oracle.h index f6fdbbff34a..32ec0b2e859 100644 --- a/src/test/jtx/Oracle.h +++ b/src/test/jtx/Oracle.h @@ -20,14 +20,36 @@ #ifndef RIPPLE_TEST_JTX_ORACLE_H_INCLUDED #define RIPPLE_TEST_JTX_ORACLE_H_INCLUDED -#include #include +#include namespace ripple { namespace test { namespace jtx { namespace oracle { +using AnyValue = std::variant; +using OraclesData = + std::vector, std::optional>>; + +// Special string value, which is converted to unquoted string in the string +// passed to rpc. +constexpr char const* NoneTag = "%None%"; +constexpr char const* UnquotedNone = "None"; +constexpr char const* NonePattern = "\"%None%\""; + +std::uint32_t +asUInt(AnyValue const& v); + +bool +validDocumentID(AnyValue const& v); + +void +toJson(Json::Value& jv, AnyValue const& v); + +void +toJsonHex(Json::Value& jv, AnyValue const& v); + // base asset, quote asset, price, scale using DataSeries = std::vector owner = std::nullopt; - std::optional documentID = 1; + std::optional documentID = 1; DataSeries series = {{"XRP", "USD", 740, 1}}; - std::optional assetClass = "currency"; - std::optional provider = "provider"; - std::optional uri = "URI"; - std::optional lastUpdateTime = std::nullopt; + std::optional assetClass = "currency"; + std::optional provider = "provider"; + std::optional uri = "URI"; + std::optional lastUpdateTime = std::nullopt; std::uint32_t flags = 0; std::optional msig = std::nullopt; std::optional seq = std::nullopt; - std::uint32_t fee = 10; + int fee = 10; std::optional err = std::nullopt; bool close = false; }; @@ -57,26 +79,27 @@ struct CreateArg struct UpdateArg { std::optional owner = std::nullopt; - std::optional documentID = std::nullopt; + std::optional documentID = std::nullopt; DataSeries series = {}; - std::optional assetClass = std::nullopt; - std::optional provider = std::nullopt; - std::optional uri = "URI"; - std::optional lastUpdateTime = std::nullopt; + std::optional assetClass = std::nullopt; + std::optional provider = std::nullopt; + std::optional uri = "URI"; + std::optional lastUpdateTime = std::nullopt; std::uint32_t flags = 0; std::optional msig = std::nullopt; std::optional seq = std::nullopt; - std::uint32_t fee = 10; + int fee = 10; std::optional err = std::nullopt; }; struct RemoveArg { std::optional const& owner = std::nullopt; - std::optional const& documentID = std::nullopt; + std::optional const& documentID = std::nullopt; + std::uint32_t flags = 0; std::optional const& msig = std::nullopt; std::optional seq = std::nullopt; - std::uint32_t fee = 10; + int fee = 10; std::optional const& err = std::nullopt; }; @@ -123,12 +146,11 @@ class Oracle static Json::Value aggregatePrice( Env& env, - std::optional const& baseAsset, - std::optional const& quoteAsset, - std::optional>> const& - oracles = std::nullopt, - std::optional const& trim = std::nullopt, - std::optional const& timeTreshold = std::nullopt); + std::optional const& baseAsset, + std::optional const& quoteAsset, + std::optional const& oracles = std::nullopt, + std::optional const& trim = std::nullopt, + std::optional const& timeTreshold = std::nullopt); std::uint32_t documentID() const @@ -154,8 +176,8 @@ class Oracle static Json::Value ledgerEntry( Env& env, - AccountID const& account, - std::variant const& documentID, + std::optional> const& account, + std::optional const& documentID, std::optional const& index = std::nullopt); Json::Value diff --git a/src/test/jtx/PathSet.h b/src/test/jtx/PathSet.h index f578ceb190d..0f4c4ddd3dd 100644 --- a/src/test/jtx/PathSet.h +++ b/src/test/jtx/PathSet.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_LEDGER_TESTS_PATHSET_H_INCLUDED #define RIPPLE_LEDGER_TESTS_PATHSET_H_INCLUDED -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/TestHelpers.h b/src/test/jtx/TestHelpers.h index b065cec470a..800662aa05b 100644 --- a/src/test/jtx/TestHelpers.h +++ b/src/test/jtx/TestHelpers.h @@ -19,13 +19,13 @@ #ifndef RIPPLE_TEST_JTX_TESTHELPERS_H_INCLUDED #define RIPPLE_TEST_JTX_TESTHELPERS_H_INCLUDED -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include diff --git a/src/test/jtx/TestSuite.h b/src/test/jtx/TestSuite.h index 9bd8d50ab57..22b8fb7e53b 100644 --- a/src/test/jtx/TestSuite.h +++ b/src/test/jtx/TestSuite.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_BASICS_TESTSUITE_H_INCLUDED #define RIPPLE_BASICS_TESTSUITE_H_INCLUDED -#include +#include #include namespace ripple { diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index da7ea1c137a..a10b9999ad2 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -19,12 +19,13 @@ #ifndef RIPPLE_TEST_TRUSTED_PUBLISHER_SERVER_H_INCLUDED #define RIPPLE_TEST_TRUSTED_PUBLISHER_SERVER_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include @@ -574,7 +574,7 @@ xbEQ+TUZ5jbJGSeBqNFKFeuOUQGJ46Io0jBSYd4rSmKUXkvElQwR+n7KF3jy1uAt if (ec) break; - std::string path = req.target(); + std::string_view const path = req.target(); res.insert("Server", "TrustedPublisherServer"); res.version(req.version()); res.keep_alive(req.keep_alive()); @@ -677,7 +677,9 @@ xbEQ+TUZ5jbJGSeBqNFKFeuOUQGJ46Io0jBSYd4rSmKUXkvElQwR+n7KF3jy1uAt // unknown request res.result(boost::beast::http::status::not_found); res.insert("Content-Type", "text/html"); - res.body() = "The file '" + path + "' was not found"; + res.body() = "The file '" + std::string(path) + + "' was not " + "found"; } if (prepare) diff --git a/src/test/jtx/WSClient.h b/src/test/jtx/WSClient.h index 8961522a038..d0356dbcbf7 100644 --- a/src/test/jtx/WSClient.h +++ b/src/test/jtx/WSClient.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_WSCLIENT_H_INCLUDED #define RIPPLE_TEST_WSCLIENT_H_INCLUDED -#include #include +#include #include #include diff --git a/src/test/jtx/WSClient_test.cpp b/src/test/jtx/WSClient_test.cpp index 85440003ba4..18dadb0bf9a 100644 --- a/src/test/jtx/WSClient_test.cpp +++ b/src/test/jtx/WSClient_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/amount.h b/src/test/jtx/amount.h index f8a8f67c75e..c8e0d0c3701 100644 --- a/src/test/jtx/amount.h +++ b/src/test/jtx/amount.h @@ -20,16 +20,16 @@ #ifndef RIPPLE_TEST_JTX_AMOUNT_H_INCLUDED #define RIPPLE_TEST_JTX_AMOUNT_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/jtx/attester.h b/src/test/jtx/attester.h index 7741991b752..327fb2e4873 100644 --- a/src/test/jtx/attester.h +++ b/src/test/jtx/attester.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_ATTESTER_H_INCLUDED #define RIPPLE_TEST_JTX_ATTESTER_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/test/jtx/delivermin.h b/src/test/jtx/delivermin.h index 579b66e97ff..46e633dab20 100644 --- a/src/test/jtx/delivermin.h +++ b/src/test/jtx/delivermin.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_DELIVERMIN_H_INCLUDED #define RIPPLE_TEST_JTX_DELIVERMIN_H_INCLUDED -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/envconfig.h b/src/test/jtx/envconfig.h index 02c99c52f09..259b61b6caf 100644 --- a/src/test/jtx/envconfig.h +++ b/src/test/jtx/envconfig.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_TEST_JTX_ENVCONFIG_H_INCLUDED #define RIPPLE_TEST_JTX_ENVCONFIG_H_INCLUDED -#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/fee.h b/src/test/jtx/fee.h index 58813409edd..c671e0b2a1e 100644 --- a/src/test/jtx/fee.h +++ b/src/test/jtx/fee.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_TEST_JTX_FEE_H_INCLUDED #define RIPPLE_TEST_JTX_FEE_H_INCLUDED -#include -#include #include #include +#include +#include #include diff --git a/src/test/jtx/flags.h b/src/test/jtx/flags.h index 27b6ea95611..c8887cdee4b 100644 --- a/src/test/jtx/flags.h +++ b/src/test/jtx/flags.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_TEST_JTX_FLAGS_H_INCLUDED #define RIPPLE_TEST_JTX_FLAGS_H_INCLUDED -#include -#include -#include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/AMM.cpp b/src/test/jtx/impl/AMM.cpp index 38cdb201854..c083b6df35c 100644 --- a/src/test/jtx/impl/AMM.cpp +++ b/src/test/jtx/impl/AMM.cpp @@ -19,12 +19,12 @@ #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { namespace test { @@ -163,7 +163,8 @@ AMM::ammRpcInfo( std::optional issue1, std::optional issue2, std::optional const& ammAccount, - bool ignoreParams) const + bool ignoreParams, + unsigned apiVersion) const { Json::Value jv; if (account) @@ -191,7 +192,10 @@ AMM::ammRpcInfo( if (ammAccount) jv[jss::amm_account] = to_string(*ammAccount); } - auto jr = env_.rpc("json", "amm_info", to_string(jv)); + auto jr = + (apiVersion == RPC::apiInvalidVersion + ? env_.rpc("json", "amm_info", to_string(jv)) + : env_.rpc(apiVersion, "json", "amm_info", to_string(jv))); if (jr.isObject() && jr.isMember(jss::result) && jr[jss::result].isMember(jss::status)) return jr[jss::result]; diff --git a/src/test/jtx/impl/AMMTest.cpp b/src/test/jtx/impl/AMMTest.cpp index 2c384a7d6f4..575e2e1d889 100644 --- a/src/test/jtx/impl/AMMTest.cpp +++ b/src/test/jtx/impl/AMMTest.cpp @@ -19,13 +19,13 @@ #include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include namespace ripple { namespace test { @@ -103,44 +103,50 @@ AMMTestBase::testAMM( std::optional> const& pool, std::uint16_t tfee, std::optional const& ter, - std::optional const& features) + std::vector const& vfeatures) { using namespace jtx; - auto env = [&]() { - if (features) - return Env{*this, *features}; - return Env{*this}; - }(); - auto const [asset1, asset2] = - pool ? *pool : std::make_pair(XRP(10000), USD(10000)); - auto tofund = [&](STAmount const& a) -> STAmount { - if (a.native()) - { - auto const defXRP = XRP(30000); - if (a <= defXRP) - return defXRP; - return a + XRP(1000); - } - auto const defIOU = STAmount{a.issue(), 30000}; - if (a <= defIOU) - return defIOU; - return a + STAmount{a.issue(), 1000}; - }; - auto const toFund1 = tofund(asset1); - auto const toFund2 = tofund(asset2); - BEAST_EXPECT(asset1 <= toFund1 && asset2 <= toFund2); + for (auto const& features : vfeatures) + { + Env env{*this, features}; - if (!asset1.native() && !asset2.native()) - fund(env, gw, {alice, carol}, {toFund1, toFund2}, Fund::All); - else if (asset1.native()) - fund(env, gw, {alice, carol}, toFund1, {toFund2}, Fund::All); - else if (asset2.native()) - fund(env, gw, {alice, carol}, toFund2, {toFund1}, Fund::All); + auto const [asset1, asset2] = + pool ? *pool : std::make_pair(XRP(10000), USD(10000)); + auto tofund = [&](STAmount const& a) -> STAmount { + if (a.native()) + { + auto const defXRP = XRP(30000); + if (a <= defXRP) + return defXRP; + return a + XRP(1000); + } + auto const defIOU = STAmount{a.issue(), 30000}; + if (a <= defIOU) + return defIOU; + return a + STAmount{a.issue(), 1000}; + }; + auto const toFund1 = tofund(asset1); + auto const toFund2 = tofund(asset2); + BEAST_EXPECT(asset1 <= toFund1 && asset2 <= toFund2); + + if (!asset1.native() && !asset2.native()) + fund(env, gw, {alice, carol}, {toFund1, toFund2}, Fund::All); + else if (asset1.native()) + fund(env, gw, {alice, carol}, toFund1, {toFund2}, Fund::All); + else if (asset2.native()) + fund(env, gw, {alice, carol}, toFund2, {toFund1}, Fund::All); - AMM ammAlice(env, alice, asset1, asset2, false, tfee); - BEAST_EXPECT(ammAlice.expectBalances(asset1, asset2, ammAlice.tokens())); - cb(ammAlice, env); + AMM ammAlice( + env, + alice, + asset1, + asset2, + CreateArg{.log = false, .tfee = tfee, .err = ter}); + if (BEAST_EXPECT( + ammAlice.expectBalances(asset1, asset2, ammAlice.tokens()))) + cb(ammAlice, env); + } } XRPAmount diff --git a/src/test/jtx/impl/Account.cpp b/src/test/jtx/impl/Account.cpp index a17186d4ffb..9d41456ef75 100644 --- a/src/test/jtx/impl/Account.cpp +++ b/src/test/jtx/impl/Account.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index 884caf9162e..6f0f9e3fc73 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -17,27 +17,6 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include @@ -49,6 +28,27 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/JSONRPCClient.cpp b/src/test/jtx/impl/JSONRPCClient.cpp index 1e3664c60ec..20f2149e4a0 100644 --- a/src/test/jtx/impl/JSONRPCClient.cpp +++ b/src/test/jtx/impl/JSONRPCClient.cpp @@ -16,10 +16,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/Oracle.cpp b/src/test/jtx/impl/Oracle.cpp index 95da59952a0..df9483cbaae 100644 --- a/src/test/jtx/impl/Oracle.cpp +++ b/src/test/jtx/impl/Oracle.cpp @@ -17,11 +17,12 @@ */ //============================================================================== -#include -#include #include +#include +#include #include +#include #include @@ -43,8 +44,8 @@ Oracle::Oracle(Env& env, CreateArg const& arg, bool submit) env_.close(now + testStartTime - epoch_offset); if (arg.owner) owner_ = *arg.owner; - if (arg.documentID) - documentID_ = *arg.documentID; + if (arg.documentID && validDocumentID(*arg.documentID)) + documentID_ = asUInt(*arg.documentID); if (submit) set(arg); } @@ -55,13 +56,15 @@ Oracle::remove(RemoveArg const& arg) Json::Value jv; jv[jss::TransactionType] = jss::OracleDelete; jv[jss::Account] = to_string(arg.owner.value_or(owner_)); - jv[jss::OracleDocumentID] = arg.documentID.value_or(documentID_); + toJson(jv[jss::OracleDocumentID], arg.documentID.value_or(documentID_)); if (Oracle::fee != 0) jv[jss::Fee] = std::to_string(Oracle::fee); else if (arg.fee != 0) jv[jss::Fee] = std::to_string(arg.fee); else jv[jss::Fee] = std::to_string(env_.current()->fees().increment.drops()); + if (arg.flags != 0) + jv[jss::Flags] = arg.flags; submit(jv, arg.msig, arg.seq, arg.err); } @@ -142,12 +145,11 @@ Oracle::expectLastUpdateTime(std::uint32_t lastUpdateTime) const Json::Value Oracle::aggregatePrice( Env& env, - std::optional const& baseAsset, - std::optional const& quoteAsset, - std::optional>> const& - oracles, - std::optional const& trim, - std::optional const& timeThreshold) + std::optional const& baseAsset, + std::optional const& quoteAsset, + std::optional const& oracles, + std::optional const& trim, + std::optional const& timeThreshold) { Json::Value jv; Json::Value jvOracles(Json::arrayValue); @@ -156,26 +158,34 @@ Oracle::aggregatePrice( for (auto const& id : *oracles) { Json::Value oracle; - oracle[jss::account] = to_string(id.first.id()); - oracle[jss::oracle_document_id] = id.second; + if (id.first) + oracle[jss::account] = to_string((*id.first).id()); + if (id.second) + toJson(oracle[jss::oracle_document_id], *id.second); jvOracles.append(oracle); } jv[jss::oracles] = jvOracles; } if (trim) - jv[jss::trim] = *trim; + toJson(jv[jss::trim], *trim); if (baseAsset) - jv[jss::base_asset] = *baseAsset; + toJson(jv[jss::base_asset], *baseAsset); if (quoteAsset) - jv[jss::quote_asset] = *quoteAsset; + toJson(jv[jss::quote_asset], *quoteAsset); if (timeThreshold) - jv[jss::time_threshold] = *timeThreshold; - - auto jr = env.rpc("json", "get_aggregate_price", to_string(jv)); + toJson(jv[jss::time_threshold], *timeThreshold); + // Convert "%None%" to None + auto str = to_string(jv); + str = boost::regex_replace(str, boost::regex(NonePattern), UnquotedNone); + auto jr = env.rpc("json", "get_aggregate_price", str); - if (jr.isObject() && jr.isMember(jss::result) && - jr[jss::result].isMember(jss::status)) - return jr[jss::result]; + if (jr.isObject()) + { + if (jr.isMember(jss::result) && jr[jss::result].isMember(jss::status)) + return jr[jss::result]; + else if (jr.isMember(jss::error)) + return jr; + } return Json::nullValue; } @@ -186,17 +196,24 @@ Oracle::set(UpdateArg const& arg) Json::Value jv; if (arg.owner) owner_ = *arg.owner; - if (arg.documentID) - documentID_ = *arg.documentID; + if (arg.documentID && + std::holds_alternative(*arg.documentID)) + { + documentID_ = std::get(*arg.documentID); + jv[jss::OracleDocumentID] = documentID_; + } + else if (arg.documentID) + toJson(jv[jss::OracleDocumentID], *arg.documentID); + else + jv[jss::OracleDocumentID] = documentID_; jv[jss::TransactionType] = jss::OracleSet; jv[jss::Account] = to_string(owner_); - jv[jss::OracleDocumentID] = documentID_; if (arg.assetClass) - jv[jss::AssetClass] = strHex(*arg.assetClass); + toJsonHex(jv[jss::AssetClass], *arg.assetClass); if (arg.provider) - jv[jss::Provider] = strHex(*arg.provider); + toJsonHex(jv[jss::Provider], *arg.provider); if (arg.uri) - jv[jss::URI] = strHex(*arg.uri); + toJsonHex(jv[jss::URI], *arg.uri); if (arg.flags != 0) jv[jss::Flags] = arg.flags; if (Oracle::fee != 0) @@ -207,8 +224,14 @@ Oracle::set(UpdateArg const& arg) jv[jss::Fee] = std::to_string(env_.current()->fees().increment.drops()); // lastUpdateTime if provided is offset from testStartTime if (arg.lastUpdateTime) - jv[jss::LastUpdateTime] = - to_string(testStartTime.count() + *arg.lastUpdateTime); + { + if (std::holds_alternative(*arg.lastUpdateTime)) + jv[jss::LastUpdateTime] = to_string( + testStartTime.count() + + std::get(*arg.lastUpdateTime)); + else + toJson(jv[jss::LastUpdateTime], *arg.lastUpdateTime); + } else jv[jss::LastUpdateTime] = to_string( duration_cast( @@ -263,18 +286,22 @@ Oracle::set(CreateArg const& arg) Json::Value Oracle::ledgerEntry( Env& env, - AccountID const& account, - std::variant const& documentID, + std::optional> const& account, + std::optional const& documentID, std::optional const& index) { Json::Value jvParams; - jvParams[jss::oracle][jss::account] = to_string(account); - if (std::holds_alternative(documentID)) - jvParams[jss::oracle][jss::oracle_document_id] = - std::get(documentID); - else - jvParams[jss::oracle][jss::oracle_document_id] = - std::get(documentID); + if (account) + { + if (std::holds_alternative(*account)) + jvParams[jss::oracle][jss::account] = + to_string(std::get(*account)); + else + jvParams[jss::oracle][jss::account] = + std::get(*account); + } + if (documentID) + toJson(jvParams[jss::oracle][jss::oracle_document_id], *documentID); if (index) { std::uint32_t i; @@ -283,7 +310,68 @@ Oracle::ledgerEntry( else jvParams[jss::oracle][jss::ledger_index] = *index; } - return env.rpc("json", "ledger_entry", to_string(jvParams))[jss::result]; + // Convert "%None%" to None + auto str = to_string(jvParams); + str = boost::regex_replace(str, boost::regex(NonePattern), UnquotedNone); + auto jr = env.rpc("json", "ledger_entry", str); + + if (jr.isObject()) + { + if (jr.isMember(jss::result) && jr[jss::result].isMember(jss::status)) + return jr[jss::result]; + else if (jr.isMember(jss::error)) + return jr; + } + return Json::nullValue; +} + +void +toJson(Json::Value& jv, AnyValue const& v) +{ + std::visit([&](auto&& arg) { jv = arg; }, v); +} + +void +toJsonHex(Json::Value& jv, AnyValue const& v) +{ + std::visit( + [&](T&& arg) { + if constexpr (std::is_same_v) + { + if (arg.starts_with("##")) + jv = arg.substr(2); + else + jv = strHex(arg); + } + else + jv = arg; + }, + v); +} + +std::uint32_t +asUInt(AnyValue const& v) +{ + Json::Value jv; + toJson(jv, v); + return jv.asUInt(); +} + +bool +validDocumentID(AnyValue const& v) +{ + try + { + Json::Value jv; + toJson(jv, v); + jv.asUInt(); + jv.isNumeric(); + return true; + } + catch (...) + { + } + return false; } } // namespace oracle diff --git a/src/test/jtx/impl/TestHelpers.cpp b/src/test/jtx/impl/TestHelpers.cpp index 41d9db7c7e5..b8105b1a631 100644 --- a/src/test/jtx/impl/TestHelpers.cpp +++ b/src/test/jtx/impl/TestHelpers.cpp @@ -19,9 +19,9 @@ #include -#include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/WSClient.cpp b/src/test/jtx/impl/WSClient.cpp index e9b27168108..185d0ea5dba 100644 --- a/src/test/jtx/impl/WSClient.cpp +++ b/src/test/jtx/impl/WSClient.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include #include #include @@ -32,7 +32,7 @@ #include -#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/acctdelete.cpp b/src/test/jtx/impl/acctdelete.cpp index a62ab6a48bb..d7f8f10e04d 100644 --- a/src/test/jtx/impl/acctdelete.cpp +++ b/src/test/jtx/impl/acctdelete.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/amount.cpp b/src/test/jtx/impl/amount.cpp index 86f51d135d7..01fa5369592 100644 --- a/src/test/jtx/impl/amount.cpp +++ b/src/test/jtx/impl/amount.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include +#include +#include +#include #include #include #include -#include -#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/attester.cpp b/src/test/jtx/impl/attester.cpp index dd00f536af8..66be9da83b3 100644 --- a/src/test/jtx/impl/attester.cpp +++ b/src/test/jtx/impl/attester.cpp @@ -19,11 +19,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/check.cpp b/src/test/jtx/impl/check.cpp index d862130bc70..21af6c9cc3f 100644 --- a/src/test/jtx/impl/check.cpp +++ b/src/test/jtx/impl/check.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/delivermin.cpp b/src/test/jtx/impl/delivermin.cpp index 464c31e0118..6e4838c7c0a 100644 --- a/src/test/jtx/impl/delivermin.cpp +++ b/src/test/jtx/impl/delivermin.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/deposit.cpp b/src/test/jtx/impl/deposit.cpp index 803705c8cb5..09f0cb704b0 100644 --- a/src/test/jtx/impl/deposit.cpp +++ b/src/test/jtx/impl/deposit.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/did.cpp b/src/test/jtx/impl/did.cpp index 94dfcc32754..a9a6e974ef4 100644 --- a/src/test/jtx/impl/did.cpp +++ b/src/test/jtx/impl/did.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/envconfig.cpp b/src/test/jtx/impl/envconfig.cpp index cbca244be6d..c9788a6d70f 100644 --- a/src/test/jtx/impl/envconfig.cpp +++ b/src/test/jtx/impl/envconfig.cpp @@ -19,8 +19,8 @@ #include -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/fee.cpp b/src/test/jtx/impl/fee.cpp index dea666cd3e8..e390136a3c0 100644 --- a/src/test/jtx/impl/fee.cpp +++ b/src/test/jtx/impl/fee.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/flags.cpp b/src/test/jtx/impl/flags.cpp index c80e329fdc8..992e1a88bb2 100644 --- a/src/test/jtx/impl/flags.cpp +++ b/src/test/jtx/impl/flags.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/jtx_json.cpp b/src/test/jtx/impl/jtx_json.cpp index d5fb7bfae91..c9cf6636cf9 100644 --- a/src/test/jtx/impl/jtx_json.cpp +++ b/src/test/jtx/impl/jtx_json.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include #include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/last_ledger_sequence.cpp b/src/test/jtx/impl/last_ledger_sequence.cpp index b0d7bd5c5eb..57742bab2a1 100644 --- a/src/test/jtx/impl/last_ledger_sequence.cpp +++ b/src/test/jtx/impl/last_ledger_sequence.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/memo.cpp b/src/test/jtx/impl/memo.cpp index 174a132eb3d..6469748b4f9 100644 --- a/src/test/jtx/impl/memo.cpp +++ b/src/test/jtx/impl/memo.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/multisign.cpp b/src/test/jtx/impl/multisign.cpp index 1e1f5141798..42c3bfc78bf 100644 --- a/src/test/jtx/impl/multisign.cpp +++ b/src/test/jtx/impl/multisign.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/offer.cpp b/src/test/jtx/impl/offer.cpp index 6e9a1b4f2ff..55a1af4beab 100644 --- a/src/test/jtx/impl/offer.cpp +++ b/src/test/jtx/impl/offer.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/paths.cpp b/src/test/jtx/impl/paths.cpp index 5de9761a110..393e36e9d61 100644 --- a/src/test/jtx/impl/paths.cpp +++ b/src/test/jtx/impl/paths.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/pay.cpp b/src/test/jtx/impl/pay.cpp index 35df2ec191c..2a627223fdd 100644 --- a/src/test/jtx/impl/pay.cpp +++ b/src/test/jtx/impl/pay.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/quality2.cpp b/src/test/jtx/impl/quality2.cpp index e1837035e2d..dd10b3c6117 100644 --- a/src/test/jtx/impl/quality2.cpp +++ b/src/test/jtx/impl/quality2.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/rate.cpp b/src/test/jtx/impl/rate.cpp index cf4cd3211a8..f95170537f3 100644 --- a/src/test/jtx/impl/rate.cpp +++ b/src/test/jtx/impl/rate.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/regkey.cpp b/src/test/jtx/impl/regkey.cpp index 917fb440624..9fc260d2d03 100644 --- a/src/test/jtx/impl/regkey.cpp +++ b/src/test/jtx/impl/regkey.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/sendmax.cpp b/src/test/jtx/impl/sendmax.cpp index a292e2a98ef..9514b923166 100644 --- a/src/test/jtx/impl/sendmax.cpp +++ b/src/test/jtx/impl/sendmax.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/seq.cpp b/src/test/jtx/impl/seq.cpp index ca57e79227d..3a3de002db6 100644 --- a/src/test/jtx/impl/seq.cpp +++ b/src/test/jtx/impl/seq.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/tag.cpp b/src/test/jtx/impl/tag.cpp index 33ec2c3b89b..be456a1e0e8 100644 --- a/src/test/jtx/impl/tag.cpp +++ b/src/test/jtx/impl/tag.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/ticket.cpp b/src/test/jtx/impl/ticket.cpp index 951c62ab72e..69bcab4d9f1 100644 --- a/src/test/jtx/impl/ticket.cpp +++ b/src/test/jtx/impl/ticket.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/token.cpp b/src/test/jtx/impl/token.cpp index 6c5cae4147a..5faf56185b9 100644 --- a/src/test/jtx/impl/token.cpp +++ b/src/test/jtx/impl/token.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace ripple { namespace test { @@ -57,6 +57,12 @@ uri::operator()(Env& env, JTx& jt) const jt.jv[sfURI.jsonName] = uri_; } +void +amount::operator()(Env& env, JTx& jt) const +{ + jt.jv[sfAmount.jsonName] = amount_.getJson(JsonOptions::none); +} + uint256 getNextID( jtx::Env const& env, diff --git a/src/test/jtx/impl/trust.cpp b/src/test/jtx/impl/trust.cpp index cce4657e025..641a0f79f28 100644 --- a/src/test/jtx/impl/trust.cpp +++ b/src/test/jtx/impl/trust.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { namespace test { @@ -39,6 +39,10 @@ trust(Account const& account, STAmount const& amount, std::uint32_t flags) return jv; } +// This function overload is especially useful for modelling Authorised trust +// lines. account (first function parameter) is the issuing authority, it +// authorises peer (third function parameter) to hold a certain currency +// (amount, the second function parameter) Json::Value trust( Account const& account, diff --git a/src/test/jtx/impl/txflags.cpp b/src/test/jtx/impl/txflags.cpp index 5c78be8bae6..7bc59876a99 100644 --- a/src/test/jtx/impl/txflags.cpp +++ b/src/test/jtx/impl/txflags.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/utility.cpp b/src/test/jtx/impl/utility.cpp index 196fd9258d7..c10fb918540 100644 --- a/src/test/jtx/impl/utility.cpp +++ b/src/test/jtx/impl/utility.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/impl/xchain_bridge.cpp b/src/test/jtx/impl/xchain_bridge.cpp index 0b81ccdcd91..43b0e7c2f96 100644 --- a/src/test/jtx/impl/xchain_bridge.cpp +++ b/src/test/jtx/impl/xchain_bridge.cpp @@ -19,17 +19,17 @@ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/jtx_json.h b/src/test/jtx/jtx_json.h index 59cc09537e2..837d6524766 100644 --- a/src/test/jtx/jtx_json.h +++ b/src/test/jtx/jtx_json.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_JSON_H_INCLUDED #define RIPPLE_TEST_JTX_JSON_H_INCLUDED -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/multisign.h b/src/test/jtx/multisign.h index 0617ea2fcbb..3946ea14b26 100644 --- a/src/test/jtx/multisign.h +++ b/src/test/jtx/multisign.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_TEST_JTX_MULTISIGN_H_INCLUDED #define RIPPLE_TEST_JTX_MULTISIGN_H_INCLUDED -#include -#include -#include #include #include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/offer.h b/src/test/jtx/offer.h index 35a46d19b6b..3951f4f934a 100644 --- a/src/test/jtx/offer.h +++ b/src/test/jtx/offer.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TEST_JTX_OFFER_H_INCLUDED #define RIPPLE_TEST_JTX_OFFER_H_INCLUDED -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/owners.h b/src/test/jtx/owners.h index 9c802ec91dc..2299af2d7f3 100644 --- a/src/test/jtx/owners.h +++ b/src/test/jtx/owners.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_TEST_JTX_OWNERS_H_INCLUDED #define RIPPLE_TEST_JTX_OWNERS_H_INCLUDED -#include -#include -#include -#include #include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/paths.h b/src/test/jtx/paths.h index 240582825f3..cc9caf3af72 100644 --- a/src/test/jtx/paths.h +++ b/src/test/jtx/paths.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_PATHS_H_INCLUDED #define RIPPLE_TEST_JTX_PATHS_H_INCLUDED -#include #include +#include #include namespace ripple { diff --git a/src/test/jtx/pay.h b/src/test/jtx/pay.h index f66075a3e80..6294b5b3082 100644 --- a/src/test/jtx/pay.h +++ b/src/test/jtx/pay.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TEST_JTX_PAY_H_INCLUDED #define RIPPLE_TEST_JTX_PAY_H_INCLUDED -#include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/prop.h b/src/test/jtx/prop.h index 6724ebf8087..8dc5f21917d 100644 --- a/src/test/jtx/prop.h +++ b/src/test/jtx/prop.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_PROP_H_INCLUDED #define RIPPLE_TEST_JTX_PROP_H_INCLUDED -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/rate.h b/src/test/jtx/rate.h index 6427b4988e5..0f8186accfc 100644 --- a/src/test/jtx/rate.h +++ b/src/test/jtx/rate.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_RATE_H_INCLUDED #define RIPPLE_TEST_JTX_RATE_H_INCLUDED -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/regkey.h b/src/test/jtx/regkey.h index 94869d1d006..7d021e4f277 100644 --- a/src/test/jtx/regkey.h +++ b/src/test/jtx/regkey.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TEST_JTX_REGKEY_H_INCLUDED #define RIPPLE_TEST_JTX_REGKEY_H_INCLUDED -#include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/require.h b/src/test/jtx/require.h index 64b1f36b5fa..271419e51b9 100644 --- a/src/test/jtx/require.h +++ b/src/test/jtx/require.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_REQUIRE_H_INCLUDED #define RIPPLE_TEST_JTX_REQUIRE_H_INCLUDED -#include #include +#include #include namespace ripple { diff --git a/src/test/jtx/sendmax.h b/src/test/jtx/sendmax.h index 41e09a4313b..495c61c33b8 100644 --- a/src/test/jtx/sendmax.h +++ b/src/test/jtx/sendmax.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_TEST_JTX_SENDMAX_H_INCLUDED #define RIPPLE_TEST_JTX_SENDMAX_H_INCLUDED -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/token.h b/src/test/jtx/token.h index 150ddfab0ea..9b4f81b7061 100644 --- a/src/test/jtx/token.h +++ b/src/test/jtx/token.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include @@ -83,6 +83,21 @@ class uri operator()(Env&, JTx& jtx) const; }; +/** Sets the optional amount field on an NFTokenMint. */ +class amount +{ +private: + STAmount const amount_; + +public: + explicit amount(STAmount const amount) : amount_(amount) + { + } + + void + operator()(Env&, JTx& jtx) const; +}; + /** Get the next NFTokenID that will be issued. */ uint256 getNextID( diff --git a/src/test/jtx/trust.h b/src/test/jtx/trust.h index 5b6dd78b3cd..f9fddf4871a 100644 --- a/src/test/jtx/trust.h +++ b/src/test/jtx/trust.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_TEST_JTX_TRUST_H_INCLUDED #define RIPPLE_TEST_JTX_TRUST_H_INCLUDED -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/utility.h b/src/test/jtx/utility.h index 42a2180eed2..6d34452cdf8 100644 --- a/src/test/jtx/utility.h +++ b/src/test/jtx/utility.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_TEST_JTX_UTILITY_H_INCLUDED #define RIPPLE_TEST_JTX_UTILITY_H_INCLUDED -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/jtx/xchain_bridge.h b/src/test/jtx/xchain_bridge.h index 8a398bc6f20..9968317c8de 100644 --- a/src/test/jtx/xchain_bridge.h +++ b/src/test/jtx/xchain_bridge.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_TEST_JTX_XCHAINBRIDGE_H_INCLUDED #define RIPPLE_TEST_JTX_XCHAINBRIDGE_H_INCLUDED -#include -#include -#include #include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/BookDirs_test.cpp b/src/test/ledger/BookDirs_test.cpp index c7dbea3d6d9..b50f4381f48 100644 --- a/src/test/ledger/BookDirs_test.cpp +++ b/src/test/ledger/BookDirs_test.cpp @@ -15,9 +15,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/Directory_test.cpp b/src/test/ledger/Directory_test.cpp index 42dcdab9bd1..1a14feff061 100644 --- a/src/test/ledger/Directory_test.cpp +++ b/src/test/ledger/Directory_test.cpp @@ -15,15 +15,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/Invariants_test.cpp b/src/test/ledger/Invariants_test.cpp index 898376bdaf7..1fd1543f18b 100644 --- a/src/test/ledger/Invariants_test.cpp +++ b/src/test/ledger/Invariants_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/ledger/PaymentSandbox_test.cpp b/src/test/ledger/PaymentSandbox_test.cpp index b5ad8c7712c..e3ede19b4b6 100644 --- a/src/test/ledger/PaymentSandbox_test.cpp +++ b/src/test/ledger/PaymentSandbox_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/PendingSaves_test.cpp b/src/test/ledger/PendingSaves_test.cpp index d826d2019fd..1bd42a64a60 100644 --- a/src/test/ledger/PendingSaves_test.cpp +++ b/src/test/ledger/PendingSaves_test.cpp @@ -15,8 +15,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/SkipList_test.cpp b/src/test/ledger/SkipList_test.cpp index 4fd117a4ca1..3e8987a806a 100644 --- a/src/test/ledger/SkipList_test.cpp +++ b/src/test/ledger/SkipList_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/ledger/View_test.cpp b/src/test/ledger/View_test.cpp index bbb1eec8fa5..29ceb54cc09 100644 --- a/src/test/ledger/View_test.cpp +++ b/src/test/ledger/View_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/net/DatabaseDownloader_test.cpp b/src/test/net/DatabaseDownloader_test.cpp index 31c8abfd12c..99e98dd3d01 100644 --- a/src/test/net/DatabaseDownloader_test.cpp +++ b/src/test/net/DatabaseDownloader_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/nodestore/Backend_test.cpp b/src/test/nodestore/Backend_test.cpp index 8c8432bb5b8..dc1fe8c7fe2 100644 --- a/src/test/nodestore/Backend_test.cpp +++ b/src/test/nodestore/Backend_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/nodestore/Basics_test.cpp b/src/test/nodestore/Basics_test.cpp index 92f2ae15aaf..aa423e7dc03 100644 --- a/src/test/nodestore/Basics_test.cpp +++ b/src/test/nodestore/Basics_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include namespace ripple { namespace NodeStore { diff --git a/src/test/nodestore/DatabaseShard_test.cpp b/src/test/nodestore/DatabaseShard_test.cpp index 5c074b14938..e185c43d157 100644 --- a/src/test/nodestore/DatabaseShard_test.cpp +++ b/src/test/nodestore/DatabaseShard_test.cpp @@ -17,24 +17,24 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/nodestore/Database_test.cpp b/src/test/nodestore/Database_test.cpp index 0cf2afb21a7..6774857dfc6 100644 --- a/src/test/nodestore/Database_test.cpp +++ b/src/test/nodestore/Database_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/nodestore/TestBase.h b/src/test/nodestore/TestBase.h index 9ccf2e1698d..98608c5fb11 100644 --- a/src/test/nodestore/TestBase.h +++ b/src/test/nodestore/TestBase.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_NODESTORE_BASE_H_INCLUDED #define RIPPLE_NODESTORE_BASE_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/nodestore/Timing_test.cpp b/src/test/nodestore/Timing_test.cpp index 61cfb0994dc..73789c02449 100644 --- a/src/test/nodestore/Timing_test.cpp +++ b/src/test/nodestore/Timing_test.cpp @@ -17,16 +17,18 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -36,8 +38,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/src/test/nodestore/import_test.cpp b/src/test/nodestore/import_test.cpp index 4a9ee9f0ac3..e13fe9c0c8d 100644 --- a/src/test/nodestore/import_test.cpp +++ b/src/test/nodestore/import_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -34,7 +34,7 @@ #include #include -#include +#include /* diff --git a/src/test/nodestore/varint_test.cpp b/src/test/nodestore/varint_test.cpp index a84506b7eac..da7ae9d2858 100644 --- a/src/test/nodestore/varint_test.cpp +++ b/src/test/nodestore/varint_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/overlay/ProtocolVersion_test.cpp b/src/test/overlay/ProtocolVersion_test.cpp index a5a26fe74ec..dfc0ee70b8e 100644 --- a/src/test/overlay/ProtocolVersion_test.cpp +++ b/src/test/overlay/ProtocolVersion_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/overlay/cluster_test.cpp b/src/test/overlay/cluster_test.cpp index afbc12a20ee..d22674d28c6 100644 --- a/src/test/overlay/cluster_test.cpp +++ b/src/test/overlay/cluster_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace ripple { namespace tests { diff --git a/src/test/overlay/compression_test.cpp b/src/test/overlay/compression_test.cpp index 81f21258e30..19669efc23f 100644 --- a/src/test/overlay/compression_test.cpp +++ b/src/test/overlay/compression_test.cpp @@ -17,34 +17,34 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/overlay/handshake_test.cpp b/src/test/overlay/handshake_test.cpp index 25bf20add12..93038e522a4 100644 --- a/src/test/overlay/handshake_test.cpp +++ b/src/test/overlay/handshake_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/overlay/reduce_relay_test.cpp b/src/test/overlay/reduce_relay_test.cpp index 025e3295f2a..4d9086dab10 100644 --- a/src/test/overlay/reduce_relay_test.cpp +++ b/src/test/overlay/reduce_relay_test.cpp @@ -16,15 +16,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/test/overlay/short_read_test.cpp b/src/test/overlay/short_read_test.cpp index 434b4100852..6dd4f8c00b8 100644 --- a/src/test/overlay/short_read_test.cpp +++ b/src/test/overlay/short_read_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/src/test/overlay/tx_reduce_relay_test.cpp b/src/test/overlay/tx_reduce_relay_test.cpp index 7b26ad0962f..074976e8586 100644 --- a/src/test/overlay/tx_reduce_relay_test.cpp +++ b/src/test/overlay/tx_reduce_relay_test.cpp @@ -16,12 +16,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/peerfinder/Livecache_test.cpp b/src/test/peerfinder/Livecache_test.cpp index b6d193f21f5..7fb9f02f42a 100644 --- a/src/test/peerfinder/Livecache_test.cpp +++ b/src/test/peerfinder/Livecache_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include namespace ripple { namespace PeerFinder { diff --git a/src/test/peerfinder/PeerFinder_test.cpp b/src/test/peerfinder/PeerFinder_test.cpp index feabe69b647..a1cb8d7408d 100644 --- a/src/test/peerfinder/PeerFinder_test.cpp +++ b/src/test/peerfinder/PeerFinder_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace PeerFinder { diff --git a/src/test/protocol/ApiVersion_test.cpp b/src/test/protocol/ApiVersion_test.cpp index 81ff0184e1e..7d634dc569d 100644 --- a/src/test/protocol/ApiVersion_test.cpp +++ b/src/test/protocol/ApiVersion_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/test/protocol/BuildInfo_test.cpp b/src/test/protocol/BuildInfo_test.cpp index 82ad4d67963..2c40681603c 100644 --- a/src/test/protocol/BuildInfo_test.cpp +++ b/src/test/protocol/BuildInfo_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/protocol/Hooks_test.cpp b/src/test/protocol/Hooks_test.cpp index 1f71abb3af7..fb61d10a739 100644 --- a/src/test/protocol/Hooks_test.cpp +++ b/src/test/protocol/Hooks_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include namespace ripple { diff --git a/src/test/protocol/InnerObjectFormats_test.cpp b/src/test/protocol/InnerObjectFormats_test.cpp index 009ceef2563..cfc8d123c22 100644 --- a/src/test/protocol/InnerObjectFormats_test.cpp +++ b/src/test/protocol/InnerObjectFormats_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include // Json::Reader -#include // RPC::containsError -#include -#include // STParsedJSONObject #include +#include +#include +#include // Json::Reader +#include // RPC::containsError +#include +#include // STParsedJSONObject namespace ripple { diff --git a/src/test/protocol/Issue_test.cpp b/src/test/protocol/Issue_test.cpp index 44eb6e0c0e3..7ec1507e04b 100644 --- a/src/test/protocol/Issue_test.cpp +++ b/src/test/protocol/Issue_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/protocol/Memo_test.cpp b/src/test/protocol/Memo_test.cpp index e119ee76eec..bd63e7003ad 100644 --- a/src/test/protocol/Memo_test.cpp +++ b/src/test/protocol/Memo_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/protocol/MultiApiJson_test.cpp b/src/test/protocol/MultiApiJson_test.cpp index a7b0e7e9aec..2c0b410f899 100644 --- a/src/test/protocol/MultiApiJson_test.cpp +++ b/src/test/protocol/MultiApiJson_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/protocol/PublicKey_test.cpp b/src/test/protocol/PublicKey_test.cpp index 040d752f481..7fa798d1483 100644 --- a/src/test/protocol/PublicKey_test.cpp +++ b/src/test/protocol/PublicKey_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/protocol/Quality_test.cpp b/src/test/protocol/Quality_test.cpp index a36591b0247..741a341d980 100644 --- a/src/test/protocol/Quality_test.cpp +++ b/src/test/protocol/Quality_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace ripple { diff --git a/src/test/protocol/STAccount_test.cpp b/src/test/protocol/STAccount_test.cpp index f8f79752a5a..034e0e9e087 100644 --- a/src/test/protocol/STAccount_test.cpp +++ b/src/test/protocol/STAccount_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/protocol/STAmount_test.cpp b/src/test/protocol/STAmount_test.cpp index bd3e96694fd..e48d0500ba6 100644 --- a/src/test/protocol/STAmount_test.cpp +++ b/src/test/protocol/STAmount_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/protocol/STObject_test.cpp b/src/test/protocol/STObject_test.cpp index 34d1cc82fac..39a5b9c2f65 100644 --- a/src/test/protocol/STObject_test.cpp +++ b/src/test/protocol/STObject_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/protocol/STTx_test.cpp b/src/test/protocol/STTx_test.cpp index f41c283e3ab..e0f6796af33 100644 --- a/src/test/protocol/STTx_test.cpp +++ b/src/test/protocol/STTx_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/protocol/STValidation_test.cpp b/src/test/protocol/STValidation_test.cpp index 3435db22ca7..8efb5847488 100644 --- a/src/test/protocol/STValidation_test.cpp +++ b/src/test/protocol/STValidation_test.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/protocol/SecretKey_test.cpp b/src/test/protocol/SecretKey_test.cpp index 08a19124508..bce89bce734 100644 --- a/src/test/protocol/SecretKey_test.cpp +++ b/src/test/protocol/SecretKey_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/test/protocol/Seed_test.cpp b/src/test/protocol/Seed_test.cpp index 86cf449e1ca..3619e84541e 100644 --- a/src/test/protocol/Seed_test.cpp +++ b/src/test/protocol/Seed_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/protocol/SeqProxy_test.cpp b/src/test/protocol/SeqProxy_test.cpp index 99a29dfe000..5e44bca5b40 100644 --- a/src/test/protocol/SeqProxy_test.cpp +++ b/src/test/protocol/SeqProxy_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/protocol/TER_test.cpp b/src/test/protocol/TER_test.cpp index 3cf21db2c0a..a43fd8758ad 100644 --- a/src/test/protocol/TER_test.cpp +++ b/src/test/protocol/TER_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include #include diff --git a/src/test/protocol/types_test.cpp b/src/test/protocol/types_test.cpp index 2ae7d15ef5c..ac4314df640 100644 --- a/src/test/protocol/types_test.cpp +++ b/src/test/protocol/types_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/test/resource/Logic_test.cpp b/src/test/resource/Logic_test.cpp index 25379370f4d..b445890c326 100644 --- a/src/test/resource/Logic_test.cpp +++ b/src/test/resource/Logic_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/rpc/AMMInfo_test.cpp b/src/test/rpc/AMMInfo_test.cpp index cfcb672c032..e4523bb0473 100644 --- a/src/test/rpc/AMMInfo_test.cpp +++ b/src/test/rpc/AMMInfo_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include #include #include #include +#include +#include #include @@ -37,6 +37,19 @@ class AMMInfo_test : public jtx::AMMTestBase testcase("Errors"); using namespace jtx; + + Account const bogie("bogie"); + enum TestAccount { None, Alice, Bogie }; + auto accountId = [&](AMM const& ammAlice, + TestAccount v) -> std::optional { + if (v == Alice) + return ammAlice.ammAccount(); + else if (v == Bogie) + return bogie; + else + return std::nullopt; + }; + // Invalid tokens pair testAMM([&](AMM& ammAlice, Env&) { Account const gw("gw"); @@ -48,36 +61,70 @@ class AMMInfo_test : public jtx::AMMTestBase // Invalid LP account id testAMM([&](AMM& ammAlice, Env&) { - Account bogie("bogie"); auto const jv = ammAlice.ammRpcInfo(bogie.id()); BEAST_EXPECT(jv[jss::error_message] == "Account malformed."); }); + std::vector, + std::optional, + TestAccount, + bool>> const invalidParams = { + {xrpIssue(), std::nullopt, None, false}, + {std::nullopt, USD.issue(), None, false}, + {xrpIssue(), std::nullopt, Alice, false}, + {std::nullopt, USD.issue(), Alice, false}, + {xrpIssue(), USD.issue(), Alice, false}, + {std::nullopt, std::nullopt, None, true}}; + // Invalid parameters testAMM([&](AMM& ammAlice, Env&) { - std::vector, - std::optional, - std::optional, - bool>> - vals = { - {xrpIssue(), std::nullopt, std::nullopt, false}, - {std::nullopt, USD.issue(), std::nullopt, false}, - {xrpIssue(), std::nullopt, ammAlice.ammAccount(), false}, - {std::nullopt, USD.issue(), ammAlice.ammAccount(), false}, - {xrpIssue(), USD.issue(), ammAlice.ammAccount(), false}, - {std::nullopt, std::nullopt, std::nullopt, true}}; - for (auto const& [iss1, iss2, acct, ignoreParams] : vals) + for (auto const& [iss1, iss2, acct, ignoreParams] : invalidParams) + { + auto const jv = ammAlice.ammRpcInfo( + std::nullopt, + std::nullopt, + iss1, + iss2, + accountId(ammAlice, acct), + ignoreParams); + BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters."); + } + }); + + // Invalid parameters *and* invalid LP account, default API version + testAMM([&](AMM& ammAlice, Env&) { + for (auto const& [iss1, iss2, acct, ignoreParams] : invalidParams) { auto const jv = ammAlice.ammRpcInfo( - std::nullopt, std::nullopt, iss1, iss2, acct, ignoreParams); + bogie, // + std::nullopt, + iss1, + iss2, + accountId(ammAlice, acct), + ignoreParams); BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters."); } }); + // Invalid parameters *and* invalid LP account, API version 3 + testAMM([&](AMM& ammAlice, Env&) { + for (auto const& [iss1, iss2, acct, ignoreParams] : invalidParams) + { + auto const jv = ammAlice.ammRpcInfo( + bogie, // + std::nullopt, + iss1, + iss2, + accountId(ammAlice, acct), + ignoreParams, + 3); + BEAST_EXPECT(jv[jss::error_message] == "Account malformed."); + } + }); + // Invalid AMM account id testAMM([&](AMM& ammAlice, Env&) { - Account bogie("bogie"); auto const jv = ammAlice.ammRpcInfo( std::nullopt, std::nullopt, @@ -86,6 +133,54 @@ class AMMInfo_test : public jtx::AMMTestBase bogie.id()); BEAST_EXPECT(jv[jss::error_message] == "Account malformed."); }); + + std::vector, + std::optional, + TestAccount, + bool>> const invalidParamsBadAccount = { + {xrpIssue(), std::nullopt, None, false}, + {std::nullopt, USD.issue(), None, false}, + {xrpIssue(), std::nullopt, Bogie, false}, + {std::nullopt, USD.issue(), Bogie, false}, + {xrpIssue(), USD.issue(), Bogie, false}, + {std::nullopt, std::nullopt, None, true}}; + + // Invalid parameters *and* invalid AMM account, default API version + testAMM([&](AMM& ammAlice, Env&) { + for (auto const& [iss1, iss2, acct, ignoreParams] : + invalidParamsBadAccount) + { + auto const jv = ammAlice.ammRpcInfo( + std::nullopt, + std::nullopt, + iss1, + iss2, + accountId(ammAlice, acct), + ignoreParams); + BEAST_EXPECT(jv[jss::error_message] == "Invalid parameters."); + } + }); + + // Invalid parameters *and* invalid AMM account, API version 3 + testAMM([&](AMM& ammAlice, Env&) { + for (auto const& [iss1, iss2, acct, ignoreParams] : + invalidParamsBadAccount) + { + auto const jv = ammAlice.ammRpcInfo( + std::nullopt, + std::nullopt, + iss1, + iss2, + accountId(ammAlice, acct), + ignoreParams, + 3); + BEAST_EXPECT( + jv[jss::error_message] == + (acct == Bogie ? std::string("Account malformed.") + : std::string("Invalid parameters."))); + } + }); } void diff --git a/src/test/rpc/AccountCurrencies_test.cpp b/src/test/rpc/AccountCurrencies_test.cpp index c3e46a3e66c..472dc02c438 100644 --- a/src/test/rpc/AccountCurrencies_test.cpp +++ b/src/test/rpc/AccountCurrencies_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/rpc/AccountInfo_test.cpp b/src/test/rpc/AccountInfo_test.cpp index ff23a5e53c1..8c69dce13d1 100644 --- a/src/test/rpc/AccountInfo_test.cpp +++ b/src/test/rpc/AccountInfo_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include #include +#include +#include -#include -#include -#include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/AccountLinesRPC_test.cpp b/src/test/rpc/AccountLinesRPC_test.cpp index 04688156d12..3c25dbe7810 100644 --- a/src/test/rpc/AccountLinesRPC_test.cpp +++ b/src/test/rpc/AccountLinesRPC_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/AccountObjects_test.cpp b/src/test/rpc/AccountObjects_test.cpp index 17217f2c880..18291bf2b95 100644 --- a/src/test/rpc/AccountObjects_test.cpp +++ b/src/test/rpc/AccountObjects_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include #include diff --git a/src/test/rpc/AccountOffers_test.cpp b/src/test/rpc/AccountOffers_test.cpp index d94442ea8e5..d53fb9ecb0b 100644 --- a/src/test/rpc/AccountOffers_test.cpp +++ b/src/test/rpc/AccountOffers_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/AccountSet_test.cpp b/src/test/rpc/AccountSet_test.cpp index 3fa214c5b4e..e5475e3f530 100644 --- a/src/test/rpc/AccountSet_test.cpp +++ b/src/test/rpc/AccountSet_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/AccountTx_test.cpp b/src/test/rpc/AccountTx_test.cpp index 6601996925e..54ca3f1f418 100644 --- a/src/test/rpc/AccountTx_test.cpp +++ b/src/test/rpc/AccountTx_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include diff --git a/src/test/rpc/AmendmentBlocked_test.cpp b/src/test/rpc/AmendmentBlocked_test.cpp index a90bcdcd0c4..196ce0e463d 100644 --- a/src/test/rpc/AmendmentBlocked_test.cpp +++ b/src/test/rpc/AmendmentBlocked_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/Book_test.cpp b/src/test/rpc/Book_test.cpp index fcc0017f539..6bcc0c20809 100644 --- a/src/test/rpc/Book_test.cpp +++ b/src/test/rpc/Book_test.cpp @@ -15,12 +15,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/DeliveredAmount_test.cpp b/src/test/rpc/DeliveredAmount_test.cpp index c17bd0c025d..9ed858e2a33 100644 --- a/src/test/rpc/DeliveredAmount_test.cpp +++ b/src/test/rpc/DeliveredAmount_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/DepositAuthorized_test.cpp b/src/test/rpc/DepositAuthorized_test.cpp index 42b871e31e5..ebabe1fbe3f 100644 --- a/src/test/rpc/DepositAuthorized_test.cpp +++ b/src/test/rpc/DepositAuthorized_test.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include #include +#include namespace ripple { namespace test { @@ -128,7 +128,7 @@ class DepositAuthorized_test : public beast::unit_test::suite depositAuthArgs(carol, becky).toStyledString()), false); - // becky clears the the DepositAuth flag so carol becomes authorized. + // becky clears the DepositAuth flag so carol becomes authorized. env(fclear(becky, asfDepositAuth)); env.close(); diff --git a/src/test/rpc/Feature_test.cpp b/src/test/rpc/Feature_test.cpp index fd63aee98e2..488255542f2 100644 --- a/src/test/rpc/Feature_test.cpp +++ b/src/test/rpc/Feature_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { @@ -31,34 +31,75 @@ class Feature_test : public beast::unit_test::suite { testcase("internals"); - std::map const& supported = - ripple::detail::supportedAmendments(); + auto const& supportedAmendments = ripple::detail::supportedAmendments(); + auto const& allAmendments = ripple::allAmendments(); + BEAST_EXPECT( - supported.size() == + supportedAmendments.size() == ripple::detail::numDownVotedAmendments() + ripple::detail::numUpVotedAmendments()); - std::size_t up = 0, down = 0, obsolete = 0; - for (std::pair const& amendment : - supported) { - switch (amendment.second) + std::size_t up = 0, down = 0, obsolete = 0; + for (auto const& [name, vote] : supportedAmendments) { - case VoteBehavior::DefaultYes: - ++up; - break; - case VoteBehavior::DefaultNo: - ++down; - break; - case VoteBehavior::Obsolete: - ++obsolete; - break; - default: - fail("Unknown VoteBehavior", __FILE__, __LINE__); + switch (vote) + { + case VoteBehavior::DefaultYes: + ++up; + break; + case VoteBehavior::DefaultNo: + ++down; + break; + case VoteBehavior::Obsolete: + ++obsolete; + break; + default: + fail("Unknown VoteBehavior", __FILE__, __LINE__); + } + + if (vote == VoteBehavior::Obsolete) + { + BEAST_EXPECT( + allAmendments.contains(name) && + allAmendments.at(name) == AmendmentSupport::Retired); + } + else + { + BEAST_EXPECT( + allAmendments.contains(name) && + allAmendments.at(name) == AmendmentSupport::Supported); + } } + BEAST_EXPECT( + down + obsolete == ripple::detail::numDownVotedAmendments()); + BEAST_EXPECT(up == ripple::detail::numUpVotedAmendments()); + } + { + std::size_t supported = 0, unsupported = 0, retired = 0; + for (auto const& [name, support] : allAmendments) + { + switch (support) + { + case AmendmentSupport::Supported: + ++supported; + BEAST_EXPECT(supportedAmendments.contains(name)); + break; + case AmendmentSupport::Unsupported: + ++unsupported; + break; + case AmendmentSupport::Retired: + ++retired; + break; + default: + fail("Unknown AmendmentSupport", __FILE__, __LINE__); + } + } + + BEAST_EXPECT(supported + retired == supportedAmendments.size()); + BEAST_EXPECT( + allAmendments.size() - unsupported == + supportedAmendments.size()); } - BEAST_EXPECT( - down + obsolete == ripple::detail::numDownVotedAmendments()); - BEAST_EXPECT(up == ripple::detail::numUpVotedAmendments()); } void diff --git a/src/test/rpc/GRPCTestClientBase.h b/src/test/rpc/GRPCTestClientBase.h index a5c613f55e2..f8b74ed6d5c 100644 --- a/src/test/rpc/GRPCTestClientBase.h +++ b/src/test/rpc/GRPCTestClientBase.h @@ -20,9 +20,9 @@ #ifndef RIPPLED_GRPCTESTCLIENTBASE_H #define RIPPLED_GRPCTESTCLIENTBASE_H -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/GatewayBalances_test.cpp b/src/test/rpc/GatewayBalances_test.cpp index 4c6ec9aaf1b..4e847c8dbdd 100644 --- a/src/test/rpc/GatewayBalances_test.cpp +++ b/src/test/rpc/GatewayBalances_test.cpp @@ -15,12 +15,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/GetAggregatePrice_test.cpp b/src/test/rpc/GetAggregatePrice_test.cpp index 4c45b7b9d2b..aad3c9be99f 100644 --- a/src/test/rpc/GetAggregatePrice_test.cpp +++ b/src/test/rpc/GetAggregatePrice_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include #include #include +#include +#include namespace ripple { namespace test { @@ -35,10 +35,9 @@ class GetAggregatePrice_test : public beast::unit_test::suite { testcase("Errors"); using namespace jtx; - using Oracles = std::vector>; Account const owner{"owner"}; Account const some{"some"}; - static Oracles oracles = {{owner, 1}}; + static OraclesData oracles = {{owner, 1}}; { Env env(*this); @@ -55,6 +54,32 @@ class GetAggregatePrice_test : public beast::unit_test::suite ret[jss::error_message].asString() == "Missing field 'quote_asset'."); + // invalid base_asset, quote_asset + std::vector invalidAsset = { + NoneTag, + 1, + -1, + 1.2, + "", + "invalid", + "a", + "ab", + "A", + "AB", + "ABCD", + "010101", + "012345678901234567890123456789012345678", + "012345678901234567890123456789012345678G"}; + for (auto const& v : invalidAsset) + { + ret = Oracle::aggregatePrice(env, "USD", v, oracles); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + ret = Oracle::aggregatePrice(env, v, "USD", oracles); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + ret = Oracle::aggregatePrice(env, v, v, oracles); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + } + // missing oracles array ret = Oracle::aggregatePrice(env, "XRP", "USD"); BEAST_EXPECT( @@ -62,16 +87,39 @@ class GetAggregatePrice_test : public beast::unit_test::suite "Missing field 'oracles'."); // empty oracles array - ret = Oracle::aggregatePrice(env, "XRP", "USD", Oracles{}); + ret = Oracle::aggregatePrice(env, "XRP", "USD", OraclesData{}); BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed"); + // no token pairs found + ret = Oracle::aggregatePrice(env, "YAN", "USD", oracles); + BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound"); + // invalid oracle document id + // id doesn't exist ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, 2}}}); BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound"); + // invalid values + std::vector invalidDocument = { + NoneTag, 1.2, -1, "", "none", "1.2"}; + for (auto const& v : invalidDocument) + { + ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{owner, v}}}); + Json::Value jv; + toJson(jv, v); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + } + // missing document id + ret = Oracle::aggregatePrice( + env, "XRP", "USD", {{{owner, std::nullopt}}}); + BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed"); // invalid owner ret = Oracle::aggregatePrice(env, "XRP", "USD", {{{some, 1}}}); BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound"); + // missing account + ret = Oracle::aggregatePrice( + env, "XRP", "USD", {{{std::nullopt, 1}}}); + BEAST_EXPECT(ret[jss::error].asString() == "oracleMalformed"); // oracles have wrong asset pair env.fund(XRP(1'000), owner); @@ -82,18 +130,35 @@ class GetAggregatePrice_test : public beast::unit_test::suite BEAST_EXPECT(ret[jss::error].asString() == "objectNotFound"); // invalid trim value - ret = Oracle::aggregatePrice( - env, "XRP", "USD", {{{owner, oracle.documentID()}}}, 0); - BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); - ret = Oracle::aggregatePrice( - env, "XRP", "USD", {{{owner, oracle.documentID()}}}, 26); - BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + std::vector invalidTrim = { + NoneTag, 0, 26, -1, 1.2, "", "none", "1.2"}; + for (auto const& v : invalidTrim) + { + ret = Oracle::aggregatePrice( + env, "XRP", "USD", {{{owner, oracle.documentID()}}}, v); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + } + + // invalid time threshold value + std::vector invalidTime = { + NoneTag, -1, 1.2, "", "none", "1.2"}; + for (auto const& v : invalidTime) + { + ret = Oracle::aggregatePrice( + env, + "XRP", + "USD", + {{{owner, oracle.documentID()}}}, + std::nullopt, + v); + BEAST_EXPECT(ret[jss::error].asString() == "invalidParams"); + } } // too many oracles { Env env(*this); - std::vector> oracles; + OraclesData oracles; for (int i = 0; i < 201; ++i) { Account const owner(std::to_string(i)); @@ -132,7 +197,7 @@ class GetAggregatePrice_test : public beast::unit_test::suite // or time threshold { Env env(*this); - std::vector> oracles; + OraclesData oracles; prep(env, oracles); // entire and trimmed stats auto ret = Oracle::aggregatePrice(env, "XRP", "USD", oracles); @@ -148,7 +213,7 @@ class GetAggregatePrice_test : public beast::unit_test::suite // Aggregate data set includes all price oracle instances { Env env(*this); - std::vector> oracles; + OraclesData oracles; prep(env, oracles); // entire and trimmed stats auto ret = @@ -171,14 +236,14 @@ class GetAggregatePrice_test : public beast::unit_test::suite // updated ledgers { Env env(*this); - std::vector> oracles; + OraclesData oracles; prep(env, oracles); for (int i = 0; i < 3; ++i) { Oracle oracle( env, {.owner = oracles[i].first, - .documentID = oracles[i].second}, + .documentID = asUInt(*oracles[i].second)}, false); // push XRP/USD by more than three ledgers, so this price // oracle is not included in the dataset @@ -191,7 +256,7 @@ class GetAggregatePrice_test : public beast::unit_test::suite Oracle oracle( env, {.owner = oracles[i].first, - .documentID = oracles[i].second}, + .documentID = asUInt(*oracles[i].second)}, false); // push XRP/USD by two ledgers, so this price // is included in the dataset @@ -201,7 +266,7 @@ class GetAggregatePrice_test : public beast::unit_test::suite // entire and trimmed stats auto ret = - Oracle::aggregatePrice(env, "XRP", "USD", oracles, 20, 200); + Oracle::aggregatePrice(env, "XRP", "USD", oracles, 20, "200"); BEAST_EXPECT(ret[jss::entire_set][jss::mean] == "74.6"); BEAST_EXPECT(ret[jss::entire_set][jss::size].asUInt() == 7); BEAST_EXPECT( @@ -219,14 +284,14 @@ class GetAggregatePrice_test : public beast::unit_test::suite // Reduced data set because of the time threshold { Env env(*this); - std::vector> oracles; + OraclesData oracles; prep(env, oracles); for (int i = 0; i < oracles.size(); ++i) { Oracle oracle( env, {.owner = oracles[i].first, - .documentID = oracles[i].second}, + .documentID = asUInt(*oracles[i].second)}, false); // push XRP/USD by two ledgers, so this price // is included in the dataset diff --git a/src/test/rpc/GetCounts_test.cpp b/src/test/rpc/GetCounts_test.cpp index 52b645ed717..132ed93d7be 100644 --- a/src/test/rpc/GetCounts_test.cpp +++ b/src/test/rpc/GetCounts_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/Handler_test.cpp b/src/test/rpc/Handler_test.cpp index 5160a68aac2..2c3bfd30d4c 100644 --- a/src/test/rpc/Handler_test.cpp +++ b/src/test/rpc/Handler_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include #include #include diff --git a/src/test/rpc/JSONRPC_test.cpp b/src/test/rpc/JSONRPC_test.cpp index 8fd453ee9f6..b2b9e7a55b8 100644 --- a/src/test/rpc/JSONRPC_test.cpp +++ b/src/test/rpc/JSONRPC_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/KeyGeneration_test.cpp b/src/test/rpc/KeyGeneration_test.cpp index 28f9afd3b7f..e136bb04beb 100644 --- a/src/test/rpc/KeyGeneration_test.cpp +++ b/src/test/rpc/KeyGeneration_test.cpp @@ -16,13 +16,13 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/LedgerClosed_test.cpp b/src/test/rpc/LedgerClosed_test.cpp index 2f81031f85c..c3f7f900e3c 100644 --- a/src/test/rpc/LedgerClosed_test.cpp +++ b/src/test/rpc/LedgerClosed_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/rpc/LedgerData_test.cpp b/src/test/rpc/LedgerData_test.cpp index f0811ba34c4..1e4f97a935f 100644 --- a/src/test/rpc/LedgerData_test.cpp +++ b/src/test/rpc/LedgerData_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { @@ -300,201 +300,214 @@ class LedgerData_test : public beast::unit_test::suite { // Put a bunch of different LedgerEntryTypes into a ledger using namespace test::jtx; - using namespace std::chrono; - Env env{*this, envconfig(validator, "")}; - Account const gw{"gateway"}; - auto const USD = gw["USD"]; - env.fund(XRP(100000), gw); - - auto makeRequest = [&env](Json::StaticString const& type) { - Json::Value jvParams; - jvParams[jss::ledger_index] = "current"; - jvParams[jss::type] = type; - return env.rpc( - "json", - "ledger_data", - boost::lexical_cast(jvParams))[jss::result]; - }; - - // Assert that state is an empty array. - for (auto const& type : - {jss::amendments, - jss::check, - jss::directory, - jss::offer, - jss::signer_list, - jss::state, - jss::ticket, - jss::escrow, - jss::payment_channel, - jss::deposit_preauth}) + // Make sure fixInnerObjTemplate2 doesn't break amendments. + for (FeatureBitset const& features : + {supported_amendments() - fixInnerObjTemplate2, + supported_amendments() | fixInnerObjTemplate2}) { - auto const jrr = makeRequest(type); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 0)); - } + using namespace std::chrono; + Env env{*this, envconfig(validator, ""), features}; + + Account const gw{"gateway"}; + auto const USD = gw["USD"]; + env.fund(XRP(100000), gw); + + auto makeRequest = [&env](Json::StaticString const& type) { + Json::Value jvParams; + jvParams[jss::ledger_index] = "current"; + jvParams[jss::type] = type; + return env.rpc( + "json", + "ledger_data", + boost::lexical_cast(jvParams))[jss::result]; + }; + + // Assert that state is an empty array. + for (auto const& type : + {jss::amendments, + jss::check, + jss::directory, + jss::offer, + jss::signer_list, + jss::state, + jss::ticket, + jss::escrow, + jss::payment_channel, + jss::deposit_preauth}) + { + auto const jrr = makeRequest(type); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 0)); + } - int const num_accounts = 10; + int const num_accounts = 10; - for (auto i = 0; i < num_accounts; i++) - { - Account const bob{std::string("bob") + std::to_string(i)}; - env.fund(XRP(1000), bob); - } - env(offer(Account{"bob0"}, USD(100), XRP(100))); - env.trust(Account{"bob2"}["USD"](100), Account{"bob3"}); + for (auto i = 0; i < num_accounts; i++) + { + Account const bob{std::string("bob") + std::to_string(i)}; + env.fund(XRP(1000), bob); + } + env(offer(Account{"bob0"}, USD(100), XRP(100))); + env.trust(Account{"bob2"}["USD"](100), Account{"bob3"}); - auto majorities = getMajorityAmendments(*env.closed()); - for (int i = 0; i <= 256; ++i) - { - env.close(); - majorities = getMajorityAmendments(*env.closed()); - if (!majorities.empty()) - break; - } - env(signers( - Account{"bob0"}, 1, {{Account{"bob1"}, 1}, {Account{"bob2"}, 1}})); - env(ticket::create(env.master, 1)); + auto majorities = getMajorityAmendments(*env.closed()); + for (int i = 0; i <= 256; ++i) + { + env.close(); + majorities = getMajorityAmendments(*env.closed()); + if (!majorities.empty()) + break; + } - { - Json::Value jv; - jv[jss::TransactionType] = jss::EscrowCreate; - jv[jss::Flags] = tfUniversal; - jv[jss::Account] = Account{"bob5"}.human(); - jv[jss::Destination] = Account{"bob6"}.human(); - jv[jss::Amount] = XRP(50).value().getJson(JsonOptions::none); - jv[sfFinishAfter.fieldName] = NetClock::time_point{env.now() + 10s} - .time_since_epoch() - .count(); - env(jv); - } + env(signers( + Account{"bob0"}, + 1, + {{Account{"bob1"}, 1}, {Account{"bob2"}, 1}})); + env(ticket::create(env.master, 1)); - { - Json::Value jv; - jv[jss::TransactionType] = jss::PaymentChannelCreate; - jv[jss::Flags] = tfUniversal; - jv[jss::Account] = Account{"bob6"}.human(); - jv[jss::Destination] = Account{"bob7"}.human(); - jv[jss::Amount] = XRP(100).value().getJson(JsonOptions::none); - jv[jss::SettleDelay] = NetClock::duration{10s}.count(); - jv[sfPublicKey.fieldName] = strHex(Account{"bob6"}.pk().slice()); - jv[sfCancelAfter.fieldName] = NetClock::time_point{env.now() + 300s} - .time_since_epoch() - .count(); - env(jv); - } + { + Json::Value jv; + jv[jss::TransactionType] = jss::EscrowCreate; + jv[jss::Flags] = tfUniversal; + jv[jss::Account] = Account{"bob5"}.human(); + jv[jss::Destination] = Account{"bob6"}.human(); + jv[jss::Amount] = XRP(50).value().getJson(JsonOptions::none); + jv[sfFinishAfter.fieldName] = + NetClock::time_point{env.now() + 10s} + .time_since_epoch() + .count(); + env(jv); + } - env(check::create("bob6", "bob7", XRP(100))); + { + Json::Value jv; + jv[jss::TransactionType] = jss::PaymentChannelCreate; + jv[jss::Flags] = tfUniversal; + jv[jss::Account] = Account{"bob6"}.human(); + jv[jss::Destination] = Account{"bob7"}.human(); + jv[jss::Amount] = XRP(100).value().getJson(JsonOptions::none); + jv[jss::SettleDelay] = NetClock::duration{10s}.count(); + jv[sfPublicKey.fieldName] = + strHex(Account{"bob6"}.pk().slice()); + jv[sfCancelAfter.fieldName] = + NetClock::time_point{env.now() + 300s} + .time_since_epoch() + .count(); + env(jv); + } - // bob9 DepositPreauths bob4 and bob8. - env(deposit::auth(Account{"bob9"}, Account{"bob4"})); - env(deposit::auth(Account{"bob9"}, Account{"bob8"})); - env.close(); + env(check::create("bob6", "bob7", XRP(100))); - // Now fetch each type + // bob9 DepositPreauths bob4 and bob8. + env(deposit::auth(Account{"bob9"}, Account{"bob4"})); + env(deposit::auth(Account{"bob9"}, Account{"bob8"})); + env.close(); - { // jvParams[jss::type] = "account"; - auto const jrr = makeRequest(jss::account); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 12)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::AccountRoot); - } + // Now fetch each type - { // jvParams[jss::type] = "amendments"; - auto const jrr = makeRequest(jss::amendments); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::Amendments); - } + { // jvParams[jss::type] = "account"; + auto const jrr = makeRequest(jss::account); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 12)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::AccountRoot); + } - { // jvParams[jss::type] = "check"; - auto const jrr = makeRequest(jss::check); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::Check); - } + { // jvParams[jss::type] = "amendments"; + auto const jrr = makeRequest(jss::amendments); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::Amendments); + } - { // jvParams[jss::type] = "directory"; - auto const jrr = makeRequest(jss::directory); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 9)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::DirectoryNode); - } + { // jvParams[jss::type] = "check"; + auto const jrr = makeRequest(jss::check); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::Check); + } - { // jvParams[jss::type] = "fee"; - auto const jrr = makeRequest(jss::fee); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::FeeSettings); - } + { // jvParams[jss::type] = "directory"; + auto const jrr = makeRequest(jss::directory); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 9)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::DirectoryNode); + } - { // jvParams[jss::type] = "hashes"; - auto const jrr = makeRequest(jss::hashes); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 2)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::LedgerHashes); - } + { // jvParams[jss::type] = "fee"; + auto const jrr = makeRequest(jss::fee); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::FeeSettings); + } - { // jvParams[jss::type] = "offer"; - auto const jrr = makeRequest(jss::offer); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::Offer); - } + { // jvParams[jss::type] = "hashes"; + auto const jrr = makeRequest(jss::hashes); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 2)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::LedgerHashes); + } - { // jvParams[jss::type] = "signer_list"; - auto const jrr = makeRequest(jss::signer_list); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::SignerList); - } + { // jvParams[jss::type] = "offer"; + auto const jrr = makeRequest(jss::offer); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::Offer); + } - { // jvParams[jss::type] = "state"; - auto const jrr = makeRequest(jss::state); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::RippleState); - } + { // jvParams[jss::type] = "signer_list"; + auto const jrr = makeRequest(jss::signer_list); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::SignerList); + } - { // jvParams[jss::type] = "ticket"; - auto const jrr = makeRequest(jss::ticket); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::Ticket); - } + { // jvParams[jss::type] = "state"; + auto const jrr = makeRequest(jss::state); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::RippleState); + } - { // jvParams[jss::type] = "escrow"; - auto const jrr = makeRequest(jss::escrow); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::Escrow); - } + { // jvParams[jss::type] = "ticket"; + auto const jrr = makeRequest(jss::ticket); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::Ticket); + } - { // jvParams[jss::type] = "payment_channel"; - auto const jrr = makeRequest(jss::payment_channel); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::PayChannel); - } + { // jvParams[jss::type] = "escrow"; + auto const jrr = makeRequest(jss::escrow); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::Escrow); + } - { // jvParams[jss::type] = "deposit_preauth"; - auto const jrr = makeRequest(jss::deposit_preauth); - BEAST_EXPECT(checkArraySize(jrr[jss::state], 2)); - for (auto const& j : jrr[jss::state]) - BEAST_EXPECT(j["LedgerEntryType"] == jss::DepositPreauth); - } + { // jvParams[jss::type] = "payment_channel"; + auto const jrr = makeRequest(jss::payment_channel); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 1)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::PayChannel); + } - { // jvParams[jss::type] = "misspelling"; - Json::Value jvParams; - jvParams[jss::ledger_index] = "current"; - jvParams[jss::type] = "misspelling"; - auto const jrr = env.rpc( - "json", - "ledger_data", - boost::lexical_cast(jvParams))[jss::result]; - BEAST_EXPECT(jrr.isMember("error")); - BEAST_EXPECT(jrr["error"] == "invalidParams"); - BEAST_EXPECT(jrr["error_message"] == "Invalid field 'type'."); + { // jvParams[jss::type] = "deposit_preauth"; + auto const jrr = makeRequest(jss::deposit_preauth); + BEAST_EXPECT(checkArraySize(jrr[jss::state], 2)); + for (auto const& j : jrr[jss::state]) + BEAST_EXPECT(j["LedgerEntryType"] == jss::DepositPreauth); + } + + { // jvParams[jss::type] = "misspelling"; + Json::Value jvParams; + jvParams[jss::ledger_index] = "current"; + jvParams[jss::type] = "misspelling"; + auto const jrr = env.rpc( + "json", + "ledger_data", + boost::lexical_cast(jvParams))[jss::result]; + BEAST_EXPECT(jrr.isMember("error")); + BEAST_EXPECT(jrr["error"] == "invalidParams"); + BEAST_EXPECT(jrr["error_message"] == "Invalid field 'type'."); + } } } diff --git a/src/test/rpc/LedgerHeader_test.cpp b/src/test/rpc/LedgerHeader_test.cpp index d6c0652d5a2..d8fe738b888 100644 --- a/src/test/rpc/LedgerHeader_test.cpp +++ b/src/test/rpc/LedgerHeader_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include #include #include +#include namespace ripple { diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index 877b8ef2a02..70e4ffbe8dc 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -17,18 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { @@ -2279,6 +2280,87 @@ class LedgerRPC_test : public beast::unit_test::suite } } + void + testInvalidOracleLedgerEntry() + { + testcase("Invalid Oracle Ledger Entry"); + using namespace ripple::test::jtx; + using namespace ripple::test::jtx::oracle; + + Env env(*this); + Account const owner("owner"); + env.fund(XRP(1'000), owner); + Oracle oracle(env, {.owner = owner}); + + // Malformed document id + auto res = Oracle::ledgerEntry(env, owner, NoneTag); + BEAST_EXPECT(res[jss::error].asString() == "invalidParams"); + std::vector invalid = {-1, 1.2, "", "Invalid"}; + for (auto const& v : invalid) + { + auto const res = Oracle::ledgerEntry(env, owner, v); + BEAST_EXPECT(res[jss::error].asString() == "malformedDocumentID"); + } + // Missing document id + res = Oracle::ledgerEntry(env, owner, std::nullopt); + BEAST_EXPECT(res[jss::error].asString() == "malformedRequest"); + + // Missing account + res = Oracle::ledgerEntry(env, std::nullopt, 1); + BEAST_EXPECT(res[jss::error].asString() == "malformedRequest"); + + // Malformed account + std::string malfAccount = to_string(owner.id()); + malfAccount.replace(10, 1, 1, '!'); + res = Oracle::ledgerEntry(env, malfAccount, 1); + BEAST_EXPECT(res[jss::error].asString() == "malformedAddress"); + } + + void + testOracleLedgerEntry() + { + testcase("Oracle Ledger Entry"); + using namespace ripple::test::jtx; + using namespace ripple::test::jtx::oracle; + + Env env(*this); + std::vector accounts; + std::vector oracles; + for (int i = 0; i < 10; ++i) + { + Account const owner(std::string("owner") + std::to_string(i)); + env.fund(XRP(1'000), owner); + // different accounts can have the same asset pair + Oracle oracle(env, {.owner = owner, .documentID = i}); + accounts.push_back(owner.id()); + oracles.push_back(oracle.documentID()); + // same account can have different asset pair + Oracle oracle1(env, {.owner = owner, .documentID = i + 10}); + accounts.push_back(owner.id()); + oracles.push_back(oracle1.documentID()); + } + for (int i = 0; i < accounts.size(); ++i) + { + auto const jv = [&]() { + // document id is uint32 + if (i % 2) + return Oracle::ledgerEntry(env, accounts[i], oracles[i]); + // document id is string + return Oracle::ledgerEntry( + env, accounts[i], std::to_string(oracles[i])); + }(); + try + { + BEAST_EXPECT( + jv[jss::node][jss::Owner] == to_string(accounts[i])); + } + catch (...) + { + fail(); + } + } + } + public: void run() override @@ -2304,6 +2386,8 @@ class LedgerRPC_test : public beast::unit_test::suite testQueue(); testLedgerAccountsOption(); testLedgerEntryDID(); + testInvalidOracleLedgerEntry(); + testOracleLedgerEntry(); forAllApiVersions(std::bind_front( &LedgerRPC_test::testLedgerEntryInvalidParams, this)); diff --git a/src/test/rpc/LedgerRequestRPC_test.cpp b/src/test/rpc/LedgerRequestRPC_test.cpp index 6c59e72c4b8..8922cd38386 100644 --- a/src/test/rpc/LedgerRequestRPC_test.cpp +++ b/src/test/rpc/LedgerRequestRPC_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include #include diff --git a/src/test/rpc/ManifestRPC_test.cpp b/src/test/rpc/ManifestRPC_test.cpp index 3c32f4d7ba7..fcf47a5745d 100644 --- a/src/test/rpc/ManifestRPC_test.cpp +++ b/src/test/rpc/ManifestRPC_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include diff --git a/src/test/rpc/NoRippleCheck_test.cpp b/src/test/rpc/NoRippleCheck_test.cpp index 3d34f55c90d..58f10c66dc1 100644 --- a/src/test/rpc/NoRippleCheck_test.cpp +++ b/src/test/rpc/NoRippleCheck_test.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/NoRipple_test.cpp b/src/test/rpc/NoRipple_test.cpp index 8da80e6483c..aa5e6e1efef 100644 --- a/src/test/rpc/NoRipple_test.cpp +++ b/src/test/rpc/NoRipple_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/NodeToShardRPC_test.cpp b/src/test/rpc/NodeToShardRPC_test.cpp index 7736d776995..ec1ff367c1e 100644 --- a/src/test/rpc/NodeToShardRPC_test.cpp +++ b/src/test/rpc/NodeToShardRPC_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/OwnerInfo_test.cpp b/src/test/rpc/OwnerInfo_test.cpp index c510c35afc8..606f2274b88 100644 --- a/src/test/rpc/OwnerInfo_test.cpp +++ b/src/test/rpc/OwnerInfo_test.cpp @@ -18,10 +18,10 @@ //============================================================================== #include -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/Peers_test.cpp b/src/test/rpc/Peers_test.cpp index 43fa601e1c0..ab9b17b2593 100644 --- a/src/test/rpc/Peers_test.cpp +++ b/src/test/rpc/Peers_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include #include #include +#include +#include +#include #include namespace ripple { diff --git a/src/test/rpc/RPCCall_test.cpp b/src/test/rpc/RPCCall_test.cpp index 09096ba76af..f3aaf468a9e 100644 --- a/src/test/rpc/RPCCall_test.cpp +++ b/src/test/rpc/RPCCall_test.cpp @@ -15,13 +15,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include #include diff --git a/src/test/rpc/RPCOverload_test.cpp b/src/test/rpc/RPCOverload_test.cpp index 088a8179043..c3328fb0b28 100644 --- a/src/test/rpc/RPCOverload_test.cpp +++ b/src/test/rpc/RPCOverload_test.cpp @@ -15,12 +15,12 @@ */ //============================================================================== -#include -#include -#include #include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/ReportingETL_test.cpp b/src/test/rpc/ReportingETL_test.cpp index 078a51d7bcd..8a030938832 100644 --- a/src/test/rpc/ReportingETL_test.cpp +++ b/src/test/rpc/ReportingETL_test.cpp @@ -18,15 +18,15 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include -#include #include #include #include #include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/RobustTransaction_test.cpp b/src/test/rpc/RobustTransaction_test.cpp index 37b16c58d7f..b0506224f79 100644 --- a/src/test/rpc/RobustTransaction_test.cpp +++ b/src/test/rpc/RobustTransaction_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include #include #include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/Roles_test.cpp b/src/test/rpc/Roles_test.cpp index 079fd2f9f26..8cef5dcbc61 100644 --- a/src/test/rpc/Roles_test.cpp +++ b/src/test/rpc/Roles_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include #include #include +#include +#include +#include #include diff --git a/src/test/rpc/ServerInfo_test.cpp b/src/test/rpc/ServerInfo_test.cpp index ece98e99a7e..a2eaa63eb42 100644 --- a/src/test/rpc/ServerInfo_test.cpp +++ b/src/test/rpc/ServerInfo_test.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include #include +#include +#include +#include +#include #include diff --git a/src/test/rpc/ShardArchiveHandler_test.cpp b/src/test/rpc/ShardArchiveHandler_test.cpp index ee0bec1eadf..82f12fe49a9 100644 --- a/src/test/rpc/ShardArchiveHandler_test.cpp +++ b/src/test/rpc/ShardArchiveHandler_test.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/rpc/Status_test.cpp b/src/test/rpc/Status_test.cpp index ab94191e1de..1ae8b23c66c 100644 --- a/src/test/rpc/Status_test.cpp +++ b/src/test/rpc/Status_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/rpc/Subscribe_test.cpp b/src/test/rpc/Subscribe_test.cpp index 24ceb54bb94..f1cb2f9a135 100644 --- a/src/test/rpc/Subscribe_test.cpp +++ b/src/test/rpc/Subscribe_test.cpp @@ -15,17 +15,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/test/rpc/TransactionEntry_test.cpp b/src/test/rpc/TransactionEntry_test.cpp index 431c812d625..09423ed25d5 100644 --- a/src/test/rpc/TransactionEntry_test.cpp +++ b/src/test/rpc/TransactionEntry_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include diff --git a/src/test/rpc/TransactionHistory_test.cpp b/src/test/rpc/TransactionHistory_test.cpp index 862eaaee507..63151bdaeb6 100644 --- a/src/test/rpc/TransactionHistory_test.cpp +++ b/src/test/rpc/TransactionHistory_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include #include #include #include +#include +#include +#include namespace ripple { diff --git a/src/test/rpc/Transaction_test.cpp b/src/test/rpc/Transaction_test.cpp index ac02dd11cda..72a7681ce97 100644 --- a/src/test/rpc/Transaction_test.cpp +++ b/src/test/rpc/Transaction_test.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/rpc/ValidatorInfo_test.cpp b/src/test/rpc/ValidatorInfo_test.cpp index f45d6867596..603a0ad9d23 100644 --- a/src/test/rpc/ValidatorInfo_test.cpp +++ b/src/test/rpc/ValidatorInfo_test.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include #include +#include +#include +#include #include #include diff --git a/src/test/rpc/ValidatorRPC_test.cpp b/src/test/rpc/ValidatorRPC_test.cpp index c9b11cdb992..2bd4b69c37b 100644 --- a/src/test/rpc/ValidatorRPC_test.cpp +++ b/src/test/rpc/ValidatorRPC_test.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/test/rpc/Version_test.cpp b/src/test/rpc/Version_test.cpp index 34e55b2be93..b66e502b9f3 100644 --- a/src/test/rpc/Version_test.cpp +++ b/src/test/rpc/Version_test.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include #include +#include +#include namespace ripple { diff --git a/src/test/server/ServerStatus_test.cpp b/src/test/server/ServerStatus_test.cpp index 249b0fd4512..8aa7bf19f30 100644 --- a/src/test/server/ServerStatus_test.cpp +++ b/src/test/server/ServerStatus_test.cpp @@ -17,13 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -33,10 +37,6 @@ #include #include #include -#include -#include -#include -#include namespace ripple { namespace test { diff --git a/src/test/server/Server_test.cpp b/src/test/server/Server_test.cpp index b5eb71f361c..c7d7dc3b911 100644 --- a/src/test/server/Server_test.cpp +++ b/src/test/server/Server_test.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/test/shamap/FetchPack_test.cpp b/src/test/shamap/FetchPack_test.cpp index f15f3163e55..ac2d16ecc99 100644 --- a/src/test/shamap/FetchPack_test.cpp +++ b/src/test/shamap/FetchPack_test.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace tests { diff --git a/src/test/shamap/SHAMapSync_test.cpp b/src/test/shamap/SHAMapSync_test.cpp index 70e578b5fb5..627e97e152c 100644 --- a/src/test/shamap/SHAMapSync_test.cpp +++ b/src/test/shamap/SHAMapSync_test.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include +#include namespace ripple { namespace tests { diff --git a/src/test/shamap/SHAMap_test.cpp b/src/test/shamap/SHAMap_test.cpp index 83bbc13253e..c8c877935f5 100644 --- a/src/test/shamap/SHAMap_test.cpp +++ b/src/test/shamap/SHAMap_test.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include #include #include +#include +#include +#include +#include +#include namespace ripple { namespace tests { diff --git a/src/test/shamap/common.h b/src/test/shamap/common.h index d89acb988d7..2280c77d4a1 100644 --- a/src/test/shamap/common.h +++ b/src/test/shamap/common.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_SHAMAP_TESTS_COMMON_H_INCLUDED #define RIPPLE_SHAMAP_TESTS_COMMON_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { namespace tests { diff --git a/src/test/unit_test/FileDirGuard.h b/src/test/unit_test/FileDirGuard.h index 3c79fb11b8e..246ac262378 100644 --- a/src/test/unit_test/FileDirGuard.h +++ b/src/test/unit_test/FileDirGuard.h @@ -20,9 +20,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef TEST_UNIT_TEST_DIRGUARD_H #define TEST_UNIT_TEST_DIRGUARD_H -#include -#include #include +#include +#include namespace ripple { namespace test { diff --git a/src/test/unit_test/SuiteJournal.h b/src/test/unit_test/SuiteJournal.h index 0e80e83cd7e..211bec0e4d3 100644 --- a/src/test/unit_test/SuiteJournal.h +++ b/src/test/unit_test/SuiteJournal.h @@ -20,8 +20,8 @@ #ifndef TEST_UNIT_TEST_SUITE_JOURNAL_H #define TEST_UNIT_TEST_SUITE_JOURNAL_H -#include -#include +#include +#include namespace ripple { namespace test { diff --git a/src/test/unit_test/multi_runner.cpp b/src/test/unit_test/multi_runner.cpp index cd84c3c999f..60487cadfb8 100644 --- a/src/test/unit_test/multi_runner.cpp +++ b/src/test/unit_test/multi_runner.cpp @@ -19,7 +19,7 @@ #include -#include +#include #include diff --git a/src/test/unit_test/multi_runner.h b/src/test/unit_test/multi_runner.h index c003a99f998..a4435dd1af7 100644 --- a/src/test/unit_test/multi_runner.h +++ b/src/test/unit_test/multi_runner.h @@ -20,8 +20,8 @@ #ifndef TEST_UNIT_TEST_MULTI_RUNNER_H #define TEST_UNIT_TEST_MULTI_RUNNER_H -#include -#include +#include +#include #include #include diff --git a/src/ripple/README.md b/src/xrpld/README.md similarity index 100% rename from src/ripple/README.md rename to src/xrpld/README.md diff --git a/src/ripple/app/consensus/RCLCensorshipDetector.h b/src/xrpld/app/consensus/RCLCensorshipDetector.h similarity index 98% rename from src/ripple/app/consensus/RCLCensorshipDetector.h rename to src/xrpld/app/consensus/RCLCensorshipDetector.h index f661a80362b..12a768ca4c8 100644 --- a/src/ripple/app/consensus/RCLCensorshipDetector.h +++ b/src/xrpld/app/consensus/RCLCensorshipDetector.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_CONSENSUS_RCLCENSORSHIPDETECTOR_H_INCLUDED #define RIPPLE_APP_CONSENSUS_RCLCENSORSHIPDETECTOR_H_INCLUDED -#include -#include +#include +#include #include #include #include diff --git a/src/ripple/app/consensus/RCLConsensus.cpp b/src/xrpld/app/consensus/RCLConsensus.cpp similarity index 96% rename from src/ripple/app/consensus/RCLConsensus.cpp rename to src/xrpld/app/consensus/RCLConsensus.cpp index c0ebe06dd7e..7b061e10b31 100644 --- a/src/ripple/app/consensus/RCLConsensus.cpp +++ b/src/xrpld/app/consensus/RCLConsensus.cpp @@ -17,32 +17,32 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/consensus/RCLConsensus.h b/src/xrpld/app/consensus/RCLConsensus.h similarity index 96% rename from src/ripple/app/consensus/RCLConsensus.h rename to src/xrpld/app/consensus/RCLConsensus.h index f8c01e93caa..893e5cf0847 100644 --- a/src/ripple/app/consensus/RCLConsensus.h +++ b/src/xrpld/app/consensus/RCLConsensus.h @@ -20,21 +20,21 @@ #ifndef RIPPLE_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED #define RIPPLE_APP_CONSENSUS_RCLCONSENSUS_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/consensus/RCLCxLedger.h b/src/xrpld/app/consensus/RCLCxLedger.h similarity index 95% rename from src/ripple/app/consensus/RCLCxLedger.h rename to src/xrpld/app/consensus/RCLCxLedger.h index b30bef135c0..ed7ad9faeb7 100644 --- a/src/ripple/app/consensus/RCLCxLedger.h +++ b/src/xrpld/app/consensus/RCLCxLedger.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_CONSENSUS_RCLCXLEDGER_H_INCLUDED #define RIPPLE_APP_CONSENSUS_RCLCXLEDGER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/consensus/RCLCxPeerPos.cpp b/src/xrpld/app/consensus/RCLCxPeerPos.cpp similarity index 91% rename from src/ripple/app/consensus/RCLCxPeerPos.cpp rename to src/xrpld/app/consensus/RCLCxPeerPos.cpp index ee5a45b943f..74747853a2d 100644 --- a/src/ripple/app/consensus/RCLCxPeerPos.cpp +++ b/src/xrpld/app/consensus/RCLCxPeerPos.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/consensus/RCLCxPeerPos.h b/src/xrpld/app/consensus/RCLCxPeerPos.h similarity index 93% rename from src/ripple/app/consensus/RCLCxPeerPos.h rename to src/xrpld/app/consensus/RCLCxPeerPos.h index e82a85d422b..4236e2ab128 100644 --- a/src/ripple/app/consensus/RCLCxPeerPos.h +++ b/src/xrpld/app/consensus/RCLCxPeerPos.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED #define RIPPLE_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/consensus/RCLCxTx.h b/src/xrpld/app/consensus/RCLCxTx.h similarity index 97% rename from src/ripple/app/consensus/RCLCxTx.h rename to src/xrpld/app/consensus/RCLCxTx.h index c6abfdfee94..58e58ac3b7d 100644 --- a/src/ripple/app/consensus/RCLCxTx.h +++ b/src/xrpld/app/consensus/RCLCxTx.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_CONSENSUS_RCLCXTX_H_INCLUDED #define RIPPLE_APP_CONSENSUS_RCLCXTX_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/consensus/RCLValidations.cpp b/src/xrpld/app/consensus/RCLValidations.cpp similarity index 92% rename from src/ripple/app/consensus/RCLValidations.cpp rename to src/xrpld/app/consensus/RCLValidations.cpp index ab9391385dd..88e8d6c4e71 100644 --- a/src/ripple/app/consensus/RCLValidations.cpp +++ b/src/xrpld/app/consensus/RCLValidations.cpp @@ -17,19 +17,19 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/consensus/RCLValidations.h b/src/xrpld/app/consensus/RCLValidations.h similarity index 96% rename from src/ripple/app/consensus/RCLValidations.h rename to src/xrpld/app/consensus/RCLValidations.h index 93628fe1695..c0d08280fed 100644 --- a/src/ripple/app/consensus/RCLValidations.h +++ b/src/xrpld/app/consensus/RCLValidations.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED #define RIPPLE_APP_CONSENSUSS_VALIDATIONS_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/consensus/README.md b/src/xrpld/app/consensus/README.md similarity index 100% rename from src/ripple/app/consensus/README.md rename to src/xrpld/app/consensus/README.md diff --git a/src/ripple/app/ledger/AbstractFetchPackContainer.h b/src/xrpld/app/ledger/AbstractFetchPackContainer.h similarity index 96% rename from src/ripple/app/ledger/AbstractFetchPackContainer.h rename to src/xrpld/app/ledger/AbstractFetchPackContainer.h index 43552a757b5..2b27471c64a 100644 --- a/src/ripple/app/ledger/AbstractFetchPackContainer.h +++ b/src/xrpld/app/ledger/AbstractFetchPackContainer.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_ABSTRACTFETCHPACKCONTAINER_H_INCLUDED #define RIPPLE_APP_LEDGER_ABSTRACTFETCHPACKCONTAINER_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/AcceptedLedger.cpp b/src/xrpld/app/ledger/AcceptedLedger.cpp similarity index 95% rename from src/ripple/app/ledger/AcceptedLedger.cpp rename to src/xrpld/app/ledger/AcceptedLedger.cpp index 4f308653dcf..37c943679da 100644 --- a/src/ripple/app/ledger/AcceptedLedger.cpp +++ b/src/xrpld/app/ledger/AcceptedLedger.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/AcceptedLedger.h b/src/xrpld/app/ledger/AcceptedLedger.h similarity index 96% rename from src/ripple/app/ledger/AcceptedLedger.h rename to src/xrpld/app/ledger/AcceptedLedger.h index 0187fdfb679..65a782aef70 100644 --- a/src/ripple/app/ledger/AcceptedLedger.h +++ b/src/xrpld/app/ledger/AcceptedLedger.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_ACCEPTEDLEDGER_H_INCLUDED #define RIPPLE_APP_LEDGER_ACCEPTEDLEDGER_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.cpp b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp similarity index 93% rename from src/ripple/app/ledger/AcceptedLedgerTx.cpp rename to src/xrpld/app/ledger/AcceptedLedgerTx.cpp index 613a91e437a..e1ad68dff37 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.cpp +++ b/src/xrpld/app/ledger/AcceptedLedgerTx.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/AcceptedLedgerTx.h b/src/xrpld/app/ledger/AcceptedLedgerTx.h similarity index 97% rename from src/ripple/app/ledger/AcceptedLedgerTx.h rename to src/xrpld/app/ledger/AcceptedLedgerTx.h index 2995d447bba..725057aa02c 100644 --- a/src/ripple/app/ledger/AcceptedLedgerTx.h +++ b/src/xrpld/app/ledger/AcceptedLedgerTx.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_ACCEPTEDLEDGERTX_H_INCLUDED #define RIPPLE_APP_LEDGER_ACCEPTEDLEDGERTX_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/AccountStateSF.cpp b/src/xrpld/app/ledger/AccountStateSF.cpp similarity index 96% rename from src/ripple/app/ledger/AccountStateSF.cpp rename to src/xrpld/app/ledger/AccountStateSF.cpp index 5c66469d5ab..c1f2ca26fc5 100644 --- a/src/ripple/app/ledger/AccountStateSF.cpp +++ b/src/xrpld/app/ledger/AccountStateSF.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/AccountStateSF.h b/src/xrpld/app/ledger/AccountStateSF.h similarity index 92% rename from src/ripple/app/ledger/AccountStateSF.h rename to src/xrpld/app/ledger/AccountStateSF.h index 43822add593..16cc686e3de 100644 --- a/src/ripple/app/ledger/AccountStateSF.h +++ b/src/xrpld/app/ledger/AccountStateSF.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_ACCOUNTSTATESF_H_INCLUDED #define RIPPLE_APP_LEDGER_ACCOUNTSTATESF_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/BookListeners.cpp b/src/xrpld/app/ledger/BookListeners.cpp similarity index 94% rename from src/ripple/app/ledger/BookListeners.cpp rename to src/xrpld/app/ledger/BookListeners.cpp index 3c7e013e1dd..2379807a91a 100644 --- a/src/ripple/app/ledger/BookListeners.cpp +++ b/src/xrpld/app/ledger/BookListeners.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/BookListeners.h b/src/xrpld/app/ledger/BookListeners.h similarity index 96% rename from src/ripple/app/ledger/BookListeners.h rename to src/xrpld/app/ledger/BookListeners.h index 605cf6dc6af..6ac52de28ee 100644 --- a/src/ripple/app/ledger/BookListeners.h +++ b/src/xrpld/app/ledger/BookListeners.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_BOOKLISTENERS_H_INCLUDED #define RIPPLE_APP_LEDGER_BOOKLISTENERS_H_INCLUDED -#include -#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/BuildLedger.h b/src/xrpld/app/ledger/BuildLedger.h similarity index 96% rename from src/ripple/app/ledger/BuildLedger.h rename to src/xrpld/app/ledger/BuildLedger.h index acefee24e70..409fa3529c4 100644 --- a/src/ripple/app/ledger/BuildLedger.h +++ b/src/xrpld/app/ledger/BuildLedger.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_BUILD_LEDGER_H_INCLUDED #define RIPPLE_APP_LEDGER_BUILD_LEDGER_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.cpp b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp similarity index 88% rename from src/ripple/app/ledger/ConsensusTransSetSF.cpp rename to src/xrpld/app/ledger/ConsensusTransSetSF.cpp index 476c757515f..4aed7d94bf3 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.cpp +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/ConsensusTransSetSF.h b/src/xrpld/app/ledger/ConsensusTransSetSF.h similarity index 94% rename from src/ripple/app/ledger/ConsensusTransSetSF.h rename to src/xrpld/app/ledger/ConsensusTransSetSF.h index ad5b2a23a48..857f2b8eae2 100644 --- a/src/ripple/app/ledger/ConsensusTransSetSF.h +++ b/src/xrpld/app/ledger/ConsensusTransSetSF.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_CONSENSUSTRANSSETSF_H_INCLUDED #define RIPPLE_APP_LEDGER_CONSENSUSTRANSSETSF_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/InboundLedger.h b/src/xrpld/app/ledger/InboundLedger.h similarity index 95% rename from src/ripple/app/ledger/InboundLedger.h rename to src/xrpld/app/ledger/InboundLedger.h index 357a6fcad1e..62b6925d59c 100644 --- a/src/ripple/app/ledger/InboundLedger.h +++ b/src/xrpld/app/ledger/InboundLedger.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_LEDGER_INBOUNDLEDGER_H_INCLUDED #define RIPPLE_APP_LEDGER_INBOUNDLEDGER_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/ledger/InboundLedgers.h b/src/xrpld/app/ledger/InboundLedgers.h similarity index 96% rename from src/ripple/app/ledger/InboundLedgers.h rename to src/xrpld/app/ledger/InboundLedgers.h index b12760153e2..8d3deb9c2df 100644 --- a/src/ripple/app/ledger/InboundLedgers.h +++ b/src/xrpld/app/ledger/InboundLedgers.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_INBOUNDLEDGERS_H_INCLUDED #define RIPPLE_APP_LEDGER_INBOUNDLEDGERS_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/InboundTransactions.h b/src/xrpld/app/ledger/InboundTransactions.h similarity index 96% rename from src/ripple/app/ledger/InboundTransactions.h rename to src/xrpld/app/ledger/InboundTransactions.h index f5b44f38616..368375c07c5 100644 --- a/src/ripple/app/ledger/InboundTransactions.h +++ b/src/xrpld/app/ledger/InboundTransactions.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_INBOUNDTRANSACTIONS_H_INCLUDED #define RIPPLE_APP_LEDGER_INBOUNDTRANSACTIONS_H_INCLUDED -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/InboundTransactions.uml b/src/xrpld/app/ledger/InboundTransactions.uml similarity index 100% rename from src/ripple/app/ledger/InboundTransactions.uml rename to src/xrpld/app/ledger/InboundTransactions.uml diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/xrpld/app/ledger/Ledger.cpp similarity index 95% rename from src/ripple/app/ledger/Ledger.cpp rename to src/xrpld/app/ledger/Ledger.cpp index 7cd6f89cad3..bcd3b6d4ba7 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/xrpld/app/ledger/Ledger.cpp @@ -17,45 +17,45 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include +#include namespace ripple { @@ -793,7 +793,7 @@ Ledger::updateNegativeUNL() if (hasToDisable) { - newNUnl.emplace_back(sfDisabledValidator); + newNUnl.push_back(STObject::makeInnerObject(sfDisabledValidator)); newNUnl.back().setFieldVL( sfPublicKey, sle->getFieldVL(sfValidatorToDisable)); newNUnl.back().setFieldU32(sfFirstLedgerSequence, seq()); diff --git a/src/ripple/app/ledger/Ledger.h b/src/xrpld/app/ledger/Ledger.h similarity index 96% rename from src/ripple/app/ledger/Ledger.h rename to src/xrpld/app/ledger/Ledger.h index 051b322e27a..1591fae1472 100644 --- a/src/ripple/app/ledger/Ledger.h +++ b/src/xrpld/app/ledger/Ledger.h @@ -20,17 +20,17 @@ #ifndef RIPPLE_APP_LEDGER_LEDGER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/LedgerCleaner.h b/src/xrpld/app/ledger/LedgerCleaner.h similarity index 92% rename from src/ripple/app/ledger/LedgerCleaner.h rename to src/xrpld/app/ledger/LedgerCleaner.h index 9f82a851f21..251e8d51281 100644 --- a/src/ripple/app/ledger/LedgerCleaner.h +++ b/src/xrpld/app/ledger/LedgerCleaner.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERCLEANER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERCLEANER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/LedgerHistory.cpp b/src/xrpld/app/ledger/LedgerHistory.cpp similarity index 98% rename from src/ripple/app/ledger/LedgerHistory.cpp rename to src/xrpld/app/ledger/LedgerHistory.cpp index ed2ccd07434..30139e2155f 100644 --- a/src/ripple/app/ledger/LedgerHistory.cpp +++ b/src/xrpld/app/ledger/LedgerHistory.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/LedgerHistory.h b/src/xrpld/app/ledger/LedgerHistory.h similarity index 96% rename from src/ripple/app/ledger/LedgerHistory.h rename to src/xrpld/app/ledger/LedgerHistory.h index 092ad7d8371..9d414e4aad3 100644 --- a/src/ripple/app/ledger/LedgerHistory.h +++ b/src/xrpld/app/ledger/LedgerHistory.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERHISTORY_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERHISTORY_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/ledger/LedgerHolder.h b/src/xrpld/app/ledger/LedgerHolder.h similarity index 96% rename from src/ripple/app/ledger/LedgerHolder.h rename to src/xrpld/app/ledger/LedgerHolder.h index 93d67400e05..5636a8ca20d 100644 --- a/src/ripple/app/ledger/LedgerHolder.h +++ b/src/xrpld/app/ledger/LedgerHolder.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/LedgerMaster.h b/src/xrpld/app/ledger/LedgerMaster.h similarity index 94% rename from src/ripple/app/ledger/LedgerMaster.h rename to src/xrpld/app/ledger/LedgerMaster.h index 980506c2267..7921773e3f0 100644 --- a/src/ripple/app/ledger/LedgerMaster.h +++ b/src/xrpld/app/ledger/LedgerMaster.h @@ -20,23 +20,23 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERMASTER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERMASTER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/LedgerReplay.h b/src/xrpld/app/ledger/LedgerReplay.h similarity index 98% rename from src/ripple/app/ledger/LedgerReplay.h rename to src/xrpld/app/ledger/LedgerReplay.h index 0365dea1b7e..8e52c8d5d5d 100644 --- a/src/ripple/app/ledger/LedgerReplay.h +++ b/src/xrpld/app/ledger/LedgerReplay.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERREPLAY_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERREPLAY_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/app/ledger/LedgerReplayTask.h b/src/xrpld/app/ledger/LedgerReplayTask.h similarity index 97% rename from src/ripple/app/ledger/LedgerReplayTask.h rename to src/xrpld/app/ledger/LedgerReplayTask.h index 4330f0b6247..54863e70956 100644 --- a/src/ripple/app/ledger/LedgerReplayTask.h +++ b/src/xrpld/app/ledger/LedgerReplayTask.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERREPLAYTASK_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERREPLAYTASK_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/LedgerReplayer.h b/src/xrpld/app/ledger/LedgerReplayer.h similarity index 96% rename from src/ripple/app/ledger/LedgerReplayer.h rename to src/xrpld/app/ledger/LedgerReplayer.h index b06dd2cc858..4ce4b20b221 100644 --- a/src/ripple/app/ledger/LedgerReplayer.h +++ b/src/xrpld/app/ledger/LedgerReplayer.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERREPLAYER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/LedgerToJson.h b/src/xrpld/app/ledger/LedgerToJson.h similarity index 85% rename from src/ripple/app/ledger/LedgerToJson.h rename to src/xrpld/app/ledger/LedgerToJson.h index 78947ca91d1..8f9316cbc66 100644 --- a/src/ripple/app/ledger/LedgerToJson.h +++ b/src/xrpld/app/ledger/LedgerToJson.h @@ -20,16 +20,16 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERTOJSON_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERTOJSON_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/LocalTxs.h b/src/xrpld/app/ledger/LocalTxs.h similarity index 96% rename from src/ripple/app/ledger/LocalTxs.h rename to src/xrpld/app/ledger/LocalTxs.h index dfd644fd207..0c102b78b2e 100644 --- a/src/ripple/app/ledger/LocalTxs.h +++ b/src/xrpld/app/ledger/LocalTxs.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_LOCALTXS_H_INCLUDED #define RIPPLE_APP_LEDGER_LOCALTXS_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/OpenLedger.h b/src/xrpld/app/ledger/OpenLedger.h similarity index 96% rename from src/ripple/app/ledger/OpenLedger.h rename to src/xrpld/app/ledger/OpenLedger.h index e3cb2b10028..b218b1d6e11 100644 --- a/src/ripple/app/ledger/OpenLedger.h +++ b/src/xrpld/app/ledger/OpenLedger.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED #define RIPPLE_APP_LEDGER_OPENLEDGER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/OrderBookDB.cpp b/src/xrpld/app/ledger/OrderBookDB.cpp similarity index 96% rename from src/ripple/app/ledger/OrderBookDB.cpp rename to src/xrpld/app/ledger/OrderBookDB.cpp index e1fc8a248f0..d0eddadbacb 100644 --- a/src/ripple/app/ledger/OrderBookDB.cpp +++ b/src/xrpld/app/ledger/OrderBookDB.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/OrderBookDB.h b/src/xrpld/app/ledger/OrderBookDB.h similarity index 93% rename from src/ripple/app/ledger/OrderBookDB.h rename to src/xrpld/app/ledger/OrderBookDB.h index 45705a61572..ce0d9f0fafe 100644 --- a/src/ripple/app/ledger/OrderBookDB.h +++ b/src/xrpld/app/ledger/OrderBookDB.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_LEDGER_ORDERBOOKDB_H_INCLUDED #define RIPPLE_APP_LEDGER_ORDERBOOKDB_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/ledger/PendingSaves.h b/src/xrpld/app/ledger/PendingSaves.h similarity index 99% rename from src/ripple/app/ledger/PendingSaves.h rename to src/xrpld/app/ledger/PendingSaves.h index f031baf4a93..d296fcacc96 100644 --- a/src/ripple/app/ledger/PendingSaves.h +++ b/src/xrpld/app/ledger/PendingSaves.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_PENDINGSAVES_H_INCLUDED #define RIPPLE_APP_PENDINGSAVES_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/app/ledger/README.md b/src/xrpld/app/ledger/README.md similarity index 100% rename from src/ripple/app/ledger/README.md rename to src/xrpld/app/ledger/README.md diff --git a/src/ripple/app/ledger/TransactionMaster.h b/src/xrpld/app/ledger/TransactionMaster.h similarity index 93% rename from src/ripple/app/ledger/TransactionMaster.h rename to src/xrpld/app/ledger/TransactionMaster.h index 9bebac37d73..65f27af6021 100644 --- a/src/ripple/app/ledger/TransactionMaster.h +++ b/src/xrpld/app/ledger/TransactionMaster.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_LEDGER_TRANSACTIONMASTER_H_INCLUDED #define RIPPLE_APP_LEDGER_TRANSACTIONMASTER_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/TransactionStateSF.cpp b/src/xrpld/app/ledger/TransactionStateSF.cpp similarity index 96% rename from src/ripple/app/ledger/TransactionStateSF.cpp rename to src/xrpld/app/ledger/TransactionStateSF.cpp index f65de5f9997..fac28cd2aa8 100644 --- a/src/ripple/app/ledger/TransactionStateSF.cpp +++ b/src/xrpld/app/ledger/TransactionStateSF.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/TransactionStateSF.h b/src/xrpld/app/ledger/TransactionStateSF.h similarity index 92% rename from src/ripple/app/ledger/TransactionStateSF.h rename to src/xrpld/app/ledger/TransactionStateSF.h index 6a5fa69ebd1..721f1870621 100644 --- a/src/ripple/app/ledger/TransactionStateSF.h +++ b/src/xrpld/app/ledger/TransactionStateSF.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_TRANSACTIONSTATESF_H_INCLUDED #define RIPPLE_APP_LEDGER_TRANSACTIONSTATESF_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/BuildLedger.cpp b/src/xrpld/app/ledger/detail/BuildLedger.cpp similarity index 95% rename from src/ripple/app/ledger/impl/BuildLedger.cpp rename to src/xrpld/app/ledger/detail/BuildLedger.cpp index 363c110cd18..8c4a7a3f41d 100644 --- a/src/ripple/app/ledger/impl/BuildLedger.cpp +++ b/src/xrpld/app/ledger/detail/BuildLedger.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/InboundLedger.cpp b/src/xrpld/app/ledger/detail/InboundLedger.cpp similarity index 98% rename from src/ripple/app/ledger/impl/InboundLedger.cpp rename to src/xrpld/app/ledger/detail/InboundLedger.cpp index 53475988cbf..b98f24aed43 100644 --- a/src/ripple/app/ledger/impl/InboundLedger.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedger.cpp @@ -17,21 +17,21 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/ledger/impl/InboundLedgers.cpp b/src/xrpld/app/ledger/detail/InboundLedgers.cpp similarity index 96% rename from src/ripple/app/ledger/impl/InboundLedgers.cpp rename to src/xrpld/app/ledger/detail/InboundLedgers.cpp index 0bff434edbc..04964d2a921 100644 --- a/src/ripple/app/ledger/impl/InboundLedgers.cpp +++ b/src/xrpld/app/ledger/detail/InboundLedgers.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/ledger/impl/InboundTransactions.cpp b/src/xrpld/app/ledger/detail/InboundTransactions.cpp similarity index 95% rename from src/ripple/app/ledger/impl/InboundTransactions.cpp rename to src/xrpld/app/ledger/detail/InboundTransactions.cpp index 7a863bce16b..83b074f317a 100644 --- a/src/ripple/app/ledger/impl/InboundTransactions.cpp +++ b/src/xrpld/app/ledger/detail/InboundTransactions.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/impl/LedgerCleaner.cpp b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp similarity index 98% rename from src/ripple/app/ledger/impl/LedgerCleaner.cpp rename to src/xrpld/app/ledger/detail/LedgerCleaner.cpp index e5ee6409d34..3021c691c53 100644 --- a/src/ripple/app/ledger/impl/LedgerCleaner.cpp +++ b/src/xrpld/app/ledger/detail/LedgerCleaner.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp similarity index 95% rename from src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp rename to src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp index 3c19c6ee156..e079fb3ee27 100644 --- a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.cpp +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.h b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h similarity index 96% rename from src/ripple/app/ledger/impl/LedgerDeltaAcquire.h rename to src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h index 2f767cf27be..b0b2c76c245 100644 --- a/src/ripple/app/ledger/impl/LedgerDeltaAcquire.h +++ b/src/xrpld/app/ledger/detail/LedgerDeltaAcquire.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERDELTAACQUIRE_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERDELTAACQUIRE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/impl/LedgerMaster.cpp b/src/xrpld/app/ledger/detail/LedgerMaster.cpp similarity index 98% rename from src/ripple/app/ledger/impl/LedgerMaster.cpp rename to src/xrpld/app/ledger/detail/LedgerMaster.cpp index 339e872b312..094cab508c1 100644 --- a/src/ripple/app/ledger/impl/LedgerMaster.cpp +++ b/src/xrpld/app/ledger/detail/LedgerMaster.cpp @@ -17,41 +17,41 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/ledger/impl/LedgerReplay.cpp b/src/xrpld/app/ledger/detail/LedgerReplay.cpp similarity index 95% rename from src/ripple/app/ledger/impl/LedgerReplay.cpp rename to src/xrpld/app/ledger/detail/LedgerReplay.cpp index 4a917cedf4a..40b4f9e412b 100644 --- a/src/ripple/app/ledger/impl/LedgerReplay.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplay.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp b/src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.cpp similarity index 97% rename from src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp rename to src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.cpp index c5301be7ea2..7b9d881d544 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.h b/src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.h similarity index 97% rename from src/ripple/app/ledger/impl/LedgerReplayMsgHandler.h rename to src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.h index 169bedea057..151a21b9563 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayMsgHandler.h +++ b/src/xrpld/app/ledger/detail/LedgerReplayMsgHandler.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_LEDGER_LEDGERREPLAYMSGHANDLER_H_INCLUDED #define RIPPLE_APP_LEDGER_LEDGERREPLAYMSGHANDLER_H_INCLUDED -#include -#include +#include +#include namespace ripple { class Application; diff --git a/src/ripple/app/ledger/impl/LedgerReplayTask.cpp b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp similarity index 96% rename from src/ripple/app/ledger/impl/LedgerReplayTask.cpp rename to src/xrpld/app/ledger/detail/LedgerReplayTask.cpp index 46ce9815a6e..d7f29e33b3b 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayTask.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayTask.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LedgerReplayer.cpp b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp similarity index 97% rename from src/ripple/app/ledger/impl/LedgerReplayer.cpp rename to src/xrpld/app/ledger/detail/LedgerReplayer.cpp index 903f72dd117..4aa0e4beb79 100644 --- a/src/ripple/app/ledger/impl/LedgerReplayer.cpp +++ b/src/xrpld/app/ledger/detail/LedgerReplayer.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LedgerToJson.cpp b/src/xrpld/app/ledger/detail/LedgerToJson.cpp similarity index 96% rename from src/ripple/app/ledger/impl/LedgerToJson.cpp rename to src/xrpld/app/ledger/detail/LedgerToJson.cpp index 1310dd13a65..95b572e9736 100644 --- a/src/ripple/app/ledger/impl/LedgerToJson.cpp +++ b/src/xrpld/app/ledger/detail/LedgerToJson.cpp @@ -17,17 +17,17 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/LocalTxs.cpp b/src/xrpld/app/ledger/detail/LocalTxs.cpp similarity index 97% rename from src/ripple/app/ledger/impl/LocalTxs.cpp rename to src/xrpld/app/ledger/detail/LocalTxs.cpp index 789a29c19ee..5bc718e8148 100644 --- a/src/ripple/app/ledger/impl/LocalTxs.cpp +++ b/src/xrpld/app/ledger/detail/LocalTxs.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include /* This code prevents scenarios like the following: diff --git a/src/ripple/app/ledger/impl/OpenLedger.cpp b/src/xrpld/app/ledger/detail/OpenLedger.cpp similarity index 94% rename from src/ripple/app/ledger/impl/OpenLedger.cpp rename to src/xrpld/app/ledger/detail/OpenLedger.cpp index 7eef84fc554..461d98ae4ac 100644 --- a/src/ripple/app/ledger/impl/OpenLedger.cpp +++ b/src/xrpld/app/ledger/detail/OpenLedger.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/impl/SkipListAcquire.cpp b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp similarity index 96% rename from src/ripple/app/ledger/impl/SkipListAcquire.cpp rename to src/xrpld/app/ledger/detail/SkipListAcquire.cpp index aa9b8564eb3..1d1de62b61b 100644 --- a/src/ripple/app/ledger/impl/SkipListAcquire.cpp +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/SkipListAcquire.h b/src/xrpld/app/ledger/detail/SkipListAcquire.h similarity index 96% rename from src/ripple/app/ledger/impl/SkipListAcquire.h rename to src/xrpld/app/ledger/detail/SkipListAcquire.h index df24d68312c..03c8181df68 100644 --- a/src/ripple/app/ledger/impl/SkipListAcquire.h +++ b/src/xrpld/app/ledger/detail/SkipListAcquire.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_LEDGER_SKIPLISTACQUIRE_H_INCLUDED #define RIPPLE_APP_LEDGER_SKIPLISTACQUIRE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/ledger/impl/TimeoutCounter.cpp b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp similarity index 95% rename from src/ripple/app/ledger/impl/TimeoutCounter.cpp rename to src/xrpld/app/ledger/detail/TimeoutCounter.cpp index 9ea20c06384..9d677dbe5a1 100644 --- a/src/ripple/app/ledger/impl/TimeoutCounter.cpp +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/TimeoutCounter.h b/src/xrpld/app/ledger/detail/TimeoutCounter.h similarity index 96% rename from src/ripple/app/ledger/impl/TimeoutCounter.h rename to src/xrpld/app/ledger/detail/TimeoutCounter.h index 88eda551acc..228e879d4de 100644 --- a/src/ripple/app/ledger/impl/TimeoutCounter.h +++ b/src/xrpld/app/ledger/detail/TimeoutCounter.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_LEDGER_TIMEOUTCOUNTER_H_INCLUDED #define RIPPLE_APP_LEDGER_TIMEOUTCOUNTER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/ledger/impl/TransactionAcquire.cpp b/src/xrpld/app/ledger/detail/TransactionAcquire.cpp similarity index 94% rename from src/ripple/app/ledger/impl/TransactionAcquire.cpp rename to src/xrpld/app/ledger/detail/TransactionAcquire.cpp index 24a03a16ffb..b3561875e96 100644 --- a/src/ripple/app/ledger/impl/TransactionAcquire.cpp +++ b/src/xrpld/app/ledger/detail/TransactionAcquire.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/ledger/impl/TransactionAcquire.h b/src/xrpld/app/ledger/detail/TransactionAcquire.h similarity index 95% rename from src/ripple/app/ledger/impl/TransactionAcquire.h rename to src/xrpld/app/ledger/detail/TransactionAcquire.h index 3863868fae0..230bce2fc94 100644 --- a/src/ripple/app/ledger/impl/TransactionAcquire.h +++ b/src/xrpld/app/ledger/detail/TransactionAcquire.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_LEDGER_TRANSACTIONACQUIRE_H_INCLUDED #define RIPPLE_APP_LEDGER_TRANSACTIONACQUIRE_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/ledger/impl/TransactionMaster.cpp b/src/xrpld/app/ledger/detail/TransactionMaster.cpp similarity index 95% rename from src/ripple/app/ledger/impl/TransactionMaster.cpp rename to src/xrpld/app/ledger/detail/TransactionMaster.cpp index c4205887740..e2e1213a37e 100644 --- a/src/ripple/app/ledger/impl/TransactionMaster.cpp +++ b/src/xrpld/app/ledger/detail/TransactionMaster.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/main/Application.cpp b/src/xrpld/app/main/Application.cpp similarity index 95% rename from src/ripple/app/main/Application.cpp rename to src/xrpld/app/main/Application.cpp index 06e92d13bd8..b6d33cfea92 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/xrpld/app/main/Application.cpp @@ -17,63 +17,63 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -225,6 +225,7 @@ class ApplicationImp : public Application, public BasicApp std::unique_ptr mRelationalDatabase; std::unique_ptr mWalletDB; std::unique_ptr overlay_; + std::optional trapTxID_; boost::asio::signal_set m_signals; @@ -1255,6 +1256,12 @@ class ApplicationImp : public Application, public BasicApp return maxDisallowedLedger_; } + virtual const std::optional& + trapTxID() const override + { + return trapTxID_; + } + private: // For a newly-started validator, this is the greatest persisted ledger // and new validations must be greater than this. @@ -1273,7 +1280,11 @@ class ApplicationImp : public Application, public BasicApp loadLedgerFromFile(std::string const& ledgerID); bool - loadOldLedger(std::string const& ledgerID, bool replay, bool isFilename); + loadOldLedger( + std::string const& ledgerID, + bool replay, + bool isFilename, + std::optional trapTxID); void setMaxDisallowedLedger(); @@ -1405,7 +1416,8 @@ ApplicationImp::setup(boost::program_options::variables_map const& cmdline) if (!loadOldLedger( config_->START_LEDGER, startUp == Config::REPLAY, - startUp == Config::LOAD_FILE)) + startUp == Config::LOAD_FILE, + config_->TRAP_TX_HASH)) { JLOG(m_journal.error()) << "The specified ledger could not be loaded."; @@ -2087,7 +2099,8 @@ bool ApplicationImp::loadOldLedger( std::string const& ledgerID, bool replay, - bool isFileName) + bool isFileName, + std::optional trapTxID) { try { @@ -2234,6 +2247,11 @@ ApplicationImp::loadOldLedger( { (void)_; auto txID = tx->getTransactionID(); + if (trapTxID == txID) + { + trapTxID_ = txID; + JLOG(m_journal.debug()) << "Trap transaction set: " << txID; + } auto s = std::make_shared(); tx->add(*s); @@ -2248,6 +2266,14 @@ ApplicationImp::loadOldLedger( } m_ledgerMaster->takeReplay(std::move(replayData)); + + if (trapTxID && !trapTxID_) + { + JLOG(m_journal.fatal()) + << "Ledger " << replayLedger->info().seq + << " does not contain the transaction hash " << *trapTxID; + return false; + } } } catch (SHAMapMissingNode const& mn) diff --git a/src/ripple/app/main/Application.h b/src/xrpld/app/main/Application.h similarity index 95% rename from src/ripple/app/main/Application.h rename to src/xrpld/app/main/Application.h index 3fa8d13e870..57e6f1730e5 100644 --- a/src/ripple/app/main/Application.h +++ b/src/xrpld/app/main/Application.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_APP_MAIN_APPLICATION_H_INCLUDED #define RIPPLE_APP_MAIN_APPLICATION_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -284,6 +284,9 @@ class Application : public beast::PropertyStream::Source * than the last ledger it persisted. */ virtual LedgerIndex getMaxDisallowedLedger() = 0; + + virtual const std::optional& + trapTxID() const = 0; }; std::unique_ptr diff --git a/src/ripple/app/main/BasicApp.cpp b/src/xrpld/app/main/BasicApp.cpp similarity index 94% rename from src/ripple/app/main/BasicApp.cpp rename to src/xrpld/app/main/BasicApp.cpp index 5993df62fa7..504309d0838 100644 --- a/src/ripple/app/main/BasicApp.cpp +++ b/src/xrpld/app/main/BasicApp.cpp @@ -17,8 +17,8 @@ */ //============================================================================== -#include -#include +#include +#include BasicApp::BasicApp(std::size_t numberOfThreads) { diff --git a/src/ripple/app/main/BasicApp.h b/src/xrpld/app/main/BasicApp.h similarity index 100% rename from src/ripple/app/main/BasicApp.h rename to src/xrpld/app/main/BasicApp.h diff --git a/src/ripple/app/main/CollectorManager.cpp b/src/xrpld/app/main/CollectorManager.cpp similarity index 98% rename from src/ripple/app/main/CollectorManager.cpp rename to src/xrpld/app/main/CollectorManager.cpp index 6e6d0f47f24..ae7ff965f5c 100644 --- a/src/ripple/app/main/CollectorManager.cpp +++ b/src/xrpld/app/main/CollectorManager.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace ripple { diff --git a/src/ripple/app/main/CollectorManager.h b/src/xrpld/app/main/CollectorManager.h similarity index 95% rename from src/ripple/app/main/CollectorManager.h rename to src/xrpld/app/main/CollectorManager.h index 46e113082d4..0bb3ae65c47 100644 --- a/src/ripple/app/main/CollectorManager.h +++ b/src/xrpld/app/main/CollectorManager.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_MAIN_COLLECTORMANAGER_H_INCLUDED #define RIPPLE_APP_MAIN_COLLECTORMANAGER_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/app/main/DBInit.h b/src/xrpld/app/main/DBInit.h similarity index 100% rename from src/ripple/app/main/DBInit.h rename to src/xrpld/app/main/DBInit.h diff --git a/src/ripple/app/main/GRPCServer.cpp b/src/xrpld/app/main/GRPCServer.cpp similarity index 98% rename from src/ripple/app/main/GRPCServer.cpp rename to src/xrpld/app/main/GRPCServer.cpp index a535a4a1a53..5d5a79db393 100644 --- a/src/ripple/app/main/GRPCServer.cpp +++ b/src/xrpld/app/main/GRPCServer.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/app/main/GRPCServer.h b/src/xrpld/app/main/GRPCServer.h similarity index 95% rename from src/ripple/app/main/GRPCServer.h rename to src/xrpld/app/main/GRPCServer.h index 79780e10137..39bfc0c9760 100644 --- a/src/ripple/app/main/GRPCServer.h +++ b/src/xrpld/app/main/GRPCServer.h @@ -20,19 +20,19 @@ #ifndef RIPPLE_CORE_GRPCSERVER_H_INCLUDED #define RIPPLE_CORE_GRPCSERVER_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "org/xrpl/rpc/v1/xrp_ledger.grpc.pb.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include namespace ripple { diff --git a/src/ripple/app/main/LoadManager.cpp b/src/xrpld/app/main/LoadManager.cpp similarity index 95% rename from src/ripple/app/main/LoadManager.cpp rename to src/xrpld/app/main/LoadManager.cpp index 5e87063f000..f5dd8719470 100644 --- a/src/ripple/app/main/LoadManager.cpp +++ b/src/xrpld/app/main/LoadManager.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/main/LoadManager.h b/src/xrpld/app/main/LoadManager.h similarity index 98% rename from src/ripple/app/main/LoadManager.h rename to src/xrpld/app/main/LoadManager.h index 905006f5e41..f818068dcfa 100644 --- a/src/ripple/app/main/LoadManager.h +++ b/src/xrpld/app/main/LoadManager.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_MAIN_LOADMANAGER_H_INCLUDED #define RIPPLE_APP_MAIN_LOADMANAGER_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/app/main/Main.cpp b/src/xrpld/app/main/Main.cpp similarity index 94% rename from src/ripple/app/main/Main.cpp rename to src/xrpld/app/main/Main.cpp index 710e4e9674f..059d9758d39 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/xrpld/app/main/Main.cpp @@ -17,26 +17,26 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef ENABLE_TESTS -#include #include +#include #endif // ENABLE_TESTS #include @@ -400,6 +400,9 @@ run(int argc, char** argv) "net", "Get the initial ledger from the network.")( "nodetoshard", "Import node store into shards")( "replay", "Replay a ledger close.")( + "trap_tx_hash", + po::value(), + "Trap a specific transaction during replay.")( "start", "Start from a fresh Ledger.")( "startReporting", po::value(), @@ -558,6 +561,7 @@ run(int argc, char** argv) argc, argv); } + // LCOV_EXCL_START else { if (vm.count("unittest-jobs")) @@ -679,7 +683,25 @@ run(int argc, char** argv) { config->START_LEDGER = vm["ledger"].as(); if (vm.count("replay")) + { config->START_UP = Config::REPLAY; + if (vm.count("trap_tx_hash")) + { + uint256 tmp = {}; + auto hash = vm["trap_tx_hash"].as(); + if (tmp.parseHex(hash)) + { + config->TRAP_TX_HASH = tmp; + } + else + { + std::cerr << "Trap parameter was ill-formed, expected " + "valid transaction hash but received: " + << hash << std::endl; + return -1; + } + } + } else config->START_UP = Config::LOAD; } @@ -693,6 +715,13 @@ run(int argc, char** argv) config->START_UP = Config::LOAD; } + if (vm.count("trap_tx_hash") && vm.count("replay") == 0) + { + std::cerr << "Cannot use trap option without replay option" + << std::endl; + return -1; + } + if (vm.count("net") && !config->FAST_LOAD) { if ((config->START_UP == Config::LOAD) || @@ -828,6 +857,7 @@ run(int argc, char** argv) beast::setCurrentThreadName("rippled: rpc"); return RPCCall::fromCommandLine( *config, vm["parameters"].as>(), *logs); + // LCOV_EXCL_STOP } } // namespace ripple diff --git a/src/ripple/app/main/NodeIdentity.cpp b/src/xrpld/app/main/NodeIdentity.cpp similarity index 92% rename from src/ripple/app/main/NodeIdentity.cpp rename to src/xrpld/app/main/NodeIdentity.cpp index e66b9e8400f..e0b83d54c8d 100644 --- a/src/ripple/app/main/NodeIdentity.cpp +++ b/src/xrpld/app/main/NodeIdentity.cpp @@ -17,11 +17,11 @@ */ //============================================================================== -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/main/NodeIdentity.h b/src/xrpld/app/main/NodeIdentity.h similarity index 92% rename from src/ripple/app/main/NodeIdentity.h rename to src/xrpld/app/main/NodeIdentity.h index b82b3657aeb..b4da8651949 100644 --- a/src/ripple/app/main/NodeIdentity.h +++ b/src/xrpld/app/main/NodeIdentity.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_MAIN_NODEIDENTITY_H_INCLUDED #define RIPPLE_APP_MAIN_NODEIDENTITY_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/main/NodeStoreScheduler.cpp b/src/xrpld/app/main/NodeStoreScheduler.cpp similarity index 97% rename from src/ripple/app/main/NodeStoreScheduler.cpp rename to src/xrpld/app/main/NodeStoreScheduler.cpp index 0ac89096410..bf07e559fd3 100644 --- a/src/ripple/app/main/NodeStoreScheduler.cpp +++ b/src/xrpld/app/main/NodeStoreScheduler.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include #include namespace ripple { diff --git a/src/ripple/app/main/NodeStoreScheduler.h b/src/xrpld/app/main/NodeStoreScheduler.h similarity index 95% rename from src/ripple/app/main/NodeStoreScheduler.h rename to src/xrpld/app/main/NodeStoreScheduler.h index 5c68dc24f8d..b16142b2613 100644 --- a/src/ripple/app/main/NodeStoreScheduler.h +++ b/src/xrpld/app/main/NodeStoreScheduler.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_MAIN_NODESTORESCHEDULER_H_INCLUDED #define RIPPLE_APP_MAIN_NODESTORESCHEDULER_H_INCLUDED -#include -#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/main/Tuning.h b/src/xrpld/app/main/Tuning.h similarity index 100% rename from src/ripple/app/main/Tuning.h rename to src/xrpld/app/main/Tuning.h diff --git a/src/xrpld/app/misc/AMMHelpers.h b/src/xrpld/app/misc/AMMHelpers.h new file mode 100644 index 00000000000..8bf5a5c5f12 --- /dev/null +++ b/src/xrpld/app/misc/AMMHelpers.h @@ -0,0 +1,651 @@ +//------------------------------------------------------------------------------ +/* + This file is part of rippled: https://github.com/ripple/rippled + Copyright (c) 2023 Ripple Labs Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#ifndef RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED +#define RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace ripple { + +namespace detail { + +Number +reduceOffer(auto const& amount) +{ + static Number const reducedOfferPct(9999, -4); + + // Make sure the result is always less than amount or zero. + NumberRoundModeGuard mg(Number::towards_zero); + return amount * reducedOfferPct; +} + +} // namespace detail + +/** Calculate LP Tokens given AMM pool reserves. + * @param asset1 AMM one side of the pool reserve + * @param asset2 AMM another side of the pool reserve + * @return LP Tokens as IOU + */ +STAmount +ammLPTokens( + STAmount const& asset1, + STAmount const& asset2, + Issue const& lptIssue); + +/** Calculate LP Tokens given asset's deposit amount. + * @param asset1Balance current AMM asset1 balance + * @param asset1Deposit requested asset1 deposit amount + * @param lptAMMBalance AMM LPT balance + * @param tfee trading fee in basis points + * @return tokens + */ +STAmount +lpTokensIn( + STAmount const& asset1Balance, + STAmount const& asset1Deposit, + STAmount const& lptAMMBalance, + std::uint16_t tfee); + +/** Calculate asset deposit given LP Tokens. + * @param asset1Balance current AMM asset1 balance + * @param lpTokens LP Tokens + * @param lptAMMBalance AMM LPT balance + * @param tfee trading fee in basis points + * @return + */ +STAmount +ammAssetIn( + STAmount const& asset1Balance, + STAmount const& lptAMMBalance, + STAmount const& lpTokens, + std::uint16_t tfee); + +/** Calculate LP Tokens given asset's withdraw amount. Return 0 + * if can't calculate. + * @param asset1Balance current AMM asset1 balance + * @param asset1Withdraw requested asset1 withdraw amount + * @param lptAMMBalance AMM LPT balance + * @param tfee trading fee in basis points + * @return tokens out amount + */ +STAmount +lpTokensOut( + STAmount const& asset1Balance, + STAmount const& asset1Withdraw, + STAmount const& lptAMMBalance, + std::uint16_t tfee); + +/** Calculate asset withdrawal by tokens + * @param assetBalance balance of the asset being withdrawn + * @param lptAMMBalance total AMM Tokens balance + * @param lpTokens LP Tokens balance + * @param tfee trading fee in basis points + * @return calculated asset amount + */ +STAmount +withdrawByTokens( + STAmount const& assetBalance, + STAmount const& lptAMMBalance, + STAmount const& lpTokens, + std::uint16_t tfee); + +/** Check if the relative distance between the qualities + * is within the requested distance. + * @param calcQuality calculated quality + * @param reqQuality requested quality + * @param dist requested relative distance + * @return true if within dist, false otherwise + */ +inline bool +withinRelativeDistance( + Quality const& calcQuality, + Quality const& reqQuality, + Number const& dist) +{ + if (calcQuality == reqQuality) + return true; + auto const [min, max] = std::minmax(calcQuality, reqQuality); + // Relative distance is (max - min)/max. Can't use basic operations + // on Quality. Have to use Quality::rate() instead, which + // is inverse of quality: (1/max.rate - 1/min.rate)/(1/max.rate) + return ((min.rate() - max.rate()) / min.rate()) < dist; +} + +/** Check if the relative distance between the amounts + * is within the requested distance. + * @param calc calculated amount + * @param req requested amount + * @param dist requested relative distance + * @return true if within dist, false otherwise + */ +// clang-format off +template + requires( + std::is_same_v || std::is_same_v || + std::is_same_v || std::is_same_v) +bool +withinRelativeDistance(Amt const& calc, Amt const& req, Number const& dist) +{ + if (calc == req) + return true; + auto const [min, max] = std::minmax(calc, req); + return ((max - min) / max) < dist; +} +// clang-format on + +/** Solve quadratic equation to find takerGets or takerPays. Round + * to minimize the amount in order to maximize the quality. + */ +std::optional +solveQuadraticEqSmallest(Number const& a, Number const& b, Number const& c); + +/** Generate AMM offer starting with takerGets when AMM pool + * from the payment perspective is IOU(in)/XRP(out) + * Equations: + * Spot Price Quality after the offer is consumed: + * Qsp = (O - o) / (I + i) -- equation (1) + * where O is poolPays, I is poolGets, o is takerGets, i is takerPays + * Swap out: + * i = (I * o) / (O - o) * f -- equation (2) + * where f is (1 - tfee/100000), tfee is in basis points + * Effective price targetQuality: + * Qep = o / i -- equation (3) + * There are two scenarios to consider + * A) Qsp = Qep. Substitute i in (1) with (2) and solve for o + * and Qsp = targetQuality(Qt): + * o**2 + o * (I * Qt * (1 - 1 / f) - 2 * O) + O**2 - Qt * I * O = 0 + * B) Qep = Qsp. Substitute i in (3) with (2) and solve for o + * and Qep = targetQuality(Qt): + * o = O - I * Qt / f + * Since the scenario is not known a priori, both A and B are solved and + * the lowest value of o is takerGets. takerPays is calculated with + * swap out eq (2). If o is less or equal to 0 then the offer can't + * be generated. + */ +template +std::optional> +getAMMOfferStartWithTakerGets( + TAmounts const& pool, + Quality const& targetQuality, + std::uint16_t const& tfee) +{ + if (targetQuality.rate() == beast::zero) + return std::nullopt; + + NumberRoundModeGuard mg(Number::to_nearest); + auto const f = feeMult(tfee); + auto const a = 1; + auto const b = pool.in * (1 - 1 / f) / targetQuality.rate() - 2 * pool.out; + auto const c = + pool.out * pool.out - (pool.in * pool.out) / targetQuality.rate(); + + auto nTakerGets = solveQuadraticEqSmallest(a, b, c); + if (!nTakerGets || *nTakerGets <= 0) + return std::nullopt; // LCOV_EXCL_LINE + + auto const nTakerGetsConstraint = + pool.out - pool.in / (targetQuality.rate() * f); + if (nTakerGetsConstraint <= 0) + return std::nullopt; + + // Select the smallest to maximize the quality + if (nTakerGetsConstraint < *nTakerGets) + nTakerGets = nTakerGetsConstraint; + + auto getAmounts = [&pool, &tfee](Number const& nTakerGetsProposed) { + // Round downward to minimize the offer and to maximize the quality. + // This has the most impact when takerGets is XRP. + auto const takerGets = toAmount( + getIssue(pool.out), nTakerGetsProposed, Number::downward); + return TAmounts{ + swapAssetOut(pool, takerGets, tfee), takerGets}; + }; + + // Try to reduce the offer size to improve the quality. + // The quality might still not match the targetQuality for a tiny offer. + if (auto const amounts = getAmounts(*nTakerGets); + Quality{amounts} < targetQuality) + return getAmounts(detail::reduceOffer(amounts.out)); + else + return amounts; +} + +/** Generate AMM offer starting with takerPays when AMM pool + * from the payment perspective is XRP(in)/IOU(out) or IOU(in)/IOU(out). + * Equations: + * Spot Price Quality after the offer is consumed: + * Qsp = (O - o) / (I + i) -- equation (1) + * where O is poolPays, I is poolGets, o is takerGets, i is takerPays + * Swap in: + * o = (O * i * f) / (I + i * f) -- equation (2) + * where f is (1 - tfee/100000), tfee is in basis points + * Effective price quality: + * Qep = o / i -- equation (3) + * There are two scenarios to consider + * A) Qsp = Qep. Substitute o in (1) with (2) and solve for i + * and Qsp = targetQuality(Qt): + * i**2 * f + i * I * (1 + f) + I**2 - I * O / Qt = 0 + * B) Qep = Qsp. Substitute i in (3) with (2) and solve for i + * and Qep = targetQuality(Qt): + * i = O / Qt - I / f + * Since the scenario is not known a priori, both A and B are solved and + * the lowest value of i is takerPays. takerGets is calculated with + * swap in eq (2). If i is less or equal to 0 then the offer can't + * be generated. + */ +template +std::optional> +getAMMOfferStartWithTakerPays( + TAmounts const& pool, + Quality const& targetQuality, + std::uint16_t tfee) +{ + if (targetQuality.rate() == beast::zero) + return std::nullopt; + + NumberRoundModeGuard mg(Number::to_nearest); + auto const f = feeMult(tfee); + auto const& a = f; + auto const b = pool.in * (1 + f); + auto const c = + pool.in * pool.in - pool.in * pool.out * targetQuality.rate(); + + auto nTakerPays = solveQuadraticEqSmallest(a, b, c); + if (!nTakerPays || nTakerPays <= 0) + return std::nullopt; // LCOV_EXCL_LINE + + auto const nTakerPaysConstraint = + pool.out * targetQuality.rate() - pool.in / f; + if (nTakerPaysConstraint <= 0) + return std::nullopt; + + // Select the smallest to maximize the quality + if (nTakerPaysConstraint < *nTakerPays) + nTakerPays = nTakerPaysConstraint; + + auto getAmounts = [&pool, &tfee](Number const& nTakerPaysProposed) { + // Round downward to minimize the offer and to maximize the quality. + // This has the most impact when takerPays is XRP. + auto const takerPays = toAmount( + getIssue(pool.in), nTakerPaysProposed, Number::downward); + return TAmounts{ + takerPays, swapAssetIn(pool, takerPays, tfee)}; + }; + + // Try to reduce the offer size to improve the quality. + // The quality might still not match the targetQuality for a tiny offer. + if (auto const amounts = getAmounts(*nTakerPays); + Quality{amounts} < targetQuality) + return getAmounts(detail::reduceOffer(amounts.in)); + else + return amounts; +} + +/** Generate AMM offer so that either updated Spot Price Quality (SPQ) + * is equal to LOB quality (in this case AMM offer quality is + * better than LOB quality) or AMM offer is equal to LOB quality + * (in this case SPQ is better than LOB quality). + * Pre-amendment code calculates takerPays first. If takerGets is XRP, + * it is rounded down, which results in worse offer quality than + * LOB quality, and the offer might fail to generate. + * Post-amendment code calculates the XRP offer side first. The result + * is rounded down, which makes the offer quality better. + * It might not be possible to match either SPQ or AMM offer to LOB + * quality. This generally happens at higher fees. + * @param pool AMM pool balances + * @param quality requested quality + * @param tfee trading fee in basis points + * @return seated in/out amounts if the quality can be changed + */ +template +std::optional> +changeSpotPriceQuality( + TAmounts const& pool, + Quality const& quality, + std::uint16_t tfee, + Rules const& rules, + beast::Journal j) +{ + if (!rules.enabled(fixAMMv1_1)) + { + // Finds takerPays (i) and takerGets (o) such that given pool + // composition poolGets(I) and poolPays(O): (O - o) / (I + i) = quality. + // Where takerGets is calculated as the swapAssetIn (see below). + // The above equation produces the quadratic equation: + // i^2*(1-fee) + i*I*(2-fee) + I^2 - I*O/quality, + // which is solved for i, and o is found with swapAssetIn(). + auto const f = feeMult(tfee); // 1 - fee + auto const& a = f; + auto const b = pool.in * (1 + f); + Number const c = + pool.in * pool.in - pool.in * pool.out * quality.rate(); + if (auto const res = b * b - 4 * a * c; res < 0) + return std::nullopt; // LCOV_EXCL_LINE + else if (auto const nTakerPaysPropose = (-b + root2(res)) / (2 * a); + nTakerPaysPropose > 0) + { + auto const nTakerPays = [&]() { + // The fee might make the AMM offer quality less than CLOB + // quality. Therefore, AMM offer has to satisfy this constraint: + // o / i >= q. Substituting o with swapAssetIn() gives: i <= O / + // q - I / (1 - fee). + auto const nTakerPaysConstraint = + pool.out * quality.rate() - pool.in / f; + if (nTakerPaysPropose > nTakerPaysConstraint) + return nTakerPaysConstraint; + return nTakerPaysPropose; + }(); + if (nTakerPays <= 0) + { + JLOG(j.trace()) + << "changeSpotPriceQuality calc failed: " + << to_string(pool.in) << " " << to_string(pool.out) << " " + << quality << " " << tfee; + return std::nullopt; + } + auto const takerPays = + toAmount(getIssue(pool.in), nTakerPays, Number::upward); + // should not fail + if (auto const amounts = + TAmounts{ + takerPays, swapAssetIn(pool, takerPays, tfee)}; + Quality{amounts} < quality && + !withinRelativeDistance( + Quality{amounts}, quality, Number(1, -7))) + { + JLOG(j.error()) + << "changeSpotPriceQuality failed: " << to_string(pool.in) + << " " << to_string(pool.out) << " " + << " " << quality << " " << tfee << " " + << to_string(amounts.in) << " " << to_string(amounts.out); + Throw("changeSpotPriceQuality failed"); + } + else + { + JLOG(j.trace()) + << "changeSpotPriceQuality succeeded: " + << to_string(pool.in) << " " << to_string(pool.out) << " " + << " " << quality << " " << tfee << " " + << to_string(amounts.in) << " " << to_string(amounts.out); + return amounts; + } + } + JLOG(j.trace()) << "changeSpotPriceQuality calc failed: " + << to_string(pool.in) << " " << to_string(pool.out) + << " " << quality << " " << tfee; + return std::nullopt; + } + + // Generate the offer starting with XRP side. Return seated offer amounts + // if the offer can be generated, otherwise nullopt. + auto const amounts = [&]() { + if (isXRP(getIssue(pool.out))) + return getAMMOfferStartWithTakerGets(pool, quality, tfee); + return getAMMOfferStartWithTakerPays(pool, quality, tfee); + }(); + if (!amounts) + { + JLOG(j.trace()) << "changeSpotPrice calc failed: " << to_string(pool.in) + << " " << to_string(pool.out) << " " << quality << " " + << tfee << std::endl; + return std::nullopt; + } + + if (Quality{*amounts} < quality) + { + JLOG(j.error()) << "changeSpotPriceQuality failed: " + << to_string(pool.in) << " " << to_string(pool.out) + << " " << quality << " " << tfee << " " + << to_string(amounts->in) << " " + << to_string(amounts->out); + return std::nullopt; + } + + JLOG(j.trace()) << "changeSpotPriceQuality succeeded: " + << to_string(pool.in) << " " << to_string(pool.out) << " " + << " " << quality << " " << tfee << " " + << to_string(amounts->in) << " " << to_string(amounts->out); + + return amounts; +} + +/** AMM pool invariant - the product (A * B) after swap in/out has to remain + * at least the same: (A + in) * (B - out) >= A * B + * XRP round-off may result in a smaller product after swap in/out. + * To address this: + * - if on swapIn the out is XRP then the amount is round-off + * downward, making the product slightly larger since out + * value is reduced. + * - if on swapOut the in is XRP then the amount is round-off + * upward, making the product slightly larger since in + * value is increased. + */ + +/** Swap assetIn into the pool and swap out a proportional amount + * of the other asset. Implements AMM Swap in. + * @see [XLS30d:AMM + * Swap](https://github.com/XRPLF/XRPL-Standards/discussions/78) + * @param pool current AMM pool balances + * @param assetIn amount to swap in + * @param tfee trading fee in basis points + * @return + */ +template +TOut +swapAssetIn( + TAmounts const& pool, + TIn const& assetIn, + std::uint16_t tfee) +{ + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixAMMv1_1)) + { + // set rounding to always favor the amm. Clip to zero. + // calculate: + // pool.out - + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // and explicitly set the rounding modes + // Favoring the amm means we should: + // minimize: + // pool.out - + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // maximize: + // (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + // (pool.in * pool.out) + // minimize: + // (pool.in + assetIn * feeMult(tfee)), + // minimize: + // assetIn * feeMult(tfee) + // feeMult is: (1-fee), fee is tfee/100000 + // minimize: + // 1-fee + // maximize: + // fee + saveNumberRoundMode _{Number::getround()}; + + Number::setround(Number::upward); + auto const numerator = pool.in * pool.out; + auto const fee = getFee(tfee); + + Number::setround(Number::downward); + auto const denom = pool.in + assetIn * (1 - fee); + + if (denom.signum() <= 0) + return toAmount(getIssue(pool.out), 0); + + Number::setround(Number::upward); + auto const ratio = numerator / denom; + + Number::setround(Number::downward); + auto const swapOut = pool.out - ratio; + + if (swapOut.signum() < 0) + return toAmount(getIssue(pool.out), 0); + + return toAmount(getIssue(pool.out), swapOut, Number::downward); + } + else + { + return toAmount( + getIssue(pool.out), + pool.out - + (pool.in * pool.out) / (pool.in + assetIn * feeMult(tfee)), + Number::downward); + } +} + +/** Swap assetOut out of the pool and swap in a proportional amount + * of the other asset. Implements AMM Swap out. + * @see [XLS30d:AMM + * Swap](https://github.com/XRPLF/XRPL-Standards/discussions/78) + * @param pool current AMM pool balances + * @param assetOut amount to swap out + * @param tfee trading fee in basis points + * @return + */ +template +TIn +swapAssetOut( + TAmounts const& pool, + TOut const& assetOut, + std::uint16_t tfee) +{ + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixAMMv1_1)) + { + // set rounding to always favor the amm. Clip to zero. + // calculate: + // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / + // (1-tfee/100000) + // maximize: + // ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) + // maximize: + // (pool.in * pool.out) / (pool.out - assetOut) + // maximize: + // (pool.in * pool.out) + // minimize + // (pool.out - assetOut) + // minimize: + // (1-tfee/100000) + // maximize: + // tfee/100000 + + saveNumberRoundMode _{Number::getround()}; + + Number::setround(Number::upward); + auto const numerator = pool.in * pool.out; + + Number::setround(Number::downward); + auto const denom = pool.out - assetOut; + if (denom.signum() <= 0) + { + return toMaxAmount(getIssue(pool.in)); + } + + Number::setround(Number::upward); + auto const ratio = numerator / denom; + auto const numerator2 = ratio - pool.in; + auto const fee = getFee(tfee); + + Number::setround(Number::downward); + auto const feeMult = 1 - fee; + + Number::setround(Number::upward); + auto const swapIn = numerator2 / feeMult; + if (swapIn.signum() < 0) + return toAmount(getIssue(pool.in), 0); + + return toAmount(getIssue(pool.in), swapIn, Number::upward); + } + else + { + return toAmount( + getIssue(pool.in), + ((pool.in * pool.out) / (pool.out - assetOut) - pool.in) / + feeMult(tfee), + Number::upward); + } +} + +/** Return square of n. + */ +Number +square(Number const& n); + +/** Adjust LP tokens to deposit/withdraw. + * Amount type keeps 16 digits. Maintaining the LP balance by adding + * deposited tokens or subtracting withdrawn LP tokens from LP balance + * results in losing precision in LP balance. I.e. the resulting LP balance + * is less than the actual sum of LP tokens. To adjust for this, subtract + * old tokens balance from the new one for deposit or vice versa for + * withdraw to cancel out the precision loss. + * @param lptAMMBalance LPT AMM Balance + * @param lpTokens LP tokens to deposit or withdraw + * @param isDeposit true if deposit, false if withdraw + */ +STAmount +adjustLPTokens( + STAmount const& lptAMMBalance, + STAmount const& lpTokens, + bool isDeposit); + +/** Calls adjustLPTokens() and adjusts deposit or withdraw amounts if + * the adjusted LP tokens are less than the provided LP tokens. + * @param amountBalance asset1 pool balance + * @param amount asset1 to deposit or withdraw + * @param amount2 asset2 to deposit or withdraw + * @param lptAMMBalance LPT AMM Balance + * @param lpTokens LP tokens to deposit or withdraw + * @param tfee trading fee in basis points + * @param isDeposit true if deposit, false if withdraw + * @return + */ +std::tuple, STAmount> +adjustAmountsByLPTokens( + STAmount const& amountBalance, + STAmount const& amount, + std::optional const& amount2, + STAmount const& lptAMMBalance, + STAmount const& lpTokens, + std::uint16_t tfee, + bool isDeposit); + +/** Positive solution for quadratic equation: + * x = (-b + sqrt(b**2 + 4*a*c))/(2*a) + */ +Number +solveQuadraticEq(Number const& a, Number const& b, Number const& c); + +} // namespace ripple + +#endif // RIPPLE_APP_MISC_AMMHELPERS_H_INCLUDED diff --git a/src/ripple/app/misc/AMMUtils.h b/src/xrpld/app/misc/AMMUtils.h similarity index 85% rename from src/ripple/app/misc/AMMUtils.h rename to src/xrpld/app/misc/AMMUtils.h index c25503ceb9c..52fe819a28e 100644 --- a/src/ripple/app/misc/AMMUtils.h +++ b/src/xrpld/app/misc/AMMUtils.h @@ -19,12 +19,12 @@ #ifndef RIPPLE_APP_MISC_AMMUTILS_H_INLCUDED #define RIPPLE_APP_MISC_AMMUTILS_H_INLCUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { @@ -113,6 +113,16 @@ initializeFeeAuctionVote( Issue const& lptIssue, std::uint16_t tfee); +/** Return true if the Liquidity Provider is the only AMM provider, false + * otherwise. Return tecINTERNAL if encountered an unexpected condition, + * for instance Liquidity Provider has more than one LPToken trustline. + */ +Expected +isOnlyLiquidityProvider( + ReadView const& view, + Issue const& ammIssue, + AccountID const& lpAccount); + } // namespace ripple #endif // RIPPLE_APP_MISC_AMMUTILS_H_INLCUDED diff --git a/src/ripple/app/misc/AmendmentTable.h b/src/xrpld/app/misc/AmendmentTable.h similarity index 97% rename from src/ripple/app/misc/AmendmentTable.h rename to src/xrpld/app/misc/AmendmentTable.h index fef13d50ddb..538d7299f3b 100644 --- a/src/ripple/app/misc/AmendmentTable.h +++ b/src/xrpld/app/misc/AmendmentTable.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_MISC_AMENDMENTTABLE_H_INCLUDED #define RIPPLE_APP_MISC_AMENDMENTTABLE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/CanonicalTXSet.cpp b/src/xrpld/app/misc/CanonicalTXSet.cpp similarity index 98% rename from src/ripple/app/misc/CanonicalTXSet.cpp rename to src/xrpld/app/misc/CanonicalTXSet.cpp index e0415406aa1..41ee1988e1f 100644 --- a/src/ripple/app/misc/CanonicalTXSet.cpp +++ b/src/xrpld/app/misc/CanonicalTXSet.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/app/misc/CanonicalTXSet.h b/src/xrpld/app/misc/CanonicalTXSet.h similarity index 96% rename from src/ripple/app/misc/CanonicalTXSet.h rename to src/xrpld/app/misc/CanonicalTXSet.h index 3ca2179448f..b061ff10dd6 100644 --- a/src/ripple/app/misc/CanonicalTXSet.h +++ b/src/xrpld/app/misc/CanonicalTXSet.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_MISC_CANONICALTXSET_H_INCLUDED #define RIPPLE_APP_MISC_CANONICALTXSET_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/misc/DeliverMax.h b/src/xrpld/app/misc/DeliverMax.h similarity index 97% rename from src/ripple/app/misc/DeliverMax.h rename to src/xrpld/app/misc/DeliverMax.h index ddc20bdd7b4..3bc875ee4ba 100644 --- a/src/ripple/app/misc/DeliverMax.h +++ b/src/xrpld/app/misc/DeliverMax.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_MISC_DELIVERMAX_H_INCLUDED #define RIPPLE_APP_MISC_DELIVERMAX_H_INCLUDED -#include +#include #include #include diff --git a/src/ripple/app/misc/FeeEscalation.md b/src/xrpld/app/misc/FeeEscalation.md similarity index 100% rename from src/ripple/app/misc/FeeEscalation.md rename to src/xrpld/app/misc/FeeEscalation.md diff --git a/src/ripple/app/misc/FeeVote.h b/src/xrpld/app/misc/FeeVote.h similarity index 91% rename from src/ripple/app/misc/FeeVote.h rename to src/xrpld/app/misc/FeeVote.h index a90f82efb35..47769e21e4d 100644 --- a/src/ripple/app/misc/FeeVote.h +++ b/src/xrpld/app/misc/FeeVote.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_MISC_FEEVOTE_H_INCLUDED #define RIPPLE_APP_MISC_FEEVOTE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/misc/FeeVoteImpl.cpp b/src/xrpld/app/misc/FeeVoteImpl.cpp similarity index 97% rename from src/ripple/app/misc/FeeVoteImpl.cpp rename to src/xrpld/app/misc/FeeVoteImpl.cpp index 0d60dc6b78e..af57314ef6d 100644 --- a/src/ripple/app/misc/FeeVoteImpl.cpp +++ b/src/xrpld/app/misc/FeeVoteImpl.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/misc/HashRouter.cpp b/src/xrpld/app/misc/HashRouter.cpp similarity index 98% rename from src/ripple/app/misc/HashRouter.cpp rename to src/xrpld/app/misc/HashRouter.cpp index ce7f9cbfd1c..3f27bb55aa1 100644 --- a/src/ripple/app/misc/HashRouter.cpp +++ b/src/xrpld/app/misc/HashRouter.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/app/misc/HashRouter.h b/src/xrpld/app/misc/HashRouter.h similarity index 96% rename from src/ripple/app/misc/HashRouter.h rename to src/xrpld/app/misc/HashRouter.h index 2abe6788b36..8bd6d2f501d 100644 --- a/src/ripple/app/misc/HashRouter.h +++ b/src/xrpld/app/misc/HashRouter.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED #define RIPPLE_APP_MISC_HASHROUTER_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/LoadFeeTrack.h b/src/xrpld/app/misc/LoadFeeTrack.h similarity index 96% rename from src/ripple/app/misc/LoadFeeTrack.h rename to src/xrpld/app/misc/LoadFeeTrack.h index d670c0b7e11..6c37864e2fd 100644 --- a/src/ripple/app/misc/LoadFeeTrack.h +++ b/src/xrpld/app/misc/LoadFeeTrack.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_CORE_LOADFEETRACK_H_INCLUDED #define RIPPLE_CORE_LOADFEETRACK_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/Manifest.h b/src/xrpld/app/misc/Manifest.h similarity index 98% rename from src/ripple/app/misc/Manifest.h rename to src/xrpld/app/misc/Manifest.h index b1cb5d2f325..1b53fda77b5 100644 --- a/src/ripple/app/misc/Manifest.h +++ b/src/xrpld/app/misc/Manifest.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_MISC_MANIFEST_H_INCLUDED #define RIPPLE_APP_MISC_MANIFEST_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/NegativeUNLVote.cpp b/src/xrpld/app/misc/NegativeUNLVote.cpp similarity index 98% rename from src/ripple/app/misc/NegativeUNLVote.cpp rename to src/xrpld/app/misc/NegativeUNLVote.cpp index 9b616be6ce1..45d72bcd2b3 100644 --- a/src/ripple/app/misc/NegativeUNLVote.cpp +++ b/src/xrpld/app/misc/NegativeUNLVote.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/misc/NegativeUNLVote.h b/src/xrpld/app/misc/NegativeUNLVote.h similarity index 97% rename from src/ripple/app/misc/NegativeUNLVote.h rename to src/xrpld/app/misc/NegativeUNLVote.h index 6ba8b3bf26e..f0284f267a8 100644 --- a/src/ripple/app/misc/NegativeUNLVote.h +++ b/src/xrpld/app/misc/NegativeUNLVote.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_MISC_NEGATIVEUNLVOTE_H_INCLUDED #define RIPPLE_APP_MISC_NEGATIVEUNLVOTE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/xrpld/app/misc/NetworkOPs.cpp similarity index 98% rename from src/ripple/app/misc/NetworkOPs.cpp rename to src/xrpld/app/misc/NetworkOPs.cpp index f85974fc603..4def2dd5e3b 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/xrpld/app/misc/NetworkOPs.cpp @@ -17,57 +17,57 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/NetworkOPs.h b/src/xrpld/app/misc/NetworkOPs.h similarity index 97% rename from src/ripple/app/misc/NetworkOPs.h rename to src/xrpld/app/misc/NetworkOPs.h index f8c3c3df046..bf3ffe5caa1 100644 --- a/src/ripple/app/misc/NetworkOPs.h +++ b/src/xrpld/app/misc/NetworkOPs.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_APP_MISC_NETWORKOPS_H_INCLUDED #define RIPPLE_APP_MISC_NETWORKOPS_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/README.md b/src/xrpld/app/misc/README.md similarity index 100% rename from src/ripple/app/misc/README.md rename to src/xrpld/app/misc/README.md diff --git a/src/ripple/app/misc/SHAMapStore.h b/src/xrpld/app/misc/SHAMapStore.h similarity index 96% rename from src/ripple/app/misc/SHAMapStore.h rename to src/xrpld/app/misc/SHAMapStore.h index c42e5f5a52a..d8415713a76 100644 --- a/src/ripple/app/misc/SHAMapStore.h +++ b/src/xrpld/app/misc/SHAMapStore.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_MISC_SHAMAPSTORE_H_INCLUDED #define RIPPLE_APP_MISC_SHAMAPSTORE_H_INCLUDED -#include -#include -#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/misc/SHAMapStoreImp.cpp b/src/xrpld/app/misc/SHAMapStoreImp.cpp similarity index 97% rename from src/ripple/app/misc/SHAMapStoreImp.cpp rename to src/xrpld/app/misc/SHAMapStoreImp.cpp index d5cb07792dc..d32556a4b29 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.cpp +++ b/src/xrpld/app/misc/SHAMapStoreImp.cpp @@ -17,18 +17,18 @@ */ //============================================================================== -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/SHAMapStoreImp.h b/src/xrpld/app/misc/SHAMapStoreImp.h similarity index 96% rename from src/ripple/app/misc/SHAMapStoreImp.h rename to src/xrpld/app/misc/SHAMapStoreImp.h index 995ee0267bb..7d36f092be8 100644 --- a/src/ripple/app/misc/SHAMapStoreImp.h +++ b/src/xrpld/app/misc/SHAMapStoreImp.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_MISC_SHAMAPSTOREIMP_H_INCLUDED #define RIPPLE_APP_MISC_SHAMAPSTOREIMP_H_INCLUDED -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include + +#include #include #include #include diff --git a/src/ripple/app/misc/Transaction.h b/src/xrpld/app/misc/Transaction.h similarity index 97% rename from src/ripple/app/misc/Transaction.h rename to src/xrpld/app/misc/Transaction.h index 36815ba0aa0..a2ef496dffd 100644 --- a/src/ripple/app/misc/Transaction.h +++ b/src/xrpld/app/misc/Transaction.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_MISC_TRANSACTION_H_INCLUDED #define RIPPLE_APP_MISC_TRANSACTION_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/TxQ.h b/src/xrpld/app/misc/TxQ.h similarity index 99% rename from src/ripple/app/misc/TxQ.h rename to src/xrpld/app/misc/TxQ.h index 7be29b49021..b962d96d50f 100644 --- a/src/ripple/app/misc/TxQ.h +++ b/src/xrpld/app/misc/TxQ.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_TXQ_H_INCLUDED #define RIPPLE_TXQ_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/ValidatorKeys.h b/src/xrpld/app/misc/ValidatorKeys.h similarity index 94% rename from src/ripple/app/misc/ValidatorKeys.h rename to src/xrpld/app/misc/ValidatorKeys.h index a6b53841739..f5b9e5735a6 100644 --- a/src/ripple/app/misc/ValidatorKeys.h +++ b/src/xrpld/app/misc/ValidatorKeys.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_MISC_VALIDATOR_KEYS_H_INCLUDED #define RIPPLE_APP_MISC_VALIDATOR_KEYS_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/misc/ValidatorList.h b/src/xrpld/app/misc/ValidatorList.h similarity index 98% rename from src/ripple/app/misc/ValidatorList.h rename to src/xrpld/app/misc/ValidatorList.h index 280818abd35..543eba2f6b7 100644 --- a/src/ripple/app/misc/ValidatorList.h +++ b/src/xrpld/app/misc/ValidatorList.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED #define RIPPLE_APP_MISC_VALIDATORLIST_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include @@ -633,7 +633,7 @@ class ValidatorList */ std::optional getAvailable( - boost::beast::string_view const& pubKey, + std::string_view pubKey, std::optional forceVersion = {}); /** Return the number of configured validator list sites. */ diff --git a/src/ripple/app/misc/ValidatorSite.h b/src/xrpld/app/misc/ValidatorSite.h similarity index 96% rename from src/ripple/app/misc/ValidatorSite.h rename to src/xrpld/app/misc/ValidatorSite.h index 57606066bf0..39bf895807f 100644 --- a/src/ripple/app/misc/ValidatorSite.h +++ b/src/xrpld/app/misc/ValidatorSite.h @@ -20,13 +20,13 @@ #ifndef RIPPLE_APP_MISC_VALIDATORSITE_H_INCLUDED #define RIPPLE_APP_MISC_VALIDATORSITE_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/impl/AMMHelpers.cpp b/src/xrpld/app/misc/detail/AMMHelpers.cpp similarity index 79% rename from src/ripple/app/misc/impl/AMMHelpers.cpp rename to src/xrpld/app/misc/detail/AMMHelpers.cpp index 736743eaaf7..f10b4c15eb0 100644 --- a/src/ripple/app/misc/impl/AMMHelpers.cpp +++ b/src/xrpld/app/misc/detail/AMMHelpers.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { @@ -165,6 +165,13 @@ adjustAmountsByLPTokens( if (lpTokensActual < lpTokens) { + bool const ammRoundingEnabled = [&]() { + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixAMMv1_1)) + return true; + return false; + }(); + // Equal trade if (amount2) { @@ -172,10 +179,14 @@ adjustAmountsByLPTokens( auto const amountActual = toSTAmount(amount.issue(), fr * amount); auto const amount2Actual = toSTAmount(amount2->issue(), fr * *amount2); - return std::make_tuple( - amountActual < amount ? amountActual : amount, - amount2Actual < amount2 ? amount2Actual : amount2, - lpTokensActual); + if (!ammRoundingEnabled) + return std::make_tuple( + amountActual < amount ? amountActual : amount, + amount2Actual < amount2 ? amount2Actual : amount2, + lpTokensActual); + else + return std::make_tuple( + amountActual, amount2Actual, lpTokensActual); } // Single trade @@ -183,13 +194,19 @@ adjustAmountsByLPTokens( if (isDeposit) return ammAssetIn( amountBalance, lptAMMBalance, lpTokensActual, tfee); - else + else if (!ammRoundingEnabled) return withdrawByTokens( amountBalance, lptAMMBalance, lpTokens, tfee); + else + return withdrawByTokens( + amountBalance, lptAMMBalance, lpTokensActual, tfee); }(); - return amountActual < amount - ? std::make_tuple(amountActual, std::nullopt, lpTokensActual) - : std::make_tuple(amount, std::nullopt, lpTokensActual); + if (!ammRoundingEnabled) + return amountActual < amount + ? std::make_tuple(amountActual, std::nullopt, lpTokensActual) + : std::make_tuple(amount, std::nullopt, lpTokensActual); + else + return std::make_tuple(amountActual, std::nullopt, lpTokensActual); } assert(lpTokensActual == lpTokens); @@ -203,4 +220,19 @@ solveQuadraticEq(Number const& a, Number const& b, Number const& c) return (-b + root2(b * b - 4 * a * c)) / (2 * a); } +// Minimize takerGets or takerPays +std::optional +solveQuadraticEqSmallest(Number const& a, Number const& b, Number const& c) +{ + auto const d = b * b - 4 * a * c; + if (d < 0) + return std::nullopt; + // use numerically stable citardauq formula for quadratic equation solution + // https://people.csail.mit.edu/bkph/articles/Quadratics.pdf + if (b > 0) + return (2 * c) / (-b - root2(d)); + else + return (2 * c) / (-b + root2(d)); +} + } // namespace ripple diff --git a/src/ripple/app/misc/impl/AMMUtils.cpp b/src/xrpld/app/misc/detail/AMMUtils.cpp similarity index 75% rename from src/ripple/app/misc/impl/AMMUtils.cpp rename to src/xrpld/app/misc/detail/AMMUtils.cpp index cf4da2c5d85..efc80cf17b6 100644 --- a/src/ripple/app/misc/impl/AMMUtils.cpp +++ b/src/xrpld/app/misc/detail/AMMUtils.cpp @@ -16,12 +16,12 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { @@ -312,7 +312,7 @@ initializeFeeAuctionVote( auto const& rules = view.rules(); // AMM creator gets the voting slot. STArray voteSlots; - STObject voteEntry = STObject::makeInnerObject(sfVoteEntry, rules); + STObject voteEntry = STObject::makeInnerObject(sfVoteEntry); if (tfee != 0) voteEntry.setFieldU16(sfTradingFee, tfee); voteEntry.setFieldU32(sfVoteWeight, VOTE_WEIGHT_SCALE_FACTOR); @@ -325,7 +325,7 @@ initializeFeeAuctionVote( if (rules.enabled(fixInnerObjTemplate) && !ammSle->isFieldPresent(sfAuctionSlot)) { - STObject auctionSlot = STObject::makeInnerObject(sfAuctionSlot, rules); + STObject auctionSlot = STObject::makeInnerObject(sfAuctionSlot); ammSle->set(std::move(auctionSlot)); } STObject& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot); @@ -348,4 +348,86 @@ initializeFeeAuctionVote( auctionSlot.makeFieldAbsent(sfDiscountedFee); // LCOV_EXCL_LINE } +Expected +isOnlyLiquidityProvider( + ReadView const& view, + Issue const& ammIssue, + AccountID const& lpAccount) +{ + // Liquidity Provider (LP) must have one LPToken trustline + std::uint8_t nLPTokenTrustLines = 0; + // There are at most two IOU trustlines. One or both could be to the LP + // if LP is the issuer, or a different account if LP is not an issuer. + // For instance, if AMM has two tokens USD and EUR and LP is not the issuer + // of the tokens then the trustlines are between AMM account and the issuer. + std::uint8_t nIOUTrustLines = 0; + // There is only one AMM object + bool hasAMM = false; + // AMM LP has at most three trustlines and only one AMM object must exist. + // If there are more than five objects then it's either an error or + // there are more than one LP. Ten pages should be sufficient to include + // five objects. + std::uint8_t limit = 10; + auto const root = keylet::ownerDir(ammIssue.account); + auto currentIndex = root; + + // Iterate over AMM owner directory objects. + while (limit-- >= 1) + { + auto const ownerDir = view.read(currentIndex); + if (!ownerDir) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + for (auto const& key : ownerDir->getFieldV256(sfIndexes)) + { + auto const sle = view.read(keylet::child(key)); + if (!sle) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + // Only one AMM object + if (sle->getFieldU16(sfLedgerEntryType) == ltAMM) + { + if (hasAMM) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + hasAMM = true; + continue; + } + if (sle->getFieldU16(sfLedgerEntryType) != ltRIPPLE_STATE) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + auto const lowLimit = sle->getFieldAmount(sfLowLimit); + auto const highLimit = sle->getFieldAmount(sfHighLimit); + auto const isLPTrustline = lowLimit.getIssuer() == lpAccount || + highLimit.getIssuer() == lpAccount; + auto const isLPTokenTrustline = + lowLimit.issue() == ammIssue || highLimit.issue() == ammIssue; + + // Liquidity Provider trustline + if (isLPTrustline) + { + // LPToken trustline + if (isLPTokenTrustline) + { + if (++nLPTokenTrustLines > 1) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + } + else if (++nIOUTrustLines > 2) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + } + // Another Liquidity Provider LPToken trustline + else if (isLPTokenTrustline) + return false; + else if (++nIOUTrustLines > 2) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + } + auto const uNodeNext = ownerDir->getFieldU64(sfIndexNext); + if (uNodeNext == 0) + { + if (nLPTokenTrustLines != 1 || nIOUTrustLines == 0 || + nIOUTrustLines > 2) + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE + return true; + } + currentIndex = keylet::page(root, uNodeNext); + } + return Unexpected(tecINTERNAL); // LCOV_EXCL_LINE +} + } // namespace ripple diff --git a/src/ripple/app/misc/impl/AccountTxPaging.cpp b/src/xrpld/app/misc/detail/AccountTxPaging.cpp similarity index 86% rename from src/ripple/app/misc/impl/AccountTxPaging.cpp rename to src/xrpld/app/misc/detail/AccountTxPaging.cpp index 433463e2826..898c41b40c4 100644 --- a/src/ripple/app/misc/impl/AccountTxPaging.cpp +++ b/src/xrpld/app/misc/detail/AccountTxPaging.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/impl/AccountTxPaging.h b/src/xrpld/app/misc/detail/AccountTxPaging.h similarity index 97% rename from src/ripple/app/misc/impl/AccountTxPaging.h rename to src/xrpld/app/misc/detail/AccountTxPaging.h index 6b8f235b5a8..23a5cbd9c23 100644 --- a/src/ripple/app/misc/impl/AccountTxPaging.h +++ b/src/xrpld/app/misc/detail/AccountTxPaging.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_MISC_IMPL_ACCOUNTTXPAGING_H_INCLUDED #define RIPPLE_APP_MISC_IMPL_ACCOUNTTXPAGING_H_INCLUDED -#include +#include #include #include #include diff --git a/src/ripple/app/misc/impl/AmendmentTable.cpp b/src/xrpld/app/misc/detail/AmendmentTable.cpp similarity index 99% rename from src/ripple/app/misc/impl/AmendmentTable.cpp rename to src/xrpld/app/misc/detail/AmendmentTable.cpp index 8f9556e0714..62b80890821 100644 --- a/src/ripple/app/misc/impl/AmendmentTable.cpp +++ b/src/xrpld/app/misc/detail/AmendmentTable.cpp @@ -17,14 +17,14 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/impl/DeliverMax.cpp b/src/xrpld/app/misc/detail/DeliverMax.cpp similarity index 95% rename from src/ripple/app/misc/impl/DeliverMax.cpp rename to src/xrpld/app/misc/detail/DeliverMax.cpp index 810b750a355..58a23599728 100644 --- a/src/ripple/app/misc/impl/DeliverMax.cpp +++ b/src/xrpld/app/misc/detail/DeliverMax.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include +#include -#include +#include namespace ripple { namespace RPC { diff --git a/src/ripple/app/misc/impl/LoadFeeTrack.cpp b/src/xrpld/app/misc/detail/LoadFeeTrack.cpp similarity index 90% rename from src/ripple/app/misc/impl/LoadFeeTrack.cpp rename to src/xrpld/app/misc/detail/LoadFeeTrack.cpp index 86d145c856c..1267af594d0 100644 --- a/src/ripple/app/misc/impl/LoadFeeTrack.cpp +++ b/src/xrpld/app/misc/detail/LoadFeeTrack.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/impl/Manifest.cpp b/src/xrpld/app/misc/detail/Manifest.cpp similarity index 98% rename from src/ripple/app/misc/impl/Manifest.cpp rename to src/xrpld/app/misc/detail/Manifest.cpp index 2916d6d2f32..a17858ceb39 100644 --- a/src/ripple/app/misc/impl/Manifest.cpp +++ b/src/xrpld/app/misc/detail/Manifest.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/misc/impl/Transaction.cpp b/src/xrpld/app/misc/detail/Transaction.cpp similarity index 89% rename from src/ripple/app/misc/impl/Transaction.cpp rename to src/xrpld/app/misc/detail/Transaction.cpp index e3ec41a25d4..e0c3f260fe5 100644 --- a/src/ripple/app/misc/impl/Transaction.cpp +++ b/src/xrpld/app/misc/detail/Transaction.cpp @@ -17,21 +17,21 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/xrpld/app/misc/detail/TxQ.cpp similarity index 99% rename from src/ripple/app/misc/impl/TxQ.cpp rename to src/xrpld/app/misc/detail/TxQ.cpp index faaca0655cf..159a700cc3f 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/xrpld/app/misc/detail/TxQ.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/misc/impl/ValidatorKeys.cpp b/src/xrpld/app/misc/detail/ValidatorKeys.cpp similarity index 93% rename from src/ripple/app/misc/impl/ValidatorKeys.cpp rename to src/xrpld/app/misc/detail/ValidatorKeys.cpp index 8da1992a2ef..2b36848c882 100644 --- a/src/ripple/app/misc/impl/ValidatorKeys.cpp +++ b/src/xrpld/app/misc/detail/ValidatorKeys.cpp @@ -17,13 +17,13 @@ */ //============================================================================== -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace ripple { ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j) diff --git a/src/ripple/app/misc/impl/ValidatorList.cpp b/src/xrpld/app/misc/detail/ValidatorList.cpp similarity index 98% rename from src/ripple/app/misc/impl/ValidatorList.cpp rename to src/xrpld/app/misc/detail/ValidatorList.cpp index ff5fbd90eac..a3854106a1c 100644 --- a/src/ripple/app/misc/impl/ValidatorList.cpp +++ b/src/xrpld/app/misc/detail/ValidatorList.cpp @@ -17,24 +17,23 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include -#include #include #include @@ -215,7 +214,8 @@ ValidatorList::load( return false; } - auto const id = parseBase58(TokenType::NodePublic, match[1]); + auto const id = + parseBase58(TokenType::NodePublic, match[1].str()); if (!id) { @@ -1707,7 +1707,7 @@ ValidatorList::for_each_available( std::optional ValidatorList::getAvailable( - boost::beast::string_view const& pubKey, + std::string_view pubKey, std::optional forceVersion /* = {} */) { std::shared_lock read_lock{mutex_}; diff --git a/src/ripple/app/misc/impl/ValidatorSite.cpp b/src/xrpld/app/misc/detail/ValidatorSite.cpp similarity index 98% rename from src/ripple/app/misc/impl/ValidatorSite.cpp rename to src/xrpld/app/misc/detail/ValidatorSite.cpp index 013d7e96ffd..0c12816c1b8 100644 --- a/src/ripple/app/misc/impl/ValidatorSite.cpp +++ b/src/xrpld/app/misc/detail/ValidatorSite.cpp @@ -17,16 +17,16 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/misc/detail/Work.h b/src/xrpld/app/misc/detail/Work.h similarity index 100% rename from src/ripple/app/misc/detail/Work.h rename to src/xrpld/app/misc/detail/Work.h diff --git a/src/ripple/app/misc/detail/WorkBase.h b/src/xrpld/app/misc/detail/WorkBase.h similarity index 98% rename from src/ripple/app/misc/detail/WorkBase.h rename to src/xrpld/app/misc/detail/WorkBase.h index 4b2c88f71a1..d7795af8bf0 100644 --- a/src/ripple/app/misc/detail/WorkBase.h +++ b/src/xrpld/app/misc/detail/WorkBase.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_MISC_DETAIL_WORKBASE_H_INCLUDED #define RIPPLE_APP_MISC_DETAIL_WORKBASE_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/detail/WorkFile.h b/src/xrpld/app/misc/detail/WorkFile.h similarity index 95% rename from src/ripple/app/misc/detail/WorkFile.h rename to src/xrpld/app/misc/detail/WorkFile.h index 2dc451feaca..266e5098cb6 100644 --- a/src/ripple/app/misc/detail/WorkFile.h +++ b/src/xrpld/app/misc/detail/WorkFile.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_MISC_DETAIL_WORKFILE_H_INCLUDED #define RIPPLE_APP_MISC_DETAIL_WORKFILE_H_INCLUDED -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/detail/WorkPlain.h b/src/xrpld/app/misc/detail/WorkPlain.h similarity index 98% rename from src/ripple/app/misc/detail/WorkPlain.h rename to src/xrpld/app/misc/detail/WorkPlain.h index e70d327c223..16bf424131f 100644 --- a/src/ripple/app/misc/detail/WorkPlain.h +++ b/src/xrpld/app/misc/detail/WorkPlain.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_MISC_DETAIL_WORKPLAIN_H_INCLUDED #define RIPPLE_APP_MISC_DETAIL_WORKPLAIN_H_INCLUDED -#include +#include namespace ripple { diff --git a/src/ripple/app/misc/detail/WorkSSL.h b/src/xrpld/app/misc/detail/WorkSSL.h similarity index 93% rename from src/ripple/app/misc/detail/WorkSSL.h rename to src/xrpld/app/misc/detail/WorkSSL.h index c7e3de614c2..d48f0b5fdff 100644 --- a/src/ripple/app/misc/detail/WorkSSL.h +++ b/src/xrpld/app/misc/detail/WorkSSL.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_MISC_DETAIL_WORKSSL_H_INCLUDED #define RIPPLE_APP_MISC_DETAIL_WORKSSL_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/misc/detail/impl/WorkSSL.cpp b/src/xrpld/app/misc/detail/detail/WorkSSL.cpp similarity index 98% rename from src/ripple/app/misc/detail/impl/WorkSSL.cpp rename to src/xrpld/app/misc/detail/detail/WorkSSL.cpp index 78a269e67cc..0285f435026 100644 --- a/src/ripple/app/misc/detail/impl/WorkSSL.cpp +++ b/src/xrpld/app/misc/detail/detail/WorkSSL.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { namespace detail { diff --git a/src/ripple/app/paths/AMMContext.h b/src/xrpld/app/paths/AMMContext.h similarity index 98% rename from src/ripple/app/paths/AMMContext.h rename to src/xrpld/app/paths/AMMContext.h index 06835189bb7..f744b8a6c91 100644 --- a/src/ripple/app/paths/AMMContext.h +++ b/src/xrpld/app/paths/AMMContext.h @@ -20,7 +20,7 @@ #ifndef RIPPLE_APP_PATHS_AMMCONTEXT_H_INCLUDED #define RIPPLE_APP_PATHS_AMMCONTEXT_H_INCLUDED -#include +#include #include diff --git a/src/ripple/app/paths/AMMLiquidity.h b/src/xrpld/app/paths/AMMLiquidity.h similarity index 94% rename from src/ripple/app/paths/AMMLiquidity.h rename to src/xrpld/app/paths/AMMLiquidity.h index 60155dbf13f..fe60d39262f 100644 --- a/src/ripple/app/paths/AMMLiquidity.h +++ b/src/xrpld/app/paths/AMMLiquidity.h @@ -20,14 +20,14 @@ #ifndef RIPPLE_APP_TX_AMMLIQUIDITY_H_INCLUDED #define RIPPLE_APP_TX_AMMLIQUIDITY_H_INCLUDED -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/AMMOffer.h b/src/xrpld/app/paths/AMMOffer.h similarity index 96% rename from src/ripple/app/paths/AMMOffer.h rename to src/xrpld/app/paths/AMMOffer.h index e3fb41e220b..e90a5b8611f 100644 --- a/src/ripple/app/paths/AMMOffer.h +++ b/src/xrpld/app/paths/AMMOffer.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_AMMOFFER_H_INCLUDED #define RIPPLE_APP_AMMOFFER_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { @@ -103,7 +103,6 @@ class AMMOffer limitOut( TAmounts const& offrAmt, TOut const& limit, - bool fixReducedOffers, bool roundUp) const; /** Limit in of the provided offer. If one-path then swapIn @@ -111,7 +110,8 @@ class AMMOffer * current quality. */ TAmounts - limitIn(TAmounts const& offrAmt, TIn const& limit) const; + limitIn(TAmounts const& offrAmt, TIn const& limit, bool roundUp) + const; QualityFunction getQualityFunc() const; diff --git a/src/ripple/app/paths/AccountCurrencies.cpp b/src/xrpld/app/paths/AccountCurrencies.cpp similarity index 98% rename from src/ripple/app/paths/AccountCurrencies.cpp rename to src/xrpld/app/paths/AccountCurrencies.cpp index 18452725b67..8646b46939a 100644 --- a/src/ripple/app/paths/AccountCurrencies.cpp +++ b/src/xrpld/app/paths/AccountCurrencies.cpp @@ -17,7 +17,7 @@ */ //============================================================================== -#include +#include namespace ripple { diff --git a/src/ripple/app/paths/AccountCurrencies.h b/src/xrpld/app/paths/AccountCurrencies.h similarity index 94% rename from src/ripple/app/paths/AccountCurrencies.h rename to src/xrpld/app/paths/AccountCurrencies.h index fa70ec2a081..26282e742c3 100644 --- a/src/ripple/app/paths/AccountCurrencies.h +++ b/src/xrpld/app/paths/AccountCurrencies.h @@ -20,8 +20,8 @@ #ifndef RIPPLE_APP_PATHS_ACCOUNTCURRENCIES_H_INCLUDED #define RIPPLE_APP_PATHS_ACCOUNTCURRENCIES_H_INCLUDED -#include -#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/Credit.cpp b/src/xrpld/app/paths/Credit.cpp similarity index 93% rename from src/ripple/app/paths/Credit.cpp rename to src/xrpld/app/paths/Credit.cpp index b9b19d29f90..c11f628a11d 100644 --- a/src/ripple/app/paths/Credit.cpp +++ b/src/xrpld/app/paths/Credit.cpp @@ -17,10 +17,10 @@ */ //============================================================================== -#include -#include -#include -#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/Credit.h b/src/xrpld/app/paths/Credit.h similarity index 95% rename from src/ripple/app/paths/Credit.h rename to src/xrpld/app/paths/Credit.h index dea9cbcde3e..1f9d5b04fe9 100644 --- a/src/ripple/app/paths/Credit.h +++ b/src/xrpld/app/paths/Credit.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_PATHS_CREDIT_H_INCLUDED #define RIPPLE_APP_PATHS_CREDIT_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/Flow.cpp b/src/xrpld/app/paths/Flow.cpp similarity index 94% rename from src/ripple/app/paths/Flow.cpp rename to src/xrpld/app/paths/Flow.cpp index 83379d34e79..c21d40c33b5 100644 --- a/src/ripple/app/paths/Flow.cpp +++ b/src/xrpld/app/paths/Flow.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/paths/Flow.h b/src/xrpld/app/paths/Flow.h similarity index 95% rename from src/ripple/app/paths/Flow.h rename to src/xrpld/app/paths/Flow.h index deafd1c7716..5390394b7f0 100644 --- a/src/ripple/app/paths/Flow.h +++ b/src/xrpld/app/paths/Flow.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_APP_PATHS_FLOW_H_INCLUDED #define RIPPLE_APP_PATHS_FLOW_H_INCLUDED -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/xrpld/app/paths/PathRequest.cpp similarity index 97% rename from src/ripple/app/paths/PathRequest.cpp rename to src/xrpld/app/paths/PathRequest.cpp index 948c6698ad1..4cd9f7d71f7 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/xrpld/app/paths/PathRequest.cpp @@ -17,22 +17,22 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include #include #include diff --git a/src/ripple/app/paths/PathRequest.h b/src/xrpld/app/paths/PathRequest.h similarity index 95% rename from src/ripple/app/paths/PathRequest.h rename to src/xrpld/app/paths/PathRequest.h index 70c286d6e1f..21f10d066ba 100644 --- a/src/ripple/app/paths/PathRequest.h +++ b/src/xrpld/app/paths/PathRequest.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_APP_PATHS_PATHREQUEST_H_INCLUDED #define RIPPLE_APP_PATHS_PATHREQUEST_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/paths/PathRequests.cpp b/src/xrpld/app/paths/PathRequests.cpp similarity index 96% rename from src/ripple/app/paths/PathRequests.cpp rename to src/xrpld/app/paths/PathRequests.cpp index 700cf137209..86560445ec7 100644 --- a/src/ripple/app/paths/PathRequests.cpp +++ b/src/xrpld/app/paths/PathRequests.cpp @@ -17,15 +17,15 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include namespace ripple { diff --git a/src/ripple/app/paths/PathRequests.h b/src/xrpld/app/paths/PathRequests.h similarity index 95% rename from src/ripple/app/paths/PathRequests.h rename to src/xrpld/app/paths/PathRequests.h index db683ee4c13..670790518a1 100644 --- a/src/ripple/app/paths/PathRequests.h +++ b/src/xrpld/app/paths/PathRequests.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_PATHS_PATHREQUESTS_H_INCLUDED #define RIPPLE_APP_PATHS_PATHREQUESTS_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include #include diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/xrpld/app/paths/Pathfinder.cpp similarity index 98% rename from src/ripple/app/paths/Pathfinder.cpp rename to src/xrpld/app/paths/Pathfinder.cpp index 556622ee7bf..885a8ae9b47 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/xrpld/app/paths/Pathfinder.cpp @@ -17,18 +17,18 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/paths/Pathfinder.h b/src/xrpld/app/paths/Pathfinder.h similarity index 96% rename from src/ripple/app/paths/Pathfinder.h rename to src/xrpld/app/paths/Pathfinder.h index 375e5e24677..01556a3c63f 100644 --- a/src/ripple/app/paths/Pathfinder.h +++ b/src/xrpld/app/paths/Pathfinder.h @@ -20,12 +20,12 @@ #ifndef RIPPLE_APP_PATHS_PATHFINDER_H_INCLUDED #define RIPPLE_APP_PATHS_PATHFINDER_H_INCLUDED -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/xrpld/app/paths/RippleCalc.cpp similarity index 95% rename from src/ripple/app/paths/RippleCalc.cpp rename to src/xrpld/app/paths/RippleCalc.cpp index 87ef694fa58..c7b2e1f01e0 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/xrpld/app/paths/RippleCalc.cpp @@ -17,12 +17,12 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include namespace ripple { namespace path { diff --git a/src/ripple/app/paths/RippleCalc.h b/src/xrpld/app/paths/RippleCalc.h similarity index 96% rename from src/ripple/app/paths/RippleCalc.h rename to src/xrpld/app/paths/RippleCalc.h index fd9ff598114..9e03da9c906 100644 --- a/src/ripple/app/paths/RippleCalc.h +++ b/src/xrpld/app/paths/RippleCalc.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_PATHS_RIPPLECALC_H_INCLUDED #define RIPPLE_APP_PATHS_RIPPLECALC_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include diff --git a/src/ripple/app/paths/RippleLineCache.cpp b/src/xrpld/app/paths/RippleLineCache.cpp similarity index 97% rename from src/ripple/app/paths/RippleLineCache.cpp rename to src/xrpld/app/paths/RippleLineCache.cpp index 2487924ff0e..0ff967c0821 100644 --- a/src/ripple/app/paths/RippleLineCache.cpp +++ b/src/xrpld/app/paths/RippleLineCache.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include namespace ripple { diff --git a/src/ripple/app/paths/RippleLineCache.h b/src/xrpld/app/paths/RippleLineCache.h similarity index 96% rename from src/ripple/app/paths/RippleLineCache.h rename to src/xrpld/app/paths/RippleLineCache.h index 590c50082f7..cde1d589f92 100644 --- a/src/ripple/app/paths/RippleLineCache.h +++ b/src/xrpld/app/paths/RippleLineCache.h @@ -20,10 +20,10 @@ #ifndef RIPPLE_APP_PATHS_RIPPLELINECACHE_H_INCLUDED #define RIPPLE_APP_PATHS_RIPPLELINECACHE_H_INCLUDED -#include -#include -#include -#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/paths/TrustLine.cpp b/src/xrpld/app/paths/TrustLine.cpp similarity index 96% rename from src/ripple/app/paths/TrustLine.cpp rename to src/xrpld/app/paths/TrustLine.cpp index 14a5d6f8823..6390c8d2117 100644 --- a/src/ripple/app/paths/TrustLine.cpp +++ b/src/xrpld/app/paths/TrustLine.cpp @@ -17,9 +17,9 @@ */ //============================================================================== -#include -#include -#include +#include +#include +#include #include #include diff --git a/src/ripple/app/paths/TrustLine.h b/src/xrpld/app/paths/TrustLine.h similarity index 97% rename from src/ripple/app/paths/TrustLine.h rename to src/xrpld/app/paths/TrustLine.h index 6b27dca3669..381ef471875 100644 --- a/src/ripple/app/paths/TrustLine.h +++ b/src/xrpld/app/paths/TrustLine.h @@ -20,11 +20,11 @@ #ifndef RIPPLE_APP_PATHS_RIPPLESTATE_H_INCLUDED #define RIPPLE_APP_PATHS_RIPPLESTATE_H_INCLUDED -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include #include diff --git a/src/ripple/app/paths/impl/AMMLiquidity.cpp b/src/xrpld/app/paths/detail/AMMLiquidity.cpp similarity index 93% rename from src/ripple/app/paths/impl/AMMLiquidity.cpp rename to src/xrpld/app/paths/detail/AMMLiquidity.cpp index bcc086e23da..8215cdee593 100644 --- a/src/ripple/app/paths/impl/AMMLiquidity.cpp +++ b/src/xrpld/app/paths/detail/AMMLiquidity.cpp @@ -16,9 +16,9 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //============================================================================== -#include +#include -#include +#include namespace ripple { @@ -205,8 +205,8 @@ AMMLiquidity::getOffer( return maxOffer(balances, view.rules()); } else if ( - auto const amounts = - changeSpotPriceQuality(balances, *clobQuality, tradingFee_)) + auto const amounts = changeSpotPriceQuality( + balances, *clobQuality, tradingFee_, view.rules(), j_)) { return AMMOffer( *this, *amounts, balances, Quality{*amounts}); @@ -239,7 +239,12 @@ AMMLiquidity::getOffer( return offer; } - JLOG(j_.error()) << "AMMLiquidity::getOffer, failed"; + JLOG(j_.error()) << "AMMLiquidity::getOffer, failed " + << ammContext_.multiPath() << " " + << ammContext_.curIters() << " " + << (clobQuality ? clobQuality->rate() : STAmount{}) + << " " << to_string(balances.in) << " " + << to_string(balances.out); } return std::nullopt; diff --git a/src/ripple/app/paths/impl/AMMOffer.cpp b/src/xrpld/app/paths/detail/AMMOffer.cpp similarity index 92% rename from src/ripple/app/paths/impl/AMMOffer.cpp rename to src/xrpld/app/paths/detail/AMMOffer.cpp index 697bac9c790..16ea8628f3b 100644 --- a/src/ripple/app/paths/impl/AMMOffer.cpp +++ b/src/xrpld/app/paths/detail/AMMOffer.cpp @@ -16,10 +16,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //==============================================================================/ -#include +#include -#include -#include +#include +#include namespace ripple { @@ -81,7 +81,6 @@ TAmounts AMMOffer::limitOut( TAmounts const& offrAmt, TOut const& limit, - bool fixReducedOffers, bool roundUp) const { // Change the offer size proportionally to the original offer quality @@ -92,7 +91,8 @@ AMMOffer::limitOut( // poolPays * poolGets < (poolPays - assetOut) * (poolGets + assetIn) if (ammLiquidity_.multiPath()) { - if (fixReducedOffers) + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixReducedOffersV1)) // It turns out that the ceil_out implementation has some slop in // it. ceil_out_strict removes that slop. But removing that slop // affects transaction outcomes, so the change must be made using @@ -110,11 +110,18 @@ template TAmounts AMMOffer::limitIn( TAmounts const& offrAmt, - TIn const& limit) const + TIn const& limit, + bool roundUp) const { // See the comments above in limitOut(). if (ammLiquidity_.multiPath()) + { + if (auto const& rules = getCurrentTransactionRules(); + rules && rules->enabled(fixReducedOffersV2)) + return quality().ceil_in_strict(offrAmt, limit, roundUp); + return quality().ceil_in(offrAmt, limit); + } return {limit, swapAssetIn(balances_, limit, ammLiquidity_.tradingFee())}; } diff --git a/src/ripple/app/paths/impl/AmountSpec.h b/src/xrpld/app/paths/detail/AmountSpec.h similarity index 97% rename from src/ripple/app/paths/impl/AmountSpec.h rename to src/xrpld/app/paths/detail/AmountSpec.h index ca814c7b3ac..8a1117f9920 100644 --- a/src/ripple/app/paths/impl/AmountSpec.h +++ b/src/xrpld/app/paths/detail/AmountSpec.h @@ -20,9 +20,9 @@ #ifndef RIPPLE_PATH_IMPL_AMOUNTSPEC_H_INCLUDED #define RIPPLE_PATH_IMPL_AMOUNTSPEC_H_INCLUDED -#include -#include -#include +#include +#include +#include #include diff --git a/src/ripple/app/paths/impl/BookStep.cpp b/src/xrpld/app/paths/detail/BookStep.cpp similarity index 86% rename from src/ripple/app/paths/impl/BookStep.cpp rename to src/xrpld/app/paths/detail/BookStep.cpp index 358dac4c796..4fa6f140aae 100644 --- a/src/ripple/app/paths/impl/BookStep.cpp +++ b/src/xrpld/app/paths/detail/BookStep.cpp @@ -17,21 +17,21 @@ */ //============================================================================== -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include @@ -275,6 +275,7 @@ class BookPaymentStep : public BookStep> using BookStep>::BookStep; using BookStep>::qualityUpperBound; + using typename BookStep>::OfferType; // Never limit self cross quality on a payment. template