-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat(raiden): check for direct channels #1065
Conversation
To be clear, this disables a trading pair entirely with a given peer if the pair involves a raiden currency for which we don't have a direct channel. I can certainly make this configurable so it can easily be turned off, and also make the logging more clear. Making the check happen only when an order is placed doesn't really work since we may have channels with some peers but not with others, and may connect to other peers later on for whom we don't have direct channels. Another option is to check right before we attempt or accept a swap, but this involves more code and potentially a bad user experience for users to be shown orders that are guaranteed not to work. |
I feel this would provide much better user experience than displaying a warning upon placing an order or executing a swap. Also, you have already done the hard work and implemented it. The concern that Offer had was that we want to be able to turn it off it starts to cause problems. I'd make it configurable under debug section. |
Thanks @erkarl . After sleeping on this, I also think we should go ahead with it. Make it configurable, default to Reason: everything else I could come up with is not better or quite some coding work. Also, simnet can support direct channels in an automated manner. And I'll put a clear warning on this limitation in the wiki install guides. |
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.
The concept looks good to me and I have just some minor questions/comments but I didn't test this branch yet. I will do that once it is rebased
lib/p2p/Peer.ts
Outdated
/** The version of xud this peer is using. */ | ||
private _version?: string; | ||
/** The node pub key of this peer. */ | ||
private _nodePubKey?: string; |
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 do these new variables have an underscore as prefix?
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 made getter functions for these two variables and needed to use different naming for the variables themselves, this was the cleanest way I could think to do it. It was done as part of #1055. I can change it in a separate PR if you have a better approach in mind.
Will review and test this manually once it is rebased. |
2650000
to
338fb55
Compare
I updated the commit to check for a direct channel with sufficient balance before each swap attempt. I put the logic in the |
} | ||
} | ||
} | ||
return []; // no direct channels, return no routes |
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 definitely would print a NoDirectChannels
error here, not generic NoRouteFound
. Maybe sth along the lines. Swap failed due to no direct raiden channel, please make sure to have a direct raiden channel with this peers and try swapping again.
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 can log messages like that here explaining that either there is no direct channel with this peer or that we have one but it doesn't have enough balance, but note that either way this will go in the log output and not in a grpc response where it's front and center for a user who has just issued an xucli
command can see.
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 log statements - I'm hesitant though to introduce a new swap failure reason tho since it would require some non-trivial refactoring and since this is a temporary safeguard that we may remove later. NoRouteFound
I think is descriptive enough, it tells the user that there's no suitable route to make a payment and the standard corrective action for that in any case is to open a channel to the peer we want to swap with.
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.
Alright. We'll make it clear in the documentation.
fc7802b
to
3bab0a7
Compare
lib/raidenclient/RaidenClient.ts
Outdated
// stub placeholder, query routes not currently implemented in raiden | ||
// assume a fixed lock time of 100 Raiden's blocks | ||
return [{ | ||
public getRoutes = async (amount: number, destination: string, currency: string) => { |
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.
Normally I'd advocate an integration test here, but since this is temporary logic... 😆
This adds logic to check that we have a direct channel with a peer with sufficient balance for raiden currencies before accepting or proposing a swap. Currently multi-hop Raiden payments are not well supported, and failed payments are not handled well in Raiden. This will prevent any attempts to swap Raiden tokens without a direct channel. Closes #1027.
3bab0a7
to
a87e903
Compare
Closes #1027.
This adds logic to check that we have a direct channel with a peer before enabling trading for a given Raiden token. Currently multi-hop Raiden payments are not well supported, and this will prevent any attempts to swap Raiden tokens without a direct channel.
Note, this branch is based off of #1055 (which has useful refactoring for determining whether to disable specific currencies trading) and #1064 (which updates raiden calls used in this PR) so it must be rebased and merged only after those two PRs are merged. The key commit to review for the purposes of this PR is the last one.