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..8703f1dea7 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()) { - gmax = appconsts.SquareSizeUpperBound(app.AppVersion()) - } - - return gmax + hardMax := appconsts.SquareSizeUpperBound(ctx.BlockHeader().Version.App) + return min(gmax, hardMax) } 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) diff --git a/cmd/celestia-appd/cmd/root.go b/cmd/celestia-appd/cmd/root.go index b0d8c9ab6b..8b55b09e7c 100644 --- a/cmd/celestia-appd/cmd/root.go +++ b/cmd/celestia-appd/cmd/root.go @@ -4,7 +4,6 @@ import ( "io" "os" "path/filepath" - "strconv" bscmd "github.com/celestiaorg/celestia-app/x/blobstream/client" @@ -237,20 +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 { - 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/go.mod b/go.mod index 81c1a340b5..3a626efb7c 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 @@ -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 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..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.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 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= @@ -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= 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..6194504474 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" @@ -134,6 +135,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] @@ -143,7 +145,7 @@ func TestMajorUpgradeToV2(t *testing.T) { } numNodes := 4 - upgradeHeight := int64(10) + upgradeHeight := int64(12) ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -158,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)) } @@ -168,16 +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) - // FIXME: we are not correctly setting the app version at genesis - require.Equal(t, uint64(0), resp.Header.Version.App, "version mismatch before upgrade") - } - errCh := make(chan error) encCfg := encoding.MakeConfig(app.ModuleEncodingRegisters...) opts := txsim.DefaultOptions().WithSeed(seed).SuppressLogs() @@ -187,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/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/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)) } diff --git a/x/upgrade/upgrade_test.go b/x/upgrade/upgrade_test.go index 5cf6b9fe78..cd9c17d2cb 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,12 @@ 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.NotNil(t, respEndBlock.ConsensusParamUpdates.Version) 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 +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()) + infoResp := testApp.Info(abci.RequestInfo{}) + require.EqualValues(t, 0, infoResp.AppVersion) cp := app.DefaultConsensusParams() abciParams := &abci.ConsensusParams{ @@ -64,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()) + infoResp = testApp.Info(abci.RequestInfo{}) + require.EqualValues(t, app.DefaultConsensusParams().Version.AppVersion, infoResp.AppVersion) _ = testApp.Commit() return testApp, kr