<p>No, each block must reference it's predecessor block in the header, and the blockchain has only a single block at each height. The second miner must therefore modify the block template that they are mining with to build on top of the just discovered block. They need to update the hash of the predecessor block and the blockchain height in the Coinbase transaction. Otherwise the block they would be finding would be competing with the just published for inclusion instead of writing forth the blockchain.</p>

<p>The rest of the block template could stay the same, if none of the transactions got included in the blockchain already.</p>

<p>However, your question sounds to me like you're thinking that searching for a block has progress. Mining is a progress-less process, each attempt may or may not succeed independently. Thus, it would be a more profitable strategy for each miner to try including the juiciest transactions (by highest fee rate) and to switch to a new block template whenever a block is published with the new juiciest transactions.</p>

CC BY-SA 4.0
2018-05-04T17:00:28.577Z
2018-05-04T17:00:28.577Z
Murch
<p>Oh, the irony... I JUST answered the exact same question on Stackoverflow. I'll copy the answer here:</p>

<p>You can imagine two competing miners creating blocks. If a miner doesn't have block N, he'll keep trying to mine that block. If he receives block number N after having mined it, the miner just ignores it, and we have a temporary fork in the blockchain with two branches, and block N+1 will have two different versions. Now what determines which branch survives is basically the branch that is mined faster. An arbitrary consensus rule is that the longer chain is always the correct chain. When a longer chain exists, all miners agree that this chain is the correct one.</p>

<p>The reason why this works, is because the probability of mining a block is wide enough over 10 minutes in Bitcoin (or block time in general).</p>

<p>The following image can be seen as the probability of mining a block over time (in bitcoin).</p>

<p><a href="https://i.sstatic.net/um2Nu.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/um2Nu.png" alt="Probability of mining a block over some time"></a></p>

<p>This is why it's wrong to create blockchains with very short time. Because if the time is very short (like 10 seconds), there will be tons of forks before the blockchain stabilizes.</p>

CC BY-SA 3.0
2018-03-20T16:02:52.723Z
Thank you for the insight. I do not think this answers my question. I am aware of what happens during a fork and how the network resolves it. My question is regarding whether a fork will happen if miner 1 and 2 are mining two independent blocks. And miner one adds his block, can miner two updates his chain and continue mining is same block as there are no conflicts?
Kyle Graham
CC BY-SA 3.0
2018-03-20T16:15:24.110Z
@Kyle Branches are completely independent and don't have any relations. The only requirement is that each branch is consistent. One of them will die.
The Quantum Physicist
CC BY-SA 3.0
2018-03-20T16:19:47.223Z
Are branches the same as forks? I am not sure I quite understand what you just said.
Kyle Graham
CC BY-SA 3.0
2018-03-20T16:23:40.267Z
@Kyle a fork has multiple branches.
The Quantum Physicist
CC BY-SA 3.0
2018-03-20T16:40:40.320Z
How can a fork have multiple branches?If I am not mistaken, when the bitcoin network branches, it creates a fork? I have not heard of the term "branch" before, I am new so still ignorant. Please correct me where I am wrong
Kyle Graham
CC BY-SA 3.0
2018-03-20T16:58:17.180Z
You're confused with terminology. First, keep in mind that I'm **not** talking about protocol forks, like Bitcoin Cash. I'm talking about temporary blochchain forks due to mining (please read my answer again). A fork is the action of creating multiple branches, which looks like the fork you have in a kitchen. Topologically speaking (shape-wise), a fork has branches, and every branch can have a fork that has more branches.
The Quantum Physicist
CC BY-SA 3.0
2018-03-20T15:40:04.427Z
2018-03-20T15:40:04.427Z
The Quantum Physicist
<p>Not really.</p>

<blockquote>
  <p>two sees that the block had nothing to do with his block, so he
  continues mining and adds that block onto mine</p>
</blockquote>

<p>Once a miner sees an arrival of a block at the same height for which he himself is mining, it's end of the competition for that block. There is no point continuing mining.</p>

<p>However in event of miners creating simultaneous blocks, the forks would happen</p>

<blockquote>
  <p>I am assuming that forks only happen when both blocks mined have
  transactions that exist in both blocks</p>
</blockquote>

<p>Miner should remove the transactions from memory pool which are already present in newly arrived block and start the mining for a fresh block</p>

CC BY-SA 3.0
2018-04-10T17:14:45.970Z
2018-04-10T17:14:45.970Z
Happy ITWala
<p>After reading  pebwindkraft comment, I have come up with an answer.</p>

<p>The particular extract "To resolve this, each node always selects and attempts to extend the chain of blocks that represents the most Proof-of-Work, also known as the longest chain or greatest cumulative work chain"</p>

<p>If the blockchain was currently:</p>

<p>Block1 -> Block2 -> Block3</p>

<p>And two miners pick from the mempool, transactions that do not overlap. Then this will cause a fork in the blockchain, if both broadcast at the same time.</p>

<p>This is because, even though the transaction do not overlap, the blockhash would be different for each miner, and if the blockhash is different then this is two different versions of the blockchain. Even if the transactions do not overlap.</p>

<p>If miner1 broadcasts first, then miner2 will have to start his block again, even though all transactions in miner1's block did not clash with miner2's. This is because as soon as miner1 adds to the blockchain. The chain becomes:</p>

<p>Block1 -> Block2 -> Block3->Block4</p>

<p>Where Block4 is miner1s block.</p>

<p>Miner2 has to start again because in his block, he was using the previous hash of block3, he now has to change it block4's hash.</p>

<p>If I have made a mistake, drop a comment instead of downvoting as I would like to know where I went wrong.</p>

CC BY-SA 3.0
2018-03-20T17:54:49.457Z
2018-03-20T17:54:49.457Z
Kyle Graham
<p>If two miners picked from the mempool two different sets of transactions, that were not dependent on each other. </p>

<p>Then could both miners, mine both blocks and not create a fork?</p>

<p>So miner 1 finishes the block and miner two sees that the block had nothing to do with his block, so he continues mining and adds that block onto miner 1s block after about a second?</p>

<p>I am assuming that forks only happen when both blocks mined have transactions that exist in both blocks</p>

CC BY-SA 3.0
2018-03-20T17:44:41.687Z
I am not subject matter expert on this topic. I have a reference from Andreas' book "Mastering Bitcoin" here, which is in Chapter 10, "Mining and Consensus" (page 240ff). <<Blocks might arrive at different nodes at different times, causing the nodes to have different perspectives of the blockchain. To resolve this, each node always selects and attempts to extend the chain of blocks that represents the most Proof-of-Work, also known as the longest chain or greatest cumulative work chain.>> (part 1 of 2)
pebwindkraft
CC BY-SA 3.0
2018-03-20T17:45:35.327Z
<< By summing the work recorded in each block in a chain, a node can calculate the total amount of work that has been expended to create that chain. As long as all nodes select the greatest-cumulative-work chain, the global bitcoin network eventually converges to a consistent state. Forks occur as temporary inconsistencies between versions of the blockchain, which are resolved by eventual reconvergence as more blocks are added to one of the forks. >> (part 2 of 2). After this intro, there are like 8-9 pages explaining the fork, hope this helps to get you started.
pebwindkraft
CC BY-SA 3.0
2018-03-20T17:47:08.943Z
@pebwindkraft I think I understand what would happen now. Thanks for the heads up. I will write an answer based upon that
Kyle Graham
<blockchain><mining-theory><blockchain-fork><block-validity>
What would happen if two miners were mining two blocks with two different set of transactions?
Kyle Graham
# What would happen if two miners were mining two blocks with two different set of transactions?

(Asked by: username_0 on 2018-03-20)

If two miners picked from the mempool two different sets of transactions, that were not dependent on each other.

Then could both miners, mine both blocks and not create a fork?

So miner 1 finishes the block and miner two sees that the block had nothing to do with his block, so he continues mining and adds that block onto miner 1s block after about a second?

I am assuming that forks only happen when both blocks mined have transactions that exist in both blocks

**Tags:** blockchain, mining-theory, blockchain-fork, block-validity

> **Comments:**
> **username_1**: I am not subject matter expert on this topic. I have a reference from Andreas' book "Mastering Bitcoin" here, which is in Chapter 10, "Mining and Consensus" (page 240ff). <<Blocks might arrive at different nodes at different times, causing the nodes to have different perspectives of the blockchain. To resolve this, each node always selects and attempts to extend the chain of blocks that represents the most Proof-of-Work, also known as the longest chain or greatest cumulative work chain.>> (part 1 of 2)  
> **username_1**: << By summing the work recorded in each block in a chain, a node can calculate the total amount of work that has been expended to create that chain. As long as all nodes select the greatest-cumulative-work chain, the global bitcoin network eventually converges to a consistent state. Forks occur as temporary inconsistencies between versions of the blockchain, which are resolved by eventual reconvergence as more blocks are added to one of the forks. >> (part 2 of 2). After this intro, there are like 8-9 pages explaining the fork, hope this helps to get you started.  
> **username_0**: @username_1 I think I understand what would happen now. Thanks for the heads up. I will write an answer based upon that  

---

## 4 answers

