Skip to content

Comments

Use TaoBalance for pallet balances balance type#2417

Open
gztensor wants to merge 12 commits intodevnet-readyfrom
chore/imbalances
Open

Use TaoBalance for pallet balances balance type#2417
gztensor wants to merge 12 commits intodevnet-readyfrom
chore/imbalances

Conversation

@gztensor
Copy link
Contributor

@gztensor gztensor commented Feb 11, 2026

Description

Replace u64 with TaoCurrency for pallet balances balance and all over the subtensor code.

Note: Manually tested on a baedeker clone: Out of 383695 account balances none changed after the runtime upgrade.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe): Cleanup

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run ./scripts/fix_rust.sh to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

ales-otf
ales-otf previously approved these changes Feb 11, 2026
Copy link
Contributor

@ales-otf ales-otf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my comments are just stylistic preferences. additionally i didn't understand why you needed to add this _u64 specifier everywhere.

other than that i think this change is safe, because there is an entrypoint for this Balance type (the alias) so if you change it, the rest is compiler-driven refactoring. the inconsistency might appear only in places outside of this type or where we had a mixed type errors (alpha/tao used interchangeably). the first thing is unlikely for the balance value, the second can have a place. so far there still persists this issue with StakeThreshold, but i didn't see anything else in your PR

@gztensor gztensor added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Feb 11, 2026
impl RemAssign for TaoCurrency {
#[allow(clippy::arithmetic_side_effects)]
fn rem_assign(&mut self, rhs: Self) {
*self = *self % rhs;
Copy link
Collaborator

@l0r1s l0r1s Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rhs == 0 panics, do we want to keep the behavior as close as possible to the normal one maybe?

l0r1s
l0r1s previously approved these changes Feb 11, 2026
Copy link
Collaborator

@l0r1s l0r1s left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small remarks around the code that can panic.

It adds a lot of type safety and pave the way for more, great stuff!

Note for later: I was thinking about the naming of TaoCurrency and AlphaCurrency, a more appropriate name to match with Substrate primitives would be TaoBalance and AlphaBalance with the CustomBalance trait (as supertrait of Balance) because Currency as actually a full fledged system where you can make transfer, slash, burn, emit, etc...

@gztensor gztensor dismissed stale reviews from l0r1s and ales-otf via ade8b6f February 11, 2026 22:45
Currency -> Token
AlphaCurrency -> AlphaBalance
TaoCurrency -> TaoBalance
CurrencyReserve -> TokenReserve
@gztensor
Copy link
Contributor Author

Small remarks around the code that can panic.

It adds a lot of type safety and pave the way for more, great stuff!

Note for later: I was thinking about the naming of TaoCurrency and AlphaCurrency, a more appropriate name to match with Substrate primitives would be TaoBalance and AlphaBalance with the CustomBalance trait (as supertrait of Balance) because Currency as actually a full fledged system where you can make transfer, slash, burn, emit, etc...

Good point! I renamed the following:

Currency -> Token
AlphaCurrency -> AlphaBalance
TaoCurrency -> TaoBalance
CurrencyReserve -> TokenReserve

@gztensor gztensor changed the title Use TaoCurrency for pallet balances balance type Use TaoBalance for pallet balances balance type Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-cargo-audit This PR fails cargo audit but needs to be merged anyway

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants