Skip to content

Conversation

@Dairus01
Copy link

Problem

The get_revealed_commitment_by_hotkey method in bittensor/core/subtensor.py contained a TODO comment indicating that the return ordering and units needed clarification and that usage examples were missing. The existing type hint Optional[tuple[tuple[int, str], ...]] was vague about what the int and str represented (e.g., block number vs. commitment message).

Thought Process

  1. Code Analysis: I examined the implementation of get_revealed_commitment_by_hotkey. It calls self.query_module and then maps the result using decode_revealed_commitment.
  2. Dependency Analysis: I looked at bittensor/core/chain_data/utils.py to find decode_revealed_commitment. It returns a tuple (revealed_block, revealed_commitment).
  3. Verification: To confirm my understanding, I wrote a unit test that mocks the low-level blockchain query response. This verified that the method indeed returns a tuple of tuples where the first element is the block number (int) and the second is the commitment message (str).
  4. Documentation Strategy: I decided to update the docstring to explicitly describe this structure ((reveal_block, commitment_message), ...) and add a Python example demonstrating a typical return value.
  5. Testing Strategy: I added unit tests to tests/unit_tests/test_subtensor.py to 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

  1. Updated Docstring: Modified bittensor/core/subtensor.py to remove the TODO. Added a detailed description of the return tuple and a usage example:
    Example:
        >>> subtensor.get_revealed_commitment_by_hotkey(netuid=1, hotkey_ss58="5C4hr...")
        ((123, "commitment_string_1"), (150, "commitment_string_2"))
  2. Added Unit Tests: Created 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/

@Dairus01
Copy link
Author

Dairus01 commented Dec 27, 2025

@basfroman, trust you are having a great Christmas, Please if you are back from the holidays i would love you to review this PR

It was a feature I did

@Dairus01 Dairus01 changed the base branch from master to staging December 27, 2025 18:44
@Dairus01
Copy link
Author

@basfroman, I have fixed CI formatting and permission issues; those 2 failing checks should pass now, trust you are having a great weekend. Please, can you help me re-review it.

Copy link
Collaborator

@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.

Thank you for your contribution!
Regarding this PR: we're moving away from adding code examples to the docstring. Instead, our docwriters are developing a document with examples that will be included in the official documentation. Once that's done, we'll simply add links to the code snippets in the docstings.

The method you're covering with your test is already covered by unit tests. Your test is redundant. Please remove it.

The only thing I'm willing to accept from your PR is changes to the .github/workflows/monitor_requirements_size_master.yml file.

To be make sure your PR has no linters and formatter issue, run make check command in your branch root directory.

Pls update your PR.

Updated docstring to clarify return format and removed example.
Copilot AI review requested due to automatic review settings December 30, 2025 08:26
Restores assertion for result equality in the test case.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to clarify the return structure and units for the get_revealed_commitment_by_hotkey method by adding unit tests and updating documentation. However, the primary objective stated in the PR description was not actually completed in the code changes.

Key changes:

  • Added three unit tests for get_revealed_commitment_by_hotkey covering success, invalid address, and None return cases
  • Added minimal whitespace change to the docstring (no substantive documentation improvements)
  • Fixed missing issues: write permission in GitHub workflow (unrelated to main PR purpose)

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/unit_tests/test_subtensor.py Added three unit tests verifying the return structure, error handling, and None cases for get_revealed_commitment_by_hotkey
bittensor/core/subtensor.py Only added trailing whitespace on line 3074; TODO comment and examples mentioned in PR description were not added
.github/workflows/monitor_requirements_size_master.yml Added issues: write permission (required for createComment API call) with incorrect indentation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Dairus01 and others added 2 commits December 30, 2025 00:29
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@Dairus01 Dairus01 requested a review from basfroman December 30, 2025 08:31
@Dairus01
Copy link
Author

Thank you for your contribution! Regarding this PR: we're moving away from adding code examples to the docstring. Instead, our docwriters are developing a document with examples that will be included in the official documentation. Once that's done, we'll simply add links to the code snippets in the docstings.

The method you're covering with your test is already covered by unit tests. Your test is redundant. Please remove it.

The only thing I'm willing to accept from your PR is changes to the .github/workflows/monitor_requirements_size_master.yml file.

To be make sure your PR has no linters and formatter issue, run make check command in your branch root directory.

Pls update your PR.

@basfroman I have done all that was requested please can you re-review this PR

@basfroman basfroman merged commit 70a873c into opentensor:staging Dec 30, 2025
615 checks passed
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.

2 participants