### Answer by username_2 on 2018-05-04. Score: 2

No, each block must reference it's predecessor block in the header, and the blockchain has only a single block at each height. The second miner must therefore modify the block template that they are mining with to build on top of the just discovered block. They need to update the hash of the predecessor block and the blockchain height in the Coinbase transaction. Otherwise the block they would be finding would be competing with the just published for inclusion instead of writing forth the blockchain.

The rest of the block template could stay the same, if none of the transactions got included in the blockchain already.

However, your question sounds to me like you're thinking that searching for a block has progress. Mining is a progress-less process, each attempt may or may not succeed independently. Thus, it would be a more profitable strategy for each miner to try including the juiciest transactions (by highest fee rate) and to switch to a new block template whenever a block is published with the new juiciest transactions.


---

### Answer by username_3 on 2018-03-20. Score: 1

Oh, the irony... I JUST answered the exact same question on Stackoverflow. I'll copy the answer here:

You can imagine two competing miners creating blocks. If a miner doesn't have block N, he'll keep trying to mine that block. If he receives block number N after having mined it, the miner just ignores it, and we have a temporary fork in the blockchain with two branches, and block N+1 will have two different versions. Now what determines which branch survives is basically the branch that is mined faster. An arbitrary consensus rule is that the longer chain is always the correct chain. When a longer chain exists, all miners agree that this chain is the correct one.

The reason why this works, is because the probability of mining a block is wide enough over 10 minutes in Bitcoin (or block time in general).

The following image can be seen as the probability of mining a block over time (in bitcoin).

[![Probability of mining a block over some time](https://i.sstatic.net/um2Nu.png)](https://i.sstatic.net/um2Nu.png)

This is why it's wrong to create blockchains with very short time. Because if the time is very short (like 10 seconds), there will be tons of forks before the blockchain stabilizes.

> **Comments:**
> **username_0**: Thank you for the insight. I do not think this answers my question. I am aware of what happens during a fork and how the network resolves it. My question is regarding whether a fork will happen if miner 1 and 2 are mining two independent blocks. And miner one adds his block, can miner two updates his chain and continue mining is same block as there are no conflicts?  
> **username_3**: @username_0 Branches are completely independent and don't have any relations. The only requirement is that each branch is consistent. One of them will die.  
> **username_0**: Are branches the same as forks? I am not sure I quite understand what you just said.  
> **username_3**: @username_0 a fork has multiple branches.  
> **username_0**: How can a fork have multiple branches?If I am not mistaken, when the bitcoin network branches, it creates a fork? I have not heard of the term "branch" before, I am new so still ignorant. Please correct me where I am wrong  
> **username_3**: You're confused with terminology. First, keep in mind that I'm **not** talking about protocol forks, like Bitcoin Cash. I'm talking about temporary blochchain forks due to mining (please read my answer again). A fork is the action of creating multiple branches, which looks like the fork you have in a kitchen. Topologically speaking (shape-wise), a fork has branches, and every branch can have a fork that has more branches.  

---

### Answer by username_4 on 2018-04-10. Score: 0

Not really.

> two sees that the block had nothing to do with his block, so he
> continues mining and adds that block onto mine

Once a miner sees an arrival of a block at the same height for which he himself is mining, it's end of the competition for that block. There is no point continuing mining.

However in event of miners creating simultaneous blocks, the forks would happen

> I am assuming that forks only happen when both blocks mined have
> transactions that exist in both blocks

Miner should remove the transactions from memory pool which are already present in newly arrived block and start the mining for a fresh block


---

### Answer by username_0 on 2018-03-20. Score: 0

After reading username_1 comment, I have come up with an answer.

The particular extract "To resolve this, each node always selects and attempts to extend the chain of blocks that represents the most Proof-of-Work, also known as the longest chain or greatest cumulative work chain"

If the blockchain was currently:

Block1 -> Block2 -> Block3

And two miners pick from the mempool, transactions that do not overlap. Then this will cause a fork in the blockchain, if both broadcast at the same time.

This is because, even though the transaction do not overlap, the blockhash would be different for each miner, and if the blockhash is different then this is two different versions of the blockchain. Even if the transactions do not overlap.

If miner1 broadcasts first, then miner2 will have to start his block again, even though all transactions in miner1's block did not clash with miner2's. This is because as soon as miner1 adds to the blockchain. The chain becomes:

Block1 -> Block2 -> Block3->Block4

Where Block4 is miner1s block.

Miner2 has to start again because in his block, he was using the previous hash of block3, he now has to change it block4's hash.

If I have made a mistake, drop a comment instead of downvoting as I would like to know where I went wrong.


---

