Skip to content

Commit

Permalink
Added particle metadata, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cyborgshead committed Jan 5, 2024
1 parent 30513af commit 544c6c2
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 163 deletions.
61 changes: 29 additions & 32 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ use crate::state::{
BURN_REGISTRATIONS_THIS_INTERVAL, CONSENSUS, DEFAULT_TAKE, DELEGATES, DENOM, DIFFICULTY,
DIVIDENDS, EMISSION, EMISSION_VALUES, IMMUNITY_PERIOD, INCENTIVE, KAPPA, LAST_ADJUSTMENT_BLOCK,
LAST_UPDATE, MAX_ALLOWED_UIDS, MAX_ALLOWED_VALIDATORS, MAX_BURN, MAX_DIFFICULTY,
MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, MIN_ALLOWED_WEIGHTS, MIN_BURN, MIN_DIFFICULTY,
NETWORKS_ADDED, NETWORK_IMMUNITY_PERIOD, NETWORK_LAST_LOCK_COST, NETWORK_LAST_REGISTERED,
NETWORK_LOCK_REDUCTION_INTERVAL, NETWORK_MIN_LOCK_COST, NETWORK_MODALITY, NETWORK_RATE_LIMIT,
NETWORK_REGISTERED_AT, NETWORK_REGISTRATION_ALLOWED, OWNER, PENDING_EMISSION,
POW_REGISTRATIONS_THIS_INTERVAL, PROMETHEUS, PRUNING_SCORES, RANK,
MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, METADATA, MIN_ALLOWED_WEIGHTS, MIN_BURN,
MIN_DIFFICULTY, NETWORKS_ADDED, NETWORK_IMMUNITY_PERIOD, NETWORK_LAST_LOCK_COST,
NETWORK_LAST_REGISTERED, NETWORK_LOCK_REDUCTION_INTERVAL, NETWORK_MIN_LOCK_COST,
NETWORK_MODALITY, NETWORK_RATE_LIMIT, NETWORK_REGISTERED_AT, NETWORK_REGISTRATION_ALLOWED,
OWNER, PENDING_EMISSION, POW_REGISTRATIONS_THIS_INTERVAL, PROMETHEUS, PRUNING_SCORES, RANK,
RAO_RECYCLED_FOR_REGISTRATION, REGISTRATIONS_THIS_BLOCK, REGISTRATIONS_THIS_INTERVAL, RHO,
ROOT, SCALING_LAW_POWER, SERVING_RATE_LIMIT, STAKE, SUBNETWORK_N, SUBNET_LIMIT, SUBNET_LOCKED,
SUBNET_OWNER, SUBNET_OWNER_CUT, TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO, TOTAL_COLDKEY_STAKE,
ROOT, SERVING_RATE_LIMIT, STAKE, SUBNETWORK_N, SUBNET_LIMIT, SUBNET_LOCKED, SUBNET_OWNER,
SUBNET_OWNER_CUT, TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO, TOTAL_COLDKEY_STAKE,
TOTAL_HOTKEY_STAKE, TOTAL_ISSUANCE, TOTAL_NETWORKS, TOTAL_STAKE, TRUST, TX_RATE_LIMIT, UIDS,
VALIDATOR_PERMIT, VALIDATOR_TRUST, WEIGHTS_SET_RATE_LIMIT, WEIGHTS_VERSION_KEY,
};
Expand All @@ -48,8 +48,8 @@ use crate::utils::{
do_sudo_set_min_allowed_weights, do_sudo_set_min_burn, do_sudo_set_min_difficulty,
do_sudo_set_network_immunity_period, do_sudo_set_network_min_lock_cost,
do_sudo_set_network_rate_limit, do_sudo_set_network_registration_allowed,
do_sudo_set_rao_recycled, do_sudo_set_rho, do_sudo_set_scaling_law_power,
do_sudo_set_serving_rate_limit, do_sudo_set_subnet_limit, do_sudo_set_subnet_owner_cut,
do_sudo_set_rao_recycled, do_sudo_set_rho, do_sudo_set_serving_rate_limit,
do_sudo_set_subnet_limit, do_sudo_set_subnet_metadata, do_sudo_set_subnet_owner_cut,
do_sudo_set_target_registrations_per_interval, do_sudo_set_tempo, do_sudo_set_total_issuance,
do_sudo_set_tx_rate_limit, do_sudo_set_validator_permit_for_uid,
do_sudo_set_validator_prune_len, do_sudo_set_weights_set_rate_limit,
Expand Down Expand Up @@ -78,8 +78,6 @@ pub fn instantiate(
DENOM.save(deps.storage, &"boot".to_string())?;
}

// TODO remove from InstantiateMsg
// // Set initial total issuance from balances
TOTAL_ISSUANCE.save(deps.storage, &0)?;
TOTAL_STAKE.save(deps.storage, &0)?;

Expand All @@ -96,20 +94,17 @@ pub fn instantiate(
DEFAULT_TAKE.save(deps.storage, &4096)?;
TX_RATE_LIMIT.save(deps.storage, &0)?;

NETWORK_LAST_LOCK_COST.save(deps.storage, &100_000_000_000)?;
NETWORK_MIN_LOCK_COST.save(deps.storage, &100_000_000_000)?;
NETWORK_LOCK_REDUCTION_INTERVAL.save(deps.storage, &(7 * 7200))?; // test value, change to 14 * 7200;
NETWORK_LAST_LOCK_COST.save(deps.storage, &10_000_000_000)?;
NETWORK_MIN_LOCK_COST.save(deps.storage, &10_000_000_000)?;
NETWORK_LOCK_REDUCTION_INTERVAL.save(deps.storage, &(7 * 7200))?;

// -- Root network initialization --

// Get the root network uid.
let root_netuid: u16 = 0;

SUBNET_OWNER.save(deps.storage, root_netuid, &info.sender)?;
// TODO revisit set of 1
SUBNETWORK_N.save(deps.storage, root_netuid, &0)?;
NETWORKS_ADDED.save(deps.storage, root_netuid, &true)?;
NETWORK_MODALITY.save(deps.storage, root_netuid, &u16::MAX)?;
NETWORK_MODALITY.save(deps.storage, root_netuid, &u16::MAX)?; // revisit
MAX_ALLOWED_UIDS.save(deps.storage, root_netuid, &64)?;
MAX_ALLOWED_VALIDATORS.save(deps.storage, root_netuid, &64)?;
MIN_ALLOWED_WEIGHTS.save(deps.storage, root_netuid, &1)?;
Expand All @@ -118,7 +113,6 @@ pub fn instantiate(
NETWORK_REGISTRATION_ALLOWED.save(deps.storage, root_netuid, &true)?;
TARGET_REGISTRATIONS_PER_INTERVAL.save(deps.storage, root_netuid, &1)?;
WEIGHTS_VERSION_KEY.save(deps.storage, root_netuid, &0)?;
SUBNET_OWNER.save(deps.storage, root_netuid, &info.sender)?;
NETWORK_REGISTERED_AT.save(deps.storage, root_netuid, &env.block.height)?;
WEIGHTS_SET_RATE_LIMIT.save(deps.storage, root_netuid, &100)?;

Expand Down Expand Up @@ -148,20 +142,20 @@ pub fn instantiate(
EMISSION_VALUES.save(deps.storage, root_netuid, &0)?;
NETWORK_LAST_REGISTERED.save(deps.storage, &0)?;
TOTAL_NETWORKS.save(deps.storage, &1)?;
SCALING_LAW_POWER.save(deps.storage, root_netuid, &50)?;
METADATA.save(
deps.storage,
root_netuid,
&"Qmd2anGbDQj7pYWMZwv9SEw11QFLQu3nzoGXfi1KwLy3Zr".to_string(),
)?;

// -- Subnetwork 1 initialization --

// Subnet config values
let netuid: u16 = 1;
let tempo = 10;
let max_uids = 4096;

SUBNET_OWNER.save(deps.storage, netuid, &info.sender)?;
NETWORKS_ADDED.save(deps.storage, netuid, &true)?;
TEMPO.save(deps.storage, netuid, &tempo)?;
TEMPO.save(deps.storage, netuid, &10)?;
NETWORK_MODALITY.save(deps.storage, netuid, &0)?;
// TEMPO.save(deps.storage, netuid, &0)?;
TEMPO.save(deps.storage, netuid, &10)?;
KAPPA.save(deps.storage, netuid, &0)?;
DIFFICULTY.save(deps.storage, netuid, &10_000_000)?;
IMMUNITY_PERIOD.save(deps.storage, netuid, &7200)?;
Expand All @@ -173,7 +167,7 @@ pub fn instantiate(
POW_REGISTRATIONS_THIS_INTERVAL.save(deps.storage, netuid, &0)?;
BURN_REGISTRATIONS_THIS_INTERVAL.save(deps.storage, netuid, &0)?;
MAX_ALLOWED_VALIDATORS.save(deps.storage, netuid, &64)?;
MAX_ALLOWED_UIDS.save(deps.storage, netuid, &max_uids)?;
MAX_ALLOWED_UIDS.save(deps.storage, netuid, &1024)?;
WEIGHTS_VERSION_KEY.save(deps.storage, netuid, &0)?;
WEIGHTS_SET_RATE_LIMIT.save(deps.storage, netuid, &100)?;

Expand All @@ -199,8 +193,12 @@ pub fn instantiate(
SUBNETWORK_N.save(deps.storage, netuid, &0)?;
SUBNET_LOCKED.save(deps.storage, netuid, &0)?;
TARGET_REGISTRATIONS_PER_INTERVAL.save(deps.storage, netuid, &1)?;
SCALING_LAW_POWER.save(deps.storage, netuid, &50)?;
NETWORK_REGISTRATION_ALLOWED.save(deps.storage, netuid, &true)?;
METADATA.save(
deps.storage,
root_netuid,
&"Qmd2anGbDQj7pYWMZwv9SEw11QFLQu3nzoGXfi1KwLy3Zr".to_string(),
)?;

RANK.save(deps.storage, netuid, &vec![])?;
TRUST.save(deps.storage, netuid, &vec![])?;
Expand Down Expand Up @@ -405,10 +403,6 @@ pub fn execute(
netuid,
validator_prune_len,
} => do_sudo_set_validator_prune_len(deps, env, info, netuid, validator_prune_len),
ExecuteMsg::SudoSetScalingLawPower {
netuid,
scaling_law_power,
} => do_sudo_set_scaling_law_power(deps, env, info, netuid, scaling_law_power),
ExecuteMsg::SudoSetImmunityPeriod {
netuid,
immunity_period,
Expand Down Expand Up @@ -474,6 +468,9 @@ pub fn execute(
ExecuteMsg::SudoSetBlockEmission { emission } => {
do_sudo_set_block_emission(deps, env, info, emission)
}
ExecuteMsg::SudoSetSubnetMetadata { netuid, particle } => {
do_sudo_set_subnet_metadata(deps, env, info, netuid, particle)
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,7 @@ pub enum ContractError {

#[error("Thrown when all subnets are in the immunity period")]
AllNetworksInImmunity {},

#[error("Thrown when particle metadata size is invalid")]
MetadataSizeError {},
}
8 changes: 4 additions & 4 deletions src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,6 @@ pub enum ExecuteMsg {
netuid: u16,
validator_prune_len: u64,
},
SudoSetScalingLawPower {
netuid: u16,
scaling_law_power: u16,
},
SudoSetImmunityPeriod {
netuid: u16,
immunity_period: u16,
Expand Down Expand Up @@ -210,6 +206,10 @@ pub enum ExecuteMsg {
SudoSetBlockEmission {
emission: u64,
},
SudoSetSubnetMetadata {
netuid: u16,
particle: String,
},
}

#[cw_serde]
Expand Down
14 changes: 9 additions & 5 deletions src/root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ use crate::state::{
BONDS_MOVING_AVERAGE, BURN, BURN_REGISTRATIONS_THIS_INTERVAL, CONSENSUS, DENOM, DIFFICULTY,
DIVIDENDS, EMISSION, EMISSION_VALUES, IMMUNITY_PERIOD, INCENTIVE, KAPPA, KEYS,
LAST_ADJUSTMENT_BLOCK, LAST_UPDATE, MAX_ALLOWED_UIDS, MAX_ALLOWED_VALIDATORS, MAX_BURN,
MAX_DIFFICULTY, MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, MIN_ALLOWED_WEIGHTS, MIN_BURN,
MIN_DIFFICULTY, NETWORKS_ADDED, NETWORK_IMMUNITY_PERIOD, NETWORK_LAST_LOCK_COST,
MAX_DIFFICULTY, MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, METADATA, MIN_ALLOWED_WEIGHTS,
MIN_BURN, MIN_DIFFICULTY, NETWORKS_ADDED, NETWORK_IMMUNITY_PERIOD, NETWORK_LAST_LOCK_COST,
NETWORK_LAST_REGISTERED, NETWORK_LOCK_REDUCTION_INTERVAL, NETWORK_MIN_LOCK_COST,
NETWORK_MODALITY, NETWORK_RATE_LIMIT, NETWORK_REGISTERED_AT, NETWORK_REGISTRATION_ALLOWED,
PENDING_EMISSION, POW_REGISTRATIONS_THIS_INTERVAL, PRUNING_SCORES, RANK,
RAO_RECYCLED_FOR_REGISTRATION, REGISTRATIONS_THIS_BLOCK, REGISTRATIONS_THIS_INTERVAL, RHO,
SCALING_LAW_POWER, SERVING_RATE_LIMIT, SUBNETWORK_N, SUBNET_LIMIT, SUBNET_OWNER,
SERVING_RATE_LIMIT, SUBNETWORK_N, SUBNET_LIMIT, SUBNET_OWNER,
TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO, TOTAL_NETWORKS, TRUST, UIDS, VALIDATOR_PERMIT,
VALIDATOR_TRUST, WEIGHTS, WEIGHTS_SET_RATE_LIMIT, WEIGHTS_VERSION_KEY,
};
Expand Down Expand Up @@ -821,7 +821,11 @@ pub fn init_new_network(
SERVING_RATE_LIMIT.save(store, netuid, &50)?;
ADJUSTMENTS_ALPHA.save(store, netuid, &0)?;
LAST_UPDATE.save(store, netuid, &vec![])?;
SCALING_LAW_POWER.save(store, netuid, &50)?;
METADATA.save(
store,
netuid,
&"Qmd2anGbDQj7pYWMZwv9SEw11QFLQu3nzoGXfi1KwLy3Zr".to_string(),
)?;

Ok(())
}
Expand Down Expand Up @@ -923,9 +927,9 @@ pub fn remove_network(store: &mut dyn Storage, netuid: u16) -> Result<(), Contra
MIN_DIFFICULTY.remove(store, netuid);
MAX_DIFFICULTY.remove(store, netuid);
ADJUSTMENTS_ALPHA.remove(store, netuid);
SCALING_LAW_POWER.remove(store, netuid);
NETWORK_REGISTRATION_ALLOWED.remove(store, netuid);
TARGET_REGISTRATIONS_PER_INTERVAL.remove(store, netuid);
METADATA.remove(store, netuid);

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ pub const LAST_MECHANISM_STEP_BLOCK: Map<u16, u64> = Map::new("last_mechanism_st
pub const SUBNET_OWNER: Map<u16, Addr> = Map::new("subnet_owner");
// --- MAP (netuid ) --> subnet_locked
pub const SUBNET_LOCKED: Map<u16, u64> = Map::new("subnet_locked");
// --- MAP (netuid ) --> metadata
pub const METADATA: Map<u16, String> = Map::new("metadata");

// =================================
// ==== Axon / Promo Endpoints =====
Expand Down Expand Up @@ -198,8 +200,6 @@ pub const BONDS_MOVING_AVERAGE: Map<u16, u64> = Map::new("bonds_moving_average")
pub const WEIGHTS_SET_RATE_LIMIT: Map<u16, u64> = Map::new("weights_set_rate_limit");
// --- MAP ( netuid ) --> validator_prune_len
pub const VALIDATOR_PRUNE_LEN: Map<u16, u64> = Map::new("validator_prune_len");
// --- MAP ( netuid ) --> scaling_law_power
pub const SCALING_LAW_POWER: Map<u16, u16> = Map::new("scaling_law_power");
// --- MAP ( netuid ) --> target_registrations_this_interval
// TODO update to target_regs_per_interval, check later
pub const TARGET_REGISTRATIONS_PER_INTERVAL: Map<u16, u16> = Map::new("target_regs_per_interval");
Expand Down
17 changes: 5 additions & 12 deletions src/state_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ use crate::state::{
NETWORK_MODALITY, NETWORK_RATE_LIMIT, NETWORK_REGISTERED_AT, NETWORK_REGISTRATION_ALLOWED,
NEURONS_TO_PRUNE_AT_NEXT_EPOCH, OWNER, PENDING_EMISSION, POW_REGISTRATIONS_THIS_INTERVAL,
PROMETHEUS, PRUNING_SCORES, RANK, RAO_RECYCLED_FOR_REGISTRATION, REGISTRATIONS_THIS_BLOCK,
REGISTRATIONS_THIS_INTERVAL, RHO, ROOT, SCALING_LAW_POWER, SERVING_RATE_LIMIT, STAKE,
SUBNETWORK_N, SUBNET_LIMIT, SUBNET_LOCKED, SUBNET_OWNER, SUBNET_OWNER_CUT,
TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO, TOTAL_COLDKEY_STAKE, TOTAL_HOTKEY_STAKE,
TOTAL_ISSUANCE, TOTAL_NETWORKS, TOTAL_STAKE, TRUST, TX_RATE_LIMIT, UIDS, USED_WORK,
VALIDATOR_PERMIT, VALIDATOR_PRUNE_LEN, VALIDATOR_TRUST, WEIGHTS, WEIGHTS_SET_RATE_LIMIT,
WEIGHTS_VERSION_KEY,
REGISTRATIONS_THIS_INTERVAL, RHO, ROOT, SERVING_RATE_LIMIT, STAKE, SUBNETWORK_N, SUBNET_LIMIT,
SUBNET_LOCKED, SUBNET_OWNER, SUBNET_OWNER_CUT, TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO,
TOTAL_COLDKEY_STAKE, TOTAL_HOTKEY_STAKE, TOTAL_ISSUANCE, TOTAL_NETWORKS, TOTAL_STAKE, TRUST,
TX_RATE_LIMIT, UIDS, USED_WORK, VALIDATOR_PERMIT, VALIDATOR_PRUNE_LEN, VALIDATOR_TRUST,
WEIGHTS, WEIGHTS_SET_RATE_LIMIT, WEIGHTS_VERSION_KEY,
};

#[cw_serde]
Expand Down Expand Up @@ -90,7 +89,6 @@ pub struct StateInfo {
bonds_moving_average: Vec<(u16, u64)>,
weights_set_rate_limit: Vec<(u16, u64)>,
validator_prune_len: Vec<(u16, u64)>,
scaling_law_power: Vec<(u16, u16)>,
target_registrations_per_interval: Vec<(u16, u16)>,
block_at_registration: Vec<((u16, u16), u64)>,
adjustments_alpha: Vec<(u16, u64)>,
Expand Down Expand Up @@ -329,10 +327,6 @@ pub fn get_state_info(store: &dyn Storage) -> StdResult<StateInfo> {
.range(store, None, None, Order::Ascending)
.collect::<StdResult<Vec<_>>>()
.unwrap();
let scaling_law_power: Vec<(u16, u16)> = SCALING_LAW_POWER
.range(store, None, None, Order::Ascending)
.collect::<StdResult<Vec<_>>>()
.unwrap();
let target_registrations_per_interval: Vec<(u16, u16)> = TARGET_REGISTRATIONS_PER_INTERVAL
.range(store, None, None, Order::Ascending)
.collect::<StdResult<Vec<_>>>()
Expand Down Expand Up @@ -477,7 +471,6 @@ pub fn get_state_info(store: &dyn Storage) -> StdResult<StateInfo> {
bonds_moving_average,
weights_set_rate_limit,
validator_prune_len,
scaling_law_power,
target_registrations_per_interval,
block_at_registration,
adjustments_alpha,
Expand Down
22 changes: 6 additions & 16 deletions src/subnet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::root::if_subnet_exist;
use crate::state::{
ACTIVITY_CUTOFF, ADJUSTMENT_INTERVAL, BLOCKS_SINCE_LAST_STEP, BONDS_MOVING_AVERAGE, BURN,
DIFFICULTY, EMISSION_VALUES, IMMUNITY_PERIOD, KAPPA, MAX_ALLOWED_UIDS, MAX_ALLOWED_VALIDATORS,
MAX_BURN, MAX_DIFFICULTY, MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, MIN_ALLOWED_WEIGHTS,
MIN_BURN, MIN_DIFFICULTY, NETWORKS_ADDED, NETWORK_MODALITY, NETWORK_REGISTRATION_ALLOWED, RHO,
SCALING_LAW_POWER, SUBNET_OWNER, TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO,
MAX_BURN, MAX_DIFFICULTY, MAX_REGISTRATION_PER_BLOCK, MAX_WEIGHTS_LIMIT, METADATA,
MIN_ALLOWED_WEIGHTS, MIN_BURN, MIN_DIFFICULTY, NETWORKS_ADDED, NETWORK_MODALITY,
NETWORK_REGISTRATION_ALLOWED, RHO, SUBNET_OWNER, TARGET_REGISTRATIONS_PER_INTERVAL, TEMPO,
WEIGHTS_SET_RATE_LIMIT, WEIGHTS_VERSION_KEY,
};
use crate::uids::get_subnetwork_n;
Expand All @@ -22,16 +22,15 @@ pub struct SubnetInfo {
pub max_allowed_validators: u16,
pub min_allowed_weights: u16,
pub max_weights_limit: u16,
pub scaling_law_power: u16,
pub subnetwork_n: u16,
pub max_allowed_uids: u16,
pub blocks_since_last_step: u64,
pub tempo: u16,
pub network_modality: u16,
pub network_connect: Vec<[u16; 2]>,
pub emission_values: u64,
pub burn: u64,
pub owner: Addr,
pub metadata: String,
}

#[cw_serde]
Expand Down Expand Up @@ -68,7 +67,6 @@ pub fn get_subnet_info(deps: Deps, netuid: u16) -> StdResult<Option<SubnetInfo>>
let max_allowed_validators = MAX_ALLOWED_VALIDATORS.load(deps.storage, netuid)?;
let min_allowed_weights = MIN_ALLOWED_WEIGHTS.load(deps.storage, netuid)?;
let max_weights_limit = MAX_WEIGHTS_LIMIT.load(deps.storage, netuid)?;
let scaling_law_power = SCALING_LAW_POWER.load(deps.storage, netuid)?;
let subnetwork_n = get_subnetwork_n(deps.storage, netuid);
let max_allowed_uids = MAX_ALLOWED_UIDS.load(deps.storage, netuid)?;
let blocks_since_last_step = BLOCKS_SINCE_LAST_STEP.load(deps.storage, netuid)?;
Expand All @@ -77,14 +75,7 @@ pub fn get_subnet_info(deps: Deps, netuid: u16) -> StdResult<Option<SubnetInfo>>
let emission_values = EMISSION_VALUES.load(deps.storage, netuid)?;
let burn = BURN.load(deps.storage, netuid)?;
let owner = SUBNET_OWNER.load(deps.storage, netuid)?;
// TODO update
// let owner = SUBNET_OWNER.load(deps.storage, netuid).map_err(|_| return Ok(None))?;

// DEPRECATED
let network_connect: Vec<[u16; 2]> = Vec::<[u16; 2]>::new();
// DEPRECATED for ( _netuid_, con_req) in < NetworkConnect<T> as IterableStorageDoubleMap<u16, u16, u16> >::iter_prefix(netuid) {
// network_connect.push([_netuid_, con_req]);
// }
let metadata = METADATA.load(deps.storage, netuid)?;

return Ok(Some(SubnetInfo {
rho: rho.into(),
Expand All @@ -95,16 +86,15 @@ pub fn get_subnet_info(deps: Deps, netuid: u16) -> StdResult<Option<SubnetInfo>>
max_allowed_validators: max_allowed_validators.into(),
min_allowed_weights: min_allowed_weights.into(),
max_weights_limit: max_weights_limit.into(),
scaling_law_power: scaling_law_power.into(),
subnetwork_n: subnetwork_n.into(),
max_allowed_uids: max_allowed_uids.into(),
blocks_since_last_step: blocks_since_last_step.into(),
tempo: tempo.into(),
network_modality: network_modality.into(),
network_connect,
emission_values: emission_values.into(),
burn,
owner: owner.into(),
metadata: metadata.into(),
}));
}

Expand Down
6 changes: 3 additions & 3 deletions src/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ pub fn pow_register_ok_neuron(
result
}

pub fn sudo_register_ok_neuron(deps: DepsMut, env: Env, netuid: u16, hotkey: &str, coldkey: &str) {
pub fn sudo_register_ok_neuron(deps: DepsMut, _env: Env, netuid: u16, hotkey: &str, coldkey: &str) {
let msg = ExecuteMsg::SudoRegister {
netuid,
hotkey: hotkey.to_string(),
Expand Down Expand Up @@ -311,7 +311,7 @@ pub fn add_network(store: &mut dyn Storage, netuid: u16, tempo: u16, _modality:
}

// TODO revisit block increasing logic before or after step
pub fn step_block(mut deps: DepsMut, mut env: &mut Env) -> Result<Response, ContractError> {
pub fn step_block(mut deps: DepsMut, env: &mut Env) -> Result<Response, ContractError> {
env.block.height += 1;
let result = execute(
deps.branch(),
Expand All @@ -336,7 +336,7 @@ pub fn step_block(mut deps: DepsMut, mut env: &mut Env) -> Result<Response, Cont
// TODO revisit block increasing logic before or after step
pub fn run_step_to_block(
mut deps: DepsMut,
mut env: &mut Env,
env: &mut Env,
block_number: u64,
) -> Result<Response, ContractError> {
while env.block.height < block_number {
Expand Down
3 changes: 1 addition & 2 deletions src/tests/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct UserOutLink {

#[test]
pub fn test() {

#[rustfmt::skip]
let user_out_links = vec![
UserOutLink { user_id: 1, out_link: 1 },
Expand Down Expand Up @@ -90,7 +89,7 @@ pub fn test() {

println!("Sparse Matrix: : {:?}", &sparseWeightsMatrix);

let mut active_stake: Vec<I32F32> = vec![
let active_stake: Vec<I32F32> = vec![
I32F32::from_num(0),
I32F32::from_num(2000u16),
I32F32::from_num(3000u16),
Expand Down
Loading

0 comments on commit 544c6c2

Please sign in to comment.