8. Disputes โ
When one of the player is not respecting the rules, the dispute systems let the other re-establish the terms of the contracts.
Non playing opponent โ
If the other player doesn't want to play you can force him to play by:
- pushing the last state or playing onchain
- calling dispute_starving
@sp.entrypoint
def dispute_starving(self, game_id, flag):
sp.set_type(game_id, sp.TBytes)
# True to activate, False to deactivate.
sp.set_type(flag, sp.TBool)
After a player called the dispute_starving entrypoint with boolean True, the other player must play within the play_delay (see constants).
If the other player timed out, you can call starved.
@sp.entrypoint
def dispute_starved(self, game_id, player_id):
sp.set_type(game_id, sp.TBytes)
# Id of the other player
sp.set_type(player_id, sp.TInt)
The game will finish with the outcome "player_inactive",ย <id_of_the_player>
.
Player signed invalid new_state
โ
It's equivalent as if the player did not play. See above.
Stop starving โ
You can stop starving
at any moment by calling starving with flag to False
.
Player double signed โ
If the player double signed call dispute_double_signed.
The opponent sent two different play action signatures for the same move_number
.
If the opponent sent one of the two play action signatures directly onchain without sending it to you, you can retrieve the signature in the call of game_play.
t_statement = sp.TRecord(
# Current of the signed play action.
current=t_current,
# State of the signed play action. See compute-new_current-and-new_state
state=sp.TBytes,
# Data of the move
move_data=sp.TBytes,
# Signature of the action game_play that corresponds. See Sign a play action
sig=sp.TSignature,
)
@sp.entrypoint
def dispute_starved(self, game_id, player_id, statement1, statement2):
sp.set_type(game_id, sp.TBytes)
# Id of the other player
sp.set_type(player_id, sp.TInt)
# A record that corresponds to a offchain game_play action and signatures.
sp.set_type(statement1, t_statement)
# Another record that corresponds to a offchain game_play action and signatures.
sp.set_type(statement2, t_statement)
See game_id, current, compute new_current
and new_state
and Sign a play action.
Player signed a different move for a past state โ
This is equivalent to a double signed state.
Player is spamming me with different valid/invalid states โ
This is equivalent to a double signed state.
Player doesn't sign my move โ
This is equivalent to a non playing opponent.
You'll need to play onchain.
Player withdraw with bonds running โ
See withdraw challenge.