update based on freeezr

This commit is contained in:
Sina Mahmoodi 2025-03-14 14:57:42 +01:00 committed by Felix Lange
parent e933ed48a8
commit 6f8293d272
2 changed files with 9 additions and 18 deletions

View file

@ -665,7 +665,7 @@ func pruneHistory(ctx *cli.Context) error {
// TODO(s1na): what if there is a crash between the two prune operations?
// Truncate everything up to merge block
if _, err := chaindb.TruncateTail(mergeBlock); err != nil {
if _, err := chaindb.TruncateTailBlocks(mergeBlock); err != nil {
return fmt.Errorf("failed to truncate ancient data: %v", err)
}

View file

@ -222,14 +222,6 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
// it to the freezer content.
if kvgenesis, _ := db.Get(headerHashKey(0)); len(kvgenesis) > 0 {
if frozen, _ := frdb.Ancients(); frozen > 0 {
tail, err := frdb.Tail()
if err != nil {
printChainMetadata(db)
return nil, fmt.Errorf("failed to retrieve tail from freezer %v", err)
}
// If tail > 0, the history has been pruned and genesis block is not anymore in the freezer.
// TODO: we need another way to verify the network for kvdb and freezer match.
if tail == 0 {
// If the freezer already contains something, ensure that the genesis blocks
// match, otherwise we might mix up freezers across chains and destroy both
// the freezer and the key-value store.
@ -241,7 +233,6 @@ func NewDatabaseWithFreezer(db ethdb.KeyValueStore, ancient string, namespace st
printChainMetadata(db)
return nil, fmt.Errorf("genesis mismatch: %#x (leveldb) != %#x (ancients)", kvgenesis, frgenesis)
}
}
// Key-value store and freezer belong to the same network. Ensure that they
// are contiguous, otherwise we might end up with a non-functional freezer.
if kvhash, _ := db.Get(headerHashKey(frozen)); len(kvhash) == 0 {