From 32145ed9a79eaca61404f49373d8fb4e4ed089a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 10:08:01 +0200
Subject: [PATCH 1/7] Proto/staking: refactor computation of stakes from
 snapshot

To set the distribution of delegates, we need to iterate over all
active delegates in the selected snapshot and compute for each of them
their stake.

In this commit, we extract the computation of the stake of each
delegate from the iteration because we want to expose this computation
in some RPCs.
---
 .../lib_protocol/delegate_sampler.ml          | 116 ++++++++++--------
 1 file changed, 64 insertions(+), 52 deletions(-)

diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.ml b/src/proto_alpha/lib_protocol/delegate_sampler.ml
index 3a4227ecbd99..d42d44ffbd68 100644
--- a/src/proto_alpha/lib_protocol/delegate_sampler.ml
+++ b/src/proto_alpha/lib_protocol/delegate_sampler.ml
@@ -151,6 +151,65 @@ let load_sampler_for_cycle ctxt cycle =
   in
   return ctxt
 
+let get_delegate_stake_from_staking_balance ctxt
+    ~staking_over_baking_global_limit_millionth ~delegation_over_baking_limit
+    delegate staking_balance =
+  let open Lwt_result_syntax in
+  let delegate_contract = Contract_repr.Implicit delegate in
+  let* delegate_own_pseudotokens =
+    Staking_pseudotokens_storage.costaking_pseudotokens_balance
+      ctxt
+      delegate_contract
+  in
+  let* delegate_own_frozen_deposits =
+    Staking_pseudotokens_storage.tez_of_frozen_deposits_pseudotokens
+      ctxt
+      delegate
+      delegate_own_pseudotokens
+  in
+  let* {staking_over_baking_limit_millionth; _} =
+    Delegate_staking_parameters.of_delegate ctxt delegate
+  in
+  let staking_over_baking_limit_millionth =
+    let delegate_staking_over_baking_limit_millionth =
+      Int64.of_int32 staking_over_baking_limit_millionth
+    in
+    Compare.Int64.min
+      staking_over_baking_global_limit_millionth
+      delegate_staking_over_baking_limit_millionth
+  in
+  let staking_over_baking_limit_plus_1_millionth =
+    Int64.add 1_000_000L staking_over_baking_limit_millionth
+  in
+  let open Tez_repr in
+  let* {current_amount = all_frozen_deposits; initial_amount = _} =
+    Frozen_deposits_storage.get ctxt delegate_contract
+  in
+  let frozen =
+    match
+      mul_ratio
+        delegate_own_frozen_deposits
+        ~num:staking_over_baking_limit_plus_1_millionth
+        ~den:1_000_000L
+    with
+    | Ok max_allowed_frozen_deposits ->
+        min all_frozen_deposits max_allowed_frozen_deposits
+        (* Over-co-staked frozen deposits counts towards delegated stake. *)
+    | Error _max_allowed_frozen_deposits_overflows -> all_frozen_deposits
+  in
+  (* This subtraction may result in a negative value if tez were frozen
+     after the snapshot. This is fine, they are then taken into account as
+     frozen stake rather than delegated. *)
+  let available_delegated =
+    sub_opt staking_balance frozen |> Option.value ~default:zero
+  in
+  let delegated =
+    match delegate_own_frozen_deposits *? delegation_over_baking_limit with
+    | Ok max_allowed_delegated -> min max_allowed_delegated available_delegated
+    | Error _max_allowed_delegated_overflows -> available_delegated
+  in
+  return (Stake_repr.make ~frozen ~delegated)
+
 let get_stakes_for_selected_index ctxt index =
   let open Lwt_result_syntax in
   let delegation_over_baking_limit =
