diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 24eaf88cf7..750a6fd9ff 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -388,6 +388,8 @@ impl Accounts { // accounts.iter().take(message.account_keys.len()) accounts.append(&mut account_deps); + let disable_builtin_loader_ownership_chains = + feature_set.is_active(&feature_set::disable_builtin_loader_ownership_chains::ID); let builtins_start_index = accounts.len(); let program_indices = message .instructions() @@ -440,6 +442,10 @@ impl Accounts { } owner_index }; + if disable_builtin_loader_ownership_chains { + account_indices.insert(0, program_index as IndexOfAccount); + return Ok(account_indices); + } } error_counters.call_chain_too_deep += 1; Err(TransactionError::CallChainTooDeep) @@ -1741,72 +1747,6 @@ mod tests { } } - #[test] - fn test_load_accounts_max_call_depth() { - let mut accounts: Vec = Vec::new(); - let mut error_counters = TransactionErrorMetrics::default(); - - let keypair = Keypair::new(); - let key0 = keypair.pubkey(); - let key1 = Pubkey::from([5u8; 32]); - let key2 = Pubkey::from([6u8; 32]); - let key3 = Pubkey::from([7u8; 32]); - let key4 = Pubkey::from([8u8; 32]); - let key5 = Pubkey::from([9u8; 32]); - let key6 = Pubkey::from([10u8; 32]); - - let account = AccountSharedData::new(1, 0, &Pubkey::default()); - accounts.push((key0, account)); - - let mut account = AccountSharedData::new(40, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(native_loader::id()); - accounts.push((key1, account)); - - let mut account = AccountSharedData::new(41, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(key1); - accounts.push((key2, account)); - - let mut account = AccountSharedData::new(42, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(key2); - accounts.push((key3, account)); - - let mut account = AccountSharedData::new(43, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(key3); - accounts.push((key4, account)); - - let mut account = AccountSharedData::new(44, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(key4); - accounts.push((key5, account)); - - let mut account = AccountSharedData::new(45, 1, &Pubkey::default()); - account.set_executable(true); - account.set_owner(key5); - accounts.push((key6, account)); - - let instructions = vec![CompiledInstruction::new(1, &(), vec![0])]; - let tx = Transaction::new_with_compiled_instructions( - &[&keypair], - &[], - Hash::default(), - vec![key6], - instructions, - ); - - let loaded_accounts = load_accounts(tx, &accounts, &mut error_counters); - - assert_eq!(error_counters.call_chain_too_deep, 1); - assert_eq!(loaded_accounts.len(), 1); - assert_eq!( - loaded_accounts[0], - (Err(TransactionError::CallChainTooDeep), None,) - ); - } - #[test] fn test_load_accounts_bad_owner() { let mut accounts: Vec = Vec::new(); diff --git a/sdk/src/feature_set.rs b/sdk/src/feature_set.rs index d0d50667b5..30ba1ed1cf 100644 --- a/sdk/src/feature_set.rs +++ b/sdk/src/feature_set.rs @@ -590,6 +590,10 @@ pub mod enable_big_mod_exp_syscall { solana_sdk::declare_id!("EBq48m8irRKuE7ZnMTLvLg2UuGSqhe8s8oMqnmja1fJw"); } +pub mod disable_builtin_loader_ownership_chains { + solana_sdk::declare_id!("4UDcAfQ6EcA6bdcadkeHpkarkhZGJ7Bpq7wTAiRMjkoi"); +} + lazy_static! { /// Map of feature identifiers to user-visible description pub static ref FEATURE_NAMES: HashMap = [ @@ -732,6 +736,7 @@ lazy_static! { (move_serialized_len_ptr_in_cpi::id(), "cpi ignore serialized_len_ptr #29592"), (update_hashes_per_tick::id(), "Update desired hashes per tick on epoch boundary"), (enable_big_mod_exp_syscall::id(), "add big_mod_exp syscall #28503"), + (disable_builtin_loader_ownership_chains::id(), "disable builtin loader ownership chains #29956"), /*************** ADD NEW FEATURES HERE ***************/ ] .iter()