Conviction v2#2658
Open
gztensor wants to merge 20 commits into
Open
Conversation
mainnet deploy 4-23-2026 (part 2)
…ribution Hotfix to remove initial owners alpha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR implements the 2nd iteration of stake locks (conviction).
Implements an exponential stake lock mechanism where a coldkey can lock alpha stake to one hotkey per subnet, building conviction for that hotkey over time. A coldkey may have only one active lock per subnet; top-ups must target the same hotkey.
Lock state is stored as
(locked_mass, conviction, last_update)for(coldkey, netuid, hotkey). Aggregate conviction is tracked separately through:HotkeyLock(netuid, hotkey)for non-owner perpetual coldkey aggregate locks.DecayingLock(netuid, hotkey)for non-owner decaying coldkey aggregate locks.OwnerLock(netuid)for the subnet owner coldkey’s aggregate lock.DecayingLock(netuid)as an optional flag controlling whether subnet owner locked mass decays.Lock state uses lazy evaluation: stored values are rolled forward only when lock-aware code touches them.
Roll-forward uses two independent exponential timescales:
UnlockRate: controls decay of locked mass.MaturityRate: controls conviction maturation/decay.Defaults:
UnlockRateis set so 90% of locked mass unlocks in 365.25 days at 12s blocks.MaturityRateis 20% slower thanUnlockRate.Current non-owner roll-forward formula follows the closed-form exponential model:
For subnet owner coldkey locks, conviction is immediate: after roll-forward, conviction is set to current locked_mass. If
PerpetualLock(netuid)is enabled, subnet owner locked mass does not decay, while conviction still matures to locked mass.The new extrinsic
lock_stakecreates or tops up a lock. If a coldkey already has a lock on the subnet, the hotkey must match. Top-up rolls the existing lock forward first, adds tolocked_mass, and preserves rolled conviction. Fresh non-owner locked mass starts with zero added conviction; owner coldkey locks receive immediate owner conviction.The new extrinsic
set_perpetual_locklets the lock owner coldkey toggleDecayingLockfor their lock, enabling or clearing decaying owner locked-mass behavior. The default value is false, so the locks are perpetual by default for everyone.There is no separate unlock queue/state. Locked mass decays over time. When locked mass and conviction decay to zero, cleanup removes the lock row and the matching aggregate row when applicable.
Unstake protection is enforced through
available_to_unstake: a coldkey can unstake only alpha above the rolled locked amount on that subnet. Lock-aware stake transitions check this so locked alpha cannot leave the locked subnet through move/swap-style operations.Same-subnet transfer between coldkeys is lock-aware: if transferred alpha exceeds the sender’s unlocked portion, the locked portion follows the stake to the destination coldkey. The hotkey remains the same. Conviction is moved proportionally to the moved locked alpha using fixed-point proportional math.
Small nomination cleanup can force-reduce a lock. The removed alpha reduces locked mass and reduces conviction proportionally. The aggregate lock is reduced by the same locked mass and conviction delta, using
OwnerLockfor subnet owner coldkey locks andHotkeyLockotherwise.Subnet owner reassignment is conviction-aware. Once the subnet is old enough (1 year old) and enough alpha is locked (at least 10% of
SubnetAlphaOut), the subnet king is selected from aggregate conviction. If ownership changes, aggregate lock state is moved betweenOwnerLockandHotkeyLockso the new owner’s aggregate is tracked as owner conviction and the old owner’s aggregate becomes a normal hotkey aggregate.Type of Change
Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctly