Skip to content

feat: Exponential Lock + Conviction System#2598

Open
unarbos wants to merge 1 commit intoopentensor:mainfrom
unarbos:locks
Open

feat: Exponential Lock + Conviction System#2598
unarbos wants to merge 1 commit intoopentensor:mainfrom
unarbos:locks

Conversation

@unarbos
Copy link
Copy Markdown

@unarbos unarbos commented Apr 17, 2026

Summary

  • Implements an exponential lock mechanism where coldkeys can lock alpha stake to a specific hotkey per subnet, building conviction over time.
  • Lock state uses lazy evaluation: locked_mass decays as exp(-dt/tau) * X and conviction grows as the time-integral of locked mass via exp(-dt/tau) * (Y + dt * X).
  • Enforces lock invariant on unstake (validate_remove_stake) and move/transfer (validate_stake_transition): total coldkey alpha on subnet must remain >= current locked amount.
  • New extrinsic lock_stake at call_index(134) with TauBlocks configurable decay timescale (default ~30 days).
  • 52 tests covering: green-path operations, incremental top-ups, decay math, invariant enforcement, multi-subnet locks, conviction aggregation, subnet king queries, lock cleanup, swap interactions, and edge cases.

Known gaps documented by tests

The following issues are documented by failing-forward tests that prove the bypass exists:

  1. do_recycle_alpha / do_burn_alpha bypass lock — calls decrease_stake_for_hotkey_and_coldkey_on_subnet without lock check.
  2. clear_small_nomination_if_required bypasses lock — removes nominator alpha without lock validation.
  3. Subnet dissolution orphans Lock entries — destroy_alpha_in_out_stakes removes all Alpha but not Lock storage; stale locks persist across netuid reuse.
  4. Coldkey swap does not migrate Lock entries.
  5. Hotkey swap does not update Lock entries.

Test plan

  • 52 tests in tests/locks.rs — all pass
  • Full pallet suite: 1003 passed, 0 failed, 7 ignored

Made with Cursor

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.

2 participants