mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 04:37:13 +00:00
calculate head block number for gloas
This commit is contained in:
@@ -5055,16 +5055,16 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO(gloas) not sure what to do here see this issue
|
|
||||||
// https://github.com/sigp/lighthouse/issues/8817
|
|
||||||
let (prev_randao, parent_block_number) = if self
|
let (prev_randao, parent_block_number) = if self
|
||||||
.spec
|
.spec
|
||||||
.fork_name_at_slot::<T::EthSpec>(proposal_slot)
|
.fork_name_at_slot::<T::EthSpec>(proposal_slot)
|
||||||
.gloas_enabled()
|
.gloas_enabled()
|
||||||
{
|
{
|
||||||
(cached_head.head_random()?, None)
|
(
|
||||||
|
cached_head.head_random()?,
|
||||||
|
cached_head.head_block_number_gloas(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
// Get the `prev_randao` and parent block number.
|
|
||||||
let head_block_number = cached_head.head_block_number()?;
|
let head_block_number = cached_head.head_block_number()?;
|
||||||
if proposer_head == head_parent_block_root {
|
if proposer_head == head_parent_block_root {
|
||||||
(
|
(
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ impl<E: EthSpec> CachedHead<E> {
|
|||||||
|
|
||||||
/// Returns the execution block number of the block at the head of the chain.
|
/// 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> {
|
pub fn head_block_number(&self) -> Result<u64, BeaconStateError> {
|
||||||
self.snapshot
|
self.snapshot
|
||||||
.beacon_block
|
.beacon_block
|
||||||
@@ -187,6 +187,17 @@ impl<E: EthSpec> CachedHead<E> {
|
|||||||
.map(|payload| payload.block_number())
|
.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.
|
/// 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
|
/// Should only return `None` if the caches have not been built on the head state (this should
|
||||||
|
|||||||
Reference in New Issue
Block a user