Delegate set claim type
Summary
This PR introduces a new Delegated root claim type and a per-subnet validator claim configuration so that stakers can opt into inheriting their validator’s claim behavior (Swap or Keep) on each subnet. It also fixes accounting by recording TAO outflow when alpha is swapped during root claims.
What’s changing
1. New Delegated claim type
-
Extend
RootClaimTypeEnum:pub enum RootClaimTypeEnum { Swap, Keep, /// Delegate choice to subnet. Delegated, } -
Change the default coldkey root claim type to
Delegated:#[pallet::type_value] pub fn DefaultRootClaimType<T: Config>() -> RootClaimTypeEnum { RootClaimTypeEnum::Delegated }New stakers will, by default, delegate their claim behavior to the validator on each subnet.
2. Per-subnet validator claim configuration
-
Introduce a new storage map for validator claim type:
#[pallet::storage] // MAP (hotkey, netuid) -> RootClaimTypeEnum pub type ValidatorClaimType<T: Config> = StorageDoubleMap< _, Blake2_128Concat, T::AccountId, Identity, NetUid, RootClaimTypeEnum, ValueQuery, DefaultRootClaimType<T>, >; -
New extrinsic to let validators configure claim behavior on a per-subnet basis:
#[pallet::call_index(125)] pub fn set_validator_claim_type( origin: OriginFor<T>, hotkey: T::AccountId, netuid: NetUid, new_claim_type: RootClaimTypeEnum, ) -> DispatchResult-
Only the coldkey that owns
hotkeymay call this (enforced bycoldkey_owns_hotkey). -
new_claim_typeis restricted toSwaporKeep. Attempting to setDelegatedresults in:Error::<T>::InvalidRootClaimType -
Emits:
Event::ValidatorClaimTypeSet { hotkey, root_claim_type }
-
3. Claim resolution logic for Delegated
-
In
claim_root_for_hotkey_on_subnet, theroot_claim_typeparameter is now mutable and we resolveDelegatedbefore processing:if root_claim_type == RootClaimTypeEnum::Delegated { root_claim_type = ValidatorClaimType::<T>::get(hotkey, netuid); } -
A
Delegatedarm is added to the match as a safety net and should never be hit after resolution; it logs an error and returns early.
This means:
- If a staker’s
RootClaimTypeisDelegated, they will use the subnet validator’s configuredSwap/Keepchoice for that hotkey + subnet. - If a staker explicitly sets
SwaporKeep, that explicit choice is respected regardless of the validator setting.
4. TAO outflow accounting for swaps
-
When
root_claim_type == Swap, we now record TAO outflow after a successful swap:Self::record_tao_outflow(netuid, owed_tao.amount_paid_out.into());This ensures subnet TAO outflow metrics correctly reflect alpha→TAO swaps performed during root claims.
5. Tests
Add test_claim_root_with_delegated_claim_type to cover the new behavior:
-
Sets up a subnet with:
- A validator hotkey + owner coldkey.
- Two stakers (Alice and Bob) each holding 10% of the root stake behind the same validator hotkey.
- A configured swap pool and price (alpha:TAO = 2:1).
-
Scenario 1 – Validator =
Keep-
Validator sets
set_validator_claim_type(..., Keep). -
Alice uses the default
Delegatedclaim type. -
Bob explicitly sets
RootClaimType = Keep. -
After distributing root emission and calling
claim_root:- Alice and Bob both receive equal alpha stake on the subnet.
- Their TAO stake on root remains unchanged.
-
-
Scenario 2 – Validator =
Swap-
Validator changes claim type to
Swap. -
Another emission is distributed and both Alice and Bob claim again.
-
Alice (delegated) now behaves as
Swap:- Her subnet alpha stake stays ~constant.
- Her TAO stake on root increases according to the swap rate.
-
Bob (explicit
Keep) continues to accumulate alpha on the subnet with unchanged TAO stake.
-
-
The test asserts:
- Delegated stakers track validator claim type changes.
- Explicit staker claim types override validator settings.
-
Keepstakes alpha on the subnet;Swapconverts to TAO and stakes on root. - Quantitative expectations for both alpha and TAO balances are within tolerance.
Rationale
This PR lets stakers opt into a sane default by delegating claim behavior to the subnet validator, while still allowing advanced users to override their own behavior. Validators gain an explicit, on-chain control point for how root emissions are handled per subnet. At the same time, TAO outflow accounting for swap-based claims is made explicit, improving tracking and observability of network flows.
Latest update
- merged PR https://github.com/opentensor/subtensor/pull/2218 with related code update (additional root claim type and logic around it)
- modified
set_validator_claim_typeto support the new root claim type
The last commits change tao outflow registration: new root prop multiplier bounded by 10.