diff --git a/beacon_node/beacon_chain/src/info.rs b/beacon_node/beacon_chain/src/info.rs index 109ab9be6..441d56b78 100644 --- a/beacon_node/beacon_chain/src/info.rs +++ b/beacon_node/beacon_chain/src/info.rs @@ -44,4 +44,12 @@ where let state = self.state(present_slot).ok()?; state.get_beacon_proposer_index(slot, &self.spec) } + + pub fn justified_slot(&self) -> u64 { + self.justified_head + .read() + .expect("Justified head poisoned") + .beacon_block + .slot + } } diff --git a/beacon_node/beacon_chain/src/lib.rs b/beacon_node/beacon_chain/src/lib.rs index 015fff017..6ea9576d8 100644 --- a/beacon_node/beacon_chain/src/lib.rs +++ b/beacon_node/beacon_chain/src/lib.rs @@ -74,6 +74,7 @@ pub struct BeaconChain { pub block_graph: BlockGraph, canonical_head: RwLock, finalized_head: RwLock, + justified_head: RwLock, pub latest_attestation_targets: RwLock, pub spec: ChainSpec, } @@ -110,6 +111,12 @@ where genesis_state.clone(), state_root.clone(), )); + let justified_head = RwLock::new(CheckPoint::new( + genesis_block.clone(), + block_root.clone(), + genesis_state.clone(), + state_root.clone(), + )); let canonical_head = RwLock::new(CheckPoint::new( genesis_block.clone(), block_root.clone(), @@ -124,6 +131,7 @@ where state_store, slot_clock, block_graph, + justified_head, finalized_head, canonical_head, latest_attestation_targets,