From 9df6887e25d66a78696ffc92dc566230bab1adc1 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 15 Mar 2024 16:02:54 +0100 Subject: [PATCH 1/4] proto/full_staking_balance_repr: min_delegated with level --- .../lib_protocol/full_staking_balance_repr.ml | 124 +++++++++++------- .../full_staking_balance_repr.mli | 8 +- src/proto_alpha/lib_protocol/stake_storage.ml | 12 +- 3 files changed, 86 insertions(+), 58 deletions(-) diff --git a/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml b/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml index d2cf0eb1c75b..ed2b6b914e5a 100644 --- a/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml +++ b/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml @@ -5,21 +5,39 @@ (* *) (*****************************************************************************) +(** This module is responsible for the construction, observation and encoding of + full staking balances that are maintained to be used at cycle end to compute + staking rights. + + The module will handle a lazy migration starting at protocol P that adds two + new fields to the balance, the minimal delegated balance over the cycle and + the last level at which it has been modified. + As there is no trivial default value for Level_repr, the + level_of_min_delegated is optional but the module must preserve the + invariant that if a min_delegated_in_cycle has been stored, a level is + stored with it. +*) + type t = { own_frozen : Tez_repr.t; staked_frozen : Tez_repr.t; delegated : Tez_repr.t; min_delegated_in_cycle : Tez_repr.t; - cycle_of_min_delegated : Cycle_repr.t; + level_of_min_delegated : Level_repr.t option; } -let init ~own_frozen ~staked_frozen ~delegated ~current_cycle = +let cycle_of_min_delegated (level_of_min_delegated : Level_repr.t option) = + match level_of_min_delegated with + | None -> Cycle_repr.root + | Some l -> l.cycle + +let init ~own_frozen ~staked_frozen ~delegated ~current_level = { own_frozen; staked_frozen; delegated; min_delegated_in_cycle = delegated; - cycle_of_min_delegated = current_cycle; + level_of_min_delegated = Some current_level; } let encoding = @@ -27,12 +45,13 @@ let encoding = (* This encoding is backward-compatible with the encoding used in Oxford, so as to avoid a stitching in P. It will act as a lazy migration. The case in which [added_in_p] is [None] happen only for pre-existing - values in the storage. For them, using [(delegated, Cycle_repr.root)] - should behave correctly. *) + values in the storage. + For them, using [(delegated, None)] and using Cycle_repr.root when no level + is set will behave correctly. *) let added_in_p = obj2 (req "min_delegated_in_cycle" Tez_repr.encoding) - (req "cycle_of_min_delegated" Cycle_repr.encoding) + (req "level_of_min_delegated" (option Level_repr.encoding)) in conv (fun { @@ -40,28 +59,28 @@ let encoding = staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } -> ( own_frozen, staked_frozen, delegated, - Some (min_delegated_in_cycle, cycle_of_min_delegated) )) + Some (min_delegated_in_cycle, level_of_min_delegated) )) (fun (own_frozen, staked_frozen, delegated, added_in_p_opt) -> - let min_delegated_in_cycle, cycle_of_min_delegated = - added_in_p_opt |> Option.value ~default:(delegated, Cycle_repr.root) + let min_delegated_in_cycle, level_of_min_delegated = + added_in_p_opt |> Option.value ~default:(delegated, None) in { own_frozen; staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; }) (obj4 (req "own_frozen" Tez_repr.encoding) (req "staked_frozen" Tez_repr.encoding) (req "delegated" Tez_repr.encoding) - (varopt "min_delegated_in_cycle_and_cycle" added_in_p)) + (varopt "min_delegated_in_cycle_and_level" added_in_p)) let voting_weight { @@ -69,7 +88,7 @@ let voting_weight staked_frozen; delegated; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = let open Result_syntax in let* frozen = Tez_repr.(own_frozen +? staked_frozen) in @@ -82,7 +101,7 @@ let apply_slashing ~percentage staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = let remaining_percentage = Percentage.neg percentage in let own_frozen = @@ -96,7 +115,7 @@ let apply_slashing ~percentage staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } let own_frozen @@ -105,7 +124,7 @@ let own_frozen staked_frozen = _; delegated = _; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = own_frozen @@ -115,7 +134,7 @@ let staked_frozen staked_frozen; delegated = _; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = staked_frozen @@ -125,7 +144,7 @@ let total_frozen staked_frozen; delegated = _; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = Tez_repr.(own_frozen +? staked_frozen) @@ -135,7 +154,7 @@ let current_delegated staked_frozen = _; delegated; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = delegated @@ -150,8 +169,9 @@ let min_delegated_in_cycle ~current_cycle staked_frozen = _; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = + let cycle_of_min_delegated = cycle_of_min_delegated level_of_min_delegated in if Cycle_repr.(cycle_of_min_delegated < current_cycle) then delegated else ( assert (Cycle_repr.(cycle_of_min_delegated = current_cycle)) ; @@ -163,7 +183,7 @@ let current_total staked_frozen; delegated; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = let open Result_syntax in let* total_frozen = Tez_repr.(own_frozen +? staked_frozen) in @@ -175,7 +195,7 @@ let own_ratio staked_frozen; delegated = _; min_delegated_in_cycle = _; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = if Tez_repr.(staked_frozen = zero) then (1L, 1L) else if Tez_repr.(own_frozen = zero) then (0L, 1L) @@ -201,29 +221,35 @@ let has_minimal_stake_to_be_considered ~minimal_stake full_staking_balance = (* If the total overflows, we are definitely over the minimal stake. *) | Ok staking_balance -> Tez_repr.(staking_balance >= minimal_stake) -let remove_delegated ~current_cycle ~amount +let remove_delegated ~(current_level : Level_repr.t) ~amount { own_frozen; staked_frozen; delegated; - min_delegated_in_cycle; - cycle_of_min_delegated; + min_delegated_in_cycle = old_min_delegated_in_cycle; + level_of_min_delegated; } = let open Result_syntax in let+ delegated = Tez_repr.(delegated -? amount) in - let min_delegated_in_cycle = + let cycle_of_min_delegated = cycle_of_min_delegated level_of_min_delegated in + let current_cycle = current_level.cycle in + let min_delegated_in_cycle, level_of_min_delegated = if Cycle_repr.(cycle_of_min_delegated < current_cycle) then - (* after decrease *) delegated + (* after decrease *) (delegated, Some current_level) else ( assert (Cycle_repr.(cycle_of_min_delegated = current_cycle)) ; - Tez_repr.min delegated min_delegated_in_cycle) + let minimum = Tez_repr.min delegated old_min_delegated_in_cycle in + ( minimum, + if Tez_repr.(minimum = old_min_delegated_in_cycle) then + level_of_min_delegated + else Some current_level )) in { own_frozen; staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated = current_cycle; + level_of_min_delegated; } let remove_own_frozen ~amount @@ -232,7 +258,7 @@ let remove_own_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = let open Result_syntax in let+ own_frozen = Tez_repr.(own_frozen -? amount) in @@ -241,7 +267,7 @@ let remove_own_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } let remove_staked_frozen ~amount @@ -250,7 +276,7 @@ let remove_staked_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = let open Result_syntax in let+ staked_frozen = Tez_repr.(staked_frozen -? amount) in @@ -259,24 +285,26 @@ let remove_staked_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } -let add_delegated ~current_cycle ~amount +let add_delegated ~(current_level : Level_repr.t) ~amount { own_frozen; staked_frozen; delegated; - min_delegated_in_cycle; - cycle_of_min_delegated; + min_delegated_in_cycle = old_min_delegated_in_cycle; + level_of_min_delegated; } = let open Result_syntax in - let min_delegated_in_cycle = + let cycle_of_min_delegated = cycle_of_min_delegated level_of_min_delegated in + let current_cycle = current_level.cycle in + let min_delegated_in_cycle, level_of_min_delegated = if Cycle_repr.(cycle_of_min_delegated < current_cycle) then - (* before increase *) delegated + (* before increase *) (delegated, Some current_level) else ( assert (Cycle_repr.(cycle_of_min_delegated = current_cycle)) ; - min_delegated_in_cycle) + (old_min_delegated_in_cycle, level_of_min_delegated)) in let+ delegated = Tez_repr.(delegated +? amount) in { @@ -284,7 +312,7 @@ let add_delegated ~current_cycle ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated = current_cycle; + level_of_min_delegated; } let add_own_frozen ~amount @@ -293,7 +321,7 @@ let add_own_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = let open Result_syntax in let+ own_frozen = Tez_repr.(own_frozen +? amount) in @@ -302,7 +330,7 @@ let add_own_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } let add_staked_frozen ~amount @@ -311,7 +339,7 @@ let add_staked_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } = let open Result_syntax in let+ staked_frozen = Tez_repr.(staked_frozen +? amount) in @@ -320,7 +348,7 @@ let add_staked_frozen ~amount staked_frozen; delegated; min_delegated_in_cycle; - cycle_of_min_delegated; + level_of_min_delegated; } module Internal_for_tests = struct @@ -330,17 +358,17 @@ module Internal_for_tests = struct staked_frozen = _; delegated = _; min_delegated_in_cycle; - cycle_of_min_delegated = _; + level_of_min_delegated = _; } = min_delegated_in_cycle - let cycle_of_min_delegated + let level_of_min_delegated { own_frozen = _; staked_frozen = _; delegated = _; min_delegated_in_cycle = _; - cycle_of_min_delegated; + level_of_min_delegated; } = - cycle_of_min_delegated + level_of_min_delegated end diff --git a/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli b/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli index 8ff2033e76b7..b4ecf10abdaa 100644 --- a/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli +++ b/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli @@ -11,7 +11,7 @@ val init : own_frozen:Tez_repr.t -> staked_frozen:Tez_repr.t -> delegated:Tez_repr.t -> - current_cycle:Cycle_repr.t -> + current_level:Level_repr.t -> t val encoding : t Data_encoding.t @@ -45,14 +45,14 @@ val has_minimal_frozen_stake : minimal_frozen_stake:Tez_repr.t -> t -> bool val has_minimal_stake_to_be_considered : minimal_stake:Tez_repr.t -> t -> bool val remove_delegated : - current_cycle:Cycle_repr.t -> amount:Tez_repr.t -> t -> t tzresult + current_level:Level_repr.t -> amount:Tez_repr.t -> t -> t tzresult val remove_own_frozen : amount:Tez_repr.t -> t -> t tzresult val remove_staked_frozen : amount:Tez_repr.t -> t -> t tzresult val add_delegated : - current_cycle:Cycle_repr.t -> amount:Tez_repr.t -> t -> t tzresult + current_level:Level_repr.t -> amount:Tez_repr.t -> t -> t tzresult val add_own_frozen : amount:Tez_repr.t -> t -> t tzresult @@ -61,5 +61,5 @@ val add_staked_frozen : amount:Tez_repr.t -> t -> t tzresult module Internal_for_tests : sig val min_delegated_in_cycle : t -> Tez_repr.t - val cycle_of_min_delegated : t -> Cycle_repr.t + val level_of_min_delegated : t -> Level_repr.t option end diff --git a/src/proto_alpha/lib_protocol/stake_storage.ml b/src/proto_alpha/lib_protocol/stake_storage.ml index 50c81bae2dbb..53ad57c4fe74 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.ml +++ b/src/proto_alpha/lib_protocol/stake_storage.ml @@ -92,13 +92,13 @@ let has_minimal_stake ctxt staking_balance = let initialize_delegate ctxt delegate ~delegated = let open Lwt_result_syntax in - let current_cycle = (Raw_context.current_level ctxt).cycle in + let current_level = Raw_context.current_level ctxt in let balance = Full_staking_balance_repr.init ~own_frozen:Tez_repr.zero ~staked_frozen:Tez_repr.zero ~delegated - ~current_cycle + ~current_level in let* ctxt = Storage.Stake.Staking_balance.init ctxt delegate balance in if has_minimal_stake ctxt balance then @@ -150,8 +150,8 @@ let update_stake ~f ctxt delegate = | false, false | true, true -> return ctxt let remove_delegated_stake ctxt delegate amount = - let current_cycle = (Raw_context.current_level ctxt).cycle in - let f = Full_staking_balance_repr.remove_delegated ~current_cycle ~amount in + let current_level = Raw_context.current_level ctxt in + let f = Full_staking_balance_repr.remove_delegated ~current_level ~amount in update_stake ctxt delegate ~f let remove_own_frozen_stake ctxt delegate amount = @@ -174,8 +174,8 @@ let remove_frozen_stake_only_call_from_token ctxt staker amount = remove_staked_frozen_stake ctxt delegate amount let add_delegated_stake ctxt delegate amount = - let current_cycle = (Raw_context.current_level ctxt).cycle in - let f = Full_staking_balance_repr.add_delegated ~current_cycle ~amount in + let current_level = Raw_context.current_level ctxt in + let f = Full_staking_balance_repr.add_delegated ~current_level ~amount in update_stake ctxt delegate ~f let add_own_frozen_stake ctxt delegate amount = -- GitLab From df50f0103c01c6a7846aa2af813cba5b0c01fda5 Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Mon, 18 Mar 2024 11:08:31 +0100 Subject: [PATCH 2/4] Proto/RPC: Provide level with min_delegated_in_current_cycle RPCs --- .../lib_protocol/alpha_context.mli | 2 +- .../lib_protocol/delegate_services.ml | 18 +++++++++++---- .../lib_protocol/delegate_services.mli | 2 +- .../lib_protocol/delegate_storage.ml | 22 +++++++++++++++---- .../lib_protocol/delegate_storage.mli | 4 +++- .../lib_protocol/full_staking_balance_repr.ml | 2 +- .../full_staking_balance_repr.mli | 2 +- 7 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 8ab973a73d01..e6ecfa1eec42 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -2500,7 +2500,7 @@ module Delegate : sig val staking_balance : context -> public_key_hash -> Tez.t tzresult Lwt.t val min_delegated_in_current_cycle : - context -> public_key_hash -> Tez.t tzresult Lwt.t + context -> public_key_hash -> (Tez.t * Level_repr.t option) tzresult Lwt.t val has_pending_denunciations : context -> public_key_hash -> bool Lwt.t diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index b8e5ac3a68c5..e48962d5b718 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -108,6 +108,13 @@ let consensus_key_info_encoding = consensus_key_encoding)) [])) +let min_delegated_in_current_cycle_encoding = + let open Data_encoding in + conv + (fun (min_delegated, anchor) -> (min_delegated, anchor)) + (fun (min_delegated, anchor) -> (min_delegated, anchor)) + (obj2 (req "amount" Tez.encoding) (opt "level" Level_repr.encoding)) + type info = { full_balance : Tez.t; current_frozen_deposits : Tez.t; @@ -116,7 +123,7 @@ type info = { frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; - min_delegated_in_current_cycle : Tez.t; + min_delegated_in_current_cycle : Tez.t * Level_repr.t option; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; @@ -199,7 +206,9 @@ let info_encoding = (opt "frozen_deposits_limit" Tez.encoding) (req "delegated_contracts" (list Contract.encoding)) (req "delegated_balance" Tez.encoding) - (req "min_delegated_in_current_cycle" Tez.encoding) + (req + "min_delegated_in_current_cycle" + min_delegated_in_current_cycle_encoding) (req "deactivated" bool) (req "grace_period" Cycle.encoding)) (merge_objs @@ -419,9 +428,10 @@ module S = struct RPC_service.get_service ~description: "Returns the minimum of delegated tez (in mutez) over the current \ - cycle." + cycle and the block level where this value was last updated (* Level \ + is `None` when decoding values from protocol O)." ~query:RPC_query.empty - ~output:Tez.encoding + ~output:min_delegated_in_current_cycle_encoding RPC_path.(path / "min_delegated_in_current_cycle") let deactivated = diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli index 16bdf5f9dd9c..60b8df658ecf 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.mli +++ b/src/proto_alpha/lib_protocol/delegate_services.mli @@ -61,7 +61,7 @@ type info = { frozen_deposits_limit : Tez.t option; delegated_contracts : Contract.t list; delegated_balance : Tez.t; - min_delegated_in_current_cycle : Tez.t; + min_delegated_in_current_cycle : Tez.t * Level_repr.t option; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; diff --git a/src/proto_alpha/lib_protocol/delegate_storage.ml b/src/proto_alpha/lib_protocol/delegate_storage.ml index 75fea2802c5c..f978a854ecb8 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_storage.ml @@ -400,10 +400,24 @@ module For_RPC = struct let+ staking_balance = Stake_storage.get_full_staking_balance ctxt delegate in - Full_staking_balance_repr.min_delegated_in_cycle - ~current_cycle - staking_balance - else return Tez_repr.zero + let min_delegated = + Full_staking_balance_repr.min_delegated_in_cycle + ~current_cycle + staking_balance + in + let level_of_min_delegated = + match + Full_staking_balance_repr.Internal_for_tests_and_RPCs + .level_of_min_delegated + staking_balance + with + | None -> None + | Some level -> + if Cycle_repr.(level.cycle < current_cycle) then None + else Some level + in + (min_delegated, level_of_min_delegated) + else return (Tez_repr.zero, None) let delegated_balance ctxt delegate = let open Lwt_result_syntax in diff --git a/src/proto_alpha/lib_protocol/delegate_storage.mli b/src/proto_alpha/lib_protocol/delegate_storage.mli index 58c91f85e8e5..a5ef9fd9f9e2 100644 --- a/src/proto_alpha/lib_protocol/delegate_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_storage.mli @@ -162,5 +162,7 @@ module For_RPC : sig Raw_context.t -> Signature.Public_key_hash.t -> Tez_repr.t tzresult Lwt.t val min_delegated_in_current_cycle : - Raw_context.t -> Signature.Public_key_hash.t -> Tez_repr.t tzresult Lwt.t + Raw_context.t -> + Signature.Public_key_hash.t -> + (Tez_repr.t * Level_repr.t option) tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml b/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml index ed2b6b914e5a..4322c273bdc9 100644 --- a/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml +++ b/src/proto_alpha/lib_protocol/full_staking_balance_repr.ml @@ -351,7 +351,7 @@ let add_staked_frozen ~amount level_of_min_delegated; } -module Internal_for_tests = struct +module Internal_for_tests_and_RPCs = struct let min_delegated_in_cycle { own_frozen = _; diff --git a/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli b/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli index b4ecf10abdaa..c628320ce328 100644 --- a/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli +++ b/src/proto_alpha/lib_protocol/full_staking_balance_repr.mli @@ -58,7 +58,7 @@ val add_own_frozen : amount:Tez_repr.t -> t -> t tzresult val add_staked_frozen : amount:Tez_repr.t -> t -> t tzresult -module Internal_for_tests : sig +module Internal_for_tests_and_RPCs : sig val min_delegated_in_cycle : t -> Tez_repr.t val level_of_min_delegated : t -> Level_repr.t option -- GitLab From d60f30a706eebd36d27d5b2125fa9535c591d531 Mon Sep 17 00:00:00 2001 From: Mathias Bourgoin Date: Mon, 18 Mar 2024 12:30:28 +0100 Subject: [PATCH 3/4] Proto/Tests: update test with level of min_delegated --- src/proto_alpha/lib_protocol/level_repr.ml | 9 +++++++++ src/proto_alpha/lib_protocol/level_repr.mli | 2 ++ .../lib_protocol/test/helpers/context.ml | 2 +- .../lib_protocol/test/helpers/context.mli | 2 +- .../test/unit/test_full_staking_balance_repr.ml | 14 ++++++++------ 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/proto_alpha/lib_protocol/level_repr.ml b/src/proto_alpha/lib_protocol/level_repr.ml index e69ec8204834..d835cb45cd49 100644 --- a/src/proto_alpha/lib_protocol/level_repr.ml +++ b/src/proto_alpha/lib_protocol/level_repr.ml @@ -362,4 +362,13 @@ module Internal_for_tests = struct level_position = Int32.add level.level_position (Int32.of_int (n * blocks_per_cycle)); } + + let root = + { + level = Raw_level_repr.root; + level_position = 0l; + cycle = Cycle_repr.root; + cycle_position = 0l; + expected_commitment = false; + } end diff --git a/src/proto_alpha/lib_protocol/level_repr.mli b/src/proto_alpha/lib_protocol/level_repr.mli index cea66e98acf9..7e29f119f515 100644 --- a/src/proto_alpha/lib_protocol/level_repr.mli +++ b/src/proto_alpha/lib_protocol/level_repr.mli @@ -119,6 +119,8 @@ module Internal_for_tests : sig val add_level : t -> int -> t val add_cycles : blocks_per_cycle:int -> t -> int -> t + + val root : t end (**/**) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 3682337bdb41..781774aefb26 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -487,7 +487,7 @@ module Delegate = struct frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; - min_delegated_in_current_cycle : Tez.t; + min_delegated_in_current_cycle : Tez.t * Level_repr.t option; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index dff28b54f6a0..d5f9a978269b 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -259,7 +259,7 @@ module Delegate : sig frozen_deposits_limit : Tez.t option; delegated_contracts : Alpha_context.Contract.t list; delegated_balance : Tez.t; - min_delegated_in_current_cycle : Tez.t; + min_delegated_in_current_cycle : Tez.t * Level_repr.t option; total_delegated_stake : Tez.t; staking_denominator : Staking_pseudotoken.t; deactivated : bool; diff --git a/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml b/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml index 3bcfa0b87378..6c9f2a893580 100644 --- a/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml +++ b/src/proto_alpha/lib_protocol/test/unit/test_full_staking_balance_repr.ml @@ -45,7 +45,7 @@ let equal_full_staking_balance (a : Full_staking_balance_repr.t) (b : Full_staking_balance_repr.t) = let open Lwt_result_syntax in let open Full_staking_balance_repr in - let open Full_staking_balance_repr.Internal_for_tests in + let open Full_staking_balance_repr.Internal_for_tests_and_RPCs in let equal_tez_repr ~loc a b = Assert.equal_int64 ~loc (Tez_repr.to_mutez a) (Tez_repr.to_mutez b) in @@ -65,10 +65,12 @@ let equal_full_staking_balance (a : Full_staking_balance_repr.t) (min_delegated_in_cycle b) in let* () = - equal_cycle_repr - ~loc:__LOC__ - (cycle_of_min_delegated a) - (cycle_of_min_delegated b) + let cycle s = + match level_of_min_delegated s with + | None -> Cycle_repr.root + | Some l -> l.cycle + in + equal_cycle_repr ~loc:__LOC__ (cycle a) (cycle b) in return_unit @@ -100,7 +102,7 @@ let test_encodings () = ~own_frozen ~staked_frozen ~delegated - ~current_cycle:Cycle_repr.root + ~current_level:Level_repr.Internal_for_tests.root in let encoding = Full_staking_balance_repr.encoding in let sb_bytes = Binary.to_bytes_exn encoding staking_balance in -- GitLab From d078c5d5250ea2005274036a0ebdd74f7be750f9 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Mon, 18 Mar 2024 16:33:47 +0100 Subject: [PATCH 4/4] tezt/RPC: reset regression --- ...lient) RPC regression tests- delegates.out | 6 +++- ...light) RPC regression tests- delegates.out | 6 +++- ...proxy) RPC regression tests- delegates.out | 6 +++- ...a_dir) RPC regression tests- delegates.out | 6 +++- ...r_rpc) RPC regression tests- delegates.out | 6 +++- ... - delegate - consensus - destination).out | 33 +++++++++++++++---- ...- delegate - consensus -- destination).out | 33 +++++++++++++++---- ...-- delegate - consensus - destination).out | 33 +++++++++++++++---- ...- delegate - consensus -- destination).out | 33 +++++++++++++++---- ...lpha- Test register with consensus key.out | 12 +++++-- ... set consensus key - baker is delegate.out | 18 ++++++++-- ... consensus key - baker is not delegate.out | 18 ++++++++-- 12 files changed, 172 insertions(+), 38 deletions(-) diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out index c1abbfa75d2a..29602dc55a14 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- delegates.out @@ -21,7 +21,11 @@ "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 5, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out index 746c00447034..d3577edcf2c1 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- delegates.out @@ -21,7 +21,11 @@ "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 5, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out index 71334ef90f47..6982ef2ae258 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- delegates.out @@ -21,7 +21,11 @@ "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 5, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out index c1abbfa75d2a..29602dc55a14 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_data_dir) RPC regression tests- delegates.out @@ -21,7 +21,11 @@ "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 5, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out index c1abbfa75d2a..29602dc55a14 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy_server_rpc) RPC regression tests- delegates.out @@ -21,7 +21,11 @@ "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 5, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out index 5cdd1a09377a..6c45d78fb530 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus - destination).out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001595660", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -65,7 +77,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001595660", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -106,8 +122,13 @@ This sequence of operations was run: { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", "frozen_deposits": "200000083983", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "4", - "deactivated": false, "grace_period": 4, "pending_denunciations": false, + "delegated_balance": "0", + "min_delegated_in_current_cycle": + { "amount": "4", + "level": + { "level": 9, "level_position": 8, "cycle": 2, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, + "grace_period": 4, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out index 945261d8da9e..181861305420 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker - delegate - consensus -- destination).out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001595660", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -65,7 +77,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001595660", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -106,8 +122,13 @@ This sequence of operations was run: { "full_balance": "238000528932", "current_frozen_deposits": "200000181573", "frozen_deposits": "200000083983", "staking_balance": "238000528932", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "4", - "deactivated": false, "grace_period": 4, "pending_denunciations": false, + "delegated_balance": "0", + "min_delegated_in_current_cycle": + { "amount": "4", + "level": + { "level": 9, "level_position": 8, "cycle": 2, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, + "grace_period": 4, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out index e86e3964537f..3a0272bda3bb 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus - destination).out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001278724", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -65,7 +77,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001278724", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -106,8 +122,13 @@ This sequence of operations was run: { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", "frozen_deposits": "200000067302", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "18", - "deactivated": false, "grace_period": 4, "pending_denunciations": false, + "delegated_balance": "0", + "min_delegated_in_current_cycle": + { "amount": "18", + "level": + { "level": 9, "level_position": 8, "cycle": 2, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, + "grace_period": 4, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out index f845c4c2c4ee..77a75198688f 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test drain delegate with (baker -- delegate - consensus -- destination).out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001278724", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -65,7 +77,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001278724", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -106,8 +122,13 @@ This sequence of operations was run: { "full_balance": "238000509096", "current_frozen_deposits": "200000164892", "frozen_deposits": "200000067302", "staking_balance": "238000509096", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "18", - "deactivated": false, "grace_period": 4, "pending_denunciations": false, + "delegated_balance": "0", + "min_delegated_in_current_cycle": + { "amount": "18", + "level": + { "level": 9, "level_position": 8, "cycle": 2, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, + "grace_period": 4, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out index 668993b15b0e..4430708cc746 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test register with consensus key.out @@ -64,8 +64,13 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "0", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "999999999385", - "deactivated": false, "grace_period": 3, "pending_denunciations": false, + "delegated_balance": "0", + "min_delegated_in_current_cycle": + { "amount": "999999999385", + "level": + { "level": 3, "level_position": 2, "cycle": 0, "cycle_position": 2, + "expected_commitment": false } }, "deactivated": false, + "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]", "pending_consensus_keys": @@ -78,7 +83,8 @@ This sequence of operations was run: { "full_balance": "999999999385", "current_frozen_deposits": "49999999970", "frozen_deposits": "0", "staking_balance": "999999999385", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], - "delegated_balance": "0", "min_delegated_in_current_cycle": "949999999415", + "delegated_balance": "0", + "min_delegated_in_current_cycle": { "amount": "949999999415" }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "active_consensus_key": "[PUBLIC_KEY_HASH]" } diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out index ce52bbd3718f..b410b3ee2c9e 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is delegate.out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000333333", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000003298113", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001595660", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001595660", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, diff --git a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out index f4f8eb4a0091..bc49237f11bc 100644 --- a/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out +++ b/tezt/tests/expected/consensus_key.ml/Alpha- Test set consensus key - baker is not delegate.out @@ -30,7 +30,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000000000000", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800000000000", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800000000000", + "level": + { "level": 1, "level_position": 0, "cycle": 0, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -41,7 +45,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "3999999999716", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3799999999716", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3799999999716", + "level": + { "level": 2, "level_position": 1, "cycle": 0, "cycle_position": 1, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, @@ -54,7 +62,11 @@ This sequence of operations was run: "frozen_deposits": "200000000000", "staking_balance": "4000002964496", "delegated_contracts": [ "[PUBLIC_KEY_HASH]" ], "delegated_balance": "0", - "min_delegated_in_current_cycle": "3800001278724", "deactivated": false, + "min_delegated_in_current_cycle": + { "amount": "3800001278724", + "level": + { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, + "expected_commitment": false } }, "deactivated": false, "grace_period": 3, "pending_denunciations": false, "total_delegated_stake": "0", "staking_denominator": "0", "voting_power": "4000000000000", "remaining_proposals": 20, -- GitLab