Skip to content

Commit

Permalink
revert: remove v3 upgrade height
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Aug 15, 2024
1 parent 2f94921 commit 3f81028
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 25 deletions.
13 changes: 7 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ type App struct {
// upgradeHeightV2 is used as a coordination mechanism for the height-based
// upgrade from v1 to v2.
upgradeHeightV2 int64
// upgradeHeightv3 is a hard-coded mechanism for the height-based
// upgrade from v2 to v3.
upgradeHeightV3 int64
// MsgGateKeeper is used to define which messages are accepted for a given
// app version.
MsgGateKeeper *ante.MsgVersioningGateKeeper
Expand All @@ -187,7 +184,6 @@ func New(
invCheckPeriod uint,
encodingConfig encoding.Config,
upgradeHeightV2 int64,
upgradeHeightV3 int64,
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
Expand All @@ -214,7 +210,6 @@ func New(
tkeys: tkeys,
memKeys: memKeys,
upgradeHeightV2: upgradeHeightV2,
upgradeHeightV3: upgradeHeightV3,
}

app.ParamsKeeper = initParamsKeeper(appCodec, encodingConfig.Amino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey])
Expand Down Expand Up @@ -459,6 +454,12 @@ func (app *App) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.R
func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
res := app.manager.EndBlock(ctx, req)
currentVersion := app.AppVersion()

// upgradeHeightV3 is a hard-coded height to upgrade from v2 to v3. We use
// this to test the upgrade in the prototype. On mainnet we'll use the
// signalling mechanism so remove this pre-merge.
upgradeHeightV3 := int64(10)

// For v1 only we upgrade using a agreed upon height known ahead of time
if currentVersion == v1 {
// check that we are at the height before the upgrade
Expand All @@ -480,7 +481,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
app.SetAppVersion(ctx, newVersion)
app.SignalKeeper.ResetTally(ctx)
}
} else if req.Height == app.upgradeHeightV3-1 {
} else if req.Height == upgradeHeightV3-1 {
app.SetAppVersion(ctx, 3)
}
return res
Expand Down
3 changes: 1 addition & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ func TestNew(t *testing.T) {
invCheckPeriod := uint(1)
encodingConfig := encoding.MakeConfig(app.ModuleEncodingRegisters...)
upgradeHeightV2 := int64(0)
upgradeHeightV3 := int64(0)
appOptions := NoopAppOptions{}

got := app.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, upgradeHeightV3, appOptions)
got := app.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, appOptions)

