Mark reduced_tree fork choice as incomplete
This commit is contained in:
parent
d0037f49d8
commit
0b2ad4d0a1
@ -770,7 +770,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
} else {
|
} else {
|
||||||
state.latest_block_header.canonical_root()
|
state.latest_block_header.canonical_root()
|
||||||
};
|
};
|
||||||
dbg!(previous_block_root);
|
|
||||||
|
|
||||||
let mut graffiti: [u8; 32] = [0; 32];
|
let mut graffiti: [u8; 32] = [0; 32];
|
||||||
graffiti.copy_from_slice(GRAFFITI.as_bytes());
|
graffiti.copy_from_slice(GRAFFITI.as_bytes());
|
||||||
@ -814,8 +813,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
self.metrics.block_production_successes.inc();
|
self.metrics.block_production_successes.inc();
|
||||||
timer.observe_duration();
|
timer.observe_duration();
|
||||||
|
|
||||||
dbg!(block.canonical_root());
|
|
||||||
|
|
||||||
Ok((block, state))
|
Ok((block, state))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -849,9 +846,6 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|
|||||||
|
|
||||||
// If we switched to a new chain (instead of building atop the present chain).
|
// If we switched to a new chain (instead of building atop the present chain).
|
||||||
if self.head().beacon_block_root != beacon_block.previous_block_root {
|
if self.head().beacon_block_root != beacon_block.previous_block_root {
|
||||||
dbg!("switched head");
|
|
||||||
dbg!(self.head().beacon_block.slot);
|
|
||||||
dbg!(beacon_block.slot);
|
|
||||||
self.metrics.fork_choice_reorg_count.inc();
|
self.metrics.fork_choice_reorg_count.inc();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -186,7 +186,6 @@ impl<T: BeaconChainTypes> Drop for Client<T> {
|
|||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// Save the beacon chain to it's store before dropping.
|
// Save the beacon chain to it's store before dropping.
|
||||||
let _result = self.beacon_chain.persist();
|
let _result = self.beacon_chain.persist();
|
||||||
dbg!("Saved BeaconChain to store");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/// An implementation of "reduced tree" LMD GHOST fork choice.
|
||||||
|
///
|
||||||
|
/// This algorithm was concieved at IC3 Cornell, 2019.
|
||||||
|
///
|
||||||
|
/// This implementation is incomplete and has known bugs.
|
||||||
use super::{LmdGhost, Result as SuperResult};
|
use super::{LmdGhost, Result as SuperResult};
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -210,8 +215,6 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn find_head_from<'a>(&'a self, start_node: &'a Node) -> Result<&'a Node> {
|
fn find_head_from<'a>(&'a self, start_node: &'a Node) -> Result<&'a Node> {
|
||||||
dbg!(&self.nodes);
|
|
||||||
|
|
||||||
if start_node.does_not_have_children() {
|
if start_node.does_not_have_children() {
|
||||||
Ok(start_node)
|
Ok(start_node)
|
||||||
} else {
|
} else {
|
||||||
@ -404,10 +407,24 @@ where
|
|||||||
|
|
||||||
if !prev_in_tree.children.is_empty() {
|
if !prev_in_tree.children.is_empty() {
|
||||||
for &child_hash in &prev_in_tree.children {
|
for &child_hash in &prev_in_tree.children {
|
||||||
let ancestor_hash = self.find_least_common_ancestor(node.block_hash, child_hash)?;
|
if self
|
||||||
|
.iter_ancestors(child_hash)?
|
||||||
|
.any(|(ancestor, _slot)| ancestor == node.block_hash)
|
||||||
|
{
|
||||||
|
let child = self.get_mut_node(child_hash)?;
|
||||||
|
|
||||||
// TODO: handle the case where the new block is a child of an existing node and a
|
child.parent_hash = Some(node.block_hash);
|
||||||
// parent of an existing node.
|
node.children.push(child_hash);
|
||||||
|
prev_in_tree.replace_child(child_hash, node.block_hash)?;
|
||||||
|
|
||||||
|
added_new_ancestor = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for &child_hash in &prev_in_tree.children {
|
||||||
|
let ancestor_hash = self.find_least_common_ancestor(node.block_hash, child_hash)?;
|
||||||
|
|
||||||
if ancestor_hash != prev_in_tree.block_hash {
|
if ancestor_hash != prev_in_tree.block_hash {
|
||||||
let child = self.get_mut_node(child_hash)?;
|
let child = self.get_mut_node(child_hash)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user