feat: deprecate x/params usage in x/auth (#12475)

* generate proto files

* wip

* wip: fix tests

* wip: add tests

* fix tests

* fix tests

* add changelog

* address review comments

* address review comments

* add err check for setparams

* updates

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Co-authored-by: Aleksandr Bezobchuk <aleks.bezobchuk@gmail.com>
This commit is contained in:
likhita-809 2022-07-11 22:46:27 +05:30 committed by GitHub
parent dc1677bdf8
commit 1815981b02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 2462 additions and 111 deletions

View File

@ -56,6 +56,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### State Machine Breaking
* (x/auth) [#12475](https://github.com/cosmos/cosmos-sdk/pull/12475) Migrate `x/auth` to self-managed parameters and deprecate its usage of `x/params`.
* (x/slashing) [#12399](https://github.com/cosmos/cosmos-sdk/pull/12399) Migrate `x/slashing` to self-managed parameters and deprecate its usage of `x/params`.
* (x/mint) [#12363](https://github.com/cosmos/cosmos-sdk/pull/12363) Migrate `x/mint` to self-managed parameters and deprecate it's usage of `x/params`.
* (x/distribution) [#12434](https://github.com/cosmos/cosmos-sdk/pull/12434) Migrate `x/distribution` to self-managed parameters and deprecate it's usage of `x/params`.

View File

@ -606,7 +606,7 @@ type GenesisState struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params *Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params,omitempty"`
// accounts are the accounts present at genesis.
Accounts []*anypb.Any `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"`

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,113 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc (unknown)
// source: cosmos/auth/v1beta1/tx.proto
package authv1beta1
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// MsgClient is the client API for Msg service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MsgClient interface {
// UpdateParams defines a governance operation for updating the x/auth module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
cc grpc.ClientConnInterface
}
func NewMsgClient(cc grpc.ClientConnInterface) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, "/cosmos.auth.v1beta1.Msg/UpdateParams", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
// All implementations must embed UnimplementedMsgServer
// for forward compatibility
type MsgServer interface {
// UpdateParams defines a governance operation for updating the x/auth module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
mustEmbedUnimplementedMsgServer()
}
// UnimplementedMsgServer must be embedded to have forward compatible implementations.
type UnimplementedMsgServer struct {
}
func (UnimplementedMsgServer) UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
func (UnimplementedMsgServer) mustEmbedUnimplementedMsgServer() {}
// UnsafeMsgServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to MsgServer will
// result in compilation errors.
type UnsafeMsgServer interface {
mustEmbedUnimplementedMsgServer()
}
func RegisterMsgServer(s grpc.ServiceRegistrar, srv MsgServer) {
s.RegisterService(&Msg_ServiceDesc, srv)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).UpdateParams(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.auth.v1beta1.Msg/UpdateParams",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
}
return interceptor(ctx, in, info, handler)
}
// Msg_ServiceDesc is the grpc.ServiceDesc for Msg service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Msg_ServiceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.auth.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/auth/v1beta1/tx.proto",
}

View File

@ -124,7 +124,7 @@ func TestBaseApp_BlockGas(t *testing.T) {
require.Equal(t, []byte("ok"), okValue)
}
// check block gas is always consumed
baseGas := uint64(70184) // baseGas is the gas consumed before tx msg
baseGas := uint64(52744) // baseGas is the gas consumed before tx msg
expGasConsumed := addUint64Saturating(tc.gasToConsume, baseGas)
if expGasConsumed > txtypes.MaxGasWanted {
// capped by gasLimit

View File

@ -9,7 +9,7 @@ option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// GenesisState defines the auth module's genesis state.
message GenesisState {
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params params = 1 [(gogoproto.nullable) = false];
// accounts are the accounts present at genesis.

View File

@ -0,0 +1,39 @@
syntax = "proto3";
package cosmos.auth.v1beta1;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos/auth/v1beta1/auth.proto";
option go_package = "github.com/cosmos/cosmos-sdk/x/auth/types";
// Msg defines the x/auth Msg service.
service Msg {
// UpdateParams defines a governance operation for updating the x/auth module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the x/auth parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
message MsgUpdateParamsResponse {}

View File

@ -269,7 +269,7 @@ func NewSimApp(
// NOTE: this is not required apps that don't use the simulator for fuzz testing
// transactions
overrideModules := map[string]module.AppModuleSimulation{
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts),
authtypes.ModuleName: auth.NewAppModule(app.appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)),
}
app.sm = module.NewSimulationManagerFromAppModules(app.ModuleManager.Modules, overrideModules)

View File

@ -1116,14 +1116,16 @@ func (suite *AnteTestSuite) TestAnteHandlerReCheck() {
}
for _, tc := range testCases {
// set testcase parameters
suite.accountKeeper.SetParams(suite.ctx, tc.params)
err := suite.accountKeeper.SetParams(suite.ctx, tc.params)
suite.Require().NoError(err)
_, err := suite.anteHandler(suite.ctx, tx, false)
_, err = suite.anteHandler(suite.ctx, tx, false)
suite.Require().NotNil(err, "tx does not fail on recheck with updated params in test case: %s", tc.name)
// reset parameters to default values
suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams())
err = suite.accountKeeper.SetParams(suite.ctx, types.DefaultParams())
suite.Require().NoError(err)
}
// require that local mempool fee check is still run on recheck since validator may change minFee between check and recheck

View File

@ -319,7 +319,8 @@ func (suite *AnteTestSuite) runSigDecorators(params types.Params, _ bool, privs
// Make block-height non-zero to include accNum in SignBytes
suite.ctx = suite.ctx.WithBlockHeight(1)
suite.accountKeeper.SetParams(suite.ctx, params)
err := suite.accountKeeper.SetParams(suite.ctx, params)
suite.Require().NoError(err)
msgs := make([]sdk.Msg, len(privs))
accNums := make([]uint64, len(privs))

View File

@ -73,7 +73,8 @@ func (suite *AnteTestSuite) SetupTest(isCheckTx bool) {
suite.Require().NoError(err)
suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1)
suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
err = suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())
suite.Require().NoError(err)
// We're using TestMsg encoding in some tests, so register it here.
legacyAmino.Amino.RegisterConcrete(&testdata.TestMsg{}, "testdata.TestMsg", nil)

View File

@ -0,0 +1,18 @@
package exported
import (
sdk "github.com/cosmos/cosmos-sdk/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
type (
ParamSet = paramtypes.ParamSet
// Subspace defines an interface that implements the legacy x/params Subspace
// type.
//
// NOTE: This is used solely for migration of x/params managed parameters.
Subspace interface {
GetParamSet(ctx sdk.Context, ps ParamSet)
}
)

View File

@ -27,19 +27,19 @@ func (ak AccountKeeper) NewAccount(ctx sdk.Context, acc types.AccountI) types.Ac
// HasAccount implements AccountKeeperI.
func (ak AccountKeeper) HasAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
return store.Has(types.AddressStoreKey(addr))
}
// HasAccountAddressByID checks account address exists by id.
func (ak AccountKeeper) HasAccountAddressByID(ctx sdk.Context, id uint64) bool {
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
return store.Has(types.AccountNumberStoreKey(id))
}
// GetAccount implements AccountKeeperI.
func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI {
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.AddressStoreKey(addr))
if bz == nil {
return nil
@ -50,7 +50,7 @@ func (ak AccountKeeper) GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.A
// GetAccountAddressById returns account address by id.
func (ak AccountKeeper) GetAccountAddressByID(ctx sdk.Context, id uint64) string {
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.AccountNumberStoreKey(id))
if bz == nil {
return ""
@ -71,7 +71,7 @@ func (ak AccountKeeper) GetAllAccounts(ctx sdk.Context) (accounts []types.Accoun
// SetAccount implements AccountKeeperI.
func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountI) {
addr := acc.GetAddress()
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
bz, err := ak.MarshalAccount(acc)
if err != nil {
@ -86,7 +86,7 @@ func (ak AccountKeeper) SetAccount(ctx sdk.Context, acc types.AccountI) {
// NOTE: this will cause supply invariant violation if called
func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountI) {
addr := acc.GetAddress()
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
store.Delete(types.AddressStoreKey(addr))
store.Delete(types.AccountNumberStoreKey(acc.GetAccountNumber()))
}
@ -94,7 +94,7 @@ func (ak AccountKeeper) RemoveAccount(ctx sdk.Context, acc types.AccountI) {
// IterateAccounts iterates over all the stored accounts and performs a callback function.
// Stops iteration when callback returns true.
func (ak AccountKeeper) IterateAccounts(ctx sdk.Context, cb func(account types.AccountI) (stop bool)) {
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
iterator := sdk.KVStorePrefixIterator(store, types.AddressStoreKeyPrefix)
defer iterator.Close()

View File

@ -10,7 +10,9 @@ import (
// CONTRACT: old coins from the FeeCollectionKeeper need to be transferred through
// a genesis port script to the new fee collector account
func (ak AccountKeeper) InitGenesis(ctx sdk.Context, data types.GenesisState) {
ak.SetParams(ctx, data.Params)
if err := ak.SetParams(ctx, data.Params); err != nil {
panic(err)
}
accounts, err := types.UnpackAccounts(data.Accounts)
if err != nil {

View File

@ -43,7 +43,7 @@ func (ak AccountKeeper) Accounts(c context.Context, req *types.QueryAccountsRequ
}
ctx := sdk.UnwrapSDKContext(c)
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
accountsStore := prefix.NewStore(store, types.AddressStoreKeyPrefix)
var accounts []*codectypes.Any

View File

@ -13,7 +13,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/address"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// AccountKeeperI is the interface contract that x/auth's keeper implements.
@ -55,14 +54,17 @@ type AccountKeeperI interface {
// AccountKeeper encodes/decodes accounts using the go-amino (binary)
// encoding/decoding library.
type AccountKeeper struct {
key storetypes.StoreKey
cdc codec.BinaryCodec
paramSubspace paramtypes.Subspace
permAddrs map[string]types.PermissionsForAddress
storeKey storetypes.StoreKey
cdc codec.BinaryCodec
permAddrs map[string]types.PermissionsForAddress
// The prototypical AccountI constructor.
proto func() types.AccountI
addressCdc address.Codec
// the address capable of executing a MsgUpdateParams message. Typically, this
// should be the x/gov module account.
authority string
}
var _ AccountKeeperI = &AccountKeeper{}
@ -74,13 +76,9 @@ var _ AccountKeeperI = &AccountKeeper{}
// and don't have to fit into any predefined structure. This auth module does not use account permissions internally, though other modules
// may use auth.Keeper to access the accounts permissions map.
func NewAccountKeeper(
cdc codec.BinaryCodec, key storetypes.StoreKey, paramstore paramtypes.Subspace, proto func() types.AccountI,
maccPerms map[string][]string, bech32Prefix string,
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() types.AccountI,
maccPerms map[string][]string, bech32Prefix string, authority string,
) AccountKeeper {
// set KeyTable if it has not already been set
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}
permAddrs := make(map[string]types.PermissionsForAddress)
for name, perms := range maccPerms {
@ -90,15 +88,20 @@ func NewAccountKeeper(
bech32Codec := newBech32Codec(bech32Prefix)
return AccountKeeper{
key: key,
proto: proto,
cdc: cdc,
paramSubspace: paramstore,
permAddrs: permAddrs,
addressCdc: bech32Codec,
storeKey: storeKey,
proto: proto,
cdc: cdc,
permAddrs: permAddrs,
addressCdc: bech32Codec,
authority: authority,
}
}
// GetAuthority returns the x/mint module's authority.
func (ak AccountKeeper) GetAuthority() string {
return ak.authority
}
// Logger returns a module-specific logger.
func (ak AccountKeeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", "x/"+types.ModuleName)
@ -128,7 +131,7 @@ func (ak AccountKeeper) GetSequence(ctx sdk.Context, addr sdk.AccAddress) (uint6
// If the global account number is not set, it initializes it with value 0.
func (ak AccountKeeper) GetNextAccountNumber(ctx sdk.Context) uint64 {
var accNumber uint64
store := ctx.KVStore(ak.key)
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.GlobalAccountNumberKey)
if bz == nil {

View File

@ -38,6 +38,7 @@ type KeeperTestSuite struct {
legacyAmino *codec.LegacyAmino
interfaceRegistry codectypes.InterfaceRegistry
accountKeeper keeper.AccountKeeper
msgServer types.MsgServer
}
func (suite *KeeperTestSuite) SetupTest() {
@ -52,6 +53,7 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.app = app
suite.ctx = app.BaseApp.NewContext(true, tmproto.Header{})
suite.msgServer = keeper.NewMsgServerImpl(suite.accountKeeper)
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, suite.interfaceRegistry)
types.RegisterQueryServer(queryHelper, suite.accountKeeper)
@ -129,7 +131,8 @@ func (suite *KeeperTestSuite) TestGetSetParams() {
ctx := suite.ctx
params := types.DefaultParams()
suite.accountKeeper.SetParams(ctx, params)
err := suite.accountKeeper.SetParams(ctx, params)
suite.Require().NoError(err)
actualParams := suite.accountKeeper.GetParams(ctx)
suite.Require().Equal(params, actualParams)

View File

@ -6,20 +6,23 @@ import (
v043 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v043"
v046 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v046"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/types"
sdk "github.com/cosmos/cosmos-sdk/types"
v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2"
)
// Migrator is a struct for handling in-place store migrations.
type Migrator struct {
keeper AccountKeeper
queryServer grpc.Server
keeper AccountKeeper
queryServer grpc.Server
legacySubspace exported.Subspace
}
// NewMigrator returns a new Migrator.
func NewMigrator(keeper AccountKeeper, queryServer grpc.Server) Migrator {
return Migrator{keeper: keeper, queryServer: queryServer}
func NewMigrator(keeper AccountKeeper, queryServer grpc.Server, ss exported.Subspace) Migrator {
return Migrator{keeper: keeper, queryServer: queryServer, legacySubspace: ss}
}
// Migrate1to2 migrates from version 1 to 2.
@ -47,7 +50,15 @@ func (m Migrator) Migrate1to2(ctx sdk.Context) error {
// Migrate2to3 migrates from consensus version 2 to version 3. Specifically, for each account
// we index the account's ID to their address.
func (m Migrator) Migrate2to3(ctx sdk.Context) error {
return v046.MigrateStore(ctx, m.keeper.key, m.keeper.cdc)
return v046.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc)
}
// Migrate3to4 migrates the x/auth module state from the consensus version 3 to
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func (m Migrator) Migrate3to4(ctx sdk.Context) error {
return v2.Migrate(ctx, ctx.KVStore(m.keeper.storeKey), m.legacySubspace, m.keeper.cdc)
}
// V45_SetAccount implements V45_SetAccount
@ -56,7 +67,7 @@ func (m Migrator) Migrate2to3(ctx sdk.Context) error {
// NOTE: This is used for testing purposes only.
func (m Migrator) V45_SetAccount(ctx sdk.Context, acc types.AccountI) error {
addr := acc.GetAddress()
store := ctx.KVStore(m.keeper.key)
store := ctx.KVStore(m.keeper.storeKey)
bz, err := m.keeper.MarshalAccount(acc)
if err != nil {

View File

@ -0,0 +1,36 @@
package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
var _ types.MsgServer = msgServer{}
type msgServer struct {
AccountKeeper
}
// NewMsgServerImpl returns an implementation of the x/auth MsgServer interface.
func NewMsgServerImpl(ak AccountKeeper) types.MsgServer {
return &msgServer{
AccountKeeper: ak,
}
}
func (ms msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams) (*types.MsgUpdateParamsResponse, error) {
if ms.authority != req.Authority {
return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", ms.authority, req.Authority)
}
ctx := sdk.UnwrapSDKContext(goCtx)
if err := ms.SetParams(ctx, req.Params); err != nil {
return nil, err
}
return &types.MsgUpdateParamsResponse{}, nil
}

View File

@ -0,0 +1,111 @@
package keeper_test
import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
func (s *KeeperTestSuite) TestUpdateParams() {
testCases := []struct {
name string
req *types.MsgUpdateParams
expectErr bool
expErrMsg string
}{
{
name: "set invalid authority",
req: &types.MsgUpdateParams{
Authority: "foo",
},
expectErr: true,
expErrMsg: "invalid authority",
},
{
name: "set invalid max memo characters",
req: &types.MsgUpdateParams{
Authority: s.accountKeeper.GetAuthority(),
Params: types.Params{
MaxMemoCharacters: 0,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
},
expectErr: true,
expErrMsg: "invalid max memo characters",
},
{
name: "set invalid tx sig limit",
req: &types.MsgUpdateParams{
Authority: s.accountKeeper.GetAuthority(),
Params: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 0,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
},
expectErr: true,
expErrMsg: "invalid tx signature limit",
},
{
name: "set invalid tx size cost per bytes",
req: &types.MsgUpdateParams{
Authority: s.accountKeeper.GetAuthority(),
Params: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 0,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
},
expectErr: true,
expErrMsg: "invalid tx size cost per byte",
},
{
name: "set invalid sig verify cost ED25519",
req: &types.MsgUpdateParams{
Authority: s.accountKeeper.GetAuthority(),
Params: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 0,
SigVerifyCostSecp256k1: 511,
},
},
expectErr: true,
expErrMsg: "invalid ED25519 signature verification cost",
},
{
name: "set invalid sig verify cost Secp256k1",
req: &types.MsgUpdateParams{
Authority: s.accountKeeper.GetAuthority(),
Params: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 0,
},
},
expectErr: true,
expErrMsg: "invalid SECK256k1 signature verification cost",
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
_, err := s.msgServer.UpdateParams(s.ctx, tc.req)
if tc.expectErr {
s.Require().Error(err)
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
s.Require().NoError(err)
}
})
}
}

View File

@ -6,12 +6,25 @@ import (
)
// SetParams sets the auth module's parameters.
func (ak AccountKeeper) SetParams(ctx sdk.Context, params types.Params) {
ak.paramSubspace.SetParamSet(ctx, &params)
func (ak AccountKeeper) SetParams(ctx sdk.Context, params types.Params) error {
if err := params.Validate(); err != nil {
return err
}
store := ctx.KVStore(ak.storeKey)
bz := ak.cdc.MustMarshal(&params)
store.Set(types.ParamsKey, bz)
return nil
}
// GetParams gets the auth module's parameters.
func (ak AccountKeeper) GetParams(ctx sdk.Context) (params types.Params) {
ak.paramSubspace.GetParamSet(ctx, &params)
return
store := ctx.KVStore(ak.storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return params
}
ak.cdc.MustUnmarshal(bz, &params)
return params
}

View File

@ -0,0 +1,92 @@
package keeper_test
import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
func (s *KeeperTestSuite) TestParams() {
testCases := []struct {
name string
input types.Params
expectErr bool
expErrMsg string
}{
{
name: "set invalid max memo characters",
input: types.Params{
MaxMemoCharacters: 0,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
expectErr: true,
expErrMsg: "invalid max memo characters",
},
{
name: "set invalid tx sig limit",
input: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 0,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
expectErr: true,
expErrMsg: "invalid tx signature limit",
},
{
name: "set invalid tx size cost per bytes",
input: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 0,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 511,
},
expectErr: true,
expErrMsg: "invalid tx size cost per byte",
},
{
name: "set invalid sig verify cost ED25519",
input: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 0,
SigVerifyCostSecp256k1: 511,
},
expectErr: true,
expErrMsg: "invalid ED25519 signature verification cost",
},
{
name: "set invalid sig verify cost Secp256k1",
input: types.Params{
MaxMemoCharacters: 140,
TxSigLimit: 9,
TxSizeCostPerByte: 5,
SigVerifyCostED25519: 694,
SigVerifyCostSecp256k1: 0,
},
expectErr: true,
expErrMsg: "invalid SECK256k1 signature verification cost",
},
}
for _, tc := range testCases {
tc := tc
s.Run(tc.name, func() {
expected := s.accountKeeper.GetParams(s.ctx)
err := s.accountKeeper.SetParams(s.ctx, tc.input)
if tc.expectErr {
s.Require().Error(err)
s.Require().Contains(err.Error(), tc.expErrMsg)
} else {
expected = tc.input
s.Require().NoError(err)
}
params := s.accountKeeper.GetParams(s.ctx)
s.Require().Equal(expected, params)
})
}
}

View File

@ -10,10 +10,15 @@ import (
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2"
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
@ -22,21 +27,44 @@ import (
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)
type mockSubspace struct {
ps authtypes.Params
}
func newMockSubspace(ps authtypes.Params) mockSubspace {
return mockSubspace{ps: ps}
}
func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps authexported.ParamSet) {
*ps.(*authtypes.Params) = ms.ps
}
func TestMigrateVestingAccounts(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
var (
accountKeeper keeper.AccountKeeper
bankKeeper bankkeeper.Keeper
stakingKeeper *stakingkeeper.Keeper
)
app, err := simtestutil.Setup(
testutil.AppConfig,
authtestutil.AppConfig,
&accountKeeper,
&bankKeeper,
&stakingKeeper,
)
require.NoError(t, err)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
legacySubspace := newMockSubspace(authtypes.DefaultParams())
require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc))
ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
stakingKeeper.SetParams(ctx, stakingtypes.DefaultParams())
testCases := []struct {
@ -58,7 +86,9 @@ func TestMigrateVestingAccounts(t *testing.T) {
ctx = ctx.WithBlockTime(ctx.BlockTime().AddDate(1, 0, 0))
accountKeeper.SetParams(ctx, authtypes.DefaultParams())
err := accountKeeper.SetParams(ctx, authtypes.DefaultParams())
require.NoError(t, err)
accountKeeper.SetAccount(ctx, delayedAccount)
_, err = stakingKeeper.Delegate(ctx, delegatorAddr, sdk.NewInt(100), stakingtypes.Unbonded, validator, true)
@ -562,7 +592,9 @@ func TestMigrateVestingAccounts(t *testing.T) {
tc := tc
t.Run(tc.name, func(t *testing.T) {
accountKeeper.SetParams(ctx, authtypes.DefaultParams())
err := accountKeeper.SetParams(ctx, authtypes.DefaultParams())
require.NoError(t, err)
addrs := simtestutil.AddTestAddrs(bankKeeper, stakingKeeper, ctx, 1, sdk.NewInt(tc.tokenAmount))
delegatorAddr := addrs[0]
@ -582,7 +614,7 @@ func TestMigrateVestingAccounts(t *testing.T) {
require.True(t, ok)
require.NoError(t, tc.garbageFunc(ctx, vestingAccount, accountKeeper))
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter())
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter(), legacySubspace)
require.NoError(t, m.Migrate1to2(ctx))
var expVested sdk.Coins

View File

@ -6,36 +6,65 @@ import (
"time"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/testutil"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/testutil"
v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2"
authtestutil "github.com/cosmos/cosmos-sdk/x/auth/testutil"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/types"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
authexported "github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/stretchr/testify/require"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
)
type mockSubspace struct {
ps authtypes.Params
}
func newMockSubspace(ps authtypes.Params) mockSubspace {
return mockSubspace{ps: ps}
}
func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps authexported.ParamSet) {
*ps.(*authtypes.Params) = ms.ps
}
// TestMigrateMapAccAddressToAccNumberKey test cases for state migration of map to accAddr to accNum
func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
var (
accountKeeper keeper.AccountKeeper
)
app, err := simtestutil.Setup(
testutil.AppConfig,
authtestutil.AppConfig,
&accountKeeper,
)
require.NoError(t, err)
legacySubspace := newMockSubspace(authtypes.DefaultParams())
require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc))
// new base account
senderPrivKey := secp256k1.GenPrivKey()
randAccNumber := uint64(rand.Intn(100000-10000) + 10000)
acc := types.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), randAccNumber, 0)
acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), randAccNumber, 0)
ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
// migrator
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter())
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter(), legacySubspace)
// set the account to store with map acc addr to acc number
require.NoError(t, m.V45_SetAccount(ctx, acc))

View File

@ -0,0 +1,35 @@
package v2
import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
const (
ModuleName = "auth"
)
var (
ParamsKey = []byte{0x01}
)
// Migrate migrates the x/auth module state from the consensus version 3 to
// version 4. Specifically, it takes the parameters that are currently stored
// and managed by the x/params modules and stores them directly into the x/auth
// module state.
func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspace, cdc codec.BinaryCodec) error {
var currParams types.Params
legacySubspace.GetParamSet(ctx, &currParams)
if err := currParams.Validate(); err != nil {
return err
}
bz := cdc.MustMarshal(&currParams)
store.Set(ParamsKey, bz)
return nil
}

View File

@ -0,0 +1,46 @@
package v2_test
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
v2 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v2"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
type mockSubspace struct {
ps types.Params
}
func newMockSubspace(ps types.Params) mockSubspace {
return mockSubspace{ps: ps}
}
func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) {
*ps.(*types.Params) = ms.ps
}
func TestMigrate(t *testing.T) {
encCfg := moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
cdc := encCfg.Codec
storeKey := sdk.NewKVStoreKey(v2.ModuleName)
tKey := sdk.NewTransientStoreKey("transient_test")
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)
legacySubspace := newMockSubspace(types.DefaultParams())
require.NoError(t, v2.Migrate(ctx, store, legacySubspace, cdc))
var res types.Params
bz := store.Get(v2.ParamsKey)
require.NoError(t, cdc.Unmarshal(bz, &res))
require.Equal(t, legacySubspace.ps, res)
}

View File

@ -17,7 +17,6 @@ import (
"cosmossdk.io/core/appmodule"
"github.com/cosmos/cosmos-sdk/runtime"
store "github.com/cosmos/cosmos-sdk/store/types"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/codec"
@ -26,11 +25,16 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
"github.com/cosmos/cosmos-sdk/x/auth/client/cli"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/simulation"
"github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
)
// ConsensusVersion defines the current x/auth module consensus version.
const ConsensusVersion = 4
var (
_ module.AppModule = AppModule{}
_ module.AppModuleBasic = AppModuleBasic{}
@ -94,14 +98,18 @@ type AppModule struct {
accountKeeper keeper.AccountKeeper
randGenAccountsFn types.RandomGenesisAccountsFn
// legacySubspace is used solely for migration of x/params managed parameters
legacySubspace exported.Subspace
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAccountsFn types.RandomGenesisAccountsFn) AppModule {
func NewAppModule(cdc codec.Codec, accountKeeper keeper.AccountKeeper, randGenAccountsFn types.RandomGenesisAccountsFn, ss exported.Subspace) AppModule {
return AppModule{
AppModuleBasic: AppModuleBasic{},
accountKeeper: accountKeeper,
randGenAccountsFn: randGenAccountsFn,
legacySubspace: ss,
}
}
@ -131,17 +139,20 @@ func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sd
// RegisterServices registers a GRPC query service to respond to the
// module-specific GRPC queries.
func (am AppModule) RegisterServices(cfg module.Configurator) {
types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.accountKeeper))
types.RegisterQueryServer(cfg.QueryServer(), am.accountKeeper)
m := keeper.NewMigrator(am.accountKeeper, cfg.QueryServer())
err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2)
if err != nil {
m := keeper.NewMigrator(am.accountKeeper, cfg.QueryServer(), am.legacySubspace)
if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil {
panic(err)
}
err = cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3)
if err != nil {
if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil {
panic(err)
}
if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil {
panic(fmt.Sprintf("failed to migrate x/%s from version 3 to 4: %v", types.ModuleName, err))
}
}
// InitGenesis performs genesis initialization for the auth module. It returns
@ -161,7 +172,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw
}
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return 3 }
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// BeginBlock returns the begin blocker for the auth module.
func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {}
@ -186,7 +197,7 @@ func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.We
// RandomizedParams creates randomized auth param changes for the simulator.
func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange {
return simulation.ParamChanges(r)
return []simtypes.ParamChange{}
}
// RegisterStoreDecoder registers a decoder for auth module's types
@ -216,10 +227,12 @@ func provideModuleBasic() runtime.AppModuleBasicWrapper {
type authInputs struct {
depinject.In
Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec
Subspace paramtypes.Subspace
Config *modulev1.Module
Key *store.KVStoreKey
Cdc codec.Codec
// LegacySubspace is used solely for migration of x/params managed parameters
LegacySubspace exported.Subspace
}
type authOutputs struct {
@ -235,8 +248,8 @@ func provideModule(in authInputs) authOutputs {
maccPerms[permission.Account] = permission.Permissions
}
k := keeper.NewAccountKeeper(in.Cdc, in.Key, in.Subspace, types.ProtoBaseAccount, maccPerms, in.Config.Bech32Prefix)
m := NewAppModule(in.Cdc, k, simulation.RandomGenesisAccounts)
k := keeper.NewAccountKeeper(in.Cdc, in.Key, types.ProtoBaseAccount, maccPerms, in.Config.Bech32Prefix, types.NewModuleAddress(govtypes.ModuleName).String())
m := NewAppModule(in.Cdc, k, simulation.RandomGenesisAccounts, in.LegacySubspace)
return authOutputs{AccountKeeper: k, Module: runtime.WrapAppModule(m)}
}

View File

@ -2,6 +2,7 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/codec/legacy"
"github.com/cosmos/cosmos-sdk/codec/types"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
@ -17,6 +18,9 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
cdc.RegisterInterface((*AccountI)(nil), nil)
cdc.RegisterConcrete(&BaseAccount{}, "cosmos-sdk/BaseAccount", nil)
cdc.RegisterConcrete(&ModuleAccount{}, "cosmos-sdk/ModuleAccount", nil)
cdc.RegisterConcrete(Params{}, "cosmos-sdk/x/auth/Params", nil)
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/auth/MsgUpdateParams")
legacytx.RegisterLegacyAminoCodec(cdc)
}
@ -37,6 +41,10 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
&BaseAccount{},
&ModuleAccount{},
)
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgUpdateParams{},
)
}
var (

View File

@ -26,7 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// GenesisState defines the auth module's genesis state.
type GenesisState struct {
// params defines all the paramaters of the module.
// params defines all the parameters of the module.
Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"`
// accounts are the accounts present at genesis.
Accounts []*types.Any `protobuf:"bytes,2,rep,name=accounts,proto3" json:"accounts,omitempty"`

View File

@ -19,6 +19,9 @@ const (
)
var (
// ParamsKey is the prefix for params key
ParamsKey = []byte{0x00}
// AddressStoreKeyPrefix prefix for account-by-address store
AddressStoreKeyPrefix = []byte{0x01}

32
x/auth/types/msgs.go Normal file
View File

@ -0,0 +1,32 @@
package types
import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
var _ sdk.Msg = &MsgUpdateParams{}
// GetSignBytes implements the LegacyMsg interface.
func (msg MsgUpdateParams) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
}
// GetSigners returns the expected signers for a MsgUpdateParams message.
func (msg *MsgUpdateParams) GetSigners() []sdk.AccAddress {
addr, _ := sdk.AccAddressFromBech32(msg.Authority)
return []sdk.AccAddress{addr}
}
// ValidateBasic does a sanity check on the provided data.
func (msg *MsgUpdateParams) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(msg.Authority); err != nil {
return sdkerrors.Wrap(err, "invalid authority address")
}
if err := msg.Params.Validate(); err != nil {
return err
}
return nil
}

View File

@ -4,8 +4,6 @@ import (
"fmt"
"sigs.k8s.io/yaml"
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Default parameter values
@ -17,17 +15,6 @@ const (
DefaultSigVerifyCostSecp256k1 uint64 = 1000
)
// Parameter keys
var (
KeyMaxMemoCharacters = []byte("MaxMemoCharacters")
KeyTxSigLimit = []byte("TxSigLimit")
KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte")
KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519")
KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
)
var _ paramtypes.ParamSet = &Params{}
// NewParams creates a new Params object
func NewParams(
maxMemoCharacters, txSigLimit, txSizeCostPerByte, sigVerifyCostED25519, sigVerifyCostSecp256k1 uint64,
@ -41,23 +28,6 @@ func NewParams(
}
}
// ParamKeyTable for auth module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
// pairs of auth module's parameters.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
paramtypes.NewParamSetPair(KeyTxSigLimit, &p.TxSigLimit, validateTxSigLimit),
paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte),
paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519),
paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1),
}
}
// DefaultParams returns a default set of parameters.
func DefaultParams() Params {
return Params{

View File

@ -0,0 +1,40 @@
/*
NOTE: Usage of x/params to manage parameters is deprecated in favor of x/gov
controlled execution of MsgUpdateParams messages. These types remains solely
for migration purposes and will be removed in a future release.
*/
package types
import (
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
)
// Parameter keys
var (
KeyMaxMemoCharacters = []byte("MaxMemoCharacters")
KeyTxSigLimit = []byte("TxSigLimit")
KeyTxSizeCostPerByte = []byte("TxSizeCostPerByte")
KeySigVerifyCostED25519 = []byte("SigVerifyCostED25519")
KeySigVerifyCostSecp256k1 = []byte("SigVerifyCostSecp256k1")
)
var _ paramtypes.ParamSet = &Params{}
// ParamKeyTable for auth module
//
// NOTE: Deprecated.
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}
// ParamSetPairs implements the ParamSet interface and returns all the key/value pairs
// pairs of auth module's parameters.
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyMaxMemoCharacters, &p.MaxMemoCharacters, validateMaxMemoCharacters),
paramtypes.NewParamSetPair(KeyTxSigLimit, &p.TxSigLimit, validateTxSigLimit),
paramtypes.NewParamSetPair(KeyTxSizeCostPerByte, &p.TxSizeCostPerByte, validateTxSizeCostPerByte),
paramtypes.NewParamSetPair(KeySigVerifyCostED25519, &p.SigVerifyCostED25519, validateSigVerifyCostED25519),
paramtypes.NewParamSetPair(KeySigVerifyCostSecp256k1, &p.SigVerifyCostSecp256k1, validateSigVerifyCostSecp256k1),
}
}

603
x/auth/types/tx.pb.go Normal file
View File

@ -0,0 +1,603 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: cosmos/auth/v1beta1/tx.proto
package types
import (
context "context"
fmt "fmt"
_ "github.com/cosmos/cosmos-proto"
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
_ "github.com/gogo/protobuf/gogoproto"
grpc1 "github.com/gogo/protobuf/grpc"
proto "github.com/gogo/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
)
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgUpdateParams is the Msg/UpdateParams request type.
//
// Since: cosmos-sdk 0.47
type MsgUpdateParams struct {
// authority is the address of the governance account.
Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"`
// params defines the x/auth parameters to update.
//
// NOTE: All parameters must be supplied.
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
}
func (m *MsgUpdateParams) Reset() { *m = MsgUpdateParams{} }
func (m *MsgUpdateParams) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateParams) ProtoMessage() {}
func (*MsgUpdateParams) Descriptor() ([]byte, []int) {
return fileDescriptor_c2d62bd9c4c212e5, []int{0}
}
func (m *MsgUpdateParams) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateParams.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgUpdateParams) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateParams.Merge(m, src)
}
func (m *MsgUpdateParams) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateParams) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateParams.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateParams proto.InternalMessageInfo
func (m *MsgUpdateParams) GetAuthority() string {
if m != nil {
return m.Authority
}
return ""
}
func (m *MsgUpdateParams) GetParams() Params {
if m != nil {
return m.Params
}
return Params{}
}
// MsgUpdateParamsResponse defines the response structure for executing a
// MsgUpdateParams message.
//
// Since: cosmos-sdk 0.47
type MsgUpdateParamsResponse struct {
}
func (m *MsgUpdateParamsResponse) Reset() { *m = MsgUpdateParamsResponse{} }
func (m *MsgUpdateParamsResponse) String() string { return proto.CompactTextString(m) }
func (*MsgUpdateParamsResponse) ProtoMessage() {}
func (*MsgUpdateParamsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_c2d62bd9c4c212e5, []int{1}
}
func (m *MsgUpdateParamsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgUpdateParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgUpdateParamsResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgUpdateParamsResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgUpdateParamsResponse.Merge(m, src)
}
func (m *MsgUpdateParamsResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgUpdateParamsResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgUpdateParamsResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgUpdateParamsResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgUpdateParams)(nil), "cosmos.auth.v1beta1.MsgUpdateParams")
proto.RegisterType((*MsgUpdateParamsResponse)(nil), "cosmos.auth.v1beta1.MsgUpdateParamsResponse")
}
func init() { proto.RegisterFile("cosmos/auth/v1beta1/tx.proto", fileDescriptor_c2d62bd9c4c212e5) }
var fileDescriptor_c2d62bd9c4c212e5 = []byte{
// 310 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x49, 0xce, 0x2f, 0xce,
0xcd, 0x2f, 0xd6, 0x4f, 0x2c, 0x2d, 0xc9, 0xd0, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4,
0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x86, 0xc8, 0xea, 0x81, 0x64, 0xf5,
0xa0, 0xb2, 0x52, 0x22, 0xe9, 0xf9, 0xe9, 0xf9, 0x60, 0x79, 0x7d, 0x10, 0x0b, 0xa2, 0x54, 0x4a,
0x12, 0xa2, 0x34, 0x1e, 0x22, 0x01, 0xd5, 0x07, 0x91, 0x12, 0x87, 0xda, 0x91, 0x5b, 0x9c, 0xae,
0x5f, 0x66, 0x08, 0xa2, 0xa0, 0x12, 0x72, 0xd8, 0x2c, 0x07, 0xdb, 0x05, 0x96, 0x57, 0x9a, 0xc2,
0xc8, 0xc5, 0xef, 0x5b, 0x9c, 0x1e, 0x5a, 0x90, 0x92, 0x58, 0x92, 0x1a, 0x90, 0x58, 0x94, 0x98,
0x5b, 0x2c, 0x64, 0xc6, 0xc5, 0x09, 0x52, 0x91, 0x5f, 0x94, 0x59, 0x52, 0x29, 0xc1, 0xa8, 0xc0,
0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x46, 0xc7, 0x94, 0x94, 0xa2, 0xd4,
0xe2, 0xe2, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x84, 0x52, 0x21, 0x4b, 0x2e, 0xb6, 0x02,
0xb0, 0x09, 0x12, 0x4c, 0x0a, 0x8c, 0x1a, 0xdc, 0x46, 0xd2, 0x7a, 0x58, 0xfc, 0xa6, 0x07, 0xb1,
0xc4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x06, 0x2b, 0xbe, 0xa6, 0xe7, 0x1b, 0xb4,
0x10, 0x46, 0x29, 0x49, 0x72, 0x89, 0xa3, 0xb9, 0x2a, 0x28, 0xb5, 0xb8, 0x20, 0x3f, 0xaf, 0x38,
0xd5, 0x28, 0x93, 0x8b, 0xd9, 0xb7, 0x38, 0x5d, 0x28, 0x89, 0x8b, 0x07, 0xc5, 0xd1, 0x2a, 0x58,
0x2d, 0x43, 0x33, 0x44, 0x4a, 0x87, 0x18, 0x55, 0x30, 0xab, 0x9c, 0x9c, 0x4f, 0x3c, 0x92, 0x63,
0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96,
0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x4a, 0x33, 0x3d, 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39,
0x3f, 0x17, 0x1a, 0x11, 0x50, 0x4a, 0xb7, 0x38, 0x25, 0x5b, 0xbf, 0x02, 0x12, 0xdc, 0x25, 0x95,
0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0x80, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x46, 0x68,
0x6d, 0x75, 0x07, 0x02, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// MsgClient is the client API for Msg service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type MsgClient interface {
// UpdateParams defines a governance operation for updating the x/auth module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error)
}
type msgClient struct {
cc grpc1.ClientConn
}
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) UpdateParams(ctx context.Context, in *MsgUpdateParams, opts ...grpc.CallOption) (*MsgUpdateParamsResponse, error) {
out := new(MsgUpdateParamsResponse)
err := c.cc.Invoke(ctx, "/cosmos.auth.v1beta1.Msg/UpdateParams", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
// UpdateParams defines a governance operation for updating the x/auth module
// parameters. The authority is hard-coded to the x/gov module account.
//
// Since: cosmos-sdk 0.47
UpdateParams(context.Context, *MsgUpdateParams) (*MsgUpdateParamsResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
type UnimplementedMsgServer struct {
}
func (*UnimplementedMsgServer) UpdateParams(ctx context.Context, req *MsgUpdateParams) (*MsgUpdateParamsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateParams not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
}
func _Msg_UpdateParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgUpdateParams)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).UpdateParams(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cosmos.auth.v1beta1.Msg/UpdateParams",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).UpdateParams(ctx, req.(*MsgUpdateParams))
}
return interceptor(ctx, in, info, handler)
}
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cosmos.auth.v1beta1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UpdateParams",
Handler: _Msg_UpdateParams_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cosmos/auth/v1beta1/tx.proto",
}
func (m *MsgUpdateParams) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgUpdateParams) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateParams) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
{
size, err := m.Params.MarshalToSizedBuffer(dAtA[:i])
if err != nil {
return 0, err
}
i -= size
i = encodeVarintTx(dAtA, i, uint64(size))
}
i--
dAtA[i] = 0x12
if len(m.Authority) > 0 {
i -= len(m.Authority)
copy(dAtA[i:], m.Authority)
i = encodeVarintTx(dAtA, i, uint64(len(m.Authority)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *MsgUpdateParamsResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgUpdateParamsResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgUpdateParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
offset -= sovTx(v)
base := offset
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return base
}
func (m *MsgUpdateParams) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Authority)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
l = m.Params.Size()
n += 1 + l + sovTx(uint64(l))
return n
}
func (m *MsgUpdateParamsResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func sovTx(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
func sozTx(x uint64) (n int) {
return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *MsgUpdateParams) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgUpdateParams: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateParams: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Authority = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MsgUpdateParamsResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgUpdateParamsResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgUpdateParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTx(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
depth := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTx
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTx
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
case 1:
iNdEx += 8
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowTx
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if length < 0 {
return 0, ErrInvalidLengthTx
}
iNdEx += length
case 3:
depth++
case 4:
if depth == 0 {
return 0, ErrUnexpectedEndOfGroupTx
}
depth--
case 5:
iNdEx += 4
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
if iNdEx < 0 {
return 0, ErrInvalidLengthTx
}
if depth == 0 {
return iNdEx, nil
}
}
return 0, io.ErrUnexpectedEOF
}
var (
ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowTx = fmt.Errorf("proto: integer overflow")
ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group")
)

View File

@ -24,6 +24,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/bank/keeper"
"github.com/cosmos/cosmos-sdk/x/bank/testutil"
"github.com/cosmos/cosmos-sdk/x/bank/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
)
@ -86,8 +87,8 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
maccPerms[randomPerm] = []string{"random"}
authKeeper := authkeeper.NewAccountKeeper(
appCodec, app.GetKey(types.StoreKey), app.GetSubspace(types.ModuleName),
authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
appCodec, app.GetKey(types.StoreKey), authtypes.ProtoBaseAccount,
maccPerms, sdk.Bech32MainPrefix, authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
keeper := keeper.NewBaseKeeper(
appCodec, app.GetKey(types.StoreKey), authKeeper,
@ -279,7 +280,7 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() {
Require().
NoError(keeper.MintCoins(ctx, authtypes.Minter, initCoins))
supplyAfterInflation, _, err := keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{})
suite.Require().NoError(err)
suite.Require().Panics(func() { keeper.BurnCoins(ctx, "", initCoins) }, "no module account") // nolint:errcheck
suite.Require().Panics(func() { keeper.BurnCoins(ctx, authtypes.Minter, initCoins) }, "invalid permission") // nolint:errcheck
suite.Require().Panics(func() { keeper.BurnCoins(ctx, randomPerm, supplyAfterInflation) }, "random permission") // nolint:errcheck
@ -304,8 +305,8 @@ func (suite *IntegrationTestSuite) TestSupply_BurnCoins() {
authKeeper.SetModuleAccount(ctx, multiPermAcc)
err = keeper.BurnCoins(ctx, multiPermAcc.GetName(), initCoins)
supplyAfterBurn, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{})
suite.Require().NoError(err)
supplyAfterBurn, _, err = keeper.GetPaginatedTotalSupply(ctx, &query.PageRequest{})
suite.Require().NoError(err)
suite.Require().Equal(sdk.NewCoins().String(), getCoinsByName(ctx, keeper, authKeeper, multiPermAcc.GetName()).String())
suite.Require().Equal(supplyAfterInflation.Sub(initCoins...), supplyAfterBurn)
@ -1053,8 +1054,9 @@ func (suite *IntegrationTestSuite) TestBalanceTrackingEvents() {
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
suite.app.AccountKeeper = authkeeper.NewAccountKeeper(
suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey), suite.app.GetSubspace(authtypes.ModuleName),
suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey),
authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
suite.app.BankKeeper = keeper.NewBaseKeeper(suite.app.AppCodec(), suite.app.GetKey(types.StoreKey),
@ -1180,8 +1182,9 @@ func (suite *IntegrationTestSuite) TestMintCoinRestrictions() {
maccPerms[multiPerm] = []string{authtypes.Burner, authtypes.Minter, authtypes.Staking}
suite.app.AccountKeeper = authkeeper.NewAccountKeeper(
suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey), suite.app.GetSubspace(authtypes.ModuleName),
suite.app.AppCodec(), suite.app.GetKey(authtypes.StoreKey),
authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
suite.app.AccountKeeper.SetModuleAccount(suite.ctx, multiPermAcc)