Skip to content

Lock transfers#2641

Merged
sam0x17 merged 3 commits intodevnet-readyfrom
feat/conviction
May 6, 2026
Merged

Lock transfers#2641
sam0x17 merged 3 commits intodevnet-readyfrom
feat/conviction

Conversation

@gztensor
Copy link
Copy Markdown
Contributor

@gztensor gztensor commented May 6, 2026

Description

When a stake transfer happens between different coldkeys on the same netuid, the lock will be transferred. Using this algorithm:

  1. Read total alpha of the coldkey on this netuid. If total alpha is lower than amount transferred, error out with StakeUnavailable.
  2. Create a new mutable variable “remaining_to_transfer”.
  3. Read the lock for this coldkey and roll forward.
  4. If no lock exists, return ok
  5. Calculate available stake by subtracting locked_mass and unlocked_mass from total alpha.
  6. Reduce remaining_to_transfer by min(remaining_to_transfer, available stake)
  7. If result is non-zero, reduce remaining_to_transfer by min(unlocked_mass, remaining_to_transfer), reduce unlocked_mass on the source coldkey by the same amount, increase unlocked_mass on the destination coldkey by the same amount.
  8. If result is non-zero, check the hotkey match between source and destination coldkey locks (if destination coldkey lock exists). If no match, error out with LockHotkeyMismatch, otherwise, reduce remaining_to_transfer by min(remaining_to_transfer, locked_mass), reduce locked_mass on the source coldkey by the same amount, increase locked_mass on the destination coldkey by the same amount, reduce conviction on the source coldkey proportionally, and increase conviction on the destination coldkey proportionally.

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

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

@gztensor gztensor added skip-cargo-audit This PR fails cargo audit but needs to be merged anyway apply-benchmark-patch labels May 6, 2026
@github-actions github-actions Bot added hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet and removed apply-benchmark-patch labels May 6, 2026
@gztensor gztensor marked this pull request as draft May 6, 2026 14:53
@gztensor gztensor changed the base branch from main to devnet-ready May 6, 2026 14:54
@gztensor gztensor added apply-benchmark-patch and removed hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet labels May 6, 2026
@opentensor opentensor deleted a comment from github-actions Bot May 6, 2026
@gztensor gztensor marked this pull request as ready for review May 6, 2026 14:55
@sam0x17 sam0x17 merged commit 2781717 into devnet-ready May 6, 2026
207 of 208 checks passed
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