From: Pieter Wuille <pieter.wuille@gmail.com>
To: bitcoin-development@lists.sourceforge.net
Subject: [Bitcoin-development] Pruning in the reference client: ultraprune mode
Date: Fri, 6 Jul 2012 18:52:04 +0200 [thread overview]
Message-ID: <20120706165204.GA27215@vps7135.xlshosting.net> (raw)
Hello all,
I've implemented a new block/transaction validation system for the
reference client, called "ultraprune".
Traditionally, pruning for bitcoin is considered to be the ability to
delete full transactions from storage once all their outputs are spent,
and they are buried deeply enough in the chain. That is not what this
is about.
Given that almost all operations performed on the blockchain do not
require full previous transactions, but only their unspent outputs, it
seemed wasteful to use the fully indexed blockchain for everything.
Instead, we keep a database with only the unspent transaction outputs.
After some effort to write custom compact serializations for these, I
could reduce the storage required for such a dataset to less than 70
MB. This is kept in a BDB database file (coins.dat), and with indexing
and overhead, and takes around 130 MB.
Now, this is not enough. You cannot have a full node wit just these
outputs. In particular, it cannot undo block connections, cannot rescan
for wallet transactions, and cannot serve the chain to other nodes.
These are, however, quite infrequent operations. To compensate, we keep
non-indexed but entire blocks (just each block in a separate file, for
now), plus "undo" information for connected blocks around in addition
to coins.dat. We also need a block index with metadata about all stored
blocks, which takes around 40 MB for now (though that could easily be
reduced too). Note that this means we lose the ability to find an
actual transaction in the chain from a txid, but this is not necessary
for normal operation. Such an index could be re-added later, if
necessary.
Once you have this, the step to pruning is easily made: just delete
block files and undo information for old blocks. This isn't implemented
for now, but there shouldn't be a problem. It simply means you cannot
rescan/reorg/server those old blocks, but once those are deep enough
(say a few thousand blocks), we can tolerate that.
So, in summary, it allows one to run a full node (now) with:
* 130 MB coins.dat
* 40 MB chain.dat
* the size of the retained blocks
* + +-12% of that for undo information.
Oh, it's also faster. I benchmarked a full import of the blockchain
(187800 blocks) on my laptop (2.2GHz i7, 8 GiB RAM, 640 GB spinning
harddisk) in 22 minutes. That was from a local disk, and not from
network (which has extra overhead, and is limited by bandwidth
constraints).
If people want to experiment with it, see my "ultraprune" branch on
github: https://github.com/sipa/bitcoin/tree/ultraprune
Note that this is experimental, and has some disadvantages:
* you cannot find a (full) transaction from just its txid.
* if you have transactions that depend on unconfirmed transactions,
those will not get rebroadcasted
* only block download and reorganization are somewhat tested; use at
your own risk
* less consistency checks are possible on the database, and even fewer
are implemented
Also note that this is not directly related to the recent pruning
proposals that use an alt chain with an index of unspent coins (and
addresses), merged mined with the main chain. This could be a step
towards such a system, however.
--
Pieter
next reply other threads:[~2012-07-06 16:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-06 16:52 Pieter Wuille [this message]
2012-07-06 17:19 ` [Bitcoin-development] Pruning in the reference client: ultraprune mode Gregory Maxwell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120706165204.GA27215@vps7135.xlshosting.net \
--to=pieter.wuille@gmail.com \
--cc=bitcoin-development@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox