lib.rs 55 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
	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,
41
42
43
	Nonce, OccupiedCoreAssumption, PersistedValidationData, ScrapedOnChainVotes,
	SessionInfo as SessionInfoData, Signature, ValidationCode, ValidationCodeHash, ValidatorId,
	ValidatorIndex,
Shawn Tabrizi's avatar
Shawn Tabrizi committed
44
45
46
47
};
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
48
};
Shawn Tabrizi's avatar
Shawn Tabrizi committed
49
use runtime_parachains::{self, runtime_api_impl::v1 as runtime_api_impl};
50
use scale_info::TypeInfo;
Shawn Tabrizi's avatar
Shawn Tabrizi committed
51
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
	transaction_validity::{TransactionPriority, TransactionSource, TransactionValidity},
59
	ApplyExtrinsicResult, KeyTypeId,
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

use runtime_parachains::{
68
69
70
	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
71
72
73
74
	paras_inherent as parachains_paras_inherent, scheduler as parachains_scheduler,
	session_info as parachains_session_info, shared as parachains_shared, ump as parachains_ump,
};

75
76
77
// 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

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;
98
mod weights;
Fedor Sakharov's avatar
Fedor Sakharov committed
99
100
101
102
103

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

249
250
251
252
		// 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,

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

		// Pallet for sending XCM.
Cheng JIANG's avatar
Cheng JIANG committed
258
		XcmPallet: pallet_xcm::{Pallet, Call, Storage, Event<T>, Origin, Config} = 99,
259

260
261
262
	}
}

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

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

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

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

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

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

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

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

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

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

parameter_types! {
	pub const ImOnlineUnsignedPriority: TransactionPriority = TransactionPriority::max_value();
385
386
387
	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
388
389
}

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

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

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

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

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

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

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

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

parameter_types! {
	pub const TransactionByteFee: Balance = 10 * MILLICENTS;
456
457
458
	/// 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
459
460
}

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

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

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

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

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

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

501
502
	type DisabledValidators = Session;

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

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

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

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

	type WeightInfo = ();
519
520

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

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

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

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

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

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

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

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

574
impl parachains_origin::Config for Runtime {}
575

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

580
581
impl parachains_shared::Config for Runtime {}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

728
impl parachains_session_info::Config for Runtime {}
729

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

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

741
impl parachains_dmp::Config for Runtime {}
742

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

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

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

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

759
impl paras_sudo_wrapper::Config for Runtime {}
760

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

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

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

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

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

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

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

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

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

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

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