comit-network / xmr-btc-swap

Bitcoin–Monero Cross-chain Atomic Swap
GNU General Public License v3.0
655 stars 83 forks source link

"Failed to deserialize bytes into message using CBOR" #1184

Open binarybaron opened 2 years ago

binarybaron commented 2 years ago

Describe the bug Initiating a swap fails. This might be due to the asb and cli using different versions of the software. CLI uses latest preview release. ASB is self-compiled and a few weeks old. I'll compile to use the latest asb version and try again.

Debug logs CLI:

{"timestamp":"2022-10-25T10:59:47.19448Z","level":"INFO","fields":{"message":"Logging initialized to /Users/****/Library/Application Support/xmr-btc-swap/cli/testnet/logs"}}
{"timestamp":"2022-10-25T10:59:47.194646Z","level":"DEBUG","fields":{"message":"Using existing sqlite database."}}
{"timestamp":"2022-10-25T10:59:47.20193Z","level":"DEBUG","fields":{"message":"Reading in seed from /Users/****/Library/Application Support/xmr-btc-swap/cli/testnet/seed.pem"}}
{"timestamp":"2022-10-25T10:59:49.605923Z","level":"DEBUG","fields":{"message":"RPC exec path: /Users/****/Library/Application Support/xmr-btc-swap/cli/testnet/monero/monero-wallet-rpc"}}
{"timestamp":"2022-10-25T10:59:50.781407Z","level":"DEBUG","fields":{"message":"RPC version output: Monero 'Fluorine Fermi' (v0.18.0.0-release)\n"}}
{"timestamp":"2022-10-25T10:59:50.781648Z","level":"DEBUG","fields":{"message":"Starting monero-wallet-rpc","port":"50409"}}
{"timestamp":"2022-10-25T10:59:54.305927Z","level":"DEBUG","fields":{"message":"Opened Monero wallet","monero_wallet_name":"swap-tool-blockchain-monitoring-wallet"}}
{"timestamp":"2022-10-25T10:59:54.948195Z","level":"DEBUG","fields":{"message":"Network layer initialized","peer_id":"12D3KooWQyzX7EHaF7WpDRftAeVbKMzk9WEuy6Kx5qeSCUB8mspU"}}
{"timestamp":"2022-10-25T10:59:54.948262Z","level":"DEBUG","fields":{"message":"Requesting quote"}}
{"timestamp":"2022-10-25T10:59:55.083714Z","level":"INFO","fields":{"message":"Connected to Alice at /dns4/asb.unstoppableswap.net/tcp/9939/p2p/12D3KooWJS3D2aN2Y4MNbDm66jCfkUSVpqW1u2TdURSqriny2CfX"}}
{"timestamp":"2022-10-25T10:59:55.127538Z","level":"INFO","fields":{"message":"Received quote","price":"0.00763674 BTC","minimum_amount":"0.00010000 BTC","maximum_amount":"0.07880419 BTC"}}
{"timestamp":"2022-10-25T10:59:55.39672Z","level":"INFO","fields":{"message":"Determined swap amount","amount":"0.00010768 BTC","fees":"0.00000122 BTC"}}
{"timestamp":"2022-10-25T10:59:55.40431Z","level":"DEBUG","fields":{"message":"Advancing state","state":"quote has been requested"}}
{"timestamp":"2022-10-25T10:59:55.664812Z","level":"DEBUG","fields":{"message":"Estimated fee for transaction","weight":"548","fee_rate":"1","sats_per_vbyte":"137.0"}}
{"timestamp":"2022-10-25T10:59:55.664907Z","level":"WARN","fields":{"message":"Estimated fee of 137.0 is smaller than the min relay fee, defaulting to min relay fee 1000"}}
{"timestamp":"2022-10-25T10:59:55.927878Z","level":"DEBUG","fields":{"message":"Estimated fee for transaction","weight":"596","fee_rate":"1","sats_per_vbyte":"149.0"}}
{"timestamp":"2022-10-25T10:59:55.927955Z","level":"WARN","fields":{"message":"Estimated fee of 149.0 is smaller than the min relay fee, defaulting to min relay fee 1000"}}
Error: Failed to complete swap

Caused by:
    0: Failed to deserialize bytes into message using CBOR
    1: EOF while parsing a value

ASB:

