Skip to content

Commit

Permalink
Feature - disable account loader special case (#3514)
Browse files Browse the repository at this point in the history
Feature gate disable_account_loader_special_case.
  • Loading branch information
Lichtso authored Nov 7, 2024
1 parent 0348991 commit f8f3fe3
Show file tree
Hide file tree
Showing 3 changed files with 14 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 @@ -7137,10 +7137,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 @@ -7161,10 +7158,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/src/feature_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,10 @@ pub mod deprecate_legacy_vote_ixs {
solana_program::declare_id!("mustrekeyysGrhwdiwU42tCadZL8GcBb1i2GYhMopQv");
}

pub mod disable_account_loader_special_case {
solana_program::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 @@ -1066,6 +1070,7 @@ lazy_static! {
(partitioned_epoch_rewards_superfeature::id(), "replaces enable_partitioned_epoch_reward to enable partitioned rewards at epoch boundary SIMD-0118"),
(enable_turbine_extended_fanout_experiments::id(), "enable turbine extended fanout experiments #2373"),
(deprecate_legacy_vote_ixs::id(), "Deprecate legacy vote instructions"),
(disable_account_loader_special_case::id(), "Disable account loader special case"),
/*************** ADD NEW FEATURES HERE ***************/
]
.iter()
Expand Down
10 changes: 7 additions & 3 deletions svm/src/account_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
get_requested_loaded_accounts_data_size_limit(message)?;
let mut accumulated_accounts_data_size: usize = 0;

let disable_account_loader_special_case =
feature_set.is_active(&feature_set::disable_account_loader_special_case::id());
let instruction_accounts = message
.instructions()
.iter()
Expand Down Expand Up @@ -239,9 +241,11 @@ fn load_transaction_accounts<CB: TransactionProcessingCallback>(
account_overrides.and_then(|overrides| overrides.get(key))
{
(account_override.data().len(), account_override.clone(), 0)
} else if let Some(program) = (!instruction_account && !message.is_writable(i))
.then_some(())
.and_then(|_| loaded_programs.find(key))
} else if let Some(program) = (!disable_account_loader_special_case
&& !instruction_account
&& !message.is_writable(i))
.then_some(())
.and_then(|_| loaded_programs.find(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 f8f3fe3

Please sign in to comment.