lib.rs 54.8 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, Nothing, 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
use runtime_parachains::{self, runtime_api_impl::v1 as runtime_api_impl};
49
use scale_info::TypeInfo;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
50
use sp_core::{OpaqueMetadata, RuntimeDebug};
Fedor Sakharov's avatar
Fedor Sakharov committed
51
52
53
use sp_runtime::{
	create_runtime_str, generic, impl_opaque_keys,
	traits::{
Shawn Tabrizi's avatar
Shawn Tabrizi committed
54
55
		self, AccountIdLookup, BlakeTwo256, Block as BlockT, Extrinsic as ExtrinsicT, Keccak256,
		OpaqueKeys, SaturatedConversion, Verify,
Fedor Sakharov's avatar
Fedor Sakharov committed
56
	},
Shawn Tabrizi's avatar
Shawn Tabrizi committed
57
	transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
58
	ApplyExtrinsicResult, KeyTypeId,
Fedor Sakharov's avatar
Fedor Sakharov committed
59
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
60
61
use sp_staking::SessionIndex;
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
62
63
#[cfg(any(feature = "std", test))]
use sp_version::NativeVersion;
64
use sp_version::RuntimeVersion;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
65
66

use runtime_parachains::{
67
68
69
	configuration as parachains_configuration, disputes as parachains_disputes,
	dmp as parachains_dmp, hrmp as parachains_hrmp, inclusion as parachains_inclusion,
	initializer as parachains_initializer, origin as parachains_origin, paras as parachains_paras,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
70
71
72
73
	paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
	session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};

74
75
76
// use bridge_runtime_common::messages::{
// 	source::estimate_message_dispatch_and_delivery_fee, MessageBridge,
// };
77

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

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

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

93
//mod bridge_messages;
Fedor Sakharov's avatar
Fedor Sakharov committed
94
95
/// Constant values used within the runtime.
pub mod constants;
96
mod validator_manager;
97
mod weights;
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"),
asynchronous rob's avatar
asynchronous rob committed
106
	impl_name: create_runtime_str!("parity-rococo-v1.8"),
107
	authoring_version: 0,
108
	spec_version: 9106,
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
);

/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Executive: handles dispatch to the various modules.
154
155
156
157
158
159
pub type Executive = frame_executive::Executive<
	Runtime,
	Block,
	frame_system::ChainContext<Runtime>,
	Runtime,
	AllPallets,
160
	(),
161
>;
Fedor Sakharov's avatar
Fedor Sakharov committed
162
163
164
165
166
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;

impl_opaque_keys! {
	pub struct SessionKeys {
167
		pub grandpa: Grandpa,
Fedor Sakharov's avatar
Fedor Sakharov committed
168
169
		pub babe: Babe,
		pub im_online: ImOnline,
170
		pub para_validator: Initializer,
171
		pub para_assignment: ParaSessionInfo,
172
		pub authority_discovery: AuthorityDiscovery,
173
174
175
176
		pub beefy: Beefy,
	}
}

