RU
Learn

Orphan blocks, stale blocks and the GHOST protocol

03 Mar 2022
Written by: Minima

A blockchain consists of a chain of blocks, as the name suggests. Transactions are bundled into blocks and verified by nodes. In Proof-of-Work networks the process of validating blocks is also known as “mining”. Validating nodes (miners) race to solve a mathematical puzzle, and whoever solves it first, validates the block and receives the block reward. They then broadcast the block to the rest of the network.

But sometimes, blocks are lost even though they are following the consensus rules, and are valid. In these instances, they don’t get attached to the chain.

On Orphan blocks and Bitcoin

When Bitcoin was launched, orphan blocks were blocks that were mined at the same time as another block but didn’t contain the previous blocks’ header. The previous block is the parent (if you think of blockchains like a family tree), and therefore blocks that didn’t know their parents’ header were named “Orphans”.

These orphans were stored in a pool until miners found a parent block for them. Once parent and orphan were linked, the block could be added to the blockchain, and miners would continue mining.

With the release of Bitcoin Core v.0.10 this type of orphan block was prevented because now headers had to be synchronized first. That means miners had to download the header of a block before starting to mine, which enabled them to immediately recognize blocks with an unknown parent.

Yet, even though this type of orphan block is now made impossible, there are still occasions when blocks aren’t added to the chain. Some people use the term Orphan block to refer to those as well, even though technically they are not the same.

Stale Blocks

Source

Unlike Orphan blocks, stale blocks contain the parent in their header and are completely valid blocks. However, it can happen that two miners nearly simultaneously mine the same block. Let’s call them Alice and Bob.

When Alice and Bob finished mining the block, they will then broadcast the block to the network. 60% of the nodes in the network receive Alice’s block whereas the other 40% receive Bob’s block.

Both blocks are valid, but remember, if miners continued validating on both these different blocks eventually we would end up with two blockchains.

What happens instead is that one of the chains will become longer (the one following Alice’s block), because more miners are finding blocks on it, and adding to it. The miners that added blocks to Bob’s block change to the other chain, because they realize that the one following Bob’s block isn’t valid because a majority of the network (60% of nodes) haven’t registered it.

For the rest of the network, the longest chain is seen as the true version.

Unfortunately for Bob, that means that he doesn’t receive any rewards, despite spending computing power on mining the block. The reason why stale blocks happen is network latency. There is a time lag between miners mining a block, and all nodes in the network receiving it.

With the emergence of mining pools and more efficient mining infrastructure, stale blocks have become less common on Bitcoin, because mining pools have established fast, low-latency connection channels between each other. But Bitcoin’s block times are relatively “long” at 10 minutes.

The GHOST protocol

Researchers investigating how likely double-spend attacks are, as transactions per second increase, have concluded that networks become more susceptible to them. That’s bad news for networks looking to scale because it could lead to a situation where blocks are created faster than broadcasted to the majority of the network.

Other Blockchains like Ethereum with faster block times have seen stale blocks increase. Minima, as a Proof-of-Work chain where everyone validates and adds their own transactions, is facing a similar challenge. The GHOST protocol offers a solution to enable scalable PoW networks.

GHOST was proposed by Yonatan Sompolinsky and Aviv Zohar in 2013. It’s short for “Greedy Heaviest Observer Sub-Tree” and was envisioned to help scalability. In short, GHOST is a policy for selecting the mainchain. Instead of following the “longest chain” rule, which doesn’t work for high throughput blockchains because they create many forks; GHOST takes into account the weight of blocks not included in the mainchain (the stale blocks).

According to the longest chain rule, the blocks 0–1B — 2D — 3F — 4C — 5B would be the new main chain. An attacker could create a chain as seen below from 1A — 6A which looks longer at first, however, with GHOST the actual mainchain that will be followed is the one most work has been put into 0–1B -2B & 2C — 3E & D & C& B — 4B.

With GHOST an attacker cannot outpace the network by simply creating new blocks faster. All blocks are considered when deciding which chain to follow.

GHOST in practice

On Ethereum, GHOST is addressing three critical issues according to the Whitepaper written by Vitalik Buterin:

  • Security Breaches
  • Wastage
  • Centralization.

As we’ve seen above, GHOST makes it harder for attackers to breach the network. Additionally, by considering blocks that aren’t on the mainchain, it reduces wastage. The third topic is worth considering because, why would a high throughput lead to centralization?

When throughput (transactions) increase, large mining pools will have a head start to resolve forks in their favor, which would give them more control. Ethereum, therefore, decided to reward miners to produce stale blocks (the first stale block produced on Ethereum is called Uncle block). Rewards are lower than for normal block validation and calculated using the following formula:

( [ uncleHeightNumber + 8 — BlockHeightNumber] * reward / 8 )

Ethereum allows for 7 levels of Uncle blocks, each with decreasing rewards. In practice, uncle chains are swiftly abandoned by miners.

Image Source

Once Ethereum moves to Proof-of-Stake, the GHOST protocol will be replaced by Caspar, a variation of GHOST using sharding.

And on Minima?

Unlike Ethereum and Bitcoin, Minima uses a consensus algorithm where users provide the Proof-of-Work and don’t rely on miners. Every user performs a small amount of Work before sending transactions, which can be summed up into a full block’s worth of Proof-of-Work. We call this Tx-PoW.

On average a user will be doing 10seconds of work per device, and sometimes when their Tx-PoW value is high enough they might mine an entire block that can be added to the current chain. From a users’ perspective, it’s seamless. It doesn’t require a lot of storage either.

Since blocks only store the hashes of transactions, like Compact blocks in Bitcoin, they are of negligible size. A 10KB block would hold about 330 transaction hashes. (Minima Whitepaper, P.3)

As you can imagine in that scenario it’s very likely that 2 users simultaneously validate the same block. With GHOST implemented, it’s possible to calculate the block tree (all the blocks created) by including all stale blocks as transactions in the main chain and consequently come to a consensus on which one the main chain is.

By using GHOST, Minima can have a faster block confirmation time than Bitcoin and is aiming for 10 second block time. That means that every ten seconds new blocks are created.

On Minima, everyone is equally validating, and running nodes in the network which completely removes the centralizing forces that we’re witnessing on other networks, such as Ethereum and Bitcoin. A network that’s run by the people for the people.

Присоединяйтесь к обсуждению
Настройки cookie

Нажимая «Принять все cookie», вы соглашаетесь на хранение файлов cookie на вашем устройстве для улучшения навигации по сайту, анализа использования сайта и помощи в наших маркетинговых усилиях. Подробнее

Сохранить настройки
Настройки cookie

Нажимая «Принять», вы соглашаетесь на хранение файлов cookie на вашем устройстве для улучшения навигации по сайту, анализа использования сайта и помощи в наших маркетинговых усилиях. Подробнее

Настройки cookie