Skip to content

Commit

Permalink
try to get the v2 upgrade to work
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwaters committed Nov 21, 2023
1 parent fc378bd commit 9536657
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ test-short:
## test-e2e: Run end to end tests via knuu. This command requires a kube/config file to configure kubernetes.
test-e2e:
@echo "--> Running end to end tests"
@KNUU_NAMESPACE=test KNUU_TIMEOUT=20m E2E_LATEST_VERSION=$(shell git rev-parse --short main) E2E_VERSIONS="$(ALL_VERSIONS)" E2E=true go test ./test/e2e/... -timeout 20m -v
@KNUU_NAMESPACE=test KNUU_TIMEOUT=20m E2E_LATEST_VERSION=ef40921 E2E_VERSIONS="$(ALL_VERSIONS)" E2E=true go test ./test/e2e/... -timeout 20m -v
.PHONY: test-e2e

## test-race: Run tests in race mode.
Expand Down
1 change: 1 addition & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
// NOTE: this is a specific feature for upgrading to v2 as v3 and onward is expected
// to be coordinated through the signalling protocol
if app.UpgradeKeeper.ShouldUpgrade(req.Height) {
app.Logger().Info("Upgrading to v2", "height", req.Height)
app.SetAppVersion(ctx, v2.Version)
}
return res
Expand Down
2 changes: 2 additions & 0 deletions cmd/celestia-appd/cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cmd

import (
"fmt"
"io"
"os"
"path/filepath"
Expand Down Expand Up @@ -240,6 +241,7 @@ func NewAppServer(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts se
var upgradeHeight int64
upgradeHeightStr, ok := appOpts.Get(UpgradeHeightFlag).(string)
if ok {
fmt.Println("upgrade flag detected")
upgradeHeight, err = strconv.ParseInt(upgradeHeightStr, 10, 64)
if err != nil {
panic(err)
Expand Down
1 change: 1 addition & 0 deletions test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestE2ESimple(t *testing.T) {
switch {
case isSemVer:
case latestVersion == "latest":
case len(latestVersion) == 7:
case len(latestVersion) == 8:
// assume this is a git commit hash (we need to trim the last digit to match the docker image tag)
latestVersion = latestVersion[:7]
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/celestiaorg/celestia-app/app"
"github.com/celestiaorg/celestia-app/app/encoding"
v1 "github.com/celestiaorg/celestia-app/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/test/txsim"
"github.com/celestiaorg/knuu/pkg/knuu"
Expand All @@ -22,6 +23,7 @@ import (
const MajorVersion = 1

func TestMinorVersionCompatibility(t *testing.T) {
t.Skip()
if os.Getenv("E2E") != "true" {
t.Skip("skipping e2e test")
}
Expand Down Expand Up @@ -134,6 +136,7 @@ func TestMajorUpgradeToV2(t *testing.T) {
switch {
case isSemVer:
case latestVersion == "latest":
case len(latestVersion) == 7:
case len(latestVersion) == 8:
// assume this is a git commit hash (we need to trim the last digit to match the docker image tag)
latestVersion = latestVersion[:7]
Expand Down Expand Up @@ -175,7 +178,7 @@ func TestMajorUpgradeToV2(t *testing.T) {
resp, err := client.Header(ctx, nil)
require.NoError(t, err)
// FIXME: we are not correctly setting the app version at genesis
require.Equal(t, uint64(0), resp.Header.Version.App, "version mismatch before upgrade")
require.Equal(t, v1.Version, resp.Header.Version.App, "version mismatch before upgrade")
}

errCh := make(chan error)
Expand Down
3 changes: 3 additions & 0 deletions x/upgrade/keeper.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package upgrade

import (
fmt "fmt"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand All @@ -23,6 +25,7 @@ type VersionSetter func(version uint64)

// NewKeeper constructs an upgrade keeper
func NewKeeper(storeKey storetypes.StoreKey, upgradeHeight int64) Keeper {
fmt.Println("upgradeHeight", upgradeHeight)
return Keeper{
storeKey: storeKey,
upgradeHeight: upgradeHeight,
Expand Down

0 comments on commit 9536657

Please sign in to comment.