refactor: drop unused netuid parameter from get_miner_coldkey - #864
Conversation
|
Hi @anderdc @LandynDev — friendly review request whenever you have a moment. This PR closes #862. Tests: 4 new cases in Happy to address any feedback or rebase if needed. |
`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.
e65bfb1 to
f5eff2e
Compare
|
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 |
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:
`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
Testing
New `tests/validator/utils/test_issue_competitions.py` covers four cases:
`uv run --extra dev pytest tests/` — all 686 tests pass (682 baseline + 4 new).
Checklist