66#[ cfg( feature = "std" ) ]
77include ! ( concat!( env!( "OUT_DIR" ) , "/wasm_binary.rs" ) ) ;
88
9- use codec:: Encode ;
9+ use codec:: { Decode , Encode , MaxEncodedLen } ;
1010
1111use pallet_commitments:: CanCommit ;
1212use pallet_grandpa:: {
@@ -17,6 +17,7 @@ use frame_support::pallet_prelude::{DispatchError, DispatchResult, Get};
1717use frame_system:: { EnsureNever , EnsureRoot , RawOrigin } ;
1818
1919use pallet_registry:: CanRegisterIdentity ;
20+ use scale_info:: TypeInfo ;
2021use smallvec:: smallvec;
2122use sp_api:: impl_runtime_apis;
2223use sp_consensus_aura:: sr25519:: AuthorityId as AuraId ;
@@ -40,8 +41,8 @@ use sp_version::RuntimeVersion;
4041pub use frame_support:: {
4142 construct_runtime, parameter_types,
4243 traits:: {
43- ConstBool , ConstU128 , ConstU32 , ConstU64 , ConstU8 , KeyOwnerProofSystem , PrivilegeCmp ,
44- Randomness , StorageInfo ,
44+ ConstBool , ConstU128 , ConstU32 , ConstU64 , ConstU8 , InstanceFilter , KeyOwnerProofSystem ,
45+ PrivilegeCmp , Randomness , StorageInfo ,
4546 } ,
4647 weights:: {
4748 constants:: {
@@ -50,7 +51,7 @@ pub use frame_support::{
5051 IdentityFee , Weight , WeightToFeeCoefficient , WeightToFeeCoefficients ,
5152 WeightToFeePolynomial ,
5253 } ,
53- StorageValue ,
54+ RuntimeDebug , StorageValue ,
5455} ;
5556pub use frame_system:: Call as SystemCall ;
5657pub use pallet_balances:: Call as BalancesCall ;
@@ -87,6 +88,13 @@ type MemberCount = u32;
8788
8889pub type Nonce = u32 ;
8990
91+ // Method used to calculate the fee of an extrinsic
92+ pub const fn deposit ( items : u32 , bytes : u32 ) -> Balance {
93+ pub const ITEMS_FEE : Balance = 2_000 * 10_000 ;
94+ pub const BYTES_FEE : Balance = 100 * 10_000 ;
95+ items as Balance * ITEMS_FEE + bytes as Balance * BYTES_FEE
96+ }
97+
9098// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
9199// the specifics of the runtime. They can then be made to be agnostic over specific formats
92100// of data like extrinsics, allowing for them to continue syncing the network through upgrades
@@ -472,10 +480,13 @@ impl pallet_sudo::Config for Runtime {
472480}
473481
474482parameter_types ! {
475- // One storage item; key size is 32; value is size 4+4+16+32 bytes = 56 bytes.
476- pub const DepositBase : Balance = ( 1 ) as Balance * 2_000 * 10_000 + ( 88 as Balance ) * 100 * 10_000 ;
483+ // According to multisig pallet, key and value size be computed as follows:
484+ // value size is `4 + sizeof((BlockNumber, Balance, AccountId))` bytes
485+ // key size is `32 + sizeof(AccountId)` bytes.
486+ // For our case, One storage item; key size is 32+32=64 bytes; value is size 4+4+8+32 bytes = 48 bytes.
487+ pub const DepositBase : Balance = deposit( 1 , 112 ) ;
477488 // Additional storage item size of 32 bytes.
478- pub const DepositFactor : Balance = ( 0 ) as Balance * 2_000 * 10_000 + ( 32 as Balance ) * 100 * 10_000 ;
489+ pub const DepositFactor : Balance = deposit ( 0 , 32 ) ;
479490 pub const MaxSignatories : u32 = 100 ;
480491}
481492
@@ -489,6 +500,121 @@ impl pallet_multisig::Config for Runtime {
489500 type WeightInfo = pallet_multisig:: weights:: SubstrateWeight < Runtime > ;
490501}
491502
503+ // Proxy Pallet config
504+ parameter_types ! {
505+ // One storage item; key size sizeof(AccountId) = 32, value sizeof(Balance) = 8; 40 total
506+ pub const ProxyDepositBase : Balance = deposit( 1 , 40 ) ;
507+ // Adding 32 bytes + sizeof(ProxyType) = 32 + 1
508+ pub const ProxyDepositFactor : Balance = deposit( 0 , 33 ) ;
509+ pub const MaxProxies : u32 = 20 ; // max num proxies per acct
510+ pub const MaxPending : u32 = 15 * 5 ; // max blocks pending ~15min
511+ // 16 bytes
512+ pub const AnnouncementDepositBase : Balance = deposit( 1 , 16 ) ;
513+ // 68 bytes per announcement
514+ pub const AnnouncementDepositFactor : Balance = deposit( 0 , 68 ) ;
515+ }
516+
517+ #[ derive(
518+ Copy ,
519+ Clone ,
520+ Eq ,
521+ PartialEq ,
522+ Ord ,
523+ PartialOrd ,
524+ Encode ,
525+ Decode ,
526+ RuntimeDebug ,
527+ MaxEncodedLen ,
528+ TypeInfo ,
529+ ) ]
530+ pub enum ProxyType {
531+ Any ,
532+ Owner , // Subnet owner Calls
533+ NonCritical ,
534+ NonTransfer ,
535+ Senate ,
536+ NonFungibile , // Nothing involving moving TAO
537+ Triumvirate ,
538+ Governance , // Both above governance
539+ Staking ,
540+ Registration ,
541+ }
542+ impl Default for ProxyType {
543+ fn default ( ) -> Self {
544+ Self :: Any
545+ }
546+ } // allow all Calls; required to be most permissive
547+ impl InstanceFilter < RuntimeCall > for ProxyType {
548+ fn filter ( & self , c : & RuntimeCall ) -> bool {
549+ match self {
550+ ProxyType :: Any => true ,
551+ ProxyType :: NonTransfer => !matches ! ( c, RuntimeCall :: Balances ( ..) ) ,
552+ ProxyType :: NonFungibile => !matches ! (
553+ c,
554+ RuntimeCall :: Balances ( ..)
555+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: add_stake { .. } )
556+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: remove_stake { .. } )
557+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: burned_register { .. } )
558+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: root_register { .. } )
559+ ) ,
560+ ProxyType :: Owner => matches ! ( c, RuntimeCall :: AdminUtils ( ..) ) ,
561+ ProxyType :: NonCritical => !matches ! (
562+ c,
563+ RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: dissolve_network { .. } )
564+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: root_register { .. } )
565+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: burned_register { .. } )
566+ | RuntimeCall :: Triumvirate ( ..)
567+ ) ,
568+ ProxyType :: Triumvirate => matches ! (
569+ c,
570+ RuntimeCall :: Triumvirate ( ..) | RuntimeCall :: TriumvirateMembers ( ..)
571+ ) ,
572+ ProxyType :: Senate => matches ! ( c, RuntimeCall :: SenateMembers ( ..) ) ,
573+ ProxyType :: Governance => matches ! (
574+ c,
575+ RuntimeCall :: SenateMembers ( ..)
576+ | RuntimeCall :: Triumvirate ( ..)
577+ | RuntimeCall :: TriumvirateMembers ( ..)
578+ ) ,
579+ ProxyType :: Staking => matches ! (
580+ c,
581+ RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: add_stake { .. } )
582+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: remove_stake { .. } )
583+ ) ,
584+ ProxyType :: Registration => matches ! (
585+ c,
586+ RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: burned_register { .. } )
587+ | RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: register { .. } )
588+ ) ,
589+ }
590+ }
591+ fn is_superset ( & self , o : & Self ) -> bool {
592+ match ( self , o) {
593+ ( x, y) if x == y => true ,
594+ ( ProxyType :: Any , _) => true ,
595+ ( _, ProxyType :: Any ) => false ,
596+ ( ProxyType :: NonTransfer , _) => true ,
597+ ( ProxyType :: Governance , ProxyType :: Triumvirate | ProxyType :: Senate ) => true ,
598+ _ => false ,
599+ }
600+ }
601+ }
602+
603+ impl pallet_proxy:: Config for Runtime {
604+ type RuntimeEvent = RuntimeEvent ;
605+ type RuntimeCall = RuntimeCall ;
606+ type Currency = Balances ;
607+ type ProxyType = ProxyType ;
608+ type ProxyDepositBase = ProxyDepositBase ;
609+ type ProxyDepositFactor = ProxyDepositFactor ;
610+ type MaxProxies = MaxProxies ;
611+ type WeightInfo = pallet_proxy:: weights:: SubstrateWeight < Runtime > ;
612+ type MaxPending = MaxPending ;
613+ type CallHasher = BlakeTwo256 ;
614+ type AnnouncementDepositBase = AnnouncementDepositBase ;
615+ type AnnouncementDepositFactor = AnnouncementDepositFactor ;
616+ }
617+
492618parameter_types ! {
493619 pub MaximumSchedulerWeight : Weight = Perbill :: from_percent( 80 ) *
494620 BlockWeights :: get( ) . max_block;
@@ -540,8 +666,8 @@ impl pallet_scheduler::Config for Runtime {
540666
541667parameter_types ! {
542668 pub const PreimageMaxSize : u32 = 4096 * 1024 ;
543- pub const PreimageBaseDeposit : Balance = ( 2 ) as Balance * 2_000 * 10_000_000 + ( 64 as Balance ) * 100 * 1_000_000 ;
544- pub const PreimageByteDeposit : Balance = ( 0 ) as Balance * 2_000 * 10_000_000 + ( 1 as Balance ) * 100 * 1_000_000 ;
669+ pub const PreimageBaseDeposit : Balance = deposit ( 2 , 64 ) ;
670+ pub const PreimageByteDeposit : Balance = deposit ( 0 , 1 ) ;
545671}
546672
547673impl pallet_preimage:: Config for Runtime {
@@ -991,6 +1117,7 @@ construct_runtime!(
9911117 Multisig : pallet_multisig,
9921118 Preimage : pallet_preimage,
9931119 Scheduler : pallet_scheduler,
1120+ Proxy : pallet_proxy,
9941121 Registry : pallet_registry,
9951122 Commitments : pallet_commitments,
9961123 AdminUtils : pallet_admin_utils
0 commit comments