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

[Overview] Prepare XUD for ERC20<>Lightning swap #797

Closed
offerm opened this issue Jan 28, 2019 · 12 comments · Fixed by #874
Closed

[Overview] Prepare XUD for ERC20<>Lightning swap #797

offerm opened this issue Jan 28, 2019 · 12 comments · Fixed by #874
Assignees
Labels
P1 top priority

Comments

@offerm
Copy link
Contributor

offerm commented Jan 28, 2019

In parallel to extending Raiden with swap support we can enhance XUD to make sure we are ready.

Need to take care for the following:

  • Make gRPC work for Raiden (gRPC enhancement for Raiden #792)
  • Staring Raiden - need to have account with tokens and ETH, keystore file , EndpointRegistry address, SecretRegistry address, TokenNetworkRegistry address, and eth-rpc-endpoint. I can share a startup script when needed.
  • Create a channel with a peer PUT /api/(version)/channels
  • implement XUD to Raiden connectivity (like we do with LND). Make sure we have a connection and we are ready to trade. Need configuration support.
  • Create an XUD currency for the raiden Token. Should include the Token address
  • Get to the point where Swap agreed and the taker initiates the swap by using POST /api/(version)/payments/(token_address)/(target_address)

Suggest to gave a separate issue for each step once we start the implementation.

@kilrau kilrau added this to the 1.0.0-alpha.9 milestone Jan 29, 2019
@kilrau kilrau changed the title Planning: Prepare XUD for ERC20<>Lightning swap [Overview] Prepare XUD for ERC20<>Lightning swap Feb 5, 2019
@kilrau kilrau modified the milestones: 1.0.0-alpha.9, 1.0.0-alpha.10 Feb 5, 2019
@kilrau kilrau added the P1 top priority label Mar 6, 2019
@kilrau kilrau modified the milestones: 1.0.0-alpha.10, 1.0.0-alpha.11 Mar 6, 2019
@kilrau kilrau assigned offerm and erkarl and unassigned offerm Mar 6, 2019
@kilrau
Copy link
Contributor

kilrau commented Mar 6, 2019

Alright, I think we all agree that this is our overall top prio at the moment (by far). So my idea would be that we double check again that the list above. Make sure it is complete - definitely needs your input @offerm . And then the 3 of you divide (open & assign issues for each point) and conquer (start working on these while leaving everything else aside, with @offerm offer until feedback from the raiden team comes in) with the goal to raiden working with xud by the end of this milestone in 10 days from now. I bet @offerm will find a way to demo a BTC<-> WETH swap with this.

Completely unreasonable? 😎 Other suggestions? @offerm @sangaman @erkarl

@offerm
Copy link
Contributor Author

offerm commented Mar 6, 2019

Lets break this to internal and external tasks (from XUD POV):

External:

  • Create an Ethereum chain
  • Have a miner
  • Block reward to go to the system accounts
  • Create raiden smart contracts
  • Create a token (start with one, multiple later)
  • register the token with the raiden contracts
  • start raiden server (need one for each xud - so each xud will have lnd-btc, lnd-ltc, raiden). Use a remote ETH instance by the raiden instances so we avoid a long sync time.
  • fund remote raiden accounts somehow
  • automatic creation of channels (like we do with LND) + funding
  • make the minder smarter.

With these changes XUD can use raiden.

Internal:

  • Connect to raiden (use HTTP put/get API) - may need some additional parameters
  • create currency which is raiden based
  • LND vs Raiden handling of the swap
  • More (for @sangaman ) to complete

For now, I'm working on the external items. Note sure this is doable in 2 weeks. Lets see
@sangaman should lead the internal one.

@erkarl
Copy link
Collaborator

erkarl commented Mar 6, 2019

Good news is that the external and internal steps that @offerm mentioned are completely independent of each other and can be done in isolation.

Connect to Raiden

Via REST API - https://raiden-network.readthedocs.io/en/stable/rest_api.html

Breaking it down into smaller steps for implementation:

  • init/start
  • getInfo
  • verifyConnection
  • sendPayment POST /api/(version)/payments/(token_address)/(target_address)
  • getAddress GET /api/(version)/address
  • connectPeer
  • listChannels GET /api/(version)/channels/(token_address)
  • openChannel PUT /api/(version)/channels
  • closeChannel
  • close/exit
  • queryRoutes?
  • deploy/registerToken? PUT /api/(version)/tokens/(token_address) - do we need this? is W-ETH deployed automatically?

LND vs Raiden handling of the swap

As of now the swaps module of xud is hardcoded to support BTC/LTC clients. There's work to be done there (needs further scoping).

Also, how will we handle unknown rHash resolving within Raiden?

@offerm
Copy link
Contributor Author

offerm commented Mar 6, 2019 via email

@kilrau
Copy link
Contributor

kilrau commented Mar 7, 2019

For example, connectPeer, closeChannel, deploy/registerToken we don't need.

All one-time actions like deploy/registerToken definitely not, but closeChannel we'll need in production I believe (don't think SimNet!).

@kilrau
Copy link
Contributor

kilrau commented Mar 7, 2019

I think you are pretty clear about the external (SimNet) tasks, so full-steam ahead @offerm ! Your concern about the timeline is definitely valid, let's try tho!

Let's try to compile an exhaustive list for the internal tasks below and divide (just pick what you'd like to do) @erkarl @sangaman

@erkarl
Copy link
Collaborator

erkarl commented Mar 7, 2019

currently there is no good way to deal with unknown rHash. Basically the
caller would need to block until timeout. We will need to do something
about it but it is less urgent.

I understand you have done the heavy lifting in terms of adding Raiden support. Thanks to you Raiden now has support to include secret and secret hash as part of payment request and response. Awesome work :).

Can you please elaborate on caller blocking until the timeout?

About the API, better to check what we need. For example, connectPeer,
closeChannel, deploy/registerToken we don't need. QueryRoutes we do.

In order to clarify what exactly needs to be done I started:
#826

@kilrau kilrau modified the milestones: 1.0.0-alpha.11, 1.0.0-sprint.12 Mar 25, 2019
@kilrau
Copy link
Contributor

kilrau commented Mar 26, 2019

What else needs to be done here? @erkarl Checking your list from above..

@sangaman
Copy link
Collaborator

We do need the raiden address of our peers to be shared in the handshake and to be returned in the ListPeers response. I was mistaken earlier in thinking we already shared the raiden address in the handshake, but I've started working on this piece and will have a PR soon. It's not a major change.

@erkarl
Copy link
Collaborator

erkarl commented Mar 27, 2019

There's also: #846
and #853 for the raiden swap-resolver http endpoint.

@kilrau
Copy link
Contributor

kilrau commented Apr 2, 2019

We do need the raiden address of our peers to be shared in the handshake and to be returned in the ListPeers response. I was mistaken earlier in thinking we already shared the raiden address in the handshake, but I've started working on this piece and will have a PR soon. It's not a major change.

Is this merged? @sangaman I could only find raiden address updates: #858

@kilrau kilrau modified the milestones: 1.0.0-sprint.12, 1.0.0-sprint.13 Apr 2, 2019
@sangaman
Copy link
Collaborator

sangaman commented Apr 3, 2019

Is this merged? @sangaman I could only find raiden address updates: #858

Yes, it's handled in #857 which is now merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 top priority
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants