[BTC-dev] chuck_checkpoints vpatch submission

Funkenstein funkenstein at woodcoin.org
Fri Oct 23 14:05:43 UTC 2015


Name: patch-submission-2.txt.asc
URL: <http://therealbitcoin.org/ml/btc-dev/attachments/20151023/patch-submission-2_d2ae70e0d900ec4e555d290cad4e2423ac138a72.txt.asc>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256


This patch is self explanatory. 
In practice it doesn't do anything that running bitcoind with the --verify-all flag already does, apart from trimming unnecessary lines of code from the codebase.

In a related query, the pseudo-fork at block 168000 (see logs) and the choice of a checkpoint at exactly that block are coincidental.  Is there any known reason for this?  


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJWKj3+AAoJELK2NgSIKYq2WK8QAKbzZmKZOwAxBUV8l483gliP
6VsuBIjjc5Y1in4amm5kfzhXqdA1iWfMMhBxGtOpEKoLxIalTy1xcn9qqD5lrIDX
lNFgvRnXCRHm27IEsDMNmEGrV5gwG/R/H51AtLAaw9PN6wRcgBbVfWqyP2DAd2+m
GQOEbLA3ZQLzIQ5mMvC4Rqvt0biG2TBLNuUExyLqGxZi/9p055t3LCoybMjQbm+l
nI2nBQx2/8gB54heWP1H9hkoLfISwkVtQZ1V0BrR6SvKt/Ji56LTqjNv61dgC7Kk
BOZn5URLgpAYlBz51kCEnL2XyFwfqAvdYn65CZOYRrJ0CK7WOwXt2DCw3ZIbCovI
5jHsSfnyYuTVj6KBuzB1nZLAO8D4QWqAOaQZDzQIoaJ+l6wlcqKnz5wWdg0pHHih
Yr3GAokRHrwZLhJllXgOSRW2aQoNsMfGbT0SLwo9KLgj0MCHlk3COPfPXf91aIpo
wids/qE1zpLJ0Jda/n0C4FXutQQjLJ225vEXWPPCZr/zF2OXUozWspXLYpUMDWKj
Zc4Tw0rCY1GsExYwVz2YuCy8NmQXUViTnuypQu6HYPM0kvqneR/zApYtcwP2U+BZ
eVRGQh+FwwOTpyXUPIj51TngLZ6tCr2OZ1oJRs3CxlGPwdtYjHlADytj9F2IqJZa
fyiqjlmy1qkNyEDut2Q6
=AHDk
-----END PGP SIGNATURE-----
-------------- next part --------------
Name: funk_chuck_checkpoins.vpatch
URL: <http://therealbitcoin.org/ml/btc-dev/attachments/20151023/funk_chuck_checkpoins_86888f16775b23dfad171d74a2e6e94c69134418.vpatch>
diff -uNr a/src/checkpoints.cpp b/src/checkpoints.cpp
--- a/src/checkpoints.cpp 30d21253854354e384e2e900641c6fc7ca94f591487bd685f6e49310da9f63c1b201910fa8882e34c4eba2032a0b8a246d3c5617f215ddfeff3598fbd773e291
+++ b/src/checkpoints.cpp false
@@ -1,59 +0,0 @@
-// Copyright (c) 2009-2012 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
-// file license.txt or http://www.opensource.org/licenses/mit-license.php.
-
-#include <boost/assign/list_of.hpp> // for 'map_list_of()'
-#include <boost/foreach.hpp>
-
-#include "headers.h"
-#include "checkpoints.h"
-
-namespace Checkpoints
-{
-    typedef std::map<int, uint256> MapCheckpoints;
-
-    //
-    // What makes a good checkpoint block?
-    // + Is surrounded by blocks with reasonable timestamps
-    //   (no blocks before with a timestamp after, none after with
-    //    timestamp before)
-    // + Contains no strange transactions
-    //
-    static MapCheckpoints mapCheckpoints =
-        boost::assign::map_list_of
-        ( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
-        ( 33333, uint256("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6"))
-        ( 68555, uint256("0x00000000001e1b4903550a0b96e9a9405c8a95f387162e4944e8d9fbe501cd6a"))
-        ( 70567, uint256("0x00000000006a49b14bcf27462068f1264c961f11fa2e0eddd2be0791e1d4124a"))
-        ( 74000, uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20"))
-        (105000, uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97"))
-        (118000, uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553"))
-        (134444, uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))
-        (140700, uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))
-        (168000, uint256("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763"))
-        ;
-
-    bool CheckBlock(int nHeight, const uint256& hash)
-    {
-        MapCheckpoints::const_iterator i = mapCheckpoints.find(nHeight);
-        if (i == mapCheckpoints.end()) return true;
-        return hash == i->second;
-    }
-
-    int GetTotalBlocksEstimate()
-    {
-        return mapCheckpoints.rbegin()->first;
-    }
-
-    CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex)
-    {
-        BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints)
-        {
-            const uint256& hash = i.second;
-            std::map<uint256, CBlockIndex*>::const_iterator t = mapBlockIndex.find(hash);
-            if (t != mapBlockIndex.end())
-                return t->second;
-        }
-        return NULL;
-    }
-}
diff -uNr a/src/checkpoints.h b/src/checkpoints.h
--- a/src/checkpoints.h 8bd5d4bb576d5755203bc207138e556266ba6015d0f673bcd6d94b3272291bd637f019849caee47b6ae64e412439974d1409ec14c784dd430c88f252f856f266
+++ b/src/checkpoints.h false
@@ -1,29 +0,0 @@
-// Copyright (c) 2011 The Bitcoin developers
-// Distributed under the MIT/X11 software license, see the accompanying
-// file license.txt or http://www.opensource.org/licenses/mit-license.php.
-#ifndef BITCOIN_CHECKPOINT_H
-#define  BITCOIN_CHECKPOINT_H
-
-#include <map>
-#include "util.h"
-
-class uint256;
-class CBlockIndex;
-
-//
-// Block-chain checkpoints are compiled-in sanity checks.
-// They are updated every release or three.
-//
-namespace Checkpoints
-{
-    // Returns true if block passes checkpoint checks
-    bool CheckBlock(int nHeight, const uint256& hash);
-
-    // Return conservative estimate of total number of blocks, 0 if unknown
-    int GetTotalBlocksEstimate();
-
-    // Returns last CBlockIndex* in mapBlockIndex that is a checkpoint
-    CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex);
-}
-
-#endif
diff -uNr a/src/init.cpp b/src/init.cpp
--- a/src/init.cpp ff7009f672bf400a42d1d7afb6e58aaf1c29d9c219fad51c5f17000243a485e92bbb250d3f4bbec3f0717d00fad620c294d537832671f20c0979fb3f1383779b
+++ b/src/init.cpp 7a171c2f30805f207ae170404f2f684144c254a13f4f25581146611c38313b2bb1b3cd6347c0ce9b66c313e0004eac66b04e83b431ec78910f5aabb0de341043
@@ -174,7 +174,6 @@
             "  -daemon          \t\t  " + _("Run in the background as a daemon and accept commands\n") +
             "  -debug           \t\t  " + _("Output extra debugging information\n") +
 	    "  -caneat          \t\t  " + _("Permit the use of 'eatblock'\n") +
-	    "  -verifyall       \t\t  " + _("Forbid the skipping of ECDSA signature verification between checkpoints.\n") +
             "  -logtimestamps   \t  "   + _("Prepend debug output with timestamp\n") +
             "  -printtoconsole  \t  "   + _("Send trace/debug info to console instead of debug.log file\n") +
             "  -rpcuser=<user>  \t  "   + _("Username for JSON-RPC connections\n") +
@@ -197,7 +196,6 @@
     fDebug = GetBoolArg("-debug");
     fDaemon = GetBoolArg("-daemon");
     fCanEat = GetBoolArg("-caneat");
-    fVerifyAll = GetBoolArg("-verifyall");
 
     if (fDaemon)
         fServer = true;
diff -uNr a/src/main.cpp b/src/main.cpp
--- a/src/main.cpp 92038390413f77b55e19439738e87c21bd5b2313dc6edad78bcc8bf722dde82623a31a56a87b0182e75e6824fc709dc216fb9cb159b49a16e212e3a5ded93f58
+++ b/src/main.cpp 9cbe118c362dca5f4e340519d3ad48e79a1ef896f2fe297a3481067e8a3c0c1fdd6c09fe251918358e67bc90aa884f952454c051ddfca06f334ce359aadd688a
@@ -3,7 +3,6 @@
 // Distributed under the MIT/X11 software license, see the accompanying
 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
 #include "headers.h"
-#include "checkpoints.h"
 #include "db.h"
 #include "net.h"
 #include "init.h"
@@ -679,12 +678,12 @@
 // Return maximum amount of blocks that other nodes claim to have
 int GetNumBlocksOfPeers()
 {
-    return std::max(cPeerBlockCounts.median(), Checkpoints::GetTotalBlocksEstimate());
+    return cPeerBlockCounts.median();
 }
 
 bool IsInitialBlockDownload()
 {
-    if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate())
+    if (pindexBest == NULL)
         return true;
     static int64 nLastUpdate;
     static CBlockIndex* pindexLastBest;
@@ -829,10 +828,7 @@
                     if (pindex->nBlockPos == txindex.pos.nBlockPos && pindex->nFile == txindex.pos.nFile)
                         return error("ConnectInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - pindex->nHeight);
 
-            // Skip ECDSA signature verification when connecting blocks (fBlock=true)
-            // before the last blockchain checkpoint. This is safe because block merkle hashes are
-            // still computed and checked, and any change will be caught at the next checkpoint.
-            if (fVerifyAll || (!(fBlock && (nBestHeight < Checkpoints::GetTotalBlocksEstimate()))))
+            if (fVerifyAll || (!(fBlock)))
                 // Verify signature
                 if (!VerifySignature(txPrev, *this, i))
                     return DoS(100,error("ConnectInputs() : %s VerifySignature failed", GetHash().ToString().substr(0,10).c_str()));
@@ -1292,10 +1288,6 @@
         if (!tx.IsFinal(nHeight, GetBlockTime()))
             return DoS(10, error("AcceptBlock() : contains a non-final transaction"));
 
-    // Check that the block chain matches the known block chain up to a checkpoint
-    if (!Checkpoints::CheckBlock(nHeight, hash))
-        return DoS(100, error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight));
-
     // Write block to history file
     if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK)))
         return error("AcceptBlock() : out of disk space");
@@ -1327,27 +1319,14 @@
     if (!pblock->CheckBlock())
         return error("ProcessBlock() : CheckBlock FAILED");
 
-    CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(mapBlockIndex);
-    if (pcheckpoint && pblock->hashPrevBlock != hashBestChain)
+    if (pblock->hashPrevBlock != hashBestChain)
     {
-        // Extra checks to prevent "fill up memory by spamming with bogus blocks"
-        int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime;
-        if (deltaTime < 0)
-        {
-            if (pfrom)
-                pfrom->Misbehaving(100);
-            return error("ProcessBlock() : block with timestamp before last checkpoint");
-        }
+        // Extra checks to prevent "fill up memory by spamming with bogus blocks
         CBigNum bnNewBlock;
         bnNewBlock.SetCompact(pblock->nBits);
-        CBigNum bnRequired;
-        bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime));
-        if (bnNewBlock > bnRequired)
-        {
             if (pfrom)
                 pfrom->Misbehaving(100);
             return error("ProcessBlock() : block with too little proof-of-work");
-        }
     }
 
     // If don't already have its previous block, throw it out!
diff -uNr a/src/makefile.unix b/src/makefile.unix
--- a/src/makefile.unix 929157d5e139336f38e98555f14fc125c4217c23eba941086b648147e39fcec9ecab632567fc3295e58826fedf6239d5cc0cd028f4e78fd56ae868b795d2de02
+++ b/src/makefile.unix bbd6e9381e9e4844772f420c5d02bbaa92cb79f79f951e57fb1141c736ae61aebae0df5e67f63d431b65b0e90199e5813c95d83005335d20730ed27988a2efa0
@@ -74,7 +74,6 @@
 HEADERS = \
     base58.h \
     bignum.h \
-    checkpoints.h \
     crypter.h \
     db.h \
     headers.h \
@@ -94,7 +93,6 @@
     wallet.h
 
 OBJS= \
-    obj/checkpoints.o \
     obj/crypter.o \
     obj/db.o \
     obj/init.o \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: funk_chuck_checkpoints.vpatch.funk.sig
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://therealbitcoin.org/ml/btc-dev/attachments/20151023/funk_chuck_checkpoints_ed4eb82f32ec409e1336571b9f5ce8ee86f9b392.vpatch.funk.sig>


More information about the BTC-dev mailing list