-
I ran some experiments with the substrate node template where I set the block time to 10ms so that blocks would be produce incredibly fast, and I was surprised to find that the database growth, in the scenario where all the generated blocks are empty except for the timestamp, didn't seem to be helping. For example, after 5000 blocks in archive mode, the database directory was 20M. After the same amount of blocks with the pruning set to retain only 5 blocks, the database directory was actually larger at 55M! What's going on here? That seems pretty strange. :) Ideally, for my use-case I would like to have an upper-bound on how large the database usage will get. I don't need a permanent block history all the way to genesis in my case. I would like the ability for users to opt-in to having the whole chain without having to require it. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
Indeed blocks are not pruned, it is a deliberate choice to advocate users to keep chain history on their full nodes (same thing with warp sync, history will be download in background). |
Beta Was this translation helpful? Give feedback.
-
Pruning setting only affects the state available. I.e. with pruning 100 you can query the state of the last 100 finalized blocks, but no further. The nodes still stores full history of block headers, bodies and signatures. You can also try using experimental |
Beta Was this translation helpful? Give feedback.
-
I tested out using What is happening when I restart the node and it cleans up all that extra space? Is there a way to force it to do that periodically, without having to restart the node? |
Beta Was this translation helpful? Give feedback.
-
It offers less security, although still enough for any practical use. The effects you observe regarding database compaction should not matter for any real world blockchain application. Substrate is optimized for data size over 1Gb. On that scale temporary database overhead is insignificant. Even with If you are developing for the constrained embedded environment take a look at smoldot as @cheme suggested. |
Beta Was this translation helpful? Give feedback.
Pruning setting only affects the state available. I.e. with pruning 100 you can query the state of the last 100 finalized blocks, but no further. The nodes still stores full history of block headers, bodies and signatures.
You can also try using experimental
--keep-blocks
option, that limits stored block body history, but still keeps the headers. Note that if all the nodes on your network don't have the block history, your only option to sync a new node with the network is to use fast or warp sync.