Bitcoin Forum
March 29, 2024, 09:23:01 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Exact definition of POW  (Read 882 times)
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1077


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
1711704181
Hero Member
*
Offline Offline

Posts: 1711704181

View Profile Personal Message (Offline)

Ignore
1711704181
Reply with quote  #2

1711704181
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1711704181
Hero Member
*
Offline Offline

Posts: 1711704181

View Profile Personal Message (Offline)

Ignore
1711704181
Reply with quote  #2

1711704181
Report to moderator
1711704181
Hero Member
*
Offline Offline

Posts: 1711704181

View Profile Personal Message (Offline)

Ignore
1711704181
Reply with quote  #2

1711704181
Report to moderator
1711704181
Hero Member
*
Offline Offline

Posts: 1711704181

View Profile Personal Message (Offline)

Ignore
1711704181
Reply with quote  #2

1711704181
Report to moderator
MatthewLM
Legendary
*
Offline Offline

Activity: 1190
Merit: 1004


View Profile
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
leijurv
Member
**
Offline Offline

Activity: 63
Merit: 10


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
Legendary
*
Offline Offline

Activity: 2058
Merit: 1431



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.

Adblock for annoying signature ads | Enhanced Merit UI
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1077


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
Merit: 1024



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.

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1077


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
Merit: 1024



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,

17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8
I routinely ignore posters with paid advertising in their sigs.  You should too.
TierNolan (OP)
Legendary
*
Offline Offline

Activity: 1232
Merit: 1077


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: 1190
Merit: 1004


View Profile
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.
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!