Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post-merge epic: update pow page #7105

Merged
merged 6 commits into from
Aug 1, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 21 additions & 24 deletions src/content/developers/docs/consensus-mechanisms/pow/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,73 @@ title: Proof-of-work (PoW)
description: An explanation of the proof-of-work consensus protocol and its role in Ethereum.
lang: en
sidebar: true
incomplete: true
---

Ethereum, like Bitcoin, currently uses a consensus protocol called **[Proof-of-work (PoW)](https://wikipedia.org/wiki/Proof_of_work)**. This allows the nodes of the Ethereum network to agree on the state of all information recorded on the Ethereum blockchain and prevents certain kinds of economic attacks.
The Ethereum network started using a consensus mechanism called **[Proof-of-work (PoW)](/developers/docs/consensus-mechanisms/pow)**. This allowed the nodes of the Ethereum network to agree on the state of all information recorded on the Ethereum blockchain and prevents certain kinds of economic attacks. However, Ethereum switched off proof-of-work in 2022 and started using [proof-of-stake](/developers/docs/consensus-mechanisms/pos) instead.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

Over the next year, proof-of-work will be phased out in favour of **[Proof-of-stake (PoS)](/developers/docs/consensus-mechanisms/pos)**. The transition to proof-of-stake will also phase out mining from Ethereum. [More on The Merge.](/upgrades/merge/)
<InfoBanner emoji=":wave:">
Proof-of-work has now been deprecated. Ethereum no longer uses proof-of-work as a consensus mechanism. Instead, it uses proof-of-stake. Read more on <a href="/developers/docs/consensus-mechanisms/pos/">proof-of-stake</a> and <a href="/staking/">staking</a>.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved
</InfoBanner>

## Prerequisites {#prerequisites}

To better understand this page, we recommend you first read up on [transactions](/developers/docs/transactions/), [blocks](/developers/docs/blocks/), and [consensus mechanisms](/developers/docs/consensus-mechanisms/).

## What is Proof-of-work (PoW)? {#what-is-pow}

Proof-of-work is the mechanism that allows the decentralized Ethereum network to come to consensus, or agree on things like account balances and the order of transactions. This prevents users from "double spending" their coins and ensures that the Ethereum chain is tremendously difficult to attack or manipulate.
Proof-of-work is the mechanism that once allowed the decentralized Ethereum network to come to consensus (i.e. all nodes agree) on things like account balances and the order of transactions. This prevented users from "double spending" their coins and ensured that the Ethereum chain was tremendously difficult to attack or manipulate. These security properties now come from proof-of-stake instead.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

## Proof-of-work and mining {#pow-and-mining}

Proof-of-work is the underlying algorithm that sets the difficulty and rules for the work miners do. Mining is the "work" itself. It's the act of adding valid blocks to the chain. This is important because the chain's length helps the network follow the correct Ethereum chain and understand Ethereum's current state. The more "work" done, the longer the chain, and the higher the block number, the more certain the network can be of the current state of things.
Proof-of-work is the underlying algorithm that sets the difficulty and rules for the work miners do on proof-of-work blockchains. Mining is the "work" itself. It's the act of adding valid blocks to the chain. This is important because the chain's length helps the network follow the correct fork of the blockchain. The more "work" done, the longer the chain, and the higher the block number, the more certain the network can be of the current state of things.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here, "mining" is just the act of finding the nonce that results in a block hash with an adequate number of leading binary zeros by brute-force hashing. By finding this nonce, it provide proof that the work was performed. I believe it would be more correct to say the underlying algorithm that adjusts the difficulty is the Nakamoto Consensus mechanism which uses PoW.
@jmcook1186 Thought on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure - in Geth the difficulty calculation is part of the Ethash package - it's just a simple comparison between the change in time taken to mine a block relative to its parent and a threshold. To me it feels fine to describe it as part of PoW.


[More on mining](/developers/docs/consensus-mechanisms/pow/mining/)

## How does Ethereum's proof-of-work work? {#how-it-works}
## How did Ethereum's proof-of-work work? {#how-it-works}

Ethereum transactions are processed into blocks. Each block has a:
Ethereum transactions are processed into blocks. In proof-of-work Ethereum, each block contained:
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

- block difficulty – for example: 3,324,092,183,262,715
- mixHash – for example: `0x44bca881b07a6a09f83b130798072441705d9a665c5ac8bdf2f39a3cdf3bee29`
- nonce – for example: `0xd3ee432b4fb3d26b`

This block data is directly related to proof-of-work.
This block data was directly related to proof-of-work.

### The work in proof-of-work {#the-work}

The proof-of-work protocol, Ethash, requires miners to go through an intense race of trial and error to find the nonce for a block. Only blocks with a valid nonce can be added to the chain.
The proof-of-work protocol, Ethash, required miners to go through an intense race of trial and error to find the nonce for a block. Only blocks with a valid nonce could be added to the chain.

When racing to create a block, a miner will repeatedly put a dataset, that you can only get from downloading and running the full chain (as a miner does), through a mathematical function. The dataset gets used to generate a mixHash below a target nonce, as dictated by the block difficulty. The best way to do this is through trial and error.
When racing to create a block, a miner repeatedly put a dataset, that could only be obtained by downloading and running the full chain (as a miner does), through a mathematical function. The dataset was used to generate a mixHash below a target nonce, as dictated by the block difficulty. The best way to do this is through trial and error.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

The difficulty determines the target for the hash. The lower the target, the smaller the set of valid hashes. Once generated, this is incredibly easy for other miners and clients to verify. Even if one transaction were to change, the hash would be completely different, signalling fraud.
The difficulty determined the target for the hash. The lower the target, the smaller the set of valid hashes. Once generated, this was incredibly easy for other miners and clients to verify. Even if one transaction were to change, the hash would be completely different, signalling fraud.

Hashing makes fraud easy to spot. But proof-of-work as a process is also a big deterrent to attacking the chain.
Hashing makes fraud easy to spot. But proof-of-work as a process was also a big deterrent to attacking the chain.

### Proof-of-work and security {#security}

Miners are incentivised to do this work on the main Ethereum chain. There is little incentive for a subset of miners to start their own chain – it undermines the system. Blockchains rely on having a single state as a source of truth. And users will always choose the longest or "heaviest" chain.
Miners were incentivised to do this work on the main Ethereum chain. There was little incentive for a subset of miners to start their own chain – it undermines the system. Blockchains rely on having a single state as a source of truth.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

The objective of proof-of-work is to extend the chain. The longest chain is most believable as the valid one because it's had the most computational work done. Within Ethereum's PoW system, it's nearly impossible to create new blocks that erase transactions, create fake ones, or maintain a second chain. That's because a malicious miner would need to always solve the block nonce faster than everyone else.
The objective of proof-of-work was to extend the chain. The longest chain was most believable as the valid one because it had the most computational work done to generate it. Within Ethereum's PoW system, it was nearly impossible to create new blocks that erase transactions, create fake ones, or maintain a second chain. That's because a malicious miner would have needed to always solve the block nonce faster than everyone else.

To consistently create malicious yet valid blocks, you'd need over 51% of the network mining power to beat everyone else. You'd need a lot of computing power to be able to do this amount of "work". And the energy spent might even outweigh the gains you'd make in an attack.
To consistently create malicious yet valid blocks, a malicious miner would have needed over 51% of the network mining power to beat everyone else. That amount of "work" requires a lot of expensive computing power and the energy spent might even have outweighed the gains made in an attack.

### Proof-of-work economics {#economics}

Proof-of-work is also responsible for issuing new currency into the system and incentivizing miners to do the work.
Proof-of-work was also responsible for issuing new currency into the system and incentivizing miners to do the work.

Miners who successfully create a block get rewarded with two freshly minted ETH but no longer receive all the transaction fees, as the base fee gets burned, while the tip and block reward goes to the miner. A miner may also get 1.75 ETH for an uncle block. Uncle blocks are valid blocks created by a miner practically at the same time as another miner mined the successful block. Uncle blocks usually happen due to network latency.
Miners who successfully create a block were rewarded with two freshly minted ETH and part of the transaction fees. 1.75 ETH was also paid for an uncle block. Uncle blocks are valid blocks created by a miner practically at the same time as another miner mined the successful block. Uncle blocks usually happen due to network latency.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

## Finality {#finality}

A transaction has "finality" on Ethereum when it's part of a block that can't change.

Because miners work in a decentralized way, two valid blocks can get mined at the same time. This creates a temporary fork. Eventually, one of these chains will become the accepted chain after a subsequent block has been mined and added, making it longer.
Because miners worked in a decentralized way, two valid blocks could be mined at the same time. This creates a temporary fork. Eventually, one of these chains became the accepted chain after subsequent blocks were mined and added to it, making it longer.

But to complicate things further, transactions rejected on the temporary fork may have been included in the accepted chain. This means it could get reversed. So finality refers to the time you should wait before considering a transaction irreversible. For Ethereum, the recommended time is six blocks or just over 1 minute. After six blocks, you can say with relative confidence that the transaction was successful. You can wait longer for even greater assurances.

Finality is something to bear in mind when designing dapps. It would be a poor user experience to misrepresent transaction information to your users, especially if the transaction is of high value.

Remember, this timing doesn't include the wait times for having a transaction picked up by a miner.
But to complicate things further, transactions rejected on the temporary fork may have been included in the accepted chain. This means it could get reversed. So finality refers to the time you should wait before considering a transaction irreversible. For Ethereum, the recommended time was six blocks or just over 1 minute. After six blocks, there was high confidence that the transaction was successful - lonmgher waits gave higher confidence. Now, with proof-of-stake, finalization is an explicit, rather than probabilistic, property of a block.
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

## Proof-of-work energy-usage {#energy}

A major criticism of proof-of-work is the amount of energy output required to keep the network safe. To maintain security and decentralization, Ethereum on proof-of-work consumes 73.2 TWh annually, the energy equivalent of a medium-sized country like Austria.
A major criticism of proof-of-work is the amount of energy output required to keep the network safe. To maintain security and decentralization, Ethereum on proof-of-work consumed large amounts of energy. Shortly before switching to proof-of-stake, Ethereum miners were collectively consuming about 70 TWh/yr (about the same as the Czech Republic - according to [digiconomist](digiconomist.net) on 18/07/22).
jmcook1186 marked this conversation as resolved.
Show resolved Hide resolved

## Pros and cons {#pros-and-cons}

Expand Down
Loading