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

stake-pool: Add instruction creators that re-use existing seeds #6279

Closed
joncinque opened this issue Feb 20, 2024 · 6 comments · Fixed by #7129
Closed

stake-pool: Add instruction creators that re-use existing seeds #6279

joncinque opened this issue Feb 20, 2024 · 6 comments · Fixed by #7129
Labels
good first issue Good for newcomers

Comments

@joncinque
Copy link
Contributor

Problem

The IncreaseAdditionalValidatorStake and DecreaseAdditionalValidatorStake instruction creators helpers that take the vote account require that you pass in the transient_stake_seed:

pub fn decrease_additional_validator_stake_with_vote(
program_id: &Pubkey,
stake_pool: &StakePool,
stake_pool_address: &Pubkey,
vote_account_address: &Pubkey,
lamports: u64,
validator_stake_seed: Option<NonZeroU32>,
transient_stake_seed: u64,
ephemeral_stake_seed: u64,
) -> Instruction {

And

pub fn increase_additional_validator_stake_with_vote(
program_id: &Pubkey,
stake_pool: &StakePool,
stake_pool_address: &Pubkey,
vote_account_address: &Pubkey,
lamports: u64,
validator_stake_seed: Option<NonZeroU32>,
transient_stake_seed: u64,
ephemeral_stake_seed: u64,
) -> Instruction {

Since these instructions are usually meant to reuse an existing transient stake account, these instruction creators can be confusing.

Solution

Create a new variant of these creators, decrease_additional_validator_stake_with_list and increase_additional_validator_stake_with_list, which takes in the pool's ValidatorList, ie:

pub fn increase_additional_validator_stake_with_list(
    program_id: &Pubkey,
    stake_pool: &StakePool,
    validator_list: &ValidatorList,
    stake_pool_address: &Pubkey,
    vote_account_address: &Pubkey,
    lamports: u64,
    ephemeral_stake_seed: u64,
) -> Instruction {

From the validator list, it can figure out the seeds and be much easier to use.

@joncinque joncinque added the good first issue Good for newcomers label Feb 20, 2024
@joncinque joncinque changed the title stake-pool: Add instruction creators that re-use seeds stake-pool: Add instruction creators that re-use existing seeds Feb 20, 2024
@zahratt82

This comment was marked as spam.

1 similar comment
@zahratt82

This comment was marked as spam.

@lucky-gru
Copy link

@joncinque
increase_additional_validator_stake_with_vote uses &stake_pool.validator_list without having the validator list as an argument.
IncreaseValidatorStake instruction requires a transient_stake_seed.
so need to add another instruction that doesn't require a transient_stake_seed. I don't think it's your intent.
Or that instruction can consume lists of transient_stake_seeds?
Then, How can I get a transient_stake_seed from validators lists?

@joncinque
Copy link
Contributor Author

I'm not sure I totally understand the comment, but the concept is that ValidatorList contains the validator stake seed and the transient stake seed for the given vote account address:

/// Transient account seed suffix, used to derive the transient stake
/// account address
pub transient_seed_suffix: PodU64,
/// Unused space, initially meant to specify the end of seed suffixes
pub unused: PodU32,
/// Validator account seed suffix
pub validator_seed_suffix: PodU32, // really `Option<NonZeroU32>` so 0 is `None`

So increase_additional_validator_stake_with_list can just read those values for the given validator and pass them into increase_additional_validator_stake_with_vote

@Hrushi20
Copy link
Contributor

Hrushi20 commented Aug 4, 2024

So do we want to iterate through the validator lists and execute the DecreaseAdditionalValidatorStake / IncreaseAdditionalValidatorStake? Do we return an array of instructions?

@joncinque
Copy link
Contributor Author

@Hrushi20 it's only one instruction in this case, but you'll need to search through the ValidatorList to find the validator and use the transient stake seed stored there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants