Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth: Add --historymode flag for configurable blockchain history pruning FIX #31277 #31325

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

VolodymyrBg
Copy link

@VolodymyrBg VolodymyrBg commented Mar 5, 2025

PR Description

This PR adds a new --historymode command-line flag to geth that allows users to configure how blockchain history is retained.
Fix #31277
#31277

Overview

The --historymode flag provides a way to configure how much of the blockchain history is retained by the node. Currently, there are two options:

  • full: Keeps all blockchain history (current default)
  • pruned: Keeps only recent history according to StateHistory and TransactionHistory settings
    This flag is conceptually similar to --syncmode and --gcmode, helping users better control disk usage and database size.

Implementation Details

  • Added a new HistoryMode union type in eth/ethconfig
  • Added the HistoryMode field to the Config struct
  • Added the --historymode CLI flag
  • Implemented proper handling of the flag value in the configuration
  • Added logic to adjust transaction and state history based on the chosen mode
  • Ensured compatibility with existing flags like --gcmode

Behavior

When --historymode=pruned is set:

  • Transaction history will be limited to the value set by --txlookup (defaults to 2350000 blocks)
  • State history will be limited similarly, preventing unbounded growth
  • When combined with --gcmode=archive, a warning is shown and the incompatible settings are adjusted
    This PR lays the groundwork for eventually making pruned mode the default, which will help reduce disk usage for regular nodes without sacrificing critical functionality.

Testing

The implementation has been tested with various combinations of flags to ensure proper behavior:

  • --historymode=full (default)
  • --historymode=pruned
  • --historymode=full --gcmode=archive
  • --historymode=pruned --gcmode=archive (produces appropriate warnings)
    Tested on a local blockchain to ensure transaction history and state pruning worked as expected.

@VolodymyrBg VolodymyrBg changed the title eth: Add --historymode flag for configurable blockchain history pruning eth: Add --historymode flag for configurable blockchain history pruning FIX #31277 Mar 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Geth --historymode flag
1 participant