@@ -55,7 +55,8 @@ Accounts of programs owned by loader-v4 must have the following layout:
55
55
- ` u64 ` Slot in which the program was last deployed, retracted or
56
56
initialized.
57
57
- ` [u8; 32] ` Authority address which can send program management
58
- instructions.
58
+ instructions. Or if the status is finalized, then the address of the next
59
+ version of the program.
59
60
- ` u64 ` status enum:
60
61
- Enum variant ` 0u64 ` : Retracted, program is in maintenance
61
62
- Enum variant ` 1u64 ` : Deployed, program is ready to be executed
@@ -225,30 +226,56 @@ necessarily the current one, but the one of the epoch of the next slot
225
226
- Instruction accounts:
226
227
- ` [writable] ` The program account to change the authority of.
227
228
- ` [signer] ` The current authority of the program.
228
- - ` [signer] ` Optional, the new authority of the program.
229
+ - ` [signer] ` The new authority of the program.
229
230
- Instruction data:
230
231
- Enum variant ` 4u32 `
231
232
- Behavior:
232
- - Check there are at least two instruction accounts,
233
+ - Check there are at least three instruction accounts,
233
234
otherwise throw ` NotEnoughAccountKeys `
234
235
- Verify the program account
235
- - In case a new authority was provided (instruction account at index 2):
236
- - Check that it signed as well,
237
- otherwise throw ` MissingRequiredSignature `
238
- - Check that the authority stored in the program account is different
239
- from the one provided, otherwise throw ` InvalidArgument `
240
- - Copy the new authority address into the program account
241
- - In case no new authority was provided:
242
- - Check that the status stored in the program account is deployed,
236
+ - Check that the new authority (instruction account at index 2)
237
+ signed as well, otherwise throw ` MissingRequiredSignature `
238
+ - Check that the authority stored in the program account is different
239
+ from the one provided, otherwise throw ` InvalidArgument `
240
+ - Copy the new authority address into the program account
241
+
242
+ #### Finalize
243
+
244
+ - Instruction accounts:
245
+ - ` [writable] ` The program account to change the authority of.
246
+ - ` [signer] ` The current authority of the program.
247
+ - ` [] ` Optional, the reserved address for the next version of the program.
248
+ - Instruction data:
249
+ - Enum variant ` 5u32 `
250
+ - Behavior:
251
+ - Check there are at least three instruction accounts,
252
+ otherwise throw ` NotEnoughAccountKeys `
253
+ - Verify the program account
254
+ - Check that the status stored in the program account is deployed,
243
255
otherwise throw ` InvalidArgument `
244
- - Change the status stored in the program account to finalized
256
+ - for the program account of the next version
257
+ (instruction account at index 2) check that:
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 into the next version field stored in
267
+ the previous versions program account
268
+ - Change the status stored in the program account to finalized
245
269
246
270
## Impact
247
271
248
272
This proposal:
249
273
250
274
- covers all the use cases loader-v3 had but in a cleaner way and comes with
251
275
a specification.
276
+ - allows finalized programs to mark which other program supersedes them which
277
+ can then be offered as an option in forntends. This provides a more secure
278
+ alternative to redeployment / upgrading of programs at the same address.
252
279
- makes deployment slightly cheaper for dapp developers as they would no longer
253
280
have to burn funds for the rent exception of the proxy account.
254
281
- provides an alternative redeployment path which does not require a big
0 commit comments