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

Swap failed, then a few seconds later completed #756

Closed
lukechilds opened this issue Apr 11, 2018 · 10 comments
Closed

Swap failed, then a few seconds later completed #756

lukechilds opened this issue Apr 11, 2018 · 10 comments

Comments

@lukechilds
Copy link
Contributor

I just did a swap that got a message saying it had failed, then a few seconds later a message saying it completed:

[
  {"gui":"hyperdex","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","timestamp":1523422535,"txfee":"10000","satoshis":"104235856","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09631822,"pubkey":"0000000000000000000000000000000000000000000000000000000000000000","method":"request"},
  {"gui":"hyperdex","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","timestamp":1523422535,"txfee":"10000","satoshis":"104235856","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09631822,"pubkey":"0000000000000000000000000000000000000000000000000000000000000000","method2":"request","method":"request"},
  {"gui":"nogui","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","address":"RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD","timestamp":1523422535,"txid":"03b818939063b74da94fa044a9bbada054e2175e9e3bf22f32797e153b9ca23d","vout":0,"srchash":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","txfee":"10000","quotetime":1523422537,"satoshis":"104275855","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","txid2":"acfb8e2027038ee65d27be24ea2713783cb93da8f3ea407295b451a1e6013672","vout2":0,"destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09628127,"requestid":1822085784,"quoteid":1835899996,"pending":1523422625,"method2":"reserved","method":"reserved"},
  {"gui":"hyperdex","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","address":"RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD","timestamp":1523422535,"txid":"03b818939063b74da94fa044a9bbada054e2175e9e3bf22f32797e153b9ca23d","vout":0,"srchash":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","txfee":"10000","quotetime":1523422537,"satoshis":"104275855","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","txid2":"acfb8e2027038ee65d27be24ea2713783cb93da8f3ea407295b451a1e6013672","vout2":0,"destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09628127,"requestid":523815073,"quoteid":4048394043,"pubkey":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","method":"connect","proof":[]},
  {"gui":"hyperdex","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","address":"RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD","timestamp":1523422535,"txid":"03b818939063b74da94fa044a9bbada054e2175e9e3bf22f32797e153b9ca23d","vout":0,"srchash":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","txfee":"10000","quotetime":1523422537,"satoshis":"104275855","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","txid2":"acfb8e2027038ee65d27be24ea2713783cb93da8f3ea407295b451a1e6013672","vout2":0,"destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09628127,"requestid":523815073,"quoteid":4048394043,"pubkey":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","proof":[],"method2":"connect","method":"connect"},
  {"gui":"nogui","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","address":"RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD","timestamp":1523422535,"txid":"03b818939063b74da94fa044a9bbada054e2175e9e3bf22f32797e153b9ca23d","vout":0,"srchash":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","txfee":"10000","quotetime":1523422542,"satoshis":"104275855","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","txid2":"acfb8e2027038ee65d27be24ea2713783cb93da8f3ea407295b451a1e6013672","vout2":0,"destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09628127,"requestid":523815073,"quoteid":3270592855,"pair":"tcp://173.212.225.176:27958","proof":[],"method2":"connected","method":"connected"},
  {"gui":"hyperdex","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","aliceid":"8164005029987024897","tradeid":2450937681,"base":"CHIPS","etomicsrc":"","rel":"KMD","etomicdest":"","address":"RB8yufv3YTfdzYnwz5paNnnDynGJG6WsqD","timestamp":1523422535,"txid":"03b818939063b74da94fa044a9bbada054e2175e9e3bf22f32797e153b9ca23d","vout":0,"srchash":"8adbf9d5de4fb49ec1fca9ca3f28ba384715752de1197c9cddbb756c3d2a1a7c","txfee":"10000","quotetime":1523422542,"satoshis":"104275855","desthash":"2632d12cd16572b7f45ce0ec3cf92d6beac9a2f53ca3971afbc90dbf6a16344d","txid2":"acfb8e2027038ee65d27be24ea2713783cb93da8f3ea407295b451a1e6013672","vout2":0,"destaddr":"RQm8BNygniNVqVPRYXEosznRZ7uEiooqSm","desttxid":"4c71d234aacdfbd1be6bbb21ee1d314d60edae0bba5c7a5aef01165abaa29884","destvout":1,"feetxid":"e1ec505f6c56df12681ee9623e94fedf392524b37e09007c8f3e5c19efce4dca","feevout":1,"desttxfee":"1000","destsatoshis":"10038849","price":0.09628127,"requestid":523815073,"quoteid":3270592855,"result":"success"},
  {"name":"myfee","coin":"KMD","tx":"0100000001ca4dceef195c3e8f7c00097eb3242539dffe943e62e91e6812df566c5f50ece1010000006a473044022035677f22168530ff399c7e6485b975528b2a213bd79e52c9892968311e50afd202202d7942d133bff0260b97721b07b1875f9af7162ac917c9c421b0c7c34a78413f01210330b4191bd253364abe8c19976f196bbcc2f3e66724816ef70e7fe472b5f59d0cffffffff0276320000000000001976a914ca1e04745e8ca0c60d8c5881531d51bec470743f88ac0c270500000000001976a914a9d2476fa20db74a8a9117f7999614ecb5b0a9d988ac4895cd5a","txid":"34b155a2aa2df6308ec0d03ea3fe198b08b6fece79d907459de1deeea91a66cf","expiration":1523438135,"uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","iambob":0,"bobcoin":"CHIPS","alicecoin":"KMD","lock":0,"amount":0.00012918,"Apayment":"bKEqkKHzGu8VGoeDmm7ERgZ95CK41rGAKd","method":"update","update":"myfee","requestid":523815073,"quoteid":3270592855},
  {"name":"bobdeposit","coin":"CHIPS","tx":"0100000001723601e6a151b4957240eaf3a83db93c781327ea24be275de68e0327208efbac000000006a47304402202adc5299fdccb165034e2cc8427f32f3efcaa112e136005d6808c29393342c320220063ba319945c5c93ca2c46a023f405c7279460addddf6627b530359626cf9f0601210315d9c51c657ab1be4ae9d3ab6e76a619d3bccfe830d5363fa168424c0d044732ffffffff02ae25fe060000000017a914a4f9427f8cc1ca5cb78f4a25c1169d652181f91f8702039c03000000001976a9141462c3dd3f936d595c9af55978003b27c250441f88ac37d2cd5a","txid":"90c06678b8a59503cc8eb254cc157fd850f69645564b9412aa3452c0790e5ce8","Bdeposit":"bTma7Zapm8DkQmKcmy9W9ZxvYGZUisheRY","expiration":1523438135,"uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","iambob":0,"bobcoin":"CHIPS","alicecoin":"KMD","lock":0,"amount":1.17319086,"Apayment":"bKEqkKHzGu8VGoeDmm7ERgZ95CK41rGAKd","redeem":"630437d2cd5ab17582012088a914a768e2cdcfd968afee0081aa3cc69a7541a22c1f882102b06b89542890f45e201c797a86dceb3325219bb9932bbe5a51068aae187f2a30ac6782012088a91457b63ba39663c93d824698f6c37dd926b4e6bc5d8821035439e370d83ba7277f10124081349b1f6a4ca347369da2f22c7816f989feef21ac68","method":"update","update":"bobdeposit","requestid":523815073,"quoteid":3270592855},
  {"name":"alicepayment","coin":"KMD","tx":"01000000018498a2ba5a1601ef5a7a5cba0baeed604d311dee21bb6bbed1fbcdaa34d2714c010000006b483045022100ee00b55b753a2ec3a59a5c5f1203e69861f58cbc5c35f1d885744c7d5a8aae5b022036e3ee0cf5027fe1c6102e0bba758e3fd9863538e8efd003098cff0e25d2eaee01210330b4191bd253364abe8c19976f196bbcc2f3e66724816ef70e7fe472b5f59d0cffffffff02293299000000000017a914476868b52bd51050da91183d297ef8d194b1792f87acb29e00000000001976a914a9d2476fa20db74a8a9117f7999614ecb5b0a9d988ac5092cd5a","txid":"94298563a9c1b82398339a0c543cc2dbd910ca0b1f412789fd1c1592697f8a8f","Bdeposit":"bTma7Zapm8DkQmKcmy9W9ZxvYGZUisheRY","expiration":1523438135,"uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","iambob":0,"bobcoin":"CHIPS","alicecoin":"KMD","lock":0,"amount":0.10039849,"trigger":"90c06678b8a59503cc8eb254cc157fd850f69645564b9412aa3452c0790e5ce8","Apayment":"bKEqkKHzGu8VGoeDmm7ERgZ95CK41rGAKd","redeem":"522102474f14f7d434d4989ef9eb56360faceb34eb4bba44d0cff83258b9017ed509962103a60c4b533dddd04ab4707a28bd34f974d4e9122b0f735f1ff202563790d64cd052ae","method":"update","update":"alicepayment","requestid":523815073,"quoteid":3270592855},
  {"name":"bobpayment","coin":"CHIPS","tx":"01000000013da29c3b157e79322ff23b9e5e17e254a0adbba944a04fa94db763909318b803000000006a47304402207ce7256e1e5bff57b813761b437f42dda13795d233d2a7568885a4817123470e02203fc432ba1b767060a2228cf7397cba9e2859b68362d458f25e42f20d49cdb62001210315d9c51c657ab1be4ae9d3ab6e76a619d3bccfe830d5363fa168424c0d044732ffffffff029f4637060000000017a9146e133085ccd2257d8b715eb23d11814483d0b64587dcefd302000000001976a9141462c3dd3f936d595c9af55978003b27c250441f88acbfb3cd5a","txid":"0142c02ced82b83e7759812032684647ff7ca5945c0de52989e2c92465e9972f","Bdeposit":"bTma7Zapm8DkQmKcmy9W9ZxvYGZUisheRY","Bpayment":"bNmJ1eMRxM8ikY8qZgHLA8XinZ5VCQPLyy","expiration":1523438135,"uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","iambob":0,"bobcoin":"CHIPS","alicecoin":"KMD","lock":0,"amount":1.04285855,"Apayment":"bKEqkKHzGu8VGoeDmm7ERgZ95CK41rGAKd","redeem":"6304bfb3cd5ab17521039de3807bcb3a61c9c17866ebe1b5aeb3a8a9b7996a9a355eada11696b44c7479ac6782012088a914a768e2cdcfd968afee0081aa3cc69a7541a22c1f882102b06b89542890f45e201c797a86dceb3325219bb9932bbe5a51068aae187f2a30ac68","method":"update","update":"bobpayment","requestid":523815073,"quoteid":3270592855},
  {"method":"failed","uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","error":-1007,"requestid":523815073,"quoteid":3270592855},
  {"uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22","expiration":1523438135,"tradeid":2450937681,"requestid":523815073,"quoteid":3270592855,"iambob":0,"Bgui":"","Agui":"hyperdex","gui":"hyperdex","bob":"CHIPS","srcamount":1.04265855,"bobtxfee":0.0001,"alice":"KMD","destamount":0.10037849,"alicetxfee":0.00001,"aliceid":"8164005029987024897","sentflags":["alicespend","bobpayment","alicepayment","bobdeposit","myfee"],"values":[1.04275855,0,1.04285855,0.10039849,1.17319086,0,0.00012918,0,0,0,0],"result":"success","status":"finished","finishtime":1523422821,"bobdeposit":"90c06678b8a59503cc8eb254cc157fd850f69645564b9412aa3452c0790e5ce8","alicepayment":"94298563a9c1b82398339a0c543cc2dbd910ca0b1f412789fd1c1592697f8a8f","bobpayment":"0142c02ced82b83e7759812032684647ff7ca5945c0de52989e2c92465e9972f","paymentspent":"d6f42cc13b1fdf4637459cca68917690e9b60c506a107f108e3d8a383b3006ed","Apaymentspent":"0000000000000000000000000000000000000000000000000000000000000000","depositspent":"0000000000000000000000000000000000000000000000000000000000000000","method":"tradestatus"}
]

Check the last two messages.

@jl777
Copy link
Owner

jl777 commented Apr 11, 2018

did the swap complete? my guess is that it failed waiting for some tx, so it both failed and then went on to complete the atomic swap protocol by unwinding the atomic swap and then completed

so this is maybe a bit unexpected, but an artifact of having 50+ possible failed messages to make sure that any problem is identified.

@lukechilds
Copy link
Contributor Author

According to the last message it appears to have completed. bobdeposit, alicepayment, bobpayment and paymentspent all have TXIDs. Wouldn't some of these be missing if it was unwound?

{  
   "uuid":"9201125e07d4e8a9a2bd24d7abcbb2872e2d77be0f5aea3c5f2d861b9fbf6c22",
   "expiration":1523438135,
   "tradeid":2450937681,
   "requestid":523815073,
   "quoteid":3270592855,
   "iambob":0,
   "Bgui":"",
   "Agui":"hyperdex",
   "gui":"hyperdex",
   "bob":"CHIPS",
   "srcamount":1.04265855,
   "bobtxfee":0.0001,
   "alice":"KMD",
   "destamount":0.10037849,
   "alicetxfee":0.00001,
   "aliceid":"8164005029987024897",
   "sentflags":[  
      "alicespend",
      "bobpayment",
      "alicepayment",
      "bobdeposit",
      "myfee"
   ],
   "values":[  
      1.04275855,
      0,
      1.04285855,
      0.10039849,
      1.17319086,
      0,
      0.00012918,
      0,
      0,
      0,
      0
   ],
   "result":"success",
   "status":"finished",
   "finishtime":1523422821,
   "bobdeposit":"90c06678b8a59503cc8eb254cc157fd850f69645564b9412aa3452c0790e5ce8",
   "alicepayment":"94298563a9c1b82398339a0c543cc2dbd910ca0b1f412789fd1c1592697f8a8f",
   "bobpayment":"0142c02ced82b83e7759812032684647ff7ca5945c0de52989e2c92465e9972f",
   "paymentspent":"d6f42cc13b1fdf4637459cca68917690e9b60c506a107f108e3d8a383b3006ed",
   "Apaymentspent":"0000000000000000000000000000000000000000000000000000000000000000",
   "depositspent":"0000000000000000000000000000000000000000000000000000000000000000",
   "method":"tradestatus"
}

Also, if the swap unwinds, do we get any extra TXIDs? Like the payments being sent back to the original address? Or is that not how it works?

@jl777
Copy link
Owner

jl777 commented Apr 12, 2018

From alice point of view, this one did complete. It seems to be a rare edge case where it gets an error in one part, even while it completed in the other. Never seen it before, but of course it makes sense you run into it.

i guess, this means some "failed" arent really failures. I guess the thing to do is to wait a bit, even after a failed message to see if it will end up completing. Horrible... but what else to do

@lukechilds
Copy link
Contributor Author

From alice point of view, this one did complete

So did it not complete for bob too? If that's the case, what happened to bobs funds? Surely it either completed or it didn't, as it's an atomic operation.

i guess, this means some "failed" arent really failures. I guess the thing to do is to wait a bit, even after a failed message to see if it will end up completing.

This could potentially lead to memory leaks because we need to keep listening on all failed swaps to check if they eventually complete.

Horrible... but what else to do

Can we not make the status atomic? It either fails or it doesn't.

@jl777
Copy link
Owner

jl777 commented Apr 12, 2018

i guess its possible, but it wont be easy...

bob's completion status is different from alice's as bob needs to do more things to undo a half started swap

@lukechilds
Copy link
Contributor Author

So how has it failed for bob? Did he not get his funds released? Is there any possibility of rolling back the trade?

@jl777
Copy link
Owner

jl777 commented Apr 13, 2018

bob manages his side independently from alice, there is no indication that the swap failed. the failed message was a network comms issue,

@lukechilds
Copy link
Contributor Author

Ok, are you able to track down the communication issue and resolve it from the posted socket messages?

We need to remove the swap listener from the socket message stream on failed event to avoid memory leaks. But currently that's not safe to do because in this scenario it will result in completed swaps listed as failed.

@jl777
Copy link
Owner

jl777 commented Apr 17, 2018

could you delay the swap listener removal for 5 or 10 minutes?
I could probably try to make it better, but there is no direct communication between the swap negotiation and the actual swap. basically the swap negotiation starts the swap and the swap does its thing in its own thread.

i fear messing with this could be like what happened with the orderbook/portfolio override. It just isnt designed for that. The failed messages are just posted to the event stream as you wanted all events. and here we have an event that is wrong... so what to do, we cant have the working swap fail just because there was a failed message. and we cant stop the failed message if there was a comms breakdown.

really, i think it is best for the GUI to deal with this edge case of a false positive failed message. it doesnt happen that often and it seems like having an expiration time for the removal of the swap listner that is set 10 minutes in the future whenever there is any activity would solve your issue

@lukechilds
Copy link
Contributor Author

we cant have the working swap fail just because there was a failed message. and we cant stop the failed message if there was a comms breakdown.

Ok, thanks for the explanation, will implement a 10 min delay before removing the event listener.

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

No branches or pull requests

2 participants