Improve Invariant check handling if not in Transactor context

- Adds an option to isFeatureEnabled to return true if no global rules
  set. Can be used for functionality that uses the post-amendment
  behavior when called outside of a Transactor context.
This commit is contained in:
Ed Hennis
2026-04-15 16:17:56 -04:00
parent c86e8ce532
commit be0e099386
3 changed files with 13 additions and 6 deletions

View File

@@ -8,8 +8,13 @@
namespace xrpl {
/** Check whether a feature is enabled in the current ledger rules
*
* @param feature The feature to be tested.
* @param resultIfNoRules What to return if called from outside a Transactor context.
*/
bool
isFeatureEnabled(uint256 const& feature);
isFeatureEnabled(uint256 const& feature, bool resultIfNoRules = false);
class DigestAwareReadView;

View File

@@ -140,10 +140,12 @@ Rules::operator!=(Rules const& other) const
}
bool
isFeatureEnabled(uint256 const& feature)
isFeatureEnabled(uint256 const& feature, bool resultIfNoRules)
{
auto const& rules = getCurrentTransactionRules();
return rules && rules->enabled(feature);
if (!rules)
return resultIfNoRules;
return rules->enabled(feature);
}
} // namespace xrpl

View File

@@ -322,7 +322,7 @@ NoZeroEscrow::visitEntry(
bad_ = true;
};
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
if (after && after->getType() == ltMPTOKEN_ISSUANCE)
{
@@ -605,7 +605,7 @@ NoXRPTrustLines::visitEntry(
std::shared_ptr<SLE const> const&,
std::shared_ptr<SLE const> const& after)
{
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
if (after && after->getType() == ltRIPPLE_STATE)
{
@@ -646,7 +646,7 @@ NoDeepFreezeTrustLinesWithoutFreeze::visitEntry(
{
if (after && after->getType() == ltRIPPLE_STATE)
{
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3);
bool const overwriteFixEnabled = isFeatureEnabled(fixSecurity3_1_3, true);
std::uint32_t const uFlags = after->getFieldU32(sfFlags);
bool const lowFreeze = (uFlags & lsfLowFreeze) != 0u;