Bail on all CPI errors (#14500)

* Bail on all CPI errors

* whitespace
This commit is contained in:
Jack May
2021-01-08 18:27:39 -08:00
committed by GitHub
parent 638f225dc4
commit ec48631fc5
9 changed files with 127 additions and 110 deletions

View File

@ -17,8 +17,8 @@ use solana_sdk::{
bpf_loader_upgradeable::{self, UpgradeableLoaderState},
entrypoint::{MAX_PERMITTED_DATA_INCREASE, SUCCESS},
feature_set::{
limit_cpi_loader_invoke, pubkey_log_syscall_enabled, ristretto_mul_syscall_enabled,
sha256_syscall_enabled, sol_log_compute_units_syscall,
abort_on_all_cpi_failures, limit_cpi_loader_invoke, pubkey_log_syscall_enabled,
ristretto_mul_syscall_enabled, sha256_syscall_enabled, sol_log_compute_units_syscall,
try_find_program_address_syscall_enabled, use_loaded_program_accounts,
},
hash::{Hasher, HASH_BYTES},
@ -1503,10 +1503,16 @@ fn call<'a>(
*(&mut *invoke_context),
) {
Ok(()) => (),
Err(err) => match ProgramError::try_from(err) {
Ok(err) => return Ok(err.into()),
Err(err) => return Err(SyscallError::InstructionError(err).into()),
},
Err(err) => {
if invoke_context.is_feature_active(&abort_on_all_cpi_failures::id()) {
return Err(SyscallError::InstructionError(err).into());
} else {
match ProgramError::try_from(err) {
Ok(err) => return Ok(err.into()),
Err(err) => return Err(SyscallError::InstructionError(err).into()),
}
}
}
}
// Copy results back to caller