-
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%
==============================================================
Files 839 839
Lines 71385 71399 +14
Branches 8317 8315 -2
==============================================================
+ Hits 56481 56497 +16
+ Misses 14904 14902 -2
🚀 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
| // 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?
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.
You are correct. I was confused by one of the comments in the code, but after reviewing the XLS-33 spec, I found that locked MPTs CAN be sent back to the issuer
(section 2.1.2.2.5: 'cannot be used in any transactions other than sending value back to the issuer').
The implementation and comments were incorrect. I've fixed this in the latest commit - locked MPTs now have the same issuer exemption as frozen IOUs.
| { | ||
| 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)
src/test/app/Freeze_test.cpp
Outdated
| // 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();
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
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();
I see a lot of changes where the loan broker deposits and withdraws, but I would like to see a simple payment from the issuer here in testIsFrozenDirectly
ximinez
left a comment
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.
There are a bunch of unit test failures
| coverDeposit(holder, brokerKeylet.key, USD(10)), | ||
| ter(tecFROZEN)); | ||
|
|
||
| env_post(coverDeposit(issuer, brokerKeylet.key, USD(20))); |
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 doesn't look right. Only the broker owner (owner) should be able to deposit cover. Not because of the freeze, but because of the LP rules. The CI results confirm that - there are many unit test failures.
src/test/app/Freeze_test.cpp
Outdated
| // 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();
I see a lot of changes where the loan broker deposits and withdraws, but I would like to see a simple payment from the issuer here in testIsFrozenDirectly
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)