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

Commit

Permalink
Fixes feature gate of simplify_writable_program_account_check.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Jun 1, 2023
1 parent 16775a8 commit 037468f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 23 deletions.
14 changes: 2 additions & 12 deletions ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use {
},
solana_program_runtime::{
invoke_context::InvokeContext,
loaded_programs::{
LoadProgramMetrics, LoadedProgram, LoadedProgramType, DELAY_VISIBILITY_SLOT_OFFSET,
},
loaded_programs::{LoadProgramMetrics, LoadedProgramType, DELAY_VISIBILITY_SLOT_OFFSET},
with_mock_invoke_context,
},
solana_rbpf::{
Expand Down Expand Up @@ -540,16 +538,8 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
let mut loaded_programs =
LoadedProgramsForTxBatch::new(bank.slot() + DELAY_VISIBILITY_SLOT_OFFSET);
for key in cached_account_keys {
let program = bank.load_program(&key).unwrap_or_else(|err| {
// Create a tombstone for the program in the cache
debug!("Failed to load program {}, error {:?}", key, err);
Arc::new(LoadedProgram::new_tombstone(
0,
LoadedProgramType::FailedVerification,
))
});
loaded_programs.replenish(key, bank.load_program(&key));
debug!("Loaded program {}", key);
loaded_programs.replenish(key, program);
}
invoke_context.programs_loaded_for_tx_batch = &loaded_programs;

Expand Down
21 changes: 10 additions & 11 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,21 +294,20 @@ impl Accounts {
program_accounts: &HashMap<Pubkey, &Pubkey>,
) -> Result<AccountSharedData> {
// Check for tombstone
let result = match &program.program {
LoadedProgramType::FailedVerification | LoadedProgramType::Closed => {
Err(TransactionError::InvalidProgramForExecution)
match &program.program {
LoadedProgramType::FailedVerification
if feature_set.is_active(&simplify_writable_program_account_check::id()) =>
{
return Err(TransactionError::InvalidProgramForExecution);
}
LoadedProgramType::Closed => {
return Err(TransactionError::InvalidProgramForExecution);
}
LoadedProgramType::DelayVisibility => {
debug_assert!(feature_set.is_active(&delay_visibility_of_program_deployment::id()));
Err(TransactionError::InvalidProgramForExecution)
return Err(TransactionError::InvalidProgramForExecution);
}
_ => 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
Expand Down

0 comments on commit 037468f

Please sign in to comment.