-
Notifications
You must be signed in to change notification settings - Fork 252
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
Open
unconst
wants to merge
18
commits into
devnet-ready
Choose a base branch
from
delegate_set_claim_type
base: devnet-ready
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Delegate set claim type #2224
+330
−4
Conversation
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
0xcacti
approved these changes
Nov 21, 2025
0xcacti
approved these changes
Nov 21, 2025
shamil-gadelshin
requested changes
Nov 24, 2025
Collaborator
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.
Collaborator
Latest update
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
New feature or request
skip-cargo-audit
This PR fails cargo audit but needs to be merged anyway
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.
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.