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:

  1. Sorting and Saving Validators (Period Level): Filtering and categorizing validators into governance, standard, and rotating types, based on trusted weights and staking amounts.
  2. 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

  1. Input Validation:

    • Ensure cids, trustedWeights, and stakedAmounts arrays have the same length.
    • Check that the total number of validators does not exceed the sum of nGV, nSV, and nRV.
    • If the number of all candidates \( \leq \sum(nGV, nSV, nRV) \), take all candidates as validators.
  2. 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.
  3. 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.
  4. 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.

  5. 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

  1. Input Preparation:

    • Retrieve the list of rotating validators and their stakes from Phase 1.
    • Ensure the number of rotating validators does not exceed nRV.
  2. 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 \)

  3. Top-k Selection:

    • Sort the rotating validators by their calculated beacon weights.
    • Select the top nRV validators for the current epoch.
  4. 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 IDTrusted WeightStaked Amount (RON)Governance Validator (GV)Standard Validator (SV)Rotating Validator (RV)
Validator A10050,000
Validator B10040,000
Validator C10030,000
Validator D025,000
Validator E020,000
Validator F015,000
Validator G014,000
Validator H013,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 ValidatorStaked Amount (RON)Beacon HashWeight
Validator C30,0000x12348,500
Validator G15,0000x56785,100
Validator F14,0000x9abc5,625
Validator H13,0000x9def2,500

Selected Rotating Validators for Epoch

  • Validator C (Weight: 8,500)
  • Validator G (Weight: 5,625)