Bitcoin Forum
December 15, 2024, 08:19:47 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How is chain length calculated?  (Read 1008 times)
Hello1024 (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
June 08, 2011, 02:32:55 PM
 #1

If my understanding is correct, clients assume the currently longest chain is authoritative.  The chain with most peers working on it gets longer quicker, and therefore anyone on any other chain "switches" to the longest.  This is a clever way to ensure no "forks" exist for long.

Difficulty is calculated based on how many blocks have been calculated in the past week/2 weeks, to keep a global target of around 1 block every 10 mins.


If I were to start a new isolated firewalled bitcoin network, working from the same base block as the existing network, with only a single slow host working on it, the chain would still get longer by 1 block every 10 minutes, since the difficulty would adjust after 2 weeks to ensure this.

If I now tweak the system clock to go at double-speed, the difficulty will re-adjust to make generation yet easier, and a block will be generated every 5 minutes.  I now have the possibility for my chain to catch up and overtake the official one.  When this happens, I unfirewall my host, upload all my blocks to the network, and all the clients see my chain as longer, and therefore authorative.

How does the network protect against this?  Is the "chain length" actually a function of both difficulty and length in blocks?
Pieter Wuille
Legendary
*
qt
Offline Offline

Activity: 1072
Merit: 1189


View Profile WWW
June 08, 2011, 07:33:52 PM
 #2

The chain length is defined as the expected (in the statistical meaning) number of hashes performed to create it. This is proportional to the sum of the difficulties of all blocks.

I do Bitcoin stuff.
Hello1024 (OP)
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
June 09, 2011, 12:15:52 PM
 #3

That solves that mystery!  Thankyou.
Sukrim
Legendary
*
Offline Offline

Activity: 2618
Merit: 1007


View Profile
June 09, 2011, 12:32:03 PM
 #4

If I were to start a new isolated firewalled bitcoin network, working from the same base block as the existing network, with only a single slow host working on it, the chain would still get longer by 1 block every 10 minutes, since the difficulty would adjust after 2 weeks to ensure this.
Also difficulty changes only every 2016 blocks - not every 2 weeks. It is expected that hash rates grow/decrease within limits (= not moving from a few Terahashes/s to a few Megahashes/s in your example). also the new difficulty takes into consideration the average time it took to calculate the past 2016 blocks. For the difficulty to go down by 50%, the last 2016 blocks would need to be solved within 4 weeks, instead of 2.

The Bitcoin blockchain is essentially a global clock, where it is ensured more or less that it's hard enough for members to trigger a "tick" at the same time - and if they do, the network will solve it on it's own.

To be able to build a longer Blockchain than the official one, you need more hashing power than the rest of the network. This is also known as the "51% attack" and which is why people are currently worried that deepbit might become (again) big enough to do this in theory. In practice, deepbit will most likely NOT pull off a stunt like that, but it still poses some dangers and insecurities.

https://www.coinlend.org <-- automated lending at various exchanges.
https://www.bitfinex.com <-- Trade BTC for other currencies and vice versa.
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!