From d5827f62f2cccb25cc5badb58ddb54d09f59721d Mon Sep 17 00:00:00 2001 From: Thomas Athorne Date: Fri, 20 May 2022 10:11:56 +0100 Subject: [PATCH] Proto: SCORU: add `level` to refutation game type --- src/proto_alpha/lib_protocol/alpha_context.mli | 1 + .../lib_protocol/sc_rollup_game_repr.ml | 18 ++++++++++++------ .../lib_protocol/sc_rollup_game_repr.mli | 6 ++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 1afc764720de..818a6c8b56c3 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2612,6 +2612,7 @@ module Sc_rollup : sig type t = { turn : player; inbox_snapshot : Inbox.t; + level : Raw_level.t; dissection : (State_hash.t option * Tick.t) list; } diff --git a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml index a5bcc03d1eb0..2322c868fa95 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml @@ -99,6 +99,7 @@ type player = Alice | Bob type t = { turn : player; inbox_snapshot : Sc_rollup_inbox_repr.t; + level : Raw_level_repr.t; dissection : (State_hash.t option * Sc_rollup_tick_repr.t) list; } @@ -130,13 +131,14 @@ let opponent = function Alice -> Bob | Bob -> Alice let encoding = let open Data_encoding in conv - (fun {turn; inbox_snapshot; dissection} -> - (turn, inbox_snapshot, dissection)) - (fun (turn, inbox_snapshot, dissection) -> - {turn; inbox_snapshot; dissection}) - (obj3 + (fun {turn; inbox_snapshot; level; dissection} -> + (turn, inbox_snapshot, level, dissection)) + (fun (turn, inbox_snapshot, level, dissection) -> + {turn; inbox_snapshot; level; dissection}) + (obj4 (req "turn" player_encoding) (req "inbox_snapshot" Sc_rollup_inbox_repr.encoding) + (req "level" Raw_level_repr.encoding) (req "dissection" (list @@ -159,13 +161,15 @@ let pp_dissection ppf d = let pp ppf game = Format.fprintf ppf - "[%a] %a playing; inbox snapshot is %a" + "[%a] %a playing; inbox snapshot = %a; level = %a" pp_dissection game.dissection pp_player game.turn Sc_rollup_inbox_repr.pp game.inbox_snapshot + Raw_level_repr.pp + game.level module Index = struct type t = Staker.t * Staker.t @@ -220,6 +224,7 @@ let initial inbox ~(parent : Commitment.t) ~(child : Commitment.t) ~refuter { turn = (if alice_to_play then Alice else Bob); inbox_snapshot = inbox; + level = child.inbox_level; dissection = [ (Some parent.compressed_state, Sc_rollup_tick_repr.initial); @@ -466,6 +471,7 @@ let play game refutation = { turn = opponent game.turn; inbox_snapshot = game.inbox_snapshot; + level = game.level; dissection = states; }) | Proof proof -> diff --git a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.mli b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.mli index 04c4a6705bd0..d50970a8e67f 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.mli @@ -182,6 +182,11 @@ type player = Alice | Bob otherwise they would have a 'moving target' because the actual inbox may be updated continuously. + - [level], the inbox level of the commitment the game is refuting. + This is only used when checking [Blocked_step] proofs---the proof + will show that the next message available in [inbox_snapshot] is + at [level], so shouldn't be included in this commitment. + - [dissection], a list of states with tick counts. The current player will specify, in the next move, a tick count that indicates the last of these states that she agrees with. @@ -195,6 +200,7 @@ type player = Alice | Bob type t = { turn : player; inbox_snapshot : Sc_rollup_inbox_repr.t; + level : Raw_level_repr.t; dissection : (State_hash.t option * Sc_rollup_tick_repr.t) list; } -- GitLab