Skip to content

Commit 3e1aa3b

Browse files
authored
Cleanup - Feature gate of remove_accounts_executable_flag_checks (#6847)
* Cleans the feature gate of remove_accounts_executable_flag_checks. * Removes BorrowedAccount::is_executable_internal().
1 parent ccbf967 commit 3e1aa3b

File tree

9 files changed

+42
-205
lines changed

9 files changed

+42
-205
lines changed

feature-set/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ impl FeatureSet {
104104
SVMFeatureSet {
105105
move_precompile_verification_to_svm: self
106106
.is_active(&move_precompile_verification_to_svm::id()),
107-
remove_accounts_executable_flag_checks: self
108-
.is_active(&remove_accounts_executable_flag_checks::id()),
109107
stricter_abi_and_runtime_constraints: self
110108
.is_active(&stricter_abi_and_runtime_constraints::id()),
111109
enable_bpf_loader_set_authority_checked_ix: self

program-runtime/src/invoke_context.rs

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -444,15 +444,6 @@ impl<'a> InvokeContext<'a> {
444444
})?;
445445
let borrowed_program_account = instruction_context
446446
.try_borrow_instruction_account(self.transaction_context, program_account_index)?;
447-
#[allow(deprecated)]
448-
if !self
449-
.get_feature_set()
450-
.remove_accounts_executable_flag_checks
451-
&& !borrowed_program_account.is_executable()
452-
{
453-
ic_msg!(self, "Account {} is not executable", callee_program_id);
454-
return Err(InstructionError::AccountNotExecutable);
455-
}
456447

457448
borrowed_program_account.get_index_in_transaction()
458449
};
@@ -561,21 +552,14 @@ impl<'a> InvokeContext<'a> {
561552
let owner_id = borrowed_root_account.get_owner();
562553
if native_loader::check_id(owner_id) {
563554
*borrowed_root_account.get_key()
564-
} else if self
565-
.get_feature_set()
566-
.remove_accounts_executable_flag_checks
555+
} else if bpf_loader_deprecated::check_id(owner_id)
556+
|| bpf_loader::check_id(owner_id)
557+
|| bpf_loader_upgradeable::check_id(owner_id)
558+
|| loader_v4::check_id(owner_id)
567559
{
568-
if bpf_loader_deprecated::check_id(owner_id)
569-
|| bpf_loader::check_id(owner_id)
570-
|| bpf_loader_upgradeable::check_id(owner_id)
571-
|| loader_v4::check_id(owner_id)
572-
{
573-
*owner_id
574-
} else {
575-
return Err(InstructionError::UnsupportedProgramId);
576-
}
577-
} else {
578560
*owner_id
561+
} else {
562+
return Err(InstructionError::UnsupportedProgramId);
579563
}
580564
};
581565

programs/bpf_loader/src/lib.rs

Lines changed: 10 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -403,46 +403,20 @@ pub(crate) fn process_instruction_inner(
403403
Err(InstructionError::UnsupportedProgramId)
404404
} else {
405405
ic_logger_msg!(log_collector, "Invalid BPF loader id");
406-
Err(
407-
if invoke_context
408-
.get_feature_set()
409-
.remove_accounts_executable_flag_checks
410-
{
411-
InstructionError::UnsupportedProgramId
412-
} else {
413-
InstructionError::IncorrectProgramId
414-
},
415-
)
406+
Err(InstructionError::UnsupportedProgramId)
416407
}
417408
.map(|_| 0)
418409
.map_err(|error| Box::new(error) as Box<dyn std::error::Error>);
419410
}
420411

