bittensor.core.chain_data#
This module provides data structures and functions for working with the Bittensor network, including neuron and subnet information, SCALE encoding/decoding, and custom RPC type registry.
Submodules#
- bittensor.core.chain_data.axon_info
- bittensor.core.chain_data.delegate_info
- bittensor.core.chain_data.delegate_info_lite
- bittensor.core.chain_data.ip_info
- bittensor.core.chain_data.neuron_info
- bittensor.core.chain_data.neuron_info_lite
- bittensor.core.chain_data.prometheus_info
- bittensor.core.chain_data.proposal_vote_data
- bittensor.core.chain_data.scheduled_coldkey_swap_info
- bittensor.core.chain_data.stake_info
- bittensor.core.chain_data.subnet_hyperparameters
- bittensor.core.chain_data.subnet_info
- bittensor.core.chain_data.utils
Attributes#
Classes#
| The AxonInfo class represents information about an axon endpoint in the bittensor network. This includes | |
| Dataclass for delegate information. For a lighter version of this class, see  | |
| Dataclass for DelegateLiteInfo. This is a lighter version of :func: | |
| Dataclass representing IP information. | |
| Represents the metadata of a neuron including keys, UID, stake, rankings, and other attributes. | |
| NeuronInfoLite is a dataclass representing neuron metadata without weights and bonds. | |
| Dataclass representing information related to Prometheus. | |
| This TypedDict represents the data structure for a proposal vote in the Senate. | |
| The ScheduledColdkeySwapInfo class is a dataclass representing information about scheduled cold key swaps. | |
| Dataclass for representing stake information linked to hotkey and coldkey pairs. | |
| This class represents the hyperparameters for a subnet. | |
| Dataclass for subnet info. | 
Package Contents#
- class bittensor.core.chain_data.AxonInfo[source]#
- The AxonInfo class represents information about an axon endpoint in the bittensor network. This includes properties such as IP address, ports, and relevant keys. - Variables:
- version (int) – The version of the axon endpoint. 
- ip (str) – The IP address of the axon endpoint. 
- port (int) – The port number the axon endpoint uses. 
- ip_type (int) – The type of IP protocol (e.g., IPv4 or IPv6). 
- hotkey (str) – The hotkey associated with the axon endpoint. 
- coldkey (str) – The coldkey associated with the axon endpoint. 
- protocol (int) – The protocol version (default is 4). 
- placeholder1 (int) – Reserved field (default is 0). 
- placeholder2 (int) – Reserved field (default is 0). 
 
 - to_string()[source]#
- Converts the AxonInfo object to a string representation using JSON. - Return type:
 
 - classmethod from_string(json_string)[source]#
- Creates an AxonInfo object from its string representation using JSON. - Parameters:
- json_string (str) – The JSON string representation of the AxonInfo object. 
- Returns:
- An instance of AxonInfo created from the JSON string. If decoding fails, returns a default AxonInfo object with default values. 
- Return type:
- Raises:
- json.JSONDecodeError – If there is an error in decoding the JSON string. 
- TypeError – If there is a type error when creating the AxonInfo object. 
- ValueError – If there is a value error when creating the AxonInfo object. 
 
 
 
- class bittensor.core.chain_data.DelegateInfo[source]#
- Dataclass for delegate information. For a lighter version of this class, see - DelegateInfoLite.- Parameters:
- hotkey_ss58 (str) – Hotkey of the delegate for which the information is being fetched. 
- total_stake (int) – Total stake of the delegate. 
- nominators (list[tuple[str, int]]) – List of nominators of the delegate and their stake. 
- take (float) – Take of the delegate as a percentage. 
- owner_ss58 (str) – Coldkey of the owner. 
- registrations (list[int]) – List of subnets that the delegate is registered on. 
- validator_permits (list[int]) – List of subnets that the delegate is allowed to validate on. 
- return_per_1000 (int) – Return per 1000 TAO, for the delegate over a day. 
- total_daily_return (int) – Total daily return of the delegate. 
 
 - total_stake: bittensor.utils.balance.Balance#
 - nominators: list[tuple[str, bittensor.utils.balance.Balance]]#
 - return_per_1000: bittensor.utils.balance.Balance#
 - total_daily_return: bittensor.utils.balance.Balance#
 - classmethod from_vec_u8(vec_u8)[source]#
