Skip to content

Commit

Permalink
feat: include v2 upgrade height in binary
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Dec 6, 2024
1 parent f11a169 commit ad04239
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
3 changes: 1 addition & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 32 additions & 2 deletions cmd/celestia-appd/cmd/app_server.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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))),
Expand All @@ -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
}
}
2 changes: 2 additions & 0 deletions pkg/appconsts/chain_ids.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ package appconsts

const (
ArabicaChainID = "arabica-11"
MochaChainID = "mocha-4"
MainnetChainID = "celestia"
)
13 changes: 13 additions & 0 deletions pkg/appconsts/upgrade_heights.go
Original file line number Diff line number Diff line change
@@ -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
)

0 comments on commit ad04239

Please sign in to comment.