Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(server/v2,upgrade): add skip upgrade flag #22682

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions server/v2/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ func prefix(f string) string {
}

var (
FlagMinGasPrices = prefix("minimum-gas-prices")
FlagCPUProfiling = prefix("cpu-profile")
FlagMinGasPrices = prefix("minimum-gas-prices")
FlagCPUProfiling = prefix("cpu-profile")
FlagUnsafeSkipUpgrades = prefix("unsafe-skip-upgrades")
)

const (
Expand Down
1 change: 1 addition & 0 deletions server/v2/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ func (s *Server[T]) StartCmdFlags() *pflag.FlagSet {
flags := pflag.NewFlagSet(s.Name(), pflag.ExitOnError)
flags.String(FlagMinGasPrices, "", "Minimum gas prices to accept for transactions; Any fee in a tx must meet this minimum (e.g. 0.01photino;0.0001stake)")
flags.String(FlagCPUProfiling, "", "Enable CPU profiling and write to the specified file")
flags.IntSlice(FlagUnsafeSkipUpgrades, []int{}, "Skip a set of upgrade heights to continue the old binary")

return flags
}
Expand Down
13 changes: 11 additions & 2 deletions x/upgrade/depinject.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

// flagUnsafeSkipUpgradesV2 is a custom flag that allows the user to skip upgrades
// It is used in a v2 chain.
const flagUnsafeSkipUpgradesV2 = "server.unsafe-skip-upgrades"

var _ depinject.OnePerModuleType = AppModule{}

// IsOnePerModuleType implements the depinject.OnePerModuleType interface.
Expand All @@ -36,6 +40,7 @@ func ProvideConfig(key depinject.OwnModuleKey) coreserver.ModuleConfigMap {
Module: depinject.ModuleKey(key).Name(),
Config: coreserver.ConfigMap{
server.FlagUnsafeSkipUpgrades: []int{},
flagUnsafeSkipUpgradesV2: []int{},
flags.FlagHome: "",
},
}
Expand Down Expand Up @@ -66,10 +71,14 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
skipUpgradeHeights = make(map[int64]bool)
)

skipUpgrades, ok := in.ConfigMap[server.FlagUnsafeSkipUpgrades]
skipUpgrades, ok := in.ConfigMap[flagUnsafeSkipUpgradesV2] // check v2
if !ok || skipUpgrades == nil {
skipUpgrades = []int{}
skipUpgrades, ok = in.ConfigMap[server.FlagUnsafeSkipUpgrades] // check v1
if !ok || skipUpgrades == nil {
skipUpgrades = []int{}
}
}

heights := cast.ToIntSlice(skipUpgrades) // safe to use cast here as we've handled nil case
for _, h := range heights {
skipUpgradeHeights[int64(h)] = true
Expand Down
Loading