fix: amendment-gate invariant bool overwrite fix (fixInvariantOverwrite)

Three invariant checks used = instead of |= to accumulate their
boolean flag across multiple visited entries. A later "good" entry
could overwrite a violation detected by an earlier "bad" entry.

Gate the corrected |= behavior behind fixInvariantOverwrite to
preserve pre-amendment consensus. Each affected class tracks both
the fixed (|=) and legacy (=) values; finalize picks which to use
based on the amendment.

Affected invariants:
- NoZeroEscrow (bad_ for MPT locked vs outstanding)
- NoXRPTrustLines (xrpTrustLine_)
- NoDeepFreezeTrustLinesWithoutFreeze (deepFreezeWithoutFreeze_)
This commit is contained in:
Vito
2026-03-21 14:36:35 +01:00
parent d08e7b4495
commit 311719daeb
4 changed files with 40 additions and 13 deletions

View File

@@ -41,7 +41,7 @@ class Invariants_test : public beast::unit_test::suite
defaultAmendments()
{
return xrpl::test::jtx::testable_amendments() | featureInvariantsV1_1 |
featureSingleAssetVault;
featureSingleAssetVault | fixInvariantOverwrite;
}
/** Run a specific test case to put the ledger into a state that will be
@@ -987,9 +987,9 @@ class Invariants_test : public beast::unit_test::suite
MPTIssue const mpt{MPTIssue{makeMptID(1, AccountID(0x4985601))}};
auto sleNew = std::make_shared<SLE>(keylet::mptIssuance(mpt.getMptID()));
// outstanding exceeds maxMPTokenAmount checkAmount sets bad_
// outstanding exceeds maxMPTokenAmount -> checkAmount sets bad_
sleNew->setFieldU64(sfOutstandingAmount, maxMPTokenAmount + 1);
// locked is valid and <= outstanding must NOT clear bad_
// locked is valid and <= outstanding -> must NOT clear bad_
sleNew->setFieldU64(sfLockedAmount, 10);
ac.view().insert(sleNew);
return true;