Demo Implementation of CPU Mining - QuarkChain/pyquarkchain GitHub Wiki

We provide the demo implementation of CPU mining software to the public. Start mining with the following command.

pypy3 quarkchain/tools/external_miner.py --worker $NUMBERS_OF_WORKDER --shard $SHARD_ID --host localhost --config </path/to/cluster_config_template.json>

Command Line Flags

Command line flags are defined in external_miner.py. Some interesting ones regarding mining:

  • --worker (default 1) defines the number of worker threads. Utilize as many CPU cores as possible.

  • --shard defines specify shards to mine. Use R to indicate root chain and 0 ~ 7 to indicate sharded chain id. More specifically, shards 0 ~ 3 are Ethash, 4 ~ 5 are Double Sha256, and 6 ~7 are Qkchash. Since each worker thread is an independent process, you may want to make the number of specified shards equal to the number of worker threads.

  • --config defines the path to config JSON file, same as the config running cluster. We provide an example config JSON in the repo (testnet/2/cluster_config_template.json).

You can select one shard or multiple shards to mine according to your machines. One example command line of two worker threads working with shard 0 and 1 is,

pypy3 quarkchain/tools/external_miner.py --worker 2 --shard 0 1 --host localhost --config </path/to/cluster_config_template.json>

Qkchash

The current demo implementation of Qkchash algorithm is based on the python version, which is less efficient than the native version, which is based on C++. The performance comparison is shown as follow,

Python version, time used: 0.46, hashes per sec: 21.54
Native version, time used: 6.16, hashes per sec: 162.23

The external miner can switch to the native version of Qkchash by passing lib path to mining params during invocation.