Change the priority of the amendments for large mantissas

- Order the checks so that large mantissa is only enabled if SAV or LP
  are enabled. fixCleanup3_2_0 only enables the rounding fix.
- Fix tests, and don't exclude fixCleanup3_2_0 in AMM tests
- Also fix formatting
This commit is contained in:
Ed Hennis
2026-05-21 00:12:31 +01:00
parent aea19df3c1
commit 3a4b92b050
7 changed files with 17 additions and 24 deletions

View File

@@ -123,7 +123,7 @@ private:
default:
// If called in a constexpr context, this throw assures that the build fails if an
// invalid scale is used.
throw std::runtime_error("Unknown mantissa scale"); //LCOV_EXCL_LINE
throw std::runtime_error("Unknown mantissa scale"); // LCOV_EXCL_LINE
}
}
@@ -140,7 +140,7 @@ private:
default:
// If called in a constexpr context, this throw assures that the build fails if an
// invalid scale is used.
throw std::runtime_error("Unknown mantissa scale"); //LCOV_EXCL_LINE
throw std::runtime_error("Unknown mantissa scale"); // LCOV_EXCL_LINE
}
}

View File

@@ -40,31 +40,23 @@ setCurrentTransactionRules(std::optional<Rules> r)
// Push the appropriate setting, instead of having the class pull every time
// the value is needed. That could get expensive fast.
// The improved accuracy that will come from enabling large
// mantissas is a goal separate from SAV and LP. It was originally
// only tied to those two amendments to avoid needing a new
// amendment of its own, and because they require that behavior.
// Because fixCleanup3_2_0 fixes a separate bug related to the large
// mantissas, that can take precedence and activate the large
// mantissas even in the absence of the other two amendments.
//
// If any new conditions with new amendments are added, those amendments must also be added to
// useRulesGuards.
bool const enableVaultNumbers =
!r || (r->enabled(featureSingleAssetVault) || r->enabled(featureLendingProtocol));
bool const enableCuspRoundingFix = !r || r->enabled(fixCleanup3_2_0);
bool const enableVaultNumbers = enableCuspRoundingFix ||
(r->enabled(featureSingleAssetVault) || r->enabled(featureLendingProtocol));
XRPL_ASSERT(
!r || useRulesGuards(*r) == (enableCuspRoundingFix || enableVaultNumbers),
"setCurrentTransactionRules : rule decisions match");
// Declare the range this way to keep clang-tidy from complaining
auto const range = [enableCuspRoundingFix, enableVaultNumbers]() {
if (enableCuspRoundingFix)
{
return MantissaRange::MantissaScale::Large;
}
if (enableVaultNumbers)
{
if (enableCuspRoundingFix)
{
return MantissaRange::MantissaScale::Large;
}
return MantissaRange::MantissaScale::LargeLegacy;
}
return MantissaRange::MantissaScale::Small;

View File

@@ -1829,7 +1829,7 @@ class AMMClawbackMPT_test : public beast::unit_test::Suite
testLastHolderLPTokenBalance(all - fixAMMv1_3 - fixAMMClawbackRounding);
testLastHolderLPTokenBalance(
all - fixAMMv1_3 - fixAMMClawbackRounding - featureSingleAssetVault -
featureLendingProtocol - fixCleanup3_2_0);
featureLendingProtocol);
testLastHolderLPTokenBalance(all - fixAMMClawbackRounding);
testClawAssetCheck(all);
}

View File

@@ -2506,8 +2506,8 @@ class AMMClawback_test : public beast::unit_test::Suite
{
// For now, just disable SAV entirely, which locks in the small Number
// mantissas
FeatureBitset const all = jtx::testableAmendments() - featureSingleAssetVault -
featureLendingProtocol - fixCleanup3_2_0;
FeatureBitset const all =
jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol;
testInvalidRequest(all);
testInvalidRequest(all - featureMPTokensV2);

View File

@@ -73,7 +73,7 @@ class AMMExtended_test : public jtx::AMMTest
// For now, just disable SAV entirely, which locks in the small Number
// mantissas
FeatureBitset const all_{
testableAmendments() - featureSingleAssetVault - featureLendingProtocol - fixCleanup3_2_0};
testableAmendments() - featureSingleAssetVault - featureLendingProtocol};
private:
void

View File

@@ -82,8 +82,7 @@ private:
{
// For now, just disable SAV entirely, which locks in the small Number
// mantissas
return jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol -
fixCleanup3_2_0;
return jtx::testableAmendments() - featureSingleAssetVault - featureLendingProtocol;
}
void

View File

@@ -573,7 +573,8 @@ struct EscrowToken_test : public beast::unit_test::Suite
env(pay(gw, bob, usd(1)));
env.close();
bool const largeMantissa = useRulesGuards(env.current()->rules());
bool const largeMantissa =
features[featureSingleAssetVault] || features[featureLendingProtocol];
// alice cannot create escrow for 1/10 iou - precision loss
env(escrow::create(alice, bob, usd(1)),
@@ -2200,7 +2201,8 @@ struct EscrowToken_test : public beast::unit_test::Suite
env(pay(gw, bob, usd(1)));
env.close();
bool const largeMantissa = useRulesGuards(env.current()->rules());
bool const largeMantissa =
features[featureSingleAssetVault] || features[featureLendingProtocol];
// alice cannot create escrow for 1/10 iou - precision loss
env(escrow::create(alice, bob, usd(1)),