Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: remove blobstream param subspace when upgrading to v2 #3401

Merged
merged 8 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,11 @@ func (app *App) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.Respo
if req.Height == app.upgradeHeightV2-1 {
app.SetInitialAppVersionInConsensusParams(ctx, v2)
app.SetAppVersion(ctx, v2)
// The blobstream module was disabled in v2 so the following line
// removes the the params subspace for blobstream.
if err := app.ParamsKeeper.DeleteSubspace(blobstreamtypes.ModuleName); err != nil {
panic(err)
}
rootulp marked this conversation as resolved.
Show resolved Hide resolved
}
// from v2 to v3 and onwards we use a signalling mechanism
} else if shouldUpgrade, newVersion := app.SignalKeeper.ShouldUpgrade(); shouldUpgrade {
Expand Down
48 changes: 41 additions & 7 deletions app/test/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,19 @@ import (
v1 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v1"
v2 "github.com/celestiaorg/celestia-app/v2/pkg/appconsts/v2"
"github.com/celestiaorg/celestia-app/v2/test/util"
blobstreamtypes "github.com/celestiaorg/celestia-app/v2/x/blobstream/types"
"github.com/celestiaorg/celestia-app/v2/x/minfee"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/params/types/proposal"
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate import statement.

- packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"

This import statement is duplicated and should be removed to clean up the code.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"

icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
tmversion "github.com/tendermint/tendermint/proto/tendermint/version"
dbm "github.com/tendermint/tm-db"

packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"

"github.com/tendermint/tendermint/libs/log"
)

// TestAppUpgrades verifies that the all module's params are overridden during an
Expand Down Expand Up @@ -63,9 +62,6 @@ func TestAppUpgrades(t *testing.T) {
t.Run(tt.module, func(t *testing.T) {
testApp, _ := SetupTestAppWithUpgradeHeight(t, 3)

supportedVersions := []uint64{v1.Version, v2.Version}
require.Equal(t, supportedVersions, testApp.SupportedVersions())

ctx := testApp.NewContext(true, tmproto.Header{
Version: tmversion.Consensus{
App: 1,
Expand Down Expand Up @@ -102,6 +98,30 @@ func TestAppUpgrades(t *testing.T) {
}
}

// TestBlobstreamRemovedInV2 verifies that the blobstream params exist in v1 and
// do not exist in v2.
func TestBlobstreamRemovedInV2(t *testing.T) {
testApp, _ := SetupTestAppWithUpgradeHeight(t, 3)
ctx := testApp.NewContext(true, tmproto.Header{})

require.EqualValues(t, 1, testApp.AppVersion())
got, err := testApp.ParamsKeeper.Params(ctx, &proposal.QueryParamsRequest{
Subspace: blobstreamtypes.ModuleName,
Key: string(blobstreamtypes.ParamsStoreKeyDataCommitmentWindow),
})
require.NoError(t, err)
require.Equal(t, "\"400\"", got.Param.Value)

upgradeFromV1ToV2(t, testApp)

require.EqualValues(t, 2, testApp.AppVersion())
_, err = testApp.ParamsKeeper.Params(ctx, &proposal.QueryParamsRequest{
Subspace: blobstreamtypes.ModuleName,
Key: string(blobstreamtypes.ParamsStoreKeyDataCommitmentWindow),
})
require.Error(t, err)
}

func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App, keyring.Keyring) {
t.Helper()

Expand Down Expand Up @@ -139,6 +159,20 @@ func SetupTestAppWithUpgradeHeight(t *testing.T, upgradeHeight int64) (*app.App,
infoResp = testApp.Info(abci.RequestInfo{})
require.EqualValues(t, app.DefaultInitialConsensusParams().Version.AppVersion, infoResp.AppVersion)

supportedVersions := []uint64{v1.Version, v2.Version}
require.Equal(t, supportedVersions, testApp.SupportedVersions())

_ = testApp.Commit()
return testApp, kr
}

func upgradeFromV1ToV2(t *testing.T, testApp *app.App) {
t.Helper()
testApp.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{
Height: 2,
Version: tmversion.Consensus{App: 1},
}})
testApp.EndBlock(abci.RequestEndBlock{Height: 2})
testApp.Commit()
require.EqualValues(t, 2, testApp.AppVersion())
}
Loading