Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions crates/blockchain/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ impl BlockChainServer {

// Update safe target slot metric (updated by store.on_tick at interval 2)
metrics::update_safe_target_slot(self.store.safe_target_slot());
// Update head slot metric (head may change when attestations are promoted at intervals 0/3)
metrics::update_head_slot(self.store.head_slot());
}

/// Returns the validator ID if any of our validators is the proposer for this slot.
Expand Down Expand Up @@ -275,9 +277,8 @@ impl BlockChainServer {
&mut self,
signed_block: SignedBlockWithAttestation,
) -> Result<(), StoreError> {
let slot = signed_block.message.block.slot;
store::on_block(&mut self.store, signed_block)?;
metrics::update_head_slot(slot);
metrics::update_head_slot(self.store.head_slot());
metrics::update_latest_justified_slot(self.store.latest_justified().slot);
metrics::update_latest_finalized_slot(self.store.latest_finalized().slot);
metrics::update_validators_count(self.key_manager.validator_ids().len() as u64);
Expand Down
7 changes: 7 additions & 0 deletions crates/storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,13 @@ impl Store {

// ============ Derived Accessors ============

/// Returns the slot of the current head block.
pub fn head_slot(&self) -> u64 {
self.get_block_header(&self.head())
.expect("head block exists")
.slot
}

/// Returns the slot of the current safe target block.
pub fn safe_target_slot(&self) -> u64 {
self.get_block_header(&self.safe_target())
Expand Down