pub enum UpgradeableLoaderInstruction {
    InitializeBuffer,
    Write {
        offset: u32,
        bytes: Vec<u8, Global>,
    },
    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

Fields

§offset: u32

Offset at which to write the given bytes.

§bytes: Vec<u8, Global>

Serialized program data

Write program data into a Buffer account.

Account references

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

DeployWithMaxDataLen

Fields

§max_data_len: usize

Maximum length that the program can be upgraded to.

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
§

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

Fields

§additional_bytes: u32

Number of bytes to extend the program data.

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.
§

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<UpgradeableLoaderInstruction> for UpgradeableLoaderInstruction

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method 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 StructuralEq for UpgradeableLoaderInstruction

source§

impl StructuralPartialEq for UpgradeableLoaderInstruction

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> AbiEnumVisitor for Twhere T: Serialize + ?Sized,

source§

default fn visit_for_abi( &self, _digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

source§

impl<T> AbiEnumVisitor for Twhere T: Serialize + AbiExample + ?Sized,

source§

default fn visit_for_abi( &self, digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

source§

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