Skip to content

Add subnet specific take #315

@distributedstatemachine

Description

Description

We aim to fully integrate the functionality for delegates to set and adjust their take values per subnet, including the ability to increase or decrease these values. This involves updating the do_become_delegate function, modifying the existing DelegateInfo struct to include subnet-specific take values, and ensuring that delegates can dynamically adjust their take values for specific subnets.

By providing delegates with the flexibility to manage their take values on a per-subnet basis, we enable them to tailor their participation and rewards strategy according to their preferences and the unique characteristics of each subnet.

Acceptance Criteria

  • The DelegateInfo struct should be modified to include a new field subnet_takes of type Vec<(Compact<u16>, Compact<u16>)> to store subnet-specific take values.
  • The do_become_delegate function should be updated to accept a list of subnet IDs and their corresponding take values, allowing delegates to set initial take values for multiple subnets upon becoming a delegate.
  • A storage migration should be implemented to handle the addition of the subnet_takes field to the DelegateInfo struct, ensuring a smooth transition for existing delegates.
  • The do_increase_take and do_decrease_take functions should be adjusted to handle subnet-specific take adjustments, ensuring that increases or decreases are performed within the constraints of the system's rules.
  • Proper validation should be in place to ensure that the specified subnets exist and that the new take values adhere to the system's constraints.
  • The updated functionality should be thoroughly tested to verify that delegates can successfully set and adjust their take values per subnet, and that the changes are accurately reflected in the storage and overall system behavior.

Tasks

  • Modify the DelegateInfo struct in lib.rs to include the subnet_takes field.
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
pub struct DelegateInfo<T: Config> {
    // ...
    subnet_takes: Vec<(Compact<u16>, Compact<u16>)>, // New field: Vec of (subnet ID, take value)
}
  • Implement a storage migration to handle the addition of the subnet_takes field to the DelegateInfo struct.
  • Update the do_become_delegate function in staking.rs to accept a list of subnet IDs and their corresponding take values.
// Update the do_become_delegate function
pub fn do_become_delegate(
    origin: T::RuntimeOrigin,
    hotkey: T::AccountId,
    subnet_takes: Vec<(u16, u16)>,
) -> dispatch::DispatchResult {
    // ...
    let mut delegate_info = DelegateInfo {
        // ...
        subnet_takes: subnet_takes.iter().map(|(id, take)| (Compact(*id), Compact(*take))).collect(),
    };
    // ...
}
  • Modify the do_increase_take function in staking.rs to handle subnet-specific take increases.
  • Modify the do_decrease_take function in staking.rs to handle subnet-specific take decreases.

Related Links

Metadata

Metadata

Assignees

Labels

red teamfeature development, etc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions