-
Notifications
You must be signed in to change notification settings - Fork 67
feat: batching extrinsic for saving fees #787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
okay it was because of #778 , pushed a fix |
d33ac51 to
570670f
Compare
|
@basfroman were you able to check my pr? FYI - am not mining gittensor anymore |
basfroman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for contribution!
What I like:
- good idea and motivation
- backward compatibility
- integration with existing features
- parallel retrieval of balances
But this logic:
- has critical bugs
- have to be up-to-date with staging (as fas as I can see, currently it doesn't)
- should have more understandable and detailed docstrings for the new functions
| ) | ||
| if not mev_success: | ||
| status.stop() | ||
| print_error.print( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print_error is a function and don't have print parameter.
| ) | ||
| if not mev_success: | ||
| status.stop() | ||
| print_error.print( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
print_error is a function and don't have print parameter.
| console.print( | ||
| f"[yellow][DEBUG][/yellow] Operation {idx} (netuid={op['netuid']}): assigning ext_id={batch_ext_id}" | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually show debug info in verbose mode.
| coldkey_ss58 = proxy or wallet.coldkeypub.ss58_address | ||
|
|
||
| # Capture initial balance before operations | ||
| initial_balance_all = await subtensor.get_balance(coldkey_ss58) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variable 'initial_balance_all' value is not used
| try: | ||
| # Extract batch execution results from receipt | ||
| # The receipt should contain information about which calls succeeded/failed | ||
| for i, call in enumerate(calls): | ||
| call_results.append( | ||
| { | ||
| "index": i, | ||
| "call": call, | ||
| "success": True, # Will be updated if we can parse receipt | ||
| } | ||
| ) | ||
| except Exception: | ||
| # If we can't parse results, assume all succeeded if batch succeeded | ||
| for i, call in enumerate(calls): | ||
| call_results.append( | ||
| { | ||
| "index": i, | ||
| "call": call, | ||
| "success": success, | ||
| } | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this try/except block is pointless - the code in the try block will never raise an exception (a simple loop with append). The comment Will be updated if we can parse receipt indicates an incomplete implementation.
Pls either implement parsing of events from the receipt to determine the success of individual calls, or remove the dead code
| proxy=proxy, | ||
| nonce=next_nonce, | ||
| mev_protection=mev_protection, | ||
| batch_type="batch_all", # Use batch_all to execute all even if some fail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a misunderstanding. batch_all means: all calls will be executed, but if at least one fails, all will be rolled back. it doesn't mean execute all even if some fail.
If you need to execute all regardless of errors you need force_batch (which is in the signature, but not used).
Pls, clarify the requirements and correct the comments/logic
| if batch_success and batch_receipt: | ||
| if mev_protection: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend you to create something like handle_mev_protection function with proper parameters to handle the result. You broke DRY rule.
Currently, you have 3 exact the same code section in stake_add, unstake, and unstake_all calls.
| batch_success, | ||
| batch_err_msg, | ||
| batch_receipt, | ||
| call_results, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this call_results never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The e2e tests doesn't verify:
- the correctness of balances after transactions
- that the stake is actually added/removed
- behavior in case of errors


This PR implements comprehensive batching support for CLI commands that can submit multiple extrinsic calls, significantly reducing transaction fees for users. This closes GitHub issue #567.
Core Changes:
New Batching Interface (subtensor_interface.py)
Stake Add Command Refactoring (stake/add.py)
Stake Remove Command Refactoring (stake/remove.py)
CLI Validation Updates (cli.py)
Technical Details:
Benefits:
Tests for batching:
Closes #567