Skip to content

Conversation

@jose-blockchain
Copy link

Description

Removes the overly aggressive precision check in the share pool that forced full unstake when partial unstake was requested. The previous implementation would force-remove all stake when the remaining share fraction dropped below 0.00001 or when the denominator appeared "too low" after emissions. This caused problems when paying transaction fees in alpha because there was no way to return unused portions of unstaked TAO.

The fix simplifies the precision handling to only clean up shares when the remaining value is truly negligible (less than 1 unit), allowing partial unstakes to succeed as expected.

Related Issue(s)

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):

Breaking Change

N/A - This is a bug fix that removes an error condition. Existing code that handled PrecisionLoss errors will no longer receive them, but operations will succeed instead of failing.

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

Screenshots (if applicable)

N/A

Additional Notes

Files changed:

  • primitives/share-pool/src/lib.rs - Simplified precision handling in update_value_for_one()
  • pallets/subtensor/src/macros/errors.rs - Removed PrecisionLoss error variant
  • pallets/subtensor/src/staking/recycle_alpha.rs - Removed PrecisionLoss checks
  • pallets/subtensor/src/tests/recycle_alpha.rs - Updated tests to verify operations succeed

Potential Reviewers: @const-t @opentensor/core-devs

…fees

Fixes opentensor#2336

- Remove overly aggressive precision loss check that forced full unstake
- Only clean up shares when remaining value is truly negligible (<1 unit)
- Remove PrecisionLoss error that blocked valid partial unstake operations
- Update tests to verify partial unstake now succeeds with low-precision denominators
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shared pool precision affects alpha tx fees

1 participant