Skip to content

Commit

Permalink
Problem: versiondb commands not compatible with sdk 47
Browse files Browse the repository at this point in the history
Solution:
- introduce "--sdk46-compact" flag to support both.
  • Loading branch information
yihuang committed Jul 28, 2023
1 parent d7d9101 commit 1a8b853
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- [#1100](https://github.com/crypto-org-chain/cronos/pull/1100) memiavl support read-only mode, and grab exclusive lock for write mode.
- [#1103](https://github.com/crypto-org-chain/cronos/pull/1103) Add EventQueryTxFor cmd to subscribe and wait for transaction.
- [#1108](https://github.com/crypto-org-chain/cronos/pull/1108) versiondb support restore from local snapshot.
- [#]() versiondb commands support sdk47 app hash calculation.

### Improvements

Expand Down
1 change: 1 addition & 0 deletions versiondb/client/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ const (
flagLoadSnapshot = "load-snapshot"
flagSorterChunkSize = "sorter-chunk-size"
flagInitialVersion = "initial-version"
flagSDK64Compact = "sdk64-compact"
)
10 changes: 8 additions & 2 deletions versiondb/client/restore_app_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ func RestoreAppDBCmd(opts Options) *cobra.Command {
if err != nil {
return err
}
sdk64Compact, err := cmd.Flags().GetBool(flagSDK64Compact)
if err != nil {
return err
}
stores, err := GetStoresOrDefault(cmd, opts.DefaultStores)
if err != nil {
return err
Expand All @@ -76,9 +80,10 @@ func RestoreAppDBCmd(opts Options) *cobra.Command {

// load the snapshots and compute commit info first
var lastestVersion int64
storeInfos := []storetypes.StoreInfo{
var storeInfos []storetypes.StoreInfo
if sdk64Compact {
// https://github.com/cosmos/cosmos-sdk/issues/14916
{Name: capabilitytypes.MemStoreKey, CommitId: storetypes.CommitID{}},
storeInfos = append(storeInfos, storetypes.StoreInfo{Name: capabilitytypes.MemStoreKey, CommitId: storetypes.CommitID{}})
}
snapshots := make([]*memiavl.Snapshot, len(stores))
for i, store := range stores {
Expand Down Expand Up @@ -167,6 +172,7 @@ func RestoreAppDBCmd(opts Options) *cobra.Command {
cmd.Flags().String(flagStores, "", "list of store names, default to the current store list in application")
cmd.Flags().Uint64(flagSorterChunkSize, DefaultSorterChunkSizeIAVL, "uncompressed chunk size for external sorter, it decides the peak ram usage, on disk it'll be snappy compressed")
cmd.Flags().Int(flagConcurrency, runtime.NumCPU(), "Number concurrent goroutines to parallelize the work")
cmd.Flags().Bool(flagSDK64Compact, true, "Should the app hash calculation be compatible with cosmos-sdk v0.46 and earlier")

return cmd
}
Expand Down

0 comments on commit 1a8b853

Please sign in to comment.