Author

Topic: Facing a problem while trying to change initial difficulty target threashold!!!! (Read 254 times)

jr. member
Activity: 48
Merit: 17
The problem is solved and is in the three final posts of https://bitcointalksearch.org/topic/m.47431328.
jr. member
Activity: 48
Merit: 17
The problem is halfway solved. I should've changed powLimit field of consensus too. In chainparams.cpp in mainnet consensus.powLimit is set to  :
Code:
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
by changing it to
Code:
consensus.powLimit = uint256S("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
I could startup the server successfully. For genesis block i found out that GenesisH0 for sure didn't work properly and I changed https://github.com/JonPullinger/Genesis-Block-Generator-Crypto-Bitcoin.git manually. Just by changing line 312
Code:
unsigned int check = *((uint32_t *)(block_hash2 + 28)); // The hash is in little-endian, so we check the last 4 bytes.
if(check == 0) // \x00\x00\x00\x00
{....
to
Code:
if(check <=1048575) // \x00\x0f\xff\xff (for example)
generated genesis block quickly. All similar C codes on github will run the same.
My problem is I can't add one node to the other. I ran the first node like :
Code:
bitcoind -dns=0 -dnsseed=0 -port=15333 -rpcport=15332 -datadir=/home/user/.bitcoin2 -maxtipage=$((24*60*60*5000))
and it seemed to work fine. Then the second node :
Code:
bitcoind -dns=0 -dnsseed=0 -port=6333 -rpcport=6332 -addnode=127.0.0.1:15332 -debug=rpc -maxtipage=$((24*60*60*50000))
The server will start up but when I type
Code:
bitcoin-cli getblocktemplate
in another terminal,I get :
Code:
error code: -10
error message:
Bitcoin is downloading blocks...

When I add port instead of rpcport:
Code:
bitcoind -dns=0 -dnsseed=0 -port=6333 -rpcport=6332 -addnode=127.0.0.1:15333 -debug=rpc -maxtipage=$((24*60*60*500000000))
It shows something
Code:
New outbound peer connected: version: 70015, blocks=0, peer=0
but still bitcoin-cli getblocktemplate didn't work
Where does it come from exactly?Why changing difficulty will result in this ?


jr. member
Activity: 48
Merit: 17
Quote
What are you using for the parameters in this call?

Code:
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);

Did you change
Code:
0x1d00ffff
to your custom difficulty?

Yes ,now I changed it to 0x200fffff and set  537919487 in :
Code:
txNew.vin[0].scriptSig = CScript() << 537919487‬<< CScriptNum(4) << std::vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
jr. member
Activity: 48
Merit: 17

Quote
How did you mine the genesis block? Does that application correctly mine the original genesis block, just to make sure it is working correctly?

Where did you set you genesis block? You should be calling this (but modifying it for the block you mined):

Code:
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);

Also, what does this function look like for you?

Code:
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
    const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

-reindex just rebuilds chain state and block index from the blk*.dat files on disk. You might need to delete the existing blockchain files in ~/.bitcoin/blocks and ~/.bitcoin/chainstate.


Thank you so much for response. I mined my genesisblock with https://github.com/lhartikk/GenesisH0. I used several  C codes first but they didn't take the target that I manually set (https://github.com/vlamer/genesis-block-generator for example). They all had a same line :
Code:
unsigned int check = *((uint32_t *)(block_hash2 + 28));
I wanted to generate a genesis hash so close to my custom threshold but it seems C codes don't work for my purpose. I have doubt about mining it with GenesisH0.
That CreateGenesisBlock function looks exactly the same for me.
Code:
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
    const char* pszTimestamp = "My change is awesome in 01/OCT/2018";    
    const CScript genesisOutputScript = CScript() << ParseHex("049b8db7f03a5e5fa10183019168dabafc367ab38f8b16ef0e16297a45a9acae9053eb915cadda71bf982eb685fed120ed365ae09544cd4f8f08d8c5c21185cbbe") << OP_CHECKSIG;
    return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
And thanks for explaining -reindex.
jr. member
Activity: 48
Merit: 17
Recently, I read https://bitcointalksearch.org/topic/complete-guide-on-how-to-create-a-new-alt-coin-update-2018-3345808  for forking bitcoin. Then I wanted to change the difficulty(Target Treshold) inorder to mine blocks faster, so I set regtest network difficulty(0x207fffff) to main network(which was 0x1d00ffff) and created my genesis block from scratch. when I run bitcoind command i get this error :

