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 4 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
2 changes: 2 additions & 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: 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
2 changes: 2 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,4 @@ std = [
# runtime without clashing with the runtime api exported functions
# in WASM.
disable-runtime-api = []
runtime-benchmarks = []
49 changes: 43 additions & 6 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ use runtime_parachains::{
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,
Expand All @@ -64,7 +62,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 @@ -91,10 +89,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 Down Expand Up @@ -208,6 +207,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 @@ -451,7 +453,7 @@ impl pallet_session::Config for Runtime {
type ValidatorIdOf = pallet_staking::StashOf<Self>;
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 @@ -621,6 +623,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