-
Notifications
You must be signed in to change notification settings - Fork 1.6k
VaultClawback: Burn shares of an empty vault #6120
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: develop
Are you sure you want to change the base?
Conversation
gregtatcam
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.
LGTM
1ba2f8d to
2c63982
Compare
|
Sorry for the force-push, the devcontainer commit wasn't signed |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #6120 +/- ##
=======================================
Coverage 79.1% 79.2%
=======================================
Files 836 836
Lines 71257 71312 +55
Branches 8305 8299 -6
=======================================
+ Hits 56393 56448 +55
Misses 14864 14864
🚀 New features to boost your workflow:
|
| if (sharesTotal > 0 && assetsTotal == 0 && assetsAvailable == 0 && | ||
| account == owner) | ||
| { | ||
| if (auto const amount = ctx.tx[~sfAmount]; amount) |
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.
Don't need to have this additional amount check.
if (auto const amount = ctx.tx[~sfAmount])
|
If this PR gets merged into |
| } | ||
| }); | ||
|
|
||
| testCase([&](Env& env, |
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.
@ximinez @gregtatcam , since the Clawback transaction serves two purposes, the owner can submit the transaction to burn own shares.
This unit test checks if the issuer is trying to clawback from itself, however since now it's a valid use-case to submit the same account as "issuer" and "holder", these unit-tests are no longer valid (as the code they're testing was removed)
| AccountID const issuer = ctx.tx[sfAccount]; | ||
| AccountID const holder = ctx.tx[sfHolder]; | ||
|
|
||
| if (issuer == holder) |
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.
@ximinez , @gregtatcam this check is no longer valid, as the Vault Owner may submit a clawback transaction to burn their own shares.
Co-authored-by: Ed Hennis <ed@ripple.com>
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.
In addition to these, there are a couple of comments from my first review still left pending.
|
@ximinez , @gregtatcam thank you for your time reviewing this PR 🙇 |
| MPTIssue const share{mptIssuanceID}; | ||
|
|
||
| Asset const vaultAsset = vault->at(sfAsset); | ||
| STAmount const amount = [&]() { |
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.
Maybe makes sense to have a helper function? There is a similar block of code in preclaim.
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.
Added a helper function.
| env(pay(issuer, owner, MPT(1000))); | ||
| env(pay(issuer, depositor, MPT(1000))); | ||
| env.close(); | ||
| testCase(MPT, "MPT", owner, depositor); |
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 add unit-tests when owner is the issuer.
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.
I added the unit test and found a bug. Great call Greg!
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.
I left a couple of minor style suggestions, but otherwise this looks good, aside from the items that @gregtatcam has identified.
| } | ||
| else | ||
| { |
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.
Minor: You could return at the end of the if block, instead of having the else.
src/test/app/Vault_test.cpp
Outdated
| BEAST_EXPECT(vaultSle != nullptr); | ||
| if (!vaultSle) | ||
| return; |
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.
Minor: This could be written as
if (!BEAST_EXPECT(vaultSle != nullptr))
return;
gregtatcam
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.
Looks good. I just have a couple of minor suggestions left for your consideration and a request to update the unit-test when an asset's issuer is also the vault holder.
In the context of the Single Asset Vault there exists a situation where
Vault.AssetsTotalandVault.AssetsAvailableare zero, but the Vault still has shares. Such a situation may arise due to a Loan that was issued for the total of Vault's assets defaulting. The problem with such situation is that the Vault becomes permanently stuck, deposits will not be able to settle the balance, and the Vault object is non-deletable. This PR fixes this problem, namely:The PR updates the logic of
VaultClawbacktransaction allowing the Owner of the Vault to submitVaultClawbacktransaction to burn shares of a depositor only when the there are no assets in the vault.Edit:
The link to specification PR: XRPLF/XRPL-Standards#422
High Level Overview of Change
Context of Change
Type of Change
.gitignore, formatting, dropping support for older tooling)API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)