From 546bfa89d81c39445554e5c48296b19313dc8fc8 Mon Sep 17 00:00:00 2001 From: Ed Hennis Date: Sun, 16 Nov 2025 20:59:17 -0500 Subject: [PATCH] For now, skip the larger mantissas in AMM transactions and tests --- include/xrpl/protocol/Asset.h | 9 ++++++++- src/test/app/AMM_test.cpp | 15 +++++++++++++++ src/xrpld/app/tx/detail/Transactor.cpp | 20 ++++++++++++++++++++ src/xrpld/app/tx/detail/Transactor.h | 3 +++ src/xrpld/app/tx/detail/applySteps.cpp | 2 ++ 5 files changed, 48 insertions(+), 1 deletion(-) diff --git a/include/xrpl/protocol/Asset.h b/include/xrpl/protocol/Asset.h index 6765f7cf7d..0a7f41880a 100644 --- a/include/xrpl/protocol/Asset.h +++ b/include/xrpl/protocol/Asset.h @@ -87,7 +87,14 @@ public: bool integral() const { - return !holds() || get().native(); + return std::visit( + [&](TIss const& issue) { + if constexpr (std::is_same_v) + return issue.native(); + if constexpr (std::is_same_v) + return true; + }, + issue_); } friend constexpr bool diff --git a/src/test/app/AMM_test.cpp b/src/test/app/AMM_test.cpp index aeba8abf1b..edabd56ce8 100644 --- a/src/test/app/AMM_test.cpp +++ b/src/test/app/AMM_test.cpp @@ -30,6 +30,9 @@ namespace test { */ struct AMM_test : public jtx::AMMTest { + // Use small Number mantissas for the life of this test. + NumberMantissaScaleGuard sg_{ripple::MantissaRange::small}; + private: void testInstanceCreate() @@ -3011,6 +3014,11 @@ private: using namespace jtx; using namespace std::chrono; + // For now, just disable SAV entirely, which locks in the small Number + // mantissas + features = + features - featureSingleAssetVault /* - featureLendingProtocol */; + // Auction slot initially is owned by AMM creator, who pays 0 price. // Bid 110 tokens. Pay bidMin. @@ -3755,6 +3763,11 @@ private: testcase("Basic Payment"); using namespace jtx; + // For now, just disable SAV entirely, which locks in the small Number + // mantissas + features = + features - featureSingleAssetVault /* - featureLendingProtocol */; + // Payment 100USD for 100XRP. // Force one path with tfNoRippleDirect. testAMM( @@ -6473,6 +6486,8 @@ private: Env env(*this, features, std::make_unique(&logs)); auto rules = env.current()->rules(); CurrentTransactionRulesGuard rg(rules); + NumberMantissaScaleGuard sg(MantissaRange::small); + for (auto const& t : tests) { auto getPool = [&](std::string const& v, bool isXRP) { diff --git a/src/xrpld/app/tx/detail/Transactor.cpp b/src/xrpld/app/tx/detail/Transactor.cpp index 2ce5025e79..c46baf71c2 100644 --- a/src/xrpld/app/tx/detail/Transactor.cpp +++ b/src/xrpld/app/tx/detail/Transactor.cpp @@ -592,6 +592,24 @@ Transactor::ticketDelete( return tesSUCCESS; } +bool +Transactor::useOldNumberRules(TxType txType) +{ + constexpr auto skipTransactions = std::to_array( + {ttAMM_BID, + ttAMM_CLAWBACK, + ttAMM_CREATE, + ttAMM_DELETE, + ttAMM_DEPOSIT, + ttAMM_VOTE, + ttAMM_WITHDRAW}); + + return std::find( + std::begin(skipTransactions), + std::end(skipTransactions), + txType) != std::end(skipTransactions); +} + // check stuff before you bother to lock the ledger void Transactor::preCompute() @@ -1114,6 +1132,8 @@ Transactor::operator()() // fixUniversalNumber predate the rulesGuard and should be replaced. NumberSO stNumberSO{view().rules().enabled(fixUniversalNumber)}; CurrentTransactionRulesGuard currentTransctionRulesGuard(view().rules()); + if (Transactor::useOldNumberRules(ctx_.tx.getTxnType())) + Number::setMantissaScale(MantissaRange::small); #ifdef DEBUG { diff --git a/src/xrpld/app/tx/detail/Transactor.h b/src/xrpld/app/tx/detail/Transactor.h index 2195ef0a85..7cd6d8bad2 100644 --- a/src/xrpld/app/tx/detail/Transactor.h +++ b/src/xrpld/app/tx/detail/Transactor.h @@ -230,6 +230,9 @@ public: uint256 const& ticketIndex, beast::Journal j); + static bool + useOldNumberRules(TxType txType); + protected: TER apply(); diff --git a/src/xrpld/app/tx/detail/applySteps.cpp b/src/xrpld/app/tx/detail/applySteps.cpp index 39a5c5ee90..96e3f49cc5 100644 --- a/src/xrpld/app/tx/detail/applySteps.cpp +++ b/src/xrpld/app/tx/detail/applySteps.cpp @@ -58,6 +58,8 @@ with_txn_type(Rules const& rules, TxType txnType, F&& f) stNumberSO.emplace(rules.enabled(fixUniversalNumber)); rulesGuard.emplace(rules); } + if (Transactor::useOldNumberRules(txnType)) + Number::setMantissaScale(MantissaRange::small); switch (txnType) {