@@ -169,61 +228,14 @@ let get_stakes_for_selected_index ctxt index =
     ctxt
     ~index
     ~f:(fun (delegate, staking_balance) (acc, total_stake) ->
-      let delegate_contract = Contract_repr.Implicit delegate in
-      let* delegate_own_pseudotokens =
-        Staking_pseudotokens_storage.costaking_pseudotokens_balance
-          ctxt
-          delegate_contract
-      in
-      let* delegate_own_frozen_deposits =
-        Staking_pseudotokens_storage.tez_of_frozen_deposits_pseudotokens
+      let* stake_for_cycle =
+        get_delegate_stake_from_staking_balance
+          ~staking_over_baking_global_limit_millionth
+          ~delegation_over_baking_limit
           ctxt
           delegate
-          delegate_own_pseudotokens
-      in
-      let* {staking_over_baking_limit_millionth; _} =
-        Delegate_staking_parameters.of_delegate ctxt delegate
-      in
-      let staking_over_baking_limit_millionth =
-        let delegate_staking_over_baking_limit_millionth =
-          Int64.of_int32 staking_over_baking_limit_millionth
-        in
-        Compare.Int64.min
-          staking_over_baking_global_limit_millionth
-          delegate_staking_over_baking_limit_millionth
-      in
-      let staking_over_baking_limit_plus_1_millionth =
-        Int64.add 1_000_000L staking_over_baking_limit_millionth
-      in
-      let open Tez_repr in
-      let* {current_amount = all_frozen_deposits; initial_amount = _} =
-        Frozen_deposits_storage.get ctxt delegate_contract
-      in
-      let frozen =
-        match
-          mul_ratio
-            delegate_own_frozen_deposits
-            ~num:staking_over_baking_limit_plus_1_millionth
-            ~den:1_000_000L
-        with
-        | Ok max_allowed_frozen_deposits ->
-            min all_frozen_deposits max_allowed_frozen_deposits
-            (* Over-co-staked frozen deposits counts towards delegated stake. *)
-        | Error _max_allowed_frozen_deposits_overflows -> all_frozen_deposits
-      in
-      (* This subtraction may result in a negative value if tez were frozen
-         after the snapshot. This is fine, they are then taken into account as
-         frozen stake rather than delegated. *)
-      let available_delegated =
-        sub_opt staking_balance frozen |> Option.value ~default:zero
-      in
-      let delegated =
-        match delegate_own_frozen_deposits *? delegation_over_baking_limit with
-        | Ok max_allowed_delegated ->
-            min max_allowed_delegated available_delegated
-        | Error _max_allowed_delegated_overflows -> available_delegated
+          staking_balance
       in
-      let stake_for_cycle = Stake_repr.make ~frozen ~delegated in
       let*? total_stake = Stake_repr.(total_stake +? stake_for_cycle) in
       return ((delegate, stake_for_cycle) :: acc, total_stake))
     ~init:([], Stake_repr.zero)
-- 
GitLab


From d6d86b62498861d351b8f316bb190b2ab1d92b46 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 10:08:10 +0200
Subject: [PATCH 2/7] Proto/Staking: add delegate_baking_power_for_cycle

This adds a function to computing the baking power of a delegate in a
given cycle based on the snapshot selected for that cycle.
---
 src/proto_alpha/lib_protocol/alpha_context.ml |  2 +
 .../lib_protocol/alpha_context.mli            |  5 +++
 .../lib_protocol/delegate_sampler.ml          | 38 +++++++++++++++++++
 .../lib_protocol/delegate_sampler.mli         | 10 +++++
 4 files changed, 55 insertions(+)

diff --git a/src/proto_alpha/lib_protocol/alpha_context.ml b/src/proto_alpha/lib_protocol/alpha_context.ml
index 5779d0061c0e..035e94c78e8d 100644
--- a/src/proto_alpha/lib_protocol/alpha_context.ml
+++ b/src/proto_alpha/lib_protocol/alpha_context.ml
@@ -527,6 +527,8 @@ module Stake_distribution = struct
     let open Lwt_result_syntax in
     let* total_stake = Stake_storage.get_total_active_stake ctxt cycle in
     return (Stake_repr.get_frozen total_stake)
+
+  module For_RPC = Delegate_sampler.For_RPC
 end
 
 module Nonce = Nonce_storage
diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli
index 311987624be9..7aa2c53df7ab 100644
--- a/src/proto_alpha/lib_protocol/alpha_context.mli
+++ b/src/proto_alpha/lib_protocol/alpha_context.mli
@@ -4586,6 +4586,11 @@ module Stake_distribution : sig
   val load_sampler_for_cycle : context -> Cycle.t -> context tzresult Lwt.t
 
   val get_total_frozen_stake : context -> Cycle.t -> Tez.t tzresult Lwt.t
