-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
CheckCashMakesTrustLine amendment #3823
Conversation
// Set the delivered_amount metadata. | ||
ctx_.deliver(result.actualAmountOut); | ||
} | ||
// Set the delivered amount metadata in all cases, not just |
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.
Prior to checkCashMakesTrustLine
, why was the delivered amount metadata set only if DeliverMin was used?
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.
Hi @intelliot, I believe that was a bug. As part of this pull request I added some unit tests. I expected that in all cases the result of a successful CheckCash
transactions would include a delivered_amount
field. I found that delivered_amount
was not always set. I surmised delivered_amount
was not set because DeliveredAmount
was not always set due to the conditional above.
When I changed the code so setting DeliveredAmount
was only conditional on the amendment then the unit tests returned a delivery_amount
field in all of the tested cases.
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.
Thanks for the great review @ximinez! I've pushed a commit that I believe addresses your comments. Please let me know if I missed anything.
I've also rebased on top of #3840 since it has passed and provides functionality that I'm using. I anticipate that #3840 will be merged before this pull request is.
Any future reviewers will want to skip the commits below the one named Introduce CheckCashMakesTrustLine amendment
.
@ximinez, thanks for the suggestion regarding the macro. I followed your lead but tweaked it a bit. At your convenience take a look and see what you think. |
With this amendment, the CheckCash transaction creates a TrustLine if needed. The change is modeled after offer crossing. And, similar to offer crossing, cashing a check allows an account to exceed its trust line limit.
Rebased to 1.8.0-b3. |
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.
Sorry for the delay on this followup. The latest changes look good!
suite.expect( | ||
ownerCount(env, acct) == owners, | ||
"Owner count mismatch", | ||
__FILE__, | ||
line); |
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.
Nice
@nbougalis is really busy right now, so I'm swapping in @thejohnfreeman as a technical reviewer. Thanks for the help, @thejohnfreeman! |
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.
Can we add a test that a second check for the same currency can be cashed after one that created a trust line (i.e. that the limits are ignored even when a trust line already existed)?
src/ripple/app/tx/impl/CashCheck.cpp
Outdated
JLOG(ctx.j.warn()) | ||
<< "Cannot cash check for IOU without trustline."; | ||
return tecNO_LINE; | ||
if (!ctx.view.rules().enabled(featureCheckCashMakesTrustLine)) |
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.
One way to do the changes from line 200 (in the original code) to line 225 that requires fewer actual code changes is to just add && !ctx.view.rules().enabled(featureCheckCashMakesTrustLine)
to the condition on line 200, and insert this condition on line 218:
if (!sleTrustLine) {
return tecNO_AUTH;
}
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 believe you, but I'm not really clear on the edit you'd like to see. Can you spell out the proposed change further? Thanks.
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.
Here it is as a commit: thejohnfreeman@d57c0e8
src/test/app/Check_test.cpp
Outdated
// All remaining tests require featureCheckCashMakesTrustLine. | ||
if (!features[featureCheckCashMakesTrustLine]) | ||
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.
With CheckCashMakesTrustLine disabled, this function is only the test above this return, which duplicates a test elsewhere. I personally find it easier to understand if this function is only run with CheckCashMakesTrustLine enabled, without lines 1943 - 1974 (the sanity check and early return), but maybe with an assertion that the feature is enabled.
Thanks for the great review @thejohnfreeman. I've pushed a couple of commits that I believe address your comments. Please let me know if there's anything else you'd like addressed. |
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.
Still looks good. I like the changes.
Looks great! Thank you! |
@mDuo13 and @intelliot, does this change look reasonable to you? I want to make sure before I mark it passed. Thanks. |
Tentatively, looks good. I certainly appreciate the idea, and the semantics as laid out in the description sound perfect to me. I haven't tested out the changes or looked through the code to confirm that it works as described or that there aren't any relevant edge cases I haven't thought of. To be clear, when cashing a Check for a "flexible" amount, is the amount it delivers is no longer bounded by the Check recipient's trust limits (even if there's an existing line and trust limits are set to nonzero values)? That's sensible to me, though it may be surprising in at least a couple cases, so it's something to make sure the docs clarify. I guess in that case, the only things that may limit the redemption to less than the Check's full amount are: (a) the amount the check sender holds, if they aren't the issuer Right? |
@mDuo13, that sounds correct. |
High Level Overview of Change
With this amendment, the
CheckCash
transaction creates a trust line if needed. The change is modeled afterOffer
crossing. And, similar toOffer
crossing, cashing aCheck
allows an account to exceed its trust line limit.Context of Change
It has been determined that the user experience of needing to create a trust line prior to cashing a
Check
was both inconvenient and not necessary. Similar to anOffer
, anyone who cashes aCheck
clearly wants to accept the funds involved. Automatically creating the trust line, if necessary, would be convenient and has precedent withOffer
crossing.Therefore this amendment introduces two changes to the behavior of cashing a
Check
:If the account cashing the
Check
does not already have a trust line for the currency being received, then that trust line is created if possible. It usually is possible.Reasons it might not be possible to create the trust line include:
lsfDefaultRipple
flag.lsfGlobalFreeze
flag.lsfRequireAuth
flag, so an automatically created trust line would not be authorized.The currency being brought into the account by the
Check
is allowed to exceed any limit specified the in trust line. There are three reasons for this:Check
then they must want the currency in question.Offer
s have the same behavior. It makes sense to limit the number of unique behaviors on the ledger.If cashing the
Check
fails for any reason, then the trust line is not added to the account.Type of Change
If this change is merged then documentation will need to be updated to cover the behavior changes. This change will also need to be mentioned in the release notes.
Test Plan
Unit tests were added to verify that prior to the introduction of the amendment cashing a
Check
without a pre-existing trust line would fail. After the introduction of the amendment cashing aCheck
without a pre-existing trust line succeeds by adding the necessary trust line to the ledger.A number of different scenarios were tested including:
Check
that was created by the issuer of the currency in question.Check
written by an account other than the issuer.AccountRoot
flags were tested which either allowed or prevented the automatic trust line creation.Offer
crossing were compared to trust lines automatically created byCheck
cashing and found to be very similar (as intended).Requests of Reviewers
Please consider situations I might have forgotten which might affect creation of a trust line. I tested the account root flags I thought would matter. Did I miss important account root flags? Are there conditions other than account root flags that need to be tested? Thanks for the help.
Future Tasks
Once a trust line is added to the ledger, it can be challenging for a ledger user to remove the trust line. It may be useful to explore ways for non-issuer accounts to more easily remove trust lines.