Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Merge branch 'master' into coderobe/sync-29
Browse files Browse the repository at this point in the history
  • Loading branch information
coderobe authored Sep 9, 2022
2 parents b4a9bcd + 87d6cfc commit 2037cdf
Show file tree
Hide file tree
Showing 34 changed files with 4,620 additions and 1,076 deletions.
551 changes: 264 additions & 287 deletions Cargo.lock

Large diffs are not rendered by default.

30 changes: 24 additions & 6 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,26 +1048,35 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
})
.collect::<Vec<_>>(),
},
phragmen_election: Default::default(),
babe: rococo_runtime::BabeConfig {
authorities: Default::default(),
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
},
grandpa: Default::default(),
im_online: Default::default(),
collective: Default::default(),
membership: Default::default(),
democracy: rococo_runtime::DemocracyConfig::default(),
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: rococo::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
treasury: Default::default(),
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
paras: rococo_runtime::ParasConfig { paras: vec![] },
hrmp: Default::default(),
configuration: rococo_runtime::ConfigurationConfig {
config: default_parachains_host_configuration(),
},
gilt: Default::default(),
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID,
},
xcm_pallet: Default::default(),
transaction_payment: Default::default(),
}
}

Expand Down Expand Up @@ -1599,8 +1608,17 @@ pub fn rococo_testnet_genesis(
},
grandpa: Default::default(),
im_online: Default::default(),
collective: Default::default(),
membership: Default::default(),
phragmen_election: Default::default(),
democracy: rococo::DemocracyConfig::default(),
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
technical_committee: rococo::TechnicalCommitteeConfig {
members: vec![],
phantom: Default::default(),
},
technical_membership: Default::default(),
treasury: Default::default(),
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
vesting: rococo::VestingConfig { vesting: vec![] },
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
hrmp: Default::default(),
Expand All @@ -1610,12 +1628,12 @@ pub fn rococo_testnet_genesis(
..default_parachains_host_configuration()
},
},
gilt: Default::default(),
paras: rococo_runtime::ParasConfig { paras: vec![] },
registrar: rococo_runtime::RegistrarConfig {
next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID,
},
xcm_pallet: Default::default(),
transaction_payment: Default::default(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion node/service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ where
let auth_or_collator = role.is_authority() || is_collator.is_collator();
let requires_overseer_for_chain_sel = local_keystore.is_some() && auth_or_collator;

let pvf_checker_enabled = !is_collator.is_collator() && chain_spec.is_versi();
let pvf_checker_enabled = role.is_authority() && !is_collator.is_collator();

let select_chain = if requires_overseer_for_chain_sel {
let metrics =
Expand Down
18 changes: 5 additions & 13 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
#![recursion_limit = "256"]

use pallet_transaction_payment::CurrencyAdapter;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use primitives::v2::{
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
Expand Down Expand Up @@ -63,7 +62,7 @@ use frame_system::EnsureRoot;
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
use sp_core::OpaqueMetadata;
use sp_mmr_primitives as mmr;
use sp_runtime::{
Expand All @@ -86,7 +85,6 @@ pub use pallet_balances::Call as BalancesCall;
pub use pallet_election_provider_multi_phase::Call as EPMCall;
#[cfg(feature = "std")]
pub use pallet_staking::StakerStatus;
pub use pallet_timestamp::Call as TimestampCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

Expand Down Expand Up @@ -361,11 +359,6 @@ impl pallet_authorship::Config for Runtime {
type EventHandler = (Staking, ImOnline);
}

parameter_types! {
pub const Period: BlockNumber = 10 * MINUTES;
pub const Offset: BlockNumber = 0;
}

impl_opaque_keys! {
pub struct SessionKeys {
pub grandpa: Grandpa,
Expand Down Expand Up @@ -425,6 +418,8 @@ parameter_types! {
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
/// shall not increase the size of the validator intentions.
pub const MaxElectableTargets: u16 = u16::MAX;
pub NposSolutionPriority: TransactionPriority =
Perbill::from_percent(90) * TransactionPriority::max_value();
}

generate_solution_type!(
Expand Down Expand Up @@ -733,8 +728,6 @@ impl pallet_authority_discovery::Config for Runtime {
}

parameter_types! {
pub NposSolutionPriority: TransactionPriority =
Perbill::from_percent(90) * TransactionPriority::max_value();
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
}

Expand Down Expand Up @@ -1159,7 +1152,7 @@ impl parachains_hrmp::Config for Runtime {
type Event = Event;
type Origin = Origin;
type Currency = Balances;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
}

impl parachains_paras_inherent::Config for Runtime {
Expand All @@ -1176,7 +1169,7 @@ impl parachains_initializer::Config for Runtime {

impl parachains_disputes::Config for Runtime {
type Event = Event;
type RewardValidators = ();
type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints<Runtime>;
type PunishValidators = ();
type WeightInfo = weights::runtime_parachains_disputes::WeightInfo<Runtime>;
}
Expand Down Expand Up @@ -1343,7 +1336,6 @@ construct_runtime! {
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 18,


// Claims. Usable initially.
Claims: claims::{Pallet, Call, Storage, Event<T>, Config<T>, ValidateUnsigned} = 19,

Expand Down
3 changes: 2 additions & 1 deletion runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,9 @@ pub type XcmRouter = (
parameter_types! {
pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) });
pub const Statemine: MultiLocation = Parachain(1000).into();
pub const Encointer: MultiLocation = Parachain(1001).into();
pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Statemine::get());
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1001).into());
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Encointer::get());
}
pub type TrustedTeleporters =
(xcm_builder::Case<KusamaForStatemine>, xcm_builder::Case<KusamaForEncointer>);
Expand Down
61 changes: 45 additions & 16 deletions runtime/parachains/src/reward_points.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,42 +22,71 @@
//! for the time being, although we will build schemes to do so in the future.

use crate::{session_info, shared};
use frame_support::traits::ValidatorSet;
use primitives::v2::ValidatorIndex;
use frame_support::traits::{Defensive, ValidatorSet};
use primitives::v2::{SessionIndex, ValidatorIndex};
use sp_std::collections::btree_set::BTreeSet;

/// The amount of era points given by backing a candidate that is included.
pub const BACKING_POINTS: u32 = 20;
/// The amount of era points given by dispute voting on a candidate.
pub const DISPUTE_STATEMENT_POINTS: u32 = 20;

/// Rewards validators for participating in parachains with era points in pallet-staking.
pub struct RewardValidatorsWithEraPoints<C>(sp_std::marker::PhantomData<C>);

impl<C> crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints<C>
impl<C> RewardValidatorsWithEraPoints<C>
where
C: pallet_staking::Config + shared::Config + session_info::Config,
C: pallet_staking::Config + session_info::Config,
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
{
fn reward_backing(indices: impl IntoIterator<Item = ValidatorIndex>) {
// Fetch the validators from the _session_ because sessions are offset from eras
// and we are rewarding for behavior in current session.
let session_index = shared::Pallet::<C>::session_index();
/// Reward validators in session with points, but only if they are in the active set.
fn reward_only_active(
session_index: SessionIndex,
indices: impl IntoIterator<Item = ValidatorIndex>,
points: u32,
) {
let validators = session_info::Pallet::<C>::account_keys(&session_index);
let validators = match validators {
let validators = match validators
.defensive_proof("account_keys are present for dispute_period sessions")
{
Some(validators) => validators,
None => {
// Account keys are missing for the current session.
// This might happen only for the first session after
// `AccountKeys` were introduced via runtime upgrade.
return
},
None => return,
};
// limit rewards to the active validator set
let active_set: BTreeSet<_> = C::ValidatorSet::validators().into_iter().collect();

let rewards = indices
.into_iter()
.filter_map(|i| validators.get(i.0 as usize).cloned())
.map(|v| (v, BACKING_POINTS));
.filter(|v| active_set.contains(v))
.map(|v| (v, points));

<pallet_staking::Pallet<C>>::reward_by_ids(rewards);
}
}

impl<C> crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints<C>
where
C: pallet_staking::Config + shared::Config + session_info::Config,
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
{
fn reward_backing(indices: impl IntoIterator<Item = ValidatorIndex>) {
let session_index = shared::Pallet::<C>::session_index();
Self::reward_only_active(session_index, indices, BACKING_POINTS);
}

fn reward_bitfields(_validators: impl IntoIterator<Item = ValidatorIndex>) {}
}

impl<C> crate::disputes::RewardValidators for RewardValidatorsWithEraPoints<C>
where
C: pallet_staking::Config + session_info::Config,
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
{
fn reward_dispute_statement(
session: SessionIndex,
validators: impl IntoIterator<Item = ValidatorIndex>,
) {
Self::reward_only_active(session, validators, DISPUTE_STATEMENT_POINTS);
}
}
Loading

0 comments on commit 2037cdf

Please sign in to comment.