+
+  module For_RPC : sig
+    val delegate_baking_power_for_cycle :
+      context -> Cycle.t -> Signature.public_key_hash -> int64 tzresult Lwt.t
+  end
 end
 
 (** This module re-exports definitions from {!Commitment_repr} and,
diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.ml b/src/proto_alpha/lib_protocol/delegate_sampler.ml
index d42d44ffbd68..758d4761fe39 100644
--- a/src/proto_alpha/lib_protocol/delegate_sampler.ml
+++ b/src/proto_alpha/lib_protocol/delegate_sampler.ml
@@ -275,6 +275,30 @@ let select_distribution_for_cycle ctxt cycle =
   (* pre-allocate the sampler *)
   Lwt.return (Raw_context.init_sampler_for_cycle ctxt cycle seed state)
 
+let delegate_baking_power_from_staking_balance ctxt delegate staking_balance =
+  let open Lwt_result_syntax in
+  let delegation_over_baking_limit =
+    Int64.of_int (Constants_storage.delegation_over_baking_limit ctxt)
+  in
+  let staking_over_baking_global_limit_millionth =
+    Int64.(
+      mul
+        1_000_000L
+        (of_int
+           (Constants_storage
+            .adaptive_inflation_staking_over_baking_global_limit
+              ctxt)))
+  in
+  let+ stake =
+    get_delegate_stake_from_staking_balance
+      ctxt
+      ~staking_over_baking_global_limit_millionth
+      ~delegation_over_baking_limit
+      delegate
+      staking_balance
+  in
+  Stake_context.staking_weight ctxt stake
+
 let select_new_distribution_at_cycle_end ctxt ~new_cycle =
   let preserved = Constants_storage.preserved_cycles ctxt in
   let for_cycle = Cycle_repr.add new_cycle preserved in
@@ -287,3 +311,17 @@ let clear_outdated_sampling_data ctxt ~new_cycle =
   | Some outdated_cycle ->
       Delegate_sampler_state.remove_existing ctxt outdated_cycle
       >>=? fun ctxt -> Seed_storage.remove_for_cycle ctxt outdated_cycle
+
+module For_RPC = struct
+  let delegate_baking_power_for_cycle ctxt cycle delegate =
+    let open Lwt_result_syntax in
+    let* max_snapshot_index = Stake_storage.max_snapshot_index ctxt in
+    let* seed = Seed_storage.raw_for_cycle ctxt cycle in
+    let* selected_index =
+      compute_snapshot_index_for_seed ~max_snapshot_index seed
+    in
+    let* staking_balance =
+      Storage.Stake.Staking_balance.Snapshot.get ctxt (selected_index, delegate)
+    in
+    delegate_baking_power_from_staking_balance ctxt delegate staking_balance
+end
diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.mli b/src/proto_alpha/lib_protocol/delegate_sampler.mli
index 864cea84b717..afd31a02486a 100644
--- a/src/proto_alpha/lib_protocol/delegate_sampler.mli
+++ b/src/proto_alpha/lib_protocol/delegate_sampler.mli
@@ -77,3 +77,13 @@ val clear_outdated_sampling_data :
 
 val select_distribution_for_cycle :
   Raw_context.t -> Cycle_repr.t -> Raw_context.t tzresult Lwt.t
+
+module For_RPC : sig
+  (** The baking power for a given delegate from the selected stake
+    snapshot of the current cycle. *)
+  val delegate_baking_power_for_cycle :
+    Raw_context.t ->
+    Cycle_repr.t ->
+    Signature.public_key_hash ->
+    int64 tzresult Lwt.t
+end
-- 
GitLab


From f0705ddef998efa67f1df02cabd2d215f98f103e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 10:34:02 +0200
Subject: [PATCH 3/7] Proto/Staking: add the baking_power RPC

---
 .../lib_protocol/delegate_services.ml          | 18 ++++++++++++++++++
 .../lib_protocol/delegate_services.mli         |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml
index ebd5605f7323..1ea7b2eb7ae1 100644
--- a/src/proto_alpha/lib_protocol/delegate_services.ml
+++ b/src/proto_alpha/lib_protocol/delegate_services.ml
@@ -387,6 +387,17 @@ module S = struct
       ~output:Data_encoding.int64
       RPC_path.(path / "voting_power")
 
+  let baking_power =
+    RPC_service.get_service
+      ~description:
+        "The baking power for a given delegate from the selected stake \
+         snapshot of the current cycle. This is the baking power which will be \
+         used preserved_cycles after the current cycle to compute the baking \
+         and endorsing rights."
+      ~query:RPC_query.empty
+      ~output:Data_encoding.int64
+      RPC_path.(path / "baking_power")
+
   let voting_info =
     RPC_service.get_service
       ~description:
@@ -543,6 +554,10 @@ let register () =
   register1 ~chunked:false S.voting_power (fun ctxt pkh () () ->
       check_delegate_registered ctxt pkh >>=? fun () ->
       Vote.get_voting_power_free ctxt pkh) ;
+  register1 ~chunked:false S.baking_power (fun ctxt pkh () () ->
+      check_delegate_registered ctxt pkh >>=? fun () ->
+      let cycle = (Level.current ctxt).cycle in
+      Stake_distribution.For_RPC.delegate_baking_power_for_cycle ctxt cycle pkh) ;
   register1 ~chunked:false S.voting_info (fun ctxt pkh () () ->
       check_delegate_registered ctxt pkh >>=? fun () ->
       Vote.get_delegate_info ctxt pkh) ;
@@ -609,6 +624,9 @@ let voting_power ctxt block pkh =
 let current_voting_power ctxt block pkh =
   RPC_context.make_call1 S.current_voting_power ctxt block pkh () ()
 
+let baking_power ctxt block pkh =
+  RPC_context.make_call1 S.baking_power ctxt block pkh () ()
+
 let voting_info ctxt block pkh =
   RPC_context.make_call1 S.voting_info ctxt block pkh () ()
 
diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli
index 4d0de3b058c2..9167ff34d16d 100644
--- a/src/proto_alpha/lib_protocol/delegate_services.mli
+++ b/src/proto_alpha/lib_protocol/delegate_services.mli
@@ -137,6 +137,9 @@ val current_voting_power :
 val voting_power :
   'a #RPC_context.simple -> 'a -> public_key_hash -> int64 shell_tzresult Lwt.t
 
+val baking_power :
+  'a #RPC_context.simple -> 'a -> public_key_hash -> int64 shell_tzresult Lwt.t
+
 val voting_info :
   'a #RPC_context.simple ->
   'a ->
-- 
GitLab


From 60d954293cad91a9291e3935662ff1531ff7c10a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 11:18:44 +0200
Subject: [PATCH 4/7] Proto/Staking: compute current baking power

This adds a function to compute the baking power of a delegate based
on its current balance (instead of fetching it from a snapshot).
---
 src/proto_alpha/lib_protocol/alpha_context.mli    | 3 +++
 src/proto_alpha/lib_protocol/delegate_sampler.ml  | 5 +++++
 src/proto_alpha/lib_protocol/delegate_sampler.mli | 5 +++++
 3 files changed, 13 insertions(+)

diff --git a/src/proto_alpha/lib_protocol/alpha_context.mli b/src/proto_alpha/lib_protocol/alpha_context.mli
index 7aa2c53df7ab..f5e2274213fb 100644
--- a/src/proto_alpha/lib_protocol/alpha_context.mli
+++ b/src/proto_alpha/lib_protocol/alpha_context.mli
@@ -4590,6 +4590,9 @@ module Stake_distribution : sig
   module For_RPC : sig
     val delegate_baking_power_for_cycle :
       context -> Cycle.t -> Signature.public_key_hash -> int64 tzresult Lwt.t
+
+    val delegate_current_baking_power :
+      context -> Signature.public_key_hash -> int64 tzresult Lwt.t
   end
 end
 
diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.ml b/src/proto_alpha/lib_protocol/delegate_sampler.ml
index 758d4761fe39..69f1693c0c2e 100644
--- a/src/proto_alpha/lib_protocol/delegate_sampler.ml
+++ b/src/proto_alpha/lib_protocol/delegate_sampler.ml
@@ -324,4 +324,9 @@ module For_RPC = struct
       Storage.Stake.Staking_balance.Snapshot.get ctxt (selected_index, delegate)
     in
     delegate_baking_power_from_staking_balance ctxt delegate staking_balance
+
+  let delegate_current_baking_power ctxt delegate =
+    let open Lwt_result_syntax in
+    let* staking_balance = Stake_storage.get_staking_balance ctxt delegate in
+    delegate_baking_power_from_staking_balance ctxt delegate staking_balance
 end
diff --git a/src/proto_alpha/lib_protocol/delegate_sampler.mli b/src/proto_alpha/lib_protocol/delegate_sampler.mli
index afd31a02486a..506cc04ee2d3 100644
--- a/src/proto_alpha/lib_protocol/delegate_sampler.mli
+++ b/src/proto_alpha/lib_protocol/delegate_sampler.mli
@@ -86,4 +86,9 @@ module For_RPC : sig
     Cycle_repr.t ->
     Signature.public_key_hash ->
     int64 tzresult Lwt.t
+
+  (** The baking power for a given delegate computed from its current
+    stake. *)
+  val delegate_current_baking_power :
+    Raw_context.t -> Signature.public_key_hash -> int64 tzresult Lwt.t
 end
-- 
GitLab


From e1d10e13ad468e0349eeed12776daefc861cf88c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 11:20:50 +0200
Subject: [PATCH 5/7] Proto/Staking: add the current_baking_power RPC

---
 .../lib_protocol/delegate_services.ml          | 18 ++++++++++++++++++
 .../lib_protocol/delegate_services.mli         |  3 +++
 2 files changed, 21 insertions(+)

diff --git a/src/proto_alpha/lib_protocol/delegate_services.ml b/src/proto_alpha/lib_protocol/delegate_services.ml
index 1ea7b2eb7ae1..2613434a8e8e 100644
--- a/src/proto_alpha/lib_protocol/delegate_services.ml
+++ b/src/proto_alpha/lib_protocol/delegate_services.ml
@@ -398,6 +398,18 @@ module S = struct
       ~output:Data_encoding.int64
       RPC_path.(path / "baking_power")
 
+  let current_baking_power =
+    RPC_service.get_service
+      ~description:
+        "The baking power of a delegate, as computed from its current stake. \
+         Contrary to the value returned by the baking_power endpoint, this \
+         value is not used for computing baking rights but only reflects the \
+         baking power that the delegate would have if a snapshot was taken at \
+         the current block."
+      ~query:RPC_query.empty
+      ~output:Data_encoding.int64
+      RPC_path.(path / "current_baking_power")
+
   let voting_info =
     RPC_service.get_service
       ~description:
@@ -558,6 +570,9 @@ let register () =
       check_delegate_registered ctxt pkh >>=? fun () ->
       let cycle = (Level.current ctxt).cycle in
       Stake_distribution.For_RPC.delegate_baking_power_for_cycle ctxt cycle pkh) ;
+  register1 ~chunked:false S.current_baking_power (fun ctxt pkh () () ->
+      check_delegate_registered ctxt pkh >>=? fun () ->
+      Stake_distribution.For_RPC.delegate_current_baking_power ctxt pkh) ;
   register1 ~chunked:false S.voting_info (fun ctxt pkh () () ->
       check_delegate_registered ctxt pkh >>=? fun () ->
       Vote.get_delegate_info ctxt pkh) ;
@@ -627,6 +642,9 @@ let current_voting_power ctxt block pkh =
 let baking_power ctxt block pkh =
   RPC_context.make_call1 S.baking_power ctxt block pkh () ()
 
+let current_baking_power ctxt block pkh =
+  RPC_context.make_call1 S.current_baking_power ctxt block pkh () ()
+
 let voting_info ctxt block pkh =
   RPC_context.make_call1 S.voting_info ctxt block pkh () ()
 
diff --git a/src/proto_alpha/lib_protocol/delegate_services.mli b/src/proto_alpha/lib_protocol/delegate_services.mli
index 9167ff34d16d..2dcfb1d21f2d 100644
--- a/src/proto_alpha/lib_protocol/delegate_services.mli
+++ b/src/proto_alpha/lib_protocol/delegate_services.mli
@@ -140,6 +140,9 @@ val voting_power :
 val baking_power :
   'a #RPC_context.simple -> 'a -> public_key_hash -> int64 shell_tzresult Lwt.t
 
