lib.rs 42 KB
Newer Older
Fedor Sakharov's avatar
Fedor Sakharov committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2020 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/>.

17
//! The Rococo runtime for v1 parachains.
Fedor Sakharov's avatar
Fedor Sakharov committed
18
19
20

#![cfg_attr(not(feature = "std"), no_std)]
// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.
21
#![recursion_limit = "256"]
Fedor Sakharov's avatar
Fedor Sakharov committed
22

Albrecht's avatar
Albrecht committed
23
use pallet_transaction_payment::CurrencyAdapter;
Fedor Sakharov's avatar
Fedor Sakharov committed
24
use sp_std::prelude::*;
Sergey Pepyakin's avatar
Sergey Pepyakin committed
25
use sp_std::collections::btree_map::BTreeMap;
26
use parity_scale_codec::{Encode, Decode, MaxEncodedLen};
Fedor Sakharov's avatar
Fedor Sakharov committed
27
28
use primitives::v1::{
	AccountId, AccountIndex, Balance, BlockNumber, Hash, Nonce, Signature, Moment,
29
	GroupRotationInfo, CoreState, Id, ValidationCode, ValidationCodeHash, CandidateEvent,
Fedor Sakharov's avatar
Fedor Sakharov committed
30
	ValidatorId, ValidatorIndex, CommittedCandidateReceipt, OccupiedCoreAssumption,
31
32
	PersistedValidationData, InboundDownwardMessage, InboundHrmpMessage,
	SessionInfo as SessionInfoData,
Fedor Sakharov's avatar
Fedor Sakharov committed
33
34
};
use runtime_common::{
35
	mmr as mmr_common,
36
	SlowAdjustingFeeUpdate, impls::ToAuthor, BlockHashCount, BlockWeights, BlockLength, RocksDbWeight,
Fedor Sakharov's avatar
Fedor Sakharov committed
37
38
39
40
41
};
use runtime_parachains::{
	self,
	runtime_api_impl::v1 as runtime_api_impl,
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
42
43
use frame_support::{
	construct_runtime, parameter_types,
44
	traits::{Filter, KeyOwnerProofSystem, Randomness, All, IsInVec},
Shawn Tabrizi's avatar
Shawn Tabrizi committed
45
46
47
	weights::Weight,
	PalletId
};
Fedor Sakharov's avatar
Fedor Sakharov committed
48
49
use sp_runtime::{
	create_runtime_str, generic, impl_opaque_keys,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
50
	ApplyExtrinsicResult, KeyTypeId, Perbill,
Fedor Sakharov's avatar
Fedor Sakharov committed
51
52
	transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
	traits::{
53
		self, Keccak256, BlakeTwo256, Block as BlockT, OpaqueKeys, AccountIdLookup,
Fedor Sakharov's avatar
Fedor Sakharov committed
54
55
56
		Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
	},
};
57
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
Fedor Sakharov's avatar
Fedor Sakharov committed
58
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
59
60
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
61
use sp_version::RuntimeVersion;
62
use pallet_transaction_payment::{FeeDetails, RuntimeDispatchInfo};
63
use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
64
use sp_core::{OpaqueMetadata, RuntimeDebug};
Fedor Sakharov's avatar
Fedor Sakharov committed
65
use sp_staking::SessionIndex;
66
use pallet_session::historical as session_historical;
Andreas Doerr's avatar
Andreas Doerr committed
67
use beefy_primitives::crypto::AuthorityId as BeefyId;
68
use pallet_mmr_primitives as mmr;
69
70
use frame_system::EnsureRoot;
use runtime_common::{paras_sudo_wrapper, paras_registrar, xcm_sender, auctions, crowdloan, slots};
Fedor Sakharov's avatar
Fedor Sakharov committed
71

72
use runtime_parachains::origin as parachains_origin;
Fedor Sakharov's avatar
Fedor Sakharov committed
73
use runtime_parachains::configuration as parachains_configuration;
74
use runtime_parachains::shared as parachains_shared;
Fedor Sakharov's avatar
Fedor Sakharov committed
75
use runtime_parachains::inclusion as parachains_inclusion;
76
use runtime_parachains::paras_inherent as parachains_paras_inherent;
Fedor Sakharov's avatar
Fedor Sakharov committed
77
use runtime_parachains::initializer as parachains_initializer;
78
use runtime_parachains::session_info as parachains_session_info;
Fedor Sakharov's avatar
Fedor Sakharov committed
79
use runtime_parachains::paras as parachains_paras;
80
81
82
use runtime_parachains::dmp as parachains_dmp;
use runtime_parachains::ump as parachains_ump;
use runtime_parachains::hrmp as parachains_hrmp;
Fedor Sakharov's avatar
Fedor Sakharov committed
83
84
use runtime_parachains::scheduler as parachains_scheduler;

85
pub use pallet_balances::Call as BalancesCall;
Fedor Sakharov's avatar
Fedor Sakharov committed
86

Shawn Tabrizi's avatar
Shawn Tabrizi committed
87
use polkadot_parachain::primitives::Id as ParaId;
88

89
use xcm::v0::{Xcm, MultiLocation, NetworkId, BodyId};
Gavin Wood's avatar
Gavin Wood committed
90
use xcm_executor::XcmExecutor;
91
92
93
94
use xcm_builder::{
	AccountId32Aliases, ChildParachainConvertsVia, SovereignSignedViaLocation,
	CurrencyAdapter as XcmCurrencyAdapter, ChildParachainAsNative, SignedAccountId32AsNative,
	ChildSystemParachainAsSuperuser, LocationInverter, IsConcrete, FixedWeightBounds,
95
	BackingToPlurality, SignedToAccountId32, UsingComponents,
96
};
97
use constants::{time::*, currency::*, fee::*};
98
use frame_support::traits::InstanceFilter;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
99

Fedor Sakharov's avatar
Fedor Sakharov committed
100
101
/// Constant values used within the runtime.
pub mod constants;
102
mod validator_manager;
Fedor Sakharov's avatar
Fedor Sakharov committed
103
104
105
106
107

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

108
109
110
/// Runtime version (Rococo).
pub const VERSION: RuntimeVersion = RuntimeVersion {
	spec_name: create_runtime_str!("rococo"),
Bastian Köcher's avatar
Bastian Köcher committed
111
	impl_name: create_runtime_str!("parity-rococo-v1.6"),
112
	authoring_version: 0,
113
	spec_version: 9004,
114
115
116
117
118
119
120
121
	impl_version: 0,
	#[cfg(not(feature = "disable-runtime-api"))]
	apis: RUNTIME_API_VERSIONS,
	#[cfg(feature = "disable-runtime-api")]
	apis: sp_version::create_apis_vec![[]],
	transaction_version: 0,
};

122
123
124
125
126
127
128
/// 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
	};

129
130
131
132
133
134
135
136
137
/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
	NativeVersion {
		runtime_version: VERSION,
		can_author_with: Default::default(),
	}
}

Fedor Sakharov's avatar
Fedor Sakharov committed
138
/// The address format for describing accounts.
139
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
Fedor Sakharov's avatar
Fedor Sakharov committed
140
141
142
143
144
145
146
147
148
149
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
150
151
152
153
154
155
156
	frame_system::CheckSpecVersion<Runtime>,
	frame_system::CheckTxVersion<Runtime>,
	frame_system::CheckGenesis<Runtime>,
	frame_system::CheckMortality<Runtime>,
	frame_system::CheckNonce<Runtime>,
	frame_system::CheckWeight<Runtime>,
	pallet_transaction_payment::ChargeTransactionPayment<Runtime>,
Fedor Sakharov's avatar
Fedor Sakharov committed
157
158
159
160
161
);

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
162
163
164
165
166
167
pub type Executive = frame_executive::Executive<
	Runtime,
	Block,
	frame_system::ChainContext<Runtime>,
	Runtime,
	AllPallets,
168
	GrandpaStoragePrefixMigration,
169
>;
Fedor Sakharov's avatar
Fedor Sakharov committed
170
171
172
173
174
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

impl_opaque_keys! {
	pub struct SessionKeys {
175
		pub grandpa: Grandpa,
Fedor Sakharov's avatar
Fedor Sakharov committed
176
177
		pub babe: Babe,
		pub im_online: ImOnline,
178
179
		pub para_validator: Initializer,
		pub para_assignment: SessionInfo,
180
		pub authority_discovery: AuthorityDiscovery,
181
182
183
184
		pub beefy: Beefy,
	}
}

Fedor Sakharov's avatar
Fedor Sakharov committed
185
186
187
188
189
190
construct_runtime! {
	pub enum Runtime where
		Block = Block,
		NodeBlock = primitives::v1::Block,
		UncheckedExtrinsic = UncheckedExtrinsic
	{
191
		System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
Fedor Sakharov's avatar
Fedor Sakharov committed
192
193

		// Must be before session.
194
		Babe: pallet_babe::{Pallet, Call, Storage, Config, ValidateUnsigned},
Fedor Sakharov's avatar
Fedor Sakharov committed
195

196
197
198
199
		Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent},
		Indices: pallet_indices::{Pallet, Call, Storage, Config<T>, Event<T>},
		Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>},
		TransactionPayment: pallet_transaction_payment::{Pallet, Storage},
Fedor Sakharov's avatar
Fedor Sakharov committed
200
201

		// Consensus support.
202
		Authorship: pallet_authorship::{Pallet, Call, Storage},
Keith Yeung's avatar
Keith Yeung committed
203
		Offences: pallet_offences::{Pallet, Storage, Event},
204
205
206
207
		Historical: session_historical::{Pallet},
		Session: pallet_session::{Pallet, Call, Storage, Event, Config<T>},
		Grandpa: pallet_grandpa::{Pallet, Call, Storage, Config, Event, ValidateUnsigned},
		ImOnline: pallet_im_online::{Pallet, Call, Storage, Event<T>, ValidateUnsigned, Config<T>},
Keith Yeung's avatar
Keith Yeung committed
208
		AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
Fedor Sakharov's avatar
Fedor Sakharov committed
209
210

		// Parachains modules.
211
212
213
214
		ParachainsOrigin: parachains_origin::{Pallet, Origin},
		ParachainsConfiguration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
		Shared: parachains_shared::{Pallet, Call, Storage},
		Inclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
215
		ParasInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent},
216
		Scheduler: parachains_scheduler::{Pallet, Call, Storage},
ferrell-code's avatar
ferrell-code committed
217
		Paras: parachains_paras::{Pallet, Call, Storage, Event, Config},
218
219
		Initializer: parachains_initializer::{Pallet, Call, Storage},
		Dmp: parachains_dmp::{Pallet, Call, Storage},
220
		Ump: parachains_ump::{Pallet, Call, Storage, Event},
221
		Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event, Config},
222
223
		SessionInfo: parachains_session_info::{Pallet, Call, Storage},

224
		// Parachain Onboarding Pallets
225
		Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>},
226
227
228
		Auctions: auctions::{Pallet, Call, Storage, Event<T>},
		Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>},
		Slots: slots::{Pallet, Call, Storage, Event<T>},
229
		ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call},
230
231

		// Sudo
232
		Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>},
233

234
235
236
237
238
		// Bridges support.
		Mmr: pallet_mmr::{Pallet, Call, Storage},
		Beefy: pallet_beefy::{Pallet, Config<T>, Storage},
		MmrLeaf: mmr_common::{Pallet, Storage},

239
240
241
242
243
244
		// It might seem strange that we add both sides of the bridge to the same runtime. We do this because this
		// runtime as shared by both the Rococo and Wococo chains. When running as Rococo we only use
		// `BridgeWococoGrandpa`, and vice versa.
		BridgeRococoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Config<T>} = 40,
		BridgeWococoGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Storage, Config<T>} = 41,

245
246
		// Validator Manager pallet.
		ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
247

248
249
250
251
		// A "council"
		Collective: pallet_collective::{Pallet, Call, Storage, Origin<T>, Event<T>, Config<T>} = 80,
		Membership: pallet_membership::{Pallet, Call, Storage, Event<T>, Config<T>} = 81,

252
253
		Utility: pallet_utility::{Pallet, Call, Event} = 90,
		Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 91,
Gavin Wood's avatar
Gavin Wood committed
254
255

		// Pallet for sending XCM.
Shawn Tabrizi's avatar
Shawn Tabrizi committed
256
		XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin} = 99,
257
258
259
	}
}

260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
pub struct GrandpaStoragePrefixMigration;
impl frame_support::traits::OnRuntimeUpgrade for GrandpaStoragePrefixMigration {
	fn on_runtime_upgrade() -> frame_support::weights::Weight {
		use frame_support::traits::PalletInfo;
		let name = <Runtime as frame_system::Config>::PalletInfo::name::<Grandpa>()
			.expect("grandpa is part of pallets in construct_runtime, so it has a name; qed");
		pallet_grandpa::migrations::v3_1::migrate::<Runtime, Grandpa, _>(name)
	}

	#[cfg(feature = "try-runtime")]
	fn pre_upgrade() -> Result<(), &'static str> {
		use frame_support::traits::PalletInfo;
		let name = <Runtime as frame_system::Config>::PalletInfo::name::<Grandpa>()
			.expect("grandpa is part of pallets in construct_runtime, so it has a name; qed");
		pallet_grandpa::migrations::v3_1::pre_migration::<Runtime, Grandpa, _>(name);
		Ok(())
	}

	#[cfg(feature = "try-runtime")]
	fn post_upgrade() -> Result<(), &'static str> {
		pallet_grandpa::migrations::v3_1::post_migration::<Grandpa>();
		Ok(())
	}
}

285
286
287
288
289
290
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
	fn filter(_call: &Call) -> bool {
		true
	}
}
291

Fedor Sakharov's avatar
Fedor Sakharov committed
292
293
parameter_types! {
	pub const Version: RuntimeVersion = VERSION;
294
	pub const SS58Prefix: u8 = 42;
Fedor Sakharov's avatar
Fedor Sakharov committed
295
296
}

297
impl frame_system::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
298
	type BaseCallFilter = BaseFilter;
299
300
301
	type BlockWeights = BlockWeights;
	type BlockLength = BlockLength;
	type DbWeight = RocksDbWeight;
Fedor Sakharov's avatar
Fedor Sakharov committed
302
303
304
305
306
307
308
	type Origin = Origin;
	type Call = Call;
	type Index = Nonce;
	type BlockNumber = BlockNumber;
	type Hash = Hash;
	type Hashing = BlakeTwo256;
	type AccountId = AccountId;
309
	type Lookup = AccountIdLookup<AccountId, ()>;
Fedor Sakharov's avatar
Fedor Sakharov committed
310
311
312
313
	type Header = generic::Header<BlockNumber, BlakeTwo256>;
	type Event = Event;
	type BlockHashCount = BlockHashCount;
	type Version = Version;
314
	type PalletInfo = PalletInfo;
315
	type AccountData = pallet_balances::AccountData<Balance>;
Fedor Sakharov's avatar
Fedor Sakharov committed
316
317
318
	type OnNewAccount = ();
	type OnKilledAccount = ();
	type SystemWeightInfo = ();
319
	type SS58Prefix = SS58Prefix;
320
	type OnSetCode = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
321
322
323
324
325
326
327
328
329
330
}

parameter_types! {
	pub const ValidationUpgradeFrequency: BlockNumber = 2 * DAYS;
	pub const ValidationUpgradeDelay: BlockNumber = 8 * HOURS;
	pub const SlashPeriod: BlockNumber = 7 * DAYS;
}

/// Submits a transaction with the node's public and signature type. Adheres to the signed extension
/// format of the chain.
331
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
Fedor Sakharov's avatar
Fedor Sakharov committed
332
333
	Call: From<LocalCall>,
{
334
	fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
Fedor Sakharov's avatar
Fedor Sakharov committed
335
336
337
		call: Call,
		public: <Signature as Verify>::Signer,
		account: AccountId,
338
		nonce: <Runtime as frame_system::Config>::Index,
Fedor Sakharov's avatar
Fedor Sakharov committed
339
	) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
340
		use sp_runtime::traits::StaticLookup;
Fedor Sakharov's avatar
Fedor Sakharov committed
341
342
343
344
345
346
347
348
349
350
351
352
353
		// take the biggest period possible.
		let period = BlockHashCount::get()
			.checked_next_power_of_two()
			.map(|c| c / 2)
			.unwrap_or(2) as u64;

		let current_block = System::block_number()
			.saturated_into::<u64>()
			// The `System::block_number` is initialized with `n+1`,
			// so the actual block number is `n`.
			.saturating_sub(1);
		let tip = 0;
		let extra: SignedExtra = (
354
355
356
357
358
359
360
			frame_system::CheckSpecVersion::<Runtime>::new(),
			frame_system::CheckTxVersion::<Runtime>::new(),
			frame_system::CheckGenesis::<Runtime>::new(),
			frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(period, current_block)),
			frame_system::CheckNonce::<Runtime>::from(nonce),
			frame_system::CheckWeight::<Runtime>::new(),
			pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
Fedor Sakharov's avatar
Fedor Sakharov committed
361
362
		);
		let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
363
			log::warn!("Unable to create signed payload: {:?}", e);
Fedor Sakharov's avatar
Fedor Sakharov committed
364
365
366
367
368
		}).ok()?;
		let signature = raw_payload.using_encoded(|payload| {
			C::sign(payload, public)
		})?;
		let (call, extra, _) = raw_payload.deconstruct();
369
370
		let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
		Some((call, (address, signature, extra)))
Fedor Sakharov's avatar
Fedor Sakharov committed
371
372
373
	}
}

374
impl frame_system::offchain::SigningTypes for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
375
376
377
378
	type Public = <Signature as Verify>::Signer;
	type Signature = Signature;
}

379
380
381
382
/// 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()) }
Fedor Sakharov's avatar
Fedor Sakharov committed
383
384
}

385
386
387
impl pallet_session::historical::Config for Runtime {
	type FullIdentification = ();
	type FullIdentificationOf = FullIdentificationOf;
Fedor Sakharov's avatar
Fedor Sakharov committed
388
389
390
}

parameter_types! {
391
	pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _;
Fedor Sakharov's avatar
Fedor Sakharov committed
392
393
394
395
396
397
}

parameter_types! {
	pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
}

398
impl pallet_im_online::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
399
400
	type AuthorityId = ImOnlineId;
	type Event = Event;
401
	type ValidatorSet = Historical;
402
	type NextSessionRotation = Babe;
Fedor Sakharov's avatar
Fedor Sakharov committed
403
	type ReportUnresponsiveness = Offences;
404
	type UnsignedPriority = ImOnlineUnsignedPriority;
Fedor Sakharov's avatar
Fedor Sakharov committed
405
406
407
408
409
	type WeightInfo = ();
}

parameter_types! {
	pub const ExistentialDeposit: Balance = 1 * CENTS;
410
	pub const MaxLocks: u32 = 50;
Gavin Wood's avatar
Gavin Wood committed
411
	pub const MaxReserves: u32 = 50;
Fedor Sakharov's avatar
Fedor Sakharov committed
412
413
}

414
impl pallet_balances::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
415
416
417
418
419
	type Balance = Balance;
	type DustRemoval = ();
	type Event = Event;
	type ExistentialDeposit = ExistentialDeposit;
	type AccountStore = System;
420
	type MaxLocks = MaxLocks;
Gavin Wood's avatar
Gavin Wood committed
421
422
	type MaxReserves = MaxReserves;
	type ReserveIdentifier = [u8; 8];
Fedor Sakharov's avatar
Fedor Sakharov committed
423
424
425
	type WeightInfo = ();
}

426
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
Fedor Sakharov's avatar
Fedor Sakharov committed
427
428
429
430
431
432
433
434
435
436
437
	Call: From<C>,
{
	type OverarchingCall = Call;
	type Extrinsic = UncheckedExtrinsic;
}

parameter_types! {
	pub const QueueSize: usize = 2;
	pub const MaxRetries: u32 = 3;
}

438
impl pallet_offences::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
439
	type Event = Event;
440
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
441
	type OnOffenceHandler = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
442
443
}

444
impl pallet_authority_discovery::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
445
446
447
448

parameter_types! {
	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
449
impl pallet_timestamp::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
450
451
452
453
454
455
456
457
458
459
	type Moment = u64;
	type OnTimestampSet = Babe;
	type MinimumPeriod = MinimumPeriod;
	type WeightInfo = ();
}

parameter_types! {
	pub const TransactionByteFee: Balance = 10 * MILLICENTS;
}

