Skip to content

Commit

Permalink
v2.1: Feature - disable account loader special case (backport of #354…
Browse files Browse the repository at this point in the history
…8) (#3552)

Feature - disable account loader special case (#3548)

Feature gate disable_account_loader_special_case.

(cherry picked from commit f0d7e4f71cc1f0ed2d1f12614b4f254fb13f2303)

Co-authored-by: Alexander Meißner <[email protected]>
  • Loading branch information
mergify[bot] and Lichtso authored Nov 11, 2024
1 parent b6fc167 commit c6e88e4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 2 additions & 8 deletions runtime/src/bank/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7229,10 +7229,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
);
assert_eq!(
bank.process_transaction(&transaction),
Err(TransactionError::InstructionError(
0,
InstructionError::InvalidAccountData
)),
Err(TransactionError::InvalidProgramForExecution),
);
{
let program_cache = bank.transaction_processor.program_cache.read().unwrap();
Expand All @@ -7253,10 +7250,7 @@ fn test_bpf_loader_upgradeable_deploy_with_max_len() {
let transaction = Transaction::new(&[&binding], message, bank.last_blockhash());
assert_eq!(
bank.process_transaction(&transaction),
Err(TransactionError::InstructionError(
0,
InstructionError::InvalidAccountData,
)),
Err(TransactionError::InvalidProgramForExecution),
);
{
let program_cache = bank.transaction_processor.program_cache.read().unwrap();
Expand Down
5 changes: 5 additions & 0 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,10 @@ pub mod reenable_sbpf_v1_execution {
solana_pubkey::declare_id!("TestFeature21111111111111111111111111111111");
}

pub mod disable_account_loader_special_case {
solana_pubkey::declare_id!("EQUMpNFr7Nacb1sva56xn1aLfBxppEoSBH8RRVdkcD1x");
}

lazy_static! {
/// Map of feature identifiers to user-visible description
pub static ref FEATURE_NAMES: HashMap<Pubkey, &'static str> = [
Expand Down Expand Up @@ -1081,6 +1085,7 @@ lazy_static! {
(partitioned_epoch_rewards_superfeature::id(), "replaces enable_partitioned_epoch_reward to enable partitioned rewards at epoch boundary SIMD-0118"),
(disable_sbpf_v1_execution::id(), "Disables execution of SBPFv1 programs"),
(reenable_sbpf_v1_execution::id(), "Re-enables execution of SBPFv1 programs"),
(disable_account_loader_special_case::id(), "Disable account loader special case #3513"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down
9 changes: 6 additions & 3 deletions svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ fn load_transaction_account<CB: TransactionProcessingCallback>(
loaded_programs: &ProgramCacheForTxBatch,
) -> Result<(LoadedTransactionAccount, bool)> {
let mut account_found = true;
let disable_account_loader_special_case =
feature_set.is_active(&feature_set::disable_account_loader_special_case::id());
let is_instruction_account = u8::try_from(account_index)
.map(|i| instruction_accounts.contains(&&i))
.unwrap_or(false);
Expand All @@ -444,9 +446,10 @@ fn load_transaction_account<CB: TransactionProcessingCallback>(
account: account_override.clone(),
rent_collected: 0,
}
} else if let Some(program) = (!is_instruction_account && !is_writable)
.then_some(())
.and_then(|_| loaded_programs.find(account_key))
} else if let Some(program) =
(!disable_account_loader_special_case && !is_instruction_account && !is_writable)
.then_some(())
.and_then(|_| loaded_programs.find(account_key))
{
// Optimization to skip loading of accounts which are only used as
// programs in top-level instructions and not passed as instruction accounts.
Expand Down

0 comments on commit c6e88e4

Please sign in to comment.