-2

I'm using https://github.com/jgarzik/pyminer/blob/master/pyminer.py to test a few different hash functions. Instead, I'd like to try keccak, a few of them in some order like an "X5" and so on.

This is a toy project to try and change the proof of work in Bitcoin and recompile and test, either an old version < 0.10.0 since getwork() might be easier to test with, or the latest release - apparently bitcoin-cli can mine blocks if starting from a new genesis block and the difficulty is set so low that a CPU can mine as much as you like.

My problem is that I can't find in Bitcoin Core where the proof of work is. I've looked in pow and validation files for near a week now, but no luck so far, or I just can't see it for some reason.

I thought it might have been obvious in miner.cpp which I think is no longer used (but might be able to be enabled?), and the best I can find is CheckProofOfWork in pow.cpp.

It doesn't seem to check whether the PoW is sha256d. Does it? I must be missing something. So it looks like I can just change the miner code and submit a proof of work and if it meets the requirements, it will be accepted.

Is there a reasonably easy way to use a toy miner, change the PoW algorithm, and modify Bitcoin Core if necessary to try a different proof of work?

Edit: this is not altcoin development, it's an effort to understand Bitcoin's code in more detail. Please stop begging the question. Also please consider downvoting only questions which are truly useless instead of those you just don't like. Thanks!

closed as too broad by Anonymous, Andrew Chow May 9 at 17:09

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Edit: Found github.com/BitcoinHardfork/bitcoin and what seems easier to implement with adding a few new files and adjusting a couple of bits: use Keccak from some date also by Luke DashJr github.com/luke-jr/bitcoin/commit/… Still no real information on how to get it going and test it though, unless it's as easy as cloning the code to make an altcoin and using this proof of work from the beginning. – James Young May 1 at 12:15
  • Why was this down voted? Changing a proof of work not an interesting enough topic for our voting overlords? – James Young May 1 at 16:57
  • Generally speaking, altcoin "development" questions provide little to no value. Basic code comprehension assistance for a financial product being akin to asking for help finding the ignition button in an aircraft, we can help you with the very specific question, but everybody knows you're not getting off the ground. – Anonymous May 2 at 15:08
  • 1
    I’ve been involved in Bitcoin for the better part of a decade and have never seen an instance of someone producing meaningful understanding by producing altcoins. It is usually the complete opposite, with misunderstanding born from the misconception that the implementation of Bitcoin has a huge amount to do with its overall design. The same way disassembling a cake doesn’t tell you much about its ingredients, or why taking a spanner to a car unsupervised can lead to confusion rather than detailed knowledge. – Anonymous May 2 at 20:27
  • 2
    This is altcoin development because the end result is that you will have created an altcoin. – Andrew Chow May 2 at 23:20
0

The hash function used in the Proof of Work is not some variable or additional data in blocks that Bitcoin Core needs to check. Furthermore, the Proof of Work is not just something that you submit; in fact, it is not a separate data field at all. The Proof of Work is the hash of the block header, and checking the Proof of Work means computing that hash and comparing it against the current target value.

So to change the proof of work algorithm, you need to change the hash function used for hashing block headers. Keep in mind that doing so will also change how blocks are identified because blocks are identified by hash.

The function that is called to compute and get the block header's hash can be found here. This function itself calls a helper function which calls some other helpers. If you want to change the hash function used in the PoW, you need to change those helpers as well. Keep in mind that if you change those functions too, other things may break and more than the hash function used in the PoW will change.

Not the answer you're looking for? Browse other questions tagged or ask your own question.