mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
For now, skip the larger mantissas in AMM transactions and tests
This commit is contained in:
@@ -87,7 +87,14 @@ public:
|
||||
bool
|
||||
integral() const
|
||||
{
|
||||
return !holds<Issue>() || get<Issue>().native();
|
||||
return std::visit(
|
||||
[&]<ValidIssueType TIss>(TIss const& issue) {
|
||||
if constexpr (std::is_same_v<TIss, Issue>)
|
||||
return issue.native();
|
||||
if constexpr (std::is_same_v<TIss, MPTIssue>)
|
||||
return true;
|
||||
},
|
||||
issue_);
|
||||
}
|
||||
|
||||
friend constexpr bool
|
||||
|
||||
@@ -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<CaptureLogs>(&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) {
|
||||
|
||||
@@ -592,6 +592,24 @@ Transactor::ticketDelete(
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
bool
|
||||
Transactor::useOldNumberRules(TxType txType)
|
||||
{
|
||||
constexpr auto skipTransactions = std::to_array<TxType>(
|
||||
{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
|
||||
{
|
||||
|
||||
@@ -230,6 +230,9 @@ public:
|
||||
uint256 const& ticketIndex,
|
||||
beast::Journal j);
|
||||
|
||||
static bool
|
||||
useOldNumberRules(TxType txType);
|
||||
|
||||
protected:
|
||||
TER
|
||||
apply();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user