Skip to content

RPC to get validators #1614

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

Open
wants to merge 12 commits into
base: devnet-ready
Choose a base branch
from
Open

RPC to get validators #1614

wants to merge 12 commits into from

Conversation

open-junius
Copy link
Contributor

Description

Related Issue(s)

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

If this PR introduces a breaking change, please provide a detailed description of the impact and the migration path for existing applications.

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

Screenshots (if applicable)

Please include any relevant screenshots or GIFs that demonstrate the changes made.

Additional Notes

Please provide any additional information or context that may be helpful for reviewers.

@open-junius open-junius self-assigned this May 8, 2025
@github-actions github-actions bot added the run-bittensor-e2e-tests Runs Bittensor SDK and BTCLI tests label May 8, 2025
@open-junius open-junius added the skip-cargo-audit This PR fails cargo audit but needs to be merged anyway label May 8, 2025
@open-junius open-junius changed the title init solution RPC to get validators May 8, 2025
@@ -1356,13 +1369,52 @@ impl<T: Config> Pallet<T> {
..Default::default()
}
}
None => SelectiveMetagraph {
_ => SelectiveMetagraph {
Copy link
Contributor

Choose a reason for hiding this comment

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

This means if the SelectiveMetagraphIndex is Validators, we'd still be going to this match arm. Is this correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is correct. get validators is a separate branch. that's the validator_only parameter means.

Copy link
Contributor

Choose a reason for hiding this comment

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

But is there a case where the validators_only parameter is false, and yet the SelectedMetagraphIndex is Validators?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if validators_only is false, we don't return validators in the result. The index is wield, let me check how to change it. thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the validators index.

Copy link
Contributor

@camfairchild camfairchild May 13, 2025

Choose a reason for hiding this comment

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

should we not use the index of ValidatorsOnly to do this and not add a boolean to the api?

e.g. remove the only_validators param. Then, if ValidatorsOnly is present just keys that are validators.

This requires we add a uids field to the struct also

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say this impl can be like this:

  • we add SelectedMetagraphIndex::Validators. Then it gonna handled the same way as other SelectedMetagraphIndex indices.
  • we add validators field into Metagraph struct.

Result:

  • get_metagraph_info always has filed Metagraph::validators field
  • SelectiveMetagraph returns object with filed validators as Vec with related HK indexes if SelectedMetagraphIndex::Validators passed in params as item in field_indices
  • SDK MetagraphInfo class will get a new field validators

This is gonnabe clearest way for this and SDK implementation as far as I see.
Pleas feel free to correct me if I'm wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, we can handle the validators the same as other items in metagraph. user can get any data according to passed index list.

keithtensor
keithtensor previously approved these changes May 15, 2025
basfroman
basfroman previously approved these changes May 20, 2025
Copy link
Contributor

@basfroman basfroman left a comment

Choose a reason for hiding this comment

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

LGTM for SDK
Tested with PR opentensor/bittensor#2887 locally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-bittensor-e2e-tests Runs Bittensor SDK and BTCLI tests 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.

4 participants