[Ethereum] the exact “longest chain” rule implemented in the Ethereum “Homestead” protocol

difficultyhomesteaduncle-blocks

This paper from 2016 claims (in section 3.3.2, speaking about the actual Ethereum implementation as opposed to the specification) that:

although uncle blocks that are included in a block receive a reward, they do not count towards the total difficulty of a chain, i.e., Ethereum uses a longest chain rule with added rewards for uncle blocks. This clearly contradicts Ethereum’s claim of using a blockchain protocol adapting GHOST

(Emphasis in original). The only reference offered is to this paper which appears to assert a contrasting claim, that:

A variant of GHOST has been adopted and implemented by the Ethereum project.

Its only reference is to ethereum.org so that doesn't help either. I am aware of the extensive documentation which describes Ethereum's rules for rewarding ommer/uncle blocks, frequently saying that they "contribute to security". However the specific question of whether ommers/uncles are counted in determining the longest chain does not seem to be as clearly documented.

The first paper goes on to claim:

Ethereum has also recently modified its longest chain algorithm to
incorporate uniform tie breaking…[which] allows a selfish miner
to increase its chances of catching up to the honest chain

And in this case links to a specific commit as well as this paper on optimal selfish mining strategies which points out that uniform tie breaking is a specific trade-off, making attacks much harder for highly connected and coordinated attackers while making attacks slightly easier for less connected or coordinated ones. However, since that paper is a paper about Bitcoin and assumes a non-uncle-counting longest chain rule (nor does it specifically account for the strategic implications of ommer/uncle rewards), assessing the real-world impact of uniform tie breaking in Ethereum still requires knowing whether or not ommer/uncle difficulty is being counted in the first place.

So, what are Ethereum nodes doing in Homestead as far as their actual longest chain rule?

Are they counting uncle difficulty as contributing to the longest chain? And are they still doing uniform tie breaking? Have any other changes been made? For example, SPV mining became prevalent in bitcoin despite not actually being implemented in the official releases. In theory Ethereum prescribes that blocks in the main chain are fully validated while ommer/uncle blocks only have their headers validated. However both block timestamps and transaction inclusion have definitely been tweaked by miners before for strategic reasons.

What I want is just the best answer to this question we can currently get for the nodes actually running on pools, clients, etc. Note that links to white or yellow papers are insufficient here, since this paper specifically claims that implementation differs from theory and documentation. Responses need to come from the developers of actual clients such as geth and parity, and/or link directly to repositories showing how the rule is actually implemented.

Best Answer

Ethereum determines the longest chain based on the total difficulty, which is embedded in the block header. Ties are broken randomly.

Total difficulty is the simple sum of block difficulty values without explicitly counting uncles. Difficulty is computed based on parent difficulty and timestamp, block timestamp, and block number, again without reference to uncles.

All of these except tiebreaking are consensus-critical, and so can be expected to be the same across all clients.

Related Topic