Cleanup staking hotkeys on stake removal - #3095
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🛡️ AI Review — Skeptic (security review)VERDICT: VULNERABLE VERY HIGH scrutiny: 48-day-old account with one public repository and write access; fix/cleanup-staking-hotkeys -> release-448; no Gittensor association established. The cleanup remains underweighted in both its idle migration and normal staking paths. In particular, the migration converts an entire unbounded row into persistent cursor state despite accounting for only fixed database operations. Findings
Prior-comment reconciliation
ConclusionThe change appears legitimate, but unbounded migration-state construction and stale generated weights create runtime resource-exhaustion risk. These issues should be fixed before merge. 📜 Previous run (superseded)
# 🔍 AI Review — Auditor (domain review) has not yet run on this PR. |
|
🔄 AI review updated — Skeptic: VULNERABLE |
|
🔄 AI review updated — Skeptic: VULNERABLE |
| progress.vector_writes = progress.vector_writes.saturating_add(1); | ||
| continue; |
There was a problem hiding this comment.
[HIGH] Bound migration state before copying an entire staking-hotkey row
hotkeys is an unbounded storage vector, yet the migration decodes and copies the entire row into remaining_hotkeys in one idle pass. row_load_weight() charges only one fixed database read, and cursor persistence is also charged as a fixed write, so a sufficiently large row can consume unbounded CPU, memory, proof size, and encoded-state work beyond the supplied idle-weight limit. Process the row through a bounded cursor/page or impose and account for a strict maximum row size.
| @@ -868,13 +889,7 @@ impl<T: Config> Pallet<T> { | |||
| } | |||
There was a problem hiding this comment.
[MEDIUM] Regenerate weights for staking-hotkey cleanup
This newly reachable cleanup adds prefix iteration, a basket read, and potentially a linear vector read/retain/write to stake-removal calls. The benchmarks were adjusted, but this PR does not update the generated weights.rs, leaving deployed calls charged according to the old storage behavior. Regenerate and commit the affected weights, ensuring the benchmark covers the maximum supported StakingHotkeys row size.
|
🔄 AI review updated — Skeptic: VULNERABLE |
Summary
Clean up stale
StakingHotkeysassociations when a hotkey/coldkey pair no longer has stake.Changes
maybe_remove_staking_hotkey.Testing
cargo fmt --all -- --checkandgit diff --checkalso pass.