Skip to content

Commit

Permalink
feat: set defaults for --v2-upgrade-height (celestiaorg#4091)
Browse files Browse the repository at this point in the history
Closes celestiaorg#3995

If a user specifies the `--v2-upgrade-height` flag then it takes
precedence over any defaults. If the user doesn't specify a
`--v2-upgrade-height` flag and the chainID is `arabica-11`, `mocha-4`,
or `celestia` then the v2 upgrade height is set to the block height that
was coordinated on those chains.

See:
https://docs.celestia.org/how-to-guides/network-upgrade-process#lemongrass-network-upgrade

## Testing

1. `./scripts/single-node.sh` doesn't set a v2 upgrade height
2. `./arabica.sh` if we remove the `--v2-upgrade-height` flag in the
script, gets defaulted correctly
3. `./arabica.sh` if we override the `--v2-upgrade-height` flag in the
script, that gets used
  • Loading branch information
rootulp committed Dec 9, 2024
1 parent 0ab3f1e commit 398ae62
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/celestia-appd/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"strings"
"time"

"github.com/celestiaorg/celestia-app/v3/pkg/appconsts"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -117,6 +118,20 @@ is performed. Note, when enabled, gRPC will also be automatically enabled.
return err
}

switch clientCtx.ChainID {
case appconsts.ArabicaChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.ArabicaChainID, appconsts.ArabicaUpgradeHeightV2))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.ArabicaUpgradeHeightV2)
case appconsts.MochaChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MochaChainID, appconsts.MochaUpgradeHeightV2))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MochaUpgradeHeightV2)
case appconsts.MainnetChainID:
serverCtx.Logger.Info(fmt.Sprintf("Since the chainID is %v, configuring the default v2 upgrade height to %v", appconsts.MainnetChainID, appconsts.MainnetUpgradeHeightV2))
serverCtx.Viper.SetDefault(UpgradeHeightFlag, appconsts.MainnetUpgradeHeightV2)
default:
serverCtx.Logger.Info(fmt.Sprintf("No default value exists for the v2 upgrade height when the chainID is %v", clientCtx.ChainID))
}

withTM, _ := cmd.Flags().GetBool(flagWithTendermint)
if !withTM {
serverCtx.Logger.Info("starting ABCI without Tendermint")
Expand Down
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 398ae62

Please sign in to comment.