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

Hotkey swap causes parent key to lose emissions from children. #860

Closed
bdmason opened this issue Oct 15, 2024 · 3 comments · Fixed by #863
Closed

Hotkey swap causes parent key to lose emissions from children. #860

bdmason opened this issue Oct 15, 2024 · 3 comments · Fixed by #863
Assignees
Labels
bug Something isn't working

Comments

@bdmason
Copy link

bdmason commented Oct 15, 2024

Describe the bug

When a hotkey is swapped, the children of the hotkey still see the old hotkey when they read ParentKeys storage.

Also, any inactive subnets are ignored when migrating to the new hotkey in ChildKeys, so if a subnet is inactive at the block of swap then comes back online later on, the new hotkey will have lost it's child key relationship. Not sure this is a bug with bad consequence, but stale data is left behind

To Reproduce

Neural Internet swapped their hotkey today https://taostats.io/extrinsic/4047654-0009. If you read ChildKeys and ParentKeys at blocks 4047653 and 4047654 you will see the following:

  1. 0xeaad1116568ea7eaf369b541cbfa9db7480d618c3f968b05e39e2c9ced7a0026 (old hotkey) & netuid 36 exists as a key with a child on SN 36 in ChildKeys after the swap (block 4047654).

  2. 0xeaad1116568ea7eaf369b541cbfa9db7480d618c3f968b05e39e2c9ced7a0026 (old hotkey) exists in 48 separate entries of ParentKeys after the swap (block 4047654). All 48 of it's children will no longer be paying emissions to the parent as they still have the old hotkey and will pay 0% of the old hotkeys 0% stake (as the stake was migrated in the swap).

Expected behavior

All instances of the old hotkey in ChildKeys and ParentKeys should be swapped with the new hotkey

Screenshots

No response

Environment

N/A I'm indexing the data

Additional context

This line causes the less severe first issue https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/swap/swap_hotkey.rs#L322 as get_all_subnet_netuids only returns active networks.

This loop causes the more severe second issue https://github.com/opentensor/subtensor/blob/main/pallets/subtensor/src/swap/swap_hotkey.rs#L333 as the ParentKeys storage for the children of the swapped hotkeys isn't updated.

@bdmason bdmason added the bug Something isn't working label Oct 15, 2024
@gztensor gztensor self-assigned this Oct 15, 2024
@gztensor
Copy link
Contributor

@bdmason , the root cause is that subnet 36 doesn't exist. Is there any confusion? Are you aware of validators / miners that are still trying to operate?

@gztensor
Copy link
Contributor

Image

@bdmason
Copy link
Author

bdmason commented Oct 16, 2024

@gztensor please have another read of the issue. There are 2 problems, one is that inactive subnets (eg 36) are ignored in the hotkey swap... which isn't really severe (but should probably be handled) as it just leaves stale and incorrect data on chain.

The other more severe problem is that ParentKeys isn't updated properly. There are 2 updates to ParentKeys that need to happen:

  1. swap the hotkey where it makes up part of the storage key, the "child" here /// DMAP ( child, netuid ) --> Vec<(proportion,parent)>.

  2. swap the hotkey where it is in the array of parents here /// DMAP ( child, netuid ) --> Vec<(proportion,parent)>.

The second update doesn't currently happen, all 48 of Neural Internet's children still see the old NeuralInternet hotkey when they read ParentKeys and try to pay their parents their share of emissions. Take a look at chain storage for ParentKeys at block 4047653 and bock 4047654. You'll see that update 1 above has been done in the swap, but not update 2.

The result is that the children will pay 0 TAO emissions to Neural Internet, as the children see the old hotkey in storage. As the stake has been migrated to the new hotkey in the swap, there's no more stake to pay emissions on.

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 a pull request may close this issue.

2 participants