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

Suppress scope value owner migration events. #2195

Merged
merged 3 commits into from
Oct 24, 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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Suppress the events emitted during the metadata migration that changes how scope value owners are recorded [PR 2195](https://github.com/provenance-io/provenance/pull/2195).
46 changes: 46 additions & 0 deletions internal/sdk/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package sdk

import (
abci "github.com/cometbft/cometbft/abci/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/gogoproto/proto"
)

// NoOpEventManager is an event manager that satisfies the sdk.EventManagerI interface, but does nothing.
type NoOpEventManager struct{}

var _ sdk.EventManagerI = (*NoOpEventManager)(nil)

// NewNoOpEventManager returns a new event manager that does nothing.
func NewNoOpEventManager() *NoOpEventManager {
return &NoOpEventManager{}
}

// Events returns sdk.EmptyEvents().
func (x NoOpEventManager) Events() sdk.Events {
// Returning sdk.EmptyEvents() here (instead of nil) to match sdk.EventManager behavior.
return sdk.EmptyEvents()
}

// ABCIEvents returns sdk.EmptyABCIEvents().
func (x NoOpEventManager) ABCIEvents() []abci.Event {
// Returning sdk.EmptyABCIEvents() here (instead of nil) to match sdk.EventManager behavior.
return sdk.EmptyABCIEvents()
}

// EmitTypedEvent ignores the provided argument, does nothing, and always returns nil.
func (x NoOpEventManager) EmitTypedEvent(_ proto.Message) error {
return nil
}

// EmitTypedEvents ignores the provided arguments, does nothing, and always returns nil.
func (x NoOpEventManager) EmitTypedEvents(_ ...proto.Message) error {
return nil
}

// EmitEvent ignores the provided event and does nothing.
func (x NoOpEventManager) EmitEvent(_ sdk.Event) {}

// EmitEvents ignores the provided events and does nothing.
func (x NoOpEventManager) EmitEvents(_ sdk.Events) {}
8 changes: 8 additions & 0 deletions x/metadata/keeper/migrations_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ import (
"github.com/cosmos/cosmos-sdk/types/address"
"github.com/cosmos/gogoproto/proto"

internalsdk "github.com/provenance-io/provenance/internal/sdk"
markertypes "github.com/provenance-io/provenance/x/marker/types"
"github.com/provenance-io/provenance/x/metadata/types"
)

// Migrate3To4 will update the metadata store from version 3 to version 4. This should be part of the viridian upgrade.
func (m Migrator) Migrate3To4(ctx sdk.Context) error {
// This migration emits too many events and can cause problems with nodes due to its size.
// So we'll just throw all of them away by swapping in a different event manager here.
// But the testnet migration already ran using v1.20.0-rc2 which included all of the events in the block result.
// So, to keep v1.20.0-rc2 and v1.20.0 state compatible, we only throw out the events when not on a testnet.
if sdk.GetConfig().GetBech32AccountAddrPrefix() != "tp" {
ctx = ctx.WithEventManager(internalsdk.NewNoOpEventManager())
}
logger := m.keeper.Logger(ctx)
logger.Info("Starting migration of x/metadata from 3 to 4.")
if err := migrateValueOwners(ctx, newKeeper3To4(m.keeper)); err != nil {
Expand Down
Loading