From e58f02a8342b2ae8864e8bf195034e66b9578632 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 18 Sep 2024 06:53:58 -0400 Subject: [PATCH 01/12] Archive Node Online Migration --- app/test_state_store.go | 20 +++++++++ go.mod | 2 +- tools/migration/ss/migrator.go | 82 ++++++++++++++++++++++------------ 3 files changed, 74 insertions(+), 30 deletions(-) diff --git a/app/test_state_store.go b/app/test_state_store.go index 15b4d63e1..a5b071145 100644 --- a/app/test_state_store.go +++ b/app/test_state_store.go @@ -244,6 +244,26 @@ func (s *InMemoryStateStore) RawImport(ch <-chan types.RawSnapshotNode) error { return nil } +func (s *InMemoryStateStore) SetLatestMigratedModule(module string) error { + // TODO: Add set call here + return nil +} + +func (s *InMemoryStateStore) GetLatestMigratedModule() (string, error) { + // TODO: Add get call here + return "", nil +} + +func (s *InMemoryStateStore) SetLatestMigratedKey(key []byte) error { + // TODO: Add set call here + return nil +} + +func (s *InMemoryStateStore) GetLatestMigratedKey() ([]byte, error) { + // TODO: Add get call here + return nil, nil +} + func (s *InMemoryStateStore) Prune(version int64) error { s.mu.Lock() defer s.mu.Unlock() diff --git a/go.mod b/go.mod index 5d794e01b..068e018ec 100644 --- a/go.mod +++ b/go.mod @@ -351,7 +351,7 @@ replace ( github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.44 + github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891 // Latest goleveldb is broken, we have to stick to this version github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.3.8 diff --git a/tools/migration/ss/migrator.go b/tools/migration/ss/migrator.go index cb4e42bfc..2e08a0900 100644 --- a/tools/migration/ss/migrator.go +++ b/tools/migration/ss/migrator.go @@ -3,6 +3,7 @@ package ss import ( "bytes" "fmt" + "time" "github.com/cosmos/iavl" "github.com/sei-protocol/sei-db/config" @@ -43,36 +44,42 @@ func NewMigrator(homeDir string, db dbm.DB) *Migrator { } func (m *Migrator) Migrate(version int64, homeDir string) error { - // TODO: Read in capacity of this buffered channel as param ch := make(chan types.RawSnapshotNode, 1000) errCh := make(chan error, 2) - fmt.Println("Beginning Migration...") + // Get the latest key, if any, to resume from + latestKey, err := m.stateStore.GetLatestMigratedKey() + if err != nil { + return fmt.Errorf("failed to get latest key: %w", err) + } + + latestModule, err := m.stateStore.GetLatestMigratedModule() + if err != nil { + return fmt.Errorf("failed to get latest module: %w", err) + } - // Goroutine to iterate through iavl and export leaf nodes + fmt.Println("Starting migration...") + + // Goroutine to iterate through IAVL and export leaf nodes go func() { defer close(ch) - errCh <- ExportLeafNodes(m.iavlDB, ch) + errCh <- ExportLeafNodesFromKey(m.iavlDB, ch, latestKey, latestModule) }() + // Import nodes into PebbleDB go func() { errCh <- m.stateStore.RawImport(ch) }() - // Block on completion of both goroutines + // Block until both processes complete for i := 0; i < 2; i++ { if err := <-errCh; err != nil { return err } } - // Set latest version - err := m.stateStore.SetLatestVersion(version) - if err != nil { - return err - } - - return nil + // Set latest version in the database + return m.stateStore.SetLatestVersion(version) } func (m *Migrator) Verify(version int64) error { @@ -113,40 +120,52 @@ func (m *Migrator) Verify(version int64) error { return verifyErr } -// Export leaf nodes of iavl -func ExportLeafNodes(db dbm.DB, ch chan<- types.RawSnapshotNode) error { - // Module by module, TODO: Potentially parallelize +func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey []byte, startModule string) error { count := 0 leafNodeCount := 0 - fmt.Println("Scanning database and exporting leaf nodes...") + fmt.Println("ExportLeafNodesFromKey - Scanning database and exporting leaf nodes...") + + startTimeTotal := time.Now() // Start measuring total time for _, module := range modules { - fmt.Printf("Iterating through %s module...\n", module) + if module != startModule && startModule != "" { + continue + } + startTimeModule := time.Now() // Measure time for each module + fmt.Printf("ExportLeafNodesFromKey - Iterating through %s module...\n", module) - // Can't use the previous, have to create an inner prefixDB := dbm.NewPrefixDB(db, []byte(buildRawPrefix(module))) - itr, err := prefixDB.Iterator(nil, nil) + var itr dbm.Iterator + var err error + + // If there is a starting key, seek to it, otherwise start from the beginning + if startKey != nil && bytes.HasPrefix(startKey, []byte(buildRawPrefix(module))) { + itr, err = prefixDB.Iterator(startKey, nil) // Start from the latest key + } else { + itr, err = prefixDB.Iterator(nil, nil) // Start from the beginning + } + if err != nil { - fmt.Printf("error Export Leaf Nodes %+v\n", err) + fmt.Printf("ExportLeafNodesFromKey - Error creating iterator: %+v\n", err) return fmt.Errorf("failed to create iterator: %w", err) } defer itr.Close() + startTimeBatch := time.Now() // Measure time for every 10,000 iterations + for ; itr.Valid(); itr.Next() { value := bytes.Clone(itr.Value()) node, err := iavl.MakeNode(value) - if err != nil { - fmt.Printf("failed to make node err: %+v\n", err) + fmt.Printf("ExportLeafNodesFromKey - Failed to make node: %+v\n", err) return fmt.Errorf("failed to make node: %w", err) } - // leaf node + // Only export leaf nodes if node.GetHeight() == 0 { leafNodeCount++ ch <- types.RawSnapshotNode{ - // TODO: Likely need to clone StoreKey: module, Key: node.GetNodeKey(), Value: node.GetValue(), @@ -156,20 +175,25 @@ func ExportLeafNodes(db dbm.DB, ch chan<- types.RawSnapshotNode) error { count++ if count%10000 == 0 { - fmt.Printf("Total scanned: %d, leaf nodes exported: %d\n", count, leafNodeCount) + batchDuration := time.Since(startTimeBatch) + fmt.Printf("ExportLeafNodesFromKey - Last 10,000 iterations took: %v. Total scanned: %d, leaf nodes exported: %d\n", batchDuration, count, leafNodeCount) + + startTimeBatch = time.Now() // Reset the start time for the next batch } } - fmt.Printf("Finished scanning module %s Total scanned: %d, leaf nodes exported: %d\n", module, count, leafNodeCount) - if err := itr.Error(); err != nil { - fmt.Printf("iterator error: %+v\n", err) + fmt.Printf("Iterator error: %+v\n", err) return fmt.Errorf("iterator error: %w", err) } + moduleDuration := time.Since(startTimeModule) + fmt.Printf("ExportLeafNodesFromKey - Finished scanning module %s. Time taken: %v. Total scanned: %d, leaf nodes exported: %d\n", module, moduleDuration, count, leafNodeCount) } - fmt.Printf("DB contains %d entries, exported %d leaf nodes\n", count, leafNodeCount) + totalDuration := time.Since(startTimeTotal) + fmt.Printf("ExportLeafNodesFromKey - DB scanning completed. Total time taken: %v. Total entries scanned: %d, leaf nodes exported: %d\n", totalDuration, count, leafNodeCount) + return nil } From 27a16763f704e053c6cf73a620acc8f561002cda Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Mon, 23 Sep 2024 10:25:27 -0400 Subject: [PATCH 02/12] Add migrate-iavl flag for online migration --- app/app.go | 7 ++++++- app/seidb.go | 7 ++++--- cmd/seid/cmd/root.go | 20 +++++++++++++++++++- tools/migration/cmd/cmd.go | 31 +++++++++++++++++++++++++------ tools/migration/ss/migrator.go | 14 +------------- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/app/app.go b/app/app.go index 580aef2d4..cb2e6136d 100644 --- a/app/app.go +++ b/app/app.go @@ -368,6 +368,7 @@ type App struct { genesisImportConfig genesistypes.GenesisImportConfig + stateStore seidb.StateStore receiptStore seidb.StateStore } @@ -396,7 +397,7 @@ func New( cdc := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry - bAppOptions := SetupSeiDB(logger, homePath, appOpts, baseAppOptions) + bAppOptions, stateStore := SetupSeiDB(logger, homePath, appOpts, baseAppOptions) bApp := baseapp.NewBaseApp(AppName, logger, db, encodingConfig.TxConfig.TxDecoder(), tmConfig, appOpts, bAppOptions...) bApp.SetCommitMultiStoreTracer(traceStore) @@ -429,6 +430,7 @@ func New( versionInfo: version.NewInfo(), metricCounter: &map[string]float32{}, encodingConfig: encodingConfig, + stateStore: stateStore, } for _, option := range appOptions { @@ -1064,6 +1066,9 @@ func (app *App) Name() string { return app.BaseApp.Name() } // GetBaseApp returns the base app of the application func (app App) GetBaseApp() *baseapp.BaseApp { return app.BaseApp } +// GetStateStore returns the state store of the application +func (app App) GetStateStore() seidb.StateStore { return app.stateStore } + // BeginBlocker application updates every begin block func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock { metrics.GaugeSeidVersionAndCommit(app.versionInfo.Version, app.versionInfo.GitCommit) diff --git a/app/seidb.go b/app/seidb.go index a50614639..5c25b5a34 100644 --- a/app/seidb.go +++ b/app/seidb.go @@ -7,6 +7,7 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/storev2/rootmulti" "github.com/sei-protocol/sei-db/config" + seidb "github.com/sei-protocol/sei-db/ss/types" "github.com/spf13/cast" "github.com/tendermint/tendermint/libs/log" ) @@ -40,11 +41,11 @@ func SetupSeiDB( homePath string, appOpts servertypes.AppOptions, baseAppOptions []func(*baseapp.BaseApp), -) []func(*baseapp.BaseApp) { +) ([]func(*baseapp.BaseApp), seidb.StateStore) { scEnabled := cast.ToBool(appOpts.Get(FlagSCEnable)) if !scEnabled { logger.Info("SeiDB is disabled, falling back to IAVL") - return baseAppOptions + return baseAppOptions, nil } logger.Info("SeiDB SC is enabled, running node with StoreV2 commit store") scConfig := parseSCConfigs(appOpts) @@ -63,7 +64,7 @@ func SetupSeiDB( }, }, baseAppOptions...) - return baseAppOptions + return baseAppOptions, cms.GetStateStore() } func parseSCConfigs(appOpts servertypes.AppOptions) config.StateCommitConfig { diff --git a/cmd/seid/cmd/root.go b/cmd/seid/cmd/root.go index df8ed1fe1..5e0b927c5 100644 --- a/cmd/seid/cmd/root.go +++ b/cmd/seid/cmd/root.go @@ -26,6 +26,7 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/store" + "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/utils/tracing" aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper" @@ -38,6 +39,7 @@ import ( "github.com/sei-protocol/sei-chain/app/params" "github.com/sei-protocol/sei-chain/evmrpc" "github.com/sei-protocol/sei-chain/tools" + "github.com/sei-protocol/sei-chain/tools/migration/ss" "github.com/sei-protocol/sei-chain/x/evm/blocktest" "github.com/sei-protocol/sei-chain/x/evm/querier" "github.com/sei-protocol/sei-chain/x/evm/replay" @@ -220,6 +222,7 @@ func txCommand() *cobra.Command { func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) + startCmd.Flags().Bool("migrate-iavl", false, "Run migration of IAVL data store to SeiDB State Store") } // newApp creates a new Cosmos SDK app @@ -266,7 +269,7 @@ func newApp( // This makes it such that the wasm VM gas converts to sdk gas at a 6.66x rate vs that of the previous multiplier wasmGasRegisterConfig.GasMultiplier = 21_000_000 - return app.New( + app := app.New( logger, db, traceStore, @@ -302,6 +305,21 @@ func newApp( baseapp.SetSnapshotDirectory(cast.ToString(appOpts.Get(server.FlagStateSyncSnapshotDir))), baseapp.SetOccEnabled(cast.ToBool(appOpts.Get(baseapp.FlagOccEnabled))), ) + + // Start migration if --migrate flag is set + if cast.ToBool(appOpts.Get("migrate-iavl")) { + go func() { + homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) + stateStore := app.GetStateStore() + latestVersion := rootmulti.GetLatestVersion(db) + migrator := ss.NewMigrator(homeDir, db, stateStore) + if err := migrator.Migrate(latestVersion, homeDir); err != nil { + panic(err) + } + }() + } + + return app } // appExport creates a new simapp (optionally at a given height) diff --git a/tools/migration/cmd/cmd.go b/tools/migration/cmd/cmd.go index d1ff27a28..578265ffd 100644 --- a/tools/migration/cmd/cmd.go +++ b/tools/migration/cmd/cmd.go @@ -7,7 +7,10 @@ import ( "github.com/cosmos/cosmos-sdk/store/rootmulti" "github.com/sei-protocol/sei-chain/tools/migration/sc" "github.com/sei-protocol/sei-chain/tools/migration/ss" + "github.com/sei-protocol/sei-db/config" + sstypes "github.com/sei-protocol/sei-db/ss" "github.com/spf13/cobra" + "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" ) @@ -51,13 +54,16 @@ func migrateSC(version int64, homeDir string, db dbm.DB) error { } func migrateSS(version int64, homeDir string, db dbm.DB) error { - migrator := ss.NewMigrator(homeDir, db) - return migrator.Migrate(version, homeDir) -} + ssConfig := config.DefaultStateStoreConfig() + ssConfig.Enable = true -func verifySS(version int64, homeDir string, db dbm.DB) error { - migrator := ss.NewMigrator(homeDir, db) - return migrator.Verify(version) + stateStore, err := sstypes.NewStateStore(log.NewNopLogger(), homeDir, ssConfig) + if err != nil { + return err + } + + migrator := ss.NewMigrator(homeDir, db, stateStore) + return migrator.Migrate(version, homeDir) } func VerifyMigrationCmd() *cobra.Command { @@ -97,3 +103,16 @@ func verify(cmd *cobra.Command, _ []string) { fmt.Println("Verification Succeeded") } + +func verifySS(version int64, homeDir string, db dbm.DB) error { + ssConfig := config.DefaultStateStoreConfig() + ssConfig.Enable = true + + stateStore, err := sstypes.NewStateStore(log.NewNopLogger(), homeDir, ssConfig) + if err != nil { + return err + } + + migrator := ss.NewMigrator(homeDir, db, stateStore) + return migrator.Verify(version) +} diff --git a/tools/migration/ss/migrator.go b/tools/migration/ss/migrator.go index 2e08a0900..4fde4aa41 100644 --- a/tools/migration/ss/migrator.go +++ b/tools/migration/ss/migrator.go @@ -6,10 +6,7 @@ import ( "time" "github.com/cosmos/iavl" - "github.com/sei-protocol/sei-db/config" - "github.com/sei-protocol/sei-db/ss" "github.com/sei-protocol/sei-db/ss/types" - "github.com/tendermint/tendermint/libs/log" dbm "github.com/tendermint/tm-db" ) @@ -27,16 +24,7 @@ var modules = []string{ "wasm", "aclaccesscontrol", "oracle", "epoch", "mint", "acc", "bank", "feegrant", "staking", "distribution", "slashing", "gov", "params", "ibc", "upgrade", "evidence", "transfer", "tokenfactory", } -func NewMigrator(homeDir string, db dbm.DB) *Migrator { - // TODO: Pass in more configs outside default, in particular ImportNumWorkers - ssConfig := config.DefaultStateStoreConfig() - ssConfig.Enable = true - - stateStore, err := ss.NewStateStore(log.NewNopLogger(), homeDir, ssConfig) - if err != nil { - panic(err) - } - +func NewMigrator(homeDir string, db dbm.DB, stateStore types.StateStore) *Migrator { return &Migrator{ iavlDB: db, stateStore: stateStore, From c28c7830e7a2526b01e96a735d3abe5c64dd7ae1 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Tue, 24 Sep 2024 23:35:33 -0400 Subject: [PATCH 03/12] Update sei cosmos --- go.mod | 2 +- go.sum | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 068e018ec..6686daadb 100644 --- a/go.mod +++ b/go.mod @@ -346,7 +346,7 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.37-0.20240923023912-aa7a702d42cc + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955 github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b diff --git a/go.sum b/go.sum index 38d948197..69fcb61fe 100644 --- a/go.sum +++ b/go.sum @@ -1347,10 +1347,10 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= -github.com/sei-protocol/sei-cosmos v0.3.37-0.20240923023912-aa7a702d42cc h1:srWLbsoS0NYBIl8OjZOFuPmIeqf+fJTkfsK39MmG3+k= -github.com/sei-protocol/sei-cosmos v0.3.37-0.20240923023912-aa7a702d42cc/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= -github.com/sei-protocol/sei-db v0.0.44 h1:HMgcyDTQlmXdJysHJxmIo66EKeXn1CSQT9qXDnxjJgI= -github.com/sei-protocol/sei-db v0.0.44/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= +github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955 h1:FXeQsPJSb+EOKTBcWdrShJ1FwyxlR7Yum2uXBURzXLk= +github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= +github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891 h1:gf23XvhKmCRyMvzEe2puRp3ZuXvw3noqF1cL1XxMQHQ= +github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 h1:BaMZ6gjwqe3R/5dLmcJ1TkSZ3omcWy2TjaAZAeOJH44= From 3ac501fec8fe7026669be58f2a2d318a1fcb36bc Mon Sep 17 00:00:00 2001 From: Yiming Zang <50607998+yzang2019@users.noreply.github.com> Date: Tue, 24 Sep 2024 20:38:47 -0700 Subject: [PATCH 04/12] Add QMS for online migration (#1870) * Add QMS for online migration * Fix lint --------- Co-authored-by: kbhat1 --- app/seidb.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/seidb.go b/app/seidb.go index 5c25b5a34..5c7e2a38c 100644 --- a/app/seidb.go +++ b/app/seidb.go @@ -34,6 +34,8 @@ const ( // Other configs FlagSnapshotInterval = "state-sync.snapshot-interval" + FlagMigrateIAVL = "migrate-iavl" + FlagMigrateHeight = "migrate-height" ) func SetupSeiDB( @@ -58,8 +60,15 @@ func SetupSeiDB( // cms must be overridden before the other options, because they may use the cms, // make sure the cms aren't be overridden by the other options later on. cms := rootmulti.NewStore(homePath, logger, scConfig, ssConfig) + migrationEnabled := cast.ToBool(appOpts.Get(FlagMigrateIAVL)) + migrationHeight := cast.ToInt64(appOpts.Get(FlagMigrateHeight)) baseAppOptions = append([]func(*baseapp.BaseApp){ func(baseApp *baseapp.BaseApp) { + if migrationEnabled { + originalCMS := baseApp.CommitMultiStore() + baseApp.SetQueryMultiStore(originalCMS) + baseApp.SetMigrationHeight(migrationHeight) + } baseApp.SetCMS(cms) }, }, baseAppOptions...) From 30a83118c8b17a5ea2aec59b0ab2fdaa168edea5 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 25 Sep 2024 17:09:20 -0400 Subject: [PATCH 05/12] Add migrate-height flag to start cmd --- cmd/seid/cmd/root.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/seid/cmd/root.go b/cmd/seid/cmd/root.go index 5e0b927c5..81c7f8203 100644 --- a/cmd/seid/cmd/root.go +++ b/cmd/seid/cmd/root.go @@ -26,7 +26,6 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/snapshots" "github.com/cosmos/cosmos-sdk/store" - "github.com/cosmos/cosmos-sdk/store/rootmulti" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/utils/tracing" aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper" @@ -223,6 +222,7 @@ func txCommand() *cobra.Command { func addModuleInitFlags(startCmd *cobra.Command) { crisis.AddModuleInitFlags(startCmd) startCmd.Flags().Bool("migrate-iavl", false, "Run migration of IAVL data store to SeiDB State Store") + startCmd.Flags().Int64("migrate-height", 0, "Height at which to start the migration") } // newApp creates a new Cosmos SDK app @@ -311,9 +311,9 @@ func newApp( go func() { homeDir := cast.ToString(appOpts.Get(flags.FlagHome)) stateStore := app.GetStateStore() - latestVersion := rootmulti.GetLatestVersion(db) + migrationHeight := cast.ToInt64(appOpts.Get("migrate-height")) migrator := ss.NewMigrator(homeDir, db, stateStore) - if err := migrator.Migrate(latestVersion, homeDir); err != nil { + if err := migrator.Migrate(migrationHeight, homeDir); err != nil { panic(err) } }() From e75b2224e7b85abc83736a409caf510c32998966 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Mon, 7 Oct 2024 08:30:29 -0600 Subject: [PATCH 06/12] Bump seidb --- app/seidb.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- tools/migration/sc/migrator.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/seidb.go b/app/seidb.go index 5c7e2a38c..175d5c1a4 100644 --- a/app/seidb.go +++ b/app/seidb.go @@ -59,7 +59,7 @@ func SetupSeiDB( // cms must be overridden before the other options, because they may use the cms, // make sure the cms aren't be overridden by the other options later on. - cms := rootmulti.NewStore(homePath, logger, scConfig, ssConfig) + cms := rootmulti.NewStore(homePath, logger, scConfig, ssConfig, cast.ToBool(appOpts.Get("migrate-iavl"))) migrationEnabled := cast.ToBool(appOpts.Get(FlagMigrateIAVL)) migrationHeight := cast.ToInt64(appOpts.Get(FlagMigrateHeight)) baseAppOptions = append([]func(*baseapp.BaseApp){ diff --git a/go.mod b/go.mod index 6686daadb..9b7ba9b62 100644 --- a/go.mod +++ b/go.mod @@ -346,7 +346,7 @@ require ( replace ( github.com/CosmWasm/wasmd => github.com/sei-protocol/sei-wasmd v0.2.4 github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8.0 - github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955 + github.com/cosmos/cosmos-sdk => github.com/sei-protocol/sei-cosmos v0.3.37-0.20241007142359-ca29513f17aa github.com/cosmos/iavl => github.com/sei-protocol/sei-iavl v0.2.0 github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b diff --git a/go.sum b/go.sum index 69fcb61fe..730ac96a9 100644 --- a/go.sum +++ b/go.sum @@ -1347,8 +1347,8 @@ github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b/go.mod h1:kcRZmuzRn1lVejiFNTz4l4W7imnpq1bDAnuKS/RyhbQ= github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQpIbXDA= github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= -github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955 h1:FXeQsPJSb+EOKTBcWdrShJ1FwyxlR7Yum2uXBURzXLk= -github.com/sei-protocol/sei-cosmos v0.3.37-0.20240925031313-e61849179955/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= +github.com/sei-protocol/sei-cosmos v0.3.37-0.20241007142359-ca29513f17aa h1:F27bny97cLUl1PAUX67qnFEAwH2OtLXH/b3r5S3mfVA= +github.com/sei-protocol/sei-cosmos v0.3.37-0.20241007142359-ca29513f17aa/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891 h1:gf23XvhKmCRyMvzEe2puRp3ZuXvw3noqF1cL1XxMQHQ= github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= diff --git a/tools/migration/sc/migrator.go b/tools/migration/sc/migrator.go index 5eec43a62..d3fe2a949 100644 --- a/tools/migration/sc/migrator.go +++ b/tools/migration/sc/migrator.go @@ -77,7 +77,7 @@ func NewMigrator(homeDir string, db dbm.DB) *Migrator { scConfig.Enable = true ssConfig := config.DefaultStateStoreConfig() ssConfig.Enable = false - cmsV2 := rootmulti2.NewStore(homeDir, logger, scConfig, ssConfig) + cmsV2 := rootmulti2.NewStore(homeDir, logger, scConfig, ssConfig, true) for _, key := range Keys { cmsV2.MountStoreWithDB(key, sdk.StoreTypeIAVL, db) } From fa3c6b69c5aa52b8bf8bfa73a69b7f2212cda456 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 9 Oct 2024 13:19:07 -0400 Subject: [PATCH 07/12] Reduce logging --- go.mod | 2 +- go.sum | 4 ++-- tools/migration/ss/migrator.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 9b7ba9b62..83a01a321 100644 --- a/go.mod +++ b/go.mod @@ -351,7 +351,7 @@ replace ( github.com/cosmos/ibc-go/v3 => github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 github.com/ethereum/go-ethereum => github.com/sei-protocol/go-ethereum v1.13.5-sei-9.0.20240923025222-815b87dde97b github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 - github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891 + github.com/sei-protocol/sei-db => github.com/sei-protocol/sei-db v0.0.45-0.20241009171123-c9b6c253819b // Latest goleveldb is broken, we have to stick to this version github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/sei-protocol/sei-tendermint v0.3.8 diff --git a/go.sum b/go.sum index 730ac96a9..0fc966151 100644 --- a/go.sum +++ b/go.sum @@ -1349,8 +1349,8 @@ github.com/sei-protocol/goutils v0.0.2 h1:Bfa7Sv+4CVLNM20QcpvGb81B8C5HkQC/kW1CQp github.com/sei-protocol/goutils v0.0.2/go.mod h1:iYE2DuJfEnM+APPehr2gOUXfuLuPsVxorcDO+Tzq9q8= github.com/sei-protocol/sei-cosmos v0.3.37-0.20241007142359-ca29513f17aa h1:F27bny97cLUl1PAUX67qnFEAwH2OtLXH/b3r5S3mfVA= github.com/sei-protocol/sei-cosmos v0.3.37-0.20241007142359-ca29513f17aa/go.mod h1:ZwWxF/69WlcLEn4BzVjPPToTFkE2sjPanU8PNNyKoOk= -github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891 h1:gf23XvhKmCRyMvzEe2puRp3ZuXvw3noqF1cL1XxMQHQ= -github.com/sei-protocol/sei-db v0.0.45-0.20240918104613-6c0900823891/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= +github.com/sei-protocol/sei-db v0.0.45-0.20241009171123-c9b6c253819b h1:q25KpfxNwTrS8UZgkjdTvQkNI1Wo84KkavDpPA3aHwI= +github.com/sei-protocol/sei-db v0.0.45-0.20241009171123-c9b6c253819b/go.mod h1:F/ZKZA8HJPcUzSZPA8yt6pfwlGriJ4RDR4eHKSGLStI= github.com/sei-protocol/sei-iavl v0.2.0 h1:OisPjXiDT+oe+aeckzDEFgkZCYuUjHgs/PP8DPicN+I= github.com/sei-protocol/sei-iavl v0.2.0/go.mod h1:qRf8QYUPfrAO7K6VDB2B2l/N7K5L76OorioGBcJBIbw= github.com/sei-protocol/sei-ibc-go/v3 v3.3.2 h1:BaMZ6gjwqe3R/5dLmcJ1TkSZ3omcWy2TjaAZAeOJH44= diff --git a/tools/migration/ss/migrator.go b/tools/migration/ss/migrator.go index 4fde4aa41..758b79428 100644 --- a/tools/migration/ss/migrator.go +++ b/tools/migration/ss/migrator.go @@ -162,9 +162,9 @@ func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey } count++ - if count%10000 == 0 { + if count%1000000 == 0 { batchDuration := time.Since(startTimeBatch) - fmt.Printf("ExportLeafNodesFromKey - Last 10,000 iterations took: %v. Total scanned: %d, leaf nodes exported: %d\n", batchDuration, count, leafNodeCount) + fmt.Printf("ExportLeafNodesFromKey - Last 1,000,000 iterations took: %v. Total scanned: %d, leaf nodes exported: %d\n", batchDuration, count, leafNodeCount) startTimeBatch = time.Now() // Reset the start time for the next batch } From f5defc1158f2c749ddac67d5e72fb55d67e43338 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 16 Oct 2024 13:35:52 -0400 Subject: [PATCH 08/12] Archive Migration doc --- docs/migration/seidb_archive_migration.md | 149 ++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 docs/migration/seidb_archive_migration.md diff --git a/docs/migration/seidb_archive_migration.md b/docs/migration/seidb_archive_migration.md new file mode 100644 index 000000000..a18b65bad --- /dev/null +++ b/docs/migration/seidb_archive_migration.md @@ -0,0 +1,149 @@ +# SeiDB Archive Migration Guide + +## Overview +SeiDB is the next generation of chain storage in SeiV2. +One issue for archive nodes is that we need to keep the full state of the chain, so we can't +state sync a node and clear out previous data. + +In order to run an archive node with SeiDB, we need to run a migration from iavl to sei-db. + +The overall process will work as follows: +(1) Stop archive node and note down its height, call it MIGRATION_HEIGHT +(2) Update config to enable SeiDB (state committment + state store) +(3) Run sc migration at the MIGRATION_HEIGHT +(4) Re start seid with `--migrate-iavl` enabled (migrating state store in background) +(5) Verify migration at various sampled heights once state store is complete +(6) Stop seid, clear out iavl and restart seid normally, now only using SeiDB fully + +You may need to ensure you have sufficient disk space available, as during the migration process, both IAVL and SeiDB state stores will need to be maintained simultaneously. This could potentially double your storage requirements temporarily. + + +## Migration Steps + +### Step 1: Stop Node and note down latest height +Stop the seid process and note down the latest height. Save it as an env var $MIGRATION_HEIGHT. +```bash +systemctl stop seid +MIGRATION_HEIGHT=<> +``` + +### Step 2: Add SeiDB Configurations +We can enable SeiDB by adding the following configs to app.toml file. +Usually you can find this file under ~/.sei/config/app.toml. +```bash +############################################################################# +### SeiDB Configuration ### +############################################################################# + +[state-commit] +# Enable defines if the SeiDB should be enabled to override existing IAVL db backend. +sc-enable = true + +# AsyncCommitBuffer defines the size of asynchronous commit queue, this greatly improve block catching-up +# performance, <=0 means synchronous commit. +sc-async-commit-buffer = 100 + +# SnapshotKeepRecent defines how many memiavl snapshots (beyond the latest one) to keep +# Recommend to set to 1 to make sure IBC relayers work. +sc-keep-recent = 1 + +# SnapshotInterval defines the number of blocks interval the memiavl snapshot is taken, default to 10000 blocks. +# Adjust based on your needs: +# Setting this too low could lead to lot of extra heavy disk IO +# Setting this too high could lead to slow restart +sc-snapshot-interval = 10000 + +# SnapshotWriterLimit defines the max concurrency for taking memiavl snapshot +sc-snapshot-writer-limit = 1 + +# CacheSize defines the size of the LRU cache for each store on top of the tree, default to 100000. +sc-cache-size = 100000 + +[state-store] +# Enable defines if the state-store should be enabled for historical queries. +# In order to use state-store, you need to make sure to enable state-commit at the same time. +# Validator nodes should turn this off. +# State sync node or full nodes should turn this on. +ss-enable = true + +# DBBackend defines the backend database used for state-store. +# Supported backends: pebbledb, rocksdb +# defaults to pebbledb (recommended) +ss-backend = "pebbledb" + +# AsyncWriteBuffer defines the async queue length for commits to be applied to State Store +# Set <= 0 for synchronous writes, which means commits also need to wait for data to be persisted in State Store. +# defaults to 100 +ss-async-write-buffer = 100 + +# KeepRecent defines the number of versions to keep in state store +# Setting it to 0 means keep everything, default to 100000 +ss-keep-recent = 0 + +# PruneIntervalSeconds defines the minimum interval in seconds + some random delay to trigger pruning. +# It is more efficient to trigger pruning less frequently with large interval. +# default to 600 seconds +ss-prune-interval = 600 + +# ImportNumWorkers defines the concurrency for state sync import +# defaults to 1 +ss-import-num-workers = 1 +``` + + +### Step 3: Run SC Migration + +```bash +seid tools migrate-iavl --target-db SC --home-dir /root/.sei +``` + +This may take a couple hours to run. You will see logs of form +`Start restoring SC store for height` + + +### Step 4: Restart seid with background SS migration +```bash +seid start --migrate-iavl --migrate-height $MIGRATION_HEIGHT --chain-id pacific-1 +``` + +Seid will run normally and the migration will run in the background. Data from iavl +will be written to SS and new writes will be directed at SS not iavl. + +You will see logs of form +`SeiDB Archive Migration: Iterating through %s module...` and +`SeiDB Archive Migration: Last 1,000,000 iterations took:...` + + +NOTE: While this is running, any historical queries will be routed to iavl if +they are for a height BEFORE the migrate-height. Any queries on heights +AFTER the migrate-height will be routed to state store (pebbbledb). + + +### Step 5: Verify State Store Migration after completion +Once State Store Migration is complete, you will see logs of form +`SeiDB Archive Migration: DB scanning completed. Total time taken:...` + +You DO NOT immediately need to do anything. Your node will continue to run +and will operate normally. However we added a verification tool that will iterate through +all keys in iavl at a specific height and verify they exist in State Store. + +You should run the following command for a selection of different heights +```bash +seid tools verify-migration --version $VERIFICATION_HEIGHT +``` + +This will output `Verification Succeeded` if the verification was successful. + + +### Step 6: Clear out Iavl and restart seid +Once the verification is complete, we can proceed to clear out the iavl and +restart seid normally. + +```bash +systemctl stop seid +rm -rf ~/.sei/data/application.db +seid start --chain-id pacific-1 +``` + + +## FAQ From 0cc3b817feb7362a366ada1be19962ebcffe19d7 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 16 Oct 2024 13:37:14 -0400 Subject: [PATCH 09/12] Update form --- docs/migration/seidb_archive_migration.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/docs/migration/seidb_archive_migration.md b/docs/migration/seidb_archive_migration.md index a18b65bad..13bb3fee8 100644 --- a/docs/migration/seidb_archive_migration.md +++ b/docs/migration/seidb_archive_migration.md @@ -8,12 +8,13 @@ state sync a node and clear out previous data. In order to run an archive node with SeiDB, we need to run a migration from iavl to sei-db. The overall process will work as follows: -(1) Stop archive node and note down its height, call it MIGRATION_HEIGHT -(2) Update config to enable SeiDB (state committment + state store) -(3) Run sc migration at the MIGRATION_HEIGHT -(4) Re start seid with `--migrate-iavl` enabled (migrating state store in background) -(5) Verify migration at various sampled heights once state store is complete -(6) Stop seid, clear out iavl and restart seid normally, now only using SeiDB fully + +1. Stop archive node and note down its height, call it MIGRATION_HEIGHT +2. Update config to enable SeiDB (state committment + state store) +3. Run sc migration at the MIGRATION_HEIGHT +4. Re start seid with `--migrate-iavl` enabled (migrating state store in background) +5. Verify migration at various sampled heights once state store is complete +6. Stop seid, clear out iavl and restart seid normally, now only using SeiDB fully You may need to ensure you have sufficient disk space available, as during the migration process, both IAVL and SeiDB state stores will need to be maintained simultaneously. This could potentially double your storage requirements temporarily. From 241632b2c73d92559b4d8ba9419ac50212ddaddd Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 16 Oct 2024 13:39:02 -0400 Subject: [PATCH 10/12] Update --- docs/migration/seidb_archive_migration.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/migration/seidb_archive_migration.md b/docs/migration/seidb_archive_migration.md index 13bb3fee8..a9b6d8a74 100644 --- a/docs/migration/seidb_archive_migration.md +++ b/docs/migration/seidb_archive_migration.md @@ -2,8 +2,8 @@ ## Overview SeiDB is the next generation of chain storage in SeiV2. -One issue for archive nodes is that we need to keep the full state of the chain, so we can't -state sync a node and clear out previous data. +One issue for running SeiDB on archive nodes is that we need to keep the full state of the chain, so we can't +state sync it and clear out previous iavl data. In order to run an archive node with SeiDB, we need to run a migration from iavl to sei-db. From 387c96d1a34bb8212d82ad6a1745f56b239bcb90 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 16 Oct 2024 14:48:43 -0400 Subject: [PATCH 11/12] Export metric --- tools/migration/ss/migrator.go | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/tools/migration/ss/migrator.go b/tools/migration/ss/migrator.go index 758b79428..a0a3dcabe 100644 --- a/tools/migration/ss/migrator.go +++ b/tools/migration/ss/migrator.go @@ -5,6 +5,7 @@ import ( "fmt" "time" + "github.com/armon/go-metrics" "github.com/cosmos/iavl" "github.com/sei-protocol/sei-db/ss/types" dbm "github.com/tendermint/tm-db" @@ -95,15 +96,15 @@ func (m *Migrator) Verify(version int64) error { } count++ if count%10000 == 0 { - fmt.Printf("Verified %d keys in for module %s\n", count, module) + fmt.Printf("SeiDB Archive Migration:: Verified %d keys in for module %s\n", count, module) } return false }) if err != nil { - fmt.Printf("Failed to iterate the tree %s: %s\n", module, err.Error()) + fmt.Printf("SeiDB Archive Migration: Failed to iterate the tree %s: %s\n", module, err.Error()) return err } - fmt.Printf("Finished verifying module %s, total scanned: %d keys\n", module, count) + fmt.Printf("SeiDB Archive Migration:: Finished verifying module %s, total scanned: %d keys\n", module, count) } return verifyErr } @@ -111,16 +112,18 @@ func (m *Migrator) Verify(version int64) error { func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey []byte, startModule string) error { count := 0 leafNodeCount := 0 - fmt.Println("ExportLeafNodesFromKey - Scanning database and exporting leaf nodes...") + fmt.Println("SeiDB Archive Migration: Scanning database and exporting leaf nodes...") startTimeTotal := time.Now() // Start measuring total time + var batchLeafNodeCount int + for _, module := range modules { if module != startModule && startModule != "" { continue } startTimeModule := time.Now() // Measure time for each module - fmt.Printf("ExportLeafNodesFromKey - Iterating through %s module...\n", module) + fmt.Printf("SeiDB Archive Migration: Iterating through %s module...\n", module) prefixDB := dbm.NewPrefixDB(db, []byte(buildRawPrefix(module))) var itr dbm.Iterator @@ -134,7 +137,7 @@ func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey } if err != nil { - fmt.Printf("ExportLeafNodesFromKey - Error creating iterator: %+v\n", err) + fmt.Printf("SeiDB Archive Migration: Error creating iterator: %+v\n", err) return fmt.Errorf("failed to create iterator: %w", err) } defer itr.Close() @@ -146,13 +149,14 @@ func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey node, err := iavl.MakeNode(value) if err != nil { - fmt.Printf("ExportLeafNodesFromKey - Failed to make node: %+v\n", err) + fmt.Printf("SeiDB Archive Migration: Failed to make node: %+v\n", err) return fmt.Errorf("failed to make node: %w", err) } // Only export leaf nodes if node.GetHeight() == 0 { leafNodeCount++ + batchLeafNodeCount++ ch <- types.RawSnapshotNode{ StoreKey: module, Key: node.GetNodeKey(), @@ -164,9 +168,13 @@ func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey count++ if count%1000000 == 0 { batchDuration := time.Since(startTimeBatch) - fmt.Printf("ExportLeafNodesFromKey - Last 1,000,000 iterations took: %v. Total scanned: %d, leaf nodes exported: %d\n", batchDuration, count, leafNodeCount) + fmt.Printf("SeiDB Archive Migration: Last 1,000,000 iterations took: %v. Total scanned: %d, leaf nodes exported: %d\n", batchDuration, count, leafNodeCount) + metrics.IncrCounterWithLabels([]string{"sei", "migration", "leaf_nodes_exported"}, float32(batchLeafNodeCount), []metrics.Label{ + {Name: "module", Value: module}, + }) - startTimeBatch = time.Now() // Reset the start time for the next batch + batchLeafNodeCount = 0 + startTimeBatch = time.Now() } } @@ -176,11 +184,11 @@ func ExportLeafNodesFromKey(db dbm.DB, ch chan<- types.RawSnapshotNode, startKey } moduleDuration := time.Since(startTimeModule) - fmt.Printf("ExportLeafNodesFromKey - Finished scanning module %s. Time taken: %v. Total scanned: %d, leaf nodes exported: %d\n", module, moduleDuration, count, leafNodeCount) + fmt.Printf("SeiDB Archive Migration: Finished scanning module %s. Time taken: %v. Total scanned: %d, leaf nodes exported: %d\n", module, moduleDuration, count, leafNodeCount) } totalDuration := time.Since(startTimeTotal) - fmt.Printf("ExportLeafNodesFromKey - DB scanning completed. Total time taken: %v. Total entries scanned: %d, leaf nodes exported: %d\n", totalDuration, count, leafNodeCount) + fmt.Printf("SeiDB Archive Migration: DB scanning completed. Total time taken: %v. Total entries scanned: %d, leaf nodes exported: %d\n", totalDuration, count, leafNodeCount) return nil } From a586dbc45c4b5ba71e11d797bd9fb689c817cf01 Mon Sep 17 00:00:00 2001 From: kbhat1 Date: Wed, 16 Oct 2024 15:14:30 -0400 Subject: [PATCH 12/12] latest height --- docs/migration/seidb_archive_migration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/migration/seidb_archive_migration.md b/docs/migration/seidb_archive_migration.md index a9b6d8a74..6adbefb37 100644 --- a/docs/migration/seidb_archive_migration.md +++ b/docs/migration/seidb_archive_migration.md @@ -24,8 +24,8 @@ You may need to ensure you have sufficient disk space available, as during the m ### Step 1: Stop Node and note down latest height Stop the seid process and note down the latest height. Save it as an env var $MIGRATION_HEIGHT. ```bash +MIGRATION_HEIGHT=$(seid q block | jq ".block.last_commit.height" | tr -d '"') systemctl stop seid -MIGRATION_HEIGHT=<> ``` ### Step 2: Add SeiDB Configurations