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 <seananderson33@gmail.com>
This commit is contained in:
realbigsean 2021-12-03 16:58:10 +00:00
parent a80ccc3a33
commit b5f2764bae

View File

@ -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(())