diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index 4dee5096896adea44d83396441345863f2110aba..3d6bfcdc4027faff3c745c5fcdafebf1bb0661b7 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -2841,21 +2841,21 @@ module Registration_section = struct let stack_type = ticket unit @$ cpair nat nat @$ bot let () = - let zero = Script_int.zero_n in + let one = Script_int.one_n in let ticket = { ticketer = Alpha_context.Contract.Implicit Environment.Signature.Public_key_hash.zero; contents = (); - amount = Ticket_amount.one; + amount = Ticket_amount.(add one one); } in benchmark_with_fixed_stack ~intercept:true ~name:Interpreter_workload.N_ISplit_ticket ~stack_type - ~stack:(ticket, ((zero, zero), eos)) + ~stack:(ticket, ((one, one), eos)) ~kinstr:split_ticket_instr () @@ -2867,11 +2867,15 @@ module Registration_section = struct make_default_samplers config.Default_config.sampler in fun () -> - let half_amount = Samplers.Random_value.value nat rng_state in - let half_amount = Script_int.add_n half_amount Script_int.one_n in - let amount = Script_int.add_n half_amount half_amount in + let x_amount = + Script_int.succ_n @@ Samplers.Random_value.value nat rng_state + in + let y_amount = + Script_int.succ_n @@ Samplers.Random_value.value nat rng_state + in + let amount = Script_int.add_n x_amount y_amount in let amount = - (* this is safe because half_amount > 0 *) + (* this is safe because x_amount > 0 and y_amount > 0 *) WithExceptions.Option.get ~loc:__LOC__ @@ Ticket_amount.of_n amount in @@ -2879,7 +2883,7 @@ module Registration_section = struct let ticket = {ticket with amount} in Ex_stack_and_kinstr { - stack = (ticket, ((half_amount, half_amount), eos)); + stack = (ticket, ((x_amount, y_amount), eos)); stack_type; kinstr = split_ticket_instr; }) diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml index bfeb4cc4e774e8a58ecb328d10069e8f01a55014..1d640eb8d91bdc5d41a7b8dc13e3674ae6a77183 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_model.ml @@ -238,27 +238,6 @@ module Models = struct ~coeff2:(fv (sf "%s_micheline_int_bytes" name)) ~coeff3:(fv (sf "%s_micheline_string_bytes" name)) - let split_ticket_model name = - let module M = struct - type arg_type = int * (int * unit) - - module Def (X : Costlang.S) = struct - open X - - type model_type = size -> size -> size - - let arity = Model.arity_2 - - let model = - lam ~name:"size1" @@ fun size1 -> - lam ~name:"size2" @@ fun size2 -> - free ~name:(fv (sf "%s_const" name)) - + (free ~name:(fv (sf "%s_add_coeff" name)) * max size1 size2) - + (free ~name:(fv (sf "%s_cmp_coeff" name)) * min size1 size2) - end - end in - (module M : Model.Model_impl with type arg_type = int * (int * unit)) - let open_chest_model name = let module M = struct type arg_type = int * (int * unit) @@ -446,7 +425,7 @@ let ir_model ?specialization instr_or_cont = | N_IComb_get | N_IComb | N_IComb_set | N_IUncomb -> model_1 instr_or_cont (affine_model name) | N_ITicket | N_IRead_ticket -> model_0 instr_or_cont (const1_model name) - | N_ISplit_ticket -> model_2 instr_or_cont (split_ticket_model name) + | N_ISplit_ticket -> model_2 instr_or_cont (linear_max_model name) | N_IJoin_tickets -> model_4 instr_or_cont (join_tickets_model name) | N_ISapling_verify_update -> model_2 instr_or_cont (verify_update_model name) diff --git a/src/proto_alpha/lib_protocol/michelson_v1_gas.ml b/src/proto_alpha/lib_protocol/michelson_v1_gas.ml index 38b80c962ea56cae34f594e360c4e297a78e9566..4f6bc65f1a23f419f9df85b744e147a89aab0446 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_gas.ml +++ b/src/proto_alpha/lib_protocol/michelson_v1_gas.ml @@ -1319,7 +1319,7 @@ module Cost_of = struct let hash_key _ = atomic_step_cost cost_N_IHash_key - let split_ticket _ amount_a amount_b = + let split_ticket amount_a amount_b = atomic_step_cost (cost_N_ISplit_ticket (int_bytes amount_a) (int_bytes amount_b)) diff --git a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli index 9a06aacfc62924bc00411bfa4cd3f1f0fc0dea67..59b4cd7df69cd1c57825add51c2c0d00b4a4f34a 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli +++ b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli @@ -350,11 +350,7 @@ module Cost_of : sig val read_ticket : Gas.cost - val split_ticket : - Script_typed_ir.ticket_amount -> - 'a Script_int.num -> - 'a Script_int.num -> - Gas.cost + val split_ticket : 'a Script_int.num -> 'a Script_int.num -> Gas.cost val join_tickets : 'a Script_typed_ir.comparable_ty -> diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index a6e85c0c2b7d4c35c624ee7901cf291506c82496..08e3ef4451cccbfc265aadd2963be8ed718d93f1 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -240,8 +240,8 @@ let cost_of_instr : type a s r f. (a, s, r, f) kinstr -> a -> s -> Gas.cost = let outputs = List.length tx.outputs in Interp_costs.sapling_verify_update_deprecated ~inputs ~outputs | ISplit_ticket _ -> - let ticket = accu and (amount_a, amount_b), _ = stack in - Interp_costs.split_ticket ticket.amount amount_a amount_b + let (amount_a, amount_b), _ = stack in + Interp_costs.split_ticket amount_a amount_b | IJoin_tickets (_, ty, _) -> let ticket_a, ticket_b = accu in Interp_costs.join_tickets ty ticket_a ticket_b