Bitcoin hardware | Clasf

Standalone Bitcoin miners

Bitcoin Mining / January 12, 2020

Rather than working towards a centralized mining solution, I think we should focus our early efforts on a decentralized solution: p2pool.

Zcashd, p2pool, and a standalone miner will all run on the same machine (no third party server needed). Not only does this prevent centralization of mining, but every miner will also be a full node.

To achieve this we need to do the following:

Fork/Modify P2Pool

Also, I'm not sure if P2Pool verifies blocks/shares itself or whether it leverages zcashd to do that. If it verifies the validity of blocks itself then we'll also need to modify it so it can verify zcash blocks.

Create a Standalone Zcash Miner

Zcashd has an internal miner (see line 400 here). It should be modified so that it gets it's block headers from P2Pool, instead of building them from scratch on it's own. Moreover, it needs to be able to communicate with p2pool using the stratum protocol.

There are already a few standalone miners (for bitcoin and various alts) that use the stratum protocol (and are therefore compatible with p2pool). BFGminer and cgminer are two that stand out. It may be tempting to fork one of those projects and swap out their native hashing algorithm with Equihash. But I wouldn't recommend that.

Existing standalone miners come with a LOT of code we don't need. Much of the code complexity of bitcoin miners comes from the fact that SHA256 hashing is so fast that miners quickly exhaust their nonce space. They then have to tweak things and recompute their block headers often. We don't have this problem in zcash. Equihash takes dozens of seconds to complete a single hash. It is unlikely any zcash miner will ever exhaust their nonce space and need to tweak/recompute the block headers. So a standalone zcash miner can omit much of the code complexity found in the existing miners.

Also, the Stratum protocol isn't very complicated. This is why I think it makes sense to write a standalone miner "from scratch", starting with the native zcash internal miner.

Moving Forward

P2Pool is written primarily in Python. The native zcashd miner is written in C++.
I'm a python developer and feel comfortable jumping into the P2Pool code to modify it as needed.

On the other hand, I have next to zero C++ experience, so it would be great if someone else could volunteer to help with the standalone miner.