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

Add missing SDK 0.47 upgrade items #323

Merged
merged 2 commits into from
Oct 29, 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
10 changes: 9 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,11 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() {

if upgradeInfo.Name == v8.UpgradeName {
storeUpgrades = &storetypes.StoreUpgrades{
Added: []string{addressestypes.ModuleName},
Added: []string{
addressestypes.ModuleName,
consensusparamtypes.ModuleName,
crisistypes.ModuleName,
},
}
}

Expand All @@ -1034,12 +1038,16 @@ func (app *SommelierApp) setupUpgradeStoreLoaders() {
}

func (app *SommelierApp) setupUpgradeHandlers() {
baseAppLegacySS := app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())

// TODO: Add v8 upgrade handle
app.UpgradeKeeper.SetUpgradeHandler(
v8.UpgradeName,
v8.CreateUpgradeHandler(
app.mm,
app.configurator,
&baseAppLegacySS,
&app.ConsensusParamsKeeper,
),
)
}
8 changes: 8 additions & 0 deletions app/upgrades/v8/upgrades.go
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
package v8

import (
"github.com/cosmos/cosmos-sdk/baseapp"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
consensusparamkeeper "github.com/cosmos/cosmos-sdk/x/consensus/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func CreateUpgradeHandler(
mm *module.Manager,
configurator module.Configurator,
baseAppLegacySS *paramstypes.Subspace,
consensusParamsKeeper *consensusparamkeeper.Keeper,
) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
ctx.Logger().Info("v8 upgrade: entering handler and running migrations")

// new x/consensus module params migration
baseapp.MigrateParams(ctx, baseAppLegacySS, consensusParamsKeeper)
Comment on lines +21 to +22
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider adding error handling for parameter migration

While the parameter migration is correctly implemented, consider handling potential errors from MigrateParams to ensure a more robust upgrade process.

 // new x/consensus module params migration
-baseapp.MigrateParams(ctx, baseAppLegacySS, consensusParamsKeeper)
+if err := baseapp.MigrateParams(ctx, baseAppLegacySS, consensusParamsKeeper); err != nil {
+    return nil, fmt.Errorf("failed to migrate consensus params: %w", err)
+}

Committable suggestion was skipped due to low confidence.


return mm.RunMigrations(ctx, configurator, vm)
}
}
4 changes: 0 additions & 4 deletions x/cork/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ func (k Keeper) ScheduleCork(c context.Context, msg *types.MsgScheduleCorkReques

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, corktypes.AttributeValueCategory),
),
sdk.NewEvent(
corktypes.EventTypeCork,
sdk.NewAttribute(sdk.AttributeKeyModule, corktypes.AttributeValueCategory),
Expand Down
42 changes: 0 additions & 42 deletions x/pubsub/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ func (k Keeper) AddPublisherIntent(c context.Context, msg *types.MsgAddPublisher

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeAddPublisherIntent),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeAddPublisherIntent,
sdk.NewAttribute(types.AttributeKeySubscriptionID, publisherIntent.SubscriptionId),
Expand Down Expand Up @@ -127,12 +121,6 @@ func (k Keeper) AddSubscriberIntent(c context.Context, msg *types.MsgAddSubscrib

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeAddSubscriberIntent),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeAddSubscriberIntent,
sdk.NewAttribute(types.AttributeKeySubscriptionID, subscriberIntent.SubscriptionId),
Expand Down Expand Up @@ -164,12 +152,6 @@ func (k Keeper) AddSubscriber(c context.Context, msg *types.MsgAddSubscriberRequ

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeAddSubscriber),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeAddSubscriber,
sdk.NewAttribute(types.AttributeKeySubscriberAddress, subscriber.Address),
Expand Down Expand Up @@ -212,12 +194,6 @@ func (k Keeper) RemovePublisherIntent(c context.Context, msg *types.MsgRemovePub

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeRemovePublisherIntent),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeRemovePublisherIntent,
sdk.NewAttribute(types.AttributeKeySubscriptionID, subscriptionID),
Expand Down Expand Up @@ -263,12 +239,6 @@ func (k Keeper) RemoveSubscriberIntent(c context.Context, msg *types.MsgRemoveSu

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeRemoveSubscriberIntent),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeRemoveSubscriberIntent,
sdk.NewAttribute(types.AttributeKeySubscriptionID, subscriptionID),
Expand Down Expand Up @@ -305,12 +275,6 @@ func (k Keeper) RemoveSubscriber(c context.Context, msg *types.MsgRemoveSubscrib

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeRemoveSubscriber),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeRemoveSubscriber,
sdk.NewAttribute(types.AttributeKeySubscriptionID, subscriberAddress),
Expand Down Expand Up @@ -343,12 +307,6 @@ func (k Keeper) RemovePublisher(c context.Context, msg *types.MsgRemovePublisher

ctx.EventManager().EmitEvents(
sdk.Events{
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyAction, types.EventTypeRemovePublisher),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer),
),
sdk.NewEvent(
types.EventTypeRemovePublisher,
sdk.NewAttribute(types.AttributeKeyPublisherDomain, publisherDomain),
Expand Down
Loading