-
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
fixDisallowIncomingV1 #4721
fixDisallowIncomingV1 #4721
Conversation
if (ctx.view.rules().enabled(fixDisallowIncomingV1) && | ||
ctx.view.exists(keylet::line(id, uDstAccountID, currency))) | ||
{ | ||
// pass | ||
} | ||
else | ||
return tecNO_PERMISSION; |
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.
Why not just invert the if
and return inside it, instead of having an empty if
and returning in the 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.
I actually have it like that on my local branch but with clang-format
it makes it very "compact". I'm open to doing it like that if its preferred. It was just done like that for readability.
if (ctx.view.rules().enabled(fixDisallowIncomingV1) &&
!ctx.view.exists(keylet::line(id, uDstAccountID, currency)))
return tecNO_PERMISSION;
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 general positive conditions should be preferred over negative conditions. They are quick and easy to scan through, it's very obvious to the reader what's happening. The more complicated the condition the more likely the next programmer will misunderstand it and insert a mistake.
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.
Personally, I have no trouble reading the current formulation of the if
. So I'm good with leaving it the way it is.
I just looked over this pull request. The proposed approach looks like it would work and solve the identified problem. However, I'm not yet convinced that the identified problem justifies an amendment. Let me walk through why. If
This unit test fragment demonstrates the approach I'm suggesting.
This approach has the advantage that it works today (without an amendment) and it's pretty easy to explain. Is it elegant? No. But it solves the problem for what I suspect is a pretty small user population. I'm also open to being wrong on this. Convince me that this proposed amendment has a good justification. Thanks for reading. |
I would argue a few things.
|
@dangell7 wrote:
Thanks for bringing those up. I think all of those are legitimate points. However I'm not completely convinced they are important enough to merit an amendment. On the other hand I recognize that I'm not a very good representative of ledger usability concerns. So my hope is that someone with more usability focus will weigh in. Possibly @mvadari or @ximinez? |
While I agree that the flow @scottschurr described would be an easier solution to the problem (easier in that it doesn't require enabling an amendment), I think this amendment fixes the behavior to be what it should be. IMO this amendment should still be approved, but in the meanwhile we can use other mechanisms to deal with the problem (and the explanations will be a bit simpler when the fix is enabled). I'm of the opinion that if a fix amendment isn't going to change the user API (which would be a pain to deal with in tooling), then there's no reason why it shouldn't be in the codebase. |
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 job with this pull request. The implementation is straightforward and easy to read. The unit test demonstrates the intention and utility of the change.
I left one note about a comment that might be changed. But I leave that your discretion.
if (ctx.view.rules().enabled(fixDisallowIncomingV1) && | ||
ctx.view.exists(keylet::line(id, uDstAccountID, currency))) | ||
{ | ||
// pass | ||
} | ||
else | ||
return tecNO_PERMISSION; |
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.
Personally, I have no trouble reading the current formulation of the if
. So I'm good with leaving it the way it is.
This PR has sufficient approvals. @dangell7 , please:
Thanks! |
LGTM |
…F#4721) Context: The `DisallowIncoming` amendment provides an option to block incoming trust lines from reaching your account. The asfDisallowIncomingTrustline AccountSet Flag, when enabled, prevents any incoming trust line from being created. However, it was too restrictive: it would block an issuer from authorizing a trust line, even if the trust line already exists. Consider: 1. Issuer sets asfRequireAuth on their account. 2. User sets asfDisallowIncomingTrustline on their account. 3. User submits tx to SetTrust to Issuer. At this point, without `fixDisallowIncomingV1` active, the issuer would not be able to authorize the trust line. The `fixDisallowIncomingV1` amendment, once activated, allows an issuer to authorize a trust line even after the user sets the asfDisallowIncomingTrustline flag, as long as the trust line already exists.
…F#4721) Context: The `DisallowIncoming` amendment provides an option to block incoming trust lines from reaching your account. The asfDisallowIncomingTrustline AccountSet Flag, when enabled, prevents any incoming trust line from being created. However, it was too restrictive: it would block an issuer from authorizing a trust line, even if the trust line already exists. Consider: 1. Issuer sets asfRequireAuth on their account. 2. User sets asfDisallowIncomingTrustline on their account. 3. User submits tx to SetTrust to Issuer. At this point, without `fixDisallowIncomingV1` active, the issuer would not be able to authorize the trust line. The `fixDisallowIncomingV1` amendment, once activated, allows an issuer to authorize a trust line even after the user sets the asfDisallowIncomingTrustline flag, as long as the trust line already exists.
This commit introduces a new fix amendment (fixDisallowIncomingV1) which fixes an issue that occurs with authorized trustlines and the
lsfDisallowIncomingTrustline
flag.Currently if a user creates an authorized trustline then sets the
lsfDisallowIncomingTrustline
flag on their account, the gateway/issuer cannot then approve the trustline.To recreate the issue:
asfRequireAuth
on their account.asfDisallowIncomingTrustline
on their account.Once the amendment is activated, the issuer can authorize the trustline after the User sets the
asfDisallowIncomingTrustline
flag because the trustline already exists.