From 93d30e0e7110ab7ecac3ee04780a612eb33c575f Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 15 Jun 2023 12:33:42 +0530 Subject: [PATCH 1/3] chore: remove x/gov module dependecies in x/staking --- x/staking/keeper/keeper_test.go | 3 +-- x/staking/keeper/msg_server.go | 3 +-- x/staking/module.go | 3 +-- x/staking/types/errors.go | 1 + x/staking/types/keys.go | 3 +++ 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/x/staking/keeper/keeper_test.go b/x/staking/keeper/keeper_test.go index bbfbeda17467..ec8d353ca40c 100644 --- a/x/staking/keeper/keeper_test.go +++ b/x/staking/keeper/keeper_test.go @@ -18,7 +18,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingtestutil "github.com/cosmos/cosmos-sdk/x/staking/testutil" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -60,7 +59,7 @@ func (s *KeeperTestSuite) SetupTest() { key, accountKeeper, bankKeeper, - authtypes.NewModuleAddress(govtypes.ModuleName).String(), + authtypes.NewModuleAddress(stakingtypes.GovModuleName).String(), ) keeper.SetParams(ctx, stakingtypes.DefaultParams()) diff --git a/x/staking/keeper/msg_server.go b/x/staking/keeper/msg_server.go index 94793e455760..e3ae767e84d3 100644 --- a/x/staking/keeper/msg_server.go +++ b/x/staking/keeper/msg_server.go @@ -16,7 +16,6 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -542,7 +541,7 @@ func (k msgServer) CancelUnbondingDelegation(goCtx context.Context, msg *types.M func (k msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if k.authority != msg.Authority { - return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) + return nil, errorsmod.Wrapf(types.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, msg.Authority) } if err := msg.Params.Validate(); err != nil { diff --git a/x/staking/module.go b/x/staking/module.go index 4588cfa7cda5..46ceca9bb6cc 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -22,7 +22,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" "github.com/cosmos/cosmos-sdk/x/staking/exported" "github.com/cosmos/cosmos-sdk/x/staking/keeper" @@ -232,7 +231,7 @@ type ModuleOutputs struct { 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) } diff --git a/x/staking/types/errors.go b/x/staking/types/errors.go index ee1750c22368..4a064adeea56 100644 --- a/x/staking/types/errors.go +++ b/x/staking/types/errors.go @@ -50,4 +50,5 @@ var ( ErrCommissionLTMinRate = errors.Register(ModuleName, 40, "commission cannot be less than min rate") ErrUnbondingNotFound = errors.Register(ModuleName, 41, "unbonding operation not found") ErrUnbondingOnHoldRefCountNegative = errors.Register(ModuleName, 42, "cannot un-hold unbonding operation that is not on hold") + ErrInvalidSigner = errors.Register(ModuleName, 43, "expected gov account as only signer for proposal message") ) diff --git a/x/staking/types/keys.go b/x/staking/types/keys.go index 4c905e1110c3..8b77a9098751 100644 --- a/x/staking/types/keys.go +++ b/x/staking/types/keys.go @@ -22,6 +22,9 @@ const ( // RouterKey is the msg router key for the staking module RouterKey = ModuleName + + // GovModuleName is the name of the gov module + GovModuleName = "gov" ) var ( From 82b150592925a73c9652f6778877bb08bddd5bc3 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 15 Jun 2023 14:45:30 +0530 Subject: [PATCH 2/3] review change --- x/staking/types/errors.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/staking/types/errors.go b/x/staking/types/errors.go index 4a064adeea56..480a121a2390 100644 --- a/x/staking/types/errors.go +++ b/x/staking/types/errors.go @@ -50,5 +50,5 @@ var ( ErrCommissionLTMinRate = errors.Register(ModuleName, 40, "commission cannot be less than min rate") ErrUnbondingNotFound = errors.Register(ModuleName, 41, "unbonding operation not found") ErrUnbondingOnHoldRefCountNegative = errors.Register(ModuleName, 42, "cannot un-hold unbonding operation that is not on hold") - ErrInvalidSigner = errors.Register(ModuleName, 43, "expected gov account as only signer for proposal message") + ErrInvalidSigner = errors.Register(ModuleName, 43, "expected authority account as only signer for proposal message") ) From ef5989d3d5d1c2d3af9cf93c55d8bf0e84fac805 Mon Sep 17 00:00:00 2001 From: atheesh Date: Thu, 15 Jun 2023 14:58:01 +0530 Subject: [PATCH 3/3] review change --- x/auth/keeper/msg_server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/auth/keeper/msg_server.go b/x/auth/keeper/msg_server.go index cee9af2633e6..195031460640 100644 --- a/x/auth/keeper/msg_server.go +++ b/x/auth/keeper/msg_server.go @@ -24,7 +24,7 @@ func NewMsgServerImpl(ak AccountKeeper) types.MsgServer { func (ms msgServer) UpdateParams(goCtx context.Context, msg *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) { if ms.ak.authority != msg.Authority { return nil, fmt.Errorf( - "expected gov account as only signer for proposal message; invalid authority; expected %s, got %s", + "expected authority account as only signer for proposal message; invalid authority; expected %s, got %s", ms.ak.authority, msg.Authority) }