Skip to content

[v10] Add Proxy Pallet Support#3140

Merged
basfroman merged 65 commits intoSDKv10from
feat/roman/proxy
Nov 13, 2025
Merged

[v10] Add Proxy Pallet Support#3140
basfroman merged 65 commits intoSDKv10from
feat/roman/proxy

Conversation

@basfroman
Copy link
Collaborator

@basfroman basfroman commented Nov 10, 2025

This PR implements comprehensive support for the Proxy pallet in the Bittensor SDK, enabling users to manage proxy relationships, announcements, and pure proxy accounts on the Subtensor network.


Context

The Proxy pallet allows accounts to delegate permissions to other accounts (proxies) to execute calls on their behalf. This implementation provides both synchronous and asynchronous interfaces for all Proxy pallet operations, following the established SDK patterns and architecture.

New Extrinsics

  • add_proxy_extrinsic - Adds a proxy relationship between accounts
  • remove_proxy_extrinsic - Removes a specific proxy relationship
  • remove_proxies_extrinsic - Removes all proxy relationships for an account in a single call
  • create_pure_proxy_extrinsic - Creates a keyless pure proxy account
  • kill_pure_proxy_extrinsic - Removes a pure proxy account (automatically handles execution via proxy)
  • proxy_extrinsic - Executes a call on behalf of the real account through a proxy
  • proxy_announced_extrinsic - Executes a previously announced call through a proxy
  • announce_extrinsic - Announces a future call that will be executed through a proxy
  • reject_announcement_extrinsic - Rejects an announcement made by a proxy delegate
  • remove_announcement_extrinsic - Removes an announcement made by a proxy account
  • poke_deposit_extrinsic - Adjusts deposits for proxies and announcements based on current values

Subtensor methods

  • get_proxies(block=None) - Retrieves all proxy relationships from the chain (returns dict mapping real accounts to their proxy lists)
  • get_proxies_for_real_account(real_account_ss58, block=None) - Returns proxies and deposit for a specific real account
  • get_proxy_announcement(delegate_account_ss58, block=None) - Retrieves proxy announcements for a specific delegate account
  • get_proxy_announcements(block=None) - Retrieves all proxy announcements from the chain
  • get_proxy_constants(constants=None, as_dict=False, block=None) - Fetches runtime configuration constants from the Proxy pallet

All extrinsic functions are exposed as convenient wrapper methods in the Subtensor class:

  • add_proxy
  • remove_proxy
  • remove_proxies
  • create_pure_proxy
  • kill_pure_proxy
  • proxy
  • proxy_announced
  • announce_proxy
  • reject_proxy_announcement
  • remove_proxy_announcement
  • poke_deposit

New CallBuilder class

Proxy CallBuilder (bittensor/core/extrinsics/pallets/proxy.py)

A new Proxy class extends CallBuilder to create GenericCall objects for all Proxy pallet functions:

  • add_proxy(delegate, proxy_type, delay)
  • remove_proxy(delegate, proxy_type, delay)
  • remove_proxies()
  • create_pure(proxy_type, delay, index)
  • kill_pure(spawner, proxy_type, index, height, ext_index)
  • proxy(real, force_proxy_type, call)
  • announce(real, call_hash)
  • proxy_announced(delegate, real, force_proxy_type, call)
  • reject_announcement(delegate, call_hash)
  • remove_announcement(real, call_hash)
  • poke_deposit()

Chain Data Classes

  • ProxyType
  • ProxyInfo
  • ProxyAnnouncementInfo
  • ProxyConstants

Testing

Comprehensive Test Coverage

  • added e2e tests
  • added unit tests
  • added new type of tests - consistency tests

Usage Examples

Query Methods

Get all proxies in the network

all_proxies = subtensor.proxies.get_proxies()

Get proxies for a specific account

proxies, deposit = subtensor.proxies.get_proxies_for_real_account(
    real_account_ss58=wallet.coldkey.ss58_address
)

Get proxy announcements for a delegate

announcements = subtensor.proxies.get_proxy_announcement(
    delegate_account_ss58=delegate_wallet.coldkey.ss58_address
)

Get all proxy announcements in the network

all_announcements = subtensor.proxies.get_proxy_announcements()

Get proxy constants

constants = subtensor.proxies.get_proxy_constants()

Get specific constants as dictionary

constants_dict = subtensor.proxies.get_proxy_constants(
    constants=["MaxProxies", "ProxyDepositBase"],
    as_dict=True
)

Proxy Management

Add a proxy relationship

response = subtensor.proxies.add_proxy(
    wallet=wallet,
    delegate_ss58=delegate_wallet.coldkey.ss58_address,
    proxy_type=ProxyType.Staking,
    delay=100
)

Remove a specific proxy

response = subtensor.proxies.remove_proxy(
    wallet=wallet,
    delegate_ss58=delegate_wallet.coldkey.ss58_address,
    proxy_type=ProxyType.Staking,
    delay=100
)

Remove all proxies at once

response = subtensor.proxies.remove_proxies(wallet=wallet)

Pure Proxy Operations

Create a pure proxy account

response = subtensor.proxies.create_pure_proxy(
    wallet=wallet,
    proxy_type=ProxyType.Any,
    delay=0,
    index=0
)
pure_account = response.data["pure_account"]
spawner = response.data["spawner"]
height = response.data["height"]
ext_index = response.data["ext_index"]

Kill the pure proxy

response = subtensor.proxies.kill_pure_proxy(
    wallet=wallet,
    pure_proxy_ss58=pure_account,
    spawner=spawner,
    proxy_type=ProxyType.Any,
    index=0,
    height=height,
    ext_index=ext_index
)

Executing Calls Through Proxy

Execute a transfer call through proxy

from bittensor.core.extrinsics.pallets import Balances

transfer_call = Balances(subtensor).transfer_keep_alive(
    dest="5DE...",
    value=1000000000
)

response = subtensor.proxies.proxy(
    wallet=delegate_wallet,
    real_account_ss58=wallet.coldkey.ss58_address,
    force_proxy_type=ProxyType.Transfer,
    call=transfer_call
)

Announcement Mechanism

Announce a future call

from bittensor.core.extrinsics.pallets import SubtensorModule

register_call = SubtensorModule(subtensor).register_network(
    hotkey=delegate_wallet.hotkey.ss58_address
)
call_hash = "0x" + register_call.call_hash.hex()

response = subtensor.proxies.announce_proxy(
    wallet=delegate_wallet,
    real_account_ss58=wallet.coldkey.ss58_address,
    call_hash=call_hash
)

Execute the announced call (after delay period)

response = subtensor.proxies.proxy_announced(
    wallet=delegate_wallet,
    delegate_ss58=delegate_wallet.coldkey.ss58_address,
    real_account_ss58=wallet.coldkey.ss58_address,
    force_proxy_type=ProxyType.Any,
    call=register_call
)

Managing Announcements

Real account rejects an announcement

response = subtensor.proxies.reject_proxy_announcement(
    wallet=wallet,
    delegate_ss58=delegate_wallet.coldkey.ss58_address,
    call_hash=call_hash
)

Proxy removes its own announcement

response = subtensor.proxies.remove_proxy_announcement(
    wallet=delegate_wallet,
    real_account_ss58=wallet.coldkey.ss58_address,
    call_hash=call_hash
)

Deposit Optimization

Adjust deposits after runtime upgrade or proxy removal

response = subtensor.proxies.poke_deposit(wallet=wallet)

Related links:

@basfroman basfroman mentioned this pull request Nov 10, 2025
@basfroman basfroman requested a review from a team November 10, 2025 23:09
Base automatically changed from feat/roman/create-subtensor-callls-logic to SDKv10 November 10, 2025 23:18
Copy link
Contributor

@thewhaleking thewhaleking left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Only blocking comment is to remove the " НОВЫЙ ПАРАМЕТР" comment.

@basfroman basfroman requested review from a team and thewhaleking November 11, 2025 21:33
@basfroman
Copy link
Collaborator Author

Looks good. Only blocking comment is to remove the " НОВЫЙ ПАРАМЕТР" comment.

Jy was nie veronderstel om my boodskap aan die Vrymesselaars te sien nie.

@basfroman basfroman merged commit 0305156 into SDKv10 Nov 13, 2025
521 of 551 checks passed
@basfroman basfroman deleted the feat/roman/proxy branch November 13, 2025 23:56
This was referenced Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature new feature added

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants