From cb09e61d2f765435dbc4624d5ac3b214197f5622 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Thu, 13 Jul 2023 13:25:08 -0400 Subject: [PATCH 1/2] Update dependencies (#4595) Use the most recent versions in ConanCenter. * Due to a bug in Clang 16, you may get a compile error: "call to 'async_teardown' is ambiguous" * A compiler flag workaround is documented in `BUILD.md`. * At this time, building this with gcc 13 may require editing some files in `.conan/data` * A patch to support gcc13 may be added in a later PR. --------- Co-authored-by: Scott Schurr --- .github/actions/dependencies/action.yml | 5 +++- .github/workflows/macos.yml | 4 ++++ BUILD.md | 20 +++++++++++++--- conanfile.py | 23 +++++++++--------- external/snappy/conandata.yml | 24 +++++++++++++++++++ .../1.1.10-0001-fix-inlining-failure.patch | 13 ++++++++++ ....10-0003-fix-clobber-list-older-llvm.patch | 13 ++++++++++ src/ripple/basics/RangeSet.h | 1 + src/ripple/consensus/Consensus.h | 3 +++ src/ripple/json/impl/json_reader.cpp | 7 +++--- src/ripple/net/HTTPClient.h | 4 ++++ src/ripple/overlay/impl/Handshake.cpp | 24 ++++++++++--------- src/ripple/overlay/impl/PeerImp.cpp | 14 +++++------ src/ripple/rpc/impl/ServerHandler.cpp | 4 ++-- src/ripple/rpc/impl/WSInfoSub.h | 2 +- src/test/app/LedgerLoad_test.cpp | 2 +- src/test/jtx/TrustedPublisherServer.h | 4 ++-- 17 files changed, 124 insertions(+), 43 deletions(-) create mode 100644 external/snappy/patches/1.1.10-0001-fix-inlining-failure.patch create mode 100644 external/snappy/patches/1.1.10-0003-fix-clobber-list-older-llvm.patch diff --git a/.github/actions/dependencies/action.yml b/.github/actions/dependencies/action.yml index af570f21b82..3147e8774f2 100644 --- a/.github/actions/dependencies/action.yml +++ b/.github/actions/dependencies/action.yml @@ -6,10 +6,13 @@ inputs: runs: using: composite steps: + - name: unlock Conan + shell: bash + run: conan remove --locks - name: export custom recipes shell: bash run: | - conan export external/snappy snappy/1.1.9@ + conan export external/snappy snappy/1.1.10@ conan export external/soci soci/4.0.3@ - name: install dependencies shell: bash diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 888ad6f7692..1ebb9f690bb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -33,6 +33,10 @@ jobs: conan --version cmake --version env | sort + - name: configure Conan + run : | + conan profile get env.CXXFLAGS default || true + conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_ASIO_DISABLE_CONCEPTS"]' default - name: build uses: ./.github/actions/build with: diff --git a/BUILD.md b/BUILD.md index 4ef5e5aad2c..daef082fdd1 100644 --- a/BUILD.md +++ b/BUILD.md @@ -117,7 +117,7 @@ can't build earlier Boost versions. which allows you to statically link it with GCC, if you want. ``` - conan export external/snappy snappy/1.1.9@ + conan export external/snappy snappy/1.1.10@ ``` 5. Export our [Conan recipe for SOCI](./external/soci). @@ -180,7 +180,7 @@ can't build earlier Boost versions. `$OUTPUT_FOLDER/build/generators/conan_toolchain.cmake`. Single-config generators: - + ``` cmake -DCMAKE_TOOLCHAIN_FILE:FILEPATH=build/generators/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=Release .. ``` @@ -210,7 +210,7 @@ can't build earlier Boost versions. ``` Multi-config generators: - + ``` cmake --build . --config Release cmake --build . --config Debug @@ -279,6 +279,18 @@ conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_ASIO_HAS_STD_INVOKE_R ``` +### call to 'async_teardown' is ambiguous + +If you are compiling with an early version of Clang 16, then you might hit +a [regression][6] when compiling C++20 that manifests as an [error in a Boost +header][7]. You can workaround it by adding this preprocessor definition: + +``` +conan profile update 'env.CXXFLAGS="-DBOOST_ASIO_DISABLE_CONCEPTS"' default +conan profile update 'conf.tools.build:cxxflags+=["-DBOOST_ASIO_DISABLE_CONCEPTS"]' default +``` + + ### recompile with -fPIC If you get a linker error suggesting that you recompile Boost with @@ -319,6 +331,8 @@ If you want to experiment with a new package, follow these steps: [2]: https://en.cppreference.com/w/cpp/compiler_support/20 [3]: https://docs.conan.io/en/latest/getting_started.html [5]: https://en.wikipedia.org/wiki/Unity_build +[6]: https://github.com/boostorg/beast/issues/2648 +[7]: https://github.com/boostorg/beast/issues/2661 [build_type]: https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html [runtime]: https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html [toolchain]: https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html diff --git a/conanfile.py b/conanfile.py index 9c135d9e445..25d30d23c37 100644 --- a/conanfile.py +++ b/conanfile.py @@ -24,18 +24,18 @@ class Xrpl(ConanFile): } requires = [ - 'boost/1.77.0', + 'boost/1.82.0', 'date/3.0.1', - 'libarchive/3.6.0', - 'lz4/1.9.3', 'grpc/1.50.1', + 'libarchive/3.6.2', + 'lz4/1.9.3', 'nudb/2.0.8', - 'openssl/1.1.1m', - 'protobuf/3.21.4', - 'snappy/1.1.9', + 'openssl/1.1.1u', + 'protobuf/3.21.9', + 'snappy/1.1.10', 'soci/4.0.3', - 'sqlite3/3.38.0', - 'zlib/1.2.12', + 'sqlite3/3.42.0', + 'zlib/1.2.13', ] default_options = { @@ -51,6 +51,7 @@ class Xrpl(ConanFile): 'unity': False, 'cassandra-cpp-driver:shared': False, + 'cassandra-cpp-driver:use_atomic': None, 'date:header_only': True, 'grpc:shared': False, 'grpc:secure': True, @@ -101,12 +102,12 @@ def configure(self): def requirements(self): if self.options.jemalloc: - self.requires('jemalloc/5.2.1') + self.requires('jemalloc/5.3.0') if self.options.reporting: self.requires('cassandra-cpp-driver/2.15.3') - self.requires('libpq/13.6') + self.requires('libpq/14.7') if self.options.rocksdb: - self.requires('rocksdb/6.27.3') + self.requires('rocksdb/6.29.5') exports_sources = ( 'CMakeLists.txt', 'Builds/*', 'bin/getRippledInfo', 'src/*', 'cfg/*' diff --git a/external/snappy/conandata.yml b/external/snappy/conandata.yml index 6c12aed54a1..1488c7a2baf 100644 --- a/external/snappy/conandata.yml +++ b/external/snappy/conandata.yml @@ -1,4 +1,7 @@ sources: + "1.1.10": + url: "https://github.com/google/snappy/archive/1.1.10.tar.gz" + sha256: "49d831bffcc5f3d01482340fe5af59852ca2fe76c3e05df0e67203ebbe0f1d90" "1.1.9": url: "https://github.com/google/snappy/archive/1.1.9.tar.gz" sha256: "75c1fbb3d618dd3a0483bff0e26d0a92b495bbe5059c8b4f1c962b478b6e06e7" @@ -9,8 +12,29 @@ sources: url: "https://github.com/google/snappy/archive/1.1.7.tar.gz" sha256: "3dfa02e873ff51a11ee02b9ca391807f0c8ea0529a4924afa645fbf97163f9d4" patches: + "1.1.10": + - patch_file: "patches/1.1.10-0001-fix-inlining-failure.patch" + patch_description: "disable inlining for compilation error" + patch_type: "portability" + - patch_file: "patches/1.1.9-0002-no-Werror.patch" + patch_description: "disable 'warning as error' options" + patch_type: "portability" + - patch_file: "patches/1.1.10-0003-fix-clobber-list-older-llvm.patch" + patch_description: "disable inline asm on apple-clang" + patch_type: "portability" + - patch_file: "patches/1.1.9-0004-rtti-by-default.patch" + patch_description: "remove 'disable rtti'" + patch_type: "conan" "1.1.9": - patch_file: "patches/1.1.9-0001-fix-inlining-failure.patch" + patch_description: "disable inlining for compilation error" + patch_type: "portability" - patch_file: "patches/1.1.9-0002-no-Werror.patch" + patch_description: "disable 'warning as error' options" + patch_type: "portability" - patch_file: "patches/1.1.9-0003-fix-clobber-list-older-llvm.patch" + patch_description: "disable inline asm on apple-clang" + patch_type: "portability" - patch_file: "patches/1.1.9-0004-rtti-by-default.patch" + patch_description: "remove 'disable rtti'" + patch_type: "conan" diff --git a/external/snappy/patches/1.1.10-0001-fix-inlining-failure.patch b/external/snappy/patches/1.1.10-0001-fix-inlining-failure.patch new file mode 100644 index 00000000000..66b0f055219 --- /dev/null +++ b/external/snappy/patches/1.1.10-0001-fix-inlining-failure.patch @@ -0,0 +1,13 @@ +diff --git a/snappy-stubs-internal.h b/snappy-stubs-internal.h +index 1548ed7..3b4a9f3 100644 +--- a/snappy-stubs-internal.h ++++ b/snappy-stubs-internal.h +@@ -100,7 +100,7 @@ + + // Inlining hints. + #if HAVE_ATTRIBUTE_ALWAYS_INLINE +-#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) ++#define SNAPPY_ATTRIBUTE_ALWAYS_INLINE + #else + #define SNAPPY_ATTRIBUTE_ALWAYS_INLINE + #endif // HAVE_ATTRIBUTE_ALWAYS_INLINE diff --git a/external/snappy/patches/1.1.10-0003-fix-clobber-list-older-llvm.patch b/external/snappy/patches/1.1.10-0003-fix-clobber-list-older-llvm.patch new file mode 100644 index 00000000000..969ce3805da --- /dev/null +++ b/external/snappy/patches/1.1.10-0003-fix-clobber-list-older-llvm.patch @@ -0,0 +1,13 @@ +diff --git a/snappy.cc b/snappy.cc +index d414718..e4efb59 100644 +--- a/snappy.cc ++++ b/snappy.cc +@@ -1132,7 +1132,7 @@ inline size_t AdvanceToNextTagX86Optimized(const uint8_t** ip_p, size_t* tag) { + size_t literal_len = *tag >> 2; + size_t tag_type = *tag; + bool is_literal; +-#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__) ++#if defined(__GCC_ASM_FLAG_OUTPUTS__) && defined(__x86_64__) && ( (!defined(__clang__) && !defined(__APPLE__)) || (!defined(__APPLE__) && defined(__clang__) && (__clang_major__ >= 9)) || (defined(__APPLE__) && defined(__clang__) && (__clang_major__ > 11)) ) + // TODO clang misses the fact that the (c & 3) already correctly + // sets the zero flag. + asm("and $3, %k[tag_type]\n\t" diff --git a/src/ripple/basics/RangeSet.h b/src/ripple/basics/RangeSet.h index e003a229af0..3a9e470ddfb 100644 --- a/src/ripple/basics/RangeSet.h +++ b/src/ripple/basics/RangeSet.h @@ -28,6 +28,7 @@ #include #include +#include namespace ripple { diff --git a/src/ripple/consensus/Consensus.h b/src/ripple/consensus/Consensus.h index 71ceed71431..ea88e3232ee 100644 --- a/src/ripple/consensus/Consensus.h +++ b/src/ripple/consensus/Consensus.h @@ -30,6 +30,9 @@ #include #include #include + +#include +#include #include #include diff --git a/src/ripple/json/impl/json_reader.cpp b/src/ripple/json/impl/json_reader.cpp index c92bea6d7e0..e4124e9bc8f 100644 --- a/src/ripple/json/impl/json_reader.cpp +++ b/src/ripple/json/impl/json_reader.cpp @@ -30,8 +30,6 @@ namespace Json { // Implementation of class Reader // //////////////////////////////// -constexpr unsigned Reader::nest_limit; - static std::string codePointToUTF8(unsigned int cp) { @@ -924,8 +922,9 @@ Reader::getLocationLineAndColumn(Location location) const { int line, column; getLocationLineAndColumn(location, line, column); - char buffer[18 + 16 + 16 + 1]; - sprintf(buffer, "Line %d, Column %d", line, column); + constexpr std::size_t n = 18 + 16 + 16 + 1; + char buffer[n]; + snprintf(buffer, n, "Line %d, Column %d", line, column); return buffer; } diff --git a/src/ripple/net/HTTPClient.h b/src/ripple/net/HTTPClient.h index 8cadc84bcb2..f133e3ee04a 100644 --- a/src/ripple/net/HTTPClient.h +++ b/src/ripple/net/HTTPClient.h @@ -24,7 +24,11 @@ #include #include #include + #include +#include +#include +#include namespace ripple { diff --git a/src/ripple/overlay/impl/Handshake.cpp b/src/ripple/overlay/impl/Handshake.cpp index 9fe025787f8..8fe383e1d47 100644 --- a/src/ripple/overlay/impl/Handshake.cpp +++ b/src/ripple/overlay/impl/Handshake.cpp @@ -25,7 +25,9 @@ #include #include #include + #include + #include #include @@ -44,7 +46,7 @@ getFeatureValue( return {}; boost::smatch match; boost::regex rx(feature + "=([^;\\s]+)"); - auto const value = header->value().to_string(); + std::string const value = header->value(); if (boost::regex_search(value, match, rx)) return {match[1]}; return {}; @@ -233,7 +235,7 @@ verifyHandshake( { if (auto const iter = headers.find("Server-Domain"); iter != headers.end()) { - if (!isProperlyFormedTomlDomain(iter->value().to_string())) + if (!isProperlyFormedTomlDomain(iter->value())) throw std::runtime_error("Invalid server domain"); } @@ -241,7 +243,7 @@ verifyHandshake( { std::uint32_t nid; - if (!beast::lexicalCastChecked(nid, iter->value().to_string())) + if (!beast::lexicalCastChecked(nid, std::string(iter->value()))) throw std::runtime_error("Invalid peer network identifier"); if (networkID && nid != *networkID) @@ -251,7 +253,7 @@ verifyHandshake( if (auto const iter = headers.find("Network-Time"); iter != headers.end()) { auto const netTime = - [str = iter->value().to_string()]() -> TimeKeeper::time_point { + [str = std::string(iter->value())]() -> TimeKeeper::time_point { TimeKeeper::duration::rep val; if (beast::lexicalCastChecked(val, str)) @@ -286,8 +288,8 @@ verifyHandshake( PublicKey const publicKey = [&headers] { if (auto const iter = headers.find("Public-Key"); iter != headers.end()) { - auto pk = parseBase58( - TokenType::NodePublic, iter->value().to_string()); + auto pk = + parseBase58(TokenType::NodePublic, iter->value()); if (pk) { @@ -313,7 +315,7 @@ verifyHandshake( if (iter == headers.end()) throw std::runtime_error("No session signature specified"); - auto sig = base64_decode(iter->value().to_string()); + auto sig = base64_decode(iter->value()); if (!verifyDigest(publicKey, sharedValue, makeSlice(sig), false)) throw std::runtime_error("Failed to verify session"); @@ -325,8 +327,8 @@ verifyHandshake( if (auto const iter = headers.find("Local-IP"); iter != headers.end()) { boost::system::error_code ec; - auto const local_ip = boost::asio::ip::address::from_string( - iter->value().to_string(), ec); + auto const local_ip = + boost::asio::ip::address::from_string(iter->value(), ec); if (ec) throw std::runtime_error("Invalid Local-IP"); @@ -340,8 +342,8 @@ verifyHandshake( if (auto const iter = headers.find("Remote-IP"); iter != headers.end()) { boost::system::error_code ec; - auto const remote_ip = boost::asio::ip::address::from_string( - iter->value().to_string(), ec); + auto const remote_ip = + boost::asio::ip::address::from_string(iter->value(), ec); if (ec) throw std::runtime_error("Invalid Remote-IP"); diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp index a07c457458c..0d58a10abac 100644 --- a/src/ripple/overlay/impl/PeerImp.cpp +++ b/src/ripple/overlay/impl/PeerImp.cpp @@ -176,7 +176,7 @@ PeerImp::run() if (auto const iter = headers_.find("Closed-Ledger"); iter != headers_.end()) { - closed = parseLedgerHash(iter->value().to_string()); + closed = parseLedgerHash(iter->value()); if (!closed) fail("Malformed handshake data (1)"); @@ -185,7 +185,7 @@ PeerImp::run() if (auto const iter = headers_.find("Previous-Ledger"); iter != headers_.end()) { - previous = parseLedgerHash(iter->value().to_string()); + previous = parseLedgerHash(iter->value()); if (!previous) fail("Malformed handshake data (2)"); @@ -372,8 +372,8 @@ std::string PeerImp::getVersion() const { if (inbound_) - return headers_["User-Agent"].to_string(); - return headers_["Server"].to_string(); + return headers_["User-Agent"]; + return headers_["Server"]; } Json::Value @@ -399,8 +399,8 @@ PeerImp::json() if (auto const d = domain(); !d.empty()) ret[jss::server_domain] = domain(); - if (auto const nid = headers_["Network-ID"].to_string(); !nid.empty()) - ret[jss::network_id] = nid; + if (auto const nid = headers_["Network-ID"]; !nid.empty()) + ret[jss::network_id] = std::string(nid); ret[jss::load] = usage_.balance(); @@ -839,7 +839,7 @@ PeerImp::name() const std::string PeerImp::domain() const { - return headers_["Server-Domain"].to_string(); + return headers_["Server-Domain"]; } //------------------------------------------------------------------------------ diff --git a/src/ripple/rpc/impl/ServerHandler.cpp b/src/ripple/rpc/impl/ServerHandler.cpp index 85bff54232b..f33ecd625aa 100644 --- a/src/ripple/rpc/impl/ServerHandler.cpp +++ b/src/ripple/rpc/impl/ServerHandler.cpp @@ -248,11 +248,11 @@ build_map(boost::beast::http::fields const& h) std::map c; for (auto const& e : h) { - auto key(e.name_string().to_string()); + std::string key(e.name_string()); std::transform(key.begin(), key.end(), key.begin(), [](auto kc) { return std::tolower(static_cast(kc)); }); - c[key] = e.value().to_string(); + c[key] = e.value(); } return c; } diff --git a/src/ripple/rpc/impl/WSInfoSub.h b/src/ripple/rpc/impl/WSInfoSub.h index 8f386c8ebf9..267c8f98f24 100644 --- a/src/ripple/rpc/impl/WSInfoSub.h +++ b/src/ripple/rpc/impl/WSInfoSub.h @@ -50,7 +50,7 @@ class WSInfoSub : public InfoSub { auto it = h.find("X-User"); if (it != h.end()) - user_ = it->value().to_string(); + user_ = it->value(); fwdfor_ = std::string(forwardedFor(h)); } } diff --git a/src/test/app/LedgerLoad_test.cpp b/src/test/app/LedgerLoad_test.cpp index 2685014e474..93fc002ae2a 100644 --- a/src/test/app/LedgerLoad_test.cpp +++ b/src/test/app/LedgerLoad_test.cpp @@ -154,7 +154,7 @@ class LedgerLoad_test : public beast::unit_test::suite copy_file( sd.ledgerFile, ledgerFileCorrupt, - copy_option::overwrite_if_exists, + copy_options::overwrite_existing, ec); if (!BEAST_EXPECTS(!ec, ec.message())) return; diff --git a/src/test/jtx/TrustedPublisherServer.h b/src/test/jtx/TrustedPublisherServer.h index 985c1bfd6c0..da7ea1c137a 100644 --- a/src/test/jtx/TrustedPublisherServer.h +++ b/src/test/jtx/TrustedPublisherServer.h @@ -574,7 +574,7 @@ xbEQ+TUZ5jbJGSeBqNFKFeuOUQGJ46Io0jBSYd4rSmKUXkvElQwR+n7KF3jy1uAt if (ec) break; - auto path = req.target().to_string(); + std::string path = req.target(); res.insert("Server", "TrustedPublisherServer"); res.version(req.version()); res.keep_alive(req.keep_alive()); @@ -642,7 +642,7 @@ xbEQ+TUZ5jbJGSeBqNFKFeuOUQGJ46Io0jBSYd4rSmKUXkvElQwR+n7KF3jy1uAt auto const sleep_sec = boost::lexical_cast(path.substr(7)); std::this_thread::sleep_for( - std::chrono::seconds{sleep_sec}); + std::chrono::seconds(sleep_sec)); } else if (boost::starts_with(path, "/redirect")) { From 5ba1f984df57242aeb82f36f2afe1cfbeccbae83 Mon Sep 17 00:00:00 2001 From: Shawn Xie <35279399+shawnxie999@users.noreply.github.com> Date: Thu, 13 Jul 2023 21:00:32 -0400 Subject: [PATCH 2/2] Rename `allowClawback` flag to `allowTrustLineClawback` (#4617) Reason for this change is here XRPLF/XRPL-Standards#119 We would want to be explicit that this flag is exclusively for trustline. For new token types(eg. CFT), they will not utilize this flag for clawback, instead, they will turn clawback on/off on the token-level, which is more versatile. --- src/ripple/app/tx/impl/Clawback.cpp | 6 +- src/ripple/app/tx/impl/SetAccount.cpp | 8 +- src/ripple/protocol/LedgerFormats.h | 2 +- src/ripple/protocol/TxFlags.h | 2 +- src/ripple/rpc/handlers/AccountInfo.cpp | 7 +- src/test/app/Clawback_test.cpp | 166 ++++++++++++------------ src/test/jtx/flags.h | 4 +- src/test/rpc/AccountInfo_test.cpp | 16 ++- src/test/rpc/AccountSet_test.cpp | 6 +- 9 files changed, 113 insertions(+), 104 deletions(-) diff --git a/src/ripple/app/tx/impl/Clawback.cpp b/src/ripple/app/tx/impl/Clawback.cpp index d4a16e7adbc..4fb4d4bc8f8 100644 --- a/src/ripple/app/tx/impl/Clawback.cpp +++ b/src/ripple/app/tx/impl/Clawback.cpp @@ -65,8 +65,10 @@ Clawback::preclaim(PreclaimContext const& ctx) std::uint32_t const issuerFlagsIn = sleIssuer->getFieldU32(sfFlags); - // If AllowClawback is not set or NoFreeze is set, return no permission - if (!(issuerFlagsIn & lsfAllowClawback) || (issuerFlagsIn & lsfNoFreeze)) + // If AllowTrustLineClawback is not set or NoFreeze is set, return no + // permission + if (!(issuerFlagsIn & lsfAllowTrustLineClawback) || + (issuerFlagsIn & lsfNoFreeze)) return tecNO_PERMISSION; auto const sleRippleState = diff --git a/src/ripple/app/tx/impl/SetAccount.cpp b/src/ripple/app/tx/impl/SetAccount.cpp index 123a5bdc91e..b080fcfe86a 100644 --- a/src/ripple/app/tx/impl/SetAccount.cpp +++ b/src/ripple/app/tx/impl/SetAccount.cpp @@ -223,7 +223,7 @@ SetAccount::preclaim(PreclaimContext const& ctx) // if (ctx.view.rules().enabled(featureClawback)) { - if (uSetFlag == asfAllowClawback) + if (uSetFlag == asfAllowTrustLineClawback) { if (uFlagsIn & lsfNoFreeze) { @@ -240,7 +240,7 @@ SetAccount::preclaim(PreclaimContext const& ctx) else if (uSetFlag == asfNoFreeze) { // Cannot set NoFreeze if clawback is enabled - if (uFlagsIn & lsfAllowClawback) + if (uFlagsIn & lsfAllowTrustLineClawback) { JLOG(ctx.j.trace()) << "Can't set NoFreeze if clawback is enabled"; @@ -595,10 +595,10 @@ SetAccount::doApply() // Set flag for clawback if (ctx_.view().rules().enabled(featureClawback) && - uSetFlag == asfAllowClawback) + uSetFlag == asfAllowTrustLineClawback) { JLOG(j_.trace()) << "set allow clawback"; - uFlagsOut |= lsfAllowClawback; + uFlagsOut |= lsfAllowTrustLineClawback; } if (uFlagsIn != uFlagsOut) diff --git a/src/ripple/protocol/LedgerFormats.h b/src/ripple/protocol/LedgerFormats.h index b330a4de8bd..a613c3a470d 100644 --- a/src/ripple/protocol/LedgerFormats.h +++ b/src/ripple/protocol/LedgerFormats.h @@ -250,7 +250,7 @@ enum LedgerSpecificFlags { lsfDisallowIncomingTrustline = 0x20000000, // True, reject new trustlines (only if no issued assets) lsfAMM [[maybe_unused]] = 0x40000000, // True, AMM account - lsfAllowClawback = + lsfAllowTrustLineClawback = 0x80000000, // True, enable clawback // ltOFFER diff --git a/src/ripple/protocol/TxFlags.h b/src/ripple/protocol/TxFlags.h index 7b68876ffc0..75d405cb827 100644 --- a/src/ripple/protocol/TxFlags.h +++ b/src/ripple/protocol/TxFlags.h @@ -88,7 +88,7 @@ constexpr std::uint32_t asfDisallowIncomingNFTokenOffer = 12; constexpr std::uint32_t asfDisallowIncomingCheck = 13; constexpr std::uint32_t asfDisallowIncomingPayChan = 14; constexpr std::uint32_t asfDisallowIncomingTrustline = 15; -constexpr std::uint32_t asfAllowClawback = 16; +constexpr std::uint32_t asfAllowTrustLineClawback = 16; // OfferCreate flags: constexpr std::uint32_t tfPassive = 0x00010000; diff --git a/src/ripple/rpc/handlers/AccountInfo.cpp b/src/ripple/rpc/handlers/AccountInfo.cpp index c8d25a3d8b7..8c85670af6a 100644 --- a/src/ripple/rpc/handlers/AccountInfo.cpp +++ b/src/ripple/rpc/handlers/AccountInfo.cpp @@ -97,7 +97,8 @@ doAccountInfo(RPC::JsonContext& context) {"disallowIncomingTrustline", lsfDisallowIncomingTrustline}}}; static constexpr std::pair - allowClawbackFlag{"allowClawback", lsfAllowClawback}; + allowTrustLineClawbackFlag{ + "allowTrustLineClawback", lsfAllowTrustLineClawback}; auto const sleAccepted = ledger->read(keylet::account(accountID)); if (sleAccepted) @@ -128,8 +129,8 @@ doAccountInfo(RPC::JsonContext& context) } if (ledger->rules().enabled(featureClawback)) - acctFlags[allowClawbackFlag.first.data()] = - sleAccepted->isFlag(allowClawbackFlag.second); + acctFlags[allowTrustLineClawbackFlag.first.data()] = + sleAccepted->isFlag(allowTrustLineClawbackFlag.second); result[jss::account_flags] = std::move(acctFlags); diff --git a/src/test/app/Clawback_test.cpp b/src/test/app/Clawback_test.cpp index 33b9049790e..630e4836d8e 100644 --- a/src/test/app/Clawback_test.cpp +++ b/src/test/app/Clawback_test.cpp @@ -75,14 +75,14 @@ class Clawback_test : public beast::unit_test::suite } void - testAllowClawbackFlag(FeatureBitset features) + testAllowTrustLineClawbackFlag(FeatureBitset features) { - testcase("Enable AllowClawback flag"); + testcase("Enable AllowTrustLineClawback flag"); using namespace test::jtx; - // Test that one can successfully set asfAllowClawback flag. + // Test that one can successfully set asfAllowTrustLineClawback flag. // If successful, asfNoFreeze can no longer be set. - // Also, asfAllowClawback cannot be cleared. + // Also, asfAllowTrustLineClawback cannot be cleared. { Env env(*this, features); Account alice{"alice"}; @@ -90,23 +90,23 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - // set asfAllowClawback - env(fset(alice, asfAllowClawback)); + // set asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // clear asfAllowClawback does nothing - env(fclear(alice, asfAllowClawback)); + // clear asfAllowTrustLineClawback does nothing + env(fclear(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // asfNoFreeze cannot be set when asfAllowClawback is set + // asfNoFreeze cannot be set when asfAllowTrustLineClawback is set env.require(nflags(alice, asfNoFreeze)); env(fset(alice, asfNoFreeze), ter(tecNO_PERMISSION)); env.close(); } - // Test that asfAllowClawback cannot be set when + // Test that asfAllowTrustLineClawback cannot be set when // asfNoFreeze has been set { Env env(*this, features); @@ -124,14 +124,15 @@ class Clawback_test : public beast::unit_test::suite // NoFreeze is set env.require(flags(alice, asfNoFreeze)); - // asfAllowClawback cannot be set if asfNoFreeze is set - env(fset(alice, asfAllowClawback), ter(tecNO_PERMISSION)); + // asfAllowTrustLineClawback cannot be set if asfNoFreeze is set + env(fset(alice, asfAllowTrustLineClawback), ter(tecNO_PERMISSION)); env.close(); - env.require(nflags(alice, asfAllowClawback)); + env.require(nflags(alice, asfAllowTrustLineClawback)); } - // Test that asfAllowClawback is not allowed when owner dir is non-empty + // Test that asfAllowTrustLineClawback is not allowed when owner dir is + // non-empty { Env env(*this, features); @@ -142,7 +143,7 @@ class Clawback_test : public beast::unit_test::suite env.close(); auto const USD = alice["USD"]; - env.require(nflags(alice, asfAllowClawback)); + env.require(nflags(alice, asfAllowTrustLineClawback)); // alice issues 10 USD to bob env.trust(USD(1000), bob); @@ -153,7 +154,7 @@ class Clawback_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, bob) == 1); // alice fails to enable clawback because she has trustline with bob - env(fset(alice, asfAllowClawback), ter(tecOWNERS)); + env(fset(alice, asfAllowTrustLineClawback), ter(tecOWNERS)); env.close(); // bob sets trustline to default limit and pays alice back to delete @@ -164,16 +165,16 @@ class Clawback_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 0); - // alice now is able to set asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice now is able to set asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); BEAST_EXPECT(ownerCount(env, alice) == 0); BEAST_EXPECT(ownerCount(env, bob) == 0); } - // Test that one cannot enable asfAllowClawback when + // Test that one cannot enable asfAllowTrustLineClawback when // featureClawback amendment is disabled { Env env(*this, features - featureClawback); @@ -183,22 +184,23 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - env.require(nflags(alice, asfAllowClawback)); + env.require(nflags(alice, asfAllowTrustLineClawback)); - // alice attempts to set asfAllowClawback flag while amendment is - // disabled. no error is returned, but the flag remains to be unset. - env(fset(alice, asfAllowClawback)); + // alice attempts to set asfAllowTrustLineClawback flag while + // amendment is disabled. no error is returned, but the flag remains + // to be unset. + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(nflags(alice, asfAllowClawback)); + env.require(nflags(alice, asfAllowTrustLineClawback)); // now enable clawback amendment env.enableFeature(featureClawback); env.close(); - // asfAllowClawback can be set - env(fset(alice, asfAllowClawback)); + // asfAllowTrustLineClawback can be set + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); } } @@ -210,7 +212,7 @@ class Clawback_test : public beast::unit_test::suite // Test that Clawback tx fails for the following: // 1. when amendment is disabled - // 2. when asfAllowClawback flag has not been set + // 2. when asfAllowTrustLineClawback flag has not been set { Env env(*this, features - featureClawback); @@ -220,7 +222,7 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - env.require(nflags(alice, asfAllowClawback)); + env.require(nflags(alice, asfAllowTrustLineClawback)); auto const USD = alice["USD"]; @@ -240,7 +242,7 @@ class Clawback_test : public beast::unit_test::suite env.enableFeature(featureClawback); env.close(); - // clawback fails because asfAllowClawback has not been set + // clawback fails because asfAllowTrustLineClawback has not been set env(claw(alice, bob["USD"](5)), ter(tecNO_PERMISSION)); env.close(); @@ -265,10 +267,10 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); auto const USD = alice["USD"]; @@ -350,10 +352,10 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice); env.close(); - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // bob, the token holder, does not exist env(claw(alice, bob["USD"](5)), ter(terNO_ACCOUNT)); @@ -374,15 +376,15 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // cindy sets asfAllowClawback - env(fset(cindy, asfAllowClawback)); + // cindy sets asfAllowTrustLineClawback + env(fset(cindy, asfAllowTrustLineClawback)); env.close(); - env.require(flags(cindy, asfAllowClawback)); + env.require(flags(cindy, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(USD(1000), bob); @@ -417,15 +419,15 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; auto const CAD = bob["CAD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // bob sets asfAllowClawback - env(fset(bob, asfAllowClawback)); + // bob sets asfAllowTrustLineClawback + env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowClawback)); + env.require(flags(bob, asfAllowTrustLineClawback)); // alice issues 10 USD to bob. // bob then attempts to submit a clawback tx to claw USD from alice. @@ -486,10 +488,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(USD(1000), bob); @@ -536,15 +538,15 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob, cindy); env.close(); - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // bob sets asfAllowClawback - env(fset(bob, asfAllowClawback)); + // bob sets asfAllowTrustLineClawback + env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowClawback)); + env.require(flags(bob, asfAllowTrustLineClawback)); // alice sends 1000 USD to cindy env.trust(alice["USD"](1000), cindy); @@ -596,10 +598,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice sends 600 USD to bob env.trust(USD(1000), bob); @@ -663,15 +665,15 @@ class Clawback_test : public beast::unit_test::suite env.fund(XRP(1000), alice, bob); env.close(); - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); - // bob sets asfAllowClawback - env(fset(bob, asfAllowClawback)); + // bob sets asfAllowTrustLineClawback + env(fset(bob, asfAllowTrustLineClawback)); env.close(); - env.require(flags(bob, asfAllowClawback)); + env.require(flags(bob, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(alice["USD"](1000), bob); @@ -752,10 +754,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(USD(1000), bob); @@ -802,10 +804,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(USD(1000), bob); @@ -848,10 +850,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice issues 1000 USD to bob env.trust(USD(1000), bob); @@ -900,10 +902,10 @@ class Clawback_test : public beast::unit_test::suite auto const USD = alice["USD"]; - // alice sets asfAllowClawback - env(fset(alice, asfAllowClawback)); + // alice sets asfAllowTrustLineClawback + env(fset(alice, asfAllowTrustLineClawback)); env.close(); - env.require(flags(alice, asfAllowClawback)); + env.require(flags(alice, asfAllowTrustLineClawback)); // alice issues 100 USD to bob env.trust(USD(1000), bob); @@ -944,7 +946,7 @@ class Clawback_test : public beast::unit_test::suite void testWithFeats(FeatureBitset features) { - testAllowClawbackFlag(features); + testAllowTrustLineClawbackFlag(features); testValidation(features); testPermission(features); testEnabled(features); diff --git a/src/test/jtx/flags.h b/src/test/jtx/flags.h index a6f4345cfd2..27b6ea95611 100644 --- a/src/test/jtx/flags.h +++ b/src/test/jtx/flags.h @@ -80,8 +80,8 @@ class flags_helper case asfDepositAuth: mask_ |= lsfDepositAuth; break; - case asfAllowClawback: - mask_ |= lsfAllowClawback; + case asfAllowTrustLineClawback: + mask_ |= lsfAllowTrustLineClawback; break; default: Throw("unknown flag"); diff --git a/src/test/rpc/AccountInfo_test.cpp b/src/test/rpc/AccountInfo_test.cpp index a0a819502b1..ff23a5e53c1 100644 --- a/src/test/rpc/AccountInfo_test.cpp +++ b/src/test/rpc/AccountInfo_test.cpp @@ -609,25 +609,29 @@ class AccountInfo_test : public beast::unit_test::suite } static constexpr std::pair - allowClawbackFlag{"allowClawback", asfAllowClawback}; + allowTrustLineClawbackFlag{ + "allowTrustLineClawback", asfAllowTrustLineClawback}; if (features[featureClawback]) { // must use bob's account because alice has noFreeze set - auto const f1 = getAccountFlag(allowClawbackFlag.first, bob); + auto const f1 = + getAccountFlag(allowTrustLineClawbackFlag.first, bob); BEAST_EXPECT(f1.has_value()); BEAST_EXPECT(!f1.value()); - // Set allowClawback - env(fset(bob, allowClawbackFlag.second)); + // Set allowTrustLineClawback + env(fset(bob, allowTrustLineClawbackFlag.second)); env.close(); - auto const f2 = getAccountFlag(allowClawbackFlag.first, bob); + auto const f2 = + getAccountFlag(allowTrustLineClawbackFlag.first, bob); BEAST_EXPECT(f2.has_value()); BEAST_EXPECT(f2.value()); } else { - BEAST_EXPECT(!getAccountFlag(allowClawbackFlag.first, bob)); + BEAST_EXPECT( + !getAccountFlag(allowTrustLineClawbackFlag.first, bob)); } } diff --git a/src/test/rpc/AccountSet_test.cpp b/src/test/rpc/AccountSet_test.cpp index fc2b4ffe116..3fa214c5b4e 100644 --- a/src/test/rpc/AccountSet_test.cpp +++ b/src/test/rpc/AccountSet_test.cpp @@ -93,10 +93,10 @@ class AccountSet_test : public beast::unit_test::suite // and are tested elsewhere continue; } - if (flag == asfAllowClawback) + if (flag == asfAllowTrustLineClawback) { - // The asfAllowClawback flag can't be cleared. It is tested - // elsewhere. + // The asfAllowTrustLineClawback flag can't be cleared. It + // is tested elsewhere. continue; }