Conversation
nickfrosty
left a comment
There was a problem hiding this comment.
I also noticed there are several typos on the word "throw"
fc20b4e to
bd5ab89
Compare
proposals/0167-loader-v4.md
Outdated
|
|
||
| - loader-v3 clears the program proxy account (setting its size to zero) | ||
| - loader-v3 transfers all funds from the programdata to the proxy account | ||
| - loader-v3 gifts the program proxy account to loader-v4 |
There was a problem hiding this comment.
How would the gifting work? Do we need to add a new instruction to the v3 loader? Will this upgrade mechanism be specified in a future SIMD?
There was a problem hiding this comment.
I see three options here:
- A migrate instruction for loader-v3 which the dApp devs trigger themselves
- A migrate instruction for loader-v3 which we the protocol engineers trigger
- A feature gate which scans the accounts DB and migrates all loader-v3 programs
I would prefer the second option as that allows us to keep the gathering of the loader-v3 program list and then slowly working through it off-chain and still makes sure that all loader-v3 programs get migrated.
There was a problem hiding this comment.
Added a more detailed description of how this would work:
f2d4970
1f95ac3 to
a788388
Compare
05f0b13 to
f2d4970
Compare
buffalojoec
left a comment
There was a problem hiding this comment.
Getting really close on my side. Based on our last discussion we wanted to add the following to SetAuthority:
- If the program is
Uninitializedwill skip the existing authority check, set the new authority, and set the status toNeverBeenDeployed. - Programs that are
Retractedcan be finalized only if the program length is 0
| - the program account was not deployed within the current slot (delay | ||
| visibility) |
There was a problem hiding this comment.
Can we define "delay visibility" or "deployment cooldown" in terminology and use the term consistently in this SIMD?
proposals/0167-loader-v4.md
Outdated
| - Change the status stored in the program account to `Retracted` | ||
| - Set the `is_executable` flag to `false` | ||
|
|
||
| #### SetAuthority |
There was a problem hiding this comment.
This instruction does three different actions: initialize, set-authority, or finalize. All of them set the authority field but they are all different enough that they warrant having specific instructions, in my opinion.
Splitting this instruction up would help clarify instruction account requirements:
Initializedoes not require an instruction account to specify the current authoritySetAuthoritywould always require the new authority to be a signer, no need to specify it as optionalFinalizedoes not require an instruction account to specify a new authority
Additionally, the way SetAuthority is specified to be treated as an "initialization" is an anti-pattern because it's typically assumed that when initializing accounts on solana that the caller allocates the account data before invoking the initialization instruction.
proposals/0167-loader-v4.md
Outdated
|
|
||
| None. | ||
|
|
||
| ## Detailed Design |
There was a problem hiding this comment.
@Lichtso I don't think this has been addressed yet (https://github.com/solana-foundation/solana-improvement-documents/pull/167/files#r2184891211)
proposals/0167-loader-v4.md
Outdated
|
|
||
| The feature gate must enable loader-v4 program management and execution. | ||
|
|
||
| ### Owned Program Accounts |
There was a problem hiding this comment.
nit: I don't really understand what "owned" is supposed to indicate here. Can we call this section "Program Account Layout"?
proposals/0167-loader-v4.md
Outdated
| otherwise throw `InvalidArgument` | ||
| - Check that there are enough funds in the program account for rent | ||
| exemption of the new length, otherwise throw `InsufficientFunds` | ||
| - Set the length of the program account to the requested new size plus |
There was a problem hiding this comment.
I don't think this was addressed (https://github.com/solana-foundation/solana-improvement-documents/pull/167/files#r2226342431)
proposals/0167-loader-v4.md
Outdated
| - Enum variant `0u64`: `Uninitalized`, account was zero-filled externally | ||
| - Enum variant `1u64`: `NeverBeenDeployed`, used as write buffer | ||
| - Enum variant `2u64`: `Retracted`, program is in maintenance | ||
| - Enum variant `3u64`: `Deployed`, program is ready to be executed | ||
| - Enum variant `4u64`: `Finalized`, same as `Deployed`, but can not be |
There was a problem hiding this comment.
some typo fixes (u64 -> u32 and Uninitalized -> Uninitialized) and a new naming suggestion for NeverBeenDeployed -> Buffered.
| - Enum variant `0u64`: `Uninitalized`, account was zero-filled externally | |
| - Enum variant `1u64`: `NeverBeenDeployed`, used as write buffer | |
| - Enum variant `2u64`: `Retracted`, program is in maintenance | |
| - Enum variant `3u64`: `Deployed`, program is ready to be executed | |
| - Enum variant `4u64`: `Finalized`, same as `Deployed`, but can not be | |
| - Enum variant `0u32`: `Uninitialized`, account was zero-filled externally | |
| - Enum variant `1u32`: `Buffered`, used as write buffer | |
| - Enum variant `2u32`: `Retracted`, program is in maintenance | |
| - Enum variant `3u32`: `Deployed`, program is ready to be executed | |
| - Enum variant `4u32`: `Finalized`, same as `Deployed`, but can not be |
proposals/0167-loader-v4.md
Outdated
|
|
||
| ### Program Account Header Verification | ||
|
|
||
| Verification the program account checks in the following order that: |
There was a problem hiding this comment.
| Verification the program account checks in the following order that: | |
| Verification of the program account checks the following in order: |
proposals/0167-loader-v4.md
Outdated
|
|
||
| - the owner of the program account is loader-v4, | ||
| otherwise throw `InvalidAccountOwner` | ||
| - the program account is at least as long enough for the header (48 bytes), |
There was a problem hiding this comment.
| - the program account is at least as long enough for the header (48 bytes), | |
| - the program account is at least long enough for the header (48 bytes), |
| Invoking programs owned by loader-v4 checks in the following order that: | ||
|
|
||
| - the owner of the program account is loader-v4 | ||
| - the program account is at least as long enough for the header |
There was a problem hiding this comment.
In light of the conversation here should we change this to check that the program account is strictly greater than the length of the header? A finalized program with executable length of zero definitely wouldn't be executable. But this is technically a sub-case of the later "executable verification" check anyways.
proposals/0167-loader-v4.md
Outdated
|
|
||
| ### Program Management Instructions | ||
|
|
||
| The loader-v4 intructions Deploy and Retract are not authorized in CPI. |
There was a problem hiding this comment.
| The loader-v4 intructions Deploy and Retract are not authorized in CPI. | |
| The loader-v4 instructions Deploy and Retract are not authorized in CPI. If | |
| these instructions are invoked from another program, throw | |
| `ProgramFailedToComplete`. |
There was a problem hiding this comment.
Was thinking about the CPI restriction some more: Isn't it a problem for multisig and governance? E.g. #167 (comment) would not work, right?
There was a problem hiding this comment.
Ah yeah, you're right. Didn't think about that. Let's try to remove this restriction then. If I remember correctly it's because we don't yet allow changing the executable flag from CPI.
| - Enum variant `3u32` | ||
| - `u32` The new size after the operation. | ||
| - Behavior: | ||
| - Charge 32 + new_size_in_bytes / cpi_bytes_per_unit CUs |
There was a problem hiding this comment.
We should only charge CU's for the increased size (if any)
There was a problem hiding this comment.
I think we discussed this before. The reason why we charge for the entire length is because the program runtime has to copy over the existing data into the new allocation.
There was a problem hiding this comment.
Ah yeah, you're right never mind.
| - Instruction data: | ||
| - Enum variant `4u32` | ||
| - `u32` Byte offset at which to write the given bytes | ||
| - `[u8]` Chunk of the programs executable file |
There was a problem hiding this comment.
This looks different from loader-v3 which serializes the length of the chunk as a u64 before the chunk data. Are you implying that the length isn't serialized here and that chunk_length_in_bytes is inferred from ix.data.len - 4 bytes (enum variant) - 4 bytes (offset)? I think we should match loader-v3 behavior and serialize the chunk length as well. But consider serializing the length as u16 or u32 instead of u64 to save some bytes
There was a problem hiding this comment.
What is the advantage of doing so? It would introduce additional failure cases of the explicit field and implicit calculation disagreeing.
|
|
||
| failing any of the above checks must throw `UnsupportedProgramId`. | ||
|
|
||
| ### Program Management Instructions |
There was a problem hiding this comment.
Should also add a note saying that instruction data length is limited to 1232 bytes to match loader-v3 behavior
proposals/0167-loader-v4.md
Outdated
| otherwise throw `InvalidArgument` | ||
| - Check that the executable length is not longer than the program account, | ||
| otherwise throw `InvalidArgument` | ||
| - Charge program_length_in_bytes / cpi_bytes_per_unit CUs |
There was a problem hiding this comment.
We should only charge for the executable length rather than the full account data length
| - Charge program_length_in_bytes / cpi_bytes_per_unit CUs | |
| - Charge executable length / cpi_bytes_per_unit CUs |
proposals/0167-loader-v4.md
Outdated
| - Charge program_length_in_bytes / cpi_bytes_per_unit CUs | ||
| - Check that the executable file stored in the program account passes | ||
| executable verification | ||
| - Change the executable length in the program account header |
There was a problem hiding this comment.
| - Change the executable length in the program account header | |
| - Change the executable length in the program account header to the specified | |
| value. |
|
If we explicitly encode the ELF length anyway, we might as well move the header down to become a footer: From |
5ac9b65
No description provided.