lib.rs 33.7 KB
Newer Older
ddorgan's avatar
ddorgan committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2017-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/>.

//! The Polkadot runtime. This can be compiled with `#[no_std]`, ready for Wasm.

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

use sp_std::prelude::*;
use codec::{Encode, Decode};
25
use primitives::v1::{
26
27
28
	AccountId, AccountIndex, Balance, BlockNumber, CandidateEvent, CommittedCandidateReceipt,
	CoreState, GroupRotationInfo, Hash, Id, Moment, Nonce, OccupiedCoreAssumption,
	PersistedValidationData, Signature, ValidationCode, ValidationData, ValidatorId, ValidatorIndex,
ddorgan's avatar
ddorgan committed
29
};
30
use runtime_common::{
31
32
	SlowAdjustingFeeUpdate, CurrencyToVote,
	impls::ToAuthor,
ddorgan's avatar
ddorgan committed
33
	BlockHashCount, MaximumBlockWeight, AvailableBlockRatio, MaximumBlockLength,
Gavin Wood's avatar
Gavin Wood committed
34
	BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, MaximumExtrinsicWeight,
35
	ParachainSessionKeyPlaceholder,
ddorgan's avatar
ddorgan committed
36
37
38
};
use sp_runtime::{
	create_runtime_str, generic, impl_opaque_keys,
39
	ApplyExtrinsicResult, KeyTypeId, Perbill, curve::PiecewiseLinear,
Gavin Wood's avatar
Gavin Wood committed
40
	transaction_validity::{TransactionValidity, TransactionSource, TransactionPriority},
ddorgan's avatar
ddorgan committed
41
	traits::{
Gavin Wood's avatar
Gavin Wood committed
42
43
		BlakeTwo256, Block as BlockT, OpaqueKeys, ConvertInto, IdentityLookup,
		Extrinsic as ExtrinsicT, SaturatedConversion, Verify,
ddorgan's avatar
ddorgan committed
44
45
46
47
	},
};
#[cfg(feature = "runtime-benchmarks")]
use sp_runtime::RuntimeString;
48
49
use sp_version::RuntimeVersion;
use pallet_grandpa::{AuthorityId as GrandpaId, fg_primitives};
ddorgan's avatar
ddorgan committed
50
#[cfg(any(feature = "std", test))]
51
use sp_version::NativeVersion;
ddorgan's avatar
ddorgan committed
52
53
use sp_core::OpaqueMetadata;
use sp_staking::SessionIndex;
54
use frame_support::{
55
	parameter_types, construct_runtime, debug, RuntimeDebug,
56
	traits::{KeyOwnerProofSystem, Randomness, Filter, InstanceFilter},
57
	weights::Weight,
58
};
59
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
ddorgan's avatar
ddorgan committed
60
use authority_discovery_primitives::AuthorityId as AuthorityDiscoveryId;
61
62
use pallet_transaction_payment_rpc_runtime_api::RuntimeDispatchInfo;
use pallet_session::historical as session_historical;
63
use frame_system::{EnsureRoot};
ddorgan's avatar
ddorgan committed
64
65

#[cfg(feature = "std")]
66
pub use pallet_staking::StakerStatus;
ddorgan's avatar
ddorgan committed
67
68
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
69
70
pub use pallet_timestamp::Call as TimestampCall;
pub use pallet_balances::Call as BalancesCall;
ddorgan's avatar
ddorgan committed
71
72
73
74
75

/// Constant values used within the runtime.
pub mod constants;
use constants::{time::*, currency::*, fee::*};

76
77
78
// Weights used in the runtime
mod weights;

ddorgan's avatar
ddorgan committed
79
80
81
82
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));

83
/// Runtime version (Westend).
ddorgan's avatar
ddorgan committed
84
85
86
87
pub const VERSION: RuntimeVersion = RuntimeVersion {
	spec_name: create_runtime_str!("westend"),
	impl_name: create_runtime_str!("parity-westend"),
	authoring_version: 2,
88
	spec_version: 45,
89
	impl_version: 1,
90
	#[cfg(not(feature = "disable-runtime-api"))]
ddorgan's avatar
ddorgan committed
91
	apis: RUNTIME_API_VERSIONS,
92
	#[cfg(feature = "disable-runtime-api")]
93
94
	apis: version::create_apis_vec![[]],
	transaction_version: 3,
ddorgan's avatar
ddorgan committed
95
96
97
98
99
100
101
102
103
104
105
};

/// Native version.
#[cfg(any(feature = "std", test))]
pub fn native_version() -> NativeVersion {
	NativeVersion {
		runtime_version: VERSION,
		can_author_with: Default::default(),
	}
}

106
/// Accept all transactions.
107
108
pub struct BaseFilter;
impl Filter<Call> for BaseFilter {
109
110
	fn filter(_: &Call) -> bool {
		true
ddorgan's avatar
ddorgan committed
111
112
113
114
115
116
117
	}
}

parameter_types! {
	pub const Version: RuntimeVersion = VERSION;
}

118
impl frame_system::Trait for Runtime {
119
	type BaseCallFilter = BaseFilter;
ddorgan's avatar
ddorgan committed
120
121
122
123
124
125
126
127
128
129
130
131
	type Origin = Origin;
	type Call = Call;
	type Index = Nonce;
	type BlockNumber = BlockNumber;
	type Hash = Hash;
	type Hashing = BlakeTwo256;
	type AccountId = AccountId;
	type Lookup = IdentityLookup<Self::AccountId>;
	type Header = generic::Header<BlockNumber, BlakeTwo256>;
	type Event = Event;
	type BlockHashCount = BlockHashCount;
	type MaximumBlockWeight = MaximumBlockWeight;
132
133
	type DbWeight = RocksDbWeight;
	type BlockExecutionWeight = BlockExecutionWeight;
134
	type ExtrinsicBaseWeight = ExtrinsicBaseWeight;
Tomasz Drwięga's avatar
Tomasz Drwięga committed
135
	type MaximumExtrinsicWeight = MaximumExtrinsicWeight;
ddorgan's avatar
ddorgan committed
136
137
138
	type MaximumBlockLength = MaximumBlockLength;
	type AvailableBlockRatio = AvailableBlockRatio;
	type Version = Version;
139
	type PalletInfo = PalletInfo;
140
	type AccountData = pallet_balances::AccountData<Balance>;
ddorgan's avatar
ddorgan committed
141
142
	type OnNewAccount = ();
	type OnKilledAccount = ();
143
	type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
144
145
}

146
147
148
149
parameter_types! {
	pub const MaxScheduledPerBlock: u32 = 50;
}

150
impl pallet_scheduler::Trait for Runtime {
ddorgan's avatar
ddorgan committed
151
152
	type Event = Event;
	type Origin = Origin;
153
	type PalletsOrigin = OriginCaller;
ddorgan's avatar
ddorgan committed
154
155
	type Call = Call;
	type MaximumWeight = MaximumBlockWeight;
156
	type ScheduleOrigin = EnsureRoot<AccountId>;
157
	type MaxScheduledPerBlock = MaxScheduledPerBlock;
158
	type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
159
160
161
162
163
164
165
}

parameter_types! {
	pub const EpochDuration: u64 = EPOCH_DURATION_IN_BLOCKS as u64;
	pub const ExpectedBlockTime: Moment = MILLISECS_PER_BLOCK;
}

166
impl pallet_babe::Trait for Runtime {
ddorgan's avatar
ddorgan committed
167
168
169
170
	type EpochDuration = EpochDuration;
	type ExpectedBlockTime = ExpectedBlockTime;

	// session module is the trigger
171
	type EpochChangeTrigger = pallet_babe::ExternalTrigger;
172
173
174
175
176

	type KeyOwnerProofSystem = Historical;

	type KeyOwnerProof = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
177
		pallet_babe::AuthorityId,
178
179
180
181
	)>>::Proof;

	type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(
		KeyTypeId,
182
		pallet_babe::AuthorityId,
183
184
185
	)>>::IdentificationTuple;

	type HandleEquivocation =
186
		pallet_babe::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
187
188

	type WeightInfo = ();
ddorgan's avatar
ddorgan committed
189
190
191
192
193
194
}

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

195
impl pallet_indices::Trait for Runtime {
ddorgan's avatar
ddorgan committed
196
197
198
199
	type AccountIndex = AccountIndex;
	type Currency = Balances;
	type Deposit = IndexDeposit;
	type Event = Event;
200
	type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
201
202
203
204
}

parameter_types! {
	pub const ExistentialDeposit: Balance = 1 * CENTS;
205
	pub const MaxLocks: u32 = 50;
ddorgan's avatar
ddorgan committed
206
207
}

208
impl pallet_balances::Trait for Runtime {
ddorgan's avatar
ddorgan committed
209
210
211
212
213
	type Balance = Balance;
	type DustRemoval = ();
	type Event = Event;
	type ExistentialDeposit = ExistentialDeposit;
	type AccountStore = System;
214
	type MaxLocks = MaxLocks;
215
	type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
216
217
218
219
220
221
}

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

222
impl pallet_transaction_payment::Trait for Runtime {
ddorgan's avatar
ddorgan committed
223
224
225
226
	type Currency = Balances;
	type OnTransactionPayment = ToAuthor<Runtime>;
	type TransactionByteFee = TransactionByteFee;
	type WeightToFee = WeightToFee;
227
	type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
ddorgan's avatar
ddorgan committed
228
229
230
231
232
}

parameter_types! {
	pub const MinimumPeriod: u64 = SLOT_DURATION / 2;
}
233
impl pallet_timestamp::Trait for Runtime {
ddorgan's avatar
ddorgan committed
234
235
236
	type Moment = u64;
	type OnTimestampSet = Babe;
	type MinimumPeriod = MinimumPeriod;
237
	type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
238
239
240
241
242
243
244
}

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

// TODO: substrate#2986 implement this properly
245
246
impl pallet_authorship::Trait for Runtime {
	type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Babe>;
ddorgan's avatar
ddorgan committed
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
	type UncleGenerations = UncleGenerations;
	type FilterUncle = ();
	type EventHandler = (Staking, ImOnline);
}

parameter_types! {
	pub const Period: BlockNumber = 10 * MINUTES;
	pub const Offset: BlockNumber = 0;
}

impl_opaque_keys! {
	pub struct SessionKeys {
		pub grandpa: Grandpa,
		pub babe: Babe,
		pub im_online: ImOnline,
262
		pub parachain_validator: ParachainSessionKeyPlaceholder<Runtime>,
ddorgan's avatar
ddorgan committed
263
264
265
266
267
268
269
270
		pub authority_discovery: AuthorityDiscovery,
	}
}

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

271
impl pallet_session::Trait for Runtime {
ddorgan's avatar
ddorgan committed
272
273
	type Event = Event;
	type ValidatorId = AccountId;
274
	type ValidatorIdOf = pallet_staking::StashOf<Self>;
ddorgan's avatar
ddorgan committed
275
276
	type ShouldEndSession = Babe;
	type NextSessionRotation = Babe;
277
	type SessionManager = pallet_session::historical::NoteHistoricalRoot<Self, Staking>;
ddorgan's avatar
ddorgan committed
278
279
280
	type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
	type Keys = SessionKeys;
	type DisabledValidatorsThreshold = DisabledValidatorsThreshold;
281
	type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
282
283
}

