From b5f2764bae2c00c44e430f9dcba305a1282d0e43 Mon Sep 17 00:00:00 2001 From: realbigsean Date: Fri, 3 Dec 2021 16:58:10 +0000 Subject: [PATCH] fix cache miss justified balances calculation (#2852) ## Issue Addressed We were calculating justified balances incorrectly on cache misses in `set_justified_checkpoint` ## Proposed Changes Use the `get_effective_balances` method as opposed to `state.balances`, which returns exact balances Co-authored-by: realbigsean --- beacon_node/beacon_chain/src/beacon_fork_choice_store.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs index 34903aed5d..7d9e42fb81 100644 --- a/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs +++ b/beacon_node/beacon_chain/src/beacon_fork_choice_store.rs @@ -321,14 +321,13 @@ where .deconstruct() .0; - self.justified_balances = self + let state = self .store .get_state(&justified_block.state_root(), Some(justified_block.slot())) .map_err(Error::FailedToReadState)? - .ok_or_else(|| Error::MissingState(justified_block.state_root()))? - .balances() - .clone() - .into(); + .ok_or_else(|| Error::MissingState(justified_block.state_root()))?; + + self.justified_balances = get_effective_balances(&state); } Ok(())