Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Return error early if program is a tombstone (#30940)
Browse files Browse the repository at this point in the history
  • Loading branch information
pgarg66 authored Mar 30, 2023
1 parent b35e833 commit bc44ac7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,7 @@ impl Accounts {
program_accounts: &HashMap<Pubkey, &Pubkey>,
) -> Result<AccountSharedData> {
// Check for tombstone
// Ignoring the tombstone here for now. The loader will catch this condition and return
// error.
let _ignore = match &program.program {
let result = match &program.program {
LoadedProgramType::FailedVerification | LoadedProgramType::Closed => {
Err(TransactionError::InvalidProgramForExecution)
}
Expand All @@ -312,6 +310,12 @@ impl Accounts {
}
_ => Ok(()),
};
if feature_set.is_active(&simplify_writable_program_account_check::id()) {
// Currently CPI only fails if an execution is actually attempted. With this check it
// would also fail if a transaction just references an invalid program. So the checking
// of the result is being feature gated.
result?;
}
// It's an executable program account. The program is already loaded in the cache.
// So the account data is not needed. Return a dummy AccountSharedData with meta
// information.
Expand Down

0 comments on commit bc44ac7

Please sign in to comment.