Conversation
shamil-gadelshin
left a comment
There was a problem hiding this comment.
Great job overall!
I noticed that you introduce aliases more often than use Alpha as it is. What do you think about renaming it instead? Maybe AlphaToken instead of AlphaCurrency?
Thanks! Yeah, I was thinking about it as well. Just didn't want to introduce |
shamil-gadelshin
left a comment
There was a problem hiding this comment.
I would still prefer "AlphaToken".
| /// | ||
| /// * 'stake_to_be_added' (u64): | ||
| /// - The amount of stake to be added to the hotkey staking account. | ||
| /// * 'alpha_unstaked' (Alpha): |
There was a problem hiding this comment.
| /// * 'alpha_unstaked' (Alpha): | |
| /// * 'alpha_unstaked' (AlphaCurrency): |
|
|
||
| // 3. Swap the alpha to tao and update counters for this subnet. | ||
| let tao_unstaked: u64 = Self::unstake_from_subnet( | ||
| // 3. Swap the alpba to tao and update counters for this subnet. |
There was a problem hiding this comment.
| // 3. Swap the alpba to tao and update counters for this subnet. | |
| // 3. Swap the alpha to tao and update counters for this subnet. |
| let amount = amount.to_u64() as i64; | ||
| let actual_alpha = alpha_share_pool.update_value_for_one(coldkey, amount); |
There was a problem hiding this comment.
This can cause overflow and cause an produce negative value
| let amount = amount.to_u64() as i64; | ||
| alpha_share_pool.sim_update_value_for_one(amount) |
There was a problem hiding this comment.
Same here, maybe this is something to be fixed in another PR?
There was a problem hiding this comment.
We can probably leverage this clippy lint:
https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
@sam0x17 @ales-otf wdyt?
Description
Introduces a type for alpha currency.
Haven't touched tao yet, because it requires too much changes and takes too long to refactor and hard to maintain the branch, so only a half of the overall work on making tao/alpha type safe in this PR.
As we learned with the netuid refactoring, this new type has manual (non-derived) implementation for
TypeInfoin a way when it produces the same type info as foru64to make it backward compatible.Related Issue(s)
Type of Change
Breaking Change
Basically, this is a wrapper. It's done the same way, we wrapped netuid (u16) and the new type's binary representation and metadata should be identical to
u64. So it supposed to be backward-compatible and should not affect the clients.Checklist
cargo fmtandcargo clippyto ensure my code is formatted and linted correctlyScreenshots (if applicable)
Please include any relevant screenshots or GIFs that demonstrate the changes made.
Additional Notes
Please provide any additional information or context that may be helpful for reviewers.