-
Notifications
You must be signed in to change notification settings - Fork 622
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Introduce cutoff threshold for endorsement ratio #12047
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12047 +/- ##
==========================================
+ Coverage 71.40% 71.45% +0.04%
==========================================
Files 814 814
Lines 163936 164177 +241
Branches 163936 164177 +241
==========================================
+ Hits 117055 117305 +250
+ Misses 41754 41744 -10
- Partials 5127 5128 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
#[derive(Clone, Debug)] | ||
pub struct RewardCalculator { | ||
pub max_inflation_rate: Rational32, | ||
pub num_blocks_per_year: u64, | ||
pub epoch_length: u64, | ||
pub protocol_reward_rate: Rational32, | ||
pub protocol_treasury_account: AccountId, | ||
pub online_min_threshold: Rational32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved these to the ValidatorOnlineThresholds
struct passed to calculate_reward
.
In fact we do not re-initialize the RewardCalculator
when there is a new epoch or protocol change, so this way it is safer as we will need to change the online thresholds (endorsement cutoff in this case) via protocol upgrades.
Issue: #11900.
This PR introduces a cutoff threshold for chunk endorsement ratio. We use the same kickout threshold as the cutoff threshold. It is currently 80, but we will make it 70 when stabilizing this feature.
If the endorsement ratio is less than the cutoff ratio, it is treated 0, otherwise treated 1, when computing the average uptime ratio (including block and chunk production and endorsement).
For this, we introduce a new struct
ValidatorOnlineThresholds
to containonline_min_threshold
andonline_max_threshold
as well asendorsement_cutoff_threshold
(initialized to the kickout threshold=70 if featureChunkEndorsementsInBlockHeader
is enabled).ValidatorOnlineThresholds
is initialized fromEpochConfig
. We pass this struct tocalculate_rewards
, which then callsget_validator_online_ratio
to apply the cutoff if present.We performed simulation of last 5 epochs in mainnet, results are in this doc. Only the chunk validators with very low endorsement ratio are kicked out and do not get any reward.
Testing: We added some unittests for the basic logic. We will later add integration tests for the full behavior.