284
285
286
impl pallet_session::historical::Trait for Runtime {
	type FullIdentification = pallet_staking::Exposure<AccountId, Balance>;
	type FullIdentificationOf = pallet_staking::ExposureOf<Runtime>;
ddorgan's avatar
ddorgan committed
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
}

pallet_staking_reward_curve::build! {
	const REWARD_CURVE: PiecewiseLinear<'static> = curve!(
		min_inflation: 0_025_000,
		max_inflation: 0_100_000,
		ideal_stake: 0_500_000,
		falloff: 0_050_000,
		max_piece_count: 40,
		test_precision: 0_005_000,
	);
}

parameter_types! {
	// Six sessions in an era (6 hours).
	pub const SessionsPerEra: SessionIndex = 6;
	// 28 eras for unbonding (7 days).
304
	pub const BondingDuration: pallet_staking::EraIndex = 28;
305
	// 27 eras in which slashes can be cancelled (slightly less than 7 days).
306
	pub const SlashDeferDuration: pallet_staking::EraIndex = 27;
ddorgan's avatar
ddorgan committed
307
308
309
310
	pub const RewardCurve: &'static PiecewiseLinear<'static> = &REWARD_CURVE;
	pub const MaxNominatorRewardedPerValidator: u32 = 64;
	// quarter of the last session will be for election.
	pub const ElectionLookahead: BlockNumber = EPOCH_DURATION_IN_BLOCKS / 4;
311
	pub const MaxIterations: u32 = 10;
312
	pub MinSolutionScoreBump: Perbill = Perbill::from_rational_approximation(5u32, 10_000);
313
314
315
	pub OffchainSolutionWeightLimit: Weight = MaximumExtrinsicWeight::get()
		.saturating_sub(BlockExecutionWeight::get())
		.saturating_sub(ExtrinsicBaseWeight::get());
ddorgan's avatar
ddorgan committed
316
317
}

318
impl pallet_staking::Trait for Runtime {
ddorgan's avatar
ddorgan committed
319
320
	type Currency = Balances;
	type UnixTime = Timestamp;
321
	type CurrencyToVote = CurrencyToVote;
ddorgan's avatar
ddorgan committed
322
323
324
325
326
327
328
329
	type RewardRemainder = ();
	type Event = Event;
	type Slash = ();
	type Reward = ();
	type SessionsPerEra = SessionsPerEra;
	type BondingDuration = BondingDuration;
	type SlashDeferDuration = SlashDeferDuration;
	// A majority of the council can cancel the slash.
330
	type SlashCancelOrigin = EnsureRoot<AccountId>;
ddorgan's avatar
ddorgan committed
331
332
333
334
335
336
337
	type SessionInterface = Self;
	type RewardCurve = RewardCurve;
	type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
	type NextNewSession = Session;
	type ElectionLookahead = ElectionLookahead;
	type Call = Call;
	type UnsignedPriority = StakingUnsignedPriority;
338
	type MaxIterations = MaxIterations;
339
	type MinSolutionScoreBump = MinSolutionScoreBump;
340
	type OffchainSolutionWeightLimit = OffchainSolutionWeightLimit;
341
	type WeightInfo = weights::pallet_staking::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
342
343
344
345
346
347
348
349
350
351
352
353
354
355
}

parameter_types! {
	pub const LaunchPeriod: BlockNumber = 7 * DAYS;
	pub const VotingPeriod: BlockNumber = 7 * DAYS;
	pub const FastTrackVotingPeriod: BlockNumber = 3 * HOURS;
	pub const MinimumDeposit: Balance = 1 * DOLLARS;
	pub const EnactmentPeriod: BlockNumber = 8 * DAYS;
	pub const CooloffPeriod: BlockNumber = 7 * DAYS;
	// One cent: $10,000 / MB
	pub const PreimageByteDeposit: Balance = 10 * MILLICENTS;
	pub const InstantAllowed: bool = true;
}

356
parameter_types! {
357
	pub OffencesWeightSoftLimit: Weight = Perbill::from_percent(60) * MaximumBlockWeight::get();
358
359
}

360
impl pallet_offences::Trait for Runtime {
ddorgan's avatar
ddorgan committed
361
	type Event = Event;
362
	type IdentificationTuple = pallet_session::historical::IdentificationTuple<Self>;
ddorgan's avatar
ddorgan committed
363
	type OnOffenceHandler = Staking;
364
	type WeightSoftLimit = OffencesWeightSoftLimit;
ddorgan's avatar
ddorgan committed
365
366
}

367
impl pallet_authority_discovery::Trait for Runtime {}
ddorgan's avatar
ddorgan committed
368
369
370
371
372
373
374
375
376
377

parameter_types! {
	pub const SessionDuration: BlockNumber = EPOCH_DURATION_IN_BLOCKS as _;
}

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

378
impl pallet_im_online::Trait for Runtime {
ddorgan's avatar
ddorgan committed
379
380
381
382
383
	type AuthorityId = ImOnlineId;
	type Event = Event;
	type ReportUnresponsiveness = Offences;
	type SessionDuration = SessionDuration;
	type UnsignedPriority = StakingUnsignedPriority;
384
	type WeightInfo = weights::pallet_im_online::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
385
386
}

387
impl pallet_grandpa::Trait for Runtime {
ddorgan's avatar
ddorgan committed
388
	type Event = Event;
389
390
391
392
393
394
395
396
397
398
399
400
	type Call = Call;

	type KeyOwnerProofSystem = Historical;

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

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

401
	type HandleEquivocation = pallet_grandpa::EquivocationHandler<Self::KeyOwnerIdentification, Offences>;
402
403

	type WeightInfo = ();
ddorgan's avatar
ddorgan committed
404
405
406
}

parameter_types! {
407
408
	pub WindowSize: BlockNumber = pallet_finality_tracker::DEFAULT_WINDOW_SIZE.into();
	pub ReportLatency: BlockNumber = pallet_finality_tracker::DEFAULT_REPORT_LATENCY.into();
ddorgan's avatar
ddorgan committed
409
410
}

411
impl pallet_finality_tracker::Trait for Runtime {
ddorgan's avatar
ddorgan committed
412
413
414
415
416
	type OnFinalizationStalled = ();
	type WindowSize = WindowSize;
	type ReportLatency = ReportLatency;
}

417
418
/// Submits a transaction with the node's public and signature type. Adheres to the signed extension
/// format of the chain.
419
impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for Runtime where
420
421
	Call: From<LocalCall>,
{
422
	fn create_transaction<C: frame_system::offchain::AppCrypto<Self::Public, Self::Signature>>(
423
424
425
		call: Call,
		public: <Signature as Verify>::Signer,
		account: AccountId,
426
		nonce: <Runtime as frame_system::Trait>::Index,
427
	) -> Option<(Call, <UncheckedExtrinsic as ExtrinsicT>::SignaturePayload)> {
428
		// take the biggest period possible.
429
430
431
432
433
434
435
		let period = BlockHashCount::get()
			.checked_next_power_of_two()
			.map(|c| c / 2)
			.unwrap_or(2) as u64;

		let current_block = System::block_number()
			.saturated_into::<u64>()
436
437
			// The `System::block_number` is initialized with `n+1`,
			// so the actual block number is `n`.
438
439
440
			.saturating_sub(1);
		let tip = 0;
		let extra: SignedExtra = (
441
442
443
444
445
446
447
			frame_system::CheckSpecVersion::<Runtime>::new(),
			frame_system::CheckTxVersion::<Runtime>::new(),
			frame_system::CheckGenesis::<Runtime>::new(),
			frame_system::CheckMortality::<Runtime>::from(generic::Era::mortal(period, current_block)),
			frame_system::CheckNonce::<Runtime>::from(nonce),
			frame_system::CheckWeight::<Runtime>::new(),
			pallet_transaction_payment::ChargeTransactionPayment::<Runtime>::from(tip),
448
449
		);
		let raw_payload = SignedPayload::new(call, extra).map_err(|e| {
450
			debug::warn!("Unable to create signed payload: {:?}", e);
451
		}).ok()?;
452
453
454
		let signature = raw_payload.using_encoded(|payload| {
			C::sign(payload, public)
		})?;
455
456
457
		let (call, extra, _) = raw_payload.deconstruct();
		Some((call, (account, signature, extra)))
	}
ddorgan's avatar
ddorgan committed
458
459
}

460
impl frame_system::offchain::SigningTypes for Runtime {
461
462
463
464
	type Public = <Signature as Verify>::Signer;
	type Signature = Signature;
}

465
impl<C> frame_system::offchain::SendTransactionTypes<C> for Runtime where
466
467
468
469
470
471
	Call: From<C>,
{
	type OverarchingCall = Call;
	type Extrinsic = UncheckedExtrinsic;
}

ddorgan's avatar
ddorgan committed
472
473
474
475
476
477
478
parameter_types! {
	// Minimum 100 bytes/KSM deposited (1 CENT/byte)
	pub const BasicDeposit: Balance = 10 * DOLLARS;       // 258 bytes on-chain
	pub const FieldDeposit: Balance = 250 * CENTS;        // 66 bytes on-chain
	pub const SubAccountDeposit: Balance = 2 * DOLLARS;   // 53 bytes on-chain
	pub const MaxSubAccounts: u32 = 100;
	pub const MaxAdditionalFields: u32 = 100;
479
	pub const MaxRegistrars: u32 = 20;
ddorgan's avatar
ddorgan committed
480
481
}

482
impl pallet_identity::Trait for Runtime {
ddorgan's avatar
ddorgan committed
483
484
485
486
487
488
489
490
	type Event = Event;
	type Currency = Balances;
	type Slashed = ();
	type BasicDeposit = BasicDeposit;
	type FieldDeposit = FieldDeposit;
	type SubAccountDeposit = SubAccountDeposit;
	type MaxSubAccounts = MaxSubAccounts;
	type MaxAdditionalFields = MaxAdditionalFields;
491
	type MaxRegistrars = MaxRegistrars;
492
493
	type RegistrarOrigin = frame_system::EnsureRoot<AccountId>;
	type ForceOrigin = frame_system::EnsureRoot<AccountId>;
494
	type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
495
496
}

497
impl pallet_utility::Trait for Runtime {
498
499
	type Event = Event;
	type Call = Call;
500
	type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
501
502
}

ddorgan's avatar
ddorgan committed
503
parameter_types! {
504
505
	// One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
	pub const DepositBase: Balance = deposit(1, 88);
ddorgan's avatar
ddorgan committed
506
	// Additional storage item size of 32 bytes.
507
	pub const DepositFactor: Balance = deposit(0, 32);
ddorgan's avatar
ddorgan committed
508
509
510
	pub const MaxSignatories: u16 = 100;
}

511
impl pallet_multisig::Trait for Runtime {
ddorgan's avatar
ddorgan committed
512
513
514
	type Event = Event;
	type Call = Call;
	type Currency = Balances;
515
516
	type DepositBase = DepositBase;
	type DepositFactor = DepositFactor;
ddorgan's avatar
ddorgan committed
517
	type MaxSignatories = MaxSignatories;
518
	type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
519
520
521
522
523
524
525
526
527
}

parameter_types! {
	pub const ConfigDepositBase: Balance = 5 * DOLLARS;
	pub const FriendDepositFactor: Balance = 50 * CENTS;
	pub const MaxFriends: u16 = 9;
	pub const RecoveryDeposit: Balance = 5 * DOLLARS;
}

528
impl pallet_recovery::Trait for Runtime {
ddorgan's avatar
ddorgan committed
529
530
531
532
533
534
535
536
537
538
539
540
541
	type Event = Event;
	type Call = Call;
	type Currency = Balances;
	type ConfigDepositBase = ConfigDepositBase;
	type FriendDepositFactor = FriendDepositFactor;
	type MaxFriends = MaxFriends;
	type RecoveryDeposit = RecoveryDeposit;
}

parameter_types! {
	pub const MinVestedTransfer: Balance = 100 * DOLLARS;
}

542
impl pallet_vesting::Trait for Runtime {
ddorgan's avatar
ddorgan committed
543
544
545
546
	type Event = Event;
	type Currency = Balances;
	type BlockNumberToBalance = ConvertInto;
	type MinVestedTransfer = MinVestedTransfer;
547
	type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
ddorgan's avatar
ddorgan committed
548
549
}

550
impl pallet_sudo::Trait for Runtime {
ddorgan's avatar
ddorgan committed
551
552
553
554
	type Event = Event;
	type Call = Call;
}

555
556
557
558
559
560
parameter_types! {
	// One storage item; key size 32, value size 8; .
	pub const ProxyDepositBase: Balance = deposit(1, 8);
	// Additional storage item size of 33 bytes.
	pub const ProxyDepositFactor: Balance = deposit(0, 33);
	pub const MaxProxies: u16 = 32;
561
562
563
	pub const AnnouncementDepositBase: Balance = deposit(1, 8);
	pub const AnnouncementDepositFactor: Balance = deposit(0, 66);
	pub const MaxPending: u16 = 32;
564
565
566
567
568
569
570
571
}

/// The type used to represent the kinds of proxying allowed.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug)]
pub enum ProxyType {
	Any,
	NonTransfer,
	Staking,
572
	SudoBalances,
Chevdor's avatar
Chevdor committed
573
	IdentityJudgement,
574
575
576
577
578
579
}
impl Default for ProxyType { fn default() -> Self { Self::Any } }
impl InstanceFilter<Call> for ProxyType {
	fn filter(&self, c: &Call) -> bool {
		match self {
			ProxyType::Any => true,
580
581
582
583
			ProxyType::NonTransfer => matches!(c,
				Call::System(..) |
				Call::Babe(..) |
				Call::Timestamp(..) |
584
585
586
				Call::Indices(pallet_indices::Call::claim(..)) |
				Call::Indices(pallet_indices::Call::free(..)) |
				Call::Indices(pallet_indices::Call::freeze(..)) |
587
588
589
590
591
592
593
594
595
596
597
598
				// Specifically omitting Indices `transfer`, `force_transfer`
				// Specifically omitting the entire Balances pallet
				Call::Authorship(..) |
				Call::Staking(..) |
				Call::Offences(..) |
				Call::Session(..) |
				Call::FinalityTracker(..) |
				Call::Grandpa(..) |
				Call::ImOnline(..) |
				Call::AuthorityDiscovery(..) |
				Call::Utility(..) |
				Call::Identity(..) |
599
600
601
602
603
604
				Call::Recovery(pallet_recovery::Call::as_recovered(..)) |
				Call::Recovery(pallet_recovery::Call::vouch_recovery(..)) |
				Call::Recovery(pallet_recovery::Call::claim_recovery(..)) |
				Call::Recovery(pallet_recovery::Call::close_recovery(..)) |
				Call::Recovery(pallet_recovery::Call::remove_recovery(..)) |
				Call::Recovery(pallet_recovery::Call::cancel_recovered(..)) |
605
				// Specifically omitting Recovery `create_recovery`, `initiate_recovery`
606
607
				Call::Vesting(pallet_vesting::Call::vest(..)) |
				Call::Vesting(pallet_vesting::Call::vest_other(..)) |
608
609
610
611
612
				// Specifically omitting Vesting `vested_transfer`, and `force_vested_transfer`
				Call::Scheduler(..) |
				// Specifically omitting Sudo pallet
				Call::Proxy(..) |
				Call::Multisig(..)
613
614
			),
			ProxyType::Staking => matches!(c,
Gavin Wood's avatar
Gavin Wood committed
615
				Call::Staking(..) | Call::Utility(..)
616
			),
617
			ProxyType::SudoBalances => match c {
618
				Call::Sudo(pallet_sudo::Call::sudo(ref x)) => matches!(x.as_ref(), &Call::Balances(..)),
Gavin Wood's avatar
Gavin Wood committed
619
				Call::Utility(..) => true,
620
621
				_ => false,
			},
Chevdor's avatar
Chevdor committed
622
			ProxyType::IdentityJudgement => matches!(c,
623
624
				Call::Identity(pallet_identity::Call::provide_judgement(..))
				| Call::Utility(pallet_utility::Call::batch(..))
Chevdor's avatar
Chevdor committed
625
			)
626
627
628
629
630
631
632
633
634
		}
	}
	fn is_superset(&self, o: &Self) -> bool {
		match (self, o) {
			(x, y) if x == y => true,
			(ProxyType::Any, _) => true,
			(_, ProxyType::Any) => false,
			(ProxyType::NonTransfer, _) => true,
			_ => false,
635
636
637
638
		}
	}
}

