Skip to content

refactor: drop unused netuid parameter from get_miner_coldkey - #864

Merged
anderdc merged 2 commits into
entrius:testfrom
ebios-star:refactor/drop-unused-netuid-from-get-miner-coldkey
May 5, 2026
Merged

refactor: drop unused netuid parameter from get_miner_coldkey#864
anderdc merged 2 commits into
entrius:testfrom
ebios-star:refactor/drop-unused-netuid-from-get-miner-coldkey

Conversation

@ebios-star

Copy link
Copy Markdown
Contributor

Summary

Closes #862.

`get_miner_coldkey` in gittensor/validator/utils/issue_competitions.py:11 declared a `netuid: int` parameter but never referenced it inside the body — only `subtensor.get_hotkey_owner(hotkey)` is called, which is netuid-agnostic in bittensor.

The single caller in validator/issue_competitions/forward.py:139 dutifully threaded its own `self.config.netuid` through, and paid a `# type: ignore[attr-defined]` for the bittensor config attribute access. Both the parameter and the type-ignore comment only existed to feed an unused argument.

After this change:

  • `get_miner_coldkey(hotkey, subtensor)` is the new signature.
  • The lone call site drops both the third argument and the `# type: ignore[attr-defined]` comment.

`grep -rn get_miner_coldkey` confirms exactly one caller across `gittensor/`, `neurons/`, and `tests/`.

Net: -2 / +0 lines on the source side, plus a fresh `tests/validator/utils/test_issue_competitions.py` that pins the new signature.

Related Issues

Closes #862.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other

Testing

New `tests/validator/utils/test_issue_competitions.py` covers four cases:

  • success path → owner string returned, `subtensor.get_hotkey_owner` called with the hotkey.
  • falsy owner → returns `None`.
  • subtensor exception → returns `None`.
  • regression guard ensuring `netuid=` is no longer accepted (`TypeError`).

`uv run --extra dev pytest tests/` — all 686 tests pass (682 baseline + 4 new).

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Changes are documented (if applicable)

@ebios-star

Copy link
Copy Markdown
Contributor Author

Hi @anderdc @LandynDev — friendly review request whenever you have a moment.

This PR closes #862. get_miner_coldkey declared a netuid: int parameter that's never referenced in its body, and the lone call site in validator/issue_competitions/forward.py was paying a # type: ignore[attr-defined] to thread self.config.netuid through. Dropping the parameter eliminates both — the call site stops needing the type-ignore comment as a side benefit.

Tests: 4 new cases in tests/validator/utils/test_issue_competitions.py (the file had none) — success path, falsy-owner, subtensor-exception, and a guard that the dead parameter cannot reappear. Full suite (686) passes.

Happy to address any feedback or rebase if needed.

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label Apr 29, 2026

@anderdc anderdc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Remove tests.

`get_miner_coldkey` declared a `netuid: int` parameter but never
referenced it inside the body — only `subtensor.get_hotkey_owner(hotkey)`
is called, which is netuid-agnostic in bittensor.

The single caller in `validator/issue_competitions/forward.py` dutifully
threaded its own `self.config.netuid` through and paid a
`# type: ignore[attr-defined]` for the bittensor config attribute access.
Both the parameter and the type-ignore comment only existed to feed an
unused argument.

After this change:
- `get_miner_coldkey(hotkey, subtensor)` is the new signature.
- The lone call site drops both the third argument and the
  `# type: ignore[attr-defined]` comment.

`grep -rn get_miner_coldkey` confirms exactly one caller across
`gittensor/`, `neurons/`, and `tests/`.

Add `tests/validator/utils/test_issue_competitions.py` covering:
- the success path (owner string returned)
- the falsy-owner case (None returned)
- the subtensor-exception case (None returned)
- a regression guard ensuring `netuid=` is no longer accepted

Closes entrius#862.
@ebios-star
ebios-star force-pushed the refactor/drop-unused-netuid-from-get-miner-coldkey branch from e65bfb1 to f5eff2e Compare April 30, 2026 21:57
@ebios-star

Copy link
Copy Markdown
Contributor Author

Done @anderdc — thanks for the review.

Removed the test file. The PR is now just the 2-line source change:

- def get_miner_coldkey(hotkey: str, subtensor: bt.Subtensor, netuid: int) -> Optional[str]:
+ def get_miner_coldkey(hotkey: str, subtensor: bt.Subtensor) -> Optional[str]:
- miner_coldkey = get_miner_coldkey(miner_hotkey, self.subtensor, self.config.netuid)  # type: ignore[attr-defined]
+ miner_coldkey = get_miner_coldkey(miner_hotkey, self.subtensor)

Branch rebased onto current test and force-pushed (--force-with-lease).

@anderdc
anderdc merged commit 00beed8 into entrius:test May 5, 2026
3 checks passed
@anderdc anderdc mentioned this pull request May 5, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Refactor] get_miner_coldkey accepts netuid parameter that's never used

2 participants