....
asb  | 2022-10-25 10:59:56 DEBUG Estimated fee for transaction weight=548 fee_rate=1 sats_per_vbyte=137.0
asb  | 2022-10-25 10:59:56  WARN Estimated fee of 137.0 is smaller than the min relay fee, defaulting to min relay fee 1000
asb  | 2022-10-25 10:59:56 DEBUG Estimated fee for transaction weight=548 fee_rate=1 sats_per_vbyte=137.0
asb  | 2022-10-25 10:59:56  WARN Estimated fee of 137.0 is smaller than the min relay fee, defaulting to min relay fee 1000
asb  | 2022-10-25 10:59:57 ERROR Communication error: Failed to read message2: Failed to deserialize bytes into message using CBOR: invalid type: byte array, expected a script peer=12D3KooWQyzX7EHaF7WpDRftAeVbKMzk9WEuy6Kx5qeSCUB8mspU

Lost/trapped Funds No

Platform (please complete the following information):

binarybaron commented 2 years ago

@delta1 Any idea what could be causing this? Could it be related to the bdk update? It's preventing me from working on the GUI :/

delta1 commented 2 years ago

Hey @binarybaron I do suspect it's the bdk change because of this error message:

invalid type: byte array, expected a script

Because the bump in rust-bitcoin that accompanied this changed the type of bitcoin witness scripts

Can you please try with swap/asb compiled from the same commit and specify what it is? I will try reproduce and get on fixing it.

binarybaron commented 2 years ago

Can you please try with swap/asb compiled from the same commit and specify what it is? I will try reproduce and get on fixing it.

Will do. I'm compiling the new version on my server at this very moment.

If it's the reason this is happening, would you be okay with just reversing the upgrade from bdk 0.16 to 0.23? If there aren't any critical security fixes in the upgrade and if there is no need for the new features, I don't see a reason to upgrade if breaks backwards compatability.

delta1 commented 2 years ago

would you be okay with just reversing the upgrade from bdk 0.16 to 0.23

Not really, I'd much rather make a new release for 0.12.

What changes do you have to 0.11? Can they be upstreamed here? Then we can do a backport release of that into 0.11.1 for you.

If there aren't any critical security fixes in the upgrade

I can't answer without an investigation and is a very good reason to stay current with their releases

delta1 commented 2 years ago

I'll take a look at making a 0.11.1 release with everything except the bdk changes

binarybaron commented 2 years ago

would you be okay with just reversing the upgrade from bdk 0.16 to 0.23

Not really, I'd much rather make a new release for 0.12.

What changes do you have to 0.11? Can they be upstreamed here? Then we can do a backport release of that into 0.11.1 for you.

If there aren't any critical security fixes in the upgrade

I can't answer without an investigation and is a very good reason to stay current with their releases

I understand your point but I think we have to consider the costs-benefits. The upgrade changes the internal data structures therefore a database created by the old version is not compatible with the latest version. We are essentially forcing users to delete their whole database just to be able to use the cli again. The GUI also uses the tx_lock saved in the database to display amounts, fees etc. The upgrade completely breaks the "History" tab (page where you can look at past swaps).

delta1 commented 2 years ago

I hear you, but what I’m saying is that we can make a release that excludes it - using the master branch can never guarantee non-breaking changes.

delta1 commented 2 years ago

@binarybaron here's a branch with everything from that bdk upgrade removed https://github.com/comit-network/xmr-btc-swap/tree/0.11.x

Want to give it a shot? I'm waiting on CI then I'll do a release from that branch of 0.11.1

delta1 commented 2 years ago

@binarybaron here's a branch with everything from that bdk upgrade removed https://github.com/comit-network/xmr-btc-swap/tree/0.11.x

Want to give it a shot? I'm waiting on CI then I'll do a release from that branch of 0.11.1

@binarybaron please try this branch - there's a CI/test failure that I'm only going to fix if this works for you

binarybaron commented 2 years ago

Sorry, forgot to reply. Running asb on https://github.com/comit-network/xmr-btc-swap/releases/tag/0.11.0 and CLI on the branch you provided fixes the issue

delta1 commented 2 years ago

No worries, happy to hear that. Let me take a quick look at this broken test and make a release for you.

lescuer97 commented 1 year ago

if this is ready and tests passed can we close this?

delta1 commented 1 year ago

Well, it's not an issue with 0.11.x but is likely to remain incompatible with master/the next major release 0.12

delta1 commented 1 year ago

Actually want to keep this open so I can remember to try fix it

lescuer97 commented 1 year ago

perfect no problem