1

I'm playing around with the code and tried to adjust difficulty by changing code from

bnProofOfWorkLimit = ~uint256(0) >> 1

to

bnProofOfWorkLimit = ~uint256(0) >> 20

inside code block for Regression Test in chainparams.cpp (bitcoin-0.10.0).

I configured, did make, then make install with binaries in a custom directory (not default /usr/local/bin/bitcoind !), started bitcoind in regtest mode and generated some blocks.
Somehow it feels like it takes same amount of time for generating blocks as before modifying the code.

What am I doing wrong?


UPDATE:

Changed difficulty in chainparams.cpp from

bnProofOfWorkLimit = ~uint256(0) >> 1

to

bnProofOfWorkLimit = ~uint256(0) >> 32

still getting this:

Bitcoin version v0.10.0.0-g047a898 (Fri, 13 Feb 2015 09:55:11 +0100)
Using OpenSSL version OpenSSL 1.0.1f 6 Jan 2014
Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
Default data directory /home/aliakbar/.bitcoin
Using data directory /home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/regtest
Using config file /home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/bitcoin.conf
Using at most 125 connections (1024 file descriptors available)
Using 4 threads for script verification
Binding RPC on address ::1 port 23333 (IPv4+IPv6 bind any: 0)
Binding RPC on address 127.0.0.1 port 23333 (IPv4+IPv6 bind any: 0)
Using wallet wallet.dat
init message: Verifying wallet...
CDBEnv::Open : LogDir=/home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/regtest/database ErrorFile=/home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/regtest/db.log
Bound to [::]:13333
Bound to 0.0.0.0:13333
init message: Loading block index...
Opening LevelDB in /home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/regtest/blocks/index
Opened LevelDB successfully
Opening LevelDB in /home/aliakbar/Downloads/bitcoin-0.10.0_test1/build/bin/test1/regtest/chainstate
Opened LevelDB successfully
LoadBlockIndexDB: last block file = 0
LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
Checking all blk files are present...
LoadBlockIndexDB(): transaction index disabled
Initializing databases...
Pre-allocating up to position 0x1000000 in blk00000.dat
ERROR: CheckProofOfWork() : nBits below minimum work
ERROR: CheckBlockHeader() : proof of work failed
InvalidChainFound: invalid block=0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206  height=0  log2_work=1  date=2011-02-02 23:16:42

What am I doing wrong? Do I have to adjust difficulty somewhere else than in chainparams.cpp?

1

What am I doing wrong?

Not setting the difficulty high enough. A standard computer can do 1 MH/s SHA256d hashes, or about 2^20 hashes. That means in your scenario, solving a regtest block will take about 1 second. If you want it to take longer, increase the difficulty.

Also, note that if you're using an 0.9.* version of bitcoin, then setting the regtest difficulty to below ~uint256(0) >> 16 won't really do much, as the mining code won't even check a result that doesn't hash to below that difficulty.

If you're using the most recent code, though, then rather than adjusting the regtest parameters, you could also just add your own set of parameters.

  • If you're using the most recent code, though, then rather than adjusting the regtest parameters, you could also just add your own set of parameters. - if adding new own set of parameters, where am I going to call them? I mean, even a parameter, such as nSubsidyHalvingInterval, doesn't show up anywhere else (like in main.cpp) than in chainparams.cpp only!? – Aliakbar Ahmadi May 27 '15 at 16:04
  • 1
    You would have to modify the startup process to recognize some new flag (like -myparams) and select the parameters based on that flag. Then all calls to Params() will return your params. – morsecoder May 27 '15 at 16:11
  • Unfortunately I can't follow you with modify the startup process, do you mean a flag, like -regtest or -testnet?If so, I searched for them in src but only found out - to my perception - that out of bitcoind.cpp there isn't any call for parameters defined in chainparams.cpp..Could you please give me hints or give me concrete instructions on how to set new set of parameters? – Aliakbar Ahmadi May 27 '15 at 16:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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