Skip to content

Commit

Permalink
Removes markers and adds comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jul 2, 2021
1 parent d619984 commit b4701c3
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion program-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion programs/bpf_loader/src/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
1 change: 0 additions & 1 deletion rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions runtime/src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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<Vec<_>> = loaders
.iter_mut()
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 0 additions & 6 deletions runtime/src/message_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -463,7 +462,6 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
self.feature_set.is_active(feature_id)
}
fn get_account(&self, pubkey: &Pubkey) -> Option<Rc<RefCell<AccountSharedData>>> {
// REFACTOR: account_deps unification
self.accounts.iter().find_map(|(key, account)| {
if key == pubkey {
Some(account.clone())
Expand Down Expand Up @@ -622,7 +620,6 @@ impl MessageProcessor {
.map(|(key, account)| (false, false, key, account as &RefCell<AccountSharedData>))
.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),
Expand Down Expand Up @@ -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(());
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit b4701c3

Please sign in to comment.