@@ -58,7 +58,8 @@ Accounts of programs owned by loader-v4 must have the following layout:
5858 - ` u64 ` Slot in which the program was last deployed, retracted or
5959 initialized.
6060 - ` [u8; 32] ` Authority address which can send program management
61- instructions.
61+ instructions. Or if the status is finalized, then the address of the next
62+ version of the program.
6263 - ` u64 ` status enum:
6364 - Enum variant ` 0u64 ` : Retracted, program is in maintenance
6465 - Enum variant ` 1u64 ` : Deployed, program is ready to be executed
@@ -228,30 +229,56 @@ necessarily the current one, but the one of the epoch of the next slot
228229- Instruction accounts:
229230 - ` [writable] ` The program account to change the authority of.
230231 - ` [signer] ` The current authority of the program.
231- - ` [signer] ` Optional, the new authority of the program.
232+ - ` [signer] ` The new authority of the program.
232233- Instruction data:
233234 - Enum variant ` 4u32 `
234235- Behavior:
235- - Check there are at least two instruction accounts,
236+ - Check there are at least three instruction accounts,
236237 otherwise throw ` NotEnoughAccountKeys `
237238 - Verify the program account
238- - In case a new authority was provided (instruction account at index 2):
239- - Check that it signed as well,
240- otherwise throw ` MissingRequiredSignature `
241- - Check that the authority stored in the program account is different
242- from the one provided, otherwise throw ` InvalidArgument `
243- - Copy the new authority address into the program account
244- - In case no new authority was provided:
245- - Check that the status stored in the program account is deployed,
239+ - Check that the new authority (instruction account at index 2)
240+ signed as well, otherwise throw ` MissingRequiredSignature `
241+ - Check that the authority stored in the program account is different
242+ from the one provided, otherwise throw ` InvalidArgument `
243+ - Copy the new authority address into the program account
244+
245+ #### Finalize
246+
247+ - Instruction accounts:
248+ - ` [writable] ` The program account to change the authority of.
249+ - ` [signer] ` The current authority of the program.
250+ - ` [] ` Optional, the reserved address for the next version of the program.
251+ - Instruction data:
252+ - Enum variant ` 5u32 `
253+ - Behavior:
254+ - Check there are at least three instruction accounts,
255+ otherwise throw ` NotEnoughAccountKeys `
256+ - Verify the program account
257+ - Check that the status stored in the program account is deployed,
246258 otherwise throw ` InvalidArgument `
247- - Change the status stored in the program account to finalized
259+ - for the program account of the next version
260+ (instruction account at index 2) check that:
261+ - the owner of the program account is loader-v4,
262+ otherwise throw ` InvalidAccountOwner `
263+ - the program account is at least as long enough for the header,
264+ otherwise throw ` AccountDataTooSmall `
265+ - the authority stored in the program account is the one provided,
266+ otherwise throw ` IncorrectAuthority `
267+ - the status stored in the program account is not finalized,
268+ otherwise throw ` Immutable `
269+ - Copy the address of the next version into the next version field stored in
270+ the previous versions program account
271+ - Change the status stored in the program account to finalized
248272
249273## Impact
250274
251275This proposal:
252276
253277- covers all the use cases loader-v3 had but in a cleaner way and comes with
254278a specification.
279+ - allows finalized programs to mark which other program supersedes them which
280+ can then be offered as an option in forntends. This provides a more secure
281+ alternative to redeployment / upgrading of programs at the same address.
255282- makes deployment slightly cheaper for dapp developers as they would no longer
256283have to burn funds for the rent exception of the proxy account.
257284- provides an alternative redeployment path which does not require a big
0 commit comments