From 2f15afa8373dc283168c2c37253569f05d4f831f Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 10 Oct 2023 16:23:26 +0200 Subject: [PATCH 1/5] Revert "proto/init_storage: call adaptive issuance storage migration" This reverts commit f2df42c3cbedbd6354c01588bd15fe1b74c0890d. --- src/proto_alpha/lib_protocol/init_storage.ml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/proto_alpha/lib_protocol/init_storage.ml b/src/proto_alpha/lib_protocol/init_storage.ml index b8632ba21f4f..27d7e71e2432 100644 --- a/src/proto_alpha/lib_protocol/init_storage.ml +++ b/src/proto_alpha/lib_protocol/init_storage.ml @@ -204,11 +204,6 @@ let prepare_first_block chain_id ctxt ~typecheck_smart_contract let* ctxt = Sc_rollup_refutation_storage.migrate_clean_refutation_games ctxt in - let* ctxt = - Adaptive_issuance_storage - .migrate_adaptive_issuance_storages_from_O_to_P - ctxt - in return (ctxt, []) in let* ctxt = -- GitLab From e74839178222c2683bfab7179358b3ce94a6c942 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 10 Oct 2023 16:23:43 +0200 Subject: [PATCH 2/5] Revert "proto/adaptive_issuance: add storage(s) migration function" This reverts commit 4ae19e306cfe4ecedb3e287a06b9a1bcf0a26887. --- .../lib_protocol/adaptive_issuance_storage.ml | 22 ------------------- .../adaptive_issuance_storage.mli | 3 --- 2 files changed, 25 deletions(-) diff --git a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml index 97370d3b0c2b..2713bd5837ad 100644 --- a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml +++ b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.ml @@ -325,28 +325,6 @@ let update_ema ctxt ~vote = in (ctxt, launch_cycle, new_ema) -let migrate_adaptive_issuance_storages_from_O_to_P ctxt = - let open Lwt_result_syntax in - let* activation = Storage.Adaptive_issuance.Activation.get ctxt in - let edge_of_staking_over_delegation = - Int64.of_int - (Constants_storage.adaptive_issuance_edge_of_staking_over_delegation ctxt) - in - match activation with - | None -> return ctxt - | Some activation_cycle -> - (* Distributions selected at the end of cycle C will be used for cycle - C+1+Preserved_cycles, so AI weighting only takes effect - preserved_cycles+1 after AI activation cycle. *) - let cycle_of_first_distribution_set_after_activation = - Cycle_repr.( - add (succ activation_cycle) (Constants_storage.preserved_cycles ctxt)) - in - Stake_storage.migrate_storage_to_weighted_value_for_O_to_P - ctxt - (Stake_repr.migrate_stake_from_O_to_P ~edge_of_staking_over_delegation) - ~from_cycle:cycle_of_first_distribution_set_after_activation - module For_RPC = struct let get_reward_coeff = get_reward_coeff diff --git a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.mli b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.mli index 44fbb05e82a0..11eee1b528a0 100644 --- a/src/proto_alpha/lib_protocol/adaptive_issuance_storage.mli +++ b/src/proto_alpha/lib_protocol/adaptive_issuance_storage.mli @@ -67,9 +67,6 @@ val update_ema : voted to be activated (yet). *) val launch_cycle : Raw_context.t -> Cycle_repr.t option tzresult Lwt.t -val migrate_adaptive_issuance_storages_from_O_to_P : - Raw_context.t -> Raw_context.t tzresult Lwt.t - module For_RPC : sig (** [get_reward_coeff ctxt cycle] reads the reward coeff for the given cycle from the storage. -- GitLab From 245787a82397227ac95b7a24921df75074ec556d Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 10 Oct 2023 16:24:38 +0200 Subject: [PATCH 3/5] Revert "proto/stake_storage: fold over stake in the provided cycles" This reverts commit e55664371422bdba28d37b29844c8cfb6b8adbc7. --- src/proto_alpha/lib_protocol/stake_storage.ml | 30 ------------------- .../lib_protocol/stake_storage.mli | 8 ----- 2 files changed, 38 deletions(-) diff --git a/src/proto_alpha/lib_protocol/stake_storage.ml b/src/proto_alpha/lib_protocol/stake_storage.ml index 3ce3c36dbc56..76a511869ec7 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.ml +++ b/src/proto_alpha/lib_protocol/stake_storage.ml @@ -71,33 +71,6 @@ module Selected_distribution_for_cycle = struct let id = identifier_of_cycle cycle in let*? ctxt = Cache.update ctxt id None in Storage.Stake.Selected_distribution_for_cycle.remove_existing ctxt cycle - - (* updating [compute_new_value] to all stored stake in all selected distribution at - cycles greater or equal to [from_cycle] *) - let migrate_storage_to_weighted_value_for_O_to_P ctxt compute_new_value - ~from_cycle = - let open Lwt_result_syntax in - let*! cycles = Storage.Stake.Selected_distribution_for_cycle.keys ctxt in - let cycles = - List.filter (fun cycle -> Cycle_repr.(cycle >= from_cycle)) cycles - in - List.fold_left_es - (fun ctxt cycle -> - let* old_value = get ctxt cycle in - let*? new_value = - let open Result_syntax in - List.map_e - (fun (pkh, stake) -> - let* new_stake = compute_new_value stake in - return (pkh, new_stake)) - old_value - in - Storage.Stake.Selected_distribution_for_cycle.update - ctxt - cycle - new_value) - ctxt - cycles end let get_full_staking_balance ctxt delegate = @@ -359,9 +332,6 @@ let prepare_stake_distribution ctxt = ctxt stake_distribution) -let migrate_storage_to_weighted_value_for_O_to_P = - Selected_distribution_for_cycle.migrate_storage_to_weighted_value_for_O_to_P - let get_total_active_stake = Storage.Stake.Total_active_stake.get let remove_contract_delegated_stake ctxt contract amount = diff --git a/src/proto_alpha/lib_protocol/stake_storage.mli b/src/proto_alpha/lib_protocol/stake_storage.mli index b9287f3f663d..1069903d7f92 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.mli +++ b/src/proto_alpha/lib_protocol/stake_storage.mli @@ -135,14 +135,6 @@ val find_selected_distribution : context. *) val prepare_stake_distribution : Raw_context.t -> Raw_context.t tzresult Lwt.t -(** Migrating all stored stake using [compute_new_value] in all selected - distribution at cycles greater or equal to [from_cycle] *) -val migrate_storage_to_weighted_value_for_O_to_P : - Raw_context.t -> - (Stake_repr.t -> Stake_repr.t tzresult) -> - from_cycle:Cycle_repr.t -> - Raw_context.t tzresult Lwt.t - (** [get_total_active_stake ctxt cycle] retrieves the amount in Tez of the active stake at [cycle] from [ctxt]. *) val get_total_active_stake : -- GitLab From 5bf2cfd4846872dac27e06bcaf71615189755f90 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 10 Oct 2023 16:26:32 +0200 Subject: [PATCH 4/5] Revert "Proto/stake_repr: compute new AI stake from an old one" This reverts commit 487d22ae103cdd9e617271d6a2940548c48485b8. --- src/proto_alpha/lib_protocol/stake_repr.ml | 11 ++--------- src/proto_alpha/lib_protocol/stake_repr.mli | 3 --- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_protocol/stake_repr.ml b/src/proto_alpha/lib_protocol/stake_repr.ml index 42f2a95d3967..a2890c52e7c0 100644 --- a/src/proto_alpha/lib_protocol/stake_repr.ml +++ b/src/proto_alpha/lib_protocol/stake_repr.ml @@ -22,6 +22,8 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) +(* TODO: https://gitlab.com/tezos/tezos/-/issues/6380 + Stitching is needed for current Stake_repr *) type t = {frozen : Tez_repr.t; weighted_delegated : Tez_repr.t} let make ~frozen ~weighted_delegated = {frozen; weighted_delegated} @@ -50,12 +52,3 @@ let staking_weight {frozen; weighted_delegated} = Int64.add frozen weighted_delegated let compare s1 s2 = Int64.compare (staking_weight s1) (staking_weight s2) - -let migrate_stake_from_O_to_P ~edge_of_staking_over_delegation - ({frozen; weighted_delegated = actually_unweighted_delegated} : t) : - t tzresult = - let open Result_syntax in - let* weighted_delegated = - Tez_repr.(actually_unweighted_delegated /? edge_of_staking_over_delegation) - in - return @@ {frozen; weighted_delegated} diff --git a/src/proto_alpha/lib_protocol/stake_repr.mli b/src/proto_alpha/lib_protocol/stake_repr.mli index f949f56f1a3d..e7f58ea9c875 100644 --- a/src/proto_alpha/lib_protocol/stake_repr.mli +++ b/src/proto_alpha/lib_protocol/stake_repr.mli @@ -43,6 +43,3 @@ val ( +? ) : t -> t -> t tzresult val staking_weight : t -> int64 val compare : t -> t -> int - -val migrate_stake_from_O_to_P : - edge_of_staking_over_delegation:int64 -> t -> t tzresult -- GitLab From 88e7303a7ca1f213decd607891fa1e64cc1ae862 Mon Sep 17 00:00:00 2001 From: Mehdi Bouaziz Date: Tue, 10 Oct 2023 16:27:10 +0200 Subject: [PATCH 5/5] Proto/Stake: no stitching needed before AI --- src/proto_alpha/lib_protocol/stake_repr.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/stake_repr.ml b/src/proto_alpha/lib_protocol/stake_repr.ml index a2890c52e7c0..b5da168279a6 100644 --- a/src/proto_alpha/lib_protocol/stake_repr.ml +++ b/src/proto_alpha/lib_protocol/stake_repr.ml @@ -22,8 +22,7 @@ (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) -(* TODO: https://gitlab.com/tezos/tezos/-/issues/6380 - Stitching is needed for current Stake_repr *) + type t = {frozen : Tez_repr.t; weighted_delegated : Tez_repr.t} let make ~frozen ~weighted_delegated = {frozen; weighted_delegated} -- GitLab