Skip to content

Commit ae83901

Browse files
Increase priority for validator HTTP requests (#6292)
* Increase priority for validator HTTP requests
1 parent 100f33a commit ae83901

File tree

1 file changed

+24
-3
lines changed
  • beacon_node/http_api/src

1 file changed

+24
-3
lines changed

beacon_node/http_api/src/lib.rs

+24-3
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,14 @@ pub fn serve<T: BeaconChainTypes>(
714714
task_spawner: TaskSpawner<T::EthSpec>,
715715
chain: Arc<BeaconChain<T>>,
716716
query_res: Result<api_types::ValidatorsQuery, warp::Rejection>| {
717-
task_spawner.blocking_json_task(Priority::P1, move || {
717+
// Prioritise requests for validators at the head. These should be fast to service
718+
// and could be required by the validator client.
719+
let priority = if let StateId(eth2::types::StateId::Head) = state_id {
720+
Priority::P0
721+
} else {
722+
Priority::P1
723+
};
724+
task_spawner.blocking_json_task(priority, move || {
718725
let query = query_res?;
719726
crate::validators::get_beacon_state_validators(
720727
state_id,
@@ -737,7 +744,14 @@ pub fn serve<T: BeaconChainTypes>(
737744
task_spawner: TaskSpawner<T::EthSpec>,
738745
chain: Arc<BeaconChain<T>>,
739746
query: ValidatorsRequestBody| {
740-
task_spawner.blocking_json_task(Priority::P1, move || {
747+
// Prioritise requests for validators at the head. These should be fast to service
748+
// and could be required by the validator client.
749+
let priority = if let StateId(eth2::types::StateId::Head) = state_id {
750+
Priority::P0
751+
} else {
752+
Priority::P1
753+
};
754+
task_spawner.blocking_json_task(priority, move || {
741755
crate::validators::get_beacon_state_validators(
742756
state_id,
743757
chain,
@@ -763,7 +777,14 @@ pub fn serve<T: BeaconChainTypes>(
763777
task_spawner: TaskSpawner<T::EthSpec>,
764778
chain: Arc<BeaconChain<T>>,
765779
validator_id: ValidatorId| {
766-
task_spawner.blocking_json_task(Priority::P1, move || {
780+
// Prioritise requests for validators at the head. These should be fast to service
781+
// and could be required by the validator client.
782+
let priority = if let StateId(eth2::types::StateId::Head) = state_id {
783+
Priority::P0
784+
} else {
785+
Priority::P1
786+
};
787+
task_spawner.blocking_json_task(priority, move || {
767788
let (data, execution_optimistic, finalized) = state_id
768789
.map_state_and_execution_optimistic_and_finalized(
769790
&chain,

0 commit comments

Comments
 (0)