fix: Prevents overwritting a bool value in an invariant (#6609)#6961
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. |
|
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. |
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.
| using namespace test::jtx; | ||
|
|
||
| Env env{*this, testable_amendments() | featureSingleAssetVault}; | ||
| Env env{*this, testable_amendments()}; |
There was a problem hiding this comment.
Do we need to clean | featureSingleAssetVault at other places in this file and other files as well?
There was a problem hiding this comment.
Do we need to clean
| featureSingleAssetVaultat other places in this file and other files as well?
No. This one slipped through, and while it doesn't break anything, I'm not a fan.
…iminez/invariant-bugfix-313
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Vito <[email protected]>
High Level Overview of Change
This PR backports the changes from #6609 to 3.1.x.