Optimize hotkey swap stake iteration#2920
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🛡️ AI Review — Skeptic (security review)VERDICT: VULNERABLE VERY HIGH scrutiny: 14-day-old account with zero public repos; mitigated by repository write permission, matching human commits, an expected benchmark-bot commit, and no Gittensor association; bound-hotkey-swap-work → staging. The refactor removes the subnet multiplier, but it still scans and materializes an unlimited number of stake rows while assigning one fixed dispatch weight. The latest benchmark was reduced to 16 subnets and 1,273 positions without introducing a protocol bound. Findings
Prior-comment reconciliation
ConclusionA hotkey with sufficiently many stake rows can exceed the fixed charge and consume unaccounted runtime resources. The prior vulnerability remains unresolved. 📜 Previous run (superseded)
🔍 AI Review — Auditor (domain review)VERDICT: 👎 UNKNOWN gittensor association; newer contributor with repository write access, so the resource-limit rationale requires independent evidence. The PR body claims fees remain unchanged, but stake-moving swaps now retain the maximum normal-extrinsic weight, materially changing transaction fees and normal-block capacity. The overlapping PRs concern broad runtime work and are not functional duplicates. Findings
ConclusionThe repeated prefix scan is removed, but the replacement limits and weight are unbenchmarked. This does not establish that the maximum admitted workload is safe, while imposing maximum weight and fees on every stake-moving swap. |
|
🔄 AI review updated — Skeptic: SAFE Auditor: 👎 |
|
🔄 AI review updated — Skeptic: VULNERABLE |
|
🔄 AI review updated — Skeptic: VULNERABLE |
|
🔄 AI review updated — Skeptic: VULNERABLE |
Summary
Fixes the hotkey-swap runtime resource-exhaustion path by ensuring stake storage is scanned once instead of once per subnet.
The previous all-subnet swap behavior repeatedly scanned the full
AlphaandAlphaV2prefixes inside every subnet iteration. For hotkeys with many stake positions, this multiplied the work by the number of active subnets and could cause validator execution stalls.Changes
AlphaandAlphaV2once before executing a stake-moving hotkey swapAlphaV2precedence when merging duplicate stake positionsBehavior
Successful hotkey swaps retain the existing behavior:
keep_stakebehaviorThe implementation does not introduce new stake-position limits or reject swaps based on the number of stake rows.
The transaction fee may change because the declared weight is regenerated from a substantially larger and more representative benchmark workload.
Why this fixes the issue
Previously, an all-subnet swap performed approximately:
stake-row visits.
After this change, it performs approximately:
This removes the accidental multiplicative scan while preserving the existing state transition.
Benchmark
The previous benchmark covered only four subnets with a small number of stake positions.
The updated benchmark exercises the optimized implementation with:
Scope
The patch is limited to removing the repeated hotkey stake-prefix scans and updating the corresponding benchmark and weight.