Skip to content

fix: prefer configured network over stale ws_endpoint in miner PAT commands#1200

Open
MkDev11 wants to merge 3 commits into
entrius:testfrom
MkDev11:fix/issue-1198-miner-config-network-priority
Open

fix: prefer configured network over stale ws_endpoint in miner PAT commands#1200
MkDev11 wants to merge 3 commits into
entrius:testfrom
MkDev11:fix/issue-1198-miner-config-network-priority

Conversation

@MkDev11
Copy link
Copy Markdown
Contributor

@MkDev11 MkDev11 commented May 12, 2026

Summary

_resolve_endpoint() in gittensor/cli/miner_commands/helpers.py checks ws_endpoint before the configured network, so a stale ws_endpoint silently overrides a named network the user set. When both keys are present in ~/.gittensor/config.json, gitt miner post and gitt miner check connect to the wrong chain.

PR #1035 fixed the same precedence bug for issue commands (resolve_network() in issue_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 recognized network (finney, test, local) wins over ws_endpoint. Unrecognized config network values still fall back to ws_endpoint as before.

Related Issues

Closes #1198

Type of Change

  • Bug fix

Testing

  • Tests added/updated

test_config_recognized_network_beats_stale_ws_endpoint — regression: network=finney + ws_endpoint=ws://127.0.0.1:9944 now resolves to NETWORK_MAP['finney']; returned the stale endpoint before the fix.

test_config_test_network_beats_stale_ws_endpoint — regression: same for network=test.

test_unrecognized_config_network_falls_back_to_ws_endpoint — compatibility: unrecognized config network still lets ws_endpoint win.

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

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

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label May 12, 2026
@alpurkan17
Copy link
Copy Markdown
Contributor

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. 🚀

Copy link
Copy Markdown
Contributor

@alpurkan17 alpurkan17 left a comment

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] gitt miner post and gitt miner check ignore configured network when ws_endpoint is also set

2 participants