Fedor Sakharov's avatar
Fedor Sakharov committed
177
178
179
180
181
182
construct_runtime! {
	pub enum Runtime where
		Block = Block,
		NodeBlock = primitives::v1::Block,
		UncheckedExtrinsic = UncheckedExtrinsic
	{
183
		System: frame_system::{Pallet, Call, Storage, Config, Event<T>},
Fedor Sakharov's avatar
Fedor Sakharov committed
184
185

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

188
189
190
191
		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
192
193

		// Consensus support.
194
		Authorship: pallet_authorship::{Pallet, Call, Storage},
Keith Yeung's avatar
Keith Yeung committed
195
		Offences: pallet_offences::{Pallet, Storage, Event},
196
197
198
199
		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
200
		AuthorityDiscovery: pallet_authority_discovery::{Pallet, Config},
Fedor Sakharov's avatar
Fedor Sakharov committed
201
202

		// Parachains modules.
203
		ParachainsOrigin: parachains_origin::{Pallet, Origin},
204
		Configuration: parachains_configuration::{Pallet, Call, Storage, Config<T>},
205
		ParasShared: parachains_shared::{Pallet, Call, Storage},
206
		ParaInclusion: parachains_inclusion::{Pallet, Call, Storage, Event<T>},
207
		ParaInherent: parachains_paras_inherent::{Pallet, Call, Storage, Inherent},
208
		ParaScheduler: parachains_scheduler::{Pallet, Storage},
ferrell-code's avatar
ferrell-code committed
209
		Paras: parachains_paras::{Pallet, Call, Storage, Event, Config},
210
211
		Initializer: parachains_initializer::{Pallet, Call, Storage},
		Dmp: parachains_dmp::{Pallet, Call, Storage},
212
		Ump: parachains_ump::{Pallet, Call, Storage, Event},
213
		Hrmp: parachains_hrmp::{Pallet, Call, Storage, Event<T>, Config},
214
		ParaSessionInfo: parachains_session_info::{Pallet, Storage},
215
		ParasDisputes: parachains_disputes::{Pallet, Call, Storage, Event<T>},
216

217
		// Parachain Onboarding Pallets
218
		Registrar: paras_registrar::{Pallet, Call, Storage, Event<T>, Config},
219
220
221
		Auctions: auctions::{Pallet, Call, Storage, Event<T>},
		Crowdloan: crowdloan::{Pallet, Call, Storage, Event<T>},
		Slots: slots::{Pallet, Call, Storage, Event<T>},
222
		ParasSudoWrapper: paras_sudo_wrapper::{Pallet, Call},
223
224

		// Sudo
225
		Sudo: pallet_sudo::{Pallet, Call, Storage, Event<T>, Config<T>},
226

227
		// Bridges support.
228
		Mmr: pallet_mmr::{Pallet, Storage},
229
		Beefy: pallet_beefy::{Pallet, Config<T>, Storage},
230
		MmrLeaf: pallet_beefy_mmr::{Pallet, Storage},
231

232
233
234
		// 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.
235
236
		// BridgeRococoGrandpa: pallet_bridge_grandpa::{Pallet, Call, Storage, Config<T>} = 40,
		// BridgeWococoGrandpa: pallet_bridge_grandpa::<Instance1>::{Pallet, Call, Storage, Config<T>} = 41,
237

238
239
		// Validator Manager pallet.
		ValidatorManager: validator_manager::{Pallet, Call, Storage, Event<T>},
240

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

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

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

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

259
260
261
	}
}

262
pub struct BaseFilter;
263
264
impl Contains<Call> for BaseFilter {
	fn contains(_call: &Call) -> bool {
265
266
267
		true
	}
}
268

Fedor Sakharov's avatar
Fedor Sakharov committed
269
270
parameter_types! {
	pub const Version: RuntimeVersion = VERSION;
271
	pub const SS58Prefix: u8 = 42;
Fedor Sakharov's avatar
Fedor Sakharov committed
272
273
}

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

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

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

353
impl frame_system::offchain::SigningTypes for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
354
355
356
357
	type Public = <Signature as Verify>::Signer;
	type Signature = Signature;
}

358
359
360
/// 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
361
362
363
	fn convert(_: AccountId) -> Option<()> {
		Some(Default::default())
	}
Fedor Sakharov's avatar
Fedor Sakharov committed
364
365
}

366
367
368
impl pallet_session::historical::Config for Runtime {
	type FullIdentification = ();
	type FullIdentificationOf = FullIdentificationOf;
Fedor Sakharov's avatar
Fedor Sakharov committed
369
370
}

371
372
373
374
impl parachains_disputes::Config for Runtime {
	type Event = Event;
	type RewardValidators = ();
	type PunishValidators = ();
375
	type WeightInfo = weights::runtime_parachains_disputes::WeightInfo<Runtime>;
376
377
}

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

