Revert "CLI: Put `deploy` ephemeral keypair behind a flag" (#12983)

This reverts commit 5a5b7f39c1.
This commit is contained in:
Tyera Eulberg 2020-10-19 12:44:32 -06:00 committed by GitHub
parent 456eae6ccb
commit cca318f805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 31 deletions

View File

@ -177,7 +177,6 @@ pub enum CliCommand {
program_location: String, program_location: String,
address: Option<SignerIndex>, address: Option<SignerIndex>,
use_deprecated_loader: bool, use_deprecated_loader: bool,
random_address: bool,
}, },
// Stake Commands // Stake Commands
CreateStakeAccount { CreateStakeAccount {
@ -610,14 +609,12 @@ pub fn parse_command(
1 1
}); });
let use_deprecated_loader = matches.is_present("use_deprecated_loader"); let use_deprecated_loader = matches.is_present("use_deprecated_loader");
let random_address = matches.is_present("random_address");
Ok(CliCommandInfo { Ok(CliCommandInfo {
command: CliCommand::Deploy { command: CliCommand::Deploy {
program_location: matches.value_of("program_location").unwrap().to_string(), program_location: matches.value_of("program_location").unwrap().to_string(),
address, address,
use_deprecated_loader, use_deprecated_loader,
random_address,
}, },
signers, signers,
}) })
@ -1134,16 +1131,12 @@ fn process_deploy(
program_location: &str, program_location: &str,
address: Option<SignerIndex>, address: Option<SignerIndex>,
use_deprecated_loader: bool, use_deprecated_loader: bool,
random_address: bool,
) -> ProcessResult { ) -> ProcessResult {
let new_keypair = Keypair::new(); // Create ephemeral keypair to use for program address, if not provided let new_keypair = Keypair::new(); // Create ephemeral keypair to use for program address, if not provided
let program_id = if let Some(i) = address { let program_id = if let Some(i) = address {
config.signers[i] config.signers[i]
} else if random_address {
&new_keypair
} else { } else {
// Clap will enforce one of the previous two conditions &new_keypair
unreachable!();
}; };
let mut file = File::open(program_location).map_err(|err| { let mut file = File::open(program_location).map_err(|err| {
CliError::DynamicProgramError(format!("Unable to open program file: {}", err)) CliError::DynamicProgramError(format!("Unable to open program file: {}", err))
@ -1584,14 +1577,12 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
program_location, program_location,
address, address,
use_deprecated_loader, use_deprecated_loader,
random_address,
} => process_deploy( } => process_deploy(
&rpc_client, &rpc_client,
config, config,
program_location, program_location,
*address, *address,
*use_deprecated_loader, *use_deprecated_loader,
*random_address,
), ),
// Stake Commands // Stake Commands
@ -2208,17 +2199,10 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.arg( .arg(
Arg::with_name("address_signer") Arg::with_name("address_signer")
.index(2) .index(2)
.value_name("ADDRESS_KEYPAIR") .value_name("SIGNER_KEYPAIR")
.takes_value(true) .takes_value(true)
.validator(is_valid_signer) .validator(is_valid_signer)
.required_unless("random_address") .help("The signer for the desired address of the program [default: new random address]")
.help("The signer for the desired program address. See also: --random-address")
)
.arg(
Arg::with_name("random_address")
.long("random-address")
.takes_value(false)
.help("Deploy at a random address. WARNING: Deployment cannot be retried!")
) )
.arg( .arg(
Arg::with_name("use_deprecated_loader") Arg::with_name("use_deprecated_loader")
@ -2581,12 +2565,10 @@ mod tests {
); );
// Test Deploy Subcommand // Test Deploy Subcommand
let test_deploy = test_commands.clone().get_matches_from(vec![ let test_deploy =
"test", test_commands
"deploy", .clone()
"/Users/test/program.o", .get_matches_from(vec!["test", "deploy", "/Users/test/program.o"]);
"--random-address",
]);
assert_eq!( assert_eq!(
parse_command(&test_deploy, &default_signer, &mut None).unwrap(), parse_command(&test_deploy, &default_signer, &mut None).unwrap(),
CliCommandInfo { CliCommandInfo {
@ -2594,7 +2576,6 @@ mod tests {
program_location: "/Users/test/program.o".to_string(), program_location: "/Users/test/program.o".to_string(),
address: None, address: None,
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: true,
}, },
signers: vec![read_keypair_file(&keypair_file).unwrap().into()], signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
} }
@ -2616,7 +2597,6 @@ mod tests {
program_location: "/Users/test/program.o".to_string(), program_location: "/Users/test/program.o".to_string(),
address: Some(1), address: Some(1),
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: false,
}, },
signers: vec![ signers: vec![
read_keypair_file(&keypair_file).unwrap().into(), read_keypair_file(&keypair_file).unwrap().into(),
@ -2930,7 +2910,6 @@ mod tests {
program_location: pathbuf.to_str().unwrap().to_string(), program_location: pathbuf.to_str().unwrap().to_string(),
address: None, address: None,
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: true,
}; };
let result = process_command(&config); let result = process_command(&config);
let json: Value = serde_json::from_str(&result.unwrap()).unwrap(); let json: Value = serde_json::from_str(&result.unwrap()).unwrap();
@ -2949,7 +2928,6 @@ mod tests {
program_location: "bad/file/location.so".to_string(), program_location: "bad/file/location.so".to_string(),
address: None, address: None,
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: true,
}; };
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
} }

View File

@ -64,7 +64,6 @@ fn test_cli_deploy_program() {
program_location: pathbuf.to_str().unwrap().to_string(), program_location: pathbuf.to_str().unwrap().to_string(),
address: None, address: None,
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: true,
}; };
let response = process_command(&config); let response = process_command(&config);
@ -99,7 +98,6 @@ fn test_cli_deploy_program() {
program_location: pathbuf.to_str().unwrap().to_string(), program_location: pathbuf.to_str().unwrap().to_string(),
address: Some(1), address: Some(1),
use_deprecated_loader: false, use_deprecated_loader: false,
random_address: false,
}; };
process_command(&config).unwrap(); process_command(&config).unwrap();
let account1 = rpc_client let account1 = rpc_client