From 0764ad23a87ea383b0dba1cc041be7b0e2e4f126 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Wed, 26 Apr 2023 14:32:32 +1000 Subject: [PATCH] Fix data race in HTTP state API --- beacon_node/http_api/src/state_id.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/beacon_node/http_api/src/state_id.rs b/beacon_node/http_api/src/state_id.rs index 9e4aadef17e..8e5365a2488 100644 --- a/beacon_node/http_api/src/state_id.rs +++ b/beacon_node/http_api/src/state_id.rs @@ -70,10 +70,14 @@ impl StateId { .map_err(BeaconChainError::DBError) .map_err(warp_utils::reject::beacon_chain_error)? { + // Check fork choice for the optimistic status, falling back to the finalized + // block's status if the block isn't found. The block may not be found if the + // database has been slow to update its split point, while fork choice has + // already updated and pruned the block. let execution_optimistic = chain .canonical_head .fork_choice_read_lock() - .is_optimistic_or_invalid_block_no_fallback(&hot_summary.latest_block_root) + .is_optimistic_or_invalid_block(&hot_summary.latest_block_root) .map_err(BeaconChainError::ForkChoiceError) .map_err(warp_utils::reject::beacon_chain_error)?; let finalized = chain