Skip to content

Commit

Permalink
use verify-with-signer on --remote, same as remote submit-job, to mak…
Browse files Browse the repository at this point in the history
…e API behavior consistent, and improve error messages
  • Loading branch information
ngundotra committed Dec 19, 2024
1 parent 74facb5 commit f2a5a9f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
40 changes: 26 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use signal_hook::{
};
use solana_cli_config::{Config, CONFIG_FILE};
use solana_client::rpc_client::RpcClient;
use solana_program::get_address_from_keypair_or_config;
use solana_sdk::{
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
pubkey::Pubkey,
Expand Down Expand Up @@ -1265,7 +1266,7 @@ pub async fn verify_from_repo(
program_id,
connection,
skip_prompt,
path_to_keypair,
path_to_keypair.clone(),
compute_unit_price,
)
.await?;
Expand All @@ -1277,18 +1278,23 @@ pub async fn verify_from_repo(
return Err(anyhow!("Remote verification only works with mainnet. Please omit the --remote flag to verify locally."));
}

println!("Sending verify command to remote machine...");
send_job_to_remote(
&repo_url,
&commit_hash,
&program_id,
&library_name_opt.clone(),
bpf_flag,
relative_mount_path.clone(),
base_image.clone(),
cargo_args.clone(),
)
.await?;
let uploader = get_address_from_keypair_or_config(path_to_keypair.as_ref())?;
println!(
"Sending verify command to remote machine with uploader: {}",
&uploader
);
send_job_with_uploader_to_remote(&connection, &program_id, &uploader).await?;
// send_job_to_remote(
// &repo_url,
// &commit_hash,
// &program_id,
// &library_name_opt.clone(),
// bpf_flag,
// relative_mount_path.clone(),
// base_image.clone(),
// cargo_args.clone(),
// )
// .await?;
}

Ok(())
Expand All @@ -1299,7 +1305,13 @@ pub async fn verify_from_repo(
Ok(())
}
}
Err(e) => Err(anyhow!("Error verifying program: {:?}", e)),
Err(e) => {
eprintln!(
"\nPlease note that if the desired uploader is not the provided keypair, you will need to run `solana-verify remote submit-job --program-id {} --uploader <uploader-address>.\n",
&program_id,
);
Err(anyhow!("Error verifying program: {:?}", e))
}
}
}

Expand Down
18 changes: 11 additions & 7 deletions src/solana_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,16 @@ pub fn resolve_rpc_url(url: Option<String>) -> anyhow::Result<RpcClient> {
Ok(connection)
}

pub fn get_address_from_keypair_or_config(
path_to_keypair: Option<&String>,
) -> anyhow::Result<Pubkey> {
if let Some(path_to_keypair) = path_to_keypair {
Ok(get_keypair_from_path(&path_to_keypair)?.pubkey())
} else {
Ok(get_user_config()?.0.pubkey())
}
}

#[allow(clippy::too_many_arguments)]
pub async fn upload_program_verification_data(
git_url: String,
Expand All @@ -226,13 +236,7 @@ pub async fn upload_program_verification_data(
{
println!("Uploading the program verification params to the Solana blockchain...");

let cli_config = get_user_config()?;

let signer_pubkey: Pubkey = if let Some(ref path_to_keypair) = path_to_keypair {
get_keypair_from_path(path_to_keypair)?.pubkey()
} else {
cli_config.0.pubkey()
};
let signer_pubkey: Pubkey = get_address_from_keypair_or_config(path_to_keypair.as_ref())?;

// let rpc_url = connection.url();
println!("Using connection url: {}", connection.url());
Expand Down

0 comments on commit f2a5a9f

Please sign in to comment.