Skip to content

Conversation

@0xsid0703
Copy link

Summary

Implements get_submetagraphs(netuid) method that returns all submetagraphs (mechagraphs) for a specific netuid, addressing issue #2050.

Problem

Currently, get_all_mechagraphs() returns up to 128*8 items (all netuids × all mecids). When subnet owners enable many sub-subnets, this becomes inefficient when only data for one subnet is needed.

Solution

Add get_submetagraphs(netuid) that:

  • Returns all mechagraphs for a single netuid
  • Includes all sub_ids (mecids) for that netuid
  • Returns empty vector if subnet doesn't exist
  • More efficient than filtering get_all_mechagraphs() results

Changes

  • ✅ Added get_submetagraphs() in pallet implementation
  • ✅ Added runtime API trait method
  • ✅ Added runtime implementation
  • ✅ Added RPC endpoint subnetInfo_getSubmetagraphs
  • ✅ Added 7 comprehensive unit tests

Testing

All unit tests pass, covering:

  • Non-existent subnets
  • Empty mechanisms
  • Single and multiple mechanisms
  • Filtering verification
  • Comparison with get_all_mechagraphs()
  • Registered neurons scenarios

Closes #2050

Contribution by Gittensor, learn more at https://gittensor.io/

@0xsid0703
Copy link
Author

0xsid0703 commented Dec 17, 2025

@gztensor @sam0x17 I’m happy to contribute to Subtensor. When you have a moment, could you review my PR?

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