-
Notifications
You must be signed in to change notification settings - Fork 264
Delegate set claim type #2224
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: devnet-ready
Are you sure you want to change the base?
Delegate set claim type #2224
Conversation
shamil-gadelshin
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.
I found a minor bug (incompatibility with the pending PR). Looks good otherwise.
Latest update
|
|
The last commits change tao outflow registration: new root prop multiplier bounded by 10. |
| let root_tao: U96F32 = U96F32::saturating_from_num(SubnetTAO::<T>::get(NetUid::ROOT)); | ||
| let tao_weight: U96F32 = root_tao.saturating_mul(Self::get_tao_weight()); | ||
| let alpha_issuance: U96F32 = U96F32::saturating_from_num(Self::get_alpha_issuance(netuid)); | ||
| let root_proportion: U96F32 = tao_weight |
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 have this code in multiple places in code and need to consolidate it. Let it be a tech debt for now :(
Summary
This PR introduces a new
Delegatedroot claim type and a per-subnet validator claim configuration so that stakers can opt into inheriting their validator’s claim behavior (SwaporKeep) on each subnet. It also fixes accounting by recording TAO outflow when alpha is swapped during root claims.What’s changing
1. New
Delegatedclaim typeExtend
RootClaimTypeEnum:Change the default coldkey root claim type to
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:
New extrinsic to let validators configure claim behavior on a per-subnet basis:
Only the coldkey that owns
hotkeymay call this (enforced bycoldkey_owns_hotkey).new_claim_typeis restricted toSwaporKeep. Attempting to setDelegatedresults in:Emits:
3. Claim resolution logic for
DelegatedIn
claim_root_for_hotkey_on_subnet, theroot_claim_typeparameter is now mutable and we resolveDelegatedbefore processing: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:
RootClaimTypeisDelegated, they will use the subnet validator’s configuredSwap/Keepchoice for that hotkey + subnet.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:This ensures subnet TAO outflow metrics correctly reflect alpha→TAO swaps performed during root claims.
5. Tests
Add
test_claim_root_with_delegated_claim_typeto cover the new behavior:Sets up a subnet with:
Scenario 1 – Validator =
KeepValidator 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:Scenario 2 – Validator =
SwapValidator changes claim type to
Swap.Another emission is distributed and both Alice and Bob claim again.
Alice (delegated) now behaves as
Swap:Bob (explicit
Keep) continues to accumulate alpha on the subnet with unchanged TAO stake.The test asserts:
Keepstakes alpha on the subnet;Swapconverts to TAO and stakes on root.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.