-
Notifications
You must be signed in to change notification settings - Fork 277
Consensus modes devnet #2202
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
base: devnet-ready
Are you sure you want to change the base?
Consensus modes devnet #2202
Conversation
|
needs to merge in latest devnet-ready |
| let previous_consensus_u16 = Consensus::<T>::get(netuid); | ||
| previous_consensus_u16 | ||
| .iter() | ||
| .map(|&c| { | ||
| I32F32::saturating_from_num(c) | ||
| .safe_div(I32F32::saturating_from_num(u16::MAX)) | ||
| }) | ||
| .collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated below, should be extracted to a function
| let diff = if *res > expected { | ||
| *res - expected | ||
| } else { | ||
| expected - *res | ||
| }; | ||
| assert!( | ||
| diff < I32F32::from_num(0.001), | ||
| "Values should be approximately equal" | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_abs_diff_eq! can be useful here
| let diff = if *res > expected { | ||
| *res - expected | ||
| } else { | ||
| expected - *res | ||
| }; | ||
| assert!( | ||
| diff < I32F32::from_num(0.001), | ||
| "Should use previous consensus when bond_penalty == 1" | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_abs_diff_eq! can be useful here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it is missing a dispatch call
- Extract duplicated consensus u16->I32F32 conversion to helper function - Replace manual diff assertions with assert_abs_diff_eq! macro - Add dispatchable extrinsic for set_liquid_alpha_consensus_mode
958be6e to
92b39a0
Compare
Description
Introducing consensus modes for liquid alpha calculations (using previous epoch or current epoch consensus)
The AUTO mode on default sets to CURRENT if bond_penalty != 1 and PREVIOUS if bond_penalty == 1
Type of Change
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctlyAdditional Notes
This is my first Subtensor contribution so please review it carefully and be lenient.