From 4e066ea455fe1fb7d80a84af0c4a816756808f02 Mon Sep 17 00:00:00 2001 From: Bart <11445373+bthomee@users.noreply.github.com> Date: Wed, 8 Apr 2026 09:14:54 -0400 Subject: [PATCH] refactor: Apply various minor improvements and corrections (#6739) --- API-CHANGELOG.md | 15 ++------- include/xrpl/protocol/detail/features.macro | 1 - src/libxrpl/beast/core/CurrentThreadName.cpp | 10 +++--- src/test/app/NFToken_test.cpp | 32 +++++++++---------- .../beast/beast_CurrentThreadName_test.cpp | 4 +++ src/test/rpc/LedgerEntry_test.cpp | 6 ++-- .../app/tx/detail/NFTokenAcceptOffer.cpp | 8 ++--- src/xrpld/overlay/detail/PeerImp.cpp | 2 +- src/xrpld/rpc/handlers/LedgerEntry.cpp | 2 +- 9 files changed, 37 insertions(+), 43 deletions(-) diff --git a/API-CHANGELOG.md b/API-CHANGELOG.md index d08b020d23..b8a1ba711b 100644 --- a/API-CHANGELOG.md +++ b/API-CHANGELOG.md @@ -77,20 +77,11 @@ When reading Payments, the `Amount` field should generally **not** be used. Inst This version is supported by all `rippled` versions. For WebSocket and HTTP JSON-RPC requests, it is currently the default API version used when no `api_version` is specified. -## Unreleased +The [commandline](https://xrpl.org/docs/references/http-websocket-apis/api-conventions/request-formatting/#commandline-format) always uses the latest API version. The command line is intended for ad-hoc usage by humans, not programs or automated scripts. The command line is not meant for use in production code. -This section contains changes targeting a future version. +## XRP Ledger server version 3.1.3 -### Additions - -- `server_definitions`: Added the following new sections to the response ([#6321](https://github.com/XRPLF/rippled/pull/6321)): - - `TRANSACTION_FORMATS`: Describes the fields and their optionality for each transaction type, including common fields shared across all transactions. - - `LEDGER_ENTRY_FORMATS`: Describes the fields and their optionality for each ledger entry type, including common fields shared across all ledger entries. - - `TRANSACTION_FLAGS`: Maps transaction type names to their supported flags and flag values. - - `LEDGER_ENTRY_FLAGS`: Maps ledger entry type names to their flags and flag values. - - `ACCOUNT_SET_FLAGS`: Maps AccountSet flag names (asf flags) to their numeric values. - -### Bugfixes +### Bugfixes in 3.1.3 - Peer Crawler: The `port` field in `overlay.active[]` now consistently returns an integer instead of a string for outbound peers. [#6318](https://github.com/XRPLF/rippled/pull/6318) diff --git a/include/xrpl/protocol/detail/features.macro b/include/xrpl/protocol/detail/features.macro index 07102b762e..c07b678865 100644 --- a/include/xrpl/protocol/detail/features.macro +++ b/include/xrpl/protocol/detail/features.macro @@ -33,7 +33,6 @@ // Keep it sorted in reverse chronological order. XRPL_FIX (Security3_1_3, Supported::no, VoteBehavior::DefaultNo) -XRPL_FIX (ExpiredNFTokenOfferRemoval, Supported::yes, VoteBehavior::DefaultNo) XRPL_FIX (BatchInnerSigs, Supported::no, VoteBehavior::DefaultNo) XRPL_FEATURE(LendingProtocol, Supported::yes, VoteBehavior::DefaultNo) XRPL_FIX (DirectoryLimit, Supported::yes, VoteBehavior::DefaultNo) diff --git a/src/libxrpl/beast/core/CurrentThreadName.cpp b/src/libxrpl/beast/core/CurrentThreadName.cpp index b3aea1b475..cb335e94fe 100644 --- a/src/libxrpl/beast/core/CurrentThreadName.cpp +++ b/src/libxrpl/beast/core/CurrentThreadName.cpp @@ -104,12 +104,10 @@ setCurrentThreadNameImpl(std::string_view name) { // truncate and set the thread name. char boundedName[maxThreadNameLength + 1]; - std::snprintf( - boundedName, - sizeof(boundedName), - "%.*s", - static_cast(maxThreadNameLength), - name.data()); + auto const boundedSize = + name.size() < maxThreadNameLength ? name.size() : maxThreadNameLength; + name.copy(boundedName, boundedSize); + boundedName[boundedSize] = '\0'; pthread_setname_np(pthread_self(), boundedName); diff --git a/src/test/app/NFToken_test.cpp b/src/test/app/NFToken_test.cpp index 75125b4086..2f48c34453 100644 --- a/src/test/app/NFToken_test.cpp +++ b/src/test/app/NFToken_test.cpp @@ -1189,10 +1189,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The buy offer must not have expired. // NOTE: this is only a preclaim check with the - // fixExpiredNFTokenOfferRemoval amendment disabled. + // fixSecurity3_1_3 amendment disabled. env(token::acceptBuyOffer(alice, buyerExpOfferIndex), ter(tecEXPIRED)); env.close(); - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { buyerCount--; } @@ -1212,12 +1212,12 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The sell offer must not have expired. // NOTE: this is only a preclaim check with the - // fixExpiredNFTokenOfferRemoval amendment disabled. + // fixSecurity3_1_3 amendment disabled. env(token::acceptSellOffer(buyer, aliceExpOfferIndex), ter(tecEXPIRED)); env.close(); // Alice's count is decremented by one when the expired offer is // removed. - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { aliceCount--; } @@ -3394,10 +3394,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // No one can accept an expired sell offer. env(token::acceptSellOffer(buyer, offer1), ter(tecEXPIRED)); - // With fixExpiredNFTokenOfferRemoval amendment, the first accept + // With fixSecurity3_1_3 amendment, the first accept // attempt deletes the expired offer. Without the amendment, // the offer remains and we can try to accept it again. - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { // After amendment: offer was deleted by first accept attempt minterCount--; @@ -3417,7 +3417,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == minterCount); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); - if (!features[fixExpiredNFTokenOfferRemoval]) + if (!features[fixSecurity3_1_3]) { // Before amendment: expired offer still exists and needs to be // cancelled @@ -3484,10 +3484,10 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // An expired buy offer cannot be accepted. env(token::acceptBuyOffer(minter, offer1), ter(tecEXPIRED)); - // With fixExpiredNFTokenOfferRemoval amendment, the first accept + // With fixSecurity3_1_3 amendment, the first accept // attempt deletes the expired offer. Without the amendment, // the offer remains and we can try to accept it again. - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { // After amendment: offer was deleted by first accept attempt buyerCount--; @@ -3507,7 +3507,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == minterCount); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); - if (!features[fixExpiredNFTokenOfferRemoval]) + if (!features[fixSecurity3_1_3]) { // Before amendment: expired offer still exists and can be // cancelled @@ -3592,7 +3592,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite ter(tecEXPIRED)); env.close(); - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { // With amendment: expired offers are deleted minterCount--; @@ -3602,7 +3602,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite BEAST_EXPECT(ownerCount(env, minter) == minterCount); BEAST_EXPECT(ownerCount(env, buyer) == buyerCount); - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { // The buy offer was deleted, so no need to cancel it // The sell offer still exists, so we can cancel it @@ -3689,7 +3689,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite env.close(); BEAST_EXPECT(ownerCount(env, issuer) == 0); - if (features[fixExpiredNFTokenOfferRemoval]) + if (features[fixSecurity3_1_3]) { // After amendment: expired offers were deleted during broker // attempt @@ -3781,7 +3781,7 @@ class NFTokenBaseUtil_test : public beast::unit_test::suite // The expired offers are still in the ledger. BEAST_EXPECT(ownerCount(env, issuer) == 0); - if (!features[fixExpiredNFTokenOfferRemoval]) + if (!features[fixSecurity3_1_3]) { // Before amendment: expired offers still exist in ledger BEAST_EXPECT(ownerCount(env, minter) == 2); @@ -8253,7 +8253,7 @@ public: ripple::test::jtx::testable_amendments()}; testWithFeats( allFeatures - fixNFTokenReserve - featureNFTokenMintOffer - - featureDynamicNFT - fixExpiredNFTokenOfferRemoval); + featureDynamicNFT - fixSecurity3_1_3); } }; @@ -8318,7 +8318,7 @@ class NFTokenWOExpiredOfferRemoval_test : public NFTokenBaseUtil_test { FeatureBitset const allFeatures{ ripple::test::jtx::testable_amendments()}; - testWithFeats(allFeatures - fixExpiredNFTokenOfferRemoval); + testWithFeats(allFeatures - fixSecurity3_1_3); } }; diff --git a/src/test/beast/beast_CurrentThreadName_test.cpp b/src/test/beast/beast_CurrentThreadName_test.cpp index 490e8e6dbe..46c899c3fc 100644 --- a/src/test/beast/beast_CurrentThreadName_test.cpp +++ b/src/test/beast/beast_CurrentThreadName_test.cpp @@ -24,6 +24,10 @@ #include +#if BOOST_OS_LINUX +#include +#endif // BOOST_OS_LINUX + namespace ripple { namespace test { diff --git a/src/test/rpc/LedgerEntry_test.cpp b/src/test/rpc/LedgerEntry_test.cpp index 61c2bd4e73..52345f7878 100644 --- a/src/test/rpc/LedgerEntry_test.cpp +++ b/src/test/rpc/LedgerEntry_test.cpp @@ -1085,7 +1085,8 @@ class LedgerEntry_test : public beast::unit_test::suite checkErrorValue( jrr[jss::result], "malformedAuthorizedCredentials", - "Invalid field 'authorized_credentials', not array."); + "Invalid field 'authorized_credentials', not array of " + "objects."); } { @@ -1106,7 +1107,8 @@ class LedgerEntry_test : public beast::unit_test::suite checkErrorValue( jrr[jss::result], "malformedAuthorizedCredentials", - "Invalid field 'authorized_credentials', not array."); + "Invalid field 'authorized_credentials', not array of " + "objects."); } { diff --git a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp b/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp index 7190012391..cba44560eb 100644 --- a/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp +++ b/src/xrpld/app/tx/detail/NFTokenAcceptOffer.cpp @@ -74,12 +74,12 @@ NFTokenAcceptOffer::preclaim(PreclaimContext const& ctx) if (hasExpired(ctx.view, (*offerSLE)[~sfExpiration])) { - // Before fixExpiredNFTokenOfferRemoval amendment, expired + // Before fixSecurity3_1_3 amendment, expired // offers caused tecEXPIRED in preclaim, leaving them on ledger // forever. After the amendment, we allow expired offers to // reach doApply() where they get deleted and tecEXPIRED is // returned. - if (!ctx.view.rules().enabled(fixExpiredNFTokenOfferRemoval)) + if (!ctx.view.rules().enabled(fixSecurity3_1_3)) return {nullptr, tecEXPIRED}; // Amendment enabled: return the expired offer to be handled in // doApply @@ -531,10 +531,10 @@ NFTokenAcceptOffer::doApply() auto bo = loadToken(ctx_.tx[~sfNFTokenBuyOffer]); auto so = loadToken(ctx_.tx[~sfNFTokenSellOffer]); - // With fixExpiredNFTokenOfferRemoval amendment, check for expired offers + // With fixSecurity3_1_3 amendment, check for expired offers // and delete them, returning tecEXPIRED. This ensures expired offers // are properly cleaned up from the ledger. - if (view().rules().enabled(fixExpiredNFTokenOfferRemoval)) + if (view().rules().enabled(fixSecurity3_1_3)) { bool foundExpired = false; diff --git a/src/xrpld/overlay/detail/PeerImp.cpp b/src/xrpld/overlay/detail/PeerImp.cpp index d18dc910f5..6de8ee909f 100644 --- a/src/xrpld/overlay/detail/PeerImp.cpp +++ b/src/xrpld/overlay/detail/PeerImp.cpp @@ -2541,7 +2541,7 @@ PeerImp::onMessage(std::shared_ptr const& m) { fee_.update( Resource::feeModerateBurdenPeer, - " Reply limit reached. Truncating reply."); + "Reply limit reached. Truncating reply."); break; } } diff --git a/src/xrpld/rpc/handlers/LedgerEntry.cpp b/src/xrpld/rpc/handlers/LedgerEntry.cpp index 4c7ddbb141..d5f08a024b 100644 --- a/src/xrpld/rpc/handlers/LedgerEntry.cpp +++ b/src/xrpld/rpc/handlers/LedgerEntry.cpp @@ -227,7 +227,7 @@ parseAuthorizeCredentials(Json::Value const& jv) return LedgerEntryHelpers::invalidFieldError( "malformedAuthorizedCredentials", jss::authorized_credentials, - "array"); + "array of objects"); } if (auto const value = LedgerEntryHelpers::hasRequired(