<p>Contrary to popular belief, the longer blockchain is not the one with the most blocks. Rather it is the blockchain which has the most proof of work. Each block has a field for indicating the difficulty (i.e. work) for that block. The longest blockchain is the one that has the largest sum of these difficulty fields. The only way for a fork to overtake the current blockchain and replace it with the fork is if the miners on the fork have equal to or greater hashrate than the miners on the current blockchain. Otherwise the miners on that fork won't be doing as much work as the miners on the current blockchain so they can never overtake the blockchain.</p>

CC BY-SA 3.0
2017-06-18T22:14:02.843Z
That is a very good point, thanks. How about other changes to the protocol? For example something minor. Is it possible that most miners have made some changes to it but the network simply doesn't know because from their point of view everything is normal? In other words, is there any consensus mechanism for the protocol? (I haven't come across anything like that reading around)
tsotsi
CC BY-SA 3.0
2017-06-18T22:18:33.447Z
What you are describing here is a soft fork. A soft fork is something that changes the consensus rules without breaking backwards compatibility. These forks only require miners to upgrade, whereas any other consensus change requires everyone (nodes, wallets, etc.) to upgrade. However soft forks are limited in what they can do as they must be backwards compatible. They can only make something that was previously valid, invalid.
Ava Chow
CC BY-SA 3.0
2017-06-18T22:19:16.283Z
@tsotsi If miners produce blocks that violate consensus rules, their blocks are ignored by nodes. Is there a consensus mechanism for the protocol: yes, politics.
Pieter Wuille
CC BY-SA 3.0
2017-06-19T05:47:22.047Z
@AndrewChow Is it a correct statement to make "the longest chain(with the most blocks) must have the highest PoW backing it" because other forks violating the current difficulty parameters will not be compatible with the existing chain
sanket1729
CC BY-SA 3.0
2017-06-19T06:34:49.340Z
@Sanket Kanjalkar Yes
Ava Chow
CC BY-SA 4.0
2022-10-09T08:33:23.433Z
@AndreChow Say at time T1, the chain is n blocks long and the (n+1)th is being mined with a difficulty d. Suppose miner M1 mines it first, and then proceeds to start mining (n+2)th block. 
What happens if miner M2 (at the same time M1 has started mining n+1 th block i.e at T1) starts mining the n+1 th block , but with a modified difficulty of d+1.
Now, even if M2 would be slower (than M1) in mining the (n+1)th block, would its version of blockchain trump the other ones because it has a bigger POW because its difficulty for N=1th block was d+1 as compared to d for other chain ?
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T02:33:35.093Z
@ShariqHasanKhan Miners do not get to choose the difficulty of their blocks, so this generally cannot happen. For a given blockchain, the difficulty of the next block can always be calculated. This is how all nodes can be in consensus with each other on the difficulty of the next block. However the scenario you describe would be possible if n+1 was the last in a difficulty period and a race. Then n+2 may have a different difficulty depending on the timestamp of n+1. If the variation were large enough, and M2's n+2 had a higher difficulty, then it would immediately overtake M1's n+2.
Ava Chow
CC BY-SA 4.0
2022-10-10T02:36:36.433Z
But I'm not sure that's a scenario that can actually happen as the "difficulty" in blocks is actually rounded, and I don't think a single block can introduce enough variation to get past the rounding. Also, if M2 were slower to mine n+2, then M1 may have already found n+3, or could find n+3 soon after M2 publishes n+2, thereby likely overtaking M2.
Ava Chow
CC BY-SA 4.0
2022-10-10T06:49:26.260Z
@AndrewChow Sorry, I should have made it clear that I was talking about the case when M2 modified his software to change the difficulty. That's possible, right?
Also, in the case where (n+1)th block is at the beginning of the difficulty period D, M1 Is mining (n+1)th block with difficulty D and M2 is mining the same (n+1)th block with difficulty D+x where x is a sufficiently small increment.
M1 would mine (n+1)th block faster than M2, but not so fast that it is also able to mine (n+2)th block before M2 is done with the (n+1)th block.
Is this possible?
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-10T17:38:49.900Z
@ShariqHasanKhan No, miners cannot change the difficulty, otherwise they will not be in consensus with everyone else and their block will be invalid.
Ava Chow
CC BY-SA 4.0
2022-10-11T13:05:37.710Z
@AndrewChow How do nodes check whether the difficulty is in consensus? My understanding is the nodes check an incoming chain and check for its validity and POW length and they accept the longer one. How would they know whether the longer POW chain has a difficulty that has been modified?
Shariq Hasan Khan
CC BY-SA 4.0
2022-10-11T16:32:43.973Z
@ShariqHasanKhan Block headers contain a compact representation of the target that the block hash must be less than. This is the representation of the difficulty. This target can be computed to given all of the previous blocks in the blockchain, and so nodes will compute the expected target for the next block and make sure that it has that target in the header. Computing the total work for a chain is done by summing these targets, not the actual block hashes.
Ava Chow
CC BY-SA 4.0
2022-10-11T17:22:40.147Z
@AndrewChow That makes sense. Thank you for humoring my queries.
Shariq Hasan Khan
CC BY-SA 3.0
2017-06-18T22:04:56.393Z
2017-06-18T22:04:56.393Z
Ava Chow
<p>The rest of the network, which uses the existing difficulty parameters, will reject the new blocks generated by your modified miners. There will be a longer blockchain, but there will not be a longer <em>valid</em> blockchain according to the established rules.</p>

CC BY-SA 3.0
2017-06-24T11:41:27.557Z
As soon as they use an incorrect difficulty on even a single block, nobody else will accept that block or any block after it ... ever.
David Schwartz
CC BY-SA 3.0
2017-06-18T21:55:51.920Z
2017-06-18T21:55:51.920Z
Greg Hewgill
<p>How about a scenario where a few miners change their protocols by setting difficulty to something easy. Let's take it to the extreme and say they are able to accept any block. </p>

<p>They would keep publishing blocks which they think are valid and those would get rejected by the network. What if more miners start joining that scheme though (by changing their protocols)? </p>

<p>Because they are able to publish blocks extremely quickly (because they set their difficulty low) they might actually be able to compete with the whole network and their branch might overtake the network branch even if they are not that many of them.</p>

<p>What am I missing here?</p>

<blockchain><difficulty><majority-attack><consensus>
Why wouldn't miners change the protocol? (e.g. change difficulty)
tsotsi
# Why wouldn't miners change the protocol? (e.g. change difficulty)

(Asked by: username_0 on 2017-06-18)

How about a scenario where a few miners change their protocols by setting difficulty to something easy. Let's take it to the extreme and say they are able to accept any block.

They would keep publishing blocks which they think are valid and those would get rejected by the network. What if more miners start joining that scheme though (by changing their protocols)?

Because they are able to publish blocks extremely quickly (because they set their difficulty low) they might actually be able to compete with the whole network and their branch might overtake the network branch even if they are not that many of them.

What am I missing here?

**Tags:** blockchain, difficulty, majority-attack, consensus


---

## 2 answers

### Answer by username_1 on 2017-06-18. Score: 1 | Accepted answer

Contrary to popular belief, the longer blockchain is not the one with the most blocks. Rather it is the blockchain which has the most proof of work. Each block has a field for indicating the difficulty (i.e. work) for that block. The longest blockchain is the one that has the largest sum of these difficulty fields. The only way for a fork to overtake the current blockchain and replace it with the fork is if the miners on the fork have equal to or greater hashrate than the miners on the current blockchain. Otherwise the miners on that fork won't be doing as much work as the miners on the current blockchain so they can never overtake the blockchain.

