Skip to content

Commit

Permalink
Feature - disable_bpf_loader_instructions (#35104)
Browse files Browse the repository at this point in the history
* Remove feature gate for disable_bpf_loader_instructions.

* Disables related tests.
  • Loading branch information
Lichtso authored Feb 6, 2024
1 parent 4f00402 commit 09e0300
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions programs/bpf_loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ use {
feature_set::{
bpf_account_data_direct_mapping, cap_accounts_data_allocations_per_transaction,
cap_bpf_program_instruction_accounts, delay_visibility_of_program_deployment,
disable_bpf_loader_instructions, enable_bpf_loader_extend_program_ix,
enable_bpf_loader_set_authority_checked_ix, enable_program_redeployment_cooldown,
limit_max_instruction_trace_length, native_programs_consume_cu,
remove_bpf_loader_incorrect_program_id,
enable_bpf_loader_extend_program_ix, enable_bpf_loader_set_authority_checked_ix,
enable_program_redeployment_cooldown, limit_max_instruction_trace_length,
native_programs_consume_cu, remove_bpf_loader_incorrect_program_id,
},
instruction::{AccountMeta, InstructionError},
loader_instruction::LoaderInstruction,
Expand Down Expand Up @@ -510,20 +509,11 @@ pub fn process_instruction_inner(
if native_programs_consume_cu {
invoke_context.consume_checked(DEFAULT_LOADER_COMPUTE_UNITS)?;
}
// Return `UnsupportedProgramId` error for bpf_loader when
// `disable_bpf_loader_instruction` feature is activated.
if invoke_context
.feature_set
.is_active(&disable_bpf_loader_instructions::id())
{
ic_logger_msg!(
log_collector,
"BPF loader management instructions are no longer supported"
);
Err(InstructionError::UnsupportedProgramId)
} else {
process_loader_instruction(invoke_context)
}
ic_logger_msg!(
log_collector,
"BPF loader management instructions are no longer supported"
);
Err(InstructionError::UnsupportedProgramId)
} else if bpf_loader_deprecated::check_id(program_id) {
if native_programs_consume_cu {
invoke_context.consume_checked(DEPRECATED_LOADER_COMPUTE_UNITS)?;
Expand Down Expand Up @@ -1486,7 +1476,7 @@ fn common_close_account(
Ok(())
}

fn process_loader_instruction(invoke_context: &mut InvokeContext) -> Result<(), InstructionError> {
fn _process_loader_instruction(invoke_context: &mut InvokeContext) -> Result<(), InstructionError> {
let transaction_context = &invoke_context.transaction_context;
let instruction_context = transaction_context.get_current_instruction_context()?;
let instruction_data = instruction_context.get_instruction_data();
Expand Down Expand Up @@ -1787,7 +1777,6 @@ mod tests {
},
account_utils::StateMut,
clock::Clock,
feature_set::FeatureSet,
instruction::{AccountMeta, InstructionError},
pubkey::Pubkey,
rent::Rent,
Expand Down Expand Up @@ -1826,9 +1815,6 @@ mod tests {
expected_result,
Entrypoint::vm,
|invoke_context| {
let mut features = FeatureSet::all_enabled();
features.deactivate(&disable_bpf_loader_instructions::id());
invoke_context.feature_set = Arc::new(features);
test_utils::load_all_invoked_programs(invoke_context);
},
|_invoke_context| {},
Expand All @@ -1847,6 +1833,7 @@ mod tests {
program_account
}

#[ignore]
#[test]
fn test_bpf_loader_write() {
let loader_id = bpf_loader::id();
Expand Down Expand Up @@ -1914,6 +1901,7 @@ mod tests {
);
}

#[ignore]
#[test]
fn test_bpf_loader_finalize() {
let loader_id = bpf_loader::id();
Expand Down Expand Up @@ -1978,6 +1966,7 @@ mod tests {
);
}

#[ignore]
#[test]
fn test_bpf_loader_invoke_main() {
let loader_id = bpf_loader::id();
Expand Down Expand Up @@ -2048,9 +2037,6 @@ mod tests {
Err(InstructionError::ProgramFailedToComplete),
Entrypoint::vm,
|invoke_context| {
let mut features = FeatureSet::all_enabled();
features.deactivate(&disable_bpf_loader_instructions::id());
invoke_context.feature_set = Arc::new(features);
invoke_context.mock_set_remaining(0);
test_utils::load_all_invoked_programs(invoke_context);
},
Expand Down Expand Up @@ -2596,11 +2582,7 @@ mod tests {
instruction_accounts,
expected_result,
Entrypoint::vm,
|invoke_context| {
let mut features = FeatureSet::all_enabled();
features.deactivate(&disable_bpf_loader_instructions::id());
invoke_context.feature_set = Arc::new(features);
},
|_invoke_context| {},
|_invoke_context| {},
)
}
Expand Down

0 comments on commit 09e0300

Please sign in to comment.