Change prune point to prague

This commit is contained in:
Sina Mahmoodi 2026-03-06 18:45:14 +01:00
parent b249bf9962
commit 73c26a326a
4 changed files with 38 additions and 38 deletions

View file

@ -215,7 +215,7 @@ helps reduce storage requirements for nodes that don't need full historical data
The --history.chain flag is required to specify the pruning target: The --history.chain flag is required to specify the pruning target:
- postmerge: Prune up to the merge block - postmerge: Prune up to the merge block
- postcancun: Prune up to the Cancun (Dencun) upgrade block`, - postprague: Prune up to the Prague (Pectra) upgrade block`,
} }
downloadEraCommand = &cli.Command{ downloadEraCommand = &cli.Command{
@ -678,7 +678,7 @@ func hashish(x string) bool {
func pruneHistory(ctx *cli.Context) error { func pruneHistory(ctx *cli.Context) error {
// Parse and validate the history mode flag. // Parse and validate the history mode flag.
if !ctx.IsSet(utils.ChainHistoryFlag.Name) { if !ctx.IsSet(utils.ChainHistoryFlag.Name) {
return errors.New("--history.chain flag is required (use 'postmerge' or 'postcancun')") return errors.New("--history.chain flag is required (use 'postmerge' or 'postprague')")
} }
var mode history.HistoryMode var mode history.HistoryMode
if err := mode.UnmarshalText([]byte(ctx.String(utils.ChainHistoryFlag.Name))); err != nil { if err := mode.UnmarshalText([]byte(ctx.String(utils.ChainHistoryFlag.Name))); err != nil {

View file

@ -309,7 +309,7 @@ var (
} }
ChainHistoryFlag = &cli.StringFlag{ ChainHistoryFlag = &cli.StringFlag{
Name: "history.chain", Name: "history.chain",
Usage: `Blockchain history retention ("all", "postmerge", or "postcancun")`, Usage: `Blockchain history retention ("all", "postmerge", or "postprague")`,
Value: ethconfig.Defaults.HistoryMode.String(), Value: ethconfig.Defaults.HistoryMode.String(),
Category: flags.StateCategory, Category: flags.StateCategory,
} }

View file

@ -706,7 +706,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
freezerTail, _ = bc.db.Tail() freezerTail, _ = bc.db.Tail()
genesisHash = bc.genesisBlock.Hash() genesisHash = bc.genesisBlock.Hash()
mergePoint = history.MergePrunePoints[genesisHash] mergePoint = history.MergePrunePoints[genesisHash]
cancunPoint = history.CancunPrunePoints[genesisHash] praguePoint = history.PraguePrunePoints[genesisHash]
) )
switch bc.cfg.ChainHistoryMode { switch bc.cfg.ChainHistoryMode {
case history.KeepAll: case history.KeepAll:
@ -719,8 +719,8 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
bc.historyPrunePoint.Store(mergePoint) bc.historyPrunePoint.Store(mergePoint)
return nil return nil
} }
if cancunPoint != nil && freezerTail == cancunPoint.BlockNumber { if praguePoint != nil && freezerTail == praguePoint.BlockNumber {
bc.historyPrunePoint.Store(cancunPoint) bc.historyPrunePoint.Store(praguePoint)
return nil return nil
} }
log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail) log.Error("Chain history database is pruned with unknown configuration", "tail", freezerTail)
@ -735,11 +735,11 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
log.Error("Run 'geth prune-history --history.chain postmerge' to prune pre-merge history.") log.Error("Run 'geth prune-history --history.chain postmerge' to prune pre-merge history.")
return errors.New("history pruning requested via configuration") return errors.New("history pruning requested via configuration")
} }
// Check if DB is pruned further than requested (to Cancun). // Check if DB is pruned further than requested (to Prague).
if cancunPoint != nil && freezerTail == cancunPoint.BlockNumber { if praguePoint != nil && freezerTail == praguePoint.BlockNumber {
log.Error("Chain history database is pruned to Cancun block, but postmerge mode was requested.") log.Error("Chain history database is pruned to Prague block, but postmerge mode was requested.")
log.Error("History cannot be unpruned. To restore history, use 'geth import-history'.") log.Error("History cannot be unpruned. To restore history, use 'geth import-history'.")
log.Error("If you intended to keep post-Cancun history, use '--history.chain postcancun' instead.") log.Error("If you intended to keep post-Prague history, use '--history.chain postprague' instead.")
return errors.New("database pruned beyond requested history mode") return errors.New("database pruned beyond requested history mode")
} }
if freezerTail > 0 && freezerTail != mergePoint.BlockNumber { if freezerTail > 0 && freezerTail != mergePoint.BlockNumber {
@ -748,32 +748,32 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
bc.historyPrunePoint.Store(mergePoint) bc.historyPrunePoint.Store(mergePoint)
return nil return nil
case history.KeepPostCancun: case history.KeepPostPrague:
if cancunPoint == nil { if praguePoint == nil {
return errors.New("history pruning requested for unknown network") return errors.New("history pruning requested for unknown network")
} }
// Check if already at the cancun prune point. // Check if already at the prague prune point.
if freezerTail == cancunPoint.BlockNumber { if freezerTail == praguePoint.BlockNumber {
bc.historyPrunePoint.Store(cancunPoint) bc.historyPrunePoint.Store(praguePoint)
return nil return nil
} }
// Check if database needs pruning. // Check if database needs pruning.
if latest != 0 { if latest != 0 {
if freezerTail == 0 { if freezerTail == 0 {
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String())) log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is not pruned.", bc.cfg.ChainHistoryMode.String()))
log.Error("Run 'geth prune-history --history.chain postcancun' to prune pre-Cancun history.") log.Error("Run 'geth prune-history --history.chain postprague' to prune pre-Prague history.")
return errors.New("history pruning requested via configuration") return errors.New("history pruning requested via configuration")
} }
if mergePoint != nil && freezerTail == mergePoint.BlockNumber { if mergePoint != nil && freezerTail == mergePoint.BlockNumber {
log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is only pruned to merge block.", bc.cfg.ChainHistoryMode.String())) log.Error(fmt.Sprintf("Chain history mode is configured as %q, but database is only pruned to merge block.", bc.cfg.ChainHistoryMode.String()))
log.Error("Run 'geth prune-history --history.chain postcancun' to prune pre-Cancun history.") log.Error("Run 'geth prune-history --history.chain postprague' to prune pre-Prague history.")
return errors.New("history pruning requested via configuration") return errors.New("history pruning requested via configuration")
} }
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail) log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
return errors.New("unexpected database tail") return errors.New("unexpected database tail")
} }
// Fresh database (latest == 0), will sync from cancun point. // Fresh database (latest == 0), will sync from prague point.
bc.historyPrunePoint.Store(cancunPoint) bc.historyPrunePoint.Store(praguePoint)
return nil return nil
default: default:

View file

@ -33,12 +33,12 @@ const (
// KeepPostMerge sets the history pruning point to the merge activation block. // KeepPostMerge sets the history pruning point to the merge activation block.
KeepPostMerge KeepPostMerge
// KeepPostCancun sets the history pruning point to the Cancun (Dencun) activation block. // KeepPostPrague sets the history pruning point to the Prague (Pectra) activation block.
KeepPostCancun KeepPostPrague
) )
func (m HistoryMode) IsValid() bool { func (m HistoryMode) IsValid() bool {
return m <= KeepPostCancun return m <= KeepPostPrague
} }
func (m HistoryMode) String() string { func (m HistoryMode) String() string {
@ -47,8 +47,8 @@ func (m HistoryMode) String() string {
return "all" return "all"
case KeepPostMerge: case KeepPostMerge:
return "postmerge" return "postmerge"
case KeepPostCancun: case KeepPostPrague:
return "postcancun" return "postprague"
default: default:
return fmt.Sprintf("invalid HistoryMode(%d)", m) return fmt.Sprintf("invalid HistoryMode(%d)", m)
} }
@ -69,10 +69,10 @@ func (m *HistoryMode) UnmarshalText(text []byte) error {
*m = KeepAll *m = KeepAll
case "postmerge": case "postmerge":
*m = KeepPostMerge *m = KeepPostMerge
case "postcancun": case "postprague":
*m = KeepPostCancun *m = KeepPostPrague
default: default:
return fmt.Errorf(`unknown history mode %q, want "all", "postmerge", or "postcancun"`, text) return fmt.Errorf(`unknown history mode %q, want "all", "postmerge", or "postprague"`, text)
} }
return nil return nil
} }
@ -98,19 +98,19 @@ var MergePrunePoints = map[common.Hash]*PrunePoint{
}, },
} }
// CancunPrunePoints contains the pre-defined history pruning cutoff blocks for the Cancun // PraguePrunePoints contains the pre-defined history pruning cutoff blocks for the Prague
// (Dencun) upgrade. They point to the first post-Cancun block. Any pruning should truncate // (Pectra) upgrade. They point to the first post-Prague block. Any pruning should truncate
// *up to* but excluding the given block. // *up to* but excluding the given block.
var CancunPrunePoints = map[common.Hash]*PrunePoint{ var PraguePrunePoints = map[common.Hash]*PrunePoint{
// mainnet - first Cancun block (March 13, 2024) // mainnet - first Prague block (May 7, 2025)
params.MainnetGenesisHash: { params.MainnetGenesisHash: {
BlockNumber: 19426587, BlockNumber: 22431084,
BlockHash: common.HexToHash("0xf8e2f40d98fe5862bc947c8c83d34799c50fb344d7445d020a8a946d891b62ee"), BlockHash: common.HexToHash("0x50c8cab760b2948349c590461b166773c45d8f4858cccf5a43025ab2960152e8"),
}, },
// sepolia - first Cancun block (January 30, 2024) // sepolia - first Prague block (March 5, 2025)
params.SepoliaGenesisHash: { params.SepoliaGenesisHash: {
BlockNumber: 5187023, BlockNumber: 7836331,
BlockHash: common.HexToHash("0x8f9753667f95418f70db36279a269ed6523cea399ecc3f4cfa2f1689a3a4b130"), BlockHash: common.HexToHash("0xe6571beb68bf24dbd8a6ba354518996920c55a3f8d8fdca423e391b8ad071f22"),
}, },
} }
@ -124,8 +124,8 @@ func GetPrunePoint(genesisHash common.Hash, mode HistoryMode) *PrunePoint {
switch mode { switch mode {
case KeepPostMerge: case KeepPostMerge:
return MergePrunePoints[genesisHash] return MergePrunePoints[genesisHash]
case KeepPostCancun: case KeepPostPrague:
return CancunPrunePoints[genesisHash] return PraguePrunePoints[genesisHash]
default: default:
return nil return nil
} }