lib.rs 50 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

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

use runtime_parachains::{
	configuration as parachains_configuration, dmp as parachains_dmp, hrmp as parachains_hrmp,
	inclusion as parachains_inclusion, initializer as parachains_initializer,
	origin as parachains_origin, paras as parachains_paras,
	paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
	session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};

use bridge_runtime_common::messages::{
	source::estimate_message_dispatch_and_delivery_fee, MessageBridge,
};
76

77
pub use pallet_balances::Call as BalancesCall;
Fedor Sakharov's avatar
Fedor Sakharov committed
78

Shawn Tabrizi's avatar
Shawn Tabrizi committed
79
use polkadot_parachain::primitives::Id as ParaId;
80

Shawn Tabrizi's avatar
Shawn Tabrizi committed
81
82
use constants::{currency::*, fee::*, time::*};
use frame_support::traits::InstanceFilter;
Gavin Wood's avatar
Gavin Wood committed
83
use xcm::latest::prelude::*;
84
use xcm_builder::{
Shawn Tabrizi's avatar
Shawn Tabrizi committed
85
86
87
88
	AccountId32Aliases, BackingToPlurality, ChildParachainAsNative, ChildParachainConvertsVia,
	ChildSystemParachainAsSuperuser, CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds,
	IsConcrete, LocationInverter, SignedAccountId32AsNative, SignedToAccountId32,
	SovereignSignedViaLocation, UsingComponents,
89
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
90
use xcm_executor::XcmExecutor;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
91

Shawn Tabrizi's avatar
Shawn Tabrizi committed
92
mod bridge_messages;
Fedor Sakharov's avatar
Fedor Sakharov committed
93
94
/// Constant values used within the runtime.
pub mod constants;
95
mod validator_manager;
Fedor Sakharov's avatar
Fedor Sakharov committed
96
97
98
99
100

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

101
102
103
/// Runtime version (Rococo).
pub const VERSION: RuntimeVersion = RuntimeVersion {
	spec_name: create_runtime_str!("rococo"),
Bastian Köcher's avatar
Bastian Köcher committed
104
	impl_name: create_runtime_str!("parity-rococo-v1.6"),
105
	authoring_version: 0,
106
	spec_version: 9004,
107
108
109
110
111
112
113
114
	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,
};

115
116
117
118
/// The BABE epoch configuration at genesis.
pub const BABE_GENESIS_EPOCH_CONFIG: babe_primitives::BabeEpochConfiguration =
	babe_primitives::BabeEpochConfiguration {
		c: PRIMARY_PROBABILITY,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
119
		allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
120
121
	};

122
123
124
/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
125
	NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
126
127
}

Fedor Sakharov's avatar
Fedor Sakharov committed
128
/// The address format for describing accounts.
129
pub type Address = sp_runtime::MultiAddress<AccountId, ()>;
Fedor Sakharov's avatar
Fedor Sakharov committed
130
131
132
133
134
135
/// 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>;
Denis_P's avatar
Denis_P committed
136
/// `BlockId` type as expected by this runtime.
Fedor Sakharov's avatar
Fedor Sakharov committed
137
pub type BlockId = generic::BlockId<Block>;
Denis_P's avatar
Denis_P committed
138
/// The `SignedExtension` to the basic transaction logic.
Fedor Sakharov's avatar
Fedor Sakharov committed
139
pub type SignedExtra = (
140
141
142
143
144
145
146
	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
147
148
);

149
150
151
152
153
/// Migrate from `PalletVersion` to the new `StorageVersion`
pub struct MigratePalletVersionToStorageVersion;

impl OnRuntimeUpgrade for MigratePalletVersionToStorageVersion {
	fn on_runtime_upgrade() -> frame_support::weights::Weight {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
154
155
156
		frame_support::migrations::migrate_from_pallet_version_to_storage_version::<
			AllPalletsWithSystem,
		>(&RocksDbWeight::get())
157
158
159
	}
}

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

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

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

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

197
198
199
200
		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
201
202

		// Consensus support.
203
		Authorship: pallet_authorship::{Pallet, Call, Storage},
Keith Yeung's avatar
Keith Yeung committed
204
		Offences: pallet_offences::{Pallet, Storage, Event},
205
206
207
208
		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
209
		AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
Fedor Sakharov's avatar
Fedor Sakharov committed
210
211

		// Parachains modules.
212
		ParachainsOrigin: parachains_origin::{Pallet, Origin},
213
		Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
214
		ParasShared: parachains_shared::{Pallet, Call, Storage},
215
		ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
216
		ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent},
217
		ParaScheduler: parachains_scheduler::{Pallet, Storage},
ferrell-code's avatar
ferrell-code committed
218
		Paras: parachains_paras::{Pallet, Call, Storage, Event, Config},
219
220
		Initializer: parachains_initializer::{Pallet, Call, Storage},
		Dmp: parachains_dmp::{Pallet, Call, Storage},
221
		Ump: parachains_ump::{Pallet, Call, Storage, Event},
222
		Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event<T>, Config},
223
		ParaSessionInfo: parachains_session_info::{Pallet, Storage},
224

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

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

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

240
241
242
243
244
245
		// 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,

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

249
250
251
252
253
254
255
		// Bridge messages support. The same story as with the bridge grandpa pallet above ^^^ - when we're
		// running as Rococo we only use `BridgeWococoMessages`/`BridgeWococoMessagesDispatch`, and vice versa.
		BridgeRococoMessages: pallet_bridge_messages::{Pallet, Call, Storage, Event<T>, Config<T>} = 43,
		BridgeWococoMessages: pallet_bridge_messages::<Instance1>::{Pallet, Call, Storage, Event<T>, Config<T>} = 44,
		BridgeRococoMessagesDispatch: pallet_bridge_dispatch::{Pallet, Event<T>} = 45,
		BridgeWococoMessagesDispatch: pallet_bridge_dispatch::<Instance1>::{Pallet, Event<T>} = 46,

256
257
258
259
		// 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,

260
261
		Utility: pallet_utility::{Pallet, Call, Event} = 90,
		Proxy: pallet_proxy::{Pallet, Call, Storage, Event<T>} = 91,
Gavin Wood's avatar
Gavin Wood committed
262
263

		// Pallet for sending XCM.
Shawn Tabrizi's avatar
Shawn Tabrizi committed
264
		XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin} = 99,
265
266
267
	}
}

268
pub struct BaseFilter;
269
270
impl Contains<Call> for BaseFilter {
	fn contains(_call: &Call) -> bool {
271
272
273
		true
	}
}
274

Fedor Sakharov's avatar
Fedor Sakharov committed
275
276
parameter_types! {
	pub const Version: RuntimeVersion = VERSION;
277
	pub const SS58Prefix: u8 = 42;
Fedor Sakharov's avatar
Fedor Sakharov committed
278
279
}

280
impl frame_system::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
281
	type BaseCallFilter = BaseFilter;
282
283
284
	type BlockWeights = BlockWeights;
	type BlockLength = BlockLength;
	type DbWeight = RocksDbWeight;
Fedor Sakharov's avatar
Fedor Sakharov committed
285
286
287
288
289
290
291
	type Origin = Origin;
	type Call = Call;
	type Index = Nonce;
	type BlockNumber = BlockNumber;
	type Hash = Hash;
	type Hashing = BlakeTwo256;
	type AccountId = AccountId;
292
	type Lookup = AccountIdLookup<AccountId, ()>;
Fedor Sakharov's avatar
Fedor Sakharov committed
293
294
295
296
	type Header = generic::Header<BlockNumber, BlakeTwo256>;
	type Event = Event;
	type BlockHashCount = BlockHashCount;
	type Version = Version;
297
	type PalletInfo = PalletInfo;
298
	type AccountData = pallet_balances::AccountData<Balance>;
Fedor Sakharov's avatar
Fedor Sakharov committed
299
300
301
	type OnNewAccount = ();
	type OnKilledAccount = ();
	type SystemWeightInfo = ();
302
	type SS58Prefix = SS58Prefix;
303
	type OnSetCode = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
304
305
306
307
308
309
310
311
312
313
}

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.
Shawn Tabrizi's avatar
Shawn Tabrizi committed
314
315
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime
where
Fedor Sakharov's avatar
Fedor Sakharov committed
316
317
	Call: From<LocalCall>,
{
318
	fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
Fedor Sakharov's avatar
Fedor Sakharov committed
319
320
321
		call: Call,
		public: <Signature as Verify>::Signer,
		account: AccountId,
322
		nonce: <Runtime as frame_system::Config>::Index,
Fedor Sakharov's avatar
Fedor Sakharov committed
323
	) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
324
		use sp_runtime::traits::StaticLookup;
Fedor Sakharov's avatar
Fedor Sakharov committed
325
		// take the biggest period possible.
Shawn Tabrizi's avatar
Shawn Tabrizi committed
326
327
		let period =
			BlockHashCount::get().checked_next_power_of_two().map(|c| c / 2).unwrap_or(2) as u64;
Fedor Sakharov's avatar
Fedor Sakharov committed
328
329
330
331
332
333
334
335

		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 = (
336
337
338
			frame_system::CheckSpecVersion::<Runtime>::new(),
			frame_system::CheckTxVersion::<Runtime>::new(),
			frame_system::CheckGenesis::<Runtime>::new(),
Shawn Tabrizi's avatar
Shawn Tabrizi committed
339
340
341
342
			frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
				period,
				current_block,
			)),
343
344
345
			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
346
		);
Shawn Tabrizi's avatar
Shawn Tabrizi committed
347
348
349
350
351
352
		let raw_payload = SignedPayload::new(call, extra)
			.map_err(|e| {
				log::warn!("Unable to create signed payload: {:?}", e);
			})
			.ok()?;
		let signature = raw_payload.using_encoded(|payload| C::sign(payload, public))?;
Fedor Sakharov's avatar
Fedor Sakharov committed
353
		let (call, extra, _) = raw_payload.deconstruct();
354
355
		let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
		Some((call, (address, signature, extra)))
Fedor Sakharov's avatar
Fedor Sakharov committed
356
357
358
	}
}

359
impl frame_system::offchain::SigningTypes for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
360
361
362
363
	type Public = <Signature as Verify>::Signer;
	type Signature = Signature;
}

364
365
366
/// Special `FullIdentificationOf` implementation that is returning for every input `Some(Default::default())`.
pub struct FullIdentificationOf;
impl sp_runtime::traits::Convert<AccountId, Option<()>> for FullIdentificationOf {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
367
368
369
	fn convert(_: AccountId) -> Option<()> {
		Some(Default::default())
	}
Fedor Sakharov's avatar
Fedor Sakharov committed
370
371
}

372
373
374
impl pallet_session::historical::Config for Runtime {
	type FullIdentification = ();
	type FullIdentificationOf = FullIdentificationOf;
Fedor Sakharov's avatar
Fedor Sakharov committed
375
376
377
}

parameter_types! {
378
	pub SessionDuration: BlockNumber = EpochDurationInBlocks::get() as _;
Fedor Sakharov's avatar
Fedor Sakharov committed
379
380
381
382
383
384
}

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

385
impl pallet_im_online::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
386
387
	type AuthorityId = ImOnlineId;
	type Event = Event;
388
	type ValidatorSet = Historical;
389
	type NextSessionRotation = Babe;
Fedor Sakharov's avatar
Fedor Sakharov committed
390
	type ReportUnresponsiveness = Offences;
391
	type UnsignedPriority = ImOnlineUnsignedPriority;
Fedor Sakharov's avatar
Fedor Sakharov committed
392
393
394
395
396
	type WeightInfo = ();
}

parameter_types! {
	pub const ExistentialDeposit: Balance = 1 * CENTS;
397
	pub const MaxLocks: u32 = 50;
Gavin Wood's avatar
Gavin Wood committed
398
	pub const MaxReserves: u32 = 50;
Fedor Sakharov's avatar
Fedor Sakharov committed
399
400
}

401
impl pallet_balances::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
402
403
404
405
406
	type Balance = Balance;
	type DustRemoval = ();
	type Event = Event;
	type ExistentialDeposit = ExistentialDeposit;
	type AccountStore = System;
407
	type MaxLocks = MaxLocks;
Gavin Wood's avatar
Gavin Wood committed
408
409
	type MaxReserves = MaxReserves;
	type ReserveIdentifier = [u8; 8];
Fedor Sakharov's avatar
Fedor Sakharov committed
410
411
412
	type WeightInfo = ();
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
413
414
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
Fedor Sakharov's avatar
Fedor Sakharov committed
415
416
417
418
419
420
421
422
423
424
	Call: From<C>,
{
	type OverarchingCall = Call;
	type Extrinsic = UncheckedExtrinsic;
}

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

425
impl pallet_offences::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
426
	type Event = Event;
427
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
428
	type OnOffenceHandler = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
429
430
}

431
impl pallet_authority_discovery::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
432
433
434
435

parameter_types! {
	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
436
impl pallet_timestamp::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
437
438
439
440
441
442
443
444
445
446
	type Moment = u64;
	type OnTimestampSet = Babe;
	type MinimumPeriod = MinimumPeriod;
	type WeightInfo = ();
}

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

447
impl pallet_transaction_payment::Config for Runtime {
Albrecht's avatar
Albrecht committed
448
	type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;
Fedor Sakharov's avatar
Fedor Sakharov committed
449
450
451
452
453
454
455
456
457
	type TransactionByteFee = TransactionByteFee;
	type WeightToFee = WeightToFee;
	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
}

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

458
459
460
/// Special `ValidatorIdOf` implementation that is just returning the input as result.
pub struct ValidatorIdOf;
impl sp_runtime::traits::Convert<AccountId, Option<AccountId>> for ValidatorIdOf {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
461
462
463
	fn convert(a: AccountId) -> Option<AccountId> {
		Some(a)
	}
464
465
}

466
impl pallet_session::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
467
468
	type Event = Event;
	type ValidatorId = AccountId;
469
	type ValidatorIdOf = ValidatorIdOf;
Fedor Sakharov's avatar
Fedor Sakharov committed
470
471
	type ShouldEndSession = Babe;
	type NextSessionRotation = Babe;
472
	type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, ValidatorManager>;
Fedor Sakharov's avatar
Fedor Sakharov committed
473
474
475
476
477
478
479
480
	type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
	type Keys = SessionKeys;
	type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
	type WeightInfo = ();
}

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

484
impl pallet_babe::Config for Runtime {
485
	type EpochDuration = EpochDurationInBlocks;
Fedor Sakharov's avatar
Fedor Sakharov committed
486
487
488
	type ExpectedBlockTime = ExpectedBlockTime;

	// session module is the trigger
489
	type EpochChangeTrigger = pallet_babe::ExternalTrigger;
Fedor Sakharov's avatar
Fedor Sakharov committed
490

491
492
	type DisabledValidators = Session;

Fedor Sakharov's avatar
Fedor Sakharov committed
493
494
495
496
	type KeyOwnerProofSystem = Historical;

	type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
497
		pallet_babe::AuthorityId,
Fedor Sakharov's avatar
Fedor Sakharov committed
498
499
500
501
	)>>::Proof;

	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
502
		pallet_babe::AuthorityId,
Fedor Sakharov's avatar
Fedor Sakharov committed
503
504
505
	)>>::IdentificationTuple;

	type HandleEquivocation =
506
		pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
507
508

	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
509
510
511
512
513
514
}

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

515
impl pallet_indices::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
516
517
518
519
520
521
522
523
524
525
526
	type AccountIndex = AccountIndex;
	type Currency = Balances;
	type Deposit = IndexDeposit;
	type Event = Event;
	type WeightInfo = ();
}

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

527
impl pallet_grandpa::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
528
529
530
531
532
533
534
535
536
537
538
539
540
	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;

Shawn Tabrizi's avatar
Shawn Tabrizi committed
541
542
543
544
545
	type HandleEquivocation = pallet_grandpa::EquivocationHandler<
		Self::KeyOwnerIdentification,
		Offences,
		ReportLongevity,
	>;
546
547

	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
548
549
550
551
552
553
}

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

554
impl pallet_authorship::Config for Runtime {
555
	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
Fedor Sakharov's avatar
Fedor Sakharov committed
556
557
	type UncleGenerations = UncleGenerations;
	type FilterUncle = ();
558
	type EventHandler = ImOnline;
Fedor Sakharov's avatar
Fedor Sakharov committed
559
560
}

561
impl parachains_origin::Config for Runtime {}
562

563
impl parachains_configuration::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
564

565
566
impl parachains_shared::Config for Runtime {}

567
568
569
/// Special `RewardValidators` that does nothing ;)
pub struct RewardValidators;
impl runtime_parachains::inclusion::RewardValidators for RewardValidators {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
570
571
	fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
	fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
572
573
}

574
impl parachains_inclusion::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
575
	type Event = Event;
