A Sneak Peek into Aleo Reward Distribution Mechanism

ZKRush
6 min readAug 9, 2022

--

The Aleo team just modified their GitHub development branch’s rewards section. While this portion may not be the finalized version that will be deployed on the mainnet in Q4, we may still get a glimpse of how the rewards mechanism may be designed.

GitHub Source: https://github.com/AleoHQ/snarkOS/blob/feat%2Fexperimental-networking2/consensus/src/rewards/mod.rs

Before we get started with the code analysis, let’s address a couple of the most pressing concerns we all have:

Q: Do miners still get paid?

A: Yes, miners will have incentives for 10 years since the mainnet launch, which will decrease each year accordingly. After 10 years, the reward for each mined block will fall to zero.

Q: How much can a miner(prover) get from a mined block?

A: Around 80 Aleo / block in the first year, and the reward will decrease in the following decade.

Q: What is the validator threshold? How much revenue can I get?

A: 1 million Aleo to become a validator, and approximately 11 Aleo per block for the validator income.(*Explain Later)

Now let’s take a closer look at these codes.

Defined Values:

Here is to define the conversion rate between the two tokens — gates/credit: 1 credit = 1 million gates.

Starting Supply: 1 billion Aleo

The staking ratio is closely related to the validators’ income which will be explained later.

The anchor time, which should be the block genesis, currently set as 2019–01–01 00:00:00 UTC.

The block generation rate. It is indicated that the block generation rate will be adjusted to 15s from 20s during testnet 2.

Now, we will move on to the two most crucial functions.

staking_reward

(https://github.com/AleoHQ/snarkOS/blob/d8b852977b0dd1800488ba45daf74f6f09729ec4/consensus/src/rewards/mod.rs#L30-L39 )

As you can see, the function has no normal parameters, only two constants, so once the mainnet is online and the starting supply and the block generation rate are defined, the value of the staking reward in each block should remain the same.

Calculate the Staking Reward:

reward = (starting supply * staking percentage) / block height around 1 year

After defining the block generation rate, the block height in a year is calculated by dividing the total number of seconds in a year by the block generation rate (15s).

reward = 1billon (starting supply) * 2.5% / 365*24*3600/15 (block height) ≈ 11.89

We can round it down to 11, so in this way, validators can obtain around 11 Aleo in each mined block. (Please note that the number of Aleo in each of our formulas is multiplied by a factor of 1 million to convert to gates, and then brought into the calculation, resulting in a value that is the same below.)

This does not imply that each validator may obtain the same number of Aleo from each mined block; rather, it implies that all eligible validators should be able to obtain 11 Aleo from each mined block.In terms of how many validators will there be, and what’s the distribution plan among validators in one mined block, we will release our interpretation soon after Aleo team posts the rules.

So what about miners’ income?

https://github.com/AleoHQ/snarkOS/blob/d8b852977b0dd1800488ba45daf74f6f09729ec4/consensus/src/rewards/mod.rs#L42-L56

coinbase_reward

The calculation of miners’ income is a bit complicated. Through the function definition, we can see that the coinbase reward is dynamically altered, which is closely linked to 3 dynamic parameters — num_validators: (the number of validators), timestamp: (timestamp of each mined block) and block_height.

First of all, we need to know about anchor_reward.

(https://github.com/AleoHQ/snarkOS/blob/d8b852977b0dd1800488ba45daf74f6f09729ec4/consensus/src/rewards/mod.rs#L20-L27 )

anchor_reward is an anchored base value which will no longer be changed once the starting supply and the block generation rate is defined.

anchor_reward = 2 * starting supply / (block height in 10 years)^2

anchor_reward = 2 * 1 billion (starting supply) / 21,024,000^2 (block height in 10 years) ≈4.524

We can round it down to 4.

There is also a function defined as factor that is involved in the coinbase reward calculation used to dynamically adjust the incentives.

(https://github.com/AleoHQ/snarkOS/blob/d8b852977b0dd1800488ba45daf74f6f09729ec4/consensus/src/rewards/mod.rs#L58-L64 )

factor = numerator / denominator

numerator = (current time — initial time) — (current block height * block generation rate)

As you can see from above, the numerator represents the theoretical time difference in block generation interval. E.g., set the genesis block as 2023–01–01 00:00:00 TC, after generated 5760 blocks (24*3600/15), the theoretical time should be 2023–01–02 00:00:00 UTC. Nevertheless, there could be some time deviations, the real time could be 5s slower, as 2023–01–02 00:00:05 UTC.

denominator = the number of validator * block generation rate

We can simplify it by dividing the block generation rate by the numerator to get the time difference in blocks. Therefore, the factor is actually equal to time deviation of each mined block / the number of validators.

The factor will eventually be introduced into the coinbase reward, which is used to guide miners to adjust the block generation rate, and also to guide the number of participating validators. To wrap this up, the larger the deviation, the larger the factor; the larger of validator numbers, the smaller the factor.

After understanding anchor_reward and factor, we may now look back in details at the reward codes.

block_diff = block height in 10 years — current block height

When the current block height exceeds the block height in 10 years, the value takes 0. We can clearly see that with all conditions being the same, the higher the block height, the lower the revenue. The reward turns to 0 after 10 years.

If miners want to obtain more income, then we should probably focus on the last part, 1/2 ^factor, since the previous parts are non-adjustable as discussed. Remember, 1) the larger the deviations , the larger the factor and the smaller the miners’ income. 2) The larger the number of validators, the smaller the factor and the more the miners can earn. Hence, Aleo team can guide all miners through the dynamic factor. There are 2 things we can learn from this design, 1) try to control the block generation rate to 15s avoiding causing much deviations; 2) actively participate in staking and become a validator.

In a nutshell, below are the rough earnings miners(provers) can obtain in ten years.

Year 1: 83 Aleo

Year 2: 67 Aleo

Year 3: 58 Aleo

```

Year 10: 8 Aleo

Year 11: 0

Pleas note that this is not the final version of the provers’ income distribution mechanism by Aleo, we will continue to release more insights regarding the upcoming phase2 in the testnet 3.

Learn more about ZKRush

Twitter | Discord | Website

--

--

ZKRush

⚡️Leading Technical Solutions & Infrastructure Service Provider on Zero-Knowledge Proof