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

Properly create the module account for auction #8178

Merged
merged 5 commits into from
May 1, 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
8 changes: 8 additions & 0 deletions app/upgrades/v25/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"errors"
"sort"

"github.com/osmosis-labs/osmosis/osmoutils"
auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
Expand Down Expand Up @@ -67,6 +70,11 @@ func CreateUpgradeHandler(
return nil, errors.New("unsupported chain ID")
}

// Ensure the auction module account is properly created to avoid sniping
err = osmoutils.CreateModuleAccountByName(ctx, keepers.AccountKeeper, auctiontypes.ModuleName)
if err != nil {
return nil, err
}
// update block-sdk params
if err := keepers.AuctionKeeper.SetParams(ctx, AuctionParams); err != nil {
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions app/upgrades/v25/upgrades_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v25_test

import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
auctiontypes "github.com/skip-mev/block-sdk/x/auction/types"
"testing"
"time"

Expand Down Expand Up @@ -48,6 +50,12 @@ func (s *UpgradeTestSuite) TestUpgrade() {
s.App.BeginBlocker(s.Ctx, abci.RequestBeginBlock{})
})

// check auction module account
acc := s.App.AccountKeeper.GetModuleAccount(s.Ctx, auctiontypes.ModuleName)
s.Require().NotNil(acc)
s.Require().Equal(auctiontypes.ModuleName, acc.GetName())
s.Require().Equal(authtypes.NewModuleAddress(auctiontypes.ModuleName), acc.GetAddress())

// check auction params
params, err := s.App.AuctionKeeper.GetParams(s.Ctx)
s.Require().NoError(err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/ory/dockertest/v3 v3.10.0
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3
github.com/osmosis-labs/osmosis/osmomath v0.0.12-0.20240423073233-246239a8f662
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430090100-86b41c48fe1b
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430173456-105713b242f8
github.com/osmosis-labs/osmosis/x/epochs v0.0.8-0.20240423073233-246239a8f662
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.14-0.20240423073233-246239a8f662
github.com/osmosis-labs/sqs/sqsdomain v0.0.0-20240429202838-7d69de2c9bea
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1487,8 +1487,8 @@ github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:Ylmch
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.12-0.20240423073233-246239a8f662 h1:P6deXtGtSXJgPtvo6f/1vAQgF38HUsrIT6Mq7LMGYrs=
github.com/osmosis-labs/osmosis/osmomath v0.0.12-0.20240423073233-246239a8f662/go.mod h1:ubFhAjLis9cH6GPIhaCjf4JdXrn8HBBOxvOYMxPtgSM=
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430090100-86b41c48fe1b h1:VT4eKfFkL9FxuVAO05I06z6Wp6sD99eB7z1ZzaqoMF0=
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430090100-86b41c48fe1b/go.mod h1:sHrm1JXicWHDt74cJavXKe19OWongf/kiVX9SBI+Dec=
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430173456-105713b242f8 h1:4Zm6E1mk8r68kwIUafaHbEWhexob60sxBTcVDlV7jek=
github.com/osmosis-labs/osmosis/osmoutils v0.0.12-0.20240430173456-105713b242f8/go.mod h1:sHrm1JXicWHDt74cJavXKe19OWongf/kiVX9SBI+Dec=
github.com/osmosis-labs/osmosis/x/epochs v0.0.8-0.20240423073233-246239a8f662 h1:bG3Fll3ryw+yo+70u0oOUjxq1SZ2GgTRDgmivZEdPKE=
github.com/osmosis-labs/osmosis/x/epochs v0.0.8-0.20240423073233-246239a8f662/go.mod h1:3BTKszIZFP/3ut/sW0izJOZRNDXWINU5zfZGo+a8QhE=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.14-0.20240423073233-246239a8f662 h1:1GiW1IDHH6BfmBYdP5YGnS+TkO6ZKKVzSFccG9RH9gA=
Expand Down
19 changes: 19 additions & 0 deletions osmoutils/module_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,22 @@ func CreateModuleAccount(ctx sdk.Context, ak AccountKeeper, addr sdk.AccAddress)
ak.SetAccount(ctx, acc)
return nil
}

// CreateModuleAccountByName creates a module account at the provided name
func CreateModuleAccountByName(ctx sdk.Context, ak AccountKeeper, name string) error {
addr := authtypes.NewModuleAddress(name)
err := CanCreateModuleAccountAtAddr(ctx, ak, addr)
if err != nil {
return err
}

acc := ak.NewAccount(
ctx,
authtypes.NewModuleAccount(
authtypes.NewBaseAccountWithAddress(addr),
name,
),
)
ak.SetAccount(ctx, acc)
return nil
}