460
impl pallet_transaction_payment::Config for Runtime {
Albrecht's avatar
Albrecht committed
461
	type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;
Fedor Sakharov's avatar
Fedor Sakharov committed
462
463
464
465
466
467
468
469
470
	type TransactionByteFee = TransactionByteFee;
	type WeightToFee = WeightToFee;
	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
}

parameter_types! {
	pub const DisabledValidatorsThreshold: Perbill = Perbill::from_percent(17);
}

471
472
473
474
475
476
/// 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) }
}

477
impl pallet_session::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
478
479
	type Event = Event;
	type ValidatorId = AccountId;
480
	type ValidatorIdOf = ValidatorIdOf;
Fedor Sakharov's avatar
Fedor Sakharov committed
481
482
	type ShouldEndSession = Babe;
	type NextSessionRotation = Babe;
483
	type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ValidatorManager>;
Fedor Sakharov's avatar
Fedor Sakharov committed
484
485
486
487
488
489
490
491
	type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
	type Keys = SessionKeys;
	type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
	type WeightInfo = ();
}

parameter_types! {
	pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
492
	pub ReportLongevity: u64 = EpochDurationInBlocks::get() as u64 * 10;
Fedor Sakharov's avatar
Fedor Sakharov committed
493
494
}

495
impl pallet_babe::Config for Runtime {
496
	type EpochDuration = EpochDurationInBlocks;
Fedor Sakharov's avatar
Fedor Sakharov committed
497
498
499
	type ExpectedBlockTime = ExpectedBlockTime;

	// session module is the trigger
500
	type EpochChangeTrigger = pallet_babe::ExternalTrigger;
Fedor Sakharov's avatar
Fedor Sakharov committed
501
502
503
504
505

	type KeyOwnerProofSystem = Historical;

	type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
506
		pallet_babe::AuthorityId,
Fedor Sakharov's avatar
Fedor Sakharov committed
507
508
509
510
	)>>::Proof;

	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
511
		pallet_babe::AuthorityId,
Fedor Sakharov's avatar
Fedor Sakharov committed
512
513
514
	)>>::IdentificationTuple;

	type HandleEquivocation =
515
		pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
516
517

	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
518
519
520
521
522
523
}

parameter_types! {
	pub const IndexDeposit: Balance = 1 * DOLLARS;
}

524
impl pallet_indices::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
525
526
527
528
529
530
531
532
533
534
535
	type AccountIndex = AccountIndex;
	type Currency = Balances;
	type Deposit = IndexDeposit;
	type Event = Event;
	type WeightInfo = ();
}

parameter_types! {
	pub const AttestationPeriod: BlockNumber = 50;
}

536
impl pallet_grandpa::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
537
538
539
540
541
542
543
544
545
546
547
548
549
	type Event = Event;
	type Call = Call;

	type KeyOwnerProofSystem = Historical;

	type KeyOwnerProof =
		<Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;

	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
		GrandpaId,
	)>>::IdentificationTuple;

550
551
	type HandleEquivocation =
		pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
552
553

	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
554
555
556
557
558
559
}

parameter_types! {
	pub const UncleGenerations: u32 = 0;
}

560
impl pallet_authorship::Config for Runtime {
561
	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
Fedor Sakharov's avatar
Fedor Sakharov committed
562
563
	type UncleGenerations = UncleGenerations;
	type FilterUncle = ();
564
	type EventHandler = ImOnline;
Fedor Sakharov's avatar
Fedor Sakharov committed
565
566
}

567
impl parachains_origin::Config for Runtime {}
568

569
impl parachains_configuration::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
570

571
572
impl parachains_shared::Config for Runtime {}

573
574
575
576
577
578
579
/// 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>) {}
}

580
impl parachains_inclusion::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
581
	type Event = Event;
582
	type RewardValidators = RewardValidators;
Fedor Sakharov's avatar
Fedor Sakharov committed
583
584
}

585
impl parachains_paras::Config for Runtime {
586
	type Origin = Origin;
587
	type Event = Event;
588
}
Fedor Sakharov's avatar
Fedor Sakharov committed
589

Shawn Tabrizi's avatar
Shawn Tabrizi committed
590
591
592
593
parameter_types! {
	pub const RocLocation: MultiLocation = MultiLocation::Null;
	pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
	pub const Ancestry: MultiLocation = MultiLocation::Null;
594
	pub CheckAccount: AccountId = XcmPallet::check_account();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
595
596
}

597
pub type SovereignAccountOf = (
Shawn Tabrizi's avatar
Shawn Tabrizi committed
598
599
600
601
602
603
604
605
606
607
608
	ChildParachainConvertsVia<ParaId, AccountId>,
	AccountId32Aliases<RococoNetwork, AccountId>,
);

pub type LocalAssetTransactor =
	XcmCurrencyAdapter<
		// Use this currency:
		Balances,
		// Use this currency when it is a fungible asset matching the given location or name:
		IsConcrete<RocLocation>,
		// We can convert the MultiLocations with our converter above:
609
		SovereignAccountOf,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
610
611
		// Our chain's account ID type (we can't get away without mentioning it explicitly):
		AccountId,
612
613
		// It's a native asset so we keep track of the teleports to maintain total issuance.
		CheckAccount,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
614
615
616
	>;

