solana_program/
loader_v4_instruction.rs

1//! Instructions for the v4 built-in loader program.
2
3#[repr(u8)]
4#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
5pub enum LoaderV4Instruction {
6    /// Write ELF data into an undeployed program account.
7    ///
8    /// # Account references
9    ///   0. `[writable]` The program account to write to.
10    ///   1. `[signer]` The authority of the program.
11    Write {
12        /// Offset at which to write the given bytes.
13        offset: u32,
14        /// Serialized program data
15        #[serde(with = "serde_bytes")]
16        bytes: Vec<u8>,
17    },
18
19    /// Changes the size of an undeployed program account.
20    ///
21    /// A program account is automatically initialized when its size is first increased.
22    /// In this initial truncate, the program account needs to be a signer and
23    /// it also sets the authority needed for subsequent operations.
24    /// Decreasing to size zero closes the program account and resets it
25    /// into an uninitialized state.
26    /// Providing additional lamports upfront might be necessary to reach rent exemption.
27    /// Superflous funds are transferred to the recipient account.
28    ///
29    /// # Account references
30    ///   0. `[(signer), writable]` The program account to change the size of.
31    ///   1. `[signer]` The authority of the program.
32    ///   2. `[writable]` Optional, the recipient account.
33    Truncate {
34        /// The new size after the operation.
35        new_size: u32,
36    },
37
38    /// Verify the data of a program account to be a valid ELF.
39    ///
40    /// If this succeeds the program becomes executable, and is ready to use.
41    /// A source program account can be provided to overwrite the data before deployment
42    /// in one step, instead retracting the program and writing to it and redeploying it.
43    /// The source program is truncated to zero (thus closed) and lamports necessary for
44    /// rent exemption are transferred, in case that the source was bigger than the program.
45    ///
46    /// # Account references
47    ///   0. `[writable]` The program account to deploy.
48    ///   1. `[signer]` The authority of the program.
49    ///   2. `[writable]` Optional, an undeployed source program account to take data and lamports from.
50    Deploy,
51
52    /// Undo the deployment of a program account.
53    ///
54    /// The program is no longer executable and goes into maintenance.
55    /// Necessary for writing data and truncating.
56    ///
57    /// # Account references
58    ///   0. `[writable]` The program account to retract.
59    ///   1. `[signer]` The authority of the program.
60    Retract,
61
62    /// Transfers the authority over a program account.
63    ///
64    /// # Account references
65    ///   0. `[writable]` The program account to change the authority of.
66    ///   1. `[signer]` The current authority of the program.
67    ///   2. `[signer]` The new authority of the program.
68    TransferAuthority,
69
70    /// Finalizes the program account, rendering it immutable.
71    ///
72    /// # Account references
73    ///   0. `[writable]` The program account to change the authority of.
74    ///   1. `[signer]` The current authority of the program.
75    ///   2. `[]` The next version of the program (can be itself).
76    Finalize,
77}