Bitcoin Forum
May 28, 2024, 06:29:27 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 [2]  All
  Print  
Author Topic: High speed Blockchain Download  (Read 2702 times)
SgtSpike
Legendary
*
Offline Offline

Activity: 1400
Merit: 1005



View Profile
August 19, 2011, 11:41:06 PM
 #21

When the Bitcoin client loads up, it only checks that the last 2500 blocks in the chain that it has are valid. Beyond that, you can change anything you want in the previous blocks without effecting what the client thinks the block hash is. Remember, the data on disk is assumed to have already been checked by your client, so there is no reason to check it on every startup. If it did, it would take hours to start your client.

That said, I have to thank you. I just discovered an undocumented command line option: -checkblocks. If you use that, you will be safe if you download an untrusted blockchain and put it in your data directory.

Code:
    for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
    {
        if (pindex->nHeight < nBestHeight-2500 && !mapArgs.count("-checkblocks"))
            break;
        CBlock block;
        if (!block.ReadFromDisk(pindex))
            return error("LoadBlockIndex() : block.ReadFromDisk failed");
        if (!block.CheckBlock())
        {
            printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
            pindexFork = pindex->pprev;
        }
    }
Line 474 in src/db.cpp
So a potential attack might go like this:
- Create corrupt blockchain, showing that you have 100,000 BTC at a particular address from a transaction back in block 100,000.
- Get more than 50% of miners to download said blockchain (impossible, given that major pools make up far more than 50% of hashing power, and they already have the blockchain)
- Send those 100,000 BTC to another real address.  The miners with the corrupted blockchain would accept the transaction.
- Spend, spend away!

What other concerns might this present?
nibor (OP)
Sr. Member
****
Offline Offline

Activity: 438
Merit: 291


View Profile
August 21, 2011, 02:49:02 PM
 #22

So the regular block chain isn't compressed at all? Why not? Isn't regular RLE pretty trivial to implement these days? Maybe some other reason.

Because the blockchain is full of hashes that are in effect random numbers it does not compress well.
You only get 20% compression, so does not seem worth it for all the extra effort.
Pages: « 1 [2]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!