repo_name
stringlengths
1
62
dataset
stringclasses
1 value
lang
stringclasses
11 values
pr_id
int64
1
20.1k
owner
stringlengths
2
34
reviewer
stringlengths
2
39
diff_hunk
stringlengths
15
262k
code_review_comment
stringlengths
1
99.6k
subtensor
github_2023
others
335
opentensor
distributedstatemachine
@@ -1277,6 +1278,83 @@ pub mod pallet { Self::do_set_weights(origin, netuid, dests, weights, version_key) } + // # Args: + // * `origin`: (<T as frame_system::Config>Origin): + // - The caller, a hotkey who wishes to set their weights. + // + // * `netuid` ...
Is this meant to be an error on an event ?
subtensor
github_2023
others
335
opentensor
sam0x17
@@ -1305,6 +1307,81 @@ pub mod pallet { Self::do_set_weights(origin, netuid, dests, weights, version_key) } + // # Args: + // * `origin`: (<T as frame_system::Config>Origin): + // - The caller, a hotkey who wishes to set their weights. + // + // * `netuid` ...
I know we haven't really started doing this yet but ideally these should be doc comments
subtensor
github_2023
others
387
opentensor
distributedstatemachine
@@ -12,12 +12,10 @@ workspace = true [dependencies] +[dev-dependencies]
Should we delete this crate ? Its a no op at the moment
subtensor
github_2023
others
387
opentensor
distributedstatemachine
@@ -11,6 +11,99 @@ resolver = "2" [workspace.lints.clippy] type_complexity = "allow" +[workspace.dependencies]
Lisan Al Gaib!
subtensor
github_2023
others
387
opentensor
distributedstatemachine
@@ -13,6 +13,10 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_consensus_aura::sr25519::AuthorityPair as AuraPair; use std::{sync::Arc, time::Duration}; +/// The minimum period of blocks on which justifications will be +/// imported and generated. +const GRANDPA_JUSTIFICATION_PERIOD: u32 = 5...
How do we arrive at this value ? Is 512 best practice , or is it implict in our existing code base and exposed in v1.10?
subtensor
github_2023
others
279
opentensor
rajkaramchedu
@@ -283,26 +283,11 @@ A FRAME pallet is compromised of a number of blockchain primitives: First, install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/). -Then run the following command to start a single node development chain. +Then run the following com...
So I believe we should add a `-b` flag explicitly. I have seen at least two cases where the users ran this command it came back with "node-subtensor command not found". This meant that the binary doesn't exist. Is this script supposed to build the "node-subtensor" without exception or only under some conditions? See a ...
subtensor
github_2023
others
369
opentensor
orriin
@@ -1,3 +1,6 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)]
Yeah, nice to allow this in tests, benchmarks, and some node stuff like this
subtensor
github_2023
others
369
opentensor
orriin
@@ -125,11 +137,21 @@ pub mod pallet { let old_deposit = id.deposit; id.deposit = T::InitialDeposit::get() + fd; if id.deposit > old_deposit { - T::Currency::reserve(&who, id.deposit - old_deposit)?; + T::Currency::hold( + &HoldReas...
Is there a reason to do the currency -> fungible migration here? Seems unrelated to direct indexing and I think you need a migration?
subtensor
github_2023
others
369
opentensor
distributedstatemachine
@@ -5,6 +5,7 @@ use mock::*; use sp_core::U256; #[test] +#[allow(clippy::unwrap_used)]
Does it make sense to allow unwraps for all the tests ?
subtensor
github_2023
others
369
opentensor
distributedstatemachine
@@ -529,134 +529,36 @@ impl<T: Config> Pallet<T> { hash_as_vec } - pub fn hash_block_and_hotkey(block_hash_bytes: &[u8], hotkey: &T::AccountId) -> H256 { + #[allow(clippy::indexing_slicing)]
Is this something you plan of tackling when you deal with Sparse matrix calculation i.e. https://github.com/orgs/opentensor/projects/27/views/9?pane=issue&itemId=59053066
subtensor
github_2023
others
369
opentensor
sam0x17
@@ -270,34 +257,32 @@ pub fn inplace_normalize_64(x: &mut [I64F64]) { if x_sum == I64F64::from_num(0) { return; } - #[allow(clippy::needless_range_loop)] - for i in 0..x.len() { - x[i] /= x_sum; - } + x.into_iter().for_each(|value| *value /= x_sum); } /// Returns x / y for inpu...
nice
subtensor
github_2023
others
381
opentensor
distributedstatemachine
@@ -1552,7 +1552,7 @@ pub mod pallet { // - The work has been performed on a stale, future, or non existent block. // // * 'InvalidDifficulty': - // - The work does not match the difficutly. + // - The work does not match the difficultly.
```suggestion // - The work does not match the difficulty. ```
subtensor
github_2023
others
381
opentensor
distributedstatemachine
@@ -205,7 +205,7 @@ impl<T: Config> Pallet<T> { // - The work has been performed on a stale, future, or non existent block. // // * 'InvalidDifficulty': - // - The work does not match the difficutly. + // - The work does not match the difficultly.
```suggestion // - The work does not match the difficulty. ```
subtensor
github_2023
others
381
opentensor
distributedstatemachine
@@ -27,7 +27,7 @@ fn test_registration_difficulty_adjustment() { SubtensorModule::set_max_registrations_per_block(netuid, 3); SubtensorModule::set_max_allowed_uids(netuid, 3); SubtensorModule::set_network_registration_allowed(netuid, true); - assert_eq!(SubtensorModule::get_difficulty_...
```suggestion assert_eq!(SubtensorModule::get_difficulty_as_u64(netuid), 20000); // Check set difficulty. ```
subtensor
github_2023
others
372
opentensor
distributedstatemachine
@@ -1203,14 +1203,21 @@ pub mod pallet { "feabaafee293d3b76dae304e2f9d885f77d2b17adab9e17e921b321eccd61c77" ]; weight = weight + // Initializes storage version (to 1) .saturating_add(migration::migrate_to_v1_separate_emission::<T>()) + ...
Why do we have to remove this after the upgrade ? this was added ages ago and wont run anymore since the storage version would be higher
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -548,3 +548,37 @@ pub fn migrate_stake_to_substake<T: Config>() -> Weight { log::info!("Final weight: {:?}", weight); // Debug print weight } + +pub fn migrate_nominator_counters<T: Config>() -> Weight {
We need to check that this is only migrating nominations and not self delegations i.e when the cold key owns the hot key
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -294,8 +298,11 @@ pub mod pallet { #[pallet::storage] // --- MAP ( hot ) --> cold | Returns the controlling coldkey for a hotkey. pub type Owner<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, ValueQuery, DefaultAccount<T>>; - #[pallet::storage] // --- ITEM ( delegate_l...
Do you think `NominationLimit` would be a more appropriate name ?
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -294,8 +298,11 @@ pub mod pallet { #[pallet::storage] // --- MAP ( hot ) --> cold | Returns the controlling coldkey for a hotkey. pub type Owner<T: Config> = StorageMap<_, Blake2_128Concat, T::AccountId, T::AccountId, ValueQuery, DefaultAccount<T>>; - #[pallet::storage] // --- ITEM ( delegate_l...
same as above `NominationCount`
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -258,7 +258,7 @@ impl<T: Config> Pallet<T> { .collect() } - pub fn get_delegate_limit() -> u32 { - DelegateLimit::<T>::get() + pub fn get_nominator_limit() -> u32 {
`get_nomination_limit`
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -162,7 +162,7 @@ pub mod pallet { #[pallet::constant] // Initial default delegation take. type InitialDefaultTake: Get<u16>; #[pallet::constant] // Initial limit on number of nominators per subnet validator - type InitialDelegateLimit: Get<u32>; + type InitialNominatorLimit: ...
`InitialNominationLimit`
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -488,6 +488,13 @@ impl<T: Config> Pallet<T> { Error::<T>::NonAssociatedColdKey ); + // --- 5.5 Enforce the nominator limit + let nominator_count: u32 = NominatorCount::<T>::get(&hotkey);
Do we want self delegations to increase this counter ? They return
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -15,13 +15,13 @@ fn test_add_subnet_stake_ok_no_emission() { let coldkey = U256::from(1); SubtensorModule::add_balance_to_coldkey_account(&coldkey, 100_000_000_000); // 100 TAO. - // Check - // -- that the lock cost is 100 TAO. - // -- that the balance is 100 TAO. - //...
Do we want this formatting ?
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -156,7 +156,7 @@ parameter_types! { pub const InitialSubnetLimit: u16 = 10; // Max 10 subnets. pub const InitialNetworkRateLimit: u64 = 0; pub const InitialTargetStakesPerInterval: u16 = 2; - pub const InitialDelegateLimit: u16 = 128; + pub const InitialNominatorLimit: u16 = 128;
```suggestion pub const InitialNominationLimit: u16 = 128; ```
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -357,7 +357,7 @@ impl pallet_subtensor::Config for Test { type InitialSubnetLimit = InitialSubnetLimit; type InitialNetworkRateLimit = InitialNetworkRateLimit; type InitialTargetStakesPerInterval = InitialTargetStakesPerInterval; - type InitialDelegateLimit = InitialDelegateLimit; + type Initial...
```suggestion type InitialNominationLimit = InitialNominationLimit; ```
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -4415,3 +4415,220 @@ fn set_delegate_takes_enforces_rate_limit() { ); }); } + +#[test] +fn test_add_stake_within_nominator_limit_ok() { + new_test_ext(1).execute_with(|| { + // Set the global nominator limit to 10 + SubtensorModule::set_nominator_limit(10); + let delegate = U25...
Do we need to add this case given that we already test for it in the previous test?
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -644,7 +644,7 @@ parameter_types! { pub const SubtensorInitialScalingLawPower: u16 = 50; // 0.5 pub const SubtensorInitialMaxAllowedValidators: u16 = 128; pub const SubtensorInitialTempo: u16 = 99; - pub const SubtensorInitialDelegateLimit: u32 = 128; // Limits the number of nominators per subnet v...
```suggestion pub const SubtensorInitialNominationLimit: u32 = 128; // Limits the number of nominators per subnet validator ```
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -696,7 +696,7 @@ impl pallet_subtensor::Config for Runtime { type InitialValidatorPruneLen = SubtensorInitialValidatorPruneLen; type InitialScalingLawPower = SubtensorInitialScalingLawPower; type InitialTempo = SubtensorInitialTempo; - type InitialDelegateLimit = SubtensorInitialDelegateLimit; + ...
```suggestion type InitialNominationLimit = SubtensorInitialNominationLimit; ```
subtensor
github_2023
others
367
opentensor
distributedstatemachine
@@ -886,8 +886,8 @@ impl SubtensorModule::set_tempo(netuid, tempo); } - fn set_delegate_limit(limit: u32) { - SubtensorModule::set_delegate_limit(limit); + fn set_nominator_limit(limit: u32) {
```suggestion fn set_nomination_limit(limit: u32) { ```
subtensor
github_2023
others
356
opentensor
distributedstatemachine
@@ -3205,6 +3205,14 @@ fn test_can_set_different_take_per_subnet() { }); } +fn assert_substake(coldkey: &U256, hotkey: &U256, netuid: u16, amount: u64) {
Do you think it might be better if we moved these to the end of the file ? Or better yet , create a test utils file where we can add all the helper functions
subtensor
github_2023
others
356
opentensor
distributedstatemachine
@@ -3222,14 +3230,37 @@ fn test_different_subnet_take_different_distribution() { SubtensorModule::set_max_allowed_uids(netuid2, 10); // Allow at least 10 to be registered at once, so no unstaking occurs // Add balances. - SubtensorModule::add_balance_to_coldkey_account(&coldkey0, 100000); - ...
I think these should be tested separated. Is it possible to isolate subnet takes v dtao ?
subtensor
github_2023
others
358
opentensor
gztensor
@@ -517,7 +517,7 @@ impl<T: Config> Pallet<T> { } } - // Performs the burn adjustment by multiplying the current difficulty by the ratio ( reg_actual + reg_target / reg_target * reg_target ) + // Performs the burn adjustment by multiplying the current burn by the ratio ( reg_actual + reg_target / ...
Actually, the function name is off: It doesn't adjust anything, just returns updated value. Maybe we should rename it too? Something like `get_upgated_burn` is more accurate.
subtensor
github_2023
others
358
opentensor
gztensor
@@ -517,7 +517,7 @@ impl<T: Config> Pallet<T> { } } - // Performs the burn adjustment by multiplying the current difficulty by the ratio ( reg_actual + reg_target / reg_target * reg_target ) + // Performs the burn adjustment by multiplying the current burn by the ratio ( reg_actual + reg_target / ...
Is updated burn calculated correctly? Why is there "target_registrations_per_interval + target_registrations_per_interval" in the code (addition vs. multiplication)?
subtensor
github_2023
others
359
opentensor
gztensor
@@ -850,6 +850,98 @@ impl<T: Config> Pallet<T> { DelegatesTake::<T>::get(hotkey, netuid) } + /// Sets the delegator takes for subnets if the subnet exists and does not exceed the initial default take. + /// + /// # Arguments + /// * `hotkey` - The account ID of the hotkey. + /// * `netuid...
The formatting is off
subtensor
github_2023
others
359
opentensor
gztensor
@@ -850,6 +850,98 @@ impl<T: Config> Pallet<T> { DelegatesTake::<T>::get(hotkey, netuid) } + /// Sets the delegator takes for subnets if the subnet exists and does not exceed the initial default take. + /// + /// # Arguments + /// * `hotkey` - The account ID of the hotkey. + /// * `netuid...
The method doesn't seem to be called in extrinsics. Do we really need it?
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + #[pallet::call_index(43)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_nominator_min_required_stake( + origin: OriginF...
If the min stake is reduced, we need to check every account
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + #[pallet::call_index(43)] + #[pallet::weight((0, DispatchClass::Operational, Pays::No))] + pub fn sudo_set_nominator_min_required_stake( + origin: OriginF...
Is this the correct method call? The logic of this call is identical to the one above. Need to test these?
subtensor
github_2023
others
348
opentensor
orriin
@@ -852,4 +874,6 @@ pub trait SubtensorInterface<AccountId, Balance, RuntimeOrigin> { fn set_weights_set_rate_limit(netuid: u16, weights_set_rate_limit: u64); fn init_new_network(netuid: u16, tempo: u16); fn set_weights_min_stake(min_stake: u64); + fn set_nominator_min_required_stake(min_stake: u64); ...
What's the difference between the minimum required stake and the minimum staking threshold? Maybe can document somewhere?
subtensor
github_2023
others
348
opentensor
orriin
@@ -106,7 +106,7 @@ parameter_types! { pub const InitialSubnetLimit: u16 = 10; // Max 10 subnets. pub const InitialNetworkRateLimit: u64 = 0; pub const InitialTargetStakesPerInterval: u16 = 1; - + pub const InitialMinimumStakingThreshold: u64 = 100_000_000;
Maybe a comment here with what the amount is in decimal units
subtensor
github_2023
others
348
opentensor
orriin
@@ -23,6 +23,8 @@ impl<T: Config> Pallet<T> { Self::drain_emission(block_number); // --- 4. Generates emission tuples from epoch functions. Self::generate_emission(block_number); + +
? ```suggestion ```
subtensor
github_2023
others
348
opentensor
orriin
@@ -397,6 +399,10 @@ pub mod pallet { 0 } #[pallet::type_value] + pub fn DefaultNominatorMinRequiredStake<T: Config>() -> u64 { + 0
Shouldn't this be some higher amount like 10 TAO?
subtensor
github_2023
others
348
opentensor
orriin
@@ -604,4 +604,15 @@ impl<T: Config> Pallet<T> { pub fn is_subnet_owner(address: &T::AccountId) -> bool { SubnetOwner::<T>::iter_values().any(|owner| *address == owner) } + + pub fn get_nominator_min_required_stake() -> u64 { + NominatorMinRequiredStake::<T>::get() + } + pub fn set_no...
```suggestion } pub fn set_nominator_min_required_stake( min_stake: u64 ) { ```
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + /// Sets the minimum stake required for nominators , and clears small nominations + /// that are below the minimum required stake. + /// + /// # Arguments + ...
The "rusty" way to doc args :) ```suggestion /// Sets the minimum stake required for nominators, and clears small nominations /// that are below the minimum required stake. #[pallet::call_index(43)] #[pallet::weight((0, DispatchClass::Operational, Pays::No))] pub fn sudo_...
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + /// Sets the minimum stake required for nominators , and clears small nominations + /// that are below the minimum required stake. + /// + /// # Arguments + ...
```suggestion log::trace!("Setting minimum stake to: {}", min_stake); T::Subtensor::set_nominator_min_required_stake(min_stake); log::trace!("Clearing small nominations"); T::Subtensor::clear_small_nominations(); log::trace!("Small nominations cleared"); ...
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + /// Sets the minimum stake required for nominators , and clears small nominations + /// that are below the minimum required stake. + /// + /// # Arguments + ...
Only need to clear small nominations if `new_min_required_stake > prev_min_required_stake`. ```suggestion let prev_min_stake = T::Subtensor::get_nominator_min_required_stake(); log::info!("Setting minimum stake to: {}", min_stake); T::Subtensor::set_nominator_min_required_stake...
subtensor
github_2023
others
348
opentensor
orriin
@@ -429,6 +429,14 @@ impl pallet_admin_utils::SubtensorInterface<AccountId, Balance, RuntimeOrigin> f fn set_weights_min_stake(min_stake: u64) { SubtensorModule::set_weights_min_stake(min_stake); } + + fn set_nominator_min_required_stake(min_stake: u64) { + SubtensorModule::set_nominator_mi...
DQ but why do you use this pattern of wrapping the `Subtensor` module calls instead of calling them directly in the code?
subtensor
github_2023
others
348
opentensor
orriin
@@ -336,6 +367,115 @@ fn test_sudo_set_issuance() { }); } +// Run this test using: cargo test --package pallet-admin-utils --test tests test_sudo_set_nominator_min_required_stake +// #[test] +// fn test_sudo_set_nominator_min_required_stake() { +// new_test_ext().execute_with(|| { +// let to_be_set:...
?
subtensor
github_2023
others
348
opentensor
orriin
@@ -27,6 +27,35 @@ impl<T: Config> Pallet<T> { Ok(()) } + + /// Clears small nominations that are below the minimum required stake. + /// This function runs when ever we set the minimum required nominations to ensure that + /// the network does not retain nominator accounts with stakes that are...
```suggestion ```
subtensor
github_2023
others
348
opentensor
orriin
@@ -27,6 +27,35 @@ impl<T: Config> Pallet<T> { Ok(()) } + + /// Clears small nominations that are below the minimum required stake. + /// This function runs when ever we set the minimum required nominations to ensure that + /// the network does not retain nominator accounts with stakes that are...
```suggestion log::trace!("Checking nomination for hotkey: {}, coldkey: {}, stake: {}", hotkey, coldkey, stake); ```
subtensor
github_2023
others
348
opentensor
orriin
@@ -27,6 +27,35 @@ impl<T: Config> Pallet<T> { Ok(()) } + + /// Clears small nominations that are below the minimum required stake. + /// This function runs when ever we set the minimum required nominations to ensure that + /// the network does not retain nominator accounts with stakes that are...
```suggestion log::trace!("Account is not a nominator, skipping"); // If the stake is below the minimum required, it's considered a small nomination and needs to be cleared. if stake < Self::get_nominator_min_required_stake() { log::trace!("Stake i...
subtensor
github_2023
others
348
opentensor
orriin
@@ -290,24 +298,32 @@ impl<T: Config> Pallet<T> { !Self::exceeds_tx_rate_limit(Self::get_last_tx_block(&coldkey), block), Error::<T>::TxRateLimitExceeded ); -
?
subtensor
github_2023
others
348
opentensor
orriin
@@ -503,6 +519,27 @@ impl<T: Config> Pallet<T> { ); TotalStake::<T>::put(TotalStake::<T>::get().saturating_sub(decrement)); } + /// Empties the stake associated with a given coldkey-hotkey account pairing. + /// This function retrieves the current stake for the specified coldkey-hotkey pair...
The "rusty" way to do it :) ```suggestion /// Empties the stake associated with a given coldkey-hotkey account pairing. /// This function retrieves the current stake for the specified coldkey-hotkey pairing, /// then subtracts this stake amount from both the TotalColdkeyStake and TotalHotkeyStake. ...
subtensor
github_2023
others
348
opentensor
orriin
@@ -2469,3 +2469,300 @@ fn test_faucet_ok() { )); }); } + +/// This test ensures that the clear_small_nominations function works as expected. +/// It creates a network with two hotkeys and two coldkeys, and then registers a nominator account for each hotkey. +/// When we call set_nominator_min_requ...
```suggestion /// This test ensures that the clear_small_nominations function works as expected. /// It creates a network with two hotkeys and two coldkeys, and then registers a nominator account for each hotkey. /// When we call set_nominator_min_required_stake, it should clear all small nominations that are below ...
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,28 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + /// Sets the minimum stake required for nominators , and clears small nominations + /// that are below the minimum required stake. + /// + /// # Arguments + ...
```suggestion /// * `min_stake` - The minimum stake required for nominators. #[pallet::call_index(43)] ```
subtensor
github_2023
others
348
opentensor
orriin
@@ -764,6 +764,27 @@ pub mod pallet { T::Subtensor::set_weights_min_stake(min_stake); Ok(()) } + + /// Sets the minimum stake required for nominators, and clears small nominations + /// that are below the minimum required stake. + #[pallet::call_index(43)] + ...
```suggestion T::Subtensor::clear_small_nominations(); log::trace!("Small nominations cleared"); } ```
subtensor
github_2023
others
345
opentensor
orriin
@@ -24,10 +24,39 @@ impl<T: Config> Pallet<T> { Self::drain_emission(block_number); // --- 4. Generates emission tuples from epoch functions. Self::generate_emission(block_number); + + // --- 5. Clear small accounts under limit after 1000 blocks. + if Self::blocks_until_next_epo...
In what scenarios can the stake go beneath the minimum stake? If only when `NominatorMinRequiredStake` increases or a nominators individual stake decreases, can we check the min stake at those moments rather than on a fixed interval? It should be O(1) cost to check a nominators individual stake when it decreases, so...
subtensor
github_2023
others
345
opentensor
orriin
@@ -24,10 +24,39 @@ impl<T: Config> Pallet<T> { Self::drain_emission(block_number); // --- 4. Generates emission tuples from epoch functions. Self::generate_emission(block_number); + + // --- 5. Clear small accounts under limit after 1000 blocks. + if Self::blocks_until_next_epo...
```suggestion // Remove the stake from the nominator account (this is a more forceful unstake operation which // actually deletes the staking account). ```
subtensor
github_2023
others
345
opentensor
orriin
@@ -369,6 +369,10 @@ pub mod pallet { 0 } #[pallet::type_value] + pub fn DefaultNominatorMinRequiredStake<T: Config>() -> u64 { + 0
Why is 0 the default? My understanding is that it should be some significant amount, like 10TAO.
subtensor
github_2023
others
324
opentensor
gztensor
@@ -190,16 +190,17 @@ To run an archive node connected to the mainchain, execute the below command (no To run a lite node connected to the testchain, execute the below command: ```bash title="With bootnodes set to testnet and --sync=warp setting, for lite node." -./target/release/node-subtensor --chain raw_spec.jso...
The binary prints the following warning when run with these parameters: ``` CLI parameter `--execution` has no effect anymore and will be removed in the future ``` I think Parity made execution to be wasm-only, so this parameter doesn't make any difference.
subtensor
github_2023
others
338
opentensor
keithtensor
@@ -0,0 +1,162 @@ +pub(crate) mod account_data_migration { + use crate::*; + use frame_support::log; + use pallet_balances::ExtraFlags; + + mod prev { + use super::*; + use frame_support::{pallet_prelude::ValueQuery, storage_alias, Blake2_128Concat}; + + #[derive( + Clone, Eq...
Might wanna give this a more descriptive name.
subtensor
github_2023
others
338
opentensor
keithtensor
@@ -1147,121 +1150,6 @@ pub type SignedExtra = ( pallet_commitments::CommitmentsSignedExtension<Runtime>, ); -mod account_data_migration { - use super::*; - use frame_support::log; - use pallet_balances::ExtraFlags; - - mod prev { - use super::*; - use frame_support::{pallet_prelude::V...
Was this something you wrote? I was thinking how it was even possible to get an old lifecycle runtime upgrade hook from upstream to execute in our chain, but if you wrote a brand new one, it does the job just fine.
subtensor
github_2023
others
338
opentensor
keithtensor
@@ -0,0 +1,162 @@ +pub(crate) mod account_data_migration { + use crate::*; + use frame_support::log; + use pallet_balances::ExtraFlags; + + mod prev { + use super::*; + use frame_support::{pallet_prelude::ValueQuery, storage_alias, Blake2_128Concat}; + + #[derive( + Clone, Eq...
You're better than this, Mr. Rust expert: ```suggestion <Runtime as frame_system::Config>::DbWeight::get().reads_writes(0u64, 0u64) ```
subtensor
github_2023
others
338
opentensor
keithtensor
@@ -0,0 +1,162 @@ +pub(crate) mod account_data_migration {
Oh, I didn't know you did this weird thing. Do you mind pulling this mod definition up to `lib.rs` and rename this file?
subtensor
github_2023
others
333
opentensor
sam0x17
@@ -331,3 +330,25 @@ jobs: else echo "No changes detected after running 'cargo fix --workspace' ✅" fi + + check-feature-propagation: + name: zepter run check + runs-on: ubuntu-22.04 + + steps: + - name: Install stable Rust + uses: actions-rs/toolchain@v1 + ...
```suggestion uses: actions/checkout@v4 ```
subtensor
github_2023
others
328
opentensor
open-junius
@@ -295,11 +301,7 @@ where _len: usize, _result: &DispatchResult, ) -> Result<(), TransactionValidityError> { - if let Some((call_type, _transaction_fee, _who)) = maybe_pre { - match call_type { - _ => (), - } - } + if let Some((call_type,...
can just remove it.
subtensor
github_2023
others
328
opentensor
open-junius
@@ -145,7 +145,7 @@ fn test_senate_vote_works() { )); // Check if balance has decreased to pay for the burn. assert_eq!( - SubtensorModule::get_coldkey_balance(&coldkey_account_id) as u64, + { SubtensorModule::get_coldkey_balance(&coldkey_account_id) },
{} can be removed
subtensor
github_2023
others
328
opentensor
open-junius
@@ -254,7 +254,7 @@ fn test_senate_vote_not_member() { )); // Check if balance has decreased to pay for the burn. assert_eq!( - SubtensorModule::get_coldkey_balance(&coldkey_account_id) as u64, + { SubtensorModule::get_coldkey_balance(&coldkey_account_id) },
the same as line 148
subtensor
github_2023
others
328
opentensor
open-junius
@@ -315,7 +315,7 @@ fn test_senate_leave_works() { )); // Check if balance has decreased to pay for the burn. assert_eq!( - SubtensorModule::get_coldkey_balance(&coldkey_account_id) as u64, + { SubtensorModule::get_coldkey_balance(&coldkey_account_id) },
the same as line 148
subtensor
github_2023
others
327
opentensor
sam0x17
@@ -0,0 +1,42 @@ +#!/bin/bash + +echo "*** Checking if Rust is already installed" + +if which rustup >/dev/null 2>&1; then + echo "Rust is already installed. Exiting." + exit 0 +fi + +echo "*** Installing Rust" + +if [[ "$(uname)" == "Darwin" ]]; then + # macOS + if ! which brew >/dev/null 2>&1; then + ...
```suggestion echo "*** Rust installation complete" ```
subtensor
github_2023
others
327
opentensor
sam0x17
@@ -0,0 +1,42 @@ +#!/bin/bash + +echo "*** Checking if Rust is already installed" + +if which rustup >/dev/null 2>&1; then + echo "Rust is already installed. Exiting." + exit 0 +fi + +echo "*** Installing Rust" + +if [[ "$(uname)" == "Darwin" ]]; then + # macOS + if ! which brew >/dev/null 2>&1; then + ...
note that usage of plain `apt` in scripts is unstable, still supposed to use `apt-get` because it has a stable CLI that won't i.e. spawn some UI sometimes ```suggestion sudo apt-get update ```
subtensor
github_2023
others
327
opentensor
sam0x17
@@ -0,0 +1,42 @@ +#!/bin/bash + +echo "*** Checking if Rust is already installed" + +if which rustup >/dev/null 2>&1; then + echo "Rust is already installed. Exiting." + exit 0 +fi + +echo "*** Installing Rust" + +if [[ "$(uname)" == "Darwin" ]]; then + # macOS + if ! which brew >/dev/null 2>&1; then + ...
```suggestion sudo apt-get install -y cmake pkg-config libssl-dev git gcc build-essential clang libclang-dev ```
subtensor
github_2023
others
327
opentensor
sam0x17
@@ -0,0 +1,42 @@ +#!/bin/bash
would prefer like this so it is POSIX compliant and will work with things like zsh so we don't require bash ```suggestion #!/bin/sh ```
subtensor
github_2023
others
317
opentensor
distributedstatemachine
@@ -190,11 +191,7 @@ impl<T: Config> Pallet<T> { Self::set_last_tx_block(&coldkey, block); // --- 10. Emit the staking event. - Self::set_stakes_this_interval_for_hotkey( - &hotkey, - stakes_this_interval + 1, - block, - ); + Self::set_stakes_thi...
nit: Is your editor automatically formatting ? If you are using vscode , it migght make sense for you to turn the formatOnSave off in your settings.json
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -86,6 +86,87 @@ impl<T: Config> Pallet<T> { Ok(()) } + // ---- The implementation for the extrinsic become_delegate: signals that this hotkey allows delegated stake.
```suggestion // ---- The implementation for the extrinsic decrease_take ```
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -1279,6 +1281,38 @@ pub mod pallet { Self::do_become_delegate(origin, hotkey, Self::get_default_take()) } + // --- Allows delegates to decrease its take value. + // + // # Args: + // * 'origin': (<T as frame_system::Config>::Origin): + // - The signature ...
```suggestion // * 'take' (u16): ```
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -1279,6 +1281,38 @@ pub mod pallet { Self::do_become_delegate(origin, hotkey, Self::get_default_take()) } + // --- Allows delegates to decrease its take value. + // + // # Args: + // * 'origin': (<T as frame_system::Config>::Origin): + // - The signature ...
```suggestion // * TakeDecreased; // - On successfully setting a decreased take for this hotkey. ```
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -86,6 +86,87 @@ impl<T: Config> Pallet<T> { Ok(()) } + // ---- The implementation for the extrinsic decrease_take + // + // # Args: + // * 'origin': (<T as frame_system::Config>::RuntimeOrigin): + // - The signature of the caller's coldkey. + // + // * 'hotkey' (T::AccountId)...
```suggestion // * TakeDecreased; // - On successfully setting a decreased take for this hotkey. ```
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -86,6 +86,87 @@ impl<T: Config> Pallet<T> { Ok(()) } + // ---- The implementation for the extrinsic decrease_take + // + // # Args: + // * 'origin': (<T as frame_system::Config>::RuntimeOrigin): + // - The signature of the caller's coldkey. + // + // * 'hotkey' (T::AccountId)...
```suggestion // * 'InvalidTransaction': // - The delegate is setting a take which is not lower than the previous. ```
subtensor
github_2023
others
288
opentensor
cuteolaf
@@ -86,6 +86,87 @@ impl<T: Config> Pallet<T> { Ok(()) } + // ---- The implementation for the extrinsic decrease_take + // + // # Args: + // * 'origin': (<T as frame_system::Config>::RuntimeOrigin): + // - The signature of the caller's coldkey. + // + // * 'hotkey' (T::AccountId)...
```suggestion // --- 2. Ensure we are delegating a known key. ```
subtensor
github_2023
others
313
opentensor
distributedstatemachine
@@ -84,6 +84,7 @@ parameter_types! { pub const InitialWeightsVersionKey: u16 = 0; pub const InitialServingRateLimit: u64 = 0; // No limit. pub const InitialTxRateLimit: u64 = 0; // Disable rate limit for testing + pub const InitialTxRateLimitDelegateTake: u64 = 0; // Disable rate limit for testing
Nit: Should we call this `InitialDelegateTakeRateLimit` ? This seems to follow the pattern of the other rate limit constants
subtensor
github_2023
others
313
opentensor
distributedstatemachine
@@ -2245,3 +2245,378 @@ fn test_faucet_ok() { )); }); } + +// Verify delegate take can be decreased +#[test] +fn test_delegate_take_can_be_decreased() { + new_test_ext().execute_with(|| { + // Make account + let hotkey0 = U256::from(1); + let coldkey0 = U256::from(3); + + /...
How is the delegate able to set a 50% take ?
subtensor
github_2023
others
290
opentensor
sam0x17
@@ -697,3 +697,95 @@ fn test_weights_after_network_pruning() { assert_eq!(latest_weights[0][1], 0); }); } +#[test] +fn test_halving() { + new_test_ext().execute_with(|| { + let expected_emissions: [(u64, u64); 41] = [ + (1_776_000, 1_000_000_000), + (1_776_000_000, 1_000_0...
nit: get these comments all vertically aligned
subtensor
github_2023
others
290
opentensor
sam0x17
@@ -697,3 +697,95 @@ fn test_weights_after_network_pruning() { assert_eq!(latest_weights[0][1], 0); }); } +#[test] +fn test_halving() { + new_test_ext().execute_with(|| { + let expected_emissions: [(u64, u64); 41] = [ + (1_776_000, 1_000_000_000), + (1_776_000_000, 1_000_0...
I guess as long as this consistently passes this is fine but I suppose if there is ever a hardware difference w.r.t floating points vs the safe implementation this test _might_ fail on some random hardware. Probably fine tho my preference tho would be that this uses safe math as well if possible
subtensor
github_2023
others
290
opentensor
sam0x17
@@ -599,3 +597,37 @@ impl<T: Config> Pallet<T> { SubnetOwner::<T>::iter_values().any(|owner| *address == owner) } } + +pub fn log2(x: I96F32) -> I96F32 { + let mut y = x; + let mut result = I96F32::from_num(0.0); + while y < I96F32::from_num(1.0) { + y *= I96F32::from_num(2.0); + r...
as const mentioned, first one is built into `I96F32` apparently, and second one you can just self-multiply in a loop since we don't have fractional exponent. In other words don't need `powf` really just need `pow` which is a lot simpler to implement
subtensor
github_2023
others
302
opentensor
sam0x17
@@ -222,26 +222,44 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> { ); } + let finality_proof_provider = sc_consensus_grandpa::FinalityProofProvider::new_for_service( + backend.clone(), + Some(grandpa_link.shared_authority_set().clone()), + ); + let rpc_backend = backen...
lot of boxing and cloning here, I wonder if it is actually all necessary?
subtensor
github_2023
others
287
opentensor
keithtensor
@@ -1817,14 +1831,32 @@ where return Err(InvalidTransaction::Call.into()); } } - Some(Call::add_stake { .. }) => Ok(ValidTransaction { - priority: Self::get_priority_vanilla(), - ..Default::default() - }), - ...
When is this `validate` function called? We're essentially doing 2 storage lookups whenever the call is `add_stake` or `remove_stake`, not sure if we're OK with that...
subtensor
github_2023
others
287
opentensor
keithtensor
@@ -140,6 +140,16 @@ impl<T: Config> Pallet<T> { WeightsMinStake::<T>::put(min_stake); Self::deposit_event(Event::WeightsMinStake(min_stake)); } + pub fn set_target_stakes_per_interval(target_stakes_per_interval: u64) { + TargetStakesPerInterval::<T>::set(target_stakes_per_interval) + ...
Need to be careful about this one, how many hotkey stakes do we expect to have in each interval? If it's a lot, it may consume a lot of compute from the chain.
subtensor
github_2023
others
285
opentensor
distributedstatemachine
@@ -1825,10 +1825,20 @@ where priority: Self::get_priority_vanilla(), ..Default::default() }), - Some(Call::register { .. }) => Ok(ValidTransaction { - priority: Self::get_priority_vanilla(), - ..Default::default() - }), ...
can we also add this for `burned_register` ? We should be able to use `||` in the method
subtensor
github_2023
others
285
opentensor
distributedstatemachine
@@ -153,6 +154,99 @@ fn test_registration_ok() { }); } +#[test] +fn test_registration_under_limit() { + new_test_ext().execute_with(|| { + let netuid: u16 = 1; + let block_number: u64 = 0; + let hotkey_account_id: U256 = U256::from(1); + let coldkey_account_id = U256::from(667); +...
Do you think it would be a good idea to asser the actual error ?
subtensor
github_2023
others
254
opentensor
shibshib
@@ -294,6 +294,9 @@ impl<T: Config> Pallet<T> { pub fn burn_tokens(amount: u64) { TotalIssuance::<T>::put(TotalIssuance::<T>::get().saturating_sub(amount)); } + pub fn mint_tokens(amount: u64 ){
This sort of naming might freak people out. Maybe let's just rename it to `update_totalissuance` or something
subtensor
github_2023
others
254
opentensor
shibshib
@@ -148,9 +148,9 @@ impl<T: Config> Pallet<T> { &Self::get_subnet_owner(netuid), Self::u64_to_balance(cut.to_num::<u64>()).unwrap(), ); - TotalIssuance::<T>::put( - TotalIssuance::<T>::get().saturating_add(cut.to_num::<u64>()),...
Same comment as below, 'minting' should be reworded to something less defi-sounding.
subtensor
github_2023
others
254
opentensor
shibshib
@@ -401,9 +401,10 @@ impl<T: Config> Pallet<T> { // --- 5. Add Balance via faucet. let balance_to_add: u64 = 100_000_000_000; + Self::mint_tokens( 100_000_000_000 ); // Accounting here for the newly created tokens.
Why is the total issuance being updated here?
subtensor
github_2023
others
254
opentensor
sam0x17
@@ -22,6 +22,46 @@ pub mod deprecated_loaded_emission_format { StorageMap<Pallet<T>, Identity, u16, Vec<(AccountIdOf<T>, u64)>, OptionQuery>; } + +/// Performs migration to update the total issuance based on the sum of stakes and total balances. +/// This migration is applicable only if the current storage ...
honestly this panic is really scary, could we just keep with the type of `T::Currency::total_issuance()` instead or does it not support the ops we need? (another reason to use my currencies crate in the future hahaha)
subtensor
github_2023
others
210
opentensor
Rubberbandits
@@ -625,7 +625,7 @@ parameter_types! { pub const SubtensorInitialSenateRequiredStakePercentage: u64 = 1; // 1 percent of total stake pub const SubtensorInitialNetworkImmunity: u64 = 7 * 7200; pub const SubtensorInitialMinAllowedUids: u16 = 128; - pub const SubtensorInitialMinLockCost: u64 = 1_000_000_...
This will be a problem for future runtime upgrades, we need to have two of these definitions with their own compiler flags to only insert them under specific conditions.
subtensor
github_2023
others
207
opentensor
Rubberbandits
@@ -710,18 +710,18 @@ impl<T: Config> Pallet<T> { TotalNetworks::<T>::mutate(|n| *n += 1); // --- 6. Set all default values **explicitly**. - Self::set_network_registration_allowed(netuid, true); - Self::set_max_allowed_uids(netuid, 256); - Self::set_max_allowed_validators(netui...
These all need to be `SubnetDefault*::<T>:get()`
subtensor
github_2023
others
195
opentensor
Rubberbandits
@@ -2033,36 +2037,38 @@ pub mod pallet { SubnetLimit::<T>::set(max_subnets); - log::info!( - "SubnetLimit( max_subnets: {:?} ) ", - max_subnets - ); - Self::deposit_event(Event::SubnetLimitSet( - max_subnets, - ));...
This will need to be benchmarked, as it seems the ostraca function is going to be pretty read/write heavy as it iterates through all stakers for a hotkey.
subtensor
github_2023
others
177
opentensor
camfairchild
@@ -289,27 +289,16 @@ A FRAME pallet is compromised of a number of blockchain primitives: First, install [Docker](https://docs.docker.com/get-docker/) and [Docker Compose](https://docs.docker.com/compose/install/). -Then run the following command to start a single node development chain. +Then at the source directo...
```suggestion docker-compose up -d ```
subtensor
github_2023
others
150
opentensor
eduardogr
@@ -27,49 +27,45 @@ env: # Test and build and publish jobs: check: - name: Tests and publishes targeting ${{ matrix.rust-target }} for OS ${{ matrix.os }} + name: Testing, building and publishing for ${{ matrix.rust-target }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} ## # Define multiple...
can't we build for both ??? and include them all in the release?
subtensor
github_2023
others
181
opentensor
Eugene-hu
@@ -155,14 +159,21 @@ impl<T: Config> Pallet<T> { // == Bonds and Dividends == // ========================= + // Get validator bonds penalty in [0, 1]. + let bonds_penalty: I32F32 = Self::get_float_bonds_penalty( netuid ); + // Calculate weights for bonds, apply bonds penalty to...
So if the bonds penalty = 0.5, will the interpolate function return an average between weights and clipped weights?
subtensor
github_2023
others
181
opentensor
Rubberbandits
@@ -1959,6 +1969,18 @@ pub mod pallet { ) -> DispatchResult { Self::do_sudo_set_adjustment_alpha(origin, netuid, adjustment_alpha) } + + #[pallet::call_index(59)] + #[pallet::weight((Weight::from_ref_time(14_000_000)
Was this benchmarked? If not, will add it to the list of features that need benchmarking before we push latest chain upgrade.
subtensor
github_2023
others
203
opentensor
Rubberbandits
@@ -37,8 +37,8 @@ ndarray = { version = "0.15.0", default-features = false } hex = { version = "0.4", default-features = false } # Used for sudo decentralization -pallet-collective = { version = "4.0.0-dev", default-features = false, path = "../collective" } -pallet-membership = {version = "4.0.0-dev", default-feat...
Instead of commenting these out, these need to be removed entirely. Git history will maintain all of this