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

client/dcr: restarting dexc mid-trade results in stuck trade #2442

Open
norwnd opened this issue Jul 19, 2023 · 4 comments
Open

client/dcr: restarting dexc mid-trade results in stuck trade #2442

norwnd opened this issue Jul 19, 2023 · 4 comments
Labels
bug bug or bugfix
Milestone

Comments

@norwnd
Copy link
Contributor

norwnd commented Jul 19, 2023

I'm observing this issue pretty consistently when restarting dexc mid-trade (right after Taker swap): #2042 (comment)

I've looked a bit into it and think it more likely has to do with the following being out of sync than with reorgs, something like:

  • when dexc starts, trades are pulled from DB and redemption search starts (through FindRedemption method findRedemptionQueue gets filled)
  • dcr spv wallet starts in parallel to this ^ and inspects blocks that keep coming in monitorBlocks, it seems to be doing some time-based delays (at least I don't see obvious way it's synched with 1st process from above)

so when dexc restarts (perhaps with several minutes delay), it misses the block we are interested in (or a whole range of blocks maybe) would be my guess ... but I give up this investigation, leaving this in case somebody wants to pick it up.

@chappjc
Copy link
Member

chappjc commented Jul 19, 2023

Is it revoked? Shouldn't be searching for a redemption unless the match is revoked.
Can you provide a specific repro?

@norwnd
Copy link
Contributor Author

norwnd commented Jul 20, 2023

Trade DCR-USDC with self (on testnet) such that DCR swap txn is done as 2nd step, wait until DCR swap txn is broadcasted (show up at dcrdata explorer) and restart dexc (seems like there is no need to even wait before starting it again),

now we can navigate to Taker and Maker match cards, both point of view on Taker DCR swap (after restart, same as before restart) is that confirmations are stuck at 0:

image
image

while dcrdata shows 4 confirmations at this point (and they keep growing over time ofc):

image

Is it revoked?

I don't think it's revoked, see Status=settling(Taker Swap Sent), I think it gets revoked eventually and funds are refunded, but I'm not sure I understand/agree with that:

Shouldn't be searching for a redemption unless the match is revoked.

revoked or not, Maker can redeem; hence Taker must be ready to redeem right ? never mind, I meant that if Maker redeems Taker won't know and will keep trying to refund, from what I've gathered.

To sum up, there seems to be 2 undesirable outcomes from this dexc mid-trade restart:

  • (if we are Maker) trade is stuck and then refunded
  • (if we are Taker) trade is stuck and then refunded, or worse we might never redeem

observing with dcr spv wallet, but haven't tested for other wallets.

@norwnd
Copy link
Contributor Author

norwnd commented Jul 20, 2023

Now that match is revoked on both sides, it looks like this (more restarts don't change anything):

image image

my understanding: Maker should be trying (and succeeding) to redeem, but it doesn't and I see this in logs:

2023-07-20 08:39:42.927 [INF] CORE: Match 898cdf9d705b9febb59dfbc82db8b56619417d4a200ed73ef42e6459e3355875 not yet redeemable: current confs = 0, required confs = 1

@chappjc chappjc added the bug bug or bugfix label Jul 20, 2023
@chappjc chappjc added this to the 0.6.3 milestone Jul 20, 2023
@chappjc
Copy link
Member

chappjc commented Jul 20, 2023

It's not consistent, but I did reproduce it twice. PR just for debugging, with a possible workaround: #2444
However, there seems to be a bug in dcrwallet/wallet/udb that keeps the transaction unconfirmed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug or bugfix
Projects
None yet
Development

No branches or pull requests

2 participants