diff --git a/cli/src/program.rs b/cli/src/program.rs index 34b6341236..4993538049 100644 --- a/cli/src/program.rs +++ b/cli/src/program.rs @@ -122,7 +122,6 @@ impl ProgramSubCommands for App<'_, '_> { .value_name("BUFFER_SIGNER") .takes_value(true) .validator(is_valid_signer) - .conflicts_with("program_location") .help("Intermediate buffer account to write data to, which can be used to resume a failed deploy \ [default: random address]") ) @@ -695,7 +694,11 @@ fn process_program_deploy( true }; - let (program_data, program_len) = if buffer_provided { + let (program_data, program_len) = if let Some(program_location) = program_location { + let program_data = read_and_verify_elf(&program_location)?; + let program_len = program_data.len(); + (program_data, program_len) + } else if buffer_provided { // Check supplied buffer account if let Some(account) = rpc_client .get_account_with_commitment(&buffer_pubkey, config.commitment)? @@ -712,10 +715,6 @@ fn process_program_deploy( } else { return Err("Buffer account not found, was it already consumed?".into()); } - } else if let Some(program_location) = program_location { - let program_data = read_and_verify_elf(&program_location)?; - let program_len = program_data.len(); - (program_data, program_len) } else { return Err("Program location required if buffer not supplied".into()); }; diff --git a/docs/src/cli/deploy-a-program.md b/docs/src/cli/deploy-a-program.md index 28d87d4223..7cee809081 100644 --- a/docs/src/cli/deploy-a-program.md +++ b/docs/src/cli/deploy-a-program.md @@ -112,6 +112,40 @@ Note that program accounts are required to be `max-len` is fixed after initial deployment, so any SOL in the program accounts is locked up permanently. +### Resuming a failed deploy + +If program deployment fails, there will be a hanging intermediate buffer account +that contains a non-zero balance. In order to recoup that balance you may +resume a failed deployment by providing the same intermediate buffer to a new +call to `deploy`. + +Deployment failures will print an error message specifying the seed phrase +needed to recover the generated intermediate buffer's keypair: + +```bash +======================================================================= +To resume a failed deploy, recover the ephemeral keypair file with +`solana-keygen recover` and the following 12-word seed phrase, +then pass it as the [BUFFER_SIGNER] argument to `solana deploy` or `solana write-buffer` +======================================================================= +spy axis cream equip bonus daring muffin fish noise churn broken diesel +======================================================================= +``` + +To recover the keypair: + +```bash +$ solana-keypair recover -o +``` + +When asked, enter the 12-word seed phrase. + +Then issue a new `deploy` command and specify the buffer: + +```bash +$ solana program deploy --buffer +``` + ### Set a program's upgrade authority The program's upgrade authority must to be present to deploy a program. If no