From c2f8933d86e96956813e3cc344bec9cfb4d3e868 Mon Sep 17 00:00:00 2001 From: Povilas Liubauskas Date: Wed, 7 Aug 2024 16:49:57 +0300 Subject: [PATCH] Avoid loading beacon states when building fork choice context for debug --- fork_choice_control/src/queries.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fork_choice_control/src/queries.rs b/fork_choice_control/src/queries.rs index 57cb6377..80d9c4ef 100644 --- a/fork_choice_control/src/queries.rs +++ b/fork_choice_control/src/queries.rs @@ -199,20 +199,22 @@ where pub fn fork_choice_context(&self) -> ForkChoiceContext { let store = self.store_snapshot(); + let justified_checkpoint = store.justified_checkpoint(); + let finalized_checkpoint = store.finalized_checkpoint(); + let fork_choice_nodes = store .unfinalized() .values() .flatten() .map(|unfinalized_block| { let chain_link = &unfinalized_block.chain_link; - let state = chain_link.state(&store); ForkChoiceNode { slot: chain_link.slot(), block_root: chain_link.block_root, parent_root: chain_link.block.message().parent_root(), - justified_epoch: state.current_justified_checkpoint().epoch, - finalized_epoch: state.finalized_checkpoint().epoch, + justified_epoch: justified_checkpoint.epoch, + finalized_epoch: finalized_checkpoint.epoch, validity: chain_link.payload_status, weight: unfinalized_block.attesting_balance, execution_block_hash: chain_link.execution_block_hash().unwrap_or_default(), @@ -221,8 +223,8 @@ where .collect(); ForkChoiceContext { - justified_checkpoint: store.justified_checkpoint(), - finalized_checkpoint: store.finalized_checkpoint(), + justified_checkpoint, + finalized_checkpoint, fork_choice_nodes, } }