diff --git a/beacon_node/beacon_chain/src/fork_choice.rs b/beacon_node/beacon_chain/src/fork_choice.rs index 21986e72b4..6985a913b8 100644 --- a/beacon_node/beacon_chain/src/fork_choice.rs +++ b/beacon_node/beacon_chain/src/fork_choice.rs @@ -65,7 +65,7 @@ impl ForkChoice { Self { backend, genesis_block_root, - checkpoint_manager: RwLock::new(CheckpointManager::new(genesis_checkpoint.clone())), + checkpoint_manager: RwLock::new(CheckpointManager::new(genesis_checkpoint)), _phantom: PhantomData, } } diff --git a/beacon_node/beacon_chain/src/fork_choice/checkpoint_manager.rs b/beacon_node/beacon_chain/src/fork_choice/checkpoint_manager.rs index 32ed2ef7d3..5441f4aa78 100644 --- a/beacon_node/beacon_chain/src/fork_choice/checkpoint_manager.rs +++ b/beacon_node/beacon_chain/src/fork_choice/checkpoint_manager.rs @@ -248,10 +248,9 @@ impl CheckpointManager { finalized: state.finalized_checkpoint.clone(), }; - // From the given state, read the block root at first slot of - // `self.justified_checkpoint.epoch`. If that root matches, then - // `new_justified_checkpoint` is a descendant of `self.justified_checkpoint` and we may - // proceed (see next `if` statement). + // Using the given `state`, determine its ancestor at the slot of our current justified + // epoch. Later, this will be compared to the root of the current justified checkpoint + // to determine if this state is descendant of our current justified state. let new_checkpoint_ancestor = Self::get_block_root_at_slot( state, chain, diff --git a/eth2/proto_array_fork_choice/src/proto_array.rs b/eth2/proto_array_fork_choice/src/proto_array.rs index f3245bd523..85d47ede99 100644 --- a/eth2/proto_array_fork_choice/src/proto_array.rs +++ b/eth2/proto_array_fork_choice/src/proto_array.rs @@ -34,12 +34,12 @@ impl ProtoArray { /// the best-child of each parent. /// /// The structure of the `self.nodes` array ensures that the child of each node is always - /// touched before it's parent. + /// touched before its parent. /// /// For each node, the following is done: /// - /// - Update the nodes weight with the corresponding delta. - /// - Back-propgrate each nodes delta to its parents delta. + /// - Update the node's weight with the corresponding delta. + /// - Back-propagate each node's 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. /// - If required, update the parents best-descendant with the current node or its best-descendant. @@ -63,7 +63,7 @@ impl ProtoArray { // Iterate backwards through all indices in `self.nodes`. for node_index in (0..self.nodes.len()).rev() { - let node = &mut self + let node = self .nodes .get_mut(node_index) .ok_or_else(|| Error::InvalidNodeIndex(node_index))?; @@ -108,7 +108,7 @@ impl ProtoArray { .get_mut(parent_index) .ok_or_else(|| Error::InvalidParentDelta(parent_index))?; - // Back-propogate the nodes delta to its parent. + // Back-propagate the nodes delta to its parent. *parent_delta += node_delta; self.maybe_update_best_child_and_descendant(parent_index, node_index)?; diff --git a/eth2/proto_array_fork_choice/src/proto_array_fork_choice.rs b/eth2/proto_array_fork_choice/src/proto_array_fork_choice.rs index a22fd4fb63..0112b690c6 100644 --- a/eth2/proto_array_fork_choice/src/proto_array_fork_choice.rs +++ b/eth2/proto_array_fork_choice/src/proto_array_fork_choice.rs @@ -261,7 +261,7 @@ fn compute_deltas( // of our tree (i.e., pre-finalization) and therefore not interesting. if let Some(current_delta_index) = indices.get(&vote.current_root).copied() { let delta = deltas - .get_mut(current_delta_index) + .get(current_delta_index) .ok_or_else(|| Error::InvalidNodeDelta(current_delta_index))? .checked_sub(old_balance as i64) .ok_or_else(|| Error::DeltaOverflow(current_delta_index))?;