fix: validate hotkey registration on specific subnet in serve_axon and serve_prometheus#2541
Open
ppolewicz wants to merge 9 commits intodevnet-readyfrom
Open
fix: validate hotkey registration on specific subnet in serve_axon and serve_prometheus#2541ppolewicz wants to merge 9 commits intodevnet-readyfrom
ppolewicz wants to merge 9 commits intodevnet-readyfrom
Conversation
…hip workflow Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…d serve_prometheus - serve_axon and serve_prometheus now check is_hotkey_registered_on_network(netuid, ...) instead of is_hotkey_registered_on_any_network, preventing hotkeys from setting axon info on subnets they are not registered on - Add migrate_remove_orphan_axon_prom_cert_v2 migration to clean up 243 orphaned entries found on mainnet (242 orphaned Axons + 1 orphaned NeuronCertificate across 41 subnets) - Add 3 new serving tests and 1 migration test
Replace saturating_add with + in migration test to comply with the custom lint that bans safe math in tests (to encourage panics on bugs).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Bug
serve_axonandserve_prometheususedis_hotkey_registered_on_any_networkto validate whether a caller is permitted to set axon/prometheus info. This allowed a hotkey to set serving info on any subnet as long as it was registered on some subnet — even one it has no registration on.Fix
Both
serve_axonandserve_prometheusnow callis_hotkey_registered_on_network(netuid, hotkey)to ensure the hotkey is actually registered on the specific subnet it is trying to serve on.Migration:
migrate_remove_orphan_axon_prom_cert_v2A data-cleanup migration removes orphaned serving entries that were created before this fix. On-chain inspection of mainnet found:
Axonsentries across 41 subnetsNeuronCertificateentryTotal: 243 orphaned entries. The migration iterates all
Axons,Prometheus, andNeuronCertificatesstorage maps and removes entries where the hotkey is not registered on the corresponding subnet.Tests
test_serve_axon_registered_on_different_subnet— hotkey registered on subnet A cannot serve on subnet Btest_serve_prometheus_registered_on_different_subnet— same check for prometheustest_serve_axon_registered_on_correct_subnet— hotkey registered on the correct subnet can servetest_migrate_remove_orphan_axon_prom_cert_v2— migration correctly removes orphaned entries and leaves valid entries intactTest plan
pallet-subtensor --libtests pass (cargo test -p pallet-subtensor --lib)serve_axonandserve_prometheusreturnNotRegisterederror when hotkey is not registered on the target subnet🤖 Generated with Claude Code