delvingbitcoin

Great Consensus Cleanup Revival

Great Consensus Cleanup Revival

Original Postby AntoineP

Posted on: May 17, 2024 09:38 UTC

The Python script provided demonstrates a method to reduce the difficulty of block creation on a blockchain network to 1 in less than 40 days.

The script operates by manipulating the timestamp of each new block to be the minimum allowed under the blockchain's Median Time Past (MTP) rule, which affects the calculation of difficulty adjustments. The initial setup includes variables for the starting block height, its timestamp, and the difficulty level at that point.

Following this setup, the script enters the attack phase, where it systematically adds blocks with timestamps set just above the median of the previous 11 blocks' timestamps. This manipulation ensures that when the network adjusts the difficulty every 2016 blocks, the calculated time taken to mine these blocks is significantly reduced, thereby reducing the difficulty substantially. The adjustment logic takes into account the actual time spent mining the last 2016 blocks compared to the expected time, adjusting the difficulty proportionately.

The script also outlines how to override the timestamp of the last block in each period to ensure that the difficulty adjustment calculation aligns with the attacker's objectives. This involves setting the timestamp of the last block in a period to a future time based on the current difficulty and then adjusting the difficulty based on the ratio of actual mining time to the expected mining time.

The effectiveness of the attack is summarized by printing the duration it took to bring the difficulty down to 1, alongside the number of periods it required. Additionally, the script outputs a table listing each block's height and timestamp during the attack. The complete dataset of blocks and their timestamps throughout this simulated attack can be found in the provided gist.