Assessment reports>BPF Stake Program>Threat Model>Instruction: DelegateStake

Instruction: DelegateStake

This instruction delegates a stake account to a vote account. If the stake account is already delegated, the stake account is redelegated to the provided vote account.

Input structure

pub enum StakeInstruction { /// # Account references /// 0. `[WRITE]` Initialized stake account to be delegated /// 1. `[]` Vote account to which this stake will be delegated /// 2. `[]` Clock sysvar /// 3. `[]` Stake history sysvar that carries stake warmup/cooldown history /// 4. `[]` Unused account, formerly the stake config /// 5. `[SIGNER]` Stake authority DelegateStake, }

Accounts

  • stake_account: The initialized stake account to be delegated.

    • Signer: No.

    • Init: No.

    • PDA: No.

    • Writable: Yes.

    • Rent checks: The account must be rent-exempt.

    • Ownership checks: The account must be owned by the program.

    • Address checks: None.

  • vote_account: The vote account to which this stake will be delegated.

    • Signer: No.

    • Init: No.

    • PDA: No.

    • Writable: Yes.

    • Rent checks: None.

    • Ownership checks: The account must be owned by the Solana vote program.

    • Address checks: None.

  • clock: The account must be a clock sysvar.

  • stake_history_info: Unused.

  • stake_config: Unused.

  • stake_authority: The stake authority account who is authorized to manage the stake account.

    • Signer: Yes.

    • Init: No.

    • PDA: No.

    • Writable: No.

    • Rent checks: None.

    • Ownership checks: None.

    • Address checks: None.

Additional checks and behavior

  • The stake account must be initialized or delegated.

  • The current staker or the withdrawer of the stake account must be a signer.

  • The stake account must have enough lamports to be rent-exempt.

  • The stake amount must be greater than the minimum delegation amount.

  • The stake account state is set to Stake with the provided stake amount and vote account if the stake account is initialized.

  • If the stake account is already delegated, the stake account is redelegated to the provided vote account.

    • If the stake is active, deactivation is rescinded if the new voter pubkey is the same as the current voter pubkey and the stake is scheduled to start deactivating this epoch. Otherwise, an error is returned, indicating that it is too soon to redelegate.

    • The activation epoch of the stake delegation is set to the current epoch.

    • The deactivation epoch of the stake delegation is set to u64::MAX to indicate that the stake is not deactivating.

    • The voter of the stake delegation is set to the provided vote account pubkey.

    • The credits observed are set to the credits of the provided vote account.

Zellic © 2025Back to top ↑