Skip to content
Unverified Commit 325df541 authored by Alexandru Vasile's avatar Alexandru Vasile Committed by GitHub
Browse files

chainHead/fix: Report bestBlock events only for newBlock reports (#5527)

The https://github.com/paritytech/polkadot-sdk/issues/5512 has surfaced
that we reported a `BestBlock` event for a block not previously reported
via `NewBlock`.

This is because of a race between:
- the stream of events that announces new blocks
- `self.client.info().best_block`

It is possible that `client.info()` contains newer information than the
information polled from the block stream (that may be lagging).

To mitigate this, instead of relying on the client's info use the last
finalized block to emit a new event.

There are two cases when a new best block event is emitted:
- The best block is in the pruned list and is reported immediately
- The best block is not a descendant of the last finalized block 

Closes: https://github.com/paritytech/polkadot-sdk/issues/5512 

Thanks @jsdw and @josepot for helping debug this 🙏

 

cc @paritytech/subxt-team

---------

Signed-off-by: default avatarAlexandru Vasile <[email protected]>
Co-authored-by: default avatarSebastian Kunert <[email protected]>
Co-authored-by: command-bot <>
parent d7b57533
Pipeline #495093 waiting for manual action with stages
in 7 minutes and 44 seconds
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment