@@ -54,7 +54,7 @@ Accounts of programs owned by loader-v4 must have the following layout:
54
54
- ` u64 ` Slot in which the program was last deployed, retracted or
55
55
initialized.
56
56
- ` [u8; 32] ` Authority address which can send program management
57
- instructions.
57
+ instructions. Or if the status is finalized, then the redirection link.
58
58
- ` u64 ` status enum:
59
59
- Enum variant ` 0u64 ` : Retracted, program is in maintenance
60
60
- Enum variant ` 1u64 ` : Deployed, program is ready to be executed
@@ -223,23 +223,49 @@ necessarily the current one, but the one of the epoch of the next slot
223
223
- Instruction accounts:
224
224
- ` [writable] ` The program account to change the authority of.
225
225
- ` [signer] ` The current authority of the program.
226
- - ` [signer] ` Optional, the new authority of the program.
226
+ - ` [signer] ` The new authority of the program.
227
227
- Instruction data:
228
228
- Enum variant ` 4u32 `
229
+ - Behavior:
230
+ - Check there are at least three instruction accounts,
231
+ otherwise throw ` NotEnoughAccountKeys `
232
+ - Verify the program account
233
+ - Check that the new authority (instruction account at index 2)
234
+ signed as well, otherwise throw ` MissingRequiredSignature `
235
+ - Check that the authority stored in the program account is different
236
+ from the one provided, otherwise throw ` InvalidArgument `
237
+ - Copy the new authority address into the program account
238
+
239
+ #### Finalize
240
+
241
+ - Instruction accounts:
242
+ - ` [writable] ` The program account to change the authority of.
243
+ - ` [signer] ` The current authority of the program.
244
+ - ` [] ` Optional, the reserved address for the next version of the program.
245
+ - Instruction data:
246
+ - Enum variant ` 5u32 `
229
247
- Behavior:
230
248
- Check there are at least two instruction accounts,
231
249
otherwise throw ` NotEnoughAccountKeys `
232
250
- Verify the program account
233
- - In case a new authority was provided (instruction account at index 2):
234
- - Check that it signed as well,
235
- otherwise throw ` MissingRequiredSignature `
236
- - Check that the authority stored in the program account is different
237
- from the one provided, otherwise throw ` InvalidArgument `
238
- - Copy the new authority address into the program account
239
- - In case no new authority was provided:
240
- - Check that the status stored in the program account is deployed,
251
+ - Check that the status stored in the program account is deployed,
241
252
otherwise throw ` InvalidArgument `
242
- - Change the status stored in the program account to finalized
253
+ - In case the address of the next version was provided
254
+ (instruction account at index 2):
255
+ - for the program account of the next version check that:
256
+ - its address is different from the current version,
257
+ otherwise throw ` AccountBorrowFailed `
258
+ - the owner of the program account is loader-v4,
259
+ otherwise throw ` InvalidAccountOwner `
260
+ - the program account is at least as long enough for the header,
261
+ otherwise throw ` AccountDataTooSmall `
262
+ - the authority stored in the program account is the one provided,
263
+ otherwise throw ` IncorrectAuthority `
264
+ - the status stored in the program account is not finalized,
265
+ otherwise throw ` Immutable `
266
+ - Copy the address of the next version as redirection link stored in the
267
+ previous versions program account
268
+ - Change the status stored in the program account to finalized
243
269
244
270
## Impact
245
271
0 commit comments