Optimise head block root API (#4799)
## Issue Addressed
We've had a report of sync committee performance suffering with the beacon processor HTTP API prioritisations.
## Proposed Changes
Increase the priority of `/eth/v1/beacon/blocks/head/root` requests, which are used by the validator client to form sync committee messages, here:
441fc1691b/validator_client/src/sync_committee_service.rs (L181-L188)
Additionally, avoid loading the blinded block in all but the `block_id=block_root` case. I'm not sure why we were doing this previously, I suspect it was just an oversight during the implementation of the `finalized` status on API requests.
## Additional Info
I think this change should have minimal negative impact as:
- The block root endpoint is quick to compute (a few ms max).
- Only the priority of `head` requests is increased. Analytical processes that are making lots of block root requests for past slots are unable to DoS the beacon processor, as their requests will still be processed after attestations.
This commit is contained in:
parent
5bab9b866e
commit
6ec649a4e2
@ -1629,13 +1629,19 @@ pub fn serve<T: BeaconChainTypes>(
|
||||
|block_id: BlockId,
|
||||
task_spawner: TaskSpawner<T::EthSpec>,
|
||||
chain: Arc<BeaconChain<T>>| {
|
||||
task_spawner.blocking_json_task(Priority::P1, move || {
|
||||
let (block, execution_optimistic, finalized) =
|
||||
block_id.blinded_block(&chain)?;
|
||||
Ok(api_types::GenericResponse::from(api_types::RootData::from(
|
||||
block.canonical_root(),
|
||||
))
|
||||
.add_execution_optimistic_finalized(execution_optimistic, finalized))
|
||||
// Prioritise requests for the head block root, as it is used by some VCs (including
|
||||
// the Lighthouse VC) to create sync committee messages.
|
||||
let priority = if let BlockId(eth2::types::BlockId::Head) = block_id {
|
||||
Priority::P0
|
||||
} else {
|
||||
Priority::P1
|
||||
};
|
||||
task_spawner.blocking_json_task(priority, move || {
|
||||
let (block_root, execution_optimistic, finalized) = block_id.root(&chain)?;
|
||||
Ok(
|
||||
api_types::GenericResponse::from(api_types::RootData::from(block_root))
|
||||
.add_execution_optimistic_finalized(execution_optimistic, finalized),
|
||||
)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user