Skip to content

Commit fc20b4e

Browse files
committed
Adds explicit finalization and next version forwarding.
1 parent c40c3ef commit fc20b4e

File tree

1 file changed

+39
-12
lines changed

1 file changed

+39
-12
lines changed

proposals/0167-loader-v4.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ Accounts of programs owned by loader-v4 must have the following layout:
5555
- `u64` Slot in which the program was last deployed, retracted or
5656
initialized.
5757
- `[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.
5960
- `u64` status enum:
6061
- Enum variant `0u64`: Retracted, program is in maintenance
6162
- 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
225226
- Instruction accounts:
226227
- `[writable]` The program account to change the authority of.
227228
- `[signer]` The current authority of the program.
228-
- `[signer]` Optional, the new authority of the program.
229+
- `[signer]` The new authority of the program.
229230
- Instruction data:
230231
- Enum variant `4u32`
231232
- Behavior:
232-
- Check there are at least two instruction accounts,
233+
- Check there are at least three instruction accounts,
233234
otherwise throw `NotEnoughAccountKeys`
234235
- 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,
243255
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
245269

246270
## Impact
247271

248272
This proposal:
249273

250274
- covers all the use cases loader-v3 had but in a cleaner way and comes with
251275
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.
252279
- makes deployment slightly cheaper for dapp developers as they would no longer
253280
have to burn funds for the rent exception of the proxy account.
254281
- provides an alternative redeployment path which does not require a big

0 commit comments

Comments
 (0)