Add precompile verification to preflight (#12486)

This commit is contained in:
sakridge 2020-09-27 22:29:00 -07:00 committed by GitHub
parent f0e02d2588
commit 6583c8cffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -2210,6 +2210,10 @@ impl RpcSol for RpcSolImpl {
return Err(RpcCustomError::TransactionSignatureVerificationFailure.into()); return Err(RpcCustomError::TransactionSignatureVerificationFailure.into());
} }
if let Err(e) = transaction.verify_precompiles() {
return Err(RpcCustomError::TransactionPrecompileVerificationFailure(e).into());
}
if meta.health.check() != RpcHealthStatus::Ok { if meta.health.check() != RpcHealthStatus::Ok {
return Err(RpcCustomError::RpcNodeUnhealthy.into()); return Err(RpcCustomError::RpcNodeUnhealthy.into());
} }

View File

@ -7,6 +7,7 @@ const JSON_RPC_SERVER_ERROR_2: i64 = -32002;
const JSON_RPC_SERVER_ERROR_3: i64 = -32003; const JSON_RPC_SERVER_ERROR_3: i64 = -32003;
const JSON_RPC_SERVER_ERROR_4: i64 = -32004; const JSON_RPC_SERVER_ERROR_4: i64 = -32004;
const JSON_RPC_SERVER_ERROR_5: i64 = -32005; const JSON_RPC_SERVER_ERROR_5: i64 = -32005;
const JSON_RPC_SERVER_ERROR_6: i64 = -32006;
pub enum RpcCustomError { pub enum RpcCustomError {
BlockCleanedUp { BlockCleanedUp {
@ -22,6 +23,7 @@ pub enum RpcCustomError {
slot: Slot, slot: Slot,
}, },
RpcNodeUnhealthy, RpcNodeUnhealthy,
TransactionPrecompileVerificationFailure(solana_sdk::transaction::TransactionError),
} }
impl From<RpcCustomError> for Error { impl From<RpcCustomError> for Error {
@ -58,6 +60,11 @@ impl From<RpcCustomError> for Error {
message: "RPC node is unhealthy".to_string(), message: "RPC node is unhealthy".to_string(),
data: None, data: None,
}, },
RpcCustomError::TransactionPrecompileVerificationFailure(e) => Self {
code: ErrorCode::ServerError(JSON_RPC_SERVER_ERROR_6),
message: format!("Transaction precompile verification failure {:?}", e),
data: None,
},
} }
} }
} }