Skip to content

python ss58 conversion #143

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 3 commits into
base: feat/thewhaleking/distribute-runtime
Choose a base branch
from

Conversation

thewhaleking
Copy link
Collaborator

@thewhaleking thewhaleking commented Jun 27, 2025

This is not a breaking change, as we only do the convesion if SubstrateInterface.decode_ss58 is set to True (it is False by default)

Converts all AccountID bytes tuples to SS58.

Resolves #61

Based on #141

Speed concerns: when tested with the following:

qm = await substrate.query_map(
    "SubtensorModule",
    "OwnedHotkeys",
    block_hash="0x7c50e0dd92a2054f36651c6632b2a9a6adb649d2875031dea91768137b7883f1"
)

Results were 107 seconds for decode_ss58=True and 111 seconds for decode_ss58=False. I don't think the added SS58 decoding makes it slower, and I think the minor difference in time can be explained by network imperfection. However, I will say this shows it should not run any slower (real world).

@thewhaleking thewhaleking requested a review from a team June 27, 2025 13:29
@thewhaleking thewhaleking marked this pull request as draft June 27, 2025 13:33
@thewhaleking thewhaleking marked this pull request as ready for review June 27, 2025 14:16
@thewhaleking thewhaleking added run-bittensor-sdk-tests Runs Bittensor SDK tests. run-bittensor-cli-tests Runs BTCLI tests. and removed do not merge labels Jun 27, 2025
Comment on lines +1005 to +1013
if self.decode_ss58:
try:
type_str_int = int(type_string.split("::")[1])
decoded_type_str = runtime.type_id_to_name[type_str_int]
obj = convert_account_ids(
obj, decoded_type_str, runtime.ss58_format
)
except (ValueError, KeyError):
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

hacky logic :D

Comment on lines +125 to +128
for (kts, vts), (dk, dv) in zip(
zip(pre_decoded_key_types, pre_decoded_value_types),
zip(decoded_keys, decoded_values),
):
Copy link
Contributor

Choose a reason for hiding this comment

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

for kts, vts, dk, dv in zip(
    pre_decoded_key_types,
    pre_decoded_value_types,
    decoded_keys,
    decoded_values,
):

wouldn't it be the same logic with a more elegant look?
looks like this is optimization too. no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-bittensor-cli-tests Runs BTCLI tests. run-bittensor-sdk-tests Runs Bittensor SDK tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Decoded addresses returned from parent and child key storage calls
3 participants