Skip to content

Update network resolution by reusing resolve_network from helpers#411

Open
statxc wants to merge 5 commits intoentrius:testfrom
statxc:refactor/reuse-resolve-network
Open

Update network resolution by reusing resolve_network from helpers#411
statxc wants to merge 5 commits intoentrius:testfrom
statxc:refactor/reuse-resolve-network

Conversation

@statxc
Copy link
Copy Markdown

@statxc statxc commented Apr 14, 2026

Description

  • Remove the duplicated NETWORK_MAP dict and _resolve_endpoint() function from cli/miner_commands/post.py
  • Delegate to the existing resolve_network() in cli/issue_commands/helpers.py which handles the same priority chain (rpc-url > network flag > config > default)

No behavior change.

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented Apr 14, 2026

Review of refactor/reuse-resolve-network

  • Bug -- config network fallback dropped: The old _resolve_endpoint fell back to _load_config_value('network') when ws_endpoint was absent in config. resolve_network in helpers.py skips that -- if config['ws_endpoint'] is unset it jumps straight to the finney default (line 591). Users with only "network": "test" in ~/.gittensor/config.json will silently hit mainnet after this change. Fix: add a config.get('network') fallback branch in resolve_network between the ws_endpoint check and the finney default.

  • Trailing-slash diff in NETWORK_MAP: The old post.py map had trailing / on test and finney URLs (wss://test.finney.opentensor.ai:443/). helpers.py omits the slash. Likely harmless for WS but worth confirming nothing downstream does exact-string comparison on endpoints.

  • Wrapper can be inlined: _resolve_endpoint is called exactly once (ws_endpoint = _resolve_endpoint(network, rpc_url)). Replace with ws_endpoint, _ = resolve_network(network=network, rpc_url=rpc_url) and delete the wrapper.

  • _load_config_value is NOT dead code: Still used for wallet and hotkey config lookups in miner_post. Do not remove.

Copy link
Copy Markdown
Collaborator

@anderdc anderdc left a comment

Choose a reason for hiding this comment

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

  • Bug — config network fallback dropped: old _resolve_endpoint checked _load_config_value('network') when ws_endpoint was absent in config. resolve_network in helpers.py skips that — jumps straight to finney default (line 590). Users with only "network": "test" in ~/.gittensor/config.json will silently hit mainnet. Fix: add a config.get('network') fallback branch in resolve_network between the ws_endpoint check and the finney default.
  • Wrapper can be inlined: _resolve_endpoint is called once — replace with ws_endpoint, _ = resolve_network(network=network, rpc_url=rpc_url) and delete the wrapper.

@statxc
Copy link
Copy Markdown
Author

statxc commented Apr 14, 2026

@anderdc I have updated. Thanks for your feedback.

@statxc statxc requested a review from anderdc April 14, 2026 20:55
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.

2 participants