421412
// Program Invocation
422-
#[allow(deprecated)]
423-
if !invoke_context
424-
.get_feature_set()
425-
.remove_accounts_executable_flag_checks
426-
&& !program_account.is_executable()
427-
{
428-
ic_logger_msg!(log_collector, "Program is not executable");
429-
return Err(Box::new(InstructionError::IncorrectProgramId));
430-
}
431-
432413
let mut get_or_create_executor_time = Measure::start("get_or_create_executor_time");
433414
let executor = invoke_context
434415
.program_cache_for_tx_batch
435416
.find(program_account.get_key())
436417
.ok_or_else(|| {
437418
ic_logger_msg!(log_collector, "Program is not cached");
438-
if invoke_context
439-
.get_feature_set()
440-
.remove_accounts_executable_flag_checks
441-
{
442-
InstructionError::UnsupportedProgramId
443-
} else {
444-
InstructionError::InvalidAccountData
445-
}
419+
InstructionError::UnsupportedProgramId
446420
})?;
447421
drop(program_account);
448422
get_or_create_executor_time.stop();
@@ -453,28 +427,10 @@ pub(crate) fn process_instruction_inner(
453427
| ProgramCacheEntryType::Closed
454428
| ProgramCacheEntryType::DelayVisibility => {
455429
ic_logger_msg!(log_collector, "Program is not deployed");
456-
let instruction_error = if invoke_context
457-
.get_feature_set()
458-
.remove_accounts_executable_flag_checks
459-
{
460-
InstructionError::UnsupportedProgramId
461-
} else {
462-
InstructionError::InvalidAccountData
463-
};
464-
Err(Box::new(instruction_error) as Box<dyn std::error::Error>)
430+
Err(Box::new(InstructionError::UnsupportedProgramId) as Box<dyn std::error::Error>)
465431
}
466432
ProgramCacheEntryType::Loaded(executable) => execute(executable, invoke_context),
467-
_ => {
468-
let instruction_error = if invoke_context
469-
.get_feature_set()
470-
.remove_accounts_executable_flag_checks
471-
{
472-
InstructionError::UnsupportedProgramId
473-
} else {
474-
InstructionError::IncorrectProgramId
475-
};
476-
Err(Box::new(instruction_error) as Box<dyn std::error::Error>)
477-
}
433+
_ => Err(Box::new(InstructionError::UnsupportedProgramId) as Box<dyn std::error::Error>),
478434
}
479435
.map(|_| 0)
480436
}
@@ -730,15 +686,6 @@ fn process_loader_upgradeable_instruction(
730686

731687
let program =
732688
instruction_context.try_borrow_instruction_account(transaction_context, 1)?;
733-
#[allow(deprecated)]
734-
if !invoke_context
735-
.get_feature_set()
736-
.remove_accounts_executable_flag_checks
737-
&& !program.is_executable()
738-
{
739-
ic_logger_msg!(log_collector, "Program account not executable");
740-
return Err(InstructionError::AccountNotExecutable);
741-
}
742689
if !program.is_writable() {
743690
ic_logger_msg!(log_collector, "Program account not writeable");
744691
return Err(InstructionError::InvalidArgument);
@@ -1881,13 +1828,11 @@ mod tests {
18811828
solana_epoch_schedule::EpochSchedule,
18821829
solana_instruction::{error::InstructionError, AccountMeta},
18831830
solana_program_runtime::{
1884-
invoke_context::{mock_process_instruction, mock_process_instruction_with_feature_set},
1885-
with_mock_invoke_context,
1831+
invoke_context::mock_process_instruction, with_mock_invoke_context,
18861832
},
18871833
solana_pubkey::Pubkey,
18881834
solana_rent::Rent,
18891835
solana_sdk_ids::{system_program, sysvar},
1890-
solana_svm_feature_set::SVMFeatureSet,
18911836
std::{fs::File, io::Read, ops::Range, sync::atomic::AtomicU64},
18921837
};
18931838

@@ -2002,23 +1947,19 @@ mod tests {
20021947
|_invoke_context| {},
20031948
);
20041949

2005-
let mut feature_set = SVMFeatureSet::all_enabled();
2006-
feature_set.remove_accounts_executable_flag_checks = false;
2007-
20081950
// Case: Account not a program
2009-
mock_process_instruction_with_feature_set(
1951+
mock_process_instruction(
20101952
&loader_id,
20111953
Some(0),
20121954
&[],
20131955
vec![(program_id, parameter_account.clone())],
20141956
Vec::new(),
2015-
Err(InstructionError::IncorrectProgramId),
1957+
Err(InstructionError::UnsupportedProgramId),
20161958
Entrypoint::vm,
20171959
|invoke_context| {
20181960
test_utils::load_all_invoked_programs(invoke_context);
20191961
},
20201962
|_invoke_context| {},
2021-
&feature_set,
20221963
);
20231964
process_instruction(
20241965
&loader_id,
@@ -2688,7 +2629,7 @@ mod tests {
26882629
Err(InstructionError::AccountBorrowFailed),
26892630
);
26902631

2691-
// Case: Program account not executable
2632+
// Case: Program account not a program
26922633
let (transaction_accounts, mut instruction_accounts) = get_accounts(
26932634
&buffer_address,
26942635
&upgrade_authority_address,
@@ -2699,22 +2640,18 @@ mod tests {
26992640
*instruction_accounts.get_mut(1).unwrap() = instruction_accounts.get(2).unwrap().clone();
27002641
let instruction_data = bincode::serialize(&UpgradeableLoaderInstruction::Upgrade).unwrap();
27012642

2702-
let mut feature_set = SVMFeatureSet::all_enabled();
2703-
feature_set.remove_accounts_executable_flag_checks = false;
2704-
2705-
mock_process_instruction_with_feature_set(
2643+
mock_process_instruction(
27062644
&bpf_loader_upgradeable::id(),
27072645
None,
27082646
&instruction_data,
27092647
transaction_accounts.clone(),
27102648
instruction_accounts.clone(),
2711-
Err(InstructionError::AccountNotExecutable),
2649+
Err(InstructionError::InvalidAccountData),
27122650
Entrypoint::vm,
27132651
|invoke_context| {
27142652
test_utils::load_all_invoked_programs(invoke_context);
27152653
},
27162654
|_invoke_context| {},
2717-
&feature_set,
27182655
);
27192656
process_instruction(
27202657
transaction_accounts.clone(),

runtime/src/bank/tests.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7209,7 +7209,6 @@ fn test_invoke_non_program_account_owned_by_a_builtin(
72097209
) {
72107210
let (genesis_config, mint_keypair) = create_genesis_config(10000000);
72117211
let mut bank = Bank::new_for_tests(&genesis_config);
7212-
bank.activate_feature(&feature_set::remove_accounts_executable_flag_checks::id());
72137212
if formalize_loaded_transaction_data_size {
72147213
bank.activate_feature(&feature_set::formalize_loaded_transaction_data_size::id());
72157214
}
@@ -11551,11 +11550,7 @@ fn test_deploy_last_epoch_slot() {
1155111550
&mut genesis_config,
1155211551
agave_feature_set::enable_loader_v4::id(),
1155311552
);
11554-
genesis_config
11555-
.accounts
11556-
.remove(&feature_set::remove_accounts_executable_flag_checks::id());
11557-
let mut bank = Bank::new_for_tests(&genesis_config);
11558-
bank.activate_feature(&feature_set::remove_accounts_executable_flag_checks::id());
11553+
let bank = Bank::new_for_tests(&genesis_config);
1155911554

1156011555
// go to the last slot in the epoch
1156111556
let (bank, bank_forks) = bank.wrap_with_bank_forks_for_tests();
@@ -11657,7 +11652,6 @@ fn test_loader_v3_to_v4_migration(formalize_loaded_transaction_data_size: bool)
1165711652
agave_feature_set::enable_loader_v4::id(),
1165811653
);
1165911654
let mut bank = Bank::new_for_tests(&genesis_config);
11660-
bank.activate_feature(&feature_set::remove_accounts_executable_flag_checks::id());
1166111655
if formalize_loaded_transaction_data_size {
1166211656
bank.activate_feature(&feature_set::formalize_loaded_transaction_data_size::id());
1166311657
}

svm-feature-set/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#[derive(Clone, Copy, Default)]
22
pub struct SVMFeatureSet {
33
pub move_precompile_verification_to_svm: bool,
4-
pub remove_accounts_executable_flag_checks: bool,
54
pub stricter_abi_and_runtime_constraints: bool,
65
pub enable_bpf_loader_set_authority_checked_ix: bool,
76
pub enable_loader_v4: bool,
@@ -44,7 +43,6 @@ impl SVMFeatureSet {
4443
pub fn all_enabled() -> Self {
4544
Self {
4645
move_precompile_verification_to_svm: true,
47-
remove_accounts_executable_flag_checks: true,
4846
stricter_abi_and_runtime_constraints: true,
4947
enable_bpf_loader_set_authority_checked_ix: true,
5048
enable_loader_v4: true,

svm/src/account_loader.rs

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,6 @@ fn load_transaction_accounts_simd186<CB: TransactionProcessingCallback>(
610610
return Err(TransactionError::ProgramAccountNotFound);
611611
};
612612

613-
if !account_loader
614-
.feature_set
615-
.remove_accounts_executable_flag_checks
616-
&& !program_account.executable()
617-
{
618-
error_metrics.invalid_program_for_execution += 1;
619-
return Err(TransactionError::InvalidProgramForExecution);
620-
}
621-
622613
let owner_id = program_account.owner();
623614
if !native_loader::check_id(owner_id) && !PROGRAM_OWNERS.contains(owner_id) {
624615
error_metrics.invalid_program_for_execution += 1;
@@ -690,28 +681,14 @@ fn load_transaction_accounts_old<CB: TransactionProcessingCallback>(
690681
return Err(TransactionError::ProgramAccountNotFound);
691682
};
692683

693-
if !account_loader
694-
.feature_set
695-
.remove_accounts_executable_flag_checks
696-
&& !program_account.executable()
697-
{
698-
error_metrics.invalid_program_for_execution += 1;
699-
return Err(TransactionError::InvalidProgramForExecution);
700-
}
701-
702684
let owner_id = program_account.owner();
703685
if native_loader::check_id(owner_id) {
704686
return Ok(program_index as IndexOfAccount);
705687
}
706688

707689
if !validated_loaders.contains(owner_id) {
708690
if let Some(owner_account) = account_loader.load_account(owner_id) {
709-
if !native_loader::check_id(owner_account.owner())
710-
|| (!account_loader
711-
.feature_set
712-
.remove_accounts_executable_flag_checks
713-
&& !owner_account.executable())
714-
{
691+
if !native_loader::check_id(owner_account.owner()) {
715692
error_metrics.invalid_program_for_execution += 1;
716693
return Err(TransactionError::InvalidProgramForExecution);
717694
}
@@ -1154,7 +1131,6 @@ mod tests {
11541131
);
11551132

11561133
let mut feature_set = SVMFeatureSet::all_enabled();
1157-
feature_set.remove_accounts_executable_flag_checks = false;
11581134
feature_set.formalize_loaded_transaction_data_size = formalize_loaded_transaction_data_size;
11591135

11601136
let load_results = load_accounts_with_features_and_rent(
@@ -1165,14 +1141,18 @@ mod tests {
11651141
feature_set,
11661142
);
11671143

1168-
assert_eq!(error_metrics.invalid_program_for_execution.0, 1);
1169-
assert!(matches!(
1170-
load_results,
1171-
TransactionLoadResult::FeesOnly(FeesOnlyTransaction {
1172-
load_error: TransactionError::InvalidProgramForExecution,
1173-
..
1174-
}),
1175-
));
1144+
assert_eq!(error_metrics.invalid_program_for_execution.0, 0);
1145+
match &load_results {
1146+
TransactionLoadResult::Loaded(loaded_transaction) => {
1147+
assert_eq!(loaded_transaction.accounts.len(), 2);
1148+
assert_eq!(loaded_transaction.accounts[0].1, accounts[0].1);
1149+
assert_eq!(loaded_transaction.accounts[1].1, accounts[1].1);
1150+
assert_eq!(loaded_transaction.program_indices.len(), 1);
1151+
assert_eq!(loaded_transaction.program_indices[0], 1);
1152+
}
1153+
TransactionLoadResult::FeesOnly(fees_only_tx) => panic!("{}", fees_only_tx.load_error),
1154+
TransactionLoadResult::NotLoaded(e) => panic!("{e}"),
1155+
}
11761156
}
11771157

11781158
#[test_case(false; "informal_loaded_size")]
@@ -2810,15 +2790,10 @@ mod tests {
28102790

28112791
// note all magic numbers (how many accounts, how many instructions, how big to size buffers) are arbitrary
28122792
// other than trying not to swamp programs with blank accounts and keep transaction size below the 64mb limit
2813-
#[test_case(false; "executable_mandatory")]
2814-
#[test_case(true; "executable_optional")]
2815-
fn test_load_transaction_accounts_data_sizes_simd186(
2816-
remove_accounts_executable_flag_checks: bool,
2817-
) {
2793+
#[test]
2794+
fn test_load_transaction_accounts_data_sizes_simd186() {
28182795
let mut rng = rand0_7::thread_rng();
28192796
let mut mock_bank = TestCallbacks::default();
2820-
mock_bank.feature_set.remove_accounts_executable_flag_checks =
2821-
remove_accounts_executable_flag_checks;
28222797

28232798
// arbitrary accounts
28242799
for _ in 0..128 {
@@ -2857,7 +2832,7 @@ mod tests {
28572832
1,
28582833
vec![0; rng.gen_range(0, 512)],
28592834
*loader,
2860-
!remove_accounts_executable_flag_checks || rng.gen(),
2835+
rng.gen(),
28612836
u64::MAX,
28622837
);
28632838

@@ -2875,7 +2850,7 @@ mod tests {
28752850
1,
28762851
vec![0; rng.gen_range(0, 512)],
28772852
*loader,
2878-
!remove_accounts_executable_flag_checks || rng.gen(),
2853+
rng.gen(),
28792854
u64::MAX,
28802855
);
28812856
programdata_tracker.insert(

svm/src/transaction_processor.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -850,11 +850,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
850850
compute_budget.max_instruction_stack_depth,
851851
compute_budget.max_instruction_trace_length,
852852
);
853-
transaction_context.set_remove_accounts_executable_flag_checks(
854-
environment
855-
.feature_set
856-
.remove_accounts_executable_flag_checks,
857-
);
858853

859854
let pre_account_state_info =
860855
TransactionAccountStateInfo::new(&transaction_context, tx, &environment.rent);

0 commit comments

Comments
 (0)