From 5cc012019c9a602fdf7ec69109e482098622f912 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Mon, 11 Aug 2025 15:32:46 +0200 Subject: [PATCH 01/17] Proto/Tests: mv is_inactive to scenario_activity --- .../test/helpers/scenario_activity.ml | 20 +++++++++++++------ .../test/helpers/scenario_bake.ml | 7 +------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml index 264b2f858072..30598ac72833 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml @@ -8,11 +8,22 @@ open State_account open State +let is_inactive constants current_activity_cycle account = + let tolerated_inactivity_period = + constants + .Protocol.Alpha_context.Constants.Parametric.tolerated_inactivity_period + in + match account.last_seen_activity with + | None -> assert false (* delegates have a minimum activity cycle *) + | Some last_seen_activity_cycle -> + Cycle.( + add last_seen_activity_cycle tolerated_inactivity_period + < current_activity_cycle) + let update_activity_account constants current_activity_cycle account = let consensus_rights_delay = constants.Protocol.Alpha_context.Constants.Parametric.consensus_rights_delay in - let tolerated_inactivity_period = constants.tolerated_inactivity_period in let last_seen_activity = (* When a delegate is initialized or reactivated (either from [set_delegate] or participating in the consensus again), we put @@ -22,11 +33,8 @@ let update_activity_account constants current_activity_cycle account = | None -> Cycle.add current_activity_cycle consensus_rights_delay | Some last_seen_activity_cycle -> let updated = - if - Cycle.( - add last_seen_activity_cycle tolerated_inactivity_period - < current_activity_cycle) - then Cycle.add current_activity_cycle consensus_rights_delay + if is_inactive constants current_activity_cycle account then + Cycle.add current_activity_cycle consensus_rights_delay else current_activity_cycle in Cycle.max last_seen_activity_cycle updated diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml index 8328e923c459..01b51f1e3a78 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml @@ -153,12 +153,7 @@ let check_misc _full_metadata (block, state) : unit tzresult Lwt.t = else Cycle.succ current_cycle in let deactivated = - match account.last_seen_activity with - | None -> assert false (* delegates have a minimum activity cycle *) - | Some activity_cycle -> - Cycle.( - add activity_cycle state.constants.tolerated_inactivity_period) - < ctxt_cycle + Scenario_activity.is_inactive state.constants ctxt_cycle account in let*! r3 = Assert.equal_bool ~loc:__LOC__ deactivated deactivated_rpc -- GitLab From 375523e9c5c4c1b7d5f8dfd2903895c5b88d0503 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 4 Apr 2025 22:49:45 +0200 Subject: [PATCH 02/17] proto/stake_storage: refacto - mv selected distribution in a separate module This will allow to access the distribution from dependencies of stake_storage --- src/proto_alpha/lib_protocol/TEZOS_PROTOCOL | 3 +- src/proto_alpha/lib_protocol/dune | 12 ++- .../selected_distribution_storage.ml | 95 +++++++++++++++++++ .../selected_distribution_storage.mli | 57 +++++++++++ src/proto_alpha/lib_protocol/stake_storage.ml | 89 +---------------- 5 files changed, 163 insertions(+), 93 deletions(-) create mode 100644 src/proto_alpha/lib_protocol/selected_distribution_storage.ml create mode 100644 src/proto_alpha/lib_protocol/selected_distribution_storage.mli diff --git a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL index a79880431053..d66f75933320 100644 --- a/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/TEZOS_PROTOCOL @@ -149,7 +149,6 @@ "Nonce_storage", "Seed_storage", "Contract_manager_storage", - "Delegate_activation_storage", "Sapling_storage_costs_generated", "Sapling_storage_costs", "Sapling_storage", @@ -159,6 +158,8 @@ "Cache_repr_costs_generated", "Cache_repr_costs", "Cache_repr", + "Selected_distribution_storage", + "Delegate_activation_storage", "Zk_rollup_storage", diff --git a/src/proto_alpha/lib_protocol/dune b/src/proto_alpha/lib_protocol/dune index fa81fbafe08b..5bfafdb0b469 100644 --- a/src/proto_alpha/lib_protocol/dune +++ b/src/proto_alpha/lib_protocol/dune @@ -168,7 +168,6 @@ Nonce_storage Seed_storage Contract_manager_storage - Delegate_activation_storage Sapling_storage_costs_generated Sapling_storage_costs Sapling_storage @@ -178,6 +177,8 @@ Cache_repr_costs_generated Cache_repr_costs Cache_repr + Selected_distribution_storage + Delegate_activation_storage Zk_rollup_storage Stake_context Adaptive_issuance_costs @@ -463,7 +464,6 @@ nonce_storage.ml nonce_storage.mli seed_storage.ml seed_storage.mli contract_manager_storage.ml contract_manager_storage.mli - delegate_activation_storage.ml delegate_activation_storage.mli sapling_storage_costs_generated.ml sapling_storage_costs.ml sapling_storage.ml @@ -473,6 +473,8 @@ cache_repr_costs_generated.ml cache_repr_costs.ml cache_repr.ml cache_repr.mli + selected_distribution_storage.ml selected_distribution_storage.mli + delegate_activation_storage.ml delegate_activation_storage.mli zk_rollup_storage.ml zk_rollup_storage.mli stake_context.ml stake_context.mli adaptive_issuance_costs.ml adaptive_issuance_costs.mli @@ -760,7 +762,6 @@ nonce_storage.ml nonce_storage.mli seed_storage.ml seed_storage.mli contract_manager_storage.ml contract_manager_storage.mli - delegate_activation_storage.ml delegate_activation_storage.mli sapling_storage_costs_generated.ml sapling_storage_costs.ml sapling_storage.ml @@ -770,6 +771,8 @@ cache_repr_costs_generated.ml cache_repr_costs.ml cache_repr.ml cache_repr.mli + selected_distribution_storage.ml selected_distribution_storage.mli + delegate_activation_storage.ml delegate_activation_storage.mli zk_rollup_storage.ml zk_rollup_storage.mli stake_context.ml stake_context.mli adaptive_issuance_costs.ml adaptive_issuance_costs.mli @@ -1041,7 +1044,6 @@ nonce_storage.ml nonce_storage.mli seed_storage.ml seed_storage.mli contract_manager_storage.ml contract_manager_storage.mli - delegate_activation_storage.ml delegate_activation_storage.mli sapling_storage_costs_generated.ml sapling_storage_costs.ml sapling_storage.ml @@ -1051,6 +1053,8 @@ cache_repr_costs_generated.ml cache_repr_costs.ml cache_repr.ml cache_repr.mli + selected_distribution_storage.ml selected_distribution_storage.mli + delegate_activation_storage.ml delegate_activation_storage.mli zk_rollup_storage.ml zk_rollup_storage.mli stake_context.ml stake_context.mli adaptive_issuance_costs.ml adaptive_issuance_costs.mli diff --git a/src/proto_alpha/lib_protocol/selected_distribution_storage.ml b/src/proto_alpha/lib_protocol/selected_distribution_storage.ml new file mode 100644 index 000000000000..8b3785499714 --- /dev/null +++ b/src/proto_alpha/lib_protocol/selected_distribution_storage.ml @@ -0,0 +1,95 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* Copyright (c) 2021 Nomadic Labs, *) +(* *) +(*****************************************************************************) + +module Selected_distribution_for_cycle = struct + module Cache_client = struct + type cached_value = (Signature.Public_key_hash.t * Stake_repr.t) list + + let namespace = Cache_repr.create_namespace "stake_distribution" + + let cache_index = 1 + + let value_of_identifier ctxt identifier = + let cycle = Cycle_repr.of_string_exn identifier in + Storage.Stake.Selected_distribution_for_cycle.get ctxt cycle + end + + module Cache = (val Cache_repr.register_exn (module Cache_client)) + + let identifier_of_cycle cycle = Format.asprintf "%a" Cycle_repr.pp cycle + + let init ctxt cycle stakes = + let open Lwt_result_syntax in + let id = identifier_of_cycle cycle in + let* ctxt = + Storage.Stake.Selected_distribution_for_cycle.init ctxt cycle stakes + in + let size = + 1 + (* that's symbolic: 1 cycle = 1 entry *) + in + let*? ctxt = Cache.update ctxt id (Some (stakes, size)) in + return ctxt + + let get ctxt cycle = + let open Lwt_result_syntax in + let id = identifier_of_cycle cycle in + let* value_opt = Cache.find ctxt id in + match value_opt with + | None -> Storage.Stake.Selected_distribution_for_cycle.get ctxt cycle + | Some v -> return v + + let find ctxt cycle = + let open Lwt_result_syntax in + let id = identifier_of_cycle cycle in + let* value_opt = Cache.find ctxt id in + match value_opt with + | None -> Storage.Stake.Selected_distribution_for_cycle.find ctxt cycle + | Some _ as some_v -> return some_v + + let remove_existing ctxt cycle = + let open Lwt_result_syntax in + 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 + + let remove ctxt cycle = + let open Lwt_result_syntax in + let id = identifier_of_cycle cycle in + let*? ctxt = Cache.update ctxt id None in + let*! ctxt = + Storage.Stake.Selected_distribution_for_cycle.remove ctxt cycle + in + return ctxt +end + +let set_selected_distribution_for_cycle ctxt cycle stakes total_stake = + let open Lwt_result_syntax in + 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 + return ctxt + +let get_selected_distribution = Selected_distribution_for_cycle.get + +let find_selected_distribution = Selected_distribution_for_cycle.find + +let get_selected_distribution_as_map ctxt cycle = + let open Lwt_result_syntax in + let+ stakes = Selected_distribution_for_cycle.get ctxt cycle in + List.fold_left + (fun map (pkh, stake) -> Signature.Public_key_hash.Map.add pkh stake map) + Signature.Public_key_hash.Map.empty + stakes + +let prepare_stake_distribution ctxt = + let open Lwt_result_syntax in + let level = Level_storage.current ctxt in + let+ stake_distribution = get_selected_distribution_as_map ctxt level.cycle in + Raw_context.init_stake_distribution_for_current_cycle ctxt stake_distribution + +let get_total_active_stake = Storage.Stake.Total_active_stake.get diff --git a/src/proto_alpha/lib_protocol/selected_distribution_storage.mli b/src/proto_alpha/lib_protocol/selected_distribution_storage.mli new file mode 100644 index 000000000000..1c48b17c7e7e --- /dev/null +++ b/src/proto_alpha/lib_protocol/selected_distribution_storage.mli @@ -0,0 +1,57 @@ +(*****************************************************************************) +(* *) +(* SPDX-License-Identifier: MIT *) +(* Copyright (c) 2021 Nomadic Labs, *) +(* *) +(*****************************************************************************) +module Selected_distribution_for_cycle : sig + val identifier_of_cycle : Cycle_repr.cycle -> string + + val init : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list -> + Raw_context.t tzresult Lwt.t + + val get : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list tzresult Lwt.t + + val find : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list option tzresult Lwt.t + + val remove_existing : + Raw_context.t -> Cycle_repr.cycle -> Raw_context.t tzresult Lwt.t + + val remove : Raw_context.t -> Cycle_repr.cycle -> Raw_context.t tzresult Lwt.t +end + +val set_selected_distribution_for_cycle : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list -> + Stake_repr.t -> + Raw_context.t tzresult Lwt.t + +val get_selected_distribution : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list tzresult Lwt.t + +val find_selected_distribution : + Raw_context.t -> + Cycle_repr.cycle -> + (Signature.public_key_hash * Stake_repr.t) list option tzresult Lwt.t + +val get_selected_distribution_as_map : + Raw_context.t -> + Cycle_repr.cycle -> + Stake_repr.t Signature.Public_key_hash.Map.t tzresult Lwt.t + +val prepare_stake_distribution : Raw_context.t -> Raw_context.t tzresult Lwt.t + +val get_total_active_stake : + Raw_context.t -> Cycle_repr.t -> Stake_repr.t tzresult Lwt.t diff --git a/src/proto_alpha/lib_protocol/stake_storage.ml b/src/proto_alpha/lib_protocol/stake_storage.ml index 318aa5cfff7e..12fcad37c15c 100644 --- a/src/proto_alpha/lib_protocol/stake_storage.ml +++ b/src/proto_alpha/lib_protocol/stake_storage.ml @@ -23,67 +23,7 @@ (* *) (*****************************************************************************) -module Selected_distribution_for_cycle = struct - module Cache_client = struct - type cached_value = (Signature.Public_key_hash.t * Stake_repr.t) list - - let namespace = Cache_repr.create_namespace "stake_distribution" - - let cache_index = 1 - - let value_of_identifier ctxt identifier = - let cycle = Cycle_repr.of_string_exn identifier in - Storage.Stake.Selected_distribution_for_cycle.get ctxt cycle - end - - module Cache = (val Cache_repr.register_exn (module Cache_client)) - - let identifier_of_cycle cycle = Format.asprintf "%a" Cycle_repr.pp cycle - - let init ctxt cycle stakes = - let open Lwt_result_syntax in - let id = identifier_of_cycle cycle in - let* ctxt = - Storage.Stake.Selected_distribution_for_cycle.init ctxt cycle stakes - in - let size = - 1 - (* that's symbolic: 1 cycle = 1 entry *) - in - let*? ctxt = Cache.update ctxt id (Some (stakes, size)) in - return ctxt - - let get ctxt cycle = - let open Lwt_result_syntax in - let id = identifier_of_cycle cycle in - let* value_opt = Cache.find ctxt id in - match value_opt with - | None -> Storage.Stake.Selected_distribution_for_cycle.get ctxt cycle - | Some v -> return v - - let find ctxt cycle = - let open Lwt_result_syntax in - let id = identifier_of_cycle cycle in - let* value_opt = Cache.find ctxt id in - match value_opt with - | None -> Storage.Stake.Selected_distribution_for_cycle.find ctxt cycle - | Some _ as some_v -> return some_v - - let remove_existing ctxt cycle = - let open Lwt_result_syntax in - 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 - - let remove ctxt cycle = - let open Lwt_result_syntax in - let id = identifier_of_cycle cycle in - let*? ctxt = Cache.update ctxt id None in - let*! ctxt = - Storage.Stake.Selected_distribution_for_cycle.remove ctxt cycle - in - return ctxt -end +include Selected_distribution_storage let get_full_staking_balance = Storage.Stake.Staking_balance.get @@ -225,13 +165,6 @@ let set_active ctxt delegate = return ctxt else return ctxt -let set_selected_distribution_for_cycle ctxt cycle stakes total_stake = - let open Lwt_result_syntax in - 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 - return ctxt - let fold_on_active_delegates_with_minimal_stake_es ctxt ~f ~order ~init = let open Lwt_result_syntax in Storage.Stake.Active_delegates_with_minimal_stake.fold @@ -255,26 +188,6 @@ let clear_at_cycle_end ctxt ~new_cycle = let fold_on_active_delegates_with_minimal_stake_s = Storage.Stake.Active_delegates_with_minimal_stake.fold -let get_selected_distribution = Selected_distribution_for_cycle.get - -let find_selected_distribution = Selected_distribution_for_cycle.find - -let get_selected_distribution_as_map ctxt cycle = - let open Lwt_result_syntax in - let+ stakes = Selected_distribution_for_cycle.get ctxt cycle in - List.fold_left - (fun map (pkh, stake) -> Signature.Public_key_hash.Map.add pkh stake map) - Signature.Public_key_hash.Map.empty - stakes - -let prepare_stake_distribution ctxt = - let open Lwt_result_syntax in - let level = Level_storage.current ctxt in - let+ stake_distribution = get_selected_distribution_as_map ctxt level.cycle in - Raw_context.init_stake_distribution_for_current_cycle ctxt stake_distribution - -let get_total_active_stake = Storage.Stake.Total_active_stake.get - let remove_contract_delegated_stake ctxt contract amount = let open Lwt_result_syntax in let* delegate_opt = Contract_delegate_storage.find ctxt contract in -- GitLab From 5c8cc366ac54eecf3660665f00aa390a817dc88b Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 4 Apr 2025 21:29:58 +0200 Subject: [PATCH 03/17] proto: add new parametric constants tolerated_inactivity_period_(high|low|threshold) --- .../lib_parameters/default_parameters.ml | 17 ++++++++++- .../lib_protocol/alpha_context.mli | 3 ++ .../lib_protocol/constants_parametric_repr.ml | 23 ++++++++++++--- .../constants_parametric_repr.mli | 3 ++ .../lib_protocol/constants_storage.ml | 15 +++++++++- .../lib_protocol/constants_storage.mli | 10 ++++++- src/proto_alpha/lib_protocol/raw_context.ml | 29 ++++++++++++++++--- 7 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index b8dc5a2ae602..41f28e9c6777 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -272,8 +272,23 @@ let constants_mainnet : Constants.Parametric.t = first [consensus_rights_delay] cycles, so of course the chain will not witness any activity from it then. - Last updated in protocol R. *) + [tolerated_inactivity_period] depends on the delegate's stake + ratio over the total active stake. If the ratio is greater than + the [tolerated_inactivity_period_threshold] (expressed in 'per + thousand'), we apply a low tolerance + [tolerated_inactivity_period_low]. Otherwise, we apply a high + tolerance [tolerated_inactivity_period_high]. If the stake is + unknown, we apply a low tolerance (e.g., after the delegate's + registration, reactivation, or decreasing its stake below + [minimal_stake]). + + Last updated in protocol T. *) + (* to be removed *) tolerated_inactivity_period = 2; + tolerated_inactivity_period_high = 12; + tolerated_inactivity_period_low = 1; + (* threshold is in per thousand *) + tolerated_inactivity_period_threshold = 10; (* [blocks_per_cycle] is the duration of a cycle in number of blocks. Multiply it by [minimal_block_delay] to get the minimal duration of a cycle in seconds. diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 33b37f556a96..ee535f7187e2 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -924,6 +924,9 @@ module Constants : sig blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; tolerated_inactivity_period : int; + tolerated_inactivity_period_high : int; + tolerated_inactivity_period_low : int; + tolerated_inactivity_period_threshold : int; blocks_per_cycle : int32; blocks_per_commitment : int32; nonce_revelation_threshold : int32; diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index 4450769df8bd..d599fec500df 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -260,6 +260,9 @@ type t = { blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; tolerated_inactivity_period : int; + tolerated_inactivity_period_high : int; + tolerated_inactivity_period_low : int; + tolerated_inactivity_period_threshold : int; blocks_per_cycle : int32; blocks_per_commitment : int32; nonce_revelation_threshold : int32; @@ -567,7 +570,10 @@ let encoding = ( ( ( c.consensus_rights_delay, c.blocks_preservation_cycles, c.delegate_parameters_activation_delay, - c.tolerated_inactivity_period ), + c.tolerated_inactivity_period, + c.tolerated_inactivity_period_high, + c.tolerated_inactivity_period_low, + c.tolerated_inactivity_period_threshold ), ( c.blocks_per_cycle, c.blocks_per_commitment, c.nonce_revelation_threshold, @@ -612,7 +618,10 @@ let encoding = (fun ( ( ( consensus_rights_delay, blocks_preservation_cycles, delegate_parameters_activation_delay, - tolerated_inactivity_period ), + tolerated_inactivity_period, + tolerated_inactivity_period_high, + tolerated_inactivity_period_low, + tolerated_inactivity_period_threshold ), ( blocks_per_cycle, blocks_per_commitment, nonce_revelation_threshold, @@ -660,6 +669,9 @@ let encoding = blocks_preservation_cycles; delegate_parameters_activation_delay; tolerated_inactivity_period; + tolerated_inactivity_period_high; + tolerated_inactivity_period_low; + tolerated_inactivity_period_threshold; blocks_per_cycle; blocks_per_commitment; nonce_revelation_threshold; @@ -705,11 +717,14 @@ let encoding = }) (merge_objs (merge_objs - (obj4 + (obj7 (req "consensus_rights_delay" uint8) (req "blocks_preservation_cycles" uint8) (req "delegate_parameters_activation_delay" uint8) - (req "tolerated_inactivity_period" uint8)) + (req "tolerated_inactivity_period" uint8) + (req "tolerated_inactivity_period_high" uint8) + (req "tolerated_inactivity_period_low" uint8) + (req "tolerated_inactivity_period_threshold" uint8)) (obj8 (req "blocks_per_cycle" int32) (req "blocks_per_commitment" int32) diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 811789f166c4..355fd06a4de4 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -212,6 +212,9 @@ type t = { blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; tolerated_inactivity_period : int; + tolerated_inactivity_period_high : int; + tolerated_inactivity_period_low : int; + tolerated_inactivity_period_threshold : int; blocks_per_cycle : int32; blocks_per_commitment : int32; nonce_revelation_threshold : int32; diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index ce92bd32d4e9..bf141e3c4208 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -45,11 +45,24 @@ let adaptive_issuance_activation_delay c = let constants = Raw_context.constants c in 1 + constants.consensus_rights_delay + Constants_repr.slashing_delay + 1 -(** Tolerated inactivity period for delegates before being deactivated. *) +(** Tolerated inactivity periods for delegates before being deactivated. *) +let tolerated_inactivity_period_high c = + let constants = Raw_context.constants c in + constants.tolerated_inactivity_period_high + +let tolerated_inactivity_period_low c = + let constants = Raw_context.constants c in + constants.tolerated_inactivity_period_low + +(* temporary, to introduce new constants incrementally *) let tolerated_inactivity_period c = let constants = Raw_context.constants c in constants.tolerated_inactivity_period +let tolerated_inactivity_period_threshold c = + let constants = Raw_context.constants c in + constants.tolerated_inactivity_period_threshold + (** Number of cycles during which a misbehavior of the delegate will induce a slashing of the funds that are currently in its frozen deposits. *) let slashable_deposits_period c = diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 032bd2572ca5..20505c3c93a7 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -157,9 +157,17 @@ val direct_ticket_spending_enable : Raw_context.t -> bool val allow_tz4_delegate_enable : Raw_context.t -> bool +(** Temporary value to be removed when discriminated inactivity tolerance is + implemented *) +val tolerated_inactivity_period : Raw_context.t -> int + (** Tolerated period of inactivity, in cycles, before a delegate is deactivated *) -val tolerated_inactivity_period : Raw_context.t -> int +val tolerated_inactivity_period_high : Raw_context.t -> int + +val tolerated_inactivity_period_low : Raw_context.t -> int + +val tolerated_inactivity_period_threshold : Raw_context.t -> int (* attestation aggregation feature flag *) val aggregate_attestation : Raw_context.t -> bool diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 733bf7a24b17..2bd327160c3a 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -1024,6 +1024,7 @@ type delays = { blocks_per_cycle : int32; delegate_parameters_activation_delay : int; cycles_per_voting_period : int32; + tolerated_inactivity_period : int; blocks_per_commitment : int32; nonce_revelation_threshold : int32; vdf_difficulty : int64; @@ -1070,10 +1071,16 @@ let new_constants_four_hours_cycles ~preserve_duration_in_days let cycles_per_voting_period = preserve_duration previous_delays.cycles_per_voting_period in + let tolerated_inactivity_period = + Int32.to_int + @@ preserve_duration + (Int32.of_int previous_delays.tolerated_inactivity_period) + in { blocks_per_cycle; delegate_parameters_activation_delay; cycles_per_voting_period; + tolerated_inactivity_period; blocks_per_commitment; nonce_revelation_threshold; vdf_difficulty; @@ -1303,6 +1310,9 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = blocks_preservation_cycles; delegate_parameters_activation_delay; tolerated_inactivity_period; + tolerated_inactivity_period_high; + tolerated_inactivity_period_low; + tolerated_inactivity_period_threshold; blocks_per_cycle; blocks_per_commitment; nonce_revelation_threshold; @@ -1355,6 +1365,9 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = blocks_preservation_cycles; delegate_parameters_activation_delay; tolerated_inactivity_period; + tolerated_inactivity_period_high; + tolerated_inactivity_period_low; + tolerated_inactivity_period_threshold; blocks_per_cycle; blocks_per_commitment; nonce_revelation_threshold; @@ -1654,6 +1667,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = blocks_per_cycle; delegate_parameters_activation_delay; cycles_per_voting_period; + tolerated_inactivity_period; blocks_per_commitment; nonce_revelation_threshold; vdf_difficulty; @@ -1663,6 +1677,7 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = blocks_per_cycle; blocks_per_commitment; delegate_parameters_activation_delay; + tolerated_inactivity_period; cycles_per_voting_period; nonce_revelation_threshold; vdf_difficulty; @@ -1670,9 +1685,10 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = in if is_new_constants then (* we keep the same duration in days for the - [cycles_per_voting_period] and - [delegate_parameters_activation_delay] protocol - constants on mainnet *) + [cycles_per_voting_period], + [delegate_parameters_activation_delay], + [tolerated_inactivity_period] protocol constants on + mainnet *) let preserve_duration_in_days = Compare.Int64.(Period_repr.to_seconds c.minimal_block_delay = 8L) in @@ -1695,13 +1711,18 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = ~new_blocks_per_commitment:blocks_per_commitment else return ctxt in - let consensus_rights_delay = 1 in let constants = + let consensus_rights_delay = 1 in + let tolerated_inactivity_period_high = tolerated_inactivity_period in + let tolerated_inactivity_period_low = 1 in { Constants_parametric_repr.consensus_rights_delay; blocks_preservation_cycles; delegate_parameters_activation_delay; tolerated_inactivity_period; + tolerated_inactivity_period_high; + tolerated_inactivity_period_low; + tolerated_inactivity_period_threshold = 10; blocks_per_cycle; blocks_per_commitment; nonce_revelation_threshold; -- GitLab From 27e862610f0fa722a3f3ff3e0443098287677ec9 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Thu, 24 Apr 2025 22:18:46 +0200 Subject: [PATCH 04/17] proto/tests: adapt period correlation test --- .../test/integration/test_constants.ml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml index 70769f548db5..aa7e2f4ea8e6 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_constants.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_constants.ml @@ -193,12 +193,22 @@ let () = ~duration:(Days 5l) let () = - register_test ~title:"tolerated inactivity period is 8 hours" @@ fun () -> + register_test ~title:"tolerated inactivity period is 2 days for small bakers" + @@ fun () -> + let constants = Default_parameters.constants_mainnet in + check_protocol_time_correlation + ~constants + ~cycles:(Int32.of_int constants.tolerated_inactivity_period_high) + ~duration:(Days 2l) + +let () = + register_test ~title:"tolerated inactivity period is 4 hours for big bakers" + @@ fun () -> let constants = Default_parameters.constants_mainnet in check_protocol_time_correlation ~constants - ~cycles:(Int32.of_int constants.tolerated_inactivity_period) - ~duration:(Hours 8l) + ~cycles:(Int32.of_int constants.tolerated_inactivity_period_low) + ~duration:(Hours 4l) let () = register_test ~title:"Nonce commitment per cycle is above 128" @@ fun () -> -- GitLab From bbc229399e5880700ae3c68e46cd04ff325cd347 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 4 Apr 2025 22:52:05 +0200 Subject: [PATCH 05/17] proto/delegate_activation: apply differentiated tolerance for inactivity depending on bakers stake power and tolerance threshold, we use either high tolerance or low tolerance. Co-authored-by: Marina Polubelova --- .../lib_protocol/alpha_context.mli | 2 - .../lib_protocol/constants_storage.ml | 5 -- .../lib_protocol/constants_storage.mli | 4 -- .../delegate_activation_storage.ml | 68 ++++++++++++++++++- 4 files changed, 65 insertions(+), 14 deletions(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index ee535f7187e2..a75a5cd15f3e 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1007,8 +1007,6 @@ module Constants : sig val delegate_parameters_activation_delay : context -> int - val tolerated_inactivity_period : context -> int - val slashable_deposits_period : context -> int (** See {!Constants_storage.unstake_finalization_delay}. *) diff --git a/src/proto_alpha/lib_protocol/constants_storage.ml b/src/proto_alpha/lib_protocol/constants_storage.ml index bf141e3c4208..db6b258f0998 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.ml +++ b/src/proto_alpha/lib_protocol/constants_storage.ml @@ -54,11 +54,6 @@ let tolerated_inactivity_period_low c = let constants = Raw_context.constants c in constants.tolerated_inactivity_period_low -(* temporary, to introduce new constants incrementally *) -let tolerated_inactivity_period c = - let constants = Raw_context.constants c in - constants.tolerated_inactivity_period - let tolerated_inactivity_period_threshold c = let constants = Raw_context.constants c in constants.tolerated_inactivity_period_threshold diff --git a/src/proto_alpha/lib_protocol/constants_storage.mli b/src/proto_alpha/lib_protocol/constants_storage.mli index 20505c3c93a7..fc838230a954 100644 --- a/src/proto_alpha/lib_protocol/constants_storage.mli +++ b/src/proto_alpha/lib_protocol/constants_storage.mli @@ -157,10 +157,6 @@ val direct_ticket_spending_enable : Raw_context.t -> bool val allow_tz4_delegate_enable : Raw_context.t -> bool -(** Temporary value to be removed when discriminated inactivity tolerance is - implemented *) -val tolerated_inactivity_period : Raw_context.t -> int - (** Tolerated period of inactivity, in cycles, before a delegate is deactivated *) val tolerated_inactivity_period_high : Raw_context.t -> int diff --git a/src/proto_alpha/lib_protocol/delegate_activation_storage.ml b/src/proto_alpha/lib_protocol/delegate_activation_storage.ml index f1778351f5eb..f35602d3f9ff 100644 --- a/src/proto_alpha/lib_protocol/delegate_activation_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_activation_storage.ml @@ -23,6 +23,68 @@ (* *) (*****************************************************************************) +(** Tolerated inactivity period depends on the delegate's stake ratio + over the total active stake. + + If the stake is unknown, it means that the baker had no staking + rights for the current cycle. In this case, the call to + [set_active] is subsequent to a delegate registration or + reactivation. As we do not know its future weight in the + consensus, we take a conservative approach and assign it a low + tolerance [tolerated_inactivity_period_low]. + + If the ratio is greater than the threshold (expressed in 'per + thousand'), we apply a low tolerance. Otherwise, we apply a high + tolerance. *) +let tolerated_inactivity_period ctxt delegate = + let open Lwt_result_syntax in + let tolerance_threshold = + Constants_storage.tolerated_inactivity_period_threshold ctxt + in + let tolerance_low = Constants_storage.tolerated_inactivity_period_low ctxt in + let tolerance_high = + Constants_storage.tolerated_inactivity_period_high ctxt + in + let current_cycle = Cycle_storage.current ctxt in + if Cycle_repr.(current_cycle = root) then + (* There is no selected distribution at chain initialisation, so + we give a low tolerance *) + return tolerance_low + else + let* delegates_stakes = + Selected_distribution_storage.get_selected_distribution ctxt current_cycle + in + match + List.assoc + ~equal:Signature.Public_key_hash.equal + delegate + delegates_stakes + with + | None -> + (* There is no stake registered at + - a first delegate registration + - a delegate reactivation + - after decreasing its stake below [minimal_stake] + so we give a low tolerance *) + return tolerance_low + | Some delegate_stake -> + let+ total_stake = + Selected_distribution_storage.get_total_active_stake + ctxt + current_cycle + in + let compare_stake_ratio_with_threshold = + Int64.( + compare + (div + (mul 1000L (Stake_repr.staking_weight delegate_stake)) + (Stake_repr.staking_weight total_stake)) + (of_int tolerance_threshold)) + in + if Compare.Int.(compare_stake_ratio_with_threshold > 0) then + tolerance_low + else tolerance_high + let is_inactive ctxt delegate = let open Lwt_result_syntax in let*! inactive = @@ -32,12 +94,12 @@ let is_inactive ctxt delegate = in if inactive then Lwt.return_ok inactive else - let+ cycle_opt = + let* cycle_opt = Storage.Contract.Delegate_last_cycle_before_deactivation.find ctxt (Contract_repr.Implicit delegate) in - let tolerance = Constants_storage.tolerated_inactivity_period ctxt in + let+ tolerance = tolerated_inactivity_period ctxt delegate in match cycle_opt with | Some last_active_cycle -> let ({Level_repr.cycle = current_cycle; _} : Level_repr.t) = @@ -51,7 +113,7 @@ let is_inactive ctxt delegate = let last_cycle_before_deactivation ctxt delegate = let open Lwt_result_syntax in - let tolerance = Constants_storage.tolerated_inactivity_period ctxt in + let* tolerance = tolerated_inactivity_period ctxt delegate in let contract = Contract_repr.Implicit delegate in let+ cycle = Storage.Contract.Delegate_last_cycle_before_deactivation.get ctxt contract -- GitLab From 4a6ecf4c99d663446d74dcd58a9b6ca8971d34b9 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Mon, 18 Aug 2025 10:49:10 +0200 Subject: [PATCH 06/17] Proto/Tests: add stake_info to helpers --- src/proto_alpha/lib_plugin/RPC.ml | 2 ++ src/proto_alpha/lib_protocol/test/helpers/context.ml | 11 +++++++++++ src/proto_alpha/lib_protocol/test/helpers/context.mli | 3 +++ 3 files changed, 16 insertions(+) diff --git a/src/proto_alpha/lib_plugin/RPC.ml b/src/proto_alpha/lib_plugin/RPC.ml index a095557b2623..ead141d208a2 100644 --- a/src/proto_alpha/lib_plugin/RPC.ml +++ b/src/proto_alpha/lib_plugin/RPC.ml @@ -4317,6 +4317,8 @@ let levels_in_current_cycle ctxt ?(offset = 0l) block = let consecutive_round_zero ctxt block = RPC_context.make_call0 S.consecutive_round_zero ctxt block () () +let stake_info ctxt block = RPC_context.make_call0 S.stake_info ctxt block () () + let rpc_services = register () ; RPC_directory.merge rpc_services !Registration.patched_services diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index 15cbceb15706..500902936bcf 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -657,6 +657,17 @@ module Delegate = struct Protocol.Tez_repr.to_mutez weighted_delegated |> Tez.of_mutez_exn in return {frozen; weighted_delegated} + + let stake_info ctxt ~manager_pkh = + let open Lwt_result_wrap_syntax in + let* total_stake, stakes = Plugin.RPC.stake_info rpc_ctxt ctxt in + let stakes = + List.map (fun (ck, stake) -> (ck.Consensus_key.delegate, stake)) stakes + in + let stake_opt = + List.assoc ~equal:Signature.Public_key_hash.equal manager_pkh stakes + in + return (total_stake, stake_opt) end module Sc_rollup = struct diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index cfa96066b9cf..6f8fcb00b7e8 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -349,6 +349,9 @@ module Delegate : sig val is_forbidden : t -> public_key_hash -> bool tzresult Lwt.t val stake_for_cycle : t -> Cycle.t -> public_key_hash -> stake tzresult Lwt.t + + val stake_info : + t -> manager_pkh:public_key_hash -> (int64 * int64 option) tzresult Lwt.t end module Sc_rollup : sig -- GitLab From 39aec13ecbae5d9f30fcd4b67a656957d4ef9c71 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Mon, 18 Aug 2025 11:01:33 +0200 Subject: [PATCH 07/17] Proto/Tests: tolerated_inactivity_period depends on stake weight --- .../test/helpers/scenario_activity.ml | 63 ++++++++++++++----- .../test/helpers/scenario_attestation.ml | 20 +++--- .../test/helpers/scenario_bake.ml | 11 ++-- .../lib_protocol/test/helpers/scenario_op.ml | 10 ++- 4 files changed, 74 insertions(+), 30 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml index 30598ac72833..40c03278292a 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_activity.ml @@ -8,10 +8,36 @@ open State_account open State -let is_inactive constants current_activity_cycle account = - let tolerated_inactivity_period = - constants - .Protocol.Alpha_context.Constants.Parametric.tolerated_inactivity_period +let tolerated_inactivity_period ~block ~state account = + let open Lwt_result_syntax in + let tolerance_threshold = + state.State.constants.tolerated_inactivity_period_threshold + in + let tolerance_low = state.State.constants.tolerated_inactivity_period_low in + let tolerance_high = state.State.constants.tolerated_inactivity_period_high in + let current_cycle = Block.current_cycle block in + if Cycle.(current_cycle = root) then return tolerance_low + else + let+ total_stake, delegate_stake = + Context.Delegate.stake_info (B block) ~manager_pkh:account.pkh + in + match delegate_stake with + | None -> tolerance_low + | Some delegate_stake -> + let compare_stake_ratio_with_threshold = + Int64.( + compare + (div (mul 1000L delegate_stake) total_stake) + (of_int tolerance_threshold)) + in + if Compare.Int.(compare_stake_ratio_with_threshold > 0) then + tolerance_low + else tolerance_high + +let is_inactive ~block ~state current_activity_cycle account = + let open Lwt_result_syntax in + let+ tolerated_inactivity_period = + tolerated_inactivity_period ~block ~state account in match account.last_seen_activity with | None -> assert false (* delegates have a minimum activity cycle *) @@ -20,20 +46,26 @@ let is_inactive constants current_activity_cycle account = add last_seen_activity_cycle tolerated_inactivity_period < current_activity_cycle) -let update_activity_account constants current_activity_cycle account = +let update_activity_account ~block ~state current_activity_cycle name = + let open Lwt_result_syntax in let consensus_rights_delay = - constants.Protocol.Alpha_context.Constants.Parametric.consensus_rights_delay + state.constants + .Protocol.Alpha_context.Constants.Parametric.consensus_rights_delay in - let last_seen_activity = + let account = State.find_account name state in + let+ last_seen_activity = (* When a delegate is initialized or reactivated (either from [set_delegate] or participating in the consensus again), we put extra [consensus_rights_delay] cycles in the future to account for its extended grace period *) match account.last_seen_activity with - | None -> Cycle.add current_activity_cycle consensus_rights_delay + | None -> return @@ Cycle.add current_activity_cycle consensus_rights_delay | Some last_seen_activity_cycle -> + let+ is_inactive = + is_inactive ~block ~state current_activity_cycle account + in let updated = - if is_inactive constants current_activity_cycle account then + if is_inactive then Cycle.add current_activity_cycle consensus_rights_delay else current_activity_cycle in @@ -41,8 +73,11 @@ let update_activity_account constants current_activity_cycle account = in {account with last_seen_activity = Some last_seen_activity} -let update_activity name state current_activity_cycle : State.t = - State.update_account_f - name - (update_activity_account state.constants current_activity_cycle) - state +let update_activity ~block ~state current_activity_cycle name : + State.t tzresult Lwt.t = + let open Lwt_result_syntax in + let+ baker_acc = + update_activity_account ~block ~state current_activity_cycle name + in + let account_map = String.Map.add name baker_acc state.account_map in + {state with account_map} diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_attestation.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_attestation.ml index 8221481c98d5..68a3dfbb0fdb 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_attestation.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_attestation.ml @@ -12,8 +12,12 @@ open Log_helpers open Scenario_base open Protocol -let update_activity name block state : State.t = - Scenario_activity.update_activity name state (Block.cycle_of_next_block block) +let update_activity name block state : State.t tzresult Lwt.t = + Scenario_activity.update_activity + ~block + ~state + (Block.cycle_of_next_block block) + name type kind = Preattestation | Attestation @@ -266,7 +270,7 @@ let attest_with ?dal_content (delegate_name : string) : (t, t) scenarios = (* Fails to produce an attestation if the delegate has no slot for the block *) let* op = Op.attestation ?dal_content ~manager_pkh:delegate.pkh block in (* Update the activity of the delegate *) - let state = update_activity delegate_name block state in + let* state = update_activity delegate_name block state in let state = State.add_pending_operations [op] state in (* Check metadata *) let state = @@ -310,7 +314,7 @@ let attest_aggreg_with (delegates : string list) : (t, t) scenarios = else failwith "Cannot aggregate with non-BLS key" in (* Update the activity of the committee *) - let state = update_activity delegate_name block state in + let* state = update_activity delegate_name block state in let* attesting_slot = Op.get_attesting_slot_of_delegate ~manager_pkh:delegate.pkh @@ -394,7 +398,7 @@ let attest_with_all_ : t -> t tzresult Lwt.t = let delegate_name, _ = State.find_account_from_pkh manager_pkh state in - let state = update_activity delegate_name block state in + let* state = update_activity delegate_name block state in if state.constants.aggregate_attestation && Signature.Public_key_hash.is_bls consensus_pkh @@ -490,7 +494,7 @@ let preattest_with ?payload_round (delegate_name : string) : (* Fails to produce an attestation if the delegate has no slot for the block *) let* op = Op.preattestation ~manager_pkh:delegate.pkh fake_block in (* Update the activity of the delegate *) - let state = + let* state = update_activity delegate_name (Incremental.predecessor incr) state in (* Check metadata *) @@ -536,7 +540,7 @@ let preattest_aggreg_with ?payload_round (delegates : string list) : else failwith "Cannot aggregate non-BLS preattestation" in (* Update the activity of the committee *) - let state = + let* state = update_activity delegate_name (Incremental.predecessor incr) @@ -620,7 +624,7 @@ let preattest_with_all_ ?payload_round : t_incr -> t_incr tzresult Lwt.t = let delegate_name, _ = State.find_account_from_pkh manager_pkh state in - let state = + let* state = update_activity delegate_name (Incremental.predecessor incr) state in if diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml index 01b51f1e3a78..877d76e2d90d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml @@ -152,8 +152,8 @@ let check_misc _full_metadata (block, state) : unit tzresult Lwt.t = if not (Block.last_block_of_cycle block) then current_cycle else Cycle.succ current_cycle in - let deactivated = - Scenario_activity.is_inactive state.constants ctxt_cycle account + let* deactivated = + Scenario_activity.is_inactive ~block ~state ctxt_cycle account in let*! r3 = Assert.equal_bool ~loc:__LOC__ deactivated deactivated_rpc @@ -325,11 +325,12 @@ let finalize_block_ : t_incr -> t tzresult Lwt.t = let baker = Incremental.delegate i in let baker_name, _ = State.find_account_from_pkh baker.pkh state in (* Update baker activity *) - let state = + let* state = Scenario_activity.update_activity - baker_name - state + ~block + ~state (Block.current_cycle block) + baker_name in let* () = check_ai_launch_cycle_is_zero ~loc:__LOC__ block in let* state = State.apply_rewards ~baker:baker_name block state in diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_op.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_op.ml index c1095ea689ca..bf05adda4e7f 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_op.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_op.ml @@ -163,12 +163,16 @@ let set_delegate src_name delegate_name_opt : (t, t) scenarios = in let state = State.update_delegate src_name delegate_name_opt state in (* update delegate activation status *) - let state = + let* state = (* if self delegating *) if Option.equal String.equal delegate_name_opt (Some src_name) then let activity_cycle = current_cycle in - Scenario_activity.update_activity src_name state activity_cycle - else state + Scenario_activity.update_activity + ~block + ~state + activity_cycle + src_name + else return state in return (state, [operation])) -- GitLab From f52d4628ebf3d8d15a774d95ff87408e07551465 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 20 Aug 2025 14:58:32 +0200 Subject: [PATCH 08/17] Proto/Tests: update tests with new tolerated inactivity period --- .../test/helpers/scenario_bake.ml | 9 +++++ .../consensus/test_frozen_deposits.ml | 3 +- .../consensus/test_scenario_attestation.ml | 3 +- .../integration/test_scenario_deactivation.ml | 34 +++++-------------- .../integration/test_scenario_slashing.ml | 6 +++- .../test/integration/test_scenario_stake.ml | 3 +- 6 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml index 877d76e2d90d..aa68f15484c8 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/scenario_bake.ml @@ -595,3 +595,12 @@ let wait_n_cycles_f (n_cycles : t -> int) = let open Lwt_result_syntax in let n_cycles n = return @@ n_cycles n in wait_n_cycles_f_es n_cycles + +let wait_tolerated_inactivity_period ?(cycle_offset = 0) name = + wait_n_cycles_f_es (fun (block, state) -> + let open Lwt_result_syntax in + let account = State.find_account name state in + let* tolerated_inactivity_period = + Scenario_activity.tolerated_inactivity_period ~block ~state account + in + return @@ (tolerated_inactivity_period + cycle_offset)) diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml index 412bb3e831fa..79f51538bb7a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_frozen_deposits.ml @@ -454,7 +454,8 @@ let test_frozen_deposits_with_deactivation () = expected last cycles at which it is considered active and at which it has non-zero deposits *) let last_active_cycle = - constants.tolerated_inactivity_period + constants.consensus_rights_delay + (* at activation, accounts have a low tolerance grace period *) + constants.tolerated_inactivity_period_low + constants.consensus_rights_delay (* according to [Delegate_activation_storage.set_active] *) in let last_cycle_with_deposits = diff --git a/src/proto_alpha/lib_protocol/test/integration/consensus/test_scenario_attestation.ml b/src/proto_alpha/lib_protocol/test/integration/consensus/test_scenario_attestation.ml index 7b26f64ff26e..d8d77b80d9a3 100644 --- a/src/proto_alpha/lib_protocol/test/integration/consensus/test_scenario_attestation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/consensus/test_scenario_attestation.ml @@ -340,8 +340,9 @@ let test_attestations_keep_activation_status = --> set_baker ~min_round:1 "baker" --> set_payload_round (Some 0) --> wait_n_cycles_f (fun (_, state) -> + (* at activation, accounts have a low tolerance grace period *) state.State.constants.consensus_rights_delay - + state.State.constants.tolerated_inactivity_period + 2) + + state.State.constants.tolerated_inactivity_period_low + 2) (* Check is still activated *) --> exec_unit (fun (block, state) -> let src = State.find_account "delegate" state in diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml index 680c5205f85c..9fa749753370 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_deactivation.ml @@ -56,25 +56,6 @@ let check_cannot_bake_next_block ~loc src_name = let check_can_bake_next_block ~loc src_name = assert_success ~loc (next_block_with_baker src_name) -let check_grace_period ~loc src_name = - let open Lwt_result_syntax in - exec_unit @@ fun (block, state) -> - let src = State.find_account src_name state in - let last_seen_activity = Stdlib.Option.get src.last_seen_activity in - let grace = - Cycle.add - last_seen_activity - state.State.constants.tolerated_inactivity_period - in - let* rpc_grace = Context.Delegate.grace_period (B block) src.pkh in - Assert.equal - ( = ) - "Grace period is not correct: expected vs RPC" - ~loc - Cycle.pp - grace - rpc_grace - (** Test that a delegate gets deactivated after a set period of time if it is not baking. @@ -86,8 +67,9 @@ let test_simple_scenario = --> check_balance_field "delegate" `Staked (Tez.of_mutez 200_000_000_000L) --> set_baker "baker" --> wait_n_cycles_f (fun (_, state) -> + (* at activation, accounts have a low tolerance grace period *) state.State.constants.consensus_rights_delay - + state.State.constants.tolerated_inactivity_period) + + state.State.constants.tolerated_inactivity_period_low) --> check_balance_field "delegate" `Staked (Tez.of_mutez 200_000_000_000L) --> check_is_active ~loc:__LOC__ "delegate" --> next_cycle @@ -113,8 +95,9 @@ let test_baking_deactivation = --> begin_test ["delegate"; "baker"] --> unstake "delegate" All --> wait_n_cycles_f (fun (_, state) -> + (* at activation, accounts have a low tolerance grace period *) state.State.constants.consensus_rights_delay - + state.State.constants.tolerated_inactivity_period) + + state.State.constants.tolerated_inactivity_period_low) --> check_is_active ~loc:__LOC__ "delegate" --> next_cycle --> check_is_not_active ~loc:__LOC__ "delegate" @@ -134,8 +117,7 @@ let test_baking_deactivation = --> next_block_with_baker "delegate" (* Get deactivated by doing nothing *) --> set_baker "baker" - --> wait_n_cycles_f (fun (_, state) -> - state.State.constants.tolerated_inactivity_period) + --> wait_tolerated_inactivity_period "delegate" --> check_is_active ~loc:__LOC__ "delegate" --> next_cycle --> check_is_not_active ~loc:__LOC__ "delegate" @@ -153,14 +135,14 @@ let test_deactivation_timing = --> staked_balance_no_change --> (Tag "Delegate is never active" --> set_baker "baker" --> wait_n_cycles_f (fun (_, state) -> + (* at activation, accounts have a low tolerance grace period *) state.State.constants.consensus_rights_delay - + state.State.constants.tolerated_inactivity_period) + + state.State.constants.tolerated_inactivity_period_low) |+ Tag "Delegate is active for a few cycles" --> set_baker "delegate" --> wait_n_cycles_f (fun (_, state) -> state.State.constants.consensus_rights_delay + 1) --> set_baker "baker" - --> wait_n_cycles_f (fun (_, state) -> - state.State.constants.tolerated_inactivity_period)) + --> wait_tolerated_inactivity_period "delegate") --> exec bake_until_next_cycle_end_but_one --> check_is_active ~loc:__LOC__ "delegate" --> staked_balance_no_change --> next_block diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml index e8bec9309ea1..713fbb9a8d8a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_slashing.ml @@ -331,7 +331,11 @@ let test_slash_timing = stake to get unforbidden, see the comment in Protocol.Forbidden_delegates_storage.should_unforbid. *) --> stake "delegate" Half - --> list_map_branched [0; 1; 2; 3; 4] (fun i -> + (* With [tolerated_inactivity_period] = 1 and + [consensus_rights_delay] = 1, [delegate] is deactivated in the + end of cycle 2, before computing the consensus rights for cycle + 4, so [delegate] has no slots during cycle 4 *) + --> list_map_branched [0; 2; 3; 4] (fun i -> let i = Protocol.Constants_repr.slashing_delay + i in Tag (string_of_int i ^ " cycles lag") --> wait_n_cycles i) --> double_bake "delegate" diff --git a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml index 9afc52444c51..ac87a1d2215a 100644 --- a/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml +++ b/src/proto_alpha/lib_protocol/test/integration/test_scenario_stake.ml @@ -609,8 +609,7 @@ let test_deactivation_after_unstake_all = --> check_is_not_deactivated ~loc:__LOC__ "delegate" (* We already waited for [consensus_rights_delay] + 1 cycles since 0 stake, we must wait for [tolerated_inactivity_period - 1] more. *) - --> wait_n_cycles_f (fun (_, state) -> - state.State.constants.tolerated_inactivity_period - 1) + --> wait_tolerated_inactivity_period ~cycle_offset:(-1) "delegate" --> check_is_not_deactivated ~loc:__LOC__ "delegate" --> next_cycle --> check_is_deactivated ~loc:__LOC__ "delegate" -- GitLab From 0785f646ede953ef374feb192c39233fa1e71637 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 25 Apr 2025 22:31:00 +0200 Subject: [PATCH 09/17] proto: remove unused tolerated_inactivity_period constant --- src/proto_alpha/lib_parameters/default_parameters.ml | 2 -- src/proto_alpha/lib_protocol/alpha_context.mli | 1 - src/proto_alpha/lib_protocol/constants_parametric_repr.ml | 7 +------ src/proto_alpha/lib_protocol/constants_parametric_repr.mli | 1 - src/proto_alpha/lib_protocol/raw_context.ml | 3 --- 5 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/proto_alpha/lib_parameters/default_parameters.ml b/src/proto_alpha/lib_parameters/default_parameters.ml index 41f28e9c6777..8230b4778b82 100644 --- a/src/proto_alpha/lib_parameters/default_parameters.ml +++ b/src/proto_alpha/lib_parameters/default_parameters.ml @@ -283,8 +283,6 @@ let constants_mainnet : Constants.Parametric.t = [minimal_stake]). Last updated in protocol T. *) - (* to be removed *) - tolerated_inactivity_period = 2; tolerated_inactivity_period_high = 12; tolerated_inactivity_period_low = 1; (* threshold is in per thousand *) diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index a75a5cd15f3e..31ca9f43f47a 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -923,7 +923,6 @@ module Constants : sig consensus_rights_delay : int; blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; - tolerated_inactivity_period : int; tolerated_inactivity_period_high : int; tolerated_inactivity_period_low : int; tolerated_inactivity_period_threshold : int; diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml index d599fec500df..048d7b0865bf 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.ml +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.ml @@ -259,7 +259,6 @@ type t = { consensus_rights_delay : int; blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; - tolerated_inactivity_period : int; tolerated_inactivity_period_high : int; tolerated_inactivity_period_low : int; tolerated_inactivity_period_threshold : int; @@ -570,7 +569,6 @@ let encoding = ( ( ( c.consensus_rights_delay, c.blocks_preservation_cycles, c.delegate_parameters_activation_delay, - c.tolerated_inactivity_period, c.tolerated_inactivity_period_high, c.tolerated_inactivity_period_low, c.tolerated_inactivity_period_threshold ), @@ -618,7 +616,6 @@ let encoding = (fun ( ( ( consensus_rights_delay, blocks_preservation_cycles, delegate_parameters_activation_delay, - tolerated_inactivity_period, tolerated_inactivity_period_high, tolerated_inactivity_period_low, tolerated_inactivity_period_threshold ), @@ -668,7 +665,6 @@ let encoding = consensus_rights_delay; blocks_preservation_cycles; delegate_parameters_activation_delay; - tolerated_inactivity_period; tolerated_inactivity_period_high; tolerated_inactivity_period_low; tolerated_inactivity_period_threshold; @@ -717,11 +713,10 @@ let encoding = }) (merge_objs (merge_objs - (obj7 + (obj6 (req "consensus_rights_delay" uint8) (req "blocks_preservation_cycles" uint8) (req "delegate_parameters_activation_delay" uint8) - (req "tolerated_inactivity_period" uint8) (req "tolerated_inactivity_period_high" uint8) (req "tolerated_inactivity_period_low" uint8) (req "tolerated_inactivity_period_threshold" uint8)) diff --git a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli index 355fd06a4de4..cb074acde9e1 100644 --- a/src/proto_alpha/lib_protocol/constants_parametric_repr.mli +++ b/src/proto_alpha/lib_protocol/constants_parametric_repr.mli @@ -211,7 +211,6 @@ type t = { keep them in its history. *) blocks_preservation_cycles : int; delegate_parameters_activation_delay : int; - tolerated_inactivity_period : int; tolerated_inactivity_period_high : int; tolerated_inactivity_period_low : int; tolerated_inactivity_period_threshold : int; diff --git a/src/proto_alpha/lib_protocol/raw_context.ml b/src/proto_alpha/lib_protocol/raw_context.ml index 2bd327160c3a..99611aa8a2e1 100644 --- a/src/proto_alpha/lib_protocol/raw_context.ml +++ b/src/proto_alpha/lib_protocol/raw_context.ml @@ -1309,7 +1309,6 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = consensus_rights_delay; blocks_preservation_cycles; delegate_parameters_activation_delay; - tolerated_inactivity_period; tolerated_inactivity_period_high; tolerated_inactivity_period_low; tolerated_inactivity_period_threshold; @@ -1364,7 +1363,6 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = Constants_parametric_repr.consensus_rights_delay; blocks_preservation_cycles; delegate_parameters_activation_delay; - tolerated_inactivity_period; tolerated_inactivity_period_high; tolerated_inactivity_period_low; tolerated_inactivity_period_threshold; @@ -1719,7 +1717,6 @@ let prepare_first_block ~level ~timestamp chain_id ctxt = Constants_parametric_repr.consensus_rights_delay; blocks_preservation_cycles; delegate_parameters_activation_delay; - tolerated_inactivity_period; tolerated_inactivity_period_high; tolerated_inactivity_period_low; tolerated_inactivity_period_threshold = 10; -- GitLab From 73f01263e75bcab68857def2315d640bf67d1fdc Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Mon, 18 Aug 2025 16:18:03 +0200 Subject: [PATCH 10/17] Tezt/Test: update tolerated_inactivity migration test --- tezt/tests/protocol_migration.ml | 65 ++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/tezt/tests/protocol_migration.ml b/tezt/tests/protocol_migration.ml index b65b2b2231eb..dfcddc47d931 100644 --- a/tezt/tests/protocol_migration.ml +++ b/tezt/tests/protocol_migration.ml @@ -2187,69 +2187,78 @@ let test_tolerated_inactivity_period () = in (* Migration at the end of C3: - - D0, D1, D2 are deactivated at the end of C4 -> C6 - - D3 is deactivated at the end of C5 -> C7 + - D0, D1, D2 are deactivated at the end of C4 -> C5 + - D3 is deactivated at the end of C5 -> C6 -------------------------[proto migration] - - D4 is deactivated at the end of C6 -> C7 - - D5 is deactivated at the end of C7 - - D6 is deactivated at the end of C8 - - D7 is deactivated at the end of C9 + - D4 is deactivated at the end of C5 -> C6 + - D5 is deactivated at the end of C6 + - D6 is deactivated at the end of C7 + - D7 is deactivated at the end of C8 Migration at the end of C4: - D0, D1, D2 are deactivated at the end of C4 - - D3 is deactivated at the end of C5 -> C7 - - D4 is deactivated at the end of C6 -> C8 + - D3 is deactivated at the end of C5 -> C6 + - D4 is deactivated at the end of C6 -> C7 -------------------------[proto migration] - - D5 is deactivated at the end of C7 -> C8 - - D6 is deactivated at the end of C8 - - D7 is deactivated at the end of C9 + - D5 is deactivated at the end of C6 -> C7 + - D6 is deactivated at the end of C7 + - D7 is deactivated at the end of C8 Migration at the end of C5: - D0, D1, D2 are deactivated at the end of C4 - D3 is deactivated at the end of C5 - - D4 is deactivated at the end of C6 -> C8 - - D5 is deactivated at the end of C7 -> C9 + - D4 is deactivated at the end of C6 -> C7 + - D5 is deactivated at the end of C7 -> C8 -------------------------[proto migration] - - D6 is deactivated at the end of C8 -> C9 - - D7 is deactivated at the end of C9 + - D6 is deactivated at the end of C7 -> C8 + - D7 is deactivated at the end of C8 *) let expected_list = match target_cycle with | 3 | 4 -> all_activated | 5 -> + (* Deactivated at the end of C4. Migration at the end of + - [migration_cycle = 4] C3: None + - [migration_cycle = 5] C4: D0, D1, D2 + - [migration_cycle = 6] C5: D0, D1, D2 *) let is_deactivated i = if i <= 2 then migration_cycle >= 5 else false in List.init 8 is_deactivated | 6 -> - let is_deactivated i = - if i <= 2 then migration_cycle >= 5 - else if i = 3 then migration_cycle >= 6 - else false - in - List.init 8 is_deactivated - | 7 -> + (* Deactivated at the end of C5. Migration at the end of + - [migration_cycle = 4] C3: D0, D1, D2 + - [migration_cycle = 5] C4: D0, D1, D2 + - [migration_cycle = 6] C5: D0, D1, D2, D3 *) let is_deactivated i = if i <= 2 then true else if i = 3 then migration_cycle >= 6 else false in List.init 8 is_deactivated - | 8 -> + | 7 -> + (* Deactivated at the end of C6. Migration at the end of + - [migration_cycle = 4] C3: D0, D1, D2, D3, D4, D5 + - [migration_cycle = 5] C4: D0, D1, D2, D3 + - [migration_cycle = 6] C5: D0, D1, D2, D3 *) let is_deactivated i = if i <= 3 then true else if i = 4 || i = 5 then migration_cycle = 4 else false in List.init 8 is_deactivated - | 9 -> + | 8 -> + (* Deactivated at the end of C7. Migration at the end of + - [migration_cycle = 4] C3: D0, D1, D2, D3, D4, D5, D6 + - [migration_cycle = 5] C4: D0, D1, D2, D3, D4, D5, D6 + - [migration_cycle = 6] C5: D0, D1, D2, D3, D4 *) let is_deactivated i = - if i = 5 || i = 6 then migration_cycle <= 5 - else if i = 7 then false - else true + if i <= 4 then true + else if i = 5 || i = 6 then migration_cycle <= 5 + else false in List.init 8 is_deactivated - | 10 -> all_deactivated + | 9 | 10 -> all_deactivated | _ -> failwith "unexpected input" in (* [default_baker] must be always active *) -- GitLab From 76f07bc7a8ec2a0f8fc99f701e53ead504017a22 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 20 Aug 2025 13:54:52 +0200 Subject: [PATCH 11/17] Tezt/Tests: increase tolerated_inactivity_period_low in some testing scenarios --- tezt/tests/adaptive_issuance.ml | 6 +++++- tezt/tests/baker_test.ml | 8 ++++++++ tezt/tests/voting.ml | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tezt/tests/adaptive_issuance.ml b/tezt/tests/adaptive_issuance.ml index bba64c131d40..84c4bc84aaf7 100644 --- a/tezt/tests/adaptive_issuance.ml +++ b/tezt/tests/adaptive_issuance.ml @@ -312,7 +312,11 @@ let test_staking = let overrides = (* TODO: https://gitlab.com/tezos/tezos/-/issues/7576 use a default value for [tolerated_inactivity_period] *) - (["tolerated_inactivity_period"], `Int 3) + ( [ + (if Protocol.(number protocol <= 023) then "tolerated_inactivity_period" + else "tolerated_inactivity_period_low"); + ], + `Int 3 ) :: (["issuance_weights"; "dal_rewards_weight"], `Int 0) :: default_overrides in diff --git a/tezt/tests/baker_test.ml b/tezt/tests/baker_test.ml index 0db6b57d9583..e1e38ea95639 100644 --- a/tezt/tests/baker_test.ml +++ b/tezt/tests/baker_test.ml @@ -893,6 +893,14 @@ let attestations_aggregation_on_reproposal ~remote_mode protocol = (["minimal_block_delay"], `String "4"); (["delay_increment_per_round"], `String "0"); (["blocks_per_cycle"], `Int 2); + (* [blocks_per_cycle] is too short in this testing scenario, + so we increase [tolerated_inactivity_period] *) + ( [ + (if Protocol.(number protocol <= 023) then + "tolerated_inactivity_period" + else "tolerated_inactivity_period_low"); + ], + `Int 2 ); (["nonce_revelation_threshold"], `Int 1); (["consensus_rights_delay"], `Int consensus_rights_delay); (["cache_sampler_state_cycles"], `Int (consensus_rights_delay + 3)); diff --git a/tezt/tests/voting.ml b/tezt/tests/voting.ml index a22892d1612f..2feb2abbbb7d 100644 --- a/tezt/tests/voting.ml +++ b/tezt/tests/voting.ml @@ -298,7 +298,13 @@ let test_voting ~from_protocol ~(to_protocol : target_protocol) ~loser_protocols let parameters = (* TODO: https://gitlab.com/tezos/tezos/-/issues/7576 use a default value for [tolerated_inactivity_period] *) - (["tolerated_inactivity_period"], `Int 3) :: parameters + ( [ + (if Protocol.(number from_protocol <= 023) then + "tolerated_inactivity_period" + else "tolerated_inactivity_period_low"); + ], + `Int 3 ) + :: parameters in let* parameter_file = -- GitLab From 6ebd7e616f4d55a128896be3373563ee6f83dd80 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 20 Aug 2025 13:56:22 +0200 Subject: [PATCH 12/17] Tezt/Tests: reset regressions --- ...- (mode client) RPC regression tests- delegates.out | 4 ++-- ...ode client) RPC regression tests- misc_protocol.out | 4 +++- ...a- (mode light) RPC regression tests- delegates.out | 4 ++-- ...mode light) RPC regression tests- misc_protocol.out | 4 +++- ...a- (mode proxy) RPC regression tests- delegates.out | 4 ++-- ...mode proxy) RPC regression tests- misc_protocol.out | 4 +++- ...th (baker - delegate - consensus - destination).out | 10 +++++----- ...h (baker - delegate - consensus -- destination).out | 10 +++++----- ...h (baker -- delegate - consensus - destination).out | 10 +++++----- ... (baker -- delegate - consensus -- destination).out | 10 +++++----- .../Alpha- Test register with consensus key.out | 4 ++-- ...pha- Test set consensus key - baker is delegate.out | 6 +++--- ... Test set consensus key - baker is not delegate.out | 6 +++--- ... Test following dal and baker tutorial commands.out | 2 +- .../weeklynet.ml/Alpha- weeklynet regression test.out | 4 +++- tezt/tests/weeklynet_configs/alpha.json | 4 +++- 16 files changed, 50 insertions(+), 40 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 99040169f154..967f9a11d20a 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 @@ -27,7 +27,7 @@ { "expected_assigned_shards_per_slot": 409, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "212680", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -73,7 +73,7 @@ false [ "[PUBLIC_KEY_HASH]" ] ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/grace_period' -3 +2 ./octez-client rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/staking_balance' "4000000000000" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out index 7c00020c20f8..5cbf34264a87 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- misc_protocol.out @@ -11,7 +11,9 @@ "smart_rollup_max_number_of_messages_per_level": "1000000", "consensus_rights_delay": 1, "blocks_preservation_cycles": 1, "delegate_parameters_activation_delay": 2, - "tolerated_inactivity_period": 2, "blocks_per_cycle": 8, + "tolerated_inactivity_period_high": 12, + "tolerated_inactivity_period_low": 1, + "tolerated_inactivity_period_threshold": 10, "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", "hard_gas_limit_per_block": "1386666", 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 69f51408067c..d011a90b9a37 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 @@ -27,7 +27,7 @@ { "expected_assigned_shards_per_slot": 409, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "212680", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -73,7 +73,7 @@ false [ "[PUBLIC_KEY_HASH]" ] ./octez-client --mode light rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/grace_period' -3 +2 ./octez-client --mode light rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/staking_balance' "4000000000000" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out index f6b3c03403f9..b890df668ad8 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- misc_protocol.out @@ -11,7 +11,9 @@ "smart_rollup_max_number_of_messages_per_level": "1000000", "consensus_rights_delay": 1, "blocks_preservation_cycles": 1, "delegate_parameters_activation_delay": 2, - "tolerated_inactivity_period": 2, "blocks_per_cycle": 8, + "tolerated_inactivity_period_high": 12, + "tolerated_inactivity_period_low": 1, + "tolerated_inactivity_period_threshold": 10, "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", "hard_gas_limit_per_block": "1386666", 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 3bf5048ed0f0..139d55caf65e 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 @@ -27,7 +27,7 @@ { "expected_assigned_shards_per_slot": 409, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "212680", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -73,7 +73,7 @@ false [ "[PUBLIC_KEY_HASH]" ] ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/grace_period' -3 +2 ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/delegates/[PUBLIC_KEY_HASH]/staking_balance' "4000000000000" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out index de80fb77e8b9..41aaee3318df 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- misc_protocol.out @@ -11,7 +11,9 @@ "smart_rollup_max_number_of_messages_per_level": "1000000", "consensus_rights_delay": 1, "blocks_preservation_cycles": 1, "delegate_parameters_activation_delay": 2, - "tolerated_inactivity_period": 2, "blocks_per_cycle": 8, + "tolerated_inactivity_period_high": 12, + "tolerated_inactivity_period_low": 1, + "tolerated_inactivity_period_threshold": 10, "blocks_per_cycle": 8, "blocks_per_commitment": 4, "nonce_revelation_threshold": 4, "cycles_per_voting_period": 8, "hard_gas_limit_per_operation": "1040000", "hard_gas_limit_per_block": "1386666", 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 d88e0964d1d7..2d5677a5cdba 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -163,7 +163,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -254,7 +254,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "2652", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 4, + "denounced": false }, "grace_period": 3, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 e8cdc200f2c9..c2c5e92c027a 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -163,7 +163,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -254,7 +254,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "2652", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 4, + "denounced": false }, "grace_period": 3, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 555e2cdd0328..72d86c7ea613 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -163,7 +163,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -254,7 +254,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "2652", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 4, + "denounced": false }, "grace_period": 3, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 41f10c2c00ba..8fd030c77be5 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -163,7 +163,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -254,7 +254,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "2652", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 4, + "denounced": false }, "grace_period": 3, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 a6a9ac81d45d..213c47266aee 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 @@ -87,7 +87,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 0, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "0", "sufficient_dal_participation": false, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -134,7 +134,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 0, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "0", "sufficient_dal_participation": false, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 376b3deca6ea..1e856d8905d5 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, 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 fc1a002e7706..610e14229f98 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 @@ -36,7 +36,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -77,7 +77,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 204, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "106080", "sufficient_dal_participation": true, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, diff --git a/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out b/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out index 02e16155dd64..abbbcb3e2a4a 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out +++ b/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out @@ -121,7 +121,7 @@ This sequence of operations was run: { "expected_assigned_shards_per_slot": 0, "delegate_attested_dal_slots": 0, "delegate_attestable_dal_slots": 0, "expected_dal_rewards": "0", "sufficient_dal_participation": false, - "denounced": false }, "grace_period": 3, + "denounced": false }, "grace_period": 2, "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, diff --git a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out index acabb8617dab..0e0ef80e3dd9 100644 --- a/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out +++ b/tezt/tests/expected/weeklynet.ml/Alpha- weeklynet regression test.out @@ -2,7 +2,9 @@ ./octez-client rpc get /chains/main/blocks/head/context/constants/parametric { "consensus_rights_delay": 1, "blocks_preservation_cycles": 1, "delegate_parameters_activation_delay": 3, - "tolerated_inactivity_period": 1, "blocks_per_cycle": 200, + "tolerated_inactivity_period_high": 1, + "tolerated_inactivity_period_low": 1, + "tolerated_inactivity_period_threshold": 10, "blocks_per_cycle": 200, "blocks_per_commitment": 25, "nonce_revelation_threshold": 50, "cycles_per_voting_period": 1, "hard_gas_limit_per_operation": "1040000", "hard_gas_limit_per_block": "3328000", "proof_of_work_threshold": "-1", diff --git a/tezt/tests/weeklynet_configs/alpha.json b/tezt/tests/weeklynet_configs/alpha.json index 9307da346edf..0002a532475e 100644 --- a/tezt/tests/weeklynet_configs/alpha.json +++ b/tezt/tests/weeklynet_configs/alpha.json @@ -24,7 +24,9 @@ "consensus_rights_delay": 1, "blocks_preservation_cycles": 1, "delegate_parameters_activation_delay": 3, - "tolerated_inactivity_period": 1, + "tolerated_inactivity_period_low": 1, + "tolerated_inactivity_period_high": 2, + "tolerated_inactivity_period_threshold": 10, "blocks_per_cycle": 200, "blocks_per_commitment": 25, "nonce_revelation_threshold": 50, -- GitLab From caa46c5ae5e2f1ee0b29f795763c64321add85b7 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Tue, 5 Aug 2025 17:47:41 +0200 Subject: [PATCH 13/17] etherlink/tezt/tests: reset regressions --- ...n test for the FA deposit and withdrawal events.out | 10 +++++----- ...egression test for the claimed FA deposit event.out | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the FA deposit and withdrawal events.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the FA deposit and withdrawal events.out index de0dbaf70919..402a127e5474 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the FA deposit and withdrawal events.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the FA deposit and withdrawal events.out @@ -3,19 +3,19 @@ Address: 0x0000000000000000000000000000000000000000 Topics: - 0x7ee7a1de9c18ce695c95b8b19fbdf26cce3544e3ca9e08c9f487776783d7599f -- 0x1260a8e6705d5b2c0ffcb2f6403873322b8c183a61e390190227eb54836726dd +- 0xee19fe54ca76d01ccfe9338d25f6ba8d0757941a89cc8b85cc2c97c1e72d08bf Data: 0x0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c000000000000000000000000000000000000000000000000000000000000002a00000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000002 # FA Withdrawal ## Log 0 Address: 0xff00000000000000000000000000000000000002 Topics: - 0xab68450c9e546f6062a861eebf8ec5bbd41b4425e26b20199c91227c7f9038ca -- 0x1260a8e6705d5b2c0ffcb2f6403873322b8c183a61e390190227eb54836726dd -Data: 0x0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c00000000000000000000000000000000000000000000000000000000000000000180e5787d88921e91f5cfa294502fc82e8650f893000000000000000000000000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000000 +- 0xee19fe54ca76d01ccfe9338d25f6ba8d0757941a89cc8b85cc2c97c1e72d08bf +Data: 0x0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c000000000000000000000000000000000000000000000000000000000000000001ee26414a33edd7d99967d5d2107f0b627ace22fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000280000000000000000000000000000000000000000000000000000000000000000 # FA Fast Withdrawal ## Log 0 Address: 0xff00000000000000000000000000000000000002 Topics: - 0x7e40c982e82bccb5e8bbd29f38bcfa3996f341ef9f51e2a9cffe086ec87a11c7 -- 0x1260a8e6705d5b2c0ffcb2f6403873322b8c183a61e390190227eb54836726dd -Data: 0x0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000c55cf02dbeecc978d9c84625dcae72bb77ea4fbd000000000000000000000180e5787d88921e91f5cfa294502fc82e8650f893000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000005e0be103000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001 +- 0xee19fe54ca76d01ccfe9338d25f6ba8d0757941a89cc8b85cc2c97c1e72d08bf +Data: 0x0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000000000000000000000006ce4d79d4e77402e1ef3417fdda433aa744c6e1c0000c55cf02dbeecc978d9c84625dcae72bb77ea4fbd0000000000000000000001ee26414a33edd7d99967d5d2107f0b627ace22fd000000000000000000000000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000005e0be103000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001 diff --git a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the claimed FA deposit event.out b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the claimed FA deposit event.out index 6644fdcbd0ab..f6394722639f 100644 --- a/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the claimed FA deposit event.out +++ b/etherlink/tezt/tests/expected/evm_sequencer.ml/Alpha- Regression test for the claimed FA deposit event.out @@ -3,5 +3,5 @@ Address: 0xff00000000000000000000000000000000000002 Topics: - 0x7ee7a1de9c18ce695c95b8b19fbdf26cce3544e3ca9e08c9f487776783d7599f -- 0xef624bac0d0b6887cc4578f36ebb87d0dc8a9c4e017d6152af09e15403aa1894 +- 0x33e1638aeeb2e0e5e68f5cb32600b32f12b29b8f84e6defec7bedecf9d68a226 Data: 0x00000000000000000000000092e791df3dd5a8704f0e7d9b3003a0627d95d01700000000000000000000000092e791df3dd5a8704f0e7d9b3003a0627d95d017000000000000000000000000000000000000000000000000000000000000003200000000000000000000000000000000000000000000000000000000000000070000000000000000000000000000000000000000000000000000000000000003 -- GitLab From 1a89db0c423f46672c7524d3fd6947c730436023 Mon Sep 17 00:00:00 2001 From: Julien Tesson Date: Fri, 27 Jun 2025 09:31:28 +0200 Subject: [PATCH 14/17] kaitai: update structs --- client-libs/kaitai-struct-files/files/alpha__constants.ksy | 6 +++++- .../files/alpha__constants__parametric.ksy | 6 +++++- client-libs/kaitai-struct-files/files/alpha__parameters.ksy | 6 +++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/client-libs/kaitai-struct-files/files/alpha__constants.ksy b/client-libs/kaitai-struct-files/files/alpha__constants.ksy index 28fb695f223e..d9cf90c3b984 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants.ksy @@ -263,7 +263,11 @@ seq: type: u1 - id: delegate_parameters_activation_delay type: u1 -- id: tolerated_inactivity_period +- id: tolerated_inactivity_period_high + type: u1 +- id: tolerated_inactivity_period_low + type: u1 +- id: tolerated_inactivity_period_threshold type: u1 - id: blocks_per_cycle type: s4be diff --git a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy index 5071ed826a07..e418a5cdf84c 100644 --- a/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__constants__parametric.ksy @@ -233,7 +233,11 @@ seq: type: u1 - id: delegate_parameters_activation_delay type: u1 -- id: tolerated_inactivity_period +- id: tolerated_inactivity_period_high + type: u1 +- id: tolerated_inactivity_period_low + type: u1 +- id: tolerated_inactivity_period_threshold type: u1 - id: blocks_per_cycle type: s4be diff --git a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy index 8d4023d9493f..26f0c5ee8ee7 100644 --- a/client-libs/kaitai-struct-files/files/alpha__parameters.ksy +++ b/client-libs/kaitai-struct-files/files/alpha__parameters.ksy @@ -511,7 +511,11 @@ seq: type: u1 - id: delegate_parameters_activation_delay type: u1 -- id: tolerated_inactivity_period +- id: tolerated_inactivity_period_high + type: u1 +- id: tolerated_inactivity_period_low + type: u1 +- id: tolerated_inactivity_period_threshold type: u1 - id: blocks_per_cycle type: s4be -- GitLab From a07be99e418459caa08c497c2792b1b7a2d3105c Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Tue, 19 Aug 2025 10:57:57 +0200 Subject: [PATCH 15/17] Proto: increase a default safety guard for delegation This is a temporal fix for test_fix_delegated_balance in tezt/tests/adaptive_issuance.ml --- src/proto_alpha/lib_client/injection.ml | 4 +-- ...lient) RPC regression tests- contracts.out | 4 +-- ...light) RPC regression tests- contracts.out | 4 +-- ...proxy) RPC regression tests- contracts.out | 4 +-- ...companion and consensus keys and stake.out | 12 +++---- ...a- register keys with proofs and stake.out | 12 +++---- ...lpha- Test register with consensus key.out | 34 +++++++++---------- ...lowing dal and baker tutorial commands.out | 24 ++++++------- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 26a33c3cea2c..caaae413e987 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -861,8 +861,8 @@ let may_patch_limits (type kind) (cctxt : #Protocol_client_context.full) let default_safety_guard = match c.operation with | Transaction {destination = Implicit _; _} - | Reveal _ | Delegation _ | Set_deposits_limit _ - | Increase_paid_storage _ -> + | Reveal _ | Set_deposits_limit _ | Increase_paid_storage _ + -> Gas.Arith.zero | _ -> default_safety_guard in diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- contracts.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- contracts.out index de438beb54dd..33935e48a489 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- contracts.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode client) RPC regression tests- contracts.out @@ -69,11 +69,11 @@ Fatal error: ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]' -{ "balance": "99999565", "delegate": "[PUBLIC_KEY_HASH]", +{ "balance": "99999554", "delegate": "[PUBLIC_KEY_HASH]", "counter": "4", "revealed": true } ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"99999565" +"99999554" ./octez-client rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/counter' "4" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- contracts.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- contracts.out index 33e01b853fae..fd1600886988 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- contracts.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode light) RPC regression tests- contracts.out @@ -69,11 +69,11 @@ Fatal error: ./octez-client --mode light rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]' -{ "balance": "99999565", "delegate": "[PUBLIC_KEY_HASH]", +{ "balance": "99999554", "delegate": "[PUBLIC_KEY_HASH]", "counter": "4", "revealed": true } ./octez-client --mode light rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"99999565" +"99999554" ./octez-client --mode light rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/counter' "4" diff --git a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- contracts.out b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- contracts.out index 4fcb3b18c07e..dd7f1028264c 100644 --- a/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- contracts.out +++ b/tezt/tests/expected/RPC_test.ml/Alpha- (mode proxy) RPC regression tests- contracts.out @@ -69,11 +69,11 @@ Fatal error: ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]' -{ "balance": "99999565", "delegate": "[PUBLIC_KEY_HASH]", +{ "balance": "99999554", "delegate": "[PUBLIC_KEY_HASH]", "counter": "4", "revealed": true } ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/balance' -"99999565" +"99999554" ./octez-client --mode proxy rpc get '/chains/main/blocks/head/context/contracts/[PUBLIC_KEY_HASH]/counter' "4" diff --git a/tezt/tests/expected/companion_key.ml/Alpha- register key as delegate with companion and consensus keys and stake.out b/tezt/tests/expected/companion_key.ml/Alpha- register key as delegate with companion and consensus keys and stake.out index ab1536cc86c4..3cecc93df11c 100644 --- a/tezt/tests/expected/companion_key.ml/Alpha- register key as delegate with companion and consensus keys and stake.out +++ b/tezt/tests/expected/companion_key.ml/Alpha- register key as delegate with companion and consensus keys and stake.out @@ -3,7 +3,7 @@ Node is bootstrapped. Estimated gas: 184.813 units (will add 0 for safety) Estimated storage: no bytes added -Estimated gas: 100 units (will add 0 for safety) +Estimated gas: 100 units (will add 100 for safety) Estimated storage: no bytes added Estimated gas: 1671.680 units (will add 100 for safety) Estimated storage: no bytes added @@ -31,16 +31,16 @@ This sequence of operations was run: Contract: [PUBLIC_KEY_HASH] Key: [PUBLIC_KEY] This revelation was successfully applied - Consumed gas: 184.449 + Consumed gas: 184.482 Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000159 + Fee to the baker: ꜩ0.00017 Expected counter: 3 - Gas limit: 100 + Gas limit: 200 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000159 - payload fees(the block proposer) ....... +ꜩ0.000159 + [PUBLIC_KEY_HASH] ... -ꜩ0.00017 + payload fees(the block proposer) ....... +ꜩ0.00017 Delegation: Contract: [PUBLIC_KEY_HASH] To: [PUBLIC_KEY_HASH] diff --git a/tezt/tests/expected/companion_key.ml/Alpha- register keys with proofs and stake.out b/tezt/tests/expected/companion_key.ml/Alpha- register keys with proofs and stake.out index 6049596248cc..981c664bcdc4 100644 --- a/tezt/tests/expected/companion_key.ml/Alpha- register keys with proofs and stake.out +++ b/tezt/tests/expected/companion_key.ml/Alpha- register keys with proofs and stake.out @@ -3,7 +3,7 @@ Node is bootstrapped. Estimated gas: 184.813 units (will add 0 for safety) Estimated storage: no bytes added -Estimated gas: 100 units (will add 0 for safety) +Estimated gas: 100 units (will add 100 for safety) Estimated storage: no bytes added Estimated gas: 1671.680 units (will add 100 for safety) Estimated storage: no bytes added @@ -31,16 +31,16 @@ This sequence of operations was run: Contract: [PUBLIC_KEY_HASH] Key: [PUBLIC_KEY] This revelation was successfully applied - Consumed gas: 184.449 + Consumed gas: 184.482 Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000159 + Fee to the baker: ꜩ0.00017 Expected counter: 3 - Gas limit: 100 + Gas limit: 200 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000159 - payload fees(the block proposer) ....... +ꜩ0.000159 + [PUBLIC_KEY_HASH] ... -ꜩ0.00017 + payload fees(the block proposer) ....... +ꜩ0.00017 Delegation: Contract: [PUBLIC_KEY_HASH] To: [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 213c47266aee..576d050bbd9c 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 @@ -6,7 +6,7 @@ Node is bootstrapped. Estimated gas: 178.785 units (will add 0 for safety) Estimated storage: no bytes added -Estimated gas: 100 units (will add 0 for safety) +Estimated gas: 100 units (will add 100 for safety) Estimated storage: no bytes added Estimated gas: 100 units (will add 100 for safety) Estimated storage: no bytes added @@ -32,16 +32,16 @@ This sequence of operations was run: Contract: [PUBLIC_KEY_HASH] Key: [PUBLIC_KEY] This revelation was successfully applied - Consumed gas: 178.486 + Consumed gas: 178.520 Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000159 + Fee to the baker: ꜩ0.00017 Expected counter: 3 - Gas limit: 100 + Gas limit: 200 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000159 - payload fees(the block proposer) ....... +ꜩ0.000159 + [PUBLIC_KEY_HASH] ... -ꜩ0.00017 + payload fees(the block proposer) ....... +ꜩ0.00017 Delegation: Contract: [PUBLIC_KEY_HASH] To: [PUBLIC_KEY_HASH] @@ -92,18 +92,18 @@ This sequence of operations was run: { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, "pending_staking_parameters": [], "baking_power": "0", "total_staked": "0", - "total_delegated": "999999998927", + "total_delegated": "999999998916", "min_delegated_in_current_cycle": - { "amount": "999999998927", + { "amount": "999999998916", "level": { "level": 3, "level_position": 2, "cycle": 0, "cycle_position": 2, "expected_commitment": false } }, - "own_full_balance": "999999998927", "own_staked": "0", - "own_delegated": "999999998927", "external_staked": "0", + "own_full_balance": "999999998916", "own_staked": "0", + "own_delegated": "999999998916", "external_staked": "0", "external_delegated": "0", "total_unstaked_per_cycle": [ { "cycle": 0, "deposit": "0" } ], "denunciations": [], "estimated_shared_pending_slashed_amount": "0", - "staking_denominator": "0", "current_voting_power": "999999998927", + "staking_denominator": "0", "current_voting_power": "999999998916", "voting_power": "0", "voting_info": {}, "consensus_key": { "active": @@ -138,20 +138,20 @@ This sequence of operations was run: "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, - "pending_staking_parameters": [], "baking_power": "666666666101", - "total_staked": "500000000000", "total_delegated": "499999998304", + "pending_staking_parameters": [], "baking_power": "666666666097", + "total_staked": "500000000000", "total_delegated": "499999998293", "min_delegated_in_current_cycle": - { "amount": "499999998304", + { "amount": "499999998293", "level": { "level": 5, "level_position": 4, "cycle": 1, "cycle_position": 0, "expected_commitment": false } }, - "own_full_balance": "999999998304", "own_staked": "500000000000", - "own_delegated": "499999998304", "external_staked": "0", + "own_full_balance": "999999998293", "own_staked": "500000000000", + "own_delegated": "499999998293", "external_staked": "0", "external_delegated": "0", "total_unstaked_per_cycle": [ { "cycle": 0, "deposit": "0" }, { "cycle": 1, "deposit": "0" } ], "denunciations": [], "estimated_shared_pending_slashed_amount": "0", - "staking_denominator": "0", "current_voting_power": "999999998304", + "staking_denominator": "0", "current_voting_power": "999999998293", "voting_power": "0", "voting_info": {}, "consensus_key": { "active": diff --git a/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out b/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out index abbbcb3e2a4a..0f24e6c31272 100644 --- a/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out +++ b/tezt/tests/expected/dal.ml/Alpha- Test following dal and baker tutorial commands.out @@ -39,7 +39,7 @@ This sequence of operations was run: Node is bootstrapped. Estimated gas: 170.702 units (will add 0 for safety) Estimated storage: no bytes added -Estimated gas: 100 units (will add 0 for safety) +Estimated gas: 100 units (will add 100 for safety) Estimated storage: no bytes added Operation successfully injected in the node. Operation hash is '[OPERATION_HASH]' @@ -61,16 +61,16 @@ This sequence of operations was run: Contract: [PUBLIC_KEY_HASH] Key: [PUBLIC_KEY] This revelation was successfully applied - Consumed gas: 170.536 + Consumed gas: 170.570 Manager signed operations: From: [PUBLIC_KEY_HASH] - Fee to the baker: ꜩ0.000159 + Fee to the baker: ꜩ0.00017 Expected counter: 3 - Gas limit: 100 + Gas limit: 200 Storage limit: 0 bytes Balance updates: - [PUBLIC_KEY_HASH] ... -ꜩ0.000159 - payload fees(the block proposer) ....... +ꜩ0.000159 + [PUBLIC_KEY_HASH] ... -ꜩ0.00017 + payload fees(the block proposer) ....... +ꜩ0.00017 Delegation: Contract: [PUBLIC_KEY_HASH] To: [PUBLIC_KEY_HASH] @@ -125,19 +125,19 @@ This sequence of operations was run: "active_staking_parameters": { "limit_of_staking_over_baking_millionth": 0, "edge_of_baking_over_staking_billionth": 1000000000 }, - "pending_staking_parameters": [], "baking_power": "499933332980", - "total_staked": "499900000000", "total_delegated": "99998942", + "pending_staking_parameters": [], "baking_power": "499933332977", + "total_staked": "499900000000", "total_delegated": "99998931", "min_delegated_in_current_cycle": - { "amount": "99998942", + { "amount": "99998931", "level": { "level": 4, "level_position": 3, "cycle": 0, "cycle_position": 3, "expected_commitment": true } }, - "own_full_balance": "499999998942", "own_staked": "499900000000", - "own_delegated": "99998942", "external_staked": "0", + "own_full_balance": "499999998931", "own_staked": "499900000000", + "own_delegated": "99998931", "external_staked": "0", "external_delegated": "0", "total_unstaked_per_cycle": [ { "cycle": 0, "deposit": "0" } ], "denunciations": [], "estimated_shared_pending_slashed_amount": "0", - "staking_denominator": "0", "current_voting_power": "499999998942", + "staking_denominator": "0", "current_voting_power": "499999998931", "voting_power": "0", "voting_info": {}, "consensus_key": { "active": -- GitLab From 820c59414272e7cb1c6ffa85038e9d6db8da1597 Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 20 Aug 2025 11:29:56 +0200 Subject: [PATCH 16/17] Proto/Tests: get actual list of voters for each voting period Voters are active delegates with a minimal stake when a voting period starts. With tolerated_inactivity_period = 1, delegates can get quickly deactivated in such testing scenarios. Co-authored-by: Diane Gallois-Wong --- .../validate/generator_descriptors.ml | 24 ++++++++++++------- .../validate/generator_descriptors.mli | 10 ++------ .../validate/valid_operations_generators.ml | 6 +---- 3 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml index 03f1e3974417..486abc43b604 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.ml @@ -40,7 +40,6 @@ type state = { pred : Block.t option; bootstraps : public_key_hash list; delegates : (public_key_hash * public_key_hash option) list; - voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; protocol_hashes : Protocol_hash.t list; @@ -78,7 +77,7 @@ let init_dbl_attestation_state = When adding a new operation kind, if such an initialization is required, it should occur here. *) -let init_state block ~voters ~(bootstraps : Contract.t list) = +let init_state block ~(bootstraps : Contract.t list) = let bootstraps = List.map (function Contract.Implicit pkh -> pkh | _ -> assert false) @@ -89,7 +88,6 @@ let init_state block ~voters ~(bootstraps : Contract.t list) = pred = None; bootstraps; delegates = List.map (fun pkh -> (pkh, None)) bootstraps; - voters; seed_nonce_to_reveal = []; commitments = []; protocol_hashes = []; @@ -119,6 +117,11 @@ let voting_context_params params = let constants = Parameters.{params.constants with cycles_per_voting_period} in {params with constants} +let get_voters state = + let open Lwt_result_syntax in + let+ voters = Context.Vote.get_listings (B state.block) in + List.map (fun (pkh, _) -> Contract.Implicit pkh) voters + let ballot_exploration_prelude state = let open Lwt_result_syntax in let* ctxt = @@ -129,8 +132,9 @@ let ballot_exploration_prelude state = let rem = Int32.rem state.block.Block.header.Block_header.shell.level blocks_per_cycle in + let* voters = get_voters state in if rem = 0l then - match state.voters with + match voters with | voter :: voters -> let* prop = Op.proposals (B state.block) voter [get_n protos 0] in let* props = @@ -190,7 +194,8 @@ let ballot_exploration_descriptor = let ballot = pick_one ballots in Op.ballot (B state.block) contract Protocol_hash.zero ballot in - List.map_es gen state.voters); + let* voters = get_voters state in + List.map_es gen voters); } let proposal_descriptor = @@ -212,7 +217,8 @@ let proposal_descriptor = assert (voting_period_info.voting_period.kind = Proposal) ; Op.proposals (B state.block) contract [Protocol_hash.zero] in - List.map_es gen state.voters); + let* voters = get_voters state in + List.map_es gen voters); } (** [Promotion] is the 4th voting period, it requires 3 voting period @@ -254,12 +260,13 @@ let ballot_promotion_descriptor = state.block.Block.header.Block_header.shell.level blocks_per_cycle in + let* voters = get_voters state in if rem = 0l then let* ops = List.map_es (fun voter -> Op.ballot (B state.block) voter Protocol_hash.zero Vote.Yay) - state.voters + voters in return (ops, state) else return ([], state) ); @@ -274,7 +281,8 @@ let ballot_promotion_descriptor = let ballot = Stdlib.List.hd ballots in Op.ballot (B state.block) contract Protocol_hash.zero ballot in - List.map_es gen state.voters); + let* voters = get_voters state in + List.map_es gen voters); } let seed_nonce_descriptor = diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli index ce23fb42e91e..3999ceddf8ac 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli +++ b/src/proto_alpha/lib_protocol/test/integration/validate/generator_descriptors.mli @@ -44,9 +44,6 @@ type dbl_attestation_state = { (** Generic generation state collecting information to generate any kind of operation. - For example, {!Manager.infos} for manager - or voters (Contract.t list) for voting operations... - When adding a new operation kind, [state] might be extended if a new kind of information is required for this new kind valid operations generation. *) @@ -55,7 +52,6 @@ type state = { pred : Block.t option; bootstraps : public_key_hash list; delegates : (public_key_hash * public_key_hash option) list; - voters : Contract.t list; seed_nonce_to_reveal : (Raw_level.t * Nonce_hash.t) list; commitments : secret_account list; protocol_hashes : Protocol_hash.t list; @@ -65,10 +61,8 @@ type state = { manager : Manager.infos; } -(** The initialization of a [state] requires the [voters] contracts -- - the contracts allowed to vote -- and the [bootstraps] contracts. *) -val init_state : - Block.t -> voters:Contract.t list -> bootstraps:Contract.t list -> state +(** The initialization of a [state] requires the [bootstraps] contracts. *) +val init_state : Block.t -> bootstraps:Contract.t list -> state (** {2 Descriptor for valid operations generation} *) diff --git a/src/proto_alpha/lib_protocol/test/integration/validate/valid_operations_generators.ml b/src/proto_alpha/lib_protocol/test/integration/validate/valid_operations_generators.ml index 4ad2e5a82c3c..d3cbee7f2c39 100644 --- a/src/proto_alpha/lib_protocol/test/integration/validate/valid_operations_generators.ml +++ b/src/proto_alpha/lib_protocol/test/integration/validate/valid_operations_generators.ml @@ -163,10 +163,6 @@ let init nb_accounts descrs = let* initial_block, bootstraps = Context.init_with_parameters_n setup.params nb_accounts in - let* voters = Context.Vote.get_listings (B initial_block) in - let* initial_voters = - List.map_es (fun (c, _) -> return (Contract.Implicit c)) voters - in let my_bake selected_preludes_for_cycle state = let* state, operations = List.fold_left_es @@ -205,7 +201,7 @@ let init nb_accounts descrs = let* state = List.fold_left_es (fun state cycle -> my_bake_until_cycle_end cycle state) - (init_state initial_block ~voters:initial_voters ~bootstraps) + (init_state initial_block ~bootstraps) (Stdlib.List.init setup.nb_cycles Fun.id) in let my_bake_n_default n state = -- GitLab From 876e317990ab8d88b37b93e248a9a331a4062ecd Mon Sep 17 00:00:00 2001 From: Marina Polubelova Date: Wed, 20 Aug 2025 15:12:25 +0200 Subject: [PATCH 17/17] Docs: update changelog --- docs/protocols/alpha.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index c2b912c2501e..800049857342 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -124,6 +124,20 @@ Protocol parameters ``consensus_rights_delay + slashing_delay + 2 = 1 + 1 + 2 = 4`` cycles are needed. (MR :gl:`!18783`) +- Replaced the ``tolerated_inactivity_period`` protocol constant with + three new protocol constants: ``tolerated_inactivity_period_low``, + ``tolerated_inactivity_period_high`` and + ``tolerated_inactivity_period_threshold``. The tolerated inactivity + period now depends on the delegate's stake ratio over the total + active stake. If the ratio is greater than the + ``tolerated_inactivity_period_threshold = 10`` (expressed in 'per + thousand'), we apply a low tolerance + ``tolerated_inactivity_period_low = 1``. Otherwise, we apply a high + tolerance ``tolerated_inactivity_period_high = 12``. If the stake is + unknown, we apply a low tolerance (e.g., after the delegate's + registration, reactivation, or decreasing its stake below + ``minimal_stake``). (MR :gl:`!17582`) + Bug Fixes --------- -- GitLab