Skip to content

feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2943

Open
loom-agent wants to merge 3 commits into
RaoFoundation:mainfrom
loom-agent:fix/split-insufficient-balance-1960
Open

feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2943
loom-agent wants to merge 3 commits into
RaoFoundation:mainfrom
loom-agent:fix/split-insufficient-balance-1960

Conversation

@loom-agent

Copy link
Copy Markdown
Contributor

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

  • Changed the shared InsufficientBalance dispatch error into two distinct errors, InsufficientTaoBalance (TAO) and InsufficientAlphaBalance (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::InsufficientBalance was 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.rs defined one shared InsufficientBalance variant. All TAO-side call sites in coinbase/tao.rs and the Alpha-side call site in BalanceOps::decrease_stake routed through the same error, losing the asset distinction.

The fix

  • The existing variant is renamed in place to InsufficientTaoBalance (its enum position is preserved, so the numeric indices of the variants after it do not shift).
  • A new InsufficientAlphaBalance variant is appended for the one Alpha-balance call site, BalanceOps::decrease_stake (pallets/subtensor/src/lib.rs).
  • The four TAO-side call sites in coinbase/tao.rs now use InsufficientTaoBalance.
  • The chain-extension error mapping (chain-extensions/src/types.rs) maps both new names to the existing Output::InsufficientBalance ABI code (12).
  • spec_version bumped from 429 to 430.

Notes

Testing

Closes #1960

loom-agent and others added 2 commits July 13, 2026 18:13
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.
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

@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
loom-agent force-pushed the fix/split-insufficient-balance-1960 branch from 1278085 to 4e0d466 Compare July 16, 2026 21:55
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.

Separate pallets/subtensor/src/macros/errors.rs:InsufficientBalance to two type of errors.

2 participants