Skip to content

Commit

Permalink
remove cli argument
Browse files Browse the repository at this point in the history
  • Loading branch information
jackcmay committed May 10, 2022
1 parent 154f73a commit 71faf4a
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 93 deletions.
8 changes: 0 additions & 8 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ pub enum CliCommand {
use_deprecated_loader: bool,
allow_excessive_balance: bool,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
},
Program(ProgramCliCommand),
// Stake Commands
Expand Down Expand Up @@ -651,7 +650,6 @@ pub fn parse_command(
use_deprecated_loader: matches.is_present("use_deprecated_loader"),
allow_excessive_balance: matches.is_present("allow_excessive_balance"),
skip_fee_check,
enable_sol_alloc_free: matches.is_present("enable_sol_alloc_free"),
},
signers,
})
Expand Down Expand Up @@ -1031,7 +1029,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
use_deprecated_loader,
allow_excessive_balance,
skip_fee_check,
enable_sol_alloc_free,
} => process_deploy(
rpc_client,
config,
Expand All @@ -1040,7 +1037,6 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*use_deprecated_loader,
*allow_excessive_balance,
*skip_fee_check,
*enable_sol_alloc_free,
),
CliCommand::Program(program_subcommand) => {
process_program_subcommand(rpc_client, config, program_subcommand)
Expand Down Expand Up @@ -1875,7 +1871,6 @@ mod tests {
use_deprecated_loader: false,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
},
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand All @@ -1899,7 +1894,6 @@ mod tests {
use_deprecated_loader: false,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
},
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2295,7 +2289,6 @@ mod tests {
use_deprecated_loader: false,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
};
config.output_format = OutputFormat::JsonCompact;
let result = process_command(&config);
Expand All @@ -2317,7 +2310,6 @@ mod tests {
use_deprecated_loader: false,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
};
assert!(process_command(&config).is_err());
}
Expand Down
51 changes: 5 additions & 46 deletions cli/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ pub enum ProgramCliCommand {
max_len: Option<usize>,
allow_excessive_balance: bool,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
},
WriteBuffer {
program_location: String,
Expand All @@ -76,7 +75,6 @@ pub enum ProgramCliCommand {
buffer_authority_signer_index: Option<SignerIndex>,
max_len: Option<usize>,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
},
SetBufferAuthority {
buffer_pubkey: Pubkey,
Expand Down Expand Up @@ -178,13 +176,6 @@ impl ProgramSubCommands for App<'_, '_> {
.long("allow-excessive-deploy-account-balance")
.takes_value(false)
.help("Use the designated program id even if the account already holds a large balance of SOL")
)
.arg(
Arg::with_name("enable_sol_alloc_free")
.long("enable_sol_alloc_free")
.takes_value(false)
.hidden(true)
.help("Enable support for _sol_alloc_free syscall")
),
)
.subcommand(
Expand Down Expand Up @@ -430,13 +421,6 @@ impl ProgramSubCommands for App<'_, '_> {
.long("skip-fee-check")
.hidden(true)
.takes_value(false)
)
.arg(
Arg::with_name("enable_sol_alloc_free")
.long("enable_sol_alloc_free")
.takes_value(false)
.hidden(true)
.help("Enable support for _sol_alloc_free syscall")
),
)
}
Expand Down Expand Up @@ -515,7 +499,6 @@ pub fn parse_program_subcommand(
max_len,
allow_excessive_balance: matches.is_present("allow_excessive_balance"),
skip_fee_check,
enable_sol_alloc_free: matches.is_present("enable_sol_alloc_free"),
}),
signers: signer_info.signers,
}
Expand Down Expand Up @@ -562,7 +545,6 @@ pub fn parse_program_subcommand(
.index_of_or_none(buffer_authority_pubkey),
max_len,
skip_fee_check,
enable_sol_alloc_free: matches.is_present("enable_sol_alloc_free"),
}),
signers: signer_info.signers,
}
Expand Down Expand Up @@ -712,7 +694,6 @@ pub fn process_program_subcommand(
max_len,
allow_excessive_balance,
skip_fee_check,
enable_sol_alloc_free,
} => process_program_deploy(
rpc_client,
config,
Expand All @@ -726,7 +707,6 @@ pub fn process_program_subcommand(
*max_len,
*allow_excessive_balance,
*skip_fee_check,
*enable_sol_alloc_free,
),
ProgramCliCommand::WriteBuffer {
program_location,
Expand All @@ -735,7 +715,6 @@ pub fn process_program_subcommand(
buffer_authority_signer_index,
max_len,
skip_fee_check,
enable_sol_alloc_free,
} => process_write_buffer(
rpc_client,
config,
Expand All @@ -745,7 +724,6 @@ pub fn process_program_subcommand(
*buffer_authority_signer_index,
*max_len,
*skip_fee_check,
*enable_sol_alloc_free,
),
ProgramCliCommand::SetBufferAuthority {
buffer_pubkey,
Expand Down Expand Up @@ -844,7 +822,6 @@ fn process_program_deploy(
max_len: Option<usize>,
allow_excessive_balance: bool,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
) -> ProcessResult {
let (words, mnemonic, buffer_keypair) = create_ephemeral_keypair()?;
let (buffer_provided, buffer_signer, buffer_pubkey) = if let Some(i) = buffer_signer_index {
Expand Down Expand Up @@ -938,7 +915,7 @@ fn process_program_deploy(
};

let (program_data, program_len) = if let Some(program_location) = program_location {
let program_data = read_and_verify_elf(program_location, enable_sol_alloc_free)?;
let program_data = read_and_verify_elf(program_location)?;
let program_len = program_data.len();
(program_data, program_len)
} else if buffer_provided {
Expand Down Expand Up @@ -1038,7 +1015,6 @@ fn process_write_buffer(
buffer_authority_signer_index: Option<SignerIndex>,
max_len: Option<usize>,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
) -> ProcessResult {
// Create ephemeral keypair to use for Buffer account, if not provided
let (words, mnemonic, buffer_keypair) = create_ephemeral_keypair()?;
Expand Down Expand Up @@ -1083,7 +1059,7 @@ fn process_write_buffer(
}
}

let program_data = read_and_verify_elf(program_location, enable_sol_alloc_free)?;
let program_data = read_and_verify_elf(program_location)?;
let buffer_data_len = if let Some(len) = max_len {
len
} else {
Expand Down Expand Up @@ -1694,7 +1670,6 @@ pub fn process_deploy(
use_deprecated_loader: bool,
allow_excessive_balance: bool,
skip_fee_check: bool,
enable_sol_alloc_free: bool,
) -> ProcessResult {
// Create ephemeral keypair to use for Buffer account, if not provided
let (words, mnemonic, buffer_keypair) = create_ephemeral_keypair()?;
Expand All @@ -1704,7 +1679,7 @@ pub fn process_deploy(
&buffer_keypair
};

let program_data = read_and_verify_elf(program_location, enable_sol_alloc_free)?;
let program_data = read_and_verify_elf(program_location)?;
let minimum_balance = rpc_client.get_minimum_balance_for_rent_exemption(program_data.len())?;
let loader_id = if use_deprecated_loader {
bpf_loader_deprecated::id()
Expand Down Expand Up @@ -2052,10 +2027,7 @@ fn do_process_program_upgrade(
Ok(config.output_format.formatted_string(&program_id))
}

fn read_and_verify_elf(
program_location: &str,
enable_sol_alloc_free: bool,
) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
fn read_and_verify_elf(program_location: &str) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
let mut file = File::open(program_location)
.map_err(|err| format!("Unable to open program file: {}", err))?;
let mut program_data = Vec::new();
Expand All @@ -2072,7 +2044,7 @@ fn read_and_verify_elf(
reject_broken_elfs: true,
..Config::default()
},
register_syscalls(&mut invoke_context, !enable_sol_alloc_free).unwrap(),
register_syscalls(&mut invoke_context, true).unwrap(),
)
.map_err(|err| format!("ELF error: {}", err))?;

Expand Down Expand Up @@ -2326,7 +2298,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand Down Expand Up @@ -2354,7 +2325,6 @@ mod tests {
max_len: Some(42),
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand Down Expand Up @@ -2384,7 +2354,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2416,7 +2385,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand Down Expand Up @@ -2447,7 +2415,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2481,7 +2448,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2511,7 +2477,6 @@ mod tests {
max_len: None,
skip_fee_check: false,
allow_excessive_balance: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand Down Expand Up @@ -2545,7 +2510,6 @@ mod tests {
buffer_authority_signer_index: Some(0),
max_len: None,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand All @@ -2570,7 +2534,6 @@ mod tests {
buffer_authority_signer_index: Some(0),
max_len: Some(42),
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![read_keypair_file(&keypair_file).unwrap().into()],
}
Expand Down Expand Up @@ -2598,7 +2561,6 @@ mod tests {
buffer_authority_signer_index: Some(0),
max_len: None,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2629,7 +2591,6 @@ mod tests {
buffer_authority_signer_index: Some(1),
max_len: None,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -2665,7 +2626,6 @@ mod tests {
buffer_authority_signer_index: Some(2),
max_len: None,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![
read_keypair_file(&keypair_file).unwrap().into(),
Expand Down Expand Up @@ -3109,7 +3069,6 @@ mod tests {
max_len: None,
allow_excessive_balance: false,
skip_fee_check: false,
enable_sol_alloc_free: false,
}),
signers: vec![&default_keypair],
output_format: OutputFormat::JsonCompact,
Expand Down
Loading

0 comments on commit 71faf4a

Please sign in to comment.