Program Deployment

Summary

Programs deployed via loader-v3 can be upgraded when an upgrade authority is set. Revoking the authority makes the program immutable. Covers the 9-step upgrade mechanism, all 9 loader-v3 instructions, build verification, and the 5 loader types.

Deploying programs

Upgrading programs

To upgrade a program, an account must hold the upgrade authority (typically the account that originally deployed the program). During deployment or upgrade, new bytecode is uploaded to a temporary buffer account, then written to the program data account. Setting the upgrade authority to None makes the program immutable and permanently prevents further updates.

Upgrade mechanism

When UpgradeableLoaderInstruction::Upgrade is processed, the runtime:

  1. Verifies the Program account is writable and owned by loader-v3.
  2. Verifies the Buffer account contains a Buffer state with the correct authority.
  3. Verifies the ProgramData account's upgrade_authority_address matches and is not None.
  4. Verifies the program was not already deployed in the current slot (clock.slot != slot).
  5. Loads and verifies the new ELF bytes from the buffer.
  6. Copies the new bytecode from the buffer into the ProgramData account and zeros remaining bytes.
  7. Funds the ProgramData account to rent-exemption.
  8. Drains the buffer account (sets lamports to 0) and truncates its data.
  9. The new version becomes effective in the next slot (deployment_slot + 1).

The Program account itself (its state and the programdata_address pointer) does not change during an upgrade. Only the ProgramData account's bytecode and slot metadata are updated.

Loader-v3 instruction reference

Loader-v3 (BPF Loader Upgradeable) is the current default loader for deploying programs on Solana.

InstructionDescription
InitializeBufferSets a buffer account's state to Buffer with the specified authority. Fails if already initialized.
WriteWrites bytes at the specified offset in a buffer account. Authority must sign.
DeployWithMaxDataLenCreates a new program: derives the ProgramData address, creates the ProgramData account via CPI to System Program, verifies and deploys the ELF from the buffer, sets the Program account's state and marks it executable.
UpgradeReplaces the bytecode in an existing program's ProgramData account from a buffer.
SetAuthorityChanges the authority of a Buffer or ProgramData account. Setting to None on ProgramData makes the program immutable. Buffer authority cannot be set to None.
SetAuthorityCheckedLike SetAuthority, but requires the new authority to also sign the transaction.
CloseCloses a buffer, uninitialized, or ProgramData account by transferring its lamports to a recipient. Closing ProgramData also writes a Closed tombstone to the program cache. Cannot close a program that was deployed in the current slot.
ExtendProgramCheckedExtends the ProgramData account's allocation by additional bytes, funding the extra rent from the payer.
MigrateMigrates a loader-v3 program to loader-v4 by transferring the program account's ownership and copying the bytecode. Requires the migration authority or the program's upgrade authority to sign. Loader-v4 is not yet released on mainnet.

Verifying programs

Solana supports verifiable builds, which let users confirm that a program's on-chain bytecode matches its public source code. The Anchor framework provides built-in support for verifiable builds.

To check verification status for a deployed program, search for its program ID on the Solana Explorer, or use the Ellipsis Labs Solana Verifiable Build CLI to independently verify on-chain programs.

Loader programs

LoaderAddressUpgradeableDescription
Native LoaderNativeLoader1111111111111111111111111111111Only via validator software upgradeOwns builtins (System, Vote, Stake) and other loaders
BPF Loader (v1)BPFLoader1111111111111111111111111111111111No (loader management disabled)Legacy programs
BPF Loader (v2)BPFLoader2111111111111111111111111111111111No (loader management disabled)Legacy programs
BPF Loader UpgradeableBPFLoaderUpgradeab1e11111111111111111111111Yes, if upgrade authority is setOwns all newly deployed programs
Loader-v4LoaderV411111111111111111111111111111111111Yes, if authority is setNot yet released on mainnet

Is this page helpful?

सामग्री तालिका

पृष्ठ संपादित करें

द्वारा प्रबंधित

© 2026 सोलाना फाउंडेशन। सर्वाधिकार सुरक्षित।
जुड़े रहें