# The Mystery Behind Block Time. Block time defines the time it takes to… | by Prabath Siriwardena | FACILELOGIN

block time defines the time it takes to fetch a block. In both the bitcoin blockchain and the ethereum blockchain, there is an expected block time and an average block time. in bitcoin, the expected block time is 10 minutes, while in ethereum it is 10 to 19 seconds. Both bitcoin and ethereum, at the time of writing, use a proof-of-work based distributed consensus algorithm (ethereum is planned to move to a proof-of-stake based algorithm with its **serenity** version). the expected block time is set to a constant value to ensure that miners cannot affect network security by adding more computing power. the average block time of the network is evaluated after **n** number of blocks, and if it is greater than the expected block time, then the difficulty level of the proof-of-work algorithm will be reduced, and if it is less than the expected block time, then the difficulty level will be increased. that’s the core design principle behind block time, but you’ll see as we go along how bitcoin and ethereum differ from each other.

**Maybe you are interested**

- What are Gas Fees and How Can We Fix Them?
- Will Ethereum and Bitcoin See the "Flippening" in 2022? | The Motley Fool
- Sources: OpenSea is in talks to acquire Dharma Labs, whose Ethereum wallet can transfer money between banks and exchanges, for 110M-130M in an all-stock deal (Kia Kokalitcheva/Axios) – Global Unshared News
- Gravity-Defying Ethereum Classic Faces Turbulence As Sibling Readies Gear Shift
- Ethereum post-merge staking rewards will likely be lower than anticipated

## difficulty level (bitcoin)

the level of difficulty varies over time, according to the following formula. tries to evaluate the speed of the mining network and find out how much it deviates from the expected level. the expectation is to mine a block in 10 minutes. for example, if the average mining speed of the last blocks of 2016 is 8 minutes, then the new difficulty factor will be greater than one, so the current difficulty level will increase. in case the average is greater than 10 minutes, the factor will be less than 1 and the difficulty level will be reduced for the next blocks of 2016. the difficulty level is re-evaluated every 2016 blocks, approximately every 2 weeks.

Reading: Ethereum block time

The figure below shows how the level of difficulty changed over time since the inception of bitcoin. In other words, the difficulty level reflects how difficult the proof-of-work calculation is relative to the difficulty value set at the beginning, which is 1. For example, the current difficulty is 678,760,110,083, which means that if we mine the blocks at the same hash rate, which was at the time of the first block, then it would take more than 678 billion times to mine a block with the current difficulty. But in practice, since the computational power used in bitcoin mining has improved tremendously, the time it takes to mine a block stays at a constant number (which is 10 minutes), as the difficulty level increases. During the first five years of bitcoin, the difficulty level increased from 1 to 50 billion.

in each block, in the header there is a parameter called **bits** — and in the genesis block the value of the bits is **486604799**. if we represent the same thing in hexadecimal it would be 1d00ffff. this is a compact format, which can be used to find the **target** hash value for this (current) block. in fact, the hash of this block must be less than or equal to the target. the **target** value is calculated only after the 2016 blocks, along with the difficulty level calculation, and once calculated, the next 2016 blocks will have the same value in their block header. **bits**. parameter.

**target = coefficient * 2^(8 * (exponent — 3))**

The first two digits of the hexadecimal value above are known as the **exponent**, which is 1d, and the next six digits (00ffff) are known as the **coefficient**. Now if we apply these values to the above function, it will look like the following.

Now, if we do the hexadecimal arithmetic of the above, we will find the value of **target** in hexadecimal. converted to decimal it would be **2.69 * 10 ^ 67** — and in binary it would be.

For clarity, since the block hash must be 256 bits, let’s also represent the target as 256 bits by adding leading zeros.

now the hash of the genesis block must be less than or equal to the previous one, which is:

As explained before, the difficulty of the genesis block is 1. After every 2016 blocks, the target is recalculated as follows.

**new_target = old_target / new_difficulty**, where the **old_target** is shown above (which is from the genesis block, in this case).

difficulty is calculated as follows:

for example, the new difficulty level for block 2017 is calculated as follows:

Let’s assume the average block time during the first blocks of 2016 is 8 minutes. this is just an assumption: in reality, the difficulty level of the bitcoin blockchain remained the same until block 32255, only changing from 1 to 1.18 at block 32256 (2016 x 16).

now if we add leading zeros to make the number 256 above, then the target will be:

See also : Paystand Raises 50M Series C to Build the Future of Commercial Finance | Business Wire

