-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Frozen IOUs should still be transferable to/from the issuer #6113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ximinez/lending-XLS-66-ongoing
Are you sure you want to change the base?
Frozen IOUs should still be transferable to/from the issuer #6113
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## ximinez/lending-XLS-66-ongoing #6113 +/- ##
================================================================
- Coverage 79.1% 79.1% -0.0%
================================================================
Files 839 839
Lines 71380 71394 +14
Branches 8318 8320 +2
================================================================
+ Hits 56476 56486 +10
- Misses 14904 14908 +4
🚀 New features to boost your workflow:
|
src/libxrpl/ledger/View.cpp
Outdated
| return false; | ||
| auto sle = view.read(keylet::account(issuer)); | ||
| if (sle && sle->isFlag(lsfGlobalFreeze)) | ||
| if (sle && sle->isFlag(lsfGlobalFreeze) && issuer != account) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like this helper function might have existed for some time (and being used in existing protocols). then we'd probably need to amendment gate this change with lending protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Added GlobalFreezeIssuer amendment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Added GlobalFreezeIssuer amendment.
You don't need a new amendment - you can reuse LendingProtocol and/or SingleAssetVault. This bug only affects transactions related to those amendments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
|
||
| // Add new amendments to the top of this list. | ||
| // Keep it sorted in reverse chronological order. | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really need a separate amendment? Since Lending Protocol is not supported, it can be part of the same LendingProtocol amendment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Let's discuss this in the meeting in 15 minutes. My thinking was that since this is related to Freeze, which we happened to touch during Lending testing, it should be a freeze-related amendment. But I also see an argument including it with Lending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Let's discuss this in the meeting in 15 minutes. My thinking was that since this is related to Freeze, which we happened to touch during Lending testing, it should be a freeze-related amendment. But I also see an argument including it with Lending.
You don't need a new amendment - you can reuse LendingProtocol and/or SingleAssetVault. This bug only affects transactions related to those amendments.
| // When withdrawing IOU to the issuer, ignore freeze since spec allows | ||
| // returning frozen IOU assets to their issuer. MPTs don't have this | ||
| // exemption - MPT locks function like "deep freeze" with no issuer | ||
| // exception. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vlntb, do I understand correctly that, if the depositor is the issuer of an MPT, and the asset is locked, the issue will still be able to withdraw from the vault?
| { | ||
| if (!view.rules().enabled(fixGlobalFreezeIssuer) || issuer != account) | ||
| return true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it really be a separate amendment or should it just be fixed as part of lending? cc @ximinez
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're thinking on the same line of thought: #6113 (comment)
| // Verify issuer can still receive payments (uses isFrozen internally) | ||
| env(pay(holder, issuer, USD(10))); | ||
| env.close(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also verify that the issuer can still send payments.
// Verify issuer can still send payments (uses isFrozen internally)
env(pay(issuer, holder, USD(10)));
env.close();
src/test/app/Freeze_test.cpp
Outdated
|
|
||
| // Test pre-amendment behavior (issuer IS frozen under global freeze) | ||
| { | ||
| Env env_pre(*this, features - fixGlobalFreezeIssuer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is still good, but will need to be rewritten to use LP and SAV.
| // Issuer CAN deposit to their own broker during global freeze | ||
| // This is the issuer exemption - issuer can always send (issue) their | ||
| // own tokens Per spec: "Counterparties of the frozen issuer can still | ||
| // send and receive payments directly to and from the issuing address." | ||
| env(coverDeposit(issuer, brokerKeylet.key, asset(10))); | ||
| env.close(); | ||
|
|
||
| // Verify the deposit succeeded | ||
| broker = env.le(brokerKeylet); | ||
| if (BEAST_EXPECT(broker)) | ||
| { | ||
| BEAST_EXPECT(broker->at(sfCoverAvailable) == asset(10).number()); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also add tests to check that the broker can withdraw the cover, too?
High Level Overview of Change
The freeze logic was incorrectly blocking IOU issuers from transacting with their own frozen currency. This violated the XRP Ledger protocol, which specifies that "Counterparties of the frozen issuer can still send and receive payments directly to and from the issuing address."
Context of Change
Three issues were fixed:
isFrozen()function was returning true for issuers checking their own currency during global freeze, causing the issuer to be treated as frozen. The early return prevented reaching the later issuer exemption check.LoanBrokerCoverDeposit::preclaim()was using accountHolds() with FreezeHandling::fhZERO_IF_FROZEN for all accounts, including issuers. Since issuers don't have a "balance" of their own tokens (infinite issuance ability), the balance check would return 0 and fail with tecINSUFFICIENT_FUNDS.VaultWithdraw::preclaim()had checkFrozen() calls that were always executed, even when the destination or submitter was the asset issuer. Now skips freeze checks when either the destination or submitter is the IOU issuer.Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)