Skip to content

Commit e56299c

Browse files
committed
Annotate SummariesDagError error
1 parent 979e43a commit e56299c

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub enum PruningError {
114114
UnexpectedUnequalStateRoots,
115115
MissingSummaryForFinalizedCheckpoint(Hash256),
116116
MissingBlindedBlock(Hash256),
117-
SummariesDagError(SummariesDagError),
117+
SummariesDagError(&'static str, SummariesDagError),
118118
EmptyFinalizedStates,
119119
EmptyFinalizedBlocks,
120120
}
@@ -494,6 +494,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
494494
.into_iter()
495495
.map(|(state_root, summary)| {
496496
let block_root = summary.latest_block_root;
497+
// This error should never happen unless we break a DB invariant
497498
let block = store
498499
.get_blinded_block(&block_root)?
499500
.ok_or(PruningError::MissingBlindedBlock(block_root))?;
@@ -541,7 +542,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
541542

542543
(
543544
StateSummariesDAG::new_from_v22(state_summaries)
544-
.map_err(PruningError::SummariesDagError)?,
545+
.map_err(|e| PruningError::SummariesDagError("creating StateSumariesDAG", e))?,
545546
BlockSummariesDAG::new(&blocks),
546547
)
547548
};
@@ -565,7 +566,9 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
565566
std::iter::once(new_finalized_state_hash).chain(
566567
state_summaries_dag
567568
.descendants_of(&new_finalized_state_hash)
568-
.map_err(PruningError::SummariesDagError)?,
569+
.map_err(|e| {
570+
PruningError::SummariesDagError("state summaries descendants_of", e)
571+
})?,
569572
),
570573
);
571574

@@ -582,6 +585,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
582585
// state_summaries_dag
583586
let summary = state_summaries_dag.get(state_root).ok_or(
584587
PruningError::SummariesDagError(
588+
"state summaries get summary",
585589
SummariesDagError::MissingStateSummary(*state_root),
586590
),
587591
)?;
@@ -593,7 +597,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
593597
// Note: ancestors_of includes the finalized state root
594598
let newly_finalized_state_summaries = state_summaries_dag
595599
.ancestors_of(new_finalized_state_hash)
596-
.map_err(PruningError::SummariesDagError)?;
600+
.map_err(|e| PruningError::SummariesDagError("state summaries ancestors_of", e))?;
597601
let newly_finalized_state_roots = newly_finalized_state_summaries
598602
.iter()
599603
.map(|(root, _)| *root)
@@ -607,7 +611,7 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
607611
// Note: ancestors_of includes the finalized block
608612
let newly_finalized_blocks = block_summaries_dag
609613
.ancestors_of(new_finalized_checkpoint.root)
610-
.map_err(PruningError::SummariesDagError)?;
614+
.map_err(|e| PruningError::SummariesDagError("block summaries ancestors_of", e))?;
611615
let newly_finalized_block_roots = newly_finalized_blocks
612616
.iter()
613617
.map(|(root, _)| *root)

0 commit comments

Comments
 (0)