- Parameters:
- vec_u8 (bytes) 
- Return type:
- Optional[DelegateInfo] 
 
 
- class bittensor.core.chain_data.DelegateInfoLite[source]#
- Dataclass for DelegateLiteInfo. This is a lighter version of :func: - DelegateInfo.- Parameters:
- delegate_ss58 (str) – Hotkey of the delegate for which the information is being fetched. 
- take (float) – Take of the delegate as a percentage. 
- nominators (int) – Count of the nominators of the delegate. 
- owner_ss58 (str) – Coldkey of the owner. 
- registrations (list[int]) – List of subnets that the delegate is registered on. 
- validator_permits (list[int]) – List of subnets that the delegate is allowed to validate on. 
- return_per_1000 (int) – Return per 1000 TAO, for the delegate over a day. 
- total_daily_return (int) – Total daily return of the delegate. 
 
 
- class bittensor.core.chain_data.IPInfo[source]#
- Dataclass representing IP information. - Variables:
 - classmethod fix_decoded_values(decoded)[source]#
- Returns a SubnetInfo object from a decoded IPInfo dictionary. 
 
- class bittensor.core.chain_data.NeuronInfo[source]#
- Represents the metadata of a neuron including keys, UID, stake, rankings, and other attributes. - Variables:
- hotkey (str) – The hotkey associated with the neuron. 
- coldkey (str) – The coldkey associated with the neuron. 
- uid (int) – The unique identifier for the neuron. 
- netuid (int) – The network unique identifier for the neuron. 
- active (int) – The active status of the neuron. 
- stake (Balance) – The balance staked to this neuron. 
- stake_dict (dict[str, Balance]) – A dictionary mapping coldkey to the amount staked. 
- total_stake (Balance) – The total amount of stake. 
- rank (float) – The rank score of the neuron. 
- emission (float) – The emission rate. 
- incentive (float) – The incentive value. 
- consensus (float) – The consensus score. 
- trust (float) – The trust score. 
- validator_trust (float) – The validation trust score. 
- dividends (float) – The dividends value. 
- last_update (int) – The timestamp of the last update. 
- validator_permit (bool) – Validator permit status. 
- weights (list[list[int]]) – List of weights associated with the neuron. 
- bonds (list[list[int]]) – List of bonds associated with the neuron. 
- pruning_score (int) – The pruning score of the neuron. 
- prometheus_info (Optional[PrometheusInfo]) – Information related to Prometheus. 
- axon_info (Optional[AxonInfo]) – Information related to Axon. 
- is_null (bool) – Indicator if this is a null neuron. 
 
 - stake_dict: dict[str, bittensor.utils.balance.Balance]#
 - total_stake: bittensor.utils.balance.Balance#
 - prometheus_info: bittensor.core.chain_data.prometheus_info.PrometheusInfo | None = None#
 - axon_info: bittensor.core.chain_data.axon_info.AxonInfo | None = None#
 - classmethod from_weights_bonds_and_neuron_lite(neuron_lite, weights_as_dict, bonds_as_dict)[source]#
- Creates an instance of NeuronInfo from NeuronInfoLite and dictionaries of weights and bonds. - Parameters:
- neuron_lite (NeuronInfoLite) – A lite version of the neuron containing basic attributes. 
- weights_as_dict (dict[int, list[tuple[int, int]]]) – A dictionary where the key is the UID and the value is a list of weight tuples associated with the neuron. 
- bonds_as_dict (dict[int, list[tuple[int, int]]]) – A dictionary where the key is the UID and the value is a list of bond tuples associated with the neuron. 
 
- Returns:
- An instance of NeuronInfo populated with the provided weights and bonds. 
- Return type:
 
 
- class bittensor.core.chain_data.NeuronInfoLite[source]#
- NeuronInfoLite is a dataclass representing neuron metadata without weights and bonds. - Variables:
- hotkey (str) – The hotkey string for the neuron. 
- coldkey (str) – The coldkey string for the neuron. 
- uid (int) – A unique identifier for the neuron. 
- netuid (int) – Network unique identifier for the neuron. 
- active (int) – Indicates whether the neuron is active. 
- stake (Balance) – The stake amount associated with the neuron. 
- stake_dict (dict) – Mapping of coldkey to the amount staked to this Neuron. 
- total_stake (Balance) – Total amount of the stake. 
- rank (float) – The rank of the neuron. 
- emission (float) – The emission value of the neuron. 
- incentive (float) – The incentive value of the neuron. 
- consensus (float) – The consensus value of the neuron. 
- trust (float) – Trust value of the neuron. 
- validator_trust (float) – Validator trust value of the neuron. 
- dividends (float) – Dividends associated with the neuron. 
- last_update (int) – Timestamp of the last update. 
- validator_permit (bool) – Indicates if the neuron has a validator permit. 
- prometheus_info (Optional[PrometheusInfo]) – Prometheus information associated with the neuron. 
- axon_info (Optional[AxonInfo]) – Axon information associated with the neuron. 
- pruning_score (int) – The pruning score of the neuron. 
- is_null (bool) – Indicates whether the neuron is null. 
 
 - list_from_vec_u8()[source]#
- Decodes a bytes object into a list of NeuronInfoLite instances. - Parameters:
- vec_u8 (bytes) 
- Return type:
 
 - stake_dict: dict[str, bittensor.utils.balance.Balance]#
 - total_stake: bittensor.utils.balance.Balance#
 - prometheus_info: bittensor.core.chain_data.prometheus_info.PrometheusInfo | None#
 - axon_info: bittensor.core.chain_data.axon_info.AxonInfo | None#
 
- class bittensor.core.chain_data.PrometheusInfo[source]#
- Dataclass representing information related to Prometheus. - Variables:
 
- class bittensor.core.chain_data.ProposalVoteData[source]#
- Bases: - TypedDict- This TypedDict represents the data structure for a proposal vote in the Senate. - Variables:
 - Initialize self. See help(type(self)) for accurate signature. 
- class bittensor.core.chain_data.ScheduledColdkeySwapInfo[source]#
- The ScheduledColdkeySwapInfo class is a dataclass representing information about scheduled cold key swaps. - Variables:
 - classmethod fix_decoded_values(decoded)[source]#
- Fixes the decoded values. - Parameters:
- decoded (Any) 
- Return type:
 
 - classmethod from_vec_u8(vec_u8)[source]#
- Returns a ScheduledColdkeySwapInfo object from a - vec_u8.- Parameters:
- Return type:
- Optional[ScheduledColdkeySwapInfo] 
 
 
- class bittensor.core.chain_data.StakeInfo[source]#
- Dataclass for representing stake information linked to hotkey and coldkey pairs. - Variables:
 - classmethod fix_decoded_values(decoded)[source]#
- Fixes the decoded values. - Parameters:
- decoded (Any) 
- Return type:
 
 
- class bittensor.core.chain_data.SubnetHyperparameters[source]#
- This class represents the hyperparameters for a subnet. - Variables:
- rho (int) – The rate of decay of some value. 
- kappa (int) – A constant multiplier used in calculations. 
- immunity_period (int) – The period during which immunity is active. 
- min_allowed_weights (int) – Minimum allowed weights. 
- max_weight_limit (float) – Maximum weight limit. 
- tempo (int) – The tempo or rate of operation. 
- min_difficulty (int) – Minimum difficulty for some operations. 
- max_difficulty (int) – Maximum difficulty for some operations. 
- weights_version (int) – The version number of the weights used. 
- weights_rate_limit (int) – Rate limit for processing weights. 
- adjustment_interval (int) – Interval at which adjustments are made. 
- activity_cutoff (int) – Activity cutoff threshold. 
- registration_allowed (bool) – Indicates if registration is allowed. 
- target_regs_per_interval (int) – Target number of registrations per interval. 
- min_burn (int) – Minimum burn value. 
- max_burn (int) – Maximum burn value. 
- bonds_moving_avg (int) – Moving average of bonds. 
- max_regs_per_block (int) – Maximum number of registrations per block. 
- serving_rate_limit (int) – Limit on the rate of service. 
- max_validators (int) – Maximum number of validators. 
- adjustment_alpha (int) – Alpha value for adjustments. 
- difficulty (int) – Difficulty level. 
- commit_reveal_weights_interval (int) – Interval for commit-reveal weights. 
- commit_reveal_weights_enabled (bool) – Flag indicating if commit-reveal weights are enabled. 
- alpha_high (int) – High value of alpha. 
- alpha_low (int) – Low value of alpha. 
- liquid_alpha_enabled (bool) – Flag indicating if liquid alpha is enabled. 
 
 - classmethod from_vec_u8(vec_u8)[source]#
- Create a SubnetHyperparameters instance from a vector of bytes. - This method decodes the given vector of bytes using the bt_decode module and creates a new instance of SubnetHyperparameters with the decoded values. - Parameters:
- vec_u8 (bytes) – A vector of bytes to decode into SubnetHyperparameters. 
- Returns:
- An instance of SubnetHyperparameters if decoding is successful, None otherwise. 
- Return type:
- Optional[SubnetHyperparameters] 
 
 
- class bittensor.core.chain_data.SubnetInfo[source]#
- Dataclass for subnet info. 
- bittensor.core.chain_data.custom_rpc_type_registry#
- bittensor.core.chain_data.ProposalCallData#