Removes topic from logs.

This commit is contained in:
Age Manning 2019-02-20 12:39:00 +11:00
parent 2fbdc53147
commit 0f7167992b
No known key found for this signature in database
GPG Key ID: 05EED64B79E06A93
2 changed files with 24 additions and 34 deletions

View File

@ -115,7 +115,7 @@ where
} }
} }
} }
trace!("FORKCHOICE: Latest votes: {:?}", latest_votes); trace!("Latest votes: {:?}", latest_votes);
Ok(latest_votes) Ok(latest_votes)
} }
@ -180,7 +180,7 @@ where
let mut current_votes: HashMap<Hash256, u64> = HashMap::new(); let mut current_votes: HashMap<Hash256, u64> = HashMap::new();
let mut total_vote_count = 0; let mut total_vote_count = 0;
trace!("FORKCHOICE: Clear winner at block height: {}", block_height); trace!("Clear winner at block height: {}", block_height);
// loop through the latest votes and count all votes // loop through the latest votes and count all votes
// these have already been weighted by balance // these have already been weighted by balance
for (hash, votes) in latest_votes.iter() { for (hash, votes) in latest_votes.iter() {
@ -213,22 +213,22 @@ where
let mut one_votes = 0; let mut one_votes = 0;
let mut single_candidate = (None, false); let mut single_candidate = (None, false);
trace!("FORKCHOICE: Child vote length: {}", votes.len()); trace!("Child vote length: {}", votes.len());
for (candidate, votes) in votes.iter() { for (candidate, votes) in votes.iter() {
let candidate_bit: BitVec = BitVec::from_bytes(&candidate); let candidate_bit: BitVec = BitVec::from_bytes(&candidate);
/* /*
trace!( trace!(
"FORKCHOICE: Child: {} in bits: {:?}", "Child: {} in bits: {:?}",
candidate, candidate,
candidate_bit candidate_bit
); );
trace!("FORKCHOICE: Current bitmask: {:?}", bitmask); trace!("Current bitmask: {:?}", bitmask);
*/ */
// if the bitmasks don't match // if the bitmasks don't match
if !bitmask.iter().eq(candidate_bit.iter().take(bit)) { if !bitmask.iter().eq(candidate_bit.iter().take(bit)) {
trace!( trace!(
"FORKCHOICE: Child: {} was removed in bit: {} with the bitmask: {:?}", "Child: {} was removed in bit: {} with the bitmask: {:?}",
candidate, candidate,
bit, bit,
bitmask bitmask
@ -306,7 +306,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
// simply add the attestation to the latest_attestation_target if the block_height is // simply add the attestation to the latest_attestation_target if the block_height is
// larger // larger
trace!( trace!(
"FORKCHOICE: Adding attestation of validator: {:?} for block: {}", "Adding attestation of validator: {:?} for block: {}",
validator_index, validator_index,
target_block_root target_block_root
); );
@ -316,10 +316,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
.or_insert_with(|| *target_block_root); .or_insert_with(|| *target_block_root);
// if we already have a value // if we already have a value
if attestation_target != target_block_root { if attestation_target != target_block_root {
trace!( trace!("Old attestation found: {:?}", attestation_target);
"FORKCHOICE: Old attestation found: {:?}",
attestation_target
);
// get the height of the target block // get the height of the target block
let block_height = self let block_height = self
.block_store .block_store
@ -337,7 +334,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
.height(spec.genesis_slot); .height(spec.genesis_slot);
// update the attestation only if the new target is higher // update the attestation only if the new target is higher
if past_block_height < block_height { if past_block_height < block_height {
trace!("FORKCHOICE: Updating old attestation"); trace!("Updating old attestation");
*attestation_target = *target_block_root; *attestation_target = *target_block_root;
} }
} }
@ -374,7 +371,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
// begin searching for the head // begin searching for the head
loop { loop {
debug!( debug!(
"FORKCHOICE: Iteration for block: {} with vote length: {}", "Iteration for block: {} with vote length: {}",
current_head, current_head,
latest_votes.len() latest_votes.len()
); );
@ -401,19 +398,19 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
step /= 2; step /= 2;
} }
if step > 0 { if step > 0 {
trace!("FORKCHOICE: Found clear winner in log lookup"); trace!("Found clear winner in log lookup");
} }
// if our skip lookup failed and we only have one child, progress to that child // if our skip lookup failed and we only have one child, progress to that child
else if children.len() == 1 { else if children.len() == 1 {
current_head = children[0]; current_head = children[0];
trace!( trace!(
"FORKCHOICE: Lookup failed, only one child, proceeding to child: {}", "Lookup failed, only one child, proceeding to child: {}",
current_head current_head
); );
} }
// we need to find the best child path to progress down. // we need to find the best child path to progress down.
else { else {
trace!("FORKCHOICE: Searching for best child"); trace!("Searching for best child");
let mut child_votes = HashMap::new(); let mut child_votes = HashMap::new();
for (voted_hash, vote) in latest_votes.iter() { for (voted_hash, vote) in latest_votes.iter() {
// if the latest votes correspond to a child // if the latest votes correspond to a child
@ -426,7 +423,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
current_head = self current_head = self
.choose_best_child(&child_votes) .choose_best_child(&child_votes)
.ok_or(ForkChoiceError::CannotFindBestChild)?; .ok_or(ForkChoiceError::CannotFindBestChild)?;
trace!("FORKCHOICE: Best child found: {}", current_head); trace!("Best child found: {}", current_head);
} }
// didn't find head yet, proceed to next iteration // didn't find head yet, proceed to next iteration
@ -441,7 +438,7 @@ impl<T: ClientDB + Sized> ForkChoice for BitwiseLMDGhost<T> {
// more specifically, only keep votes that have head as an ancestor // more specifically, only keep votes that have head as an ancestor
for hash in latest_votes.keys() { for hash in latest_votes.keys() {
trace!( trace!(
"FORKCHOICE: Ancestor for vote: {} at height: {} is: {:?}", "Ancestor for vote: {} at height: {} is: {:?}",
hash, hash,
block_height, block_height,
self.get_ancestor(*hash, block_height, spec) self.get_ancestor(*hash, block_height, spec)

View File

@ -78,7 +78,7 @@ where
} }
} }
} }
trace!("FORKCHOICE: Latest votes: {:?}", latest_votes); trace!("Latest votes: {:?}", latest_votes);
Ok(latest_votes) Ok(latest_votes)
} }
@ -139,7 +139,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
// simply add the attestation to the latest_attestation_target if the block_height is // simply add the attestation to the latest_attestation_target if the block_height is
// larger // larger
trace!( trace!(
"FORKCHOICE: Adding attestation of validator: {:?} for block: {}", "Adding attestation of validator: {:?} for block: {}",
validator_index, validator_index,
target_block_root target_block_root
); );
@ -149,10 +149,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
.or_insert_with(|| *target_block_root); .or_insert_with(|| *target_block_root);
// if we already have a value // if we already have a value
if attestation_target != target_block_root { if attestation_target != target_block_root {
trace!( trace!("Old attestation found: {:?}", attestation_target);
"FORKCHOICE: Old attestation found: {:?}",
attestation_target
);
// get the height of the target block // get the height of the target block
let block_height = self let block_height = self
.block_store .block_store
@ -170,7 +167,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
.height(spec.genesis_slot); .height(spec.genesis_slot);
// update the attestation only if the new target is higher // update the attestation only if the new target is higher
if past_block_height < block_height { if past_block_height < block_height {
trace!("FORKCHOICE: Updating old attestation"); trace!("Updating old attestation");
*attestation_target = *target_block_root; *attestation_target = *target_block_root;
} }
} }
@ -183,7 +180,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
justified_block_start: &Hash256, justified_block_start: &Hash256,
spec: &ChainSpec, spec: &ChainSpec,
) -> Result<Hash256, ForkChoiceError> { ) -> Result<Hash256, ForkChoiceError> {
debug!("FORKCHOICE: Running LMD Ghost Fork-choice rule"); debug!("Running LMD Ghost Fork-choice rule");
let start = self let start = self
.block_store .block_store
.get_deserialized(&justified_block_start)? .get_deserialized(&justified_block_start)?
@ -196,7 +193,7 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
let mut head_hash = *justified_block_start; let mut head_hash = *justified_block_start;
loop { loop {
debug!("FORKCHOICE: Iteration for block: {}", head_hash); debug!("Iteration for block: {}", head_hash);
let children = match self.children.get(&head_hash) { let children = match self.children.get(&head_hash) {
Some(children) => children, Some(children) => children,
@ -206,20 +203,16 @@ impl<T: ClientDB + Sized> ForkChoice for SlowLMDGhost<T> {
// if we only have one child, use it // if we only have one child, use it
if children.len() == 1 { if children.len() == 1 {
trace!("FORKCHOICE: Single child found."); trace!("Single child found.");
head_hash = children[0]; head_hash = children[0];
continue; continue;
} }
trace!("FORKCHOICE: Children found: {:?}", children); trace!("Children found: {:?}", children);
let mut head_vote_count = 0; let mut head_vote_count = 0;
for child_hash in children { for child_hash in children {
let vote_count = self.get_vote_count(&latest_votes, &child_hash)?; let vote_count = self.get_vote_count(&latest_votes, &child_hash)?;
trace!( trace!("Vote count for child: {} is: {}", child_hash, vote_count);
"FORKCHOICE: Vote count for child: {} is: {}",
child_hash,
vote_count
);
if vote_count > head_vote_count { if vote_count > head_vote_count {
head_hash = *child_hash; head_hash = *child_hash;