<p>The order that two independent transactions appear in a block does not matter. It has an effect on the block hash, but so too do many other things. As a last resort, miners may choose to reorder the transactions in their block in order to achieve a different hash, but there are far easier things to do first.</p>
<p>However miners that use the block assembly algorithm implemented in Bitcoin Core are likely to result in blocks that have transactions in the same order. This algorithm does not take into account the time that a transaction was received as it's irrelevant. What it does account for are dependencies and fee rate (specifically ancestor set fee rate). Transactions with a higher ancestor fee rate will be included first, so two nodes constructing the same block will have a similar transaction order. That being said, there is still some randomness in the ordering when transactions have the same ancestor fee rate as the order at that point is not defined.</p>

CC BY-SA 4.0
2023-10-07T19:35:19.020Z
If A has 1 btc and B has 0 btc and A sends one btc to B with fee equal to x and then B sends this 1 btc back to A with fee 2x then I assume that this 2nd transaction couldn't be included first (even though it had higher fee). But maybe this case is covered by what you meant by "dependencies".
bridgemnc
CC BY-SA 4.0
2023-10-07T19:50:28.153Z
Yes. The 2nd is dependent on the 1st, and so it must come after. That's really the only consensus rule regarding sorting.
Ava Chow
CC BY-SA 4.0
2023-10-07T19:20:10.947Z
2023-10-07T19:20:10.947Z
Ava Chow
<p>Two or more miners might produce a new block at the same time with different transactions or transactions in a different order.</p>
<p>There can only be one block accepted at any specific block height. Which means only one block with a specific parent (previous) block.</p>
<p>Every node independently chooses which of several competing blocks it accepts in its live blockchain. Since all nodes use the same rules, they all end up choosing the same block eventually.</p>
<p>This means that eventually, all nodes have identical blocks (though probably not stored in the same order on disk)</p>

CC BY-SA 4.0
2023-10-07T19:17:42.510Z
2023-10-07T19:17:42.510Z
RedGrittyBrick
<p>Having a transaction from person A to B and another transaction from person C to D that both took place in more or less the same time I assume that there might be a situation in which different nodes will receive these transactions in different order. Both transactions are valid but the order in which they will be included into the block will be different for mining nodes and therefore they will produce different hash / nonce / Proof of Work.</p>
<p>Is my assumption correct and if so then does it even matter? Or it is a natural thing that blocks produced by different nodes will be completely different in terms of order of the transactions (and maybe in terms of number of transactions contained in them) and the only thing that matters is correct nonce needed for proof of work (and if it's being found then the block will be accepted by other nodes).</p>
<p>I am happy to hear if answer to my question would be different in case of other projects (e.g. Ethereum or Cardano).</p>

<block><proof-of-work><consensus>
Are the blocks produced by different nodes in the network comparable in terms of the order of transactions contained in them?
bridgemnc
# Are the blocks produced by different nodes in the network comparable in terms of the order of transactions contained in them?

(Asked by: username_0 on 2023-10-07)

Having a transaction from person A to B and another transaction from person C to D that both took place in more or less the same time I assume that there might be a situation in which different nodes will receive these transactions in different order. Both transactions are valid but the order in which they will be included into the block will be different for mining nodes and therefore they will produce different hash / nonce / Proof of Work.

Is my assumption correct and if so then does it even matter? Or it is a natural thing that blocks produced by different nodes will be completely different in terms of order of the transactions (and maybe in terms of number of transactions contained in them) and the only thing that matters is correct nonce needed for proof of work (and if it's being found then the block will be accepted by other nodes).

I am happy to hear if answer to my question would be different in case of other projects (e.g. Ethereum or Cardano).

**Tags:** block, proof-of-work, consensus


---

## 2 answers

### Answer by username_1 on 2023-10-07. Score: 2 | Accepted answer

The order that two independent transactions appear in a block does not matter. It has an effect on the block hash, but so too do many other things. As a last resort, miners may choose to reorder the transactions in their block in order to achieve a different hash, but there are far easier things to do first.

However miners that use the block assembly algorithm implemented in Bitcoin Core are likely to result in blocks that have transactions in the same order. This algorithm does not take into account the time that a transaction was received as it's irrelevant. What it does account for are dependencies and fee rate (specifically ancestor set fee rate). Transactions with a higher ancestor fee rate will be included first, so two nodes constructing the same block will have a similar transaction order. That being said, there is still some randomness in the ordering when transactions have the same ancestor fee rate as the order at that point is not defined.

> **Comments:**
> **username_0**: If A has 1 btc and B has 0 btc and A sends one btc to B with fee equal to x and then B sends this 1 btc back to A with fee 2x then I assume that this 2nd transaction couldn't be included first (even though it had higher fee). But maybe this case is covered by what you meant by "dependencies".  
> **username_1**: Yes. The 2nd is dependent on the 1st, and so it must come after. That's really the only consensus rule regarding sorting.  

---

### Answer by username_2 on 2023-10-07. Score: 2

Two or more miners might produce a new block at the same time with different transactions or transactions in a different order.

There can only be one block accepted at any specific block height. Which means only one block with a specific parent (previous) block.

Every node independently chooses which of several competing blocks it accepts in its live blockchain. Since all nodes use the same rules, they all end up choosing the same block eventually.

This means that eventually, all nodes have identical blocks (though probably not stored in the same order on disk)


---

