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

Override childkey take to zero if sharing coldkey with parent #1103

Closed
wants to merge 2 commits into from

Conversation

gztensor
Copy link
Contributor

Description

If parent and child are sharing the same coldkey, the childkey take is ignored and overridden with zero.

Related Issue(s)

n/a

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Breaking Change

n/a

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have run cargo fmt and cargo clippy to ensure my code is formatted and linted correctly
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@gztensor gztensor requested a review from unconst as a code owner December 18, 2024 16:21
camfairchild
camfairchild previously approved these changes Dec 18, 2024
Copy link
Contributor

@camfairchild camfairchild left a comment

Choose a reason for hiding this comment

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

little nit for a comment, but looks good

pallets/subtensor/src/tests/children.rs Outdated Show resolved Hide resolved
Co-authored-by: Cameron Fairchild <cameron@opentensor.ai>
));

// Set zero hotkey take for childkey
SubtensorModule::set_min_delegate_take(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

In this test child take and childkey take should be non-zero and it should be observed that the parent didn't get a deduction from either and has extraced full dividend that was due. The current implementation doesn't have this bug, but the test should not assume that - one day someone might be refactoring the code and might make a mistake that this test would then not detect. Maybe just use 0.01, 0.02, 0.05 so that we are sure they have never been confused with each other.

@@ -3437,7 +3438,8 @@ fn test_childkey_take_drain() {
#[test]
fn test_childkey_take_drain_validator_take() {
Copy link
Contributor

Choose a reason for hiding this comment

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

This test should be refactored into a helper function that would then be used in two tests:

  • test_childkey_take_same_coldkey
  • test_childkey_take_drain_validator_take

The helper function in question wouild accept parameters for coldkey_parent and coldkey_child, which would be the same in the first test and different in the other test. The other parameters of the helper would be:

  • expected_child_emission
  • expected_parent_emission
  • expected_nominator_emission

This should save ~120 LOC and it will make maintenance of the test suite less costly as adjustments to the internal subtensor interface woudln't have to be replicated in two places, but only in one.

@gztensor gztensor added no-spec-version-bump PR does not contain changes that requires bumping the spec version skip-cargo-audit This PR fails cargo audit but needs to be merged anyway labels Dec 18, 2024
@gztensor gztensor marked this pull request as draft December 18, 2024 18:12
@gztensor gztensor closed this Dec 18, 2024
@gztensor gztensor deleted the fix/childkey-same-coldkey branch December 18, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-spec-version-bump PR does not contain changes that requires bumping the spec version skip-cargo-audit This PR fails cargo audit but needs to be merged anyway
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants