Commit 287b116
chainHead: Ensure reasonable distance between leaf and finalized block (#3562)
This PR ensure that the distance between any leaf and the finalized
block is within a reasonable distance.
For a new subscription, the chainHead has to provide all blocks between
the leaves of the chain and the finalized block.
When the distance between a leaf and the finalized block is large:
- The tree route is costly to compute
- We could deliver an unbounded number of blocks (potentially millions)
(For more details see
#3445 (comment))
The configuration of the ChainHead is extended with:
- suspend on lagging distance: When the distance between any leaf and
the finalized block is greater than this number, the subscriptions are
suspended for a given duration.
- All active subscriptions are terminated with the `Stop` event, all
blocks are unpinned and data discarded.
- For incoming subscriptions, until the suspended period expires the
subscriptions will immediately receive the `Stop` event.
- Defaults to 128 blocks
- suspended duration: The amount of time for which subscriptions are
suspended
- Defaults to 30 seconds
cc @paritytech/subxt-team
---------
Signed-off-by: Alexandru Vasile <[email protected]>
Co-authored-by: Sebastian Kunert <[email protected]>1 parent cdacfb9 commit 287b116
7 files changed
Lines changed: 313 additions & 164 deletions
File tree
- substrate/client/rpc-spec-v2/src/chain_head
- subscription
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
| |||
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
119 | 130 | | |
120 | 131 | | |
121 | 132 | | |
| |||
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| 154 | + | |
143 | 155 | | |
144 | 156 | | |
145 | 157 | | |
| |||
187 | 199 | | |
188 | 200 | | |
189 | 201 | | |
| 202 | + | |
190 | 203 | | |
191 | 204 | | |
192 | 205 | | |
| |||
207 | 220 | | |
208 | 221 | | |
209 | 222 | | |
210 | | - | |
211 | | - | |
| 223 | + | |
| 224 | + | |
212 | 225 | | |
213 | 226 | | |
214 | 227 | | |
| |||
222 | 235 | | |
223 | 236 | | |
224 | 237 | | |
| 238 | + | |
225 | 239 | | |
226 | | - | |
227 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
228 | 245 | | |
229 | 246 | | |
230 | 247 | | |
| |||
Lines changed: 62 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | | - | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
67 | 69 | | |
68 | 70 | | |
69 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
70 | 75 | | |
71 | 76 | | |
72 | 77 | | |
| |||
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
| 85 | + | |
80 | 86 | | |
81 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
82 | 96 | | |
83 | 97 | | |
84 | 98 | | |
| |||
186 | 200 | | |
187 | 201 | | |
188 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
189 | 232 | | |
190 | 233 | | |
191 | 234 | | |
| |||
198 | 241 | | |
199 | 242 | | |
200 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
201 | 251 | | |
202 | 252 | | |
203 | 253 | | |
| |||
542 | 592 | | |
543 | 593 | | |
544 | 594 | | |
545 | | - | |
| 595 | + | |
| 596 | + | |
546 | 597 | | |
547 | 598 | | |
548 | 599 | | |
| |||
576 | 627 | | |
577 | 628 | | |
578 | 629 | | |
579 | | - | |
| 630 | + | |
580 | 631 | | |
581 | 632 | | |
582 | 633 | | |
| |||
591 | 642 | | |
592 | 643 | | |
593 | 644 | | |
594 | | - | |
| 645 | + | |
| 646 | + | |
595 | 647 | | |
596 | 648 | | |
597 | 649 | | |
| |||
605 | 657 | | |
606 | 658 | | |
607 | 659 | | |
| 660 | + | |
608 | 661 | | |
609 | 662 | | |
610 | 663 | | |
611 | 664 | | |
612 | 665 | | |
613 | 666 | | |
614 | 667 | | |
615 | | - | |
| 668 | + | |
616 | 669 | | |
617 | 670 | | |
618 | 671 | | |
| |||
640 | 693 | | |
641 | 694 | | |
642 | 695 | | |
643 | | - | |
| 696 | + | |
644 | 697 | | |
645 | 698 | | |
646 | 699 | | |
| |||
650 | 703 | | |
651 | 704 | | |
652 | 705 | | |
653 | | - | |
| 706 | + | |
654 | 707 | | |
655 | 708 | | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
44 | 47 | | |
45 | 48 | | |
46 | 49 | | |
| |||
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
| 63 | + | |
60 | 64 | | |
61 | 65 | | |
62 | 66 | | |
| |||
0 commit comments