#[repr(u8)]
pub enum UpgradeableLoaderInstruction {
InitializeBuffer,
Write {
offset: u32,
bytes: Vec<u8>,
},
DeployWithMaxDataLen {
max_data_len: usize,
},
Upgrade,
SetAuthority,
Close,
ExtendProgram {
additional_bytes: u32,
},
}
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
[writable]
source account to initialize.[]
Buffer authority, optional, if omitted then the buffer will be immutable.
Write
Write program data into a Buffer account.
Account references
[writable]
Buffer account to write program data to.[signer]
Buffer authority
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
[signer]
The payer account that will pay to create the ProgramData account.[writable]
The uninitialized ProgramData account.[writable]
The uninitialized Program account.[writable]
The Buffer account where the program data has been written. The buffer account’s authority must match the program’s authority[]
Rent sysvar.[]
Clock sysvar.[]
System program (solana_sdk::system_program::id()
).[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
[writable]
The ProgramData account.[writable]
The Program account.[writable]
The Buffer account where the program data has been written. The buffer account’s authority must match the program’s authority[writable]
The spill account.[]
Rent sysvar.[]
Clock sysvar.[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
[writable]
The Buffer or ProgramData account to change the authority of.[signer]
The current authority.[]
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
[writable]
The account to close, if closing a program must be the ProgramData account.[writable]
The account to deposit the closed account’s lamports.[signer]
The account’s authority, Optional, required for initialized accounts.[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
[writable]
The ProgramData account.[writable]
The ProgramData account’s associated Program account.[]
System program (solana_sdk::system_program::id()
), optional, used to transfer lamports from the payer to the ProgramData account.[signer]
The payer account, optional, that will pay necessary rent exemption costs for the increased storage size.
Trait Implementations§
source§impl Clone for UpgradeableLoaderInstruction
impl Clone for UpgradeableLoaderInstruction
source§fn clone(&self) -> UpgradeableLoaderInstruction
fn clone(&self) -> UpgradeableLoaderInstruction
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for UpgradeableLoaderInstruction
impl Debug for UpgradeableLoaderInstruction
source§impl<'de> Deserialize<'de> for UpgradeableLoaderInstruction
impl<'de> Deserialize<'de> for UpgradeableLoaderInstruction
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl PartialEq<UpgradeableLoaderInstruction> for UpgradeableLoaderInstruction
impl PartialEq<UpgradeableLoaderInstruction> for UpgradeableLoaderInstruction
source§fn eq(&self, other: &UpgradeableLoaderInstruction) -> bool
fn eq(&self, other: &UpgradeableLoaderInstruction) -> bool
self
and other
values to be equal, and is used
by ==
.