Skip to content

feat: Add batch extrinsic support to reduce transaction fees#863

Open
bittoby wants to merge 1 commit intoopentensor:stagingfrom
bittoby:feat/batch-extrinsics
Open

feat: Add batch extrinsic support to reduce transaction fees#863
bittoby wants to merge 1 commit intoopentensor:stagingfrom
bittoby:feat/batch-extrinsics

Conversation

@bittoby
Copy link

@bittoby bittoby commented Mar 19, 2026

Problem

Every stake/unstake operation currently submits a separate on-chain extrinsic. A user staking to 3 netuids across 2 hotkeys pays 6 individual transaction fees. This adds up fast.

Solution

Wrap multiple calls into a single Utility.batch_all transaction so the user only pays one fee regardless of how many operations they're performing.

The core change is a new sign_and_send_batch_extrinsic() method on SubtensorInterface that composes a batch_all call and delegates to the existing sign_and_send_extrinsic. This means proxy, MEV protection, nonce, era, and signing logic are all reused - no duplication.

Batching kicks in automatically when there are 2+ operations. Single operations go through the original path unchanged.

What's batched

  • btcli stake add - multiple netuid/hotkey stake operations
  • btcli stake remove - multiple netuid/hotkey unstake operations
  • btcli stake remove --all - unstake-all across multiple hotkeys

Notes

Files changed

  • subtensor_interface.py - new sign_and_send_batch_extrinsic() method
  • stake/add.py - batch path for multi-operation staking
  • stake/remove.py - batch path for multi-operation unstaking + unstake-all
  • tests/unit_tests/test_batching.py - 7 unit tests covering the batch method

Test plan

  • All 77 unit tests pass
  • ruff format and lint clean (no new issues)

Fixes: #567

@bittoby
Copy link
Author

bittoby commented Mar 19, 2026

@thewhaleking could you review my PR? Welcome to any feedbacks.
Thank you

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