From 6b8c96662f1799deb5e3163937111fc69c1ba109 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 15 Jun 2020 19:04:27 +1000 Subject: [PATCH] Avoid pruning when there are no forks (#1268) --- beacon_node/beacon_chain/src/migrate.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 40be5d41d..dc92744a5 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -42,6 +42,11 @@ pub trait Migrate: Send + Sync + 'static { new_finalized_block_hash: SignedBeaconBlockHash, new_finalized_slot: Slot, ) -> Result<(), BeaconChainError> { + // There will never be any blocks to prune if there is only a single head in the chain. + if head_tracker.heads().len() == 1 { + return Ok(()); + } + let old_finalized_slot = store .get_block(&old_finalized_block_hash.into())? .ok_or_else(|| BeaconChainError::MissingBeaconBlock(old_finalized_block_hash.into()))?