Bitcoin Forum
November 06, 2024, 09:18:50 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: how-to clean up chainstate folder  (Read 190 times)
citb0in (OP)
Hero Member
*****
Offline Offline

Activity: 840
Merit: 730


Bitcoin g33k


View Profile
January 29, 2024, 11:10:49 AM
Merited by vapourminer (1)
 #1

In short: a pruned node that uses the minimum possible value "prune=550" shows a folder structure of

./blocks = 704M
./chainstate = 11G

This of course goes beyond the actual purpose of a pruned node. Why does the folder content of chainstate rise to this immense height? And how can this immensely high disk usage of the chainstate folder be cleaned up? Simply deleting it is certainly not a good option. What is the best way to proceed in such a case?

  _      _   _       __  _          _  _   __
 |_) |  / \|/   (_  / \ | \  / |_ |_) (_ 
 |_) |_ \_/ \_ |\   __) \_/ |_ \/  |_ | \ __)
--> citb0in Solo-Mining Group <--- low stake of only 0.001 BTC. We regularly rent about 5 PH/s hash power and direct it to SoloCK pool. Wanna know more? Read through the link and JOIN NOW
nc50lc
Legendary
*
Offline Offline

Activity: 2590
Merit: 6337


Self-proclaimed Genius


View Profile
January 29, 2024, 12:47:53 PM
Last edit: January 29, 2024, 01:51:33 PM by nc50lc
Merited by ABCbits (2), RickDeckard (2), vapourminer (1)
 #2

And how can this immensely high disk usage of the chainstate folder be cleaned up? Simply deleting it is certainly not a good option. What is the best way to proceed in such a case?
You can't clean it, it contains the "UTXO set" based from the blocks that you've verified.

If your node is running for a few years now, re-syncing Core or --reindex-chainstate may produce a more "optimized" chainstate
but it wont be a significant change in size, maybe a reduction of 1GB at best.

This of course goes beyond the actual purpose of a pruned node. Why does the folder content of chainstate rise to this immense height?
Your pruned node is a full node too, it needs the chainstate to verify all the transactions that it continuously receiving from its peers.
It's increasing (at a very slow rate) because of UTXOs that are being spent and created.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
NotATether
Legendary
*
Offline Offline

Activity: 1778
Merit: 7362


Top Crypto Casino


View Profile WWW
January 29, 2024, 12:57:09 PM
Merited by n0nce (1)
 #3

This of course goes beyond the actual purpose of a pruned node. Why does the folder content of chainstate rise to this immense height?
Your pruned node is a full node too, it needs the chainstate to verify all the transactions that it continuously receiving from its peers.
It's increasing (at a very slow rate) because of UTXOs that are being spent and created.

Especially Ordinals. I think all this minting is contributing to make the UTXO set bigger at an even faster rate since selling and buying an Ordinal makes the same outputs as it does inputs (IIRC).

Pretty soon, I think we will need drop provably-unspendable outputs from the chainstate.

███████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████

███████████████████████
.
BC.GAME
▄▄▀▀▀▀▀▀▀▄▄
▄▀▀░▄██▀░▀██▄░▀▀▄
▄▀░▐▀▄░▀░░▀░░▀░▄▀▌░▀▄
▄▀▄█▐░▀▄▀▀▀▀▀▄▀░▌█▄▀▄
▄▀░▀░░█░▄███████▄░█░░▀░▀▄
█░█░▀░█████████████░▀░█░█
█░██░▀█▀▀█▄▄█▀▀█▀░██░█
█░█▀██░█▀▀██▀▀█░██▀█░█
▀▄▀██░░░▀▀▄▌▐▄▀▀░░░██▀▄▀
▀▄▀██░░▄░▀▄█▄▀░▄░░██▀▄▀
▀▄░▀█░▄▄▄░▀░▄▄▄░█▀░▄▀
▀▄▄▀▀███▄███▀▀▄▄▀
██████▄▄▄▄▄▄▄██████
.
..CASINO....SPORTS....RACING..


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3542
Merit: 6885


Just writing some code


View Profile WWW
January 29, 2024, 11:13:16 PM
 #4

Pretty soon, I think we will need drop provably-unspendable outputs from the chainstate.
We already do.

pooya87
Legendary
*
Offline Offline

Activity: 3626
Merit: 11010


Crypto Swap Exchange


View Profile
January 30, 2024, 04:56:49 AM
Merited by ABCbits (1)
 #5

Especially Ordinals. I think all this minting is contributing to make the UTXO set bigger at an even faster rate since selling and buying an Ordinal makes the same outputs as it does inputs (IIRC).

Pretty soon, I think we will need drop provably-unspendable outputs from the chainstate.
Unfortunately the junk outputs Ordinals attackers create are not provably unspendable. A lot of them are just dust outputs that the standard rules prevent from being spent. Other broken scripts* (including those used for Ordinals Attack) don't contribute enough to the bloat to justify the effort of writing the code to "purge" them from the database.

The OP_RETURN outputs (the only provably unspendable outputs) have always been dropped as a.chow said.

* Example of a provably unspendable broken script that I'm talking about:
Code:
OP_DUP OP_HASH160 <push 21 bytes> OP_EQUALVERIFY OP_CHECKSIG

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
ABCbits
Legendary
*
Offline Offline

Activity: 3052
Merit: 8062


Crypto Swap Exchange


View Profile
January 30, 2024, 10:35:49 AM
 #6

If your node is running for a few years now, re-syncing Core or --reindex-chainstate may produce a more "optimized" chainstate
but it wont be a significant change in size, maybe a reduction of 1GB at best.

Do you have personal experience or know documentation that --reindex-chainstate actually reduce chainstate size? After all, chainstate basically just LevelDB (key/value) database.

