Clarify return ordering and units for get_revealed_commitment_by_hotkey
#3231
+75
−2
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.
Problem
The
get_revealed_commitment_by_hotkeymethod inbittensor/core/subtensor.pycontained a TODO comment indicating that the return ordering and units needed clarification and that usage examples were missing. The existing type hintOptional[tuple[tuple[int, str], ...]]was vague about what theintandstrrepresented (e.g., block number vs. commitment message).Thought Process
get_revealed_commitment_by_hotkey. It callsself.query_moduleand then maps the result usingdecode_revealed_commitment.bittensor/core/chain_data/utils.pyto finddecode_revealed_commitment. It returns a tuple(revealed_block, revealed_commitment).((reveal_block, commitment_message), ...)and add a Python example demonstrating a typical return value.tests/unit_tests/test_subtensor.pyto enforce this contract. This ensures that if the underlying decoding logic changes in the future, the tests will fail, signaling a need to update the documentation.Solution
bittensor/core/subtensor.pyto remove the TODO. Added a detailed description of the return tuple and a usage example:tests/unit_tests/test_subtensor.py(appended new tests) covering:test_get_revealed_commitment_by_hotkey_success: Verifies correct mapping of block number and message.test_get_revealed_commitment_by_hotkey_invalid_address: Verifies error handling.test_get_revealed_commitment_by_hotkey_none: Verifies handling when no data is found.Contribution by Gittensor, learn more at https://gittensor.io/