You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Child keys require delegates to be able to set subnet specific takes. This is already implemented in the dynamic branch. We need to extract the relevant code from that branch into the chain_bloat branch.
Acceptance Criteria
Implement a new function do_set_delegate_takes that allows delegates to set take rates for multiple subnets in a single transaction.
The function should validate that the caller (coldkey) owns the specified hotkey.
Each take rate should be checked against the maximum allowed take rate.
The function should enforce rate limiting for take rate changes.
The function should check if each specified subnet exists.
pub fn do_set_delegate_takes(
origin: T::RuntimeOrigin,
hotkey: &T::AccountId,
takes: Vec<(u16, u16)>,
) -> dispatch::DispatchResult {
let coldkey = ensure_signed(origin)?;
log::trace!(
"do_increase_take( origin:{:?} hotkey:{:?}, take:{:?} )",
coldkey,
hotkey,
takes
);
// --- 2. Ensure we are delegating a known key.
// Ensure that the coldkey is the owner.
Self::do_account_checks(&coldkey, hotkey)?;
let block: u64 = Self::get_current_block_as_u64();
for (netuid, take) in takes {
// Check if the subnet exists before setting the take.
ensure!(
Self::if_subnet_exist(netuid),
Error::<T>::SubNetworkDoesNotExist
);
// Ensure the take does not exceed the initial default take.
let max_take = T::InitialDefaultTake::get();
ensure!(take <= max_take, Error::<T>::DelegateTakeTooHigh);
// Enforce the rate limit (independently on do_add_stake rate limits)
ensure!(
!Self::exceeds_tx_delegate_take_rate_limit(
Self::get_last_tx_block_delegate_take(hotkey),
block
),
Error::<T>::DelegateTxRateLimitExceeded
);
// Insert the take into the storage.
DelegatesTake::<T>::insert(hotkey, netuid, take);
}
// Set last block for rate limiting after all takes are set
Self::set_last_tx_block_delegate_take(hotkey, block);
Ok(())
}
Add appropriate error handling for invalid inputs or conditions
Implement rate limiting for the do_set_delegate_takes function
Add events for successful take rate changes
Update relevant helper functions to work with the new do_set_delegate_takes functionality
The text was updated successfully, but these errors were encountered:
Description
Child keys require delegates to be able to set subnet specific takes. This is already implemented in the dynamic branch. We need to extract the relevant code from that branch into the chain_bloat branch.
Acceptance Criteria
Tasks
do_set_delegate_takes
functiondo_set_delegate_takes
functionalityThe text was updated successfully, but these errors were encountered: