Skip to content

Hotfix/propagate hotkey swap conviction#2736

Open
gztensor wants to merge 9 commits into
devnet-readyfrom
hotfix/propagate-hotkey-swap-conviction
Open

Hotfix/propagate hotkey swap conviction#2736
gztensor wants to merge 9 commits into
devnet-readyfrom
hotfix/propagate-hotkey-swap-conviction

Conversation

@gztensor

@gztensor gztensor commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

Propagates the hotkey-swap conviction lock hotfix from #2731 onto devnet-ready after the reverse lock index work landed.

The migration in pallets/subtensor/src/migrations/migrate_fix_subnet_hotkey_lock_swaps.rs now uses LockingColdkeys when repairing subnet-scoped hotkey swap lock state. It removes old reverse-index entries when taking source locks and inserts the new reverse-index entry when a lock is moved to the destination hotkey, keeping Lock and LockingColdkeys consistent after the migration.

The migration test in pallets/subtensor/src/tests/migration.rs was extended to seed and assert LockingColdkeys state for moved locks, discarded conflict locks, and chained hotkey-swap fixes. The runtime spec_version is bumped from 417 to 418 for the runtime migration.

Behavioral impact: affected stale subnet hotkey-swap lock records are repaired without falling back to a full Lock scan, and the reverse index remains usable for subsequent lock operations. Existing destination lock conflicts continue to preserve the destination lock and discard the old source lock as before.

Testing: targeted migration coverage was updated to validate the new reverse-index behavior.

@gztensor gztensor self-assigned this Jun 9, 2026
@gztensor gztensor added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label Jun 9, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/src/migrations/migrate_fix_subnet_hotkey_lock_swaps.rs Outdated
Comment thread pallets/subtensor/src/swap/swap_hotkey.rs
@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

BASELINE scrutiny: author has write permission, substantial subtensor history, no trusted Gittensor allowlist match, and branch hotfix/propagate-hotkey-swap-conviction -> devnet-ready.

The PR does not modify .github/ai-review/*, .github/copilot-instructions.md, dependencies, lockfiles, or build scripts. The runtime migration runs after migrate_populate_locking_coldkeys, removes stale reverse-index entries from source hotkeys, inserts destination reverse-index entries for moved locks, and uses saturating weight accounting for the added storage reads/writes.

Findings

No findings.

Prior-comment reconciliation

  • a8760b5d: addressed — The current migration charges for the LockingColdkeys prefix walk, index removals, Lock::take reads/writes, and destination index insertions before moving or discarding locks.

Conclusion

No malicious pattern or security vulnerability was found in the current diff. The prior migration weight-accounting concern remains addressed.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Gittensor: UNKNOWN by trusted allowlists; author has write permission and substantial prior subtensor history, so calibrated as an established contributor.

Description discrepancies

  • The PR body says spec_version is bumped from 417 to 418, but the current diff bumps runtime/src/lib.rs from 419 to 420. Update that sentence before merge.

The migration change is consistent with the LockingColdkeys reverse-index invariant and runs after the index-population migration in on_runtime_upgrade. git diff --check passed; I did not apply auto-fixes or run cargo because static review was sufficient for this diff.

Findings

No findings.

Prior-comment reconciliation

  • 2ac89255: addressed — The subnet swap test now expects NonAssociatedColdKey for the newly introduced ownership guard path, and existing nearby coverage still asserts HotKeyAlreadyRegisteredInSubNet for the registered-in-subnet branch.

Conclusion

The lock repair migration updates both Lock and LockingColdkeys for moved and discarded subnet hotkey-swap locks, and the added assertions cover the reverse-index cleanup/insertion paths. No blocking domain issues found.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: VULNERABLE

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/src/migrations/migrate_fix_subnet_hotkey_lock_swaps.rs Outdated
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: VULNERABLE

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

AI review — see the sticky summary comment for the verdict and the inline comments below for specific findings.

Comment thread pallets/subtensor/src/swap/swap_hotkey.rs
@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👎

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

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.

1 participant