bittensor.chain_data#

Module Contents#

Classes#

AxonInfo

ChainDataType

Create a collection of name/value pairs.

DelegateInfo

Dataclass for delegate info.

IPInfo

Dataclass for associated IP Info.

NeuronInfo

Dataclass for neuron metadata.

NeuronInfoLite

Dataclass for neuron metadata, but without the weights and bonds.

PrometheusInfo

Dataclass for prometheus info.

ProposalVoteData

dict() -> new empty dictionary

StakeInfo

Dataclass for stake info.

SubnetHyperparameters

Dataclass for subnet hyperparameters.

SubnetInfo

Dataclass for subnet info.

Functions#

from_scale_encoding(input, type_name[, is_vec, is_option])

from_scale_encoding_using_type_string(input, type_string)

Attributes#

ProposalCallData

RAOPERTAO

U16_MAX

U64_MAX

custom_rpc_type_registry

class bittensor.chain_data.AxonInfo#
property is_serving: bool#

True if the endpoint is serving.

Return type:

bool

coldkey: str#
hotkey: str#
ip: str#
ip_type: int#
placeholder1: int = 0#
placeholder2: int = 0#
port: int#
protocol: int = 4#
version: int#
__eq__(other)#

Return self==value.

Parameters:

other (AxonInfo) –

__repr__()#

Return repr(self).

__str__()#

Return str(self).

classmethod from_neuron_info(neuron_info)#

Converts a dictionary to an axon_info object.

Parameters:

neuron_info (dict) –

Return type:

AxonInfo

classmethod from_parameter_dict(parameter_dict)#

Returns an axon_info object from a torch parameter_dict.

Parameters:

parameter_dict (torch.nn.ParameterDict) –

Return type:

axon_info

classmethod from_string(s)#

Creates an AxonInfo object from its string representation using JSON.

Parameters:

s (str) –

Return type:

AxonInfo

ip_str()#

Return the whole IP as string

Return type:

str

to_parameter_dict()#

Returns a torch tensor of the subnet info.

Return type:

torch.nn.ParameterDict

to_string()#

Converts the AxonInfo object to a string representation using JSON.

Return type:

str

class bittensor.chain_data.ChainDataType(*args, **kwds)#

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

DelegateInfo = 3#
DelegatedInfo = 5#
IPInfo = 7#
NeuronInfo = 1#
NeuronInfoLite = 4#
StakeInfo = 6#
SubnetHyperparameters = 8#
SubnetInfo = 2#
class bittensor.chain_data.DelegateInfo#

Dataclass for delegate info.

hotkey_ss58: str#
nominators: List[Tuple[str, bittensor.utils.balance.Balance]]#
owner_ss58: str#
registrations: List[int]#
return_per_1000: bittensor.utils.balance.Balance#
take: float#
total_daily_return: bittensor.utils.balance.Balance#
total_stake: bittensor.utils.balance.Balance#
validator_permits: List[int]#
classmethod delegated_list_from_vec_u8(vec_u8)#

Returns a list of Tuples of DelegateInfo objects, and Balance, from a vec_u8.

This is the list of delegates that the user has delegated to, and the amount of stake delegated.

Parameters:

vec_u8 (List[int]) –

Return type:

List[Tuple[DelegateInfo, bittensor.utils.balance.Balance]]

classmethod fix_decoded_values(decoded)#

Fixes the decoded values.

Parameters:

decoded (Any) –

Return type:

DelegateInfo

classmethod from_vec_u8(vec_u8)#

Returns a DelegateInfo object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Optional[DelegateInfo]

classmethod list_from_vec_u8(vec_u8)#

Returns a list of DelegateInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[DelegateInfo]

class bittensor.chain_data.IPInfo#

Dataclass for associated IP Info.

ip: str#
ip_type: int#
protocol: int#
encode()#

Returns a dictionary of the IPInfo object that can be encoded.

Return type:

Dict[str, Any]

classmethod fix_decoded_values(decoded)#

Returns a SubnetInfo object from a decoded IPInfo dictionary.

Parameters:

decoded (Dict) –

Return type:

IPInfo

