Skip to content

Commit

Permalink
Feature - disable account loader special case (solana-labs#3548)
Browse files Browse the repository at this point in the history
Feature gate disable_account_loader_special_case.
  • Loading branch information
Lichtso authored Nov 8, 2024
1 parent 57bdb8e commit f0d7e4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions sdk/feature-set/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,10 @@ pub mod lift_cpi_caller_restriction {
solana_pubkey::declare_id!("HcW8ZjBezYYgvcbxNJwqv1t484Y2556qJsfNDWvJGZRH");
}

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 @@ -1090,6 +1094,7 @@ lazy_static! {
(reenable_sbpf_v1_execution::id(), "Re-enables execution of SBPFv1 programs"),
(remove_accounts_executable_flag_checks::id(), "Remove checks of accounts is_executable flag SIMD-0162"),
(lift_cpi_caller_restriction::id(), "Lift the restriction in CPI that the caller must have the callee as an instruction account #2202"),
(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 @@ -428,6 +428,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 @@ -448,9 +450,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 f0d7e4f

Please sign in to comment.