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
1,024
opentensor
camfairchild
@@ -90,7 +90,7 @@ impl<T: Config> Pallet<T> { Self::set_blocks_since_last_step(*netuid, 0); Self::set_last_mechanism_step_block(*netuid, current_block); - if *netuid == 0 { + if *netuid == 0 && !Self::is_registration_allowed(*netuid) {
```suggestion if *netuid == 0 || !Self::is_registration_allowed(*netuid) { ```
subtensor
github_2023
others
1,168
opentensor
keithtensor
@@ -4,6 +4,17 @@ on: release: types: [published] workflow_dispatch: + inputs: + branch-or-tag: + description: "Branch or tag to use for the Docker image tag and ref to checkout (optional)" + required: false + default: "" + + push: + branches: + - devnet-ready + - de...
not testing on main?
subtensor
github_2023
others
1,165
opentensor
ales-otf
@@ -0,0 +1,28 @@ +#!/bin/sh + +set -e # Exit immediately if a command exits with a non-zero status. + +# Function to check for git changes and commit if necessary. +commit_if_changes() { + if [ -n "$(git status --porcelain)" ]; then + echo "changes detected, committing..." + git commit --allow-empty -...
Doesn't `allow-empty` requires you to force push? If that is the case, you can force push some changes, which are not supposed to be pushed, like, rewriting the history on remote branch in case multiple people working on it - like we had recently on `feat/rao-*`. If it requires a force push, it would be better to cance...
subtensor
github_2023
others
1,161
opentensor
camfairchild
@@ -17,6 +17,8 @@ mod events { StakeAdded(T::AccountId, T::AccountId, u64, u64, u16), /// stake has been removed from the hotkey staking account onto the coldkey account. StakeRemoved(T::AccountId, T::AccountId, u64, u64, u16), + /// stake has been moved from origin (hotkey, subnet ID)...
```suggestion /// stake has been moved from origin (hotkey, subnet ID) to destination (hotkey, subnet ID) of this amount (in TAO). ```
subtensor
github_2023
others
955
opentensor
camfairchild
@@ -42,4 +42,16 @@ interface IStaking { * - The existing stake amount must be not lower than specified amount */ function removeStake(bytes32 hotkey, uint256 amount, uint16 netuid) external; + + /** + * @dev Returns the stake amount associated with the specified `hotkey` and `coldkey`. + * + * This ...
```suggestion function getStake(bytes32 hotkey, bytes32 coldkey, uint16 netuid) external view returns (uint64); ```
subtensor
github_2023
others
955
opentensor
camfairchild
@@ -42,4 +42,16 @@ interface IStaking { * - The existing stake amount must be not lower than specified amount */ function removeStake(bytes32 hotkey, uint256 amount, uint16 netuid) external; + + /** + * @dev Returns the stake amount associated with the specified `hotkey` and `coldkey`. + * + * This ...
```suggestion * @param coldkey The coldkey public key (32 bytes). * @param netuid The subnet the stake is on (uint16). ```
subtensor
github_2023
others
955
opentensor
camfairchild
@@ -59,6 +59,9 @@ impl StakingPrecompile { id if id == get_method_id("removeStake(bytes32,uint256,uint16)") => { Self::remove_stake(handle, &method_input) } + id if id == get_method_id("getStake(bytes32,bytes32)") => {
```suggestion id if id == get_method_id("getStake(bytes32,bytes32,uint16)") => { ```
subtensor
github_2023
others
1,153
opentensor
ales-otf
@@ -68,9 +68,7 @@ impl StakingPrecompile { fn add_stake(handle: &mut impl PrecompileHandle, data: &[u8]) -> PrecompileResult { let hotkey = Self::parse_hotkey(data)?.into(); let amount: U256 = handle.context().apparent_value; - - // TODO: Use netuid method parameter here - let netui...
You don't have to clarify type parameter here as `parse_netuid` returns `u16`. But is it ok to parse `u16` here, while having `u256` in contract?
subtensor
github_2023
others
1,015
opentensor
gztensor
@@ -64,7 +64,8 @@ impl<T: Config> Pallet<T> { let return_per_1000: U64F64 = if total_stake > U64F64::from_num(0) { emissions_per_day - .saturating_mul(U64F64::from_num(0.82)) + .saturating_mul(U64F64::from_num(u16::MAX.saturating_sub(take.0)))
Can we use `.into()` here to be more idiomatic?
subtensor
github_2023
others
1,109
opentensor
camfairchild
@@ -3747,3 +3747,151 @@ fn test_do_set_child_cooldown_period() { assert_eq!(children_after, vec![(proportion, child)]); }); } + +// Test that setting childkeys requires minimum stake +#[test] +fn test_do_set_child_min_stake_check() {
duplicate? of L3636
subtensor
github_2023
others
1,109
opentensor
camfairchild
@@ -3747,3 +3747,151 @@ fn test_do_set_child_cooldown_period() { assert_eq!(children_after, vec![(proportion, child)]); }); } + +// Test that setting childkeys requires minimum stake +#[test] +fn test_do_set_child_min_stake_check() { + new_test_ext(1).execute_with(|| { + let coldkey = U256::fro...
```suggestion ```
subtensor
github_2023
others
1,103
opentensor
camfairchild
@@ -3747,3 +3749,136 @@ fn test_do_set_child_cooldown_period() { assert_eq!(children_after, vec![(proportion, child)]); }); } + +/// Test that childkey take is zero if the parent and child share the same coldkey +#[test] +fn test_childkey_take_same_coldkey() { + new_test_ext(1).execute_with(|| { + ...
```suggestion // - Child stake is not increased (child & parent have same owner => no child-take) ```
subtensor
github_2023
others
1,103
opentensor
ppolewicz
@@ -3747,3 +3749,136 @@ fn test_do_set_child_cooldown_period() { assert_eq!(children_after, vec![(proportion, child)]); }); } + +/// Test that childkey take is zero if the parent and child share the same coldkey +#[test] +fn test_childkey_take_same_coldkey() { + new_test_ext(1).execute_with(|| { + ...
In this test child take and childkey take should be non-zero and it should be observed that the parent didn't get a deduction from either and has extraced full dividend that was due. The current implementation doesn't have this bug, but the test should not assume that - one day someone might be refactoring the code and...
subtensor
github_2023
others
1,103
opentensor
ppolewicz
@@ -3437,7 +3438,8 @@ fn test_childkey_take_drain() { #[test] fn test_childkey_take_drain_validator_take() {
This test should be refactored into a helper function that would then be used in two tests: - test_childkey_take_same_coldkey - test_childkey_take_drain_validator_take The helper function in question wouild accept parameters for `coldkey_parent` and `coldkey_child`, which would be the same in the first test and di...
subtensor
github_2023
others
1,093
opentensor
camfairchild
@@ -154,18 +154,36 @@ impl<T: Config> Pallet<T> { target_stakes_per_interval, )); } - pub fn set_stakes_this_interval_for_coldkey_hotkey( + + // Counts staking events within the [`StakeInterval`]. It increases the counter by 1 in case no + // limit exceeded, otherwise returns an erro...
```suggestion // Reset staking counter if it's been stake_interval blocks since the first staking action of the series. if stakes_count == 0 || last_staked_at.saturating_add(stake_interval) <= current_block { ```
subtensor
github_2023
others
1,051
opentensor
ales-otf
@@ -55,8 +69,8 @@ update_spec() { echo "*** Restoring genesis in '$chain'..." - update_genesis "$raw_genesis_temp" "$raw_spec_temp" "$raw_path" - update_genesis "$plain_genesis_temp" "$plain_spec_temp" "$plain_path" + update_genesis_and_code_substitutes "$raw_genesis_temp" "$raw_code_substitutes_temp" "$raw_s...
Makes sense adding `raw_code_substitutes_temp` and `plain_code_substitutes_temp` here as well.
subtensor
github_2023
others
1,051
opentensor
ales-otf
@@ -181,7 +181,27 @@ pub fn finney_mainnet_config() -> Result<ChainSpec, String> { balances_issuance, )) .with_properties(properties) - .build()) + .build(); + + // Load and set the code substitute to avoid archive node sync panic + // See <https://github.com/opentensor/subtensor/pull/105...
This requires having `code_substitute_2585476.txt` at the specified path at the runtime. You need to embed it into binary using `include_str!`or `include_bytes!` macro.
subtensor
github_2023
others
1,084
opentensor
distributedstatemachine
@@ -1238,6 +1248,34 @@ pub mod pallet { ChainId::<T>::set(chain_id); Ok(()) } + + /// A public interface for `pallet_grandpa::Pallet::schedule_grandpa_change`. + /// + /// Schedule a change in the authorities. + /// + /// The change will be applied a...
Do we want to push this in_block, or have it as a runtime var we can adjust ?
subtensor
github_2023
others
1,043
opentensor
gztensor
@@ -0,0 +1,381 @@ +extern crate alloc; +use crate::precompiles::{get_method_id, get_slice}; +use crate::Runtime; +use fp_evm::{ + ExitError, ExitSucceed, PrecompileFailure, PrecompileHandle, PrecompileOutput, PrecompileResult, +}; +use sp_core::{ByteArray, U256}; +use sp_std::vec; +pub const METAGRAPH_PRECOMPILE_IND...
Move this method to subnets precompile. It will be implemented in the issue #1067
subtensor
github_2023
others
1,043
opentensor
gztensor
@@ -13,10 +13,12 @@ use pallet_evm_precompile_simple::{ECRecover, ECRecoverPublicKey, Identity, Ripe // Include custom precompiles mod balance_transfer; mod ed25519; +mod metagraph;
`METAGRAPH_PRECOMPILE_INDEX` also needs to be in `used_addresses` so that `is_precompile` works correctly.
subtensor
github_2023
others
1,022
opentensor
gztensor
@@ -105,6 +106,77 @@ impl<T: Config> Pallet<T> { }) } + /// ---- The implementation for the extrinsic batch_commit_weights. + /// + /// This call runs a batch of commit weights calls, continuing on errors. + /// + /// # Args: + /// * 'origin': (<T as frame_system::Config>RuntimeOrigin...
If commit_hashes vector is longer than netuids vector, we will be committing weights for root, which will fail. Is this intentional that we don't check for vector lengths to match?
subtensor
github_2023
others
1,050
opentensor
camfairchild
@@ -1,26 +1,25 @@ use super::*; +use sp_core::Get;
Is there a test for the new rate limit mechanic?
subtensor
github_2023
others
1,050
opentensor
camfairchild
@@ -0,0 +1,45 @@ +use super::*; +use crate::HasMigrationRun; +use frame_support::pallet_prelude::ValueQuery; +use frame_support::storage_alias; +use frame_support::{traits::Get, weights::Weight}; +use scale_info::prelude::string::String; + +/// Module containing deprecated storage format for WeightsMinStake +pub mod de...
```suggestion HasMigrationRun::<T>::insert(&migration_name, true); weight = weight.saturating_add(T::DbWeight::get().writes(1)); ```
subtensor
github_2023
others
1,036
opentensor
distributedstatemachine
@@ -299,24 +299,6 @@ impl<T: Config> Pallet<T> { Self::deposit_event(Event::NetworkRateLimitSet(limit)); } - /// Checks if registrations are allowed for a given subnet. - /// - /// This function retrieves the subnet hyperparameters for the specified subnet and checks the `registration_allowed` ...
This is not dead code , and is required for not paying out emissions when registrations are turned off
subtensor
github_2023
others
1,036
opentensor
distributedstatemachine
@@ -113,26 +113,24 @@ pub fn vec_max_upscale_to_u16(vec: &[I32F32]) -> Vec<u16> { }) .collect(); } - return vec - .iter() + vec.iter() .map(|e: &I32F32| { e.saturating_mul(u16_max) ...
Do not change the math functions. they have been battled tested
subtensor
github_2023
others
1,036
opentensor
distributedstatemachine
@@ -22,33 +22,42 @@ mod errors { HotKeyAccountNotExists, /// The hotkey is not registered in any subnet. HotKeyNotRegisteredInNetwork, - /// Request to stake, unstake or subscribe is made by a coldkey that is not associated with the hotkey account. + /// Request to stake, unstak...
Do we need all these lint changes ? We should be using the exisitng defaults
subtensor
github_2023
others
1,036
opentensor
distributedstatemachine
@@ -2736,106 +2736,8 @@ fn test_blocks_since_last_step() { assert_eq!(SubtensorModule::get_blocks_since_last_step(netuid), 27); }); } -// // Map the retention graph for consensus guarantees with an single epoch on a graph with 512 nodes, of which the first 64 are validators, the graph is split into a maj...
Do not delete this. It generates code graph for yuma consensus guarantees
subtensor
github_2023
others
982
opentensor
JohnReedV
@@ -106,8 +109,16 @@ impl<T: Config> Pallet<T> { // ================================== // ==== YumaConsensus UID params ==== // ================================== + pub fn set_last_crv3_update_for_uid(netuid: u16, uid: u16, last_update: u64) { + let mut updated_last_update_vec = Self::get_last_...
A separate `get_last_update` tracker is not needed because `get_last_update` is already used throughout the codebase to track the last time weights were updated, regardless of the method, hence the failing childkey/emission tests.
subtensor
github_2023
others
982
opentensor
JohnReedV
@@ -179,6 +202,124 @@ impl<T: Config> Pallet<T> { } } + /// The `reveal_crv3_commits` function is run at the very beginning of epoch `n`, + /// revealing commitments from epoch `n - 2`. + /// n - 2. + pub fn reveal_crv3_commits(netuid: u16) -> dispatch::DispatchResult { + use ark_seri...
Need to consider `get_reveal_period`
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -434,6 +434,19 @@ pub mod pallet { pub fn DefaultSubnetOwnerCut<T: Config>() -> u16 { T::InitialSubnetOwnerCut::get() } + + #[pallet::type_value] + /// Default value for subnet minter cut.
```suggestion /// Default value for subnet miner cut. ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -434,6 +434,19 @@ pub mod pallet { pub fn DefaultSubnetOwnerCut<T: Config>() -> u16 { T::InitialSubnetOwnerCut::get() } + + #[pallet::type_value] + /// Default value for subnet minter cut. + pub fn DefaultSubnetMinterCut<T: Config>() -> u16 {
```suggestion pub fn DefaultSubnetMinerCut<T: Config>() -> u16 { ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -434,6 +434,19 @@ pub mod pallet { pub fn DefaultSubnetOwnerCut<T: Config>() -> u16 { T::InitialSubnetOwnerCut::get() } + + #[pallet::type_value] + /// Default value for subnet minter cut. + pub fn DefaultSubnetMinterCut<T: Config>() -> u16 { + T::InitialSubnetMinterCut::get()
```suggestion T::InitialSubnetMinerCut::get() ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -884,6 +897,14 @@ pub mod pallet { #[pallet::storage] /// ITEM( subnet_owner_cut ) pub type SubnetOwnerCut<T> = StorageValue<_, u16, ValueQuery, DefaultSubnetOwnerCut<T>>; + + #[pallet::storage] + /// ITEM( subnet_minter_cut ) + pub type SubnetMinterCut<T> = StorageValue<_, u16, ValueQuer...
```suggestion /// ITEM( subnet_miner_cut ) pub type SubnetMinerCut<T> = StorageValue<_, u16, ValueQuery, DefaultSubnetMinerCut<T>>; ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -174,6 +174,13 @@ mod config { /// Initial network subnet cut. #[pallet::constant] type InitialSubnetOwnerCut: Get<u16>; + /// Initial subnet minter cut. + #[pallet::constant] + type InitialSubnetMinterCut: Get<u16>;
```suggestion /// Initial subnet miner cut. #[pallet::constant] type InitialSubnetMinerCut: Get<u16>; ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -111,6 +111,10 @@ mod events { Faucet(T::AccountId, u64), /// the subnet owner cut is set. SubnetOwnerCutSet(u16), + /// the subnet minter cut is set. + SubnetMinterCutSet(u16),
```suggestion /// the subnet miner cut is set. SubnetMinerCutSet(u16), ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -611,6 +611,26 @@ impl<T: Config> Pallet<T> { Self::deposit_event(Event::SubnetOwnerCutSet(subnet_owner_cut)); } + pub fn set_subnet_minter_cut(subnet_minter_cut: u16) { + SubnetMinterCut::<T>::set(subnet_minter_cut); + Self::deposit_event(Event::SubnetMinterCutSet(subnet_minter_cut)...
```suggestion pub fn set_subnet_miner_cut(subnet_minter_cut: u16) { SubnetMinterCut::<T>::set(subnet_miner_cut); Self::deposit_event(Event::SubnetMinerCutSet(subnet_miner_cut)); } pub fn get_subnet_miner_cut() -> u16 { SubnetMinerCut::<T>::get() } ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -952,6 +952,8 @@ parameter_types! { pub const SubtensorInitialMinAllowedUids: u16 = 128; pub const SubtensorInitialMinLockCost: u64 = 1_000_000_000_000; // 1000 TAO pub const SubtensorInitialSubnetOwnerCut: u16 = 11_796; // 18 percent + pub const SubtensorInitialSubnetMinterCut: u16 = 11_796; // 18...
```suggestion pub const SubtensorInitialSubnetMinerCut: u16 = 11_796; // 18 percent ```
subtensor
github_2023
others
960
opentensor
cuteolaf
@@ -1018,6 +1020,8 @@ impl pallet_subtensor::Config for Runtime { type InitialNetworkMinLockCost = SubtensorInitialMinLockCost; type InitialNetworkLockReductionInterval = SubtensorInitialNetworkLockReductionInterval; type InitialSubnetOwnerCut = SubtensorInitialSubnetOwnerCut; + type InitialSubnetMint...
```suggestion type InitialSubnetMinerCut = SubtensorInitialSubnetMinerCut; ```
subtensor
github_2023
others
996
opentensor
sam0x17
@@ -1,8 +1,39 @@ use super::*; +use codec::{Decode, Encode, MaxEncodedLen}; pub mod lock; pub mod registration; pub mod serving; pub mod subnet; pub mod tempo; pub mod uids; pub mod weights; + +#[derive( + Clone, + Copy, + Debug, + Decode, + Default, + Encode, + PartialEq, + Eq, + Par...
maybe also `repr(u8)` so we can hint to the compiler that we are never going to add many many more variants?
subtensor
github_2023
others
950
opentensor
camfairchild
@@ -199,59 +199,73 @@ impl<T: Config> Pallet<T> { mining_emission: u64, ) { // --- 1. First, calculate the hotkey's share of the emission. - let take_proportion: I64F64 = I64F64::from_num(Self::get_childkey_take(hotkey, netuid)) - .saturating_div(I64F64::from_num(u16::MAX)); - ...
This precision differs from the later use when multiplying on 233
subtensor
github_2023
others
950
opentensor
camfairchild
@@ -199,59 +199,73 @@ impl<T: Config> Pallet<T> { mining_emission: u64, ) { // --- 1. First, calculate the hotkey's share of the emission. - let take_proportion: I64F64 = I64F64::from_num(Self::get_childkey_take(hotkey, netuid)) - .saturating_div(I64F64::from_num(u16::MAX)); - ...
probably shouldn't cast here (keep as a float). Maybe only cast the final results.
subtensor
github_2023
others
950
opentensor
camfairchild
@@ -3428,3 +3428,277 @@ fn test_set_weights_no_parent() { assert!(SubtensorModule::check_weights_min_stake(&hotkey, netuid)); }); } + +/// Test that drain_hotkey_emission sends childkey take fully to the childkey. +#[test] +fn test_childkey_take_drain() { + new_test_ext(1).execute_with(|| { + l...
Nit: Why not just populate pendinghotkeyemission directly.
subtensor
github_2023
others
927
opentensor
sam0x17
@@ -45,10 +45,11 @@ fn is_as_primitive(ident: &Ident) -> bool { #[cfg(test)] mod tests { use super::*; + use quote::quote; - fn lint(input: &str) -> Result { - let expr: ExprMethodCall = syn::parse_str(input).expect("should only use on a method call"); + fn lint(input: proc_macro2::TokenStream)...
should just `?` here instead of expecting
subtensor
github_2023
others
973
opentensor
orriin
@@ -53,41 +49,41 @@ type GrandpaBlockImport<B, C> = sc_consensus_grandpa::GrandpaBlockImport<FullBackend<B>, B, C, FullSelectChain<B>>; type GrandpaLinkHalf<B, C> = sc_consensus_grandpa::LinkHalf<B, C, FullSelectChain<B>>; -pub fn new_partial<B, RA, HF, BIQ>( +pub fn new_partial<BIQ>( config: &Configuratio...
?
subtensor
github_2023
others
973
opentensor
orriin
@@ -191,21 +187,21 @@ where } /// Build the import queue for the template runtime (aura + grandpa). -pub fn build_aura_grandpa_import_queue<B, RA, HF>( - client: Arc<FullClient<B, RA, HF>>, +pub fn build_aura_grandpa_import_queue( + client: Arc<Client>, config: &Configuration, eth_config: &EthConfig...
👀
subtensor
github_2023
others
973
opentensor
orriin
@@ -242,20 +238,20 @@ where } /// Build the import queue for the template runtime (manual seal). -pub fn build_manual_seal_import_queue<B, RA, HF>( - client: Arc<FullClient<B, RA, HF>>, +pub fn build_manual_seal_import_queue( + client: Arc<Client>, config: &Configuration, _eth_config: &EthConfigurat...
👀
subtensor
github_2023
others
973
opentensor
orriin
@@ -269,25 +265,25 @@ where } /// Builds a new service for a full client. -pub async fn new_full<B, RA, HF, NB>( +pub async fn new_full<NB>( mut config: Configuration, eth_config: EthConfiguration, sealing: Option<Sealing>, ) -> Result<TaskManager, ServiceError> where - B: BlockT<Hash = H256>, -...
👀
subtensor
github_2023
others
973
opentensor
orriin
@@ -676,35 +665,31 @@ pub fn new_chain_ops( task_manager, other, .. - } = new_partial::<Block, RuntimeApi, HostFunctions, _>( - config, - eth_config, - build_aura_grandpa_import_queue, - )?; + } = new_partial(config, eth_config, build_aura_grandpa_import_queue)?;...
👀
subtensor
github_2023
others
912
opentensor
camfairchild
@@ -714,6 +719,10 @@ impl InstanceFilter<RuntimeCall> for ProxyType { c, RuntimeCall::SubtensorModule(pallet_subtensor::Call::set_root_weights { .. }) ), + ProxyType::ChildKeys => matches!( + c, + RuntimeCall::SubtensorModule(pallet...
What about `set_childkey_take`?
subtensor
github_2023
others
954
opentensor
cuteolaf
@@ -492,7 +492,10 @@ impl<T: Config> Pallet<T> { pub fn set_commit_reveal_weights_enabled(netuid: u16, enabled: bool) { CommitRevealWeightsEnabled::<T>::set(netuid, enabled); } - + pub fn set_owner_cut(netuid: u16, owner_cut: T::AccountId) { + SubnetOwner::<T>::insert(netuid, owner_cut);
This doesn't make sense. I think `owner_cut` should be a numeric value.
subtensor
github_2023
others
954
opentensor
cuteolaf
@@ -430,7 +431,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> { Weight::from_parts(47_279_000, 4697) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) - } + } + fn sudo_set_owner_cut() -> Weight {
I see that you haven't updated the benchmarking scripts. How did you get the weight values here?
subtensor
github_2023
others
954
opentensor
cuteolaf
@@ -805,4 +811,10 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + + fn sudo_set_owner_cut() -> Weight { + Weight::from_parts(19_380_000, 456)
same issue here
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion fn devnet_genesis( ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion .with_genesis_config_patch(devnet_genesis( ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion ), // key 2 ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion ), // key 3 ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion ), // key 4 ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion ), // key 5 ```
subtensor
github_2023
others
952
opentensor
cuteolaf
@@ -0,0 +1,97 @@ +// Allowed since it's actually better to panic during chain setup when there is an error +#![allow(clippy::unwrap_used)] + +use super::*; + +pub fn devnet_config() -> Result<ChainSpec, String> { + let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; + + // ...
```suggestion ), // key 6 ```
subtensor
github_2023
others
924
opentensor
gztensor
@@ -1309,9 +1309,17 @@ pub mod pallet { } /// Is the caller allowed to set weights - pub fn check_weights_min_stake(hotkey: &T::AccountId) -> bool { + pub fn check_weights_min_stake(hotkey: &T::AccountId, netuid: u16) -> bool {
We should also consider stake that this hotkey gives to children, not only the one it receives from parents. There's a `get_stake_for_hotkey_on_subnet` function in `run_epoch.rs` that implements that. I think we should use it all over instead of `get_total_stake_for_hotkey` for this feature.
subtensor
github_2023
others
932
opentensor
camfairchild
@@ -301,10 +301,10 @@ impl<T: Config> Pallet<T> { nominator_stake.saturating_sub(Self::get_nonviable_stake(hotkey, &nominator)); // --- 10 Calculate this nominator's share of the emission. - let nominator_emission: I64F64 = I64F64::from_num(viable_nominator_stake) ...
this is a regression also
subtensor
github_2023
others
772
opentensor
sam0x17
@@ -0,0 +1,347 @@ +use crate::rpc::EthDeps; +pub use fc_rpc::{EthConfig, EthTask}; +use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; +use futures::future; +use futures::StreamExt; +use jsonrpsee::RpcModule; +use sc_client_api::{ + backend::{Backend, StorageProvider}, + client...
Would be good do discuss the performance implications of having a `BTreeMap` behind an arc+mutex. Perhaps something like a dashmap would be more appropriate if key ordering doesn't matter? Ideally we use something with more fine-grained locking I would think, though I'm not at all familiar with the access pattern here ...
subtensor
github_2023
others
772
opentensor
sam0x17
@@ -0,0 +1,347 @@ +use crate::rpc::EthDeps; +pub use fc_rpc::{EthConfig, EthTask}; +use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; +use futures::future; +use futures::StreamExt; +use jsonrpsee::RpcModule; +use sc_client_api::{ + backend::{Backend, StorageProvider}, + client...
this looks good, but we should probably think about adding a mechanism for handling task failures... if any of these tasks fail, it could leave the node in an inconsistent state. Logging and retry mechanisms could be useful here. Basically would feel safer if it was more self-healing
subtensor
github_2023
others
772
opentensor
sam0x17
@@ -0,0 +1,347 @@ +use crate::rpc::EthDeps; +pub use fc_rpc::{EthConfig, EthTask}; +use fp_rpc::{ConvertTransaction, ConvertTransactionRuntimeApi, EthereumRuntimeRPCApi}; +use futures::future; +use futures::StreamExt; +use jsonrpsee::RpcModule; +use sc_client_api::{ + backend::{Backend, StorageProvider}, + client...
I recommend breaking this up into helper functions, especially if we think this will grow to be even longer
subtensor
github_2023
others
772
opentensor
sam0x17
@@ -0,0 +1,116 @@ +use core::marker::PhantomData; +use sp_core::{crypto::ByteArray, hashing::keccak_256, H160}; +use sp_runtime::AccountId32; + +use pallet_evm::{ + ExitError, IsPrecompileResult, Precompile, PrecompileFailure, PrecompileHandle, + PrecompileResult, PrecompileSet, +}; +use pallet_evm_precompile_mod...
This should be a `TryFrom`
subtensor
github_2023
others
772
opentensor
sam0x17
@@ -93,6 +93,23 @@ pallet-registry = { default-features = false, path = "../pallets/registry" } # Metadata commitment pallet pallet-commitments = { default-features = false, path = "../pallets/commitments" } +# Frontier +fp-evm = { workspace = true }
btw you can: ```toml fp-evm.workspace = true ```
subtensor
github_2023
others
772
opentensor
orriin
@@ -1050,6 +1045,218 @@ impl pallet_admin_utils::Config for Runtime { type WeightInfo = pallet_admin_utils::weights::SubstrateWeight<Runtime>; } +// Define the ChainId +parameter_types! { + pub const SubtensorChainId: u64 = 0x03B1; // Unicode for lowercase alpha + // pub const SubtensorChainId: u64 = 0x03...
@gregzaitsev is this ok?
subtensor
github_2023
others
864
opentensor
orriin
@@ -1254,16 +1251,20 @@ pub mod pallet { /// ITEM( weights_min_stake ) pub type WeightsMinStake<T> = StorageValue<_, u64, ValueQuery, DefaultWeightsMinStake<T>>; #[pallet::storage] - /// --- MAP (netuid, who) --> (hash, weight) | Returns the hash and weight committed by an account for a given netuid. ...
do we need migrations for the storage changes?
subtensor
github_2023
others
864
opentensor
open-junius
@@ -568,6 +569,11 @@ pub mod pallet { 0 } #[pallet::type_value] + /// Default minimum stake for weights.
wrong doc
subtensor
github_2023
others
843
opentensor
ppolewicz
@@ -18,34 +18,45 @@ impl<T: Config> Pallet<T> { /// - The hash representing the committed weights. /// /// # Raises: - /// * `WeightsCommitNotAllowed`: - /// - Attempting to commit when it is not allowed. + /// * `CommitRevealDisabled`: + /// - Attempting to commit when the commit-revea...
Attempting to commit should remove expired commits from the queue, otherwise if all of them expire, you might brick a hotkey (and also lets not write the expired commits back to the storage)
subtensor
github_2023
others
843
opentensor
ppolewicz
@@ -452,50 +527,29 @@ impl<T: Config> Pallet<T> { uids.len() <= subnetwork_n as usize } - #[allow(clippy::arithmetic_side_effects)] - pub fn can_commit(netuid: u16, who: &T::AccountId) -> bool { - if let Some((_hash, commit_block)) = WeightCommits::<T>::get(netuid, who) { - let i...
it should be only allowed for one epoch, in the epoch N epochs after the commit epoch, where N might be equal to 1 by default or it might be a higher natural number, as configured by a hyperparameter
subtensor
github_2023
others
820
opentensor
distributedstatemachine
@@ -31,7 +31,7 @@ jobs: - name: Check that spec_version has been bumped run: | - spec_version=$(PATH=$PATH:$HOME/.cargo/.bin substrate-spec-version wss://entrypoint-finney.opentensor.ai:443 | tr -d '\n') + spec_version=$(PATH=$PATH:$HOME/.cargo/.bin substrate-spec-version ${{ vars.NU...
we need to revert it , otherwise it passes the wrong spec version.
subtensor
github_2023
others
846
opentensor
sam0x17
@@ -0,0 +1,78 @@ +use super::*; +use syn::{visit::Visit, ExprMethodCall, File, Ident}; + +pub struct ForbidAsPrimitiveConversion; + +impl Lint for ForbidAsPrimitiveConversion { + fn lint(source: &File) -> Result { + let mut visitor = AsPrimitiveVisitor::default(); + + visitor.visit_file(source); + + ...
maybe `u16` as well, or does that not exist for these?
subtensor
github_2023
others
850
opentensor
sam0x17
@@ -1264,6 +1269,10 @@ pub mod pallet { (H256, u64), OptionQuery, >; + #[pallet::storage] + /// ITEM( testnet_total_supply_override ) + pub type TestnetTotalSupplyOverride<T> =
nit: I would just call it `TotalSupplyOverride<T>` since it in theory could be used for any network. In practice we will only use for testnet but that is not hard-coded in any way and couldn't be really.
subtensor
github_2023
others
850
opentensor
distributedstatemachine
@@ -163,7 +168,7 @@ impl<T: Config> Pallet<T> { total_issuance .checked_div( I96F32::from_num(2.0) - .saturating_mul(I96F32::from_num(10_500_000_000_000_000.0)), + ...
Why are you dividing by 2 now ? How would be be sure that this override doesnt accidentally get into finney ?
subtensor
github_2023
others
850
opentensor
distributedstatemachine
@@ -903,6 +903,40 @@ fn test_get_emission_across_entire_issuance_range() { }); } +#[test]
Add test without. Make sure that inital tests / 21 M invariant isnt broken with by code modification
subtensor
github_2023
others
850
opentensor
distributedstatemachine
@@ -146,7 +146,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 197,...
We should bump this to whatever finney is , otherwise the build wont go all the way thorugh , as we would have to manually bump this. Not unless its a hotfix into testnet.
subtensor
github_2023
others
840
opentensor
open-junius
@@ -53,21 +53,21 @@ if [[ $BUILD_BINARY == "1" ]]; then fi echo "*** Building chainspec..." -"$BASE_DIR/target/release/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FULL_PATH +"$BASE_DIR/target/production/node-subtensor" build-spec --disable-default-bootnode --raw --chain $CHAIN >$FUL...
after "cargo build --workspace --profile=release" in line 51 executed. the binary will be in target/release
subtensor
github_2023
others
750
opentensor
distributedstatemachine
@@ -41,7 +41,13 @@ pub trait SubtensorCustomApi<BlockHash> { fn get_neurons(&self, netuid: u16, at: Option<BlockHash>) -> RpcResult<Vec<u8>>; #[method(name = "neuronInfo_getNeuron")] fn get_neuron(&self, netuid: u16, uid: u16, at: Option<BlockHash>) -> RpcResult<Vec<u8>>; - + #[method(name = "neuronIn...
We are deprecating the addition of new RPCs. going forwards , clients should make query state directly , for what they nee. That being said , since this is a part of the Axon , it can be fetched from neuron info which the cli already uses to populate the metagraph
subtensor
github_2023
others
750
opentensor
distributedstatemachine
@@ -507,6 +507,89 @@ mod dispatches { protocol, placeholder1, placeholder2, + None, + ) + } + + /// Same as `serve_axon` but takes a certificate as an extra optional argument. + /// Serves or updates axon /prometheus infor...
Do we need a new method for this ? Can we just have serve Axon ? with Certificate optional ?
subtensor
github_2023
others
750
opentensor
distributedstatemachine
@@ -507,6 +507,89 @@ mod dispatches { protocol, placeholder1, placeholder2, + None, + ) + } + + /// Same as `serve_axon` but takes a certificate as an extra optional argument. + /// Serves or updates axon /prometheus infor...
Making this an option removes the need for `serve_axon_tls`
subtensor
github_2023
others
750
opentensor
gztensor
@@ -116,6 +115,15 @@ pub mod pallet { pub placeholder2: u8, } + /// Struct for NeuronCertificate. + pub type NeuronCertificateOf = NeuronCertificate; + /// Data structure for NeuronCertificate information. + #[derive(Decode, Encode, Default, TypeInfo, PartialEq, Eq, Clone, Debug)] + pub s...
Can we make it a bounded vector instead? There should be a limit of how much data can an axon store on-chain.
subtensor
github_2023
others
750
opentensor
gztensor
@@ -86,6 +90,15 @@ impl<T: Config> Pallet<T> { Error::<T>::ServingRateLimitExceeded ); + // Check certificate
We should be cleaning up stored certificates when the neuron is deregistered, there needs to be a matching deletion for this insertion.
subtensor
github_2023
others
750
opentensor
distributedstatemachine
@@ -147,6 +147,23 @@ impl<T: Config> Pallet<T> { Some(neuron) } + pub fn get_neuron_certificate(netuid: u16, uid: u16) -> Option<NeuronCertificate> {
if we dont have rpcs, do we still need this ?
subtensor
github_2023
others
750
opentensor
ppolewicz
@@ -1369,13 +1369,7 @@ impl_runtime_apis! { } fn get_delegate(delegate_account_vec: Vec<u8>) -> Vec<u8> { - let _result = SubtensorModule::get_delegate(delegate_account_vec); - if _result.is_some() { - let result = _result.expect("Could not get DelegateInfo"); - ...
```suggestion let _result = SubtensorModule::get_delegate(delegate_account_vec); if _result.is_some() { let result = _result.expect("Could not get DelegateInfo"); result.encode() } else { vec![] } ```
subtensor
github_2023
others
750
opentensor
ppolewicz
@@ -1391,13 +1385,7 @@ impl_runtime_apis! { } fn get_neuron_lite(netuid: u16, uid: u16) -> Vec<u8> { - let _result = SubtensorModule::get_neuron_lite(netuid, uid); - if _result.is_some() { - let result = _result.expect("Could not get NeuronInfoLite"); - ...
```suggestion let _result = SubtensorModule::get_neuron_lite(netuid, uid); if _result.is_some() { let result = _result.expect("Could not get NeuronInfoLite"); result.encode() } else { vec![] } ```
subtensor
github_2023
others
750
opentensor
ppolewicz
@@ -1406,25 +1394,13 @@ impl_runtime_apis! { } fn get_neuron(netuid: u16, uid: u16) -> Vec<u8> { - let _result = SubtensorModule::get_neuron(netuid, uid); - if _result.is_some() { - let result = _result.expect("Could not get NeuronInfo"); - result....
```suggestion let _result = SubtensorModule::get_neuron(netuid, uid); if _result.is_some() { let result = _result.expect("Could not get NeuronInfo"); result.encode() } else { vec![] } ```
subtensor
github_2023
others
750
opentensor
ppolewicz
@@ -1406,25 +1394,13 @@ impl_runtime_apis! { } fn get_neuron(netuid: u16, uid: u16) -> Vec<u8> { - let _result = SubtensorModule::get_neuron(netuid, uid); - if _result.is_some() { - let result = _result.expect("Could not get NeuronInfo"); - result....
```suggestion let _result = SubtensorModule::get_subnet_info(netuid); if _result.is_some() { let result = _result.expect("Could not get SubnetInfo"); result.encode() } else { vec![] } ```
subtensor
github_2023
others
750
opentensor
ppolewicz
@@ -1448,13 +1424,7 @@ impl_runtime_apis! { } fn get_subnet_hyperparams(netuid: u16) -> Vec<u8> { - let _result = SubtensorModule::get_subnet_hyperparams(netuid); - if _result.is_some() { - let result = _result.expect("Could not get SubnetHyperparams"); - ...
```suggestion let _result = SubtensorModule::get_subnet_hyperparams(netuid); if _result.is_some() { let result = _result.expect("Could not get SubnetHyperparams"); result.encode() } else { vec![] } ```
subtensor
github_2023
others
827
opentensor
orriin
@@ -142,7 +146,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 196,...
Intentional?
subtensor
github_2023
others
821
opentensor
keithtensor
@@ -32,7 +32,7 @@ members = [ "runtime", "support/tools", "support/macros", - "support/linting", + "support/linting", "support/procedural-fork",
```suggestion "support/linting", "support/procedural-fork", ```
subtensor
github_2023
others
821
opentensor
keithtensor
@@ -7,6 +7,7 @@ edition = "2021" syn.workspace = true quote.workspace = true proc-macro2.workspace = true +procedural-fork = { version = "1.10.0-rc3", path = "../procedural-fork" }
Shouldn't just the path attribute work alone, without the version?
subtensor
github_2023
others
821
opentensor
keithtensor
@@ -0,0 +1,301 @@ +use super::*; +use proc_macro2::TokenStream as TokenStream2; +use procedural_fork::exports::construct_runtime::parse::RuntimeDeclaration; +use quote::ToTokens; +use syn::{visit::Visit, File}; + +pub struct RequireExplicitPalletIndex; + +impl Lint for RequireExplicitPalletIndex { + fn lint(source: ...
Technically speaking, we really just need to look for the `=` sign, since it MUST also have been followed by a number in order for it to compile, but this here also checks whether the pallet index is what we expect so it's fine?
subtensor
github_2023
others
828
opentensor
orriin
@@ -142,7 +142,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion { // `spec_version`, and `authoring_version` are the same between Wasm and native. // This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use // the compatible custom types. - spec_version: 202,...
This isn't a runtime change, so I don't think we need to change this
subtensor
github_2023
others
807
opentensor
garrett-opentensor
@@ -154,3 +155,1112 @@ fn test_set_and_get_hotkey_emission_tempo() { assert_eq!(updated_tempo, new_tempo); }); } + +// Test getting nonviable stake +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test coinbase test_get_nonviable_stake -- --nocapture +#[test] +fn test_get_nonviable_stake() { + new_te...
```suggestion // We expect to distribute using the NEW stake for nominator 1; because the delta is net negative ```
subtensor
github_2023
others
807
opentensor
garrett-opentensor
@@ -154,3 +155,1112 @@ fn test_set_and_get_hotkey_emission_tempo() { assert_eq!(updated_tempo, new_tempo); }); } + +// Test getting nonviable stake +// SKIP_WASM_BUILD=1 RUST_LOG=debug cargo test --test coinbase test_get_nonviable_stake -- --nocapture +#[test] +fn test_get_nonviable_stake() { + new_te...
Need to rethink this test. doesn't appear to be correctly testing negative delta
subtensor
github_2023
others
599
opentensor
open-junius
@@ -25,6 +26,7 @@ impl<T: Config> Pallet<T> { origin: T::RuntimeOrigin, netuid: u16, commit_hash: H256, + nonce: u64,
update doc for the new argument.
subtensor
github_2023
others
599
opentensor
open-junius
@@ -40,11 +42,15 @@ impl<T: Config> Pallet<T> { Error::<T>::WeightsCommitNotAllowed ); - WeightCommits::<T>::insert( - netuid, - &who, - (commit_hash, Self::get_current_block_as_u64()), - ); + WeightCommits::<T>::mutate(netuid, &who, |commits...
should we check if nonce is duplicate, nonce should be continuous or not.
subtensor
github_2023
others
599
opentensor
open-junius
@@ -86,23 +92,25 @@ impl<T: Config> Pallet<T> { values: Vec<u16>, salt: Vec<u16>, version_key: u64, + nonce: u64,
update doc for new argument.
subtensor
github_2023
others
599
opentensor
open-junius
@@ -115,10 +123,14 @@ impl<T: Config> Pallet<T> { version_key, ));
should we add nonce into hash computation.