-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
Websocket: newBlockHeaders does not return canonical blocks #18032
Comments
This is an important issue, I believe many companies rely on this. It's also a major differentiator if it works in Geth, also Parity is unreliable. |
What you're probably experiencing is a reorg. Your chain gets a new head block 6646702, but at the same time a miner also mines a side fork at the same height. The network however decides to continue on the later mined version of 6646702, and produces 6646703. The parent will be rightfully different because a mini reorg happened. The subscription only reports on new heads. If the parent is not the old head, it's up to you to handle the reorg. Does this explain the oddity you are experiencing? |
I agree that we are experiencing a reorg. But for some blocks we never see the canonical block in the stream. Most of the time, the subscription returns canonical and non-canonical (forked) blocks, for example block
But for some cases subscription never returns the canonical block. This is the main problem.
If this is the case then |
FYI The parity team is on it, flagged as ASAP and will be fixed shortly. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Afaict, this is by design. See https://github.com/ethereum/go-ethereum/blob/master/core/blockchain.go#L1519 , we only fire one event for new heads. So if we import 100 blocks in a batch, it will only fire one event. However, we will fire side-chain events for all the old blocks that were removed: https://github.com/ethereum/go-ethereum/blob/master/core/blockchain.go#L2056 . Note, though, that that info is sent on another channel: |
The subscription
It does not say that every block/header will be delivered, but that it can be used to react to changes (new heads) |
We'll need to update Real-time Events | Go Ethereum |
Hi there,
System information
Geth version: 1.8.17-stable-8bbe7207
OS & Version: Ubuntu 18.04
Expected behaviour
The websocket when subscribed using
newBlockHeaders
should return the forked blocks and also subsequently the canonical blocks.Actual behaviour
The websocket when subscribed using
newBlockHeaders
does not return the canonical blocks (for almost every ~200 blocks)Steps to reproduce the behaviour
I have a local geth node, am using web3.js for subscribing to
newBlockHeaders
, below is the code to get new blocks.most of the time the code works as expected, but sometimes (~ 1 block in 200 blocks) the subscription returns non-canonical blocks. Below is an example where the blockhash of
6646702
is different than parenthash of6646703
.This is similar to an earlier reported issue #18026
Is it possible to get canonical blocks from
newBlockHeaders
method without relying on using delayed methods likeeth_getBlockByNumber
?The text was updated successfully, but these errors were encountered: