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

@@ -64,7 +64,7 @@ pub trait InvokeContext {
&mut self,
message: &Message,
instruction: &CompiledInstruction,
accounts: &[Rc<RefCell<AccountSharedData>>],
accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)],
caller_pivileges: Option<&[bool]>,
) -> Result<(), InstructionError>;
/// Get the program ID of the currently executing program
@@ -90,7 +90,7 @@ pub trait InvokeContext {
fn record_instruction(&self, instruction: &Instruction);
/// Get the bank's active feature set
fn is_feature_active(&self, feature_id: &Pubkey) -> bool;
/// Get an account from a pre-account
/// Get an account by its key
fn get_account(&self, pubkey: &Pubkey) -> Option<Rc<RefCell<AccountSharedData>>>;
/// Update timing
fn update_timing(
@@ -395,7 +395,7 @@ impl<'a> InvokeContext for MockInvokeContext<'a> {
&mut self,
_message: &Message,
_instruction: &CompiledInstruction,
_accounts: &[Rc<RefCell<AccountSharedData>>],
_accounts: &[(Pubkey, Rc<RefCell<AccountSharedData>>)],
_caller_pivileges: Option<&[bool]>,
) -> Result<(), InstructionError> {
Ok(())