diff --git a/src/lib_shell/bench/bench_tool.ml b/src/lib_shell/bench/bench_tool.ml index dc09b6059293fefdf118c4c8ce67ac9bcb4cf40d..fce1ef11f864fcfe41773bb889652c894feec91a 100644 --- a/src/lib_shell/bench/bench_tool.ml +++ b/src/lib_shell/bench/bench_tool.ml @@ -25,9 +25,9 @@ module Helpers_Nonce = Nonce open Protocol -open Parameters_repr -open Constants_repr open Alpha_context +open Parameters +open Constants (** Args *) @@ -36,7 +36,7 @@ type args = { mutable seed : int; mutable accounts : int; mutable nb_commitments : int; - mutable params : Parameters_repr.t; + mutable params : Parameters.t; } let default_args = @@ -70,7 +70,7 @@ let parse_param_file name = else Tezos_stdlib_unix.Lwt_utils_unix.Json.read_file name >>=? fun json -> - match Data_encoding.Json.destruct Parameters_repr.encoding json with + match Data_encoding.Json.destruct Parameters.encoding json with | exception exn -> failwith "Parameters : Invalid JSON file - %a" Error_monad.pp_exn exn | param -> @@ -152,7 +152,7 @@ let list_shuffle l = type gen_state = { mutable possible_transfers : (Account.t * Account.t) list; mutable remaining_transfers : (Account.t * Account.t) list; - mutable remaining_activations : (Account.t * Commitment_repr.t) list; + mutable remaining_activations : (Account.t * Commitment.t) list; mutable nonce_to_reveal : (Cycle.t * Raw_level.t * Nonce.t) list; } @@ -317,10 +317,9 @@ let init () = (* TODO : distribute the tokens randomly *) (* Right now, we split half of 80.000 rolls between generated accounts *) (* TODO : ensure we don't overflow with the underlying commitments *) - Tez_repr.( + Tez.( Lwt.return @@ Environment.wrap_error - @@ args.params.Parameters_repr.constants.Constants_repr.tokens_per_roll - *? 80_000L + @@ (args.params.Parameters.constants.Constants.tokens_per_roll *? 80_000L) >>=? fun total_amount -> Lwt.return @@ Environment.wrap_error @@ (total_amount /? 2L) >>=? fun amount -> @@ -382,7 +381,7 @@ let init () = in let parameters = { - Parameters_repr.bootstrap_accounts; + Parameters.bootstrap_accounts; bootstrap_contracts = []; commitments; constants; @@ -417,8 +416,8 @@ let init () = "[DEBUG] Constants : %a\n%!" Data_encoding.Json.pp (Data_encoding.Json.construct - Constants_repr.parametric_encoding - parameters.Parameters_repr.constants)) ; + Constants.parametric_encoding + parameters.Parameters.constants)) ; let print_block block = let open Block in Format.printf diff --git a/src/proto_alpha/lib_client/mockup.ml b/src/proto_alpha/lib_client/mockup.ml index 34b5ff1f7e9da841833d838a9810cdbad9ad78ff..387277a59a75d3cac1df62c8d08df790eab1007d 100644 --- a/src/proto_alpha/lib_client/mockup.ml +++ b/src/proto_alpha/lib_client/mockup.ml @@ -23,21 +23,23 @@ (* *) (*****************************************************************************) +open Protocol.Alpha_context + (* ------------------------------------------------------------------------- *) (* Mockup protocol parameters *) type mockup_protocol_parameters = { initial_timestamp : Time.Protocol.t; - bootstrap_accounts : Protocol.Parameters_repr.bootstrap_account list; - bootstrap_contracts : Protocol.Parameters_repr.bootstrap_contract list; - constants : Protocol.Constants_repr.parametric; + bootstrap_accounts : Parameters.bootstrap_account list; + bootstrap_contracts : Parameters.bootstrap_contract list; + constants : Constants.parametric; } type protocol_constants_overrides = { - hard_gas_limit_per_operation : Protocol.Gas_limit_repr.Arith.integral option; - hard_gas_limit_per_block : Protocol.Gas_limit_repr.Arith.integral option; + hard_gas_limit_per_operation : Gas.Arith.integral option; + hard_gas_limit_per_block : Gas.Arith.integral option; hard_storage_limit_per_operation : Z.t option; - cost_per_byte : Protocol.Tez_repr.t option; + cost_per_byte : Tez.t option; chain_id : Chain_id.t option; timestamp : Time.Protocol.t option; } @@ -45,14 +47,12 @@ type protocol_constants_overrides = { type parsed_account_repr = { name : string; sk_uri : Client_keys.sk_uri; - amount : Protocol.Tez_repr.t; + amount : Tez.t; } let parsed_account_repr_pp ppf account = let open Format in - let format_amount ppf value = - fprintf ppf "amount:%a" Protocol.Tez_repr.pp value - in + let format_amount ppf value = fprintf ppf "amount:%a" Tez.pp value in fprintf ppf "@[name:%s@,sk_uri:%s@,%a@]" @@ -61,10 +61,9 @@ let parsed_account_repr_pp ppf account = format_amount account.amount -let bootstrap_account_encoding : - Protocol.Parameters_repr.bootstrap_account Data_encoding.t = +let bootstrap_account_encoding : Parameters.bootstrap_account Data_encoding.t = let open Data_encoding in - let open Protocol.Parameters_repr in + let open Parameters in conv (fun {public_key_hash; public_key; amount} -> (public_key_hash, public_key, amount)) @@ -73,19 +72,19 @@ let bootstrap_account_encoding : (obj3 (req "public_key_hash" Signature.Public_key_hash.encoding) (opt "public_key" Signature.Public_key.encoding) - (req "amount" Protocol.Tez_repr.encoding)) + (req "amount" Tez.encoding)) -let bootstrap_contract_encoding : - Protocol.Parameters_repr.bootstrap_contract Data_encoding.t = +let bootstrap_contract_encoding : Parameters.bootstrap_contract Data_encoding.t + = let open Data_encoding in - let open Protocol.Parameters_repr in + let open Parameters in conv (fun {delegate; amount; script} -> (delegate, amount, script)) (fun (delegate, amount, script) -> {delegate; amount; script}) (obj3 (req "delegate" Signature.Public_key_hash.encoding) - (req "amount" Protocol.Tez_repr.encoding) - (req "script" Protocol.Script_repr.encoding)) + (req "amount" Tez.encoding) + (req "script" Script.encoding)) let mockup_protocol_parameters_encoding : mockup_protocol_parameters Data_encoding.t = @@ -103,7 +102,7 @@ let mockup_protocol_parameters_encoding : (req "initial_timestamp" Time.Protocol.encoding) (req "bootstrap_accounts" (list bootstrap_account_encoding)) (req "bootstrap_contracts" (list bootstrap_contract_encoding)) - (req "constants" Protocol.Constants_repr.parametric_encoding)) + (req "constants" Constants.parametric_encoding)) let protocol_constants_overrides_encoding = let open Data_encoding in @@ -130,14 +129,10 @@ let protocol_constants_overrides_encoding = timestamp; }) (obj6 - (opt - "hard_gas_limit_per_operation" - Protocol.Gas_limit_repr.Arith.z_integral_encoding) - (opt - "hard_gas_limit_per_block" - Protocol.Gas_limit_repr.Arith.z_integral_encoding) + (opt "hard_gas_limit_per_operation" Gas.Arith.z_integral_encoding) + (opt "hard_gas_limit_per_block" Gas.Arith.z_integral_encoding) (opt "hard_storage_limit_per_operation" z) - (opt "cost_per_byte" Protocol.Tez_repr.encoding) + (opt "cost_per_byte" Tez.encoding) (opt "chain_id" Chain_id.encoding) (opt "initial_timestamp" Time.Protocol.encoding)) @@ -169,7 +164,7 @@ let default_mockup_protocol_constants : protocol_constants_overrides = (* Use the wallet to convert a bootstrap account's public key into a parsed_account_repr secret key Uri *) let bootstrap_account_to_parsed_account_repr cctxt - (bootstrap_account : Protocol.Parameters_repr.bootstrap_account) = + (bootstrap_account : Parameters.bootstrap_account) = Client_keys.get_key cctxt bootstrap_account.public_key_hash >>=? fun (name, _, sk_uri) -> return {name; sk_uri; amount = bootstrap_account.amount} @@ -182,7 +177,7 @@ let parsed_account_repr_encoding = (obj3 (req "name" string) (req "sk_uri" Client_keys.Secret_key.encoding) - (req "amount" Protocol.Tez_repr.encoding)) + (req "amount" Tez.encoding)) let mockup_default_bootstrap_accounts (cctxt : Tezos_client_base.Client_context.full) : string tzresult Lwt.t = @@ -207,8 +202,7 @@ let mockup_default_bootstrap_accounts match tz_balance with | Ok balance -> ( let tez_repr = - Protocol.Tez_repr.of_mutez - @@ Protocol.Alpha_context.Tez.to_mutez balance + Tez.of_mutez @@ Protocol.Alpha_context.Tez.to_mutez balance in match tez_repr with | None -> @@ -247,8 +241,7 @@ let protocol_constants_no_overrides = } let apply_protocol_overrides (cctxt : Tezos_client_base.Client_context.full) - (o : protocol_constants_overrides) (c : Protocol.Constants_repr.parametric) - = + (o : protocol_constants_overrides) (c : Constants.parametric) = let has_custom = Option.is_some o.hard_gas_limit_per_operation || Option.is_some o.hard_gas_limit_per_block @@ -265,17 +258,13 @@ let apply_protocol_overrides (cctxt : Tezos_client_base.Client_context.full) in cctxt#message "@[mockup client uses protocol overrides:@,%a%a%a%a@]@?" - (pp_opt_custom - "hard_gas_limit_per_operation" - Protocol.Gas_limit_repr.Arith.pp_integral) + (pp_opt_custom "hard_gas_limit_per_operation" Gas.Arith.pp_integral) o.hard_gas_limit_per_operation - (pp_opt_custom - "hard_gas_limit_per_block" - Protocol.Gas_limit_repr.Arith.pp_integral) + (pp_opt_custom "hard_gas_limit_per_block" Gas.Arith.pp_integral) o.hard_gas_limit_per_block (pp_opt_custom "hard_storage_limit_per_operation" Z.pp_print) o.hard_storage_limit_per_operation - (pp_opt_custom "cost_per_byte" Protocol.Tez_repr.pp) + (pp_opt_custom "cost_per_byte" Tez.pp) o.cost_per_byte else Lwt.return_unit ) >>= fun () -> @@ -304,7 +293,7 @@ let to_bootstrap_account repr = >>=? fun public_key -> let public_key_hash = Signature.Public_key.hash public_key in return - Protocol.Parameters_repr. + Parameters. {public_key_hash; public_key = Some public_key; amount = repr.amount} (* ------------------------------------------------------------------------- *) @@ -399,7 +388,7 @@ let mem_init : ~level:0l ~predecessor:hash ~timestamp - ~fitness:(Protocol.Fitness_repr.from_int64 0L) + ~fitness:(Fitness.from_int64 0L) ~operations_hash:Operation_list_list_hash.zero in apply_protocol_overrides cctxt protocol_overrides parameters.constants diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 16666b024c6202108923187c9016eb8218417181..e76c8b6edfa8c09e35225ef0b955672d0e97301d 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -23,47 +23,44 @@ (* *) (*****************************************************************************) -open Protocol +open Protocol.Alpha_context let constants_mainnet = - Constants_repr. + Constants. { preserved_cycles = 5; blocks_per_cycle = 4096l; blocks_per_commitment = 32l; blocks_per_roll_snapshot = 256l; blocks_per_voting_period = 20480l; - time_between_blocks = List.map Period_repr.of_seconds_exn [60L; 40L]; + time_between_blocks = List.map Period.of_seconds_exn [60L; 40L]; endorsers_per_block = 32; - hard_gas_limit_per_operation = - Gas_limit_repr.Arith.(integral_of_int 1_040_000); - hard_gas_limit_per_block = - Gas_limit_repr.Arith.(integral_of_int 10_400_000); + hard_gas_limit_per_operation = Gas.Arith.(integral_of_int 1_040_000); + hard_gas_limit_per_block = Gas.Arith.(integral_of_int 10_400_000); proof_of_work_threshold = Int64.(sub (shift_left 1L 46) 1L); - tokens_per_roll = Tez_repr.(mul_exn one 8_000); + tokens_per_roll = Tez.(mul_exn one 8_000); michelson_maximum_type_size = 1000; seed_nonce_revelation_tip = - (match Tez_repr.(one /? 8L) with Ok c -> c | Error _ -> assert false); + (match Tez.(one /? 8L) with Ok c -> c | Error _ -> assert false); origination_size = 257; - block_security_deposit = Tez_repr.(mul_exn one 512); - endorsement_security_deposit = Tez_repr.(mul_exn one 64); + block_security_deposit = Tez.(mul_exn one 512); + endorsement_security_deposit = Tez.(mul_exn one 64); baking_reward_per_endorsement = - Tez_repr.[of_mutez_exn 1_250_000L; of_mutez_exn 187_500L]; - endorsement_reward = - Tez_repr.[of_mutez_exn 1_250_000L; of_mutez_exn 833_333L]; + Tez.[of_mutez_exn 1_250_000L; of_mutez_exn 187_500L]; + endorsement_reward = Tez.[of_mutez_exn 1_250_000L; of_mutez_exn 833_333L]; hard_storage_limit_per_operation = Z.of_int 60_000; - cost_per_byte = Tez_repr.of_mutez_exn 250L; + cost_per_byte = Tez.of_mutez_exn 250L; test_chain_duration = Int64.mul 20480L 60L; quorum_min = 20_00l; (* quorum is in centile of a percentage *) quorum_max = 70_00l; min_proposal_quorum = 5_00l; initial_endorsers = 24; - delay_per_missing_endorsement = Period_repr.of_seconds_exn 8L; + delay_per_missing_endorsement = Period.of_seconds_exn 8L; } let constants_sandbox = - Constants_repr. + Constants. { constants_mainnet with preserved_cycles = 2; @@ -71,24 +68,24 @@ let constants_sandbox = blocks_per_commitment = 4l; blocks_per_roll_snapshot = 4l; blocks_per_voting_period = 64l; - time_between_blocks = List.map Period_repr.of_seconds_exn [1L; 0L]; + time_between_blocks = List.map Period.of_seconds_exn [1L; 0L]; proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; - delay_per_missing_endorsement = Period_repr.of_seconds_exn 1L; + delay_per_missing_endorsement = Period.of_seconds_exn 1L; } let constants_test = - Constants_repr. + Constants. { constants_mainnet with blocks_per_cycle = 128l; blocks_per_commitment = 4l; blocks_per_roll_snapshot = 32l; blocks_per_voting_period = 256l; - time_between_blocks = List.map Period_repr.of_seconds_exn [1L; 0L]; + time_between_blocks = List.map Period.of_seconds_exn [1L; 0L]; proof_of_work_threshold = Int64.of_int (-1); initial_endorsers = 1; - delay_per_missing_endorsement = Period_repr.of_seconds_exn 1L; + delay_per_missing_endorsement = Period.of_seconds_exn 1L; } let bootstrap_accounts_strings = @@ -98,14 +95,14 @@ let bootstrap_accounts_strings = "edpkuFrRoDSEbJYgxRtLx2ps82UdaYc1WwfS9sE11yhauZt5DgCHbU"; "edpkv8EUUH68jmo3f7Um5PezmfGrRF24gnfLpH3sVNwJnV5bVCxL2n" ] -let bootstrap_balance = Tez_repr.of_mutez_exn 4_000_000_000_000L +let bootstrap_balance = Tez.of_mutez_exn 4_000_000_000_000L let bootstrap_accounts = List.map (fun s -> let public_key = Signature.Public_key.of_b58check_exn s in let public_key_hash = Signature.Public_key.hash public_key in - Parameters_repr. + Parameters. { public_key_hash; public_key = Some public_key; @@ -136,17 +133,15 @@ let commitments = | Error err -> raise (Failure err) | Ok json -> - Data_encoding.Json.destruct - (Data_encoding.list Commitment_repr.encoding) - json + Data_encoding.Json.destruct (Data_encoding.list Commitment.encoding) json let make_bootstrap_account (pkh, pk, amount) = - Parameters_repr.{public_key_hash = pkh; public_key = Some pk; amount} + Parameters.{public_key_hash = pkh; public_key = Some pk; amount} let parameters_of_constants ?(bootstrap_accounts = bootstrap_accounts) ?(bootstrap_contracts = []) ?(with_commitments = false) constants = let commitments = if with_commitments then commitments else [] in - Parameters_repr. + Parameters. { bootstrap_accounts; bootstrap_contracts; @@ -157,4 +152,4 @@ let parameters_of_constants ?(bootstrap_accounts = bootstrap_accounts) } let json_of_parameters parameters = - Data_encoding.Json.construct Parameters_repr.encoding parameters + Data_encoding.Json.construct Parameters.encoding parameters diff --git a/src/proto_alpha/lib_parameters/default_parameters.mli b/src/proto_alpha/lib_parameters/default_parameters.mli index 598574c8f908ba46a9ad5718ba3b599097384f46..0a99181fe345d1ef89042681128e84e234fcfeb8 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.mli +++ b/src/proto_alpha/lib_parameters/default_parameters.mli @@ -23,23 +23,23 @@ (* *) (*****************************************************************************) -open Protocol +open Protocol.Alpha_context -val constants_mainnet : Constants_repr.parametric +val constants_mainnet : Constants.parametric -val constants_sandbox : Constants_repr.parametric +val constants_sandbox : Constants.parametric -val constants_test : Constants_repr.parametric +val constants_test : Constants.parametric val make_bootstrap_account : - Signature.public_key_hash * Signature.public_key * Tez_repr.t -> - Parameters_repr.bootstrap_account + Signature.public_key_hash * Signature.public_key * Tez.t -> + Parameters.bootstrap_account val parameters_of_constants : - ?bootstrap_accounts:Parameters_repr.bootstrap_account list -> - ?bootstrap_contracts:Parameters_repr.bootstrap_contract list -> + ?bootstrap_accounts:Parameters.bootstrap_account list -> + ?bootstrap_contracts:Parameters.bootstrap_contract list -> ?with_commitments:bool -> - Constants_repr.parametric -> - Parameters_repr.t + Constants.parametric -> + Parameters.t -val json_of_parameters : Parameters_repr.t -> Data_encoding.json +val json_of_parameters : Parameters.t -> Data_encoding.json diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index e842dce9c15d33752bade873df55d6e0b58e82b5..d0252bdac57594d6fd5cb4cb31dc30c53e1b89e4 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -296,3 +296,5 @@ let get_fees = Raw_context.get_fees let get_rewards = Raw_context.get_rewards let description = Raw_context.description + +module Parameters = Parameters_repr diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index b1c395abab4188f618bb35705432e35deef86f93..052dc59e3634fa4ef6c0c65b22e650f6174a01f0 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -74,6 +74,10 @@ module Tez : sig val of_mutez : int64 -> tez option val to_mutez : tez -> int64 + + val of_mutez_exn : int64 -> t + + val mul_exn : t -> int -> t end module Period : sig @@ -85,6 +89,8 @@ module Period : sig val of_seconds : int64 -> period tzresult + val of_seconds_exn : int64 -> period + val to_seconds : period -> int64 val mult : int32 -> period -> period tzresult @@ -634,6 +640,8 @@ module Fitness : sig val current : context -> int64 val to_int64 : fitness -> int64 tzresult + + val from_int64 : int64 -> bytes list end module Nonce : sig @@ -1036,7 +1044,7 @@ module Delegate : sig context -> Signature.Public_key_hash.t -> Tez.t tzresult Lwt.t val delegated_contracts : - context -> Signature.Public_key_hash.t -> Contract_repr.t list Lwt.t + context -> Signature.Public_key_hash.t -> Contract.t list Lwt.t val delegated_balance : context -> Signature.Public_key_hash.t -> Tez.t tzresult Lwt.t @@ -1510,6 +1518,8 @@ module Commitment : sig amount : Tez.tez; } + val encoding : t Data_encoding.t + val get_opt : context -> Blinded_public_key_hash.t -> Tez.t option tzresult Lwt.t @@ -1585,3 +1595,28 @@ val get_rewards : context -> Tez.t val get_deposits : context -> Tez.t Signature.Public_key_hash.Map.t val description : context Storage_description.t + +module Parameters : sig + type bootstrap_account = { + public_key_hash : public_key_hash; + public_key : public_key option; + amount : Tez.t; + } + + type bootstrap_contract = { + delegate : public_key_hash; + amount : Tez.t; + script : Script.t; + } + + type t = { + bootstrap_accounts : bootstrap_account list; + bootstrap_contracts : bootstrap_contract list; + commitments : Commitment.t list; + constants : Constants.parametric; + security_deposit_ramp_up_cycles : int option; + no_reward_cycles : int option; + } + + val encoding : t Data_encoding.t +end diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index 6c8401f8a6249614107616f370d83ea083a5a8ad..e9990d8effcdb98afe1740b709bcea5a510689ac 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -31,7 +31,7 @@ type info = { frozen_balance : Tez.t; frozen_balance_by_cycle : Delegate.frozen_balance Cycle.Map.t; staking_balance : Tez.t; - delegated_contracts : Contract_repr.t list; + delegated_contracts : Contract.t list; delegated_balance : Tez.t; deactivated : bool; grace_period : Cycle.t; @@ -84,7 +84,7 @@ let info_encoding = (req "frozen_balance" Tez.encoding) (req "frozen_balance_by_cycle" Delegate.frozen_balance_by_cycle_encoding) (req "staking_balance" Tez.encoding) - (req "delegated_contracts" (list Contract_repr.encoding)) + (req "delegated_contracts" (list Contract.encoding)) (req "delegated_balance" Tez.encoding) (req "deactivated" bool) (req "grace_period" Cycle.encoding) @@ -164,7 +164,7 @@ module S = struct ~description: "Returns the list of contracts that delegate to a given delegate." ~query:RPC_query.empty - ~output:(list Contract_repr.encoding) + ~output:(list Contract.encoding) RPC_path.(path / "delegated_contracts") let delegated_balance = diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli index 05d2dfcce29ae7f28b8a918c4580366853da58dc..f8ec3fd7426412e60ca1ba26ca66880bd9d1a642 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.mli +++ b/src/proto_alpha/lib_protocol/delegate_services.mli @@ -39,7 +39,7 @@ type info = { frozen_balance : Tez.t; frozen_balance_by_cycle : Delegate.frozen_balance Cycle.Map.t; staking_balance : Tez.t; - delegated_contracts : Contract_repr.t list; + delegated_contracts : Contract.t list; delegated_balance : Tez.t; deactivated : bool; grace_period : Cycle.t; @@ -82,7 +82,7 @@ val delegated_contracts : 'a #RPC_context.simple -> 'a -> Signature.Public_key_hash.t -> - Contract_repr.t list shell_tzresult Lwt.t + Contract.t list shell_tzresult Lwt.t val delegated_balance : 'a #RPC_context.simple -> diff --git a/src/proto_alpha/lib_protocol/test/helpers/account.ml b/src/proto_alpha/lib_protocol/test/helpers/account.ml index 2d939c6e31bc0720a83cf56d4ac60d5a55fc347c..ba6ce8dc88119d2f468588aa3a3b890f9e325897 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/account.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/account.ml @@ -24,6 +24,7 @@ (*****************************************************************************) open Protocol +open Alpha_context type t = { pkh : Signature.Public_key_hash.t; @@ -66,15 +67,15 @@ let find_alternate pkh = let dummy_account = new_account () -let generate_accounts ?(initial_balances = []) n : (t * Tez_repr.t) list = +let generate_accounts ?(initial_balances = []) n : (t * Tez.t) list = Signature.Public_key_hash.Table.clear known_accounts ; - let default_amount = Tez_repr.of_mutez_exn 4_000_000_000_000L in + let default_amount = Tez.of_mutez_exn 4_000_000_000_000L in let amount i = match List.nth_opt initial_balances i with | None -> default_amount | Some a -> - Tez_repr.of_mutez_exn a + Tez.of_mutez_exn a in List.map (fun i -> @@ -91,10 +92,10 @@ let commitment_secret = let new_commitment ?seed () = let (pkh, pk, sk) = Signature.generate_key ?seed ~algo:Ed25519 () in let unactivated_account = {pkh; pk; sk} in - let open Commitment_repr in + let open Commitment in let pkh = match pkh with Ed25519 pkh -> pkh | _ -> assert false in let bpkh = Blinded_public_key_hash.of_ed25519_pkh commitment_secret pkh in Lwt.return - ( (Environment.wrap_error @@ Tez_repr.(one *? 4_000L)) + ( (Environment.wrap_error @@ Tez.(one *? 4_000L)) >|? fun amount -> (unactivated_account, {blinded_public_key_hash = bpkh; amount}) ) diff --git a/src/proto_alpha/lib_protocol/test/helpers/account.mli b/src/proto_alpha/lib_protocol/test/helpers/account.mli index 01cd27fae1a4988eaf558ca9d0f43bb01ed68275..b39fb7d0d2310e0289d0d583d82114f7c9854210 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/account.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/account.mli @@ -24,6 +24,7 @@ (*****************************************************************************) open Protocol +open Alpha_context type t = { pkh : Signature.Public_key_hash.t; @@ -52,10 +53,9 @@ val find_alternate : Signature.Public_key_hash.t -> t [i]th value in the list [initial_balances] or otherwise 4.000.000.000 tz (if the list is too short); and add them to the global account state *) -val generate_accounts : - ?initial_balances:int64 list -> int -> (t * Tez_repr.t) list +val generate_accounts : ?initial_balances:int64 list -> int -> (t * Tez.t) list val commitment_secret : Blinded_public_key_hash.activation_code val new_commitment : - ?seed:Bytes.t -> unit -> (account * Commitment_repr.t) tzresult Lwt.t + ?seed:Bytes.t -> unit -> (account * Commitment.t) tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.ml b/src/proto_alpha/lib_protocol/test/helpers/block.ml index beaa12d0aeeb7e83a892b20d42022c7849ebc456..9ec37e332bb260eb09f3f5f2411bb074300cbc84 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/block.ml @@ -191,9 +191,9 @@ module Forge = struct >>=? fun expected_timestamp -> let timestamp = Option.value ~default:expected_timestamp timestamp in let level = Int32.succ pred.header.shell.level in - ( match Fitness_repr.to_int64 pred.header.shell.fitness with + ( match Fitness.to_int64 pred.header.shell.fitness with | Ok old_fitness -> - Fitness_repr.from_int64 (Int64.add (Int64.of_int 1) old_fitness) + Fitness.from_int64 (Int64.add (Int64.of_int 1) old_fitness) | Error _ -> assert false ) |> fun fitness -> @@ -231,7 +231,7 @@ end let protocol_param_key = ["protocol_parameters"] let check_constants_consistency constants = - let open Constants_repr in + let open Constants in let {blocks_per_cycle; blocks_per_commitment; blocks_per_roll_snapshot; _} = constants in @@ -282,7 +282,7 @@ let genesis_with_parameters parameters = ~level:0l ~predecessor:hash ~timestamp:Time.Protocol.epoch - ~fitness:(Fitness_repr.from_int64 0L) + ~fitness:(Fitness.from_int64 0L) ~operations_hash:Operation_list_list_hash.zero in let contents = Forge.make_contents ~priority:0 ~seed_nonce_hash:None () in @@ -308,7 +308,7 @@ let genesis_with_parameters parameters = (* if no parameter file is passed we check in the current directory where the test is run *) let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers - ?min_proposal_quorum (initial_accounts : (Account.t * Tez_repr.t) list) = + ?min_proposal_quorum (initial_accounts : (Account.t * Tez.t) list) = if initial_accounts = [] then Stdlib.failwith "Must have one account with a roll to bake" ; let open Tezos_protocol_alpha_parameters in @@ -335,10 +335,10 @@ let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers (fun () -> List.fold_left_es (fun acc (_, amount) -> - Environment.wrap_error @@ Tez_repr.( +? ) acc amount + Environment.wrap_error @@ Tez.( +? ) acc amount >>?= fun acc -> if acc >= constants.tokens_per_roll then raise Exit else return acc) - Tez_repr.zero + Tez.zero initial_accounts >>=? fun _ -> failwith "Insufficient tokens in initial accounts to create one roll") @@ -355,7 +355,7 @@ let genesis ?with_commitments ?endorsers_per_block ?initial_endorsers ~level:0l ~predecessor:hash ~timestamp:Time.Protocol.epoch - ~fitness:(Fitness_repr.from_int64 0L) + ~fitness:(Fitness.from_int64 0L) ~operations_hash:Operation_list_list_hash.zero in let contents = Forge.make_contents ~priority:0 ~seed_nonce_hash:None () in diff --git a/src/proto_alpha/lib_protocol/test/helpers/block.mli b/src/proto_alpha/lib_protocol/test/helpers/block.mli index 059b46762949406da1de39df1c4e0974b44fb65a..7d327b3fdf99544d227001c18d150ac74a6e9a4b 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/block.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/block.mli @@ -96,10 +96,10 @@ val genesis : ?endorsers_per_block:int -> ?initial_endorsers:int -> ?min_proposal_quorum:int32 -> - (Account.t * Tez_repr.tez) list -> + (Account.t * Tez.tez) list -> block tzresult Lwt.t -val genesis_with_parameters : Parameters_repr.t -> block tzresult Lwt.t +val genesis_with_parameters : Parameters.t -> block tzresult Lwt.t (** Applies a signed header and its operations to a block and obtains a new block *) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 12264e667a330839738c6d6f9e423d77d64475a1..48da25bc6e9c146c0f61fee4e15343cf3ff24638 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -283,7 +283,7 @@ module Delegate = struct frozen_balance : Tez.t; frozen_balance_by_cycle : Delegate.frozen_balance Cycle.Map.t; staking_balance : Tez.t; - delegated_contracts : Contract_repr.t list; + delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; deactivated : bool; grace_period : Cycle.t; diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 3b6b66f612fd4accd96a50d45ba6171de3991c4d..1a21dcd7cc92cd9a1b7b9cf050474f476d85c300 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -116,7 +116,7 @@ module Delegate : sig frozen_balance : Tez.t; frozen_balance_by_cycle : Delegate.frozen_balance Cycle.Map.t; staking_balance : Tez.t; - delegated_contracts : Contract_repr.t list; + delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; deactivated : bool; grace_period : Cycle.t;