Skip to content

Commit

Permalink
feat: Allow skip preflight health check (solana-labs#2278)
Browse files Browse the repository at this point in the history
add config to allow skipping health check in preflight call
  • Loading branch information
vovkman authored Aug 26, 2024
1 parent 71eb1d8 commit 4a777d1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
29 changes: 16 additions & 13 deletions rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ pub struct JsonRpcConfig {
pub enable_extended_tx_metadata_storage: bool,
pub faucet_addr: Option<SocketAddr>,
pub health_check_slot_distance: u64,
pub skip_preflight_health_check: bool,
pub rpc_bigtable_config: Option<RpcBigtableConfig>,
pub max_multiple_accounts: Option<usize>,
pub account_indexes: AccountSecondaryIndexes,
Expand Down Expand Up @@ -3695,21 +3696,23 @@ pub mod rpc_full {
if !skip_preflight {
verify_transaction(&transaction, &preflight_bank.feature_set)?;

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,
if !meta.config.skip_preflight_health_check {
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());
}
.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),
RpcHealthStatus::Behind { num_slots } => {
inc_new_counter_info!("rpc-send-tx_health-behind", 1);
return Err(RpcCustomError::NodeUnhealthy {
num_slots_behind: Some(num_slots),
}
.into());
}
.into());
}
}

Expand Down
8 changes: 8 additions & 0 deletions validator/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,14 @@ pub fn app<'a>(version: &'a str, default_args: &'a DefaultArgs) -> App<'a, 'a> {
latest optimistically confirmed slot",
),
)
.arg(
Arg::with_name("skip_preflight_health_check")
.long("skip-preflight-health-check")
.takes_value(false)
.help(
"Skip health check when running a preflight check",
),
)
.arg(
Arg::with_name("rpc_faucet_addr")
.long("rpc-faucet-address")
Expand Down
1 change: 1 addition & 0 deletions validator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ pub fn main() {
"rpc_max_request_body_size",
usize
)),
skip_preflight_health_check: matches.is_present("skip_preflight_health_check"),
},
on_start_geyser_plugin_config_files,
rpc_addrs: value_t!(matches, "rpc_port", u16).ok().map(|rpc_port| {
Expand Down

0 comments on commit 4a777d1

Please sign in to comment.