lib.rs 50.4 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
28
29
	traits::{
		Contains, Everything, IsInVec, KeyOwnerProofSystem, Nothing, OnRuntimeUpgrade, Randomness,
	},
Shawn Tabrizi's avatar
Shawn Tabrizi committed
30
	weights::Weight,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
	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
49
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
50
51
use runtime_parachains::{self, runtime_api_impl::v1 as runtime_api_impl};
use sp_core::{OpaqueMetadata, RuntimeDebug};
Fedor Sakharov's avatar
Fedor Sakharov committed
52
53
54
use sp_runtime::{
	create_runtime_str, generic, impl_opaque_keys,
	traits::{
Shawn Tabrizi's avatar
Shawn Tabrizi committed
55
56
		self, AccountIdLookup, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, Keccak256,
		OpaqueKeys, SaturatedConversion, Verify,
Fedor Sakharov's avatar
Fedor Sakharov committed
57
	},
Shawn Tabrizi's avatar
Shawn Tabrizi committed
58
59
	transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
	ApplyExtrinsicResult, KeyTypeId, Perbill,
Fedor Sakharov's avatar
Fedor Sakharov committed
60
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
61
62
use sp_staking::SessionIndex;
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
63
64
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
65
use sp_version::RuntimeVersion;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
66
67
68
69
70
71
72
73
74
75
76
77

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,
};
78

79
pub use pallet_balances::Call as BalancesCall;
Fedor Sakharov's avatar
Fedor Sakharov committed
80

Shawn Tabrizi's avatar
Shawn Tabrizi committed
81
use polkadot_parachain::primitives::Id as ParaId;
82

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

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

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

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

117
118
119
120
/// 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
121
		allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryVRFSlots,
122
123
	};

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

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

151
152
153
154
155
/// 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
156
157
158
		frame_support::migrations::migrate_from_pallet_version_to_storage_version::<
			AllPalletsWithSystem,
		>(&RocksDbWeight::get())
159
160
161
	}
}

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

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

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

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

199
200
201
202
		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
203
204

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

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

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

		// Sudo
235
		Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>},
236

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

242
243
244
245
246
247
		// 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,

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

251
252
253
254
255
256
257
		// 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,

258
259
260
261
		// 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,

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

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

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

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

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

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

		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 = (
338
339
340
			frame_system::CheckSpecVersion::<Runtime>::new(),
			frame_system::CheckTxVersion::<Runtime>::new(),
			frame_system::CheckGenesis::<Runtime>::new(),
Shawn Tabrizi's avatar
Shawn Tabrizi committed
341
342
343
344
			frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(
				period,
				current_block,
			)),
345
346
347
			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
348
		);
Shawn Tabrizi's avatar
Shawn Tabrizi committed
349
350
351
352
353
354
		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
355
		let (call, extra, _) = raw_payload.deconstruct();
356
357
		let address = <Runtime as frame_system::Config>::Lookup::unlookup(account);
		Some((call, (address, signature, extra)))
Fedor Sakharov's avatar
Fedor Sakharov committed
358
359
360
	}
}

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

366
367
368
/// 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
369
370
371
	fn convert(_: AccountId) -> Option<()> {
		Some(Default::default())
	}
Fedor Sakharov's avatar
Fedor Sakharov committed
372
373
}

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

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

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

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

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

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

Shawn Tabrizi's avatar
Shawn Tabrizi committed
415
416
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
Fedor Sakharov's avatar
Fedor Sakharov committed
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
	pub const MaxAuthorities: u32 = 100_000;
Fedor Sakharov's avatar
Fedor Sakharov committed
426
427
}

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

434
435
436
impl pallet_authority_discovery::Config for Runtime {
	type MaxAuthorities = MaxAuthorities;
}
Fedor Sakharov's avatar
Fedor Sakharov committed
437
438
439
440

parameter_types! {
	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
441
impl pallet_timestamp::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
442
443
444
445
446
447
448
449
450
451
	type Moment = u64;
	type OnTimestampSet = Babe;
	type MinimumPeriod = MinimumPeriod;
	type WeightInfo = ();
}

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

452
impl pallet_transaction_payment::Config for Runtime {
Albrecht's avatar
Albrecht committed
453
	type OnChargeTransaction = CurrencyAdapter<Balances, ToAuthor<Runtime>>;
Fedor Sakharov's avatar
Fedor Sakharov committed
454
455
456
457
458
459
460
461
462
	type TransactionByteFee = TransactionByteFee;
	type WeightToFee = WeightToFee;
	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
}

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

463
464
465
/// 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
466
467
468
	fn convert(a: AccountId) -> Option<AccountId> {
		Some(a)
	}
469
470
}

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

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

489
impl pallet_babe::Config for Runtime {
490
	type EpochDuration = EpochDurationInBlocks;
Fedor Sakharov's avatar
Fedor Sakharov committed
491
492
493
	type ExpectedBlockTime = ExpectedBlockTime;

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

496
497
	type DisabledValidators = Session;

Fedor Sakharov's avatar
Fedor Sakharov committed
498
499
500
501
	type KeyOwnerProofSystem = Historical;

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

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

