Skip to content

Commit 10bbb2e

Browse files
committed
Log about multiple roots in dag tree
1 parent 8c9a1b2 commit 10bbb2e

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

beacon_node/beacon_chain/src/migrate.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,17 @@ impl<E: EthSpec, Hot: ItemStore<E>, Cold: ItemStore<E>> BackgroundMigrator<E, Ho
546546
)
547547
};
548548

549+
// To debug faulty trees log unexpected that have more than one root. These trees may not
550+
// result in an error, as may not be queried in the codepaths below.
551+
let state_summaries_dag_roots = state_summaries_dag.tree_roots();
552+
if state_summaries_dag_roots.len() > 1 {
553+
warn!(
554+
log,
555+
"Prune state summaries dag found more than one root";
556+
"state_summaries_dag_roots" => ?state_summaries_dag_roots
557+
);
558+
}
559+
549560
// From the DAG compute the list of roots that descend from finalized root up to the
550561
// split slot.
551562

beacon_node/beacon_chain/src/summaries_dag.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,22 @@ impl StateSummariesDAG {
139139
Ok(Self::new(state_summaries))
140140
}
141141

142+
/// Returns a vec of state summaries that have an unknown parent when forming the DAG tree
143+
pub fn tree_roots(&self) -> Vec<(Hash256, DAGStateSummary)> {
144+
self.state_summaries_by_block_root
145+
.values()
146+
.flat_map(|summaries| {
147+
summaries.values().filter_map(|(state_root, summary)| {
148+
if summary.previous_state_root == Hash256::ZERO {
149+
Some((*state_root, *summary))
150+
} else {
151+
None
152+
}
153+
})
154+
})
155+
.collect()
156+
}
157+
142158
pub fn summaries_count(&self) -> usize {
143159
self.state_summaries_by_block_root
144160
.values()

0 commit comments

Comments
 (0)