mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
Gloas spec v1.7.0-alpha.5 and beacon_chain tests (#8998)
Fix database pruning post-Gloas - Fix DB pruning logic (and state summaries DAG) - Get the `beacon_chain` tests running with `FORK_NAME=gloas` 🎉 Co-Authored-By: Michael Sproul <michael@sigmaprime.io> Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com> Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com> Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com> Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>
This commit is contained in:
@@ -17,7 +17,7 @@ use std::{
|
||||
};
|
||||
use types::{
|
||||
AttestationShufflingId, ChainSpec, Checkpoint, Epoch, EthSpec, ExecutionBlockHash, Hash256,
|
||||
Slot, StatePayloadStatus,
|
||||
Slot,
|
||||
};
|
||||
|
||||
pub const DEFAULT_PRUNE_THRESHOLD: usize = 256;
|
||||
@@ -110,19 +110,6 @@ pub enum PayloadStatus {
|
||||
Pending = 2,
|
||||
}
|
||||
|
||||
impl PayloadStatus {
|
||||
/// Convert a `PayloadStatus` into the equivalent `StatePayloadStatus`.
|
||||
///
|
||||
/// This maps `Empty` onto `StatePayloadStatus::Pending` because empty and pending fork choice
|
||||
/// nodes correspond to the exact same state.
|
||||
pub fn as_state_payload_status(self) -> StatePayloadStatus {
|
||||
match self {
|
||||
Self::Empty | Self::Pending => StatePayloadStatus::Pending,
|
||||
Self::Full => StatePayloadStatus::Full,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Spec's `ForkChoiceNode` augmented with ProtoNode index.
|
||||
pub struct IndexedForkChoiceNode {
|
||||
pub root: Hash256,
|
||||
@@ -1019,6 +1006,34 @@ impl ProtoArrayForkChoice {
|
||||
})
|
||||
}
|
||||
|
||||
/// Returns whether the proposer should extend the parent's execution payload chain.
|
||||
///
|
||||
/// This checks timeliness, data availability, and proposer boost conditions per the spec.
|
||||
pub fn should_extend_payload<E: EthSpec>(
|
||||
&self,
|
||||
block_root: &Hash256,
|
||||
proposer_boost_root: Hash256,
|
||||
) -> Result<bool, String> {
|
||||
let block_index = self
|
||||
.proto_array
|
||||
.indices
|
||||
.get(block_root)
|
||||
.ok_or_else(|| format!("Unknown block root: {block_root:?}"))?;
|
||||
let proto_node = self
|
||||
.proto_array
|
||||
.nodes
|
||||
.get(*block_index)
|
||||
.ok_or_else(|| format!("Missing node at index: {block_index}"))?;
|
||||
let fc_node = IndexedForkChoiceNode {
|
||||
root: proto_node.root(),
|
||||
proto_node_index: *block_index,
|
||||
payload_status: proto_node.get_parent_payload_status(),
|
||||
};
|
||||
self.proto_array
|
||||
.should_extend_payload::<E>(&fc_node, proto_node, proposer_boost_root)
|
||||
.map_err(|e| format!("{e:?}"))
|
||||
}
|
||||
|
||||
/// Returns the `block.execution_status` field, if the block is present.
|
||||
pub fn get_block_execution_status(&self, block_root: &Hash256) -> Option<ExecutionStatus> {
|
||||
let block = self.get_proto_node(block_root)?;
|
||||
|
||||
Reference in New Issue
Block a user