Skip to content

Mining pool - rough draft

Christopher Schinnerl requested to merge mining-pool into master

Created by: JoshVorick

This pull request contains the code for a mining pool that technically works (I'm pretty sure, haven't done much testing beyond one miner connecting to the pool viz localhost).

I wanted to make this pull request for two reasons:

  • Avoid making a 1500+ line PR later on
  • Get the structure of the pool reviewed before I work out all the finer details.

This code is littered with TODOs. If there's anything that the pool code should include that isn't in a TODO comment, let me know and I'll throw it in. I think the one major thing that the pool needs that isn't written in the code is some sort of persistence layer so that the pool can save/load payment channels in case siad gets restarted.

The basic structure of the pool:

  1. API call to siad 'miner/connecttopool' this connects to localhost:9983 and retrieves the mining pool's settings. After getting the pool's settings, the miner makes an RPC to the pool to negotiate a new payment channel.
  2. The miner makes calls to miner/poolheaderforwork/, which returns headers of blocks with the proper pool payouts and adjusted target.
  3. The miner calls miner/submitpoolheader when it finds a partial block. This submits the block to the pool, and retrieves a payout transaction from the pool. For now, the miner immediately broadcasts said transaction, effectively closing the payment channel. The miner then makes an RPC to the pool to negotiate a new payment channel.

Right now the pool is insecure because the miner and the pool both assume each other is doing the 'right' thing (e.g. submitting valid blocks, signing transactions, etc).

Merge request reports