639
impl pallet_proxy::Trait for Runtime {
640
641
642
643
644
645
646
	type Event = Event;
	type Call = Call;
	type Currency = Balances;
	type ProxyType = ProxyType;
	type ProxyDepositBase = ProxyDepositBase;
	type ProxyDepositFactor = ProxyDepositFactor;
	type MaxProxies = MaxProxies;
647
	type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
648
649
650
651
	type MaxPending = MaxPending;
	type CallHasher = BlakeTwo256;
	type AnnouncementDepositBase = AnnouncementDepositBase;
	type AnnouncementDepositFactor = AnnouncementDepositFactor;
652
653
}

ddorgan's avatar
ddorgan committed
654
655
656
construct_runtime! {
	pub enum Runtime where
		Block = Block,
657
		NodeBlock = primitives::v1::Block,
ddorgan's avatar
ddorgan committed
658
659
660
		UncheckedExtrinsic = UncheckedExtrinsic
	{
		// Basic stuff; balances is uncallable initially.
661
662
		System: frame_system::{Module, Call, Storage, Config, Event<T>} = 0,
		RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Module, Storage} = 25,
ddorgan's avatar
ddorgan committed
663
664

		// Must be before session.
665
		Babe: pallet_babe::{Module, Call, Storage, Config, Inherent, ValidateUnsigned} = 1,
ddorgan's avatar
ddorgan committed
666

667
668
669
670
		Timestamp: pallet_timestamp::{Module, Call, Storage, Inherent} = 2,
		Indices: pallet_indices::{Module, Call, Storage, Config<T>, Event<T>} = 3,
		Balances: pallet_balances::{Module, Call, Storage, Config<T>, Event<T>} = 4,
		TransactionPayment: pallet_transaction_payment::{Module, Storage} = 26,
ddorgan's avatar
ddorgan committed
671
672

		// Consensus support.
673
674
675
676
677
678
679
680
681
		Authorship: pallet_authorship::{Module, Call, Storage} = 5,
		Staking: pallet_staking::{Module, Call, Storage, Config<T>, Event<T>, ValidateUnsigned} = 6,
		Offences: pallet_offences::{Module, Call, Storage, Event} = 7,
		Historical: session_historical::{Module} = 27,
		Session: pallet_session::{Module, Call, Storage, Event, Config<T>} = 8,
		FinalityTracker: pallet_finality_tracker::{Module, Call, Storage, Inherent} = 9,
		Grandpa: pallet_grandpa::{Module, Call, Storage, Config, Event, ValidateUnsigned} = 10,
		ImOnline: pallet_im_online::{Module, Call, Storage, Event<T>, ValidateUnsigned, Config<T>} = 11,
		AuthorityDiscovery: pallet_authority_discovery::{Module, Call, Config} = 12,
ddorgan's avatar
ddorgan committed
682
683

		// Utility module.
684
		Utility: pallet_utility::{Module, Call, Event} = 16,
ddorgan's avatar
ddorgan committed
685
686

		// Less simple identity module.
687
		Identity: pallet_identity::{Module, Call, Storage, Event<T>} = 17,
ddorgan's avatar
ddorgan committed
688
689

		// Social recovery module.
690
		Recovery: pallet_recovery::{Module, Call, Storage, Event<T>} = 18,
ddorgan's avatar
ddorgan committed
691
692

		// Vesting. Usable initially, but removed once all vesting is finished.
693
		Vesting: pallet_vesting::{Module, Call, Storage, Event<T>, Config<T>} = 19,
ddorgan's avatar
ddorgan committed
694
695

		// System scheduler.
696
		Scheduler: pallet_scheduler::{Module, Call, Storage, Event<T>} = 20,
ddorgan's avatar
ddorgan committed
697
698

		// Sudo.
699
		Sudo: pallet_sudo::{Module, Call, Storage, Event<T>, Config<T>} = 21,
700
701

		// Proxy module. Late addition.
702
		Proxy: pallet_proxy::{Module, Call, Storage, Event<T>} = 22,
703
704

		// Multisig module. Late addition.
705
		Multisig: pallet_multisig::{Module, Call, Storage, Event<T>} = 23,
ddorgan's avatar
ddorgan committed
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
	}
}

/// The address format for describing accounts.
pub type Address = AccountId;
/// Block header type as expected by this runtime.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Block type as expected by this runtime.
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// A Block signed with a Justification
pub type SignedBlock = generic::SignedBlock<Block>;
/// BlockId type as expected by this runtime.
pub type BlockId = generic::BlockId<Block>;
/// The SignedExtension to the basic transaction logic.
pub type SignedExtra = (
721
722
723
724
725
726
727
	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>,
ddorgan's avatar
ddorgan committed
728
729
730
731
732
733
);
/// Unchecked extrinsic type as expected by this runtime.
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
/// Extrinsic type that has already been checked.
pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Nonce, Call>;
/// Executive: handles dispatch to the various modules.
734
735
736
737
738
739
740
741
pub type Executive = frame_executive::Executive<
	Runtime,
	Block,
	frame_system::ChainContext<Runtime>,
	Runtime,
	AllModules,
	CustomOnRuntimeUpgrade,
>;
742
743
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
ddorgan's avatar
ddorgan committed
744