type LocalOriginConverter = (
617
	SovereignSignedViaLocation<SovereignAccountOf, Origin>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
618
619
620
621
622
	ChildParachainAsNative<parachains_origin::Origin, Origin>,
	SignedAccountId32AsNative<RococoNetwork, Origin>,
	ChildSystemParachainAsSuperuser<ParaId, Origin>,
);

Gavin Wood's avatar
Gavin Wood committed
623
624
625
626
parameter_types! {
	pub const BaseXcmWeight: Weight = 100_000;
}

Gavin Wood's avatar
Gavin Wood committed
627
628
629
630
631
632
633
/// The XCM router. When we want to send an XCM message, we use this type. It amalgamates all of our
/// individual routers.
pub type XcmRouter = (
	// Only one router so far - use DMP to communicate with child parachains.
	xcm_sender::ChildParachainRouter<Runtime>,
);

634
635
use xcm::v0::{MultiAsset, MultiAsset::AllConcreteFungible, MultiLocation::{Null, X1}, Junction::Parachain};
parameter_types! {
Ricardo Rius's avatar
Ricardo Rius committed
636
	pub const RococoForTick: (MultiAsset, MultiLocation) =
637
		(AllConcreteFungible { id: Null }, X1(Parachain(100)));
Ricardo Rius's avatar
Ricardo Rius committed
638
	pub const RococoForTrick: (MultiAsset, MultiLocation) =
639
		(AllConcreteFungible { id: Null }, X1(Parachain(110)));
Ricardo Rius's avatar
Ricardo Rius committed
640
	pub const RococoForTrack: (MultiAsset, MultiLocation) =
641
		(AllConcreteFungible { id: Null }, X1(Parachain(120)));
Ricardo Rius's avatar
Ricardo Rius committed
642
	pub const RococoForStatemint: (MultiAsset, MultiLocation) =
643
		(AllConcreteFungible { id: Null }, X1(Parachain(1001)));
644
645
646
647
648
}
pub type TrustedTeleporters = (
	xcm_builder::Case<RococoForTick>,
	xcm_builder::Case<RococoForTrick>,
	xcm_builder::Case<RococoForTrack>,
Ricardo Rius's avatar
Ricardo Rius committed
649
	xcm_builder::Case<RococoForStatemint>,
650
651
652
);

parameter_types! {
653
	pub AllowUnpaidFrom: Vec<MultiLocation> =
Ricardo Rius's avatar
Ricardo Rius committed
654
		vec![
655
656
657
			X1(Parachain(100)),
			X1(Parachain(110)),
			X1(Parachain(120)),
658
			X1(Parachain(1001))
Ricardo Rius's avatar
Ricardo Rius committed
659
		];
660
661
662
663
664
665
666
667
668
}

use xcm_builder::{TakeWeightCredit, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom};
pub type Barrier = (
	TakeWeightCredit,
	AllowTopLevelPaidExecutionFrom<All<MultiLocation>>,
	AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>,	// <- Trusted parachains get free execution
);

Shawn Tabrizi's avatar
Shawn Tabrizi committed
669
670
671
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
	type Call = Call;
Gavin Wood's avatar
Gavin Wood committed
672
	type XcmSender = XcmRouter;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
673
674
675
	type AssetTransactor = LocalAssetTransactor;
	type OriginConverter = LocalOriginConverter;
	type IsReserve = ();
676
	type IsTeleporter = TrustedTeleporters;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
677
	type LocationInverter = LocationInverter<Ancestry>;
678
	type Barrier = Barrier;
Gavin Wood's avatar
Gavin Wood committed
679
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
680
	type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
Gavin Wood's avatar
Gavin Wood committed
681
	type ResponseHandler = ();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
682
683
}

684
685
686
687
parameter_types! {
	pub const CollectiveBodyId: BodyId = BodyId::Unit;
}

Gavin Wood's avatar
Gavin Wood committed
688
689
690
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
691
692
	// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
	// `Unit` body.
693
694
695
	BackingToPlurality<Origin, pallet_collective::Origin<Runtime>, CollectiveBodyId>,
	// And a usual Signed origin to be used in XCM as a corresponding AccountId32
	SignedToAccountId32<Origin, AccountId, RococoNetwork>,
Gavin Wood's avatar
Gavin Wood committed
696
697
);

698
699
700
701
702
pub struct OnlyWithdrawTeleportForAccounts;
impl frame_support::traits::Contains<(MultiLocation, Xcm<Call>)> for OnlyWithdrawTeleportForAccounts {
	fn contains((ref origin, ref msg): &(MultiLocation, Xcm<Call>)) -> bool {
		use xcm::v0::{
			Xcm::WithdrawAsset, Order::{BuyExecution, InitiateTeleport, DepositAsset},
703
			MultiAsset::{All, ConcreteFungible}, Junction::{AccountId32, Plurality},
704
705
		};
		match origin {
706
707
			// Root and collective are allowed to execute anything.
			Null | X1(Plurality { .. }) => true,
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
			X1(AccountId32 { .. }) => {
				// An account ID trying to send a message. We ensure that it's sensible.
				// This checks that it's of the form:
				// WithdrawAsset {
				//   assets: [ ConcreteFungible { id: Null } ],
				//   effects: [ BuyExecution, InitiateTeleport {
				//     assets: All,
				//     dest: Parachain,
				//     effects: [ BuyExecution, DepositAssets {
				//       assets: All,
				//       dest: AccountId32,
				//     } ]
				//   } ]
				// }
				matches!(msg, WithdrawAsset { ref assets, ref effects }
					if assets.len() == 1
					&& matches!(assets[0], ConcreteFungible { id: Null, .. })
					&& effects.len() == 2
					&& matches!(effects[0], BuyExecution { .. })
					&& matches!(effects[1], InitiateTeleport { ref assets, dest: X1(Parachain(..)), ref effects }
						if assets.len() == 1
						&& matches!(assets[0], All)
						&& effects.len() == 2
						&& matches!(effects[0], BuyExecution { .. })
						&& matches!(effects[1], DepositAsset { ref assets, dest: X1(AccountId32{..}) }
							if assets.len() == 1
							&& matches!(assets[0], All)
						)
					)
				)
			}
			// Nobody else is allowed to execute anything.
			_ => false,
		}
	}
}