parameter_types! {
	pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
384
385
386
	pub const MaxKeys: u32 = 10_000;
	pub const MaxPeerInHeartbeats: u32 = 10_000;
	pub const MaxPeerDataEncodingSize: u32 = 1_000;
Fedor Sakharov's avatar
Fedor Sakharov committed
387
388
}

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

parameter_types! {
	pub const ExistentialDeposit: Balance = 1 * CENTS;
404
	pub const MaxLocks: u32 = 50;
Gavin Wood's avatar
Gavin Wood committed
405
	pub const MaxReserves: u32 = 50;
Fedor Sakharov's avatar
Fedor Sakharov committed
406
407
}

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

Shawn Tabrizi's avatar
Shawn Tabrizi committed
420
421
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime
where
Fedor Sakharov's avatar
Fedor Sakharov committed
422
423
424
425
426
427
428
429
	Call: From<C>,
{
	type OverarchingCall = Call;
	type Extrinsic = UncheckedExtrinsic;
}

parameter_types! {
	pub const MaxRetries: u32 = 3;
430
	pub const MaxAuthorities: u32 = 100_000;
Fedor Sakharov's avatar
Fedor Sakharov committed
431
432
}

433
impl pallet_offences::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
434
	type Event = Event;
435
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
436
	type OnOffenceHandler = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
437
438
}

439
440
441
impl pallet_authority_discovery::Config for Runtime {
	type MaxAuthorities = MaxAuthorities;
}
Fedor Sakharov's avatar
Fedor Sakharov committed
442
443
444
445

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

parameter_types! {
	pub const TransactionByteFee: Balance = 10 * MILLICENTS;
455
456
457
	/// This value increases the priority of `Operational` transactions by adding
	/// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.
	pub const OperationalFeeMultiplier: u8 = 5;
Fedor Sakharov's avatar
Fedor Sakharov committed
458
459
}

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

468
469
470
/// 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
471
472
473
	fn convert(a: AccountId) -> Option<AccountId> {
		Some(a)
	}
474
475
}

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

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

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

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

500
501
	type DisabledValidators = Session;

Fedor Sakharov's avatar
Fedor Sakharov committed
502
503
504
505
	type KeyOwnerProofSystem = Historical;

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

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

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

	type WeightInfo = ();
518
519

	type MaxAuthorities = MaxAuthorities;
Fedor Sakharov's avatar
Fedor Sakharov committed
520
521
522
523
524
525
}

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

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

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

538
impl pallet_grandpa::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
539
540
541
542
543
544
545
546
547
548
549
550
551
	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
552
553
554
555
556
	type HandleEquivocation = pallet_grandpa::EquivocationHandler<
		Self::KeyOwnerIdentification,
		Offences,
		ReportLongevity,
	>;
557
558

	type WeightInfo = ();
559
	type MaxAuthorities = MaxAuthorities;
Fedor Sakharov's avatar
Fedor Sakharov committed
560
561
562
563
564
565
}

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

566
impl pallet_authorship::Config for Runtime {
567
	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
Fedor Sakharov's avatar
Fedor Sakharov committed
568
569
	type UncleGenerations = UncleGenerations;
	type FilterUncle = ();
570
	type EventHandler = ImOnline;
Fedor Sakharov's avatar
Fedor Sakharov committed
571
572
}

573
impl parachains_origin::Config for Runtime {}
574

575
impl parachains_configuration::Config for Runtime {
576
	type WeightInfo = weights::runtime_parachains_configuration::WeightInfo<Runtime>;
577
}
Fedor Sakharov's avatar
Fedor Sakharov committed
578

579
580
impl parachains_shared::Config for Runtime {}

581
582
583
/// Special `RewardValidators` that does nothing ;)
pub struct RewardValidators;
impl runtime_parachains::inclusion::RewardValidators for RewardValidators {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
584
585
	fn reward_backing(_: impl IntoIterator<Item = ValidatorIndex>) {}
	fn reward_bitfields(_: impl IntoIterator<Item = ValidatorIndex>) {}
586
587
}