	type HandleEquivocation =
511
		pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences, ReportLongevity>;
512
513

	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
514
515
516
517
518
519
}

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

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

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

532
impl pallet_grandpa::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
533
534
535
536
537
538
539
540
541
542
543
544
545
	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
546
547
548
549
550
	type HandleEquivocation = pallet_grandpa::EquivocationHandler<
		Self::KeyOwnerIdentification,
		Offences,
		ReportLongevity,
	>;
551
552

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

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

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

566
impl parachains_origin::Config for Runtime {}
567

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

570
571
impl parachains_shared::Config for Runtime {}

572
573
574
/// Special `RewardValidators` that does nothing ;)
pub struct RewardValidators;
impl runtime_parachains::inclusion::RewardValidators for RewardValidators {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
575
576
	fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
	fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
577
578
}

579
impl parachains_inclusion::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
580
	type Event = Event;
asynchronous rob's avatar
asynchronous rob committed
581
	type DisputesHandler = ();
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
parameter_types! {
591
	pub const RocLocation: MultiLocation = Here.into();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
592
	pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
593
	pub const Ancestry: MultiLocation = Here.into();
594
	pub CheckAccount: AccountId = XcmPallet::check_account();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
595
596
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
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
612
613

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

Gavin Wood's avatar
Gavin Wood committed
620
621
622
623
parameter_types! {
	pub const BaseXcmWeight: Weight = 100_000;
}

Gavin Wood's avatar
Gavin Wood committed
624
625
626
627
/// 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
628
	xcm_sender::ChildParachainRouter<Runtime, xcm::AlwaysRelease>,
Gavin Wood's avatar
Gavin Wood committed
629
630
);

631
parameter_types! {
Gavin Wood's avatar
Gavin Wood committed
632
	pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
633
634
635
636
	pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(100).into());
	pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into());
	pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into());
	pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1001).into());
637
	pub const MaxInstructions: u32 = 100;
638
639
640
641
642
}
pub type TrustedTeleporters = (
	xcm_builder::Case<RococoForTick>,
	xcm_builder::Case<RococoForTrick>,
	xcm_builder::Case<RococoForTrack>,
Ricardo Rius's avatar
Ricardo Rius committed
643
	xcm_builder::Case<RococoForStatemint>,
644
645
646
);

parameter_types! {
647
	pub AllowUnpaidFrom: Vec<MultiLocation> =
Ricardo Rius's avatar
Ricardo Rius committed
648
		vec![
649
650
651
652
			Parachain(100).into(),
			Parachain(110).into(),
			Parachain(120).into(),
			Parachain(1001).into(),
Ricardo Rius's avatar
Ricardo Rius committed
653
		];
654
655
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
656
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
657
658
pub type Barrier = (
	TakeWeightCredit,
659
	AllowTopLevelPaidExecutionFrom<Everything>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
660
	AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
661
662
);

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

680
681
682
683
parameter_types! {
	pub const CollectiveBodyId: BodyId = BodyId::Unit;
}

Gavin Wood's avatar
Gavin Wood committed
684
685
686
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
687
688
	// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
	// `Unit` body.
689
690
691
	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
692
693
694
695
696
697
);

impl pallet_xcm::Config for Runtime {
	type Event = Event;
	type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
	type XcmRouter = XcmRouter;
698
699
	// Anyone can execute XCM messages locally...
	type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Gavin Wood's avatar
Gavin Wood committed
700
	// ...but they must match our filter, which right now rejects everything.
701
	type XcmExecuteFilter = Nothing;
Gavin Wood's avatar
Gavin Wood committed
702
	type XcmExecutor = XcmExecutor<XcmConfig>;
703
704
	type XcmTeleportFilter = Everything;
	type XcmReserveTransferFilter = Everything;
705
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
706
	type LocationInverter = LocationInverter<Ancestry>;
707
708
	type Origin = Origin;
	type Call = Call;
Gavin Wood's avatar
Gavin Wood committed
709
710
}

711
impl parachains_session_info::Config for Runtime {}
712

Gavin Wood's avatar
Gavin Wood committed
713
714
715
716
parameter_types! {
	pub const FirstMessageFactorPercent: u64 = 100;
}

717
impl parachains_ump::Config for Runtime {
718
719
	type Event = Event;
	type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
Gavin Wood's avatar
Gavin Wood committed
720
	type FirstMessageFactorPercent = FirstMessageFactorPercent;
721
}
722

723
impl parachains_dmp::Config for Runtime {}
724

725
impl parachains_hrmp::Config for Runtime {
726
	type Event = Event;
727
	type Origin = Origin;
728
	type Currency = Balances;
729
730
}

731
impl parachains_paras_inherent::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
732

733
impl parachains_scheduler::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
734

735
impl parachains_initializer::Config for Runtime {
736
	type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
737
	type ForceOrigin = EnsureRoot<AccountId>;
Fedor Sakharov's avatar
Fedor Sakharov committed
738
}
739

740
impl paras_sudo_wrapper::Config for Runtime {}
741

742
743
744
745
746
parameter_types! {
	pub const ParaDeposit: Balance = 5 * DOLLARS;
	pub const DataDepositPerByte: Balance = deposit(0, 1);
}

747
impl paras_registrar::Config for Runtime {
748
	type Event = Event;
749
	type Origin = Origin;
750
	type Currency = Balances;
751
	type OnSwap = (Crowdloan, Slots);
752
753
754
	type ParaDeposit = ParaDeposit;
	type DataDepositPerByte = DataDepositPerByte;
	type WeightInfo = paras_registrar::TestWeightInfo;
755
}
756

757
758
759
760
/// An insecure randomness beacon that uses the parent block hash as random material.
///
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub struct ParentHashRandomness;
761

762
impl pallet_beefy::Config for Runtime {
Andreas Doerr's avatar
Andreas Doerr committed
763
	type BeefyId = BeefyId;
764
765
766
767
768
769
}

impl pallet_mmr::Config for Runtime {
	const INDEXING_PREFIX: &'static [u8] = b"mmr";
	type Hashing = Keccak256;
	type Hash = <Keccak256 as traits::Hash>::Output;
770
	type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
771
	type WeightInfo = ();
772
773
774
775
776
777
778
779
	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
780
			.filter_map(|id| Paras::para_head(&id).map(|head| (id.into(), head.0)))
781
782
			.collect()
	}
783
784
}

785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
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;
806
807
}

808
parameter_types! {
809
810
811
812
	/// 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.
813
814
	pub const MaxRequests: u32 = 4 * HOURS as u32;

815
816
817
818
	/// Number of headers to keep.
	///
	/// Assuming the worst case of every header being finalized, we will keep headers at least for a
	/// week.
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
	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
840
// Instance that is "deployed" at Wococo chain. Responsible for dispatching Rococo -> Wococo messages.
841
842
843
844
845
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;
846
	type CallFilter = frame_support::traits::Everything;
847
848
849
850
851
852
853
	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
854
// Instance that is "deployed" at Rococo chain. Responsible for dispatching Wococo -> Rococo messages.
855
856
857
858
859
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;
860
	type CallFilter = frame_support::traits::Everything;
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
	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
877
// Instance that is "deployed" at Wococo chain. Responsible for sending Wococo -> Rococo messages
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
// 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
899
900
901
902
903
904
905
	type MessageDeliveryAndDispatchPayment =
		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
			Runtime,
			pallet_balances::Pallet<Runtime>,
			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
			RootAccountForPayments,
		>;
906
907
908
909
910
911
	type OnDeliveryConfirmed = ();

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

Denis_P's avatar
Denis_P committed
912
// Instance that is "deployed" at Rococo chain. Responsible for sending Rococo -> Wococo messages
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
// 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
934
935
936
937
938
939
940
	type MessageDeliveryAndDispatchPayment =
		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
			Runtime,
			pallet_balances::Pallet<Runtime>,
			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
			RootAccountForPayments,
		>;
941
942
943
944
945
946
	type OnDeliveryConfirmed = ();

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

947
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
948
	fn random(subject: &[u8]) -> (Hash, BlockNumber) {
949
		(
Shawn Tabrizi's avatar
Shawn Tabrizi committed
950
951
952
			(System::parent_hash(), subject)
				.using_encoded(sp_io::hashing::blake2_256)
				.into(),
953
954
			System::block_number(),
		)
955
956
957
	}
}

958
parameter_types! {
959
	pub const EndingPeriod: BlockNumber = 1 * HOURS;
960
961
962
	pub const SampleLength: BlockNumber = 1;
}

963
964
965
impl auctions::Config for Runtime {
	type Event = Event;
	type Leaser = Slots;
966
	type Registrar = Registrar;
967
	type EndingPeriod = EndingPeriod;
968
	type SampleLength = SampleLength;
969
	type Randomness = ParentHashRandomness;
970
971
972
	type InitiateOrigin = EnsureRoot<AccountId>;
	type WeightInfo = auctions::TestWeightInfo;
}
973

974
975
976
parameter_types! {
	pub const LeasePeriod: BlockNumber = 1 * DAYS;
}
977

978
979
980
981
982
983
984
impl slots::Config for Runtime {
	type Event = Event;
	type Currency = Balances;
	type Registrar = Registrar;
	type LeasePeriod = LeasePeriod;
	type WeightInfo = slots::TestWeightInfo;
}
985

986
parameter_types! {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
987
	pub const CrowdloanId: PalletId = PalletId(*b"py/cfund");
988
989
990
	pub const SubmissionDeposit: Balance = 100 * DOLLARS;
	pub const MinContribution: Balance = 1 * DOLLARS;
	pub const RemoveKeysLimit: u32 = 500;
991
992
	// Allow 32 bytes for an additional memo to a crowdloan.
	pub const MaxMemoLength: u8 = 32;
993
}
994

995
996
impl crowdloan::Config for Runtime {
	type Event = Event;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
997
	type PalletId = CrowdloanId;
998
999
1000
	type SubmissionDeposit = SubmissionDeposit;
	type MinContribution = MinContribution;
	type RemoveKeysLimit = RemoveKeysLimit;
For faster browsing, not all history is shown. View entire blame