clifordsymack / Electron-Cash

Electrum; Bitcoin thin client
MIT License
6 stars 3 forks source link

Shuffle loop because of wrong signature #77

Closed haplo closed 5 years ago

haplo commented 5 years ago

I had a couple coins frozen in Electron Cash before installing the CashShuffle beta, and now they get stuck in a shuffle loop. It looks like the coin participates in a shuffle, but it fails at the last step, making the shuffle fail for everyone.

CashShuffle should avoid operating on frozen coins.

haplo commented 5 years ago

Ummm, I think this is not the real issue after all, looks like the frozen coins were shuffle long ago. However the fact remains that there are two coins in my wallet that are stuck in a shuffle loop, never completing a round. I see them go up to Phase 5, then go back to In Queue.

Any tips on how can I debug this?

haplo commented 5 years ago

This is on Dev17 build BTW.

haplo commented 5 years ago

I started electron-cash --verbose and got some useful messages.

| 23.056| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 get session number.'
| 23.057| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 joined the pool!'
| 55.472| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 3 joined the pool!'
| 56.267| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 4 joined the pool!'
| 58.861| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 is about to share verification key with 5 players.'
| 59.224| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 get 5.'
| 59.225| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 begins CoinShuffle protocol  with 5 players.'
| 60.851| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 finds sufficient funds'
| 61.375| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 has broadcasted the new encryption key'
| 61.375| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 is about to read announcements'
| 61.375| [profiler] Round.broadcast_new_key 0.5236
| 61.517| [profiler] Round.check_for_signatures 0.1411
| 61.671| [profiler] Round.check_for_signatures 0.1535
| 61.811| [profiler] Round.check_for_signatures 0.1403
| 62.171| [profiler] Round.check_for_signatures 0.1749
| 62.963| [profiler] Round.check_for_signatures 0.1395
| 62.964| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 recieved all keys for test'
| 62.964| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 reaches phase 2'
| 68.326| [profiler] Round.check_for_signatures 0.1288
| 69.673| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 encrypt new address'
| 74.180| [profiler] Round.check_for_signatures 0.6575
| 74.181| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 receive addresses and found itsefs'
| 74.181| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 reaches phase 4'
| 74.933| [profiler] Round.check_for_signatures 0.2123
| 75.102| [profiler] Round.check_for_signatures 0.1685
| 75.244| [profiler] Round.check_for_signatures 0.1409
| 75.398| [profiler] Round.check_for_signatures 0.1541
| 77.458| [profiler] Round.check_for_signatures 0.1335
| 77.459| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 reaches phase 5'
| 79.494| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 send transction signatures'
| 79.628| [profiler] Round.check_for_signatures 0.1339
| 79.758| [profiler] Round.check_for_signatures 0.1295
| 79.904| [profiler] Round.check_for_signatures 0.1455
| 80.714| [profiler] Round.check_for_signatures 0.1325
| 82.194| [BackgroundShufflingThread (1009408) <shuffled>] Server shuffle.servo.cash:8080 told us that it has shufflePort=1337 poolSize=5 connections=22
| 83.125| [profiler] Round.check_for_signatures 0.1317
| 83.125| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Player 2 got transction signatures'
| 84.016| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Blame: wrong transaction signature from player 1'
| 84.016| [BackgroundShufflingThread (927488) <shuffled>] Signalling stop for scale: 10000
| 84.016| [BackgroundShufflingThread (927488) <shuffled>] Scale: 10000 Message: 'Exit: Scale '10000' Coin '<...redacted_coin_id...>:5''
| 84.016| [BackgroundShufflingThread (927488) <shuffled>] Signalling stop for scale: 10000
| 84.016| [Comm (927488) <shuffle.servo.cash:1337> <Scale: 10000>] Closing comm (subsequent socket errors are to be expected)
| 84.016| [BackgroundShufflingThread (1009408) <shuffled>] Stop protocol thread for scale: 10000
| 84.017| [BackgroundShufflingThread (1009408) <shuffled>] Thread already exited; cleaned up.
| 84.018| [BackgroundShufflingThread (1009408) <shuffled>] Stop protocol thread for scale: 10000

So the problem seems to be a signature check. No matter how many times the shuffle is attempted it's always failing with the same error.

cculianu commented 5 years ago

Thanks a lot for submitting this issue.

We recently changed the tx generation rules to disallow dust outputs and send them to miner fee. But older clients don't know this so they generate different tx's.

Chances are one of the other shufflers in the pool is using an older version of the CashShuffle program (from 3 days ago! Ha!). And so they are generating an invalid tx from the point of view of your client. Basically in corner cases newer and older clients stop agreeing on what the canonical tx should look like so they claim "invalid signature!".

This is what you get when you participate in a beta! We've changed things around a bit and the older client is breaking.

Don't worry -- you're good. Nothing's actually broken. We anticipated this happening when we changed the tx generation code. And.. we may change it again in the coming week to streamline the way shuffles work.

So this may keep happening until everyone upgrades.

cculianu commented 5 years ago

FWIW I've seen it too and I anticipated it would happen after yesterday's fix.

I'm going to go ahead and close this but if it keeps happening weeks from now -- it definitely would be a bug.

Since it hasn't happened much until recently after the fix -- a fix which I knew would create incompatibilities, I'm going to close this for now.

You've been very helpful with this bug report though. If every report for every project looked like this one -- most software would be fixed faster in general. :)

haplo commented 5 years ago

Good to know it's an expected failure. I completely understand that this is beta, so no worries! Besides this all my coins were shuffled just fine, I'm excited for CashShuffle to be integrated in as many wallets as possible.

I'm a Python programmer myself and would love to contribute to CashShuffle and Electron Cash, where should I head to?