ExchangeUnion / xud-docker

Streamlined setup of xud and all dependencies via docker 🐳
https://docs.exchangeunion.com
GNU Affero General Public License v3.0
5 stars 5 forks source link

feat: connext v2 #770

Closed erkarl closed 3 years ago

erkarl commented 3 years ago

Steps to test:

  1. docker pull connextproject/vector_node:837bafa1
  2. bash xud.sh -b feat/connext-vector

What is currently not working:

TODO:

raladev commented 3 years ago

DO NOT MERGE

kilrau commented 3 years ago

connext logs via docker logs not working which would be helpful for debugging I suppose:

d@raspixud:~$ docker logs -f simnet_connext_1 
standard_init_linux.go:211: exec user process caused "exec format error"
kilrau commented 3 years ago

collateral request does not work

can confirm this, only sell orders work because no collateralization

raladev commented 3 years ago

Steps:

  1. Set nobalancechecks flag = true
  2. place sell 20 ETH order as a maker (channel balance = 15)
  3. fill it as a taker

Actual Result:

  1. Swap Timeout err
  2. pending htlcs for lndbtc
  3. a lot of connext errors on maker side because of 404
  4. Order in hold state on maker side, but not on taker side

Screenshot from 2020-11-18 17-38-43 Screenshot from 2020-11-18 17-37-03 Screenshot from 2020-11-18 17-34-43

Expected result:

  1. no route err from connext (no swap timeout by xud)
  2. no pending htlcs
  3. no repeated connext errors on maker side
  4. order is not in hold state on both side
erkarl commented 3 years ago

@kilrau @raladev

Collateralization works for me for 0.01 ETH:

19/11/2020 11:03:42.110 [CONNEXT] debug: collateral of 0 for ETH is insufficient for order amount 1000000
19/11/2020 11:03:42.112 [RPC] error: call /xudrpc.Xud/PlaceOrder errored with code 9: channel collateralization in progress, please try again in ~1 minute
19/11/2020 11:03:42.434 [CONNEXT] debug: completed collateral request of 100000000000000000 ETH units
19/11/2020 11:03:57.604 [CONNEXT] debug: new inbound capacity (collateral) for ETH of 10000000
simnet > buy 0.01 ETH/BTC 0.03
9 FAILED_PRECONDITION: channel collateralization in progress, please try again in ~1 minute
simnet > buy 0.01 ETH/BTC 0.03
matched 0.01 ETH @ 0.02723604 with peer SheriffSolution order d78beb30-2a55-11eb-ac6b-c10519dd9b23, attempting swap...
successfully swapped 0.01 ETH with peer order d78beb30-2a55-11eb-ac6b-c10519dd9b23
simnet >

and then from the other side

simnet > sell 0.01 ETH/BTC 0.02
matched 0.01 ETH @ 0.02 with peer RiceFat order 2ac49620-2a57-11eb-aef2-d3da88282b55, attempting swap...
successfully swapped 0.01 ETH with peer order 2ac49620-2a57-11eb-aef2-d3da88282b55

For bigger amounts (14 ETH) the collateralization does not work:

19/11/2020 11:08:56.426 [CONNEXT] debug: collateral of 8000000 for ETH is insufficient for order amount 1400000000
19/11/2020 11:08:56.427 [RPC] error: call /xudrpc.Xud/PlaceOrder errored with code 9: channel collateralization in progress, please try again in ~1 minute
19/11/2020 11:08:56.750 [CONNEXT] debug: completed collateral request of 14700000000000000000 ETH units
simnet > buy 14 ETH/BTC 0.02
9 FAILED_PRECONDITION: channel collateralization in progress, please try again in ~1 minute
simnet >

It looks like the collateralization request is successfully sent to the router-node, but it never collateralizes.

After changing the router.node.config collateralization settings it seems to work.

