From 16758a5c7464e410ec9104b66797aafc9c018b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Wed, 21 Feb 2018 16:58:50 +0100 Subject: [PATCH] Alpha: remove some alphanet specifics --- .../lib_protocol/src/alpha_context.mli | 2 -- .../lib_protocol/src/alpha_services.ml | 26 ------------------- .../lib_protocol/src/alpha_services.mli | 6 ----- src/proto_alpha/lib_protocol/src/apply.ml | 1 - .../lib_protocol/src/bootstrap_storage.ml | 26 ------------------- .../lib_protocol/src/bootstrap_storage.mli | 2 -- .../lib_protocol/src/roll_storage.ml | 25 ------------------ .../lib_protocol/src/roll_storage.mli | 4 --- 8 files changed, 92 deletions(-) diff --git a/src/proto_alpha/lib_protocol/src/alpha_context.mli b/src/proto_alpha/lib_protocol/src/alpha_context.mli index 0821e8f52..e63a61ba4 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_context.mli @@ -247,7 +247,6 @@ module Bootstrap : sig } val accounts: context -> account list val account_encoding: account Data_encoding.t - val refill: context -> context tzresult Lwt.t end module Constants : sig @@ -692,7 +691,6 @@ end module Roll : sig val value: context -> Tez.t - val next: context -> Int32.t tzresult Lwt.t val freeze_rolls_for_cycle: context -> Cycle.t -> context tzresult Lwt.t val clear_cycle: context -> Cycle.t -> context tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/src/alpha_services.ml b/src/proto_alpha/lib_protocol/src/alpha_services.ml index 2b277a820..0fc396ec9 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_services.ml +++ b/src/proto_alpha/lib_protocol/src/alpha_services.ml @@ -102,20 +102,6 @@ module Context = struct ~output: Level.encoding RPC_path.(custom_root / "context" / "next_level") - let roll_value = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "roll_value" Tez.encoding)) - RPC_path.(custom_root / "context" / "roll_value") - - let next_roll = - RPC_service.post_service - ~query: RPC_query.empty - ~input: empty - ~output: (obj1 (req "next_roll" int32)) - RPC_path.(custom_root / "context" / "next_roll") - let voting_period_kind = RPC_service.post_service ~description: "Voting period kind for the current block" @@ -140,12 +126,6 @@ module Context = struct register0 S.next_level begin fun ctxt () () -> return (Level.current ctxt) end ; - register0 S.roll_value begin fun ctxt () () -> - return (Roll.value ctxt) - end; - register0 S.next_roll begin fun ctxt () () -> - Roll.next ctxt - end ; register0 S.voting_period_kind begin fun ctxt () () -> Vote.get_current_period_kind ctxt end @@ -156,12 +136,6 @@ module Context = struct let next_level ctxt block = RPC_context.make_call0 S.next_level ctxt block () () - let roll_value ctxt block = - RPC_context.make_call0 S.roll_value ctxt block () () - - let next_roll ctxt block = - RPC_context.make_call0 S.next_roll ctxt block () () - let voting_period_kind ctxt block = RPC_context.make_call0 S.voting_period_kind ctxt block () () diff --git a/src/proto_alpha/lib_protocol/src/alpha_services.mli b/src/proto_alpha/lib_protocol/src/alpha_services.mli index 6ebd619c0..7bb70390d 100644 --- a/src/proto_alpha/lib_protocol/src/alpha_services.mli +++ b/src/proto_alpha/lib_protocol/src/alpha_services.mli @@ -30,12 +30,6 @@ module Context : sig (** [next_level cctxt blk] returns the (protocol view of the) level of the successor of [blk]. *) - val next_roll: - 'a #RPC_context.simple -> 'a -> int32 shell_tzresult Lwt.t - - val roll_value: - 'a #RPC_context.simple -> 'a -> Tez.t shell_tzresult Lwt.t - val voting_period_kind: 'a #RPC_context.simple -> 'a -> Voting_period.kind shell_tzresult Lwt.t (** [voting_period_kind cctxt blk] returns the voting period kind diff --git a/src/proto_alpha/lib_protocol/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml index cca29dcfc..5a39bf179 100644 --- a/src/proto_alpha/lib_protocol/src/apply.ml +++ b/src/proto_alpha/lib_protocol/src/apply.ml @@ -299,7 +299,6 @@ let may_start_new_cycle ctxt = | Some last_cycle -> let new_cycle = Cycle.succ last_cycle in let succ_new_cycle = Cycle.succ new_cycle in - Bootstrap.refill ctxt >>=? fun ctxt -> Seed.clear_cycle ctxt last_cycle >>=? fun ctxt -> Seed.compute_for_cycle ctxt succ_new_cycle >>=? fun ctxt -> Roll.clear_cycle ctxt last_cycle >>=? fun ctxt -> diff --git a/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml b/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml index 5fa5f61da..9babfd4e3 100644 --- a/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml +++ b/src/proto_alpha/lib_protocol/src/bootstrap_storage.ml @@ -42,29 +42,3 @@ let account_encoding = (obj2 (req "publicKeyHash" Ed25519.Public_key_hash.encoding) (req "publicKey" Ed25519.Public_key.encoding)) - -let refill ctxt = - (* Unefficient HACK for the alphanet only... *) - Contract_storage.list ctxt >>= fun contracts -> - List.fold_left - (fun total contract -> - Contract_storage.get_balance ctxt contract >>=? fun balance -> - total >>=? fun total -> Lwt.return Tez_repr.(total +? balance)) - (return Tez_repr.zero) contracts >>=? fun total -> - (* The bootstrap accounts should have at least 1/2 of the total amount - of tokens. *) - let accounts = accounts ctxt in - let min_balance = - Tez_repr.(total /? 2L >>? fun r -> r /? (Int64.of_int (List.length accounts))) in - fold_left_s - (fun ctxt account -> - let contract = - Contract_repr.default_contract account.public_key_hash in - Contract_storage.get_balance ctxt contract >>=? fun balance -> - match Tez_repr.(min_balance >>? fun r -> r -? balance) with - | Error _ -> return ctxt - | Ok tez -> Contract_storage.credit ctxt contract tez) - ctxt - accounts >>=? fun c -> - Roll_storage.may_recompute_rolls c >>=? fun c -> - return c diff --git a/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli b/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli index 09c29d298..739e2718d 100644 --- a/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli +++ b/src/proto_alpha/lib_protocol/src/bootstrap_storage.mli @@ -17,5 +17,3 @@ val account_encoding: account Data_encoding.t val accounts: Raw_context.t -> account list val init: Raw_context.t -> Raw_context.t tzresult Lwt.t - -val refill: Raw_context.t -> Raw_context.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/src/roll_storage.ml b/src/proto_alpha/lib_protocol/src/roll_storage.ml index 35ebbed05..191e0a49b 100644 --- a/src/proto_alpha/lib_protocol/src/roll_storage.ml +++ b/src/proto_alpha/lib_protocol/src/roll_storage.ml @@ -215,30 +215,5 @@ end let value = Raw_context.roll_value -(* HACK for the alphanet: let's increase the roll value when - the total amount of roll is greater than 100,000. *) -let may_recompute_rolls c = - Storage.Roll.Next.get c >>=? fun next -> - let double = Roll_repr.too_many_roll next in - if Compare.Int.(double <= 0) then - return c - else - Raw_context.double_roll_value c double >>=? fun c -> - Storage.Roll.clear c >>= fun c -> - Storage.Roll.Limbo.remove c >>= fun c -> - Storage.Roll.Next.init_set c Roll_repr.first >>= fun c -> - Storage.Contract.fold c ~init:(ok c) ~f:begin fun k c -> - Lwt.return c >>=? fun c -> - Storage.Roll.Contract_roll_list.remove c k >>= fun c -> - Storage.Roll.Contract_change.init_set c k Tez_repr.zero >>= fun c -> - Storage.Contract.Balance.get c k >>=? fun balance -> - Contract.add_amount c k balance >>=? fun c -> - return c - end - -let next c = - Storage.Roll.Next.get c >>=? fun next -> - return (Roll_repr.to_int32 next) - let init c = Storage.Roll.Next.init c Roll_repr.first diff --git a/src/proto_alpha/lib_protocol/src/roll_storage.mli b/src/proto_alpha/lib_protocol/src/roll_storage.mli index ca08d0ec9..95e284268 100644 --- a/src/proto_alpha/lib_protocol/src/roll_storage.mli +++ b/src/proto_alpha/lib_protocol/src/roll_storage.mli @@ -63,7 +63,3 @@ val get_contract_delegate: Raw_context.t -> Contract_repr.t -> Ed25519.Public_key_hash.t option tzresult Lwt.t val value: Raw_context.t -> Tez_repr.t - -(** HACK for the alphanet. *) -val may_recompute_rolls: Raw_context.t -> Raw_context.t tzresult Lwt.t -val next: Raw_context.t -> Int32.t tzresult Lwt.t