fix: Prevents overwritting a bool value in an invariant (#6609)#6961
fix: Prevents overwritting a bool value in an invariant (#6609)#6961ximinez wants to merge 10 commits intoripple/staging-313from
Conversation
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
85985ba to
43daf4e
Compare
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
|
/ai-review |
There was a problem hiding this comment.
Critical correctness bug: line 416 (bad_ = outstanding < *locked) was not removed as part of this fix and silently overwrites bad_ before the new |= logic runs, defeating the fix entirely. See inline comments.
Review by Claude Opus 4.6 · Prompt: V15
There was a problem hiding this comment.
Pull request overview
Backports the fix from #6609 to prevent invariant state booleans from being overwritten across multiple visitEntry calls, and adds a safer isFeatureEnabled helper for contexts where transaction rules may be unset.
Changes:
- Add amendment-gated “overwrite fix” logic to multiple invariants by accumulating (
|=) rather than overwriting boolean state. - Extend
isFeatureEnabledto support a caller-chosen default when no CurrentTransactionRules are set. - Update/add tests to exercise the overwrite fix both enabled and disabled, and simplify feature bitsets to rely on
testable_amendments().
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/xrpld/app/tx/detail/InvariantCheck.cpp | Adds overwrite-fix gating for invariant booleans (but currently contains a regression in one branch). |
| src/libxrpl/protocol/Rules.cpp | Implements new isFeatureEnabled(feature, resultIfNoRules) behavior. |
| include/xrpl/protocol/Rules.h | Updates isFeatureEnabled declaration and documents the new parameter (potential ABI/API considerations). |
| src/test/app/Invariants_test.cpp | Adds helper amendments bitset + rules guard and runs overwrite tests for both enabled/disabled fix (currently has a namespace issue). |
| src/test/app/Vault_test.cpp | Test cleanups and a type change in callbacks (currently uses an apparently invalid xrpl::Keylet type). |
| src/test/rpc/GatewayBalances_test.cpp | Makes the feature bitset const (no behavior change). |
| src/test/app/Loan_test.cpp | Simplifies feature set to testable_amendments(). |
| src/test/app/LoanBroker_test.cpp | Simplifies feature set to testable_amendments(). |
| src/test/app/Batch_test.cpp | Simplifies Env feature composition to use the passed-in feature bitset. |
| src/test/app/AMM_test.cpp | Simplifies feature composition to rely on testable_amendments(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
43daf4e to
7e12277
Compare
There was a problem hiding this comment.
Critical bug: the old bad_ = outstanding < *locked; on line 416 was never removed, so it overwrites bad_ unconditionally before the new |= guarded logic runs — the fix is a no-op. The other two invariant checks (NoXRPTrustLines, NoDeepFreezeTrustLinesWithoutFreeze) correctly dropped the old assignment; this one did not. See inline comment.
Review by Claude Opus 4.6 · Prompt: V15
- Brings over a function overload from `develop` that the new test uses to run with different amendments
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
…invariant-bugfix-313 * XRPLF/ripple/staging-313: fix: Add rounding to Vault invariants (6217) (6957)
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
|
|
- Tests of the old behavior were failing because they relied on a change from e11f619 that did not require the output to contain "Invariant failed" if the transaction succeeded. Since the legacy transactions are expected to succeed, they were failing that test.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ripple/staging-313 #6961 +/- ##
==================================================
Coverage 79.5% 79.5%
==================================================
Files 840 840
Lines 71985 72000 +15
Branches 8202 8201 -1
==================================================
+ Hits 57221 57236 +15
Misses 14764 14764
🚀 New features to boost your workflow:
|
|
This PR has conflicts, please resolve them in order for the PR to be reviewed. |
…invariant-bugfix-313 * XRPLF/ripple/staging-313: fix: Improve invariant check for Permissioned Domains (6134) (6958)
|
All conflicts have been resolved. Assigned reviewers can now start or resume their review. |
| messages.starts_with("Invariant failed:") || | ||
| messages.starts_with("Transaction caused an exception"), | ||
| messages); | ||
| messages.starts_with("Transaction caused an |
There was a problem hiding this comment.
String literal accidentally split across two lines — compilation error. Fix:
messages.starts_with("Transaction caused an exception"),
messages);
vlntb
left a comment
There was a problem hiding this comment.
The change looks correct.
Happy to approve once the erroneous line split spotter by xrplf-ai-reviewer is fixed.
High Level Overview of Change
This PR backports the changes from #6609 to 3.1.x.