How can the blockchain be pruned?

If the blockchain is tamper-proof thus cannot be changed, how can the data be removed?

Please be as explicit as possible.

share|improve this question
2  
up vote 5 down vote accepted

The blockchain itself cannot be pruned.

Each block is verified through hashing all its data and a random nonce to find a hash that has a certain number of leading zeroes. If you even removed a single little bit of data from a block, the resulting hash would be changed. As most likely the new hash would not fulfill the difficulty requirement, the proof of work would have been destroyed. You'd have to create a new block to take its place. Then however, you would also have to recreate all subsequent block, as the parent's hash (think of it as a fingerprint) is included in its children block, i.e. if you change the parent, the whole blockchain succeeding from it becomes invalid as well.

What can happen is that the database of verified transactions that Bitcoin-Qt clients store is pruned. So far, after verifying each block, full clients keep every transaction that has ever happened locally. Instead, you could only keep the transactions in your database of which the outputs have not been spent yet.

share|improve this answer
1  
Thank you Murch! So is that what happens with lightweight clients that only balances are sent to them not the entire blockchain/transaction database? Thank you so much in advance! – user5107 Jan 6 '14 at 4:04
2  
It is similar, but not the same. In the pruned client you would still verify all blocks, but you would not keep all data. AFAIK lightweight clients actually don't verify blocks themselves. – Murch Jan 6 '14 at 4:08

A block has two parts: a short header (metadata) and a (possibly large) payload containing the actual transactions. Header contains all the necessary data to validate the PoW and chain of headers since the genesis block header. Additionally, each header contains an authenticating value of its payload. SPV wallets sync very fast because they validate only headers and not the payload.

If a block contains transactions whose outputs have not been spent, then nodes must store that block to prove to another bootstrapping node that the UTXO set indeed contains a certain element. On the other hand, if all outputs generated in a block (say X) have been spent, than a node can discard block X and say to another bootstrapping node "all UTXO of block X have been spent, just validate header and move on".

This is a conservative approach. While a bootstrapping node cannot be fooled into accepting invalid UTXOs, we also cannot prove to that node that "all UTXO of block X have been spent" without exhibiting the actual payload.

Now the question may be: How do SPV nodes obtain and maintain an untampered UTXO set? See this answer for details.

share|improve this answer
1  
SPV nodes do not maintain a UTXO set at all. That's impossible without seeing the full blocks. They only maintain a chain of headers. – Pieter Wuille Sep 9 '16 at 8:12
    
@PieterWuille They maintain a UTXO set with outputs that are relevant to them. That's what the linked answer discusses; how a node obtains blocks relevant to it. – Jus12 Sep 9 '16 at 19:13
    
Ok, yes, I don't consider that part of the node, but part of the wallet connected to it (a wallet connected to a full node also has its own UTXO set in that sense), but agree. – Pieter Wuille Sep 9 '16 at 23:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.