From 07b71329a773498a0bc3ba439b194549006e01e2 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sun, 19 Sep 2021 23:17:59 +0000 Subject: [PATCH] Update feature switch for reduced required deploy balance (backport #19999) (#20012) * Update feature switch for reduced required deploy balance (#19999) (cherry picked from commit ea34eb8a4bf455423d10d8be14f17d82bb77a8f6) # Conflicts: # programs/bpf_loader/src/lib.rs * fix conflict Co-authored-by: Justin Starry --- programs/bpf_loader/src/lib.rs | 9 ++++++--- sdk/src/feature_set.rs | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/programs/bpf_loader/src/lib.rs b/programs/bpf_loader/src/lib.rs index 368a0dea54..251a84d801 100644 --- a/programs/bpf_loader/src/lib.rs +++ b/programs/bpf_loader/src/lib.rs @@ -34,7 +34,7 @@ use solana_sdk::{ entrypoint::{HEAP_LENGTH, SUCCESS}, feature_set::{ add_missing_program_error_mappings, close_upgradeable_program_accounts, fix_write_privs, - upgradeable_close_instruction, + reduce_required_deploy_balance, upgradeable_close_instruction, }, ic_logger_msg, ic_msg, instruction::{AccountMeta, InstructionError}, @@ -391,7 +391,10 @@ fn process_loader_upgradeable_instruction( 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 payer .try_account_ref_mut()? @@ -449,7 +452,7 @@ fn process_loader_upgradeable_instruction( })?; 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 payer .try_account_ref_mut()? diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index 3893a6f9fc..ea05579719 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -203,6 +203,10 @@ pub mod fix_write_privs { solana_sdk::declare_id!("7Tr5C1tdcCeBVD8jxtHYnvjL1DGdFboYBHCJkEFdenBb"); } +pub mod reduce_required_deploy_balance { + solana_sdk::declare_id!("EBeznQDjcPG8491sFsKZYBi5S5jTVXMpAKNDJMQPS2kq"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -254,6 +258,7 @@ lazy_static! { (allow_native_ids::id(), "allow native program ids in program derived addresses"), (check_seed_length::id(), "Check program address seed lengths"), (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 ***************/ ] .iter()