Skip to content

Commit

Permalink
Merge PR: optimiz fss flag (#2769)
Browse files Browse the repository at this point in the history
* fast storage is default true and set by the data

* add fast-storage tips when start the node

* hidden flag discard-fast-storage

* print iavl.IsFastStorage when start node

* Update Makefile

* restore and hide the old flag

Co-authored-by: KamiD <[email protected]>
  • Loading branch information
giskook and KamiD authored Nov 20, 2022
1 parent 6906a00 commit 9c24579
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ IGNORE_CHECK_GO=false
install_rocksdb_version:=$(ROCKSDB_VERSION)


Version=v1.6.5.5
Version=v1.6.5.6
CosmosSDK=v0.39.2
Tendermint=v0.33.9
Iavl=v0.14.3
Expand Down
3 changes: 3 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"os"
"sync"

"github.com/okex/exchain/app/utils/appstatus"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"google.golang.org/grpc/encoding"
Expand Down Expand Up @@ -858,9 +859,11 @@ func PreRun(ctx *server.Context, cmd *cobra.Command) error {
// init tx signature cache
tmtypes.InitSignatureCache()

iavl.SetEnableFastStorage(appstatus.IsFastStorageStrategy())
// set external package flags
server.SetExternalPackageValue(cmd)

ctx.Logger.Info("The database storage strategy", "fast-storage", iavl.GetEnableFastStorage())
// set the dynamic config
appconfig.RegisterDynamicConfig(ctx.Logger.With("module", "config"))

Expand Down
5 changes: 1 addition & 4 deletions app/repair_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func repairStateOnStart(ctx *server.Context) {
orgEnableFlatKV := viper.GetBool(flatkv.FlagEnable)
iavl.EnableAsyncCommit = false
viper.Set(flatkv.FlagEnable, false)
if appstatus.IsFastStorageStrategy() &&
viper.GetBool(iavl.FlagIavlEnableFastStorage) {
iavl.SetEnableFastStorage(true)
}
iavl.SetEnableFastStorage(appstatus.IsFastStorageStrategy())

// repair state
RepairState(ctx, true)
Expand Down
10 changes: 0 additions & 10 deletions app/utils/sanity/start.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
package sanity

import (
"fmt"

apptype "github.com/okex/exchain/app/types"
"github.com/okex/exchain/app/utils/appstatus"
"github.com/okex/exchain/libs/cosmos-sdk/server"
cosmost "github.com/okex/exchain/libs/cosmos-sdk/store/types"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/iavl"
"github.com/okex/exchain/libs/tendermint/consensus"
"github.com/okex/exchain/libs/tendermint/state"
"github.com/okex/exchain/libs/tendermint/types"
Expand Down Expand Up @@ -87,12 +83,6 @@ var (
configA: stringItem{name: apptype.FlagNodeMode, expect: string(apptype.ArchiveNode)},
configB: boolItem{name: watcher.FlagFastQuery, expect: true},
},
{
configA: boolItem{name: iavl.FlagIavlEnableFastStorage, expect: true},
configB: funcItem{name: "Upgraded to fast IAVL", expect: false, f: appstatus.IsFastStorageStrategy},
tips: fmt.Sprintf("Upgrade to IAVL fast storage may take several hours, "+
"you can use exchaind fss create command to upgrade, or unset --%v", iavl.FlagIavlEnableFastStorage),
},
}

checkRangeItems = []rangeItem{
Expand Down
6 changes: 1 addition & 5 deletions cmd/exchaind/repair_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
tmtypes "github.com/okex/exchain/libs/tendermint/types"
types2 "github.com/okex/exchain/x/evm/types"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)

func repairStateCmd(ctx *server.Context) *cobra.Command {
Expand All @@ -37,14 +36,11 @@ func repairStateCmd(ctx *server.Context) *cobra.Command {
cmd.Flags().Bool(trace.FlagEnableAnalyzer, false, "Enable auto open log analyzer")
cmd.Flags().BoolVar(&types2.TrieUseCompositeKey, types2.FlagTrieUseCompositeKey, true, "Use composite key to store contract state")
cmd.Flags().Int(sm.FlagDeliverTxsExecMode, 0, "execution mode for deliver txs, (0:serial[default], 1:deprecated, 2:parallel)")
cmd.Flags().Bool(tmiavl.FlagIavlEnableFastStorage, false, "Enable fast storage")
cmd.Flags().String(sdk.FlagDBBackend, tmtypes.DBBackend, "Database backend: goleveldb | rocksdb")

return cmd
}

func setExternalPackageValue() {
enableFastStorage := viper.GetBool(tmiavl.FlagIavlEnableFastStorage) ||
appstatus.IsFastStorageStrategy()
tmiavl.SetEnableFastStorage(enableFastStorage)
tmiavl.SetEnableFastStorage(appstatus.IsFastStorageStrategy())
}
3 changes: 3 additions & 0 deletions cmd/exchaind/replay.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ import (
"github.com/gogo/protobuf/jsonpb"
"github.com/okex/exchain/app/config"
okexchain "github.com/okex/exchain/app/types"
"github.com/okex/exchain/app/utils/appstatus"
"github.com/okex/exchain/app/utils/sanity"
"github.com/okex/exchain/libs/cosmos-sdk/baseapp"
"github.com/okex/exchain/libs/cosmos-sdk/client/lcd"
"github.com/okex/exchain/libs/cosmos-sdk/codec"
"github.com/okex/exchain/libs/cosmos-sdk/server"
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/libs/iavl"
"github.com/okex/exchain/libs/system/trace"
abci "github.com/okex/exchain/libs/tendermint/abci/types"
tcmd "github.com/okex/exchain/libs/tendermint/cmd/tendermint/commands"
Expand Down Expand Up @@ -66,6 +68,7 @@ func replayCmd(ctx *server.Context, registerAppFlagFn func(cmd *cobra.Command),
fmt.Println(err)
return err
}
iavl.SetEnableFastStorage(appstatus.IsFastStorageStrategy())
server.SetExternalPackageValue(cmd)
types.InitSignatureCache()
return nil
Expand Down
4 changes: 3 additions & 1 deletion libs/cosmos-sdk/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ func SetExternalPackageValue(cmd *cobra.Command) {
tmiavl.HeightOrphansCacheSize = viper.GetInt(tmiavl.FlagIavlHeightOrphansCacheSize)
tmiavl.MaxCommittedHeightNum = viper.GetInt(tmiavl.FlagIavlMaxCommittedHeightNum)
tmiavl.EnableAsyncCommit = viper.GetBool(tmiavl.FlagIavlEnableAsyncCommit)
tmiavl.SetEnableFastStorage(viper.GetBool(tmiavl.FlagIavlEnableFastStorage))
if viper.GetBool(tmiavl.FlagIavlDiscardFastStorage) {
tmiavl.SetEnableFastStorage(false)
}
tmiavl.SetFastNodeCacheSize(viper.GetInt(tmiavl.FlagIavlFastStorageCacheSize))
system.EnableGid = viper.GetBool(system.FlagEnableGid)

Expand Down
3 changes: 3 additions & 0 deletions libs/cosmos-sdk/server/start_okchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,10 @@ func RegisterServerFlags(cmd *cobra.Command) *cobra.Command {
cmd.Flags().Int(tmiavl.FlagIavlHeightOrphansCacheSize, 8, "Max orphan version to cache in memory")
cmd.Flags().Int(tmiavl.FlagIavlMaxCommittedHeightNum, 30, "Max committed version to cache in memory")
cmd.Flags().Bool(tmiavl.FlagIavlEnableAsyncCommit, true, "Enable async commit")
cmd.Flags().Bool(tmiavl.FlagIavlDiscardFastStorage, false, "Discard fast storage")
cmd.Flags().MarkHidden(tmiavl.FlagIavlDiscardFastStorage)
cmd.Flags().Bool(tmiavl.FlagIavlEnableFastStorage, false, "Enable fast storage")
cmd.Flags().MarkHidden(tmiavl.FlagIavlEnableFastStorage)
cmd.Flags().Int(tmiavl.FlagIavlFastStorageCacheSize, 10000000, "Max size of iavl fast storage cache")
cmd.Flags().Bool(abci.FlagDisableABCIQueryMutex, true, "Disable local client query mutex for better concurrency")
cmd.Flags().Bool(abci.FlagDisableCheckTx, false, "Disable checkTx for test")
Expand Down
5 changes: 3 additions & 2 deletions libs/iavl/mutable_tree_oec.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const (
FlagIavlHeightOrphansCacheSize = "iavl-height-orphans-cache-size"
FlagIavlMaxCommittedHeightNum = "iavl-max-committed-height-num"
FlagIavlEnableAsyncCommit = "iavl-enable-async-commit"
FlagIavlEnableFastStorage = "iavl-enable-fast-storage"
FlagIavlFastStorageCacheSize = "iavl-fast-storage-cache-size"
FlagIavlEnableFastStorage = "iavl-enable-fast-storage"
FlagIavlDiscardFastStorage = "discard-fast-storage"
)

var (
Expand All @@ -33,7 +34,7 @@ var (
EnableAsyncCommit = false
EnablePruningHistoryState = true
CommitGapHeight int64 = 100
enableFastStorage = false
enableFastStorage = true
fastNodeCacheSize = 10000000
)

Expand Down

0 comments on commit 9c24579

Please sign in to comment.