-
Notifications
You must be signed in to change notification settings - Fork 289
Hotfix/no registration no emission #474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
distributedstatemachine
merged 7 commits into
main
from
hotfix/no_registration_no_emission
May 27, 2024
+114
−5
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
46990bd
feat: burn emissions for subnets with registrations turned off
490ea18
chore: make registrations allowed field pub
05151ef
chore: use getter
b09065c
tests
fc61185
fix: skip_children only available in nightly
e5708f0
test: turn reg on , gets emissions
848a6ee
chore: turn reg off for netuid that was on and assert no new emissions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -803,3 +803,94 @@ fn test_burn_adjustment_case_e_zero_registrations() { | |
| assert_eq!(adjusted_diff, 5_000); | ||
| }); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_emission_based_on_registration_status() { | ||
| new_test_ext(1).execute_with(|| { | ||
| let n: u16 = 100; | ||
| let netuid_off: u16 = 1; | ||
| let netuid_on: u16 = 2; | ||
| let tempo: u16 = 1; | ||
| let netuids: Vec<u16> = vec![netuid_off, netuid_on]; | ||
| let emissions: Vec<u64> = vec![1000000000, 1000000000]; | ||
|
|
||
| // Add subnets with registration turned off and on | ||
| add_network(netuid_off, tempo, 0); | ||
| add_network(netuid_on, tempo, 0); | ||
| SubtensorModule::set_max_allowed_uids(netuid_off, n); | ||
| SubtensorModule::set_max_allowed_uids(netuid_on, n); | ||
| SubtensorModule::set_emission_values(&netuids, emissions).unwrap(); | ||
| SubtensorModule::set_network_registration_allowed(netuid_off, false); | ||
| SubtensorModule::set_network_registration_allowed(netuid_on, true); | ||
|
|
||
| // Populate the subnets with neurons | ||
| for i in 0..n { | ||
| SubtensorModule::append_neuron(netuid_off, &U256::from(i), 0); | ||
| SubtensorModule::append_neuron(netuid_on, &U256::from(i), 0); | ||
| } | ||
|
|
||
| // Generate emission at block 0 | ||
| let block: u64 = 0; | ||
| SubtensorModule::generate_emission(block); | ||
|
|
||
| // Verify that no emission tuples are loaded for the subnet with registration off | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_off).is_none()); | ||
|
|
||
| // Verify that emission tuples are loaded for the subnet with registration on | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_on).is_some()); | ||
| assert_eq!( | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_on) | ||
| .unwrap() | ||
| .len(), | ||
| n as usize | ||
| ); | ||
|
|
||
| // Step to the next epoch block | ||
| let epoch_block: u16 = tempo; | ||
| step_block(epoch_block); | ||
|
|
||
| // Verify that no emission tuples are loaded for the subnet with registration off | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_off).is_none()); | ||
| log::info!( | ||
| "Emissions for netuid with registration off: {:?}", | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_off) | ||
| ); | ||
|
|
||
| // Verify that emission tuples are loaded for the subnet with registration on | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_on).is_some()); | ||
| log::info!( | ||
| "Emissions for netuid with registration on: {:?}", | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_on) | ||
| ); | ||
| assert_eq!( | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_on) | ||
| .unwrap() | ||
| .len(), | ||
| n as usize | ||
| ); | ||
|
|
||
| // drain the emission tuples for the subnet with registration on | ||
| SubtensorModule::drain_emission(next_block as u64); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is casting a function pointer to a |
||
| // Turn on registration for the subnet with registration off | ||
| SubtensorModule::set_network_registration_allowed(netuid_off, true); | ||
| SubtensorModule::set_network_registration_allowed(netuid_on, false); | ||
|
|
||
| // Generate emission at the next block | ||
| let next_block: u64 = block + 1; | ||
| SubtensorModule::generate_emission(next_block); | ||
|
|
||
| // Verify that emission tuples are now loaded for the subnet with registration turned on | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_off).is_some()); | ||
| log::info!( | ||
| "Emissions for netuid with registration on: {:?}", | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_on) | ||
| ); | ||
| assert!(SubtensorModule::get_loaded_emission_tuples(netuid_on).is_none()); | ||
| assert_eq!( | ||
| SubtensorModule::get_loaded_emission_tuples(netuid_off) | ||
| .unwrap() | ||
| .len(), | ||
| n as usize | ||
| ); | ||
| }); | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.