diff --git a/src/proto_alpha/lib_benchmark/autocomp.ml b/src/proto_alpha/lib_benchmark/autocomp.ml index 1a44dc9826f73a9d09bb15fc04973f87b666772d..e45662a9c1f1d3bdde80c05aff016f77369a7c2b 100644 --- a/src/proto_alpha/lib_benchmark/autocomp.ml +++ b/src/proto_alpha/lib_benchmark/autocomp.ml @@ -172,11 +172,11 @@ struct | Unit_t -> return Mikhailsky.Data.unit | Int_t -> sample @@ Michelson_base.int >>= fun i -> - let i = Protocol.Script_int_repr.to_zint i in + let i = Protocol.Script_int.to_zint i in return (Mikhailsky.Data.big_integer i) | Nat_t -> sample @@ Michelson_base.nat >>= fun n -> - let n = Protocol.Script_int_repr.to_zint n in + let n = Protocol.Script_int.to_zint n in return (Mikhailsky.Data.big_natural n) | Bool_t -> sample Base_samplers.uniform_bool >>= fun b -> @@ -184,7 +184,7 @@ struct else return Mikhailsky.Data.false_ | String_t -> sample Michelson_base.string >>= fun str -> - let str = Protocol.Script_string_repr.to_string str in + let str = Protocol.Script_string.to_string str in return (Mikhailsky.Data.string str) | Bytes_t -> sample Michelson_base.bytes >>= fun bytes -> diff --git a/src/proto_alpha/lib_benchmark/execution_context.ml b/src/proto_alpha/lib_benchmark/execution_context.ml index 404300f09730d7fa0847761bb8c226d12f04d5b8..747318a6690145b5df08e60c596813d3c1af99e7 100644 --- a/src/proto_alpha/lib_benchmark/execution_context.ml +++ b/src/proto_alpha/lib_benchmark/execution_context.ml @@ -53,8 +53,8 @@ let make ~rng_state = context_init_memory ~rng_state >>=? fun context -> let amount = Alpha_context.Tez.one in let chain_id = Chain_id.zero in - let now = Alpha_context.Script_timestamp.of_zint Z.zero in - let level = Alpha_context.Script_int.zero_n in + let now = Script_timestamp.of_zint Z.zero in + let level = Script_int.zero_n in let open Script_interpreter in (match context with | `Mem_block (block, (bs1, bs2, bs3, _, _)) -> diff --git a/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.ml b/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.ml index a015381180a0f79ee7409aba31368b0b4f6e03ba..e32e4fabcde27afd24ca40d00de67086c870ee59 100644 --- a/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.ml +++ b/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.ml @@ -377,7 +377,7 @@ module Data = struct let map elts = prim A_Map [seq elts] [] let timestamp ts = - let z = Protocol.Alpha_context.Script_timestamp.to_zint ts in + let z = Protocol.Script_timestamp.to_zint ts in prim A_Timestamp [int z] [] let mutez (tz : Protocol.Alpha_context.Tez.tez) = diff --git a/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.mli b/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.mli index 6285f6a39555d38ac12cdf88b2b9ff3331ca090e..e8c5b3ac5e19901d4cfe1307c00878b1be08f7c1 100644 --- a/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.mli +++ b/src/proto_alpha/lib_benchmark/lib_benchmark_type_inference/mikhailsky.mli @@ -304,7 +304,7 @@ module Data : sig val map : node list -> node - val timestamp : Alpha_context.Script_timestamp.t -> node + val timestamp : Script_timestamp.t -> node val mutez : Alpha_context.Tez.t -> node diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml b/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml index c772d60f1008340a40ece47a8b5446fbd7c9e4e1..586c2176e626375293b53e8c80dd582daa28e6b9 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml +++ b/src/proto_alpha/lib_benchmark/michelson_samplers_base.ml @@ -49,19 +49,19 @@ let parameters_encoding = (** A module of type [S] packs samplers used to construct basic Michelson values. *) module type S = sig - val int : Alpha_context.Script_int.z Alpha_context.Script_int.num sampler + val int : Script_int.z Script_int.num sampler - val nat : Alpha_context.Script_int.n Alpha_context.Script_int.num sampler + val nat : Script_int.n Script_int.num sampler val signature : Tezos_crypto.Signature.t sampler - val string : Alpha_context.Script_string.t sampler + val string : Script_string.t sampler val bytes : bytes sampler val tez : Alpha_context.Tez.tez sampler - val timestamp : Alpha_context.Script_timestamp.t sampler + val timestamp : Script_timestamp.t sampler end (* Samplers for basic Michelson types. *) @@ -71,11 +71,11 @@ module Make (P : sig end) : S = struct let int rng_state = let i = Base_samplers.int ~size:P.parameters.int_size rng_state in - Alpha_context.Script_int.of_zint i + Script_int.of_zint i let nat rng_state = let i = Base_samplers.nat ~size:P.parameters.int_size rng_state in - Alpha_context.Script_int.abs (Alpha_context.Script_int.of_zint i) + Script_int.abs (Script_int.of_zint i) let signature rng_state = let i = Random.State.int rng_state 4 in @@ -109,7 +109,7 @@ end) : S = struct ~size:P.parameters.string_size rng_state in - match Protocol.Alpha_context.Script_string.of_string s with + match Protocol.Script_string.of_string s with | Ok s -> s | Error _ -> assert false @@ -123,5 +123,5 @@ end) : S = struct let timestamp rng_state = let i = Base_samplers.int ~size:P.parameters.int_size rng_state in - Protocol.Alpha_context.Script_timestamp.of_zint i + Script_timestamp.of_zint i end diff --git a/src/proto_alpha/lib_benchmark/michelson_samplers_base.mli b/src/proto_alpha/lib_benchmark/michelson_samplers_base.mli index 975dd002bc1fca66f1357fcccc3acd999d42485d..18a150245cfce7b351421295d52b40c6bb140116 100644 --- a/src/proto_alpha/lib_benchmark/michelson_samplers_base.mli +++ b/src/proto_alpha/lib_benchmark/michelson_samplers_base.mli @@ -43,19 +43,19 @@ val parameters_encoding : parameters Data_encoding.t (** A module of type [S] packs samplers used to construct basic Michelson values. *) module type S = sig - val int : Alpha_context.Script_int.z Alpha_context.Script_int.num sampler + val int : Script_int.z Script_int.num sampler - val nat : Alpha_context.Script_int.n Alpha_context.Script_int.num sampler + val nat : Script_int.n Script_int.num sampler val signature : Tezos_crypto.Signature.t sampler - val string : Alpha_context.Script_string.t sampler + val string : Script_string.t sampler val bytes : bytes sampler val tez : Alpha_context.Tez.tez sampler - val timestamp : Alpha_context.Script_timestamp.t sampler + val timestamp : Script_timestamp.t sampler end (** The [Make] functor instantiates a module of type [S], where the diff --git a/src/proto_alpha/lib_benchmark/rules.ml b/src/proto_alpha/lib_benchmark/rules.ml index ff66cf05c7c4509c2f6eaefe2994d58970e0c3c0..135a4006fb60c95bddc5402be392b8edd6cd3733 100644 --- a/src/proto_alpha/lib_benchmark/rules.ml +++ b/src/proto_alpha/lib_benchmark/rules.ml @@ -718,7 +718,7 @@ struct Context_blind (fun () -> Mikhailsky.Data.big_integer - (Protocol.Script_int_repr.to_zint (Michelson_base.int rng_state))) + (Protocol.Script_int.to_zint (Michelson_base.int rng_state))) in {type_constraint; replacement = [replacement]} in diff --git a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml index 90a668770a562d7f85d3ce5215ea5b3c7023255d..9684756a3421562b01100b88f8305d756f805489 100644 --- a/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/encodings_benchmarks.ml @@ -270,12 +270,10 @@ module Timestamp = struct ~generator:(fun rng_state -> let seconds_in_year = 30_000_000 in let offset = Random.State.int rng_state seconds_in_year in - Alpha_context.Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) + Script_timestamp.of_zint (Z.of_int (1597764116 + offset))) ~make_bench:(fun generator () -> let tstamp_string = generator () in - let closure () = - ignore (Alpha_context.Script_timestamp.to_string tstamp_string) - in + let closure () = ignore (Script_timestamp.to_string tstamp_string) in Generator.Plain {workload = (); closure}) let () = @@ -288,15 +286,12 @@ module Timestamp = struct let seconds_in_year = 30_000_000 in let offset = Random.State.int rng_state seconds_in_year in let tstamp = - Alpha_context.Script_timestamp.of_zint - (Z.of_int (1597764116 + offset)) + Script_timestamp.of_zint (Z.of_int (1597764116 + offset)) in - Alpha_context.Script_timestamp.to_string tstamp) + Script_timestamp.to_string tstamp) ~make_bench:(fun generator () -> let tstamp_string = generator () in - let closure () = - ignore (Alpha_context.Script_timestamp.of_string tstamp_string) - in + let closure () = ignore (Script_timestamp.of_string tstamp_string) in Generator.Plain {workload = (); closure}) end diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml index 5667ddf5a8332c9b08ec2cb6b06ddad14be3f490..a4bfcbdf857e8b08eb1d2e20ae93512a661fdb68 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_benchmarks.ml @@ -549,7 +549,7 @@ let continuation_benchmark ?amplification ?intercept ?salt ?more_tags ~name (* Sampling helpers *) let nat_of_positive_int (i : int) = - let open Alpha_context.Script_int in + let open Script_int in match is_nat (of_int i) with None -> assert false | Some x -> x let adversarial_ints rng_state (cfg : Default_config.config) n = @@ -559,7 +559,7 @@ let adversarial_ints rng_state (cfg : Default_config.config) n = ~card:n rng_state in - List.map Script_int_repr.of_zint ls + List.map Script_int.of_zint ls (* ------------------------------------------------------------------------- *) (* Error helpers *) @@ -1152,8 +1152,7 @@ module Registration_section = struct (ISet_mem ( kinfo (int @$ set int_cmp @$ unit @$ bot), halt (bool @$ unit @$ bot) )) - ~intercept_stack: - (Alpha_context.Script_int.zero, (Script_set.empty int_cmp, ((), eos))) + ~intercept_stack:(Script_int.zero, (Script_set.empty int_cmp, ((), eos))) ~stack_sampler:(fun cfg rng_state () -> assert (cfg.sampler.set_size.min >= 1) ; let n = @@ -1183,8 +1182,7 @@ module Registration_section = struct ( kinfo (int @$ bool @$ set int_cmp @$ bot), halt (set int_cmp @$ bot) )) ~intercept_stack: - ( Alpha_context.Script_int.zero, - (false, (Script_set.empty int_cmp, eos)) ) + (Script_int.zero, (false, (Script_set.empty int_cmp, eos))) ~stack_sampler:(fun cfg rng_state () -> assert (cfg.sampler.set_size.min >= 2) ; let n = @@ -1314,7 +1312,7 @@ module Registration_section = struct halt (bool @$ unit @$ bot) )) ~intercept_stack: (let map = Script_map.empty int_cmp in - (Alpha_context.Script_int.zero, (map, ((), eos)))) + (Script_int.zero, (map, ((), eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_map_and_key_in_map cfg rng_state in (key, (map, ((), eos)))) @@ -1334,7 +1332,7 @@ module Registration_section = struct halt (option unit @$ unit @$ bot) )) ~intercept_stack: (let map = Script_map.empty int_cmp in - (Alpha_context.Script_int.zero, (map, ((), eos)))) + (Script_int.zero, (map, ((), eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_map_and_key_in_map cfg rng_state in (key, (map, ((), eos)))) @@ -1354,7 +1352,7 @@ module Registration_section = struct halt (map int_cmp unit @$ bot) )) ~intercept_stack: (let map = Script_map.empty int_cmp in - (Alpha_context.Script_int.zero, (None, (map, eos)))) + (Script_int.zero, (None, (map, eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_map_and_key_in_map cfg rng_state in (key, (Some (), (map, eos)))) @@ -1375,7 +1373,7 @@ module Registration_section = struct halt (option unit @$ map int_cmp unit @$ bot) )) ~intercept_stack: (let map = Script_map.empty int_cmp in - (Alpha_context.Script_int.zero, (None, (map, eos)))) + (Script_int.zero, (None, (map, eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_map_and_key_in_map cfg rng_state in (key, (Some (), (map, eos)))) @@ -1476,7 +1474,7 @@ module Registration_section = struct halt (option unit @$ unit @$ bot) )) ~intercept_stack: (let map = Script_ir_translator.empty_big_map int_cmp unit in - (Alpha_context.Script_int.zero, (map, ((), eos)))) + (Script_int.zero, (map, ((), eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_big_map_and_key_in_map cfg rng_state in (key, (map, ((), eos)))) @@ -1496,7 +1494,7 @@ module Registration_section = struct halt (big_map int_cmp unit @$ bot) )) ~intercept_stack: (let map = Script_ir_translator.empty_big_map int_cmp unit in - (Alpha_context.Script_int.zero, (None, (map, eos)))) + (Script_int.zero, (None, (map, eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_big_map_and_key_in_map cfg rng_state in (key, (Some (), (map, eos)))) @@ -1517,7 +1515,7 @@ module Registration_section = struct halt (option unit @$ big_map int_cmp unit @$ bot) )) ~intercept_stack: (let map = Script_ir_translator.empty_big_map int_cmp unit in - (Alpha_context.Script_int.zero, (None, (map, eos)))) + (Script_int.zero, (None, (map, eos)))) ~stack_sampler:(fun cfg rng_state () -> let (key, map) = generate_big_map_and_key_in_map cfg rng_state in (key, (Some (), (map, eos)))) @@ -1525,7 +1523,7 @@ module Registration_section = struct end module Strings = struct - open Alpha_context.Script_string + open Script_string let () = simple_benchmark @@ -1551,7 +1549,7 @@ module Registration_section = struct (ISlice_string (kinfo (nat @$ nat @$ string @$ bot), halt (option string @$ bot))) ~intercept_stack: - (let z = Alpha_context.Script_int.zero_n in + (let z = Script_int.zero_n in (z, (z, (empty, eos)))) ~stack_sampler:(fun cfg rng_state -> let (_, (module Samplers)) = make_default_samplers cfg.sampler in @@ -1597,7 +1595,7 @@ module Registration_section = struct (ISlice_bytes (kinfo (nat @$ nat @$ bytes @$ bot), halt (option bytes @$ bot))) ~intercept_stack: - (let z = Alpha_context.Script_int.zero_n in + (let z = Script_int.zero_n in (z, (z, (Bytes.empty, eos)))) ~stack_sampler:(fun cfg rng_state -> let (_, (module Samplers)) = make_default_samplers cfg.sampler in @@ -1618,9 +1616,9 @@ module Registration_section = struct end module Timestamps = struct - let zero_timestamp = Alpha_context.Script_timestamp.of_zint Z.zero + let zero_timestamp = Script_timestamp.of_zint Z.zero - let zero_int = Alpha_context.Script_int.zero + let zero_int = Script_int.zero let () = simple_benchmark @@ -1709,7 +1707,7 @@ module Registration_section = struct let mutez_int64 = Alpha_context.Tez.to_mutez mutez in let int64 = Int64.(div max_int (mul mutez_int64 2L)) in let nat = - match Alpha_context.Script_int.(is_nat (of_int64 int64)) with + match Script_int.(is_nat (of_int64 int64)) with | None -> assert false | Some nat -> nat in @@ -1740,8 +1738,7 @@ module Registration_section = struct let () = simple_benchmark_with_stack_sampler ~name:Interpreter_workload.N_IEdiv_teznat - ~intercept_stack: - (Alpha_context.Tez.zero, (Alpha_context.Script_int.zero_n, eos)) + ~intercept_stack:(Alpha_context.Tez.zero, (Script_int.zero_n, eos)) ~kinstr: (IEdiv_teznat ( kinfo (mutez @$ nat @$ bot), @@ -1791,9 +1788,9 @@ module Registration_section = struct end module Integers = struct - let zero = Alpha_context.Script_int.zero + let zero = Script_int.zero - let zero_n = Alpha_context.Script_int.zero_n + let zero_n = Script_int.zero_n let () = simple_benchmark @@ -1818,7 +1815,7 @@ module Registration_section = struct let (_, (module Samplers)) = make_default_samplers cfg.sampler in fun () -> let x = Samplers.Michelson_base.nat rng_state in - let neg_x = Alpha_context.Script_int.neg x in + let neg_x = Script_int.neg x in (neg_x, eos)) () @@ -1893,7 +1890,7 @@ module Registration_section = struct let x = Samplers.Michelson_base.nat rng_state in (* shift must be in [0;256]: 1 byte max *) let shift = - Script_int_repr.(abs (of_int (Random.State.int rng_state 256))) + Script_int.(abs (of_int (Random.State.int rng_state 256))) in (x, (shift, eos))) () @@ -1909,7 +1906,7 @@ module Registration_section = struct let x = Samplers.Michelson_base.nat rng_state in (* shift must be in [0;256]: 1 byte max *) let shift = - Script_int_repr.(abs (of_int (Random.State.int rng_state 256))) + Script_int.(abs (of_int (Random.State.int rng_state 256))) in (x, (shift, eos))) () @@ -2190,7 +2187,7 @@ module Registration_section = struct let () = let name = - match Protocol.Alpha_context.Script_string.of_string "view" with + match Protocol.Script_string.of_string "view" with | Ok s -> s | Error _ -> assert false in @@ -2589,7 +2586,7 @@ module Registration_section = struct ~stack_sampler:(fun cfg rng_state -> let (_, (module Samplers)) = make_default_samplers cfg.sampler in let fr_sampler = Samplers.Random_value.value bls12_381_fr in - let zero = Alpha_context.Script_int.zero in + let zero = Script_int.zero in fun () -> (fr_sampler rng_state, (zero, eos))) () @@ -2611,7 +2608,7 @@ module Registration_section = struct ~stack_sampler:(fun cfg rng_state -> let (_, (module Samplers)) = make_default_samplers cfg.sampler in let fr_sampler = Samplers.Random_value.value bls12_381_fr in - let zero = Alpha_context.Script_int.zero in + let zero = Script_int.zero in fun () -> (zero, (fr_sampler rng_state, eos))) () @@ -2684,7 +2681,7 @@ module Registration_section = struct halt (option pair_ticket_unit_ticket_unit @$ bot) ) let () = - let zero = Alpha_context.Script_int.zero_n in + let zero = Script_int.zero_n in let ticket = { ticketer = @@ -2710,9 +2707,7 @@ module Registration_section = struct in fun () -> let half_amount = Samplers.Random_value.value nat rng_state in - let amount = - Alpha_context.Script_int.add_n half_amount half_amount - in + let amount = Script_int.add_n half_amount half_amount in let ticket = Samplers.Random_value.value (ticket unit_cmp) rng_state in @@ -2747,8 +2742,8 @@ module Registration_section = struct let ticket = { ticket with - contents = Alpha_context.Script_string.empty; - amount = Script_int_repr.zero_n; + contents = Script_string.empty; + amount = Script_int.zero_n; } in Ex_stack_and_kinstr @@ -2787,7 +2782,7 @@ module Registration_section = struct let chest_key = Script_timelock.make_chest_key chest_key in ( chest_key, ( chest, - ( Script_int_repr.is_nat (Script_int_repr.of_int time) + ( Script_int.is_nat (Script_int.of_int time) |> WithExceptions.Option.get ~loc:"Timelock:gas benchmarks", eos ) ) ) @@ -3094,7 +3089,7 @@ module Registration_section = struct Ex_stack_and_cont { stack = ((), eos); - cont = map_enter_body_code [(Script_int_repr.zero, ())]; + cont = map_enter_body_code [(Script_int.zero, ())]; }) () diff --git a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml index 638ae6d952a97c90bb23ffdbd6dfb8bbc2a8bbda..52a91b76e7d9a4e38cfd947ca232c578c0e89590 100644 --- a/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml +++ b/src/proto_alpha/lib_benchmarks_proto/interpreter_workload.ml @@ -1422,9 +1422,7 @@ let extract_ir_sized_step : let plaintext_size = Script_timelock.get_plaintext_size chest - 1 |> Size.of_int in - let log_time = - Z.log2 Z.(one + Script_int_repr.to_zint time) |> Size.of_int - in + let log_time = Z.log2 Z.(one + Script_int.to_zint time) |> Size.of_int in Instructions.open_chest log_time plaintext_size | (IMin_block_time _, _) -> Instructions.min_block_time diff --git a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml index 23fadf09a62aeeb324876d7915df7701a877366d..a298d2522e262d16d67bb20c907f3c73706dde0c 100644 --- a/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml +++ b/src/proto_alpha/lib_benchmarks_proto/ticket_benchmarks.ml @@ -248,7 +248,7 @@ let ticket_sampler rng_state = let (pkh, _, _) = Signature.generate_key ~algo:Signature.Ed25519 ~seed () in let ticketer = Alpha_context.Contract.implicit_contract pkh in Script_typed_ir. - {ticketer; contents = Script_int_repr.zero; amount = Script_int_repr.one_n} + {ticketer; contents = Script_int.zero; amount = Script_int.one_n} (** A benchmark for {!Ticket_costs.Constants.cost_collect_tickets_step}. *) module Collect_tickets_benchmark : Benchmark.S = struct diff --git a/src/proto_alpha/lib_plugin/plugin.ml b/src/proto_alpha/lib_plugin/plugin.ml index 941647e72476cc480ea813e70fafe0182faa968b..15a173afd162b454db175f8bc76663460678e7b7 100644 --- a/src/proto_alpha/lib_plugin/plugin.ml +++ b/src/proto_alpha/lib_plugin/plugin.ml @@ -241,7 +241,7 @@ module Mempool = struct end) type state = { - grandparent_level_start : Alpha_context.Timestamp.t option; + grandparent_level_start : Timestamp.t option; round_zero_duration : Period.t option; op_prechecked_managers : manager_op_info Signature.Public_key_hash.Map.t; (** All managers that are the source of manager operations @@ -296,26 +296,25 @@ module Mempool = struct >>?= fun grandparent_round -> Alpha_context.Fitness.round_from_raw predecessor_fitness >>?= fun predecessor_round -> - Alpha_context.( - let round_durations = Constants.round_durations ctxt in - let round_zero_duration = - Round.round_duration round_durations Round.zero - in - Round.level_offset_of_round - round_durations - ~round:Round.(succ grandparent_round) - >>?= fun proposal_level_offset -> - Round.level_offset_of_round round_durations ~round:predecessor_round - >>?= fun proposal_round_offset -> - Period.(add proposal_level_offset proposal_round_offset) - >>?= fun proposal_offset -> - return - { - empty with - grandparent_level_start = - Some Timestamp.(predecessor_timestamp - proposal_offset); - round_zero_duration = Some round_zero_duration; - })) + let round_durations = Constants.round_durations ctxt in + let round_zero_duration = + Round.round_duration round_durations Round.zero + in + Round.level_offset_of_round + round_durations + ~round:Round.(succ grandparent_round) + >>?= fun proposal_level_offset -> + Round.level_offset_of_round round_durations ~round:predecessor_round + >>?= fun proposal_round_offset -> + Period.(add proposal_level_offset proposal_round_offset) + >>?= fun proposal_offset -> + return + { + empty with + grandparent_level_start = + Some Timestamp.(predecessor_timestamp - proposal_offset); + round_zero_duration = Some round_zero_duration; + }) >|= Environment.wrap_tzresult let manager_prio p = `Low p diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index 53091fb4b1ddc07a06346a91cf35f943c4c6d5a8..f6016bcb1d124652d81a1577aef9bbc566b08a89 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -37,9 +37,6 @@ "Seed_repr", "Sampler", "Voting_period_repr", - "Script_string_repr", - "Script_int_repr", - "Script_timestamp_repr", "Ticket_hash_repr", "Michelson_v1_primitives", "Script_repr", @@ -132,6 +129,9 @@ "Sc_rollup_storage", "Alpha_context", + "Script_string", + "Script_int", + "Script_timestamp", "Carbonated_map_costs", "Carbonated_map", diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 3e557667a50445c193d51c2498abeafedde8c772..bc04e36c363adcc97104fabfa858dc901a47afb6 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -92,18 +92,6 @@ end module Raw_level = Raw_level_repr module Cycle = Cycle_repr -module Script_string = Script_string_repr -module Script_int = Script_int_repr - -module Script_timestamp = struct - include Script_timestamp_repr - - let now ctxt = - let {Constants_repr.minimal_block_delay; _} = Raw_context.constants ctxt in - let first_delay = Period_repr.to_seconds minimal_block_delay in - let current_timestamp = Raw_context.predecessor_timestamp ctxt in - Time.add current_timestamp first_delay |> Timestamp.to_seconds |> of_int64 -end module Script = struct include Michelson_v1_primitives diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 2f27bf0589b423db70970cf2780ca6f80b63e479..51b05993ce52365bb2c6b5d4cd42ebcc4a5c2f30 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -477,42 +477,6 @@ end module Entrypoint : module type of Entrypoint_repr -module Script_string : module type of Script_string_repr - -module Script_int : module type of Script_int_repr - -module Script_timestamp : sig - open Script_int - - type repr - - type t = Timestamp_tag of repr [@@ocaml.unboxed] - - val compare : t -> t -> int - - val to_string : t -> string - - val to_notation : t -> string option - - val to_num_str : t -> string - - val of_string : string -> t option - - val diff : t -> t -> z num - - val add_delta : t -> z num -> t - - val sub_delta : t -> z num -> t - - val now : context -> t - - val to_zint : t -> Z.t - - val of_zint : Z.t -> t - - val encoding : t Data_encoding.encoding -end - module Script : sig type prim = Michelson_v1_primitives.prim = | K_parameter diff --git a/src/proto_alpha/lib_protocol/dune.inc b/src/proto_alpha/lib_protocol/dune.inc index 1149940e101742c1f05ddaa827f775b8b2c3ce64..f3d48717682382168153dee9d1e82e0f30a2d8a0 100644 --- a/src/proto_alpha/lib_protocol/dune.inc +++ b/src/proto_alpha/lib_protocol/dune.inc @@ -62,9 +62,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end seed_repr.mli seed_repr.ml sampler.mli sampler.ml voting_period_repr.mli voting_period_repr.ml - script_string_repr.mli script_string_repr.ml - script_int_repr.mli script_int_repr.ml - script_timestamp_repr.mli script_timestamp_repr.ml ticket_hash_repr.mli ticket_hash_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml @@ -149,6 +146,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end tx_rollup_storage.mli tx_rollup_storage.ml sc_rollup_storage.mli sc_rollup_storage.ml alpha_context.mli alpha_context.ml + script_string.mli script_string.ml + script_int.mli script_int.ml + script_timestamp.mli script_timestamp.ml carbonated_map_costs.mli carbonated_map_costs.ml carbonated_map.mli carbonated_map.ml tx_rollup_l2_storage_sig.ml @@ -249,9 +249,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end seed_repr.mli seed_repr.ml sampler.mli sampler.ml voting_period_repr.mli voting_period_repr.ml - script_string_repr.mli script_string_repr.ml - script_int_repr.mli script_int_repr.ml - script_timestamp_repr.mli script_timestamp_repr.ml ticket_hash_repr.mli ticket_hash_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml @@ -336,6 +333,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end tx_rollup_storage.mli tx_rollup_storage.ml sc_rollup_storage.mli sc_rollup_storage.ml alpha_context.mli alpha_context.ml + script_string.mli script_string.ml + script_int.mli script_int.ml + script_timestamp.mli script_timestamp.ml carbonated_map_costs.mli carbonated_map_costs.ml carbonated_map.mli carbonated_map.ml tx_rollup_l2_storage_sig.ml @@ -436,9 +436,6 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end seed_repr.mli seed_repr.ml sampler.mli sampler.ml voting_period_repr.mli voting_period_repr.ml - script_string_repr.mli script_string_repr.ml - script_int_repr.mli script_int_repr.ml - script_timestamp_repr.mli script_timestamp_repr.ml ticket_hash_repr.mli ticket_hash_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml @@ -523,6 +520,9 @@ module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end tx_rollup_storage.mli tx_rollup_storage.ml sc_rollup_storage.mli sc_rollup_storage.ml alpha_context.mli alpha_context.ml + script_string.mli script_string.ml + script_int.mli script_int.ml + script_timestamp.mli script_timestamp.ml carbonated_map_costs.mli carbonated_map_costs.ml carbonated_map.mli carbonated_map.ml tx_rollup_l2_storage_sig.ml @@ -645,9 +645,6 @@ include Tezos_raw_protocol_alpha.Main Seed_repr Sampler Voting_period_repr - Script_string_repr - Script_int_repr - Script_timestamp_repr Ticket_hash_repr Michelson_v1_primitives Script_repr @@ -732,6 +729,9 @@ include Tezos_raw_protocol_alpha.Main Tx_rollup_storage Sc_rollup_storage Alpha_context + Script_string + Script_int + Script_timestamp Carbonated_map_costs Carbonated_map Tx_rollup_l2_storage_sig @@ -873,9 +873,6 @@ include Tezos_raw_protocol_alpha.Main seed_repr.mli seed_repr.ml sampler.mli sampler.ml voting_period_repr.mli voting_period_repr.ml - script_string_repr.mli script_string_repr.ml - script_int_repr.mli script_int_repr.ml - script_timestamp_repr.mli script_timestamp_repr.ml ticket_hash_repr.mli ticket_hash_repr.ml michelson_v1_primitives.mli michelson_v1_primitives.ml script_repr.mli script_repr.ml @@ -960,6 +957,9 @@ include Tezos_raw_protocol_alpha.Main tx_rollup_storage.mli tx_rollup_storage.ml sc_rollup_storage.mli sc_rollup_storage.ml alpha_context.mli alpha_context.ml + script_string.mli script_string.ml + script_int.mli script_int.ml + script_timestamp.mli script_timestamp.ml carbonated_map_costs.mli carbonated_map_costs.ml carbonated_map.mli carbonated_map.ml tx_rollup_l2_storage_sig.ml diff --git a/src/proto_alpha/lib_protocol/gas_comparable_input_size.ml b/src/proto_alpha/lib_protocol/gas_comparable_input_size.ml index 6e90810eba69245b1d1a8a0d80ea9223cdf70815..9a70fbce2081e59603dc85875902b470d7a5898f 100644 --- a/src/proto_alpha/lib_protocol/gas_comparable_input_size.ml +++ b/src/proto_alpha/lib_protocol/gas_comparable_input_size.ml @@ -68,12 +68,11 @@ let of_int x = x let unit : t = 1 -let integer (i : 'a Alpha_context.Script_int.num) : t = - Z.numbits (Alpha_context.Script_int.to_zint i) / 8 +let integer (i : 'a Script_int.num) : t = Z.numbits (Script_int.to_zint i) / 8 let string = String.length -let script_string = Alpha_context.Script_string.length +let script_string = Script_string.length let bytes (b : Bytes.t) : t = Bytes.length b @@ -103,8 +102,8 @@ let address (addr : Script_typed_ir.address) : t = let tx_rollup_l2_address x = Tx_rollup_l2_address.Indexable.size @@ Indexable.forget x -let timestamp (tstamp : Alpha_context.Script_timestamp.t) : t = - Z.numbits (Alpha_context.Script_timestamp.to_zint tstamp) / 8 +let timestamp (tstamp : Script_timestamp.t) : t = + Z.numbits (Script_timestamp.to_zint tstamp) / 8 let rec size_of_comparable_value : type a. a Script_typed_ir.comparable_ty -> a -> t = diff --git a/src/proto_alpha/lib_protocol/gas_comparable_input_size.mli b/src/proto_alpha/lib_protocol/gas_comparable_input_size.mli index 7d697c720bd87024a309275f64562393e9a4d6ae..85c1dfbb58254af54a6ac1d3194451b54c466a4d 100644 --- a/src/proto_alpha/lib_protocol/gas_comparable_input_size.mli +++ b/src/proto_alpha/lib_protocol/gas_comparable_input_size.mli @@ -58,16 +58,16 @@ val to_int : t -> int val of_int : int -> t -val integer : 'a Alpha_context.Script_int.num -> t +val integer : 'a Script_int.num -> t val string : string -> t -val script_string : Alpha_context.Script_string.t -> t +val script_string : Script_string.t -> t val bytes : Bytes.t -> t val mutez : Alpha_context.Tez.tez -> t -val timestamp : Alpha_context.Script_timestamp.t -> t +val timestamp : Script_timestamp.t -> t val size_of_comparable_value : 'a Script_typed_ir.comparable_ty -> 'a -> t diff --git a/src/proto_alpha/lib_protocol/gas_input_size.ml b/src/proto_alpha/lib_protocol/gas_input_size.ml index bccdf39979e8e6de64942a119e357d85e71702c5..1a35ae6ea9e13d920d3ee52cc4c7952a289a7243 100644 --- a/src/proto_alpha/lib_protocol/gas_input_size.ml +++ b/src/proto_alpha/lib_protocol/gas_input_size.ml @@ -29,11 +29,11 @@ let list (list : 'a Script_typed_ir.boxed_list) : t = list.Script_typed_ir.length let set (set : 'a Script_typed_ir.set) : t = - let res = Alpha_context.Script_int.to_int (Script_set.size set) in + let res = Script_int.to_int (Script_set.size set) in match res with None -> assert false | Some x -> x let map (map : ('a, 'b) Script_typed_ir.map) : t = - let res = Alpha_context.Script_int.to_int (Script_map.size map) in + let res = Script_int.to_int (Script_map.size map) in match res with None -> assert false | Some x -> x (* ------------------------------------------------------------------------- *) @@ -55,7 +55,7 @@ let node leaves = let rec of_micheline (x : ('a, 'b) Micheline.node) = match x with | Micheline.Int (_loc, z) -> - let int_bytes = integer (Alpha_context.Script_int.of_zint z) in + let int_bytes = integer (Script_int.of_zint z) in {traversal = 1; int_bytes; string_bytes = 0} | Micheline.String (_loc, s) -> let string_bytes = String.length s in diff --git a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli index bfad3e7b770b49803e51a581bfb7807735b30cf1..5c3fc554e4cf166bf41f6ee34cb2c7a53cb6e4a2 100644 --- a/src/proto_alpha/lib_protocol/michelson_v1_gas.mli +++ b/src/proto_alpha/lib_protocol/michelson_v1_gas.mli @@ -148,7 +148,7 @@ module Cost_of : sig val is_nat : Gas.cost - val abs_int : Alpha_context.Script_int.z Script_int.num -> Gas.cost + val abs_int : Script_int.z Script_int.num -> Gas.cost val int_nat : Gas.cost @@ -157,16 +157,13 @@ module Cost_of : sig val add_int : 'a Script_int.num -> 'b Script_int.num -> Gas.cost val add_nat : - Alpha_context.Script_int.n Script_int.num -> - Alpha_context.Script_int.n Script_int.num -> - Gas.cost + Script_int.n Script_int.num -> Script_int.n Script_int.num -> Gas.cost val sub_int : 'a Script_int.num -> 'b Script_int.num -> Gas.cost val mul_int : 'a Script_int.num -> 'b Script_int.num -> Gas.cost - val mul_nat : - Alpha_context.Script_int.n Script_int.num -> 'a Script_int.num -> Gas.cost + val mul_nat : Script_int.n Script_int.num -> 'a Script_int.num -> Gas.cost val ediv_teznat : 'a -> 'b Script_int.num -> Gas.cost @@ -174,8 +171,7 @@ module Cost_of : sig val ediv_int : 'a Script_int.num -> 'b Script_int.num -> Gas.cost - val ediv_nat : - Alpha_context.Script_int.n Script_int.num -> 'a Script_int.num -> Gas.cost + val ediv_nat : Script_int.n Script_int.num -> 'a Script_int.num -> Gas.cost val eq : Gas.cost @@ -188,9 +184,7 @@ module Cost_of : sig val and_nat : 'a Script_int.num -> 'b Script_int.num -> Gas.cost val and_int_nat : - Alpha_context.Script_int.z Script_int.num -> - Alpha_context.Script_int.n Script_int.num -> - Gas.cost + Script_int.z Script_int.num -> Script_int.n Script_int.num -> Gas.cost val xor_nat : 'a Script_int.num -> 'b Script_int.num -> Gas.cost diff --git a/src/proto_alpha/lib_protocol/script_int_repr.ml b/src/proto_alpha/lib_protocol/script_int.ml similarity index 100% rename from src/proto_alpha/lib_protocol/script_int_repr.ml rename to src/proto_alpha/lib_protocol/script_int.ml diff --git a/src/proto_alpha/lib_protocol/script_int_repr.mli b/src/proto_alpha/lib_protocol/script_int.mli similarity index 100% rename from src/proto_alpha/lib_protocol/script_int_repr.mli rename to src/proto_alpha/lib_protocol/script_int.mli diff --git a/src/proto_alpha/lib_protocol/script_interpreter.ml b/src/proto_alpha/lib_protocol/script_interpreter.ml index 276c6a66cc213a09755920d0b3af2205bdcbdac6..2eb11de5eb1e20497942ec4f79e557ffcf77d606 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter.ml @@ -1502,7 +1502,7 @@ and step : type a s b t r f. (a, s, b, t, r, f) step_type = incorrect. Indeed the verification asks for an integer for practical reasons. Therefore no proof can be correct.*) let accu = - match Alpha_context.Script_int.to_int time_z with + match Script_int.to_int time_z with | None -> R false | Some time -> ( match Script_timelock.open_chest chest chest_key ~time with diff --git a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml index 12fc3baf22489125f9d8582eb2e6251517385b3a..5f3001abb4dc3d916282cdabd997e091a18af204 100644 --- a/src/proto_alpha/lib_protocol/script_interpreter_defs.ml +++ b/src/proto_alpha/lib_protocol/script_interpreter_defs.ml @@ -333,9 +333,7 @@ let cost_of_instr : type a s r f. (a, s, r, f) kinstr -> a -> s -> Gas.cost = | IRead_ticket _ -> Interp_costs.read_ticket | IOpen_chest _ -> let _chest_key = accu and (chest, (time, _)) = stack in - Interp_costs.open_chest - ~chest - ~time:(Alpha_context.Script_int.to_zint time) + Interp_costs.open_chest ~chest ~time:(Script_int.to_zint time) | ILog _ -> Gas.free [@@ocaml.inline always] [@@coq_axiom_with_reason "unreachable expression `.` not handled"] diff --git a/src/proto_alpha/lib_protocol/script_map.ml b/src/proto_alpha/lib_protocol/script_map.ml index 5a96396a518b5a4f0b6afc90225832ecd914fff9..6aaa7afedb7d8e8c544ede0dd55e448c33105443 100644 --- a/src/proto_alpha/lib_protocol/script_map.ml +++ b/src/proto_alpha/lib_protocol/script_map.ml @@ -25,7 +25,6 @@ (* *) (*****************************************************************************) -open Alpha_context open Script_typed_ir let make x = Map_tag x diff --git a/src/proto_alpha/lib_protocol/script_map.mli b/src/proto_alpha/lib_protocol/script_map.mli index 5a52c8b0b16f87d59562cacc1d243d8f0acffeae..a889610a53631895281d7592e15c062f1f038e98 100644 --- a/src/proto_alpha/lib_protocol/script_map.mli +++ b/src/proto_alpha/lib_protocol/script_map.mli @@ -24,7 +24,6 @@ (* *) (*****************************************************************************) -open Alpha_context open Script_typed_ir val make : diff --git a/src/proto_alpha/lib_protocol/script_set.ml b/src/proto_alpha/lib_protocol/script_set.ml index 22a37d1cc10d763055a3322625c4fb8a739e916f..c18824cdb973bde4acdf6b6286851932e76a262a 100644 --- a/src/proto_alpha/lib_protocol/script_set.ml +++ b/src/proto_alpha/lib_protocol/script_set.ml @@ -25,7 +25,6 @@ (* *) (*****************************************************************************) -open Alpha_context open Script_typed_ir let make x = Set_tag x diff --git a/src/proto_alpha/lib_protocol/script_set.mli b/src/proto_alpha/lib_protocol/script_set.mli index fe50a5e944c63ba222a49c407749ffc9827f4354..3d4e4b12ab3857c017d5e36aaad6061533964590 100644 --- a/src/proto_alpha/lib_protocol/script_set.mli +++ b/src/proto_alpha/lib_protocol/script_set.mli @@ -24,7 +24,6 @@ (* *) (*****************************************************************************) -open Alpha_context open Script_typed_ir val make : (module Boxed_set with type elt = 'elt) -> 'elt set diff --git a/src/proto_alpha/lib_protocol/script_string_repr.ml b/src/proto_alpha/lib_protocol/script_string.ml similarity index 100% rename from src/proto_alpha/lib_protocol/script_string_repr.ml rename to src/proto_alpha/lib_protocol/script_string.ml diff --git a/src/proto_alpha/lib_protocol/script_string_repr.mli b/src/proto_alpha/lib_protocol/script_string.mli similarity index 100% rename from src/proto_alpha/lib_protocol/script_string_repr.mli rename to src/proto_alpha/lib_protocol/script_string.mli diff --git a/src/proto_alpha/lib_protocol/script_timestamp_repr.ml b/src/proto_alpha/lib_protocol/script_timestamp.ml similarity index 86% rename from src/proto_alpha/lib_protocol/script_timestamp_repr.ml rename to src/proto_alpha/lib_protocol/script_timestamp.ml index f62077e319155e2a3b3f98ae6efc15f6e275abe4..105d751473e8ac4fb035360467f3fbee1ab802a8 100644 --- a/src/proto_alpha/lib_protocol/script_timestamp_repr.ml +++ b/src/proto_alpha/lib_protocol/script_timestamp.ml @@ -45,17 +45,22 @@ let to_num_str (Timestamp_tag x) = Z.to_string x let to_string x = match to_notation x with None -> to_num_str x | Some s -> s -let diff (Timestamp_tag x) (Timestamp_tag y) = - Script_int_repr.of_zint @@ Z.sub x y +let diff (Timestamp_tag x) (Timestamp_tag y) = Script_int.of_zint @@ Z.sub x y let sub_delta (Timestamp_tag t) delta = - Timestamp_tag (Z.sub t (Script_int_repr.to_zint delta)) + Timestamp_tag (Z.sub t (Script_int.to_zint delta)) let add_delta (Timestamp_tag t) delta = - Timestamp_tag (Z.add t (Script_int_repr.to_zint delta)) + Timestamp_tag (Z.add t (Script_int.to_zint delta)) let to_zint (Timestamp_tag x) = x let of_zint x = Timestamp_tag x let encoding = Data_encoding.(conv to_zint of_zint z) + +let now ctxt = + let open Alpha_context in + let first_delay = Period.to_seconds (Constants.minimal_block_delay ctxt) in + let current_timestamp = Timestamp.predecessor ctxt in + Time.add current_timestamp first_delay |> Timestamp.to_seconds |> of_int64 diff --git a/src/proto_alpha/lib_protocol/script_timestamp_repr.mli b/src/proto_alpha/lib_protocol/script_timestamp.mli similarity index 98% rename from src/proto_alpha/lib_protocol/script_timestamp_repr.mli rename to src/proto_alpha/lib_protocol/script_timestamp.mli index 258302cd26a78b3dfb483afa2f8ac34788a55c6a..2d246ae4f9a3141632bd6f082d1a40b692c8c909 100644 --- a/src/proto_alpha/lib_protocol/script_timestamp_repr.mli +++ b/src/proto_alpha/lib_protocol/script_timestamp.mli @@ -27,7 +27,7 @@ (** Defines the internal Michelson representation for timestamps and basic operations that can be performed on it. *) -open Script_int_repr +open Script_int type repr @@ -71,3 +71,5 @@ val of_zint : Z.t -> t (* Timestamps are encoded exactly as Z. *) val encoding : t Data_encoding.encoding + +val now : Alpha_context.t -> t diff --git a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml index e01b2436df9652e503e33f3dbe2a75b02a4aeb34..1d7d4716c72a51063c2e8958a31ad00b9ec1d7af 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/liquidity_baking_machine.ml @@ -112,7 +112,7 @@ let blocks_per_mint_tzbtc = 1L (** A timestamp “far in the future” which should not be exceeded when running tests. *) -let far_future = Alpha_context.Script_timestamp.of_zint (Z.of_int 42_000) +let far_future = Script_timestamp.of_zint (Z.of_int 42_000) (* Hypothesis: the tests start at timestamp 0, and 42000 is “big enough.” *) diff --git a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml index 1998bc4e5b1313928968fb9195d1d3aa91214354..1f35489e470357a188533f73f66fa8048457ed30 100644 --- a/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml +++ b/src/proto_alpha/lib_protocol/test/integration/gas/test_gas_costs.ml @@ -39,9 +39,9 @@ module S = Saturation_repr let dummy_list = Script_list.(cons 42 empty) -let forty_two = Alpha_context.Script_int.of_int 42 +let forty_two = Script_int.of_int 42 -let forty_two_n = Alpha_context.Script_int.abs forty_two +let forty_two_n = Script_int.abs forty_two let dummy_set = let open Script_set in @@ -51,7 +51,7 @@ let dummy_map = let open Script_map in update forty_two (Some forty_two) (empty Script_typed_ir.int_key) -let dummy_timestamp = Alpha_context.Script_timestamp.of_zint (Z.of_int 42) +let dummy_timestamp = Script_timestamp.of_zint (Z.of_int 42) let dummy_pk = Signature.Public_key.of_b58check_exn @@ -60,7 +60,7 @@ let dummy_pk = let dummy_bytes = Bytes.of_string "dummy" let dummy_string = - match Alpha_context.Script_string.of_string "dummy" with + match Script_string.of_string "dummy" with | Ok s -> s | Error _ -> assert false @@ -127,7 +127,7 @@ let all_interpreter_costs = ("mul_int", mul_int forty_two forty_two); ("ediv_teznat", ediv_teznat Alpha_context.Tez.fifty_cents forty_two); ("ediv_tez", ediv_tez); - ("ediv_int", ediv_int forty_two (Alpha_context.Script_int.of_int 1)); + ("ediv_int", ediv_int forty_two (Script_int.of_int 1)); ("eq", eq); ("lsl_nat", lsl_nat forty_two); ("lsr_nat", lsr_nat forty_two); diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_cache.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_cache.ml index 9b4125d93baa10e776da40e7082dc289203b7d4b..fc035b42bb32ac642c58751d4b000c805823f7a5 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_cache.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_cache.ml @@ -86,8 +86,7 @@ let find ctxt addr = return (ctxt, identifier, script, Ex_script ir) let value_as_int : - type a ac. - (a, ac) Script_typed_ir.ty -> a -> Script_int_repr.z Script_int_repr.num = + type a ac. (a, ac) Script_typed_ir.ty -> a -> Script_int.z Script_int.num = fun ty v -> match ty with Int_t -> v | _ -> Stdlib.failwith "value_as_int" let add_some_contracts k src block baker = diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml index 3a06aa4319c0d0cc8a30bcdbeefda2696779fafc..211a5fe3c090592e0283f84c5b367c517247df11 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_script_typed_ir_size.ml @@ -68,7 +68,7 @@ let footprint v = and is therefore not counted by [Obj.reachable_words]. *) let gen_string s = let s = Bytes.of_string s |> Bytes.to_string in - is_ok @@ Script_string_repr.of_string s + is_ok @@ Script_string.of_string s let boxed_set_elements s = Script_set.fold (fun x s -> x :: s) s [] @@ -76,7 +76,7 @@ let boxed_map_bindings s = Script_map.fold (fun k v s -> (k, v) :: s) s [] let big_map_bindings (Big_map s) = Big_map_overlay.bindings s.diff.map -let show_script_int fmt x = Z.pp_print fmt (Script_int_repr.to_zint x) +let show_script_int fmt x = Z.pp_print fmt (Script_int.to_zint x) let show_bool fmt b = Format.fprintf fmt "%B" b @@ -189,23 +189,23 @@ let check_value_size () = *) @ (let error = 8 in [ - ex ~error "0 : int" Int_t Script_int_repr.zero; - ex ~error "2^63 : int" Int_t (Script_int_repr.of_int max_int); + ex ~error "0 : int" Int_t Script_int.zero; + ex ~error "2^63 : int" Int_t (Script_int.of_int max_int); ex ~error "37^73 : int" Int_t - (Script_int_repr.of_zint Z.(pow (of_int 37) 73)); + (Script_int.of_zint Z.(pow (of_int 37) 73)); ex ~error "-37^73 : int" Int_t - (Script_int_repr.of_zint Z.(neg (pow (of_int 37) 73))); + (Script_int.of_zint Z.(neg (pow (of_int 37) 73))); ex ~error "13270006022583112970 : int" Int_t - (get @@ Script_int_repr.of_string "13270006022583112970"); + (get @@ Script_int.of_string "13270006022583112970"); ] @ exs ~error nsample show_script_int Int_t ": int") (* @@ -214,17 +214,17 @@ let check_value_size () = *) @ (let error = 8 in [ - ex ~error "0 : nat" Nat_t Script_int_repr.zero_n; + ex ~error "0 : nat" Nat_t Script_int.zero_n; ex ~error "2^63 : nat" Nat_t - (get Script_int_repr.(is_nat @@ of_int max_int)); + (get Script_int.(is_nat @@ of_int max_int)); ex ~error "37^73 : int" Nat_t - (get Script_int_repr.(is_nat @@ of_zint Z.(pow (of_int 37) 73))); + (get Script_int.(is_nat @@ of_zint Z.(pow (of_int 37) 73))); ] @ exs ~error nsample show_script_int Nat_t ": nat") (* @@ -239,9 +239,7 @@ let check_value_size () = String_t ======== *) - @ (let show fmt s = - Format.fprintf fmt "%s" (Script_string_repr.to_string s) - in + @ (let show fmt s = Format.fprintf fmt "%s" (Script_string.to_string s) in exs nsample show String_t ": string") (* Bytes_t @@ -303,7 +301,7 @@ let check_value_size () = let (Ty_ex_c ty) = is_ok @@ pair_t dummy_loc ty1 ty2 in f.apply ty in - let open Script_int_repr in + let open Script_int in [ (* "int * int" *) on_pair @@ -361,7 +359,7 @@ let check_value_size () = let (Ty_ex_c ty) = is_ok @@ union_t dummy_loc ty1 ty2 in f.apply ty in - let open Script_int_repr in + let open Script_int in [ (* "int + int" *) on_union @@ -457,7 +455,7 @@ let check_value_size () = let on_option : type a. (a, _) ty -> a P.f -> ex = fun ty f -> f.apply @@ is_ok @@ option_t dummy_loc ty in - let open Script_int_repr in + let open Script_int in [ (* "option int" *) on_option int_t {apply = (fun ty -> ex "None : option int" ty None)}; diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml index 18025e9d0590f8ad98bc0aa3b3e1cfc56178e8aa..78b41af6b79aa9dd4c6af4e26e05e5f74d55099e 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_accounting.ml @@ -468,7 +468,7 @@ let string_ticket ticketer contents amount = in let contents = Result.value_f ~default:(fun _ -> assert false) - @@ Script_string_repr.of_string contents + @@ Script_string.of_string contents in Script_typed_ir.{ticketer; contents; amount} @@ -476,7 +476,7 @@ let string_ticket_token ticketer content = let open Lwt_tzresult_syntax in let contents = Result.value_f ~default:(fun _ -> assert false) - @@ Alpha_context.Script_string.of_string content + @@ Script_string.of_string content in let*? ticketer = Environment.wrap_tzresult @@ Contract.of_b58check ticketer in return @@ -636,7 +636,7 @@ let test_diffs_lazy_storage_alloc () = ~key_type:int_key ~value_type:ticket_string_type [ - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1 ); ] in @@ -672,7 +672,7 @@ let test_diffs_remove_from_big_map () = ~value_type:ticket_string_type ~existing_entries: [ - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1 ); ] in @@ -708,12 +708,12 @@ let test_diffs_copy_big_map () = ~value_type:ticket_string_type ~existing_entries: [ - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1 ); ] ~updates: [ - ( Script_int_repr.of_int 2, + ( Script_int.of_int 2, Some (string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "blue" 1) ); ] @@ -752,11 +752,11 @@ let test_diffs_add_to_existing_big_map () = ~value_type:ticket_string_type [ (* It doesn't matter what the old entries are. They are never traversed *) - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1 ); - ( Script_int_repr.of_int 2, + ( Script_int.of_int 2, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "blue" 1 ); - ( Script_int_repr.of_int 3, + ( Script_int.of_int 3, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "green" 1 ); ] in @@ -769,17 +769,17 @@ let test_diffs_add_to_existing_big_map () = ~value_type:ticket_string_type ~existing_entries: [ - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1 ); ] ~updates: [ (* Add one new ticket to the big-map. *) - ( Script_int_repr.of_int 2, + ( Script_int.of_int 2, Some (string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "blue" 2) ); (* Remove a ticket *) - (Script_int_repr.of_int 1, None); + (Script_int.of_int 1, None); ] in (* Even if the old and the new storage are the same (and contains tickets) @@ -833,13 +833,13 @@ let test_diffs_args_storage_and_lazy_diffs () = ~existing_entries:[] ~updates: [ - ( Script_int_repr.of_int 1, + ( Script_int.of_int 1, Some (string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "red" 1) ); - ( Script_int_repr.of_int 2, + ( Script_int.of_int 2, Some (string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "blue" 1) ); - ( Script_int_repr.of_int 3, + ( Script_int.of_int 3, Some (string_ticket "KT1ThEdxfUcWUwqsdergy3QnbCWGHSUHeHJq" "green" 1) ); diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml index 31a9cc3f96a4b53336545579c5b025f6df8eb735..cbf5418e4ac48f63b819ccb87258370b27cb525d 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_balance.ml @@ -89,8 +89,7 @@ let assert_token_balance ~loc block token owner expected = let string_token ~ticketer content = let contents = - WithExceptions.Result.get_ok ~loc:__LOC__ - @@ Alpha_context.Script_string.of_string content + WithExceptions.Result.get_ok ~loc:__LOC__ @@ Script_string.of_string content in Ticket_token.Ex_token {ticketer; contents_type = Script_typed_ir.string_key; contents} diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_lazy_storage_diff.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_lazy_storage_diff.ml index a421ad34a8a5803bdd0c3356abe34c3fa406f54c..bbf5b4827362cd26bdf30b327771ca2c30d86f18 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_lazy_storage_diff.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_lazy_storage_diff.ml @@ -113,7 +113,7 @@ let updates_of_key_values ctxt key_values = (Script_ir_translator.hash_comparable_data ctxt Script_typed_ir.int_key - (Script_int_repr.of_int key)) + (Script_int.of_int key)) in return ( { diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml index 183c07137406caebf571d1881ac17ae44a596d6b..668aefffca4fa9915e67074b0bc3d891345283e1 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_operations_diff.ml @@ -60,7 +60,7 @@ let big_map_updates_of_key_values ctxt key_values = (Script_ir_translator.hash_comparable_data ctxt Script_typed_ir.int_key - (Script_int_repr.of_int key)) + (Script_int.of_int key)) in return ( { @@ -173,7 +173,7 @@ let assert_equal_ticket_token_diffs ctxt ~loc ticket_diffs let string_token ~ticketer content = let contents = Result.value_f ~default:(fun _ -> assert false) - @@ Alpha_context.Script_string.of_string content + @@ Script_string.of_string content in Ticket_token.Ex_token {ticketer; contents_type = Script_typed_ir.string_key; contents} diff --git a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_scanner.ml b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_scanner.ml index de826ae3b328f0f6ef618ff28b7b0366c59f2e61..25477bdd2d5bb98bea189b53156d9d67a8aa7ffa 100644 --- a/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_scanner.ml +++ b/src/proto_alpha/lib_protocol/test/integration/michelson/test_ticket_scanner.ml @@ -185,7 +185,7 @@ let tickets_from_big_map_ref ~pre_populated value_exp = @@ Script_ir_translator.hash_comparable_data ctxt Script_typed_ir.int_key - (Script_int_repr.of_int key) + (Script_int.of_int key) in return ( { diff --git a/src/proto_alpha/lib_protocol/ticket_costs.mli b/src/proto_alpha/lib_protocol/ticket_costs.mli index fa9745b1850446be7896c9ac9829013c68b251f9..5fa21acf9f5dc5a4d06356a85b58333ca0c4db25 100644 --- a/src/proto_alpha/lib_protocol/ticket_costs.mli +++ b/src/proto_alpha/lib_protocol/ticket_costs.mli @@ -59,8 +59,8 @@ val negate_cost : Z.t -> Alpha_context.Gas.cost (** [add_int_cost n1 n2] returns the cost of adding the values [n1] and [n2]. *) val add_int_cost : - Alpha_context.Script_int.n Alpha_context.Script_int.num -> - Alpha_context.Script_int.n Alpha_context.Script_int.num -> + Script_int.n Script_int.num -> + Script_int.n Script_int.num -> Alpha_context.Gas.cost (** [add_z_cost z1 z2] returns the cost of adding the values [z1] and [z2]. *) diff --git a/src/proto_alpha/lib_protocol/ticket_operations_diff.mli b/src/proto_alpha/lib_protocol/ticket_operations_diff.mli index b32b38b434db93df6be3761e887551e9e7f6429b..6ad466927970c0551f8b56679845de936181f6b7 100644 --- a/src/proto_alpha/lib_protocol/ticket_operations_diff.mli +++ b/src/proto_alpha/lib_protocol/ticket_operations_diff.mli @@ -34,11 +34,9 @@ Invariant: [total_amount] is the sum of the amounts in [destinations]. *) type ticket_token_diff = private { ticket_token : Ticket_token.ex_token; - total_amount : Alpha_context.Script_int.n Alpha_context.Script_int.num; + total_amount : Script_int.n Script_int.num; destinations : - (Alpha_context.Destination.t - * Alpha_context.Script_int.n Alpha_context.Script_int.num) - list; + (Alpha_context.Destination.t * Script_int.n Script_int.num) list; } (** [ticket_diffs_of_operations ctxt ops] returns a list of ticket-tokens diffs diff --git a/src/proto_alpha/lib_protocol/ticket_token.mli b/src/proto_alpha/lib_protocol/ticket_token.mli index fc177bae8fa22a96cba93dffd0b6ef617b5c7dec..ec048615d71a77e30336d32edc1066c46a0b23e6 100644 --- a/src/proto_alpha/lib_protocol/ticket_token.mli +++ b/src/proto_alpha/lib_protocol/ticket_token.mli @@ -41,5 +41,4 @@ type ex_token = (** [token_and_amount_of_ex_ticket ex_ticket] returns the token and amount of the given ticket [ex_ticket]. *) val token_and_amount_of_ex_ticket : - Ticket_scanner.ex_ticket -> - ex_token * Alpha_context.Script_int.n Alpha_context.Script_int.num + Ticket_scanner.ex_ticket -> ex_token * Script_int.n Script_int.num