Suliman Mukhtar
Suliman Mukhtar

Reputation: 46

Failed to upgrade solana program

I always close and redeploy but it's annoying. So I need to upgrade instead.

solana program upgrade target/deploy/program-keypair.json new_program.json owner.json -u "https://mainnet.helius-rpc.com/?api-key=7e466"

Error: Upgrading program failed: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: invalid program argument [3 log messages]

How to fix it or to find the log messages?

This is how I deploy:

solana program deploy target/deploy/program.so -u "https://mainnet.helius-rpc.com/?api-key=7e466" --program-id new_program.json

I tried with this simple program .

use solana_program::{
    account_info::AccountInfo,
    entrypoint,
    entrypoint::ProgramResult,
    pubkey::Pubkey,
    msg,
};

// declare and export the program's entrypoint
entrypoint!(process_instruction);

// program entrypoint's implementation
pub fn process_instruction(
    program_id: &Pubkey,
    accounts: &[AccountInfo],
    instruction_data: &[u8]
) -> ProgramResult {
    // log a message to the blockchain
    msg!("Hello, world!");
    // msg!("Hello, world!");
    Ok(())
}
[package]
name = "hello_world"
version = "0.1.0"
edition = "2018"

[lib]
name = "hello_world"
crate-type = ["cdylib", "lib"]

[dependencies]
solana-program = "1.18.2"

Upvotes: 0

Views: 913

Answers (2)

Suliman Mukhtar
Suliman Mukhtar

Reputation: 46

This could help someone like me.

The issue in my case was I'm using the target/deploy/program-keypair.json key-pair as the buffer account which is obviously wrong , instead you'll need to write a new buffer account (deploy the program to a buffer account) and then use the buffer Pubkey to do the upgrade.

so after deploying and you're willing to upgrade , you'll need to do this.

  1. solana program write-buffer path/to/program.so. (you'll get a buffer pubkey).

  2. solana program upgrade BUFFER_PUBKEY PROGRAM_PUBKEY.

Upvotes: 0

TheLazySol
TheLazySol

Reputation: 1

The error means that the RPC provider may be overloaded, so try later or try using a different RPC and try again. I have had some similar issues in the past and surprisingly the default mainnet RPC works better. I would also note that deploying and upgrading programs can become costly, so make sure you have enough SOL in your mainnet wallet.

You can also try using GenesysGO by Alchemy and use their free API.

Upvotes: 0

Related Questions