+val current_baking_power :
+  'a #RPC_context.simple -> 'a -> public_key_hash -> int64 shell_tzresult Lwt.t
+
 val voting_info :
   'a #RPC_context.simple ->
   'a ->
-- 
GitLab


From e7a66ec80d62e1ffd1ad1130cdc190c999c7ca7f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 15:00:03 +0200
Subject: [PATCH 6/7] Tests/Proto/Helpers: add wrappers for new RPCs

---
 src/proto_alpha/lib_protocol/test/helpers/context.ml  | 4 ++++
 src/proto_alpha/lib_protocol/test/helpers/context.mli | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.ml b/src/proto_alpha/lib_protocol/test/helpers/context.ml
index ab17cd2a43ed..be42b172141a 100644
--- a/src/proto_alpha/lib_protocol/test/helpers/context.ml
+++ b/src/proto_alpha/lib_protocol/test/helpers/context.ml
@@ -174,6 +174,10 @@ let get_voting_power = Delegate_services.voting_power rpc_ctxt
 
 let get_total_voting_power = Alpha_services.Voting.total_voting_power rpc_ctxt
 
+let get_baking_power = Delegate_services.baking_power rpc_ctxt
+
+let get_current_baking_power = Delegate_services.current_baking_power rpc_ctxt
+
 let get_bakers ?filter ?cycle ctxt =
   Plugin.RPC.Baking_rights.get rpc_ctxt ?cycle ctxt >|=? fun bakers ->
   (match filter with None -> bakers | Some f -> List.filter f bakers)