Gavin Wood's avatar
Gavin Wood committed
745
746
747
748
impl pallet_xcm::Config for Runtime {
	type Event = Event;
	type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
	type XcmRouter = XcmRouter;
749
750
751
752
	// Anyone can execute XCM messages locally...
	type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
	// ...but they must match our filter, which requires them to be a simple withdraw + teleport.
	type XcmExecuteFilter = OnlyWithdrawTeleportForAccounts;
Gavin Wood's avatar
Gavin Wood committed
753
	type XcmExecutor = XcmExecutor<XcmConfig>;
754
	type XcmTeleportFilter = All<(MultiLocation, Vec<MultiAsset>)>;
755
	type XcmReserveTransferFilter = All<(MultiLocation, Vec<MultiAsset>)>;
756
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
Gavin Wood's avatar
Gavin Wood committed
757
758
}

759
impl parachains_session_info::Config for Runtime {}
760

Gavin Wood's avatar
Gavin Wood committed
761
762
763
764
parameter_types! {
	pub const FirstMessageFactorPercent: u64 = 100;
}

765
impl parachains_ump::Config for Runtime {
766
767
	type Event = Event;
	type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
Gavin Wood's avatar
Gavin Wood committed
768
	type FirstMessageFactorPercent = FirstMessageFactorPercent;
769
}
770

771
impl parachains_dmp::Config for Runtime {}
772

773
impl parachains_hrmp::Config for Runtime {
774
	type Event = Event;
775
	type Origin = Origin;
776
	type Currency = Balances;
777
778
}

779
impl parachains_paras_inherent::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
780

781
impl parachains_scheduler::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
782

783
impl parachains_initializer::Config for Runtime {
784
	type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
785
	type ForceOrigin = EnsureRoot<AccountId>;
Fedor Sakharov's avatar
Fedor Sakharov committed
786
}
787

788
impl paras_sudo_wrapper::Config for Runtime {}
789

790
791
792
793
794
parameter_types! {
	pub const ParaDeposit: Balance = 5 * DOLLARS;
	pub const DataDepositPerByte: Balance = deposit(0, 1);
}

795
impl paras_registrar::Config for Runtime {
796
	type Event = Event;
797
	type Origin = Origin;
798
	type Currency = Balances;
799
	type OnSwap = (Crowdloan, Slots);
800
801
802
	type ParaDeposit = ParaDeposit;
	type DataDepositPerByte = DataDepositPerByte;
	type WeightInfo = paras_registrar::TestWeightInfo;
803
}
804

805
806
807
808
/// An insecure randomness beacon that uses the parent block hash as random material.
///
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub struct ParentHashRandomness;
809

810
impl pallet_beefy::Config for Runtime {
Andreas Doerr's avatar
Andreas Doerr committed
811
	type BeefyId = BeefyId;
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
}

impl pallet_mmr::Config for Runtime {
	const INDEXING_PREFIX: &'static [u8] = b"mmr";
	type Hashing = Keccak256;
	type Hash = <Keccak256 as traits::Hash>::Output;
	type OnNewRoot = mmr_common::DepositBeefyDigest<Runtime>;
	type WeightInfo = ();
	type LeafData = mmr_common::Pallet<Runtime>;
}

impl mmr_common::Config for Runtime {
	type BeefyAuthorityToMerkleLeaf = mmr_common::UncompressBeefyEcdsaKeys;
	type ParachainHeads = Paras;
}

828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
parameter_types! {
	// This is a pretty unscientific cap.
	//
	// Note that once this is hit the pallet will essentially throttle incoming requests down to one
	// call per block.
	pub const MaxRequests: u32 = 4 * HOURS as u32;

	// Number of headers to keep.
	//
	// Assuming the worst case of every header being finalized, we will keep headers at least for a
	// week.
	pub const HeadersToKeep: u32 = 7 * DAYS as u32;
}

pub type RococoGrandpaInstance = ();
impl pallet_bridge_grandpa::Config for Runtime {
	type BridgedChain = bp_rococo::Rococo;
	type MaxRequests = MaxRequests;
	type HeadersToKeep = HeadersToKeep;

	type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
}

