Skip to content

SDKv10 #3029

@basfroman

Description

@basfroman

PRs:

Adds:

Full progress in SDKv10/MIGRATION.md


Plan

Extrinsics and related

  1. ✅ Standardize parameter order across all extrinsics and related calls. Pass extrinsic-specific arguments first (e.g., wallet, hotkey, netuid, amount), followed by optional general flags (e.g., wait_for_inclusion, wait_for_finalization)
  2. ✅ Set wait_for_inclusion and wait_for_finalization to True by default in extrinsics and their related calls. Then we will guarantee the correct/expected extrinsic call response is consistent with the chain response. If the user changes those values, then it is the user's responsibility.
  3. ✅ Make the internal logic of extrinsics the same. There are extrinsics that are slightly different in implementation.
  4. Since SDK is not a responsible tool, try to remove all calculations inside extrinsics that do not affect the result, but are only used in logging. Actually, this should be applied not to extrinsics only but for all codebase. Just improved regarding usage.
  5. ✅ Remove unstake_all parameter from unstake_extrinsic since we have unstake_all_extrinsicwhich is calles another subtensor function.
  6. unstake and unstake_multiple extrinsics should have safe_unstaking parameters instead of safe_staking.
  7. ✅ Remove _do* extrinsic calls and combine them with extrinsic logic.
  8. subtensor.get_transfer_fee calls extrinsic inside the subtensor module. Actually the method could be updated by using bittensor.core.extrinsics.utils.get_extrinsic_fee. (get_transfer_fee isn't get_extrinsic_fee)

Subtensor

  1. ✅ In the synchronous Subtensor class, the get_owned_hotkeys method includes a reuse_block parameter that is inconsistent with other methods. Either remove this parameter from get_owned_hotkeys, or add it to all other methods that directly call self.substrate.* to maintain a consistent interface.
  2. ✅ In all methods where we sim_swap is called, remove unused arguments. Consider combining all methods using sim_swap into one common one.
  3. ✅ Delete deprecated get_current_weight_commit_info and get_current_weight_commit_info_v2. Rename get_timelocked_weight_commits to get_current_weight_commit_info.
  4. ✅ Remove references like get_stake_info_for_coldkey = get_stake_for_coldkey.
  5. ✅ Reconsider some methods naming across the entire subtensor module.
  6. Add hotkey_ss58 parameter to get_liquidity_list method. One wallet can have many HKs. Currently, the mentioned method uses default HK only. wrong idea
  7. ✅ apply correct logic if subtensor got lov_verbose=True -> set_trace level for btloggin
  8. ✅ Should the next functions move to subtensor as methods? They have exactly the same behavior as subtensor methods.
    • get_metadata
    • get_last_bonds_reset
  9. ✅ Apply SimSwap logic to calculate any stake operation fees (this is not an extrinsic fee)

Metagraph

  1. ✅ Remove verbose archival node warnings for blocks older than 300. Some users complained about many messages for them.
  2. ✅ Reconsider entire metagraph module logic.

Balance

  1. ✅ In bittensor.utils.balance._check_currencies raise the error instead of warnings.warn.
  2. ✅ In bittensor.utils.balance.check_and_convert_to_balance raise the error instead of warnings.warn. This may
    seem like a harsh decision at first, but ultimately we will push the community to use Balance and there will be fewer
    errors in their calculations. Confusion with TAO and Alpha in calculations and display/printing/logging will be
    eliminated.

Common things

  1. ✅ Reduce the amount of logging.info or transfer part of logging.info to logging.debug

  2. ✅ To be consistent across all SDK regarding local environment variables name:

    • remove BT_CHAIN_ENDPOINT (settings.py :line 124) and use BT_SUBTENSOR_CHAIN_ENDPOINT instead of that.
      rename this variable in documentation.
    • rename local env variableBT_NETWORK to BT_SUBTENSOR_NETWORK
  3. Move bittensor.utils.get_transfer_fn_params to bittensor.core.extrinsics.utils. it's on the right place.

  4. ✅ Common refactoring (improve type annotations, etc)

  5. Rename non-/fast-blocks to non-/fast-runtime in related places to be consistent with subtensor repo. Related with testing, subtensor scripts, documentation. done across many PRs.

  6. ✅ To be consistent throughout the SDK:

    • hotkey, coldkey, hotkeypub, and coldkeypub are keypairs
    • hotkey_ss58, coldkey_ss58, hotkeypub_ss58, and coldkeypub_ss58 are SS58 addresses of keypair.
  7. ✅ Replace Arguments with Parameters. Matches Python rules. Improve docstrings for writing MСP server.

  8. ✅ Remove all type annotations for parameters in docstrings.

  9. ✅ Remove all logic related to CRv3 as it will be removed from the chain next week.

    • CRv3 extrinsics
    • CRv3 logic related subtensor's calls
  10. ✅ Revise bittensor/utils/easy_imports.py module to remove deprecated backwards compatibility objects. Use this module as a functionality for exporting existing objects to the package root to keep init.py minimal and simple.

  11. ✅ Remove deprecated bittensor.utils.version.version_checking

  12. ✅ The SDK is dropping support for Python 3.9 starting with this release.

  13. ✅ Remove Default is and Default to in docstrings bc parameters enough.

  14. camfairchild: TODO, but we should have a grab_metadata if we don't already. Maybe don't decode, but can have a call that removes the Raw prefix, and another just doing grab_metadata_raw (no decoding). get_commitment_metadata added.

  15. ✅ Resolve an issue where a script using the SDK receives the --config or any other CLI parameters used in the SDK. Disable configuration processing. Use default values ​​instead.

  16. ✅ Find and process all TODOs across the entire code base. If in doubt, discuss each one with the team separately. SDK has 29 TODOs.

New features

  1. ✅ Unify extrinsic return values by introducing an ExtrinsicResponse class. Extrinsics currently return either a boolean or a tuple.

    Purpose:

    • Ease of processing.
    • This class should contain success, message, and optionally data.
    • Opportunity to expand the content of the extrinsic's response at any time upon community request or based on new technical requirements any time.
  2. ✅ Add bittensor.utils.hex_to_ss58 function. SDK still doesn't have it. (Probably inner import from scalecodec import ss58_encode, ss58_decode)

  3. ✅ Implement Sub-subnets logic. Subtensor PR Subsubnets subtensor#1984

  4. ✅ Implement classes for BlockInfo objects that will contain the following fields:

    • number (int)
    • hash (str)
    • timestamp (datetime)
    • header (dict)
    • extrinsics (list)
    • block_explorer (link to tao.app)

    This implementation has been repeatedly requested by the community in the past.

  5. ✅ Added bittensor.core.extrinsics.params subpackage. This package will contain all extrinsic parameters. Due to
    the duplication of extrinsics (async and sync implementations), it's easy to miss the sequence of changes. This also
    makes it easier to obtain the parameter list.

  6. Implement Crowdloan logic. Issue: Integrate Crowdloan #3017

Testing

  1. ✅ When running tests via Docker, ensure no lingering processes occupy required ports before launch.

  2. Improve failed test reporting from GH Actions to the Docker channel (e.g., clearer messages, formatting).

  3. ✅ Write a configurable test harness class for tests that will accept arguments and immediately:

    • create a subnet
    • activate a subnet (if the argument is passed as True)
    • register neurons (use wallets as arguments)
    • set the necessary hyperparameters (tempo, etc. if the argument are passed)
      Will greatly simplify tests.
  4. ✅ Add an async test versions. This will help us greatly improve the asynchronous implementation of Subtensors and Extrinsics.

Sub-issues

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions