Ethash Explained
Last Updated: 13th January 2019
Originally conceived by Vitalik Buterin, Ethereum can be characterized as being an open technology platform upon which developers can build and launch decentralized applications (or dapps) using smart contract technology. Ethereum’s native asset is known as ether, it serves as a fee for computations that are executed on the network. That fee is calculated in gas, but is paid for in ether. Ether also functions as an incentive mechanism for cryptocurrency miners to secure the network. Underpinning the entire protocol is the Ethereum algorithm for proof of work mining, known as Ethash.
Proof of work mining functions as a tool that is used to secure distributed networks and process blocks of transactions on the blockchain. Proof of work mining involves taking data from a block header to form an input, and repeatedly hashing that input using a cryptographic hashing algorithm. This produces an output of a fixed length, which represents the hash value. Miners will hash variations of the input data by including a different nonce each time the input data is entered into the algorithm. In the case of Ethereum, the algorithm used for this process is Ethash.
Ethash
Ethash is a proof of work algorithm that is a modified version of a precursor algorithm known as Dagger-Hashimoto. With Ethash, the output formed in the hashing process must result in a hash value that is below a certain threshold. This concept is known as difficulty, and it involves the Ethereum network increasing and decreasing the threshold in order to control the rate at which blocks are mined on the network. If the rate at which blocks are found increases, then the network will automatically increase the difficulty i.e. it will lower the network threshold so that the number of valid hashes capable of being found also decreases. Conversely, if the rate of discovered blocks decreases, the network threshold will increase to produce a higher number of correct hash values that could be found. With the Ethereum algorithm, the difficulty dynamically adjusts such that, on average, one block is produced by the network every 12 seconds.
A miner that successfully discovers a block that can be added to the blockchain receives:
- A static block reward consisting of 3 ether.
- All of the gas spent within the block, in other words, all of the gas that has been consumed by the execution of all the transactions that are contained within the block. This gas cost is awarded to the miner’s account as part of the proof of work mining process.
- An extra reward for including uncles as part of the block. Uncles that are included in a block by a proof of work miner receive 7/8 of the static block reward, which is 2.625 ether.
Ethash and ASIC-Resistance
Ethash is based around a large, randomly generated dataset known as a DAG (Directed Acyclic Graph). The DAG is updated once every 30,000 blocks, and the current DAG size of Ethereum is, at the time of writing, 2.84 GB. The DAG will continue to grow as the blockchain grows.
Mining on Ethash involves fetching random data from the dataset (the DAG), computing some randomly selected transactions from any block, and then returning the hash of the result. This means that a miner will be required to store the entire DAG in order to be able to fetch random data and compute randomly selected transactions. As a result, the proof of work mining process on Ethereum is one that can be characterized as being memory-hard or memory-bound. Memory hard refers to a situation in which the time taken to complete a given computational problem is primarily decided by the amount of memory required to hold data.
This means that the vast majority of a miner’s efforts will be expended on reading the DAG, instead of computing data fetched from it. This is intended to make Ethash ASIC (application-specific integrated circuit) resistant, as the large memory requirement of mining on Ethereum means that large-scale miners gain little benefit from packing terabytes of memory into their devices. This is because smaller miners can achieve the same effect by simply purchasing a large amount of memory holding devices, as the energy cost of memory is comparable for both ASIC chips and any physical device capable of storing memory.
Ethereum’s proof of work model can be contrasted to models such as Bitcoin, which is based on SHA-256 hashing. In the case of Bitcoin for example, its proof of work scheme is compute-bound, meaning that the time taken to complete a computational task is decided primarily by the speed of a computer’s central processor. Given the fact that Bitcoin’s mining algorithm requires a simple SHA-256 computation, we have seen the emergence of ASIC chips that have been configured and designed for the sole purpose of computing billions of SHA-256 hashes. This has made it virtually impossible for miners with general purpose CPU and GPU hardware to compete, as ASIC chips are much more efficient in computation.
Conclusion
To conclude, in an attempt to make the mining process a more egalitarian one, Ethash is a memory-hard proof of work algorithm that has been designed to be ASIC-resistant. It is also important to note that there are plans to transition Ethereum’s consensus algorithm from proof of work to proof of stake, which would make mining on Ethereum, in its current form, obsolete.