Skip to content

Commit

Permalink
Avoid loading beacon states when building fork choice context for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
povi committed Aug 7, 2024
1 parent 5a2ffe2 commit c2f8933
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions fork_choice_control/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -221,8 +223,8 @@ where
.collect();

ForkChoiceContext {
justified_checkpoint: store.justified_checkpoint(),
finalized_checkpoint: store.finalized_checkpoint(),
justified_checkpoint,
finalized_checkpoint,
fork_choice_nodes,
}
}
Expand Down

0 comments on commit c2f8933

Please sign in to comment.