Currently, the delegation rewards distribution system in our blockchain project retrieves delegate identities from a GitHub link. We need to migrate this process to use the new blockchain RPC method delegateInfo_getDelegateIdentities.
This change will affect multiple parts of our codebase, including the delegate information retrieval, display, and related commands. The new RPC method will return delegate identity information in the IdentityInfo structure.
Acceptance Criteria
Implement a new function to call the delegateInfo_getDelegateIdentities RPC method.
Update the DelegatesDetails class to match the IdentityInfo structure.
Update all relevant parts of the codebase to use the new RPC method instead of the GitHub link.
Ensure backward compatibility or provide a migration path for existing users.
Update documentation and comments to reflect the new method of retrieving delegate identities.
Tasks
Update the DelegatesDetails class in bittensor/commands/utils.py to match the IdentityInfo struct in subtensor:
Implement a new function in the Subtensor class to call the delegateInfo_getDelegateIdentities RPC method:
class Subtensor:
...
def get_delegate_identities(self, block: Optional[int] = None) -> Dict[str, DelegatesDetails]:
@retry(delay=1, tries=3, backoff=2, max_delay=4, logger=_logger)
def make_substrate_call_with_retry():
block_hash = None if block is None else self.substrate.get_block_hash(block)
return self.substrate.rpc_request(
method="delegateInfo_getDelegateIdentities",
params=[block_hash] if block_hash else [],
)
json_body = make_substrate_call_with_retry()
if not (result := json_body.get("result", None)):
return {}
return self._parse_delegate_identities(result)
def _parse_delegate_identities(self, raw_data: List[int]) -> Dict[str, DelegatesDetails]:
# Implement parsing logic here
# Convert the raw_data (Vec<u8>) into a dictionary of DelegatesDetails
# See how similar rpcs do this
pass
Update the get_delegates_details function in bittensor/commands/utils.py:
Update any parts of the codebase that call registered_delegate_info and fetch it through the github link
Update unit tests to mock the new RPC call instead of the GitHub API call and use the new DelegatesDetails structure.
Update documentation and comments throughout the codebase to reflect the new method of retrieving delegate identities and the new DelegatesDetails structure.
Additional Considerations
Do we need to implement a fallback mechanism to the GitHub method in case the RPC call fails?
Should we implement caching for the delegate identities to reduce the number of RPC calls?
How do we handle the case where a delegate's identity is not available through the RPC method?
How should we handle the additional fields in the IdentityInfo structure that weren't present in the GitHub data (legal, riot, email, pgp_fingerprint, image, twitter)?
Description
Currently, the delegation rewards distribution system in our blockchain project retrieves delegate identities from a GitHub link. We need to migrate this process to use the new blockchain RPC method
delegateInfo_getDelegateIdentities
.This change will affect multiple parts of our codebase, including the delegate information retrieval, display, and related commands. The new RPC method will return delegate identity information in the
IdentityInfo
structure.Acceptance Criteria
delegateInfo_getDelegateIdentities
RPC method.IdentityInfo
structure.Tasks
IdentityInfo
struct in subtensor:Subtensor
class to call thedelegateInfo_getDelegateIdentities
RPC method:get_delegates_details
function inbittensor/commands/utils.py
:Update any parts of the codebase that call
registered_delegate_info
and fetch it through the github linkUpdate unit tests to mock the new RPC call instead of the GitHub API call and use the new
DelegatesDetails
structure.Update documentation and comments throughout the codebase to reflect the new method of retrieving delegate identities and the new
DelegatesDetails
structure.Additional Considerations
IdentityInfo
structure that weren't present in the GitHub data (legal, riot, email, pgp_fingerprint, image, twitter)?Related Links