745
746
747
pub struct CustomOnRuntimeUpgrade;
impl frame_support::traits::OnRuntimeUpgrade for CustomOnRuntimeUpgrade {
	fn on_runtime_upgrade() -> frame_support::weights::Weight {
Shawn Tabrizi's avatar
Shawn Tabrizi committed
748
		0
749
750
751
	}
}

752
#[cfg(not(feature = "disable-runtime-api"))]
ddorgan's avatar
ddorgan committed
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
sp_api::impl_runtime_apis! {
	impl sp_api::Core<Block> for Runtime {
		fn version() -> RuntimeVersion {
			VERSION
		}

		fn execute_block(block: Block) {
			Executive::execute_block(block)
		}

		fn initialize_block(header: &<Block as BlockT>::Header) {
			Executive::initialize_block(header)
		}
	}

	impl sp_api::Metadata<Block> for Runtime {
		fn metadata() -> OpaqueMetadata {
			Runtime::metadata().into()
		}
	}

	impl block_builder_api::BlockBuilder<Block> for Runtime {
		fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {
			Executive::apply_extrinsic(extrinsic)
		}

		fn finalize_block() -> <Block as BlockT>::Header {
			Executive::finalize_block()
		}

		fn inherent_extrinsics(data: inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {
			data.create_extrinsics()
		}

		fn check_inherents(
			block: Block,
			data: inherents::InherentData,
		) -> inherents::CheckInherentsResult {
			data.check_extrinsics(&block)
		}

		fn random_seed() -> <Block as BlockT>::Hash {
			RandomnessCollectiveFlip::random_seed()
		}
	}

	impl tx_pool_api::runtime_api::TaggedTransactionQueue<Block> for Runtime {
		fn validate_transaction(
			source: TransactionSource,
			tx: <Block as BlockT>::Extrinsic,
		) -> TransactionValidity {
			Executive::validate_transaction(source, tx)
		}
	}

	impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
		fn offchain_worker(header: &<Block as BlockT>::Header) {
			Executive::offchain_worker(header)
		}
	}

814
815
816
	impl primitives::v1::ParachainHost<Block, Hash, BlockNumber> for Runtime {
		fn validators() -> Vec<ValidatorId> {
			Vec::new()
ddorgan's avatar
ddorgan committed
817
		}
818
819
820

		fn validator_groups() -> (Vec<Vec<ValidatorIndex>>, GroupRotationInfo<BlockNumber>) {
			(Vec::new(), GroupRotationInfo { session_start_block: 0, group_rotation_frequency: 0, now: 0 })
ddorgan's avatar
ddorgan committed
821
		}
822
823

		fn availability_cores() -> Vec<CoreState<BlockNumber>> {
824
			Vec::new()
ddorgan's avatar
ddorgan committed
825
		}
826
827
828

		fn full_validation_data(_: Id, _: OccupiedCoreAssumption)
			-> Option<ValidationData<BlockNumber>> {
829
			None
ddorgan's avatar
ddorgan committed
830
		}
831
832
833

		fn persisted_validation_data(_: Id, _: OccupiedCoreAssumption)
			-> Option<PersistedValidationData<BlockNumber>> {
834
			None
ddorgan's avatar
ddorgan committed
835
		}
836
837
838
839
840
841

		fn session_index_for_child() -> SessionIndex {
			0
		}

		fn validation_code(_: Id, _: OccupiedCoreAssumption) -> Option<ValidationCode> {
842
			None
ddorgan's avatar
ddorgan committed
843
		}
844
845
846

		fn candidate_pending_availability(_: Id) -> Option<CommittedCandidateReceipt<Hash>> {
			None
ddorgan's avatar
ddorgan committed
847
		}
848
849

		fn candidate_events() -> Vec<CandidateEvent<Hash>> {
850
			Vec::new()
851
		}
852
853
854
855

		fn validator_discovery(_: Vec<ValidatorId>) -> Vec<Option<AuthorityDiscoveryId>> {
			Vec::new()
		}
ddorgan's avatar
ddorgan committed
856
857
858
859
860
861
	}

	impl fg_primitives::GrandpaApi<Block> for Runtime {
		fn grandpa_authorities() -> Vec<(GrandpaId, u64)> {
			Grandpa::grandpa_authorities()
		}
862

863
		fn submit_report_equivocation_unsigned_extrinsic(
864
865
866
867
868
869
870
871
			equivocation_proof: fg_primitives::EquivocationProof<
				<Block as BlockT>::Hash,
				sp_runtime::traits::NumberFor<Block>,
			>,
			key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,
		) -> Option<()> {
			let key_owner_proof = key_owner_proof.decode()?;

872
			Grandpa::submit_unsigned_equivocation_report(
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
				equivocation_proof,
				key_owner_proof,
			)
		}

		fn generate_key_ownership_proof(
			_set_id: fg_primitives::SetId,
			authority_id: fg_primitives::AuthorityId,
		) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {
			use codec::Encode;

			Historical::prove((fg_primitives::KEY_TYPE, authority_id))
				.map(|p| p.encode())
				.map(fg_primitives::OpaqueKeyOwnershipProof::new)
		}
ddorgan's avatar
ddorgan committed
888
889
890
	}

	impl babe_primitives::BabeApi<Block> for Runtime {
891
		fn configuration() -> babe_primitives::BabeGenesisConfiguration {
ddorgan's avatar
ddorgan committed
892
893
894
895
896
			// The choice of `c` parameter (where `1 - c` represents the
			// probability of a slot being empty), is done in accordance to the
			// slot duration and expected target block time, for safely
			// resisting network delays of maximum two seconds.
			// <https://research.web3.foundation/en/latest/polkadot/BABE/Babe/#6-practical-results>
897
			babe_primitives::BabeGenesisConfiguration {
ddorgan's avatar
ddorgan committed
898
899
900
901
902
				slot_duration: Babe::slot_duration(),
				epoch_length: EpochDuration::get(),
				c: PRIMARY_PROBABILITY,
				genesis_authorities: Babe::authorities(),
				randomness: Babe::randomness(),
903
				allowed_slots: babe_primitives::AllowedSlots::PrimaryAndSecondaryPlainSlots,
ddorgan's avatar
ddorgan committed
904
905
906
907
908
909
			}
		}

		fn current_epoch_start() -> babe_primitives::SlotNumber {
			Babe::current_epoch_start()
		}
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932

		fn generate_key_ownership_proof(
			_slot_number: babe_primitives::SlotNumber,
			authority_id: babe_primitives::AuthorityId,
		) -> Option<babe_primitives::OpaqueKeyOwnershipProof> {
			use codec::Encode;

			Historical::prove((babe_primitives::KEY_TYPE, authority_id))
				.map(|p| p.encode())
				.map(babe_primitives::OpaqueKeyOwnershipProof::new)
		}

		fn submit_report_equivocation_unsigned_extrinsic(
			equivocation_proof: babe_primitives::EquivocationProof<<Block as BlockT>::Header>,
			key_owner_proof: babe_primitives::OpaqueKeyOwnershipProof,
		) -> Option<()> {
			let key_owner_proof = key_owner_proof.decode()?;

			Babe::submit_unsigned_equivocation_report(
				equivocation_proof,
				key_owner_proof,
			)
		}
ddorgan's avatar
ddorgan committed
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
	}

	impl authority_discovery_primitives::AuthorityDiscoveryApi<Block> for Runtime {
		fn authorities() -> Vec<AuthorityDiscoveryId> {
			AuthorityDiscovery::authorities()
		}
	}

	impl sp_session::SessionKeys<Block> for Runtime {
		fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {
			SessionKeys::generate(seed)
		}

		fn decode_session_keys(
			encoded: Vec<u8>,
		) -> Option<Vec<(Vec<u8>, sp_core::crypto::KeyTypeId)>> {
			SessionKeys::decode_into_raw_public_keys(&encoded)
		}
	}

953
	impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
ddorgan's avatar
ddorgan committed
954
955
956
957
958
		fn account_nonce(account: AccountId) -> Nonce {
			System::account_nonce(account)
		}
	}

