Commit 68c1250
fix(rpc-spec-v2): best block not announced immediately after initialised (#10525)
# Description
Fixes polkadot-api/polkadot-api#1244
The current chainHead_v1 implementation is [not
spec-compliant](https://paritytech.github.io/json-rpc-interface-spec/api/chainHead_v1_follow.html),
as it states:
> - Generates an `initialized` notification
> - Generates one `newBlock` notification for each non-finalized block
> - Then a `bestBlockChanged` notification
> - When a new block arrives, generates a `newBlock` notification
> - When the node finalizes a block, generates a `finalized`
notification
And the current implemention only emits the `bestBlockChanged`
notification after initialized iif the best block is different from the
finalized block.
PAPI recently is using this part of the spec as an assumption. Most
chains are unaffected, but those that produce blocks on-demand (e.g.
manual-seal) then have polkadot-api hanging until there's a higher block
different than the finalized one.
## Integration
This PR doesn't change any of the APIs of the node. Upgrade should be
automatic.
## Review Notes
This PR removes that condition so that the `bestBlockChanged`
notification is always emited. All tests are updated to this new
behaviour
# Checklist
* [x] My PR includes a detailed description as outlined in the
"Description" and its two subsections above.
* [x] My PR follows the [labeling requirements](
https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process
) of this project (at minimum one label for `T` required)
* External contributors: Use `/cmd label <label-name>` to add labels
* Maintainers can also add labels manually
* [x] I have made corresponding changes to the documentation (if
applicable)
* [x] I have added tests that prove my fix is effective or that my
feature works (if applicable)
---------
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Alexandru Vasile <[email protected]>1 parent 613e00e commit 68c1250
File tree
3 files changed
+137
-9
lines changed- prdoc
- substrate/client/rpc-spec-v2/src/chain_head
3 files changed
+137
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
Lines changed: 7 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
429 | 429 | | |
430 | 430 | | |
431 | 431 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
437 | 436 | | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
442 | 440 | | |
443 | 441 | | |
444 | 442 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
175 | 179 | | |
176 | 180 | | |
177 | 181 | | |
| |||
273 | 277 | | |
274 | 278 | | |
275 | 279 | | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
276 | 287 | | |
277 | 288 | | |
278 | 289 | | |
| |||
357 | 368 | | |
358 | 369 | | |
359 | 370 | | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
360 | 378 | | |
361 | 379 | | |
362 | 380 | | |
| |||
660 | 678 | | |
661 | 679 | | |
662 | 680 | | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
663 | 685 | | |
664 | 686 | | |
665 | 687 | | |
| |||
1389 | 1411 | | |
1390 | 1412 | | |
1391 | 1413 | | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
1392 | 1418 | | |
1393 | 1419 | | |
1394 | 1420 | | |
| |||
1402 | 1428 | | |
1403 | 1429 | | |
1404 | 1430 | | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
1405 | 1435 | | |
1406 | 1436 | | |
1407 | 1437 | | |
| |||
1626 | 1656 | | |
1627 | 1657 | | |
1628 | 1658 | | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
1629 | 1663 | | |
1630 | 1664 | | |
1631 | 1665 | | |
| |||
1706 | 1740 | | |
1707 | 1741 | | |
1708 | 1742 | | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
| 1746 | + | |
1709 | 1747 | | |
1710 | 1748 | | |
1711 | 1749 | | |
| |||
1813 | 1851 | | |
1814 | 1852 | | |
1815 | 1853 | | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
1816 | 1858 | | |
1817 | 1859 | | |
1818 | 1860 | | |
| |||
1940 | 1982 | | |
1941 | 1983 | | |
1942 | 1984 | | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
1943 | 1989 | | |
1944 | 1990 | | |
1945 | 1991 | | |
| |||
2055 | 2101 | | |
2056 | 2102 | | |
2057 | 2103 | | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
2058 | 2111 | | |
2059 | 2112 | | |
2060 | 2113 | | |
| |||
2325 | 2378 | | |
2326 | 2379 | | |
2327 | 2380 | | |
| 2381 | + | |
| 2382 | + | |
| 2383 | + | |
| 2384 | + | |
| 2385 | + | |
| 2386 | + | |
2328 | 2387 | | |
2329 | 2388 | | |
2330 | 2389 | | |
| |||
2682 | 2741 | | |
2683 | 2742 | | |
2684 | 2743 | | |
| 2744 | + | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
2685 | 2748 | | |
2686 | 2749 | | |
2687 | 2750 | | |
| |||
2915 | 2978 | | |
2916 | 2979 | | |
2917 | 2980 | | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
| 2984 | + | |
2918 | 2985 | | |
2919 | 2986 | | |
2920 | 2987 | | |
| |||
3042 | 3109 | | |
3043 | 3110 | | |
3044 | 3111 | | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
| 3115 | + | |
3045 | 3116 | | |
3046 | 3117 | | |
3047 | 3118 | | |
| |||
3178 | 3249 | | |
3179 | 3250 | | |
3180 | 3251 | | |
| 3252 | + | |
| 3253 | + | |
| 3254 | + | |
| 3255 | + | |
3181 | 3256 | | |
3182 | 3257 | | |
3183 | 3258 | | |
| |||
3474 | 3549 | | |
3475 | 3550 | | |
3476 | 3551 | | |
| 3552 | + | |
| 3553 | + | |
| 3554 | + | |
| 3555 | + | |
3477 | 3556 | | |
3478 | 3557 | | |
3479 | 3558 | | |
| |||
3742 | 3821 | | |
3743 | 3822 | | |
3744 | 3823 | | |
| 3824 | + | |
| 3825 | + | |
| 3826 | + | |
| 3827 | + | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
3745 | 3831 | | |
3746 | 3832 | | |
3747 | 3833 | | |
| |||
3911 | 3997 | | |
3912 | 3998 | | |
3913 | 3999 | | |
| 4000 | + | |
| 4001 | + | |
| 4002 | + | |
| 4003 | + | |
| 4004 | + | |
| 4005 | + | |
| 4006 | + | |
3914 | 4007 | | |
3915 | 4008 | | |
3916 | 4009 | | |
| |||
4130 | 4223 | | |
4131 | 4224 | | |
4132 | 4225 | | |
| 4226 | + | |
| 4227 | + | |
| 4228 | + | |
| 4229 | + | |
| 4230 | + | |
| 4231 | + | |
| 4232 | + | |
4133 | 4233 | | |
4134 | 4234 | | |
4135 | 4235 | | |
| |||
0 commit comments