From d01c28b242d66504566c57f8afe2b086d7cca07e Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 14 Sep 2023 15:10:38 +0200 Subject: [PATCH 1/5] remvoe some cruff in the circuit module --- runtime/module.go | 6 ------ runtime/services.go | 12 ------------ x/circuit/client/cli/tx.go | 16 +++++++++++++--- x/circuit/keeper/query.go | 6 ++---- x/circuit/module.go | 1 - x/circuit/types/codec.go | 10 ---------- x/circuit/types/msgs.go | 36 ------------------------------------ 7 files changed, 15 insertions(+), 72 deletions(-) delete mode 100644 x/circuit/types/msgs.go diff --git a/runtime/module.go b/runtime/module.go index efb71ca3152f..44b019f5809b 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -16,7 +16,6 @@ import ( "cosmossdk.io/core/appmodule" "cosmossdk.io/core/event" "cosmossdk.io/core/genesis" - "cosmossdk.io/core/header" "cosmossdk.io/core/store" "cosmossdk.io/depinject" "cosmossdk.io/log" @@ -71,7 +70,6 @@ func init() { ProvideMemoryStoreService, ProvideTransientStoreService, ProvideEventService, - ProvideHeaderInfoService, ProvideBasicManager, ProvideAppVersionModifier, ProvideAddressCodec, @@ -245,10 +243,6 @@ func ProvideEventService() event.Service { return EventService{} } -func ProvideHeaderInfoService(app *AppBuilder) header.Service { - return headerInfoService{} -} - func ProvideBasicManager(app *AppBuilder) module.BasicManager { return app.app.basicManager } diff --git a/runtime/services.go b/runtime/services.go index 844a5f7e3aa6..0b9223d92a29 100644 --- a/runtime/services.go +++ b/runtime/services.go @@ -1,15 +1,11 @@ package runtime import ( - "context" - appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - "cosmossdk.io/core/header" "github.com/cosmos/cosmos-sdk/runtime/services" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" ) @@ -25,11 +21,3 @@ func (a *App) registerRuntimeServices(cfg module.Configurator) error { return nil } - -var _ header.Service = headerInfoService{} - -type headerInfoService struct{} - -func (headerInfoService) GetHeaderInfo(ctx context.Context) header.Info { - return sdk.UnwrapSDKContext(ctx).HeaderInfo() -} diff --git a/x/circuit/client/cli/tx.go b/x/circuit/client/cli/tx.go index a3c44f8101ef..f74b2e9f1f07 100644 --- a/x/circuit/client/cli/tx.go +++ b/x/circuit/client/cli/tx.go @@ -68,7 +68,11 @@ func AuthorizeCircuitBreakerCmd() *cobra.Command { permission := types.Permissions{Level: types.Permissions_Level(lvl.Uint64()), LimitTypeUrls: typeUrls} - msg := types.NewMsgAuthorizeCircuitBreaker(clientCtx.GetFromAddress().String(), grantee.String(), &permission) + msg := &types.MsgAuthorizeCircuitBreaker{ + Granter: clientCtx.GetFromAddress().String(), + Grantee: grantee.String(), + Permissions: &permission, + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, @@ -92,7 +96,10 @@ func TripCircuitBreakerCmd() *cobra.Command { return err } - msg := types.NewMsgTripCircuitBreaker(clientCtx.GetFromAddress().String(), strings.Split(args[0], ",")) + msg := &types.MsgTripCircuitBreaker{ + Authority: clientCtx.GetFromAddress().String(), + MsgTypeUrls: strings.Split(args[0], ","), + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, @@ -118,7 +125,10 @@ func ResetCircuitBreakerCmd() *cobra.Command { msgTypeUrls := strings.Split(args[0], ",") - msg := types.NewMsgResetCircuitBreaker(clientCtx.GetFromAddress().String(), msgTypeUrls) + msg := &types.MsgResetCircuitBreaker{ + Authority: clientCtx.GetFromAddress().String(), + MsgTypeUrls: msgTypeUrls, + } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, diff --git a/x/circuit/keeper/query.go b/x/circuit/keeper/query.go index 8ab7b4214ae0..3c3e79eec421 100644 --- a/x/circuit/keeper/query.go +++ b/x/circuit/keeper/query.go @@ -5,7 +5,6 @@ import ( "cosmossdk.io/x/circuit/types" - sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/query" ) @@ -22,15 +21,14 @@ func NewQueryServer(keeper Keeper) types.QueryServer { } // Account returns account permissions. -func (qs QueryServer) Account(c context.Context, req *types.QueryAccountRequest) (*types.AccountResponse, error) { - sdkCtx := sdk.UnwrapSDKContext(c) +func (qs QueryServer) Account(ctx context.Context, req *types.QueryAccountRequest) (*types.AccountResponse, error) { add, err := qs.keeper.addressCodec.StringToBytes(req.Address) if err != nil { return nil, err } - perms, err := qs.keeper.Permissions.Get(sdkCtx, add) + perms, err := qs.keeper.Permissions.Get(ctx, add) if err != nil { return nil, err } diff --git a/x/circuit/module.go b/x/circuit/module.go index dd49a874e7ce..ddfc6449c3c3 100644 --- a/x/circuit/module.go +++ b/x/circuit/module.go @@ -50,7 +50,6 @@ func (AppModuleBasic) Name() string { return types.ModuleName } // RegisterLegacyAminoCodec registers the circuit module's types on the LegacyAmino codec. func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - types.RegisterLegacyAminoCodec(cdc) } // DefaultGenesis returns default genesis state as raw bytes for the circuit diff --git a/x/circuit/types/codec.go b/x/circuit/types/codec.go index ceddf6254300..775eb1aee1c5 100644 --- a/x/circuit/types/codec.go +++ b/x/circuit/types/codec.go @@ -1,21 +1,11 @@ package types import ( - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/codec/legacy" types "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) -// RegisterLegacyAminoCodec registers the necessary circuit interfaces and concrete types -// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. -func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgAuthorizeCircuitBreaker{}, "cosmos-sdk/MsgAuthorizeCircuitBreaker") - legacy.RegisterAminoMsg(cdc, &MsgResetCircuitBreaker{}, "cosmos-sdk/MsgResetCircuitBreaker") - legacy.RegisterAminoMsg(cdc, &MsgTripCircuitBreaker{}, "cosmos-sdk/MsgTripCircuitBreaker") -} - // RegisterInterfaces registers the interfaces types with the interface registry. func RegisterInterfaces(registry types.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), diff --git a/x/circuit/types/msgs.go b/x/circuit/types/msgs.go deleted file mode 100644 index 0e39b00c5f6b..000000000000 --- a/x/circuit/types/msgs.go +++ /dev/null @@ -1,36 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var ( - _ sdk.Msg = &MsgAuthorizeCircuitBreaker{} - _ sdk.Msg = &MsgTripCircuitBreaker{} - _ sdk.Msg = &MsgResetCircuitBreaker{} -) - -// NewMsgAuthorizeCircuitBreaker creates a new MsgAuthorizeCircuitBreaker instance. -func NewMsgAuthorizeCircuitBreaker(granter, grantee string, permission *Permissions) *MsgAuthorizeCircuitBreaker { - return &MsgAuthorizeCircuitBreaker{ - Granter: granter, - Grantee: grantee, - Permissions: permission, - } -} - -// NewMsgTripCircuitBreaker creates a new MsgTripCircuitBreaker instance. -func NewMsgTripCircuitBreaker(authority string, urls []string) *MsgTripCircuitBreaker { - return &MsgTripCircuitBreaker{ - Authority: authority, - MsgTypeUrls: urls, - } -} - -// NewMsgResetCircuitBreaker creates a new MsgResetCircuitBreaker instance. -func NewMsgResetCircuitBreaker(authority string, urls []string) *MsgResetCircuitBreaker { - return &MsgResetCircuitBreaker{ - Authority: authority, - MsgTypeUrls: urls, - } -} From df1bfab0bb2dc2cf5b4ac72df2368f5fc38ccb75 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 14 Sep 2023 17:01:12 +0200 Subject: [PATCH 2/5] golint fix --- x/circuit/keeper/query.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/circuit/keeper/query.go b/x/circuit/keeper/query.go index 3c3e79eec421..a8b39e4d4a82 100644 --- a/x/circuit/keeper/query.go +++ b/x/circuit/keeper/query.go @@ -22,7 +22,6 @@ func NewQueryServer(keeper Keeper) types.QueryServer { // Account returns account permissions. func (qs QueryServer) Account(ctx context.Context, req *types.QueryAccountRequest) (*types.AccountResponse, error) { - add, err := qs.keeper.addressCodec.StringToBytes(req.Address) if err != nil { return nil, err From 77393b67a43061dfe64dd3ac4971e11e36fb2fe9 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 14 Sep 2023 17:08:56 +0200 Subject: [PATCH 3/5] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba1efbcbed52..0fa6ea486945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,6 +145,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * `WithChainID` / `WithBlockHeight` / `WithBlockHeader` must be used to set values on the context * (x/bank) [#17569](https://github.com/cosmos/cosmos-sdk/pull/17569) `BurnCoins` takes an address instead of a module name * (x/distribution) [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` +* (x/authz) [#17741](https://github.com/cosmos/cosmos-sdk/pull/17741) Remove `NewMsgAuthorizeCircuitBreaker`, `NewMsgTripCircuitBreaker`, `NewMsgResetCircuitBreaker` were removed in favor of direct creation of the types where they are used ### CLI Breaking Changes From 60c69cf01de8f9bd304bae107ae178930a2df5ef Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 14 Sep 2023 17:19:38 +0200 Subject: [PATCH 4/5] move changelog --- CHANGELOG.md | 1 - x/circuit/CHANGELOG.md | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fa6ea486945..ba1efbcbed52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -145,7 +145,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ * `WithChainID` / `WithBlockHeight` / `WithBlockHeader` must be used to set values on the context * (x/bank) [#17569](https://github.com/cosmos/cosmos-sdk/pull/17569) `BurnCoins` takes an address instead of a module name * (x/distribution) [#17670](https://github.com/cosmos/cosmos-sdk/pull/17670) `AllocateTokens` takes `comet.VoteInfos` instead of `[]abci.VoteInfo` -* (x/authz) [#17741](https://github.com/cosmos/cosmos-sdk/pull/17741) Remove `NewMsgAuthorizeCircuitBreaker`, `NewMsgTripCircuitBreaker`, `NewMsgResetCircuitBreaker` were removed in favor of direct creation of the types where they are used ### CLI Breaking Changes diff --git a/x/circuit/CHANGELOG.md b/x/circuit/CHANGELOG.md index 63534e456362..d8ba99d47435 100644 --- a/x/circuit/CHANGELOG.md +++ b/x/circuit/CHANGELOG.md @@ -29,4 +29,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog -## [Unreleased] \ No newline at end of file +## [Unreleased] + +### Api Breaking Changes + +* [#17741](https://github.com/cosmos/cosmos-sdk/pull/17741) Remove `NewMsgAuthorizeCircuitBreaker`, `NewMsgTripCircuitBreaker`, `NewMsgResetCircuitBreaker` were removed in favor of direct creation of the types where they are used From 4ebbc0e1690280d85099012252051bf94bd34aa9 Mon Sep 17 00:00:00 2001 From: marbar3778 Date: Thu, 14 Sep 2023 17:23:12 +0200 Subject: [PATCH 5/5] remove changelog --- x/circuit/CHANGELOG.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/circuit/CHANGELOG.md b/x/circuit/CHANGELOG.md index d8ba99d47435..16de809f2717 100644 --- a/x/circuit/CHANGELOG.md +++ b/x/circuit/CHANGELOG.md @@ -30,7 +30,3 @@ Ref: https://keepachangelog.com/en/1.0.0/ # Changelog ## [Unreleased] - -### Api Breaking Changes - -* [#17741](https://github.com/cosmos/cosmos-sdk/pull/17741) Remove `NewMsgAuthorizeCircuitBreaker`, `NewMsgTripCircuitBreaker`, `NewMsgResetCircuitBreaker` were removed in favor of direct creation of the types where they are used