Skip to content

Commit

Permalink
Add missing SDK 0.47 upgrade items (#323)
Browse files Browse the repository at this point in the history
* Add missing SDK 0.47 upgrade steps

* Remove msg event boilerplate replace in 0.47
  • Loading branch information
cbrit authored Oct 29, 2024
1 parent 86d4c4f commit c1c69fd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 47 deletions.
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)

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

0 comments on commit c1c69fd

Please sign in to comment.