Deployment Failure Recovery

Whenever a deployment is attempted using the svm::deploy_program action, two different accounts are created to aid in the deployment:

  • A buffer account, which holds the program data while the deployment is in progress, and
  • An ephemeral authority account, which is used to write to the buffer account

These two accounts are created automatically by the action, and are normally cleaned up after a successful deployment, returning all lamports to the payer. However, if the deployment fails before it is complete, these accounts will remain on-chain, and can be used to recover from the failure.

Your previous execution of the deployment, which created these accounts, will have logged this info to the CLI and to a file in the .surfpool directory of your project.

Option 1: Retry the deployment

To continue the failed deployment, provide the buffer_account_pubkey input with the public key of the buffer account, and the ephemeral_authority_secret_key input with the base-58 encoded secret key of the ephemeral authority account:

action "deploy" "svm::deploy_program" {
    description = "Deploy hello world program"
    program = svm::get_program_from_anchor_project("hello_world") 
    authority = signer.authority
    payer = signer.payer  # Optional, defaults to authority
    buffer_account_pubkey = "<buffer-account-pubkey>"
    ephemeral_authority_secret_key = "<ephemeral-authority-secret-key>"
}

Execute the runbook again, and the deployment will continue from where it left off.

Option 2: Close the accounts and return funds

If you do not wish to continue the deployment, you can close the buffer account and the ephemeral authority account, returning all lamports to the payer. Follow the following steps to redeem your funds.

  1. Create a temporary keypair file with the ephemeral authority Your secret key was logged as a base-58 encoded string when the deployment was first attempted. Save this string to a file named temp-keypair.json in the current directory, with the following format:
[<byte0>, <byte1>, ..., <byte63>]
  1. Close the buffer account and transfer funds
solana program close --buffers --recipient <recipient_address> --authority temp-keypair.json --keypair temp-keypair.json
  1. Close the ephemeral authority account and transfer funds
solana transfer --from temp-keypair.json <recipient_address> ALL --allow-unfunded-recipient --fee-payer temp-keypair.json
  1. Delete the temporary keypair file
rm temp-keypair.json

Was this page helpful?