-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathlib.rs
1522 lines (1362 loc) · 56.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
// KILT Blockchain – https://botlabs.org
// Copyright (C) 2019-2024 BOTLabs GmbH
// The KILT Blockchain 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.
// The KILT Blockchain 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/>.
// If you feel like getting in touch with us, you can do so at info@botlabs.org
//! The KILT 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"]
// Make the WASM binary available.
#[cfg(feature = "std")]
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
use frame_support::{
construct_runtime, parameter_types,
traits::{AsEnsureOriginWithArg, ConstU32, EitherOfDiverse, Everything, InstanceFilter, PrivilegeCmp},
weights::{ConstantMultiplier, Weight},
};
use frame_system::{pallet_prelude::BlockNumberFor, EnsureRoot, EnsureSigned};
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
#[cfg(feature = "try-runtime")]
use frame_try_runtime::UpgradeCheckSelect;
use sp_api::impl_runtime_apis;
use sp_core::{ConstBool, OpaqueMetadata};
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{AccountIdLookup, BlakeTwo256, Block as BlockT, ConvertInto, OpaqueKeys},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, Perbill, Permill, RuntimeDebug,
};
use sp_std::{cmp::Ordering, prelude::*};
use sp_version::RuntimeVersion;
use delegation::DelegationAc;
use kilt_support::traits::ItemFilter;
use pallet_did_lookup::linkable_account::LinkableAccountId;
pub use parachain_staking::InflationInfo;
pub use public_credentials;
use runtime_common::{
assets::{AssetDid, PublicCredentialsFilter},
authorization::{AuthorizationId, PalletAuthorize},
constants::{self, UnvestedFundsAllowedWithdrawReasons, EXISTENTIAL_DEPOSIT, KILT},
dip::merkle::{CompleteMerkleProof, DidMerkleProofOf, DidMerkleRootGenerator},
errors::PublicCredentialsApiError,
fees::{ToAuthor, WeightToFee},
pallet_id, AccountId, AuthorityId, Balance, BlockHashCount, BlockLength, BlockNumber, BlockWeights, DidIdentifier,
FeeSplit, Hash, Header, Nonce, Signature, SlowAdjustingFeeUpdate,
};
#[cfg(feature = "std")]
use sp_version::NativeVersion;
#[cfg(feature = "runtime-benchmarks")]
use {kilt_support::signature::AlwaysVerify, runtime_common::benchmarks::DummySignature};
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
#[cfg(test)]
mod tests;
mod dip;
mod weights;
pub mod xcm_config;
impl_opaque_keys! {
pub struct SessionKeys {
pub aura: Aura,
}
}
/// This runtime version.
#[sp_version::runtime_version]
pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("mashnet-node"),
impl_name: create_runtime_str!("mashnet-node"),
authoring_version: 4,
spec_version: 11400,
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 8,
state_version: 0,
};
/// The version information used to identify this runtime when compiled
/// natively.
#[cfg(feature = "std")]
pub fn native_version() -> NativeVersion {
NativeVersion {
runtime_version: VERSION,
can_author_with: Default::default(),
}
}
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
pub const SS58Prefix: u8 = 38;
}
impl frame_system::Config for Runtime {
/// The identifier used to distinguish between accounts.
type AccountId = AccountId;
/// The aggregated dispatch type that is available for extrinsics.
type RuntimeCall = RuntimeCall;
/// The lookup mechanism to get account ID from whatever is passed in
/// dispatchers.
type Lookup = AccountIdLookup<AccountId, ()>;
/// The nonce type for storing how many extrinsics an account has signed.
type Nonce = Nonce;
/// The block type as expected in this runtime
type Block = Block;
/// The type for hashing blocks and tries.
type Hash = Hash;
/// The hashing algorithm used.
type Hashing = BlakeTwo256;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
/// The ubiquitous origin type.
type RuntimeOrigin = RuntimeOrigin;
/// Maximum number of block number to block hash mappings to keep (oldest
/// pruned first).
type BlockHashCount = BlockHashCount;
/// Runtime version.
type Version = Version;
/// Converts a module to an index of this module in the runtime.
type PalletInfo = PalletInfo;
type AccountData = pallet_balances::AccountData<Balance>;
type OnNewAccount = ();
type OnKilledAccount = ();
type DbWeight = weights::rocksdb_weights::constants::RocksDbWeight;
type BaseCallFilter = Everything;
type SystemWeightInfo = weights::frame_system::WeightInfo<Runtime>;
type BlockWeights = BlockWeights;
type BlockLength = BlockLength;
type SS58Prefix = SS58Prefix;
/// The set code logic
type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Runtime>;
type MaxConsumers = frame_support::traits::ConstU32<16>;
}
parameter_types! {
pub const MinimumPeriod: u64 = constants::SLOT_DURATION / 2;
}
impl pallet_timestamp::Config for Runtime {
/// A timestamp: milliseconds since the unix epoch.
type Moment = u64;
type OnTimestampSet = ();
type MinimumPeriod = MinimumPeriod;
type WeightInfo = weights::pallet_timestamp::WeightInfo<Runtime>;
}
parameter_types! {
pub const ExistentialDeposit: u128 = EXISTENTIAL_DEPOSIT;
pub const MaxLocks: u32 = 50;
pub const MaxReserves: u32 = 50;
pub const MaxHolds: u32 = 50;
pub const MaxFreezes: u32 = 50;
}
impl pallet_multisig::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type DepositBase = constants::multisig::DepositBase;
type DepositFactor = constants::multisig::DepositFactor;
type MaxSignatories = constants::multisig::MaxSignitors;
type WeightInfo = weights::pallet_multisig::WeightInfo<Runtime>;
}
impl pallet_migration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type MaxMigrationsPerPallet = constants::pallet_migration::MaxMigrationsPerPallet;
type WeightInfo = weights::pallet_migration::WeightInfo<Runtime>;
}
impl pallet_indices::Config for Runtime {
type AccountIndex = Nonce;
type Currency = pallet_balances::Pallet<Runtime>;
type Deposit = constants::IndicesDeposit;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_indices::WeightInfo<Runtime>;
}
impl pallet_balances::Config for Runtime {
/// The type for recording an account's balance.
type Balance = Balance;
type FreezeIdentifier = RuntimeFreezeReason;
type RuntimeHoldReason = RuntimeHoldReason;
type MaxFreezes = MaxFreezes;
type MaxHolds = MaxHolds;
/// The ubiquitous event type.
type RuntimeEvent = RuntimeEvent;
type DustRemoval = runtime_common::SendDustAndFeesToTreasury<Runtime>;
type ExistentialDeposit = ExistentialDeposit;
type AccountStore = System;
type WeightInfo = weights::pallet_balances::WeightInfo<Runtime>;
type MaxLocks = MaxLocks;
type MaxReserves = MaxReserves;
type ReserveIdentifier = [u8; 8];
}
impl pallet_transaction_payment::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnChargeTransaction =
pallet_transaction_payment::CurrencyAdapter<Balances, FeeSplit<Runtime, Treasury, ToAuthor<Runtime>>>;
type OperationalFeeMultiplier = constants::fee::OperationalFeeMultiplier;
type WeightToFee = WeightToFee<Runtime>;
type LengthToFee = ConstantMultiplier<Balance, constants::fee::TransactionByteFee>;
type FeeMultiplierUpdate = SlowAdjustingFeeUpdate<Self>;
}
impl pallet_sudo::Config for Runtime {
type RuntimeCall = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_sudo::WeightInfo<Runtime>;
}
parameter_types! {
pub const ReservedXcmpWeight: Weight = constants::MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
pub const ReservedDmpWeight: Weight = constants::MAXIMUM_BLOCK_WEIGHT.saturating_div(4);
}
impl cumulus_pallet_parachain_system::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type OnSystemEvent = ();
type SelfParaId = parachain_info::Pallet<Runtime>;
type OutboundXcmpMessageSource = XcmpQueue;
type DmpMessageHandler = DmpQueue;
type ReservedDmpWeight = ReservedDmpWeight;
type XcmpMessageHandler = XcmpQueue;
type ReservedXcmpWeight = ReservedXcmpWeight;
type CheckAssociatedRelayNumber = Configuration;
}
impl parachain_info::Config for Runtime {}
impl cumulus_pallet_aura_ext::Config for Runtime {}
parameter_types! {
pub const MaxAuthorities: u32 = constants::staking::MAX_CANDIDATES;
}
impl pallet_aura::Config for Runtime {
type AuthorityId = AuthorityId;
//TODO: handle disabled validators
type DisabledValidators = ();
type MaxAuthorities = MaxAuthorities;
type AllowMultipleBlocksPerSlot = ConstBool<false>;
}
parameter_types! {
pub const UncleGenerations: u32 = 0;
}
impl pallet_authorship::Config for Runtime {
type FindAuthor = pallet_session::FindAccountFromAuthorIndex<Self, Aura>;
type EventHandler = ParachainStaking;
}
impl pallet_session::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type ValidatorId = AccountId;
type ValidatorIdOf = ConvertInto;
type ShouldEndSession = ParachainStaking;
type NextSessionRotation = ParachainStaking;
type SessionManager = ParachainStaking;
type SessionHandler = <SessionKeys as OpaqueKeys>::KeyTypeIdProviders;
type Keys = SessionKeys;
type WeightInfo = weights::pallet_session::WeightInfo<Runtime>;
}
impl pallet_vesting::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type BlockNumberToBalance = ConvertInto;
// disable vested transfers by setting min amount to max balance
type MinVestedTransfer = constants::MinVestedTransfer;
type WeightInfo = weights::pallet_vesting::WeightInfo<Runtime>;
type UnvestedFundsAllowedWithdrawReasons = UnvestedFundsAllowedWithdrawReasons;
const MAX_VESTING_SCHEDULES: u32 = constants::MAX_VESTING_SCHEDULES;
}
parameter_types! {
pub const MaxClaims: u32 = 50;
pub const UsableBalance: Balance = KILT;
pub const AutoUnlockBound: u32 = 100;
}
impl pallet_preimage::Config for Runtime {
type WeightInfo = weights::pallet_preimage::WeightInfo<Runtime>;
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type ManagerOrigin = EnsureRoot<AccountId>;
type BaseDeposit = constants::preimage::PreimageBaseDeposit;
type ByteDeposit = constants::ByteDeposit;
}
parameter_types! {
pub MaximumSchedulerWeight: Weight = Perbill::from_percent(80) * BlockWeights::get().max_block;
pub const MaxScheduledPerBlock: u32 = 50;
pub const NoPreimagePostponement: Option<BlockNumber> = Some(10);
}
type ScheduleOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>,
>;
/// Used the compare the privilege of an origin inside the scheduler.
pub struct OriginPrivilegeCmp;
impl PrivilegeCmp<OriginCaller> for OriginPrivilegeCmp {
fn cmp_privilege(left: &OriginCaller, right: &OriginCaller) -> Option<Ordering> {
if left == right {
return Some(Ordering::Equal);
}
match (left, right) {
// Root is greater than anything.
(OriginCaller::system(frame_system::RawOrigin::Root), _) => Some(Ordering::Greater),
// Check which one has more yes votes.
(
OriginCaller::Council(pallet_collective::RawOrigin::Members(l_yes_votes, l_count)),
OriginCaller::Council(pallet_collective::RawOrigin::Members(r_yes_votes, r_count)),
) => Some((l_yes_votes * r_count).cmp(&(r_yes_votes * l_count))),
// For every other origin we don't care, as they are not used for `ScheduleOrigin`.
_ => None,
}
}
}
impl pallet_scheduler::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeOrigin = RuntimeOrigin;
type PalletsOrigin = OriginCaller;
type RuntimeCall = RuntimeCall;
type MaximumWeight = MaximumSchedulerWeight;
type ScheduleOrigin = ScheduleOrigin;
type MaxScheduledPerBlock = MaxScheduledPerBlock;
type WeightInfo = weights::pallet_scheduler::WeightInfo<Runtime>;
type OriginPrivilegeCmp = OriginPrivilegeCmp;
type Preimages = Preimage;
}
parameter_types! {
pub const InstantAllowed: bool = true;
pub const MaxVotes: u32 = 100;
pub const MaxProposals: u32 = 100;
}
impl pallet_democracy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type EnactmentPeriod = constants::governance::EnactmentPeriod;
type VoteLockingPeriod = constants::governance::VotingPeriod;
type LaunchPeriod = constants::governance::LaunchPeriod;
type VotingPeriod = constants::governance::VotingPeriod;
type MinimumDeposit = constants::governance::MinimumDeposit;
/// A straight majority of the council can decide what their next motion is.
type ExternalOrigin = pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
/// A majority can have the next scheduled referendum be a straight
/// majority-carries vote.
type ExternalMajorityOrigin = pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 2>;
/// A unanimous council can have the next scheduled referendum be a straight
/// default-carries (NTB) vote.
type ExternalDefaultOrigin = pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 1, 1>;
/// Two thirds of the technical committee can have an
/// ExternalMajority/ExternalDefault vote be tabled immediately and with a
/// shorter voting/enactment period.
type FastTrackOrigin = pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 2, 3>;
type InstantOrigin = pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>;
type InstantAllowed = InstantAllowed;
type FastTrackVotingPeriod = constants::governance::FastTrackVotingPeriod;
// To cancel a proposal which has been passed, 2/3 of the council must agree to
// it.
type CancellationOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 2, 3>,
>;
// To cancel a proposal before it has been passed, the technical committee must
// be unanimous or Root must agree.
type CancelProposalOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, TechnicalCollective, 1, 1>,
>;
type BlacklistOrigin = EnsureRoot<AccountId>;
// Any single technical committee member may veto a coming council proposal,
// however they can only do it once and it lasts only for the cooloff period.
type VetoOrigin = pallet_collective::EnsureMember<AccountId, TechnicalCollective>;
type CooloffPeriod = constants::governance::CooloffPeriod;
type Slash = Treasury;
type Scheduler = Scheduler;
type PalletsOrigin = OriginCaller;
type MaxVotes = MaxVotes;
type WeightInfo = weights::pallet_democracy::WeightInfo<Runtime>;
type MaxProposals = MaxProposals;
type Preimages = Preimage;
type MaxDeposits = ConstU32<100>;
type MaxBlacklisted = ConstU32<100>;
type SubmitOrigin = EnsureSigned<AccountId>;
}
parameter_types! {
pub const ProposalBond: Permill = Permill::from_percent(5);
pub const ProposalBondMinimum: Balance = 20 * KILT;
pub const SpendPeriod: BlockNumber = constants::governance::SPEND_PERIOD;
pub const Burn: Permill = Permill::zero();
pub const MaxApprovals: u32 = 100;
pub MaxProposalWeight: Weight = Perbill::from_percent(50) * BlockWeights::get().max_block;
}
type ApproveOrigin = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionAtLeast<AccountId, CouncilCollective, 3, 5>,
>;
type MoreThanHalfCouncil = EitherOfDiverse<
EnsureRoot<AccountId>,
pallet_collective::EnsureProportionMoreThan<AccountId, CouncilCollective, 1, 2>,
>;
impl pallet_treasury::Config for Runtime {
type PalletId = pallet_id::Treasury;
type Currency = Balances;
type ApproveOrigin = ApproveOrigin;
type RejectOrigin = MoreThanHalfCouncil;
type RuntimeEvent = RuntimeEvent;
type OnSlash = Treasury;
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type SpendOrigin = frame_support::traits::NeverEnsureOrigin<Balance>;
type Burn = Burn;
type BurnDestination = ();
type SpendFunds = ();
type WeightInfo = weights::pallet_treasury::WeightInfo<Runtime>;
type MaxApprovals = MaxApprovals;
}
type CouncilCollective = pallet_collective::Instance1;
impl pallet_collective::Config<CouncilCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MaxProposalWeight = MaxProposalWeight;
type MotionDuration = constants::governance::CouncilMotionDuration;
type MaxProposals = constants::governance::CouncilMaxProposals;
type MaxMembers = constants::governance::CouncilMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
type SetMembersOrigin = EnsureRoot<AccountId>;
}
type TechnicalCollective = pallet_collective::Instance2;
impl pallet_collective::Config<TechnicalCollective> for Runtime {
type RuntimeOrigin = RuntimeOrigin;
type MaxProposalWeight = MaxProposalWeight;
type Proposal = RuntimeCall;
type RuntimeEvent = RuntimeEvent;
type MotionDuration = constants::governance::TechnicalMotionDuration;
type MaxProposals = constants::governance::TechnicalMaxProposals;
type MaxMembers = constants::governance::TechnicalMaxMembers;
type DefaultVote = pallet_collective::PrimeDefaultVote;
type WeightInfo = weights::pallet_collective::WeightInfo<Runtime>;
type SetMembersOrigin = EnsureRoot<AccountId>;
}
type TechnicalMembershipProvider = pallet_membership::Instance1;
impl pallet_membership::Config<TechnicalMembershipProvider> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = MoreThanHalfCouncil;
type RemoveOrigin = MoreThanHalfCouncil;
type SwapOrigin = MoreThanHalfCouncil;
type ResetOrigin = MoreThanHalfCouncil;
type PrimeOrigin = MoreThanHalfCouncil;
type MembershipInitialized = TechnicalCommittee;
type MembershipChanged = TechnicalCommittee;
type MaxMembers = constants::governance::TechnicalMaxMembers;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
type TipsMembershipProvider = pallet_membership::Instance2;
impl pallet_membership::Config<TipsMembershipProvider> for Runtime {
type RuntimeEvent = RuntimeEvent;
type AddOrigin = MoreThanHalfCouncil;
type RemoveOrigin = MoreThanHalfCouncil;
type SwapOrigin = MoreThanHalfCouncil;
type ResetOrigin = MoreThanHalfCouncil;
type PrimeOrigin = MoreThanHalfCouncil;
type MembershipInitialized = ();
type MembershipChanged = ();
type MaxMembers = constants::governance::TipperMaxMembers;
type WeightInfo = weights::pallet_membership::WeightInfo<Runtime>;
}
impl pallet_tips::Config for Runtime {
type MaximumReasonLength = constants::tips::MaximumReasonLength;
type DataDepositPerByte = constants::ByteDeposit;
type Tippers = runtime_common::Tippers<Runtime, TipsMembershipProvider>;
type TipCountdown = constants::tips::TipCountdown;
type TipFindersFee = constants::tips::TipFindersFee;
type TipReportDepositBase = constants::tips::TipReportDepositBase;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_tips::WeightInfo<Runtime>;
}
impl pallet_configuration::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::pallet_configuration::WeightInfo<Runtime>;
type EnsureOrigin = AsEnsureOriginWithArg<EnsureRoot<AccountId>>;
}
impl attestation::Config for Runtime {
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::attestation::WeightInfo<Runtime>;
type Currency = Balances;
type Deposit = constants::attestation::AttestationDeposit;
type MaxDelegatedAttestations = constants::attestation::MaxDelegatedAttestations;
type AttesterId = DidIdentifier;
type AuthorizationId = AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>;
type AccessControl = PalletAuthorize<DelegationAc<Runtime>>;
type BalanceMigrationManager = Migration;
}
impl delegation::Config for Runtime {
type DelegationEntityId = DidIdentifier;
type DelegationNodeId = Hash;
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
#[cfg(not(feature = "runtime-benchmarks"))]
type DelegationSignatureVerification = did::DidSignatureVerify<Runtime>;
#[cfg(not(feature = "runtime-benchmarks"))]
type Signature = did::DidSignature;
#[cfg(feature = "runtime-benchmarks")]
type Signature = DummySignature;
#[cfg(feature = "runtime-benchmarks")]
type DelegationSignatureVerification = AlwaysVerify<AccountId, Vec<u8>, Self::Signature>;
type RuntimeEvent = RuntimeEvent;
type RuntimeHoldReason = RuntimeHoldReason;
type MaxSignatureByteLength = constants::delegation::MaxSignatureByteLength;
type MaxParentChecks = constants::delegation::MaxParentChecks;
type MaxRevocations = constants::delegation::MaxRevocations;
type MaxRemovals = constants::delegation::MaxRemovals;
type MaxChildren = constants::delegation::MaxChildren;
type WeightInfo = weights::delegation::WeightInfo<Runtime>;
type Currency = Balances;
type Deposit = constants::delegation::DelegationDeposit;
type BalanceMigrationManager = Migration;
}
impl ctype::Config for Runtime {
type CtypeCreatorId = AccountId;
type Currency = Balances;
type Fee = constants::CtypeFee;
type FeeCollector = runtime_common::SendDustAndFeesToTreasury<Runtime>;
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
type OverarchingOrigin = EnsureRoot<AccountId>;
type RuntimeEvent = RuntimeEvent;
type WeightInfo = weights::ctype::WeightInfo<Runtime>;
}
impl did::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeOrigin = RuntimeOrigin;
type Currency = Balances;
type DidIdentifier = DidIdentifier;
type KeyDeposit = constants::did::KeyDeposit;
type ServiceEndpointDeposit = constants::did::ServiceEndpointDeposit;
type BaseDeposit = constants::did::DidBaseDeposit;
type Fee = constants::did::DidFee;
type FeeCollector = runtime_common::SendDustAndFeesToTreasury<Runtime>;
#[cfg(not(feature = "runtime-benchmarks"))]
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
#[cfg(not(feature = "runtime-benchmarks"))]
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
#[cfg(feature = "runtime-benchmarks")]
type EnsureOrigin = EnsureSigned<DidIdentifier>;
#[cfg(feature = "runtime-benchmarks")]
type OriginSuccess = DidIdentifier;
type MaxNewKeyAgreementKeys = constants::did::MaxNewKeyAgreementKeys;
type MaxTotalKeyAgreementKeys = constants::did::MaxTotalKeyAgreementKeys;
type MaxPublicKeysPerDid = constants::did::MaxPublicKeysPerDid;
type MaxBlocksTxValidity = constants::did::MaxBlocksTxValidity;
type MaxNumberOfServicesPerDid = constants::did::MaxNumberOfServicesPerDid;
type MaxServiceIdLength = constants::did::MaxServiceIdLength;
type MaxServiceTypeLength = constants::did::MaxServiceTypeLength;
type MaxServiceUrlLength = constants::did::MaxServiceUrlLength;
type MaxNumberOfTypesPerService = constants::did::MaxNumberOfTypesPerService;
type MaxNumberOfUrlsPerService = constants::did::MaxNumberOfUrlsPerService;
type WeightInfo = weights::did::WeightInfo<Runtime>;
type BalanceMigrationManager = Migration;
}
impl pallet_did_lookup::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type RuntimeEvent = RuntimeEvent;
type DidIdentifier = DidIdentifier;
type Currency = Balances;
type Deposit = constants::did_lookup::DidLookupDeposit;
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
type WeightInfo = weights::pallet_did_lookup::WeightInfo<Runtime>;
type BalanceMigrationManager = Migration;
}
impl pallet_web3_names::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type BanOrigin = EnsureRoot<AccountId>;
type OwnerOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
type Currency = Balances;
type Deposit = constants::web3_names::Web3NameDeposit;
type RuntimeEvent = RuntimeEvent;
type MaxNameLength = constants::web3_names::MaxNameLength;
type MinNameLength = constants::web3_names::MinNameLength;
type Web3Name = pallet_web3_names::web3_name::AsciiWeb3Name<Runtime>;
type Web3NameOwner = DidIdentifier;
type WeightInfo = weights::pallet_web3_names::WeightInfo<Runtime>;
type BalanceMigrationManager = Migration;
}
impl pallet_inflation::Config for Runtime {
type Currency = Balances;
type InitialPeriodLength = constants::treasury::InitialPeriodLength;
type InitialPeriodReward = constants::treasury::InitialPeriodReward;
type Beneficiary = runtime_common::SendDustAndFeesToTreasury<Runtime>;
type WeightInfo = weights::pallet_inflation::WeightInfo<Runtime>;
}
impl parachain_staking::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type Currency = Balances;
type CurrencyBalance = Balance;
type FreezeIdentifier = RuntimeFreezeReason;
type MinBlocksPerRound = constants::staking::MinBlocksPerRound;
type DefaultBlocksPerRound = constants::staking::DefaultBlocksPerRound;
type StakeDuration = constants::staking::StakeDuration;
type ExitQueueDelay = constants::staking::ExitQueueDelay;
type MinCollators = constants::staking::MinCollators;
type MinRequiredCollators = constants::staking::MinRequiredCollators;
type MaxDelegationsPerRound = constants::staking::MaxDelegationsPerRound;
type MaxDelegatorsPerCollator = constants::staking::MaxDelegatorsPerCollator;
type MinCollatorStake = constants::staking::MinCollatorStake;
type MinCollatorCandidateStake = constants::staking::MinCollatorStake;
type MaxTopCandidates = constants::staking::MaxCollatorCandidates;
type MinDelegatorStake = constants::staking::MinDelegatorStake;
type MaxUnstakeRequests = constants::staking::MaxUnstakeRequests;
type NetworkRewardRate = constants::staking::NetworkRewardRate;
type NetworkRewardStart = constants::staking::NetworkRewardStart;
type NetworkRewardBeneficiary = runtime_common::SendDustAndFeesToTreasury<Runtime>;
type WeightInfo = weights::parachain_staking::WeightInfo<Runtime>;
const BLOCKS_PER_YEAR: BlockNumberFor<Self> = constants::BLOCKS_PER_YEAR;
}
impl pallet_utility::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type PalletsOrigin = OriginCaller;
type WeightInfo = weights::pallet_utility::WeightInfo<Runtime>;
}
impl public_credentials::Config for Runtime {
type RuntimeHoldReason = RuntimeHoldReason;
type AccessControl = PalletAuthorize<DelegationAc<Runtime>>;
type AttesterId = DidIdentifier;
type AuthorizationId = AuthorizationId<<Runtime as delegation::Config>::DelegationNodeId>;
type CredentialId = Hash;
type CredentialHash = BlakeTwo256;
type Currency = Balances;
type Deposit = runtime_common::constants::public_credentials::Deposit;
type EnsureOrigin = did::EnsureDidOrigin<DidIdentifier, AccountId>;
type MaxEncodedClaimsLength = runtime_common::constants::public_credentials::MaxEncodedClaimsLength;
type MaxSubjectIdLength = runtime_common::constants::public_credentials::MaxSubjectIdLength;
type OriginSuccess = did::DidRawOrigin<AccountId, DidIdentifier>;
type RuntimeEvent = RuntimeEvent;
type SubjectId = runtime_common::assets::AssetDid;
type WeightInfo = weights::public_credentials::WeightInfo<Runtime>;
type BalanceMigrationManager = Migration;
}
/// The type used to represent the kinds of proxying allowed.
#[derive(
Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, MaxEncodedLen, scale_info::TypeInfo,
)]
pub enum ProxyType {
/// Allow for any call.
Any,
/// Allow for calls that do not move tokens out of the caller's account.
NonTransfer,
/// Allow for governance-related calls.
Governance,
/// Allow for staking-related calls.
ParachainStaking,
/// Allow for calls that cancel proxy information.
CancelProxy,
/// Allow for calls that do not result in a deposit being claimed (e.g., for
/// attestations, delegations, or DIDs).
NonDepositClaiming,
}
impl Default for ProxyType {
fn default() -> Self {
Self::Any
}
}
impl InstanceFilter<RuntimeCall> for ProxyType {
fn filter(&self, c: &RuntimeCall) -> bool {
match self {
ProxyType::Any => true,
ProxyType::NonTransfer => matches!(
c,
RuntimeCall::Attestation(..)
// Excludes `Balances`
| RuntimeCall::Council(..)
| RuntimeCall::Ctype(..)
| RuntimeCall::Delegation(..)
| RuntimeCall::Democracy(..)
| RuntimeCall::DepositStorage(..)
| RuntimeCall::Did(..)
| RuntimeCall::DidLookup(..)
| RuntimeCall::DipProvider(..)
| RuntimeCall::Indices(
// Excludes `force_transfer`, and `transfer`
pallet_indices::Call::claim { .. }
| pallet_indices::Call::free { .. }
| pallet_indices::Call::freeze { .. }
)
| RuntimeCall::Multisig(..)
| RuntimeCall::ParachainStaking(..)
// Excludes `ParachainSystem`
| RuntimeCall::Preimage(..)
| RuntimeCall::Proxy(..)
| RuntimeCall::PublicCredentials(..)
| RuntimeCall::Scheduler(..)
| RuntimeCall::Session(..)
| RuntimeCall::System(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::TechnicalMembership(..)
| RuntimeCall::TipsMembership(..)
| RuntimeCall::Timestamp(..)
| RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
| RuntimeCall::Vesting(
// Excludes `force_vested_transfer`, `merge_schedules`, and `vested_transfer`
pallet_vesting::Call::vest { .. }
| pallet_vesting::Call::vest_other { .. }
)
| RuntimeCall::Web3Names(..),
),
ProxyType::NonDepositClaiming => matches!(
c,
RuntimeCall::Attestation(
// Excludes `reclaim_deposit`
attestation::Call::add { .. }
| attestation::Call::remove { .. }
| attestation::Call::revoke { .. }
| attestation::Call::change_deposit_owner { .. }
| attestation::Call::update_deposit { .. }
)
// Excludes `Balances`
| RuntimeCall::Council(..)
| RuntimeCall::Ctype(..)
| RuntimeCall::Delegation(
// Excludes `reclaim_deposit`
delegation::Call::add_delegation { .. }
| delegation::Call::create_hierarchy { .. }
| delegation::Call::remove_delegation { .. }
| delegation::Call::revoke_delegation { .. }
| delegation::Call::update_deposit { .. }
| delegation::Call::change_deposit_owner { .. }
)
| RuntimeCall::Democracy(..)
// Excludes `DepositStorage`
| RuntimeCall::Did(
// Excludes `reclaim_deposit`
did::Call::add_key_agreement_key { .. }
| did::Call::add_service_endpoint { .. }
| did::Call::create { .. }
| did::Call::delete { .. }
| did::Call::remove_attestation_key { .. }
| did::Call::remove_delegation_key { .. }
| did::Call::remove_key_agreement_key { .. }
| did::Call::remove_service_endpoint { .. }
| did::Call::set_attestation_key { .. }
| did::Call::set_authentication_key { .. }
| did::Call::set_delegation_key { .. }
| did::Call::submit_did_call { .. }
| did::Call::update_deposit { .. }
| did::Call::change_deposit_owner { .. }
| did::Call::create_from_account { .. }
| did::Call::dispatch_as { .. }
)
| RuntimeCall::DidLookup(
// Excludes `reclaim_deposit`
pallet_did_lookup::Call::associate_account { .. }
| pallet_did_lookup::Call::associate_sender { .. }
| pallet_did_lookup::Call::remove_account_association { .. }
| pallet_did_lookup::Call::remove_sender_association { .. }
| pallet_did_lookup::Call::update_deposit { .. }
| pallet_did_lookup::Call::change_deposit_owner { .. }
)
| RuntimeCall::DipProvider(..)
| RuntimeCall::Indices(..)
| RuntimeCall::Multisig(..)
| RuntimeCall::ParachainStaking(..)
// Excludes `ParachainSystem`
| RuntimeCall::Preimage(..)
| RuntimeCall::Proxy(..)
| RuntimeCall::PublicCredentials(
// Excludes `reclaim_deposit`
public_credentials::Call::add { .. }
| public_credentials::Call::revoke { .. }
| public_credentials::Call::unrevoke { .. }
| public_credentials::Call::remove { .. }
| public_credentials::Call::update_deposit { .. }
| public_credentials::Call::change_deposit_owner { .. }
)
| RuntimeCall::Scheduler(..)
| RuntimeCall::Session(..)
// Excludes `Sudo`
| RuntimeCall::System(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::TechnicalMembership(..)
| RuntimeCall::TipsMembership(..)
| RuntimeCall::Timestamp(..)
| RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
| RuntimeCall::Vesting(..)
| RuntimeCall::Web3Names(
// Excludes `ban`, and `reclaim_deposit`
pallet_web3_names::Call::claim { .. }
| pallet_web3_names::Call::release_by_owner { .. }
| pallet_web3_names::Call::unban { .. }
| pallet_web3_names::Call::update_deposit { .. }
| pallet_web3_names::Call::change_deposit_owner { .. }
),
),
ProxyType::Governance => matches!(
c,
RuntimeCall::Council(..)
| RuntimeCall::Democracy(..)
| RuntimeCall::TechnicalCommittee(..)
| RuntimeCall::TechnicalMembership(..)
| RuntimeCall::TipsMembership(..)
| RuntimeCall::Treasury(..)
| RuntimeCall::Utility(..)
),
ProxyType::ParachainStaking => {
matches!(
c,
RuntimeCall::ParachainStaking(..) | RuntimeCall::Session(..) | RuntimeCall::Utility(..)
)
}
ProxyType::CancelProxy => matches!(c, RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. })),
}
}
fn is_superset(&self, o: &Self) -> bool {
match (self, o) {
(x, y) if x == y => true,
// "anything" always contains any subset
(ProxyType::Any, _) => true,
(_, ProxyType::Any) => false,
// reclaiming deposits is part of NonTransfer but not in NonDepositClaiming
(ProxyType::NonDepositClaiming, ProxyType::NonTransfer) => false,
// everything except NonTransfer and Any is part of NonDepositClaiming
(ProxyType::NonDepositClaiming, _) => true,
// Transfers are part of NonDepositClaiming but not in NonTransfer
(ProxyType::NonTransfer, ProxyType::NonDepositClaiming) => false,
// everything except NonDepositClaiming and Any is part of NonTransfer
(ProxyType::NonTransfer, _) => true,
_ => false,
}
}
}
impl pallet_proxy::Config for Runtime {
type RuntimeEvent = RuntimeEvent;
type RuntimeCall = RuntimeCall;
type Currency = Balances;
type ProxyType = ProxyType;
type ProxyDepositBase = constants::proxy::ProxyDepositBase;
type ProxyDepositFactor = constants::proxy::ProxyDepositFactor;
type MaxProxies = constants::proxy::MaxProxies;
type MaxPending = constants::proxy::MaxPending;
type CallHasher = BlakeTwo256;
type AnnouncementDepositBase = constants::proxy::AnnouncementDepositBase;
type AnnouncementDepositFactor = constants::proxy::AnnouncementDepositFactor;
type WeightInfo = weights::pallet_proxy::WeightInfo<Runtime>;
}
construct_runtime! {
pub enum Runtime
{
System: frame_system = 0,
// DELETED: RandomnessCollectiveFlip: pallet_insecure_randomness_collective_flip = 1,
Timestamp: pallet_timestamp = 2,
Indices: pallet_indices exclude_parts { Config } = 5,
Balances: pallet_balances = 6,
TransactionPayment: pallet_transaction_payment exclude_parts { Config } = 7,
Sudo: pallet_sudo = 8,
Configuration: pallet_configuration = 9,
// Consensus support.
// The following order MUST NOT be changed: Aura -> Session -> Staking -> Authorship -> AuraExt
// Dependencies: AuraExt on Aura, Authorship and Session on ParachainStaking
Aura: pallet_aura = 23,
Session: pallet_session = 22,
ParachainStaking: parachain_staking = 21,
Authorship: pallet_authorship = 20,
AuraExt: cumulus_pallet_aura_ext = 24,
Democracy: pallet_democracy = 30,
Council: pallet_collective::<Instance1> = 31,
TechnicalCommittee: pallet_collective::<Instance2> = 32,
// reserved: parachain council election = 33,
TechnicalMembership: pallet_membership::<Instance1> = 34,
Treasury: pallet_treasury = 35,
// DELETED: RelayMigration: pallet_relay_migration = 36,
// DELETED: DynFilter: pallet_dyn_filter = 37,
// A stateless pallet with helper extrinsics (batch extrinsics, send from different origins, ...)
Utility: pallet_utility = 40,
// Vesting. Usable initially, but removed once all vesting is finished.
Vesting: pallet_vesting = 41,
Scheduler: pallet_scheduler = 42,
// Allowing accounts to give permission to other accounts to dispatch types of calls from their signed origin
Proxy: pallet_proxy = 43,
// Preimage pallet allows the storage of large bytes blob
Preimage: pallet_preimage = 44,
// Tips module to reward contributions to the ecosystem with small amount of KILTs.
TipsMembership: pallet_membership::<Instance2> = 45,
Tips: pallet_tips = 46,
Multisig: pallet_multisig = 47,
// KILT Pallets. Start indices 60 to leave room
// DELETED: KiltLaunch: kilt_launch = 60,
Ctype: ctype = 61,
Attestation: attestation = 62,
Delegation: delegation = 63,
Did: did = 64,
// DELETED: CrowdloanContributors = 65,
Inflation: pallet_inflation = 66,
DidLookup: pallet_did_lookup = 67,
Web3Names: pallet_web3_names = 68,
PublicCredentials: public_credentials = 69,
Migration: pallet_migration = 70,
DipProvider: pallet_dip_provider = 71,
DepositStorage: pallet_deposit_storage = 72,
// Parachains pallets. Start indices at 80 to leave room.