diff --git a/src/proto_alpha/lib_protocol/test/helpers/context.mli b/src/proto_alpha/lib_protocol/test/helpers/context.mli
index c4c76d85962a..a88bf12259ca 100644
--- a/src/proto_alpha/lib_protocol/test/helpers/context.mli
+++ b/src/proto_alpha/lib_protocol/test/helpers/context.mli
@@ -80,6 +80,12 @@ val get_voting_power :
 val get_total_voting_power :
   t -> int64 Environment.Error_monad.shell_tzresult Lwt.t
 
+val get_baking_power :
+  t -> public_key_hash -> int64 Environment.Error_monad.shell_tzresult Lwt.t
+
+val get_current_baking_power :
+  t -> public_key_hash -> int64 Environment.Error_monad.shell_tzresult Lwt.t
+
 val get_bakers :
   ?filter:(Plugin.RPC.Baking_rights.t -> bool) ->
   ?cycle:Cycle.t ->
-- 
GitLab


From b60197550128556766f3056285b6a55a6180721f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rapha=C3=ABl=20Cauderlier?=
 <raphael.cauderlier@nomadic-labs.com>
Date: Fri, 30 Jun 2023 15:27:29 +0200
Subject: [PATCH 7/7] Docs/Changelog: mention !9350

---
 docs/protocols/alpha.rst | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/docs/protocols/alpha.rst b/docs/protocols/alpha.rst
index 722dda9b60ec..01737f08314c 100644
--- a/docs/protocols/alpha.rst
+++ b/docs/protocols/alpha.rst
@@ -33,9 +33,20 @@ Breaking Changes
 RPC Changes
 -----------
 
-- The new ``current_voting_power`` RPC computes the voting power of a
-  delegate based on its current stake (as opposed to reading it from
-  the vote listings as the ``voting_power`` does) (MR :gl:`!9329`)
+- Three new variants of the ``voting_power`` RPC (which returns the
+  voting power of a delegate based on the stake it had when voting
+  snapshot was taken) have been added:
+
+  - ``current_voting_power`` the voting power of a delegate based on
+    its current stake (MR :gl:`!9329`)
+
+  - ``baking_power`` computes the baking power of a delegate based on
+     the stake snapshot selected for the current cycle (MR
+     :gl:`!9350`)
+
+  - ``current_baking_power`` computes the baking power of a delegate
+    based on its current stake (MR :gl:`!9350`)
+
 
 Operation receipts
 ------------------
-- 
GitLab