Revert "cli: Add (hidden) --use-deprecated-loader flag to solana deploy (bp #11675) (#11866)" (#11872)

This reverts commit 97c3ff8a4f.
This commit is contained in:
Jack May
2020-08-26 23:44:06 -07:00
committed by GitHub
parent 81db361d77
commit 734e669581
2 changed files with 21 additions and 63 deletions

View File

@ -37,7 +37,7 @@ use solana_faucet::faucet::request_airdrop_transaction;
use solana_faucet::faucet_mock::request_airdrop_transaction; use solana_faucet::faucet_mock::request_airdrop_transaction;
use solana_remote_wallet::remote_wallet::RemoteWalletManager; use solana_remote_wallet::remote_wallet::RemoteWalletManager;
use solana_sdk::{ use solana_sdk::{
bpf_loader, bpf_loader_deprecated, bpf_loader,
clock::{Epoch, Slot, DEFAULT_TICKS_PER_SECOND}, clock::{Epoch, Slot, DEFAULT_TICKS_PER_SECOND},
commitment_config::CommitmentConfig, commitment_config::CommitmentConfig,
decode_error::DecodeError, decode_error::DecodeError,
@ -278,10 +278,7 @@ pub enum CliCommand {
lamports: u64, lamports: u64,
}, },
// Program Deployment // Program Deployment
Deploy { Deploy(String),
program_location: String,
use_deprecated_loader: bool,
},
// Stake Commands // Stake Commands
CreateStakeAccount { CreateStakeAccount {
stake_account: SignerIndex, stake_account: SignerIndex,
@ -684,22 +681,15 @@ pub fn parse_command(
parse_withdraw_from_nonce_account(matches, default_signer_path, wallet_manager) parse_withdraw_from_nonce_account(matches, default_signer_path, wallet_manager)
} }
// Program Deployment // Program Deployment
("deploy", Some(matches)) => { ("deploy", Some(matches)) => Ok(CliCommandInfo {
let use_deprecated_loader = matches.is_present("use_deprecated_loader"); command: CliCommand::Deploy(matches.value_of("program_location").unwrap().to_string()),
signers: vec![signer_from_path(
Ok(CliCommandInfo { matches,
command: CliCommand::Deploy { default_signer_path,
program_location: matches.value_of("program_location").unwrap().to_string(), "keypair",
use_deprecated_loader, wallet_manager,
}, )?],
signers: vec![signer_from_path( }),
matches,
default_signer_path,
"keypair",
wallet_manager,
)?],
})
}
// Stake Commands // Stake Commands
("create-stake-account", Some(matches)) => { ("create-stake-account", Some(matches)) => {
parse_stake_create_account(matches, default_signer_path, wallet_manager) parse_stake_create_account(matches, default_signer_path, wallet_manager)
@ -1369,7 +1359,6 @@ fn process_deploy(
rpc_client: &RpcClient, rpc_client: &RpcClient,
config: &CliConfig, config: &CliConfig,
program_location: &str, program_location: &str,
use_deprecated_loader: bool,
) -> ProcessResult { ) -> ProcessResult {
let program_id = Keypair::new(); let program_id = Keypair::new();
let mut file = File::open(program_location).map_err(|err| { let mut file = File::open(program_location).map_err(|err| {
@ -1380,12 +1369,6 @@ fn process_deploy(
CliError::DynamicProgramError(format!("Unable to read program file: {}", err)) CliError::DynamicProgramError(format!("Unable to read program file: {}", err))
})?; })?;
let loader_id = if use_deprecated_loader {
bpf_loader_deprecated::id()
} else {
bpf_loader::id()
};
// Build transactions to calculate fees // Build transactions to calculate fees
let mut messages: Vec<&Message> = Vec::new(); let mut messages: Vec<&Message> = Vec::new();
let (blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?; let (blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?;
@ -1395,7 +1378,7 @@ fn process_deploy(
&program_id.pubkey(), &program_id.pubkey(),
minimum_balance.max(1), minimum_balance.max(1),
program_data.len() as u64, program_data.len() as u64,
&loader_id, &bpf_loader::id(),
); );
let message = Message::new(&[ix], Some(&config.signers[0].pubkey())); let message = Message::new(&[ix], Some(&config.signers[0].pubkey()));
let mut create_account_tx = Transaction::new_unsigned(message); let mut create_account_tx = Transaction::new_unsigned(message);
@ -1406,7 +1389,7 @@ fn process_deploy(
for (chunk, i) in program_data.chunks(DATA_CHUNK_SIZE).zip(0..) { for (chunk, i) in program_data.chunks(DATA_CHUNK_SIZE).zip(0..) {
let instruction = loader_instruction::write( let instruction = loader_instruction::write(
&program_id.pubkey(), &program_id.pubkey(),
&loader_id, &bpf_loader::id(),
(i * DATA_CHUNK_SIZE) as u32, (i * DATA_CHUNK_SIZE) as u32,
chunk.to_vec(), chunk.to_vec(),
); );
@ -1419,7 +1402,7 @@ fn process_deploy(
} }
messages.append(&mut write_message_refs); messages.append(&mut write_message_refs);
let instruction = loader_instruction::finalize(&program_id.pubkey(), &loader_id); let instruction = loader_instruction::finalize(&program_id.pubkey(), &bpf_loader::id());
let finalize_message = Message::new(&[instruction], Some(&signers[0].pubkey())); let finalize_message = Message::new(&[instruction], Some(&signers[0].pubkey()));
messages.push(&finalize_message); messages.push(&finalize_message);
@ -1942,15 +1925,9 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
// Program Deployment // Program Deployment
// Deploy a custom program to the chain // Deploy a custom program to the chain
CliCommand::Deploy { CliCommand::Deploy(ref program_location) => {
program_location, process_deploy(&rpc_client, config, program_location)
use_deprecated_loader, }
} => process_deploy(
&rpc_client,
config,
program_location,
*use_deprecated_loader,
),
// Stake Commands // Stake Commands
@ -2637,13 +2614,6 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
.takes_value(true) .takes_value(true)
.required(true) .required(true)
.help("/path/to/program.o"), .help("/path/to/program.o"),
)
.arg(
Arg::with_name("use-deprecated-loader")
.long("use_deprecated_loader")
.takes_value(false)
.hidden(true) // Don't document this argument to discourage its use
.help("Use the deprecated BPF loader")
), ),
) )
.subcommand( .subcommand(
@ -3088,10 +3058,7 @@ mod tests {
assert_eq!( assert_eq!(
parse_command(&test_deploy, &keypair_file, &mut None).unwrap(), parse_command(&test_deploy, &keypair_file, &mut None).unwrap(),
CliCommandInfo { CliCommandInfo {
command: CliCommand::Deploy { command: CliCommand::Deploy("/Users/test/program.o".to_string()),
program_location: "/Users/test/program.o".to_string(),
use_deprecated_loader: false,
},
signers: vec![read_keypair_file(&keypair_file).unwrap().into()], signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
} }
); );
@ -3815,10 +3782,7 @@ mod tests {
let default_keypair = Keypair::new(); let default_keypair = Keypair::new();
config.signers = vec![&default_keypair]; config.signers = vec![&default_keypair];
config.command = CliCommand::Deploy { config.command = CliCommand::Deploy(pathbuf.to_str().unwrap().to_string());
program_location: pathbuf.to_str().unwrap().to_string(),
use_deprecated_loader: false,
};
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();
let program_id = json let program_id = json
@ -3832,10 +3796,7 @@ mod tests {
assert!(program_id.parse::<Pubkey>().is_ok()); assert!(program_id.parse::<Pubkey>().is_ok());
// Failure case // Failure case
config.command = CliCommand::Deploy { config.command = CliCommand::Deploy("bad/file/location.so".to_string());
program_location: "bad/file/location.so".to_string(),
use_deprecated_loader: false,
};
assert!(process_command(&config).is_err()); assert!(process_command(&config).is_err());
} }

View File

@ -55,10 +55,7 @@ fn test_cli_deploy_program() {
config.signers = vec![&keypair]; config.signers = vec![&keypair];
process_command(&config).unwrap(); process_command(&config).unwrap();
config.command = CliCommand::Deploy { config.command = CliCommand::Deploy(pathbuf.to_str().unwrap().to_string());
program_location: pathbuf.to_str().unwrap().to_string(),
use_deprecated_loader: false,
};
let response = process_command(&config); let response = process_command(&config);
let json: Value = serde_json::from_str(&response.unwrap()).unwrap(); let json: Value = serde_json::from_str(&response.unwrap()).unwrap();