19/11/2020 11:16:48.187 [CONNEXT] debug: collateral of 8000000 for ETH is insufficient for order amount 1400000000
19/11/2020 11:16:48.189 [RPC] error: call /xudrpc.Xud/PlaceOrder errored with code 9: channel collateralization in progress, please try again in ~1 minute
19/11/2020 11:16:48.537 [CONNEXT] debug: completed collateral request of 14700000000000000000 ETH units
19/11/2020 11:17:03.718 [CONNEXT] debug: new inbound capacity (collateral) for ETH of 1470000000
simnet > tradehistory
Trades:
┌───────────────┬──────────┬───────┬─────────────┬────────────────────────────┬───────────┬─────────────────────────┐
│ Execution     │ Price    │ Role  │ Order Id    │ Order Id    (Counterparty) │ Swap Hash │ Executed At             │
├───────────────┼──────────┼───────┼─────────────┼────────────────────────────┼───────────┼─────────────────────────┤
│ Sell 14 ETH   │ 0.02 BTC │ Maker │ 95cc7d20... │ N/A (SheriffSolution)      │ 798c0d... │ 11/19/2020, 11:16:56 AM │
raladev commented 3 years ago
erkarl commented 3 years ago

collateralization works for order placing, but does not work for channel opening. (after channel opening we should collateralize for 0.1 ETH)

This is a bit tricky because the channel opening event is just the user sending funds to the multisig address (the connext address from xucli getinfo). Previously, the channel opening went through the xucli openchannel command which also triggered the collateralization.

raladev commented 3 years ago

docker logs connext

works fine for me

native@ubuntu:~$ docker logs -f 1c140d1c14fb
Using SQLite store at /database/store.db
VECTOR_DATABASE_URL: sqlite:///database/store.db
Running database migration

@prisma/cli          : 2.11.0
@prisma/client       : 2.10.0
Current platform     : linux-musl
Query Engine         : query-engine 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/query-engine-linux-musl)
Migration Engine     : migration-engine-cli 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/migration-engine-linux-musl)
Introspection Engine : introspection-core 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/introspection-engine-linux-musl)
Format Binary        : prisma-fmt 58369335532e47bdcec77a2f1e7c1fb83a463918 (at node_modules/@prisma/engines/prisma-fmt-linux-musl)
Studio               : 0.311.0
Preview Features     : connectOrCreate

Prisma schema loaded from schema.prisma
🏋️‍  migrate up

All migrations are already applied
Starting node in prod-mode
fastify not found, proceeding anyway
[1605796816336] INFO     (156 on connext): Rehydrating persisted node
    node: {
      "index": 0,
      "publicIdentifier": "indra6a5rHwXR2YjkUvqKr6zZ4fVeBTjamdHMJfTp2c2VNFiJLpnu5S"
    }
[1605796816707] INFO     (156 on connext): Created ChannelSigner
    method: "createNode"
    publicIdentifier: "indra6a5rHwXR2YjkUvqKr6zZ4fVeBTjamdHMJfTp2c2VNFiJLpnu5S"
[1605796816714] INFO     (156 on connext): Connected VectorChainService
    method: "createNode"
    providers: {
      "1337": "http://35.234.110.95:8545"
    }
kilrau commented 3 years ago

Actually both sides (buy & sell) are failing for me now:

simnet > sell 0.9 eth/btc mkt
matched 0.9 ETH @ 0.02996742 with peer SheriffSolution order 81501220-3246-11eb-a5d2-0fe5ed881d69, attempting swap...
failed to swap 0.9 ETH due to SendPaymentFailure with peer order 81501220-3246-11eb-a5d2-0fe5ed881d69, continuing with matching routine...
no more matches found, 0.9 qty will be discarded
simnet > buy 0.9 eth/btc mkt
matched 0.9 ETH @ 0.03119058 with peer SheriffSolution order 814f75e0-3246-11eb-a5d2-0fe5ed881d69, attempting swap...
failed to swap 0.9 ETH due to UnknownError with peer order 814f75e0-3246-11eb-a5d2-0fe5ed881d69, continuing with matching routine...
no more matches found, 0.9 qty will be discarded

connext logs: https://paste.ubuntu.com/p/KxpVDgbrmy/

raladev commented 3 years ago

Ran this again just now: ugly traceback is still there: https://paste.ubuntu.com/p/QMpYGWGNRh/ image pull/download percentage works fine now:

same for me, it appears in case of vector node update.

erkarl commented 3 years ago

