Heads-up to bakers and builders: A new delegation calculation tool is coming soon to Octez

TL;DR A new calculation tool is being integrated into Octez to help bakers and baking tooling builders understand better how much each of their delegators contributes to their consensus rights. The output of this tool will be available as an Octez node RPC endpoint, enabling more transparency and insight into baking power distribution — without aiming to become a full delegation rewards distribution system.

We are sharing this plan today, to give a heads up to Tezos bakers and builders. Do not hesitate also to provide feedback on the proposed design, and suggestions on how to improve this new feature.

Context

The adoption of the Paris protocol upgrade changed how the Tezos protocol estimates delegators’ contributions towards their bakers’ baking power, and consequently the share of rewards they would be eventually paid by their baker. Paris deprecated the previous approach based on aleatory stake snapshots by a continuous mechanism which determines the minimal delegated balance of a baker in the cycle.

The Quebec protocol refined this mechanism further by amending the granularity of the computation of the minimal delegated balance and improving the information available via RPC endpoints. This was necessary to address reported frictions in downstream infrastructure, like indexer and Tezos reward distribution tools.

To assist bakers and tool developers further, and remove the burden of computing delegator shares closer to the Tezos protocol, core engineering teams are planning to introduce a new RPC endpoint which will easily report all contributions by delegators to their baker’s delegated balance in a given cycle.

What This Tool Does

  • For a given cycle and baker, it breaks down the computation of the baking power arising from delegated tez in that cycle.
  • Crucially it provides the share of each individual delegator and the baker’s own towards this total.
  • It helps quantify the real impact of each delegator on baking power and would allow for a leaner computation of delegator rewards.

:stop_sign: This tool is not a full reward calculator – its purpose is to provide more clear information on the different contributions to baking rights from delegation.

Please see Baking Power in Octez for further reference.

How It Works

The new tooling will be integrated into the Octez suite, and can be queried via a new dedicated Octez node RPC endpoint.

RPC path

/chain/main/delegators_participation/<reward-cycle>/<baker-pkh>

Parameters

  • reward-cycle: The target cycle for which to calculate the share of baking power from delegated tez.
  • baker-pkh: The public key hash of the baking (or manager) key for the baker whose shares are being calculated.

JSON Output

The RPC endpoint outputs values given in weighted mutez.

Staked and delegated tez have different weights in the computation of baking power:

  • Staked tez have a weight of 1. That is, they contribute to baking power at their nominal value.
  • Delegated tez have a weight of 1/3, meaning they contribute a third of their nominal value.

The proposed JSON output has the following shape:

{ "total_baking_power" :  96_000_000_000 ,
  "total_baking_power_from_delegation" :  6_000_000_000 ,
  "delegators_share" :[
	"tz1a…." : 6000 ,
	"tz1b…." : 4301 ,
	"KT1b…." : 201 ,
	...
],
  "self_delegated": 8000,
  "overstaking_share": 4800,
  "untracked_unstake_requests": 5000,
  "overdelegation" : 150, 
}

where:

  • total_baking_power: The baker’s total baking power in the queried cycle.
  • total_baking_power_from_delegation: The portion of the baker’s baking power that comes specifically from delegated tez, with:
total_baking_power_from_delegation =
  delegators_share + overstaking_share + untracked_unstake_requests - overdelegation`
  • delegators_share: Maps delegators to their respective contributions towards their baker’s total baking power from delegation. It includes delegated spendable tez, frozen rollup bonds, unstaked tez, and other sources - see the docs for its complete definition.
  • self_delegated: The baker’s own contribution to its delegated baking power.
  • overstaking_share: The total share of the baking power from delegation that originates from overstaked tez.
  • untracked_unstake_requests: The aggregated contribution from unfinalized unstake requests from delegators that have changed their delegation to a new baker and that are still counted towards the baker’s baking power.
  • overdelegation: The total delegation excess which is not taken into account for the computation of baking power in the case the baker is overdelegated.

Requirements & Best Practices

As hinted by the path of the proposed endpoint, this is not a “protocol” RPC endpoint, but rather a shell one. This is because of the additional business logic required to serve these requests, which takes place outside the Tezos protocol.

  • Given its computational cost, the Octez node’s RPC server should be configured to be run as a separate process, when using the proposed endpoint.
  • It should not be exposed publicly by Octez nodes.
7 Likes

TL;DR: We already have a robust solution (protocol-rewards). It may be more productive to allocate resources elsewhere.

Hi,

while I appreciate the potential benefits of integrating such a tool directly into the core, we currently have a solution in place—protocol-rewards (PR)—that already meets most of your stated requirements and can be easily adjusted for the rest.

PR was specifically designed to integrate smoothly with TzKT endpoints and provides several key features:

  • Power distribution analytics for all bakers, stakers, and delegators
  • Option to operate PR specifically for a single baker
  • Rolling storage, persisting only the last N cycles for efficient querying
  • Optimized performance, likely faster than yours in ocaml, unless the latest OCaml multithreading enhancements are utilized

PR has been successfully powering tezpay since the Paris upgrade, and we’ve consistently maintained and supported it. Given this, the proposed integration might largely duplicate existing functionality, potentially diverting resources that could be better utilized addressing other community requests or enhancements.

One particular improvement that would significantly help us is an RPC endpoint for querying dangling unstake requests. Currently, we’re reliant on TzKT for this data, and while your proposal mentions untracked_unstake_requests - it would be particularly beneficial to identify specifically which delegators own these outstanding requests rather than just viewing aggregate totals.

NOTE: If desired, we can transfer the project (PR) to core teams for them to take over.

Thank you again for your efforts and consideration.

Best regards,
Val

One additional note, as this seems to be misunderstood: We specifically need identified unstake requests to distribute rewards accurately. If the tool is implemented as currently proposed and integrated by payout distributors, it would lead to incorrect payouts.

Consider this scenario: If you delegate to another baker, your balance is automatically unstaked, making you eligible for delegation rewards from your unstaked balance with the original baker, and from your remaining balance with the new baker. With the proposed solution, delegators/stakers are going to lose rewards from their unstaked balances.

Interesting stuff. Look forward to testing it out. Available now with Octez v22, or is that later? Agree with @Val comments. Hopefully this is not a reinvention of an existing wheel

1 Like