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

Commit 05622c1

Browse files
authored
Refactor - Minor fixes in the error handling of executing tombstones (#33145)
Minor fixes in the error handling of executing tombstones.
1 parent efb6846 commit 05622c1

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

programs/bpf_loader/src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -498,12 +498,10 @@ fn process_instruction_inner(
498498
let mut get_or_create_executor_time = Measure::start("get_or_create_executor_time");
499499
let executor = invoke_context
500500
.find_program_in_cache(program_account.get_key())
501-
.ok_or(InstructionError::InvalidAccountData)?;
502-
503-
if executor.is_tombstone() {
504-
return Err(Box::new(InstructionError::InvalidAccountData));
505-
}
506-
501+
.ok_or_else(|| {
502+
ic_logger_msg!(log_collector, "Program is not cached");
503+
InstructionError::InvalidAccountData
504+
})?;
507505
drop(program_account);
508506
get_or_create_executor_time.stop();
509507
saturating_add_assign!(
@@ -516,6 +514,7 @@ fn process_instruction_inner(
516514
LoadedProgramType::FailedVerification(_)
517515
| LoadedProgramType::Closed
518516
| LoadedProgramType::DelayVisibility => {
517+
ic_logger_msg!(log_collector, "Program is not deployed");
519518
Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
520519
}
521520
LoadedProgramType::LegacyV0(executable) => execute(executable, invoke_context),

programs/loader-v4/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -595,11 +595,10 @@ pub fn process_instruction_inner(
595595
let mut get_or_create_executor_time = Measure::start("get_or_create_executor_time");
596596
let loaded_program = invoke_context
597597
.find_program_in_cache(program.get_key())
598-
.ok_or(InstructionError::InvalidAccountData)?;
599-
600-
if loaded_program.is_tombstone() {
601-
return Err(Box::new(InstructionError::InvalidAccountData));
602-
}
598+
.ok_or_else(|| {
599+
ic_logger_msg!(log_collector, "Program is not cached");
600+
InstructionError::InvalidAccountData
601+
})?;
603602
get_or_create_executor_time.stop();
604603
saturating_add_assign!(
605604
invoke_context.timings.get_or_create_executor_us,
@@ -613,6 +612,7 @@ pub fn process_instruction_inner(
613612
LoadedProgramType::FailedVerification(_)
614613
| LoadedProgramType::Closed
615614
| LoadedProgramType::DelayVisibility => {
615+
ic_logger_msg!(log_collector, "Program is not deployed");
616616
Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
617617
}
618618
LoadedProgramType::Typed(executable) => execute(invoke_context, executable),

0 commit comments

Comments
 (0)