Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2c68387
delegates can set the claim type for all their delegates
Nov 20, 2025
6c50312
record flow
Nov 20, 2025
12b7af2
ran fmt
Nov 20, 2025
badae21
claim type
Nov 20, 2025
03908e3
fixes
Nov 20, 2025
13b2ee1
fmt
Nov 20, 2025
2f70212
Keep default
Nov 21, 2025
d12bcfc
add tests fix errors
Nov 21, 2025
857e59e
commit Cargo.lock
sam0x17 Nov 21, 2025
ad3a0d1
fix
sam0x17 Nov 21, 2025
f743b87
Merge remote-tracking branch 'origin/devnet-ready' into delegate_set_…
sam0x17 Nov 21, 2025
26c9a3e
bump spec version
sam0x17 Nov 21, 2025
665b72f
bump spec version
sam0x17 Nov 24, 2025
eaf07dc
Merge remote-tracking branch 'origin/devnet-ready' into delegate_set_…
sam0x17 Nov 24, 2025
43896e2
Merge branch 'root-claim-upgrade2' into delegate_set_claim_type
shamil-gadelshin Nov 24, 2025
9b34a03
Fix set_validator_claim_type
shamil-gadelshin Nov 24, 2025
c991786
Merge branch 'devnet-ready' into _delegate_set_claim_type
shamil-gadelshin Nov 25, 2025
d536c5f
Merge branch 'devnet-ready' into delegate_set_claim_type
shamil-gadelshin Nov 26, 2025
7ab6ade
Add SubnetTaoFlow test.
shamil-gadelshin Dec 4, 2025
c7c6747
Merge branch 'devnet-ready' into delegate_set_claim_type
shamil-gadelshin Dec 5, 2025
e55109d
Modify ValidatorClaimTypeSet event
shamil-gadelshin Dec 5, 2025
7b53c20
Bump spec version.
shamil-gadelshin Dec 5, 2025
897a623
Merge branch 'devnet-ready' into delegate_set_claim_type
shamil-gadelshin Dec 8, 2025
75f6845
Merge remote-tracking branch 'origin/devnet-ready' into delegate_set_…
sam0x17 Dec 8, 2025
6c38494
Merge remote-tracking branch 'origin/devnet-ready' into delegate_set_…
sam0x17 Dec 8, 2025
709676c
Add tao outflow root_prop multiplier
shamil-gadelshin Dec 9, 2025
fa61d93
Add test for calculate_tao_outflow()
shamil-gadelshin Dec 9, 2025
ef8e46d
Fix set_validator_claim_type
shamil-gadelshin Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pallets/subtensor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2244,6 +2244,17 @@ pub mod pallet {
ValueQuery,
DefaultRootClaimType<T>,
>;
#[pallet::storage] // -- MAP ( hotkey, netuid ) --> delegate_claim_type enum
pub type DelegateClaimType<T: Config> = StorageMap<
_,
Blake2_128Concat,
T::AccountId,
Identity,
u16,
RootClaimTypeEnum,
ValueQuery,
DefaultRootClaimType<T>,
>;
#[pallet::storage] // --- MAP ( u64 ) --> coldkey | Maps coldkeys that have stake to an index
pub type StakingColdkeysByIndex<T: Config> =
StorageMap<_, Identity, u64, T::AccountId, OptionQuery>;
Expand Down
26 changes: 26 additions & 0 deletions pallets/subtensor/src/macros/dispatches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2421,5 +2421,31 @@ mod dispatches {

Ok(())
}

/// --- Sets delegate claim type for a hotkey on a subnet.
#[pallet::call_index(125)]
#[pallet::weight((
Weight::from_parts(5_711_000, 0).saturating_add(T::DbWeight::get().writes(1_u64)),
DispatchClass::Operational,
Pays::Yes
))]
pub fn set_delegate_claim_type(
origin: OriginFor<T>,
hotkey: T::AccountId,
netuid: NetUid,
new_claim_type: RootClaimTypeEnum,
) -> DispatchResult {
let coldkey: T::AccountId = ensure_signed(origin)?;
ensure!(
Self::coldkey_owns_hotkey(coldkey.clone(), hotkey.clone()),
Error::<T>::NonAssociatedColdKey
);
DelegateClaimType::<T>::insert((hotkey.clone(), netuid), new_claim_type.clone());
Self::deposit_event(Event::DelegateClaimTypeSet {
hotkey: hotkey.clone(),
root_claim_type: new_claim_type,
});
Ok(())
}
}
}
9 changes: 9 additions & 0 deletions pallets/subtensor/src/macros/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ mod events {
root_claim_type: RootClaimTypeEnum,
},

/// Root claim type for a coldkey has been set.
/// Parameters:
/// (coldkey, u8)
DelegateClaimTypeSet {
/// delegate hotkey
hotkeu: T::AccountId,
root_claim_type: RootClaimTypeEnum,
},

/// Subnet lease dividends have been distributed.
SubnetLeaseDividendsDistributed {
/// The lease ID
Expand Down
18 changes: 16 additions & 2 deletions pallets/subtensor/src/staking/claim_root.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<T: Config> Pallet<T> {
hotkey: &T::AccountId,
coldkey: &T::AccountId,
netuid: NetUid,
root_claim_type: RootClaimTypeEnum,
mut root_claim_type: RootClaimTypeEnum,
ignore_minimum_condition: bool,
) {
// Subtract the root claimed.
Expand Down Expand Up @@ -157,6 +157,11 @@ impl<T: Config> Pallet<T> {
return; // no-op
}

// If root_claim_type is Delegated, switch to the delegate's actual claim type.
if let RootClaimTypeEnum::Delegated = root_claim_type {
root_claim_type = DelegateClaimType::<T>::get(hotkey, netuid);
}

match root_claim_type {
// Increase stake on root
RootClaimTypeEnum::Swap => {
Expand All @@ -175,6 +180,9 @@ impl<T: Config> Pallet<T> {
}
};

// Importantly measures swap as flow.
Self::record_tao_outflow(netuid, owed_tao);

Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
hotkey,
coldkey,
Expand All @@ -189,14 +197,20 @@ impl<T: Config> Pallet<T> {
);
}
RootClaimTypeEnum::Keep => {
// Increase the stake with the alpha owned
// Increase the stake with the alpha owed
Self::increase_stake_for_hotkey_and_coldkey_on_subnet(
hotkey,
coldkey,
netuid,
owed_u64.into(),
);
}
// Add Delegated arm for completeness, but it should never reach here due to switch above.
RootClaimTypeEnum::Delegated => {
// Should not reach here. Added for completeness.
log::error!("Delegated root_claim_type should have been switched. Skipping.");
return;
}
};

// Increase root claimed by owed amount.
Expand Down
Loading