-
Notifications
You must be signed in to change notification settings - Fork 83
Description
Monero is currently being attacked by a malicious pool that has around 33% of the network hashrate (α = 0.33). There is no evidence that the malicious pool has reached the majority of the network hashrate. Nevertheless, any pool with α > 0.25 can cause disruption with selfish mining, which is a malicious mining strategy which allows the pool to gain more that its fair share of the block rewards [1].
This is a proposal to mitigate selfish mining. It assumes that Monero keeps RandomX as its consensus mechanism and that α < 0.5. It does not (and cannot) address 51% attacks.
It's actually 2 proposals. The first proposal is a soft fork, which does not alter any consensus rules and only needs to be adopted by the honest majority of miners. The second, more comprehensive proposal, requires a hard fork.
After reviewing the available literature about selfish mining, I first want to disqualify all mitigation strategies that rely on more frequent hashrate sampling. This is the Fruitchain and related proposals [2,3]. The main idea is to submit proof of work "fruits" or "shares" with a much lower difficulty than what is required to mine a block and then aggregate those shares within a block. These ideas are unsuitable for Monero because RandomX is too slow to verify. A block consisting of 100 work shares would require 1.5 seconds just to verify the PoW.
Secondly, a large number of mitigations focus on tie-breaking rules [1,4], which apply when the attacker's private chain has the same length as the honest chain. These proposals are not sufficient against a resourceful attacker with α > 0.25, who can often outmine the honest majority and win due to the longest chain rule. We need a mitigation strategy that can work even if the attacker's chain is longer.
1. Soft-forking proposal
The most efficient selfish mining mitigation that can be rolled out as a soft fork is Publish or Perish (PoP) [5]. It works when the attacker's chain is less than k blocks longer than the honest chain (otherwise it falls back to the longest chain rule to allow network partitions to be eventually resolved). A chain weight rule is applied that takes into account the block's relative time of arrival and its embedded uncle block.
PoP introduces the concept of late blocks. A block is late if it arrives more than D seconds after any other block of the same height. This only requires relative time measurement and does not need the clocks of the network nodes to be synchronized. Late blocks do not contribute to the weight of its chain.
In case of two competing chains of equal weight, the PoP paper calls for a random selection to be made, but I would suggest to use a deterministic tie breaking rule (e.g. with hashing).
For a practical implementation in Monero, we would create a new tx_extra tag for uncle blocks and each miner could include an uncle block of height exactly N-1 (where N is the height of the current block) in the coinbase transaction. The uncle block is represented by its PoW header, which allows the PoW to be checked. Since the PoW header does not include the height, we would validate the height by checking that the prev_id field is the same as the one in block N-1 of the canonical chain. The approximate size of an uncle block is 80 bytes, which is quite negligible. Uncle blocks do not affect block rewards or the cumulative difficulty.
We would use k = 3, which means the attacker would need to mine 3 blocks more than the honest majority to cause a reorg. We would use a propagation delay of D = 5 seconds.
While not perfect, this strategy significantly reduces the excess profits from selfish mining. With α = 0.48, the attacker gets ~64% of the block rewards compared to ~88% with no mitigations (numbers from [5]).
2. Hard-forking proposal
The hard-forking proposal extends PoP with Reward Splitting (RS) [6]. It bears some similarities with the proposal by @venture-life [7].
This proposal fully removes the economic incentives for selfish mining unless the attacker can mine at least 20 blocks faster than the honest majority.
I will first list the consensus changes:
- Include the block height in the PoW blob.
- Reduce the target block time to 60 seconds and raise the output lock time to 20 blocks. The block reward and the penalty free block size will be halved.
- Increase coinbase maturity to 1440 blocks (1 day).
- The coinbase transaction of the block at height N pays out the block reward of the block at height N-20.
- A new coinbase transaction field
miner_addressthat includes the miner's Monero address (or more addresses and the percentages how to split the reward). This will be used in block N+20 to pay the miner(s). - A new coinbase transaction field
uncle_blocksthat includes uncle blocks. Uncle blocks include the PoW header, the coinbase transaction and its inclusion proof. Only uncle blocks with a height of at least N-20 can be included in block N. - Apply the PoP fork selection rule with
k = 3andD = 5. Only uncle blocks with a height of N-1 are counted towards the chain weight. - The difficulty adjustment algorithm uses the past 1440 blocks, starting from block N-30. Uncle blocks are included in the difficulty calculation. The lowest and the highest 120 block times are trimmed out before calculating the average block time.
- The block reward for block at height N is split equally between the miner who mined the block N and all miners who mined an uncle block of height N that was included in blocks N+1 to N+20.
Rationale:
- Including the block height in the PoW header makes uncle blocks easier to verify and can also help to detect malicious activity of public pools (e.g. mining a parallel chain).
- Monero used to have a 60 second block time, but it was increased to 120 seconds in 2016 to reduce the natual orphan rate. Due to reward splitting, orphan blocks are not an issue in this proposal. The faster blocks make it harder for a minority hashrate attacker to reorg longer time periods of the honest chain at the cost of doubling the PoW to verify the chain, which is acceptable. Adjusting the output lock time to 20 blocks matches the current 10-block lock time (the same 20 minutes on average, but reduced variance).
- Longer coinbase maturity prevents malicious miners from quickly selling mined coins after an attack and promotes long-term mining.
- Delaying the payment of block rewards is required for reward splitting in order to collect uncle blocks. 20 blocks seems like a good compromise as it matches the output lock time.
- Miner addresses are needed because miners no longer construct their own outputs. Note that the full (main) address and a transparent tx private key are needed in order to verify that the coinbase payout is constructed correctly (similar to p2pool).
- Uncle blocks are needed for consensus as they affect both the block reward and the difficulty calculation.
- Keeping the PoP chain selection rules makes the hard forking proposal strictly stronger than the soft forking one.
- It's essentially the same algorithm, only adjusted for 2x faster blocks and include uncles for proper network hashrate estimation.
- Reward splitting means that orphaning blocks no longer increases malicious miner's rewards (up to the limit of 20 blocks). There is no reward for including uncle blocks because malicious miners will never include them and honest miners have enough incentive through the cumulative difficulty increase that they bring due to being counted in the difficulty adjustment algorithm (a heavier chain is more difficult to reorg, which secures past block rewards waiting to be unlocked).
The exact effect of this proposal (in terms of rewards for a specific attacker strategy) is unclear (pending Monte Carlo simulations), but it should be much closer to a fair distribution.
References
[1] Majority is not Enough: Bitcoin Mining is Vulnerable https://arxiv.org/abs/1311.0243
[2] FruitChains: A Fair Blockchain https://eprint.iacr.org/2016/916
[3] Optimal Reward Allocation via Proportional Splitting https://arxiv.org/abs/2503.10185
[4] One Weird Trick to Stop Selfish Miners: Fresh Bitcoins, A Solution for the Honest Miner. https://eprint.iacr.org/2014/007
[5] Publish or Perish https://www.researchgate.net/publication/312184074_Publish_or_Perish_A_Backward-Compatible_Defense_Against_Selfish_Mining_in_Bitcoin
[6] Lay Down the Common Metrics: Evaluating Proof-of-Work Consensus Protocols' Security https://ieeexplore.ieee.org/document/8835227
[7] #141