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

[backport] chainHead/fix: Report bestBlock events only for newBlock reports (#5527) (#5582)

This backports original PR:
https://github.com/paritytech/polkadot-sdk/pull/5527 to the release
branch


```

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]>
parent 89047cdb
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