cli: Don't overallocate upgradeable program if --final specified (#15011)
This commit is contained in:
parent
53423c99aa
commit
a1b9e00c14
|
@ -692,7 +692,7 @@ fn process_program_deploy(
|
|||
true
|
||||
};
|
||||
|
||||
let (program_data, buffer_data_len) = if buffer_provided {
|
||||
let (program_data, program_len) = if buffer_provided {
|
||||
// Check supplied buffer account
|
||||
if let Some(account) = rpc_client
|
||||
.get_account_with_commitment(&buffer_pubkey, config.commitment)?
|
||||
|
@ -711,15 +711,21 @@ fn process_program_deploy(
|
|||
}
|
||||
} else if let Some(program_location) = program_location {
|
||||
let program_data = read_and_verify_elf(&program_location)?;
|
||||
let buffer_data_len = if let Some(len) = max_len {
|
||||
len
|
||||
} else {
|
||||
program_data.len() * 2
|
||||
};
|
||||
(program_data, buffer_data_len)
|
||||
let program_len = program_data.len();
|
||||
(program_data, program_len)
|
||||
} else {
|
||||
return Err("Program location required if buffer not supplied".into());
|
||||
};
|
||||
let buffer_data_len = if let Some(len) = max_len {
|
||||
if program_len > len {
|
||||
return Err("Max length specified not large enough".into());
|
||||
}
|
||||
len
|
||||
} else if is_final {
|
||||
program_len
|
||||
} else {
|
||||
program_len * 2
|
||||
};
|
||||
let minimum_balance = rpc_client.get_minimum_balance_for_rent_exemption(
|
||||
UpgradeableLoaderState::programdata_len(buffer_data_len)?,
|
||||
)?;
|
||||
|
|
Loading…
Reference in New Issue