calculate head block number for gloas

This commit is contained in:
Eitan Seri-Levi
2026-05-24 16:51:57 +03:00
parent 5045e8dd85
commit 28240f4712
2 changed files with 16 additions and 5 deletions

View File

@@ -178,7 +178,7 @@ impl<E: EthSpec> CachedHead<E> {
/// Returns the execution block number of the block at the head of the chain.
///
/// Returns an error if the chain is prior to Bellatrix.
/// Returns an error if the chain is prior to Bellatrix or post-Gloas
pub fn head_block_number(&self) -> Result<u64, BeaconStateError> {
self.snapshot
.beacon_block
@@ -187,6 +187,17 @@ impl<E: EthSpec> CachedHead<E> {
.map(|payload| payload.block_number())
}
/// Returns the execution block number of the block at the head of the chain.
///
/// Returns an error if the chain is prior to Gloas.
pub fn head_block_number_gloas(&self) -> Result<u64, BeaconStateError> {
self.snapshot
.execution_envelope
.as_ref()
.map(|envelope| envelope.message.payload.block_number)
.ok()
}
/// Returns the active validator count for the current epoch of the head state.
///
/// Should only return `None` if the caches have not been built on the head state (this should