ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 49 forks source link

multiple concurrent connext transfers causes weird issues #1691

Open raladev opened 4 years ago

raladev commented 4 years ago

Steps to reproduce

  1. U have enough balances for both sides
  2. Place ten buy 0.1 LTC/ETH 1 orders
  3. Fill them as a maker sell 1 LTC/ETH mkt

Actual behaviour

Swap timeout after third swap + xud of maker is crashed after that + connext client of maker stops print new logs Screenshot from 2020-06-26 15-41-47

Expected behaviour

  1. All orders should be filled
  2. No xud crash because of misbehavior of connext client

Logs

part_fall_lndltc_taker.log part_fall_connext_taker.log part_fall_xud_taker.log

part_fall_lndltc_maker.log part_fall_connext_maker.log part_fall_xud_maker.log

raladev commented 4 years ago

@erkarl there is also stranges in connext balances of both nodes.

1.

Maker channel balances before swap: ETH 3.5 LTC 2.1996338

Taker channel balances before swap: ETH 3.65 LTC 2.8

Screen: balances+swaps

2. 10 swaps were started and 3 of them were successful. We can see it in tradehistory, xucli and lndltc-lncli listchannels outputs (it has only 7 pending htlcs).

Screens: lndltc-lncli_listchannels tradehistory_of_both_sides

3. So, lets check balance changes after swaps.

|LTC

Side Before Swap After Swap Balance Change
Maker 2.199638 2.499036 2.499036-2.199638=0.299398
Taker 2.8 1.8 1.8-2.8=-1

ETH

Side Before Swap After Swap Balance Change
Maker 3.5 2.6 2.6-3.5=-0.9
Taker 3.65 4.05 4.05-3.65=0.4

LTC is fine for both users in general (0.3 deposited, 0.7 in pending htlcs). Only 0.3-0.299398=0.000602 disappeared with no reason.

But ETH is totally bad.

  1. only 0.9 ETH were blocked instead of 1 ETH
  2. Taker got 0.4 ETH, when only 3 swaps were succesful.
erkarl commented 4 years ago

These logs are super interesting. Thanks for the additional info. I'm trying to figure out what happened.

erkarl commented 4 years ago

So, what happened here was:

Result: => all the concurrent transfers see that there is collateral in the channel and insert into the queue and the first one to complete will take the collateral and others will fail since there is no more collateral

erkarl commented 4 years ago

This issue can be separated into 2:

erkarl commented 4 years ago

Lowering the priority of this since it's not causing xud to crash any more and we need to discuss on how to solve this.

kilrau commented 4 years ago

Just to clarify the analysis in https://github.com/ExchangeUnion/xud/issues/1691#issuecomment-650287939: this only happens for multiple concurrent connext transfers of the same client.