diff --git a/justfile b/justfile index 691d5bca2..495f78a27 100644 --- a/justfile +++ b/justfile @@ -4,7 +4,7 @@ export RUST_BACKTRACE := "full" export SKIP_WASM_BUILD := "1" export RUST_BIN_DIR := "target/x86_64-unknown-linux-gnu" export TARGET := "x86_64-unknown-linux-gnu" -export RUSTV := "nightly-2024-03-05" +export RUSTV := "stable" export RELEASE_NAME := "development" fmt: @@ -25,13 +25,13 @@ benchmarks: clippy: @echo "Running cargo clippy..." - cargo +{{RUSTV}} clippy -- -D clippy::panic \ + cargo +{{RUSTV}} clippy --workspace --all-targets -- -D \ -D clippy::todo \ -D clippy::unimplemented clippy-fix: @echo "Running cargo clippy with automatic fixes on potentially dirty code..." - cargo +{{RUSTV}} clippy --fix --allow-dirty -- -A clippy::panic \ + cargo +{{RUSTV}} clippy --fix --allow-dirty --workspace --all-targets -- -A \ -A clippy::todo \ -A clippy::unimplemented fix: diff --git a/pallets/subtensor/src/block_step.rs b/pallets/subtensor/src/block_step.rs index 80733e6b7..091ccd736 100644 --- a/pallets/subtensor/src/block_step.rs +++ b/pallets/subtensor/src/block_step.rs @@ -110,13 +110,17 @@ impl Pallet { // --- 1. Iterate across each network and add pending emission into stash. for (netuid, tempo) in as IterableStorageMap>::iter() { // Skip the root network or subnets with registrations turned off - if netuid == Self::get_root_netuid() || !Self::is_registration_allowed(netuid) { + if netuid == Self::get_root_netuid() { // Root emission or subnet emission is burned continue; } // --- 2. Queue the emission due to this network. - let new_queued_emission: u64 = Self::get_subnet_emission_value(netuid); + let mut new_queued_emission: u64 = Self::get_subnet_emission_value(netuid); + if !Self::is_registration_allowed(netuid) { + new_queued_emission = 0; // No emission for this network if registration is off. + } + log::debug!( "generate_emission for netuid: {:?} with tempo: {:?} and emission: {:?}", netuid, diff --git a/pallets/subtensor/tests/block_step.rs b/pallets/subtensor/tests/block_step.rs index 5df173906..9c81492e9 100644 --- a/pallets/subtensor/tests/block_step.rs +++ b/pallets/subtensor/tests/block_step.rs @@ -895,3 +895,45 @@ fn test_emission_based_on_registration_status() { ); }); } + +#[test] +fn test_epoch_runs_when_registration_disabled() { + new_test_ext(1).execute_with(|| { + let n: u16 = 100; + let netuid_off: u16 = 1; + let tempo: u16 = 1; + let netuids: Vec = vec![netuid_off]; + let emissions: Vec = vec![1000000000]; + + // Add subnets with registration turned off and on + add_network(netuid_off, tempo, 0); + SubtensorModule::set_max_allowed_uids(netuid_off, n); + SubtensorModule::set_emission_values(&netuids, emissions).unwrap(); + SubtensorModule::set_network_registration_allowed(netuid_off, false); + + // Populate the subnets with neurons + for i in 0..n { + SubtensorModule::append_neuron(netuid_off, &U256::from(i), 0); + } + + // Generate emission at block 1 + let block: u64 = 1; + SubtensorModule::generate_emission(block); + + step_block(1); // Now block 2 + + // Verify blocks since last step was set + assert_eq!(SubtensorModule::get_blocks_since_last_step(netuid_off), 1); + + // Step to the next epoch block + let epoch_block: u16 = tempo; + step_block(epoch_block); + + // Verify blocks since last step was set, this indicates we ran the epoch + assert_eq!( + SubtensorModule::get_blocks_since_last_step(netuid_off), + 0_u64 + ); + assert!(SubtensorModule::get_loaded_emission_tuples(netuid_off).is_some()); + }); +} diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 2364008fd..5564dca5d 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -135,7 +135,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: 152, + spec_version: 153, impl_version: 1, apis: RUNTIME_API_VERSIONS, transaction_version: 1,