classmethod from_parameter_dict(parameter_dict)#

Returns a IPInfo object from a torch parameter_dict.

Parameters:

parameter_dict (torch.nn.ParameterDict) –

Return type:

IPInfo

classmethod from_vec_u8(vec_u8)#

Returns a IPInfo object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Optional[IPInfo]

classmethod list_from_vec_u8(vec_u8)#

Returns a list of IPInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[IPInfo]

to_parameter_dict()#

Returns a torch tensor of the subnet info.

Return type:

torch.nn.ParameterDict

class bittensor.chain_data.NeuronInfo#

Dataclass for neuron metadata.

active: int#
axon_info: AxonInfo#
bonds: List[List[int]]#
coldkey: str#
consensus: float#
dividends: float#
emission: float#
hotkey: str#
incentive: float#
is_null: bool = False#
last_update: int#
netuid: int#
prometheus_info: PrometheusInfo#
pruning_score: int#
rank: float#
stake: bittensor.utils.balance.Balance#
stake_dict: Dict[str, bittensor.utils.balance.Balance]#
total_stake: bittensor.utils.balance.Balance#
trust: float#
uid: int#
validator_permit: bool#
validator_trust: float#
weights: List[List[int]]#
static _neuron_dict_to_namespace(neuron_dict)#
Return type:

NeuronInfo

static _null_neuron()#
Return type:

NeuronInfo

classmethod fix_decoded_values(neuron_info_decoded)#

Fixes the values of the NeuronInfo object.

Parameters:

neuron_info_decoded (Any) –

Return type:

NeuronInfo

classmethod from_vec_u8(vec_u8)#

Returns a NeuronInfo object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

NeuronInfo

classmethod from_weights_bonds_and_neuron_lite(neuron_lite, weights_as_dict, bonds_as_dict)#
Parameters:
Return type:

NeuronInfo

classmethod list_from_vec_u8(vec_u8)#

Returns a list of NeuronInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[NeuronInfo]

class bittensor.chain_data.NeuronInfoLite#

Dataclass for neuron metadata, but without the weights and bonds.

active: int#
axon_info: NeuronInfoLite.axon_info#
coldkey: str#
consensus: float#
dividends: float#
emission: float#
hotkey: str#
incentive: float#
is_null: bool = False#
last_update: int#
netuid: int#
prometheus_info: PrometheusInfo#
pruning_score: int#
rank: float#
stake: bittensor.utils.balance.Balance#
stake_dict: Dict[str, bittensor.utils.balance.Balance]#
total_stake: bittensor.utils.balance.Balance#
trust: float#
uid: int#
validator_permit: bool#
validator_trust: float#
static _neuron_dict_to_namespace(neuron_dict)#
Return type:

NeuronInfoLite

static _null_neuron()#
Return type:

NeuronInfoLite

classmethod fix_decoded_values(neuron_info_decoded)#

Fixes the values of the NeuronInfoLite object.

Parameters:

neuron_info_decoded (Any) –

Return type:

NeuronInfoLite

classmethod from_vec_u8(vec_u8)#

Returns a NeuronInfoLite object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

NeuronInfoLite

classmethod list_from_vec_u8(vec_u8)#

Returns a list of NeuronInfoLite objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[NeuronInfoLite]

class bittensor.chain_data.PrometheusInfo#

Dataclass for prometheus info.

block: int#
ip: str#
ip_type: int#
port: int#
version: int#
classmethod fix_decoded_values(prometheus_info_decoded)#

Returns a PrometheusInfo object from a prometheus_info_decoded dictionary.

Parameters:

prometheus_info_decoded (Dict) –

Return type:

PrometheusInfo

bittensor.chain_data.ProposalCallData#
class bittensor.chain_data.ProposalVoteData#

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via:

d = {} for k, v in iterable:

d[k] = v

dict(**kwargs) -> new dictionary initialized with the name=value pairs

in the keyword argument list. For example: dict(one=1, two=2)

ayes: List[str]#
end: int#
index: int#
nays: List[str]#
threshold: int#
bittensor.chain_data.RAOPERTAO = 1000000000.0#
class bittensor.chain_data.StakeInfo#

Dataclass for stake info.

coldkey_ss58: str#
hotkey_ss58: str#
stake: bittensor.utils.balance.Balance#
classmethod fix_decoded_values(decoded)#

Fixes the decoded values.

Parameters:

decoded (Any) –

Return type:

StakeInfo

classmethod from_vec_u8(vec_u8)#

Returns a StakeInfo object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Optional[StakeInfo]

classmethod list_from_vec_u8(vec_u8)#

Returns a list of StakeInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[StakeInfo]

classmethod list_of_tuple_from_vec_u8(vec_u8)#

Returns a list of StakeInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Dict[str, List[StakeInfo]]

class bittensor.chain_data.SubnetHyperparameters#

Dataclass for subnet hyperparameters.

activity_cutoff: int#
adjustment_interval: int#
bonds_moving_avg: int#
immunity_period: int#
kappa: int#
max_burn: int#
max_difficulty: int#
max_regs_per_block: int#
max_validators: int#
max_weight_limit: float#
min_allowed_weights: int#
min_burn: int#
min_difficulty: int#
registration_allowed: bool#
rho: int#
serving_rate_limit: int#
target_regs_per_interval: int#
tempo: int#
weights_rate_limit: int#
weights_version: int#
classmethod fix_decoded_values(decoded)#

Returns a SubnetInfo object from a decoded SubnetInfo dictionary.

Parameters:

decoded (Dict) –

Return type:

SubnetHyperparameters

classmethod from_parameter_dict(parameter_dict)#

Returns a SubnetHyperparameters object from a torch parameter_dict.

Parameters:

parameter_dict (torch.nn.ParameterDict) –

Return type:

SubnetInfo

classmethod from_vec_u8(vec_u8)#

Returns a SubnetHyperparameters object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Optional[SubnetHyperparameters]

classmethod list_from_vec_u8(vec_u8)#

Returns a list of SubnetHyperparameters objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[SubnetHyperparameters]

to_parameter_dict()#

Returns a torch tensor of the subnet hyperparameters.

Return type:

torch.nn.ParameterDict

class bittensor.chain_data.SubnetInfo#

Dataclass for subnet info.

blocks_since_epoch: int#
burn: bittensor.utils.balance.Balance#
connection_requirements: Dict[str, float]#
difficulty: int#
emission_value: float#
immunity_period: int#
kappa: int#
max_allowed_validators: int#
max_n: int#
max_weight_limit: float#
min_allowed_weights: int#
modality: int#
netuid: int#
owner_ss58: str#
rho: int#
scaling_law_power: float#
subnetwork_n: int#
tempo: int#
classmethod fix_decoded_values(decoded)#

Returns a SubnetInfo object from a decoded SubnetInfo dictionary.

Parameters:

decoded (Dict) –

Return type:

SubnetInfo

classmethod from_parameter_dict(parameter_dict)#

Returns a SubnetInfo object from a torch parameter_dict.

Parameters:

parameter_dict (torch.nn.ParameterDict) –

Return type:

SubnetInfo

classmethod from_vec_u8(vec_u8)#

Returns a SubnetInfo object from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

Optional[SubnetInfo]

classmethod list_from_vec_u8(vec_u8)#

Returns a list of SubnetInfo objects from a vec_u8.

Parameters:

vec_u8 (List[int]) –

Return type:

List[SubnetInfo]

to_parameter_dict()#

Returns a torch tensor of the subnet info.

Return type:

torch.nn.ParameterDict

bittensor.chain_data.U16_MAX = 65535#
bittensor.chain_data.U64_MAX = 18446744073709551615#
bittensor.chain_data.custom_rpc_type_registry#
bittensor.chain_data.from_scale_encoding(input, type_name, is_vec=False, is_option=False)#
Parameters:
Return type:

Optional[Dict]

bittensor.chain_data.from_scale_encoding_using_type_string(input, type_string)#
Parameters:
  • input (Union[List[int], bytes, scalecodec.base.ScaleBytes]) –

  • type_string (str) –

Return type:

Optional[Dict]