Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Child Hotkeys #2071

Open
wants to merge 31 commits into
base: staging
Choose a base branch
from
Open

Child Hotkeys #2071

wants to merge 31 commits into from

Conversation

opendansor
Copy link
Contributor

We need to integrate new extrinsics related to child key management into our Python codebase and add corresponding CLI commands. These extrinsics allow users to set and revoke child keys for hotkeys on specific subnets. This feature enhances the flexibility of our stake delegation system.

@opendansor opendansor force-pushed the feature/opendansor/child_hotkeys branch from 35a205b to d2bc588 Compare June 26, 2024 23:10
bittensor/extrinsics/unstaking.py Outdated Show resolved Hide resolved
bittensor/commands/stake.py Outdated Show resolved Hide resolved
bittensor/extrinsics/staking.py Outdated Show resolved Hide resolved
bittensor/commands/stake.py Outdated Show resolved Hide resolved
@opendansor opendansor self-assigned this Jun 27, 2024
@opendansor opendansor added the feature new feature added label Jul 2, 2024
@opendansor opendansor marked this pull request as ready for review July 8, 2024 18:41
Copy link
Contributor

@RomanCh-OT RomanCh-OT left a comment

Choose a reason for hiding this comment

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

There are no questions about implementation. I left a few comments regarding the style and tests.

bittensor/commands/stake.py Outdated Show resolved Hide resolved
bittensor/commands/stake.py Show resolved Hide resolved
bittensor/commands/stake.py Outdated Show resolved Hide resolved
bittensor/extrinsics/staking.py Outdated Show resolved Hide resolved
bittensor/commands/stake.py Outdated Show resolved Hide resolved
bittensor/extrinsics/staking.py Show resolved Hide resolved
"""


def test_get_children_info(local_chain, capsys):
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls add at least single line docstring to the test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a docstring above this test that explains what its function is. Do you want me to move it down?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would be great. Otherwise it looks like a description for a module. Thank you

"""


def test_set_revoke_child(local_chain, capsys):
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls add at least single line docstring to the test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a docstring above this test that explains what its function is. Do you want me to move it down?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would be great. Otherwise it looks like a description for a module. Thank you

"""


def test_set_revoke_children(local_chain, capsys):
Copy link
Contributor

Choose a reason for hiding this comment

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

Pls add at least single line docstring to the test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a docstring above this test that explains what its function is. Do you want me to move it down?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that would be great. Otherwise it looks like a description for a module. Thank you

Copy link
Contributor

Choose a reason for hiding this comment

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

As a suggestion for the tests

I would prefer to see test cases where an assertion is set after each change in the state of the subnet or objects under test, as in the example below, it is useful to know that each step is successful. If one of the step is broken, it will be easier to understand which one of them exactly.

...

 # Register Alice neuron to the subnet
 alice_exec_command(...)

assert foo_1 == bar_1 # example

 # Alice to Stake to become to top neuron after the first epoch
 alice_exec_command(...)

assert foo_2 == bar_2 # example

 # Register Bob neuron to the subnet
 bob_exec_command(...)

assert foo_3 == bar_3 # example

...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a certain scope for each test.

For example, when we test emissions, to get started on that test you will need an axon and dendrite, you will need to set weights, and make sure that incentive is put in correctly.

But we already have a test_axon, a test_dendrite, a test_incentive and a test for weights. These tests assert that the functionality they are testing work correctly.

For set_revoke_child, I am not going to assert the alice_exec register command or the alice_stake command, because this is already covered in other test cases. The purpose of this test is to set and revoke child hotkeys. If there is an error in stake or registering the other tests will catch that.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand what you described. As I mentioned above, this is a recommendation of what tests should look like in an ideal case. What I recommend helps track the flaky behavior of tests.
We can take this into account for future implementations. You can apply the recommendation or resolve it.

Copy link
Contributor

@RomanCh-OT RomanCh-OT left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bittensor feature new feature added
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants