Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
41 changes: 0 additions & 41 deletions bittensor/core/async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
MetagraphInfo,
NeuronInfo,
NeuronInfoLite,
ProposalVoteData,
ProxyAnnouncementInfo,
ProxyConstants,
ProxyInfo,
Expand Down Expand Up @@ -4980,46 +4979,6 @@ async def get_unstake_fee(
)
return sim_swap_result.alpha_fee.set_unit(netuid=netuid)

async def get_vote_data(
self,
proposal_hash: str,
block: Optional[int] = None,
block_hash: Optional[str] = None,
reuse_block: bool = False,
) -> Optional["ProposalVoteData"]:
# TODO: is this all deprecated? Didn't subtensor senate stuff get removed?
"""
Retrieves the voting data for a specific proposal on the Bittensor blockchain. This data includes information
about how senate members have voted on the proposal.

Parameters:
proposal_hash: The hash of the proposal for which voting data is requested.
block: The blockchain block number for the query.
block_hash: The hash of the blockchain block number to query the voting data.
reuse_block: Whether to reuse the last-used blockchain block hash.

Returns:
An object containing the proposal's voting data, or `None` if not found.

This function is important for tracking and understanding the decision-making processes within the Bittensor
network, particularly how proposals are received and acted upon by the governing body.
"""
block_hash = await self.determine_block_hash(block, block_hash, reuse_block)
vote_data = cast(
Optional[dict[str, Any]],
await self.substrate.query(
module="Triumvirate",
storage_function="Voting",
params=[proposal_hash],
block_hash=block_hash,
reuse_block_hash=reuse_block,
),
)

if vote_data is None:
return None

return ProposalVoteData.from_dict(vote_data)

async def get_uid_for_hotkey_on_subnet(
self,
Expand Down
2 changes: 0 additions & 2 deletions bittensor/core/chain_data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from .neuron_info import NeuronInfo
from .neuron_info_lite import NeuronInfoLite
from .prometheus_info import PrometheusInfo
from .proposal_vote_data import ProposalVoteData
from .proxy import ProxyAnnouncementInfo, ProxyConstants, ProxyInfo, ProxyType
from .root_claim import RootClaimType
from .scheduled_coldkey_swap_info import ScheduledColdkeySwapInfo
Expand Down Expand Up @@ -63,7 +62,6 @@
"NeuronInfoLite",
"PrometheusInfo",
"ProposalCallData",
"ProposalVoteData",
"ProxyConstants",
"ProxyAnnouncementInfo",
"ProxyInfo",
Expand Down
27 changes: 0 additions & 27 deletions bittensor/core/chain_data/proposal_vote_data.py

This file was deleted.

33 changes: 0 additions & 33 deletions bittensor/core/subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
MetagraphInfo,
NeuronInfo,
NeuronInfoLite,
ProposalVoteData,
ProxyAnnouncementInfo,
ProxyConstants,
ProxyInfo,
Expand Down Expand Up @@ -4073,38 +4072,6 @@ def get_unstake_fee(
)
return sim_swap_result.alpha_fee.set_unit(netuid=netuid)

def get_vote_data(
self, proposal_hash: str, block: Optional[int] = None
) -> Optional["ProposalVoteData"]:
# TODO: is this all deprecated? Didn't subtensor senate stuff get removed?
"""
Retrieves the voting data for a specific proposal on the Bittensor blockchain. This data includes information
about how senate members have voted on the proposal.

Parameters:
proposal_hash: The hash of the proposal for which voting data is requested.
block: The blockchain block number for the query. If `None`, queries the current chain head.

Returns:
An object containing the proposal's voting data, or `None` if not found.

This function is important for tracking and understanding the decision-making processes within the Bittensor
network, particularly how proposals are received and acted upon by the governing body.
"""
vote_data = cast(
Optional[dict[str, Any]],
self.substrate.query(
module="Triumvirate",
storage_function="Voting",
params=[proposal_hash],
block_hash=self.determine_block_hash(block),
),
)

if vote_data is None:
return None

return ProposalVoteData.from_dict(vote_data)

def get_uid_for_hotkey_on_subnet(
self, hotkey_ss58: str, netuid: int, block: Optional[int] = None
Expand Down
1 change: 0 additions & 1 deletion bittensor/extras/subtensor_api/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def __init__(self, subtensor: Union["_Subtensor", "_AsyncSubtensor"]):
self.get_minimum_required_stake = subtensor.get_minimum_required_stake
self.get_start_call_delay = subtensor.get_start_call_delay
self.get_timestamp = subtensor.get_timestamp
self.get_vote_data = subtensor.get_vote_data
self.is_fast_blocks = subtensor.is_fast_blocks
self.is_in_admin_freeze_window = subtensor.is_in_admin_freeze_window
self.last_drand_round = subtensor.last_drand_round
Expand Down
2 changes: 0 additions & 2 deletions bittensor/utils/easy_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
ProxyType,
PrometheusInfo,
ProposalCallData,
ProposalVoteData,
ScheduledColdkeySwapInfo,
SelectiveMetagraphIndex,
StakeInfo,
Expand Down Expand Up @@ -167,7 +166,6 @@
"NeuronInfoLite",
"PrometheusInfo",
"ProposalCallData",
"ProposalVoteData",
"ScheduledColdkeySwapInfo",
"SelectiveMetagraphIndex",
"StakeInfo",
Expand Down
1 change: 0 additions & 1 deletion tests/e2e_tests/test_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from bittensor.core.chain_data.chain_identity import ChainIdentity
from bittensor.core.chain_data.delegate_info import DelegatedInfo, DelegateInfo
from bittensor.core.chain_data.proposal_vote_data import ProposalVoteData
from bittensor.core.errors import (
DelegateTakeTooHigh,
DelegateTxRateLimitExceeded,
Expand Down
90 changes: 0 additions & 90 deletions tests/unit_tests/test_async_subtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
NeuronInfo,
SelectiveMetagraphIndex,
StakeInfo,
proposal_vote_data,
)
from bittensor.core.errors import BalanceTypeError
from bittensor.core.settings import DEFAULT_MEV_PROTECTION, DEFAULT_PERIOD
Expand All @@ -39,35 +38,6 @@ def subtensor(mock_substrate):
return async_subtensor.AsyncSubtensor()


def test_decode_ss58_tuples_in_proposal_vote_data(mocker):
"""Tests that ProposalVoteData instance instantiation works properly,"""
# Preps
mocked_decode_account_id = mocker.patch.object(
proposal_vote_data, "decode_account_id"
)
fake_proposal_dict = {
"index": "0",
"threshold": 1,
"ayes": ("0 line", "1 line"),
"nays": ("2 line", "3 line"),
"end": 123,
}

# Call
async_subtensor.ProposalVoteData.from_dict(fake_proposal_dict)

# Asserts
assert mocked_decode_account_id.call_count == len(fake_proposal_dict["ayes"]) + len(
fake_proposal_dict["nays"]
)
assert mocked_decode_account_id.mock_calls == [
mocker.call("0 line"),
mocker.call("1 line"),
mocker.call("2 line"),
mocker.call("3 line"),
]


def test_decode_hex_identity_dict_with_non_tuple_value():
"""Tests _decode_hex_identity_dict when value is not a tuple."""
info_dict = {"info": "regular_string"}
Expand Down Expand Up @@ -2168,66 +2138,6 @@ async def test_get_subnet_hyperparameters_without_0x_prefix(subtensor, mocker):
assert result == mocked_from_dict.return_value


@pytest.mark.asyncio
async def test_get_vote_data_success(subtensor, mocker):
"""Tests get_vote_data when voting data is successfully retrieved."""
# Preps
fake_proposal_hash = "valid_proposal_hash"
fake_block_hash = "block_hash"
fake_vote_data = {"ayes": ["senate_member_1"], "nays": ["senate_member_2"]}

mocked_query = mocker.AsyncMock(return_value=fake_vote_data)
subtensor.substrate.query = mocked_query

mocked_proposal_vote_data = mocker.Mock()
mocker.patch.object(
async_subtensor.ProposalVoteData,
"from_dict",
return_value=mocked_proposal_vote_data,
)

# Call
result = await subtensor.get_vote_data(
proposal_hash=fake_proposal_hash, block_hash=fake_block_hash
)

# Asserts
mocked_query.assert_called_once_with(
module="Triumvirate",
storage_function="Voting",
params=[fake_proposal_hash],
block_hash=fake_block_hash,
reuse_block_hash=False,
)
assert result == mocked_proposal_vote_data


@pytest.mark.asyncio
async def test_get_vote_data_no_data(subtensor, mocker):
"""Tests get_vote_data when no voting data is available."""
# Preps
fake_proposal_hash = "invalid_proposal_hash"
fake_block_hash = "block_hash"

mocked_query = mocker.AsyncMock(return_value=None)
subtensor.substrate.query = mocked_query

# Call
result = await subtensor.get_vote_data(
proposal_hash=fake_proposal_hash, block_hash=fake_block_hash
)

# Asserts
mocked_query.assert_called_once_with(
module="Triumvirate",
storage_function="Voting",
params=[fake_proposal_hash],
block_hash=fake_block_hash,
reuse_block_hash=False,
)
assert result is None


@pytest.mark.asyncio
async def test_get_delegate_identities(subtensor, mocker):
"""Tests get_delegate_identities with successful data retrieval from both chain and GitHub."""
Expand Down