Skip to content

feat: Add proxy list, proxy reject, and proxy remove --all#833

Open
MkDev11 wants to merge 11 commits intoopentensor:stagingfrom
MkDev11:feat/proxy-additions-742-v2
Open

feat: Add proxy list, proxy reject, and proxy remove --all#833
MkDev11 wants to merge 11 commits intoopentensor:stagingfrom
MkDev11:feat/proxy-additions-742-v2

Conversation

@MkDev11
Copy link
Contributor

@MkDev11 MkDev11 commented Feb 23, 2026

Description

Closes #742

Adds the missing proxy commands and flag from issue #742 and incorporates feedback from PR #745.

New commands:

  • btcli proxy list — Lists proxies for an account by querying chain storage Proxy.Proxies. Optional --address (defaults to selected wallet). Supports --json-output. Handles empty query result with explicit success/failure in JSON.
  • btcli proxy reject — Rejects a previously announced proxy call via Proxy.reject_announcement. Optional --delegate (defaults to wallet coldkey). Resolves --call-hash from the ProxyAnnouncements table when available and marks the announcement as executed on success (same flow as btcli proxy execute). Implemented as proxy_reject_announced for naming consistency with proxy_execute_announced.

Modified command:

  • btcli proxy remove — Added --all flag to remove every proxy for the account in one call (Proxy.remove_proxies). --all and --delegate are mutually exclusive; one is required.

Changes

  • bittensor_cli/src/commands/proxy.py: Added _parse_proxy_storage, list_proxies, reject_announcement, remove_all_proxies; empty query handling for list; list/tuple delegate decoding for chain data.
  • bittensor_cli/cli.py: Registered proxy list and proxy reject (handler proxy_reject_announced); extended proxy_remove with --all, validation, and branching to remove_all_proxies vs remove_proxy; proxy_reject_announced integrates with ProxyAnnouncements (resolve call_hash, mark_as_executed on success).
  • tests/unit_tests/test_cli.py: Unit tests for storage parsing (empty, one row, delegate-as-list), proxy_remove (mutual exclusivity, require delegate or all, --all vs delegate), proxy_list (with/without address), proxy_reject_announced (reject_announcement call, mark_as_executed when matched from DB).
  • tests/e2e_tests/test_proxy.py: E2E tests test_proxy_list_after_add and test_proxy_remove_all (require local chain).

Testing

  • Unit: pytest tests/unit_tests/test_cli.py -v -k "proxy or parse_proxy" — 26 passed.
  • Lint: ruff check bittensor_cli/src/commands/proxy.py bittensor_cli/cli.py tests/unit_tests/test_cli.py tests/e2e_tests/test_proxy.py — all checks passed.
  • E2E (with local chain): pytest tests/e2e_tests/test_proxy.py -v -k "list_after_add or remove_all".

Checklist

  • Code formatted with ruff; tests pass.
  • Branch off staging (or target staging when opening the PR).
  • New feature includes tests (unit + e2e).
  • PR description explains what changes do and which issue is resolved.

- btcli proxy list: query Proxy.Proxies storage, optional --address, --json-output
- btcli proxy reject: Proxy.reject_announcement; optional --delegate; resolves call_hash from ProxyAnnouncements, marks as executed on success (proxy_reject_announced)
- btcli proxy remove --all: Proxy.remove_proxies; mutually exclusive with --delegate

Addresses PR opentensor#745 feedback: top-level imports, empty query handling, naming (proxy_reject_announced), ProxyAnnouncements flow for reject.
- Respect DISK_CACHE=0 in SubtensorInterface (use cache only when config
  and env allow)
- Force use_disk_cache=False in CLI initialize_chain when DISK_CACHE=0
- Set DISK_CACHE=0 in e2e exec_command env so all e2e CLI runs skip cache

Fixes coldkey_swap and proxy e2e failures from missing cache tables.
test_coldkey_swap_dispute was missing --no-mev-protection on the
subnets create call, unlike test_coldkey_swap_with_stake which had it.
MEV protection fails on the local chain, causing subnets create to
return success: False.
…roxy entries

Two issues causing proxy e2e test failures:

1. proxy_remove used Options.proxy_type which has prompt=True, causing
   Typer to prompt for proxy_type even with --all (before function body
   runs). Changed to a non-prompting typer.Option for proxy_remove.

2. _parse_proxy_storage only handled list/tuple proxy items but
   async_substrate_interface decodes Proxy.Proxies entries as dicts.
   Added dict handling and direct SS58 string passthrough.
@thewhaleking thewhaleking requested a review from a team February 23, 2026 15:51
Substrate returns proxy storage with extra nesting:
- Items wrapped in single-element tuples: (dict,) instead of dict
- Delegate as nested tuple: ((bytes...),) instead of (bytes...)
- Proxy type as dict: {'Any': ()} instead of 'Any'

Adds unwrapping logic and dict proxy_type extraction.
@MkDev11 MkDev11 changed the base branch from staging to main February 23, 2026 17:12
@MkDev11 MkDev11 changed the base branch from main to staging February 23, 2026 17:13
@MkDev11
Copy link
Contributor Author

MkDev11 commented Feb 23, 2026

@thewhaleking could you please review the PR and let me know your feedback?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant