diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index 34ad0246ff3129f58d5e0bc626b2940562bae1b0..96ce66298b39f74f53a6112411ef5b75b4a359a9 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -572,8 +572,6 @@ module Delegate = struct end module Stake_distribution = struct - let snapshot = Stake_storage.snapshot - let compute_snapshot_index = Delegate_sampler.compute_snapshot_index let baking_rights_owner = Delegate_sampler.baking_rights_owner diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 806789257853f8ed1182ecb55ee172e0429edc23..360c9012084b0b2b2f81e12882fb3589dc03bbe9 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -4916,8 +4916,6 @@ end (** This module re-exports definitions from {!Stake_storage}, {!Delegate_storage} and {!Delegate}. *) module Stake_distribution : sig - val snapshot : context -> context tzresult Lwt.t - val compute_snapshot_index : context -> Cycle.t -> max_snapshot_index:int -> int tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/apply.ml b/src/proto_alpha/lib_protocol/apply.ml index 5c3902103c2ebdb9da87fff2f8a7f5f9d820d705..7bd50d67271ccf71e4e4a4fe24ed50ba13113a53 100644 --- a/src/proto_alpha/lib_protocol/apply.ml +++ b/src/proto_alpha/lib_protocol/apply.ml @@ -3061,11 +3061,6 @@ let finalize_application ctxt block_data_contents ~round ~predecessor_hash if Level.may_compute_randao ctxt then Seed.compute_randao ctxt else return ctxt in - let* ctxt = - if Level.may_snapshot_stake_distribution ctxt then - Stake_distribution.snapshot ctxt - else return ctxt - in let* ctxt, cycle_end_balance_updates, deactivated = may_start_new_cycle ctxt in diff --git a/src/proto_alpha/lib_protocol/delegate_cycles.ml b/src/proto_alpha/lib_protocol/delegate_cycles.ml index 72145484038ab5258d693b467541c92fe113ddd8..c99f701f5668f0d6213e2f59649e9d80bd6baa96 100644 --- a/src/proto_alpha/lib_protocol/delegate_cycles.ml +++ b/src/proto_alpha/lib_protocol/delegate_cycles.ml @@ -223,14 +223,10 @@ let cycle_end ctxt last_cycle = return (ctxt, balance_updates, deactivated_delegates) let init_first_cycles ctxt = - let open Lwt_result_syntax in let preserved = Constants_storage.preserved_cycles ctxt in List.fold_left_es (fun ctxt c -> let cycle = Cycle_repr.of_int32_exn (Int32.of_int c) in - let* ctxt = Stake_storage.snapshot ctxt in - (* NB: we need to take several snapshots because - select_distribution_for_cycle deletes the snapshots *) Delegate_sampler.select_distribution_for_cycle ctxt cycle) ctxt Misc.(0 --> preserved) diff --git a/src/proto_alpha/lib_protocol/stake_storage.ml b/src/proto_alpha/lib_protocol/stake_storage.ml index d181d05d064e6c4a23e6cf3b97b3729490650973..5475a531010a2f47529e3f1ce76e86e3a5e3a44c 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.ml +++ b/src/proto_alpha/lib_protocol/stake_storage.ml @@ -198,13 +198,6 @@ let set_active ctxt delegate = return ctxt else return ctxt -let snapshot ctxt = - let open Lwt_result_syntax in - let* index = Storage.Stake.Last_snapshot.get ctxt in - let* ctxt = Storage.Stake.Last_snapshot.update ctxt (index + 1) in - let* ctxt = Storage.Stake.Staking_balance.snapshot ctxt index in - Storage.Stake.Active_delegates_with_minimal_stake.snapshot ctxt index - let max_snapshot_index = Storage.Stake.Last_snapshot.get let set_selected_distribution_for_cycle ctxt cycle stakes total_stake = @@ -212,12 +205,7 @@ let set_selected_distribution_for_cycle ctxt cycle stakes total_stake = let stakes = List.sort (fun (_, x) (_, y) -> Stake_repr.compare y x) stakes in let* ctxt = Selected_distribution_for_cycle.init ctxt cycle stakes in let*! ctxt = Storage.Stake.Total_active_stake.add ctxt cycle total_stake in - (* cleanup snapshots *) - let*! ctxt = Storage.Stake.Staking_balance.Snapshot.clear ctxt in - let*! ctxt = - Storage.Stake.Active_delegates_with_minimal_stake.Snapshot.clear ctxt - in - Storage.Stake.Last_snapshot.update ctxt 0 + return ctxt let fold_on_active_delegates_with_minimal_stake_es ctxt ~f ~order ~init = let open Lwt_result_syntax in @@ -229,19 +217,6 @@ let fold_on_active_delegates_with_minimal_stake_es ctxt ~f ~order ~init = let*? acc in f delegate acc) -let fold_snapshot ctxt ~index ~f ~init = - let open Lwt_result_syntax in - Storage.Stake.Active_delegates_with_minimal_stake.fold_snapshot - ctxt - index - ~order:`Sorted - ~init - ~f:(fun delegate () acc -> - let* stake = - Storage.Stake.Staking_balance.Snapshot.get ctxt (index, delegate) - in - f (delegate, stake) acc) - let clear_at_cycle_end ctxt ~new_cycle = let open Lwt_result_syntax in let max_slashing_period = Constants_repr.max_slashing_period in diff --git a/src/proto_alpha/lib_protocol/stake_storage.mli b/src/proto_alpha/lib_protocol/stake_storage.mli index 7fecdcf9871b6f4a16bf3feffacec66f78035462..2c959aed04ac3a15e3fe73f19435e551bbaef90e 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.mli +++ b/src/proto_alpha/lib_protocol/stake_storage.mli @@ -30,7 +30,6 @@ - {!Storage.Stake.Selected_distribution_for_cycle} - {!Storage.Stake.Staking_balance} - {!Storage.Stake.Active_delegates_with_minimal_stake} - - {!Storage.Stake.Last_snapshot} - {!Storage.Stake.Total_active_stake} *) @@ -75,8 +74,6 @@ val set_inactive : val set_active : Raw_context.t -> Signature.Public_key_hash.t -> Raw_context.t tzresult Lwt.t -val snapshot : Raw_context.t -> Raw_context.t tzresult Lwt.t - (** [fold ctxt ~f ~order init] folds [f] on the list of active delegates having the minimal required stake. The folding process starts with [init]. Each element of the list is the public key hash of a delegate. *) @@ -87,21 +84,6 @@ val fold_on_active_delegates_with_minimal_stake_es : init:'a -> 'a tzresult Lwt.t -(** [fold_snapshot ctxt ~index ~f ~init] folds [f] on the list of active - delegates having the minimal required stake for the given snapshot [index]. The folding - process starts with [init]. Each element of the list is a pair [pkh, stake], - where [pkh] is the public key hash of the delegate and [stake] is the staking - balance of the delegate for the given snapshot [index]. *) -val fold_snapshot : - Raw_context.t -> - index:int -> - f: - (Signature.Public_key_hash.t * Full_staking_balance_repr.t -> - 'a -> - 'a tzresult Lwt.t) -> - init:'a -> - 'a tzresult Lwt.t - (** [max_snapshot_index ctxt] returns the index of the last snapshot taken of staking balances and active delegates. *) val max_snapshot_index : Raw_context.t -> int tzresult Lwt.t