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

Commit 2037cdf

Browse files
authored
Merge branch 'master' into coderobe/sync-29
2 parents b4a9bcd + 87d6cfc commit 2037cdf

34 files changed

+4620
-1076
lines changed

Cargo.lock

Lines changed: 264 additions & 287 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node/service/src/chain_spec.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,26 +1048,35 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
10481048
})
10491049
.collect::<Vec<_>>(),
10501050
},
1051+
phragmen_election: Default::default(),
10511052
babe: rococo_runtime::BabeConfig {
10521053
authorities: Default::default(),
10531054
epoch_config: Some(rococo_runtime::BABE_GENESIS_EPOCH_CONFIG),
10541055
},
10551056
grandpa: Default::default(),
10561057
im_online: Default::default(),
1057-
collective: Default::default(),
1058-
membership: Default::default(),
1058+
democracy: rococo_runtime::DemocracyConfig::default(),
1059+
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
1060+
technical_committee: rococo::TechnicalCommitteeConfig {
1061+
members: vec![],
1062+
phantom: Default::default(),
1063+
},
1064+
technical_membership: Default::default(),
1065+
treasury: Default::default(),
10591066
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
1067+
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
1068+
vesting: rococo::VestingConfig { vesting: vec![] },
10601069
sudo: rococo_runtime::SudoConfig { key: Some(endowed_accounts[0].clone()) },
10611070
paras: rococo_runtime::ParasConfig { paras: vec![] },
10621071
hrmp: Default::default(),
10631072
configuration: rococo_runtime::ConfigurationConfig {
10641073
config: default_parachains_host_configuration(),
10651074
},
1075+
gilt: Default::default(),
10661076
registrar: rococo_runtime::RegistrarConfig {
10671077
next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID,
10681078
},
10691079
xcm_pallet: Default::default(),
1070-
transaction_payment: Default::default(),
10711080
}
10721081
}
10731082

@@ -1599,8 +1608,17 @@ pub fn rococo_testnet_genesis(
15991608
},
16001609
grandpa: Default::default(),
16011610
im_online: Default::default(),
1602-
collective: Default::default(),
1603-
membership: Default::default(),
1611+
phragmen_election: Default::default(),
1612+
democracy: rococo::DemocracyConfig::default(),
1613+
council: rococo::CouncilConfig { members: vec![], phantom: Default::default() },
1614+
technical_committee: rococo::TechnicalCommitteeConfig {
1615+
members: vec![],
1616+
phantom: Default::default(),
1617+
},
1618+
technical_membership: Default::default(),
1619+
treasury: Default::default(),
1620+
claims: rococo::ClaimsConfig { claims: vec![], vesting: vec![] },
1621+
vesting: rococo::VestingConfig { vesting: vec![] },
16041622
authority_discovery: rococo_runtime::AuthorityDiscoveryConfig { keys: vec![] },
16051623
sudo: rococo_runtime::SudoConfig { key: Some(root_key.clone()) },
16061624
hrmp: Default::default(),
@@ -1610,12 +1628,12 @@ pub fn rococo_testnet_genesis(
16101628
..default_parachains_host_configuration()
16111629
},
16121630
},
1631+
gilt: Default::default(),
16131632
paras: rococo_runtime::ParasConfig { paras: vec![] },
16141633
registrar: rococo_runtime::RegistrarConfig {
16151634
next_free_para_id: polkadot_primitives::v2::LOWEST_PUBLIC_ID,
16161635
},
16171636
xcm_pallet: Default::default(),
1618-
transaction_payment: Default::default(),
16191637
}
16201638
}
16211639

node/service/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ where
801801
let auth_or_collator = role.is_authority() || is_collator.is_collator();
802802
let requires_overseer_for_chain_sel = local_keystore.is_some() && auth_or_collator;
803803

804-
let pvf_checker_enabled = !is_collator.is_collator() && chain_spec.is_versi();
804+
let pvf_checker_enabled = role.is_authority() && !is_collator.is_collator();
805805

806806
let select_chain = if requires_overseer_for_chain_sel {
807807
let metrics =

runtime/kusama/src/lib.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
2121
#![recursion_limit = "256"]
2222

23-
use pallet_transaction_payment::CurrencyAdapter;
2423
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
2524
use primitives::v2::{
2625
AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CandidateHash,
@@ -63,7 +62,7 @@ use frame_system::EnsureRoot;
6362
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
6463
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
6564
use pallet_session::historical as session_historical;
66-
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
65+
use pallet_transaction_payment::{CurrencyAdapter, FeeDetails, RuntimeDispatchInfo};
6766
use sp_core::OpaqueMetadata;
6867
use sp_mmr_primitives as mmr;
6968
use sp_runtime::{
@@ -86,7 +85,6 @@ pub use pallet_balances::Call as BalancesCall;
8685
pub use pallet_election_provider_multi_phase::Call as EPMCall;
8786
#[cfg(feature = "std")]
8887
pub use pallet_staking::StakerStatus;
89-
pub use pallet_timestamp::Call as TimestampCall;
9088
#[cfg(any(feature = "std", test))]
9189
pub use sp_runtime::BuildStorage;
9290

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

364-
parameter_types! {
365-
pub const Period: BlockNumber = 10 * MINUTES;
366-
pub const Offset: BlockNumber = 0;
367-
}
368-
369362
impl_opaque_keys! {
370363
pub struct SessionKeys {
371364
pub grandpa: Grandpa,
@@ -425,6 +418,8 @@ parameter_types! {
425418
/// ... and all of the validators as electable targets. Whilst this is the case, we cannot and
426419
/// shall not increase the size of the validator intentions.
427420
pub const MaxElectableTargets: u16 = u16::MAX;
421+
pub NposSolutionPriority: TransactionPriority =
422+
Perbill::from_percent(90) * TransactionPriority::max_value();
428423
}
429424

430425
generate_solution_type!(
@@ -733,8 +728,6 @@ impl pallet_authority_discovery::Config for Runtime {
733728
}
734729

735730
parameter_types! {
736-
pub NposSolutionPriority: TransactionPriority =
737-
Perbill::from_percent(90) * TransactionPriority::max_value();
738731
pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
739732
}
740733

@@ -1159,7 +1152,7 @@ impl parachains_hrmp::Config for Runtime {
11591152
type Event = Event;
11601153
type Origin = Origin;
11611154
type Currency = Balances;
1162-
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Self>;
1155+
type WeightInfo = weights::runtime_parachains_hrmp::WeightInfo<Runtime>;
11631156
}
11641157

11651158
impl parachains_paras_inherent::Config for Runtime {
@@ -1176,7 +1169,7 @@ impl parachains_initializer::Config for Runtime {
11761169

11771170
impl parachains_disputes::Config for Runtime {
11781171
type Event = Event;
1179-
type RewardValidators = ();
1172+
type RewardValidators = parachains_reward_points::RewardValidatorsWithEraPoints<Runtime>;
11801173
type PunishValidators = ();
11811174
type WeightInfo = weights::runtime_parachains_disputes::WeightInfo<Runtime>;
11821175
}
@@ -1343,7 +1336,6 @@ construct_runtime! {
13431336
TechnicalMembership: pallet_membership::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 17,
13441337
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 18,
13451338

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

runtime/kusama/src/xcm_config.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ pub type XcmRouter = (
102102
parameter_types! {
103103
pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) });
104104
pub const Statemine: MultiLocation = Parachain(1000).into();
105+
pub const Encointer: MultiLocation = Parachain(1001).into();
105106
pub const KusamaForStatemine: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Statemine::get());
106-
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1001).into());
107+
pub const KusamaForEncointer: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Encointer::get());
107108
}
108109
pub type TrustedTeleporters =
109110
(xcm_builder::Case<KusamaForStatemine>, xcm_builder::Case<KusamaForEncointer>);

runtime/parachains/src/reward_points.rs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,42 +22,71 @@
2222
//! for the time being, although we will build schemes to do so in the future.
2323
2424
use crate::{session_info, shared};
25-
use frame_support::traits::ValidatorSet;
26-
use primitives::v2::ValidatorIndex;
25+
use frame_support::traits::{Defensive, ValidatorSet};
26+
use primitives::v2::{SessionIndex, ValidatorIndex};
27+
use sp_std::collections::btree_set::BTreeSet;
2728

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

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

34-
impl<C> crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints<C>
37+
impl<C> RewardValidatorsWithEraPoints<C>
3538
where
36-
C: pallet_staking::Config + shared::Config + session_info::Config,
39+
C: pallet_staking::Config + session_info::Config,
3740
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
3841
{
39-
fn reward_backing(indices: impl IntoIterator<Item = ValidatorIndex>) {
40-
// Fetch the validators from the _session_ because sessions are offset from eras
41-
// and we are rewarding for behavior in current session.
42-
let session_index = shared::Pallet::<C>::session_index();
42+
/// Reward validators in session with points, but only if they are in the active set.
43+
fn reward_only_active(
44+
session_index: SessionIndex,
45+
indices: impl IntoIterator<Item = ValidatorIndex>,
46+
points: u32,
47+
) {
4348
let validators = session_info::Pallet::<C>::account_keys(&session_index);
44-
let validators = match validators {
49+
let validators = match validators
50+
.defensive_proof("account_keys are present for dispute_period sessions")
51+
{
4552
Some(validators) => validators,
46-
None => {
47-
// Account keys are missing for the current session.
48-
// This might happen only for the first session after
49-
// `AccountKeys` were introduced via runtime upgrade.
50-
return
51-
},
53+
None => return,
5254
};
55+
// limit rewards to the active validator set
56+
let active_set: BTreeSet<_> = C::ValidatorSet::validators().into_iter().collect();
5357

5458
let rewards = indices
5559
.into_iter()
5660
.filter_map(|i| validators.get(i.0 as usize).cloned())
57-
.map(|v| (v, BACKING_POINTS));
61+
.filter(|v| active_set.contains(v))
62+
.map(|v| (v, points));
5863

5964
<pallet_staking::Pallet<C>>::reward_by_ids(rewards);
6065
}
66+
}
67+
68+
impl<C> crate::inclusion::RewardValidators for RewardValidatorsWithEraPoints<C>
69+
where
70+
C: pallet_staking::Config + shared::Config + session_info::Config,
71+
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
72+
{
73+
fn reward_backing(indices: impl IntoIterator<Item = ValidatorIndex>) {
74+
let session_index = shared::Pallet::<C>::session_index();
75+
Self::reward_only_active(session_index, indices, BACKING_POINTS);
76+
}
6177

6278
fn reward_bitfields(_validators: impl IntoIterator<Item = ValidatorIndex>) {}
6379
}
80+
81+
impl<C> crate::disputes::RewardValidators for RewardValidatorsWithEraPoints<C>
82+
where
83+
C: pallet_staking::Config + session_info::Config,
84+
C::ValidatorSet: ValidatorSet<C::AccountId, ValidatorId = C::AccountId>,
85+
{
86+
fn reward_dispute_statement(
87+
session: SessionIndex,
88+
validators: impl IntoIterator<Item = ValidatorIndex>,
89+
) {
90+
Self::reward_only_active(session, validators, DISPUTE_STATEMENT_POINTS);
91+
}
92+
}

0 commit comments

Comments
 (0)