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 c8a45977cf2db849b74e75cc0224f2c850973152..f73448a384107de8d29c2c80e76011413122e3d3 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_game_repr.ml @@ -308,13 +308,13 @@ let step_encoding = let pp_step ppf step = match step with | Dissection states -> - Format.fprintf ppf "dissection:\n" ; + Format.fprintf ppf "Dissection:@ " ; Format.pp_print_list ~pp_sep:(fun ppf () -> Format.pp_print_string ppf ";\n\n") (fun ppf {state_hash; tick} -> Format.fprintf ppf - "tick = %a, state = %a\n" + "Tick: %a,@ State: %a\n" Sc_rollup_tick_repr.pp tick (Format.pp_print_option State_hash.pp) @@ -325,14 +325,14 @@ let pp_step ppf step = type refutation = {choice : Sc_rollup_tick_repr.t; step : step} -let pp_refutation ppf refutation = +let pp_refutation ppf {choice; step} = Format.fprintf ppf - "Refute from tick %a with %a.\n" + "Tick: %a@ Step: %a" Sc_rollup_tick_repr.pp - refutation.choice + choice pp_step - refutation.step + step let refutation_encoding = let open Data_encoding in diff --git a/src/proto_alpha/lib_protocol/sc_rollup_refutation_storage.ml b/src/proto_alpha/lib_protocol/sc_rollup_refutation_storage.ml index a506e941714b8fcd033356b286e4f388b739a9fe..082596c7498acea80985b2cfb63247a6440bba5d 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_refutation_storage.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_refutation_storage.ml @@ -163,7 +163,7 @@ let get_game ctxt rollup stakers = let* ctxt, game = Store.Game.find (ctxt, rollup) stakers in match game with Some g -> return (g, ctxt) | None -> fail Sc_rollup_no_game -(** [init_game ctxt rollup refuter defender] initialises the game or +(** [start_game ctxt rollup refuter defender] initialises the game or if it already exists fails with `Sc_rollup_game_already_started`. The game is created with `refuter` as the first player to move. The @@ -195,68 +195,53 @@ let get_game ctxt rollup stakers = {li [Sc_rollup_staker_in_game] if one of the [refuter] or [defender] is already playing a game} } *) -let init_game ctxt rollup ~refuter ~defender = +let start_game ctxt rollup ~player:refuter ~opponent:defender = let open Lwt_tzresult_syntax in let stakers = Sc_rollup_game_repr.Index.make refuter defender in - let* ctxt, game = Store.Game.find (ctxt, rollup) stakers in - match game with - | Some _ -> fail Sc_rollup_game_already_started - | None -> - let* ctxt, opp_1 = Store.Opponent.find (ctxt, rollup) refuter in - let* ctxt, opp_2 = Store.Opponent.find (ctxt, rollup) defender in - let* _ = - match (opp_1, opp_2) with - | None, None -> return () - | Some _refuter_opponent, None -> - fail (Sc_rollup_staker_in_game (`Refuter refuter)) - | None, Some _defender_opponent -> - fail (Sc_rollup_staker_in_game (`Defender defender)) - | Some _refuter_opponent, Some _defender_opponent -> - fail (Sc_rollup_staker_in_game (`Both (refuter, defender))) - in - let* ( ( {hash = _refuter_commit; commitment = _info}, - {hash = _defender_commit; commitment = child_info} ), - ctxt ) = - get_conflict_point ctxt rollup refuter defender - in - let* parent_info, ctxt = - Commitment_storage.get_commitment_unsafe - ctxt - rollup - child_info.predecessor - in - let* ctxt, inbox = Store.Inbox.get ctxt rollup in - let* ctxt, kind = Store.PVM_kind.get ctxt rollup in - let default_number_of_sections = - Constants_storage.sc_rollup_number_of_sections_in_dissection ctxt - in - - let game = - Sc_rollup_game_repr.initial - (Sc_rollup_inbox_repr.take_snapshot inbox) - ~pvm_name:(Sc_rollups.Kind.name_of kind) - ~parent:parent_info - ~child:child_info - ~refuter - ~defender - ~default_number_of_sections - in - let* ctxt, _ = Store.Game.init (ctxt, rollup) stakers game in - let* ctxt, _ = - Store.Game_timeout.init (ctxt, rollup) stakers (timeout_level ctxt) - in - let* ctxt, _ = Store.Opponent.init (ctxt, rollup) refuter defender in - let* ctxt, _ = Store.Opponent.init (ctxt, rollup) defender refuter in - return (game, ctxt) + let* ctxt, game_exists = Store.Game.mem (ctxt, rollup) stakers in + let* () = fail_when game_exists Sc_rollup_game_already_started in + let* ctxt, opp_1 = Store.Opponent.find (ctxt, rollup) refuter in + let* ctxt, opp_2 = Store.Opponent.find (ctxt, rollup) defender in + let* _ = + match (opp_1, opp_2) with + | None, None -> return () + | Some _refuter_opponent, None -> + fail (Sc_rollup_staker_in_game (`Refuter refuter)) + | None, Some _defender_opponent -> + fail (Sc_rollup_staker_in_game (`Defender defender)) + | Some _refuter_opponent, Some _defender_opponent -> + fail (Sc_rollup_staker_in_game (`Both (refuter, defender))) + in + let* ( ( {hash = _refuter_commit; commitment = _info}, + {hash = _defender_commit; commitment = child_info} ), + ctxt ) = + get_conflict_point ctxt rollup refuter defender + in + let* parent_info, ctxt = + Commitment_storage.get_commitment_unsafe ctxt rollup child_info.predecessor + in + let* ctxt, inbox = Store.Inbox.get ctxt rollup in + let* ctxt, kind = Store.PVM_kind.get ctxt rollup in + let default_number_of_sections = + Constants_storage.sc_rollup_number_of_sections_in_dissection ctxt + in -let start_game ctxt rollup ~player ~opponent = - let open Lwt_tzresult_syntax in - let idx = Sc_rollup_game_repr.Index.make player opponent in - let* game, ctxt = init_game ctxt rollup ~refuter:player ~defender:opponent in - let* ctxt, _ = Store.Game.update (ctxt, rollup) idx game in + let game = + Sc_rollup_game_repr.initial + (Sc_rollup_inbox_repr.take_snapshot inbox) + ~pvm_name:(Sc_rollups.Kind.name_of kind) + ~parent:parent_info + ~child:child_info + ~refuter + ~defender + ~default_number_of_sections + in + let* ctxt, _ = Store.Game.init (ctxt, rollup) stakers game in let* ctxt, _ = - Store.Game_timeout.update (ctxt, rollup) idx (timeout_level ctxt) + Store.Game_timeout.init (ctxt, rollup) stakers (timeout_level ctxt) in + let* ctxt, _ = Store.Opponent.init (ctxt, rollup) refuter defender in + let* ctxt, _ = Store.Opponent.init (ctxt, rollup) defender refuter in return ctxt let game_move ctxt rollup ~player ~opponent refutation = @@ -270,9 +255,7 @@ let game_move ctxt rollup ~player ~opponent refutation = (Sc_rollup_game_repr.Index.staker idx game.turn)) Sc_rollup_wrong_turn in - let* move_result = - Lwt.map Result.ok @@ Sc_rollup_game_repr.play game refutation - in + let*! move_result = Sc_rollup_game_repr.play game refutation in match move_result with | Either.Left outcome -> return (Some outcome, ctxt) | Either.Right new_game -> @@ -285,19 +268,14 @@ let game_move ctxt rollup ~player ~opponent refutation = let timeout ctxt rollup stakers = let open Lwt_tzresult_syntax in let level = (Raw_context.current_level ctxt).level in - let* ctxt, game = Store.Game.find (ctxt, rollup) stakers in - match game with - | None -> fail Sc_rollup_no_game - | Some game -> - let* ctxt, timeout_level = - Store.Game_timeout.get (ctxt, rollup) stakers - in - let* () = - fail_unless - Raw_level_repr.(level > timeout_level) - Sc_rollup_timeout_level_not_reached - in - return (Sc_rollup_game_repr.{loser = game.turn; reason = Timeout}, ctxt) + let* game, ctxt = get_game ctxt rollup stakers in + let* ctxt, timeout_level = Store.Game_timeout.get (ctxt, rollup) stakers in + let* () = + fail_unless + Raw_level_repr.(level > timeout_level) + Sc_rollup_timeout_level_not_reached + in + return (Sc_rollup_game_repr.{loser = game.turn; reason = Timeout}, ctxt) let apply_outcome ctxt rollup stakers (outcome : Sc_rollup_game_repr.outcome) = let open Lwt_tzresult_syntax in diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index fe5a94cc60e62cd346e1bdb01e9200ce019b981d..85018eb7f9cdde96eb1af378f6e3bab256c2fcda 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -384,6 +384,15 @@ module Sc_rollup = struct hash () () + + let genesis_info ctxt sc_rollup = + Environment.RPC_context.make_call1 + Plugin.RPC.Sc_rollup.S.genesis_info + rpc_ctxt + ctxt + sc_rollup + () + () end type (_, _) tup = diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 0f589b66ae622445f18830593f7794759eb56bcc..416b32da3cc72565bda966c0a8f6626f09f013da 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -221,6 +221,9 @@ module Sc_rollup : sig Sc_rollup.t -> Sc_rollup.Commitment.Hash.t -> Sc_rollup.Commitment.t tzresult Lwt.t + + val genesis_info : + t -> Sc_rollup.t -> Sc_rollup.Commitment.genesis_info tzresult Lwt.t end type (_, _) tup = diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml index 6d2ad1339282d58eba1e2c14cfb63016656464d8..50db1fca0911186bffbd10858ce04ebd5229bd3b 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -58,7 +58,9 @@ let rpc_context st = } let rpc_ctxt = - new Environment.proto_rpc_context_of_directory rpc_context rpc_services + new Environment.proto_rpc_context_of_directory + rpc_context + Plugin.RPC.rpc_services let alpha_ctxt st = st.state.ctxt diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.ml b/src/proto_alpha/lib_protocol/test/helpers/op.ml index ffc6e2daadfcceb70530c60c8c3d0e48417ca512..6cdcb9b872821e2f9c1fd8aca961ff38b896b375 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/op.ml @@ -788,7 +788,8 @@ let originated_sc_rollup op = Sc_rollup.Internal_for_tests.originated_sc_rollup nonce let sc_rollup_origination ?force_reveal ?counter ?fee ?gas_limit ?storage_limit - ?origination_proof ctxt (src : Contract.t) kind boot_sector parameters_ty = + ?origination_proof ctxt (src : Contract.t) kind ~boot_sector ~parameters_ty + = (match origination_proof with | None -> Sc_rollup_helpers.origination_proof ~boot_sector kind | Some origination_proof -> Lwt.return origination_proof) diff --git a/src/proto_alpha/lib_protocol/test/helpers/op.mli b/src/proto_alpha/lib_protocol/test/helpers/op.mli index c96b2140df28512518319788e983b53831c13cf6..19575638e11cbbe55cbb01d5c194a98ed6f5c830 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/op.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/op.mli @@ -527,8 +527,8 @@ val sc_rollup_origination : Context.t -> Contract.t -> Sc_rollup.Kind.t -> - string -> - Script.lazy_expr -> + boot_sector:string -> + parameters_ty:Script.lazy_expr -> (packed_operation * Sc_rollup.t) tzresult Lwt.t (** [sc_rollup_publish ctxt source rollup commitment] tries to publish diff --git a/src/proto_alpha/lib_protocol/test/helpers/ticket_helpers.ml b/src/proto_alpha/lib_protocol/test/helpers/ticket_helpers.ml index 2d324a79f5b33318af09bd74a7ba50e88900d183..ba0f48f795643205e843f2b85f1d402435673e44 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/ticket_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/ticket_helpers.ml @@ -45,3 +45,15 @@ let string_ticket_token ticketer content = return (Ticket_token.Ex_token {ticketer; contents_type = Script_typed_ir.string_t; contents}) + +let adjust_ticket_token_balance alpha_ctxt owner ticket_token ~delta = + let open Lwt_result_syntax in + let* ticket_token_hash, ctxt = + Ticket_balance_key.of_ex_token alpha_ctxt ~owner ticket_token + >|= Environment.wrap_tzresult + in + let* _, alpha_ctxt = + Ticket_balance.adjust_balance ctxt ticket_token_hash ~delta + >|= Environment.wrap_tzresult + in + return (ticket_token_hash, alpha_ctxt) diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml index 4d1c2d79b9a3a6fbf8ff1f301d2e0472c6a47f85..4c7d8f96e8458d472fca3280a6f0af715b0f1dcb 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_typechecking.ml @@ -56,8 +56,8 @@ let sc_originate block contract parameters_ty = (B block) contract kind - "" - (Script.lazy_expr @@ Expr.from_string parameters_ty) + ~boot_sector:"" + ~parameters_ty:(Script.lazy_expr @@ Expr.from_string parameters_ty) in let* incr = Incremental.begin_construction block in let* incr = Incremental.add_operation incr operation in diff --git a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml index b3dbf2c441ab432d0ebc5fe8d58923613050cb0c..fe6d792390698911c02520658005b4b3f742b54d 100644 --- a/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml +++ b/src/proto_alpha/lib_protocol/test/integration/operations/test_sc_rollup.ml @@ -103,7 +103,7 @@ let test_disable_feature_flag () = let kind = Sc_rollup.Kind.Example_arith in let* op, _ = let parameters_ty = Script.lazy_expr @@ Expr.from_string "unit" in - Op.sc_rollup_origination (I i) contract kind "" parameters_ty + Op.sc_rollup_origination (I i) contract kind ~boot_sector:"" ~parameters_ty in let expect_apply_failure = function | Environment.Ecoproto_error @@ -140,8 +140,8 @@ let sc_originate ?(boot_sector = "") ?origination_proof block contract (B block) contract kind - boot_sector - (Script.lazy_expr @@ Expr.from_string parameters_ty) + ~boot_sector + ~parameters_ty:(Script.lazy_expr @@ Expr.from_string parameters_ty) in let* incr = Incremental.begin_construction block in let* incr = Incremental.add_operation incr operation in @@ -166,20 +166,17 @@ let number_of_ticks_exn n = | None -> Stdlib.failwith "Bad Number_of_ticks" let dummy_commitment ctxt rollup = - let ctxt = Incremental.alpha_ctxt ctxt in - let* genesis_info = - Sc_rollup.genesis_info ctxt rollup >|= Environment.wrap_tzresult - in + let* genesis_info = Context.Sc_rollup.genesis_info ctxt rollup in let predecessor = genesis_info.commitment_hash in - let* {compressed_state; _}, ctxt = - Sc_rollup.Commitment.get_commitment ctxt rollup genesis_info.commitment_hash - >|= Environment.wrap_tzresult + let* {compressed_state; _} = + Context.Sc_rollup.commitment ctxt rollup genesis_info.commitment_hash in let root_level = genesis_info.level in - let inbox_level = - let commitment_freq = - Constants_storage.sc_rollup_commitment_period_in_blocks - (Alpha_context.Internal_for_tests.to_raw ctxt) + let* inbox_level = + let+ constants = Context.get_constants ctxt in + let Constants.Parametric.{commitment_period_in_blocks = commitment_freq; _} + = + constants.parametric.sc_rollup in Raw_level.of_int32_exn (Int32.add (Raw_level.to_int32 root_level) (Int32.of_int commitment_freq)) @@ -406,7 +403,7 @@ let publish_and_cement_commitment incr ~baker ~originator rollup commitment = return (hash, incr) let publish_and_cement_dummy_commitment incr ~baker ~originator rollup = - let* commitment = dummy_commitment incr rollup in + let* commitment = dummy_commitment (I incr) rollup in publish_and_cement_commitment incr ~baker ~originator rollup commitment (* Publishes repeated cemented commitments until a commitment with @@ -414,19 +411,16 @@ let publish_and_cement_dummy_commitment incr ~baker ~originator rollup = is also published and cemented). *) let publish_commitments_until_min_inbox_level incr rollup ~baker ~originator ~min_inbox_level ~cemented_commitment_hash ~cemented_commitment = - let commitment_freq = - Constants_storage.sc_rollup_commitment_period_in_blocks - (Alpha_context.Internal_for_tests.to_raw @@ Incremental.alpha_ctxt incr) + let* constants = Context.get_constants (I incr) in + let Constants.Parametric.{commitment_period_in_blocks = commitment_freq; _} = + constants.parametric.sc_rollup in let rec aux incr hash ({Sc_rollup.Commitment.inbox_level; _} as commitment) = - let level = Int32.to_int @@ Raw_level.to_int32 inbox_level in - if level >= min_inbox_level then return (hash, incr) + let level = Raw_level.to_int32 inbox_level in + if level >= Int32.of_int min_inbox_level then return (hash, incr) else let next_inbox_level = - Raw_level.of_int32_exn - (Int32.add - (Raw_level.to_int32 inbox_level) - (Int32.of_int commitment_freq)) + Raw_level.of_int32_exn (Int32.add level (Int32.of_int commitment_freq)) in let commitment = {commitment with predecessor = hash; inbox_level = next_inbox_level} @@ -438,20 +432,23 @@ let publish_commitments_until_min_inbox_level incr rollup ~baker ~originator in aux incr cemented_commitment_hash cemented_commitment -let deposit_ticket_token incr rollup ticket_token delta = - wrap - (let ctxt = Incremental.alpha_ctxt incr in - let* rollup_red_token_hash, ctxt = - Ticket_balance_key.of_ex_token - ctxt - ~owner:(Destination.Sc_rollup rollup) - ticket_token - in - let* _, ctxt = - Ticket_balance.adjust_balance ctxt rollup_red_token_hash ~delta - in - let incr = Incremental.set_alpha_ctxt incr ctxt in - return incr) +let adjust_ticket_token_balance_of_rollup ctxt rollup ticket_token ~delta = + let* incr = + Context.( + match ctxt with + | I incr -> return incr + | B block -> Incremental.begin_construction block) + in + let alpha_ctxt = Incremental.alpha_ctxt incr in + let* hash, alpha_ctxt = + Ticket_helpers.adjust_ticket_token_balance + alpha_ctxt + (Destination.Sc_rollup rollup) + ticket_token + ~delta + in + let incr = Incremental.set_alpha_ctxt incr alpha_ctxt in + return (hash, incr) (** A version of execute outbox message that output ignores proof validation. *) let execute_outbox_message_without_proof_validation incr rollup @@ -484,15 +481,14 @@ let execute_outbox_message incr ~originator rollup ~output_proof let* block = Incremental.finalize_block incr in Incremental.begin_construction block -let get_balance ctxt ~token ~owner = - let* key_hash, ctxt = - wrap @@ Ticket_balance_key.of_ex_token ctxt ~owner token - in - wrap (Ticket_balance.get_balance ctxt key_hash) - let assert_ticket_token_balance ~loc incr token owner expected = let ctxt = Incremental.alpha_ctxt incr in - let* balance, _ = get_balance ctxt ~token ~owner in + let* balance, _ = + let* key_hash, ctxt = + wrap @@ Ticket_balance_key.of_ex_token ctxt ~owner token + in + wrap (Ticket_balance.get_balance ctxt key_hash) + in match (balance, expected) with | Some b, Some e -> Assert.equal_int ~loc (Z.to_int b) e | Some b, None -> @@ -567,13 +563,13 @@ let recover_bond_with_success i contract rollup = The comitter tries to withdraw stake before and after cementing. Only the second attempt is expected to succeed. *) let test_publish_cement_and_recover_bond () = - let* ctxt, contracts, rollup = init_and_originate Context.T2 "unit" in + let* block, contracts, rollup = init_and_originate Context.T2 "unit" in let _, contract = contracts in - let* i = Incremental.begin_construction ctxt in + let* i = Incremental.begin_construction block in (* not staked yet *) let* () = recover_bond_not_staked i contract rollup in - let* c = dummy_commitment i rollup in - let* operation = Op.sc_rollup_publish (B ctxt) contract rollup c in + let* c = dummy_commitment (I i) rollup in + let* operation = Op.sc_rollup_publish (B block) contract rollup c in let* i = Incremental.add_operation i operation in let* b = Incremental.finalize_block i in let* constants = Context.get_constants (B b) in @@ -609,7 +605,7 @@ let test_publish_fails_on_backtrack () = let* ctxt, contracts, rollup = init_and_originate Context.T2 "unit" in let _, contract = contracts in let* i = Incremental.begin_construction ctxt in - let* commitment1 = dummy_commitment i rollup in + let* commitment1 = dummy_commitment (I i) rollup in let commitment2 = {commitment1 with number_of_ticks = number_of_ticks_exn 3001l} in @@ -637,7 +633,7 @@ let test_cement_fails_on_conflict () = let* ctxt, contracts, rollup = init_and_originate Context.T3 "unit" in let _, contract1, contract2 = contracts in let* i = Incremental.begin_construction ctxt in - let* commitment1 = dummy_commitment i rollup in + let* commitment1 = dummy_commitment (I i) rollup in let commitment2 = {commitment1 with number_of_ticks = number_of_ticks_exn 3001l} in @@ -667,11 +663,11 @@ let test_cement_fails_on_conflict () = let* _ = Incremental.add_operation ~expect_apply_failure i cement_op in return_unit -let commit_and_cement_after_n_bloc ?expect_apply_failure ctxt contract rollup n +let commit_and_cement_after_n_bloc ?expect_apply_failure block contract rollup n = - let* i = Incremental.begin_construction ctxt in - let* commitment = dummy_commitment i rollup in - let* operation = Op.sc_rollup_publish (B ctxt) contract rollup commitment in + let* i = Incremental.begin_construction block in + let* commitment = dummy_commitment (I i) rollup in + let* operation = Op.sc_rollup_publish (B block) contract rollup commitment in let* i = Incremental.add_operation i operation in let* b = Incremental.finalize_block i in (* This pattern would add an additional block, so we decrement [n] by one. *) @@ -903,7 +899,9 @@ let test_single_transaction_batch () = in let output = make_output ~outbox_level:0 ~message_index:0 transactions in (* Set up the balance so that the self contract owns one ticket. *) - let* incr = deposit_ticket_token incr rollup red_token Z.one in + let* _ticket_hash, incr = + adjust_ticket_token_balance_of_rollup (I incr) rollup red_token ~delta:Z.one + in let* Sc_rollup_operations.{operations; _}, incr = execute_outbox_message_without_proof_validation incr @@ -989,7 +987,13 @@ let test_multi_transaction_batch () = (* Create an atomic batch message. *) let output = make_output ~outbox_level:0 ~message_index:0 transactions in (* Set up the balance so that the rollup owns 10 units of red tokens. *) - let* incr = deposit_ticket_token incr rollup red_token (Z.of_int 10) in + let* _ticket_hash, incr = + adjust_ticket_token_balance_of_rollup + (I incr) + rollup + red_token + ~delta:(Z.of_int 10) + in let* Sc_rollup_operations.{operations; _}, incr = execute_outbox_message_without_proof_validation incr @@ -1205,7 +1209,7 @@ let test_execute_message_override_applied_messages_slot () = in return (paid_storage_size_diff, incr) in - let* cemented_commitment = dummy_commitment incr rollup in + let* cemented_commitment = dummy_commitment (I incr) rollup in let* cemented_commitment_hash, incr = publish_and_cement_commitment incr @@ -1358,21 +1362,20 @@ let test_insufficient_ticket_balances () = (* Set up the balance so that the rollup owns 7 units of red tokens. This is insufficient wrt the set of transactions above. *) - let* incr = deposit_ticket_token incr rollup red_token (Z.of_int 7) in - let* key, ctxt = - wrap - (Ticket_balance_key.of_ex_token - (Incremental.alpha_ctxt incr) - ~owner:(Destination.Sc_rollup rollup) - red_token) + let* ticket_hash, incr = + adjust_ticket_token_balance_of_rollup + (I incr) + rollup + red_token + ~delta:(Z.of_int 7) in - let incr = Incremental.set_alpha_ctxt incr ctxt in (* Executing the batch fails because the rollup only has 7 units of tickets but attempts to transfer 10 units. *) assert_fails ~loc:__LOC__ ~error: - (Ticket_balance.Negative_ticket_balance {key; balance = Z.of_int (-3)}) + (Ticket_balance.Negative_ticket_balance + {key = ticket_hash; balance = Z.of_int (-3)}) (execute_outbox_message_without_proof_validation incr rollup diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml index 2f5f15ffc87478a5358bb68c2bba5ea830f413d8..366828a02238cb94d2a0b4ab7a5b9beda2dd281a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/manager_operation_helpers.ml @@ -351,8 +351,8 @@ let originate_sc_rollup block rollup_account = (B block) rollup_contract Sc_rollup.Kind.Example_arith - "" - (Script.lazy_expr (Expr.from_string "1")) + ~boot_sector:"" + ~parameters_ty:(Script.lazy_expr (Expr.from_string "1")) in let+ block = Block.bake ~operation:rollup_origination block in (block, sc_rollup) @@ -832,8 +832,8 @@ let mk_sc_rollup_origination (oinfos : operation_req) (infos : infos) = (B infos.ctxt.block) (contract_of infos.accounts.source) Sc_rollup.Kind.Example_arith - "" - (Script.lazy_expr (Expr.from_string "1")) + ~boot_sector:"" + ~parameters_ty:(Script.lazy_expr (Expr.from_string "1")) in op