pub type WococoGrandpaInstance = pallet_bridge_grandpa::Instance1;
impl pallet_bridge_grandpa::Config<WococoGrandpaInstance> for Runtime {
	type BridgedChain = bp_wococo::Wococo;
	type MaxRequests = MaxRequests;
	type HeadersToKeep = HeadersToKeep;

	type WeightInfo = pallet_bridge_grandpa::weights::RialtoWeight<Runtime>;
}

860
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
861
	fn random(subject: &[u8]) -> (Hash, BlockNumber) {
862
863
864
865
		(
			(System::parent_hash(), subject).using_encoded(sp_io::hashing::blake2_256).into(),
			System::block_number(),
		)
866
867
868
	}
}

869
parameter_types! {
870
	pub const EndingPeriod: BlockNumber = 1 * HOURS;
871
872
873
	pub const SampleLength: BlockNumber = 1;
}

874
875
876
impl auctions::Config for Runtime {
	type Event = Event;
	type Leaser = Slots;
877
	type Registrar = Registrar;
878
	type EndingPeriod = EndingPeriod;
879
	type SampleLength = SampleLength;
880
	type Randomness = ParentHashRandomness;
881
882
883
	type InitiateOrigin = EnsureRoot<AccountId>;
	type WeightInfo = auctions::TestWeightInfo;
}
884

885
886
887
parameter_types! {
	pub const LeasePeriod: BlockNumber = 1 * DAYS;
}
888

889
890
891
892
893
894
895
impl slots::Config for Runtime {
	type Event = Event;
	type Currency = Balances;
	type Registrar = Registrar;
	type LeasePeriod = LeasePeriod;
	type WeightInfo = slots::TestWeightInfo;
}
896

897
parameter_types! {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
898
	pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
899
900
901
	pub const SubmissionDeposit: Balance = 100 * DOLLARS;
	pub const MinContribution: Balance = 1 * DOLLARS;
	pub const RemoveKeysLimit: u32 = 500;
902
903
	// Allow 32 bytes for an additional memo to a crowdloan.
	pub const MaxMemoLength: u8 = 32;
904
}
905

906
907
impl crowdloan::Config for Runtime {
	type Event = Event;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
908
	type PalletId = CrowdloanId;
909
910
911
912
913
	type SubmissionDeposit = SubmissionDeposit;
	type MinContribution = MinContribution;
	type RemoveKeysLimit = RemoveKeysLimit;
	type Registrar = Registrar;
	type Auctioneer = Auctions;
914
	type MaxMemoLength = MaxMemoLength;
915
	type WeightInfo = crowdloan::TestWeightInfo;
916
917
}

918
919
920
impl pallet_sudo::Config for Runtime {
	type Event = Event;
	type Call = Call;
921
922
}

923
impl validator_manager::Config for Runtime {
924
	type Event = Event;
925
	type PrivilegedOrigin = EnsureRoot<AccountId>;
926
927
}

928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
impl pallet_utility::Config for Runtime {
	type Event = Event;
	type Call = Call;
	type WeightInfo = ();
}

parameter_types! {
	// One storage item; key size 32, value size 8; .
	pub const ProxyDepositBase: Balance = 10;
	// Additional storage item size of 33 bytes.
	pub const ProxyDepositFactor: Balance = 10;
	pub const MaxProxies: u16 = 32;
	pub const AnnouncementDepositBase: Balance = 10;
	pub const AnnouncementDepositFactor: Balance = 10;
	pub const MaxPending: u16 = 32;
}

/// The type used to represent the kinds of proxying allowed.
946
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen)]
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
pub enum ProxyType {
	Any,
	CancelProxy,
}
impl Default for ProxyType { fn default() -> Self { Self::Any } }
impl InstanceFilter<Call> for ProxyType {
	fn filter(&self, c: &Call) -> bool {
		match self {
			ProxyType::Any => true,
			ProxyType::CancelProxy => matches!(c,
				Call::Proxy(pallet_proxy::Call::reject_announcement(..))
			)
		}
	}
	fn is_superset(&self, o: &Self) -> bool {
		match (self, o) {
			(ProxyType::Any, _) => true,
			_ => false,
		}
	}
}

impl pallet_proxy::Config for Runtime {
	type Event = Event;
	type Call = Call;
	type Currency = Balances;
	type ProxyType = ProxyType;
	type ProxyDepositBase = ProxyDepositBase;
	type ProxyDepositFactor = ProxyDepositFactor;
	type MaxProxies = MaxProxies;
	type WeightInfo = ();
	type MaxPending = MaxPending;
	type CallHasher = BlakeTwo256;
	type AnnouncementDepositBase = AnnouncementDepositBase;
	type AnnouncementDepositFactor = AnnouncementDepositFactor;
}

984
985
986
987
988
989
990
991
992
993
994
995
996
parameter_types! {
	pub const MotionDuration: BlockNumber = 5;
	pub const MaxProposals: u32 = 100;
	pub const MaxMembers: u32 = 100;
}

impl pallet_collective::Config for Runtime {
	type Origin = Origin;
	type Proposal = Call;
	type Event = Event;
	type MotionDuration = MotionDuration;
	type MaxProposals = MaxProposals;
	type DefaultVote = pallet_collective::PrimeDefaultVote;
997
	type MaxMembers = MaxMembers;
998
999
1000
	type WeightInfo = ();
}

For faster browsing, not all history is shown. View entire blame