> **Comments:**
> **username_0**: That is a very good point, thanks. How about other changes to the protocol? For example something minor. Is it possible that most miners have made some changes to it but the network simply doesn't know because from their point of view everything is normal? In other words, is there any consensus mechanism for the protocol? (I haven't come across anything like that reading around)  
> **username_1**: What you are describing here is a soft fork. A soft fork is something that changes the consensus rules without breaking backwards compatibility. These forks only require miners to upgrade, whereas any other consensus change requires everyone (nodes, wallets, etc.) to upgrade. However soft forks are limited in what they can do as they must be backwards compatible. They can only make something that was previously valid, invalid.  
> **username_2**: @username_0 If miners produce blocks that violate consensus rules, their blocks are ignored by nodes. Is there a consensus mechanism for the protocol: yes, politics.  
> **username_3**: @AndrewChow Is it a correct statement to make "the longest chain(with the most blocks) must have the highest PoW backing it" because other forks violating the current difficulty parameters will not be compatible with the existing chain  
> **username_1**: @Sanket Kanjalkar Yes  
> **username_4**: @AndreChow Say at time T1, the chain is n blocks long and the (n+1)th is being mined with a difficulty d. Suppose miner M1 mines it first, and then proceeds to start mining (n+2)th block.  What happens if miner M2 (at the same time M1 has started mining n+1 th block i.e at T1) starts mining the n+1 th block , but with a modified difficulty of d+1. Now, even if M2 would be slower (than M1) in mining the (n+1)th block, would its version of blockchain trump the other ones because it has a bigger POW because its difficulty for N=1th block was d+1 as compared to d for other chain ?  
> **username_1**: @username_4 Miners do not get to choose the difficulty of their blocks, so this generally cannot happen. For a given blockchain, the difficulty of the next block can always be calculated. This is how all nodes can be in consensus with each other on the difficulty of the next block. However the scenario you describe would be possible if n+1 was the last in a difficulty period and a race. Then n+2 may have a different difficulty depending on the timestamp of n+1. If the variation were large enough, and M2's n+2 had a higher difficulty, then it would immediately overtake M1's n+2.  
> **username_1**: But I'm not sure that's a scenario that can actually happen as the "difficulty" in blocks is actually rounded, and I don't think a single block can introduce enough variation to get past the rounding. Also, if M2 were slower to mine n+2, then M1 may have already found n+3, or could find n+3 soon after M2 publishes n+2, thereby likely overtaking M2.  
> **username_4**: @AndrewChow Sorry, I should have made it clear that I was talking about the case when M2 modified his software to change the difficulty. That's possible, right? Also, in the case where (n+1)th block is at the beginning of the difficulty period D, M1 Is mining (n+1)th block with difficulty D and M2 is mining the same (n+1)th block with difficulty D+x where x is a sufficiently small increment. M1 would mine (n+1)th block faster than M2, but not so fast that it is also able to mine (n+2)th block before M2 is done with the (n+1)th block. Is this possible?  
> **username_1**: @username_4 No, miners cannot change the difficulty, otherwise they will not be in consensus with everyone else and their block will be invalid.  
> **username_4**: @AndrewChow How do nodes check whether the difficulty is in consensus? My understanding is the nodes check an incoming chain and check for its validity and POW length and they accept the longer one. How would they know whether the longer POW chain has a difficulty that has been modified?  
> **username_1**: @username_4 Block headers contain a compact representation of the target that the block hash must be less than. This is the representation of the difficulty. This target can be computed to given all of the previous blocks in the blockchain, and so nodes will compute the expected target for the next block and make sure that it has that target in the header. Computing the total work for a chain is done by summing these targets, not the actual block hashes.  
> **username_4**: @AndrewChow That makes sense. Thank you for humoring my queries.  

---

### Answer by username_5 on 2017-06-18. Score: 4

The rest of the network, which uses the existing difficulty parameters, will reject the new blocks generated by your modified miners. There will be a longer blockchain, but there will not be a longer *valid* blockchain according to the established rules.

> **Comments:**
> **username_6**: As soon as they use an incorrect difficulty on even a single block, nobody else will accept that block or any block after it ... ever.  

---

