Skip to content

Commit 1be6303

Browse files
committed
Adds explicit finalization and redirection link.
1 parent 43d4598 commit 1be6303

File tree

1 file changed

+37
-11
lines changed

1 file changed

+37
-11
lines changed

proposals/0167-loader-v4.md

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Accounts of programs owned by loader-v4 must have the following layout:
5454
- `u64` Slot in which the program was last deployed, retracted or
5555
initialized.
5656
- `[u8; 32]` Authority address which can send program management
57-
instructions.
57+
instructions. Or if the status is finalized, then the redirection link.
5858
- `u64` status enum:
5959
- Enum variant `0u64`: Retracted, program is in maintenance
6060
- 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
223223
- Instruction accounts:
224224
- `[writable]` The program account to change the authority of.
225225
- `[signer]` The current authority of the program.
226-
- `[signer]` Optional, the new authority of the program.
226+
- `[signer]` The new authority of the program.
227227
- Instruction data:
228228
- 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`
229247
- Behavior:
230248
- Check there are at least two instruction accounts,
231249
otherwise throw `NotEnoughAccountKeys`
232250
- 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,
241252
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
243269

244270
## Impact
245271

0 commit comments

Comments
 (0)