959
	impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<
ddorgan's avatar
ddorgan committed
960
961
962
		Block,
		Balance,
	> for Runtime {
963
		fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {
ddorgan's avatar
ddorgan committed
964
965
966
967
968
969
970
			TransactionPayment::query_info(uxt, len)
		}
	}

	#[cfg(feature = "runtime-benchmarks")]
	impl frame_benchmarking::Benchmark<Block> for Runtime {
		fn dispatch_benchmark(
971
			config: frame_benchmarking::BenchmarkConfig,
ddorgan's avatar
ddorgan committed
972
		) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, RuntimeString> {
973
			use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};
974
975
976
977
978
			// Trying to add benchmarks directly to the Session Pallet caused cyclic dependency issues.
			// To get around that, we separated the Session benchmarks into its own crate, which is why
			// we need these two lines below.
			use pallet_session_benchmarking::Module as SessionBench;
			use pallet_offences_benchmarking::Module as OffencesBench;
979
			use frame_system_benchmarking::Module as SystemBench;
980
981
982

			impl pallet_session_benchmarking::Trait for Runtime {}
			impl pallet_offences_benchmarking::Trait for Runtime {}
983
			impl frame_system_benchmarking::Trait for Runtime {}
ddorgan's avatar
ddorgan committed
984

985
			let whitelist: Vec<TrackedStorageKey> = vec![
986
				// Block Number
987
				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),
988
				// Total Issuance
989
				hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),
990
				// Execution Phase
991
				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),
992
				// Event Count
993
				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),
994
				// System Events
995
				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),
996
				// Treasury Account
997
				hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7b99d880ec681799c0cf30e8886371da95ecffd7b6c0f78751baa9d281e0bfa3a6d6f646c70792f74727372790000000000000000000000000000000000000000").to_vec().into(),
998
999
			];

ddorgan's avatar
ddorgan committed
1000
			let mut batches = Vec::<BenchmarkBatch>::new();
1001
			let params = (&config, &whitelist);
1002

1003
1004
1005
			add_benchmark!(params, batches, pallet_balances, Balances);
			add_benchmark!(params, batches, pallet_identity, Identity);
			add_benchmark!(params, batches, pallet_im_online, ImOnline);
1006
1007
			add_benchmark!(params, batches, pallet_indices, Indices);
			add_benchmark!(params, batches, pallet_multisig, Multisig);
1008
			add_benchmark!(params, batches, pallet_offences, OffencesBench::<Runtime>);
1009
			add_benchmark!(params, batches, pallet_proxy, Proxy);
1010
1011
1012
1013
1014
1015
1016
			add_benchmark!(params, batches, pallet_scheduler, Scheduler);
			add_benchmark!(params, batches, pallet_session, SessionBench::<Runtime>);
			add_benchmark!(params, batches, pallet_staking, Staking);
			add_benchmark!(params, batches, frame_system, SystemBench::<Runtime>);
			add_benchmark!(params, batches, pallet_timestamp, Timestamp);
			add_benchmark!(params, batches, pallet_utility, Utility);
			add_benchmark!(params, batches, pallet_vesting, Vesting);
1017

ddorgan's avatar
ddorgan committed
1018
1019
1020
1021
1022
			if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }
			Ok(batches)
		}
	}
}