asynchronous rob's avatar
asynchronous rob committed
576
	type DisputesHandler = ();
577
	type RewardValidators = RewardValidators;
Fedor Sakharov's avatar
Fedor Sakharov committed
578
579
}

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

Shawn Tabrizi's avatar
Shawn Tabrizi committed
585
parameter_types! {
Gavin Wood's avatar
Gavin Wood committed
586
	pub const RocLocation: MultiLocation = MultiLocation::Here;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
587
	pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
Gavin Wood's avatar
Gavin Wood committed
588
	pub const Ancestry: MultiLocation = MultiLocation::Here;
589
	pub CheckAccount: AccountId = XcmPallet::check_account();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
590
591
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
pub type SovereignAccountOf =
	(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:
	SovereignAccountOf,
	// Our chain's account ID type (we can't get away without mentioning it explicitly):
	AccountId,
	// It's a native asset so we keep track of the teleports to maintain total issuance.
	CheckAccount,
>;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
607
608

type LocalOriginConverter = (
609
	SovereignSignedViaLocation<SovereignAccountOf, Origin>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
610
611
612
613
614
	ChildParachainAsNative<parachains_origin::Origin, Origin>,
	SignedAccountId32AsNative<RococoNetwork, Origin>,
	ChildSystemParachainAsSuperuser<ParaId, Origin>,
);

Gavin Wood's avatar
Gavin Wood committed
615
616
617
618
parameter_types! {
	pub const BaseXcmWeight: Weight = 100_000;
}

Gavin Wood's avatar
Gavin Wood committed
619
620
621
622
/// 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.
Gavin Wood's avatar
Gavin Wood committed
623
	xcm_sender::ChildParachainRouter<Runtime, xcm::AlwaysRelease>,
Gavin Wood's avatar
Gavin Wood committed
624
625
);

626
parameter_types! {
Gavin Wood's avatar
Gavin Wood committed
627
628
629
630
631
	pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
	pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(100)));
	pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(110)));
	pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(120)));
	pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(1001)));
632
633
634
635
636
}
pub type TrustedTeleporters = (
	xcm_builder::Case<RococoForTick>,
	xcm_builder::Case<RococoForTrick>,
	xcm_builder::Case<RococoForTrack>,
Ricardo Rius's avatar
Ricardo Rius committed
637
	xcm_builder::Case<RococoForStatemint>,
638
639
640
);

parameter_types! {
641
	pub AllowUnpaidFrom: Vec<MultiLocation> =
Ricardo Rius's avatar
Ricardo Rius committed
642
		vec![
643
644
645
			X1(Parachain(100)),
			X1(Parachain(110)),
			X1(Parachain(120)),
646
			X1(Parachain(1001))
Ricardo Rius's avatar
Ricardo Rius committed
647
		];
648
649
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
650
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
651
652
pub type Barrier = (
	TakeWeightCredit,
653
	AllowTopLevelPaidExecutionFrom<Everything>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
654
	AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
655
656
);

Shawn Tabrizi's avatar
Shawn Tabrizi committed
657
658
659
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
	type Call = Call;
Gavin Wood's avatar
Gavin Wood committed
660
	type XcmSender = XcmRouter;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
661
662
663
	type AssetTransactor = LocalAssetTransactor;
	type OriginConverter = LocalOriginConverter;
	type IsReserve = ();
664
	type IsTeleporter = TrustedTeleporters;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
665
	type LocationInverter = LocationInverter<Ancestry>;
666
	type Barrier = Barrier;
Gavin Wood's avatar
Gavin Wood committed
667
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
668
	type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
Gavin Wood's avatar
Gavin Wood committed
669
	type ResponseHandler = ();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
670
671
}

672
673
674
675
parameter_types! {
	pub const CollectiveBodyId: BodyId = BodyId::Unit;
}

Gavin Wood's avatar
Gavin Wood committed
676
677
678
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
679
680
	// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
	// `Unit` body.
681
682
683
	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
684
685
686
687
688
689
);