the new target is less than the old one, so the mining software has to find a nonce value, which makes the block hash less than or equal to the old one. when the computational power increases, the average block time decreases, and then the difficulty level increases by having a low target value. upcoming 2016 blocks will include in the block header the value of the new goal as the **bits** parameter and the value of the new difficulty level as the **difficulty** parameter.

How the difficulty level increases and how it is calculated is written into the mining software itself. if a miner wants to cheat the system by changing the rules on his own copy, of course he can. but that will make it isolated. once you cheat and then send the copy of the mined block to others, other legitimate miners validating the block will find that it was not done correctly and will reject it. the miner who cheats will automatically fall into his own copy of the blockchain.

## difficulty level (ethereum)

in ethereum, **homestead** version, the difficulty level is calculated as follows: ** //** indicates integer division and **2**** denotes the two to the power. the **int** function returns the largest integer less than or equal to a given number.

If you look at the formula above, it has two main parts. the first part to determine how much the block time deviates from the expected block time (10 to 19 seconds). this will find a **parent_block_difficulty** factor, based on how long it took to mine the current block. if the current block is mined faster, in less than 10 seconds, then this factor will be a positive number, increasing the difficulty. if the lock time is between 10 and 19 seconds (both inclusive), there will be no change in difficulty. will result in a negative value when the lockout time is greater than or equal to 20 seconds, and the difficulty will decrease (but will still have the impact of the difficulty bomb, which we’ll talk about later).

Let’s look at each of the above cases in detail and see how the above formula is reduced.

if block_time is less than 10 seconds, the above equation will reduce to (eg: block_time// 10 → 8//10 → 0):

if block_time is between 10 and 19 seconds, then the above equation will reduce to (for example: block_time// 10 → 12//10 → 1):

if block_time is greater than or equal to 20 seconds, then the above equation will reduce to (assuming it is less than 30 seconds, eg: block_time// 10 → 22//10 → 2):

the maximum down value occurs in this case, when block_time is equal to or greater than 1000 seconds, which is (for example: block_time// 10 → 1000//10 → 100):

The second part of the formula above is known as the **difficulty bomb**.

when **current_block_number** is less than 100000, the value of the above will be **int(2**(0 — 2)) or int(2**-2) or int ( 1/4) **which is 0, so there will be no impact on the difficulty level. when current_block_number is less than 200000 but greater than 100000, the value of the above will be **int(2**-2) or int(1/2) **which is again 0, so there is no impact . this will only affect if the block number is greater than 200000. say the block number is greater than 200000 but less than 300000, then **current_block_number // 100000 — ** will be 2 — so the value of the above will be **int(2**0) or int (1) **which is 1. so, the total difficulty will be.

for the current block number at the time of writing, which is 4356873, this second factor is, **int(2**41), **which is 2199023255552, where **( 4356873 / / 100000-2) → (43-2) →41**.

**note**: frontier, the initial release of ethereum, released in July 2015, aimed to keep ethereum’s lock time to around 12 seconds. the above discussion is related to the **homestead ** launch of ethereum, not the **frontier**. Below is the difficulty calculation used in **frontier**.

current_block_difficulty = parent_block_difficulty + (parent_block_difficulty // 2048) * (1 if parent_block_time_stamp — parent_block_time_stamp < 13 else -1) + int(2**((block.number // 100000) — 2))

the main difference between the difficulty level of bitcoin and ethereum is that, in bitcoin, the difficulty adjustment is done after 2016 blocks to keep the block time at a constant value (although the computational power increases) , but in ethereum, based on computational power, the block time will increase (or decrease) due to the difficulty of the bomb hit (without trying to keep it at a constant value), and the adjustment is done on each block. therefore, to keep the ethereum block time at a considerable level, the computational power must also increase over time (to match the difficulty bomb); otherwise it will be difficult to mine ethereum, resulting in a freeze of the ethereum blockchain; also known as **ice age**.

## the ethereum difficulty bomb

the ethereum difficulty bomb, which makes mining harder with a difficulty level that increases exponentially over time, was introduced to discourage miners from continuing with proof-of-work mining, when the **serenity** of ethereum is released in the future introduces proof of stake mining. the difficulty level was introduced with the first patch of ethereum **frontier**. frontier was the initial release of ethereum, released in July 2015.

See also : Hummer Miner E1 ETH Miner 780MH – MiningWatchdog

As we discussed in the previous section, below is the change (**bold**) made to ethereum’s difficulty algorithm to support the difficulty bomb:

Note that the algorithm above is based on the ethereum **homestead** release, not the **frontier** release, where the difficulty bomb was introduced. however, between these two releases, although the difficulty algorithm was changed, there was no change to the difficulty bomb part.

With changes to ethereum’s difficulty algorithm to support the difficulty bomb, starting at block 200,000 (around September 2015), the difficulty increased exponentially, but only became apparent about a year later. from that point on, there is a significant increase in difficulty that started to push up the block resolution time. as we go like this, due to harder mining targets, the network will still be useful for a few months or so, but it will eventually hit an **ice age**, where the difficulty will simply be too high for anyone . find a block the plan was to introduce proof of stake at that point with the launch of ethereum **serenity**.

As plans for the release of **serenity** were delayed, a hard fork is expected with the release of **byzantium** (still with proof of work), on the ethereum network , in a couple of days between 12:00 UTC and 13:00 UTC on Monday, October 16, 2017, in block number 4,370,000. byzantium is part of the **metropolis** ethereum development phase which includes two hard forks: **byzantium** and **constantinople**. Constantinople currently does not have a release date, but it is expected to be in 2018. With the EIP 649 proposal, which includes in **byzantium, **the ethereum difficulty bomb is further delayed. now the average lock time is 17.49 seconds and is slowly increasing due to the difficulty bomb. that discourages users/miners. this eip (ethereum improvement proposal) suggests delaying the difficulty bomb significantly, reducing the average block time below 15 seconds, and allowing more time for **serenity** development.

## why bitcoin block time is 10 minutes?

Bitcoin tries to keep its block time to around 10 minutes with its difficulty algorithm. why is it 10 minutes? why not 2 or 20 minutes? The earliest reference to having 10 minutes as the bitcoin block time comes from the original research paper, which introduced bitcoin in 2008, by satoshi nakamoto. has only one reference, and 10 minutes is not a concrete suggestion, but taken as an example.

a block header with no transactions would take about 80 bytes. if we assume that blocks are generated every 10 minutes, 80 bytes * 6 * 24 * 365 = 4.2mb per year. with computer systems typically shipping with 2gb ram as of 2008, and moore’s law predicting current growth of 1.2gb per year, storage shouldn’t be an issue even if block headers should stay in memory.

let’s say the block time is 2 minutes, and the average network latency to get that block to other miners on the bitcoin network is 1 minute (this is just an example, in practice it’s quite less than this). this latency value is independent of the block time. all miners in the network mine simultaneously and independently. let’s say everyone is mining block 3500 (let’s say everyone starts mining at time **t0**), and miner **tom** solves the puzzle first and broadcasts the block to the rest of miners at time **t0 + t, ** where **t** is the time it takes **tom** to mine block 3500. now **peter**, another average miner finds **tom**‘s block at (**t0 + t)+ 1, **because of the network latency of 1 minute. peter and all other miners, who complete the mining of the same block with **(delta_t)i **delay times, where ; (**t0 + t)< (t0 +t) + (delta_t)i < **(**t0 + t) + 1 **or can be reduced to **0< (delta_t)i< 1, they manage to solve the puzzle, but they waste all their energy, and all those blocks will be orphaned blocks with no mining rewards. the total waste of hashes on the entire network due to orphaned blocks would be:**

where **(delta_t)i** is the additional time from **t,** that the **i**th miner took before noticing the block mined by ** tom: **y **(hr)i** is the number of hashes per minute generated by the **i**th miner.

if we increase the difficulty by **p%**, then both **t** and **(delta_t)i** will increase, say the same **p1% **. as this increases **(delta_t)i**, the number of miners completing the mining where **(t0 +t) + (delta_t)i < **(**t0 + t) + 1 **will go down. so, in the wastage function above, the number of **i**s will decrease, so the wastage. Let’s see some examples with concrete values.

- if the value of
**t**is 2 minutes, then each miner that completes a block mining before a 3-minute time period (with a network latency of 1 minute) will only contribute to the waste (except the miner who finishes first and gets the reward). here you can see, there is a 50% time span that a miner can drop in this time frame. [ 50% = (3-2)/2 * 100] - if the value of
**t**is 4 minutes, then each miner who completes a block mining before 5 minutes (with 1 minute network latency) will only add to waste. here you can see, there is a 25% time span that a miner can drop in this time frame. [ 25% = (5-4)/4 * 100] - if the value of
**t**is 8 minutes, then each miner who completes a block mining before the 9 minutes (with 1 minute network latency) will only add to waste. here you can see, there is a 12.5% time span that a miner can fall into in this time frame. [ 12.5% = (9-8)/8 * 100] - if the value of
**t**is 10 minutes, then each miner that completes a block mining before 11 minutes (with 1 minute network latency) will only add to waste. here you can see, there is a 10% time span that a miner can drop in this time frame. [ 10% = (11-10)/10 * 100]

Now you can see that as the block time increases, the waste percentage decreases. Taking all other factors into account, Satoshi Nakamoto believes that the waste in the 10-minute time block is acceptable. Along with waste, if multiple nodes start generating the same block simultaneously or within a short period of time, this will lead to multiple and more frequent bitcoin forks. frequent people, it will make the bitcoin network less healthy and the transaction confirmation time will increase as everyone has to wait until the bitcoin network eventually becomes consistent.

**Note**: In the calculation above, 1 minute of network latency was taken as an example only to make calculations easier. A 2013 paper by Decker and Wattenhofer in Zurich measures the latency of the bitcoin network and finds that 12.6 seconds is the time it takes for a new block to propagate to 95% of the nodes.

## why is ethereum’s block time drastically less than bitcoin’s?

Ethereum’s average block time at the time of writing is around 17 seconds. If the story we built in the previous section is true, how would Ethereum reduce waste with such a low block time and also reduce the possibility of multiple and frequent forks? this is fixed with the modified version of the heavier and greedy observed **subtree (ghost)** protocol followed by ethereum. ghost is an innovation first introduced by yonatan sompolinsky and aviv zohar in december 2013, and is the first serious attempt to resolve the issues that prevent much faster block times.

As discussed in the previous section, the main challenge in a shorter block time is that there will be more miners producing the same block and they will end up with no economic incentive, and wasting a lot of computational power with no impact on stability addition, this will result in more frequent forks. when a fork occurs, the network continues to find the longest blockchain and all miners will switch to it. ghost solves this problem by including these stale/orphaned blocks in the calculation of finding which chain is the longest chain, and also rewarding them. on ethereum these blocks are known as **uncle** blocks. an uncle block receives a percentage of the normal block reward, so the computational power spent on mining the stale blocks is not wasted without economic incentive. so the question is, why isn’t it 1 second?

ethereum chooses the block time between 10 and 19 seconds because it is as fast as possible, but at the same time it is substantially longer than the network latency. A 2013 paper by Decker and Wattenhofer in Zurich measures the latency of the bitcoin network and finds that 12.6 seconds is the time it takes for a new block to propagate to 95% of the nodes; however, the document also notes that most of the propagation time is proportional to the block size.

Another reason is that, on ethereum, not all uncle blocks are rewarded, and the block time should not encourage more uncle blocks than can be rewarded. a block can include up to two guys. If a block references two guys, each guy will earn 7/8 of 5 eth for whoever mined that guy. Each referred dude will also earn a small reward per dude (1/32 of 5 eth) for the miner who references the guys in his block. as you can see from the way the reference works, you can go to an unlimited number of levels: one block refers to two blocks of guys, and one of those blocks of guys refers to two other blocks of guys, and one of those those uncle blocks refers to two other uncle blocks. , you too. on ethereum, a stale block can only be listed as an uncle by up to the 7th generation descendant of one of its direct siblings, and not any more distantly related block. this was done for various reasons [ref].

- unlimited ghost would include too much hassle in calculating which dudes for a given block are valid.
- unlimited dude incentive as used in ethereum removes the incentive for a miner to mine on the main chain and not a public attacker’s chain.
- Calculations show that restricting to seven levels provides most of the desired effect without many of the negative consequences.

## summary

block time defines the time it takes to fetch a block. In both the bitcoin blockchain and the ethereum blockchain, there is an expected block time and an average block time. in bitcoin, the expected block time is 10 minutes, while in ethereum it is 10 to 20 seconds. lock time is adjusted based on difficulty level. the main difference between the difficulty level of bitcoin and ethereum is that, in bitcoin, the difficulty adjustment is done after 2016 blocks to keep the block time at a constant value (although the computational power increases), but in ethereum, based on the power calculation, the block time will increase (or decrease) due to the difficulty bomb (without trying to keep it at a constant value), and the adjustment is made on each block.

Source: https://amajon.asia

Category: Ethereum

**
**