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

Add metrics for rpc send-transaction failures (backport #18156) #18163

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ use solana_sdk::{
stake_history::StakeHistory,
system_instruction,
sysvar::stake_history,
transaction::{self, Transaction},
transaction::{self, Transaction, TransactionError},
};
use solana_stake_program::stake_state::StakeState;
use solana_transaction_status::{
Expand Down Expand Up @@ -3144,12 +3144,14 @@ pub mod rpc_full {
match meta.health.check() {
RpcHealthStatus::Ok => (),
RpcHealthStatus::Unknown => {
inc_new_counter_info!("rpc-send-tx_health-unknown", 1);
return Err(RpcCustomError::NodeUnhealthy {
num_slots_behind: None,
}
.into());
}
RpcHealthStatus::Behind { num_slots } => {
inc_new_counter_info!("rpc-send-tx_health-behind", 1);
return Err(RpcCustomError::NodeUnhealthy {
num_slots_behind: Some(num_slots),
}
Expand All @@ -3158,6 +3160,14 @@ pub mod rpc_full {
}

if let (Err(err), logs, _) = preflight_bank.simulate_transaction(&transaction) {
match err {
TransactionError::BlockhashNotFound => {
inc_new_counter_info!("rpc-send-tx_err-blockhash-not-found", 1);
}
_ => {
inc_new_counter_info!("rpc-send-tx_err-other", 1);
}
}
return Err(RpcCustomError::SendTransactionPreflightFailure {
message: format!("Transaction simulation failed: {}", err),
result: RpcSimulateTransactionResult {
Expand Down