Skip to content
lib.rs 84.2 KiB
Newer Older
// Copyright (C) Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.

//! The Rococo runtime for v1 parachains.

#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit.
#![recursion_limit = "512"]
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
use beefy_primitives::{
	ecdsa_crypto::{AuthorityId as BeefyId, Signature as BeefySignature},
	mmr::{BeefyDataProvider, MmrLeafVersion},
};
use frame_support::{
	dynamic_params::{dynamic_pallet_params, dynamic_params},
	traits::FromContains,
};
use pallet_nis::WithMaximumOf;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
	slashing, AccountId, AccountIndex, ApprovalVotingParams, Balance, BlockNumber, CandidateEvent,
	CandidateHash, CommittedCandidateReceipt, CoreIndex, CoreState, DisputeState, ExecutorParams,
	GroupRotationInfo, Hash, Id as ParaId, InboundDownwardMessage, InboundHrmpMessage, Moment,
	NodeFeatures, Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
	SessionInfo, Signature, ValidationCode, ValidationCodeHash, ValidatorId, ValidatorIndex,
	PARACHAIN_KEY_TYPE_ID,
use rococo_runtime_constants::system_parachain::BROKER_ID;
use runtime_common::{
	assigned_slots, auctions, claims, crowdloan, identity_migrator, impl_runtime_weights,
		ContainsParts, LocatableAssetConverter, ToAuthor, VersionedLocatableAsset,
		VersionedLocationConverter,
	paras_registrar, paras_sudo_wrapper, prod_or_fast, slots,
	traits::{Leaser, OnSwap},
	BlockHashCount, BlockLength, SlowAdjustingFeeUpdate,
};
use runtime_parachains::{
	assigner_coretime as parachains_assigner_coretime,
	assigner_on_demand as parachains_assigner_on_demand, configuration as parachains_configuration,
	coretime, disputes as parachains_disputes,
	disputes::slashing as parachains_slashing,
	dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
	inclusion::{AggregateMessageOrigin, UmpQueueId},
	initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
	paras_inherent as parachains_paras_inherent,
	runtime_api_impl::{
		v10 as parachains_runtime_api_impl, vstaging as vstaging_parachains_runtime_api_impl,
	},
	scheduler as parachains_scheduler, session_info as parachains_session_info,
	shared as parachains_shared,
use scale_info::TypeInfo;
use sp_genesis_builder::PresetId;
use sp_std::{
	cmp::Ordering,
	collections::{btree_map::BTreeMap, vec_deque::VecDeque},
	prelude::*,
use frame_support::{
	construct_runtime, derive_impl,
	genesis_builder_helper::{build_state, get_preset},
		fungible::HoldConsideration, tokens::UnityOrOuterConversion, Contains, EitherOf,
		EitherOfDiverse, EnsureOrigin, EnsureOriginWithArg, EverythingBut, InstanceFilter,
		KeyOwnerProofSystem, LinearStoragePrice, PrivilegeCmp, ProcessMessage, ProcessMessageError,
		StorageMapShim, WithdrawReasons,
	weights::{ConstantMultiplier, WeightMeter, WeightToFee as _},
use frame_system::{EnsureRoot, EnsureSigned};
use pallet_grandpa::{fg_primitives, AuthorityId as GrandpaId};
use pallet_identity::legacy::IdentityInfo;
use pallet_session::historical as session_historical;
use pallet_transaction_payment::{FeeDetails, FungibleAdapter, RuntimeDispatchInfo};
use sp_core::{ConstU128, ConstU8, OpaqueMetadata, H256};
use sp_runtime::{
	create_runtime_str, generic, impl_opaque_keys,
	traits::{
		BlakeTwo256, Block as BlockT, ConstU32, ConvertInto, Extrinsic as ExtrinsicT,
		IdentityLookup, Keccak256, OpaqueKeys, SaturatedConversion, Verify,
	transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
	ApplyExtrinsicResult, FixedU128, KeyTypeId, Perbill, Percent, Permill, RuntimeDebug,
use sp_staking::SessionIndex;
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use xcm::{
	latest::prelude::*, IntoVersion, VersionedAssetId, VersionedAssets, VersionedLocation,
	VersionedXcm,
};
use xcm_builder::PayOverXcm;
pub use frame_system::Call as SystemCall;
pub use pallet_balances::Call as BalancesCall;
/// Constant values used within the runtime.
use rococo_runtime_constants::{currency::*, fee::*, time::*};

// Weights used in the runtime.

// XCM configurations.
pub mod xcm_config;
// Implemented types.
mod impls;
use impls::ToParachainIdentityReaper;

// Governance and configurations.
pub mod governance;
use governance::{
	pallet_custom_origins, AuctionAdmin, Fellows, GeneralAdmin, LeaseAdmin, Treasurer,
	TreasurySpender,
};
use xcm_fee_payment_runtime_api::Error as XcmPaymentApiError;
mod genesis_config_presets;
mod validator_manager;

impl_runtime_weights!(rococo_runtime_constants);

// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

/// Provides the `WASM_BINARY` build with `fast-runtime` feature enabled.
///
/// This is for example useful for local test chains.
#[cfg(feature = "std")]
pub mod fast_runtime_binary {
	include!(concat!(env!("OUT_DIR"), "/fast_runtime_binary.rs"));
}

/// Runtime version (Rococo).
Doordashcon's avatar
Doordashcon committed
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
	spec_name: create_runtime_str!("rococo"),
ordian's avatar
ordian committed
	impl_name: create_runtime_str!("parity-rococo-v2.0"),
	authoring_version: 0,
	spec_version: 1_010_000,
	impl_version: 0,
	apis: RUNTIME_API_VERSIONS,
	transaction_version: 24,
	state_version: 1,
/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
	babe_primitives::BabeEpochConfiguration {
		c: PRIMARY_PROBABILITY,
		allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
/// A type to identify calls to the Identity pallet. These will be filtered to prevent invocation,
/// locking the state of the pallet and preventing further updates to identities and sub-identities.
/// The locked state will be the genesis state of a new system chain and then removed from the Relay
/// Chain.
pub struct IsIdentityCall;
impl Contains<RuntimeCall> for IsIdentityCall {
	fn contains(c: &RuntimeCall) -> bool {
		matches!(c, RuntimeCall::Identity(_))
	}
}

parameter_types! {
	pub const Version: RuntimeVersion = VERSION;
#[derive_impl(frame_system::config_preludes::RelayChainDefaultConfig)]
Loading full blame...