Skip to content

November 13th Bitcoin Cash Hardfork Technical Details

Version 1.3, 2017-11-07


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 (B_n+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 B_n be the Nth block in a Bitcoin Cash Blockchain.

  • Let B_last be chosen[2] from [B_n-2, B_n-1, B_n].
  • Let B_first be chosen[2] from [B_n-146, B_n-145, B_n-144].
  • Let the Timespan (TS) be equal to the difference in UNIX timestamps (in seconds) between B_last and B_first within 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 B_last and B_first.
  • Let the Projected Work (PW) be equal to (W * 600) / TS.
  • Let Target (T) be equal to the (2^256 - PW) / PW. This is calculated by taking the two’s complement of PW (-PW) and dividing it by PW (-PW / PW).
  • The target difficulty for block B_n+1 is then equal to the lesser of T and 0x00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Test Case

  1. Create a genesis block with the following data:
    nHeight = 0;
    nTime = 1269211443;
    nBits = 0x1c0fffff;
  1. Add 2049 blocks at 600 second intervals with the same nBits.
  2. Add another 10 blocks at 600 second intervals. nBits should remain constant.
  3. Add a block 6000 seconds in the future with nBits remaining the same.
  4. Add a block -4800 seconds from the previous block. nBits should remain the constant.
  5. Add 20 blocks at 600 second intervals. nBits should remain constant.
  6. Add a block at a 550 second interval. nBits should remain constant.
  7. Add 10 blocks at 550 second intervals. The target difficulty should slowly decrease.
  8. nBits should be 0x1c0fe7b1.
  9. Add 20 more blocks at 10 second intervals. The target difficulty decrease quickly.
  10. nBits should be 0x1c0db19f.
  11. Add 1 block at an interval of 6000 seconds.
  12. nBits should be 0x1c0d9222.
  13. Produce 93 blocks at 6000 second intervals. The target difficulty should increase.
  14. nBits should be 0x1c2f13b9.
  15. Add one block at 6000 seconds.
  16. nBits should be 0x1c2ee9bf.
  17. Add 192 blocks at 6000 second intervals. The target difficulty should increase.
  18. nBits should be 0x1d00ffff.
  19. Add 5 blocks at 6000 second 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

  1. The MTP-11 of a block is defined as the median timestamp of the last 11 blocks prior to, and including, a specific block
  2. A block is chosen via the following mechanism: Given a list: S = [B_n-2, B_n-1, B_n] a. If timestamp(S[0]) greater than timestamp(S[2]) then swap S[0] and S[2]. b. If timestamp(S[0]) greater than timestamp(S[1]) then swap S[0] and S[1]. c. If timestamp(S[1]) greater than timestamp(S[2]) then swap S[1] and S[2]. d. Return S[1]. See GetSuitableBlock
  3. Chainwork for a Block (B) is the sum of block proofs from the genesis block up to and including block B. Block proof is defined in chain.cpp

License of this document

The MIT License (MIT)

Copyright (c) 2017 bitcoincash.org

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.