Weighted Random Selection Specification for Validators
This document outlines the detailed specification for selecting validators in the Ronin Network using the LibSortValidatorsByBeacon
library and the RoninRandomBeacon
contract. The selection process ensures a fair, decentralized, and efficient mechanism for determining the validator set for each period and epoch.
Overview
The validator selection process is divided into two phases:
- Sorting and Saving Validators (Period Level): Filtering and categorizing validators into governance, standard, and rotating types, based on trusted weights and staking amounts.
- Random Selection of Rotating Validators (Epoch Level): Using the beacon value generated by the
RoninRandomBeacon
contract to select rotating validators dynamically for each epoch.
Inputs and Parameters
General Inputs
- Candidates (
cids
): List of validator candidate IDs. - Trusted Weights (
trustedWeights
): Weights assigned to validators based on governance criteria. Weights are the same for all governing validators. - Staking Amounts (
stakedAmounts
): Total staked RON for each candidate. - Beacon Value (
beacon
): A pseudo-random number generated at the period level, used for rotating validator selection. - Epoch Number (
epoch
): The epoch within the period for which rotating validators are being selected.
Configuration Parameters
- Number of Governance Validators (
nGV
): Maximum number of governance validators. - Number of Standard Validators (
nSV
): Maximum number of standard validators. - Number of Rotating Validators (
nRV
): Maximum number of rotating validators.
Phase 1: Sorting and Saving Validators (Period Level)
Steps
-
Input Validation:
- Ensure
cids
,trustedWeights
, andstakedAmounts
arrays have the same length. - Check that the total number of validators does not exceed the sum of
nGV
,nSV
, andnRV
. - If the number of all candidates \( \leq \sum(nGV, nSV, nRV) \), take all candidates as validators.
- Ensure
-
Filter Governance Validators:
- Use
trustedWeights
to filter out validators with non-zero governance weights. - Select the top
nGV
validators based on staking amounts. - Mark these validators as selected.
- Use
-
Filter Standard Validators:
- From the remaining candidates, select the top
nSV
validators based on staking amounts. - Include any unused governance slots to the standard validator count (
nSV += nGV - actual_gv_count
). - Mark these validators as selected.
- From the remaining candidates, select the top
-
Filter Rotating Validators:
- From the remaining candidates, select up to
nRV
validators. - Use beacon randomness and staking amounts for weighted selection.
Edge-case: If number of actual governing validators \( \geq nGV \), unused governance slots are in random selection process.
- From the remaining candidates, select up to
-
Save Validators:
- Save governance and standard validators as non-rotating.
- Save rotating validators with their stakes for beacon-based selection in Phase 2.
Outputs
- Non-Rotating Validators: Combined list of governance and standard validators.
- Rotating Validators: List of rotating validators and their stakes.
Phase 2: Rotating Validator Selection (Epoch Level)
Steps
-
Input Preparation:
- Retrieve the list of rotating validators and their stakes from Phase 1.
- Ensure the number of rotating validators does not exceed
nRV
.
-
Beacon-Based Weight Calculation:
- Formula:
- denote the address of candidate \( i \) as \( \text{cid}_i \).
- denote the stake amount of candidate \( i \) of period \( p \) as \( \text{s}_{ip} \).
- denote the random beacon of period \( p \) as \( \text{r}_p \).
- denote the weight of a candidate \( i \) at epoch \(e \) in period \(p \) as \( w_{iep} \)
\[ w_{iep} = \frac{\text{s}_{ip}}{1e18}^2 \times \texttt{h}(e, \text{cid}_i, \text{r}_p) \]
where \( \texttt{h} \) is hash of concatenating \( e \), \( \text{cid}_i \) and \( \text{r}_p \)
- Formula:
-
Top-k Selection:
- Sort the rotating validators by their calculated beacon weights.
- Select the top
nRV
validators for the current epoch.
-
Combine Validator Sets:
- Merge the selected rotating validators with the non-rotating validators.
Outputs
- Epoch Validator Set: Final list of validators (rotating + non-rotating) for the epoch.
Examples and Visualization
Consider threshold values for the number of governance, standard, and rotating validators:
nGV = 2
nSV = 2
nRV = 2
Period Level Sorting Example
Candidate ID | Trusted Weight | Staked Amount (RON) | Governance Validator (GV) | Standard Validator (SV) | Rotating Validator (RV) |
---|---|---|---|---|---|
Validator A | 100 | 50,000 | ✔ | ||
Validator B | 100 | 40,000 | ✔ | ||
Validator C | 100 | 30,000 | ✔ | ||
Validator D | 0 | 25,000 | ✔ | ||
Validator E | 0 | 20,000 | ✔ | ||
Validator F | 0 | 15,000 | ✔ | ||
Validator G | 0 | 14,000 | ✔ | ||
Validator H | 0 | 13,000 | ✔ |
Summary:
- Governance Validators (GV): Validator A, Validator B
- Standard Validators (SV): Validator D, Validator E
- Rotating Validators (RV) List: Validator C, Validator F, Validator G, Validator H
Epoch Level Rotating Validator Selection Example
Rotating Validator | Staked Amount (RON) | Beacon Hash | Weight |
---|---|---|---|
Validator C | 30,000 | 0x1234 | 8,500 |
Validator G | 15,000 | 0x5678 | 5,100 |
Validator F | 14,000 | 0x9abc | 5,625 |
Validator H | 13,000 | 0x9def | 2,500 |
Selected Rotating Validators for Epoch
- Validator C (Weight:
8,500
) - Validator G (Weight:
5,625
)