This of course goes beyond the actual purpose of a pruned node.

But it's technical limitation of pruned node, since you need all "spendable" UTXO to verify all new TX/block.

Why does the folder content of chainstate rise to this immense height?

1. Ordinals (mainly BRC-20 token).
2. Rising Bitcoin popularity.

What is the best way to proceed in such a case?

Allocate more storage. I don't expect Bitcoin Core will implement compressed chainstate feature.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
nc50lc
Legendary
*
Offline Offline

Activity: 2590
Merit: 6337


Self-proclaimed Genius


View Profile
January 31, 2024, 06:06:01 AM
Merited by ABCbits (5), vapourminer (1)
 #7

Do you have personal experience or know documentation that --reindex-chainstate actually reduce chainstate size? After all, chainstate basically just LevelDB (key/value) database.
His chainstate folder is 11GB in size and based from his post history, he's been using his node for a few years now.
On the other hand, I have a recently fully synced node with 9.8GB chainstate folder.

The command: --reindex-chainstate deletes the chainstate and creates a new chainstate from the blockchain.

Here's a post in bitcoin stackexchange that explains how it work: https://bitcoin.stackexchange.com/a/117435

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
ABCbits
Legendary
*
Offline Offline

Activity: 3052
Merit: 8062


Crypto Swap Exchange


View Profile
January 31, 2024, 09:58:46 AM
 #8

Do you have personal experience or know documentation that --reindex-chainstate actually reduce chainstate size? After all, chainstate basically just LevelDB (key/value) database.
His chainstate folder is 11GB in size and based from his post history, he's been using his node for a few years now.
On the other hand, I have a recently fully synced node with 9.8GB chainstate folder.

Good point. I just found out size of my chainstate folder has smaller size.

The command: --reindex-chainstate deletes the chainstate and creates a new chainstate from the blockchain.

Here's a post in bitcoin stackexchange that explains how it work: https://bitcoin.stackexchange.com/a/117435

I already know LevelDB has some optimization, but didn't know it doesn't fully optimize/reduce size of it's DB files. Although as reminder, --reindex-chainstate will redownload whole blockchain.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
citb0in (OP)
Hero Member
*****
Offline Offline

Activity: 840
Merit: 730


Bitcoin g33k


View Profile
January 31, 2024, 10:02:23 AM
 #9

The command: --reindex-chainstate deletes the chainstate and creates a new chainstate from the blockchain.

Although as reminder, --reindex-chainstate will redownload whole blockchain.

So will that result in a smaller or significant difference folder size after such a reindex ? Please provide some folder sizes before/after if possible. Thanks a bunch in advance. What I still don't understand how two fully-synchronized non-pruned nodes can have different sizes of the chainstate. That makes no sense to me.

citb0in

  _      _   _       __  _          _  _   __
 |_) |  / \|/   (_  / \ | \  / |_ |_) (_ 
 |_) |_ \_/ \_ |\   __) \_/ |_ \/  |_ | \ __)
--> citb0in Solo-Mining Group <--- low stake of only 0.001 BTC. We regularly rent about 5 PH/s hash power and direct it to SoloCK pool. Wanna know more? Read through the link and JOIN NOW
BlackHatCoiner
Legendary
*
Offline Offline

Activity: 1694
Merit: 8324


Bitcoin is a royal fork


View Profile WWW
January 31, 2024, 10:31:21 AM
Merited by pooya87 (2), vapourminer (1)
 #10

So will that result in a smaller or significant difference folder size after such a reindex ?
It will result in a small difference. If you have a storage problem, reindexing for the sake of restructuring your chainstate is definitely not a recommended option.

What I still don't understand how two fully-synchronized non-pruned nodes can have different sizes of the chainstate. That makes no sense to me.
Due to heuristics, two LevelDB databases may have the same content, but it is not guaranteed that they are byte-to-byte identical, with the exact same size. Nodes running for different durations exhibit different write patterns. For instance, a node running for years may have more frequent but smaller writes, whereas a node completing the IBD may have fewer but larger writes.

Maybe a Bitcoin Core developer can provide us a better insight.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
ABCbits
Legendary
*
Offline Offline

Activity: 3052
Merit: 8062


Crypto Swap Exchange


View Profile
January 31, 2024, 11:04:46 AM
 #11

The command: --reindex-chainstate deletes the chainstate and creates a new chainstate from the blockchain.

Although as reminder, --reindex-chainstate will redownload whole blockchain.

So will that result in a smaller or significant difference folder size after such a reindex ? Please provide some folder sizes before/after if possible. Thanks a bunch in advance. What I still don't understand how two fully-synchronized non-pruned nodes can have different sizes of the chainstate. That makes no sense to me.

citb0in


Sorry, but i don't want to run reindex-chainstate since i only use HDD. But i don't expect much difference, where you only gain about 1GB free space. You better upgrade your storage, clear all cache on your OS and delete unused files.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
nc50lc
Legendary
*
Offline Offline

Activity: 2590
Merit: 6337


Self-proclaimed Genius


View Profile
February 01, 2024, 05:36:24 AM
 #12

The command: --reindex-chainstate deletes the chainstate and creates a new chainstate from the blockchain.
Thanks a bunch in advance. What I still don't understand how two fully-synchronized non-pruned nodes can have different sizes of the chainstate. That makes no sense to me.
Go to the link in my previous reply to see the comment of a Bitcoin Developer in bitcoin.stackexchange site regarding the chainstate database size difference.

Quote from: citb0in
So will that result in a smaller or significant difference folder size after such a reindex ? Please provide some folder sizes before/after if possible.
I've already mentioned in the first reply that it'll not be a significant difference.

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
Pages: [1]
  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!