short thread for the optimizoooors:
in
stomp.gg, players typically commit to moves and then reveal them. this is to avoid frontrunning e.g. if you tell me what your move is first, or i see it onchain, then i can react to it.
but previously this required 3 txs:
- A commits
- B can then safely reveal because A is locked in,
- and then A finally reveals the preimage to their hash
but this is several rounds of back and forth, and we want to be fast and cheap
well, turns out we can centralize a little bit (with a fallback of course) and optimize a lot
new flow is:
A first sends their move hash to B (offchain).
B then signs over it, as well as their own move, and then sends it back to A (offchain).
A now has a signature that is only valid for their previously committed move, so they can submit that, as well as the reveal (finally onchain!) and then we can advance the game state
around 20k gas saved per turn