7

Recently, BIP66 switched from activation (miners enforce rules within block) to enforcement (network enforces rules on all blocks).

I'm having trouble figuring out when this happened, or on what block it happened.

8

From BIP66:

The new rules are in effect for every block (at height H) with nVersion = 3 and at least 750 out of 1000 blocks preceding it (with heights H-1000..H-1) also have nVersion = 3. Furthermore, when 950 out of the 1000 blocks preceding a block do have nVersion = 3, nVersion = 2 blocks become invalid, and all further blocks enforce the new rules.

I wrote this script to monitor the number of the last 1000 blocks that have nVersion set to 3.

require_once 'jsonRPCClient.php';

$daemon = new jsonRPCClient('http://{my_user}:{my_password}@127.0.0.1:8332/');
$blkStart = 364136 - (24 * 14 * 6);

$ver3InLast1000 = 0;
for ($i = $blkStart;; $i++) {
    try {
        $blockHashOld = $daemon->getblockhash($i-1000);
        $blockHashNew = $daemon->getblockhash($i);
        $blockOld = $daemon->getblock($blockHashOld);
        $blockNew = $daemon->getblock($blockHashNew);
    } catch(Exception $e) {
        break;
    }

    // Don't want to start subtracting until have processed 1000 blocks
    if ($blockOld["version"] == 3 && ($i - $blkStart >= 1000)) {
        $ver3InLast1000--;
    }

    if ($blockNew["version"] == 3) {
        $ver3InLast1000++;
    }

    if ($i - $blkStart >= 1000) {
        echo "$i, $ver3InLast1000\n";
    }

}

The result can be found in this pastebin.

Block number 363724 is the block that turned on nVersion=3 enforcement for all further blocks.

  • 3
    For anyone reading this answer in the future, Bitcoin Core 0.12 and later will include this information in the getblockchaininfo RPC. See this pull request for details. – David A. Harding Jul 6 '15 at 20:21
  • excellent answer! – mulllhausen Nov 2 '15 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.