From ae8390150df7ab22bf2c08bf292641f54ca632c4 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Fri, 30 Aug 2024 15:28:18 +1000 Subject: [PATCH] Increase priority for validator HTTP requests (#6292) * Increase priority for validator HTTP requests --- beacon_node/http_api/src/lib.rs | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/beacon_node/http_api/src/lib.rs b/beacon_node/http_api/src/lib.rs index 102d138aa3a..22e9931043e 100644 --- a/beacon_node/http_api/src/lib.rs +++ b/beacon_node/http_api/src/lib.rs @@ -714,7 +714,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, query_res: Result| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { let query = query_res?; crate::validators::get_beacon_state_validators( state_id, @@ -737,7 +744,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, query: ValidatorsRequestBody| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { crate::validators::get_beacon_state_validators( state_id, chain, @@ -763,7 +777,14 @@ pub fn serve( task_spawner: TaskSpawner, chain: Arc>, validator_id: ValidatorId| { - task_spawner.blocking_json_task(Priority::P1, move || { + // Prioritise requests for validators at the head. These should be fast to service + // and could be required by the validator client. + let priority = if let StateId(eth2::types::StateId::Head) = state_id { + Priority::P0 + } else { + Priority::P1 + }; + task_spawner.blocking_json_task(priority, move || { let (data, execution_optimistic, finalized) = state_id .map_state_and_execution_optimistic_and_finalized( &chain,