tmpim / Krist

Krist is a centralized-database economy system for Minecraft servers. Krist does not use a block-chain, or any similar technology. Krist is not a "cryptocurrency".
https://krist.dev/
GNU General Public License v3.0
24 stars 19 forks source link

Potential concurrency issue with solution submission #59

Closed dmarcuse closed 2 years ago

dmarcuse commented 3 years ago

The log file attached to tmpim/kristforge#17 seems to reveal a potential concurrency issue with block submission. Specifically, the server seems to:

  1. Occasionally fail to report the correct block when responding to a valid solution, and
  2. Occasionally indicate success when a solution is incorrect.

Here's an abridged summary of the log, with redundant lines omitted and especially important lines emphasized:

Line 178: Server indicates new block (event=block), with shorthash 000000001be0, height 1836124, and work 95187. Line 180: Miner submits a solution for block 000000001be0. Line 181: Server accepts this solution (type=response, ok=true, success=true), but indicates the same exact block as before - shorthash 000000001be0, height 1836124, and work 95187. It should have provided information for the new block instead. Line 183: Server indicates new block (event=block), with shorthash 00000000de55, height 1836125, and work 92923. This appears to be the correct block that should have been reported in the previous message. Line 185: Miner submits a different solution for (now outdated) block 000000001be0. (This was probably being sent while the previous server message was being received, but would usually be rejected by the server without issue). Line 186: Server accepts this erroneous solution (type=response, ok=true, success=true), but indicates the actual correct block from the previous server message (shorthash 00000000de55).

Without seeing the backend logs/database, it's hard to tell exactly what happened, but it seems that the actual block history is correct - there's just an issue with communicating the current state to clients. I suspect that this is the root issue causing tmpim/kristforge#17, because kristforge tracks mined krist using solution response messages, and the server is responding that a solution was correct when it's not.

Lemmmy commented 2 years ago

@rangerdude @dmarcuse sorry for getting to this so late! The database handling of block submission has changed with the recent TypeScript port and it is now correctly using database transactions. If you get the chance at any point, please let me know if you can still reproduce this issue. No rush!

dmarcuse commented 2 years ago

I'm happy to just close it now and reopen it if it remains an issue. Thanks!