From b4ada677c13d7f9e482f750f158361e8ff797441 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:04:36 +0100 Subject: [PATCH 01/14] Proto/Delegate_slashed_deposits_storage: move up get_initial_frozen_deposits_of_misbehaviour_cycle --- .../delegate_slashed_deposits_storage.ml | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index d6d19835a031..ad27159c07f8 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -106,14 +106,26 @@ let punish_double_signing ctxt ~operation_hash misbehaviour delegate - for the kind: double baking > double attesting > double preattesting *) module MisMap = Map.Make (Misbehaviour_repr) -let apply_and_clear_denunciations ctxt = - let open Lwt_result_syntax in - let current_cycle = (Raw_context.current_level ctxt).cycle in +let get_initial_frozen_deposits_of_misbehaviour_cycle ~current_cycle + ~misbehaviour_cycle = let previous_cycle = match Cycle_repr.pred current_cycle with | None -> current_cycle | Some previous_cycle -> previous_cycle in + if Cycle_repr.equal current_cycle misbehaviour_cycle then + Delegate_storage.initial_frozen_deposits + else if Cycle_repr.equal previous_cycle misbehaviour_cycle then + Delegate_storage.initial_frozen_deposits_of_previous_cycle + else fun (_ : Raw_context.t) (_ : Signature.public_key_hash) -> + (* Denunciation applied too late. + We could assert false, but we can also be permissive + while keeping the same invariants. *) + return Tez_repr.zero + +let apply_and_clear_denunciations ctxt = + let open Lwt_result_syntax in + let current_cycle = (Raw_context.current_level ctxt).cycle in let slashable_deposits_period = Constants_storage.slashable_deposits_period ctxt in @@ -234,17 +246,6 @@ let apply_and_clear_denunciations ctxt = (Misbehaviour_repr.compare miskey misbehaviour) 0) ; (* Validate ensures that [denunciations] contains [delegate] at most once *) - let get_initial_frozen_deposits_of_misbehaviour_cycle = - if Cycle_repr.equal current_cycle misbehaviour_cycle then - Delegate_storage.initial_frozen_deposits - else if Cycle_repr.equal previous_cycle misbehaviour_cycle then - Delegate_storage.initial_frozen_deposits_of_previous_cycle - else fun (_ : Raw_context.t) (_ : Signature.public_key_hash) -> - return Tez_repr.zero - (* (denunciation applied too late) - We could assert false, but we can also be permissive - while keeping the same invariants *) - in let delegate_contract = Contract_repr.Implicit delegate in let* slash_history_opt = Storage.Contract.Slashed_deposits.find ctxt delegate_contract @@ -282,6 +283,8 @@ let apply_and_clear_denunciations ctxt = let* frozen_deposits = let* initial_amount = get_initial_frozen_deposits_of_misbehaviour_cycle + ~current_cycle + ~misbehaviour_cycle ctxt delegate in -- GitLab From 0bf73f5206e65292b40093d1cebff60d5101c06f Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:06:19 +0100 Subject: [PATCH 02/14] Proto/Delegate_slashed_deposits_storage: move up compute_punishing_amount slashing_percentage --- .../delegate_slashed_deposits_storage.ml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index ad27159c07f8..6bf270289e8a 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -106,6 +106,15 @@ let punish_double_signing ctxt ~operation_hash misbehaviour delegate - for the kind: double baking > double attesting > double preattesting *) module MisMap = Map.Make (Misbehaviour_repr) +let compute_punishing_amount slashing_percentage frozen_deposits = + let punish_value = + Tez_repr.mul_percentage + ~rounding:`Down + frozen_deposits.Deposits_repr.initial_amount + slashing_percentage + in + Tez_repr.min punish_value frozen_deposits.Deposits_repr.current_amount + let get_initial_frozen_deposits_of_misbehaviour_cycle ~current_cycle ~misbehaviour_cycle = let previous_cycle = @@ -139,14 +148,8 @@ let apply_and_clear_denunciations ctxt = let compute_reward_and_burn slashing_percentage (frozen_deposits : Deposits_repr.t) = let open Result_syntax in - let punish_value = - Tez_repr.mul_percentage - ~rounding:`Down - frozen_deposits.initial_amount - slashing_percentage - in let punishing_amount = - Tez_repr.min punish_value frozen_deposits.current_amount + compute_punishing_amount slashing_percentage frozen_deposits in let* reward = Tez_repr.( -- GitLab From af47136eaa7ddc4e40bb351ebdd436c33c5ae12a Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:08:57 +0100 Subject: [PATCH 03/14] Proto/Delegate_slashed_deposits_storage: move up compute_reward_and_burn --- .../delegate_slashed_deposits_storage.ml | 41 +++++++++---------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index 6bf270289e8a..580a92137bdd 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -115,6 +115,24 @@ let compute_punishing_amount slashing_percentage frozen_deposits = in Tez_repr.min punish_value frozen_deposits.Deposits_repr.current_amount +let compute_reward_and_burn ctxt slashing_percentage frozen_deposits = + let open Result_syntax in + let punishing_amount = + compute_punishing_amount slashing_percentage frozen_deposits + in + let global_limit_of_staking_over_baking_plus_two = + let global_limit_of_staking_over_baking = + Constants_storage.adaptive_issuance_global_limit_of_staking_over_baking + ctxt + in + Int64.add (Int64.of_int global_limit_of_staking_over_baking) 2L + in + let* reward = + Tez_repr.(punishing_amount /? global_limit_of_staking_over_baking_plus_two) + in + let+ amount_to_burn = Tez_repr.(punishing_amount -? reward) in + {reward; amount_to_burn} + let get_initial_frozen_deposits_of_misbehaviour_cycle ~current_cycle ~misbehaviour_cycle = let previous_cycle = @@ -138,26 +156,6 @@ let apply_and_clear_denunciations ctxt = let slashable_deposits_period = Constants_storage.slashable_deposits_period ctxt in - let global_limit_of_staking_over_baking_plus_two = - let global_limit_of_staking_over_baking = - Constants_storage.adaptive_issuance_global_limit_of_staking_over_baking - ctxt - in - Int64.add (Int64.of_int global_limit_of_staking_over_baking) 2L - in - let compute_reward_and_burn slashing_percentage - (frozen_deposits : Deposits_repr.t) = - let open Result_syntax in - let punishing_amount = - compute_punishing_amount slashing_percentage frozen_deposits - in - let* reward = - Tez_repr.( - punishing_amount /? global_limit_of_staking_over_baking_plus_two) - in - let+ amount_to_burn = Tez_repr.(punishing_amount -? reward) in - {reward; amount_to_burn} - in (* Split denunciations into two groups: to be applied, and to be delayed *) let*! block_denunciations_map, remaining_denunciations = Pending_denunciations_storage.fold @@ -297,7 +295,7 @@ let apply_and_clear_denunciations ctxt = return Deposits_repr.{initial_amount; current_amount} in let*? staked = - compute_reward_and_burn slashing_percentage frozen_deposits + compute_reward_and_burn ctxt slashing_percentage frozen_deposits in let* init_to_burn_to_reward = let giver_baker = @@ -345,6 +343,7 @@ let apply_and_clear_denunciations ctxt = in let*? {amount_to_burn; reward} = compute_reward_and_burn + ctxt slashing_percentage frozen_deposits in -- GitLab From 267e2f4c5c192d3fa913f226eeccbc19dc473427 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:10:36 +0100 Subject: [PATCH 04/14] Proto/Delegate_slashed_deposits_storage: move up update_block_denunciations_map_with --- .../delegate_slashed_deposits_storage.ml | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index 580a92137bdd..2b31443df159 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -150,6 +150,27 @@ let get_initial_frozen_deposits_of_misbehaviour_cycle ~current_cycle while keeping the same invariants. *) return Tez_repr.zero +let update_block_denunciations_map_with delegate denunciations initial_block_map + = + List.fold_left + (fun block_map denunciation -> + MisMap.update + denunciation.Denunciations_repr.misbehaviour + (function + | None -> + Some + (Signature.Public_key_hash.Map.singleton delegate denunciation) + | Some map -> + Some + (Signature.Public_key_hash.Map.update + delegate + (function + | None -> Some denunciation | Some old_d -> Some old_d) + map)) + block_map) + initial_block_map + denunciations + let apply_and_clear_denunciations ctxt = let open Lwt_result_syntax in let current_cycle = (Raw_context.current_level ctxt).cycle in @@ -188,32 +209,16 @@ let apply_and_clear_denunciations ctxt = Cycle_repr.(misb_cycle < current_cycle)) denunciations in - let block_map = - List.fold_left - (fun block_map denunciation -> - MisMap.update - denunciation.Denunciations_repr.misbehaviour - (function - | None -> - Some - (Signature.Public_key_hash.Map.singleton - delegate - denunciation) - | Some map -> - Some - (Signature.Public_key_hash.Map.update - delegate - (function - | None -> Some denunciation - | Some old_d -> Some old_d) - map)) - block_map) - block_map + let new_block_map = + update_block_denunciations_map_with + delegate denunciations_to_apply + block_map + in + let new_remaining_denunciations = + (delegate, denunciations_to_delay) :: remaining_denunciations in - Lwt.return - ( block_map, - (delegate, denunciations_to_delay) :: remaining_denunciations )) + Lwt.return (new_block_map, new_remaining_denunciations)) in (* Processes the applicable denunciations *) let* ctxt, balance_updates = -- GitLab From a965280adcbd6c7e2a722b21bcbfc8409704a11d Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:12:06 +0100 Subject: [PATCH 05/14] Proto/Delegate_slashed_deposits_storage: move up get_block_and_remaining_denunciations --- .../delegate_slashed_deposits_storage.ml | 81 ++++++++++--------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index 2b31443df159..f8abaebb080f 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -171,6 +171,46 @@ let update_block_denunciations_map_with delegate denunciations initial_block_map initial_block_map denunciations +let get_block_and_remaining_denunciations ctxt current_cycle = + Storage.Pending_denunciations.fold + ctxt + ~order:`Undefined + ~init:(MisMap.empty, []) + ~f:(fun delegate denunciations acc -> + let block_map, remaining_denunciations = acc in + (* Since the [max_slashing_period] is 2, and we want to apply denunciations at the + end of this period, we "delay" the current cycle's misbehaviour's denunciations, + while we apply the older denunciations. + Indeed, we apply denunciations in the cycle following the misbehaviour, so that + the time between the misbehaviour and the slashing is at most + [max_slashing_period = 2] cycles. *) + let denunciations_to_apply, denunciations_to_delay = + if not (Constants_storage.adaptive_issuance_ns_enable ctxt) then + (denunciations, []) + else + List.partition + (fun denunciation -> + let level = denunciation.Denunciations_repr.misbehaviour.level in + let misb_cycle = + (Level_repr.level_from_raw + ~cycle_eras:(Raw_context.cycle_eras ctxt) + level) + .cycle + in + Cycle_repr.(misb_cycle < current_cycle)) + denunciations + in + let new_block_map = + update_block_denunciations_map_with + delegate + denunciations_to_apply + block_map + in + let new_remaining_denunciations = + (delegate, denunciations_to_delay) :: remaining_denunciations + in + Lwt.return (new_block_map, new_remaining_denunciations)) + let apply_and_clear_denunciations ctxt = let open Lwt_result_syntax in let current_cycle = (Raw_context.current_level ctxt).cycle in @@ -179,46 +219,7 @@ let apply_and_clear_denunciations ctxt = in (* Split denunciations into two groups: to be applied, and to be delayed *) let*! block_denunciations_map, remaining_denunciations = - Pending_denunciations_storage.fold - ctxt - ~order:`Undefined - ~init:(MisMap.empty, []) - ~f:(fun delegate denunciations acc -> - let block_map, remaining_denunciations = acc in - (* Since the [max_slashing_period] is 2, and we want to apply denunciations at the - end of this period, we "delay" the current cycle's misbehaviour's denunciations, - while we apply the older denunciations. - Indeed, we apply denunciations in the cycle following the misbehaviour, so that - the time between the misbehaviour and the slashing is at most - [max_slashing_period = 2] cycles. *) - let denunciations_to_apply, denunciations_to_delay = - if not (Constants_storage.adaptive_issuance_ns_enable ctxt) then - (denunciations, []) - else - List.partition - (fun denunciation -> - let level = - denunciation.Denunciations_repr.misbehaviour.level - in - let misb_cycle = - (Level_repr.level_from_raw - ~cycle_eras:(Raw_context.cycle_eras ctxt) - level) - .cycle - in - Cycle_repr.(misb_cycle < current_cycle)) - denunciations - in - let new_block_map = - update_block_denunciations_map_with - delegate - denunciations_to_apply - block_map - in - let new_remaining_denunciations = - (delegate, denunciations_to_delay) :: remaining_denunciations - in - Lwt.return (new_block_map, new_remaining_denunciations)) + get_block_and_remaining_denunciations ctxt current_cycle in (* Processes the applicable denunciations *) let* ctxt, balance_updates = -- GitLab From cddcb5d37fa6a0bbce545a23eb14f65ecb54206d Mon Sep 17 00:00:00 2001 From: phink Date: Fri, 16 Feb 2024 17:43:45 +0100 Subject: [PATCH 06/14] Proto/Delegate_slashed_deposits_storage: renaming Rename get_block_and_remaining_denunciations into get_applicable_and_remaining_denunciations --- .../lib_protocol/delegate_slashed_deposits_storage.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index f8abaebb080f..ef6e592fdf4b 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -171,7 +171,7 @@ let update_block_denunciations_map_with delegate denunciations initial_block_map initial_block_map denunciations -let get_block_and_remaining_denunciations ctxt current_cycle = +let get_applicable_and_remaining_denunciations ctxt current_cycle = Storage.Pending_denunciations.fold ctxt ~order:`Undefined @@ -219,7 +219,7 @@ let apply_and_clear_denunciations ctxt = in (* Split denunciations into two groups: to be applied, and to be delayed *) let*! block_denunciations_map, remaining_denunciations = - get_block_and_remaining_denunciations ctxt current_cycle + get_applicable_and_remaining_denunciations ctxt current_cycle in (* Processes the applicable denunciations *) let* ctxt, balance_updates = -- GitLab From 38e4583386bf1935427d5a7766a6ea73303c2a41 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:13:26 +0100 Subject: [PATCH 07/14] Proto/Delegate_slashed_deposits_storage: move up apply_block_denunciations --- .../delegate_slashed_deposits_storage.ml | 331 +++++++++--------- 1 file changed, 166 insertions(+), 165 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index ef6e592fdf4b..17be7fcf4ce0 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -115,16 +115,13 @@ let compute_punishing_amount slashing_percentage frozen_deposits = in Tez_repr.min punish_value frozen_deposits.Deposits_repr.current_amount -let compute_reward_and_burn ctxt slashing_percentage frozen_deposits = +let compute_reward_and_burn slashing_percentage frozen_deposits + global_limit_of_staking_over_baking = let open Result_syntax in let punishing_amount = compute_punishing_amount slashing_percentage frozen_deposits in let global_limit_of_staking_over_baking_plus_two = - let global_limit_of_staking_over_baking = - Constants_storage.adaptive_issuance_global_limit_of_staking_over_baking - ctxt - in Int64.add (Int64.of_int global_limit_of_staking_over_baking) 2L in let* reward = @@ -211,182 +208,186 @@ let get_applicable_and_remaining_denunciations ctxt current_cycle = in Lwt.return (new_block_map, new_remaining_denunciations)) -let apply_and_clear_denunciations ctxt = - let open Lwt_result_syntax in - let current_cycle = (Raw_context.current_level ctxt).cycle in +let apply_block_denunciations ctxt current_cycle block_denunciations_map = let slashable_deposits_period = Constants_storage.slashable_deposits_period ctxt in - (* Split denunciations into two groups: to be applied, and to be delayed *) - let*! block_denunciations_map, remaining_denunciations = - get_applicable_and_remaining_denunciations ctxt current_cycle + let open Lwt_result_syntax in + let global_limit_of_staking_over_baking = + Constants_storage.adaptive_issuance_global_limit_of_staking_over_baking ctxt in - (* Processes the applicable denunciations *) - let* ctxt, balance_updates = - MisMap.fold_es - (fun ({Misbehaviour_repr.level = raw_level; round = _; kind; _} as miskey) - denunciations_map - acc -> - let ctxt, balance_updates = acc in - let level = - Level_repr.level_from_raw - ~cycle_eras:(Raw_context.cycle_eras ctxt) - raw_level - in - let misbehaviour_cycle = level.cycle in - let denunciations = - Signature.Public_key_hash.Map.bindings denunciations_map - in - let denounced = List.map fst denunciations in - let* ctxt, slashing_percentage = - Slash_percentage.get ctxt ~kind ~level denounced - in - let+ ctxt, balance_updates = - List.fold_left_es - (fun (ctxt, balance_updates) - ( delegate, - Denunciations_repr.{operation_hash; rewarded; misbehaviour} - ) -> - assert ( - Compare.Int.equal - (* This compare ignores the slot *) - (Misbehaviour_repr.compare miskey misbehaviour) - 0) ; - (* Validate ensures that [denunciations] contains [delegate] at most once *) - let delegate_contract = Contract_repr.Implicit delegate in - let* slash_history_opt = - Storage.Contract.Slashed_deposits.find ctxt delegate_contract - in - let slash_history = Option.value slash_history_opt ~default:[] in - let previous_total_slashing_percentage = - Storage.Slashed_deposits_history.get level.cycle slash_history - in - let slash_history = - Storage.Slashed_deposits_history.add - level.cycle - slashing_percentage - slash_history - in - let*! ctxt = - Storage.Contract.Slashed_deposits.add + + MisMap.fold_es + (fun ({Misbehaviour_repr.level = raw_level; round = _; kind; _} as miskey) + denunciations_map + acc -> + let ctxt, balance_updates = acc in + let level = + Level_repr.level_from_raw + ~cycle_eras:(Raw_context.cycle_eras ctxt) + raw_level + in + let misbehaviour_cycle = level.cycle in + let denunciations = + Signature.Public_key_hash.Map.bindings denunciations_map + in + let denounced = List.map fst denunciations in + let* ctxt, slashing_percentage = + Slash_percentage.get ctxt ~kind ~level denounced + in + let+ ctxt, balance_updates = + List.fold_left_es + (fun (ctxt, balance_updates) + ( delegate, + Denunciations_repr.{operation_hash; rewarded; misbehaviour} ) -> + assert ( + Compare.Int.equal + (* This compare ignores the slot *) + (Misbehaviour_repr.compare miskey misbehaviour) + 0) ; + (* Validate ensures that [denunciations] contains [delegate] at most once *) + let delegate_contract = Contract_repr.Implicit delegate in + let* slash_history_opt = + Storage.Contract.Slashed_deposits.find ctxt delegate_contract + in + let slash_history = Option.value slash_history_opt ~default:[] in + let previous_total_slashing_percentage = + Storage.Slashed_deposits_history.get level.cycle slash_history + in + let slash_history = + Storage.Slashed_deposits_history.add + level.cycle + slashing_percentage + slash_history + in + let*! ctxt = + Storage.Contract.Slashed_deposits.add + ctxt + delegate_contract + slash_history + in + let new_total_slashing_percentage = + Storage.Slashed_deposits_history.get level.cycle slash_history + in + (* We do not slash above 100%: if the slashing percentage would + make the total sum of the slashing history above 100%, we rectify + it to reach exactly 100%. This also means that subsequent slashes + are effectively ignored (set to 0%) *) + let slashing_percentage = + Percentage.sub_bounded + new_total_slashing_percentage + previous_total_slashing_percentage + in + let* frozen_deposits = + let* initial_amount = + get_initial_frozen_deposits_of_misbehaviour_cycle + ~current_cycle + ~misbehaviour_cycle ctxt - delegate_contract - slash_history + delegate in - - let new_total_slashing_percentage = - Storage.Slashed_deposits_history.get level.cycle slash_history + let* current_amount = + Delegate_storage.current_frozen_deposits ctxt delegate in - (* We do not slash above 100%: if the slashing percentage would - make the total sum of the slashing history above 100%, we rectify - it to reach exactly 100%. This also means that subsequent slashes - are effectively ignored (set to 0%) *) - let slashing_percentage = - Percentage.sub_bounded - new_total_slashing_percentage - previous_total_slashing_percentage + return Deposits_repr.{initial_amount; current_amount} + in + let*? staked = + compute_reward_and_burn + slashing_percentage + frozen_deposits + global_limit_of_staking_over_baking + in + let* init_to_burn_to_reward = + let giver_baker = + `Frozen_deposits (Frozen_staker_repr.baker delegate) in - - let* frozen_deposits = - let* initial_amount = - get_initial_frozen_deposits_of_misbehaviour_cycle - ~current_cycle - ~misbehaviour_cycle + let giver_stakers = + `Frozen_deposits + (Frozen_staker_repr.shared_between_stakers ~delegate) + in + let {amount_to_burn; reward} = staked in + let* to_burn = + let+ {baker_part; stakers_part} = + Shared_stake.share + ~rounding:`Towards_baker ctxt delegate + amount_to_burn in - let* current_amount = - Delegate_storage.current_frozen_deposits ctxt delegate - in - return Deposits_repr.{initial_amount; current_amount} - in - let*? staked = - compute_reward_and_burn ctxt slashing_percentage frozen_deposits - in - let* init_to_burn_to_reward = - let giver_baker = - `Frozen_deposits (Frozen_staker_repr.baker delegate) - in - let giver_stakers = - `Frozen_deposits - (Frozen_staker_repr.shared_between_stakers ~delegate) - in - let {amount_to_burn; reward} = staked in - let* to_burn = - let+ {baker_part; stakers_part} = - Shared_stake.share - ~rounding:`Towards_baker - ctxt - delegate - amount_to_burn - in - [(giver_baker, baker_part); (giver_stakers, stakers_part)] - in - let* to_reward = - let+ {baker_part; stakers_part} = - Shared_stake.share - ~rounding:`Towards_baker - ctxt - delegate - reward - in - [(giver_baker, baker_part); (giver_stakers, stakers_part)] - in - return (to_burn, to_reward) + [(giver_baker, baker_part); (giver_stakers, stakers_part)] in - let* to_burn, to_reward = - let oldest_slashable_cycle = - Cycle_repr.sub misbehaviour_cycle slashable_deposits_period - |> Option.value ~default:Cycle_repr.root - in - let slashable_cycles = - Cycle_repr.(oldest_slashable_cycle ---> misbehaviour_cycle) + let* to_reward = + let+ {baker_part; stakers_part} = + Shared_stake.share + ~rounding:`Towards_baker + ctxt + delegate + reward in - List.fold_left_es - (fun (to_burn, to_reward) cycle -> - let* frozen_deposits = - Unstaked_frozen_deposits_storage.get ctxt delegate cycle - in - let*? {amount_to_burn; reward} = - compute_reward_and_burn - ctxt - slashing_percentage - frozen_deposits - in - let giver = - `Unstaked_frozen_deposits - (Unstaked_frozen_staker_repr.Shared delegate, cycle) - in - return - ( (giver, amount_to_burn) :: to_burn, - (giver, reward) :: to_reward )) - init_to_burn_to_reward - slashable_cycles + [(giver_baker, baker_part); (giver_stakers, stakers_part)] in - let origin = Receipt_repr.Delayed_operation {operation_hash} in - let* ctxt, punish_balance_updates = - Token.transfer_n - ctxt - ~origin - to_burn - `Double_signing_punishments + return (to_burn, to_reward) + in + let* to_burn, to_reward = + let oldest_slashable_cycle = + Cycle_repr.sub misbehaviour_cycle slashable_deposits_period + |> Option.value ~default:Cycle_repr.root in - let+ ctxt, reward_balance_updates = - Token.transfer_n - ctxt - ~origin - to_reward - (`Contract (Contract_repr.Implicit rewarded)) + let slashable_cycles = + Cycle_repr.(oldest_slashable_cycle ---> misbehaviour_cycle) in - ( ctxt, - punish_balance_updates @ reward_balance_updates - @ balance_updates )) - (ctxt, balance_updates) - denunciations - in - (ctxt, balance_updates)) - block_denunciations_map - (ctxt, []) + List.fold_left_es + (fun (to_burn, to_reward) cycle -> + let* frozen_deposits = + Unstaked_frozen_deposits_storage.get ctxt delegate cycle + in + let*? {amount_to_burn; reward} = + compute_reward_and_burn + slashing_percentage + frozen_deposits + global_limit_of_staking_over_baking + in + let giver = + `Unstaked_frozen_deposits + (Unstaked_frozen_staker_repr.Shared delegate, cycle) + in + return + ( (giver, amount_to_burn) :: to_burn, + (giver, reward) :: to_reward )) + init_to_burn_to_reward + slashable_cycles + in + let origin = Receipt_repr.Delayed_operation {operation_hash} in + let* ctxt, punish_balance_updates = + Token.transfer_n ctxt ~origin to_burn `Double_signing_punishments + in + let+ ctxt, reward_balance_updates = + Token.transfer_n + ctxt + ~origin + to_reward + (`Contract (Contract_repr.Implicit rewarded)) + in + ( ctxt, + punish_balance_updates @ reward_balance_updates @ balance_updates + )) + (ctxt, balance_updates) + denunciations + in + (ctxt, balance_updates)) + block_denunciations_map + (ctxt, []) + +let apply_and_clear_denunciations ctxt = + let open Lwt_result_syntax in + let current_cycle = (Raw_context.current_level ctxt).cycle in + (* Split denunciations into two groups: to be applied, and to be delayed *) + let*! block_denunciations_map, remaining_denunciations = + get_applicable_and_remaining_denunciations ctxt current_cycle + in + (* Processes the applicable denunciations *) + let* ctxt, balance_updates = + apply_block_denunciations ctxt current_cycle block_denunciations_map in (* Updates the storage to only contain the remaining denunciations *) let*! ctxt = Pending_denunciations_storage.clear ctxt in -- GitLab From 36dc8cb72482b55f05ed1c2a5fbeaa3e4ebf677b Mon Sep 17 00:00:00 2001 From: phink Date: Fri, 16 Feb 2024 17:45:33 +0100 Subject: [PATCH 08/14] Proto/Delegate_slashed_deposits_storage: move up apply_denunciations --- .../delegate_slashed_deposits_storage.ml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index 17be7fcf4ce0..acd26fd1d7f6 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -168,6 +168,7 @@ let update_block_denunciations_map_with delegate denunciations initial_block_map initial_block_map denunciations +(* Split denunciations into two groups: those to be applied, and those to be delayed. *) let get_applicable_and_remaining_denunciations ctxt current_cycle = Storage.Pending_denunciations.fold ctxt @@ -216,7 +217,6 @@ let apply_block_denunciations ctxt current_cycle block_denunciations_map = let global_limit_of_staking_over_baking = Constants_storage.adaptive_issuance_global_limit_of_staking_over_baking ctxt in - MisMap.fold_es (fun ({Misbehaviour_repr.level = raw_level; round = _; kind; _} as miskey) denunciations_map @@ -378,16 +378,21 @@ let apply_block_denunciations ctxt current_cycle block_denunciations_map = block_denunciations_map (ctxt, []) -let apply_and_clear_denunciations ctxt = +let apply_denunciations ctxt = let open Lwt_result_syntax in let current_cycle = (Raw_context.current_level ctxt).cycle in - (* Split denunciations into two groups: to be applied, and to be delayed *) - let*! block_denunciations_map, remaining_denunciations = + let*! applicable_denunciations_map, remaining_denunciations = get_applicable_and_remaining_denunciations ctxt current_cycle in - (* Processes the applicable denunciations *) let* ctxt, balance_updates = - apply_block_denunciations ctxt current_cycle block_denunciations_map + apply_block_denunciations ctxt current_cycle applicable_denunciations_map + in + return (ctxt, balance_updates, remaining_denunciations) + +let apply_and_clear_denunciations ctxt = + let open Lwt_result_syntax in + let* ctxt, balance_updates, remaining_denunciations = + apply_denunciations ctxt in (* Updates the storage to only contain the remaining denunciations *) let*! ctxt = Pending_denunciations_storage.clear ctxt in -- GitLab From b767555ebe19f15c961d5cb6a558c04a01ffc389 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:15:17 +0100 Subject: [PATCH 09/14] Proto/Delegate_slashed_deposits_storage: get_estimated_pending_slashed_amount --- .../delegate_slashed_deposits_storage.ml | 127 ++++++++++++++++++ .../delegate_slashed_deposits_storage.mli | 14 ++ 2 files changed, 141 insertions(+) diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml index acd26fd1d7f6..fdc370c7a5bc 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.ml @@ -410,3 +410,130 @@ let apply_and_clear_denunciations ctxt = remaining_denunciations in return (ctxt, balance_updates) + +module For_RPC = struct + let get_pending_misbehaviour_map ctxt = + Storage.Pending_denunciations.fold + ctxt + ~order:`Undefined + ~init:MisMap.empty + ~f:(fun delegate denunciations block_map -> + let new_block_map = + update_block_denunciations_map_with delegate denunciations block_map + in + Lwt.return new_block_map) + + let get_estimated_punished_amount ctxt delegate = + let open Lwt_result_syntax in + let current_cycle = (Raw_context.current_level ctxt).cycle in + let* denunciations = Storage.Pending_denunciations.find ctxt delegate in + match denunciations with + | None | Some [] -> return Tez_repr.zero + | Some denunciations -> + let*! pending_misbehaviour_map = get_pending_misbehaviour_map ctxt in + List.fold_left_es + (fun estimated_punishing_amount denunciation -> + let ({Misbehaviour_repr.level = raw_level; kind; _} as + misbehaviour_key) = + denunciation.Denunciations_repr.misbehaviour + in + match MisMap.find misbehaviour_key pending_misbehaviour_map with + | None -> + (* Should not happen as [pending_misbehaviour_map] has been created + using the bindings of [Storage.Pending_denunciations] and + [denunciation] belongs to [Storage.Pending_denunciations]. *) + return estimated_punishing_amount + | Some denunciations -> + let level = + Level_repr.level_from_raw + ~cycle_eras:(Raw_context.cycle_eras ctxt) + raw_level + in + let denounced_pkhs = + List.map + fst + (Signature.Public_key_hash.Map.bindings denunciations) + in + let* ctxt, slashing_percentage = + Slash_percentage.get ctxt ~kind ~level denounced_pkhs + in + let misbehaviour_cycle = level.cycle in + let* frozen_deposits = + let* initial_amount = + get_initial_frozen_deposits_of_misbehaviour_cycle + ~current_cycle + ~misbehaviour_cycle + ctxt + delegate + in + let* current_amount = + Delegate_storage.current_frozen_deposits ctxt delegate + in + return {Deposits_repr.initial_amount; current_amount} + in + let punishing_amount = + compute_punishing_amount slashing_percentage frozen_deposits + in + let new_estimated_punishing_amount = + Tez_repr.(punishing_amount +? estimated_punishing_amount) + in + Lwt.return new_estimated_punishing_amount) + Tez_repr.zero + denunciations + + let get_estimated_punished_share ctxt delegate = + let open Lwt_result_syntax in + let* estimated_punished_amount = + get_estimated_punished_amount ctxt delegate + in + Shared_stake.share + ~rounding:`Towards_baker + ctxt + delegate + estimated_punished_amount + + let get_estimated_shared_pending_slashed_amount ctxt delegate = + let open Lwt_result_syntax in + let* {baker_part; stakers_part} = + get_estimated_punished_share ctxt delegate + in + Lwt.return Tez_repr.(baker_part +? stakers_part) + + let get_delegate_estimated_own_pending_slashed_amount ctxt ~delegate = + let open Lwt_result_syntax in + let+ {baker_part; stakers_part = _} = + get_estimated_punished_share ctxt delegate + in + baker_part + + let get_estimated_own_pending_slashed_amount ctxt contract = + let open Lwt_result_syntax in + let* delegate_opt = Contract_delegate_storage.find ctxt contract in + match delegate_opt with + | None -> return Tez_repr.zero + | Some delegate -> + if Contract_repr.(equal (Contract_repr.Implicit delegate) contract) then + get_delegate_estimated_own_pending_slashed_amount ctxt ~delegate + else + let* {baker_part = _; stakers_part} = + get_estimated_punished_share ctxt delegate + in + let* num = + let+ staking_pseudotokens = + Staking_pseudotokens_storage.For_RPC.staking_pseudotokens_balance + ctxt + ~delegator:contract + in + Staking_pseudotoken_repr.to_int64 staking_pseudotokens + in + let* den = + let+ frozen_deposits_pseudotokens = + Staking_pseudotokens_storage.For_RPC + .get_frozen_deposits_pseudotokens + ctxt + ~delegate + in + Staking_pseudotoken_repr.to_int64 frozen_deposits_pseudotokens + in + Lwt.return (Tez_repr.mul_ratio ~rounding:`Up stakers_part ~num ~den) +end diff --git a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.mli b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.mli index 4c19d8189c7e..3b08a5e4f6bb 100644 --- a/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.mli +++ b/src/proto_alpha/lib_protocol/delegate_slashed_deposits_storage.mli @@ -84,3 +84,17 @@ val apply_and_clear_denunciations : Raw_context.t -> (Raw_context.t * Receipt_repr.balance_updates) tzresult Lwt.t val update_slashing_storage_for_p : Raw_context.t -> Raw_context.t Lwt.t + +module For_RPC : sig + (** [get_estimated_shared_pending_slashed_amount ctxt delegate] + returns the estimated shared pending slashed amount of the given [delegate] + according to the currently available denunciations. *) + val get_estimated_shared_pending_slashed_amount : + Raw_context.t -> Signature.public_key_hash -> Tez_repr.t tzresult Lwt.t + + (** [get_estimated_own_pending_slashed_amount ctxt contract] + returns the estimated own pending slashed amount of the given [contract] + according to the currently available denunciations. *) + val get_estimated_own_pending_slashed_amount : + Raw_context.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t +end -- GitLab From 7537bd1ea6af057d7839ad4060b58efb67ea6e8d Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:16:11 +0100 Subject: [PATCH 10/14] Proto/Alpha_context: include Delegate_slashed_deposits_storage.For_RPC --- src/proto_alpha/lib_protocol/alpha_context.ml | 6 ++++++ src/proto_alpha/lib_protocol/alpha_context.mli | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml index dcecaeefcd05..2b93ccec6ba3 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.ml +++ b/src/proto_alpha/lib_protocol/alpha_context.ml @@ -398,6 +398,11 @@ module Contract = struct let get_delegate_status = Contract_delegate_storage.get_delegate_status + module For_RPC = struct + include Contract_storage.For_RPC + include Delegate_slashed_deposits_storage.For_RPC + end + module Delegate = struct let find = Contract_delegate_storage.find @@ -572,6 +577,7 @@ module Delegate = struct module For_RPC = struct include Delegate_storage.For_RPC + include Delegate_slashed_deposits_storage.For_RPC include Delegate_missed_attestations_storage.For_RPC include Pending_denunciations_storage.For_RPC diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli index 697bc0095a7b..8e0f633b6f7f 100644 --- a/src/proto_alpha/lib_protocol/alpha_context.mli +++ b/src/proto_alpha/lib_protocol/alpha_context.mli @@ -1877,6 +1877,12 @@ module Contract : sig context -> t -> Tez.t option tzresult Lwt.t val get_full_balance : context -> t -> Tez.t tzresult Lwt.t + + (** [get_estimated_own_pending_slashed_amount ctxt contract] + returns the estimated own pending slashed amount of the given [contract] + according to the currently available denunciations. *) + val get_estimated_own_pending_slashed_amount : + context -> t -> Tez.t tzresult Lwt.t end end @@ -2456,7 +2462,7 @@ module Delegate : sig end (** The functions in this module are considered too costly to be used in - the protocol. + the protocol. They are meant to be used only to answer RPC calls. *) module For_RPC : sig type participation_info = { @@ -2496,6 +2502,12 @@ module Delegate : sig val pending_denunciations_list : context -> (public_key_hash * Denunciations_repr.item) list Lwt.t + + (** [get_estimated_shared_pending_slashed_amount ctxt delegate] + returns the estimated shared pending slashed amount of the given [delegate] + according to the currently available denunciations. *) + val get_estimated_shared_pending_slashed_amount : + context -> public_key_hash -> Tez.t tzresult Lwt.t end end -- GitLab From abd181ad2d73a287d01bc38308a89f97ad62f90d Mon Sep 17 00:00:00 2001 From: phink Date: Thu, 15 Feb 2024 12:16:50 +0100 Subject: [PATCH 11/14] Proto/Delegate_service: estimated_pending_slashed_amount --- .../lib_protocol/delegate_services.ml | 26 ++++++++++++++++++- .../lib_protocol/delegate_services.mli | 3 +++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml index 4ce7a47a6336..ddfea5600563 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.ml +++ b/src/proto_alpha/lib_protocol/delegate_services.ml @@ -532,6 +532,15 @@ module S = struct ~query:RPC_query.empty ~output:(list Denunciations_repr.item_encoding) RPC_path.(path / "denunciations") + + let estimated_shared_pending_slashed_amount = + RPC_service.get_service + ~description: + "Returns the estimated shared pending slashed amount (in mutez) of a \ + given delegate." + ~query:RPC_query.empty + ~output:Tez.encoding + RPC_path.(path / "estimated_shared_pending_slashed_amount") end let check_delegate_registered ctxt pkh = @@ -743,7 +752,13 @@ let register () = register1 ~chunked:false S.pending_staking_parameters (fun ctxt pkh () () -> Delegate.Staking_parameters.pending_updates ctxt pkh) ; register1 ~chunked:false S.pending_denunciations (fun ctxt pkh () () -> - Delegate.For_RPC.pending_denunciations ctxt pkh) + Delegate.For_RPC.pending_denunciations ctxt pkh) ; + register1 + ~chunked:false + S.estimated_shared_pending_slashed_amount + (fun ctxt delegate () () -> + let* () = check_delegate_registered ctxt delegate in + Delegate.For_RPC.get_estimated_shared_pending_slashed_amount ctxt delegate) let list ctxt block ?(active = true) ?(inactive = false) ?(with_minimal_stake = true) ?(without_minimal_stake = false) () = @@ -818,3 +833,12 @@ let pending_staking_parameters ctxt block pkh = let pending_denunciations ctxt block pkh = RPC_context.make_call1 S.pending_denunciations ctxt block pkh () () + +let estimated_shared_pending_slashed_amount ctxt block pkh = + RPC_context.make_call1 + S.estimated_shared_pending_slashed_amount + ctxt + block + pkh + () + () diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli index be7bc6585733..3289cf9cd98a 100644 --- a/src/proto_alpha/lib_protocol/delegate_services.mli +++ b/src/proto_alpha/lib_protocol/delegate_services.mli @@ -197,4 +197,7 @@ val pending_denunciations : public_key_hash -> Denunciations_repr.t shell_tzresult Lwt.t +val estimated_shared_pending_slashed_amount : + 'a #RPC_context.simple -> 'a -> public_key_hash -> Tez.t shell_tzresult Lwt.t + val register : unit -> unit -- GitLab From 2eecc54289e7305c6553a2e54aa3fa48999f8404 Mon Sep 17 00:00:00 2001 From: phink Date: Wed, 14 Feb 2024 19:16:51 +0100 Subject: [PATCH 12/14] Proto/Contract_service: estimated_pending_slashed_amount --- .../lib_protocol/contract_services.ml | 26 +++++++++++++++++++ .../lib_protocol/contract_services.mli | 6 +++++ 2 files changed, 32 insertions(+) diff --git a/src/proto_alpha/lib_protocol/contract_services.ml b/src/proto_alpha/lib_protocol/contract_services.ml index 308535694aab..1b4e68cc0277 100644 --- a/src/proto_alpha/lib_protocol/contract_services.ml +++ b/src/proto_alpha/lib_protocol/contract_services.ml @@ -304,6 +304,16 @@ module S = struct ~output:(list Contract.encoding) custom_root + let estimated_own_pending_slashed_amount = + RPC_service.get_service + ~description: + "Returns the estimated own pending slashed amount (in mutez) of a \ + given contract." + ~query:RPC_query.empty + ~output:Tez.encoding + RPC_path.( + custom_root /: Contract.rpc_arg / "estimated_own_pending_slashed_amount") + module Sapling = struct (* Sapling: these RPCs are like Sapling RPCs (sapling_services.ml) @@ -714,6 +724,12 @@ let register () = script in {balance; delegate; script = Some script; counter = None})) ; + register1 + ~chunked:false + S.estimated_own_pending_slashed_amount + (fun ctxt contract () () -> + Contract.For_RPC.get_estimated_own_pending_slashed_amount ctxt contract) ; + S.Sapling.register () let list ctxt block = RPC_context.make_call0 S.list ctxt block () () @@ -778,6 +794,16 @@ let storage ctxt block contract = let contract = Contract.Originated contract in RPC_context.make_call1 S.storage ctxt block contract () () +let estimated_own_pending_slashed_amount ctxt block contract = + let contract = Contract.Implicit contract in + RPC_context.make_call1 + S.estimated_own_pending_slashed_amount + ctxt + block + contract + () + () + let entrypoint_type ctxt block contract entrypoint ~normalize_types = RPC_context.make_call2 S.entrypoint_type diff --git a/src/proto_alpha/lib_protocol/contract_services.mli b/src/proto_alpha/lib_protocol/contract_services.mli index 51d8ee862186..ead26032367e 100644 --- a/src/proto_alpha/lib_protocol/contract_services.mli +++ b/src/proto_alpha/lib_protocol/contract_services.mli @@ -155,6 +155,12 @@ val storage_opt : Contract_hash.t -> Script.expr option shell_tzresult Lwt.t +val estimated_own_pending_slashed_amount : + 'a #RPC_context.simple -> + 'a -> + Signature.public_key_hash -> + Tez.t shell_tzresult Lwt.t + val big_map_get : 'a #RPC_context.simple -> 'a -> -- GitLab From f0eb94228823e553e67338dc9c1d36b4caf5a90d Mon Sep 17 00:00:00 2001 From: phink Date: Thu, 15 Feb 2024 15:23:22 +0100 Subject: [PATCH 13/14] Proto/Test: add context helpers --- src/proto_alpha/lib_protocol/test/helpers/context.ml | 6 ++++++ src/proto_alpha/lib_protocol/test/helpers/context.mli | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml index f8dad7726763..d36166a0fb9d 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml @@ -336,6 +336,12 @@ let get_denunciations ctxt = let get_denunciations_for_delegate ctxt = Alpha_services.Delegate.pending_denunciations rpc_ctxt ctxt +let estimated_shared_pending_slashed_amount ctxt = + Alpha_services.Delegate.estimated_shared_pending_slashed_amount rpc_ctxt ctxt + +let estimated_own_pending_slashed_amount ctxt = + Alpha_services.Contract.estimated_own_pending_slashed_amount rpc_ctxt ctxt + module Dal = struct let shards ctxt = Plugin.RPC.Dal.dal_shards rpc_ctxt ctxt end diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli index 16cee0d26ffa..3939caf4de83 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/context.mli +++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli @@ -152,6 +152,12 @@ val get_denunciations_for_delegate : Signature.Public_key_hash.t -> Denunciations_repr.item list tzresult Lwt.t +val estimated_shared_pending_slashed_amount : + t -> public_key_hash -> Tez.t tzresult Lwt.t + +val estimated_own_pending_slashed_amount : + t -> public_key_hash -> Tez.t tzresult Lwt.t + module Vote : sig val get_ballots : t -> Vote.ballots tzresult Lwt.t -- GitLab From 4916b62dfd00b7398631155f7e91d4d51eff7f52 Mon Sep 17 00:00:00 2001 From: phink Date: Fri, 16 Feb 2024 12:17:16 +0100 Subject: [PATCH 14/14] Doc/Proto: update alpha.rst with new RPCs --- docs/protocols/alpha.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst index 3dd2bbc73aed..daf6522e2e71 100644 --- a/docs/protocols/alpha.rst +++ b/docs/protocols/alpha.rst @@ -125,6 +125,12 @@ RPC Changes This changes the JSON from the RPC ``/chains/main/blocks/head/context/constants`` and ``/chains/main/blocks/head/context/issuance/expected_issuance``. +- Add RPC to get contract's estimated own pending slashed amount according to the currently available denunciations. + ``GET /chains//blocks//context/contracts//estimated_own_pending_slashed_amount``. (MR :gl:`!12016`) + +- Add RPC to get delegate's estimated shared pending slashed amount according to the currently available denunciations. + ``GET /chains//blocks//context/delegates//estimated_shared_pending_slashed_amount``. (MR :gl:`!12016`) + Operation receipts ------------------ -- GitLab