Load executable accounts from invoke context (#14574) (#14575)

(cherry picked from commit 6e8a1ba7de)

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2021-01-14 09:39:26 +00:00
committed by GitHub
parent 1b02ec4f6e
commit 771b98a168
5 changed files with 378 additions and 272 deletions

View File

@@ -541,18 +541,19 @@ impl MessageProcessor {
}
}
// validate the caller has access to the program account
// validate the caller has access to the program account and that it is executable
let program_id = instruction.program_id;
let _ = keyed_accounts
match keyed_accounts
.iter()
.find_map(|keyed_account| {
if &program_id == keyed_account.unsigned_key() {
Some(keyed_account)
} else {
None
.find(|keyed_account| &program_id == keyed_account.unsigned_key())
{
Some(keyed_account) => {
if !keyed_account.executable()? {
return Err(InstructionError::AccountNotExecutable);
}
})
.ok_or(InstructionError::MissingAccount)?;
}
None => return Err(InstructionError::MissingAccount),
}
let message = Message::new(&[instruction.clone()], None);
let program_id_index = message.instructions[0].program_id_index as usize;