Skip to content

Stake locks#1860

Closed
gztensor wants to merge 10 commits intodevnet-readyfrom
feat/subnet-locks
Closed

Stake locks#1860
gztensor wants to merge 10 commits intodevnet-readyfrom
feat/subnet-locks

Conversation

@gztensor
Copy link
Contributor

Description

Change subnet owner based on subnet stake lock. Locks are linear with 100% being locked at the start block and 0% on the end block. Any staker can lock their stake. Approximately once per month (7200 * 30 blocks) the lock EMAs are recalculated and, if stake lock EMA is the highest for some account, it becomes the owner of the subnet.

If stake is locked, then only unlocked portion of it can be unstaked at a given block.

In order to prevent subnet sniping, the lock EMA is applied, which gives subnet owner enough warning to act.

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 cargo fmt and cargo clippy 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

@github-actions github-actions bot added the hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet label Jul 16, 2025
@gztensor gztensor changed the base branch from main to devnet-ready July 16, 2025 22:29
@gztensor gztensor removed the hotfix This PR needs to be merged very quickly and will likely skip testing on devnet and testnet label Jul 16, 2025
@opentensor opentensor deleted a comment from github-actions bot Jul 16, 2025
@sam0x17 sam0x17 requested a review from camfairchild July 17, 2025 13:36
sam0x17
sam0x17 previously approved these changes Jul 17, 2025
@gztensor gztensor marked this pull request as draft July 17, 2025 18:20
@gztensor gztensor requested a review from unconst July 18, 2025 00:01
coldkey: &T::AccountId,
) -> AlphaCurrency {
let one = U64F64::saturating_from_num(1.0);
let zero = U64F64::saturating_from_num(1.0);
Copy link

Choose a reason for hiding this comment

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

Should probably be 0.0

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.

3 participants