Skip to content

Commit

Permalink
Review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichtso committed Apr 5, 2024
1 parent c1af5b5 commit fd971ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion ledger-tool/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,11 @@ pub fn program(ledger_path: &Path, matches: &ArgMatches<'_>) {
let mut loaded_programs =
bank.new_program_cache_for_tx_batch_for_slot(bank.slot() + DELAY_VISIBILITY_SLOT_OFFSET);
for key in cached_account_keys {
loaded_programs.replenish(key, bank.load_program(&key, false, bank.epoch()).unwrap());
loaded_programs.replenish(
key,
bank.load_program(&key, false, bank.epoch())
.expect("Couldn't find program account"),
);
debug!("Loaded program {}", key);
}
invoke_context.programs_loaded_for_tx_batch = &loaded_programs;
Expand Down
5 changes: 4 additions & 1 deletion program-runtime/src/loaded_programs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ pub trait ForkGraph {
pub enum LoadedProgramType {
/// Tombstone for programs which currently do not pass the verifier but could if the feature set changed.
FailedVerification(ProgramRuntimeEnvironment),
/// Tombstone for accounts which are not programs but might still be owned by a loader.
/// Tombstone for programs that were either explicitly closed or never deployed.
///
/// It's also used for accounts belonging to program loaders, that don't actually contain program code (e.g. buffer accounts for LoaderV3 programs).
#[default]
Closed,
/// Tombstone for programs which have recently been modified but the new version is not visible yet.
Expand Down Expand Up @@ -774,6 +776,7 @@ impl<FG: ForkGraph> ProgramCache<FG> {
Ok(index) => {
let existing = slot_versions.get_mut(index).unwrap();
match (&existing.program, &entry.program) {
// Add test for Closed => Loaded transition in same slot
(LoadedProgramType::Builtin(_), LoadedProgramType::Builtin(_))
| (LoadedProgramType::Closed, LoadedProgramType::LegacyV0(_))
| (LoadedProgramType::Closed, LoadedProgramType::LegacyV1(_))
Expand Down
11 changes: 5 additions & 6 deletions svm/src/transaction_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,11 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
result
}

/// Load program with a specific pubkey from program cache, and
/// update the program's access slot as a side-effect.
/// Loads the program with the given pubkey.
///
/// If the account doesn't exist it returns `None`. If the account does exist, it must be a program
/// account (belong to one of the program loaders). Returns `Some(InvalidAccountData)` if the program
/// account is `Closed`, contains invalid data or any of the programdata accounts are invalid.
pub fn load_program_with_pubkey<CB: TransactionProcessingCallback>(
&self,
callbacks: &CB,
Expand Down Expand Up @@ -838,10 +841,6 @@ impl<FG: ForkGraph> TransactionBatchProcessor<FG> {
) -> Option<ProgramAccountLoadResult> {
let program_account = callbacks.get_account_shared_data(pubkey)?;

debug_assert!(solana_bpf_loader_program::check_loader_id(
program_account.owner()
));

if loader_v4::check_id(program_account.owner()) {
return Some(
solana_loader_v4_program::get_state(program_account.data())
Expand Down

0 comments on commit fd971ad

Please sign in to comment.