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

Shared and Independent re-staking option for selected roles #329

Merged
merged 20 commits into from
Dec 12, 2023

Conversation

salman01zp
Copy link
Contributor

@salman01zp salman01zp commented Dec 1, 2023

Summary of changes

The validator can now create the profile by selecting roles he is interested in and with the option to stake independently for each role to be shared across all the roles.

New extrinsic:

  • Create Profile

    • Creates a new profile for the validator.
  • Update Profile:

    • User can update profile from shared to independent or vice versa.
    • User can remove the role from the profile given that the user has completed all the jobs related to the given role.
    • User can add a new role to the profile given it meets min staking requirements.
  • Delete Profile:

    • Submits a request to remove all the jobs
    • Deletes profile if there are no pending jobs
  • Remove Role:

    • Submits requests to remove jobs related to the given role
    • Remove role profile once there are no pending jobs related to the given role
pub struct RoleStakingLedger<T: Config> {
	/// The stash account whose balance is actually locked and at stake.
	pub stash: T::AccountId,
	/// The total amount of the stash's balance that is re-staked for all selected roles.
	/// This re-staked balance we are currently accounting for new slashing conditions.
	#[codec(compact)]
	pub total: BalanceOf<T>,
	/// Re staking Profile
	pub profile: Profile,
}

pub enum Profile {
        Independent(IndependentReStakeProfile),
        Shared(SharedReStakeProfile),
}

pub struct Record {
        pub metadata: RoleTypeMetadata,
        pub amount: Option<u64>,
}

pub struct IndependentReStakeProfile {
        pub records: Vec<Record>,
}

pub struct SharedReStakeProfile {
        pub records: Vec<Record>,
        pub amount: u64,
}

Task Checklist

  • Update tests
  • Update docs

Reference issue to close (if applicable)

Closes #306
Closes #330

@salman01zp salman01zp changed the title Share re-stake for assigned roles Shared and Independent re-staking option for selected roles Dec 7, 2023
@salman01zp salman01zp marked this pull request as ready for review December 8, 2023 17:50
@salman01zp salman01zp requested a review from shekohex December 8, 2023 17:51
Copy link
Contributor

@drewstone drewstone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @salman01zp would suggest a few style changes/spelling/naming and otherwise looks good! I think we will need to properly review this 1:1 if you can book time and we can try to audit/break the mechanism

@salman01zp salman01zp merged commit af6032a into main Dec 12, 2023
8 checks passed
@salman01zp salman01zp deleted the salman/shared-re-stake branch December 12, 2023 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Roles pallet : Allow re-staking with multiple roles [TASK] Share same stake with other roles
2 participants