Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,14 @@ db = ["service/db"]
full-node = [
"polkadot-node-core-av-store",
]
runtime-benchmarks = ["polkadot-runtime/runtime-benchmarks", "kusama-runtime/runtime-benchmarks", "westend-runtime/runtime-benchmarks"]

runtime-benchmarks = [
"polkadot-runtime/runtime-benchmarks",
"kusama-runtime/runtime-benchmarks",
"westend-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks"
]

real-overseer = [
"polkadot-availability-bitfield-distribution",
"polkadot-availability-distribution",
Expand Down
2 changes: 0 additions & 2 deletions node/service/src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,6 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
}),
pallet_staking: Some(Default::default()),
pallet_sudo: Some(rococo_runtime::SudoConfig {
key: endowed_accounts[0].clone(),
}),
Expand Down Expand Up @@ -1343,7 +1342,6 @@ pub fn rococo_testnet_genesis(
pallet_authority_discovery: Some(rococo_runtime::AuthorityDiscoveryConfig {
keys: vec![],
}),
pallet_staking: Some(Default::default()),
pallet_sudo: Some(rococo_runtime::SudoConfig { key: root_key }),
parachains_configuration: Some(rococo_runtime::ParachainsConfigurationConfig {
config: polkadot_runtime_parachains::configuration::HostConfiguration {
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub type NegativeImbalance<T> = <pallet_balances::Module<T> as Currency<<T as fr

/// The sequence of bytes a valid wasm module binary always starts with. Apart from that it's also a
/// valid wasm module.
const WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];
pub const WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];

/// We assume that an on-initialize consumes 2.5% of the weight on average, hence a single extrinsic
/// will not be allowed to consume more than `AvailableBlockRatio - 2.5%`.
Expand Down
2 changes: 1 addition & 1 deletion runtime/parachains/src/paras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ decl_storage! {

/// Upcoming paras (chains and threads). These are only updated on session change. Corresponds to an
/// entry in the upcoming-genesis map.
UpcomingParas: Vec<ParaId>;
UpcomingParas get(fn upcoming_paras): Vec<ParaId>;
/// Upcoming paras instantiation arguments.
UpcomingParasGenesis: map hasher(twox_64_concat) ParaId => Option<ParaGenesisArgs>;
/// Paras that are to be cleaned up at the end of the session.
Expand Down
14 changes: 14 additions & 0 deletions runtime/rococo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parity-scale-codec = { version = "1.3.5", default-features = false, features = [
serde = { version = "1.0.118", default-features = false }
serde_derive = { version = "1.0.117", optional = true }
smallvec = "1.6.1"
hex-literal = "0.3.1"

frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
Expand Down Expand Up @@ -113,3 +114,16 @@ std = [
# runtime without clashing with the runtime api exported functions
# in WASM.
disable-runtime-api = []
runtime-benchmarks = [
"runtime-common/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-grandpa/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-indices/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
]
141 changes: 70 additions & 71 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@ use primitives::v1::{
SessionInfo as SessionInfoData,
};
use runtime_common::{
SlowAdjustingFeeUpdate,
impls::ToAuthor,
BlockHashCount, BlockWeights, BlockLength, RocksDbWeight, OffchainSolutionWeightLimit,
SlowAdjustingFeeUpdate, impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
};
use runtime_parachains::{
self,
runtime_api_impl::v1 as runtime_api_impl,
};
use frame_support::{
parameter_types, construct_runtime, debug,
traits::{KeyOwnerProofSystem, Filter},
weights::Weight,
parameter_types, construct_runtime, debug, traits::{KeyOwnerProofSystem, Filter, EnsureOrigin}, weights::Weight,
};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
ApplyExtrinsicResult, KeyTypeId, Perbill,
transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
traits::{
BlakeTwo256, Block as BlockT, OpaqueKeys, IdentityLookup,
Expand All @@ -64,7 +60,7 @@ use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
use pallet_session::historical as session_historical;
use frame_system::EnsureRoot;
use frame_system::{EnsureRoot, EnsureOneOf, EnsureSigned};
use runtime_common::{paras_sudo_wrapper, paras_registrar};

use runtime_parachains::origin as parachains_origin;
Expand All @@ -78,10 +74,8 @@ use runtime_parachains::dmp as parachains_dmp;
use runtime_parachains::ump as parachains_ump;
use runtime_parachains::hrmp as parachains_hrmp;
use runtime_parachains::scheduler as parachains_scheduler;
use runtime_parachains::reward_points::RewardValidatorsWithEraPoints;

pub use pallet_balances::Call as BalancesCall;
pub use pallet_staking::StakerStatus;

use polkadot_parachain::primitives::Id as ParaId;
use xcm::v0::{MultiLocation, NetworkId};
Expand All @@ -91,10 +85,11 @@ use xcm_builder::{
CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative,
SignedAccountId32AsNative, ChildSystemParachainAsSuperuser, LocationInverter,
};
use constants::{time::*, currency::*, fee::*};

/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*, fee::*};
mod propose_parachain;

// Make the WASM binary available.
#[cfg(feature = "std")]
Expand All @@ -105,7 +100,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("rococo"),
impl_name: create_runtime_str!("parity-rococo-v1"),
authoring_version: 0,
spec_version: 14,
spec_version: 15,
impl_version: 0,
#[cfg(not(feature = "disable-runtime-api"))]
apis: RUNTIME_API_VERSIONS,
Expand Down Expand Up @@ -182,7 +177,6 @@ construct_runtime! {

// Consensus support.
Authorship: pallet_authorship::{Module, Call, Storage},
Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>, ValidateUnsigned},
Offences: pallet_offences::{Module, Call, Storage, Event},
Historical: session_historical::{Module},
Session: pallet_session::{Module, Call, Storage, Event, Config<T>},
Expand All @@ -208,6 +202,9 @@ construct_runtime! {

// Sudo
Sudo: pallet_sudo::{Module, Call, Storage, Event<T>, Config<T>},

// Propose parachain pallet.
ProposeParachain: propose_parachain::{Module, Call, Storage, Event},
}
}

Expand Down Expand Up @@ -304,35 +301,15 @@ impl frame_system::offchain::SigningTypes for Runtime {
type Signature = Signature;
}

impl pallet_session::historical::Config for Runtime {
type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
/// Special `FullIdentificationOf` implementation that is returning for every input `Some(Default::default())`.
pub struct FullIdentificationOf;
impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
fn convert(_: AccountId) -> Option<()> { Some(Default::default()) }
}

pallet_staking_reward_curve::build! {
const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
min_inflation: 0_025_000,
max_inflation: 0_100_000,
ideal_stake: 0_500_000,
falloff: 0_050_000,
max_piece_count: 40,
test_precision: 0_005_000,
);
}

parameter_types! {
// Six sessions in an era (6 hours).
pub const SessionsPerEra: SessionIndex = 6;
// 28 eras for unbonding (7 days).
pub const BondingDuration: pallet_staking::EraIndex = 28;
// 27 eras in which slashes can be cancelled (~7 days).
pub const SlashDeferDuration: pallet_staking::EraIndex = 27;
pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
pub const MaxNominatorRewardedPerValidator: u32 = 64;
// quarter of the last session will be for election.
pub ElectionLookahead: BlockNumber = EpochDurationInBlocks::get() / 4;
pub const MaxIterations: u32 = 10;
pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
impl pallet_session::historical::Config for Runtime {
type FullIdentification = ();
type FullIdentificationOf = FullIdentificationOf;
}

parameter_types! {
Expand All @@ -353,32 +330,6 @@ impl pallet_im_online::Config for Runtime {
type WeightInfo = ();
}

impl pallet_staking::Config for Runtime {
type Currency = Balances;
type UnixTime = Timestamp;
type CurrencyToVote = frame_support::traits::U128CurrencyToVote;
type RewardRemainder = ();
type Event = Event;
type Slash = ();
type Reward = ();
type SessionsPerEra = SessionsPerEra;
type BondingDuration = BondingDuration;
type SlashDeferDuration = SlashDeferDuration;
// A majority of the council can cancel the slash.
type SlashCancelOrigin = EnsureRoot<AccountId>;
type SessionInterface = Self;
type RewardCurve = RewardCurve;
type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
type NextNewSession = Session;
type ElectionLookahead = ElectionLookahead;
type Call = Call;
type UnsignedPriority = StakingUnsignedPriority;
type MaxIterations = MaxIterations;
type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
type MinSolutionScoreBump = MinSolutionScoreBump;
type WeightInfo = ();
}

parameter_types! {
pub const ExistentialDeposit: Balance = 1 * CENTS;
pub const MaxLocks: u32 = 50;
Expand Down Expand Up @@ -414,7 +365,7 @@ parameter_types! {
impl pallet_offences::Config for Runtime {
type Event = Event;
type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
type OnOffenceHandler = Staking;
type OnOffenceHandler = ();
type WeightSoftLimit = OffencesWeightSoftLimit;
}

Expand Down Expand Up @@ -445,13 +396,19 @@ parameter_types! {
pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
}

/// Special `ValidatorIdOf` implementation that is just returning the input as result.
pub struct ValidatorIdOf;
impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf {
fn convert(a: AccountId) -> Option<AccountId> { Some(a) }
}

impl pallet_session::Config for Runtime {
type Event = Event;
type ValidatorId = AccountId;
type ValidatorIdOf = pallet_staking::StashOf<Self>;
type ValidatorIdOf = ValidatorIdOf;
type ShouldEndSession = Babe;
type NextSessionRotation = Babe;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ProposeParachain>;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
Expand Down Expand Up @@ -531,16 +488,23 @@ impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
type UncleGenerations = UncleGenerations;
type FilterUncle = ();
type EventHandler = (Staking, ImOnline);
type EventHandler = ImOnline;
}

impl parachains_origin::Config for Runtime {}

impl parachains_configuration::Config for Runtime {}

/// Special `RewardValidators` that does nothing ;)
pub struct RewardValidators;
impl runtime_parachains::inclusion::RewardValidators for RewardValidators {
fn reward_backing(_: impl IntoIterator<Item=ValidatorIndex>) {}
fn reward_bitfields(_: impl IntoIterator<Item=ValidatorIndex>) {}
}

impl parachains_inclusion::Config for Runtime {
type Event = Event;
type RewardValidators = RewardValidatorsWithEraPoints<Runtime>;
type RewardValidators = RewardValidators;
}

impl parachains_paras::Config for Runtime {
Expand Down Expand Up @@ -621,6 +585,41 @@ impl pallet_sudo::Config for Runtime {
type Call = Call;
}

/// Priviledged origin used by propose parachain.
pub struct PriviledgedOrigin;

impl EnsureOrigin<Origin> for PriviledgedOrigin {
type Success = ();

fn try_origin(o: Origin) -> Result<Self::Success, Origin> {
let allowed = [
hex_literal::hex!("b44c58e50328768ac06ed44b842bfa69d86ea10f60bc36156c9ffc5e00867220"),
hex_literal::hex!("762a6a38ba72b139cba285a39a6766e02046fb023f695f5ecf7f48b037c0dd6b")
];

let origin = o.clone();
match EnsureSigned::try_origin(o) {
Ok(who) if allowed.iter().any(|a| a == &who.as_ref()) => Ok(()),
_ => Err(origin),
}
}

#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> Origin { Origin::root() }
}

parameter_types! {
pub const ProposeDeposit: Balance = 1000 * DOLLARS;
pub const MaxNameLength: u32 = 20;
}

impl propose_parachain::Config for Runtime {
type Event = Event;
type MaxNameLength = MaxNameLength;
type ProposeDeposit = ProposeDeposit;
type PriviledgedOrigin = EnsureOneOf<AccountId, EnsureRoot<AccountId>, PriviledgedOrigin>;
}

#[cfg(not(feature = "disable-runtime-api"))]
sp_api::impl_runtime_apis! {
impl sp_api::Core<Block> for Runtime {
Expand Down
Loading