Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion runtime/common/src/attestations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,19 @@ impl RewardAttestation for () {

impl<T: staking::Trait> RewardAttestation for staking::Module<T> {
fn reward_immediate(validator_indices: impl IntoIterator<Item=u32>) {
use staking::SessionInterface;

// The number of points to reward for a validity statement.
// https://research.web3.foundation/en/latest/polkadot/Token%20Economics/#payment-details
const STAKING_REWARD_POINTS: u32 = 20;

Self::reward_by_indices(validator_indices.into_iter().map(|i| (i, STAKING_REWARD_POINTS)))
let validators = T::SessionInterface::validators();

let validator_rewards = validator_indices.into_iter()
.filter_map(|i| validators.get(i as usize).cloned())
.map(|v| (v, STAKING_REWARD_POINTS));

Self::reward_by_ids(validator_rewards);
}
}

Expand Down
2 changes: 2 additions & 0 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ parameter_types! {
// 28 eras in which slashes can be cancelled (7 days).
pub const SlashDeferDuration: staking::EraIndex = 28;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this number is a proposition as the one used in node-runtime in substrate, though I can't really tell about the precise value to use here.

}

impl staking::Trait for Runtime {
Expand All @@ -292,6 +293,7 @@ impl staking::Trait for Runtime {
type SlashCancelOrigin = collective::EnsureProportionAtLeast<_1, _2, AccountId, CouncilCollective>;
type SessionInterface = Self;
type RewardCurve = RewardCurve;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
}

parameter_types! {
Expand Down
2 changes: 2 additions & 0 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ parameter_types! {
pub const BondingDuration: staking::EraIndex = 28;
pub const SlashDeferDuration: staking::EraIndex = 28;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
}

impl staking::Trait for Runtime {
Expand All @@ -299,6 +300,7 @@ impl staking::Trait for Runtime {
type SlashCancelOrigin = collective::EnsureProportionAtLeast<_3, _4, AccountId, CouncilCollective>;
type SessionInterface = Self;
type RewardCurve = RewardCurve;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
}

parameter_types! {
Expand Down