Skip to content

Commit 3a3c1f2

Browse files
committed
Adds explicit finalization and redirection link.
1 parent 9fedd95 commit 3a3c1f2

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

proposals/0167-loader-v4.md

Lines changed: 29 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,41 @@ 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 `MissingAccount`
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 `MissingAccount`
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+
- Check that the previous and next version have different addresses,
256+
otherwise throw `AccountBorrowFailed`
257+
- Verify that program account as well
258+
- Copy the address of the next version as redirection link stored in the
259+
previous versions program account
260+
- Change the status stored in the program account to finalized
243261

244262
## Impact
245263

0 commit comments

Comments
 (0)