Attempt to fix prune error

This commit is contained in:
Paul Hauner
2020-01-15 15:43:50 +11:00
parent 029fb24858
commit cba0d9a48c

View File

@@ -357,19 +357,23 @@ impl<T: BeaconChainTypes> ForkChoice<T> {
finalized_block: &BeaconBlock<T::EthSpec>, finalized_block: &BeaconBlock<T::EthSpec>,
finalized_block_root: Hash256, finalized_block_root: Hash256,
) -> Result<()> { ) -> Result<()> {
// Only prune if it won't remove our current justified epoch. let epoch = finalized_block.slot.epoch(T::EthSpec::slots_per_epoch());
if self.justification_manager.read().justified_checkpoint.epoch
>= finalized_block.slot.epoch(T::EthSpec::slots_per_epoch()) // TODO: be more stringent about changing the finalized checkpoint (i.e., check for
{ // reversion and stuff).
self.backend if epoch > self.finalized_checkpoint.read().epoch {
.update_finalized_root( *self.finalized_checkpoint.write() = Checkpoint {
finalized_block.slot.epoch(T::EthSpec::slots_per_epoch()), epoch,
finalized_block_root, root: finalized_block_root,
) };
.map_err(Into::into) };
} else {
Ok(()) self.backend
} .update_finalized_root(
self.finalized_checkpoint.read().epoch,
self.finalized_checkpoint.read().root,
)
.map_err(Into::into)
} }
/// Returns a `SszForkChoice` which contains the current state of `Self`. /// Returns a `SszForkChoice` which contains the current state of `Self`.