Skip to content

Conversation

@eureka928
Copy link
Contributor

@eureka928 eureka928 commented Jan 27, 2026

Summary

Refactors stake child set to be simpler and more consistent, adds a parent hotkey override in the CLI, and adds e2e coverage.

Changes

  • set_children refactor: Simplified bittensor_cli/src/commands/stake/children_hotkeys.py:set_children() into a single loop over target netuids (dict_output keyed by netuid).
  • Parent hotkey override: Added --wallet-hotkey to:
    • btcli stake child set and plumbed it through to children_hotkeys.set_children(..., hotkey=...) .
  • Proportions guardrail: Added a check in set_children to reject when (\sum proportions > 1.0) (prints an error; when --json-output is set, returns a JSON error payload).
  • E2E tests: Added CLI-driven tests for set_children to tests/e2e_tests/test_children_hotkeys.py:
    • test_set_children
    • test_set_children_multiple_proportions

Before vs After

Before:

  • Complex branching for single vs multi-netuid cases.
  • Hardcoded parent hotkey (always derived from wallet).
  • Inconsistent output patterns across code paths.

After:

  • Single loop over computed netuids with consistent dict_output structure.
  • Optional hotkey parameter (CLI: --wallet-hotkey) to manage children for a different parent hotkey SS58.
  • Proportions sum guard with consistent console + JSON output.

Test Coverage

Added 7 comprehensive e2e tests in tests/e2e_tests/test_children_hotkeys.py:

stake child get Tests:

  1. test_get_children_json_output - Tests getting children with --json-output flag, verifies JSON structure and validates response format
  2. test_get_children_non_json_output - Tests getting children without JSON flag, verifies table format output

stake child set Tests:

  1. test_set_children_single_child - Tests setting a single child hotkey with 50% proportion, verifies completion_block and set_block in response
  2. test_set_children_multiple_proportions - Tests setting multiple children (Bob 30%, Charlie 40%) with different proportions, verifies both are set correctly

Test Commands Verified

Added e2e tests in tests/e2e_tests/test_children_hotkeys.py:

  • btcli stake child get --netuid <netuid>
  • btcli stake child get --all-netuids
  • btcli stake child set --children <address> --proportions <proportion> --netuid <netuid>
  • btcli stake child set with multiple children and proportions

Files Changed

  • bittensor_cli/src/commands/stake/children_hotkeys.py
  • bittensor_cli/cli.py
  • tests/e2e_tests/test_children_hotkeys.py

@eureka928 eureka928 force-pushed the fix/set-children-refactor branch from 1cb3797 to ad7f073 Compare January 27, 2026 10:48
@eureka928 eureka928 changed the base branch from main to staging January 27, 2026 10:48
@eureka928 eureka928 force-pushed the fix/set-children-refactor branch from ad7f073 to 12040c4 Compare January 27, 2026 10:49
@eureka928
Copy link
Contributor Author

Hi @thewhaleking I kept the wallet-hotkey instead of parent-hotkey

@thewhaleking thewhaleking self-requested a review January 27, 2026 10:57
@eureka928
Copy link
Contributor Author

All test passed!

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.

1 participant