-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Block ActiveLeavesUpdate and BlockFinalized events in overseer until major sync is complete
#6689
Changes from 1 commit
ae29bb4
70d031d
349c89f
5bae570
fe09d12
4c4a4db
cfcd098
27b0cf5
2204966
2ba4a97
969f71a
81a64e5
6bdb390
f8467d8
a3840a7
ade3d9d
ba1167b
809a612
2e14f46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -804,40 +804,46 @@ where | |
| Event::Stop => return self.handle_stop().await, | ||
| Event::BlockImported(block) => _ = self.block_imported(block).await, | ||
| Event::BlockFinalized(block) if self.sync_oracle.finished_syncing() => { | ||
| // Send initial `ActiveLeaves` | ||
| let update = self.block_imported(block.clone()).await; | ||
| if !update.is_empty() { | ||
| self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?; | ||
| } else { | ||
| // In theory we can receive `BlockImported` during initial major sync. In this case the | ||
| // update will be empty. | ||
| let span = match self.span_per_active_leaf.get(&block.hash) { | ||
| Some(span) => span.clone(), | ||
| None => { | ||
| // This should never happen. | ||
| gum::warn!( | ||
| target: LOG_TARGET, | ||
| ?block.hash, | ||
| ?block.number, | ||
| "Span for active leaf not found. This is not expected" | ||
| ); | ||
| let span = Arc::new(jaeger::Span::new(block.hash, "leaf-activated")); | ||
| span | ||
| } | ||
| }; | ||
| let update = ActiveLeavesUpdate::start_work(ActivatedLeaf { | ||
| hash: block.hash, | ||
| number: block.number, | ||
| status: LeafStatus::Fresh, | ||
| span, | ||
| }); | ||
| self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?; | ||
|
||
| } | ||
|
|
||
|
|
||
| // Initial sync is complete | ||
| self.block_finalized(&block).await; | ||
| // Send initial `ActiveLeaves` | ||
| for (hash, number) in self.active_leaves.clone().into_iter() { | ||
| let span = match self.span_per_active_leaf.get(&hash) { | ||
| Some(span) => span.clone(), | ||
| None => { | ||
| // This should never happen. Spans are generated in `on_head_activated` | ||
| // which is called from `block_imported`. Despite not sending a signal | ||
| // `BlockImported` events are handled so a span should exist for each | ||
| // active leaf. | ||
| gum::error!( | ||
| target: LOG_TARGET, | ||
| ?hash, | ||
| ?number, | ||
| "Span for active leaf not found. This is not expected" | ||
| ); | ||
| let span = Arc::new(jaeger::Span::new(hash, "leaf-activated")); | ||
| self.span_per_active_leaf.insert(hash, span.clone()); | ||
| span | ||
| } | ||
| }; | ||
|
|
||
| let update = ActiveLeavesUpdate::start_work(ActivatedLeaf { | ||
| hash, | ||
| number, | ||
| status: LeafStatus::Fresh, | ||
| span, | ||
| }); | ||
| self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?; | ||
| } | ||
| // Send initial `BlockFinalized` | ||
| self.broadcast_signal(OverseerSignal::BlockFinalized(block.hash, block.number)).await?; | ||
| break | ||
| let update = self.block_finalized(&block).await; | ||
| if !update.is_empty() { | ||
| self.broadcast_signal(OverseerSignal::ActiveLeaves(update)).await?; | ||
| } | ||
|
|
||
| // Send initial `BlockFinalized` | ||
| self.broadcast_signal(OverseerSignal::BlockFinalized(block.hash, block.number)).await?; | ||
| break | ||
| }, | ||
| Event::BlockFinalized(block) => _ = self.block_finalized(&block).await, | ||
| Event::ExternalRequest(request) => self.handle_external_request(request) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A concern: I think with current impl Ctrl-C before major sync is complete should not stall/deadlock subsystems, but would be nice to double check that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should this stall the subsystems?