@@ -58,7 +58,8 @@ Accounts of programs owned by loader-v4 must have the following layout:
58
58
- ` u64 ` Slot in which the program was last deployed, retracted or
59
59
initialized.
60
60
- ` [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.
62
63
- ` u64 ` status enum:
63
64
- Enum variant ` 0u64 ` : Retracted, program is in maintenance
64
65
- 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
228
229
- Instruction accounts:
229
230
- ` [writable] ` The program account to change the authority of.
230
231
- ` [signer] ` The current authority of the program.
231
- - ` [signer] ` Optional, the new authority of the program.
232
+ - ` [signer] ` The new authority of the program.
232
233
- Instruction data:
233
234
- Enum variant ` 4u32 `
234
235
- Behavior:
235
- - Check there are at least two instruction accounts,
236
+ - Check there are at least three instruction accounts,
236
237
otherwise throw ` NotEnoughAccountKeys `
237
238
- 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,
246
258
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
248
272
249
273
## Impact
250
274
251
275
This proposal:
252
276
253
277
- covers all the use cases loader-v3 had but in a cleaner way and comes with
254
278
a 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.
255
282
- makes deployment slightly cheaper for dapp developers as they would no longer
256
283
have to burn funds for the rent exception of the proxy account.
257
284
- provides an alternative redeployment path which does not require a big
0 commit comments