Post
Topic
Board Development & Technical Discussion
Merits 7 from 2 users
Re: The term orphan block
by
stwenhao
on 18/08/2025, 09:49:16 UTC
⭐ Merited by pooya87 (5) ,vapourminer (2)
Quote
The term orphan block
It is called "stale", instead of "orphan" in other places. Because "orphan" has no parents, and the only block meeting this definition, is the Genesis Block, where its previous block hash is set to zero.

Quote
When exactly does this orphan block occurs?
I think you should try mining something with signet-like difficulty on CPU, to see that in practice. In general, when hashes are grinded, then from time to time, you can get a close match. And then, you have two pieces of Proof of Work, which are equally valid. The first-seen block header is the one, which miners will work on, but both are valid, until someone will share a new block, which would be created on top of it.

See: https://en.bitcoin.it/wiki/Proof_of_work
Code:
"Hello, world!4250" => 0000c3af42fc31103f1fdc0151fa747ff87349a4714df7cc52ea464e12dcd4e9
Here, some miner successfully grinded "Hello, world!" data, with "nonce", equal to "4250". At the same time, a different miner could find a different text, with a different nonce, but also with 16 leading zero bits.
Code:
"Foo, bar!9764" => 00007a63c3af511785b8f127d4f4e4df3c0dc2e0688cacb5cbcbb1289c47dd6f
And then, you have two valid blocks: one contains "Hello, world!" with nonce "4250", and another one contains "Foo, bar!" with nonce "9764". Which one is valid? Both of them are, and then, the next miner produces the next valid block, and then, everyone switches to the stronger chain, with more Proof of Work.

Some Bash scripts for testing things:
Code:
nonce=0
while [ "$nonce" -lt "20000" ]
do
  echo -n "Hello, world!""$nonce" | sha256sum >> hello.txt
  ((nonce=nonce+1))
done

nonce=0
while [ "$nonce" -lt "20000" ]
do
  echo -n "Foo, bar!""$nonce" | sha256sum >> foobar.txt
  ((nonce=nonce+1))
done