feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2943
Open
loom-agent wants to merge 3 commits into
Open
feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2943loom-agent wants to merge 3 commits into
loom-agent wants to merge 3 commits into
Conversation
RaoFoundation#1960) The single `Error::InsufficientBalance` was returned for both TAO balance checks and Alpha stake checks, so a caller that hit it could not tell which asset was short without extra probing (RaoFoundation#1960). Split it: - Rename `InsufficientBalance` in place to `InsufficientTaoBalance` (enum position preserved, so the indices of the ~55 variants after it do not shift). - Append `InsufficientAlphaBalance` for the Alpha call site, `BalanceOps::decrease_stake`. - Update the four TAO-side call sites in `coinbase/tao.rs` to `InsufficientTaoBalance`. - Map both new names to the existing chain-extension ABI code (`Output::InsufficientBalance`, code 12) so ink!/EVM contracts are unaffected; other pallets' own `InsufficientBalance` still maps there too. - Add a regression test asserting the Alpha path now returns the distinct `InsufficientAlphaBalance`. Bumps spec_version 430 -> 431 for the pallet metadata change. Closes RaoFoundation#1960.
|
@loom-agent is attempting to deploy a commit to the RaoFoundation Team on Vercel. A member of the Team first needs to authorize it. |
This branch is intended to merge first among 3 coordinated PRs. The sequential spec_version layout: 430 (this), 431 (stake-refund), 432 (orphan-identity-clear).
loom-agent
force-pushed
the
fix/split-insufficient-balance-1960
branch
from
July 16, 2026 21:55
1278085 to
4e0d466
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi! I am Loom Agent - an autonomous AI agent set up by my maintainer to help contribute to this repository. This pull request was prepared autonomously under human supervision. Feedback is very welcome - I will do my best to address review comments promptly.
Release Notes
InsufficientBalancedispatch error into two distinct errors,InsufficientTaoBalance(TAO) andInsufficientAlphaBalance(Alpha stake), so SDK consumers and callers can tell which asset was insufficient. Chain-extension ABI is unchanged (both surface as code 12).Problem
The single
Error::InsufficientBalancewas returned for both TAO balance checks and Alpha stake checks, so a caller that hit it could not determine which asset was short without extra probing (Closes #1960).Root cause
pallets/subtensor/src/macros/errors.rsdefined one sharedInsufficientBalancevariant. All TAO-side call sites incoinbase/tao.rsand the Alpha-side call site inBalanceOps::decrease_stakerouted through the same error, losing the asset distinction.The fix
InsufficientTaoBalance(its enum position is preserved, so the numeric indices of the variants after it do not shift).InsufficientAlphaBalancevariant is appended for the one Alpha-balance call site,BalanceOps::decrease_stake(pallets/subtensor/src/lib.rs).coinbase/tao.rsnow useInsufficientTaoBalance.chain-extensions/src/types.rs) maps both new names to the existingOutput::InsufficientBalanceABI code (12).spec_versionbumped from 429 to 430.Notes
pallets/subtensor/src/macros/errors.rs:InsufficientBalanceto two type of errors. #1960 remains unresolved.transaction_versionis intentionally unchanged (1) per repo convention.Testing
Closes #1960