t.Run("initializes ICAHostKeeper", func(t *testing.T) {
assert.NotNil(t, got.ICAHostKeeper)
Expand Down
4 changes: 1 addition & 3 deletions app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,10 @@ func TestBlobstreamRemovedInV2(t *testing.T) {

func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeightV2 int64) (*app.App, keyring.Keyring) {
t.Helper()
upgradeHeightV3 := int64(0)

db := dbm.NewMemDB()
chainID := "test_chain"
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeightV2, upgradeHeightV3, util.EmptyAppOptions{})
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeightV2, util.EmptyAppOptions{})
genesisState, _, kr := util.GenesisStateWithSingleValidator(testApp, "account")
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)
Expand Down
4 changes: 1 addition & 3 deletions cmd/celestia-appd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,12 @@ func NewAppServer(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts se
if err != nil {
panic(err)
}
upgradeHeightV3 := int64(0)

return app.New(
logger, db, traceStore,
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
encoding.MakeConfig(app.ModuleEncodingRegisters...), // Ideally, we would reuse the one created by NewRootCmd.
cast.ToInt64(appOpts.Get(UpgradeHeightFlag)),
upgradeHeightV3,
appOpts,
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))),
Expand All @@ -259,7 +257,7 @@ func createAppAndExport(
appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) {
config := encoding.MakeConfig(app.ModuleEncodingRegisters...)
celestiaApp := app.New(logger, db, traceStore, uint(1), config, 0, 0, appOpts)
celestiaApp := app.New(logger, db, traceStore, uint(1), config, 0, appOpts)
if height != -1 {
if err := celestiaApp.LoadHeight(height); err != nil {
return servertypes.ExportedApp{}, err
Expand Down
6 changes: 2 additions & 4 deletions node/utils/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
const (
// upgradeHeightV2 is the height at which the app should be upgraded to v2.
upgradeHeightV2 = int64(5)
// upgradeHeightV2 is the height at which the app should be upgraded to v3.
upgradeHeightV3 = int64(10)
)

func GetApplications(db tmdb.DB) map[uint64]AppWithMigrations {
Expand All @@ -38,7 +36,7 @@ func NewAppV2(db tmdb.DB) *appV2.App {
invCheckPeriod := uint(1)
encodingConfig := encodingV2.MakeConfig(appV2.ModuleEncodingRegisters...)
appOptions := NoopAppOptions{}
return appV2.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, upgradeHeightV3, appOptions)
return appV2.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, appOptions)
}

func NewAppV3(db tmdb.DB) *appV3.App {
Expand All @@ -47,5 +45,5 @@ func NewAppV3(db tmdb.DB) *appV3.App {
invCheckPeriod := uint(1)
encodingConfig := encodingV3.MakeConfig(appV3.ModuleEncodingRegisters...)
appOptions := NoopAppOptions{}
return appV3.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, upgradeHeightV3, appOptions)
return appV3.New(logger, db, traceStore, invCheckPeriod, encodingConfig, upgradeHeightV2, appOptions)
}
2 changes: 1 addition & 1 deletion test/tokenfilter/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func SetupWithGenesisValSet(t testing.TB, valSet *tmtypes.ValidatorSet, genAccs
encCdc := encoding.MakeConfig(app.ModuleEncodingRegisters...)
genesisState := app.NewDefaultGenesisState(encCdc.Codec)
app := app.New(
log.NewNopLogger(), db, nil, 5, encCdc, 0, 0, simapp.EmptyAppOptions{},
log.NewNopLogger(), db, nil, 5, encCdc, 0, simapp.EmptyAppOptions{},
)

// set genesis accounts
Expand Down
2 changes: 1 addition & 1 deletion test/util/malicious/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func New(
appOpts servertypes.AppOptions,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
goodApp := app.New(logger, db, traceStore, invCheckPeriod, encodingConfig, 0, 0, appOpts, baseAppOptions...)
goodApp := app.New(logger, db, traceStore, invCheckPeriod, encodingConfig, 0, appOpts, baseAppOptions...)
badApp := &App{App: goodApp}

// set the malicious prepare proposal handler if it is set in the app options
Expand Down
4 changes: 1 addition & 3 deletions test/util/test_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func NewTestApp() *app.App {
cast.ToUint(emptyOpts.Get(server.FlagInvCheckPeriod)),
encCfg,
0,
0,
emptyOpts,
)
}
Expand Down Expand Up @@ -430,8 +429,7 @@ func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeightV2 int64) (*app.Ap
db := dbm.NewMemDB()
chainID := "test_chain"
encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...)
upgradeHeightV3 := int64(0)
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeightV2, upgradeHeightV3, EmptyAppOptions{})
testApp := app.New(log.NewNopLogger(), db, nil, 0, encCfg, upgradeHeightV2, EmptyAppOptions{})
genesisState, _, kr := GenesisStateWithSingleValidator(testApp, "account")
stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)
Expand Down
2 changes: 0 additions & 2 deletions test/util/testnode/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ func DefaultAppCreator() srvtypes.AppCreator {
0, // invCheckPerid
encodingConfig,
0, // v2 upgrade height
0, // v3 upgrade height
simapp.EmptyAppOptions{},
baseapp.SetMinGasPrices(fmt.Sprintf("%v%v", appconsts.DefaultMinGasPrice, app.BondDenom)),
)
Expand All @@ -198,7 +197,6 @@ func CustomAppCreator(minGasPrice string) srvtypes.AppCreator {
0, // invCheckPerid
encodingConfig,
0, // v2 upgrade height
0, // v3 upgrade height
simapp.EmptyAppOptions{},
baseapp.SetMinGasPrices(minGasPrice),
)
Expand Down

0 comments on commit 3f81028

Please sign in to comment.