Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix when_known not notified #2201

Merged
merged 4 commits into from
Apr 4, 2022
Merged

Fix when_known not notified #2201

merged 4 commits into from
Apr 4, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Apr 4, 2022

Fixed a bug introduced in #2180

Before #2180, we were detecting when the runtime is ready by subscribing to notifications about the chain, and then reading the state again when something happens on this subscription.
This is hacky, so I replaced it with a when_known: EventListener that gets notified when the runtime is ready.

Unfortunately, I forgot to notify this EventListener in case the sync service notification resets.

The problematic situation is:

  • You call RuntimeService::subscribe_all at the very beginning. The runtime service is in the FinalizedBlockRuntimeUnknown state, and we listen for events on the when_ready.
  • The sync service finishes its warp sync, and resets all its notifications subscribers.
  • This causes the RuntimeService to reset and to re-subscribe to the sync service.
  • Because the sync service has a runtime already ready, we immediately transition to FinalizedBlockRuntimeKnown, but without notifying the when_ready. This is what this PR fixes.

Because some JSON-RPC functions indirectly rely on RuntimeService::subscribe_all, this bug causes these JSON-RPC functions to never produce any answer if they are called at the very beginning.

Copy link
Contributor

@mergify mergify bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2022

twiggy diff report

Difference in .wasm size before and after this pull request.


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
         +30 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hacaa93e948fa8839
         +30 ┊ Σ [1 Total Rows]

Copy link
Contributor

@melekes melekes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Apr 4, 2022
@mergify mergify bot merged commit 1baa69b into paritytech:main Apr 4, 2022
@tomaka tomaka deleted the fix-wake-up branch April 4, 2022 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Automatically merge pull request as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants