@@ -23,7 +23,28 @@ loader-v4.
23
23
24
24
## Alternatives Considered
25
25
26
- None.
26
+ ### Loader-v1 and loader-v2 programs
27
+
28
+ The two loader-v3 accounts per program in their sum are always larger than
29
+ the one resulting loader-v4 account. Thus there is no need for additional
30
+ funding. This would not be the case when migrating from older loaders. Meaning
31
+ that expanding this SIMD to cover these as well would require a funding source.
32
+
33
+ ### Global Migration: Coordinated in valiator or out of validator
34
+
35
+ The global migration could be implemented in the validator, however:
36
+
37
+ - If the global migration mechanism is inside the validator, the risk of it
38
+ being detrimental to block production outweights any possible benefits.
39
+ - It would have to be coordinated across all validator implementations,
40
+ tested, fuzzed, etc. simply a whole lot more work for something which is only
41
+ used once.
42
+ - It being triggered manually per program or once (via a feature gate) for all
43
+ programs changes nothing about it being controlled by a single key.
44
+ - The only difference is in having more fine granular control over the
45
+ timing in when a specific programs migration is triggered.
46
+ - Doing it outside of the validator allows for the process to be aborted or
47
+ patched quickly in case things start going sideways.
27
48
28
49
## New Terminology
29
50
@@ -51,8 +72,9 @@ instruction `UpgradeableLoaderInstruction::Migrate`.
51
72
otherwise throw ` NotEnoughAccountKeys `
52
73
- Check that the program data account is writable,
53
74
otherwise throw ` InvalidArgument `
54
- - Check that the program data was last modified before the current slot
55
- if the program data has the state ` ProgramData ` ,
75
+ - Check that the last modified slot (stored in the program data accounts
76
+ header) is less than the current slot if the program data has the state
77
+ ` ProgramData ` ,
56
78
otherwise throw ` InvalidArgument `
57
79
- Check that the provided authority is either:
58
80
- the migration authority
@@ -67,26 +89,26 @@ instruction `UpgradeableLoaderInstruction::Migrate`.
67
89
otherwise throw ` InvalidArgument `
68
90
- Check that the program account is owned by loader-v3,
69
91
otherwise throw ` IncorrectProgramId `
70
- - Check that the program account has the state ` Program ` ,
71
- otherwise throw ` InvalidAccountData `
72
- - Check that the program account points to the program data account,
73
- otherwise throw ` InvalidArgument `
74
- - Clear the program account (setting its size to zero)
75
- - Transfer all funds from the program data account to the program account
76
- - Assign ownership of the program account to loader-v4
77
- - If the program data account was not closed / empty or uninitialized:
78
- - CPI loader-v4 ` SetProgramLength ` the program account to the size of the
79
- program data account minus the loader-v3 header size and use the migration
80
- authority.
92
+ - If the program account has the state ` Program ` and
93
+ the referenced program data account is owned by loader-v3:
94
+ - Set the length of the program account to 0
95
+ - Transfer all funds from the program data account to the program account
96
+ - Assign ownership of the program account to loader-v4
97
+ - CPI loader-v4 ` SetProgramLength ` the program account to the program data
98
+ account size minus the loader-v3 header size (45 bytes) and use the
99
+ provided authority.
81
100
- CPI loader-v4 ` Copy ` the program data account into the program account
82
101
- CPI loader-v4 ` Deploy ` the program account
83
102
- If the program data account was finalized (upgrade authority is ` None ` ):
84
103
- CPI loader-v4 ` Finalize ` without a next version forwarding
85
104
- otherwise, if the program data account was not finalized and the
86
105
migration authority (as opposed to the upgrade authority) was provided:
87
106
- CPI loader-v4 ` TransferAuthority ` to the upgrade authority
88
- - Clear the program data account (setting its size to zero)
89
- - Assign ownership of the program data account to the system program
107
+ - Set the length of the program data account to 0 (removing the header too)
108
+ - otherwise, if the program account is empty, has the state ` Buffer ` or has
109
+ the state ` Program ` but the program data account is not owned by loader-v3:
110
+ - Set the length of the program account to 0
111
+ - Set the ` is_executable ` flag of the program account to ` false `
90
112
91
113
## Impact
92
114
0 commit comments