@@ -11,7 +11,7 @@ use crate::channel_handler::game_handler::{
11
11
chia_dialect, GameHandler , MessageHandler , MessageInputs , MyTurnInputs , TheirTurnInputs ,
12
12
TheirTurnResult ,
13
13
} ;
14
- use crate :: channel_handler:: types:: { GameStartInfo , ReadableMove , ReadableUX } ;
14
+ use crate :: channel_handler:: types:: { GameStartInfo , ReadableMove , ReadableUX , Evidence } ;
15
15
use crate :: common:: constants:: CREATE_COIN ;
16
16
use crate :: common:: standard_coin:: {
17
17
curry_and_treehash, private_to_public_key, puzzle_for_pk, puzzle_hash_for_pk, sign_agg_sig_me,
@@ -223,6 +223,34 @@ struct RefereeMakerGameState {
223
223
pub previous_validation_program_hash : Hash ,
224
224
}
225
225
226
+ struct OnChainRefereeMove {
227
+ // Details
228
+ detauls : GameMoveDetails ,
229
+ mover_puzzle : Puzzle ,
230
+ mover_coin_spend_solution : NodePtr ,
231
+ }
232
+
233
+ struct OnChainRefereeSlash {
234
+ previous_state : NodePtr ,
235
+ previous_validation_program : Program ,
236
+ mover_coin_puzzle : Puzzle ,
237
+ mover_coin_spend_solution : NodePtr ,
238
+ slash_evidence : Evidence ,
239
+ }
240
+
241
+ // onchain referee solution
242
+ //
243
+ // This represents the whole solution for the on chain referee.
244
+ //
245
+ // It is a solution itself, but the referee coin uses the mover puzzle as a
246
+ // puzzle for a coin that represents the user's identity ... most likely a
247
+ // standard puzzle.
248
+ enum OnChainRefereeSolution {
249
+ Timeout ,
250
+ Move ( OnChainRefereeMove ) ,
251
+ Slash ( OnChainRefereeSlash )
252
+ }
253
+
226
254
// XXX break out state so we can have a previous state and easily swap them.
227
255
// Referee coin has two inner puzzles.
228
256
// Throughout channel handler, the one that's ours is the standard format puzzle
@@ -947,15 +975,15 @@ impl RefereeMaker {
947
975
state : NodePtr ,
948
976
validation_program : Puzzle ,
949
977
slash_solution : NodePtr ,
950
- coin_solution_after_slash : NodePtr
978
+ evidence : Evidence
951
979
) -> Result < NodePtr , Error > {
952
980
(
953
981
Node ( state. clone ( ) ) ,
954
982
(
955
983
validation_program. clone ( ) ,
956
984
(
957
985
self . target_puzzle_hash_for_slash ( ) ,
958
- ( Node ( slash_solution) , ( Node ( coin_solution_after_slash ) , ( ) ) ) ,
986
+ ( Node ( slash_solution) , ( Node ( evidence . to_nodeptr ( ) ) , ( ) ) ) ,
959
987
) ,
960
988
) ,
961
989
)
@@ -970,7 +998,7 @@ impl RefereeMaker {
970
998
new_puzzle : & Puzzle ,
971
999
new_puzzle_hash : & PuzzleHash ,
972
1000
slash_solution : NodePtr ,
973
- solution : NodePtr ,
1001
+ evidence : Evidence ,
974
1002
sig : & Aggsig ,
975
1003
) -> Result < TheirTurnCoinSpentResult , Error > {
976
1004
// Probably readable_info overlaps solution.
@@ -997,7 +1025,7 @@ impl RefereeMaker {
997
1025
state,
998
1026
Puzzle :: from_nodeptr ( validation_program) ,
999
1027
slash_solution,
1000
- solution
1028
+ evidence
1001
1029
) ?;
1002
1030
1003
1031
let coin_string_of_output_coin =
@@ -1171,14 +1199,16 @@ impl RefereeMaker {
1171
1199
Node ( state. clone ( ) ) ,
1172
1200
(
1173
1201
Node ( validation_program. clone ( ) ) ,
1174
- ( new_puzzle_hash. clone ( ) , ( Node ( slash_solution) , ( 0 , ( ) ) ) ) ,
1202
+ // No evidence here.
1203
+ ( new_puzzle_hash. clone ( ) , ( ( ) , ( 0 , ( ) ) ) ) ,
1175
1204
) ,
1176
1205
)
1177
1206
. to_clvm ( allocator)
1178
1207
. into_gen ( ) ?;
1179
1208
1180
1209
// Ultimately each of these cases returns some kind of
1181
1210
// TheirTurnCoinSpentResult.
1211
+ let nil_evidence = Evidence :: nil ( allocator) ;
1182
1212
match full_slash_result {
1183
1213
Ok ( _) => {
1184
1214
// result is NodePtr containing solution and aggsig.
@@ -1191,7 +1221,7 @@ impl RefereeMaker {
1191
1221
& new_puzzle,
1192
1222
& new_puzzle_hash,
1193
1223
full_slash_solution,
1194
- slash_solution ,
1224
+ nil_evidence ,
1195
1225
& slash_aggsig,
1196
1226
)
1197
1227
}
@@ -1216,15 +1246,17 @@ impl RefereeMaker {
1216
1246
run_debug : self . run_debug ,
1217
1247
} ,
1218
1248
) ? {
1219
- TheirTurnResult :: Slash ( solution, sig) => self . make_slash_for_their_turn (
1220
- allocator,
1221
- coin_string,
1222
- & new_puzzle,
1223
- & new_puzzle_hash,
1224
- full_slash_solution,
1225
- solution,
1226
- & ( slash_aggsig + sig) ,
1227
- ) ,
1249
+ TheirTurnResult :: Slash ( evidence, sig) => {
1250
+ self . make_slash_for_their_turn (
1251
+ allocator,
1252
+ coin_string,
1253
+ & new_puzzle,
1254
+ & new_puzzle_hash,
1255
+ full_slash_solution,
1256
+ evidence,
1257
+ & ( slash_aggsig + sig) ,
1258
+ )
1259
+ }
1228
1260
TheirTurnResult :: MakeMove ( game_handler, readable_move, message) => {
1229
1261
// Otherwise accept move by updating our state
1230
1262
self . accept_this_move (
0 commit comments