Refactoring: Unify account_deps and accounts (backport #17898) (#18486)

* Refactoring: Unify account_deps and accounts (#17898)

* Changes ThisInvokeContext::get_account() to use accounts instead of pre_accounts.

* Adds explicit keys to accounts to make them symmetric to account_deps.

* Appends account_deps to accounts in transaction loading and removes account_deps everywhere else.

(cherry picked from commit 7462c27d07)

# Conflicts:
#	program-test/src/lib.rs
#	runtime/src/bank.rs
#	runtime/src/message_processor.rs

* fix conflicts

Co-authored-by: Alexander Meißner <AlexanderMeissner@gmx.net>
Co-authored-by: Justin Starry <justin@solana.com>
This commit is contained in:
mergify[bot]
2021-07-07 17:14:39 +00:00
committed by GitHub
parent d668a7694f
commit 5321463892
7 changed files with 289 additions and 308 deletions

View File

@@ -1343,7 +1343,7 @@ type TranslatedAccount<'a> = (
Option<AccountReferences<'a>>,
);
type TranslatedAccounts<'a> = (
Vec<Rc<RefCell<AccountSharedData>>>,
Vec<(Pubkey, Rc<RefCell<AccountSharedData>>)>,
Vec<Option<AccountReferences<'a>>>,
);
@@ -1988,7 +1988,7 @@ where
if i == program_account_index || account.borrow().executable() {
// Use the known account
accounts.push(account);
accounts.push((**account_key, account));
refs.push(None);
} else if let Some(account_info) =
account_info_keys
@@ -2003,7 +2003,7 @@ where
})
{
let (account, account_ref) = do_translate(account_info, invoke_context)?;
accounts.push(account);
accounts.push((**account_key, account));
refs.push(account_ref);
} else {
ic_msg!(
@@ -2188,6 +2188,7 @@ fn call<'a>(
ic_msg!(invoke_context, "Unknown program {}", callee_program_id,);
SyscallError::InstructionError(InstructionError::MissingAccount)
})?
.1
.clone();
let programdata_executable =
get_upgradeable_executable(&callee_program_id, &program_account, &invoke_context)?;
@@ -2228,7 +2229,7 @@ fn call<'a>(
// Copy results back to caller
{
let invoke_context = syscall.get_context()?;
for (i, (account, account_ref)) in accounts.iter().zip(account_refs).enumerate() {
for (i, ((_key, account), account_ref)) in accounts.iter().zip(account_refs).enumerate() {
let account = account.borrow();
if let Some(mut account_ref) = account_ref {
if message.is_writable(i) && !account.executable() {