mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-31 13:17:09 +00:00
Fork choice changes
This commit is contained in:
@@ -360,7 +360,7 @@ pub struct ProtoArray {
|
||||
pub prune_threshold: usize,
|
||||
pub nodes: Vec<ProtoNode>,
|
||||
pub indices: HashMap<Hash256, usize>,
|
||||
pub unsatisfied_inclusion_list_blocks: HashMap<Slot, Hash256>,
|
||||
pub payload_inclusion_list_satisfaction: HashMap<Hash256, bool>,
|
||||
pub previous_proposer_boost: ProposerBoost,
|
||||
}
|
||||
|
||||
@@ -1510,6 +1510,16 @@ impl ProtoArray {
|
||||
proto_node: &ProtoNode,
|
||||
proposer_boost_root: Hash256,
|
||||
) -> Result<bool, Error> {
|
||||
// If the block's inclusion list satisfaction has been recorded as false,
|
||||
// do not extend the payload.
|
||||
if self
|
||||
.payload_inclusion_list_satisfaction
|
||||
.get(&fc_node.root)
|
||||
== Some(&false)
|
||||
{
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
// Per spec: `proposer_root == Root()` is one of the `or` conditions that
|
||||
// makes `should_extend_payload` return True.
|
||||
if proposer_boost_root.is_zero() {
|
||||
@@ -1616,12 +1626,10 @@ impl ProtoArray {
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO(focil) unwrap_or
|
||||
if node.root()
|
||||
== *self
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
.get(¤t_slot)
|
||||
.unwrap_or(&Hash256::zero())
|
||||
if self
|
||||
.payload_inclusion_list_satisfaction
|
||||
.get(&node.root())
|
||||
== Some(&false)
|
||||
{
|
||||
info!(
|
||||
?current_slot,
|
||||
|
||||
@@ -505,7 +505,7 @@ impl ProtoArrayForkChoice {
|
||||
finalized_checkpoint: Checkpoint,
|
||||
current_epoch_shuffling_id: AttestationShufflingId,
|
||||
next_epoch_shuffling_id: AttestationShufflingId,
|
||||
unsatisfied_inclusion_list_blocks: HashMap<Slot, Hash256>,
|
||||
payload_inclusion_list_satisfaction: HashMap<Hash256, bool>,
|
||||
execution_status: ExecutionStatus,
|
||||
execution_payload_parent_hash: Option<ExecutionBlockHash>,
|
||||
execution_payload_block_hash: Option<ExecutionBlockHash>,
|
||||
@@ -516,7 +516,7 @@ impl ProtoArrayForkChoice {
|
||||
prune_threshold: DEFAULT_PRUNE_THRESHOLD,
|
||||
nodes: Vec::with_capacity(1),
|
||||
indices: HashMap::with_capacity(1),
|
||||
unsatisfied_inclusion_list_blocks,
|
||||
payload_inclusion_list_satisfaction,
|
||||
previous_proposer_boost: ProposerBoost::default(),
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use ssz::{Encode, four_byte_option_impl};
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::collections::HashMap;
|
||||
use superstruct::superstruct;
|
||||
use types::{Checkpoint, Hash256, Slot};
|
||||
use types::{Checkpoint, Hash256};
|
||||
|
||||
// Define a "legacy" implementation of `Option<usize>` which uses four bytes for encoding the union
|
||||
// selector.
|
||||
@@ -40,7 +40,7 @@ pub struct SszContainer {
|
||||
pub indices: Vec<(Hash256, usize)>,
|
||||
#[superstruct(only(V28))]
|
||||
pub previous_proposer_boost: ProposerBoost,
|
||||
pub unsatisfied_inclusion_list_blocks: Vec<(Slot, Hash256)>,
|
||||
pub payload_inclusion_list_satisfaction: Vec<(Hash256, bool)>,
|
||||
}
|
||||
|
||||
impl SszContainerV29 {
|
||||
@@ -52,8 +52,8 @@ impl SszContainerV29 {
|
||||
prune_threshold: proto_array.prune_threshold,
|
||||
nodes: proto_array.nodes.clone(),
|
||||
indices: proto_array.indices.iter().map(|(k, v)| (*k, *v)).collect(),
|
||||
unsatisfied_inclusion_list_blocks: proto_array
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
payload_inclusion_list_satisfaction: proto_array
|
||||
.payload_inclusion_list_satisfaction
|
||||
.iter()
|
||||
.map(|(k, v)| (*k, *v))
|
||||
.collect(),
|
||||
@@ -70,8 +70,8 @@ impl TryFrom<(SszContainerV29, JustifiedBalances)> for ProtoArrayForkChoice {
|
||||
nodes: from.nodes,
|
||||
indices: from.indices.into_iter().collect::<HashMap<_, _>>(),
|
||||
previous_proposer_boost: ProposerBoost::default(),
|
||||
unsatisfied_inclusion_list_blocks: from
|
||||
.unsatisfied_inclusion_list_blocks
|
||||
payload_inclusion_list_satisfaction: from
|
||||
.payload_inclusion_list_satisfaction
|
||||
.into_iter()
|
||||
.collect::<HashMap<_, _>>(),
|
||||
};
|
||||
@@ -102,7 +102,7 @@ impl From<SszContainerV28> for SszContainerV29 {
|
||||
})
|
||||
.collect(),
|
||||
indices: v28.indices,
|
||||
unsatisfied_inclusion_list_blocks: vec![],
|
||||
payload_inclusion_list_satisfaction: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ impl From<SszContainerV29> for SszContainerV28 {
|
||||
indices: v29.indices,
|
||||
// Proposer boost is not tracked in V29 (computed on-the-fly), so reset it.
|
||||
previous_proposer_boost: ProposerBoost::default(),
|
||||
unsatisfied_inclusion_list_blocks: v29.unsatisfied_inclusion_list_blocks,
|
||||
payload_inclusion_list_satisfaction: v29.payload_inclusion_list_satisfaction,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user