-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use same online ratio calculator for computing rewards and exemptions…
… for validators (#11982) Currently the online ratio calculated for 1) reward calculator and 2) validators exempted from kickout are different; the former uses block+chunk production and endorsements, while the latter does not use endorsements. This PR makes both code use the same calculation. For this, we extract the code that calculates the online ratio to a new file `validator_stats.rs`. The function `get_validator_online_ratio` returns `Ratio<U256>`. However, this cannot be used for sorting since `Ratio` requires that the inner type is implements the `Integer` trait, which `U256` does not. Thus, for the sorting only, we convert `Ration<U256>` to `Ratio<BitInt>` (`BigRational`). In the future we may consider implementing `Integer` trait for `U256` or always using `BigInt`. This is currently not enabled and is guarded by the new protocol feature `ChunkEndorsementsInBlockHeader`, which sets the chunk endorsements in the `BlockHeader` and `BlockInfo`, so that we will calculate the endorsements in `EpochManager`. We add some tests to check chunk-validator exemptions with and without this feature.
- Loading branch information
1 parent
ec2ece3
commit 51e4728
Showing
6 changed files
with
298 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.