Skip to content

Commit

Permalink
refactor(x): cleanup module dependency graph
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 6, 2023
1 parent fb9dadc commit 0df44a0
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 1,302 deletions.
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
cosmossdk.io/math v1.1.3-rc.1
cosmossdk.io/store v1.0.0
cosmossdk.io/x/bank v0.0.0-00010101000000-000000000000
cosmossdk.io/x/gov v0.0.0-20230925135524-a1bc045b3190
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/tx v0.12.0
github.com/99designs/keyring v1.2.1
Expand Down Expand Up @@ -169,7 +168,6 @@ require (
replace (
cosmossdk.io/x/bank => ./x/bank
cosmossdk.io/x/distribution => ./x/distribution
cosmossdk.io/x/gov => ./x/gov
cosmossdk.io/x/mint => ./x/mint
cosmossdk.io/x/protocolpool => ./x/protocolpool
cosmossdk.io/x/slashing => ./x/slashing
Expand Down
12 changes: 1 addition & 11 deletions x/bank/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
cosmossdk.io/log v1.2.1
cosmossdk.io/math v1.1.3-rc.1
cosmossdk.io/store v1.0.0
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
cosmossdk.io/x/staking fb9dadc00f65d6a17fc6bc2437bb4eee33dd0408
github.com/cometbft/cometbft v0.38.0
github.com/cosmos/cosmos-proto v1.0.0-beta.3
github.com/cosmos/cosmos-sdk v0.51.0
Expand Down Expand Up @@ -157,13 +157,3 @@ require (
)

replace github.com/cosmos/cosmos-sdk => ../../.

// TODO remove post spinning out all modules
replace (
cosmossdk.io/x/distribution => ../distribution
cosmossdk.io/x/gov => ../gov
cosmossdk.io/x/mint => ../mint
cosmossdk.io/x/protocolpool => ../protocolpool
cosmossdk.io/x/slashing => ../slashing
cosmossdk.io/x/staking => ../staking
)
1,277 changes: 0 additions & 1,277 deletions x/bank/go.sum

This file was deleted.

3 changes: 1 addition & 2 deletions x/crisis/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"

"cosmossdk.io/errors"
govtypes "cosmossdk.io/x/gov/types"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
Expand Down Expand Up @@ -78,7 +77,7 @@ func (k *Keeper) VerifyInvariant(goCtx context.Context, msg *types.MsgVerifyInva
// It defines a method to update the x/crisis module parameters.
func (k *Keeper) UpdateParams(ctx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if k.authority != msg.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
return nil, errors.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority)
}

if !msg.ConstantFee.IsValid() {
Expand Down
3 changes: 1 addition & 2 deletions x/crisis/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"cosmossdk.io/core/appmodule"
"cosmossdk.io/core/store"
"cosmossdk.io/depinject"
govtypes "cosmossdk.io/x/gov/types"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
Expand Down Expand Up @@ -201,7 +200,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
}

// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govtypes.ModuleName)
authority := authtypes.NewModuleAddress(types.GovModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
Expand Down
1 change: 1 addition & 0 deletions x/crisis/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import "cosmossdk.io/errors"
var (
ErrNoSender = errors.Register(ModuleName, 2, "sender address is empty")
ErrUnknownInvariant = errors.Register(ModuleName, 3, "unknown invariant")
ErrInvalidSigner = errors.Register(ModuleName, 4, "expected authority account as only signer for proposal message")
)
5 changes: 5 additions & 0 deletions x/crisis/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const (
ModuleName = "crisis"

StoreKey = ModuleName

// GovModuleName duplicates the gov module's name to avoid a cyclic dependency with x/gov.
// It should be synced with the gov module's name if it is ever changed.
// See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9
GovModuleName = "gov"
)

var ConstantFeeKey = collections.NewPrefix(1)
4 changes: 3 additions & 1 deletion x/distribution/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ const (
// RouterKey is the message route for distribution
RouterKey = ModuleName

// GovModuleName is the name of the gov module
// GovModuleName duplicates the gov module's name to avoid a cyclic dependency with x/gov.
// It should be synced with the gov module's name if it is ever changed.
// See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9
GovModuleName = "gov"
)

Expand Down
4 changes: 3 additions & 1 deletion x/protocolpool/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ const (
// RouterKey is the message route for protocolpool
RouterKey = ModuleName

// GovModuleName is the name of the gov module
// GovModuleName duplicates the gov module's name to avoid a cyclic dependency with x/gov.
// It should be synced with the gov module's name if it is ever changed.
// See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9
GovModuleName = "gov"
)

Expand Down
4 changes: 1 addition & 3 deletions x/upgrade/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

const govModuleName = "gov"

type KeeperTestSuite struct {
suite.Suite

Expand Down Expand Up @@ -67,7 +65,7 @@ func (s *KeeperTestSuite) SetupTest() {

homeDir := filepath.Join(s.T().TempDir(), "x_upgrade_keeper_test")
ac := addresscodec.NewBech32Codec("cosmos")
authority, err := ac.BytesToString(authtypes.NewModuleAddress(govModuleName))
authority, err := ac.BytesToString(authtypes.NewModuleAddress(types.GovModuleName))
s.Require().NoError(err)
s.encodedAuthority = authority
s.upgradeKeeper = keeper.NewKeeper(skipUpgradeHeights, storeService, s.encCfg.Codec, homeDir, s.baseApp, authority)
Expand Down
4 changes: 1 addition & 3 deletions x/upgrade/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import (
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
)

const govModuleName = "gov"

func init() {
types.RegisterLegacyAminoCodec(codec.NewLegacyAmino())
}
Expand Down Expand Up @@ -207,7 +205,7 @@ func ProvideModule(in ModuleInputs) ModuleOutputs {
}

// default to governance authority if not provided
authority := authtypes.NewModuleAddress(govModuleName)
authority := authtypes.NewModuleAddress(types.GovModuleName)
if in.Config.Authority != "" {
authority = authtypes.NewModuleAddressOrBech32Address(in.Config.Authority)
}
Expand Down
5 changes: 5 additions & 0 deletions x/upgrade/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ const (

// StoreKey is the prefix under which we store this module's data
StoreKey = ModuleName

// GovModuleName duplicates the gov module's name to avoid a cyclic dependency with x/gov.
// It should be synced with the gov module's name if it is ever changed.
// See: https://github.com/cosmos/cosmos-sdk/blob/b62a28aac041829da5ded4aeacfcd7a42873d1c8/x/gov/types/keys.go#L9
GovModuleName = "gov"
)

const (
Expand Down

0 comments on commit 0df44a0

Please sign in to comment.