Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1678,7 +1678,7 @@ async def get_current_weight_commit_info(
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> list:
) -> list[tuple[str, int, str, int]]:
"""
Retrieves CRV3 weight commit information for a specific subnet.

Expand All @@ -1695,7 +1695,7 @@ async def get_current_weight_commit_info(
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
result = await self.substrate.query_map(
module="SubtensorModule",
storage_function="CRV3WeightCommits",
storage_function="CRV3WeightCommitsV2",
params=[netuid],
block_hash=block_hash,
reuse_block_hash=reuse_block,
Expand Down
19 changes: 12 additions & 7 deletions bittensor/core/chain_data/weight_commit_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,35 @@ class WeightCommitInfo:
Data class representing weight commit information.

Attributes:
ss58 (str): The SS58 address of the committer
commit_hex (str): The serialized weight commit data as hex string
reveal_round (int): The round number for reveal
ss58: The SS58 address of the committer
commit_block: The block number of the commitment.
commit_hex: The serialized weight commit data as hex string
reveal_round: The round number for reveal
"""

ss58: str
commit_block: int
commit_hex: str
reveal_round: int

@classmethod
def from_vec_u8(cls, data: tuple) -> tuple[str, str, int]:
def from_vec_u8(cls, data: tuple) -> tuple[str, int, str, int]:
"""
Creates a WeightCommitInfo instance

Args:
data (tuple): Tuple containing ((AccountId,), (commit_data,), round_number)
data (tuple): Tuple containing ((AccountId,), (commit_block, ) (commit_data,), round_number)

Returns:
WeightCommitInfo: A new instance with the decoded data
"""
account_id, commit_data, round_number = data
account_id, commit_block, commit_data, round_number = data

account_id_ = account_id[0] if isinstance(account_id, tuple) else account_id
commit_block = (
commit_block[0] if isinstance(commit_block, tuple) else commit_block
)
commit_data = commit_data[0] if isinstance(commit_data, tuple) else commit_data
commit_hex = "0x" + "".join(format(x, "02x") for x in commit_data)

return decode_account_id(account_id_), commit_hex, round_number
return decode_account_id(account_id_), commit_block, commit_hex, round_number
4 changes: 2 additions & 2 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ def get_all_revealed_commitments(

def get_current_weight_commit_info(
self, netuid: int, block: Optional[int] = None
) -> list:
) -> list[tuple[str, int, str, int]]:
"""
Retrieves CRV3 weight commit information for a specific subnet.

Expand All @@ -1086,7 +1086,7 @@ def get_current_weight_commit_info(
"""
result = self.substrate.query_map(
module="SubtensorModule",
storage_function="CRV3WeightCommits",
storage_function="CRV3WeightCommitsV2",
params=[netuid],
block_hash=self.determine_block_hash(block),
)
Expand Down
5 changes: 4 additions & 1 deletion tests/e2e_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
setup_wallet,
)

LOCALNET_IMAGE_NAME = os.getenv("LOCALNET_IMAGE_NAME") or "ghcr.io/opentensor/subtensor-localnet:devnet-ready"
LOCALNET_IMAGE_NAME = (
os.getenv("LOCALNET_IMAGE_NAME")
or "ghcr.io/opentensor/subtensor-localnet:devnet-ready"
)
CONTAINER_NAME_PREFIX = "test_local_chain_"


Expand Down
4 changes: 3 additions & 1 deletion tests/e2e_tests/test_commit_reveal_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle
reporting_interval=1,
)
current_block = subtensor.get_current_block()
expected_block = current_block
latest_drand_round = subtensor.last_drand_round()
upcoming_tempo = next_tempo(current_block, tempo)
logging.console.info(
Expand Down Expand Up @@ -161,11 +162,12 @@ async def test_commit_and_reveal_weights_cr3(local_chain, subtensor, alice_walle

# Fetch current commits pending on the chain
commits_on_chain = subtensor.get_current_weight_commit_info(netuid=netuid)
address, commit, reveal_round = commits_on_chain[0]
address, commit_block, commit, reveal_round = commits_on_chain[0]

# Assert correct values are committed on the chain
assert expected_reveal_round == reveal_round
assert address == alice_wallet.hotkey.ss58_address
assert commit_block == expected_block + 1

# Ensure no weights are available as of now
assert subtensor.weights(netuid=netuid) == []
Expand Down
4 changes: 3 additions & 1 deletion tests/unit_tests/test_subtensor_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ def test_get_current_weight_commit_info(mock_substrate, subtensor, fake_wallet,
[
(
bytearray(32),
100,
b"data",
123,
),
Expand All @@ -445,14 +446,15 @@ def test_get_current_weight_commit_info(mock_substrate, subtensor, fake_wallet,
assert result == [
(
"5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM",
100,
"0x64617461",
123,
),
]

mock_substrate.query_map.assert_called_once_with(
module="SubtensorModule",
storage_function="CRV3WeightCommits",
storage_function="CRV3WeightCommitsV2",
params=[1],
block_hash=None,
)
Expand Down