Skip to content

Removal of old trie logs specified by historical block limit #5390

@non-fungible-nelson

Description

@non-fungible-nelson

How to enable this feature: https://wiki.hyperledger.org/display/BESU/Limit+Trie+Logs+for+Bonsai

There is no need to keep all the trie logs for a near-head node as the state for old blocks is rarely needed. This will place a configurable limit on how many trie logs are kept reducing storage needed for a node.

  • Add configurable limit for number trie logs to be kept. This should be the same as the Bonsai read limit config
    --bonsai-historical-block-limit parameter
  • Prune old trie logs that are not needed
  • Trie logs are stored by block hash so there will need to be a way of determining with block hashes to remove the trie logs for
  • The logic used for the block pruning which keeps a list of block hashes for each block number could possibly be reused for pruning the trie log
  • This should be enabled independently of the chain data pruning feature and can be used together
  • Measure storage saved by having the trie log pruning enabled
  • Test that reorgs have their trie log pruned

Acceptance Criteria

  • DB size of long running node should be the same before and after resync

Notes:

  • The ChainDataPruner could be a helpful place to start and reuse some of the same logic

Tasks:


Nice to have:

  • Reorg acceptance test
  • Optimisation 3: Cache finalizedBlockHeader in Blockchain or use Observer pattern to pass it to the pruner
  • Consider an option to only prune forks
  • Prevent block building from saving orphaned trie logs ?
  • Optimisation 2: Prune in batches instead of every block?

Metadata

Metadata

Labels

TeamGrootGH issues worked on by Groot Teambonsai

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions