diff --git a/resources/local/chainspec.toml.in b/resources/local/chainspec.toml.in index 4702f56d6d..7e5db14c9e 100644 --- a/resources/local/chainspec.toml.in +++ b/resources/local/chainspec.toml.in @@ -117,7 +117,7 @@ refund_handling = { type = 'no_refund' } # administrator accounts # 'burn': fees are burned fee_handling = { type = 'no_fee' } -# The proportion of baseline rewards going to reward finality signatures specifically. +# If a validator would recieve a validator credit, it cannot exceed this percentage of their total stake. validator_credit_cap = [1, 5] # Defines how pricing is handled. # diff --git a/resources/production/chainspec.toml b/resources/production/chainspec.toml index aea399e2bd..d6c1008c80 100644 --- a/resources/production/chainspec.toml +++ b/resources/production/chainspec.toml @@ -127,7 +127,7 @@ refund_handling = { type = 'no_refund' } # administrator accounts # 'burn': fees are burned fee_handling = { type = 'no_fee' } -# The proportion of baseline rewards going to reward finality signatures specifically. +# If a validator would recieve a validator credit, it cannot exceed this percentage of their total stake. validator_credit_cap = [1, 5] # Defines how pricing is handled. # diff --git a/storage/src/system/auction/detail.rs b/storage/src/system/auction/detail.rs index ceb7433942..f7dfe4c812 100644 --- a/storage/src/system/auction/detail.rs +++ b/storage/src/system/auction/detail.rs @@ -130,12 +130,14 @@ impl ValidatorBidsDetail { && !v.inactive() }) { let staked_amount = total_staked_amount(provider, bid)?; - let total = staked_amount.saturating_add(self.credit_amount( + let credit_amount = self.credit_amount( validator_public_key, era_ending, + staked_amount, include_credits, cap, - )); + ); + let total = staked_amount.saturating_add(credit_amount); ret.insert(validator_public_key.clone(), total); } @@ -146,6 +148,7 @@ impl ValidatorBidsDetail { &self, validator_public_key: &PublicKey, era_ending: EraId, + staked_amount: U512, include_credit: bool, cap: Ratio, ) -> U512 { @@ -155,8 +158,11 @@ impl ValidatorBidsDetail { if let Some(inner) = self.validator_credits.get(validator_public_key) { if let Some(credit) = inner.get(&era_ending) { - let amount = Ratio::new_raw(credit.amount(), U512::one()); - return amount.mul(cap).to_integer(); + let capped = Ratio::new_raw(staked_amount, U512::one()) + .mul(cap) + .to_integer(); + let credit_amount = credit.amount(); + return credit_amount.min(capped); } }