3

so recently I came across a tweet suggesting lazy developers to close program buffers with:

solana program close --buffers -u m

I know buffers are something like temp accounts used during program deploy, but I'm looking for some more deep explanation on how a solana program deploy works, when program buffers are created and where's the difference between a program buffer and a program executable data. Unfortunately the official docs doesn't cover the full process.

I just checked with the following command:

solana program show --buffers -k ~/path/to/authority.json -u m

and I have some SOL locked from previous deployment, so I'm looking to free it but I'd like to better understand the underlying process, to be sure I won't break anything.

1 Answer 1

3

To give a quick rundown, a program account is actually just data for a pubkey pointing towards the account that actually contains the program executable data.

The program executable data account contains a few things:

  • authority
  • last deploy slot
  • executable data

For example, the token metadata program at https://explorer.solana.com/address/metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s actually has its data at https://explorer.solana.com/address/PwDiXFxQsGra4sFFTT8r1QWRMd4vfumiWC1jfWNfdYT.

When you upgrade a program, you create a new buffer account, write your program data to it, then swap its data with the previous executable data. This means that any buffer account that you're not actively trying to use for an upgrade is safe to cleanup and recover the SOL.

There are more complete docs available at https://docs.solana.com/cli/deploy-a-program#closing-program-and-buffer-accounts-and-reclaiming-their-lamports

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.