Skip to content
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

Check XRP endpoints for circular paths (RIPD-1781): #3209

Closed
wants to merge 1 commit into from

Conversation

seelabs
Copy link
Collaborator

@seelabs seelabs commented Jan 6, 2020

The payment engine restricts payment paths so two steps do not input the same
Currency/Issuer or output the same Currency/Issuer. This check was skipped when
the path started or ended with XRP. An example of a path that was incorrectly
accepted was: XRP -> //USD -> //XRP -> EUR

This patch enables the path loop check for paths that start or end with XRP.

@codecov-io
Copy link

codecov-io commented Jan 6, 2020

Codecov Report

Merging #3209 into develop will decrease coverage by 0.00%.
The diff coverage is 42.85%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3209      +/-   ##
===========================================
- Coverage    70.61%   70.61%   -0.01%     
===========================================
  Files          676      676              
  Lines        54339    54346       +7     
===========================================
+ Hits         38374    38377       +3     
- Misses       15965    15969       +4     
Impacted Files Coverage Δ
src/ripple/protocol/Feature.h 100.00% <ø> (ø)
src/ripple/protocol/impl/Feature.cpp 91.66% <ø> (ø)
src/ripple/app/paths/impl/XRPEndpointStep.cpp 78.62% <42.85%> (-2.02%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f00f263...a9333bb. Read the comment docs.

mellery451
mellery451 previously approved these changes Jan 7, 2020
Copy link
Contributor

@mellery451 mellery451 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM. CI has manual test failures that look related, so probably worth investigating.

@yxxyun
Copy link

yxxyun commented Jan 8, 2020

I think should support circular payment not disable it
#1257

@MarkusTeufelberger
Copy link
Collaborator

Me too, but currently this is not supported, so until they are properly enabled I guess it is fine to make sure they are strictly not happening and not just most of the time unless there's some special edge case.

@tuloski
Copy link

tuloski commented Jan 9, 2020

All the forward and backward problems and then it seems that rippled can already handle that, so why not just enabling circular payments. It's a feature more than a drawback IMO.

scottschurr
scottschurr previously approved these changes Jan 10, 2020
Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good. The change does what is intended. I left a nit suggesting that the unit test coverage might be improved. But I'll leave that decision to you.

src/ripple/app/paths/impl/XRPEndpointStep.cpp Show resolved Hide resolved
JLOG(j_.debug())
<< "XRPEndpointStep: loop detected: Index: " << ctx.strandSize
<< ' ' << *this;
return temBAD_PATH_LOOP;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run code_cov over the new code, this line returning temBAD_PATH_LOOP isn't hit. Is there a (not too painful) way to hit this line with a unit test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I can make a test that will hit this. The reason is the book steps also check for a path, and the book step will detect the loop before the endpoint will.

I'd still like to leave this code in, but in practice I don't think it can be hit.

@seelabs
Copy link
Collaborator Author

seelabs commented Feb 24, 2020

Rebased onto 1.5.0-b5 and added two more tests. Since this has already been approved in it's current version, I'm still going to consider this approved (but of course feel free to review the new tests). I'm going to aim to get this into 1.6 rather than 1.5, since we're so late into the 1.5 cycle.

scottschurr
scottschurr previously approved these changes Feb 25, 2020
Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

scottschurr
scottschurr previously approved these changes Apr 3, 2020
Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Code changes still look good.

I recommend patching up the commit message so the lines in the body are no more than 72 characters long. Right now, using git log, the commit message looks like this in my terminal:

    Check XRP endpoints for circular paths (RIPD-1781):
    
    The payment engine restricts payment paths so two steps do not input the sam
e
    Currency/Issuer or output the same Currency/Issuer. This check was skipped w
hen
    the path started or ended with XRP. An example of a path that was incorrectl
y
    accepted was: XRP -> //USD -> //XRP -> EUR
    
    This patch enables the path loop check for paths that start or end with XRP.

@seelabs
Copy link
Collaborator Author

seelabs commented Apr 4, 2020

@scottschurr I don't mind wrapping at 72 characters. Will do. I know you've requested changes like this in the past. The reason I keep posting 80 character commit messages is my editor wraps git commit messages at 80 characters by default and I haven't taken the time to figure out what I need to do to change that.

The payment engine restricts payment paths so two steps do not input the
same Currency/Issuer or output the same Currency/Issuer. This check was
skipped when the path started or ended with XRP. An example of a path
that was incorrectly accepted was: XRP -> //USD -> //XRP -> EUR

This patch enables the path loop check for paths that start or end with
XRP.
Copy link
Collaborator

@scottschurr scottschurr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks.

@seelabs seelabs added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Apr 6, 2020
@carlhua carlhua moved this from In Review to Approved for Merging in XRPL 1.6 Apr 6, 2020
This was referenced Apr 7, 2020
@manojsdoshi manojsdoshi mentioned this pull request Apr 8, 2020
@intelliot
Copy link
Collaborator

This introduces a new amendment called fix1781.

@carlhua carlhua moved this from Approved for Merging to Done in XRPL 1.6 Apr 13, 2020
@seelabs seelabs deleted the xrp-circular-paths branch April 24, 2020 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Amendment Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

8 participants