-
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
JSON-RPC: chainHead_v1_follow
Subscription Sends newBlock
events with unannounced parentBlockHash
#5761
Comments
I was able to reproduce the same issue against |
I recently reviewed new logs that provide additional insight into this issue. Specifically, in the logs, when block It seems that at this point, the server detects that its state is corrupted and triggers a This is not an isolated case; I observed a similar pattern yesterday. After the server sent blocks with missing One notable point is that after the EDIT: in those logs you will see other instances of the "stop" event. However, please know that the instances that have an extra property like |
Thanks @josepot for the detailed report here! And apologies again for the inconvenience 🙏 Looking briefly at the code, the importing of polkadot-sdk/substrate/client/rpc-spec-v2/src/chain_head/chain_head_follow.rs Lines 412 to 414 in 4ee1d7f
In those cases, we'd need to extend the state corruption detection to take this into account:
In this example, block B8 is reported as |
This issue has been mentioned on Polkadot Forum. There might be relevant details there: https://forum.polkadot.network/t/polkadot-api-updates-thread/7685/15 |
There are cases during warp sync or re-orgs, where we receive a notification with a block parent that was not reported in the past. This PR extends the tracking state to catch those cases and report a `Stop` event to the user. This PR adds a new state to the RPC-v2 chainHead to track which blocks have been reported. In the past we relied on the pinning mechanism to provide us details if a block is pinned or not. However, the pinning state keeps the minimal information around for pinning. Therefore, unpinning a block will cause the state to disappear. Closes: #5761 --------- Signed-off-by: Alexandru Vasile <[email protected]> Co-authored-by: Sebastian Kunert <[email protected]>
The
chainHead_v1_follow
subscription is not compliant with the specification because it sometimes sendsnewBlock
events where theparentBlockHash
has not been previously announced. According to the specification:Issue Details
While testing against the endpoint
wss://sys.dotters.network/paseo
, we observed that some blocks are missing from thenewBlock
events sequence. Specifically:#3012893
with hash0x2b8cbe6887a3e2869d462920d784b604a4683751aea1f2e10f02f97c9333abae
is announced.#3012896
with hash0x0e95ce16ed5cbf2008bf00c5e1a65736a8cd00c6dcf08da17126d216f79605d9
.The two missing blocks are:
#3012894
with hash0x5c7ed91698a589a1b2ec120b6bea82db88ef0ecc4abc7c25d491d9a10b165841
#3012895
with hash0x84654e06c8a6d4f0793b377c84cd80d5e802e227636a6b7bc52f1088863447f7
As a result, the
parentBlockHash
of block#3012896
refers to an unannounced block, which violates the specification's guarantee.This issue causes the PAPI client to crash.
Logs
I've attached the logs capturing this behavior: pre.log
Steps to Reproduce
Install Bun:
curl -fsSL https://bun.sh/install | bash
Set up the project:
mkdir paseo-test cd paseo-test bun init -y bun install polkadot-api bun papi add -w wss://sys.dotters.network/paseo pas
Create a file named
paseo.ts
with the following content:Run the script:
Impact
This issue disrupts the integrity of the block sequence received via the subscription, making it challenging to process data accurately. It hinders our ability to maintain a consistent view of the blockchain state, as we rely on the guarantee provided by the specification regarding
parentBlockHash
.Expected Behavior
Each
newBlock
event'sparentBlockHash
should either be:newBlock
event.Actual Behavior
The
newBlock
event for block#3012896
references aparentBlockHash
that was neither finalized nor previously announced via anewBlock
event.Request
Please investigate why the
chainHead_v1_follow
subscription is emittingnewBlock
events withparentBlockHash
values that have not been previously announced.cc: @jsdw @lexnv
The text was updated successfully, but these errors were encountered: