diff --git a/bittensor/axon.py b/bittensor/axon.py index b8d4eb50ba..59f45ba4f0 100644 --- a/bittensor/axon.py +++ b/bittensor/axon.py @@ -59,20 +59,20 @@ class FastAPIThreadedServer(uvicorn.Server): """ - The ``FastAPIThreadedServer`` class is a specialized server implementation for the Axon server in the Bittensor network. - + The ``FastAPIThreadedServer`` class is a specialized server implementation for the Axon server in the Bittensor network. + It extends the functionality of :func:`uvicorn.Server` to run the FastAPI application in a separate thread, allowing the Axon server to handle HTTP requests concurrently and non-blocking. This class is designed to facilitate the integration of FastAPI with the Axon's asynchronous architecture, ensuring efficient and scalable handling of network requests. Importance and Functionality Threaded Execution - The class allows the FastAPI application to run in a separate thread, enabling concurrent handling of HTTP requests which is crucial for the performance and scalability of the Axon server. + The class allows the FastAPI application to run in a separate thread, enabling concurrent handling of HTTP requests which is crucial for the performance and scalability of the Axon server. Seamless Integration By running FastAPI in a threaded manner, this class ensures seamless integration of FastAPI's capabilities with the Axon server's asynchronous and multi-threaded architecture. - Controlled Server Management + Controlled Server Management The methods start and stop provide controlled management of the server's lifecycle, ensuring that the server can be started and stopped as needed, which is vital for maintaining the Axon server's reliability and availability. Signal Handling @@ -81,7 +81,7 @@ class FastAPIThreadedServer(uvicorn.Server): Use Cases Starting the Server When the Axon server is initialized, it can use this class to start the FastAPI application in a separate thread, enabling it to begin handling HTTP requests immediately. - + Stopping the Server During shutdown or maintenance of the Axon server, this class can be used to stop the FastAPI application gracefully, ensuring that all resources are properly released. @@ -152,8 +152,8 @@ def stop(self): class axon: """ - The ``axon`` class in Bittensor is a fundamental component that serves as the server-side interface for a neuron within the Bittensor network. - + The ``axon`` class in Bittensor is a fundamental component that serves as the server-side interface for a neuron within the Bittensor network. + This class is responsible for managing incoming requests from other neurons and implements various mechanisms to ensure efficient and secure network interactions. @@ -180,7 +180,7 @@ class is designed to be flexible and customizable, allowing users to specify cus - Command-line argument support for user-friendly program interaction. Example Usage:: - + import bittensor # Define your custom synapse class class MySyanpse( bittensor.Synapse ): @@ -428,7 +428,7 @@ def attach( priority_fn (Callable, optional): Function to rank requests based on their priority. It should take the same arguments as :func:`forward_fn` and return a numerical value representing the request's priority. Defaults to ``None``, meaning no priority sorting will be applied. verify_fn (Callable, optional): Function to verify requests. It should take the same arguments as :func:`forward_fn` and return a boolean value. If ``None``, :func:`self.default_verify` function will be used. - Note: + Note: The methods :func:`forward_fn`, :func:`blacklist_fn`, :func:`priority_fn`, and :func:`verify_fn` should be designed to receive the same parameters. Raises: @@ -441,7 +441,7 @@ def attach( self: Returns the instance of the AxonServer class for potential method chaining. Example Usage:: - + def forward_custom(synapse: MyCustomSynapse) -> MyCustomSynapse: # Custom logic for processing the request return synapse @@ -679,7 +679,7 @@ async def verify_body_integrity(self, request: Request): The response includes the detailed error message specifying which field has a hash mismatch. This method performs several key functions: - + 1. Decoding and loading the request body for inspection. 2. Gathering required field names for hash comparison from the Axon configuration. 3. Loading and parsing the request body into a dictionary. @@ -780,7 +780,7 @@ def start(self) -> "bittensor.axon": bittensor.axon: The Axon instance in the 'started' state. Example:: - + my_axon = bittensor.axon(...) ... # setup axon, attach functions, etc. my_axon.start() # Starts the axon server @@ -806,12 +806,12 @@ def stop(self) -> "bittensor.axon": bittensor.axon: The Axon instance in the 'stopped' state. Example:: - + my_axon = bittensor.axon(...) my_axon.start() ... my_axon.stop() # Stops the axon server - + Note: It is advisable to ensure that all ongoing processes or requests are completed or properly handled before invoking this method. @@ -837,7 +837,7 @@ def serve( bittensor.axon: The Axon instance that is now actively serving on the specified subtensor. Example:: - + my_axon = bittensor.axon(...) subtensor = bt.subtensor(network="local") # Local by default my_axon.serve(netuid=1, subtensor=subtensor) # Serves the axon on subnet with netuid 1 @@ -962,8 +962,8 @@ def log_and_handle_error( class AxonMiddleware(BaseHTTPMiddleware): """ - The `AxonMiddleware` class is a key component in the Axon server, responsible for processing all incoming requests. - + The `AxonMiddleware` class is a key component in the Axon server, responsible for processing all incoming requests. + It handles the essential tasks of verifying requests, executing blacklist checks, running priority functions, and managing the logging of messages and errors. Additionally, the class is responsible for updating the headers of the response and executing the requested functions. @@ -1008,7 +1008,7 @@ async def dispatch( Response: The HTTP response generated after processing the request. This method performs several key functions: - + 1. Request Preprocessing: Sets up Synapse object from request headers and fills necessary information. 2. Logging: Logs the start of request processing. 3. Blacklist Checking: Verifies if the request is blacklisted. @@ -1120,7 +1120,7 @@ async def preprocess(self, request: Request) -> bittensor.Synapse: bittensor.Synapse: The Synapse object representing the preprocessed state of the request. The preprocessing involves: - + 1. Extracting the request name from the URL path. 2. Creating a Synapse instance from the request headers using the appropriate class type. 3. Filling in the Axon and Dendrite information into the Synapse object. @@ -1188,7 +1188,7 @@ async def verify(self, synapse: bittensor.Synapse): Exception: If the verification process fails due to unmet criteria or security concerns. The verification process involves: - + 1. Retrieving the specific verification function for the request's Synapse type. 2. Executing the verification function and handling any exceptions that arise. @@ -1236,7 +1236,7 @@ async def blacklist(self, synapse: bittensor.Synapse): Exception: If the request is found in the blacklist. The blacklist check involves: - + 1. Retrieving the blacklist checking function for the request's Synapse type. 2. Executing the check and handling the case where the request is blacklisted. diff --git a/bittensor/commands/delegates.py b/bittensor/commands/delegates.py index 878252b654..e96a43963b 100644 --- a/bittensor/commands/delegates.py +++ b/bittensor/commands/delegates.py @@ -54,8 +54,8 @@ def show_delegates( width: Optional[int] = None, ): """ - Displays a formatted table of Bittensor network delegates with detailed statistics to the console. - + Displays a formatted table of Bittensor network delegates with detailed statistics to the console. + The table is sorted by total stake in descending order and provides a snapshot of delegate performance and status, helping users make informed decisions for staking or nominating. @@ -67,7 +67,7 @@ def show_delegates( - width (Optional[int]): The width of the console output table. Defaults to ``None``, which will make the table expand to the maximum width of the console. The output table includes the following columns: - + - INDEX: The numerical index of the delegate. - DELEGATE: The name of the delegate. - SS58: The truncated SS58 address of the delegate. @@ -86,7 +86,7 @@ def show_delegates( options to users who are considering where to stake their tokens. Example usage:: - + show_delegates(current_delegates, previous_delegates, width=80) Note: @@ -214,8 +214,8 @@ def show_delegates( class DelegateStakeCommand: """ - Executes the ``delegate`` command, which stakes Tao to a specified delegate on the Bittensor network. - + Executes the ``delegate`` command, which stakes Tao to a specified delegate on the Bittensor network. + This action allocates the user's Tao to support a delegate, potentially earning staking rewards in return. Optional Arguments: @@ -230,7 +230,7 @@ class DelegateStakeCommand: The user must specify the delegate's SS58 address and the amount of Tao to stake. The function sends a transaction to the subtensor network to delegate the specified amount to the chosen delegate. These values are prompted if not provided. Example usage:: - + btcli delegate --delegate_ss58key --amount btcli delegate --delegate_ss58key --all @@ -343,8 +343,8 @@ def check_config(config: "bittensor.config"): class DelegateUnstakeCommand: """ - Executes the ``undelegate`` command, allowing users to withdraw their staked Tao from a delegate on the Bittensor network. - + Executes the ``undelegate`` command, allowing users to withdraw their staked Tao from a delegate on the Bittensor network. + This process is known as "undelegating" and it reverses the delegation process, freeing up the staked tokens. Optional Arguments: @@ -359,7 +359,7 @@ class DelegateUnstakeCommand: The user must provide the delegate's SS58 address and the amount of Tao to undelegate. The function will then send a transaction to the Bittensor network to process the undelegation. Example usage:: - + btcli undelegate --delegate_ss58key --amount btcli undelegate --delegate_ss58key --all @@ -478,8 +478,8 @@ def check_config(config: "bittensor.config"): class ListDelegatesCommand: """ - Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information. - + Displays a formatted table of Bittensor network delegates, providing a comprehensive overview of delegate statistics and information. + This table helps users make informed decisions on which delegates to allocate their Tao stake. Optional Arguments: @@ -487,7 +487,7 @@ class ListDelegatesCommand: - ``subtensor.network``: The name of the network to use for the command. The table columns include: - + - INDEX: The delegate's index in the sorted list. - DELEGATE: The name of the delegate. - SS58: The delegate's unique SS58 address (truncated for display). @@ -504,7 +504,7 @@ class ListDelegatesCommand: Sorting is done based on the ``TOTAL STAKE`` column in descending order. Changes in stake are highlighted: increases in green and decreases in red. Entries with no previous data are marked with ``NA``. Each delegate's name is a hyperlink to their respective URL, if available. Example usage:: - + btcli root list_delegates btcli root list_delegates --wallet.name my_wallet btcli root list_delegates --subtensor.network finney # can also be `test` or `local` @@ -567,12 +567,12 @@ def check_config(config: "bittensor.config"): class NominateCommand: """ - Executes the ``nominate`` command, which facilitates a wallet to become a delegate on the Bittensor network. - + Executes the ``nominate`` command, which facilitates a wallet to become a delegate on the Bittensor network. + This command handles the nomination process, including wallet unlocking and verification of the hotkey's current delegate status. The command performs several checks: - + - Verifies that the hotkey is not already a delegate to prevent redundant nominations. - Tries to nominate the wallet and reports success or failure. @@ -586,7 +586,7 @@ class NominateCommand: To run the command, the user must have a configured wallet with both hotkey and coldkey. If the wallet is not already nominated, this command will initiate the process. Example usage:: - + btcli root nominate btcli root nominate --wallet.name my_wallet --wallet.hotkey my_hotkey @@ -669,8 +669,8 @@ def check_config(config: "bittensor.config"): class MyDelegatesCommand: """ - Executes the ``my_delegates`` command within the Bittensor CLI, which retrieves and displays a table of delegated stakes from a user's wallet(s) to various delegates on the Bittensor network. - + Executes the ``my_delegates`` command within the Bittensor CLI, which retrieves and displays a table of delegated stakes from a user's wallet(s) to various delegates on the Bittensor network. + The command provides detailed insights into the user's staking activities and the performance of their chosen delegates. @@ -679,7 +679,7 @@ class MyDelegatesCommand: - ``all``: If specified, the command aggregates information across all wallets. The table output includes the following columns: - + - Wallet: The name of the user's wallet. - OWNER: The name of the delegate's owner. - SS58: The truncated SS58 address of the delegate. @@ -699,7 +699,7 @@ class MyDelegatesCommand: The command can be run as part of the Bittensor CLI suite of tools and requires no parameters if a single wallet is used. If multiple wallets are present, the ``--all`` flag can be specified to aggregate information across all wallets. Example usage:: - + btcli my_delegates btcli my_delegates --all btcli my_delegates --wallet.name my_wallet diff --git a/bittensor/commands/identity.py b/bittensor/commands/identity.py index 6cf99b4092..2e71bf406b 100644 --- a/bittensor/commands/identity.py +++ b/bittensor/commands/identity.py @@ -9,8 +9,8 @@ class SetIdentityCommand: """ - Executes the :func:`set_identity` command within the Bittensor network, which allows for the creation or update of a delegate's on-chain identity. - + Executes the :func:`set_identity` command within the Bittensor network, which allows for the creation or update of a delegate's on-chain identity. + This identity includes various attributes such as display name, legal name, web URL, PGP fingerprint, and contact information, among others. @@ -250,12 +250,12 @@ class GetIdentityCommand: - ``key``: The ``ss58`` address of the coldkey or hotkey to query. The command performs the following actions: - + - Connects to the subtensor network and retrieves the identity information. - Displays the information in a structured table format. The displayed table includes: - + - **Address**: The ``ss58`` address of the queried key. - **Item**: Various attributes of the identity such as stake, rank, and trust. - **Value**: The corresponding values of the attributes. @@ -265,7 +265,7 @@ class GetIdentityCommand: provided in the configuration, the user is prompted to enter one. Example usage:: - + btcli wallet get_identity --key Note: diff --git a/bittensor/commands/inspect.py b/bittensor/commands/inspect.py index 6ef2ad124d..bdf2a00e26 100644 --- a/bittensor/commands/inspect.py +++ b/bittensor/commands/inspect.py @@ -73,8 +73,8 @@ def _get_hotkey_wallets_for_wallet(wallet) -> List["bittensor.wallet"]: class InspectCommand: """ - Executes the ``inspect`` command, which compiles and displays a detailed report of a user's wallet pairs (coldkey, hotkey) on the Bittensor network. - + Executes the ``inspect`` command, which compiles and displays a detailed report of a user's wallet pairs (coldkey, hotkey) on the Bittensor network. + This report includes balance and staking information for both the coldkey and hotkey associated with the wallet. @@ -82,13 +82,13 @@ class InspectCommand: - ``all``: If set to ``True``, the command will inspect all wallets located within the specified path. If set to ``False``, the command will inspect only the wallet specified by the user. The command gathers data on: - + - Coldkey balance and delegated stakes. - Hotkey stake and emissions per neuron on the network. - Delegate names and details fetched from the network. The resulting table includes columns for: - + - **Coldkey**: The coldkey associated with the user's wallet. - **Balance**: The balance of the coldkey. - **Delegate**: The name of the delegate to which the coldkey has staked funds. @@ -103,7 +103,7 @@ class InspectCommand: and performance in the Bittensor network. Example usage:: - + btcli wallet inspect btcli wallet inspect --all diff --git a/bittensor/commands/list.py b/bittensor/commands/list.py index 04ecb2932e..6079112ed1 100644 --- a/bittensor/commands/list.py +++ b/bittensor/commands/list.py @@ -26,8 +26,8 @@ class ListCommand: """ - Executes the ``list`` command which enumerates all wallets and their respective hotkeys present in the user's Bittensor configuration directory. - + Executes the ``list`` command which enumerates all wallets and their respective hotkeys present in the user's Bittensor configuration directory. + The command organizes the information in a tree structure, displaying each wallet along with the ``ss58`` addresses for the coldkey public key and any hotkeys associated with it. Optional arguments: @@ -41,7 +41,7 @@ class ListCommand: Upon invocation, the command scans the wallet directory and prints a list of all wallets, indicating whether the public keys are available (``?`` denotes unavailable or encrypted keys). Example usage:: - + btcli wallet list --path ~/.bittensor Note: diff --git a/bittensor/commands/metagraph.py b/bittensor/commands/metagraph.py index c4a7a4cb25..d837e19028 100644 --- a/bittensor/commands/metagraph.py +++ b/bittensor/commands/metagraph.py @@ -26,8 +26,8 @@ class MetagraphCommand: """ - Executes the ``metagraph`` command to retrieve and display the entire metagraph for a specified network. - + Executes the ``metagraph`` command to retrieve and display the entire metagraph for a specified network. + This metagraph contains detailed information about all the neurons (nodes) participating in the network, including their stakes, trust scores, and more. @@ -37,7 +37,7 @@ class MetagraphCommand: - ``--subtensor.network``: The name of the network to query. Defaults to the default network name. The table displayed includes the following columns for each neuron: - + - UID: Unique identifier of the neuron. - STAKE(τ): Total stake of the neuron in Tau (τ). - RANK: Rank score of the neuron. @@ -60,7 +60,7 @@ class MetagraphCommand: The user must specify the network UID to query the metagraph. If not specified, the default network UID is used. Example usage:: - + btcli subnet metagraph --netuid 0 # Root network btcli subnet metagraph --netuid 1 --subtensor.network test diff --git a/bittensor/commands/misc.py b/bittensor/commands/misc.py index b350176108..ded0a6c06b 100644 --- a/bittensor/commands/misc.py +++ b/bittensor/commands/misc.py @@ -29,21 +29,21 @@ class UpdateCommand: """ Executes the ``update`` command to update the local Bittensor package. - + This command performs a series of operations to ensure that the user's local Bittensor installation is updated to the latest version from the master branch of its GitHub repository. It primarily involves pulling the latest changes from the repository and reinstalling the package. Usage: Upon invocation, the command first checks the user's configuration for the ``no_prompt`` setting. If ``no_prompt`` is set to ``True``, or if the user explicitly confirms with ``Y`` when prompted, the command proceeds to update the local Bittensor package. It changes the current directory to the Bittensor package directory, checks out the master branch of the Bittensor repository, pulls the latest changes, and then reinstalls the package using ``pip``. The command structure is as follows: - + 1. Change directory to the Bittensor package directory. 2. Check out the master branch of the Bittensor GitHub repository. 3. Pull the latest changes with the ``--ff-only`` option to ensure a fast-forward update. 4. Reinstall the Bittensor package using pip. Example usage:: - + btcli legacy update Note: diff --git a/bittensor/commands/network.py b/bittensor/commands/network.py index 42c077c8f0..df497f2cec 100644 --- a/bittensor/commands/network.py +++ b/bittensor/commands/network.py @@ -29,13 +29,13 @@ class RegisterSubnetworkCommand: """ - Executes the ``register_subnetwork`` command to register a new subnetwork on the Bittensor network. - + Executes the ``register_subnetwork`` command to register a new subnetwork on the Bittensor network. + This command facilitates the creation and registration of a subnetwork, which involves interaction with the user's wallet and the Bittensor subtensor. It ensures that the user has the necessary credentials and configurations to successfully register a new subnetwork. Usage: Upon invocation, the command performs several key steps to register a subnetwork: - + 1. It copies the user's current configuration settings. 2. It accesses the user's wallet using the provided configuration. 3. It initializes the Bittensor subtensor object with the user's configuration. @@ -44,14 +44,14 @@ class RegisterSubnetworkCommand: If the user's configuration does not specify a wallet name and ``no_prompt`` is not set, the command will prompt the user to enter a wallet name. This name is then used in the registration process. The command structure includes: - + - Copying the user's configuration. - Accessing and preparing the user's wallet. - Initializing the Bittensor subtensor. - Registering the subnetwork with the necessary credentials. Example usage:: - + btcli subnets create Note: @@ -101,15 +101,15 @@ def add_args(cls, parser: argparse.ArgumentParser): class SubnetLockCostCommand: """ - Executes the ``lock_cost`` command to view the locking cost required for creating a new subnetwork on the Bittensor network. - + Executes the ``lock_cost`` command to view the locking cost required for creating a new subnetwork on the Bittensor network. + This command is designed to provide users with the current cost of registering a new subnetwork, which is a critical piece of information for anyone considering expanding the network's infrastructure. The current implementation anneals the cost of creating a subnet over a period of two days. If the cost is unappealing currently, check back in a day or two to see if it has reached an amenble level. Usage: Upon invocation, the command performs the following operations: - + 1. It copies the user's current Bittensor configuration. 2. It initializes the Bittensor subtensor object with this configuration. 3. It then retrieves the subnet lock cost using the ``get_subnet_burn_cost()`` method from the subtensor object. @@ -118,13 +118,13 @@ class SubnetLockCostCommand: In case of any errors during the process (e.g., network issues, configuration problems), the command will catch these exceptions and inform the user that it failed to retrieve the lock cost, along with the specific error encountered. The command structure includes: - + - Copying and using the user's configuration for Bittensor. - Retrieving the current subnet lock cost from the Bittensor network. - Displaying the cost in a user-friendly manner. Example usage:: - + btcli subnets lock_cost Note: @@ -176,7 +176,7 @@ def add_args(cls, parser: argparse.ArgumentParser): class SubnetListCommand: """ Executes the ``list`` command to list all subnets and their detailed information on the Bittensor network. - + This command is designed to provide users with comprehensive information about each subnet within the network, including its unique identifier (netuid), the number of neurons, maximum neuron capacity, emission rate, tempo, recycle register cost (burn), proof of work (PoW) difficulty, and the name or @@ -184,7 +184,7 @@ class SubnetListCommand: Usage: Upon invocation, the command performs the following actions: - + 1. It initializes the Bittensor subtensor object with the user's configuration. 2. It retrieves a list of all subnets in the network along with their detailed information. 3. The command compiles this data into a table format, displaying key information about each subnet. @@ -194,14 +194,14 @@ class SubnetListCommand: address is displayed. The command structure includes: - + - Initializing the Bittensor subtensor and retrieving subnet information. - Calculating the total number of neurons across all subnets. - Constructing a table that includes columns for ``NETUID``, ``N`` (current neurons), ``MAX_N`` (maximum neurons), ``EMISSION``, ``TEMPO``, ``BURN``, ``POW`` (proof of work difficulty), and ``SUDO`` (owner's name or ``SS58`` address). - Displaying the table with a footer that summarizes the total number of subnets and neurons. Example usage:: - + btcli subnets list Note: @@ -304,7 +304,7 @@ def add_args(parser: argparse.ArgumentParser): class SubnetSudoCommand: """ Executes the ``set`` command to set hyperparameters for a specific subnet on the Bittensor network. - + This command allows subnet owners to modify various hyperparameters of theirs subnet, such as its tempo, emission rates, and other network-specific settings. @@ -314,7 +314,7 @@ class SubnetSudoCommand: to the specified subnet. Example usage:: - + btcli sudo set --netuid 1 --param 'tempo' --value '0.5' Note: @@ -386,8 +386,8 @@ def add_args(parser: argparse.ArgumentParser): class SubnetHyperparamsCommand: """ - Executes the '``hyperparameters``' command to view the current hyperparameters of a specific subnet on the Bittensor network. - + Executes the '``hyperparameters``' command to view the current hyperparameters of a specific subnet on the Bittensor network. + This command is useful for users who wish to understand the configuration and operational parameters of a particular subnet. @@ -397,7 +397,7 @@ class SubnetHyperparamsCommand: the subnet's behavior. Example usage:: - + $ btcli subnets hyperparameters --netuid 1 Subnet Hyperparameters - NETUID: 1 - finney @@ -485,7 +485,7 @@ def add_args(parser: argparse.ArgumentParser): class SubnetGetHyperparamsCommand: """ Executes the ``get`` command to retrieve the hyperparameters of a specific subnet on the Bittensor network. - + This command is similar to the ``hyperparameters`` command but may be used in different contexts within the CLI. Usage: @@ -494,7 +494,7 @@ class SubnetGetHyperparamsCommand: performance and interaction within the network. Example usage:: - + $ btcli sudo get --netuid 1 Subnet Hyperparameters - NETUID: 1 - finney diff --git a/bittensor/commands/overview.py b/bittensor/commands/overview.py index 4d42df0b51..068c11f004 100644 --- a/bittensor/commands/overview.py +++ b/bittensor/commands/overview.py @@ -39,7 +39,7 @@ class OverviewCommand: """ Executes the ``overview`` command to present a detailed overview of the user's registered accounts on the Bittensor network. - + This command compiles and displays comprehensive information about each neuron associated with the user's wallets, including both hotkeys and coldkeys. It is especially useful for users managing multiple accounts or seeking a summary of their network activities and stake distributions. @@ -48,7 +48,7 @@ class OverviewCommand: The command offers various options to customize the output. Users can filter the displayed data by specific netuids, sort by different criteria, and choose to include all wallets in the user's configuration directory. The output is presented in a tabular format with the following columns: - + - COLDKEY: The SS58 address of the coldkey. - HOTKEY: The SS58 address of the hotkey. - UID: Unique identifier of the neuron. @@ -67,7 +67,7 @@ class OverviewCommand: - HOTKEY_SS58: Human-readable representation of the hotkey. Example usage:: - + btcli wallet overview btcli wallet overview --all --sort_by stake --sort_order descending diff --git a/bittensor/commands/register.py b/bittensor/commands/register.py index 53365a2f1f..07225ca2f8 100644 --- a/bittensor/commands/register.py +++ b/bittensor/commands/register.py @@ -30,30 +30,30 @@ class RegisterCommand: """ Executes the ``register`` command to register a neuron on the Bittensor network by recycling some TAO (the network's native token). - + This command is used to add a new neuron to a specified subnet within the network, contributing to the decentralization and robustness of Bittensor. Usage: Before registering, the command checks if the specified subnet exists and whether the user's balance is sufficient to cover the registration cost. - + The registration cost is determined by the current recycle amount for the specified subnet. If the balance is insufficient or the subnet does not exist, the command will exit with an appropriate error message. If the preconditions are met, and the user confirms the transaction (if ``no_prompt`` is not set), the command proceeds to register the neuron by burning the required amount of TAO. The command structure includes: - + - Verification of subnet existence. - Checking the user's balance against the current recycle amount for the subnet. - User confirmation prompt for proceeding with registration. - Execution of the registration process. Columns Displayed in the confirmation prompt: - + - Balance: The current balance of the user's wallet in TAO. - Cost to Register: The required amount of TAO needed to register on the specified subnet. Example usage:: - + btcli subnets register --netuid 1 Note: @@ -159,7 +159,7 @@ def check_config(config: "bittensor.config"): class PowRegisterCommand: """ Executes the ``pow_register`` command to register a neuron on the Bittensor network using Proof of Work (PoW). - + This method is an alternative registration process that leverages computational work for securing a neuron's place on the network. Usage: @@ -180,7 +180,7 @@ class PowRegisterCommand: The command also supports additional wallet and subtensor arguments, enabling further customization of the registration process. Example usage:: - + btcli pow_register --netuid 1 --pow_register.num_processes 4 --cuda.use_cuda Note: @@ -359,10 +359,10 @@ def check_config(config: "bittensor.config"): class RunFaucetCommand: """ Executes the ``faucet`` command to obtain test TAO tokens by performing Proof of Work (PoW). - + IMPORTANT: **THIS COMMAND IS CURRENTLY DISABLED.** - + This command is particularly useful for users who need test tokens for operations on the Bittensor testnet. Usage: @@ -381,7 +381,7 @@ class RunFaucetCommand: These options provide flexibility in configuring the PoW process according to the user's hardware capabilities and preferences. Example usage:: - + btcli wallet faucet --faucet.num_processes 4 --faucet.cuda.use_cuda Note: diff --git a/bittensor/commands/root.py b/bittensor/commands/root.py index 483bd447d1..49355d23f2 100644 --- a/bittensor/commands/root.py +++ b/bittensor/commands/root.py @@ -35,7 +35,7 @@ class RootRegisterCommand: """ Executes the ``register`` command to register a wallet to the root network of the Bittensor network. - + This command is used to formally acknowledge a wallet's participation in the network's root layer. Usage: @@ -45,12 +45,12 @@ class RootRegisterCommand: - None. The command primarily uses the wallet and subtensor configurations. Example usage:: - + btcli root register Note: This command is important for users seeking to engage deeply with the Bittensor network, particularly in aspects related to network governance and decision-making. - + It is a straightforward process but requires the user to have an initialized and configured wallet. """ @@ -97,7 +97,7 @@ def check_config(config: "bittensor.config"): class RootList: """ Executes the ``list`` command to display the members of the root network on the Bittensor network. - + This command provides an overview of the neurons that constitute the network's foundational layer. Usage: @@ -107,7 +107,7 @@ class RootList: - None. The command uses the subtensor configuration to retrieve data. Example usage:: - + $ btcli root list UID NAME ADDRESS STAKE(τ) SENATOR @@ -229,7 +229,7 @@ class RootSetBoostCommand: - ``--increase`` (float): The cooresponding increase in the weight for this subnet. Example usage:: - + $ btcli root boost --netuid 1 --increase 0.01 Enter netuid (e.g. 1): 1 @@ -350,7 +350,7 @@ class RootSetSlashCommand: - ``--decrease`` (float): The corresponding decrease in the weight for this subnet. Example usage:: - + $ btcli root slash --netuid 1 --decrease 0.01 Enter netuid (e.g. 1): 1 @@ -458,7 +458,7 @@ def check_config(config: "bittensor.config"): class RootSetWeightsCommand: """ Executes the ``weights`` command to set the weights for the root network on the Bittensor network. - + This command is used by network senators to influence the distribution of network rewards and responsibilities. Usage: @@ -469,7 +469,7 @@ class RootSetWeightsCommand: - ``--weights`` (str): Corresponding weights for the specified netuids, in comma-separated format. Example usage:: - + btcli root weights --netuids 1,2,3 --weights 0.3,0.3,0.4 Note: @@ -561,7 +561,7 @@ def check_config(config: "bittensor.config"): class RootGetWeightsCommand: """ Executes the ``get_weights`` command to retrieve the weights set for the root network on the Bittensor network. - + This command provides visibility into how network responsibilities and rewards are distributed among various subnets. Usage: @@ -571,7 +571,7 @@ class RootGetWeightsCommand: - None. The command fetches weight information based on the subtensor configuration. Example usage:: - + $ btcli root get_weights Root Network Weights diff --git a/bittensor/commands/senate.py b/bittensor/commands/senate.py index 1bfc978ea6..adb704a582 100644 --- a/bittensor/commands/senate.py +++ b/bittensor/commands/senate.py @@ -31,7 +31,7 @@ class SenateCommand: """ Executes the ``senate`` command to view the members of Bittensor's governance protocol, known as the Senate. - + This command lists the delegates involved in the decision-making process of the Bittensor network. Usage: @@ -39,7 +39,7 @@ class SenateCommand: This information is crucial for understanding who holds governance roles within the network. Example usage:: - + btcli root senate Note: @@ -168,14 +168,14 @@ def display_votes( class ProposalsCommand: """ Executes the ``proposals`` command to view active proposals within Bittensor's governance protocol. - + This command displays the details of ongoing proposals, including votes, thresholds, and proposal data. Usage: The command lists all active proposals, showing their hash, voting threshold, number of ayes and nays, detailed votes by address, end block number, and call data associated with each proposal. Example usage:: - + btcli root proposals Note: @@ -283,10 +283,10 @@ def add_args(cls, parser: argparse.ArgumentParser): class ShowVotesCommand: """ Executes the ``proposal_votes`` command to view the votes for a specific proposal in Bittensor's governance protocol. - + IMPORTANT **THIS COMMAND IS DEPRECATED**. Use ``btcli root proposals`` to see vote status. - + This command provides a detailed breakdown of the votes cast by the senators for a particular proposal. Usage: @@ -296,7 +296,7 @@ class ShowVotesCommand: - ``--proposal`` (str): The hash of the proposal for which votes need to be displayed. Example usage:: - + btcli root proposal_votes --proposal Note: @@ -394,7 +394,7 @@ def add_args(cls, parser: argparse.ArgumentParser): class SenateRegisterCommand: """ Executes the ``senate_register`` command to register as a member of the Senate in Bittensor's governance protocol. - + This command is used by delegates who wish to participate in the governance and decision-making process of the network. Usage: @@ -402,7 +402,7 @@ class SenateRegisterCommand: Successful execution allows the user to participate in proposal voting and other governance activities. Example usage:: - + btcli root senate_register Note: @@ -476,7 +476,7 @@ def add_args(cls, parser: argparse.ArgumentParser): class SenateLeaveCommand: """ Executes the ``senate_leave`` command to discard membership in Bittensor's Senate. - + This command allows a Senate member to voluntarily leave the governance body. Usage: @@ -484,7 +484,7 @@ class SenateLeaveCommand: It effectively removes the user from participating in future governance decisions. Example usage:: - + btcli root senate_leave Note: @@ -549,7 +549,7 @@ def add_args(cls, parser: argparse.ArgumentParser): class VoteCommand: """ Executes the ``senate_vote`` command to cast a vote on an active proposal in Bittensor's governance protocol. - + This command is used by Senate members to vote on various proposals that shape the network's future. Usage: @@ -559,7 +559,7 @@ class VoteCommand: - ``--proposal`` (str): The hash of the proposal to vote on. Example usage:: - + btcli root senate_vote --proposal Note: diff --git a/bittensor/commands/stake.py b/bittensor/commands/stake.py index 18c1561dc1..cbb210f34b 100644 --- a/bittensor/commands/stake.py +++ b/bittensor/commands/stake.py @@ -31,7 +31,7 @@ class StakeCommand: """ Executes the ``add`` command to stake tokens to one or more hotkeys from a user's coldkey on the Bittensor network. - + This command is used to allocate tokens to different hotkeys, securing their position and influence on the network. Usage: @@ -49,7 +49,7 @@ class StakeCommand: The command prompts for confirmation before executing the staking operation. Example usage:: - + btcli stake add --amount 100 --wallet.name --wallet.hotkey Note: @@ -345,7 +345,7 @@ def _get_hotkey_wallets_for_wallet(wallet) -> List["bittensor.wallet"]: class StakeShow: """ Executes the ``show`` command to list all stake accounts associated with a user's wallet on the Bittensor network. - + This command provides a comprehensive view of the stakes associated with both hotkeys and delegates linked to the user's coldkey. Usage: @@ -356,7 +356,7 @@ class StakeShow: - ``--all`` (bool): When set, the command checks all coldkey wallets instead of just the specified wallet. The command compiles a table showing: - + - Coldkey: The coldkey associated with the wallet. - Balance: The balance of the coldkey. - Account: The name of the hotkey or delegate. @@ -364,7 +364,7 @@ class StakeShow: - Rate: The rate of return on the stake, typically shown in TAO per day. Example usage:: - + btcli stake show --all Note: diff --git a/bittensor/commands/transfer.py b/bittensor/commands/transfer.py index aeaddacaba..24c6e78402 100644 --- a/bittensor/commands/transfer.py +++ b/bittensor/commands/transfer.py @@ -28,7 +28,7 @@ class TransferCommand: """ Executes the ``transfer`` command to transfer TAO tokens from one account to another on the Bittensor network. - + This command is used for transactions between different accounts, enabling users to send tokens to other participants on the network. Usage: @@ -42,7 +42,7 @@ class TransferCommand: The command displays the user's current balance before prompting for the amount to transfer, ensuring transparency and accuracy in the transaction. Example usage:: - + btcli wallet transfer --dest 5Dp8... --amount 100 Note: diff --git a/bittensor/commands/unstake.py b/bittensor/commands/unstake.py index 627635fc4f..a2290d5b84 100644 --- a/bittensor/commands/unstake.py +++ b/bittensor/commands/unstake.py @@ -30,7 +30,7 @@ class UnStakeCommand: """ Executes the ``remove`` command to unstake TAO tokens from one or more hotkeys and transfer them back to the user's coldkey on the Bittensor network. - + This command is used to withdraw tokens previously staked to different hotkeys. Usage: @@ -47,7 +47,7 @@ class UnStakeCommand: The command prompts for confirmation before executing the unstaking operation. Example usage:: - + btcli stake remove --amount 100 --hotkeys hk1,hk2 Note: diff --git a/bittensor/commands/wallets.py b/bittensor/commands/wallets.py index a02f07dbbc..e40f2cb8dc 100644 --- a/bittensor/commands/wallets.py +++ b/bittensor/commands/wallets.py @@ -30,7 +30,7 @@ class RegenColdkeyCommand: """ Executes the ``regen_coldkey`` command to regenerate a coldkey for a wallet on the Bittensor network. - + This command is used to create a new coldkey from an existing mnemonic, seed, or JSON file. Usage: @@ -46,7 +46,7 @@ class RegenColdkeyCommand: - ``--overwrite_coldkey`` (bool): Overwrites the existing coldkey with the new one. Example usage:: - + btcli wallet regen_coldkey --mnemonic "word1 word2 ... word12" Note: @@ -156,7 +156,7 @@ def add_args(parser: argparse.ArgumentParser): class RegenColdkeypubCommand: """ Executes the ``regen_coldkeypub`` command to regenerate the public part of a coldkey (coldkeypub) for a wallet on the Bittensor network. - + This command is used when a user needs to recreate their coldkeypub from an existing public key or SS58 address. Usage: @@ -168,7 +168,7 @@ class RegenColdkeypubCommand: - ``--overwrite_coldkeypub`` (bool): Overwrites the existing coldkeypub file with the new one. Example usage:: - + btcli wallet regen_coldkeypub --ss58_address 5DkQ4... Note: @@ -243,7 +243,7 @@ def add_args(parser: argparse.ArgumentParser): class RegenHotkeyCommand: """ Executes the ``regen_hotkey`` command to regenerate a hotkey for a wallet on the Bittensor network. - + Similar to regenerating a coldkey, this command creates a new hotkey from a mnemonic, seed, or JSON file. Usage: @@ -259,7 +259,7 @@ class RegenHotkeyCommand: - ``--overwrite_hotkey`` (bool): Overwrites the existing hotkey with the new one. Example usage:: - + btcli wallet regen_hotkey btcli wallet regen_hotkey --seed 0x1234... @@ -375,7 +375,7 @@ def add_args(parser: argparse.ArgumentParser): class NewHotkeyCommand: """ Executes the ``new_hotkey`` command to create a new hotkey under a wallet on the Bittensor network. - + This command is used to generate a new hotkey for managing a neuron or participating in the network. Usage: @@ -388,7 +388,7 @@ class NewHotkeyCommand: - ``--overwrite_hotkey`` (bool): Overwrites the existing hotkey with the new one. Example usage:: - + btcli wallet new_hotkey --n_words 24 Note: @@ -454,7 +454,7 @@ def add_args(parser: argparse.ArgumentParser): class NewColdkeyCommand: """ Executes the ``new_coldkey`` command to create a new coldkey under a wallet on the Bittensor network. - + This command generates a coldkey, which is essential for holding balances and performing high-value transactions. Usage: @@ -467,7 +467,7 @@ class NewColdkeyCommand: - ``--overwrite_coldkey`` (bool): Overwrites the existing coldkey with the new one. Example usage:: - + btcli wallet new_coldkey --n_words 15 Note: @@ -529,7 +529,7 @@ def add_args(parser: argparse.ArgumentParser): class WalletCreateCommand: """ Executes the ``create`` command to generate both a new coldkey and hotkey under a specified wallet on the Bittensor network. - + This command is a comprehensive utility for creating a complete wallet setup with both cold and hotkeys. Usage: @@ -543,7 +543,7 @@ class WalletCreateCommand: - ``--overwrite_hotkey`` (bool): Overwrites the existing hotkey with the new one. Example usage:: - + btcli wallet create --n_words 21 Note: @@ -630,7 +630,7 @@ def _get_coldkey_wallets_for_path(path: str) -> List["bittensor.wallet"]: class UpdateWalletCommand: """ Executes the ``update`` command to check and potentially update the security of the wallets in the Bittensor network. - + This command is used to enhance wallet security using modern encryption standards. Usage: @@ -642,7 +642,7 @@ class UpdateWalletCommand: - ``--no_prompt`` (bool): Disables user prompting during the update process. Example usage:: - + btcli wallet update --all Note: @@ -725,7 +725,7 @@ def list_coldkeypub_files(dir_path): class WalletBalanceCommand: """ Executes the ``balance`` command to check the balance of the wallet on the Bittensor network. - + This command provides a detailed view of the wallet's coldkey balances, including free and staked balances. Usage: @@ -735,7 +735,7 @@ class WalletBalanceCommand: None. The command uses the wallet and subtensor configurations to fetch balance data. Example usage:: - + btcli wallet balance Note: @@ -894,7 +894,7 @@ class GetWalletHistoryCommand: None. The command uses the wallet and subtensor configurations to fetch latest transfer data associated with a wallet. Example usage:: - + btcli wallet history Note: diff --git a/bittensor/extrinsics/delegation.py b/bittensor/extrinsics/delegation.py index 81f07de4e1..f64365f2bb 100644 --- a/bittensor/extrinsics/delegation.py +++ b/bittensor/extrinsics/delegation.py @@ -35,7 +35,7 @@ def nominate_extrinsic( wait_for_inclusion: bool = True, ) -> bool: r"""Becomes a delegate for the hotkey. - + Args: wallet (bittensor.wallet): The wallet to become a delegate for. Returns: @@ -104,7 +104,7 @@ def delegate_extrinsic( prompt: bool = False, ) -> bool: r"""Delegates the specified amount of stake to the passed delegate. - + Args: wallet (bittensor.wallet): Bittensor wallet object. delegate_ss58 (Optional[str]): The ``ss58`` address of the delegate. @@ -239,7 +239,7 @@ def undelegate_extrinsic( prompt: bool = False, ) -> bool: r"""Un-delegates stake from the passed delegate. - + Args: wallet (bittensor.wallet): Bittensor wallet object. delegate_ss58 (Optional[str]): The ``ss58`` address of the delegate. diff --git a/bittensor/extrinsics/log_utilities.py b/bittensor/extrinsics/log_utilities.py index c87d4ed79c..bcd6f09890 100644 --- a/bittensor/extrinsics/log_utilities.py +++ b/bittensor/extrinsics/log_utilities.py @@ -665,7 +665,7 @@ def print_console_subtensor_weight( class ValidatorPrometheus: r""" Prometheis logging object for validator. - + Args: config (bittensor.Config, optional): ``bittensor.server.config()`` diff --git a/bittensor/extrinsics/network.py b/bittensor/extrinsics/network.py index 99592264c8..d9e8fe346a 100644 --- a/bittensor/extrinsics/network.py +++ b/bittensor/extrinsics/network.py @@ -31,7 +31,7 @@ def register_subnetwork_extrinsic( prompt: bool = False, ) -> bool: r"""Registers a new subnetwork. - + Args: wallet (bittensor.wallet): bittensor wallet object. @@ -116,7 +116,7 @@ def set_hyperparameter_extrinsic( prompt: bool = False, ) -> bool: r"""Sets a hyperparameter for a specific subnetwork. - + Args: wallet (bittensor.wallet): bittensor wallet object. diff --git a/bittensor/extrinsics/prometheus.py b/bittensor/extrinsics/prometheus.py index c9c86d03c3..754f65ddd9 100644 --- a/bittensor/extrinsics/prometheus.py +++ b/bittensor/extrinsics/prometheus.py @@ -32,7 +32,7 @@ def prometheus_extrinsic( wait_for_finalization=True, ) -> bool: r"""Subscribes an Bittensor endpoint to the substensor chain. - + Args: subtensor (bittensor.subtensor): Bittensor subtensor object. diff --git a/bittensor/extrinsics/registration.py b/bittensor/extrinsics/registration.py index 277d210812..e75217b217 100644 --- a/bittensor/extrinsics/registration.py +++ b/bittensor/extrinsics/registration.py @@ -42,7 +42,7 @@ def register_extrinsic( log_verbose: bool = False, ) -> bool: r"""Registers the wallet to the chain. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -223,7 +223,7 @@ def burned_register_extrinsic( prompt: bool = False, ) -> bool: r"""Registers the wallet to chain by recycling TAO. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -341,7 +341,7 @@ def run_faucet_extrinsic( log_verbose: bool = False, ) -> bool: r"""Runs a continual POW to get a faucet of TAO on the test net. - + Args: wallet (bittensor.wallet): Bittensor wallet object. diff --git a/bittensor/extrinsics/root.py b/bittensor/extrinsics/root.py index 0c3d70868f..71cd88c5ed 100644 --- a/bittensor/extrinsics/root.py +++ b/bittensor/extrinsics/root.py @@ -37,7 +37,7 @@ def root_register_extrinsic( prompt: bool = False, ) -> bool: r"""Registers the wallet to root network. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -109,7 +109,7 @@ def set_root_weights_extrinsic( prompt: bool = False, ) -> bool: r"""Sets the given weights and values on chain for wallet hotkey account. - + Args: wallet (bittensor.wallet): Bittensor wallet object. diff --git a/bittensor/extrinsics/senate.py b/bittensor/extrinsics/senate.py index d859773243..565854dd69 100644 --- a/bittensor/extrinsics/senate.py +++ b/bittensor/extrinsics/senate.py @@ -32,7 +32,7 @@ def register_senate_extrinsic( prompt: bool = False, ) -> bool: r"""Registers the wallet to chain for senate voting. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -109,7 +109,7 @@ def leave_senate_extrinsic( prompt: bool = False, ) -> bool: r"""Removes the wallet from chain for senate voting. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -189,7 +189,7 @@ def vote_senate_extrinsic( prompt: bool = False, ) -> bool: r"""Removes the wallet from chain for senate voting. - + Args: wallet (bittensor.wallet): Bittensor wallet object. diff --git a/bittensor/extrinsics/serving.py b/bittensor/extrinsics/serving.py index 2238b0d792..ed49e871e5 100644 --- a/bittensor/extrinsics/serving.py +++ b/bittensor/extrinsics/serving.py @@ -37,7 +37,7 @@ def serve_extrinsic( prompt: bool = False, ) -> bool: r"""Subscribes a Bittensor endpoint to the subtensor chain. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -147,7 +147,7 @@ def serve_axon_extrinsic( prompt: bool = False, ) -> bool: r"""Serves the axon to the network. - + Args: netuid ( int ): The ``netuid`` being served on. diff --git a/bittensor/extrinsics/set_weights.py b/bittensor/extrinsics/set_weights.py index a5ae7cdc12..d27214cd36 100644 --- a/bittensor/extrinsics/set_weights.py +++ b/bittensor/extrinsics/set_weights.py @@ -40,7 +40,7 @@ def set_weights_extrinsic( prompt: bool = False, ) -> bool: r"""Sets the given weights and values on chain for wallet hotkey account. - + Args: wallet (bittensor.wallet): Bittensor wallet object. diff --git a/bittensor/extrinsics/staking.py b/bittensor/extrinsics/staking.py index e51246a058..7f89b9fc00 100644 --- a/bittensor/extrinsics/staking.py +++ b/bittensor/extrinsics/staking.py @@ -33,7 +33,7 @@ def add_stake_extrinsic( prompt: bool = False, ) -> bool: r"""Adds the specified amount of stake to passed hotkey ``uid``. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -210,7 +210,7 @@ def add_stake_multiple_extrinsic( prompt: bool = False, ) -> bool: r"""Adds stake to each ``hotkey_ss58`` in the list, using each amount, from a common coldkey. - + Args: wallet (bittensor.wallet): Bittensor wallet object for the coldkey. @@ -435,7 +435,7 @@ def __do_add_stake_single( ) -> bool: r""" Executes a stake call to the chain using the wallet and the amount specified. - + Args: wallet (bittensor.wallet): Bittensor wallet object. diff --git a/bittensor/extrinsics/transfer.py b/bittensor/extrinsics/transfer.py index a524c0a15a..2bb673eaf3 100644 --- a/bittensor/extrinsics/transfer.py +++ b/bittensor/extrinsics/transfer.py @@ -35,7 +35,7 @@ def transfer_extrinsic( prompt: bool = False, ) -> bool: r"""Transfers funds from this wallet to the destination public key address. - + Args: wallet (bittensor.wallet): Bittensor wallet object to make transfer from. diff --git a/bittensor/extrinsics/unstaking.py b/bittensor/extrinsics/unstaking.py index 4c218d8d01..b2c19c876d 100644 --- a/bittensor/extrinsics/unstaking.py +++ b/bittensor/extrinsics/unstaking.py @@ -33,7 +33,7 @@ def __do_remove_stake_single( ) -> bool: r""" Executes an unstake call to the chain using the wallet and the amount specified. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -81,7 +81,7 @@ def unstake_extrinsic( prompt: bool = False, ) -> bool: r"""Removes stake into the wallet coldkey from the specified hotkey ``uid``. - + Args: wallet (bittensor.wallet): Bittensor wallet object. @@ -216,7 +216,7 @@ def unstake_multiple_extrinsic( prompt: bool = False, ) -> bool: r"""Removes stake from each ``hotkey_ss58`` in the list, using each amount, to a common coldkey. - + Args: wallet (bittensor.wallet): The wallet with the coldkey to unstake to. diff --git a/bittensor/metagraph.py b/bittensor/metagraph.py index 5a3da93d83..a1e8467adf 100644 --- a/bittensor/metagraph.py +++ b/bittensor/metagraph.py @@ -70,8 +70,8 @@ def latest_block_path(dir_path: str) -> int: class metagraph(torch.nn.Module): """ - The metagraph class is a core component of the Bittensor network, representing the neural graph that forms the backbone of the decentralized machine learning system. - + The metagraph class is a core component of the Bittensor network, representing the neural graph that forms the backbone of the decentralized machine learning system. + The metagraph is a dynamic representation of the network's state, capturing the interconnectedness and attributes of neurons (participants) in the Bittensor ecosystem. This class is not just a static structure but a live reflection of the network, constantly updated and synchronized with the state of the blockchain. In Bittensor, neurons are akin to nodes in a distributed system, each contributing computational resources and participating in the network's collective intelligence. The metagraph tracks various attributes of these neurons, such as stake, trust, and consensus, which are crucial for the network's incentive mechanisms and the Yuma Consensus algorithm as outlined in the `NeurIPS paper `_. These attributes @@ -106,22 +106,22 @@ class metagraph(torch.nn.Module): Example Usage: Initializing the metagraph to represent the current state of the Bittensor network:: - + metagraph = bt.metagraph(netuid=config.netuid, network=subtensor.network, sync=False) Synchronizing the metagraph with the network to reflect the latest state and neuron data:: - + metagraph.sync(subtensor=subtensor) Accessing metagraph properties to inform network interactions and decisions:: - + total_stake = metagraph.S neuron_ranks = metagraph.R neuron_incentives = metagraph.I ... - + Maintaining a local copy of hotkeys for querying and interacting with network entities:: - + hotkeys = deepcopy(metagraph.hotkeys) """ @@ -270,14 +270,14 @@ def W(self) -> torch.FloatTensor: @property def hotkeys(self) -> List[str]: """ - Represents a list of ``hotkeys`` for each neuron in the Bittensor network. - + Represents a list of ``hotkeys`` for each neuron in the Bittensor network. + Hotkeys are unique identifiers used by neurons for active participation in the network, such as sending and receiving information or transactions. They are akin to public keys in cryptographic systems and are essential for identifying and authenticating neurons within the network's operations. Returns: - List[str]: A list of hotkeys, with each string representing the hotkey of a corresponding neuron. - + List[str]: A list of hotkeys, with each string representing the hotkey of a corresponding neuron. + These keys are crucial for the network's security and integrity, ensuring proper identification and authorization of network participants. Note: @@ -288,9 +288,9 @@ def hotkeys(self) -> List[str]: @property def coldkeys(self) -> List[str]: """ - Contains a list of ``coldkeys`` for each neuron in the Bittensor network. - - Coldkeys are similar to hotkeys but are typically used for more secure, offline activities such as storing assets or offline signing of transactions. They are an important aspect of a neuron's security, providing an additional layer of protection for sensitive operations and assets. + Contains a list of ``coldkeys`` for each neuron in the Bittensor network. + + Coldkeys are similar to hotkeys but are typically used for more secure, offline activities such as storing assets or offline signing of transactions. They are an important aspect of a neuron's security, providing an additional layer of protection for sensitive operations and assets. Returns: List[str]: A list of coldkeys, each string representing the coldkey of a neuron. These keys play a vital role in the secure management of assets and sensitive operations within the network. @@ -328,7 +328,7 @@ def __str__(self) -> str: Example: When printing the metagraph object or using it in a string context, this method is automatically invoked:: - + print(metagraph) # Output: "metagraph(netuid:1, n:100, block:500, network:finney)" """ return "metagraph(netuid:{}, n:{}, block:{}, network:{})".format( @@ -345,7 +345,7 @@ def __repr__(self) -> str: Example: The :func:`__repr__` output can be used in debugging to get a clear and concise description of the metagraph:: - + metagraph_repr = repr(metagraph) print(metagraph_repr) # Output mirrors that of __str__ """ @@ -360,7 +360,7 @@ def metadata(self) -> dict: Returns: dict: A dictionary containing essential metadata about the metagraph, including: - + - ``netuid``: The unique identifier for the network. - ``n``: The total number of neurons in the network. - ``block``: The current block number in the network's blockchain. @@ -382,8 +382,8 @@ def __init__( self, netuid: int, network: str = "finney", lite: bool = True, sync: bool = True ) -> "metagraph": """ - Initializes a new instance of the metagraph object, setting up the basic structure and parameters based on the provided arguments. - + Initializes a new instance of the metagraph object, setting up the basic structure and parameters based on the provided arguments. + This method is the entry point for creating a metagraph object, which is a central component in representing the state of the Bittensor network. @@ -395,7 +395,7 @@ def __init__( Example: Initializing a metagraph object for the Bittensor network with a specific network UID:: - + metagraph = metagraph(netuid=123, network="finney", lite=True, sync=True) """ super(metagraph, self).__init__() @@ -484,19 +484,19 @@ def sync( Example: Sync the metagraph with the latest block from the subtensor, using the lite version for efficiency:: - + metagraph.sync(subtensor=subtensor) Sync with a specific block number for detailed analysis:: - + metagraph.sync(block=12345, lite=False, subtensor=subtensor) - NOTE: + NOTE: If attempting to access data beyond the previous 300 blocks, you **must** use the ``archive`` network for subtensor. Light nodes are configured only to store the previous 300 blocks if connecting to finney or test networks. For example:: - + subtensor = bittensor.subtensor(network='archive') """ # Initialize subtensor @@ -514,8 +514,8 @@ def sync( def _initialize_subtensor(self, subtensor): """ - Initializes the subtensor to be used for syncing the metagraph. - + Initializes the subtensor to be used for syncing the metagraph. + This method ensures that a subtensor instance is available and properly set up for data retrieval during the synchronization process. If no subtensor is provided, this method is responsible for creating a new instance of the subtensor, configured according to the current network settings. @@ -528,7 +528,7 @@ def _initialize_subtensor(self, subtensor): Internal Usage: Used internally during the sync process to ensure a valid subtensor instance is available:: - + subtensor = self._initialize_subtensor(subtensor) """ if not subtensor: @@ -538,8 +538,8 @@ def _initialize_subtensor(self, subtensor): def _assign_neurons(self, block, lite, subtensor): """ - Assigns neurons to the metagraph based on the provided block number and the lite flag. - + Assigns neurons to the metagraph based on the provided block number and the lite flag. + This method is responsible for fetching and setting the neuron data in the metagraph, which includes neuron attributes like UID, stake, trust, and other relevant information. Args: @@ -549,7 +549,7 @@ def _assign_neurons(self, block, lite, subtensor): Internal Usage: Used internally during the sync process to fetch and set neuron data:: - + self._assign_neurons(block, lite, subtensor) """ # TODO: Check and test the conditions for assigning neurons @@ -562,7 +562,7 @@ def _assign_neurons(self, block, lite, subtensor): def _set_metagraph_attributes(self, block, subtensor): """ Sets various attributes of the metagraph based on the latest network data fetched from the subtensor. - + This method updates parameters like the number of neurons, block number, stakes, trusts, ranks, and other neuron-specific information. Args: @@ -571,7 +571,7 @@ def _set_metagraph_attributes(self, block, subtensor): Internal Usage: Used internally during the sync process to update the metagraph's attributes:: - + self._set_metagraph_attributes(block, subtensor) """ # TODO: Check and test the setting of each attribute @@ -637,7 +637,7 @@ def _create_tensor(self, data, dtype) -> torch.nn.Parameter: Internal Usage: Used internally to create tensor parameters for various metagraph attributes:: - + self.stake = self._create_tensor(neuron_stakes, dtype=torch.float32) """ # TODO: Check and test the creation of tensor @@ -652,7 +652,7 @@ def _set_weights_and_bonds(self, subtensor: bittensor.subtensor = None): Internal Usage: Used internally during the sync process to update the weights and bonds of the neurons:: - + self._set_weights_and_bonds(subtensor=subtensor) """ # TODO: Check and test the computation of weights and bonds @@ -681,7 +681,7 @@ def _process_weights_or_bonds(self, data, attribute: str) -> torch.nn.Parameter: Internal Usage: Used internally to process and set weights or bonds for the neurons:: - + self.weights = self._process_weights_or_bonds(raw_weights_data, "weights") """ data_array = [] @@ -730,11 +730,11 @@ def _process_root_weights( Internal Usage: Used internally to process and set root weights for the metagraph:: - + self.root_weights = self._process_root_weights( raw_root_weights_data, "weights", subtensor ) - + """ data_array = [] n_subnets = subtensor.get_total_subnets() @@ -771,17 +771,17 @@ def save(self) -> "metagraph": Example: Save the current state of the metagraph to the default directory:: - + metagraph.save() The saved state can later be loaded to restore or analyze the metagraph's state at this point. If using the default save path:: - + metagraph.load() If using a custom save path:: - + metagraph.load_from_path(dir_path) """ save_directory = get_save_dir(self.network, self.netuid) @@ -808,7 +808,7 @@ def load(self) -> "metagraph": Example: Load the metagraph state from the last saved snapshot in the default directory:: - + metagraph.load() After this operation, the metagraph's parameters and neuron data are restored to their state at the time of the last save in the default directory. @@ -834,10 +834,10 @@ def load_from_path(self, dir_path: str) -> "metagraph": Example: Load the metagraph state from a specific directory:: - + dir_path = "/path/to/saved/metagraph/states" metagraph.load_from_path(dir_path) - + The metagraph is now restored to the state it was in at the time of the latest saved block in the specified directory. Note: diff --git a/bittensor/wallet.py b/bittensor/wallet.py index 2e8481d91f..29a6129ca2 100644 --- a/bittensor/wallet.py +++ b/bittensor/wallet.py @@ -54,8 +54,8 @@ def display_mnemonic_msg(keypair: Keypair, key_type: str): class wallet: """ - The wallet class in the Bittensor framework handles wallet functionality, crucial for participating in the Bittensor network. - + The wallet class in the Bittensor framework handles wallet functionality, crucial for participating in the Bittensor network. + It manages two types of keys: coldkey and hotkey, each serving different purposes in network operations. Each wallet contains a coldkey and a hotkey. The coldkey is the user's primary key for holding stake in their wallet and is the only way that users @@ -86,7 +86,7 @@ class wallet: The wallet class is a fundamental component for users to interact securely with the Bittensor network, facilitating both operational tasks and transactions involving value transfer across the network. Example Usage:: - + # Create a new wallet with default coldkey and hotkey names my_wallet = wallet() @@ -416,7 +416,7 @@ def get_coldkeypub(self, password: str = None) -> "bittensor.Keypair": @property def hotkey(self) -> "bittensor.Keypair": r"""Loads the hotkey from wallet.path/wallet.name/hotkeys/wallet.hotkey or raises an error. - + Returns: hotkey (Keypair): hotkey loaded from config arguments. @@ -431,7 +431,7 @@ def hotkey(self) -> "bittensor.Keypair": @property def coldkey(self) -> "bittensor.Keypair": r"""Loads the hotkey from wallet.path/wallet.name/coldkey or raises an error. - + Returns: coldkey (Keypair): coldkey loaded from config arguments. Raises: @@ -445,7 +445,7 @@ def coldkey(self) -> "bittensor.Keypair": @property def coldkeypub(self) -> "bittensor.Keypair": r"""Loads the coldkeypub from wallet.path/wallet.name/coldkeypub.txt or raises an error. - + Returns: coldkeypub (Keypair): coldkeypub loaded from config arguments. Raises: @@ -464,7 +464,7 @@ def create_coldkey_from_uri( suppress: bool = False, ) -> "wallet": """Creates coldkey from suri string, optionally encrypts it with the user-provided password. - + Args: uri: (str, required): URI string to use i.e., ``/Alice`` or ``/Bob``. @@ -491,7 +491,7 @@ def create_hotkey_from_uri( suppress: bool = False, ) -> "wallet": """Creates hotkey from suri string, optionally encrypts it with the user-provided password. - + Args: uri: (str, required): URI string to use i.e., ``/Alice`` or ``/Bob`` @@ -517,7 +517,7 @@ def new_coldkey( suppress: bool = False, ) -> "wallet": """Creates a new coldkey, optionally encrypts it with the user-provided password and saves to disk. - + Args: n_words: (int, optional): Number of mnemonic words to use. @@ -539,7 +539,7 @@ def create_new_coldkey( suppress: bool = False, ) -> "wallet": """Creates a new coldkey, optionally encrypts it with the user-provided password and saves to disk. - + Args: n_words: (int, optional): Number of mnemonic words to use. @@ -567,7 +567,7 @@ def new_hotkey( suppress: bool = False, ) -> "wallet": """Creates a new hotkey, optionally encrypts it with the user-provided password and saves to disk. - + Args: n_words: (int, optional): Number of mnemonic words to use. @@ -589,7 +589,7 @@ def create_new_hotkey( suppress: bool = False, ) -> "wallet": """Creates a new hotkey, optionally encrypts it with the user-provided password and saves to disk. - + Args: n_words: (int, optional): Number of mnemonic words to use. @@ -616,7 +616,7 @@ def regenerate_coldkeypub( suppress: bool = False, ) -> "wallet": """Regenerates the coldkeypub from the passed ``ss58_address`` or public_key and saves the file. Requires either ``ss58_address`` or public_key to be passed. - + Args: ss58_address: (str, optional): Address as ``ss58`` string. @@ -699,7 +699,7 @@ def regenerate_coldkey( **kwargs, ) -> "wallet": """Regenerates the coldkey from the passed mnemonic or seed, or JSON encrypts it with the user's password and saves the file. - + Args: mnemonic: (Union[list, str], optional): Key mnemonic as list of words or string space separated words. @@ -715,9 +715,9 @@ def regenerate_coldkey( wallet (bittensor.wallet): This object with newly created coldkey. - Note: + Note: Uses priority order: ``mnemonic > seed > json``. - + """ if len(kwargs) == 0: raise ValueError("Must pass either mnemonic, seed, or json") @@ -807,7 +807,7 @@ def regenerate_hotkey( **kwargs, ) -> "wallet": """Regenerates the hotkey from passed mnemonic or seed, encrypts it with the user's password and saves the file. - + Args: mnemonic: (Union[list, str], optional): Key mnemonic as list of words or string space separated words. diff --git a/contrib/CONTRIBUTING.md b/contrib/CONTRIBUTING.md index 628c52614a..443f6d2dc6 100644 --- a/contrib/CONTRIBUTING.md +++ b/contrib/CONTRIBUTING.md @@ -35,7 +35,7 @@ Bittensor is still in the Alpha stages, and as such you will likely run into som Additionally, note that the core implementation of Bittensor consists of two separate repositories: [The core Bittensor code](https://github.com/opentensor/bittensor) and the Bittensor Blockchain [subtensor](https://github.com/opentensor/subtensor). -Supplemental, yet necessary repositories are [openvalidators](https://github.com/opentensor/validators) and [openminers](https://github.com/opentensor/miners) which contain Bittensor Validators and Miners (respectively) designed by the OpenTensor Foundation team and open-sourced for the community to use. +Supplemental repository for the Bittensor subnet template can be found [here](https://github.com/opentensor/bittensor-subnet-template). This is a great first place to look for getting your hands dirty and started learning and building on Bittensor. See the subnet links [page](https://github.com/opentensor/bittensor-subnet-template/blob/main/subnet_links.json) for a list of all the repositories for the active registered subnets. ## Getting Started New contributors are very welcome and needed. @@ -43,7 +43,8 @@ Reviewing and testing is highly valued and the most effective way you can contri Before you start contributing, familiarize yourself with the Bittensor Core build system and tests. Refer to the documentation in the repository on how to build Bittensor core and how to run the unit tests, functional tests. -There are many open issues of varying difficulty waiting to be fixed. If you're looking for somewhere to start contributing, check out the [good first issue](https://github.com/opentensor/bittensor/labels/good%20first%20issue) list or changes that are up for grabs. Some of them might no longer be applicable. So if you are interested, but unsure, you might want to leave a comment on the issue first. +There are many open issues of varying difficulty waiting to be fixed. If you're looking for somewhere to start contributing, check out the [good first issue](https://github.com/opentensor/bittensor/labels/good%20first%20issue) list or changes that are up for grabs. Some of them might no longer be applicable. So if you are interested, but unsure, you might want to leave a comment on the issue first. Also peruse the [issues](https://github.com/opentensor/bittensor/issues) tab for all open issues. + ### Good First Issue Label The purpose of the good first issue label is to highlight which issues are suitable for a new contributor without a deep understanding of the codebase. @@ -67,10 +68,9 @@ And also here. ## How Can I Contribute? -You can contribute to Bittensor in one of three main ways (as well as many others): +You can contribute to Bittensor in one of two main ways (as well as many others): 1. [Bug](#reporting-bugs) reporting and fixes 2. New features and Bittensor [enhancements](#suggesting-enhancements) -3. [Documentation](https://github.com/opentensor/docs) fixes and updates > Please follow the Bittensor [style guide](./STYLE.md) regardless of your contribution type. @@ -100,6 +100,7 @@ If you're looking to contribute to Bittensor but unsure where to start, please j Patchsets and enhancements should always be focused. A pull request could add a feature, fix a bug, or refactor code, but it should not contain a mixture of these. Please also avoid 'super' pull requests which attempt to do too much, are overly large, or overly complex as this makes review difficult. Specifically, pull requests must adhere to the following criteria: +- **Must** branch off from `staging`. Make sure that all your PRs are using `staging` branch as a base or will be closed. - Contain fewer than 50 files. PRs with more than 50 files will be closed. - Use the specific [template](./.github/pull_request_template.md) appropriate to your contribution. - If a PR introduces a new feature, it *must* include corresponding tests.