From b4701c31124f6bed93d7041356d73f59039f341e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20Mei=C3=9Fner?= Date: Fri, 2 Jul 2021 16:02:20 +0200 Subject: [PATCH] Removes markers and adds comment. --- program-test/src/lib.rs | 1 - programs/bpf_loader/src/syscalls.rs | 1 - rpc/src/rpc.rs | 1 - runtime/src/accounts.rs | 7 +++++-- runtime/src/bank.rs | 7 +------ runtime/src/message_processor.rs | 6 ------ 6 files changed, 6 insertions(+), 17 deletions(-) diff --git a/program-test/src/lib.rs b/program-test/src/lib.rs index 3f365fb9b5eba6..bb01626149292c 100644 --- a/program-test/src/lib.rs +++ b/program-test/src/lib.rs @@ -336,7 +336,6 @@ impl solana_sdk::program_stubs::SyscallStubs for SyscallStubs { .map_err(|err| ProgramError::try_from(err).unwrap_or_else(|err| panic!("{}", err)))?; // Copy writeable account modifications back into the caller's AccountInfos - // REFACTOR: account_deps unification for (i, (pubkey, account)) in accounts.iter().enumerate().take(message.account_keys.len()) { if !message.is_writable(i, true) { continue; diff --git a/programs/bpf_loader/src/syscalls.rs b/programs/bpf_loader/src/syscalls.rs index 992e040b4e3445..9ad7f9e259e228 100644 --- a/programs/bpf_loader/src/syscalls.rs +++ b/programs/bpf_loader/src/syscalls.rs @@ -2309,7 +2309,6 @@ fn call<'a>( { let invoke_context = syscall.get_context()?; for (i, ((_key, account), account_ref)) in accounts.iter().zip(account_refs).enumerate() { - // REFACTOR: account_deps unification let account = account.borrow(); if let Some(mut account_ref) = account_ref { if message.is_writable(i, demote_sysvar_write_locks) && !account.executable() { diff --git a/rpc/src/rpc.rs b/rpc/src/rpc.rs index 9251a1cfd8f34b..7c062cf3eb950e 100644 --- a/rpc/src/rpc.rs +++ b/rpc/src/rpc.rs @@ -3090,7 +3090,6 @@ pub mod rpc_full { accounts.push(if result.is_err() { None } else { - // REFACTOR: account_deps unification (0..transaction.message.account_keys.len()) .position(|i| { post_simulation_accounts diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 6698f3feb8df3e..b521c81b9f4dd0 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -278,7 +278,11 @@ impl Accounts { accounts.push((*key, account)); } debug_assert_eq!(accounts.len(), message.account_keys.len()); - // REFACTOR: account_deps unification + // Appends the account_deps at the end of the accounts, + // this way they can be accessed in a uniform way. + // At places where only the accounts are needed, + // the account_deps are truncated using e.g: + // accounts.iter().take(message.account_keys.len()) accounts.append(&mut account_deps); if let Some(payer_index) = payer_index { @@ -996,7 +1000,6 @@ impl Accounts { .zip(loaded_transaction.accounts.iter_mut()) .filter(|(i, (key, _account))| message.is_non_loader_key(key, *i)) { - // REFACTOR: account_deps unification let is_nonce_account = prepare_if_nonce_account( account, key, diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 74691a6e029253..ae627e634d4bc8 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -630,7 +630,6 @@ impl NonceRollbackFull { nonce_address, nonce_account, } = partial; - // REFACTOR: account_deps unification let fee_payer = (0..message.account_keys.len()).find_map(|i| { if let Some((k, a)) = &accounts.get(i) { if message.is_non_loader_key(k, i) { @@ -2950,10 +2949,7 @@ impl Bank { ) -> (TransactionAccountRefCells, TransactionLoaderRefCells) { let account_refcells: Vec<_> = accounts .drain(..) - .map(|(pubkey, account)| { - // REFACTOR: account_deps unification - (pubkey, Rc::new(RefCell::new(account))) - }) + .map(|(pubkey, account)| (pubkey, Rc::new(RefCell::new(account)))) .collect(); let loader_refcells: Vec> = loaders .iter_mut() @@ -4804,7 +4800,6 @@ impl Bank { .zip(loaded_transaction.accounts.iter()) .filter(|(_i, (_pubkey, account))| (Stakes::is_stake(account))) { - // REFACTOR: account_deps unification if Stakes::is_stake(account) { if let Some(old_vote_account) = self.stakes.write().unwrap().store( pubkey, diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 1d58a96a3c59c2..039a008e7917ca 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -358,7 +358,6 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> { let keyed_accounts = keyed_accounts .iter() .map(|(is_signer, is_writable, search_key, account)| { - // REFACTOR: account_deps unification self.accounts .iter() .position(|(key, _account)| key == *search_key) @@ -463,7 +462,6 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> { self.feature_set.is_active(feature_id) } fn get_account(&self, pubkey: &Pubkey) -> Option>> { - // REFACTOR: account_deps unification self.accounts.iter().find_map(|(key, account)| { if key == pubkey { Some(account.clone()) @@ -622,7 +620,6 @@ impl MessageProcessor { .map(|(key, account)| (false, false, key, account as &RefCell)) .chain(instruction.accounts.iter().map(|index| { let index = *index as usize; - // REFACTOR: account_deps unification ( message.is_signer(index), message.is_writable(index, demote_sysvar_write_locks), @@ -978,7 +975,6 @@ impl MessageProcessor { let mut work = |_unique_index: usize, account_index: usize| { if account_index < message.account_keys.len() && account_index < accounts.len() { let account = accounts[account_index].1.borrow(); - // REFACTOR: account_deps unification pre_accounts.push(PreAccount::new(&accounts[account_index].0, &account)); return Ok(()); } @@ -1080,7 +1076,6 @@ impl MessageProcessor { let mut work = |_unique_index: usize, account_index: usize| { if account_index < message.account_keys.len() && account_index < accounts.len() { let (key, account) = &accounts[account_index]; - // REFACTOR: account_deps unification let is_writable = if let Some(caller_write_privileges) = caller_write_privileges { caller_write_privileges[account_index] } else { @@ -1151,7 +1146,6 @@ impl MessageProcessor { if feature_set.is_active(&instructions_sysvar_enabled::id()) { for (pubkey, accont) in accounts.iter().take(message.account_keys.len()) { if instructions::check_id(pubkey) { - // REFACTOR: account_deps unification let mut mut_account_ref = accont.borrow_mut(); instructions::store_current_index( mut_account_ref.data_as_mut_slice(),