[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: Alexandru Vasile <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]>
parent
89047cdb
Please register or sign in to comment