Skip to content

Commit deaa72d

Browse files
authored
Merge pull request #251 from opentensor/subnet_hyperparameters_fix
Allow the setting of specific subnet hyperparameters on chain.
2 parents e607d7e + a6583f5 commit deaa72d

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

pallets/subtensor/src/subnet_info.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ pub struct SubnetHyperparams {
4040
weights_version: Compact<u64>,
4141
weights_rate_limit: Compact<u64>,
4242
adjustment_interval: Compact<u16>,
43-
adjustment_alpha: Compact<u64>,
4443
activity_cutoff: Compact<u16>,
4544
registration_allowed: bool,
4645
target_regs_per_interval: Compact<u16>,
@@ -50,6 +49,8 @@ pub struct SubnetHyperparams {
5049
max_regs_per_block: Compact<u16>,
5150
serving_rate_limit: Compact<u64>,
5251
max_validators: Compact<u16>,
52+
adjustment_alpha: Compact<u64>,
53+
difficulty: Compact<u64>,
5354
}
5455

5556
impl<T: Config> Pallet<T> {
@@ -60,7 +61,6 @@ impl<T: Config> Pallet<T> {
6061

6162
let rho = Self::get_rho(netuid);
6263
let kappa = Self::get_kappa(netuid);
63-
let difficulty = Self::get_difficulty_as_u64(netuid);
6464
let immunity_period = Self::get_immunity_period(netuid);
6565
let max_allowed_validators = Self::get_max_allowed_validators(netuid);
6666
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
@@ -73,6 +73,9 @@ impl<T: Config> Pallet<T> {
7373
let network_modality = <NetworkModality<T>>::get(netuid);
7474
let emission_values = Self::get_emission_value(netuid);
7575
let burn: Compact<u64> = Self::get_burn_as_u64(netuid).into();
76+
let adjustment_alpha: Compact<u64> = Self::get_adjustment_alpha(netuid).into();
77+
let difficulty: Compact<u64> = Self::get_difficulty(netuid).into();
78+
let bonds_moving_avg: Compact<u64> = Self::get_bonds_moving_average(netuid).into();
7679

7780
// DEPRECATED
7881
let network_connect: Vec<[u16; 2]> = Vec::<[u16; 2]>::new();
@@ -83,7 +86,6 @@ impl<T: Config> Pallet<T> {
8386
return Some(SubnetInfo {
8487
rho: rho.into(),
8588
kappa: kappa.into(),
86-
difficulty: difficulty.into(),
8789
immunity_period: immunity_period.into(),
8890
netuid: netuid.into(),
8991
max_allowed_validators: max_allowed_validators.into(),
@@ -98,6 +100,10 @@ impl<T: Config> Pallet<T> {
98100
network_connect,
99101
emission_values: emission_values.into(),
100102
burn,
103+
difficulty: difficulty.into(),
104+
adjustment_alpha: adjustment_alpha.into(),
105+
bonds_moving_avg: bonds_moving_avg.into(),
106+
101107
owner: Self::get_subnet_owner(netuid).into(),
102108
});
103109
}
@@ -131,7 +137,6 @@ impl<T: Config> Pallet<T> {
131137

132138
let rho = Self::get_rho(netuid);
133139
let kappa = Self::get_kappa(netuid);
134-
let difficulty = Self::get_difficulty_as_u64(netuid);
135140
let immunity_period = Self::get_immunity_period(netuid);
136141
let min_allowed_weights = Self::get_min_allowed_weights(netuid);
137142
let max_weights_limit = Self::get_max_weight_limit(netuid);
@@ -141,7 +146,6 @@ impl<T: Config> Pallet<T> {
141146
let weights_version = Self::get_weights_version_key(netuid);
142147
let weights_rate_limit = Self::get_weights_set_rate_limit(netuid);
143148
let adjustment_interval = Self::get_adjustment_interval(netuid);
144-
let adjustment_alpha = Self::get_adjustment_alpha(netuid);
145149
let activity_cutoff = Self::get_activity_cutoff(netuid);
146150
let registration_allowed = Self::get_network_registration_allowed(netuid);
147151
let target_regs_per_interval = Self::get_target_registrations_per_interval(netuid);
@@ -151,6 +155,9 @@ impl<T: Config> Pallet<T> {
151155
let max_regs_per_block = Self::get_max_registrations_per_block(netuid);
152156
let serving_rate_limit = Self::get_serving_rate_limit(netuid);
153157
let max_validators = Self::get_max_allowed_validators(netuid);
158+
let adjustment_alpha = Self::get_adjustment_alpha(netuid);
159+
let difficulty = Self::get_difficulty_as_u64(netuid);
160+
154161

155162
return Some(SubnetHyperparams {
156163
rho: rho.into(),
@@ -164,7 +171,6 @@ impl<T: Config> Pallet<T> {
164171
weights_version: weights_version.into(),
165172
weights_rate_limit: weights_rate_limit.into(),
166173
adjustment_interval: adjustment_interval.into(),
167-
adjustment_alpha: adjustment_alpha.into(),
168174
activity_cutoff: activity_cutoff.into(),
169175
registration_allowed,
170176
target_regs_per_interval: target_regs_per_interval.into(),
@@ -174,6 +180,8 @@ impl<T: Config> Pallet<T> {
174180
max_regs_per_block: max_regs_per_block.into(),
175181
serving_rate_limit: serving_rate_limit.into(),
176182
max_validators: max_validators.into(),
183+
adjustment_alpha: adjustment_alpha.into(),
184+
difficulty: difficulty.into()
177185
});
178186
}
179187
}

runtime/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
121121
// `spec_version`, and `authoring_version` are the same between Wasm and native.
122122
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
123123
// the compatible custom types.
124-
spec_version: 142,
124+
spec_version: 143,
125125
impl_version: 1,
126126
apis: RUNTIME_API_VERSIONS,
127127
transaction_version: 1,

0 commit comments

Comments
 (0)