@@ -33,7 +33,6 @@ import (
3333 "github.com/ethereum/go-ethereum/console/prompt"
3434 "github.com/ethereum/go-ethereum/core/rawdb"
3535 "github.com/ethereum/go-ethereum/core/state/snapshot"
36- "github.com/ethereum/go-ethereum/core/types"
3736 "github.com/ethereum/go-ethereum/crypto"
3837 "github.com/ethereum/go-ethereum/ethdb"
3938 "github.com/ethereum/go-ethereum/internal/flags"
@@ -69,7 +68,6 @@ Remove blockchain and state databases`,
6968 dbImportCmd ,
7069 dbExportCmd ,
7170 dbMetadataCmd ,
72- dbMigrateFreezerCmd ,
7371 dbCheckStateContentCmd ,
7472 },
7573 }
@@ -195,17 +193,6 @@ WARNING: This is a low-level operation which may cause database corruption!`,
195193 }, utils .NetworkFlags , utils .DatabasePathFlags ),
196194 Description : "Shows metadata about the chain status." ,
197195 }
198- dbMigrateFreezerCmd = & cli.Command {
199- Action : freezerMigrate ,
200- Name : "freezer-migrate" ,
201- Usage : "Migrate legacy parts of the freezer. (WARNING: may take a long time)" ,
202- ArgsUsage : "" ,
203- Flags : flags .Merge ([]cli.Flag {
204- utils .SyncModeFlag ,
205- }, utils .NetworkFlags , utils .DatabasePathFlags ),
206- Description : `The freezer-migrate command checks your database for receipts in a legacy format and updates those.
207- WARNING: please back-up the receipt files in your ancients before running this command.` ,
208- }
209196)
210197
211198func removeDB (ctx * cli.Context ) error {
@@ -756,92 +743,3 @@ func showMetaData(ctx *cli.Context) error {
756743 table .Render ()
757744 return nil
758745}
759-
760- func freezerMigrate (ctx * cli.Context ) error {
761- stack , _ := makeConfigNode (ctx )
762- defer stack .Close ()
763-
764- db := utils .MakeChainDatabase (ctx , stack , false )
765- defer db .Close ()
766-
767- // Check first block for legacy receipt format
768- numAncients , err := db .Ancients ()
769- if err != nil {
770- return err
771- }
772- if numAncients < 1 {
773- log .Info ("No receipts in freezer to migrate" )
774- return nil
775- }
776-
777- isFirstLegacy , firstIdx , err := dbHasLegacyReceipts (db , 0 )
778- if err != nil {
779- return err
780- }
781- if ! isFirstLegacy {
782- log .Info ("No legacy receipts to migrate" )
783- return nil
784- }
785-
786- log .Info ("Starting migration" , "ancients" , numAncients , "firstLegacy" , firstIdx )
787- start := time .Now ()
788- if err := db .MigrateTable ("receipts" , types .ConvertLegacyStoredReceipts ); err != nil {
789- return err
790- }
791- if err := db .Close (); err != nil {
792- return err
793- }
794- log .Info ("Migration finished" , "duration" , time .Since (start ))
795-
796- return nil
797- }
798-
799- // dbHasLegacyReceipts checks freezer entries for legacy receipts. It stops at the first
800- // non-empty receipt and checks its format. The index of this first non-empty element is
801- // the second return parameter.
802- func dbHasLegacyReceipts (db ethdb.Database , firstIdx uint64 ) (bool , uint64 , error ) {
803- // Check first block for legacy receipt format
804- numAncients , err := db .Ancients ()
805- if err != nil {
806- return false , 0 , err
807- }
808- if numAncients < 1 {
809- return false , 0 , nil
810- }
811- if firstIdx >= numAncients {
812- return false , firstIdx , nil
813- }
814- var (
815- legacy bool
816- blob []byte
817- emptyRLPList = []byte {192 }
818- )
819- // Find first block with non-empty receipt, only if
820- // the index is not already provided.
821- if firstIdx == 0 {
822- for i := uint64 (0 ); i < numAncients ; i ++ {
823- blob , err = db .Ancient ("receipts" , i )
824- if err != nil {
825- return false , 0 , err
826- }
827- if len (blob ) == 0 {
828- continue
829- }
830- if ! bytes .Equal (blob , emptyRLPList ) {
831- firstIdx = i
832- break
833- }
834- }
835- }
836- first , err := db .Ancient ("receipts" , firstIdx )
837- if err != nil {
838- return false , 0 , err
839- }
840- // We looped over all receipts and they were all empty
841- if bytes .Equal (first , emptyRLPList ) {
842- return false , 0 , nil
843- }
844- // Is first non-empty receipt legacy?
845- legacy , err = types .IsLegacyStoredReceipts (first )
846- return legacy , firstIdx , err
847- }
0 commit comments