Skip to content

reuse canonical alpha iterator helper #2929

Merged
UnArbosSix merged 1 commit into
stagingfrom
reuse-alpha-iterator-swap-hotkey
Jul 16, 2026
Merged

reuse canonical alpha iterator helper #2929
UnArbosSix merged 1 commit into
stagingfrom
reuse-alpha-iterator-swap-hotkey

Conversation

@UnArbosSix

@UnArbosSix UnArbosSix commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Motivation

prepare_hotkey_stake duplicated the legacy/V2 alpha-row merge already implemented by alpha_iter_single_prefix. Keeping two copies of this logic risks their precedence or conversion behavior diverging over time.

Changes

  • Replaced the local Alpha/AlphaV2 merge in pallets/subtensor/src/swap/swap_hotkey.rs with Self::alpha_iter_single_prefix(old_hotkey).
  • Preserved the existing output type, deterministic ordering, and V2 precedence when both storage versions contain the same (coldkey, netuid) key.

Behavioral impact

This is a behavior-preserving refactor. Hotkey swaps continue to collect the same stake positions and group the same coldkeys by subnet; no storage layout or economic logic changes.

Migration and runtime version

No migration is required. The PR targets staging, which has no network spec-version check, so no spec_version bump is needed.

Testing

Static equivalence was verified against the implementation of alpha_iter_single_prefix. No targeted runtime test was required because the change delegates to the existing canonical helper without altering its inputs or outputs.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
subtensor Ready Ready Preview, Comment Jul 16, 2026 4:13pm

Request Review

@github-actions

github-actions Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

🛡️ AI Review — Skeptic (security review)

VERDICT: SAFE

VERY HIGH scrutiny due to a <30-day-old account and sparse public profile, mitigated by repository write permission; no Gittensor association. Branch: reuse-alpha-iterator-swap-hotkey -> staging.

Static analysis confirms that alpha_iter_single_prefix preserves the removed implementation’s key ordering, tuple shape, legacy conversion, and V2-over-V1 precedence. The PR changes no dependencies, authorization logic, arithmetic, or trusted review files.

Findings

No findings.

Conclusion

The small mechanical refactor is behaviorally equivalent to the removed code and introduces no security vulnerability or malicious behavior.


🔍 AI Review — Auditor (domain review)

VERDICT: 👍

Gittensor association: UNKNOWN by the prescribed allowlists/merged-PR heuristic; author has repository write access but a very new account, so the refactor received heightened static scrutiny.

PR body was empty/trivial; the Auditor has auto-filled it. Please review.

The replacement is behaviorally equivalent: both implementations iterate legacy Alpha before AlphaV2, merge by (coldkey, netuid) in a BTreeMap, and give V2 rows precedence. This is a minimal deduplication with no new runtime behavior, migration, dependency, or test requirement. No runtime confirmation was necessary.

The overlapping PRs (#2759 and #2745) are broad, unrelated features rather than duplicate implementations. No spec-version bump applies to the staging base branch.

Findings

No findings.

Conclusion

The PR safely reuses the canonical iterator without changing merge precedence or output ordering. It is ready to merge.

@github-actions

Copy link
Copy Markdown
Contributor

🔄 AI review updated — Skeptic: SAFE Auditor: 👍

@UnArbosSix
UnArbosSix merged commit a7cb3ce into staging Jul 16, 2026
172 of 174 checks passed
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.

1 participant