fix: prefer configured network over stale ws_endpoint in miner PAT commands#1200
fix: prefer configured network over stale ws_endpoint in miner PAT commands#1200MkDev11 wants to merge 3 commits into
Conversation
|
Nice fix! The precedence logic looks clean and follows the same pattern as #1035. Tests cover both regression cases (recognized network beats stale ws_endpoint) and the fallback for unrecognized config networks. Good catch on the config key typo reference too — that would've been confusing during review. 🚀 |
alpurkan17
left a comment
There was a problem hiding this comment.
Thanks for the fix. One concern: this manually reimplements the precedence logic that already exists in issue_commands/helpers.py:resolve_network (fixed in #1035). That function properly handles config_network beating ws_endpoint, so we end up with the same logic in two places.
A simpler approach worth considering: delegate _resolve_endpoint directly to resolve_network, which is what #1242 does — single source of truth, less maintenance burden, and guarantees consistent behavior across all CLI commands.
No blocking objection, just flagging the DRY concern.
Summary
_resolve_endpoint()ingittensor/cli/miner_commands/helpers.pychecksws_endpointbefore the configurednetwork, so a stalews_endpointsilently overrides a named network the user set. When both keys are present in~/.gittensor/config.json,gitt miner postandgitt miner checkconnect to the wrong chain.PR #1035 fixed the same precedence bug for issue commands (
resolve_network()inissue_commands/helpers.py, lines 660–662), but the miner PAT command helper was not updated.Fix: reorder the config-fallback checks in
_resolve_endpoint()so a recognizednetwork(finney,test,local) wins overws_endpoint. Unrecognized config network values still fall back tows_endpointas before.Related Issues
Closes #1198
Type of Change
Testing
test_config_recognized_network_beats_stale_ws_endpoint— regression:network=finney+ws_endpoint=ws://127.0.0.1:9944now resolves toNETWORK_MAP['finney']; returned the stale endpoint before the fix.test_config_test_network_beats_stale_ws_endpoint— regression: same fornetwork=test.test_unrecognized_config_network_falls_back_to_ws_endpoint— compatibility: unrecognized config network still letsws_endpointwin.test_rpc_url_beats_everything,test_network_flag_beats_config,test_ws_endpoint_used_when_no_config_network,test_default_finney_when_nothing_configured— full precedence ladder covered.Full suite:
uv run pytest tests/ -v→ 1495 passed.Checklist