diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index 90173595c..638671048 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -23,7 +23,7 @@ use { feature_set::{ add_get_processed_sibling_instruction_syscall, blake3_syscall_enabled, check_physical_overlapping, check_slice_translation_size, disable_fees_sysvar, - do_support_realloc, fixed_memcpy_nonoverlapping_check, + do_support_realloc, executables_incur_cpi_data_cost, fixed_memcpy_nonoverlapping_check, libsecp256k1_0_5_upgrade_enabled, limit_secp256k1_recovery_id, prevent_calling_precompiles_as_programs, return_data_syscall_enabled, secp256k1_recover_syscall_enabled, sol_log_data_syscall_enabled, @@ -2783,6 +2783,16 @@ where .map_err(SyscallError::InstructionError)?; if account.borrow().executable() { // Use the known account + if invoke_context + .feature_set + .is_active(&executables_incur_cpi_data_cost::id()) + { + invoke_context + .get_compute_meter() + .consume((account.borrow().data().len() as u64).saturating_div( + invoke_context.get_compute_budget().cpi_bytes_per_unit, + ))?; + } accounts.push((instruction_account.index_in_transaction, None)); } else if let Some(caller_account_index) = account_info_keys.iter().position(|key| *key == account_key) diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index b9b52245a..470aa3833 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -351,6 +351,10 @@ pub mod drop_redundant_turbine_path { solana_sdk::declare_id!("4Di3y24QFLt5QEUPZtbnjyfQKfm6ZMTfa6Dw1psfoMKU"); } +pub mod executables_incur_cpi_data_cost { + solana_sdk::declare_id!("7GUcYgq4tVtaqNCKT3dho9r4665Qp5TxCZ27Qgjx3829"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -433,6 +437,7 @@ lazy_static! { (error_on_syscall_bpf_function_hash_collisions::id(), "error on bpf function hash collisions"), (reject_callx_r10::id(), "Reject bpf callx r10 instructions"), (drop_redundant_turbine_path::id(), "drop redundant turbine path"), + (executables_incur_cpi_data_cost::id(), "Executables incure CPI data costs"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter()