HF-20171113
layout: specification
title: November 13th Bitcoin Cash Hardfork Technical Details
category: spec
date: 2017-11-07
activation: 1510600000
version: 1.3
Summary
When the median time past[1] of the most recent 11 blocks (MTP - 11) is greater than or equal to UNIX timestamp 1510600000 Bitcoin Cash will execute a hardfork according to this specification.
Starting from the next block these three consensus rules changes will take effect:
- Enforcement of LOW_S signatures (BIP 0146)
- Enforcement of NULLFAIL (BIP 0146)
- A replacement for the emergency difficulty adjustment.
The algorithm for the new difficulty adjustment is described below
Difficulty Adjustment Algorithm Description
To calculate the difficulty of a given block (Bn + 1), with an MTP-11[1] greater than or equal to the unix timestamp 1510600000, perform the following steps:
NOTE: Implementations must use integer arithmetic only
- Let Bnbe the Nth block in a Bitcoin Cash Blockchain.
- Let Blastbe chosen[2] from[Bn - 2, Bn - 1, Bn].
- Let Bfirstbe chosen[2] from[Bn - 146, Bn - 145, Bn - 144].
- Let the Timespan (TS) be equal to the difference in UNIX timestamps (in seconds) betweenBlastandBfirstwithin the range[72 * 600, 288 * 600]. Values outside should be treated as their respective limit.
- Let the Work Performed (W) be equal to the difference in chainwork[3] between Blast and Bfirst.
- Let the Projected Work (PW) be equal to(W * 600) / TS.
- Let Target (T) be equal to the(2256 - PW) / PW. This is calculated by taking the two’s complement ofPW(-PW) and dividing it byPW(-PW / PW).
- The target difficulty for block Bn + 1is then equal to the lesser ofTand0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Test Case
- Create a genesis block with the following data:
    nHeight = 0;
    nTime = 1269211443;
    nBits = 0x1C0FFFFF;
- Add 2049blocks at600second intervals with the samenBits.
- Add another 10blocks at600second intervals.nBitsshould remain constant.
- Add a block 6000seconds in the future withnBitsremaining the same.
- Add a block -4800seconds from the previous block.nBitsshould remain the constant.
- Add 20blocks at600second intervals.nBitsshould remain constant.
- Add a block at a 550second interval.nBitsshould remain constant.
- Add 10blocks at550second intervals. The target difficulty should slowly decrease.
- nBitsshould be- 0x1C0FE7B1.
- Add 20more blocks at10second intervals. The target difficulty decrease quickly.
- nBitsshould be- 0x1C0DB19F.
- Add 1block at an interval of6000seconds.
- nBitsshould be- 0x1C0D9222.
- Produce 93blocks at6000second intervals. The target difficulty should increase.
- nBitsshould be- 0x1C2F13B9.
- Add one block at 6000seconds.
- nBitsshould be- 0x1C2EE9BF.
- Add 192blocks at6000second intervals. The target difficulty should increase.
- nBitsshould be- 0x1D00FFFF.
- Add 5blocks at6000second intervals. Target should stay constant at the maximum value.
References
FAQ
Q: Does this imply that if the blocks are timestamped sequentially, the last block has no effect since it will look at the block before that one?
A: Yes
Footnotes
- The MTP-11of a block is defined as the median timestamp of the last11blocks prior to, and including, a specific block.
- A block is chosen via the following mechanism:
Given a list:
S = [B<sub>n</sub> - 2, B<sub>n</sub> - 1, B<sub>n</sub>]a. If timestamp (
S<sub>0</sub>) greater than timestamp (S<sub>2</sub>) then swapS<sub>0</sub>andS<sub>2</sub>.b. If timestamp (
S<sub>0</sub>) greater than timestamp (S<sub>1</sub>) then swapS<sub>0</sub>andS<sub>1</sub>.c. If timestamp (
S<sub>1</sub>) greater than timestamp (S<sub>2</sub>) then swapS<sub>1</sub>andS<sub>2</sub>.d. Return
S<sub>1</sub>.See GetSuitableBlock
- Chainwork for a Block (B) is the sum of block proofs from the genesis block up to and including block B.Block proofis defined in chain.cpp