Bitcoin Forum
May 06, 2024, 06:37:10 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Why does the difficulty adjust every 2016 blocks? Why not every block?  (Read 1927 times)
The Fool (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
February 09, 2013, 05:26:38 AM
 #1

What would happen if difficulty readjusted every block to make sure every block was resolved in 10 minutes time?
1715020630
Hero Member
*
Offline Offline

Posts: 1715020630

View Profile Personal Message (Offline)

Ignore
1715020630
Reply with quote  #2

1715020630
Report to moderator
1715020630
Hero Member
*
Offline Offline

Posts: 1715020630

View Profile Personal Message (Offline)

Ignore
1715020630
Reply with quote  #2

1715020630
Report to moderator
1715020630
Hero Member
*
Offline Offline

Posts: 1715020630

View Profile Personal Message (Offline)

Ignore
1715020630
Reply with quote  #2

1715020630
Report to moderator
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715020630
Hero Member
*
Offline Offline

Posts: 1715020630

View Profile Personal Message (Offline)

Ignore
1715020630
Reply with quote  #2

1715020630
Report to moderator
odolvlobo
Legendary
*
Offline Offline

Activity: 4298
Merit: 3214



View Profile
February 09, 2013, 05:51:09 AM
 #2

The difficulty determines the expected amount of time. The actual amount of time to produce a block is random. So, even if it were feasible, adjusting the difficulty every block would not ensure that the blocks are produced exactly every 10 minutes.

Join an anti-signature campaign: Click ignore on the members of signature campaigns.
PGP Fingerprint: 6B6BC26599EC24EF7E29A405EAF050539D0B2925 Signing address: 13GAVJo8YaAuenj6keiEykwxWUZ7jMoSLt
The Fool (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
February 09, 2013, 05:57:52 AM
 #3

The difficulty determines the expected amount of time. The actual amount of time to produce a block is random. So, even if it were feasible, adjusting the difficulty every block would not ensure that the blocks are produced exactly every 10 minutes.
So, if bitcoin were to check every block would it break? Would it be usable at all?
Jutarul
Donator
Legendary
*
Offline Offline

Activity: 994
Merit: 1000



View Profile
February 09, 2013, 06:32:38 AM
 #4

The difficulty determines the expected amount of time. The actual amount of time to produce a block is random. So, even if it were feasible, adjusting the difficulty every block would not ensure that the blocks are produced exactly every 10 minutes.
So, if bitcoin were to check every block would it break? Would it be usable at all?
It checks every block, but adjusts only every 2 weeks. Good averaging requires a significant sampling size (>1000).

However, it could also be a running averaging. See the difficulty adjustment for ppcoin.

The ASICMINER Project https://bitcointalk.org/index.php?topic=99497.0
"The way you solve things is by making it politically profitable for the wrong people to do the right thing.", Milton Friedman
The Fool (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
February 09, 2013, 06:47:15 AM
 #5

The difficulty determines the expected amount of time. The actual amount of time to produce a block is random. So, even if it were feasible, adjusting the difficulty every block would not ensure that the blocks are produced exactly every 10 minutes.
So, if bitcoin were to check every block would it break? Would it be usable at all?
It checks every block, but adjusts only every 2 weeks. Good averaging requires a significant sampling size (>1000).

However, it could also be a running averaging. See the difficulty adjustment for ppcoin.
Thank you. However, my question is this: What would happen if it adjusted with every block? Would bitcoin break?
FreeMoney
Legendary
*
Offline Offline

Activity: 1246
Merit: 1014


Strength in numbers


View Profile WWW
February 09, 2013, 07:05:46 AM
 #6

As the rules are now people can enter their own timestamp on a block up to some distance from other nearby blocks. Over 2016 blocks inaccuracies of an hour or so don't matter, but it would be severe if we changed the difficulty every block. There are even blocks with timestamps before the blocks that they come after, what would difficulty be then?

Play Bitcoin Poker at sealswithclubs.eu. We're active and open to everyone.
The Fool (OP)
Newbie
*
Offline Offline

Activity: 56
Merit: 0


View Profile
February 09, 2013, 07:25:02 AM
 #7

As the rules are now people can enter their own timestamp on a block up to some distance from other nearby blocks. Over 2016 blocks inaccuracies of an hour or so don't matter, but it would be severe if we changed the difficulty every block. There are even blocks with timestamps before the blocks that they come after, what would difficulty be then?
Let's change the valid timestamp. Every timestamp has to be greater than the previous block's time and less than the network-adjusted time + 10 minutes. What happens then?

Thank you all for your help.
eleuthria
Legendary
*
Offline Offline

Activity: 1750
Merit: 1007



View Profile
February 09, 2013, 07:41:08 AM
 #8

As the rules are now people can enter their own timestamp on a block up to some distance from other nearby blocks. Over 2016 blocks inaccuracies of an hour or so don't matter, but it would be severe if we changed the difficulty every block. There are even blocks with timestamps before the blocks that they come after, what would difficulty be then?
Let's change the valid timestamp. Every timestamp has to be greater than the previous block's time and less than the network-adjusted time + 10 minutes. What happens then?

Thank you all for your help.

Your solution is impossible, since there is no guarantee of blocks being generated within 10 minutes, and forcing timestamps to show up as if they were 10 minutes apart would just be putting purposely bad information into the block headers.

As for the main question, there is still the massive problem of luck.  Creating a block is a purely random process.  If you've never looked yourself, you should leave blockchain.info up on your screen one day and take note of the varying time between blocks.  Some blocks are generated within seconds of each other, while other blocks have an hour gap between them.  This isn't the result of network hash rate growing/shrinking, just the standard variance associated with mining, spread across the entire network.

The only way to "guarantee" a block is made within 10 minutes would be to set the difficulty so absurdly low that blocks average LESS than 30 seconds.  It is not impossible for a block to take more than 20x the expected amount of work to be completed.

RIP BTC Guild, April 2011 - June 2015
FreeMoney
Legendary
*
Offline Offline

Activity: 1246
Merit: 1014


Strength in numbers


View Profile WWW
February 09, 2013, 07:49:41 AM
 #9

Even if you solve the pick-your-own timestamp issue which is far from trivial, like eleuthria says, you would just get wildly fluctuating difficulty. Sometimes you'll find blocks within 1 second of each other and difficulty will go up 600x or more, then since it will take so long to find that high difficulty block (much worse than you expect because many miners will just turn off) that you'll have a very low difficulty next year when someone finds that block and difficulty will go way down, then BAM next block found and sky high difficulty again.

Adjusting every block is not workable, but I wonder how fast it could be and still be mostly ok. Intuitively daily doesn't seem like it would be a problem, but you would have more fluctuations than now and I don't see the benefit. Anywhere from 1 week to 2 months seems ok, except if you pick something like 2 months and there is a big slowdown it could take a multiple of that to get to the next adjustment, that seems bad.

Play Bitcoin Poker at sealswithclubs.eu. We're active and open to everyone.
wabber
Member
**
Offline Offline

Activity: 85
Merit: 10


View Profile
February 09, 2013, 08:49:17 AM
 #10

Well it was said already that the 10mins are the average time needed to find a block. But let me put it in some more understandable analogy.
Think of the difficulty as the sided of a dice. All sides are black except one which is white.
Now you roll the dice, white means you have found a block and black means you didn't.
Let's assume you can only roll the dice once per minute. If the dice has 6 sides you have a chance of 1/6 to find a block every minute. So in average you need 6 minutes to find a block.
But it's also possible that you get the white side on the first try, which means you can also find a block in one minute.

If you are able to somehow increase your speed and you can roll the dice twice a minute now then you would get a block every 3 minutes in average. But if we want the generation time to be constant we need to increase the difficulty which means we take a dice with 12 sides and the generation time is back to 6 minutes in average.

As you can see it's pretty easy to set the difficulty if the global hash rate of the network is known. The problem is that we actually can't know about the hash rate directly, but we do know the elapsed time since the last block was found. Combined with the current difficulty that's enough to calculate the hash rate. But there is a very high error rate. Let's go back to our analogy. Imagine you set the difficulty after every found block(which is what you wanted to know about), then with a dice with 6 sides it's actually pretty common to get the white side on the first try. The Network only knows that we found a block after 1 minute with a difficulty of 6. The Network wants to have a constant rate of 6 minutes per block which is why the difficulty gets adjusted to 36. As you can see the difficulty was multiplied by 6 although our hash rate didn't really change.

The solution for the problem is to average between block generations. If the number of blocks to average is too high, the difficulty will stay on the same level for too long. But if it's too low we will have huge difficulty jumps.

So changing the difficulty after every block would work, but it would be a mess because of the jumping difficulty. However as already said "running averaging" would also be an option. But I think we can agree on that the current system works just fine.
Nancarrow
Hero Member
*****
Offline Offline

Activity: 492
Merit: 500


View Profile
February 10, 2013, 11:01:00 AM
 #11

Even if you solve the pick-your-own timestamp issue which is far from trivial, like eleuthria says, you would just get wildly fluctuating difficulty. Sometimes you'll find blocks within 1 second of each other and difficulty will go up 600x or more, then since it will take so long to find that high difficulty block (much worse than you expect because many miners will just turn off) that you'll have a very low difficulty next year when someone finds that block and difficulty will go way down, then BAM next block found and sky high difficulty again.

But even if we adjust the difficulty every block, that doesn't mean it has to be calculated solely with respect to the previous block. As someone else said upthread, you could keep a moving average of, say the last 200 blocks. That would smooth things out.

But I can see the OPs proposal being a serious pain in the arse for miners (of whom I am one). As it is, you have to keep reassessing every two weeks or so, whether it is still profitable to mine. If the difficulty (and hence, payout on a share in a pool) changes every block that would make it a bit of a nightmare to calculate profitability. The incentive to mine would be reduced, and without miners Bitcoin can't work.

Hijiack: What I *do* think would have been a good idea would be for the block rewards to have decayed more smoothly, say every month instead of every four years. Then again, the sky didn't appear to fall last December, not even with those pesky Mayans egging it on.

If I've said anything amusing and/or informative and you're feeling generous:
1GNJq39NYtf7cn2QFZZuP5vmC1mTs63rEW
FreeMoney
Legendary
*
Offline Offline

Activity: 1246
Merit: 1014


Strength in numbers


View Profile WWW
February 10, 2013, 09:32:44 PM
 #12

Even if you solve the pick-your-own timestamp issue which is far from trivial, like eleuthria says, you would just get wildly fluctuating difficulty. Sometimes you'll find blocks within 1 second of each other and difficulty will go up 600x or more, then since it will take so long to find that high difficulty block (much worse than you expect because many miners will just turn off) that you'll have a very low difficulty next year when someone finds that block and difficulty will go way down, then BAM next block found and sky high difficulty again.

But even if we adjust the difficulty every block, that doesn't mean it has to be calculated solely with respect to the previous block. As someone else said upthread, you could keep a moving average of, say the last 200 blocks. That would smooth things out.

But I can see the OPs proposal being a serious pain in the arse for miners (of whom I am one). As it is, you have to keep reassessing every two weeks or so, whether it is still profitable to mine. If the difficulty (and hence, payout on a share in a pool) changes every block that would make it a bit of a nightmare to calculate profitability. The incentive to mine would be reduced, and without miners Bitcoin can't work.

Hijiack: What I *do* think would have been a good idea would be for the block rewards to have decayed more smoothly, say every month instead of every four years. Then again, the sky didn't appear to fall last December, not even with those pesky Mayans egging it on.

Ah, I overlooked continual readjusting based on a large number of blocks.

I don't think it would be that bad for miners turn-off decisions. If they really wanted to stop asap when difficulty reached a certain point that is trivial to code. As it is profitability already fluctuates in real time based on the bitcoin value.

Play Bitcoin Poker at sealswithclubs.eu. We're active and open to everyone.
FreeMoney
Legendary
*
Offline Offline

Activity: 1246
Merit: 1014


Strength in numbers


View Profile WWW
February 10, 2013, 09:43:36 PM
 #13

I have a feeling that Satoshi new he might be alone for a while and didn't want to "give himself" low difficulty and very high block rewards. I mean he did get to have highest ever block rewards, but at least he gave others 4 years to get in on that. 4 years was probably his "by then or never" guess.

Or maybe he figured we could use some free media every 4 years :-)

Play Bitcoin Poker at sealswithclubs.eu. We're active and open to everyone.
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!