mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-25 16:58:28 +00:00
Fix compilation, clear best_child/best_descendant in migration
- Fix leaf detection in heads_descended_from_finalization (parent() method call, map away enumerate index) - Clear best_child and best_descendant in v28->v29 migration (no longer used, replaced by virtual tree walk) - Migration now rewrites fork choice data instead of being a no-op
This commit is contained in:
@@ -283,14 +283,7 @@ impl ForkChoiceTestDefinition {
|
||||
proposer_index: Some(0),
|
||||
};
|
||||
fork_choice
|
||||
.process_block::<MainnetEthSpec>(
|
||||
block,
|
||||
slot,
|
||||
self.justified_checkpoint,
|
||||
self.finalized_checkpoint,
|
||||
&spec,
|
||||
Duration::ZERO,
|
||||
)
|
||||
.process_block::<MainnetEthSpec>(block, slot, &spec, Duration::ZERO)
|
||||
.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"process_block op at index {} returned error: {:?}",
|
||||
|
||||
@@ -389,9 +389,6 @@ impl ProtoArray {
|
||||
pub fn apply_score_changes<E: EthSpec>(
|
||||
&mut self,
|
||||
mut deltas: Vec<NodeDelta>,
|
||||
best_justified_checkpoint: Checkpoint,
|
||||
best_finalized_checkpoint: Checkpoint,
|
||||
current_slot: Slot,
|
||||
) -> Result<(), Error> {
|
||||
if deltas.len() != self.indices.len() {
|
||||
return Err(Error::InvalidDeltaLen {
|
||||
@@ -518,8 +515,6 @@ impl ProtoArray {
|
||||
&mut self,
|
||||
block: Block,
|
||||
current_slot: Slot,
|
||||
best_justified_checkpoint: Checkpoint,
|
||||
best_finalized_checkpoint: Checkpoint,
|
||||
spec: &ChainSpec,
|
||||
time_into_slot: Duration,
|
||||
) -> Result<(), Error> {
|
||||
@@ -677,10 +672,10 @@ impl ProtoArray {
|
||||
self.indices.insert(node.root(), node_index);
|
||||
self.nodes.push(node.clone());
|
||||
|
||||
if let Some(parent_index) = node.parent() {
|
||||
if matches!(block.execution_status, ExecutionStatus::Valid(_)) {
|
||||
self.propagate_execution_payload_validation_by_index(parent_index)?;
|
||||
}
|
||||
if let Some(parent_index) = node.parent()
|
||||
&& matches!(block.execution_status, ExecutionStatus::Valid(_))
|
||||
{
|
||||
self.propagate_execution_payload_validation_by_index(parent_index)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -1773,17 +1768,14 @@ impl ProtoArray {
|
||||
.enumerate()
|
||||
.filter(|(i, node)| {
|
||||
// TODO(gloas): we unoptimized this for Gloas fork choice, could re-optimize.
|
||||
let num_children = self
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|node| node.parent == Some(i))
|
||||
.count();
|
||||
let num_children = self.nodes.iter().filter(|n| n.parent() == Some(*i)).count();
|
||||
num_children == 0
|
||||
&& self.is_finalized_checkpoint_or_descendant::<E>(
|
||||
node.root(),
|
||||
best_finalized_checkpoint,
|
||||
)
|
||||
})
|
||||
.map(|(_, node)| node)
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,8 +512,6 @@ impl ProtoArrayForkChoice {
|
||||
.on_block::<E>(
|
||||
block,
|
||||
current_slot,
|
||||
justified_checkpoint,
|
||||
finalized_checkpoint,
|
||||
spec,
|
||||
// Anchor block is always timely (delay=0 ensures both timeliness
|
||||
// checks pass). Combined with `is_genesis` override in on_block,
|
||||
@@ -615,8 +613,6 @@ impl ProtoArrayForkChoice {
|
||||
&mut self,
|
||||
block: Block,
|
||||
current_slot: Slot,
|
||||
justified_checkpoint: Checkpoint,
|
||||
finalized_checkpoint: Checkpoint,
|
||||
spec: &ChainSpec,
|
||||
time_into_slot: Duration,
|
||||
) -> Result<(), String> {
|
||||
@@ -625,14 +621,7 @@ impl ProtoArrayForkChoice {
|
||||
}
|
||||
|
||||
self.proto_array
|
||||
.on_block::<E>(
|
||||
block,
|
||||
current_slot,
|
||||
justified_checkpoint,
|
||||
finalized_checkpoint,
|
||||
spec,
|
||||
time_into_slot,
|
||||
)
|
||||
.on_block::<E>(block, current_slot, spec, time_into_slot)
|
||||
.map_err(|e| format!("process_block_error: {:?}", e))
|
||||
}
|
||||
|
||||
@@ -667,12 +656,7 @@ impl ProtoArrayForkChoice {
|
||||
.map_err(|e| format!("find_head compute_deltas failed: {:?}", e))?;
|
||||
|
||||
self.proto_array
|
||||
.apply_score_changes::<E>(
|
||||
deltas,
|
||||
justified_checkpoint,
|
||||
finalized_checkpoint,
|
||||
current_slot,
|
||||
)
|
||||
.apply_score_changes::<E>(deltas)
|
||||
.map_err(|e| format!("find_head apply_score_changes failed: {:?}", e))?;
|
||||
|
||||
*old_balances = new_balances.clone();
|
||||
@@ -1354,8 +1338,6 @@ mod test_compute_deltas {
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
genesis_slot + 1,
|
||||
genesis_checkpoint,
|
||||
genesis_checkpoint,
|
||||
&spec,
|
||||
Duration::ZERO,
|
||||
)
|
||||
@@ -1384,8 +1366,6 @@ mod test_compute_deltas {
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
genesis_slot + 1,
|
||||
genesis_checkpoint,
|
||||
genesis_checkpoint,
|
||||
&spec,
|
||||
Duration::ZERO,
|
||||
)
|
||||
@@ -1521,8 +1501,6 @@ mod test_compute_deltas {
|
||||
proposer_index: Some(0),
|
||||
},
|
||||
Slot::from(block.slot),
|
||||
genesis_checkpoint,
|
||||
genesis_checkpoint,
|
||||
&spec,
|
||||
Duration::ZERO,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user