Bitcoin Forum
May 12, 2024, 06:06:28 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: getblocktemplate on testnet giving wrong target and bits?  (Read 1969 times)
fireduck (OP)
Sr. Member
****
Offline Offline

Activity: 392
Merit: 251



View Profile
February 19, 2015, 08:22:10 AM
 #1

I've tried this with 0.8 release branch, 0.9 and head.  I get the same results for each.

The getdifficulty returns 1.0 and the found blocks confirm that this seems to be the case.

However, getblocktemplate is showing a much harder difficulty in the target:
00000000000003a2d80000000000000000000000000000000000000000000000

Broken up for readability:
00000000000003a2
d800000000000000
0000000000000000
0000000000000000

For that difficulty it should be something like:
0000000100000000
0000000000000000
0000000000000000
0000000000000000

The most recent found block agrees with this:
0000000076f8abad2


./bitcoind -testnet getblocktemplate

...transactions omitted...

    "coinbasevalue" : 2500081729,
    "target" : "00000000000003a2d80000000000000000000000000000000000000000000000",
    "mintime" : 1424334619,
    "mutable" : [
        "time",
        "transactions",
        "prevblock"
    ],
    "noncerange" : "00000000ffffffff",
    "sigoplimit" : 20000,
    "sizelimit" : 1000000,
    "curtime" : 1424334619,
    "bits" : "1a03a2d8",
    "height" : 323482
}

./bitcoind -testnet getdifficulty
1.00000000

I'm trying to run some blocks on testnet to make sure my mining pool software still works correctly.

 Huh

Bitrated user: fireduck.
There are several different types of Bitcoin clients. The most secure are full nodes like Bitcoin Core, but full nodes are more resource-heavy, and they must do a lengthy initial syncing process. As a result, lightweight clients with somewhat less security are commonly used.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715537188
Hero Member
*
Offline Offline

Posts: 1715537188

View Profile Personal Message (Offline)

Ignore
1715537188
Reply with quote  #2

1715537188
Report to moderator
1715537188
Hero Member
*
Offline Offline

Posts: 1715537188

View Profile Personal Message (Offline)

Ignore
1715537188
Reply with quote  #2

1715537188
Report to moderator
1715537188
Hero Member
*
Offline Offline

Posts: 1715537188

View Profile Personal Message (Offline)

Ignore
1715537188
Reply with quote  #2

1715537188
Report to moderator
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4172
Merit: 8420



View Profile WWW
February 19, 2015, 06:59:46 PM
 #2

Getblocktemplate is working correctly there.

Getdifficulty is telling you the difficulty of the prior block. "Difficulty" is not an interface that is suitable for use in mining, its fundamentally imprecise. It's a human friendly number for display.
fireduck (OP)
Sr. Member
****
Offline Offline

Activity: 392
Merit: 251



View Profile
February 19, 2015, 08:16:52 PM
 #3

If it is indeed working correctly, why do all the recent found blocks have a much higher hash than the target I am seeing (both before and after the block is found)?

    "previousblockhash" : "00000000680260e45f57f0cdbe264366aa5095b4b60cbdf47b3a89b416b5d228",
    "previousblockhash" : "00000000b76a0528040b33a15c474261c799ac626fcc889754d01e37f0351a36",

    "target" : "00000000000003a2d80000000000000000000000000000000000000000000000",


Looking at the recent blocks, it appears they are coming in almost exactly every 20 minutes.  I imagine the code that drops the difficulty (in testnet) if there are no blocks takes effect then.  Maybe the node finding them has a clock set a few seconds ahead such that it sees the 20 minutes elapsed and makes a new block before I see the difficulty adjustment.  I'm checking every second and am not seeing the window.

Bitrated user: fireduck.
fireduck (OP)
Sr. Member
****
Offline Offline

Activity: 392
Merit: 251



View Profile
February 19, 2015, 10:00:14 PM
 #4

I'm pretty sure there is some bug somewhere in the block template caching relative to the testnet special difficulty after 20 minutes.

I just generated a block by commenting out a line.

pow.cpp
GetNextWorkRequired

I commented out this line:
if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + Params().TargetSpacing()*2)

In my testing, the difference between
pindexLast->GetBlockTime() and pblock->GetBlockTime() is always 6004.

My guess is that something is creating a template block and then not updating it because there are no new transactions and because the next target hasn't changed.  And the next target isn't changing because the block time is never changing.

But some of that is guesswork and I'm not sure.

Bitrated user: fireduck.
fireduck (OP)
Sr. Member
****
Offline Offline

Activity: 392
Merit: 251



View Profile
February 19, 2015, 10:26:21 PM
 #5

It is also possible that everything is fine, and jerks are just generating testnet blocks two hours in the future to mess with me.


Bitrated user: fireduck.
gmaxwell
Moderator
Legendary
*
expert
Online Online

Activity: 4172
Merit: 8420



View Profile WWW
February 19, 2015, 11:02:59 PM
 #6

It is also possible that everything is fine, and jerks are just generating testnet blocks two hours in the future to mess with me.
Well, not to mess with you but because they can. Of course, if you generate a single block at the full difficulty you'll reorg out a wad of those blocks that came after you... so they shouldn't be blocking you from mining, only potentially from mining at difficulty 1.
fireduck (OP)
Sr. Member
****
Offline Offline

Activity: 392
Merit: 251



View Profile
February 19, 2015, 11:43:05 PM
 #7

It is also possible that everything is fine, and jerks are just generating testnet blocks two hours in the future to mess with me.
Well, not to mess with you but because they can. Of course, if you generate a single block at the full difficulty you'll reorg out a wad of those blocks that came after you... so they shouldn't be blocking you from mining, only potentially from mining at difficulty 1.

Sure.  I've managed to do the testing I intended by accidentally having my node misbehave enough to isolate itself from the network and then build some blocks on my own side chain.


Bitrated user: fireduck.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!