-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathlib.rs
1900 lines (1691 loc) · 86.4 KB
/
lib.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
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
814
815
816
817
818
819
820
821
822
823
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
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2022-2023 Forecasting Technologies LTD.
// Copyright 2021-2022 Zeitgeist PM LLC.
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
//
// This file is part of Zeitgeist.
//
// Zeitgeist 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.
//
// Zeitgeist 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 Zeitgeist. If not, see <https://www.gnu.org/licenses/>.
//
// This file incorporates work covered by the following copyright and
// permission notice:
//
// Copyright (C) 2020-2022 Acala Foundation.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
//
// This program 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.
//
// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
#![cfg_attr(not(feature = "std"), no_std)]
#![recursion_limit = "512"]
#![allow(clippy::crate_in_macro_def)]
pub mod weights;
#[macro_export]
macro_rules! decl_common_types {
{} => {
use sp_runtime::generic;
use frame_support::traits::{Currency, Imbalance, OnUnbalanced, NeverEnsureOrigin, TryStateSelect};
pub type Block = generic::Block<Header, UncheckedExtrinsic>;
type Address = sp_runtime::MultiAddress<AccountId, ()>;
#[cfg(feature = "with-global-disputes")]
type ConditionalMigration = zrml_global_disputes::migrations::ModifyGlobalDisputesStructures<Runtime>;
#[cfg(not(feature = "with-global-disputes"))]
type ConditionalMigration = ();
#[cfg(feature = "parachain")]
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(
zrml_prediction_markets::migrations::AddOutsiderBond<Runtime>,
ConditionalMigration,
),
>;
#[cfg(not(feature = "parachain"))]
pub type Executive = frame_executive::Executive<
Runtime,
Block,
frame_system::ChainContext<Runtime>,
Runtime,
AllPalletsWithSystem,
(
zrml_prediction_markets::migrations::AddOutsiderBond<Runtime>,
ConditionalMigration,
),
>;
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
pub(crate) type NodeBlock = generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
type RikiddoSigmoidFeeMarketVolumeEma = zrml_rikiddo::Instance1;
pub type SignedExtra = (
CheckNonZeroSender<Runtime>,
CheckSpecVersion<Runtime>,
CheckTxVersion<Runtime>,
CheckGenesis<Runtime>,
CheckEra<Runtime>,
CheckNonce<Runtime>,
CheckWeight<Runtime>,
ChargeTransactionPayment<Runtime>,
);
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;
// Governance
type AdvisoryCommitteeInstance = pallet_collective::Instance1;
type AdvisoryCommitteeMembershipInstance = pallet_membership::Instance1;
type CouncilInstance = pallet_collective::Instance2;
type CouncilMembershipInstance = pallet_membership::Instance2;
type TechnicalCommitteeInstance = pallet_collective::Instance3;
type TechnicalCommitteeMembershipInstance = pallet_membership::Instance3;
// Council vote proportions
// At least 50%
type EnsureRootOrHalfCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 2>>;
// At least 66%
type EnsureRootOrTwoThirdsCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 2, 3>>;
// At least 75%
type EnsureRootOrThreeFourthsCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 3, 4>>;
// At least 100%
type EnsureRootOrAllCouncil =
EitherOfDiverse<EnsureRoot<AccountId>, EnsureProportionAtLeast<AccountId, CouncilInstance, 1, 1>>;
// Technical committee vote proportions
// At least 50%
#[cfg(feature = "parachain")]
type EnsureRootOrHalfTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 1, 2>,
>;
// At least 66%
type EnsureRootOrTwoThirdsTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 2, 3>,
>;
// At least 100%
type EnsureRootOrAllTechnicalCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, TechnicalCommitteeInstance, 1, 1>,
>;
// Advisory committee vote proportions
// At least 50%
type EnsureRootOrHalfAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 1, 2>,
>;
// Technical committee vote proportions
// At least 66%
type EnsureRootOrTwoThirdsAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 2, 3>,
>;
// At least 100%
type EnsureRootOrAllAdvisoryCommittee = EitherOfDiverse<
EnsureRoot<AccountId>,
EnsureProportionAtLeast<AccountId, AdvisoryCommitteeInstance, 1, 1>,
>;
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion { runtime_version: VERSION, can_author_with: Default::default() }
}
// Accounts protected from being deleted due to a too low amount of funds.
pub struct DustRemovalWhitelist;
impl Contains<AccountId> for DustRemovalWhitelist
where
frame_support::PalletId: AccountIdConversion<AccountId>,
{
fn contains(ai: &AccountId) -> bool {
let mut pallets = vec![
AuthorizedPalletId::get(),
CourtPalletId::get(),
LiquidityMiningPalletId::get(),
PmPalletId::get(),
SimpleDisputesPalletId::get(),
SwapsPalletId::get(),
TreasuryPalletId::get(),
];
#[cfg(feature = "with-global-disputes")]
pallets.push(GlobalDisputesPalletId::get());
if let Some(pallet_id) = frame_support::PalletId::try_from_sub_account::<u128>(ai) {
return pallets.contains(&pallet_id.0);
}
for pallet_id in pallets {
let pallet_acc: AccountId = pallet_id.into_account_truncating();
if pallet_acc == *ai {
return true;
}
}
false
}
}
pub struct DealWithFees;
type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;
impl OnUnbalanced<NegativeImbalance> for DealWithFees
{
fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {
if let Some(mut fees) = fees_then_tips.next() {
if let Some(tips) = fees_then_tips.next() {
tips.merge_into(&mut fees);
}
let mut split = fees.ration(
FEES_AND_TIPS_TREASURY_PERCENTAGE,
FEES_AND_TIPS_BURN_PERCENTAGE,
);
Treasury::on_unbalanced(split.0);
}
}
}
pub mod opaque {
//! Opaque types. These are used by the CLI to instantiate machinery that don't need to know
//! the specifics of the runtime. They can then be made to be agnostic over specific formats
//! of data like extrinsics, allowing for them to continue syncing the network through upgrades
//! to even the core data structures.
use super::Header;
use alloc::vec::Vec;
use sp_runtime::{generic, impl_opaque_keys};
pub type Block = generic::Block<Header, sp_runtime::OpaqueExtrinsic>;
#[cfg(feature = "parachain")]
impl_opaque_keys! {
pub struct SessionKeys {
pub nimbus: crate::AuthorInherent,
pub vrf: session_keys_primitives::VrfSessionKey,
}
}
#[cfg(not(feature = "parachain"))]
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: crate::Aura,
pub grandpa: crate::Grandpa,
}
}
}
}
}
// Construct runtime
#[macro_export]
macro_rules! create_runtime {
($($additional_pallets:tt)*) => {
use alloc::{boxed::Box, vec::Vec};
// Pallets are enumerated based on the dependency graph.
//
// For example, `PredictionMarkets` is pĺaced after `SimpleDisputes` because
// `PredictionMarkets` depends on `SimpleDisputes`.
construct_runtime!(
pub enum Runtime where
Block = crate::Block,
NodeBlock = crate::NodeBlock,
UncheckedExtrinsic = crate::UncheckedExtrinsic,
{
// System
System: frame_system::{Call, Config, Event<T>, Pallet, Storage} = 0,
Timestamp: pallet_timestamp::{Call, Pallet, Storage, Inherent} = 1,
RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 2,
Scheduler: pallet_scheduler::{Pallet, Call, Storage, Event<T>} = 3,
Preimage: pallet_preimage::{Pallet, Call, Storage, Event<T>} = 4,
// Money
Balances: pallet_balances::{Call, Config<T>, Event<T>, Pallet, Storage} = 10,
TransactionPayment: pallet_transaction_payment::{Config, Event<T>, Pallet, Storage} = 11,
Treasury: pallet_treasury::{Call, Config, Event<T>, Pallet, Storage} = 12,
Vesting: pallet_vesting::{Call, Config<T>, Event<T>, Pallet, Storage} = 13,
Multisig: pallet_multisig::{Call, Event<T>, Pallet, Storage} = 14,
Bounties: pallet_bounties::{Call, Event<T>, Pallet, Storage} = 15,
// Governance
Democracy: pallet_democracy::{Pallet, Call, Storage, Config<T>, Event<T>} = 20,
AdvisoryCommittee: pallet_collective::<Instance1>::{Call, Config<T>, Event<T>, Origin<T>, Pallet, Storage} = 21,
AdvisoryCommitteeMembership: pallet_membership::<Instance1>::{Call, Config<T>, Event<T>, Pallet, Storage} = 22,
Council: pallet_collective::<Instance2>::{Call, Config<T>, Event<T>, Origin<T>, Pallet, Storage} = 23,
CouncilMembership: pallet_membership::<Instance2>::{Call, Config<T>, Event<T>, Pallet, Storage} = 24,
TechnicalCommittee: pallet_collective::<Instance3>::{Call, Config<T>, Event<T>, Origin<T>, Pallet, Storage} = 25,
TechnicalCommitteeMembership: pallet_membership::<Instance3>::{Call, Config<T>, Event<T>, Pallet, Storage} = 26,
// Other Parity pallets
Identity: pallet_identity::{Call, Event<T>, Pallet, Storage} = 30,
Utility: pallet_utility::{Call, Event, Pallet, Storage} = 31,
Proxy: pallet_proxy::{Call, Event<T>, Pallet, Storage} = 32,
// Third-party
AssetManager: orml_currencies::{Call, Pallet, Storage} = 40,
Tokens: orml_tokens::{Config<T>, Event<T>, Pallet, Storage} = 41,
// Zeitgeist
MarketCommons: zrml_market_commons::{Pallet, Storage} = 50,
Authorized: zrml_authorized::{Call, Event<T>, Pallet, Storage} = 51,
Court: zrml_court::{Call, Event<T>, Pallet, Storage} = 52,
LiquidityMining: zrml_liquidity_mining::{Call, Config<T>, Event<T>, Pallet, Storage} = 53,
RikiddoSigmoidFeeMarketEma: zrml_rikiddo::<Instance1>::{Pallet, Storage} = 54,
SimpleDisputes: zrml_simple_disputes::{Event<T>, Pallet, Storage} = 55,
Swaps: zrml_swaps::{Call, Event<T>, Pallet, Storage} = 56,
PredictionMarkets: zrml_prediction_markets::{Call, Event<T>, Pallet, Storage} = 57,
Styx: zrml_styx::{Call, Event<T>, Pallet, Storage} = 58,
$($additional_pallets)*
}
);
}
}
#[macro_export]
macro_rules! create_runtime_with_additional_pallets {
($($additional_pallets:tt)*) => {
#[cfg(feature = "parachain")]
create_runtime!(
// System
ParachainSystem: cumulus_pallet_parachain_system::{Call, Config, Event<T>, Inherent, Pallet, Storage, ValidateUnsigned} = 100,
ParachainInfo: parachain_info::{Config, Pallet, Storage} = 101,
// Consensus
ParachainStaking: pallet_parachain_staking::{Call, Config<T>, Event<T>, Pallet, Storage} = 110,
AuthorInherent: pallet_author_inherent::{Call, Inherent, Pallet, Storage} = 111,
AuthorFilter: pallet_author_slot_filter::{Call, Config, Event, Pallet, Storage} = 112,
AuthorMapping: pallet_author_mapping::{Call, Config<T>, Event<T>, Pallet, Storage} = 113,
// XCM
CumulusXcm: cumulus_pallet_xcm::{Event<T>, Origin, Pallet} = 120,
DmpQueue: cumulus_pallet_dmp_queue::{Call, Event<T>, Pallet, Storage} = 121,
PolkadotXcm: pallet_xcm::{Call, Config, Event<T>, Origin, Pallet, Storage} = 122,
XcmpQueue: cumulus_pallet_xcmp_queue::{Call, Event<T>, Pallet, Storage} = 123,
AssetRegistry: orml_asset_registry::{Call, Config<T>, Event<T>, Pallet, Storage} = 124,
UnknownTokens: orml_unknown_tokens::{Pallet, Storage, Event} = 125,
XTokens: orml_xtokens::{Pallet, Storage, Call, Event<T>} = 126,
// Others
$($additional_pallets)*
);
#[cfg(not(feature = "parachain"))]
create_runtime!(
// Consensus
Aura: pallet_aura::{Config<T>, Pallet, Storage} = 100,
Grandpa: pallet_grandpa::{Call, Config, Event, Pallet, Storage} = 101,
// Others
$($additional_pallets)*
);
}
}
#[macro_export]
macro_rules! impl_config_traits {
{} => {
use common_runtime::weights;
#[cfg(feature = "parachain")]
use xcm_config::config::*;
// Configure Pallets
#[cfg(feature = "parachain")]
impl cumulus_pallet_dmp_queue::Config for Runtime {
type Event = Event;
type ExecuteOverweightOrigin = EnsureRootOrHalfTechnicalCommittee;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
}
#[cfg(feature = "parachain")]
impl cumulus_pallet_parachain_system::Config for Runtime {
type CheckAssociatedRelayNumber = cumulus_pallet_parachain_system::RelayNumberStrictlyIncreases;
type DmpMessageHandler = DmpQueue;
type Event = Event;
type OnSystemEvent = ();
type OutboundXcmpMessageSource = XcmpQueue;
type ReservedDmpWeight = crate::parachain_params::ReservedDmpWeight;
type ReservedXcmpWeight = crate::parachain_params::ReservedXcmpWeight;
type SelfParaId = parachain_info::Pallet<Runtime>;
type XcmpMessageHandler = XcmpQueue;
}
#[cfg(feature = "parachain")]
impl cumulus_pallet_xcm::Config for Runtime {
type Event = Event;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
}
#[cfg(feature = "parachain")]
impl cumulus_pallet_xcmp_queue::Config for Runtime {
type ChannelInfo = ParachainSystem;
type ControllerOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
type ControllerOriginConverter = XcmOriginToTransactDispatchOrigin;
type Event = Event;
type ExecuteOverweightOrigin = EnsureRootOrHalfTechnicalCommittee;
type VersionWrapper = ();
type WeightInfo = weights::cumulus_pallet_xcmp_queue::WeightInfo<Runtime>;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
}
impl frame_system::Config for Runtime {
type AccountData = pallet_balances::AccountData<Balance>;
type AccountId = AccountId;
type BaseCallFilter = IsCallable;
type BlockHashCount = BlockHashCount;
type BlockLength = RuntimeBlockLength;
type BlockNumber = BlockNumber;
type BlockWeights = RuntimeBlockWeights;
type Call = Call;
type DbWeight = RocksDbWeight;
type Event = Event;
type Hash = Hash;
type Hashing = BlakeTwo256;
type Header = generic::Header<BlockNumber, BlakeTwo256>;
type Index = Index;
type Lookup = AccountIdLookup<AccountId, ()>;
type MaxConsumers = ConstU32<16>;
type OnKilledAccount = ();
type OnNewAccount = ();
#[cfg(feature = "parachain")]
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;
#[cfg(not(feature = "parachain"))]
type OnSetCode = ();
type Origin = Origin;
type PalletInfo = PalletInfo;
type SS58Prefix = SS58Prefix;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
type Version = Version;
}
#[cfg(not(feature = "parachain"))]
impl pallet_aura::Config for Runtime {
type AuthorityId = sp_consensus_aura::sr25519::AuthorityId;
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
}
#[cfg(feature = "parachain")]
impl pallet_author_inherent::Config for Runtime {
type AccountLookup = AuthorMapping;
type CanAuthor = AuthorFilter;
type SlotBeacon = cumulus_pallet_parachain_system::RelaychainBlockNumberProvider<Self>;
type WeightInfo = weights::pallet_author_inherent::WeightInfo<Runtime>;
}
#[cfg(feature = "parachain")]
impl pallet_author_mapping::Config for Runtime {
type DepositAmount = CollatorDeposit;
type DepositCurrency = Balances;
type Event = Event;
type Keys = session_keys_primitives::VrfId;
type WeightInfo = weights::pallet_author_mapping::WeightInfo<Runtime>;
}
#[cfg(feature = "parachain")]
impl pallet_author_slot_filter::Config for Runtime {
type Event = Event;
type RandomnessSource = RandomnessCollectiveFlip;
type PotentialAuthors = ParachainStaking;
type WeightInfo = weights::pallet_author_slot_filter::WeightInfo<Runtime>;
}
#[cfg(not(feature = "parachain"))]
impl pallet_grandpa::Config for Runtime {
type Event = Event;
type Call = Call;
type KeyOwnerProofSystem = ();
type KeyOwnerProof =
<Self::KeyOwnerProofSystem as frame_support::traits::KeyOwnerProofSystem<(
KeyTypeId,
pallet_grandpa::AuthorityId,
)>>::Proof;
type KeyOwnerIdentification =
<Self::KeyOwnerProofSystem as frame_support::traits::KeyOwnerProofSystem<(
KeyTypeId,
pallet_grandpa::AuthorityId,
)>>::IdentificationTuple;
type HandleEquivocation = ();
type MaxAuthorities = MaxAuthorities;
// Currently the benchmark does yield an invalid weight implementation
// type WeightInfo = weights::pallet_grandpa::WeightInfo<Runtime>;
type WeightInfo = ();
}
#[cfg(feature = "parachain")]
impl pallet_xcm::Config for Runtime {
type Event = Event;
type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmRouter = XcmRouter;
type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;
type XcmExecuteFilter = Nothing;
// ^ Disable dispatchable execute on the XCM pallet.
// Needs to be `Everything` for local testing.
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
type XcmTeleportFilter = Everything;
type XcmReserveTransferFilter = Nothing;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type LocationInverter = LocationInverter<Ancestry>;
type Origin = Origin;
type Call = Call;
const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;
// ^ Override for AdvertisedXcmVersion default
type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;
}
#[cfg(feature = "parachain")]
impl pallet_parachain_staking::Config for Runtime {
type BlockAuthor = AuthorInherent;
type CandidateBondLessDelay = CandidateBondLessDelay;
type Currency = Balances;
type DelegationBondLessDelay = DelegationBondLessDelay;
type Event = Event;
type LeaveCandidatesDelay = LeaveCandidatesDelay;
type LeaveDelegatorsDelay = LeaveDelegatorsDelay;
type MaxBottomDelegationsPerCandidate = MaxBottomDelegationsPerCandidate;
type MaxTopDelegationsPerCandidate = MaxTopDelegationsPerCandidate;
type MaxDelegationsPerDelegator = MaxDelegationsPerDelegator;
type MinBlocksPerRound = MinBlocksPerRound;
type MinCandidateStk = MinCollatorStk;
type MinCollatorStk = MinCollatorStk;
type MinDelegation = MinDelegatorStk;
type MinDelegatorStk = MinDelegatorStk;
type MinSelectedCandidates = MinSelectedCandidates;
type MonetaryGovernanceOrigin = EnsureRoot<AccountId>;
type OnCollatorPayout = ();
type OnNewRound = ();
type RevokeDelegationDelay = RevokeDelegationDelay;
type RewardPaymentDelay = RewardPaymentDelay;
type WeightInfo = weights::pallet_parachain_staking::WeightInfo<Runtime>;
}
#[cfg(feature = "parachain")]
impl orml_asset_registry::Config for Runtime {
type AssetId = CurrencyId;
type AssetProcessor = CustomAssetProcessor;
type AuthorityOrigin = AsEnsureOriginWithArg<EnsureRootOrTwoThirdsCouncil>;
type Balance = Balance;
type CustomMetadata = CustomMetadata;
type Event = Event;
type WeightInfo = ();
}
impl orml_currencies::Config for Runtime {
type GetNativeCurrencyId = GetNativeCurrencyId;
type MultiCurrency = Tokens;
type NativeCurrency = BasicCurrencyAdapter<Runtime, Balances>;
type WeightInfo = weights::orml_currencies::WeightInfo<Runtime>;
}
impl orml_tokens::Config for Runtime {
type Amount = Amount;
type Balance = Balance;
type CurrencyId = CurrencyId;
type DustRemovalWhitelist = DustRemovalWhitelist;
type Event = Event;
type ExistentialDeposits = ExistentialDeposits;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type OnDust = orml_tokens::TransferDust<Runtime, DustAccount>;
type OnKilledTokenAccount = ();
type OnNewTokenAccount = ();
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::orml_tokens::WeightInfo<Runtime>;
}
#[cfg(feature = "parachain")]
impl orml_unknown_tokens::Config for Runtime {
type Event = Event;
}
#[cfg(feature = "parachain")]
impl orml_xtokens::Config for Runtime {
type AccountIdToMultiLocation = AccountIdToMultiLocation;
type Balance = Balance;
type BaseXcmWeight = BaseXcmWeight;
type CurrencyId = CurrencyId;
type CurrencyIdConvert = AssetConvert;
type Event = Event;
type LocationInverter = LocationInverter<Ancestry>;
type MaxAssetsForTransfer = MaxAssetsForTransfer;
type MinXcmFee = ParachainMinFee;
type MultiLocationsFilter = Everything;
type ReserveProvider = orml_traits::location::AbsoluteReserveProvider;
type SelfLocation = SelfLocation;
type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;
type XcmExecutor = xcm_executor::XcmExecutor<XcmConfig>;
}
impl pallet_balances::Config for Runtime {
type AccountStore = System;
type Balance = Balance;
type DustRemoval = ();
type Event = Event;
type ExistentialDeposit = ExistentialDeposit;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
}
impl pallet_collective::Config<AdvisoryCommitteeInstance> for Runtime {
type DefaultVote = PrimeDefaultVote;
type Event = Event;
type MaxMembers = AdvisoryCommitteeMaxMembers;
type MaxProposals = AdvisoryCommitteeMaxProposals;
type MotionDuration = AdvisoryCommitteeMotionDuration;
type Origin = Origin;
type Proposal = Call;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}
impl pallet_collective::Config<CouncilInstance> for Runtime {
type DefaultVote = PrimeDefaultVote;
type Event = Event;
type MaxMembers = CouncilMaxMembers;
type MaxProposals = CouncilMaxProposals;
type MotionDuration = CouncilMotionDuration;
type Origin = Origin;
type Proposal = Call;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}
impl pallet_collective::Config<TechnicalCommitteeInstance> for Runtime {
type DefaultVote = PrimeDefaultVote;
type Event = Event;
type MaxMembers = TechnicalCommitteeMaxMembers;
type MaxProposals = TechnicalCommitteeMaxProposals;
type MotionDuration = TechnicalCommitteeMotionDuration;
type Origin = Origin;
type Proposal = Call;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
}
impl pallet_democracy::Config for Runtime {
type Proposal = Call;
type Event = Event;
type Currency = Balances;
type EnactmentPeriod = EnactmentPeriod;
type LaunchPeriod = LaunchPeriod;
type VotingPeriod = VotingPeriod;
type VoteLockingPeriod = VoteLockingPeriod;
type MinimumDeposit = MinimumDeposit;
/// Origin that can decide what their next motion is.
type ExternalOrigin = EnsureRootOrHalfCouncil;
/// Origin that can have the next scheduled referendum be a straight majority-carries vote.
type ExternalMajorityOrigin = EnsureRootOrHalfCouncil;
/// Origina that can have the next scheduled referendum be a straight default-carries
/// (NTB) vote.
type ExternalDefaultOrigin = EnsureRootOrAllCouncil;
/// Origin that can have an ExternalMajority/ExternalDefault vote
/// be tabled immediately and with a shorter voting/enactment period.
type FastTrackOrigin = EnsureRootOrTwoThirdsTechnicalCommittee;
/// Origin from which the next majority-carries (or more permissive) referendum may be tabled
/// to vote immediately and asynchronously in a similar manner to the emergency origin.
type InstantOrigin = EnsureRootOrAllTechnicalCommittee;
type InstantAllowed = InstantAllowed;
type FastTrackVotingPeriod = FastTrackVotingPeriod;
/// Origin from which any referendum may be cancelled in an emergency.
type CancellationOrigin = EnsureRootOrThreeFourthsCouncil;
/// Origin from which proposals may be blacklisted.
type BlacklistOrigin = EnsureRootOrAllCouncil;
/// Origin from which a proposal may be cancelled and its backers slashed.
type CancelProposalOrigin = EnsureRootOrAllTechnicalCommittee;
/// Origin for anyone able to veto proposals.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCommitteeInstance>;
type CooloffPeriod = CooloffPeriod;
type PreimageByteDeposit = PreimageByteDeposit;
type OperationalPreimageOrigin = pallet_collective::EnsureMember<AccountId, CouncilInstance>;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
type MaxProposals = MaxProposals;
}
impl pallet_identity::Config for Runtime {
type BasicDeposit = BasicDeposit;
type Currency = Balances;
type Event = Event;
type FieldDeposit = FieldDeposit;
type ForceOrigin = EnsureRootOrTwoThirdsAdvisoryCommittee;
type MaxAdditionalFields = MaxAdditionalFields;
type MaxRegistrars = MaxRegistrars;
type MaxSubAccounts = MaxSubAccounts;
type RegistrarOrigin = EnsureRootOrHalfCouncil;
type Slashed = Treasury;
type SubAccountDeposit = SubAccountDeposit;
type WeightInfo = weights::pallet_identity::WeightInfo<Runtime>;
}
impl pallet_membership::Config<AdvisoryCommitteeMembershipInstance> for Runtime {
type AddOrigin = EnsureRootOrTwoThirdsCouncil;
type Event = Event;
type MaxMembers = AdvisoryCommitteeMaxMembers;
type MembershipChanged = AdvisoryCommittee;
type MembershipInitialized = AdvisoryCommittee;
type PrimeOrigin = EnsureRootOrTwoThirdsCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsCouncil;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
impl pallet_membership::Config<CouncilMembershipInstance> for Runtime {
type AddOrigin = EnsureRootOrThreeFourthsCouncil;
type Event = Event;
type MaxMembers = CouncilMaxMembers;
type MembershipChanged = Council;
type MembershipInitialized = Council;
type PrimeOrigin = EnsureRootOrThreeFourthsCouncil;
type RemoveOrigin = EnsureRootOrThreeFourthsCouncil;
type ResetOrigin = EnsureRootOrThreeFourthsCouncil;
type SwapOrigin = EnsureRootOrThreeFourthsCouncil;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
impl pallet_membership::Config<TechnicalCommitteeMembershipInstance> for Runtime {
type AddOrigin = EnsureRootOrTwoThirdsCouncil;
type Event = Event;
type MaxMembers = TechnicalCommitteeMaxMembers;
type MembershipChanged = TechnicalCommittee;
type MembershipInitialized = TechnicalCommittee;
type PrimeOrigin = EnsureRootOrTwoThirdsCouncil;
type RemoveOrigin = EnsureRootOrTwoThirdsCouncil;
type ResetOrigin = EnsureRootOrTwoThirdsCouncil;
type SwapOrigin = EnsureRootOrTwoThirdsCouncil;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
impl pallet_multisig::Config for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type DepositBase = DepositBase;
type DepositFactor = DepositFactor;
type MaxSignatories = ConstU16<100>;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}
impl pallet_preimage::Config for Runtime {
type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
type Event = Event;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type MaxSize = PreimageMaxSize;
type BaseDeposit = PreimageBaseDeposit;
type ByteDeposit = PreimageByteDeposit;
}
impl InstanceFilter<Call> for ProxyType {
fn filter(&self, c: &Call) -> bool {
match self {
ProxyType::Any => true,
ProxyType::CancelProxy => {
matches!(c, Call::Proxy(pallet_proxy::Call::reject_announcement { .. }))
}
ProxyType::Governance => matches!(
c,
Call::Democracy(..)
| Call::Council(..)
| Call::TechnicalCommittee(..)
| Call::AdvisoryCommittee(..)
| Call::Treasury(..)
),
#[cfg(feature = "parachain")]
ProxyType::Staking => matches!(c, Call::ParachainStaking(..)),
#[cfg(not(feature = "parachain"))]
ProxyType::Staking => false,
}
}
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
_ => false,
}
}
}
impl pallet_proxy::Config for Runtime {
type Event = Event;
type Call = Call;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = ProxyDepositBase;
type ProxyDepositFactor = ProxyDepositFactor;
type MaxProxies = ConstU32<32>;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
type MaxPending = ConstU32<32>;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = AnnouncementDepositBase;
type AnnouncementDepositFactor = AnnouncementDepositFactor;
}
impl pallet_randomness_collective_flip::Config for Runtime {}
impl pallet_scheduler::Config for Runtime {
type Event = Event;
type Origin = Origin;
type PalletsOrigin = OriginCaller;
type Call = Call;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = EnsureRoot<AccountId>;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
type OriginPrivilegeCmp = EqualPrivilegeOnly;
type PreimageProvider = Preimage;
type NoPreimagePostponement = NoPreimagePostponement;
}
// Timestamp
/// Custom getter for minimum timestamp delta.
/// This ensures that consensus systems like Aura don't break assertions
/// in a benchmark environment
pub struct MinimumPeriod;
impl MinimumPeriod {
/// Returns the value of this parameter type.
pub fn get() -> u64 {
#[cfg(feature = "runtime-benchmarks")]
{
use frame_benchmarking::benchmarking::get_whitelist;
// Should that condition be true, we can assume that we are in a benchmark environment.
if !get_whitelist().is_empty() {
return u64::MAX;
}
}
MinimumPeriodValue::get()
}
}
impl<I: From<u64>> frame_support::traits::Get<I> for MinimumPeriod {
fn get() -> I {
I::from(Self::get())
}
}
impl frame_support::traits::TypedGet for MinimumPeriod {
type Type = u64;
fn get() -> u64 {
Self::get()
}
}
impl pallet_timestamp::Config for Runtime {
type MinimumPeriod = MinimumPeriod;
type Moment = u64;
#[cfg(feature = "parachain")]
type OnTimestampSet = ();
#[cfg(not(feature = "parachain"))]
type OnTimestampSet = Aura;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}
impl pallet_transaction_payment::Config for Runtime {
type Event = Event;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Runtime>;
type LengthToFee = ConstantMultiplier<Balance, TransactionByteFee>;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = IdentityFee<Balance>;
}
impl pallet_treasury::Config for Runtime {
type ApproveOrigin = EnsureRootOrTwoThirdsCouncil;
type Burn = Burn;
type BurnDestination = ();
type Currency = Balances;
type Event = Event;
type MaxApprovals = MaxApprovals;
type OnSlash = ();
type PalletId = TreasuryPalletId;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ProposalBondMaximum;
type RejectOrigin = EnsureRootOrTwoThirdsCouncil;
type SpendFunds = Bounties;
type SpendOrigin = NeverEnsureOrigin<Balance>;
type SpendPeriod = SpendPeriod;
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
}
impl pallet_bounties::Config for Runtime {
type BountyDepositBase = BountyDepositBase;
type BountyDepositPayoutDelay = BountyDepositPayoutDelay;
type BountyUpdatePeriod = BountyUpdatePeriod;
type BountyValueMinimum = BountyValueMinimum;
type ChildBountyManager = ();
type CuratorDepositMax = CuratorDepositMax;
type CuratorDepositMin = CuratorDepositMin;
type CuratorDepositMultiplier = CuratorDepositMultiplier;
type DataDepositPerByte = DataDepositPerByte;
type Event = Event;
type MaximumReasonLength = MaximumReasonLength;
type WeightInfo = weights::pallet_bounties::WeightInfo<Runtime>;
}
impl pallet_utility::Config for Runtime {
type Event = Event;
type Call = Call;
type PalletsOrigin = OriginCaller;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}
impl pallet_vesting::Config for Runtime {
type Event = Event;
type Currency = Balances;
type BlockNumberToBalance = sp_runtime::traits::ConvertInto;
type MinVestedTransfer = MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
// `VestingInfo` encode length is 36bytes. 28 schedules gets encoded as 1009 bytes, which is the
// highest number of schedules that encodes less than 2^10.
const MAX_VESTING_SCHEDULES: u32 = 28;
}
#[cfg(feature = "parachain")]
impl parachain_info::Config for Runtime {}
impl zrml_authorized::Config for Runtime {
type AuthorizedDisputeResolutionOrigin = EnsureRootOrHalfAdvisoryCommittee;
type CorrectionPeriod = CorrectionPeriod;
type DisputeResolution = zrml_prediction_markets::Pallet<Runtime>;
type Event = Event;
type MarketCommons = MarketCommons;
type PalletId = AuthorizedPalletId;
type WeightInfo = zrml_authorized::weights::WeightInfo<Runtime>;
}
impl zrml_court::Config for Runtime {
type CourtCaseDuration = CourtCaseDuration;
type DisputeResolution = zrml_prediction_markets::Pallet<Runtime>;
type Event = Event;
type MarketCommons = MarketCommons;
type PalletId = CourtPalletId;
type Random = RandomnessCollectiveFlip;
type StakeWeight = StakeWeight;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = zrml_court::weights::WeightInfo<Runtime>;
}
impl zrml_liquidity_mining::Config for Runtime {
type Event = Event;
type MarketCommons = MarketCommons;
type MarketId = MarketId;
type PalletId = LiquidityMiningPalletId;
type WeightInfo = zrml_liquidity_mining::weights::WeightInfo<Runtime>;
}
impl zrml_market_commons::Config for Runtime {
type Currency = Balances;
type MarketId = MarketId;
type PredictionMarketsPalletId = PmPalletId;
type Timestamp = Timestamp;
}
// NoopLiquidityMining implements LiquidityMiningPalletApi with no-ops.
// Has to be public because it will be exposed by Runtime.
pub struct NoopLiquidityMining;
impl zrml_liquidity_mining::LiquidityMiningPalletApi for NoopLiquidityMining {
type AccountId = AccountId;
type Balance = Balance;
type BlockNumber = BlockNumber;
type MarketId = MarketId;
fn add_shares(_: Self::AccountId, _: Self::MarketId, _: Self::Balance) {}
fn distribute_market_incentives(
_: &Self::MarketId,
) -> frame_support::pallet_prelude::DispatchResult {
Ok(())
}
fn remove_shares(_: &Self::AccountId, _: &Self::MarketId, _: Self::Balance) {}
}
impl zrml_prediction_markets::Config for Runtime {
type AdvisoryBond = AdvisoryBond;
type AdvisoryBondSlashPercentage = AdvisoryBondSlashPercentage;
type ApproveOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureMember<AccountId, AdvisoryCommitteeInstance>
>;
type Authorized = Authorized;
type Court = Court;