Ran this again just now: ugly traceback is still there: https://paste.ubuntu.com/p/QMpYGWGNRh/ image pull/download percentage works fine now: image

@reliveyy didn't we fix this with https://github.com/ExchangeUnion/xud-docker/pull/796?

kilrau commented 3 years ago

volume/folder should be renamed back to connext (from currently vector)

Can we do this quick fix? @erkarl

reliveyy commented 3 years ago

didn't we fix this with #796?

@erkarl Sorry. It's a missing parameter I left while printing logs.

erkarl commented 3 years ago

@raladev - thanks for testing.

* [ ]  `closechannel eth --destination 0xa36d9059C30D82A537e11155849095ABC75B236d`
  and `simnet > closechannel eth --amount 0.000000001 (too small) --destination 0x00dAADB8bb8fb5CA023ef9Aeca98e9e14d963c86` lead to 500 err

We get the 500 error with ugly error message at the moment because the error happens at the contract level. Connext team is in the process of adding protocol validations at which point we can address this issue.

* [ ]  withdraw call does not work, it is critical because i cant get money from walletbalance (walletdeposit works fine)

I changed the withdraw ETH alias to xucli closechannel since the user shouldn't be depositing to the on-chain wallet balance. Deposits happen to/from channel address.

* [ ]  would be good to throw help in addition like we do in other cases
simnet > closechannel eth
Error: 3 INVALID_ARGUMENT: destination account for the withdrawal is missing

The help is available via withdraw --help or closechannel --help. I've also added a bit of text to the generic utils-cli help command.

* [ ]  lost 1 sat during deposits, but got it back after depositing 5 sat (not sure that it is xud err, so, maybe it was connext)
  [Screenshot from 2020-12-01 23-11-07](https://user-images.githubusercontent.com/29906866/100797198-cdc23c80-3432-11eb-9664-6f356778eb88.png)
  [Screenshot from 2020-12-01 23-11-59](https://user-images.githubusercontent.com/29906866/100797191-cc910f80-3432-11eb-958b-10ff515b2225.png)

I don't see a loss of funds in these screenshots. Can you elaborate?

* [ ]  Problem with swap failed swap handling still exists

Thanks, will look into it.

* [ ]  `TODO: Not exposed, yet` for connext version of getinfo response

This is in the pipeline for the Connext team to implement. At the moment we cannot query the version via Connext API.

raladev commented 3 years ago

I changed the withdraw ETH alias to xucli closechannel since the user shouldn't be depositing to the on-chain wallet balance. Deposits happen to/from channel address.

But i able to get wallet address using walletbalance command (walletbalance eth) and can deposit to it (for example, using closechanel), but there is no way to withdraw from wallet balance (closechannel withdraws from channel wallet, not from on-chain wallet).

So, there is 2 ways:

  1. repair walletwithdraw
  2. dont return on-chain wallet in walletdeposit eth response

I don't see a loss of funds in these screenshots. Can you elaborate?

  1. I deposited 0.00000001 -> it was displayed in getbalance call
  2. after that i deposited 10 ETH -> 0.00000001 was missed in getbalance call (balance was equal 10 instead of 10.00000001)
  3. after that i deposited 0.00000005 -> 0.00000001 was returned back (balance was equal 10.00000006)
erkarl commented 3 years ago
  • after that i deposited 10 ETH -> 0.00000001 was missed in getbalance call (balance was equal 10 instead of 10.00000001)

  • after that i deposited 0.00000005 -> 0.00000001 was returned back (balance was equal 10.00000006)

Think it's a rounding error on xud side.

raladev commented 3 years ago

We get the 500 error with ugly error message at the moment because the error happens at the contract level. Connext team is in the process of adding protocol validations at which point we can address this issue.

but what about withdrawing full amount? connext still does not handle this case?

erkarl commented 3 years ago

but what about withdrawing full amount? connext still does not handle this case?

Yep, same case. Needs protocol validations from Connext team.

erkarl commented 3 years ago

Removed nodeIdentifer from xud config as it's now being handled internally by xud. https://github.com/ExchangeUnion/xud-docker/pull/770/commits/6f91814739b2c039c0f62134d80f67f1198ecd42