feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2883
Closed
loom-agent wants to merge 2 commits into
Closed
feat(subtensor): split InsufficientBalance into TAO and Alpha variants#2883loom-agent wants to merge 2 commits into
loom-agent wants to merge 2 commits into
Conversation
|
@loom-agent is attempting to deploy a commit to the RaoFoundation Team on Vercel. A member of the Team first needs to authorize it. |
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.
b21ce48 to
819986b
Compare
unarbos
approved these changes
Jul 14, 2026
Contributor
|
Superseded by #2898 (v431 release): these changes were reviewed and integrated there. |
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 still surface as code 12).Revision notes (addressing code-review feedback)
This update rebases the branch onto current
mainand collapses it into a single self-contained commit to address the review blockers:InsufficientAlphaBalanceis defined inpallets/subtensor/src/macros/errors.rs(appended, so no existing error index shifts) and is wired into the Alpha balance guard ofBalanceOps::decrease_stake(pallets/subtensor/src/lib.rs).decrease_stakeis a trait method ofsubtensor_runtime_common::BalanceOps, so the regression test brings the trait into scope (use subtensor_runtime_common::BalanceOps;) to call it. The earlier multi-commit history had a spec-only commit with no source diff, which made the change look absent when viewed one commit at a time; the single commit removes that ambiguity.spec_versionis now a single clean bump. Currentmainis atspec_version: 430; this commit sets it to431(main+ 1). The earlier 429->430 then 430->431 two-commit churn is gone.transaction_versionis intentionally not bumped. This repo keepstransaction_version: 1across every spec bump (it is still1atspec_version: 430). Renaming a dispatch error in place (index preserved) and appending a new variant change pallet metadata, which is covered by thespec_versionbump, but do not change extrinsic/call encoding, sotransaction_versionis left unchanged per repo convention and Substrate semantics.InsufficientBalanceis renamed in place toInsufficientTaoBalance. The numeric index is preserved, so index-based clients are unaffected; only string-based metadata consumers must handle the new names.spec_versionis bumped accordingly.#[allow(deprecated)]prerequisite commit was dropped: currentmainalready annotates the legacy-migration tests that touch the deprecatedLastTxBlockDelegateTakestorage, so it is no longer needed on this branch.Description
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 (issue #1960). This splits it: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); other pallets' ownInsufficientBalance(swap, crowdloan) still maps there too, so ink!/EVM contracts are unaffected.Related Issue(s)
pallets/subtensor/src/macros/errors.rs:InsufficientBalanceto two type of errors. #1960NotEnoughBalanceToPayFee/NotEnoughBalanceToPayStakenames.Type of Change
Breaking Change
The pallet error variant
InsufficientBalanceis renamed toInsufficientTaoBalanceand a newInsufficientAlphaBalancevariant is appended (prescribed by #1960). The numeric index of the renamed variant is unchanged, but string consumers of the metadata (e.g. SDKs matching the error name) must handle the new names.spec_versionis bumped to 431. The chain-extension ABI is unchanged.Testing
Verified statically against current
main:InsufficientAlphaBalanceis defined inmacros/errors.rs;decrease_stakereturns it from the Alpha guard (lib.rs), reached via theBalanceOpstrait the test imports; the chain-extension maps both new names to ABI code 12.mainwith no conflicts in the touched files; the only differences versus the prior build are the dropped obsolete lint prerequisite (already present onmain) and the consolidated singlespec_versionbump.Runtime gate output for this exact HEAD was not obtainable in this environment: the build VM was unreachable during this revision and fork-PR CI does not auto-run Actions without maintainer approval (0 check-runs at the time of writing). The project
check-rustworkflow (cargo fmt --check,cargo clippy --workspace --all-targets --all-features -- -D warnings,cargo test -p pallet-subtensor --all-features) is the authoritative gate; the prior build of this identical pallet logic passedfmt,clippy, and1349 passed; 0 failed; 9 ignored. I will address any CI failures as soon as the workflow runs.Checklist
./scripts/fix_rust.shto ensure my code is formatted and linted correctly (equivalent read-only fmt/clippy gates were run on the prior identical build; CI will confirm for this HEAD)Additional Notes
OutputABI (a new code instead of collapsing both to code 12) is a larger ABI decision left to the team.