From 4dd911cd3a3ed128b2e820ec7c8cefa78cd1856a Mon Sep 17 00:00:00 2001 From: Adam Szkoda Date: Tue, 11 Aug 2020 12:19:24 +0200 Subject: [PATCH] Fix the bug Pruning stopped short of pruning the entire abandoned chain. It only pruned the head. This has to do with get_state() returning unexpected states based on slots for states that that lie below the "split point". Fix by doing pruning on the hot database (as it should be from the start) and not touching the cold database. --- beacon_node/beacon_chain/src/migrate.rs | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/beacon_node/beacon_chain/src/migrate.rs b/beacon_node/beacon_chain/src/migrate.rs index 59079344c92..83eae0ae71d 100644 --- a/beacon_node/beacon_chain/src/migrate.rs +++ b/beacon_node/beacon_chain/src/migrate.rs @@ -202,11 +202,6 @@ impl, Cold: ItemStore> Migrate old_finalized_block_hash: SignedBeaconBlockHash, new_finalized_block_hash: SignedBeaconBlockHash, ) { - if let Err(e) = process_finalization(self.db.clone(), state_root, &new_finalized_state) { - // This migrator is only used for testing, so we just log to stderr without a logger. - eprintln!("Migration error: {:?}", e); - } - if let Err(e) = Self::prune_abandoned_forks( self.db.clone(), head_tracker, @@ -216,6 +211,11 @@ impl, Cold: ItemStore> Migrate ) { eprintln!("Pruning error: {:?}", e); } + + if let Err(e) = process_finalization(self.db.clone(), state_root, &new_finalized_state) { + // This migrator is only used for testing, so we just log to stderr without a logger. + eprintln!("Migration error: {:?}", e); + } } } @@ -325,6 +325,17 @@ impl, Cold: ItemStore> BackgroundMigrator {} + Err(e) => warn!(log, "Block pruning failed: {:?}", e), + } + match process_finalization(db.clone(), state_root, &state) { Ok(()) => {} Err(Error::HotColdDBError(HotColdDBError::FreezeSlotUnaligned(slot))) => { @@ -342,17 +353,6 @@ impl, Cold: ItemStore> BackgroundMigrator {} - Err(e) => warn!(log, "Block pruning failed: {:?}", e), - } } });