solana_sdk::loader_upgradeable_instruction

Enum UpgradeableLoaderInstruction

Source
#[repr(u8)]
pub enum UpgradeableLoaderInstruction { InitializeBuffer, Write { offset: u32, bytes: Vec<u8>, }, DeployWithMaxDataLen { max_data_len: usize, }, Upgrade, SetAuthority, Close, ExtendProgram { additional_bytes: u32, }, SetAuthorityChecked, }

Variants§

§

InitializeBuffer

Initialize a Buffer account.

A Buffer account is an intermediary that once fully populated is used with the DeployWithMaxDataLen instruction to populate the program’s ProgramData account.

The InitializeBuffer instruction requires no signers and MUST be included within the same Transaction as the system program’s CreateAccount instruction that creates the account being initialized. Otherwise another party may initialize the account.

§Account references

  1. [writable] source account to initialize.
  2. [] Buffer authority, optional, if omitted then the buffer will be immutable.
§

Write

Write program data into a Buffer account.

§Account references

  1. [writable] Buffer account to write program data to.
  2. [signer] Buffer authority

Fields

§offset: u32

Offset at which to write the given bytes.

§bytes: Vec<u8>

Serialized program data

§

DeployWithMaxDataLen

Deploy an executable program.

A program consists of a Program and ProgramData account pair.

  • The Program account’s address will serve as the program id for any instructions that execute this program.
  • The ProgramData account will remain mutable by the loader only and holds the program data and authority information. The ProgramData account’s address is derived from the Program account’s address and created by the DeployWithMaxDataLen instruction.

The ProgramData address is derived from the Program account’s address as follows:

let (program_data_address, _) = Pubkey::find_program_address(
     &[program_address],
     &bpf_loader_upgradeable::id()
 );

The DeployWithMaxDataLen instruction does not require the ProgramData account be a signer and therefore MUST be included within the same Transaction as the system program’s CreateAccount instruction that creates the Program account. Otherwise another party may initialize the account.

§Account references

  1. [signer] The payer account that will pay to create the ProgramData account.
  2. [writable] The uninitialized ProgramData account.
  3. [writable] The uninitialized Program account.
  4. [writable] The Buffer account where the program data has been written. The buffer account’s authority must match the program’s authority
  5. [] Rent sysvar.
  6. [] Clock sysvar.
  7. [] System program (solana_sdk::system_program::id()).
  8. [signer] The program’s authority

Fields

§max_data_len: usize

Maximum length that the program can be upgraded to.

§

Upgrade

Upgrade a program.

A program can be updated as long as the program’s authority has not been set to None.

The Buffer account must contain sufficient lamports to fund the ProgramData account to be rent-exempt, any additional lamports left over will be transferred to the spill account, leaving the Buffer account balance at zero.

§Account references

  1. [writable] The ProgramData account.
  2. [writable] The Program account.
  3. [writable] The Buffer account where the program data has been written. The buffer account’s authority must match the program’s authority
  4. [writable] The spill account.
  5. [] Rent sysvar.
  6. [] Clock sysvar.
  7. [signer] The program’s authority.
§

SetAuthority

Set a new authority that is allowed to write the buffer or upgrade the program. To permanently make the buffer immutable or disable program updates omit the new authority.

§Account references

  1. [writable] The Buffer or ProgramData account to change the authority of.
  2. [signer] The current authority.
  3. [] The new authority, optional, if omitted then the program will not be upgradeable.
§

Close

Closes an account owned by the upgradeable loader of all lamports and withdraws all the lamports

§Account references

  1. [writable] The account to close, if closing a program must be the ProgramData account.
  2. [writable] The account to deposit the closed account’s lamports.
  3. [signer] The account’s authority, Optional, required for initialized accounts.
  4. [writable] The associated Program account if the account to close is a ProgramData account.
§

ExtendProgram

Extend a program’s ProgramData account by the specified number of bytes. Only upgradeable program’s can be extended.

The payer account must contain sufficient lamports to fund the ProgramData account to be rent-exempt. If the ProgramData account balance is already sufficient to cover the rent exemption cost for the extended bytes, the payer account is not required.

§Account references

  1. [writable] The ProgramData account.
  2. [writable] The ProgramData account’s associated Program account.
  3. [] System program (solana_sdk::system_program::id()), optional, used to transfer lamports from the payer to the ProgramData account.
  4. [signer] The payer account, optional, that will pay necessary rent exemption costs for the increased storage size.

Fields

§additional_bytes: u32

Number of bytes to extend the program data.

§

SetAuthorityChecked

Set a new authority that is allowed to write the buffer or upgrade the program.

This instruction differs from SetAuthority in that the new authority is a required signer.

§Account references

  1. [writable] The Buffer or ProgramData account to change the authority of.
  2. [signer] The current authority.
  3. [signer] The new authority.

Trait Implementations§

Source§

impl Clone for UpgradeableLoaderInstruction

Source§

fn clone(&self) -> UpgradeableLoaderInstruction

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UpgradeableLoaderInstruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UpgradeableLoaderInstruction

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<UpgradeableLoaderInstruction, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for UpgradeableLoaderInstruction

Source§

fn eq(&self, other: &UpgradeableLoaderInstruction) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for UpgradeableLoaderInstruction

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for UpgradeableLoaderInstruction

Source§

impl StructuralPartialEq for UpgradeableLoaderInstruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,