Skip to content

Commit

Permalink
feat(server/v2,upgrade): add skip upgrade flag (backport #22682) (#22686
Browse files Browse the repository at this point in the history
)

Co-authored-by: Julien Robert <[email protected]>
  • Loading branch information
mergify[bot] and julienrbrt authored Nov 28, 2024
1 parent 61691b5 commit bfdff95
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/v2/cometbft/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
cosmossdk.io/errors/v2 v2.0.0-20240731132947-df72853b3ca5
cosmossdk.io/log v1.5.0
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b //main
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37 // main
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/store/v2 v2.0.0-20241108140525-43e28b43ad7a // main
Expand Down
4 changes: 2 additions & 2 deletions server/v2/cometbft/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ cosmossdk.io/math v1.4.0 h1:XbgExXFnXmF/CccPPEto40gOO7FpWu9yWNAZPN3nkNQ=
cosmossdk.io/math v1.4.0/go.mod h1:O5PkD4apz2jZs4zqFdTr16e1dcaQCc5z6lkEnrrppuk=
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b h1:svpFdulZRrYz+RTHu2u9CeKkMKrIHx5354vjiHerovo=
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95 h1:WUho1r7Zcg5aPn5YtYRN5TW9fvxUirX1mSihBDJ6ccg=
cosmossdk.io/server/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37 h1:zZvYQ/xSv5hsWcJiZOOqYrywzMm2TN+xdkedPgRdoss=
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37/go.mod h1:T4ptCA8LAxlBZ/MYJQTHMPNuvb+cgMsrPX31njPtJmw=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc=
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU=
Expand Down
2 changes: 1 addition & 1 deletion simapp/v2/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
cosmossdk.io/log v1.5.0
cosmossdk.io/math v1.4.0
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 // main
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3 // main
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37 // main
cosmossdk.io/server/v2/cometbft v0.0.0-00010101000000-000000000000
cosmossdk.io/store/v2 v2.0.0-20241108144957-78b5cd4dbd08 // main
cosmossdk.io/tools/confix v0.0.0-00010101000000-000000000000
Expand Down
4 changes: 2 additions & 2 deletions simapp/v2/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95 h1:hYI7pvrmdkgFZJ4HVQ
cosmossdk.io/runtime/v2 v2.0.0-20241119134933-d697a3de0f95/go.mod h1:J4Wv2eOwAz8t14Ak8XBMWDoFbwqwyllMaJF91O7n/wI=
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b h1:svpFdulZRrYz+RTHu2u9CeKkMKrIHx5354vjiHerovo=
cosmossdk.io/schema v0.3.1-0.20241128094659-bd76b47e1d8b/go.mod h1:RDAhxIeNB4bYqAlF4NBJwRrgtnciMcyyg0DOKnhNZQQ=
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3 h1:92+h62WOgxdb3eqjIT1sNn+/gcQYLvtZ9eln84h0nMg=
cosmossdk.io/server/v2 v2.0.0-20241120173909-b45cf753a7a3/go.mod h1:gPATMrgLSzDoJiyoY+N8ULwfvAJ3Ooh6TYFsW60tHW0=
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37 h1:zZvYQ/xSv5hsWcJiZOOqYrywzMm2TN+xdkedPgRdoss=
cosmossdk.io/server/v2 v2.0.0-20241128145253-6cfe2dc1bb37/go.mod h1:T4ptCA8LAxlBZ/MYJQTHMPNuvb+cgMsrPX31njPtJmw=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95 h1:GOznErJieaI0OS0LDUsu5Vy3qPnCyjdvkncejP0Zv5s=
cosmossdk.io/server/v2/appmanager v0.0.0-20241119134933-d697a3de0f95/go.mod h1:elhlrldWtm+9U4PxE0G3wjz83yQwVVGVAOncXJPY1Xc=
cosmossdk.io/server/v2/stf v0.0.0-20241119134933-d697a3de0f95 h1:cK7wvmlA18AvLcaInseKTBmt5EXtLwafe7oH1rx7veU=
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

0 comments on commit bfdff95

Please sign in to comment.