Skip to content

Commit c6e88e4

Browse files
v2.1: Feature - disable account loader special case (backport of #3548) (#3552)
Feature - disable account loader special case (#3548) Feature gate disable_account_loader_special_case. (cherry picked from commit f0d7e4f) Co-authored-by: Alexander Meißner <[email protected]>
1 parent b6fc167 commit c6e88e4

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

runtime/src/bank/tests.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7229,10 +7229,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
72297229
);
72307230
assert_eq!(
72317231
bank.process_transaction(&transaction),
7232-
Err(TransactionError::InstructionError(
7233-
0,
7234-
InstructionError::InvalidAccountData
7235-
)),
7232+
Err(TransactionError::InvalidProgramForExecution),
72367233
);
72377234
{
72387235
let program_cache = bank.transaction_processor.program_cache.read().unwrap();
@@ -7253,10 +7250,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
72537250
let transaction = Transaction::new(&[&binding], message, bank.last_blockhash());
72547251
assert_eq!(
72557252
bank.process_transaction(&transaction),
7256-
Err(TransactionError::InstructionError(
7257-
0,
7258-
InstructionError::InvalidAccountData,
7259-
)),
7253+
Err(TransactionError::InvalidProgramForExecution),
72607254
);
72617255
{
72627256
let program_cache = bank.transaction_processor.program_cache.read().unwrap();

sdk/feature-set/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,10 @@ pub mod reenable_sbpf_v1_execution {
869869
solana_pubkey::declare_id!("TestFeature21111111111111111111111111111111");
870870
}
871871

872+
pub mod disable_account_loader_special_case {
873+
solana_pubkey::declare_id!("EQUMpNFr7Nacb1sva56xn1aLfBxppEoSBH8RRVdkcD1x");
874+
}
875+
872876
lazy_static! {
873877
/// Map of feature identifiers to user-visible description
874878
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
@@ -1081,6 +1085,7 @@ lazy_static! {
10811085
(partitioned_epoch_rewards_superfeature::id(), "replaces enable_partitioned_epoch_reward to enable partitioned rewards at epoch boundary SIMD-0118"),
10821086
(disable_sbpf_v1_execution::id(), "Disables execution of SBPFv1 programs"),
10831087
(reenable_sbpf_v1_execution::id(), "Re-enables execution of SBPFv1 programs"),
1088+
(disable_account_loader_special_case::id(), "Disable account loader special case #3513"),
10841089
/*************** ADD NEW FEATURES HERE ***************/
10851090
]
10861091
.iter()

svm/src/account_loader.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,8 @@ fn load_transaction_account<CB: TransactionProcessingCallback>(
424424
loaded_programs: &ProgramCacheForTxBatch,
425425
) -> Result<(LoadedTransactionAccount, bool)> {
426426
let mut account_found = true;
427+
let disable_account_loader_special_case =
428+
feature_set.is_active(&feature_set::disable_account_loader_special_case::id());
427429
let is_instruction_account = u8::try_from(account_index)
428430
.map(|i| instruction_accounts.contains(&&i))
429431
.unwrap_or(false);
@@ -444,9 +446,10 @@ fn load_transaction_account<CB: TransactionProcessingCallback>(
444446
account: account_override.clone(),
445447
rent_collected: 0,
446448
}
447-
} else if let Some(program) = (!is_instruction_account && !is_writable)
448-
.then_some(())
449-
.and_then(|_| loaded_programs.find(account_key))
449+
} else if let Some(program) =
450+
(!disable_account_loader_special_case && !is_instruction_account && !is_writable)
451+
.then_some(())
452+
.and_then(|_| loaded_programs.find(account_key))
450453
{
451454
// Optimization to skip loading of accounts which are only used as
452455
// programs in top-level instructions and not passed as instruction accounts.

0 commit comments

Comments
 (0)