diff --git a/app/app.go b/app/app.go index eadd034ea1..21405c7530 100644 --- a/app/app.go +++ b/app/app.go @@ -179,8 +179,7 @@ type App struct { // call app.Info or app.InitChain to initialize the baseapp. // // NOTE: upgradeHeightV2 refers specifically to the height that a node will -// upgrade from v1 to v2. It will be deprecated in v3 in place for a dynamically -// signalling scheme +// upgrade from v1 to v2. func New( logger log.Logger, db dbm.DB, diff --git a/cmd/celestia-appd/cmd/app_server.go b/cmd/celestia-appd/cmd/app_server.go index b2bfecf844..a1d50b3760 100644 --- a/cmd/celestia-appd/cmd/app_server.go +++ b/cmd/celestia-appd/cmd/app_server.go @@ -1,11 +1,13 @@ package cmd import ( + "fmt" "io" "path/filepath" "github.com/celestiaorg/celestia-app/v3/app" "github.com/celestiaorg/celestia-app/v3/app/encoding" + "github.com/celestiaorg/celestia-app/v3/pkg/appconsts" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server" @@ -44,10 +46,12 @@ func NewAppServer(logger log.Logger, db dbm.DB, traceStore io.Writer, appOptions } return app.New( - logger, db, traceStore, + logger, + db, + traceStore, cast.ToUint(appOptions.Get(server.FlagInvCheckPeriod)), encoding.MakeConfig(app.ModuleEncodingRegisters...), - cast.ToInt64(appOptions.Get(UpgradeHeightFlag)), + getUpgradeHeightV2(appOptions), appOptions, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOptions.Get(server.FlagMinGasPrices))), @@ -61,3 +65,29 @@ func NewAppServer(logger log.Logger, db dbm.DB, traceStore io.Writer, appOptions baseapp.SetSnapshot(snapshotStore, snapshottypes.NewSnapshotOptions(cast.ToUint64(appOptions.Get(server.FlagStateSyncSnapshotInterval)), cast.ToUint32(appOptions.Get(server.FlagStateSyncSnapshotKeepRecent)))), ) } + +func getUpgradeHeightV2(appOptions servertypes.AppOptions) int64 { + upgradeHeight := cast.ToInt64(appOptions.Get(UpgradeHeightFlag)) + if upgradeHeight != 0 { + fmt.Printf("upgrade height flag non-zero so using it: %d\n", upgradeHeight) + return upgradeHeight + } + + fmt.Printf("upgrade height flag zero\n") + + // TODO: this chainID doesn't always appear populated. + chainID := cast.ToString(appOptions.Get(flags.FlagChainID)) + fmt.Printf("chainID %v\n", chainID) + + switch chainID { + case appconsts.ArabicaChainID: + return appconsts.ArabicaUpgradeHeightV2 + case appconsts.MochaChainID: + return appconsts.MochaUpgradeHeightV2 + case appconsts.MainnetChainID: + return appconsts.MainnetUpgradeHeightV2 + default: + // default to the upgrade height provided by the flag + return upgradeHeight + } +} diff --git a/pkg/appconsts/chain_ids.go b/pkg/appconsts/chain_ids.go index 50c26932f9..056bc2606e 100644 --- a/pkg/appconsts/chain_ids.go +++ b/pkg/appconsts/chain_ids.go @@ -2,4 +2,6 @@ package appconsts const ( ArabicaChainID = "arabica-11" + MochaChainID = "mocha-4" + MainnetChainID = "celestia" ) diff --git a/pkg/appconsts/upgrade_heights.go b/pkg/appconsts/upgrade_heights.go new file mode 100644 index 0000000000..13ee0963f0 --- /dev/null +++ b/pkg/appconsts/upgrade_heights.go @@ -0,0 +1,13 @@ +package appconsts + +const ( + // ArabicaUpgradeHeightV2 is the block height at which the arabica-11 + // upgraded from app version 1 to 2. + ArabicaUpgradeHeightV2 = 1751707 + // MochaUpgradeHeightV2 is the block height at which the mocha-4 upgraded + // from app version 1 to 2. + MochaUpgradeHeightV2 = 2585031 + // MainnetUpgradeHeightV2 is the block height at which the celestia upgraded + // from app version 1 to 2. + MainnetUpgradeHeightV2 = 2371495 +)