mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 22:38:34 +00:00
completing should_extend_payload implementation
This commit is contained in:
@@ -4840,10 +4840,53 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// If the current slot is already equal to the proposal slot (or we are in the tail end of
|
||||
// the prior slot), then check the actual weight of the head against the head re-org threshold
|
||||
// and the actual weight of the parent against the parent re-org threshold.
|
||||
// Per spec `is_head_weak`: uses get_attestation_score(head, PENDING) which is
|
||||
// the total weight. Per spec `is_parent_strong`: uses
|
||||
// get_attestation_score(parent, parent_payload_status) where parent_payload_status
|
||||
// is determined by the head block's relationship to its parent.
|
||||
let head_weight = info.head_node.weight();
|
||||
let parent_weight = if let Ok(head_payload_status) = info.head_node.parent_payload_status()
|
||||
{
|
||||
// Post-GLOAS: use the payload-filtered weight matching how the head
|
||||
// extends from its parent.
|
||||
match head_payload_status {
|
||||
proto_array::PayloadStatus::Full => {
|
||||
info.parent_node.full_payload_weight().map_err(|()| {
|
||||
Box::new(ProposerHeadError::Error(
|
||||
Error::ProposerHeadForkChoiceError(
|
||||
fork_choice::Error::ProtoArrayError(
|
||||
proto_array::Error::InvalidNodeVariant {
|
||||
block_root: info.parent_node.root(),
|
||||
},
|
||||
),
|
||||
),
|
||||
))
|
||||
})?
|
||||
}
|
||||
proto_array::PayloadStatus::Empty => {
|
||||
info.parent_node.empty_payload_weight().map_err(|()| {
|
||||
Box::new(ProposerHeadError::Error(
|
||||
Error::ProposerHeadForkChoiceError(
|
||||
fork_choice::Error::ProtoArrayError(
|
||||
proto_array::Error::InvalidNodeVariant {
|
||||
block_root: info.parent_node.root(),
|
||||
},
|
||||
),
|
||||
),
|
||||
))
|
||||
})?
|
||||
}
|
||||
proto_array::PayloadStatus::Pending => info.parent_node.weight(),
|
||||
}
|
||||
} else {
|
||||
// Pre-GLOAS (V17): use total weight.
|
||||
info.parent_node.weight()
|
||||
};
|
||||
|
||||
let (head_weak, parent_strong) = if fork_choice_slot == re_org_block_slot {
|
||||
(
|
||||
info.head_node.weight() < info.re_org_head_weight_threshold,
|
||||
info.parent_node.weight() > info.re_org_parent_weight_threshold,
|
||||
head_weight < info.re_org_head_weight_threshold,
|
||||
parent_weight > info.re_org_parent_weight_threshold,
|
||||
)
|
||||
} else {
|
||||
(true, true)
|
||||
@@ -4851,7 +4894,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
if !head_weak {
|
||||
return Err(Box::new(
|
||||
DoNotReOrg::HeadNotWeak {
|
||||
head_weight: info.head_node.weight(),
|
||||
head_weight,
|
||||
re_org_head_weight_threshold: info.re_org_head_weight_threshold,
|
||||
}
|
||||
.into(),
|
||||
@@ -4860,7 +4903,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
if !parent_strong {
|
||||
return Err(Box::new(
|
||||
DoNotReOrg::ParentNotStrong {
|
||||
parent_weight: info.parent_node.weight(),
|
||||
parent_weight,
|
||||
re_org_parent_weight_threshold: info.re_org_parent_weight_threshold,
|
||||
}
|
||||
.into(),
|
||||
|
||||
@@ -23,9 +23,9 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
||||
// Only check blocks that are descendants of the finalized checkpoint.
|
||||
// Pruned non-canonical fork blocks may linger in the proto-array but
|
||||
// are legitimately absent from the database.
|
||||
fc.is_finalized_checkpoint_or_descendant(node.root)
|
||||
fc.is_finalized_checkpoint_or_descendant(node.root())
|
||||
})
|
||||
.map(|node| (node.root, node.slot))
|
||||
.map(|node| (node.root(), node.slot()))
|
||||
.collect()
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user