What EIP-1967 defines
A proxy contract holds the state and forwards every call to an implementation contract withdelegatecall. EIP-1967 fixes the storage slots where the proxy
keeps the implementation address and the admin address, so tools can find them
and the slots do not collide with the implementation’s variables.
1
User calls the proxy
The proxy address never changes.
2
Proxy delegates
delegatecall runs the implementation’s code against the proxy’s storage.3
Admin upgrades
The admin points the proxy at a new implementation contract.
4
Storage must match
The new implementation has to keep the same storage layout.
How upgrades work on Solana
A Solana program’s address points to a program data account that stores the code and the upgrade authority. An upgrade writes new code into that account. Callers keep using the same program ID, and state is unaffected because it lives in separate accounts.An upgrade replaces the code in the program data account. The program ID and the data accounts that the program owns stay as they are.
EIP-1967 proxy
- You deploy a proxy and an implementation.
delegatecalladds gas to every call.- Storage collisions between versions can corrupt state.
- The admin is an address in a storage slot.
Solana program
- You deploy one program. Upgradeability is built in.
- Calls go directly to the program.
- State lives in separate accounts with their own layouts.
- The upgrade authority is a field of the program data account.
Upgrade, transfer, or lock a program
The upgrade authority signs each of these commands. Removing the authority with--final cannot be undone.
Terminal
Protect the upgrade authorityWhoever holds the upgrade authority can replace the program’s code. Move it to a
multisig or a governance program before launch. Such an address cannot sign in
the CLI, so pass it with
--skip-new-upgrade-authority-signer-check. After
that, upgrade by writing the new build to a buffer account and approving the
upgrade through the multisig. Publish a verified
build so users can confirm that the
deployed code matches your source.Migrate account data
An upgrade changes the code, and existing accounts keep their old layout. Plan the data change the way you would plan a storage layout change behind a proxy.1
Version your accounts
Store a version field in each account type so the program can tell layouts
apart.
2
Append new fields
Add fields at the end of a struct, and resize each existing account before the
new code reads it, unless you reserved padding. Reordering or removing fields
breaks deserialization of existing accounts.
3
Resize existing accounts
Grow an account with a reallocation, an instruction that changes its data size,
and fund the extra rent deposit. An account can grow by at most 10 KiB per
instruction.
4
Migrate lazily or in batches
Upgrade each account the next time its owner uses it, or run a script that calls
the migration instruction for every account.
Side by side
| Question | EIP-1967 proxy | Solana |
|---|---|---|
| What stays constant? | The proxy address | The program ID |
| Who can upgrade? | The proxy admin | The upgrade authority |
| How do you make it immutable? | Renounce the admin or deploy without a proxy | Set the upgrade authority to none |
| Where does state live? | In the proxy’s storage | In data accounts the program owns |
| How do users verify the code? | Verified source for the implementation | A verified build of the program |