From b37cc47fdb55b9fb9a392c504dafbcb830948ddb Mon Sep 17 00:00:00 2001 From: Joel Bjornson Date: Thu, 24 Nov 2022 12:17:34 +0000 Subject: [PATCH] Proto/SCORU: carbonize proof start/stop --- src/proto_alpha/lib_protocol/sc_rollup_costs.mli | 5 +++++ src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/sc_rollup_costs.mli b/src/proto_alpha/lib_protocol/sc_rollup_costs.mli index a252b2030ba2..03887f970e8e 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_costs.mli +++ b/src/proto_alpha/lib_protocol/sc_rollup_costs.mli @@ -93,3 +93,8 @@ val cost_check_dissection : for a tick of a give [tick_size] within a given [number_of_sections]. *) val cost_find_tick : number_of_sections:int -> tick_size:int -> Gas_limit_repr.cost + +(** [cost_compare a_size_in_bytes b_size_in_bytes] returns the gas + cost of comparing two values given their respective sizes [a_size_in_bytes] + and [b_size_in_bytes]. *) +val cost_compare : int -> int -> Gas_limit_repr.cost 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 d7d6bdb4f654..5a7cdeddd2a9 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml @@ -817,6 +817,11 @@ let loser_of_results ~alice_result ~bob_result = | false, true -> Some Alice | true, false -> Some Bob +(* Cost of checking the start and stop hashes of a proof. *) +let cost_check_proof_start_stop = + let size = State_hash.size in + Saturation_repr.(mul (safe_int 2) (Sc_rollup_costs.cost_compare size size)) + (* TODO: https://gitlab.com/tezos/tezos/-/issues/2926 This function is incomplete and needs to account for additional gas. *) let cost_play ~number_of_sections _game refutation = @@ -833,8 +838,9 @@ let cost_play ~number_of_sections _game refutation = ~number_of_states ~tick_size ~hash_size - | Proof _proof -> Gas_limit_repr.free + | Proof _proof -> cost_check_proof_start_stop in + Gas_limit_repr.(cost_find_tick +@ cost_refutation) let play dal_parameters ~dal_attestation_lag ~stakers metadata game refutation = -- GitLab