-
Notifications
You must be signed in to change notification settings - Fork 696
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
chainHead/fix: Report bestBlock events only for newBlock reports #5527
Conversation
Signed-off-by: Alexandru Vasile <[email protected]>
blocks Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
First of all, thank you for your quick response and for addressing this so promptly! I’d like to clarify a few points regarding the generation of multiple
I’m not entirely sure I fully understood your intent here, but I have some concerns. It's important to note that the actual name of the event is While the spec doesn't explicitly prohibit emitting the same event multiple times for an unchanged best block, I believe it's not in the spirit of the spec to do so. The event’s name, That said, I believe this behavior wouldn’t break anything in PAPI, but it could break things for other libraries, as the spec implies that the event is meant to signal an actual change in the best block:
Also, the spec states:
Given these points, it seems reasonable to expect that cc @tomaka |
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
I don't think we should focus too much on the name. All APIs always have small prints that aren't conveyed by the name of the thing itself. Whether it is allowed to emit multiple identical events in a row should be explicitly written in the spec. |
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Have modified the code logic to take care of the following edge-cases:
We now should not emit extra |
substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs
Outdated
Show resolved
Hide resolved
Co-authored-by: Sebastian Kunert <[email protected]>
Co-authored-by: Sebastian Kunert <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
Signed-off-by: Alexandru Vasile <[email protected]>
bot fmt |
@niklasad1 https://gitlab.parity.io/parity/mirrors/polkadot-sdk/-/jobs/7233685 was started for your command Comment |
@niklasad1 Command |
// | ||
// However, we double check if the best block is a descendant of the last finalized | ||
// block to ensure we don't miss any events. | ||
let ancestor = sp_blockchain::lowest_common_ancestor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get why we need this. If the best block was not pruned, it needs to be a descendant of the finalized block.
The #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: #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]> Co-authored-by: command-bot <>
The #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: #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]> Co-authored-by: command-bot <>
…eports (#5527) (#5582) This backports original PR: #5527 to the release branch ``` The #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: #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]>
The #5512 has surfaced that we reported a
BestBlock
event for a block not previously reported viaNewBlock
.This is because of a race between:
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:
Closes: #5512
Thanks @jsdw and @josepot for helping debug this 🙏
cc @paritytech/subxt-team