Process incoming foreground messages while subscribing #2705
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Calling
relay_chain_sync.subscribe_all(...).await
might take a long time (as it waits for the runtime of the chain to have been downloaded), during which messages coming from the public API of the sync service just pile up and aren't answered.This PR fixes this by answering messages while we wait for the subscription to happen.
The consequence is that a parachain initialization now finishes quickly, while before it was waiting for its relay chain initialization to finish.
It also means that we now properly clean up parachains if we remove them, even if their relay chain never downloads its runtime. Before, the clean up didn't happen because the clean up never happens before initialization is complete.
I'm not really happy with the code duplication here, and would perform a refactoring that moves local variables into a struct, and adds methods to that struct, similar to
standalone.rs
.