mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-08 09:16:00 +00:00
Store parent_payload_hash in ProtoNode
This commit is contained in:
@@ -1138,6 +1138,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// index == 1 (payload_present) requires the block's payload to have been received.
|
// index == 1 (payload_present) requires the block's payload to have been received.
|
||||||
|
// TODO(gloas): could optimise by adding `payload_received` to `Block`
|
||||||
if index == 1
|
if index == 1
|
||||||
&& !self
|
&& !self
|
||||||
.proto_array
|
.proto_array
|
||||||
|
|||||||
@@ -143,6 +143,8 @@ pub struct ProtoNode {
|
|||||||
pub full_payload_weight: u64,
|
pub full_payload_weight: u64,
|
||||||
#[superstruct(only(V29), partial_getter(copy))]
|
#[superstruct(only(V29), partial_getter(copy))]
|
||||||
pub execution_payload_block_hash: ExecutionBlockHash,
|
pub execution_payload_block_hash: ExecutionBlockHash,
|
||||||
|
#[superstruct(only(V29), partial_getter(copy))]
|
||||||
|
pub execution_payload_parent_hash: ExecutionBlockHash,
|
||||||
/// Equivalent to spec's `block_timeliness[root][ATTESTATION_TIMELINESS_INDEX]`.
|
/// Equivalent to spec's `block_timeliness[root][ATTESTATION_TIMELINESS_INDEX]`.
|
||||||
#[superstruct(only(V29), partial_getter(copy))]
|
#[superstruct(only(V29), partial_getter(copy))]
|
||||||
pub block_timeliness_attestation_threshold: bool,
|
pub block_timeliness_attestation_threshold: bool,
|
||||||
@@ -181,7 +183,6 @@ pub struct ProtoNode {
|
|||||||
impl ProtoNode {
|
impl ProtoNode {
|
||||||
/// Generic version of spec's `parent_payload_status` that works for pre-Gloas nodes by
|
/// Generic version of spec's `parent_payload_status` that works for pre-Gloas nodes by
|
||||||
/// considering their parents Empty.
|
/// considering their parents Empty.
|
||||||
/// Pre-Gloas nodes have no ePBS, default to Empty.
|
|
||||||
pub fn get_parent_payload_status(&self) -> PayloadStatus {
|
pub fn get_parent_payload_status(&self) -> PayloadStatus {
|
||||||
self.parent_payload_status().unwrap_or(PayloadStatus::Empty)
|
self.parent_payload_status().unwrap_or(PayloadStatus::Empty)
|
||||||
}
|
}
|
||||||
@@ -620,6 +621,7 @@ impl ProtoArray {
|
|||||||
empty_payload_weight: 0,
|
empty_payload_weight: 0,
|
||||||
full_payload_weight: 0,
|
full_payload_weight: 0,
|
||||||
execution_payload_block_hash,
|
execution_payload_block_hash,
|
||||||
|
execution_payload_parent_hash,
|
||||||
// Per spec `get_forkchoice_store`: the anchor block's PTC votes are
|
// Per spec `get_forkchoice_store`: the anchor block's PTC votes are
|
||||||
// initialized to all-True, ensuring `is_payload_timely` and
|
// initialized to all-True, ensuring `is_payload_timely` and
|
||||||
// `is_payload_data_available` return true for the anchor.
|
// `is_payload_data_available` return true for the anchor.
|
||||||
|
|||||||
@@ -1030,7 +1030,7 @@ impl ProtoArrayForkChoice {
|
|||||||
.unwrap_or_else(|_| ExecutionStatus::irrelevant()),
|
.unwrap_or_else(|_| ExecutionStatus::irrelevant()),
|
||||||
unrealized_justified_checkpoint: block.unrealized_justified_checkpoint(),
|
unrealized_justified_checkpoint: block.unrealized_justified_checkpoint(),
|
||||||
unrealized_finalized_checkpoint: block.unrealized_finalized_checkpoint(),
|
unrealized_finalized_checkpoint: block.unrealized_finalized_checkpoint(),
|
||||||
execution_payload_parent_hash: None,
|
execution_payload_parent_hash: block.execution_payload_parent_hash().ok(),
|
||||||
execution_payload_block_hash: block.execution_payload_block_hash().ok(),
|
execution_payload_block_hash: block.execution_payload_block_hash().ok(),
|
||||||
proposer_index: block.proposer_index().ok(),
|
proposer_index: block.proposer_index().ok(),
|
||||||
})
|
})
|
||||||
@@ -1047,7 +1047,8 @@ impl ProtoArrayForkChoice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns whether the execution payload for a block has been received.
|
/// Returns whether the execution payload for a block has been received.
|
||||||
/// Returns `false` for pre-GLOAS (V17) nodes or unknown blocks.
|
///
|
||||||
|
/// Returns `false` for pre-Gloas (V17) nodes or unknown blocks.
|
||||||
pub fn is_payload_received(&self, block_root: &Hash256) -> bool {
|
pub fn is_payload_received(&self, block_root: &Hash256) -> bool {
|
||||||
self.get_proto_node(block_root)
|
self.get_proto_node(block_root)
|
||||||
.and_then(|node| node.payload_received().ok())
|
.and_then(|node| node.payload_received().ok())
|
||||||
|
|||||||
Reference in New Issue
Block a user