588
impl parachains_inclusion::Config for Runtime {
Fedor Sakharov's avatar
Fedor Sakharov committed
589
	type Event = Event;
590
	type DisputesHandler = ParasDisputes;
591
	type RewardValidators = RewardValidators;
Fedor Sakharov's avatar
Fedor Sakharov committed
592
593
}

594
impl parachains_paras::Config for Runtime {
595
	type Origin = Origin;
596
	type Event = Event;
597
	type WeightInfo = weights::runtime_parachains_paras::WeightInfo<Runtime>;
598
}
Fedor Sakharov's avatar
Fedor Sakharov committed
599

Shawn Tabrizi's avatar
Shawn Tabrizi committed
600
parameter_types! {
601
	pub const RocLocation: MultiLocation = Here.into();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
602
	pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
603
	pub const Ancestry: MultiLocation = Here.into();
604
	pub CheckAccount: AccountId = XcmPallet::check_account();
Shawn Tabrizi's avatar
Shawn Tabrizi committed
605
606
}

Shawn Tabrizi's avatar
Shawn Tabrizi committed
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
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
622
623

type LocalOriginConverter = (
624
	SovereignSignedViaLocation<SovereignAccountOf, Origin>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
625
626
627
628
629
	ChildParachainAsNative<parachains_origin::Origin, Origin>,
	SignedAccountId32AsNative<RococoNetwork, Origin>,
	ChildSystemParachainAsSuperuser<ParaId, Origin>,
);

Gavin Wood's avatar
Gavin Wood committed
630
parameter_types! {
631
	pub const BaseXcmWeight: Weight = 1_000_000_000;
Gavin Wood's avatar
Gavin Wood committed
632
633
}

Gavin Wood's avatar
Gavin Wood committed
634
635
636
637
/// 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
638
	xcm_sender::ChildParachainRouter<Runtime, xcm::AlwaysRelease>,
Gavin Wood's avatar
Gavin Wood committed
639
640
);

641
parameter_types! {
Gavin Wood's avatar
Gavin Wood committed
642
	pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
643
644
645
646
	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());
Ricardo Rius's avatar
Ricardo Rius committed
647
	pub const RococoForCanvas: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1002).into());
648
	pub const MaxInstructions: u32 = 100;
649
650
651
652
653
}
pub type TrustedTeleporters = (
	xcm_builder::Case<RococoForTick>,
	xcm_builder::Case<RococoForTrick>,
	xcm_builder::Case<RococoForTrack>,
Ricardo Rius's avatar
Ricardo Rius committed
654
	xcm_builder::Case<RococoForStatemint>,
Ricardo Rius's avatar
Ricardo Rius committed
655
	xcm_builder::Case<RococoForCanvas>,
656
657
658
);

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

Shawn Tabrizi's avatar
Shawn Tabrizi committed
669
use xcm_builder::{AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, TakeWeightCredit};
670
671
pub type Barrier = (
	TakeWeightCredit,
672
	AllowTopLevelPaidExecutionFrom<Everything>,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
673
	AllowUnpaidExecutionFrom<IsInVec<AllowUnpaidFrom>>, // <- Trusted parachains get free execution
674
675
);

Shawn Tabrizi's avatar
Shawn Tabrizi committed
676
677
678
pub struct XcmConfig;
impl xcm_executor::Config for XcmConfig {
	type Call = Call;
Gavin Wood's avatar
Gavin Wood committed
679
	type XcmSender = XcmRouter;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
680
681
682
	type AssetTransactor = LocalAssetTransactor;
	type OriginConverter = LocalOriginConverter;
	type IsReserve = ();
683
	type IsTeleporter = TrustedTeleporters;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
684
	type LocationInverter = LocationInverter<Ancestry>;
685
	type Barrier = Barrier;
686
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
687
	type Trader = UsingComponents<WeightToFee, RocLocation, AccountId, Balances, ToAuthor<Runtime>>;
688
689
690
	type ResponseHandler = XcmPallet;
	type AssetTrap = XcmPallet;
	type AssetClaims = XcmPallet;
691
	type SubscriptionService = XcmPallet;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
692
693
}

694
695
696
697
parameter_types! {
	pub const CollectiveBodyId: BodyId = BodyId::Unit;
}

Gavin Wood's avatar
Gavin Wood committed
698
699
700
/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
/// of this chain.
pub type LocalOriginToLocation = (
701
702
	// We allow an origin from the Collective pallet to be used in XCM as a corresponding Plurality of the
	// `Unit` body.
703
704
705
	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
706
707
708
709
710
711
);

impl pallet_xcm::Config for Runtime {
	type Event = Event;
	type SendXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
	type XcmRouter = XcmRouter;
712
713
	// Anyone can execute XCM messages locally...
	type ExecuteXcmOrigin = xcm_builder::EnsureXcmOrigin<Origin, LocalOriginToLocation>;
Gavin Wood's avatar
Gavin Wood committed
714
	// ...but they must match our filter, which right now rejects everything.
715
	type XcmExecuteFilter = Nothing;
Gavin Wood's avatar
Gavin Wood committed
716
	type XcmExecutor = XcmExecutor<XcmConfig>;
717
718
	type XcmTeleportFilter = Everything;
	type XcmReserveTransferFilter = Everything;
719
	type Weigher = FixedWeightBounds<BaseXcmWeight, Call, MaxInstructions>;
720
	type LocationInverter = LocationInverter<Ancestry>;
721
722
	type Origin = Origin;
	type Call = Call;
723
724
	const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
	type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
Gavin Wood's avatar
Gavin Wood committed
725
726
}

727
impl parachains_session_info::Config for Runtime {}
728

Gavin Wood's avatar
Gavin Wood committed
729
730
731
732
parameter_types! {
	pub const FirstMessageFactorPercent: u64 = 100;
}

733
impl parachains_ump::Config for Runtime {
734
735
	type Event = Event;
	type UmpSink = crate::parachains_ump::XcmSink<XcmExecutor<XcmConfig>, Runtime>;
Gavin Wood's avatar
Gavin Wood committed
736
	type FirstMessageFactorPercent = FirstMessageFactorPercent;
737
	type ExecuteOverweightOrigin = EnsureRoot<AccountId>;
738
}
739

740
impl parachains_dmp::Config for Runtime {}
741

742
impl parachains_hrmp::Config for Runtime {
743
	type Event = Event;
744
	type Origin = Origin;
745
	type Currency = Balances;
746
747
}

748
impl parachains_paras_inherent::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
749

750
impl parachains_scheduler::Config for Runtime {}
Fedor Sakharov's avatar
Fedor Sakharov committed
751

752
impl parachains_initializer::Config for Runtime {
753
	type Randomness = pallet_babe::RandomnessFromOneEpochAgo<Runtime>;
754
	type ForceOrigin = EnsureRoot<AccountId>;
755
	type WeightInfo = ();
Fedor Sakharov's avatar
Fedor Sakharov committed
756
}
757

758
impl paras_sudo_wrapper::Config for Runtime {}
759

760
761
762
763
764
parameter_types! {
	pub const ParaDeposit: Balance = 5 * DOLLARS;
	pub const DataDepositPerByte: Balance = deposit(0, 1);
}

765
impl paras_registrar::Config for Runtime {
766
	type Event = Event;
767
	type Origin = Origin;
768
	type Currency = Balances;
769
	type OnSwap = (Crowdloan, Slots);
770
771
772
	type ParaDeposit = ParaDeposit;
	type DataDepositPerByte = DataDepositPerByte;
	type WeightInfo = paras_registrar::TestWeightInfo;
773
}
774

775
776
777
778
/// An insecure randomness beacon that uses the parent block hash as random material.
///
/// THIS SHOULD ONLY BE USED FOR TESTING PURPOSES.
pub struct ParentHashRandomness;
779

780
impl pallet_beefy::Config for Runtime {
Andreas Doerr's avatar
Andreas Doerr committed
781
	type BeefyId = BeefyId;
782
783
784
785
786
787
}

impl pallet_mmr::Config for Runtime {
	const INDEXING_PREFIX: &'static [u8] = b"mmr";
	type Hashing = Keccak256;
	type Hash = <Keccak256 as traits::Hash>::Output;
788
	type OnNewRoot = pallet_beefy_mmr::DepositBeefyDigest<Runtime>;
789
	type WeightInfo = ();
790
791
792
793
794
795
796
797
	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
798
			.filter_map(|id| Paras::para_head(&id).map(|head| (id.into(), head.0)))
799
800
			.collect()
	}
801
802
}

803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
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;
824
825
}

826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
// parameter_types! {
// 	/// This is a pretty unscientific cap.
// 	///
// 	/// Note that once this is hit the pallet will essentially throttle incoming requests down to one
// 	/// call per block.
// 	pub const MaxRequests: u32 = 4 * HOURS as u32;

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

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

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

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

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

// // Instance that is "deployed" at Wococo chain. Responsible for dispatching Rococo -> Wococo messages.
// 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;
// 	type CallFilter = frame_support::traits::Everything;
// 	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;
// }

// // Instance that is "deployed" at Rococo chain. Responsible for dispatching Wococo -> Rococo messages.
// 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;
// 	type CallFilter = frame_support::traits::Everything;
// 	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;
// }

// // Instance that is "deployed" at Wococo chain. Responsible for sending Wococo -> Rococo messages
// // 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;
// 	type MessageDeliveryAndDispatchPayment =
// 		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
// 			Runtime,
// 			pallet_balances::Pallet<Runtime>,
// 			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
// 			RootAccountForPayments,
// 		>;
// 	type OnDeliveryConfirmed = ();

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

// // Instance that is "deployed" at Rococo chain. Responsible for sending Rococo -> Wococo messages
// // 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;
// 	type MessageDeliveryAndDispatchPayment =
// 		pallet_bridge_messages::instant_payments::InstantCurrencyPayments<
// 			Runtime,
// 			pallet_balances::Pallet<Runtime>,
// 			crate::bridge_messages::GetDeliveryConfirmationTransactionFee,
// 			RootAccountForPayments,
// 		>;
// 	type OnDeliveryConfirmed = ();

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

965
impl Randomness<Hash, BlockNumber> for ParentHashRandomness {
966
	fn random(subject: &[u8]) -> (Hash, BlockNumber) {
967
		(
Shawn Tabrizi's avatar
Shawn Tabrizi committed
968
969
970
			(System::parent_hash(), subject)
				.using_encoded(sp_io::hashing::blake2_256)
				.into(),
971
972
			System::block_number(),
		)
973
974
975
	}
}

976
parameter_types! {
977
	pub const EndingPeriod: BlockNumber = 1 * HOURS;
978
979
980
	pub const SampleLength: BlockNumber = 1;
}

981
982
983
impl auctions::Config for Runtime {
	type Event = Event;
	type Leaser = Slots;
984
	type Registrar = Registrar;
985
	type EndingPeriod = EndingPeriod;
986
	type SampleLength = SampleLength;
987
	type Randomness = ParentHashRandomness;
988
989
990
	type InitiateOrigin = EnsureRoot<AccountId>;
	type WeightInfo = auctions::TestWeightInfo;
}
991

992
993
994
parameter_types! {
	pub const LeasePeriod: BlockNumber = 1 * DAYS;
}
995

996
997
998
999
1000
impl slots::Config for Runtime {
	type Event = Event;
	type Currency = Balances;
	type Registrar = Registrar;
	type LeasePeriod = LeasePeriod;
For faster browsing, not all history is shown. View entire blame