From a37458eafbd068f452fa9371612555598d5c3e8b Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 22 Jun 2021 19:54:52 -0600 Subject: [PATCH 1/2] Add metrics for rpc send-tx failures (#18156) (cherry picked from commit 64cff8c5a1a01ae93078114df6d6192f64705c89) # Conflicts: # core/src/rpc.rs --- core/src/rpc.rs | 84 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index e294870aabd720..012129c8e65308 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -1,5 +1,6 @@ //! The `rpc` module implements the Solana RPC interface. +<<<<<<< HEAD:core/src/rpc.rs use crate::{ cluster_info::ClusterInfo, contact_info::ContactInfo, @@ -19,6 +20,79 @@ use solana_account_decoder::{ parse_token::{ get_token_account_mint, spl_token_id_v2_0, spl_token_v2_0_native_mint, token_amount_to_ui_amount, UiTokenAmount, +======= +use { + crate::{ + max_slots::MaxSlots, + optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, + parsed_token_accounts::*, + rpc_health::*, + send_transaction_service::{SendTransactionService, TransactionInfo}, + }, + bincode::{config::Options, serialize}, + jsonrpc_core::{types::error, Error, Metadata, Result}, + jsonrpc_derive::rpc, + serde::{Deserialize, Serialize}, + solana_account_decoder::{ + parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount}, + UiAccount, UiAccountEncoding, UiDataSliceConfig, + }, + solana_client::{ + rpc_cache::LargestAccountsCache, + rpc_config::*, + rpc_custom_error::RpcCustomError, + rpc_deprecated_config::*, + rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, + rpc_request::{ + TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE, + MAX_GET_CONFIRMED_BLOCKS_RANGE, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT, + MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, MAX_GET_PROGRAM_ACCOUNT_FILTERS, + MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_GET_SLOT_LEADERS, MAX_MULTIPLE_ACCOUNTS, + NUM_LARGEST_ACCOUNTS, + }, + rpc_response::Response as RpcResponse, + rpc_response::*, + }, + solana_faucet::faucet::request_airdrop_transaction, + solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, + solana_ledger::{ + blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path, + leader_schedule_cache::LeaderScheduleCache, + }, + solana_metrics::inc_new_counter_info, + solana_perf::packet::PACKET_DATA_SIZE, + solana_runtime::{ + accounts::AccountAddressFilter, + accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey}, + bank::Bank, + bank_forks::{BankForks, SnapshotConfig}, + commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots}, + inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, + non_circulating_supply::calculate_non_circulating_supply, + snapshot_utils::get_highest_snapshot_archive_path, + }, + solana_sdk::{ + account::{AccountSharedData, ReadableAccount}, + account_utils::StateMut, + clock::{Slot, UnixTimestamp, MAX_RECENT_BLOCKHASHES}, + commitment_config::{CommitmentConfig, CommitmentLevel}, + epoch_info::EpochInfo, + epoch_schedule::EpochSchedule, + exit::Exit, + hash::Hash, + pubkey::Pubkey, + sanitize::Sanitize, + signature::{Keypair, Signature, Signer}, + stake::state::StakeState, + stake_history::StakeHistory, + system_instruction, + sysvar::stake_history, + transaction::{self, Transaction, TransactionError}, + }, + solana_transaction_status::{ + EncodedConfirmedTransaction, Reward, RewardType, TransactionConfirmationStatus, + TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, +>>>>>>> 64cff8c5a (Add metrics for rpc send-tx failures (#18156)):rpc/src/rpc.rs }, UiAccount, UiAccountData, UiAccountEncoding, UiDataSliceConfig, }; @@ -3144,12 +3218,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), } @@ -3158,6 +3234,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 { From bdee7799bc32449f28a702560d246a36b0d880fd Mon Sep 17 00:00:00 2001 From: Tyera Eulberg Date: Tue, 22 Jun 2021 20:41:07 -0600 Subject: [PATCH 2/2] Fix conflict --- core/src/rpc.rs | 76 +------------------------------------------------ 1 file changed, 1 insertion(+), 75 deletions(-) diff --git a/core/src/rpc.rs b/core/src/rpc.rs index 012129c8e65308..668acff029f0aa 100644 --- a/core/src/rpc.rs +++ b/core/src/rpc.rs @@ -1,6 +1,5 @@ //! The `rpc` module implements the Solana RPC interface. -<<<<<<< HEAD:core/src/rpc.rs use crate::{ cluster_info::ClusterInfo, contact_info::ContactInfo, @@ -20,79 +19,6 @@ use solana_account_decoder::{ parse_token::{ get_token_account_mint, spl_token_id_v2_0, spl_token_v2_0_native_mint, token_amount_to_ui_amount, UiTokenAmount, -======= -use { - crate::{ - max_slots::MaxSlots, - optimistically_confirmed_bank_tracker::OptimisticallyConfirmedBank, - parsed_token_accounts::*, - rpc_health::*, - send_transaction_service::{SendTransactionService, TransactionInfo}, - }, - bincode::{config::Options, serialize}, - jsonrpc_core::{types::error, Error, Metadata, Result}, - jsonrpc_derive::rpc, - serde::{Deserialize, Serialize}, - solana_account_decoder::{ - parse_token::{spl_token_id_v2_0, token_amount_to_ui_amount, UiTokenAmount}, - UiAccount, UiAccountEncoding, UiDataSliceConfig, - }, - solana_client::{ - rpc_cache::LargestAccountsCache, - rpc_config::*, - rpc_custom_error::RpcCustomError, - rpc_deprecated_config::*, - rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, - rpc_request::{ - TokenAccountsFilter, DELINQUENT_VALIDATOR_SLOT_DISTANCE, - MAX_GET_CONFIRMED_BLOCKS_RANGE, MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS2_LIMIT, - MAX_GET_CONFIRMED_SIGNATURES_FOR_ADDRESS_SLOT_RANGE, MAX_GET_PROGRAM_ACCOUNT_FILTERS, - MAX_GET_SIGNATURE_STATUSES_QUERY_ITEMS, MAX_GET_SLOT_LEADERS, MAX_MULTIPLE_ACCOUNTS, - NUM_LARGEST_ACCOUNTS, - }, - rpc_response::Response as RpcResponse, - rpc_response::*, - }, - solana_faucet::faucet::request_airdrop_transaction, - solana_gossip::{cluster_info::ClusterInfo, contact_info::ContactInfo}, - solana_ledger::{ - blockstore::Blockstore, blockstore_db::BlockstoreError, get_tmp_ledger_path, - leader_schedule_cache::LeaderScheduleCache, - }, - solana_metrics::inc_new_counter_info, - solana_perf::packet::PACKET_DATA_SIZE, - solana_runtime::{ - accounts::AccountAddressFilter, - accounts_index::{AccountIndex, AccountSecondaryIndexes, IndexKey}, - bank::Bank, - bank_forks::{BankForks, SnapshotConfig}, - commitment::{BlockCommitmentArray, BlockCommitmentCache, CommitmentSlots}, - inline_spl_token_v2_0::{SPL_TOKEN_ACCOUNT_MINT_OFFSET, SPL_TOKEN_ACCOUNT_OWNER_OFFSET}, - non_circulating_supply::calculate_non_circulating_supply, - snapshot_utils::get_highest_snapshot_archive_path, - }, - solana_sdk::{ - account::{AccountSharedData, ReadableAccount}, - account_utils::StateMut, - clock::{Slot, UnixTimestamp, MAX_RECENT_BLOCKHASHES}, - commitment_config::{CommitmentConfig, CommitmentLevel}, - epoch_info::EpochInfo, - epoch_schedule::EpochSchedule, - exit::Exit, - hash::Hash, - pubkey::Pubkey, - sanitize::Sanitize, - signature::{Keypair, Signature, Signer}, - stake::state::StakeState, - stake_history::StakeHistory, - system_instruction, - sysvar::stake_history, - transaction::{self, Transaction, TransactionError}, - }, - solana_transaction_status::{ - EncodedConfirmedTransaction, Reward, RewardType, TransactionConfirmationStatus, - TransactionStatus, UiConfirmedBlock, UiTransactionEncoding, ->>>>>>> 64cff8c5a (Add metrics for rpc send-tx failures (#18156)):rpc/src/rpc.rs }, UiAccount, UiAccountData, UiAccountEncoding, UiDataSliceConfig, }; @@ -141,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::{