NOTE: This repository is no longer updated. All contracts of this repository have been migrated to the Testimonium repository.
This project contains an Ethereum smart contract that enables the on-chain verification of Ethereum Proof of Work (PoW).
By providing the block number, the Keccak hash of the RLP-encoded block header without nonce and mix, the nonce, difficulty, and some elements of the Directed Acyclic Graph (DAG) used for mining, callers are able to verify the PoW on-chain. For instance, the contract is used by Testimonium to verify the validity of submitted block headers.
Important: Ethash is a research prototype. It represents ongoing work conducted within the TAST research project. Use with care.
Ethash can be deployed through the CLI tool of Testimonium, so go check it out here.
If you want to deploy the contracts manually, follow the steps below.
The following guide will walk you through the deployment of Ethash on a local blockchain (Ganache).
You need to have the following tools installed:
- Clone the repository:
git clone [email protected]:pantos-io/ethash.git
- Change into the project directory:
cd ethash/
- Install all dependencies:
npm install
- Deploy contract:
truffle migrate --reset
Developers can use this contract to perform an on-chain verification of Ethereum PoW by calling the function verifyPoW with the following parameters: the block number, the Keccak hash of the RLP-encoded block header without nonce and mix, the nonce, difficulty, and some elements of the Directed Acyclic Graph (DAG) used for mining. To check that elements come from the correct DAG (for every epoch (30,000 blocks) a new DAG is used), the contract has to be initialized with so-called epoch data. This can be done by using the function setEpochData. In case the contract is intended to be used in production, it should be initialized in advance with an sufficient amount of epoch data (e.g., epoch data for the next 5 years). Since the data of each epoch can be easily recomputed, everyone can verify the correctness of the data used for the contract initialization. Thus, no trust in the party initializing the contract is needed.
The generation of epoch data and example calls of the contract's functions are shown at https://github.com/pantos-io/go-testimonium/blob/master/cmd/submitEpoch.go
Ethash is a research prototype. We welcome anyone to contribute. File a bug report or submit feature requests through the issue tracker. If you want to contribute feel free to submit a pull request.
- The development of this prototype was funded by Pantos within the TAST research project.
- The original code for the Ethash contract comes from the smartpool project.
This project is licensed under the MIT License.