magmo / apps

Proof of concept applications that use the Force Move Game framework.
9 stars 5 forks source link

race condition for challenging #143

Open geoknee opened 5 years ago

geoknee commented 5 years ago

Glenn and I had a game of TTT on Ropsten. (Presumably the same thing could happen in RPS)

  1. I played magnificently and totalled cornered @glennzw : Screenshot 2019-02-01 at 11.32.46.png
  2. Totally overwhelmed by my skillz, Glenn took ages. We think the following then happened.
  3. I fired off a challenge to the blockchain
  4. Shortly thereafter, and before he was notified of the challenge, Glenn made his move: Screen Shot 2019-02-01 at 11.15.13.png
  5. Please note that I would still have won
  6. I was able to eventually successfully withdraw when the challenge expired, and Glenn's app was stuck .

I think this can be fixed by watching for challenges even when we are waiting for a move. Then when the challenge arrives, we need either

  1. Roll back the state and explain why, and then we are in the usual challenge received workflow, OR
  2. Use the move that was already made in a RespondWithMove transaction, and explain what's happening to the user.
lalexgap commented 5 years ago

I believe this is handled already in rps. If a user has already made a move and gets a challenge they are given the option to respond with existing move.

geoknee commented 5 years ago

We tried to reproduce this today, and successfully followed the 'Respond With Existing Move' -> 'Continue Playing' path.

So either we didn't wait long enough for this to happen last time, or this is a different bug that we haven't been able to reproduce.