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

Add BestBlockChanged notif in sync and runtime services #2457

Merged
merged 4 commits into from
Jul 4, 2022

Conversation

tomaka
Copy link
Contributor

@tomaka tomaka commented Jul 4, 2022

This PR fixes a hole in the notifications sent by the syncing service and runtime service.

The problem is as follows:

  • Let's say that that there's a new best relay chain block R1 containing parachain block P1. We report P1 as the new best parachain block.
  • Then there's a new best relay chain block R2 containing parachain block P2. We report P2 as the new best parachain block.
  • Then there's a new best relay chain block R3 containing parachain block P1.

Normally, we should report P1 as the new best parachain block.
However, it is at the moment not possible to do so. The only way to report a change in the best chain is either when a new block arrives or when a block gets finalized.
This PR therefore introduces a new event BestBlockUpdated, which gets generated specifically in this kind of situation.

In addition to the parachain syncing code, introducing this new event required modifications to several other parts of the code: the JSON-RPC service, the transactions service, the runtime service, and the asynchronous tree.

I took the liberty to rename the non_finalized_headers variable in the JSON-RPC service to headers, as this variable also contains the current finalized block (which is an important detail) and this name is therefore misleading.

I'm aware of the fact that the async_tree is starting to be a bit chaotic, but improving it is a big effort that is out of scope of this PR.

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 Jul 4, 2022

twiggy diff report

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


 Delta Bytes │ Item
─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────
      +13005 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc30405b34d49625c
      +11820 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha6c9b2ea82f7a6ed
      -11710 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hcc3119285a65f2a2
      -11144 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h7a2403911890797c
       +8779 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h587283da085a7d0b
       -7880 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9aeb61987864f96f
       +6253 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5e2b775250716b73
       -5810 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h42450fc13c352bce
       +4643 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h2c065a6672bed1e8
       -4643 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hfc2ac5298e5656dd
       +3109 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hbc3c857cc83c38aa
       -2497 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h8c98ac360a62bd38
       +2437 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h55d3843603f20ca4
       +2275 ┊ smoldot::chain::async_tree::AsyncTree<TNow,TBl,TAsync>::try_advance_output::hc4e84a510243543d
       -2021 ┊ smoldot::chain::async_tree::AsyncTree<TNow,TBl,TAsync>::try_advance_output::h98e053c584885d79
       +1998 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h0bd668b3026bdd5a
       -1998 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5529772bc8a58636
       -1982 ┊ <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h659bcc793f2ab8d8
       +1949 ┊ smoldot::chain::async_tree::AsyncTree<TNow,TBl,TAsync>::try_advance_output::h0d369b08bcdc021f
       +1939 ┊ smoldot::chain::async_tree::AsyncTree<TNow,TBl,TAsync>::try_advance_output::he95fbf2689da5d19
        +507 ┊ ... and 619 more.
      +11161 ┊ Σ [639 Total Rows]

@tomaka tomaka added the automerge Automatically merge pull request as soon as possible label Jul 4, 2022
@mergify mergify bot merged commit 84745ac into paritytech:main Jul 4, 2022
@tomaka tomaka deleted the report-best-block-changed branch July 4, 2022 17:15
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