Skip to content

Commit 95734fe

Browse files
committed
add sections on 'competing tx chains' and on MEV
1 parent 6a71fbc commit 95734fe

1 file changed

Lines changed: 47 additions & 4 deletions

File tree

website/docs/guides/adversarial.md

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Bitcoin Cash has a blocktime of 10 minutes, meaning that on average every 10 min
1111

1212
Miners can choose which transactions to include in their block. Some miners might set a higher minimum fee or mine empty blocks so transactions can remain pending in the mempool even though a new block was mined.
1313

14-
:::tip
14+
:::note
1515
In Bitcoin Cash it is standard for transactions to be included in very next mined block. Because there is no network congestion,
1616
the mempool can get cleared with the arrivial of a new block.
1717
:::
@@ -20,8 +20,8 @@ Because transactions in the mempool are "seen" but not included in the blockchai
2020

2121
Where things get more complex however is if there are **competing unconfirmed transactions**. In this scenario it is **not** necessarily the case that a transaction is destined to be included in the blockchain. In other words, the latest state of the blockchain is still undecided.
2222

23-
:::note
24-
This is why many BCH indexers will allow you to query UTXOs with the option to include or exclude unconfirmed transactions.
23+
:::tip
24+
This is why many BCH indexers will allow you to query UTXOs with the option to include or exclude unconfirmed transactions. By default indexers will include unconfirmed UTXOs/unconfirmed transactions in the query result.
2525
:::
2626

2727
## Unconfirmed Transaction Chains
@@ -31,7 +31,23 @@ Unconfirmed transactions can be chained after one another meaning that even an o
3131
There is no maximum to the length of an unconfirmed transaction chain on BCH, software of full nodes has been upgraded to allow for arbitrary length unconfirmed tx chains. This is very important for public covenants which might have many users interacting and transacting with the same smart contract UTXO.
3232

3333
:::tip
34-
On Bitcoin Cash it is possible to design smart contract systems which utilize long unconfirmed transaction chain, avoiding the need for blockchain confirmations. However contract developers should keep in front of mind that a competing transaction chain can in effect "cancel" pending unconfirmed transactions.
34+
On Bitcoin Cash it is possible to design smart contract systems which utilize long unconfirmed transaction chain, avoiding the need for blockchain confirmations. However contract developers should be mindful of the possibility of competing transaction chains.
35+
:::
36+
37+
## Competing Transactions
38+
39+
When there are competing transactions (double spends) being propagated on the network, only one of the conflicting transactions can be included, the other transactions will in effect be cancelled. In the case of an unconfirmed transaction chain, any competing transaction for one of the tranactions in this newly formed chain then presents a cancellation of all child transactions dependent on this parent transaction with a conflict.
40+
41+
:::note
42+
Unlike on Ethereum, on Bitcoin Cash you can never have a transaction which has to pay fees but does not get included in the blockchain. Either it gets included and the fee is paid, or it's like it never happened.
43+
:::
44+
45+
In open contract systems competing transactions can happen organically and by accident, when 2 different users who might be on different sides of the world, interact with your on-chain system at roughly the same time. This situation can be called "UTXO contention" because 2 users simultaneously try to spend the same anyone-can-spend covenant.
46+
47+
However, it is also possible double-spends are created intentioanlly. For example in the case of a DEX naively updating its price state, a rational economic actors might be incentivized to ignore the latest unconfirmed transaction chain and to **intentially** create a competing unconfirmed transaction chain. This way they can interact with the smart contract at an earlier (more advantageous) price.
48+
49+
:::caution
50+
Smart contract developers developing applications at scale should consider the game-theorethic interaction of advanced, rational economic actors who might benefit from competing against intead of cooparating on building a transaction chain.
3551
:::
3652

3753
## First-Seen Rule
@@ -48,3 +64,30 @@ Importantly, the "first-seen rule" is just a default and a network relay rule, a
4864
On BTC the node default got changed to replace-by-fee, and tooling to submit your non-standard transaction directly to mining pools has become common place with oridinals.
4965
:::
5066

67+
## Miner-Extractable-Value (MEV)
68+
69+
Miner-Extractable-Value (MEV) refers to the value (either in dollars or in BCH) which miners can "extract" by having the ability to decide transaction inclusion and the ability to prioritize or insert their own transactions in their new block.
70+
71+
MEV works quite differently on a UTXO-model blockchain than on an account-based chain. So even if you are very familiar with the MEV meechanisms on Ethereum it will still be helpful to consider how they do - or do not - apply to Bitcoin Cash.
72+
73+
:::note
74+
On Ethereum they changed the acronym to mean "Maximum-Extractable-Value" because ETH is now a proof-of-stake system and does not have miners. The modified concept still applies to the ETH block producers.
75+
:::
76+
77+
The reason why block producers are better positioned than other economic actors such as on-chain traders or arbitrageurs is that they can priorize their own transactions even if conflicting transactions exist in the mempool.
78+
79+
### Abandoning First-Seen
80+
81+
As should be clear from the explenation higher up, the "first-seen rule" is just a convention and a way to play nice, however it is not per se economically maximizing. If we see more "bribe" double spends then we can expect over times that some miners will deflect from the covention and use custom transaction selection software to extract MEV from bribe transactions.
82+
83+
### Bounty for Transaction Building
84+
85+
A 1st source of potential MEV on Bitcoin Cash comes from smart contract systems which have a "bounty for transaction building" mechanism. Miners can automate the transaction building or possibly even modify an existing tansaction to claim the bounties for such a system.
86+
87+
### Profitable DEX trades
88+
89+
If DEXes don't cleverly aggregate their prices, then miners may be incentived to strategically create a competing transaction chain which takes advange of an older price state/ratio which has not yet been confirmed in the blockchain.
90+
91+
### Not possible on UTXO
92+
93+
What is not possible to do on UTXO chains is a "sandwich" strategy where a miner would insert a transaction in the middle of a valid transaction chain. In UTXO each transaction explicitly consumes inputs of a previous transaction and creates outputs. Because of this it is not possible to "insert" a transaction in the middle of an unconfirmed chain and thus sandwich strategies are not possible.

0 commit comments

Comments
 (0)