xaya / libxayagame

MIT License
21 stars 20 forks source link

Implement "updating state proof" for game channels #53

Closed domob1812 closed 5 years ago

domob1812 commented 5 years ago

One of the core components in the channel-management part of a game-channels game is the updating state proof. We should implement a library class that keeps track of a "current" state with full proof in memory, and updates it whenever either new on-chain states or new off-chain state transitions come in.

When a new on-chain state is found, we can simply use that without signatures as new state proof. When state transitions are added (e.g. sent from other players), we should make sure that we always keep enough signatures to have a valid proof, but remove older states that are no longer needed for that.

domob1812 commented 5 years ago

With the design changes made in #54 and #55, the logic here will need to be changed as well. We want to keep a current state proof for each reinitisliation of a channel that we know of. When new moves come in either off-chain or through disputes/resolutions published on-chain for an existing reinitisliation, we then simply update that reinitialisation's state proof if the new move is later (or do not do anything if not).

This ensures that we always have a valid state proof with the latest known turn, even if the on-chain states change and even if e.g. reinitsialisation moves are reorged away.

domob1812 commented 5 years ago

Fixed with 9d82306c77fdd2f5655a81e7af4043b11abf0096.