Code:
bitcoind
2018-09-28T04:46:14Z Bitcoin Core version v0.17.99.0-bddc7753d-dirty (release build)
2018-09-28T04:46:14Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2018-09-28T04:46:14Z Assuming ancestors of block 0448936a4bf373c9c203012ce041a8f41d538861676aaeb9ef4a98aa08eb9360 have valid signatures.
2018-09-28T04:46:14Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000100010001
2018-09-28T04:46:14Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2018-09-28T04:46:14Z Using RdRand as an additional entropy source
2018-09-28T04:46:14Z Default data directory /home/myuser/.bitcoin
2018-09-28T04:46:14Z Using data directory /home/myuser/.bitcoin
2018-09-28T04:46:14Z Using config file /home/myuser/.bitcoin/bitcoin.conf
2018-09-28T04:46:14Z Using at most 125 automatic connections (1024 file descriptors available)
2018-09-28T04:46:14Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2018-09-28T04:46:14Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-09-28T04:46:14Z Using 0 threads for script verification
2018-09-28T04:46:14Z HTTP: creating work queue of depth 16
2018-09-28T04:46:14Z No rpcpassword set - using random cookie authentication.
2018-09-28T04:46:14Z Generated RPC authentication cookie /home/myuser/.bitcoin/.cookie
2018-09-28T04:46:14Z HTTP: starting 4 worker threads
2018-09-28T04:46:14Z Using wallet directory /home/myuser/.bitcoin/wallets
2018-09-28T04:46:14Z init message: Verifying wallet(s)...
2018-09-28T04:46:14Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2018-09-28T04:46:14Z Using wallet wallet.dat
2018-09-28T04:46:14Z BerkeleyEnvironment::Open: LogDir=/home/myuser/.bitcoin/wallets/database ErrorFile=/home/myuser/.bitcoin/wallets/db.log
2018-09-28T04:46:14Z scheduler thread start
2018-09-28T04:46:14Z Cache configuration:
2018-09-28T04:46:14Z * Using 2.0MiB for block index database
2018-09-28T04:46:14Z * Using 8.0MiB for chain state database
2018-09-28T04:46:14Z * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2018-09-28T04:46:14Z init message: Loading block index...
2018-09-28T04:46:14Z Opening LevelDB in /home/myuser/.bitcoin/blocks/index
2018-09-28T04:46:14Z Opened LevelDB successfully
2018-09-28T04:46:14Z Using obfuscation key for /home/myuser/.bitcoin/blocks/index: 0000000000000000
2018-09-28T04:46:14Z LoadBlockIndexDB: last block file = 0
2018-09-28T04:46:14Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
2018-09-28T04:46:14Z Checking all blk files are present...
2018-09-28T04:46:14Z Initializing databases...
2018-09-28T04:46:14Z Pre-allocating up to position 0x1000000 in blk00000.dat
2018-09-28T04:46:14Z Opening LevelDB in /home/myuser/.bitcoin/chainstate
2018-09-28T04:46:14Z Opened LevelDB successfully
2018-09-28T04:46:14Z Wrote new obfuscate key for /home/myuser/.bitcoin/chainstate: 486c004dfb89eb73
2018-09-28T04:46:14Z Using obfuscation key for /home/myuser/.bitcoin/chainstate: 486c004dfb89eb73
2018-09-28T04:46:14Z init message: Rewinding blocks...
2018-09-28T04:46:14Z  block index              47ms
2018-09-28T04:46:14Z init message: Loading wallet...
2018-09-28T04:46:14Z [default wallet] nFileVersion = 179900
2018-09-28T04:46:14Z [default wallet] Keys: 0 plaintext, 0 encrypted, 0 w/ metadata, 0 total. Unknown wallet records: 0
2018-09-28T04:46:14Z [default wallet] Performing wallet upgrade to 169900
2018-09-28T04:46:18Z [default wallet] keypool added 2000 keys (1000 internal), size=2000 (1000 internal)
2018-09-28T04:46:18Z [default wallet] Wallet completed loading in            3384ms
2018-09-28T04:46:18Z [default wallet] setKeyPool.size() = 2000
2018-09-28T04:46:18Z [default wallet] mapWallet.size() = 0
2018-09-28T04:46:18Z [default wallet] mapAddressBook.size() = 0
2018-09-28T04:46:18Z ERROR: ReadBlockFromDisk: Errors in block header at CDiskBlockPos(nFile=0, nPos=8)
2018-09-28T04:46:18Z *** Failed to read block
2018-09-28T04:46:18Z Error: Error: A fatal internal error occurred, see debug.log for details
Error: Error: A fatal internal error occurred, see debug.log for details
Segmentation fault (core dumped)

There is actually nothing more than what I get in debug.log. I tried to run it with -reindex (though I don't precisely know what reindex does!?) and I get :

Code:
bitcoind -reindex
2018-09-28T04:47:06Z Bitcoin Core version v0.17.99.0-bddc7753d-dirty (release build)
2018-09-28T04:47:06Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2018-09-28T04:47:06Z Assuming ancestors of block 0448936a4bf373c9c203012ce041a8f41d538861676aaeb9ef4a98aa08eb9360 have valid signatures.
2018-09-28T04:47:06Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000100010001
2018-09-28T04:47:06Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2018-09-28T04:47:06Z Using RdRand as an additional entropy source
2018-09-28T04:47:06Z Default data directory /home/myuser/.bitcoin
2018-09-28T04:47:06Z Using data directory /home/myuser/.bitcoin
2018-09-28T04:47:06Z Using config file /home/myuser/.bitcoin/bitcoin.conf
2018-09-28T04:47:06Z Using at most 125 automatic connections (1024 file descriptors available)
2018-09-28T04:47:06Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2018-09-28T04:47:06Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-09-28T04:47:06Z Using 0 threads for script verification
2018-09-28T04:47:06Z HTTP: creating work queue of depth 16
2018-09-28T04:47:06Z No rpcpassword set - using random cookie authentication.
2018-09-28T04:47:06Z Generated RPC authentication cookie /home/myuser/.bitcoin/.cookie
2018-09-28T04:47:06Z HTTP: starting 4 worker threads
2018-09-28T04:47:06Z Using wallet directory /home/myuser/.bitcoin/wallets
2018-09-28T04:47:06Z init message: Verifying wallet(s)...
2018-09-28T04:47:06Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2018-09-28T04:47:06Z Using wallet wallet.dat
2018-09-28T04:47:06Z BerkeleyEnvironment::Open: LogDir=/home/myuser/.bitcoin/wallets/database ErrorFile=/home/myuser/.bitcoin/wallets/db.log
2018-09-28T04:47:06Z scheduler thread start
2018-09-28T04:47:06Z Cache configuration:
2018-09-28T04:47:06Z * Using 2.0MiB for block index database
2018-09-28T04:47:06Z * Using 8.0MiB for chain state database
2018-09-28T04:47:06Z * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2018-09-28T04:47:06Z init message: Loading block index...
2018-09-28T04:47:06Z Wiping LevelDB in /home/myuser/.bitcoin/blocks/index
2018-09-28T04:47:06Z Opening LevelDB in /home/myuser/.bitcoin/blocks/index
2018-09-28T04:47:06Z Opened LevelDB successfully
2018-09-28T04:47:06Z Using obfuscation key for /home/myuser/.bitcoin/blocks/index: 0000000000000000
2018-09-28T04:47:06Z Initializing databases...
2018-09-28T04:47:06Z Wiping LevelDB in /home/myuser/.bitcoin/chainstate
2018-09-28T04:47:06Z Opening LevelDB in /home/myuser/.bitcoin/chainstate
2018-09-28T04:47:06Z Opened LevelDB successfully
2018-09-28T04:47:06Z Wrote new obfuscate key for /home/myuser/.bitcoin/chainstate: 329d28cbdd513256
2018-09-28T04:47:06Z Using obfuscation key for /home/myuser/.bitcoin/chainstate: 329d28cbdd513256
2018-09-28T04:47:06Z  block index              20ms
2018-09-28T04:47:06Z init message: Loading wallet...
2018-09-28T04:47:06Z [default wallet] nFileVersion = 179900
2018-09-28T04:47:06Z [default wallet] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 0
2018-09-28T04:47:06Z [default wallet] Wallet completed loading in             112ms
2018-09-28T04:47:06Z [default wallet] setKeyPool.size() = 2000
2018-09-28T04:47:06Z [default wallet] mapWallet.size() = 0
2018-09-28T04:47:06Z [default wallet] mapAddressBook.size() = 0
2018-09-28T04:47:06Z Reindexing block file blk00000.dat...
2018-09-28T04:47:06Z ERROR: AcceptBlock: high-hash, proof of work failed (code 16)
2018-09-28T04:47:07Z Reindexing finished
2018-09-28T04:47:07Z Failed to open mempool file from disk. Continuing anyway.

It seems to have problem with PoW. I guessed there is something with this line in "chainparams.cpp":
Code:
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));

At first I set 486604799 (decimal of bitcoin core's initial difficulty 0x1d00ffff) to the new difficulty 545259519 (decimal of 0x207fffff) but I get core dumped instantly.Maybe this
 
Code:
if (UintToArith256(hash) > bnTarget)
     return false;
from pow.cpp always returns false. Anyone has any idea what should I do ? I will be very grateful.
Jump to: