Refactor - Minor fixes in the error handling of executing tombstones (#33145)

Minor fixes in the error handling of executing tombstones.
This commit is contained in:
Alexander Meißner 2023-09-05 23:57:25 +02:00 committed by GitHub
parent efb6846fe7
commit 05622c17da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -498,12 +498,10 @@ fn process_instruction_inner(
let mut get_or_create_executor_time = Measure::start("get_or_create_executor_time");
let executor = invoke_context
.find_program_in_cache(program_account.get_key())
.ok_or(InstructionError::InvalidAccountData)?;
if executor.is_tombstone() {
return Err(Box::new(InstructionError::InvalidAccountData));
}
.ok_or_else(|| {
ic_logger_msg!(log_collector, "Program is not cached");
InstructionError::InvalidAccountData
})?;
drop(program_account);
get_or_create_executor_time.stop();
saturating_add_assign!(
@ -516,6 +514,7 @@ fn process_instruction_inner(
LoadedProgramType::FailedVerification(_)
| LoadedProgramType::Closed
| LoadedProgramType::DelayVisibility => {
ic_logger_msg!(log_collector, "Program is not deployed");
Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
}
LoadedProgramType::LegacyV0(executable) => execute(executable, invoke_context),

View File

@ -595,11 +595,10 @@ pub fn process_instruction_inner(
let mut get_or_create_executor_time = Measure::start("get_or_create_executor_time");
let loaded_program = invoke_context
.find_program_in_cache(program.get_key())
.ok_or(InstructionError::InvalidAccountData)?;
if loaded_program.is_tombstone() {
return Err(Box::new(InstructionError::InvalidAccountData));
}
.ok_or_else(|| {
ic_logger_msg!(log_collector, "Program is not cached");
InstructionError::InvalidAccountData
})?;
get_or_create_executor_time.stop();
saturating_add_assign!(
invoke_context.timings.get_or_create_executor_us,
@ -613,6 +612,7 @@ pub fn process_instruction_inner(
LoadedProgramType::FailedVerification(_)
| LoadedProgramType::Closed
| LoadedProgramType::DelayVisibility => {
ic_logger_msg!(log_collector, "Program is not deployed");
Err(Box::new(InstructionError::InvalidAccountData) as Box<dyn std::error::Error>)
}
LoadedProgramType::Typed(executable) => execute(invoke_context, executable),