diff options
| author | Bitflash <btf01@proton.me> | 2026-07-31 14:26:47 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-31 14:26:47 -0300 |
| commit | 3268ea95c1443238d380dea26e7b1bb3bd108aed (patch) | |
| tree | cbc3d0046e94be9c5a3c33b8442a0367438ed983 /src/db.cpp | |
| parent | f904c4bd4057ab7333c7d701fb40f3e87fedf7fd (diff) | |
mine: do not submit a solution for a parent that is no longer the tip (#69)
The mining loop tests pindexPrev != pindexBest every 256 hashes, but never
again once a solution turns up. A thread that found one just after somebody
else extended the chain submitted a block built on a stale parent -- a
block born orphaned, at a height already taken.
Every miner thread on a machine works from the same pindexPrev, so the
moment one wins, all the others are hashing a doomed template until their
next checkpoint. On a 32-core box that is thirty threads with a standing
chance of producing a guaranteed orphan.
Re-check the tip inside cs_main before submitting, and drop the solution if
it moved.
Verified on an isolated chain with three miner threads: 2790 blocks
accepted, so nothing legitimate is being discarded, and 2 solutions dropped
for a moved tip -- which is the race actually happening and being caught.
Honest about the size of it: two in 2790 is not what fills a wallet with
orphans. On the 32-core node in production, 1287 of 4117 processed blocks
arrive with a missing parent, which is a different problem and the one
worth chasing next.
Diffstat (limited to 'src/db.cpp')
0 files changed, 0 insertions, 0 deletions