From 20009fd924c4db94c27b63c0ed233b848bd84f91 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Mon, 20 Nov 2023 16:30:56 +0100 Subject: [PATCH 01/11] chore: bump sdk to v1.20.0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 81c1a340b5..552305555a 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.18.3-sdk-v0.46.14 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 diff --git a/go.sum b/go.sum index 74b2baa708..78a9014ebc 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,8 @@ github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 h1:h1Y4V3EMQ2mFmNtWt2sIhZI github.com/celestiaorg/blobstream-contracts/v3 v3.1.0/go.mod h1:x4DKyfKOSv1ZJM9NwV+Pw01kH2CD7N5zTFclXIVJ6GQ= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 h1:Fd7ymPUzExPGNl2gZw4i5S74arMw+iDHLE78M/cCxl4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29/go.mod h1:xrICN0PBhp3AdTaZ8q4wS5Jvi32V02HNjaC2EsWiEKk= -github.com/celestiaorg/cosmos-sdk v1.18.3-sdk-v0.46.14 h1:+Te28r5Zp4Vp69f82kcON9/BIF8f1BNXb0go2+achuc= -github.com/celestiaorg/cosmos-sdk v1.18.3-sdk-v0.46.14/go.mod h1:Og5KKgoBEiQlI6u56lDLG191pfknIdXctFn3COWLQP8= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0 h1:KyuLAqq4qd0MkoA+wN8tr/3msUWgt4Kc/rxCZ5Zfm6U= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg= github.com/celestiaorg/knuu v0.10.0 h1:uYO6hVsoCAJ/Q4eV0Pn8CLbbupGAjD56xQc4y2t4lf0= github.com/celestiaorg/knuu v0.10.0/go.mod h1:2NjDX29x09hRpaaWaKvi7pw9VjI/SHo+/4HldyEW50g= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= From fc378bd9e0efcfef73c78e885140a489fea5fbe5 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Mon, 20 Nov 2023 16:48:08 +0100 Subject: [PATCH 02/11] fix compile errors --- app/app.go | 5 +---- app/prepare_proposal.go | 2 +- app/process_proposal.go | 2 +- app/square_size.go | 4 ++-- test/util/malicious/out_of_order_prepare.go | 2 +- x/upgrade/upgrade_test.go | 9 +++++---- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/app.go b/app/app.go index 1e6d312d2a..90666e85b0 100644 --- a/app/app.go +++ b/app/app.go @@ -576,7 +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.SetProtocolVersion(v2.Version) + app.SetAppVersion(ctx, v2.Version) } return res } @@ -587,9 +587,6 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res if err := tmjson.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - if req.ConsensusParams != nil && req.ConsensusParams.Version != nil { - app.SetProtocolVersion(req.ConsensusParams.Version.AppVersion) - } return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } diff --git a/app/prepare_proposal.go b/app/prepare_proposal.go index 2240f79371..4ab62bcce5 100644 --- a/app/prepare_proposal.go +++ b/app/prepare_proposal.go @@ -62,7 +62,7 @@ func (app *App) PrepareProposal(req abci.RequestPrepareProposal) abci.ResponsePr // build the square from the set of valid and prioritised transactions. // The txs returned are the ones used in the square and block - dataSquare, txs, err := square.Build(txs, app.GetBaseApp().AppVersion(), app.GovSquareSizeUpperBound(sdkCtx)) + dataSquare, txs, err := square.Build(txs, app.GetBaseApp().AppVersion(sdkCtx), app.GovSquareSizeUpperBound(sdkCtx)) if err != nil { panic(err) } diff --git a/app/process_proposal.go b/app/process_proposal.go index ebbbc85345..68f7048058 100644 --- a/app/process_proposal.go +++ b/app/process_proposal.go @@ -110,7 +110,7 @@ func (app *App) ProcessProposal(req abci.RequestProcessProposal) (resp abci.Resp } // Construct the data square from the block's transactions - dataSquare, err := square.Construct(req.BlockData.Txs, app.GetBaseApp().AppVersion(), app.GovSquareSizeUpperBound(sdkCtx)) + dataSquare, err := square.Construct(req.BlockData.Txs, app.GetBaseApp().AppVersion(sdkCtx), app.GovSquareSizeUpperBound(sdkCtx)) if err != nil { logInvalidPropBlockError(app.Logger(), req.Header, "failure to compute data square from transactions:", err) return reject() diff --git a/app/square_size.go b/app/square_size.go index f0c3825580..9af83aef55 100644 --- a/app/square_size.go +++ b/app/square_size.go @@ -20,8 +20,8 @@ func (app *App) GovSquareSizeUpperBound(ctx sdk.Context) int { gmax := int(app.BlobKeeper.GovMaxSquareSize(ctx)) // perform a secondary check on the max square size. - if gmax > appconsts.SquareSizeUpperBound(app.AppVersion()) { - gmax = appconsts.SquareSizeUpperBound(app.AppVersion()) + if gmax > appconsts.SquareSizeUpperBound(app.AppVersion(ctx)) { + gmax = appconsts.SquareSizeUpperBound(app.AppVersion(ctx)) } return gmax diff --git a/test/util/malicious/out_of_order_prepare.go b/test/util/malicious/out_of_order_prepare.go index ebc23bc31b..24a6bff664 100644 --- a/test/util/malicious/out_of_order_prepare.go +++ b/test/util/malicious/out_of_order_prepare.go @@ -36,7 +36,7 @@ func (a *App) OutOfOrderPrepareProposal(req abci.RequestPrepareProposal) abci.Re // build the square from the set of valid and prioritised transactions. // The txs returned are the ones used in the square and block - dataSquare, txs, err := Build(txs, a.GetBaseApp().AppVersion(), a.GovSquareSizeUpperBound(sdkCtx), OutOfOrderExport) + dataSquare, txs, err := Build(txs, a.GetBaseApp().AppVersion(sdkCtx), a.GovSquareSizeUpperBound(sdkCtx), OutOfOrderExport) if err != nil { panic(err) } diff --git a/x/upgrade/upgrade_test.go b/x/upgrade/upgrade_test.go index 5cf6b9fe78..4817e09f0c 100644 --- a/x/upgrade/upgrade_test.go +++ b/x/upgrade/upgrade_test.go @@ -9,6 +9,7 @@ import ( "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/test/util" "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" @@ -21,11 +22,11 @@ func TestUpgradeAppVersion(t *testing.T) { testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: 2}}) // app version should not have changed yet - require.EqualValues(t, 1, testApp.AppVersion()) + require.EqualValues(t, 1, testApp.AppVersion(sdk.Context{})) respEndBlock := testApp.EndBlock(abci.RequestEndBlock{Height: 2}) // now the app version changes require.EqualValues(t, 2, respEndBlock.ConsensusParamUpdates.Version.AppVersion) - require.EqualValues(t, 2, testApp.AppVersion()) + require.EqualValues(t, 2, testApp.AppVersion(sdk.Context{})) } func setupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) { @@ -40,7 +41,7 @@ func setupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) - require.EqualValues(t, 0, testApp.GetBaseApp().AppVersion()) + require.EqualValues(t, 0, testApp.GetBaseApp().AppVersion(sdk.Context{})) cp := app.DefaultConsensusParams() abciParams := &abci.ConsensusParams{ @@ -64,7 +65,7 @@ func setupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) ) // assert that the chain starts with version provided in genesis - require.EqualValues(t, app.DefaultConsensusParams().Version.AppVersion, testApp.GetBaseApp().AppVersion()) + require.EqualValues(t, app.DefaultConsensusParams().Version.AppVersion, testApp.GetBaseApp().AppVersion(sdk.Context{})) _ = testApp.Commit() return testApp, kr From 9536657f6ee7126518288e90c525addcbdb236ed Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 11:04:00 +0100 Subject: [PATCH 03/11] try to get the v2 upgrade to work --- Makefile | 2 +- app/app.go | 1 + cmd/celestia-appd/cmd/root.go | 2 ++ test/e2e/simple_test.go | 1 + test/e2e/upgrade_test.go | 5 ++++- x/upgrade/keeper.go | 3 +++ 6 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9f66f9035d..21fe85a1a4 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/app/app.go b/app/app.go index 90666e85b0..6ba65324d2 100644 --- a/app/app.go +++ b/app/app.go @@ -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 diff --git a/cmd/celestia-appd/cmd/root.go b/cmd/celestia-appd/cmd/root.go index b0d8c9ab6b..f24133df6a 100644 --- a/cmd/celestia-appd/cmd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -1,6 +1,7 @@ package cmd import ( + "fmt" "io" "os" "path/filepath" @@ -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) diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 1e7843ab85..2fe606d531 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -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] diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 05d5efad34..081590ba36 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -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" @@ -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") } @@ -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] @@ -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) diff --git a/x/upgrade/keeper.go b/x/upgrade/keeper.go index 54b03dd7d9..f7c2ea0fd3 100644 --- a/x/upgrade/keeper.go +++ b/x/upgrade/keeper.go @@ -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" @@ -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, From a6b82fceec9f88544698337c83a0c714b585fe7c Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 11:57:55 +0100 Subject: [PATCH 04/11] bump to rc1 --- app/app.go | 3 ++- go.mod | 2 +- go.sum | 4 ++-- x/upgrade/upgrade_test.go | 7 +++++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/app.go b/app/app.go index 6ba65324d2..3899f7f242 100644 --- a/app/app.go +++ b/app/app.go @@ -1,6 +1,7 @@ package app import ( + "fmt" "io" "os" "path/filepath" @@ -576,7 +577,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) + fmt.Println("upgrading to v2", "height", req.Height) app.SetAppVersion(ctx, v2.Version) } return res diff --git a/go.mod b/go.mod index 552305555a..bdec48db53 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 diff --git a/go.sum b/go.sum index 78a9014ebc..2aa36862b9 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,8 @@ github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 h1:h1Y4V3EMQ2mFmNtWt2sIhZI github.com/celestiaorg/blobstream-contracts/v3 v3.1.0/go.mod h1:x4DKyfKOSv1ZJM9NwV+Pw01kH2CD7N5zTFclXIVJ6GQ= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 h1:Fd7ymPUzExPGNl2gZw4i5S74arMw+iDHLE78M/cCxl4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29/go.mod h1:xrICN0PBhp3AdTaZ8q4wS5Jvi32V02HNjaC2EsWiEKk= -github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0 h1:KyuLAqq4qd0MkoA+wN8tr/3msUWgt4Kc/rxCZ5Zfm6U= -github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc0/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1 h1:GtiF/vbSeJVd89W5b3jCFpik9JwcDmYsvZ1o9Tqg8Ds= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg= github.com/celestiaorg/knuu v0.10.0 h1:uYO6hVsoCAJ/Q4eV0Pn8CLbbupGAjD56xQc4y2t4lf0= github.com/celestiaorg/knuu v0.10.0/go.mod h1:2NjDX29x09hRpaaWaKvi7pw9VjI/SHo+/4HldyEW50g= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc= diff --git a/x/upgrade/upgrade_test.go b/x/upgrade/upgrade_test.go index 4817e09f0c..cd9c17d2cb 100644 --- a/x/upgrade/upgrade_test.go +++ b/x/upgrade/upgrade_test.go @@ -25,6 +25,7 @@ func TestUpgradeAppVersion(t *testing.T) { require.EqualValues(t, 1, testApp.AppVersion(sdk.Context{})) respEndBlock := testApp.EndBlock(abci.RequestEndBlock{Height: 2}) // now the app version changes + require.NotNil(t, respEndBlock.ConsensusParamUpdates.Version) require.EqualValues(t, 2, respEndBlock.ConsensusParamUpdates.Version.AppVersion) require.EqualValues(t, 2, testApp.AppVersion(sdk.Context{})) } @@ -41,7 +42,8 @@ func setupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) - require.EqualValues(t, 0, testApp.GetBaseApp().AppVersion(sdk.Context{})) + infoResp := testApp.Info(abci.RequestInfo{}) + require.EqualValues(t, 0, infoResp.AppVersion) cp := app.DefaultConsensusParams() abciParams := &abci.ConsensusParams{ @@ -65,7 +67,8 @@ func setupTestApp(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) ) // assert that the chain starts with version provided in genesis - require.EqualValues(t, app.DefaultConsensusParams().Version.AppVersion, testApp.GetBaseApp().AppVersion(sdk.Context{})) + infoResp = testApp.Info(abci.RequestInfo{}) + require.EqualValues(t, app.DefaultConsensusParams().Version.AppVersion, infoResp.AppVersion) _ = testApp.Commit() return testApp, kr From 856c42f30e881f8820710da8423437a456477b8e Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 12:27:48 +0100 Subject: [PATCH 05/11] take 3 --- Makefile | 2 +- cmd/celestia-appd/cmd/root.go | 14 +------------- test/e2e/simple_test.go | 1 + test/e2e/upgrade_test.go | 1 - 4 files changed, 3 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 21fe85a1a4..fc5e807ea7 100644 --- a/Makefile +++ b/Makefile @@ -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=ef40921 E2E_VERSIONS="$(ALL_VERSIONS)" E2E=true go test ./test/e2e/... -timeout 20m -v + @KNUU_NAMESPACE=test KNUU_TIMEOUT=20m E2E_LATEST_VERSION=b8d2449 E2E_VERSIONS="$(ALL_VERSIONS)" E2E=true go test ./test/e2e/... -timeout 20m -v .PHONY: test-e2e ## test-race: Run tests in race mode. diff --git a/cmd/celestia-appd/cmd/root.go b/cmd/celestia-appd/cmd/root.go index f24133df6a..8b55b09e7c 100644 --- a/cmd/celestia-appd/cmd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -1,11 +1,9 @@ package cmd import ( - "fmt" "io" "os" "path/filepath" - "strconv" bscmd "github.com/celestiaorg/celestia-app/x/blobstream/client" @@ -238,21 +236,11 @@ func NewAppServer(logger log.Logger, db dbm.DB, traceStore io.Writer, appOpts se panic(err) } - 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) - } - } - return app.New( logger, db, traceStore, true, cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)), encoding.MakeConfig(app.ModuleEncodingRegisters...), // Ideally, we would reuse the one created by NewRootCmd. - upgradeHeight, + cast.ToInt64(appOpts.Get(UpgradeHeightFlag)), appOpts, baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(server.FlagMinGasPrices))), diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 2fe606d531..31f58f440c 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -23,6 +23,7 @@ var latestVersion = "latest" // and MsgSends over 30 seconds and then asserts that at least 10 transactions were // committed. func TestE2ESimple(t *testing.T) { + t.Skip() if os.Getenv("E2E") != "true" { t.Skip("skipping e2e test") } diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 081590ba36..79ec158d15 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -177,7 +177,6 @@ func TestMajorUpgradeToV2(t *testing.T) { require.NoError(t, err) resp, err := client.Header(ctx, nil) require.NoError(t, err) - // FIXME: we are not correctly setting the app version at genesis require.Equal(t, v1.Version, resp.Header.Version.App, "version mismatch before upgrade") } From 69f9d6aa499317072cff1973403def1c5f7b9bd2 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 13:34:11 +0100 Subject: [PATCH 06/11] fix the test to make it work --- Makefile | 2 +- app/app.go | 2 -- app/square_size.go | 8 ++------ test/e2e/simple_test.go | 1 - test/e2e/upgrade_test.go | 23 ++++++++--------------- x/upgrade/keeper.go | 3 --- 6 files changed, 11 insertions(+), 28 deletions(-) diff --git a/Makefile b/Makefile index fc5e807ea7..9f66f9035d 100644 --- a/Makefile +++ b/Makefile @@ -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=b8d2449 E2E_VERSIONS="$(ALL_VERSIONS)" E2E=true go test ./test/e2e/... -timeout 20m -v + @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 .PHONY: test-e2e ## test-race: Run tests in race mode. diff --git a/app/app.go b/app/app.go index 3899f7f242..90666e85b0 100644 --- a/app/app.go +++ b/app/app.go @@ -1,7 +1,6 @@ package app import ( - "fmt" "io" "os" "path/filepath" @@ -577,7 +576,6 @@ 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) { - fmt.Println("upgrading to v2", "height", req.Height) app.SetAppVersion(ctx, v2.Version) } return res diff --git a/app/square_size.go b/app/square_size.go index 9af83aef55..e7d0ce0985 100644 --- a/app/square_size.go +++ b/app/square_size.go @@ -19,10 +19,6 @@ func (app *App) GovSquareSizeUpperBound(ctx sdk.Context) int { } gmax := int(app.BlobKeeper.GovMaxSquareSize(ctx)) - // perform a secondary check on the max square size. - if gmax > appconsts.SquareSizeUpperBound(app.AppVersion(ctx)) { - gmax = appconsts.SquareSizeUpperBound(app.AppVersion(ctx)) - } - - return gmax + hardMax :=appconsts.SquareSizeUpperBound(ctx.BlockHeader().Version.App) + return min(gmax, hardMax) } diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 31f58f440c..2fe606d531 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -23,7 +23,6 @@ var latestVersion = "latest" // and MsgSends over 30 seconds and then asserts that at least 10 transactions were // committed. func TestE2ESimple(t *testing.T) { - t.Skip() if os.Getenv("E2E") != "true" { t.Skip("skipping e2e test") } diff --git a/test/e2e/upgrade_test.go b/test/e2e/upgrade_test.go index 79ec158d15..6194504474 100644 --- a/test/e2e/upgrade_test.go +++ b/test/e2e/upgrade_test.go @@ -23,7 +23,6 @@ import ( const MajorVersion = 1 func TestMinorVersionCompatibility(t *testing.T) { - t.Skip() if os.Getenv("E2E") != "true" { t.Skip("skipping e2e test") } @@ -146,7 +145,7 @@ func TestMajorUpgradeToV2(t *testing.T) { } numNodes := 4 - upgradeHeight := int64(10) + upgradeHeight := int64(12) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -161,7 +160,6 @@ func TestMajorUpgradeToV2(t *testing.T) { require.NoError(t, err) for i := 0; i < numNodes; i++ { - t.Log("Starting node", "node", i, "version", latestVersion) require.NoError(t, testnet.CreateGenesisNode(latestVersion, 10000000, upgradeHeight)) } @@ -171,15 +169,6 @@ func TestMajorUpgradeToV2(t *testing.T) { require.NoError(t, testnet.Setup()) require.NoError(t, testnet.Start()) - // assert that the network is initially running on v1 - for i := 0; i < numNodes; i++ { - client, err := testnet.Node(i).Client() - require.NoError(t, err) - resp, err := client.Header(ctx, nil) - require.NoError(t, err) - require.Equal(t, v1.Version, resp.Header.Version.App, "version mismatch before upgrade") - } - errCh := make(chan error) encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) opts := txsim.DefaultOptions().WithSeed(seed).SuppressLogs() @@ -189,12 +178,16 @@ func TestMajorUpgradeToV2(t *testing.T) { errCh <- txsim.Run(ctx, testnet.GRPCEndpoints()[0], kr, encCfg, opts, sequences...) }() - // wait for all nodes to move past the upgrade height + // assert that the network is initially running on v1 + heightBefore := upgradeHeight - 1 for i := 0; i < numNodes; i++ { client, err := testnet.Node(i).Client() require.NoError(t, err) - require.NoError(t, waitForHeight(ctx, client, upgradeHeight+2, time.Minute)) - resp, err := client.Header(ctx, nil) + require.NoError(t, waitForHeight(ctx, client, upgradeHeight, time.Minute)) + resp, err := client.Header(ctx, &heightBefore) + require.NoError(t, err) + require.Equal(t, v1.Version, resp.Header.Version.App, "version mismatch before upgrade") + resp, err = client.Header(ctx, &upgradeHeight) require.NoError(t, err) require.Equal(t, v2.Version, resp.Header.Version.App, "version mismatch after upgrade") } diff --git a/x/upgrade/keeper.go b/x/upgrade/keeper.go index f7c2ea0fd3..54b03dd7d9 100644 --- a/x/upgrade/keeper.go +++ b/x/upgrade/keeper.go @@ -1,8 +1,6 @@ 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" @@ -25,7 +23,6 @@ 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, From 9dec0bb4dd00c63dc61bf6262a4ea7ab3ef2b08a Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 14:12:00 +0100 Subject: [PATCH 07/11] gofumpt --- app/square_size.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/square_size.go b/app/square_size.go index e7d0ce0985..8703f1dea7 100644 --- a/app/square_size.go +++ b/app/square_size.go @@ -19,6 +19,6 @@ func (app *App) GovSquareSizeUpperBound(ctx sdk.Context) int { } gmax := int(app.BlobKeeper.GovMaxSquareSize(ctx)) - hardMax :=appconsts.SquareSizeUpperBound(ctx.BlockHeader().Version.App) + hardMax := appconsts.SquareSizeUpperBound(ctx.BlockHeader().Version.App) return min(gmax, hardMax) } From fa90c36f81bd7aa2fb4ebdb425525633fb2318e1 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 14:47:38 +0100 Subject: [PATCH 08/11] use block header version --- x/blob/ante/max_total_blob_size_ante.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/blob/ante/max_total_blob_size_ante.go b/x/blob/ante/max_total_blob_size_ante.go index 7d7c0f4a7c..a94382e425 100644 --- a/x/blob/ante/max_total_blob_size_ante.go +++ b/x/blob/ante/max_total_blob_size_ante.go @@ -65,7 +65,7 @@ func (d MaxTotalBlobSizeDecorator) getMaxSquareSize(ctx sdk.Context) int { return int(appconsts.DefaultGovMaxSquareSize) } - upperBound := appconsts.SquareSizeUpperBound(ctx.ConsensusParams().Version.AppVersion) + upperBound := appconsts.SquareSizeUpperBound(ctx.BlockHeader().Version.App) govParam := d.k.GovMaxSquareSize(ctx) return min(upperBound, int(govParam)) } From e60aed57155298a281fb0a7455d2987d3f1af7b8 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Tue, 21 Nov 2023 16:17:26 +0100 Subject: [PATCH 09/11] fix integration tests --- app/test/integration_test.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app/test/integration_test.go b/app/test/integration_test.go index 4a2e054e71..775dfff370 100644 --- a/app/test/integration_test.go +++ b/app/test/integration_test.go @@ -23,6 +23,7 @@ import ( "github.com/celestiaorg/celestia-app/app" "github.com/celestiaorg/celestia-app/app/encoding" "github.com/celestiaorg/celestia-app/pkg/appconsts" + v2 "github.com/celestiaorg/celestia-app/pkg/appconsts/v2" "github.com/celestiaorg/celestia-app/pkg/blob" "github.com/celestiaorg/celestia-app/pkg/da" appns "github.com/celestiaorg/celestia-app/pkg/namespace" @@ -191,10 +192,7 @@ func (s *IntegrationTestSuite) TestMaxBlockSize() { require.LessOrEqual(t, size, uint64(appconsts.DefaultGovMaxSquareSize)) require.GreaterOrEqual(t, size, uint64(appconsts.MinSquareSize)) - // assert that the app version is correctly set - // FIXME: This should return the latest version but tendermint v0.34.x doesn't copy - // over the version when converting from proto so it disappears - require.EqualValues(t, 0, blockRes.Block.Header.Version.App) + require.EqualValues(t, v2.Version, blockRes.Block.Header.Version.App) sizes = append(sizes, size) ExtendBlobTest(t, blockRes.Block) @@ -329,9 +327,7 @@ func (s *IntegrationTestSuite) TestShareInclusionProof() { blockRes, err := node.Block(context.Background(), &txResp.Height) require.NoError(t, err) - // FIXME: This should return the latest version but tendermint v0.34.x doesn't copy - // over the version when converting from proto so it disappears - require.EqualValues(t, 0, blockRes.Block.Header.Version.App) + require.EqualValues(t, v2.Version, blockRes.Block.Header.Version.App) _, isBlobTx := coretypes.UnmarshalBlobTx(blockRes.Block.Txs[txResp.Index]) require.True(t, isBlobTx) From 71dd65abeb9b53c12f85508246b22915a21d1954 Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Wed, 22 Nov 2023 10:09:28 +0100 Subject: [PATCH 10/11] use v0.12.4 instead --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index bdec48db53..40e500e6ea 100644 --- a/go.mod +++ b/go.mod @@ -44,7 +44,7 @@ require ( github.com/bits-and-blooms/bitset v1.7.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.1 // indirect - github.com/cosmos/ledger-cosmos-go v0.13.2 // indirect + github.com/cosmos/ledger-cosmos-go v0.12.4 // indirect github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/go-connections v0.4.0 // indirect diff --git a/go.sum b/go.sum index 2aa36862b9..e462b2666e 100644 --- a/go.sum +++ b/go.sum @@ -420,8 +420,8 @@ github.com/cosmos/iavl v0.19.6 h1:XY78yEeNPrEYyNCKlqr9chrwoeSDJ0bV2VjocTk//OU= github.com/cosmos/iavl v0.19.6/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go/v6 v6.2.1 h1:NiaDXTRhKwf3n9kELD4VRIe5zby1yk1jBvaz9tXTQ6k= github.com/cosmos/ibc-go/v6 v6.2.1/go.mod h1:XLsARy4Y7+GtAqzMcxNdlQf6lx+ti1e8KcMGv5NIK7A= -github.com/cosmos/ledger-cosmos-go v0.13.2 h1:aY0KZSmUwNKbBm9OvbIjvf7Ozz2YzzpAbgvN2C8x2T0= -github.com/cosmos/ledger-cosmos-go v0.13.2/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= +github.com/cosmos/ledger-cosmos-go v0.12.4 h1:drvWt+GJP7Aiw550yeb3ON/zsrgW0jgh5saFCr7pDnw= +github.com/cosmos/ledger-cosmos-go v0.12.4/go.mod h1:fjfVWRf++Xkygt9wzCsjEBdjcf7wiiY35fv3ctT+k4M= github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= From 1dae88c56af91c976803e657c3aabdf5bb2d600b Mon Sep 17 00:00:00 2001 From: Callum Waters Date: Wed, 22 Nov 2023 10:45:17 +0100 Subject: [PATCH 11/11] use the actual v1.20.0 version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 40e500e6ea..3a626efb7c 100644 --- a/go.mod +++ b/go.mod @@ -239,7 +239,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1 + github.com/cosmos/cosmos-sdk => github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16 github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 github.com/tendermint/tendermint => github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 diff --git a/go.sum b/go.sum index e462b2666e..a7f3581544 100644 --- a/go.sum +++ b/go.sum @@ -322,8 +322,8 @@ github.com/celestiaorg/blobstream-contracts/v3 v3.1.0 h1:h1Y4V3EMQ2mFmNtWt2sIhZI github.com/celestiaorg/blobstream-contracts/v3 v3.1.0/go.mod h1:x4DKyfKOSv1ZJM9NwV+Pw01kH2CD7N5zTFclXIVJ6GQ= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29 h1:Fd7ymPUzExPGNl2gZw4i5S74arMw+iDHLE78M/cCxl4= github.com/celestiaorg/celestia-core v1.29.0-tm-v0.34.29/go.mod h1:xrICN0PBhp3AdTaZ8q4wS5Jvi32V02HNjaC2EsWiEKk= -github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1 h1:GtiF/vbSeJVd89W5b3jCFpik9JwcDmYsvZ1o9Tqg8Ds= -github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16-rc1/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16 h1:L2j5luXXoEMQLzJkxBixeeEWkgcxnGFm6HnwN3X3L9g= +github.com/celestiaorg/cosmos-sdk v1.20.0-sdk-v0.46.16/go.mod h1:Tvsc3YnqvflXTYC8xIy/Q07Es95xZ1pZC/imoKogtbg= github.com/celestiaorg/knuu v0.10.0 h1:uYO6hVsoCAJ/Q4eV0Pn8CLbbupGAjD56xQc4y2t4lf0= github.com/celestiaorg/knuu v0.10.0/go.mod h1:2NjDX29x09hRpaaWaKvi7pw9VjI/SHo+/4HldyEW50g= github.com/celestiaorg/merkletree v0.0.0-20210714075610-a84dc3ddbbe4 h1:CJdIpo8n5MFP2MwK0gSRcOVlDlFdQJO1p+FqdxYzmvc=