Commit e8b01c4
committed
mining: createNewBlock() waits if tip is updating
At startup isInitialBlockDownload() stops returning true once there’s
less than a day of blocks left to sync. Connected mining clients will
receive a flood of new templates as these last blocks are connected.
Fix this by briefly pausing block template creation while the best
header chain is ahead of the tip. If no tip update happens for one
second, we stop waiting.
It’s not safe to keep waiting, because a malicious miner could announce
a header and delay revealing the block, causing all other miners using
this software to stall.
The cooldown only applies to createNewBlock(), which is typically called
once per connected client. Subsequent templates are provided by
waitNext().
Fixes #339941 parent 2bcb3f6 commit e8b01c4
File tree
6 files changed
+98
-5
lines changed- src
- node
- test/functional
6 files changed
+98
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
964 | 964 | | |
965 | 965 | | |
966 | 966 | | |
967 | | - | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
968 | 974 | | |
969 | 975 | | |
970 | 976 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
415 | 451 | | |
416 | 452 | | |
417 | 453 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6320 | 6320 | | |
6321 | 6321 | | |
6322 | 6322 | | |
| 6323 | + | |
| 6324 | + | |
| 6325 | + | |
| 6326 | + | |
| 6327 | + | |
| 6328 | + | |
| 6329 | + | |
| 6330 | + | |
| 6331 | + | |
| 6332 | + | |
6323 | 6333 | | |
6324 | 6334 | | |
6325 | 6335 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
| 1339 | + | |
| 1340 | + | |
1339 | 1341 | | |
1340 | 1342 | | |
1341 | 1343 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
13 | 22 | | |
14 | 23 | | |
15 | 24 | | |
| 25 | + | |
16 | 26 | | |
17 | 27 | | |
18 | 28 | | |
| 29 | + | |
19 | 30 | | |
20 | 31 | | |
21 | 32 | | |
| |||
174 | 185 | | |
175 | 186 | | |
176 | 187 | | |
177 | | - | |
178 | 188 | | |
179 | 189 | | |
180 | 190 | | |
181 | 191 | | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
182 | 211 | | |
183 | 212 | | |
184 | 213 | | |
185 | 214 | | |
186 | 215 | | |
187 | 216 | | |
188 | | - | |
189 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
190 | 220 | | |
191 | 221 | | |
192 | 222 | | |
| |||
0 commit comments