Update feature switch for reduced required deploy balance (#19999)

This commit is contained in:
Justin Starry 2021-09-19 14:50:41 -05:00 committed by GitHub
parent f579f73700
commit ea34eb8a4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -32,7 +32,7 @@ use solana_sdk::{
entrypoint::{HEAP_LENGTH, SUCCESS}, entrypoint::{HEAP_LENGTH, SUCCESS},
feature_set::{ feature_set::{
add_missing_program_error_mappings, close_upgradeable_program_accounts, fix_write_privs, add_missing_program_error_mappings, close_upgradeable_program_accounts, fix_write_privs,
stop_verify_mul64_imm_nonzero, reduce_required_deploy_balance, stop_verify_mul64_imm_nonzero,
}, },
ic_logger_msg, ic_msg, ic_logger_msg, ic_msg,
instruction::{AccountMeta, InstructionError}, instruction::{AccountMeta, InstructionError},
@ -390,7 +390,10 @@ fn process_loader_upgradeable_instruction(
return Err(InstructionError::InvalidArgument); return Err(InstructionError::InvalidArgument);
} }
if invoke_context.is_feature_active(&fix_write_privs::id()) { let predrain_buffer = invoke_context
.is_feature_active(&reduce_required_deploy_balance::id())
&& invoke_context.is_feature_active(&fix_write_privs::id());
if predrain_buffer {
// Drain the Buffer account to payer before paying for programdata account // Drain the Buffer account to payer before paying for programdata account
payer payer
.try_account_ref_mut()? .try_account_ref_mut()?
@ -448,7 +451,7 @@ fn process_loader_upgradeable_instruction(
})?; })?;
program.try_account_ref_mut()?.set_executable(true); program.try_account_ref_mut()?.set_executable(true);
if !invoke_context.is_feature_active(&fix_write_privs::id()) { if !predrain_buffer {
// Drain the Buffer account back to the payer // Drain the Buffer account back to the payer
payer payer
.try_account_ref_mut()? .try_account_ref_mut()?

View File

@ -207,6 +207,10 @@ pub mod fix_write_privs {
solana_sdk::declare_id!("7Tr5C1tdcCeBVD8jxtHYnvjL1DGdFboYBHCJkEFdenBb"); solana_sdk::declare_id!("7Tr5C1tdcCeBVD8jxtHYnvjL1DGdFboYBHCJkEFdenBb");
} }
pub mod reduce_required_deploy_balance {
solana_sdk::declare_id!("EBeznQDjcPG8491sFsKZYBi5S5jTVXMpAKNDJMQPS2kq");
}
lazy_static! { lazy_static! {
/// Map of feature identifiers to user-visible description /// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [ pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@ -254,6 +258,7 @@ lazy_static! {
(check_seed_length::id(), "Check program address seed lengths"), (check_seed_length::id(), "Check program address seed lengths"),
(return_data_syscall_enabled::id(), "enable sol_{set,get}_return_data syscall"), (return_data_syscall_enabled::id(), "enable sol_{set,get}_return_data syscall"),
(fix_write_privs::id(), "fix native invoke write privileges"), (fix_write_privs::id(), "fix native invoke write privileges"),
(reduce_required_deploy_balance::id(), "reduce required payer balance for program deploys"),
/*************** ADD NEW FEATURES HERE ***************/ /*************** ADD NEW FEATURES HERE ***************/
] ]
.iter() .iter()