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:
- 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{
@ -678,7 +678,7 @@ func hashish(x string) bool {
func pruneHistory(ctx *cli.Context) error {
// Parse and validate the history mode flag.
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
if err := mode.UnmarshalText([]byte(ctx.String(utils.ChainHistoryFlag.Name))); err != nil {

View file

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

View file

@ -706,7 +706,7 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
freezerTail, _ = bc.db.Tail()
genesisHash = bc.genesisBlock.Hash()
mergePoint = history.MergePrunePoints[genesisHash]
cancunPoint = history.CancunPrunePoints[genesisHash]
praguePoint = history.PraguePrunePoints[genesisHash]
)
switch bc.cfg.ChainHistoryMode {
case history.KeepAll:
@ -719,8 +719,8 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
bc.historyPrunePoint.Store(mergePoint)
return nil
}
if cancunPoint != nil && freezerTail == cancunPoint.BlockNumber {
bc.historyPrunePoint.Store(cancunPoint)
if praguePoint != nil && freezerTail == praguePoint.BlockNumber {
bc.historyPrunePoint.Store(praguePoint)
return nil
}
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.")
return errors.New("history pruning requested via configuration")
}
// Check if DB is pruned further than requested (to Cancun).
if cancunPoint != nil && freezerTail == cancunPoint.BlockNumber {
log.Error("Chain history database is pruned to Cancun block, but postmerge mode was requested.")
// Check if DB is pruned further than requested (to Prague).
if praguePoint != nil && freezerTail == praguePoint.BlockNumber {
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("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")
}
if freezerTail > 0 && freezerTail != mergePoint.BlockNumber {
@ -748,32 +748,32 @@ func (bc *BlockChain) initializeHistoryPruning(latest uint64) error {
bc.historyPrunePoint.Store(mergePoint)
return nil
case history.KeepPostCancun:
if cancunPoint == nil {
case history.KeepPostPrague:
if praguePoint == nil {
return errors.New("history pruning requested for unknown network")
}
// Check if already at the cancun prune point.
if freezerTail == cancunPoint.BlockNumber {
bc.historyPrunePoint.Store(cancunPoint)
// Check if already at the prague prune point.
if freezerTail == praguePoint.BlockNumber {
bc.historyPrunePoint.Store(praguePoint)
return nil
}
// Check if database needs pruning.
if latest != 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("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")
}
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("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")
}
log.Error("Chain history database is pruned to unknown block", "tail", freezerTail)
return errors.New("unexpected database tail")
}
// Fresh database (latest == 0), will sync from cancun point.
bc.historyPrunePoint.Store(cancunPoint)
// Fresh database (latest == 0), will sync from prague point.
bc.historyPrunePoint.Store(praguePoint)
return nil
default:

View file

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