General tidy

This commit is contained in:
Paul Hauner
2020-01-28 13:36:10 +11:00
parent 98ed038775
commit 023ce333a1
4 changed files with 7 additions and 14 deletions

View File

@@ -61,7 +61,7 @@ pub enum BlockProcessingOutcome {
/// The parent block was unknown.
ParentUnknown {
parent: Hash256,
reference_location: String,
reference_location: &'static str,
},
/// The block slot is greater than the present slot.
FutureSlot {
@@ -1239,7 +1239,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
if !self.fork_choice.contains_block(&block.parent_root) {
return Ok(BlockProcessingOutcome::ParentUnknown {
parent: block.parent_root,
reference_location: "fork_choice".to_string(),
reference_location: "fork_choice",
});
}
@@ -1280,7 +1280,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
None => {
return Ok(BlockProcessingOutcome::ParentUnknown {
parent: block.parent_root,
reference_location: "database".to_string(),
reference_location: "database",
});
}
};

View File

@@ -13,8 +13,8 @@ use std::fs::File;
fn main() {
write_test_def_to_yaml("votes.yaml", get_votes_test_definition());
write_test_def_to_yaml("no_votes.yaml", get_no_votes_test_definition());
write_test_def_to_yaml("no_votes.yaml", get_ffg_case_01_test_definition());
write_test_def_to_yaml("no_votes.yaml", get_ffg_case_02_test_definition());
write_test_def_to_yaml("ffg_01.yaml", get_ffg_case_01_test_definition());
write_test_def_to_yaml("ffg_02.yaml", get_ffg_case_02_test_definition());
}
fn write_test_def_to_yaml(filename: &str, def: ForkChoiceTestDefinition) {

View File

@@ -42,8 +42,7 @@ impl ProtoArray {
/// - Back-propgrate each nodes delta to its parents delta.
/// - Compare the current node with the parents best-child, updating it if the current node
/// should become the best child.
/// - Update the parents best-descendant with the current node or its best-descendant, if
/// required.
/// - If required, update the parents best-descendant with the current node or its best-descendant.
pub fn apply_score_changes(
&mut self,
mut deltas: Vec<i64>,
@@ -187,8 +186,7 @@ impl ProtoArray {
.get(best_descendant_index)
.ok_or_else(|| Error::InvalidBestDescendant(best_descendant_index))?;
// It is a logic error to try and find the head starting from a block that does not match
// the filter.
// Perform a sanity check that the node is indeed valid to be the head.
if !self.node_is_viable_for_head(&best_node) {
return Err(Error::InvalidBestNode {
start_root: *justified_root,
@@ -329,7 +327,6 @@ impl ProtoArray {
.get(best_child_index)
.ok_or_else(|| Error::InvalidBestDescendant(best_child_index))?;
let child_leads_to_viable_head = self.node_leads_to_viable_head(&child)?;
let best_child_leads_to_viable_head =
self.node_leads_to_viable_head(&best_child)?;

View File

@@ -13,9 +13,6 @@ pub struct SszContainer {
votes: Vec<VoteTracker>,
balances: Vec<u64>,
prune_threshold: usize,
// TODO: this field is no longer required, I'm just leaving it here for the time being so we
// don't need to resync nodes.
ffg_update_required: bool,
justified_epoch: Epoch,
finalized_epoch: Epoch,
nodes: Vec<ProtoNode>,
@@ -30,7 +27,6 @@ impl From<&ProtoArrayForkChoice> for SszContainer {
votes: from.votes.read().0.clone(),
balances: from.balances.read().clone(),
prune_threshold: proto_array.prune_threshold,
ffg_update_required: false,
justified_epoch: proto_array.justified_epoch,
finalized_epoch: proto_array.finalized_epoch,
nodes: proto_array.nodes.clone(),