From 8afe8b3569085d05eba78a0cb11399485320405b Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 24 Jun 2019 15:31:36 +1000 Subject: [PATCH] Implement fixes from PR review --- beacon_node/beacon_chain/src/fork_choice.rs | 2 +- beacon_node/beacon_chain/tests/tests.rs | 2 +- eth2/types/src/beacon_state.rs | 9 +++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/beacon_node/beacon_chain/src/fork_choice.rs b/beacon_node/beacon_chain/src/fork_choice.rs index 389e5b46b..c693145ea 100644 --- a/beacon_node/beacon_chain/src/fork_choice.rs +++ b/beacon_node/beacon_chain/src/fork_choice.rs @@ -87,7 +87,7 @@ impl ForkChoice { start_state .validator_registry .get(validator_index) - .and_then(|v| Some(v.effective_balance)) + .map(|v| v.effective_balance) }; self.backend diff --git a/beacon_node/beacon_chain/tests/tests.rs b/beacon_node/beacon_chain/tests/tests.rs index 42b6cb6a2..17e373ad6 100644 --- a/beacon_node/beacon_chain/tests/tests.rs +++ b/beacon_node/beacon_chain/tests/tests.rs @@ -33,7 +33,7 @@ fn fork() { let honest_fork_blocks = delay + 1; let faulty_fork_blocks = delay + 2; - // Build an initial chain were all validators agree. + // Build an initial chain where all validators agree. harness.extend_chain( initial_blocks, BlockStrategy::OnCanonicalHead, diff --git a/eth2/types/src/beacon_state.rs b/eth2/types/src/beacon_state.rs index f82340017..1be6eac23 100644 --- a/eth2/types/src/beacon_state.rs +++ b/eth2/types/src/beacon_state.rs @@ -586,13 +586,10 @@ impl BeaconState { /// Gets the oldest (earliest slot) state root. /// - /// Spec v0.5.1 + /// Spec v0.6.3 pub fn get_oldest_state_root(&self) -> Result<&Hash256, Error> { - let lookback = std::cmp::min( - self.slot - Slot::from(self.latest_state_roots.len()), - self.slot, - ); - let i = self.get_latest_state_roots_index(self.slot - lookback)?; + let i = self + .get_latest_state_roots_index(self.slot - Slot::from(self.latest_state_roots.len()))?; Ok(&self.latest_state_roots[i]) }