Skip to content
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

Add subnet specific take #315

Closed
5 tasks
distributedstatemachine opened this issue Apr 11, 2024 · 2 comments
Closed
5 tasks

Add subnet specific take #315

distributedstatemachine opened this issue Apr 11, 2024 · 2 comments
Assignees
Labels
red team feature development, etc

Comments

@distributedstatemachine
Copy link
Contributor

distributedstatemachine commented Apr 11, 2024

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

@gztensor gztensor self-assigned this Apr 12, 2024
@distributedstatemachine distributedstatemachine removed their assignment Apr 13, 2024
@distributedstatemachine distributedstatemachine added the red team feature development, etc label Apr 16, 2024
@distributedstatemachine
Copy link
Contributor Author

@gztensor this is merged into stao / dtao right ? I guess we can close the issue ?

@gztensor
Copy link
Contributor

gztensor commented Apr 25, 2024

@distributedstatemachine , PR#356 addresses what's left of this issue. If PR looks good, ok to merge and close this issue.

@sam0x17 sam0x17 closed this as completed May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
red team feature development, etc
Projects
None yet
Development

No branches or pull requests

3 participants