Bitcoin Forum
October 23, 2017, 06:27:48 AM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Exact definition of POW  (Read 774 times)
TierNolan
Legendary
*
Offline Offline

Activity: 1120


View Profile
May 11, 2013, 12:01:42 AM
 #1

The POW for a block is equal to 1/target.  Is there an exact way to calculate it?  Presumably, it is an integer division and so approximate.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
1508740068
Hero Member
*
Offline Offline

Posts: 1508740068

View Profile Personal Message (Offline)

Ignore
1508740068
Reply with quote  #2

1508740068
Report to moderator
1508740068
Hero Member
*
Offline Offline

Posts: 1508740068

View Profile Personal Message (Offline)

Ignore
1508740068
Reply with quote  #2

1508740068
Report to moderator
1508740068
Hero Member
*
Offline Offline

Posts: 1508740068

View Profile Personal Message (Offline)

Ignore
1508740068
Reply with quote  #2

1508740068
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
MatthewLM
Legendary
*
Offline Offline

Activity: 1092



View Profile WWW
May 11, 2013, 12:21:58 AM
 #2

The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28

Bitcoin Extra Wallet | Peercoin Android Wallet
BTC: 1D5A1q5d192j5gYuWiP3CSE5fcaaZxe6E9  PPC: PH7fVn1Xs7nkUFmdwCX2ZRYfLPCSwGxAq9
leijurv
Member
**
Offline Offline

Activity: 63


Vires in Numeris


View Profile WWW
May 11, 2013, 12:25:55 AM
 #3

No... The POW of a block is the nonce which makes the hash below the target. It's not 1/target. Maybe you mean that one in every 2^256/target nonces will be below the target?

Firstbits 1Leijurv. Or, if you like cats, Firstbits 1Kittens and 1catcat as well. If you're a chemist, also 1Helium, 1Erbium, 1Copper, 1Cerium, and 1Nickel. If you like numbers, 123four, 12234,  12three.
Keybase and onename user: leijurv.
grue
Global Moderator
Legendary
*
Offline Offline

Activity: 2016



View Profile
May 11, 2013, 12:32:32 AM
 #4

The POW for a block is equal to 1/target.  Is there an exact way to calculate it?  Presumably, it is an integer division and so approximate.
floating point is approximate (rounding rules dependent on implementation and precision), integer division isn't.

It is pitch black. You are likely to be eaten by a grue.

Tired of annoying signature ads? Ad block for signatures
TierNolan
Legendary
*
Offline Offline

Activity: 1120


View Profile
May 11, 2013, 01:32:51 AM
 #5

The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28


Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
May 11, 2013, 02:59:14 AM
 #6

The proof-of-work  is a method/system for demonstrating that work has been done. I guess you mean the block work, ie. the number used as the extent to which work has been done. You can see how it is calculated in the satoshi client here: https://github.com/bitcoin/bitcoin/blob/33edd0a477f4448be9c6c4949fbff4e53f16cac6/src/main.h#L1725

No idea why it is in the header file.

In cbitcoin the calculation is a bit more complicated: https://github.com/MatthewLM/cbitcoin/blob/master/src/CBValidationFunctions.c#L28


Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.

Same?  Tie?

Work is based on the difficulty, not the hash.

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
TierNolan
Legendary
*
Offline Offline

Activity: 1120


View Profile
May 11, 2013, 07:16:35 AM
 #7

Same?  Tie?

Work is based on the difficulty, not the hash.

The point is that if you have a different formula for working out the POW per block, you could have 2 chains, where there is disagreement on which one has more POW.  However, as long as they are nearly the same, 1 - 2 blocks should move one ahead of the other.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
kjj
Legendary
*
Offline Offline

Activity: 1302



View Profile
May 11, 2013, 11:51:46 AM
 #8

Ahh, ok.  In that case, you need to look at the header.  The exact integer amount of work that a block is "worth" is encoded in the bits field.  The wiki page describes the format, and someone already posted a link into the actual source where the calculation is done.

If you are looking for the math that updates the expected next target once a 2016 block window has been completed, let me know.  I think it is in main.cpp, and I can find it, it is just annoying to do from this computer.  It basically calculates what the difficulty in the previous window should have been to get an average of 10 minutes per block.

Edit:  Oh, blocks that have the wrong difficulty in the header are rejected as invalid, so there won't be any subtle disagreements,

p2pcoin: a USB/CD/PXE p2pool miner - 1N8ZXx2cuMzqBYSK72X4DAy1UdDbZQNPLf - todo
I routinely ignore posters with paid advertising in their sigs.  You should too.
TierNolan
Legendary
*
Offline Offline

Activity: 1120


View Profile
May 11, 2013, 01:12:43 PM
 #9

If you are looking for the math that updates the expected next target once a 2016 block window has been completed, let me know.

I have read it before.  My memory is that it calculates the target, not the difficulty.  As you say the link gives the official definition.

(1 << 256) / (target + 1)

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
MatthewLM
Legendary
*
Offline Offline

Activity: 1092



View Profile WWW
May 11, 2013, 01:54:34 PM
 #10

Shouldn't it be the same?  I guess it doesn't matter much, since a tie isn't likely to last long.

The result is the same but the code is different.

The next target in the satoshi client is calculated here: https://github.com/bitcoin/bitcoin/blob/master/src/main.cpp#L1110

The "bits" field contains the claimed target for the block. The target is different than the block work, but the block work is derived from the target.

Bitcoin Extra Wallet | Peercoin Android Wallet
BTC: 1D5A1q5d192j5gYuWiP3CSE5fcaaZxe6E9  PPC: PH7fVn1Xs7nkUFmdwCX2ZRYfLPCSwGxAq9
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!