impl pallet_xcm::Config for Runtime {
	type Event = Event;
	type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
	type XcmRouter = XcmRouter;
690
691
	// Anyone can execute XCM messages locally...
	type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Gavin Wood's avatar
Gavin Wood committed
692
693
	// ...but they must match our filter, which right now rejects everything.
	type XcmExecuteFilter = ();
Gavin Wood's avatar
Gavin Wood committed
694
	type XcmExecutor = XcmExecutor<XcmConfig>;
695
696
	type XcmTeleportFilter = Everything;
	type XcmReserveTransferFilter = Everything;
697
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call>;
698
	type LocationInverter = LocationInverter<Ancestry>;
Gavin Wood's avatar
Gavin Wood committed
699
700
}

701
impl parachains_session_info::Config for Runtime {}
702

Gavin Wood's avatar
Gavin Wood committed
703
704
705
706
parameter_types! {
	pub const FirstMessageFactorPercent: u64 = 100;
}

707
impl parachains_ump::Config for Runtime {
708
709
	type Event = Event;
	type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
Gavin Wood's avatar
Gavin Wood committed
710
	type FirstMessageFactorPercent = FirstMessageFactorPercent;
711
}
712

713
impl parachains_dmp::Config for Runtime {}
714

715
impl parachains_hrmp::Config for Runtime {
716
	type Event = Event;
717
	type Origin = Origin;
718
	type Currency = Balances;
719
720
}

721
impl parachains_paras_inherent::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
722

723
impl parachains_scheduler::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
724

725
impl parachains_initializer::Config for Runtime {
726
	type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
727
	type ForceOrigin = EnsureRoot<AccountId>;
Fedor Sakharov's avatar
Fedor Sakharov committed
728
}
729

730
impl paras_sudo_wrapper::Config for Runtime {}
731

732
733
734
735
736
parameter_types! {
	pub const ParaDeposit: Balance = 5 * DOLLARS;
	pub const DataDepositPerByte: Balance = deposit(0, 1);
}

737
impl paras_registrar::Config for Runtime {
738
	type Event = Event;
739
	type Origin = Origin;
740
	type Currency = Balances;
741
	type OnSwap = (Crowdloan, Slots);
742
743
744
	type ParaDeposit = ParaDeposit;
	type DataDepositPerByte = DataDepositPerByte;
	type WeightInfo = paras_registrar::TestWeightInfo;
745
}
746

747
748
749
750
/// An insecure randomness beacon that uses the parent block hash as random material.
///
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub struct ParentHashRandomness;
751

752
impl pallet_beefy::Config for Runtime {
Andreas Doerr's avatar
Andreas Doerr committed
753
	type BeefyId = BeefyId;
754
755
756
757
758
759
}

impl pallet_mmr::Config for Runtime {
	const INDEXING_PREFIX: &'static [u8] = b"mmr";
	type Hashing = Keccak256;
	type Hash = <Keccak256 as traits::Hash>::Output;
760
	type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
761
	type WeightInfo = ();
762
763
764
765
766
767
768
769
	type LeafData = pallet_beefy_mmr::Pallet<Runtime>;
}

pub struct ParasProvider;
impl pallet_beefy_mmr::ParachainHeadsProvider for ParasProvider {
	fn parachain_heads() -> Vec<(u32, Vec<u8>)> {
		Paras::parachains()
			.into_iter()
Shawn Tabrizi's avatar
Shawn Tabrizi committed
770
			.filter_map(|id| Paras::para_head(&id).map(|head| (id.into(), head.0)))
771
772
			.collect()
	}
773
774
}

775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
parameter_types! {
	/// Version of the produced MMR leaf.
	///
	/// The version consists of two parts;
	/// - `major` (3 bits)
	/// - `minor` (5 bits)
	///
	/// `major` should be updated only if decoding the previous MMR Leaf format from the payload
	/// is not possible (i.e. backward incompatible change).
	/// `minor` should be updated if fields are added to the previous MMR Leaf, which given SCALE
	/// encoding does not prevent old leafs from being decoded.
	///
	/// Hence we expect `major` to be changed really rarely (think never).
	/// See [`MmrLeafVersion`] type documentation for more details.
	pub LeafVersion: MmrLeafVersion = MmrLeafVersion::new(0, 0);
}

impl pallet_beefy_mmr::Config for Runtime {
	type LeafVersion = LeafVersion;
	type BeefyAuthorityToMerkleLeaf = pallet_beefy_mmr::BeefyEcdsaToEthereum;
	type ParachainHeads = ParasProvider;
796
797
}

798
parameter_types! {
799
800
801
802
	/// 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.
803
804
	pub const MaxRequests: u32 = 4 * HOURS as u32;

805
806
807
808
	/// Number of headers to keep.
	///
	/// Assuming the worst case of every header being finalized, we will keep headers at least for a
	/// week.
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
	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>;
}

Denis_P's avatar
Denis_P committed
830
// Instance that is "deployed" at Wococo chain. Responsible for dispatching Rococo -> Wococo messages.
831
832
833
834
835
pub type AtWococoFromRococoMessagesDispatch = pallet_bridge_dispatch::DefaultInstance;
impl pallet_bridge_dispatch::Config<AtWococoFromRococoMessagesDispatch> for Runtime {
	type Event = Event;
	type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
	type Call = Call;
836
	type CallFilter = frame_support::traits::Everything;
837
838
839
840
841
842
843
	type EncodedCall = bridge_messages::FromRococoEncodedCall;
	type SourceChainAccountId = bp_wococo::AccountId;
	type TargetChainAccountPublic = sp_runtime::MultiSigner;
	type TargetChainSignature = sp_runtime::MultiSignature;
	type AccountIdConverter = bp_rococo::AccountIdConverter;
}

Denis_P's avatar
Denis_P committed
844
// Instance that is "deployed" at Rococo chain. Responsible for dispatching Wococo -> Rococo messages.
845
846
847
848
849
pub type AtRococoFromWococoMessagesDispatch = pallet_bridge_dispatch::Instance1;
impl pallet_bridge_dispatch::Config<AtRococoFromWococoMessagesDispatch> for Runtime {
	type Event = Event;
	type MessageId = (bp_messages::LaneId, bp_messages::MessageNonce);
	type Call = Call;
850
	type CallFilter = frame_support::traits::Everything;
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
	type EncodedCall = bridge_messages::FromWococoEncodedCall;
	type SourceChainAccountId = bp_rococo::AccountId;
	type TargetChainAccountPublic = sp_runtime::MultiSigner;
	type TargetChainSignature = sp_runtime::MultiSignature;
	type AccountIdConverter = bp_wococo::AccountIdConverter;
}

parameter_types! {
	pub const MaxMessagesToPruneAtOnce: bp_messages::MessageNonce = 8;
	pub const MaxUnrewardedRelayerEntriesAtInboundLane: bp_messages::MessageNonce =
		bp_rococo::MAX_UNREWARDED_RELAYER_ENTRIES_AT_INBOUND_LANE;
	pub const MaxUnconfirmedMessagesAtInboundLane: bp_messages::MessageNonce =
		bp_rococo::MAX_UNCONFIRMED_MESSAGES_AT_INBOUND_LANE;
	pub const RootAccountForPayments: Option<AccountId> = None;
}

Denis_P's avatar
Denis_P committed
867
// Instance that is "deployed" at Wococo chain. Responsible for sending Wococo -> Rococo messages
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
// and receiving Rococo -> Wococo messages.
pub type AtWococoWithRococoMessagesInstance = pallet_bridge_messages::DefaultInstance;
impl pallet_bridge_messages::Config<AtWococoWithRococoMessagesInstance> for Runtime {
	type Event = Event;
	type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
	type Parameter = ();
	type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
	type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
	type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;

	type OutboundPayload = crate::bridge_messages::ToRococoMessagePayload;
	type OutboundMessageFee = bp_wococo::Balance;

	type InboundPayload = crate::bridge_messages::FromRococoMessagePayload;
	type InboundMessageFee = bp_rococo::Balance;
	type InboundRelayer = bp_rococo::AccountId;

	type AccountIdConverter = bp_wococo::AccountIdConverter;

	type TargetHeaderChain = crate::bridge_messages::RococoAtWococo;
	type LaneMessageVerifier = crate::bridge_messages::ToRococoMessageVerifier;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
889
890
891
892
893
894
895
	type MessageDeliveryAndDispatchPayment =
		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
			Runtime,
			pallet_balances::Pallet<Runtime>,
			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
			RootAccountForPayments,
		>;
896
897
898
899
900
901
	type OnDeliveryConfirmed = ();

	type SourceHeaderChain = crate::bridge_messages::RococoAtWococo;
	type MessageDispatch = crate::bridge_messages::FromRococoMessageDispatch;
}

Denis_P's avatar
Denis_P committed
902
// Instance that is "deployed" at Rococo chain. Responsible for sending Rococo -> Wococo messages
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
// and receiving Wococo -> Rococo messages.
pub type AtRococoWithWococoMessagesInstance = pallet_bridge_messages::Instance1;
impl pallet_bridge_messages::Config<AtRococoWithWococoMessagesInstance> for Runtime {
	type Event = Event;
	type WeightInfo = pallet_bridge_messages::weights::RialtoWeight<Runtime>;
	type Parameter = ();
	type MaxMessagesToPruneAtOnce = MaxMessagesToPruneAtOnce;
	type MaxUnrewardedRelayerEntriesAtInboundLane = MaxUnrewardedRelayerEntriesAtInboundLane;
	type MaxUnconfirmedMessagesAtInboundLane = MaxUnconfirmedMessagesAtInboundLane;

	type OutboundPayload = crate::bridge_messages::ToWococoMessagePayload;
	type OutboundMessageFee = bp_rococo::Balance;

	type InboundPayload = crate::bridge_messages::FromWococoMessagePayload;
	type InboundMessageFee = bp_wococo::Balance;
	type InboundRelayer = bp_wococo::AccountId;

	type AccountIdConverter = bp_rococo::AccountIdConverter;

	type TargetHeaderChain = crate::bridge_messages::WococoAtRococo;
	type LaneMessageVerifier = crate::bridge_messages::ToWococoMessageVerifier;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
924
925
926
927
928
929
930
	type MessageDeliveryAndDispatchPayment =
		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
			Runtime,
			pallet_balances::Pallet<Runtime>,
			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
			RootAccountForPayments,
		>;
931
932
933
934
935
936
	type OnDeliveryConfirmed = ();

	type SourceHeaderChain = crate::bridge_messages::WococoAtRococo;
	type MessageDispatch = crate::bridge_messages::FromWococoMessageDispatch;
}

937
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
938
	fn random(subject: &[u8]) -> (Hash, BlockNumber) {
939
		(
Shawn Tabrizi's avatar
Shawn Tabrizi committed
940
941
942
			(System::parent_hash(), subject)
				.using_encoded(sp_io::hashing::blake2_256)
				.into(),
943
944
			System::block_number(),
		)
945
946
947
	}
}

948
parameter_types! {
949
	pub const EndingPeriod: BlockNumber = 1 * HOURS;
950
951
952
	pub const SampleLength: BlockNumber = 1;
}

953
954
955
impl auctions::Config for Runtime {
	type Event = Event;
	type Leaser = Slots;
956
	type Registrar = Registrar;
957
	type EndingPeriod = EndingPeriod;
958
	type SampleLength = SampleLength;
959
	type Randomness = ParentHashRandomness;
960
961
962
	type InitiateOrigin = EnsureRoot<AccountId>;
	type WeightInfo = auctions::TestWeightInfo;
}
963

964
965
966
parameter_types! {
	pub const LeasePeriod: BlockNumber = 1 * DAYS;
}
967

968
969
970
971
972
973
974
impl slots::Config for Runtime {
	type Event = Event;
	type Currency = Balances;
	type Registrar = Registrar;
	type LeasePeriod = LeasePeriod;
	type WeightInfo = slots::TestWeightInfo;
}
975

976
parameter_types! {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
977
	pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
978
979
980
	pub const SubmissionDeposit: Balance = 100 * DOLLARS;
	pub const MinContribution: Balance = 1 * DOLLARS;
	pub const RemoveKeysLimit: u32 = 500;
981
982
	// Allow 32 bytes for an additional memo to a crowdloan.
	pub const MaxMemoLength: u8 = 32;
983
}
984

985
986
impl crowdloan::Config for Runtime {
	type Event = Event;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
987
	type PalletId = CrowdloanId;
988
989
990
991
992
	type SubmissionDeposit = SubmissionDeposit;
	type MinContribution = MinContribution;
	type RemoveKeysLimit = RemoveKeysLimit;
	type Registrar = Registrar;
	type Auctioneer = Auctions;
993
	type MaxMemoLength = MaxMemoLength;
994
	type WeightInfo = crowdloan::TestWeightInfo;
995
996
}

997
998
999
impl pallet_sudo::Config for Runtime {
	type Event = Event;
	type Call = Call;
1000
}
For faster browsing, not all history is shown. View entire blame