diff --git a/app/app.go b/app/app.go index a97da5804..fe5e82fe8 100644 --- a/app/app.go +++ b/app/app.go @@ -361,7 +361,7 @@ func NewComposableApp( mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(slashingtypes.ModuleName)), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper, app.GetSubspace(distrtypes.ModuleName)), - customstaking.NewAppModule(appCodec, *&app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), + customstaking.NewAppModule(appCodec, app.CustomStakingKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(stakingtypes.ModuleName)), stakingmiddleware.NewAppModule(appCodec, app.StakingMiddlewareKeeper), authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry), upgrade.NewAppModule(app.UpgradeKeeper), diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index f7a155c18..c46e8867c 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -196,7 +196,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.StakingMiddlewareKeeper = stakingmiddleware.NewKeeper(appCodec, appKeepers.keys[stakingmiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String()) appKeepers.CustomStakingKeeper = customstaking.NewKeeper( - appCodec /*appKeepers.keys[stakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, &appKeepers.MintKeeper, &appKeepers.StakingMiddlewareKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), + appCodec /*appKeepers.keys[stakingtypes.StoreKey],*/, *appKeepers.StakingKeeper, appKeepers.AccountKeeper, &appKeepers.StakingMiddlewareKeeper, authtypes.NewModuleAddress(govtypes.ModuleName).String(), ) appKeepers.DistrKeeper = distrkeeper.NewKeeper( diff --git a/custom/staking/abci.go b/custom/staking/abci.go new file mode 100644 index 000000000..915dafca0 --- /dev/null +++ b/custom/staking/abci.go @@ -0,0 +1,22 @@ +package bank + +import ( + "time" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/telemetry" + sdk "github.com/cosmos/cosmos-sdk/types" + + // "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" + + customstakingkeeper "github.com/notional-labs/composable/v6/custom/staking/keeper" +) + +// Called every block, update validator set +func EndBlocker(ctx sdk.Context, k *customstakingkeeper.Keeper) []abci.ValidatorUpdate { + defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), telemetry.MetricKeyEndBlocker) + + return k.BlockValidatorUpdates(ctx, ctx.BlockHeight()) +} diff --git a/custom/staking/keeper/keeper.go b/custom/staking/keeper/keeper.go index 7717e2249..309f1b211 100644 --- a/custom/staking/keeper/keeper.go +++ b/custom/staking/keeper/keeper.go @@ -1,11 +1,13 @@ package keeper import ( + abcicometbft "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/codec" accountkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + "github.com/cosmos/cosmos-sdk/x/staking/types" - mintkeeper "github.com/notional-labs/composable/v6/x/mint/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" stakingmiddleware "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper" ) @@ -13,31 +15,102 @@ type Keeper struct { stakingkeeper.Keeper cdc codec.BinaryCodec acck accountkeeper.AccountKeeper - mintkeeper *mintkeeper.Keeper - stakingmiddleware *stakingmiddleware.Keeper + Stakingmiddleware *stakingmiddleware.Keeper authority string } -// func NewBaseKeeper( -// cdc codec.BinaryCodec, -// key storetypes.StoreKey, -// ak types.AccountKeeper, -// acck accountkeeper.AccountKeeper, -// bk bankkeeper.Keeper, -// authority string, -// ) Keeper { -// keeper := Keeper{ -// Keeper: *stakingkeeper.NewKeeper(cdc, key, ak, bk, authority), -// acck: acck, -// } -// return keeper -// } +func (k Keeper) BlockValidatorUpdates(ctx sdk.Context, hight int64) []abcicometbft.ValidatorUpdate { + // Calculate validator set changes. + // + // NOTE: ApplyAndReturnValidatorSetUpdates has to come before + // UnbondAllMatureValidatorQueue. + // This fixes a bug when the unbonding period is instant (is the case in + // some of the tests). The test expected the validator to be completely + // unbonded after the Endblocker (go from Bonded -> Unbonding during + // ApplyAndReturnValidatorSetUpdates and then Unbonding -> Unbonded during + // UnbondAllMatureValidatorQueue). + println("BlockValidatorUpdates Custom Staking Module") + params := k.Stakingmiddleware.GetParams(ctx) + println("BlocksPerEpoch: ", params.BlocksPerEpoch) + should_execute_batch := (hight % int64(params.BlocksPerEpoch)) == 0 + var validatorUpdates []abcicometbft.ValidatorUpdate + if should_execute_batch { + println("Should Execute Batch: ", hight) + v, err := k.ApplyAndReturnValidatorSetUpdates(ctx) + if err != nil { + panic(err) + } + validatorUpdates = v + } + + // unbond all mature validators from the unbonding queue + k.UnbondAllMatureValidators(ctx) + + // Remove all mature unbonding delegations from the ubd queue. + matureUnbonds := k.DequeueAllMatureUBDQueue(ctx, ctx.BlockHeader().Time) + for _, dvPair := range matureUnbonds { + addr, err := sdk.ValAddressFromBech32(dvPair.ValidatorAddress) + if err != nil { + panic(err) + } + delegatorAddress := sdk.MustAccAddressFromBech32(dvPair.DelegatorAddress) + + balances, err := k.CompleteUnbonding(ctx, delegatorAddress, addr) + if err != nil { + continue + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCompleteUnbonding, + sdk.NewAttribute(sdk.AttributeKeyAmount, balances.String()), + sdk.NewAttribute(types.AttributeKeyValidator, dvPair.ValidatorAddress), + sdk.NewAttribute(types.AttributeKeyDelegator, dvPair.DelegatorAddress), + ), + ) + } + + // Remove all mature redelegations from the red queue. + matureRedelegations := k.DequeueAllMatureRedelegationQueue(ctx, ctx.BlockHeader().Time) + for _, dvvTriplet := range matureRedelegations { + valSrcAddr, err := sdk.ValAddressFromBech32(dvvTriplet.ValidatorSrcAddress) + if err != nil { + panic(err) + } + valDstAddr, err := sdk.ValAddressFromBech32(dvvTriplet.ValidatorDstAddress) + if err != nil { + panic(err) + } + delegatorAddress := sdk.MustAccAddressFromBech32(dvvTriplet.DelegatorAddress) + + balances, err := k.CompleteRedelegation( + ctx, + delegatorAddress, + valSrcAddr, + valDstAddr, + ) + if err != nil { + continue + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCompleteRedelegation, + sdk.NewAttribute(sdk.AttributeKeyAmount, balances.String()), + sdk.NewAttribute(types.AttributeKeyDelegator, dvvTriplet.DelegatorAddress), + sdk.NewAttribute(types.AttributeKeySrcValidator, dvvTriplet.ValidatorSrcAddress), + sdk.NewAttribute(types.AttributeKeyDstValidator, dvvTriplet.ValidatorDstAddress), + ), + ) + } + + return validatorUpdates +} func NewKeeper( cdc codec.BinaryCodec, staking stakingkeeper.Keeper, acck accountkeeper.AccountKeeper, - mintkeeper *mintkeeper.Keeper, stakingmiddleware *stakingmiddleware.Keeper, authority string, ) Keeper { @@ -45,21 +118,8 @@ func NewKeeper( Keeper: staking, acck: acck, authority: authority, - mintkeeper: mintkeeper, - stakingmiddleware: stakingmiddleware, + Stakingmiddleware: stakingmiddleware, cdc: cdc, } return keeper } - -// func (k *Keeper) RegisterKeepers(akk banktypes.StakingKeeper) { -// k.acck = sk -// } - -// func (k Keeper) StoreDelegation(ctx sdk.Context, delegation types.Delegation) { -// delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) - -// store := ctx.KVStore(k.storeKey) -// b := types.MustMarshalDelegation(k.cdc, delegation) -// store.Set(customstakingtypes.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()), b) -// } diff --git a/custom/staking/keeper/msg_server.go b/custom/staking/keeper/msg_server.go index 22a208cef..234f3f2e4 100644 --- a/custom/staking/keeper/msg_server.go +++ b/custom/staking/keeper/msg_server.go @@ -3,8 +3,6 @@ package keeper import ( "context" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" "github.com/cosmos/cosmos-sdk/x/staking/types" ) @@ -29,27 +27,7 @@ func (k msgServer) EditValidator(goCtx context.Context, msg *types.MsgEditValida } func (k msgServer) Delegate(goCtx context.Context, msg *types.MsgDelegate) (*types.MsgDelegateResponse, error) { - - ctx := sdk.UnwrapSDKContext(goCtx) - - // bondDenom := k.BondDenom(ctx) - // if msg.Amount.Denom != bondDenom { - // return nil, sdkerrors.Wrapf( - // sdkerrors.ErrInvalidRequest, "invalid coin denomination: got %s, expected %s", msg.Amount.Denom, bondDenom, - // ) - // } - - // delegation := types.Delegation{ - // DelegatorAddress: msg.DelegatorAddress, - // ValidatorAddress: msg.ValidatorAddress, - // Shares: msg.Amount.Amount.ToLegacyDec(), - // } - k.mintkeeper.SetLastTotalPower(ctx, math.Int{}) - k.stakingmiddleware.SetLastTotalPower(ctx, math.Int{}) - - return &types.MsgDelegateResponse{}, nil - // return nil, fmt.Errorf("My custom error: Nikita") - // return k.msgServer.Delegate(goCtx, msg) + return k.msgServer.Delegate(goCtx, msg) } func (k msgServer) BeginRedelegate(goCtx context.Context, msg *types.MsgBeginRedelegate) (*types.MsgBeginRedelegateResponse, error) { diff --git a/custom/staking/module.go b/custom/staking/module.go index 6f982554b..44a306f73 100644 --- a/custom/staking/module.go +++ b/custom/staking/module.go @@ -3,32 +3,35 @@ package bank import ( "fmt" + abcitype "github.com/cometbft/cometbft/abci/types" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/types/module" stakingmodule "github.com/cosmos/cosmos-sdk/x/staking" "github.com/cosmos/cosmos-sdk/x/staking/exported" - "github.com/cosmos/cosmos-sdk/x/staking/keeper" stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - "github.com/cosmos/cosmos-sdk/x/staking/types" + stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" // custombankkeeper "github.com/notional-labs/composable/v6/custom/bank/keeper" + sdk "github.com/cosmos/cosmos-sdk/types" customstakingkeeper "github.com/notional-labs/composable/v6/custom/staking/keeper" ) // AppModule wraps around the bank module and the bank keeper to return the right total supply type AppModule struct { stakingmodule.AppModule - keeper customstakingkeeper.Keeper - subspace exported.Subspace + keeper customstakingkeeper.Keeper + subspace exported.Subspace + msgServer stakingtypes.MsgServer } // NewAppModule creates a new AppModule object -func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ss exported.Subspace) AppModule { +func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKeeper stakingtypes.AccountKeeper, bankKeeper stakingtypes.BankKeeper, ss exported.Subspace) AppModule { stakingModule := stakingmodule.NewAppModule(cdc, &keeper.Keeper, accountKeeper, bankKeeper, ss) return AppModule{ AppModule: stakingModule, keeper: keeper, subspace: ss, + msgServer: stakingkeeper.NewMsgServerImpl(&keeper.Keeper), } } @@ -37,20 +40,24 @@ func NewAppModule(cdc codec.Codec, keeper customstakingkeeper.Keeper, accountKee // when trying to force this custom keeper into a bankkeeper.BaseKeeper func (am AppModule) RegisterServices(cfg module.Configurator) { // types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(&am.keeper)) - types.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper)) - querier := keeper.Querier{Keeper: &am.keeper.Keeper} - types.RegisterQueryServer(cfg.QueryServer(), querier) + stakingtypes.RegisterMsgServer(cfg.MsgServer(), customstakingkeeper.NewMsgServerImpl(am.keeper.Keeper, am.keeper)) + querier := stakingkeeper.Querier{Keeper: &am.keeper.Keeper} + stakingtypes.RegisterQueryServer(cfg.QueryServer(), querier) m := stakingkeeper.NewMigrator(&am.keeper.Keeper, am.subspace) - if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + if err := cfg.RegisterMigration(stakingtypes.ModuleName, 1, m.Migrate1to2); err != nil { panic(fmt.Sprintf("failed to migrate x/staking from version 1 to 2: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { + if err := cfg.RegisterMigration(stakingtypes.ModuleName, 2, m.Migrate2to3); err != nil { panic(fmt.Sprintf("failed to migrate x/staking from version 2 to 3: %v", err)) } - if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { + if err := cfg.RegisterMigration(stakingtypes.ModuleName, 3, m.Migrate3to4); err != nil { panic(fmt.Sprintf("failed to migrate x/staking from version 3 to 4: %v", err)) } } + +func (am AppModule) EndBlock(ctx sdk.Context, _abc abcitype.RequestEndBlock) []abcitype.ValidatorUpdate { + return EndBlocker(ctx, &am.keeper) +} diff --git a/custom/staking/types/keeper_interfaces.go b/custom/staking/types/keeper_interfaces.go deleted file mode 100644 index 0907289a7..000000000 --- a/custom/staking/types/keeper_interfaces.go +++ /dev/null @@ -1,10 +0,0 @@ -package types - -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -type MintKeeper interface { - SetLastTotalPower(ctx sdk.Context, power math.Int) -} diff --git a/proto/centauri/mint/v1beta1/genesis.proto b/proto/centauri/mint/v1beta1/genesis.proto index f984181b3..a30271a06 100644 --- a/proto/centauri/mint/v1beta1/genesis.proto +++ b/proto/centauri/mint/v1beta1/genesis.proto @@ -19,11 +19,4 @@ message GenesisState { (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coin", (gogoproto.nullable) = false ]; - - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - bytes last_total_power = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; } diff --git a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto index 2a5012761..f2cdb42c2 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto @@ -2,16 +2,13 @@ syntax = "proto3"; package centauri.stakingmiddleware.v1beta1; import "gogoproto/gogo.proto"; +import "centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto"; +import "amino/amino.proto"; option go_package = "x/stakingmiddleware/types"; // GenesisState defines the stakingmiddleware module's genesis state. message GenesisState { - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - bytes last_total_power = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; + Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/centauri/stakingmiddleware/v1beta1/query.proto b/proto/centauri/stakingmiddleware/v1beta1/query.proto index 4c592f4b4..026dd1972 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/query.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/query.proto @@ -3,20 +3,23 @@ package centauri.stakingmiddleware.v1beta1; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; +import "centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto"; option go_package = "x/stakingmiddleware/types"; // Query provides defines the gRPC querier service. service Query { // Params returns the total set of minting parameters. - rpc Power(QueryPowerRequest) returns (QueryPowerResponse) { - option (google.api.http).get = "/cosmos/stakingmiddleware/v1beta1/params"; + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/cosmos/mint/v1beta1/params"; } } // QueryParamsRequest is the request type for the Query/Params RPC method. -message QueryPowerRequest {} +message QueryParamsRequest {} // QueryParamsResponse is the response type for the Query/Params RPC method. -message QueryPowerResponse { +message QueryParamsResponse { + // params defines the parameters of the module. + Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto b/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto new file mode 100644 index 000000000..b427cbef0 --- /dev/null +++ b/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto @@ -0,0 +1,79 @@ +syntax = "proto3"; +package centauri.stakingmiddleware.v1beta1; + +option go_package = "x/stakingmiddleware/types"; + +import "gogoproto/gogo.proto"; +import "cosmos_proto/cosmos.proto"; +import "cosmos/base/v1beta1/coin.proto"; + +import "amino/amino.proto"; +import "cosmos/msg/v1/msg.proto"; + + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +message Delegation { + option (cosmos.msg.v1.signer) = "delegator_address"; + option (amino.name) = "cosmos-sdk/MsgDelegate"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// BeginRedelegate defines a SDK message for performing a begin redelegation of coins +// from a delegator to a validator. +message BeginRedelegate{ + option (cosmos.msg.v1.signer) = "delegator_address"; + option (amino.name) = "cosmos-sdk/MsgBeginRedelegate"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_src_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_dst_address = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +message Undelegate { + option (cosmos.msg.v1.signer) = "delegator_address"; + option (amino.name) = "cosmos-sdk/MsgUndelegate"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; +} + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +message CancelUnbondingDelegation { + option (cosmos.msg.v1.signer) = "delegator_address"; + option (amino.name) = "cosmos-sdk/MsgCancelUnbondingDelegation"; + + option (gogoproto.equal) = false; + option (gogoproto.goproto_getters) = false; + + string delegator_address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + string validator_address = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + cosmos.base.v1beta1.Coin amount = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + int64 creation_height = 4; +} + + + +// Params holds parameters for the stakingmiddleware module. +message Params { + // expected blocks per year + uint64 blocks_per_epoch = 1; +} + diff --git a/proto/centauri/stakingmiddleware/v1beta1/tx.proto b/proto/centauri/stakingmiddleware/v1beta1/tx.proto index 5efe97b5d..491b4fcab 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/tx.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/tx.proto @@ -5,6 +5,7 @@ import "cosmos/msg/v1/msg.proto"; import "amino/amino.proto"; import "gogoproto/gogo.proto"; import "cosmos_proto/cosmos.proto"; +import "centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto"; option go_package = "x/stakingmiddleware/types"; @@ -12,18 +13,29 @@ option go_package = "x/stakingmiddleware/types"; service Msg { option (cosmos.msg.v1.service) = true; - rpc SetPower(MsgSetPower) returns (MsgSetPowerResponse); + rpc UpdateEpochParams(MsgUpdateEpochParams) returns (MsgUpdateParamsEpochResponse); } -// MsgSetPower is the Msg/SetPower request type. +// MsgUpdateParams is the Msg/UpdateParams request type. // // Since: cosmos-sdk 0.47 -message MsgSetPower { - string from_address = 1; +message MsgUpdateEpochParams { + option (cosmos.msg.v1.signer) = "authority"; + option (amino.name) = "centauri/x/stakingmiddleware/MsgUpdateParams"; + + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ]; + + // params defines the x/stakingmiddleware parameters to update. + // + // NOTE: All parameters must be supplied. + Params params = 2 + [ (gogoproto.nullable) = false, (amino.dont_omitempty) = true ]; } -// MsgSetPowerResponse defines the response structure for executing a -// MsgSetPower message. +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. // // Since: cosmos-sdk 0.47 -message MsgSetPowerResponse {} +message MsgUpdateParamsEpochResponse {} diff --git a/x/mint/types/genesis.pb.go b/x/mint/types/genesis.pb.go index 93b5c6d44..4c2486d24 100644 --- a/x/mint/types/genesis.pb.go +++ b/x/mint/types/genesis.pb.go @@ -5,7 +5,6 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" @@ -32,9 +31,6 @@ type GenesisState struct { // params defines all the paramaters of the module. Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` IncentivesSupply types.Coin `protobuf:"bytes,3,opt,name=incentives_supply,json=incentivesSupply,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coin" json:"incentives_supply"` - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - LastTotalPower github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=last_total_power,json=lastTotalPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"last_total_power"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -100,29 +96,26 @@ func init() { } var fileDescriptor_dc8b577617211e57 = []byte{ - // 340 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x41, 0x4b, 0xf3, 0x30, - 0x18, 0x80, 0xdb, 0x7d, 0x63, 0x87, 0x7e, 0x43, 0x66, 0x51, 0xa8, 0x03, 0xb3, 0xa1, 0x30, 0x77, - 0x31, 0x61, 0x7a, 0xf4, 0x56, 0x0f, 0xe2, 0x41, 0x18, 0x9b, 0x07, 0xf1, 0x32, 0xd2, 0x1a, 0x6a, - 0x70, 0x4d, 0x4a, 0xf3, 0x6e, 0x73, 0xff, 0xc2, 0xdf, 0xe1, 0x2f, 0xd9, 0x71, 0x47, 0x51, 0x98, - 0xb2, 0xfd, 0x11, 0x49, 0xd2, 0xcd, 0xcb, 0x10, 0x4f, 0x2d, 0xe4, 0x79, 0x9e, 0xe4, 0xe5, 0xf5, - 0x8e, 0x63, 0x26, 0x80, 0x8e, 0x72, 0x4e, 0x52, 0x2e, 0x80, 0x8c, 0x3b, 0x11, 0x03, 0xda, 0x21, - 0x09, 0x13, 0x4c, 0x71, 0x85, 0xb3, 0x5c, 0x82, 0xf4, 0xf7, 0xd7, 0x10, 0xd6, 0x10, 0x2e, 0xa0, - 0xfa, 0x5e, 0x22, 0x13, 0x69, 0x08, 0xa2, 0xff, 0x2c, 0x5c, 0x6f, 0x6e, 0x2f, 0x1a, 0xd3, 0x12, - 0x28, 0x96, 0x2a, 0x95, 0x8a, 0x44, 0x54, 0xb1, 0xcd, 0x79, 0x2c, 0xb9, 0xb0, 0xe7, 0x47, 0x1f, - 0x25, 0xaf, 0x7a, 0x65, 0x1f, 0xd0, 0x07, 0x0a, 0xcc, 0xbf, 0xf0, 0x2a, 0x5a, 0x67, 0x79, 0xe0, - 0x36, 0xdd, 0xf6, 0xff, 0xb3, 0x43, 0xbc, 0xf5, 0x41, 0xf8, 0xc6, 0x40, 0x61, 0x79, 0xb6, 0x68, - 0x38, 0xbd, 0x42, 0xd1, 0x72, 0x46, 0x73, 0x9a, 0xaa, 0xa0, 0xf4, 0xab, 0xdc, 0x35, 0xd0, 0x5a, - 0xb6, 0x8a, 0x3f, 0xf1, 0x76, 0xb9, 0xd0, 0x3c, 0x1f, 0x33, 0x35, 0x50, 0xa3, 0x2c, 0x1b, 0x4e, - 0x83, 0x7f, 0xa6, 0x73, 0x80, 0xed, 0x18, 0x58, 0x8f, 0xb1, 0xa9, 0x5c, 0x4a, 0x2e, 0x42, 0xa2, - 0x1b, 0xaf, 0x9f, 0x8d, 0x93, 0x84, 0xc3, 0xe3, 0x28, 0xc2, 0xb1, 0x4c, 0x49, 0x31, 0xb3, 0xfd, - 0x9c, 0xaa, 0x87, 0x27, 0x02, 0xd3, 0x8c, 0x29, 0x23, 0xf4, 0x6a, 0x3f, 0x97, 0xf4, 0xcd, 0x1d, - 0xfe, 0x9d, 0x57, 0x1b, 0x52, 0x05, 0x03, 0x90, 0x40, 0x87, 0x83, 0x4c, 0x4e, 0x58, 0x1e, 0x94, - 0x9b, 0x6e, 0xbb, 0x1a, 0x62, 0x1d, 0x7f, 0x5f, 0x34, 0x5a, 0x7f, 0x88, 0x5f, 0x0b, 0xe8, 0xed, - 0xe8, 0xce, 0xad, 0xce, 0x74, 0x75, 0x25, 0x6c, 0xcd, 0x96, 0xc8, 0x9d, 0x2f, 0x91, 0xfb, 0xb5, - 0x44, 0xee, 0xcb, 0x0a, 0x39, 0xf3, 0x15, 0x72, 0xde, 0x56, 0xc8, 0xb9, 0xaf, 0x3e, 0xdb, 0x95, - 0x19, 0x37, 0xaa, 0x98, 0x65, 0x9c, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0x51, 0x7e, 0xb8, 0x8b, - 0x22, 0x02, 0x00, 0x00, + // 296 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0x3f, 0x4e, 0xc3, 0x30, + 0x14, 0x87, 0xe3, 0x82, 0x3a, 0x84, 0x0e, 0x10, 0x81, 0x14, 0x2a, 0xe1, 0x56, 0x20, 0x01, 0x0b, + 0xb6, 0x0a, 0x23, 0x5b, 0x18, 0x98, 0x90, 0x50, 0xbb, 0xb1, 0x20, 0x27, 0x58, 0xc1, 0x82, 0xd8, + 0x56, 0x9e, 0x53, 0xe8, 0xc8, 0x0d, 0x38, 0x07, 0x27, 0xe9, 0xd8, 0x91, 0x09, 0x50, 0x72, 0x11, + 0x64, 0x3b, 0x2d, 0x4b, 0xc5, 0x64, 0x4b, 0xef, 0xfb, 0x7e, 0xef, 0x4f, 0x78, 0x94, 0x71, 0x69, + 0x58, 0x55, 0x0a, 0x5a, 0x08, 0x69, 0xe8, 0x74, 0x94, 0x72, 0xc3, 0x46, 0x34, 0xe7, 0x92, 0x83, + 0x00, 0xa2, 0x4b, 0x65, 0x54, 0xb4, 0xb7, 0x84, 0x88, 0x85, 0x48, 0x0b, 0xf5, 0x77, 0x73, 0x95, + 0x2b, 0x47, 0x50, 0xfb, 0xf3, 0x70, 0x7f, 0xb8, 0x3e, 0xd1, 0x99, 0x9e, 0xc0, 0x99, 0x82, 0x42, + 0x01, 0x4d, 0x19, 0xf0, 0x55, 0x3d, 0x53, 0x42, 0xfa, 0xfa, 0xe1, 0x5b, 0x27, 0xec, 0x5d, 0xfb, + 0x01, 0x26, 0x86, 0x19, 0x1e, 0x5d, 0x86, 0x5d, 0xab, 0xf3, 0x32, 0x46, 0x43, 0x74, 0xba, 0x75, + 0x7e, 0x40, 0xd6, 0x0e, 0x44, 0x6e, 0x1c, 0x94, 0x6c, 0xce, 0xbf, 0x06, 0xc1, 0xb8, 0x55, 0xac, + 0xac, 0x59, 0xc9, 0x0a, 0x88, 0x3b, 0xff, 0xca, 0xb7, 0x0e, 0x5a, 0xca, 0x5e, 0x89, 0x5e, 0xc2, + 0x1d, 0x21, 0x2d, 0x2f, 0xa6, 0x1c, 0xee, 0xa1, 0xd2, 0xfa, 0x79, 0x16, 0x6f, 0xb8, 0x9c, 0x7d, + 0xe2, 0xd7, 0x20, 0x76, 0x8d, 0x55, 0xca, 0x95, 0x12, 0x32, 0xa1, 0x36, 0xe3, 0xe3, 0x7b, 0x70, + 0x92, 0x0b, 0xf3, 0x58, 0xa5, 0x24, 0x53, 0x05, 0x6d, 0x77, 0xf6, 0xcf, 0x19, 0x3c, 0x3c, 0x51, + 0x33, 0xd3, 0x1c, 0x9c, 0x30, 0xde, 0xfe, 0x6b, 0x32, 0x71, 0x3d, 0x92, 0xe3, 0x79, 0x8d, 0xd1, + 0xa2, 0xc6, 0xe8, 0xa7, 0xc6, 0xe8, 0xbd, 0xc1, 0xc1, 0xa2, 0xc1, 0xc1, 0x67, 0x83, 0x83, 0xbb, + 0xde, 0xab, 0x3f, 0xac, 0xd3, 0xd3, 0xae, 0x3b, 0xd9, 0xc5, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x7c, 0x38, 0xd2, 0x82, 0xc8, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -145,16 +138,6 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - { - size := m.LastTotalPower.Size() - i -= size - if _, err := m.LastTotalPower.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 { size, err := m.IncentivesSupply.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -211,8 +194,6 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) l = m.IncentivesSupply.Size() n += 1 + l + sovGenesis(uint64(l)) - l = m.LastTotalPower.Size() - n += 1 + l + sovGenesis(uint64(l)) return n } @@ -350,39 +331,6 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastTotalPower", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.LastTotalPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/stakingmiddleware/client/cli/query.go b/x/stakingmiddleware/client/cli/query.go index 939b8a5c0..31b1150dd 100644 --- a/x/stakingmiddleware/client/cli/query.go +++ b/x/stakingmiddleware/client/cli/query.go @@ -1,8 +1,6 @@ package cli import ( - "fmt" - "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -14,14 +12,14 @@ import ( func GetQueryCmd() *cobra.Command { mintingQueryCmd := &cobra.Command{ Use: types.ModuleName, - Short: "Querying commands for the minting module", + Short: "Querying commands for the staking middleware module", DisableFlagParsing: true, SuggestionsMinimumDistance: 2, RunE: client.ValidateCmd, } mintingQueryCmd.AddCommand( - GetCmdQueryPower(), + GetCmdQueryParams(), ) return mintingQueryCmd @@ -29,31 +27,25 @@ func GetQueryCmd() *cobra.Command { // GetCmdQueryParams implements a command to return the current minting // parameters. -func GetCmdQueryPower() *cobra.Command { +func GetCmdQueryParams() *cobra.Command { cmd := &cobra.Command{ - Use: "power", - Short: "Query the current power", + Use: "params", + Short: "Query the current minting parameters", Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } - - return clientCtx.PrintString(fmt.Sprintf("%s\n", "hello world")) - queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryPowerRequest{} - res, err := queryClient.Power(cmd.Context(), params) + params := &types.QueryParamsRequest{} + res, err := queryClient.Params(cmd.Context(), params) if err != nil { return err } - _ = res - // return nil - return clientCtx.PrintString(fmt.Sprintf("%s\n", "hello world")) - // return clientCtx.PrintProto(&res.Power) + return clientCtx.PrintProto(&res.Params) }, } diff --git a/x/stakingmiddleware/client/cli/tx.go b/x/stakingmiddleware/client/cli/tx.go index bd6465a2b..82597aec2 100644 --- a/x/stakingmiddleware/client/cli/tx.go +++ b/x/stakingmiddleware/client/cli/tx.go @@ -2,8 +2,6 @@ package cli import ( "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" "github.com/spf13/cobra" "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" @@ -19,28 +17,7 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } - txCmd.AddCommand( - GetCmdSetPower(), - ) + txCmd.AddCommand() return txCmd } - -func GetCmdSetPower() *cobra.Command { - cmd := &cobra.Command{ - Use: "fund [amount]", - Args: cobra.ExactArgs(1), - RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, err := client.GetClientTxContext(cmd) - if err != nil { - return err - } - - msg := types.NewMsgSetPower(clientCtx.GetFromAddress()) - return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) - }, - } - flags.AddTxFlagsToCmd(cmd) - - return cmd -} diff --git a/x/stakingmiddleware/keeper/genesis.go b/x/stakingmiddleware/keeper/genesis.go index 418884413..e5472e6ab 100644 --- a/x/stakingmiddleware/keeper/genesis.go +++ b/x/stakingmiddleware/keeper/genesis.go @@ -7,11 +7,13 @@ import ( // InitGenesis new mint genesis func (keeper Keeper) InitGenesis(ctx sdk.Context, data *types.GenesisState) { - keeper.SetLastTotalPower(ctx, data.LastTotalPower) + if err := keeper.SetParams(ctx, data.Params); err != nil { + panic(err) + } } // ExportGenesis returns a GenesisState for a given context and keeper. func (keeper Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { - minter := keeper.GetLastTotalPower(ctx) - return types.NewGenesisState(minter) + params := keeper.GetParams(ctx) + return types.NewGenesisState(params) } diff --git a/x/stakingmiddleware/keeper/keeper.go b/x/stakingmiddleware/keeper/keeper.go index a1f1bb960..837bbc7c6 100644 --- a/x/stakingmiddleware/keeper/keeper.go +++ b/x/stakingmiddleware/keeper/keeper.go @@ -1,14 +1,14 @@ package keeper import ( - "cosmossdk.io/math" + "fmt" + "github.com/cometbft/cometbft/libs/log" - "github.com/notional-labs/composable/v6/x/mint/types" + "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - // "github.com/notional-labs/composable/v6/x/mint/types" ) // Keeper of the staking middleware store @@ -43,59 +43,31 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", "x/"+types.ModuleName) } -// // SetParams sets the x/mint module parameters. -// func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { -// if err := p.Validate(); err != nil { -// return err -// } - -// store := ctx.KVStore(k.storeKey) -// bz := k.cdc.MustMarshal(&p) -// store.Set(types.ParamsKey, bz) - -// return nil -// } - -// // GetParams returns the current x/mint module parameters. -// func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { -// store := ctx.KVStore(k.storeKey) -// bz := store.Get(types.ParamsKey) -// if bz == nil { -// return p -// } - -// k.cdc.MustUnmarshal(bz, &p) -// return p -// } +// SetParams sets the x/mint module parameters. +func (k Keeper) SetParams(ctx sdk.Context, p types.Params) error { + if p.BlocksPerEpoch < 5 { + //return error + return fmt.Errorf( + "BlocksPerEpoch must be greater than or equal to 5", + ) -// func (k Keeper) StoreDelegation(ctx sdk.Context, delegation stakingtypes.Delegation) { -// delegatorAddress := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) -// log := k.Logger(ctx) -// log.Info("StoreDelegation", "delegatorAddress", delegatorAddress, "validatorAddress", delegation.GetValidatorAddr()) -// store := ctx.KVStore(k.storeKey) -// b := stakingtypes.MustMarshalDelegation(k.cdc, delegation) -// kkk := types.GetDelegationKey(delegatorAddress, delegation.GetValidatorAddr()) -// // log.Info() -// store.Set(kkk, b) -// } + } -// SetLastTotalPower Set the last total validator power. -func (k Keeper) SetLastTotalPower(ctx sdk.Context, power math.Int) { store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&sdk.IntProto{Int: power}) - store.Set(types.DelegationKey, bz) + bz := k.cdc.MustMarshal(&p) + store.Set(types.ParamsKey, bz) + + return nil } -func (k Keeper) GetLastTotalPower(ctx sdk.Context) math.Int { +// GetParams returns the current x/mint module parameters. +func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) { store := ctx.KVStore(k.storeKey) - bz := store.Get(types.DelegationKey) - + bz := store.Get(types.ParamsKey) if bz == nil { - return math.ZeroInt() + return p } - ip := sdk.IntProto{} - k.cdc.MustUnmarshal(bz, &ip) - - return ip.Int + k.cdc.MustUnmarshal(bz, &p) + return p } diff --git a/x/stakingmiddleware/keeper/msg_server.go b/x/stakingmiddleware/keeper/msg_server.go index 79056c132..1d51b5da1 100644 --- a/x/stakingmiddleware/keeper/msg_server.go +++ b/x/stakingmiddleware/keeper/msg_server.go @@ -3,6 +3,9 @@ package keeper import ( "context" + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" ) @@ -21,7 +24,15 @@ func NewMsgServerImpl(k Keeper) types.MsgServer { } // UpdateParams updates the params. -func (ms msgServer) SetPower(goCtx context.Context, req *types.MsgSetPower) (*types.MsgSetPowerResponse, error) { +func (ms msgServer) UpdateEpochParams(goCtx context.Context, req *types.MsgUpdateEpochParams) (*types.MsgUpdateParamsEpochResponse, error) { + if ms.authority != req.Authority { + return nil, errorsmod.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.MsgSetPowerResponse{}, nil + return &types.MsgUpdateParamsEpochResponse{}, nil } diff --git a/x/stakingmiddleware/module.go b/x/stakingmiddleware/module.go index 881d954d7..0cf65e3f4 100644 --- a/x/stakingmiddleware/module.go +++ b/x/stakingmiddleware/module.go @@ -20,7 +20,6 @@ import ( "github.com/notional-labs/composable/v6/x/stakingmiddleware/client/cli" "github.com/notional-labs/composable/v6/x/stakingmiddleware/keeper" "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" - middlewarestaking "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" ) var ( @@ -38,7 +37,7 @@ var _ module.AppModuleBasic = AppModuleBasic{} // Name returns the mint module's name. func (AppModuleBasic) Name() string { - return middlewarestaking.ModuleName + return types.ModuleName } // RegisterLegacyAminoCodec registers the mint module's types on the given LegacyAmino codec. diff --git a/x/stakingmiddleware/types/codec.go b/x/stakingmiddleware/types/codec.go index 66b175743..c8986807f 100644 --- a/x/stakingmiddleware/types/codec.go +++ b/x/stakingmiddleware/types/codec.go @@ -16,13 +16,13 @@ import ( // RegisterLegacyAminoCodec registers the account 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, &MsgSetPower{}, "composable/MsgSetPower") + legacy.RegisterAminoMsg(cdc, &MsgUpdateEpochParams{}, "composable/MsgUpdateEpochParams") } func RegisterInterfaces(registry codectypes.InterfaceRegistry) { registry.RegisterImplementations( (*sdk.Msg)(nil), - &MsgSetPower{}, + &MsgUpdateEpochParams{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/stakingmiddleware/types/genesis.go b/x/stakingmiddleware/types/genesis.go index 3830da245..fe53f6d29 100644 --- a/x/stakingmiddleware/types/genesis.go +++ b/x/stakingmiddleware/types/genesis.go @@ -1,21 +1,16 @@ package types -import ( - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - // NewGenesisState creates a new GenesisState object -func NewGenesisState(m math.Int) *GenesisState { +func NewGenesisState(params Params) *GenesisState { return &GenesisState{ - LastTotalPower: m, + Params: params, } } // DefaultGenesisState creates a default GenesisState object func DefaultGenesisState() *GenesisState { return &GenesisState{ - LastTotalPower: sdk.ZeroInt(), + Params: Params{BlocksPerEpoch: 10}, } } diff --git a/x/stakingmiddleware/types/genesis.pb.go b/x/stakingmiddleware/types/genesis.pb.go index 5aad5c330..56b0631be 100644 --- a/x/stakingmiddleware/types/genesis.pb.go +++ b/x/stakingmiddleware/types/genesis.pb.go @@ -5,7 +5,7 @@ package types import ( fmt "fmt" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" _ "github.com/cosmos/gogoproto/gogoproto" proto "github.com/cosmos/gogoproto/proto" io "io" @@ -26,9 +26,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the stakingmiddleware module's genesis state. type GenesisState struct { - // last_total_power tracks the total amounts of bonded tokens recorded during - // the previous end block. - LastTotalPower github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=last_total_power,json=lastTotalPower,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"last_total_power"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -64,6 +62,13 @@ func (m *GenesisState) XXX_DiscardUnknown() { var xxx_messageInfo_GenesisState proto.InternalMessageInfo +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + func init() { proto.RegisterType((*GenesisState)(nil), "centauri.stakingmiddleware.v1beta1.GenesisState") } @@ -73,22 +78,20 @@ func init() { } var fileDescriptor_1aa0bd912277c095 = []byte{ - // 229 bytes of a gzipped FileDescriptorProto + // 206 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x32, 0x48, 0x4e, 0xcd, 0x2b, 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xe9, 0xd0, 0xc3, 0xd0, 0xa1, 0x07, 0xd5, 0x21, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xae, 0x0f, - 0x62, 0x41, 0x74, 0x2a, 0x65, 0x70, 0xf1, 0xb8, 0x43, 0x8c, 0x0a, 0x2e, 0x49, 0x2c, 0x49, 0x15, - 0x8a, 0xe0, 0x12, 0xc8, 0x49, 0x2c, 0x2e, 0x89, 0x2f, 0xc9, 0x2f, 0x49, 0xcc, 0x89, 0x2f, 0xc8, - 0x2f, 0x4f, 0x2d, 0x92, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x71, 0xd2, 0x3b, 0x71, 0x4f, 0x9e, 0xe1, - 0xd6, 0x3d, 0x79, 0xb5, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xe4, - 0xfc, 0xe2, 0xdc, 0xfc, 0x62, 0x28, 0xa5, 0x5b, 0x9c, 0x92, 0xad, 0x5f, 0x52, 0x59, 0x90, 0x5a, - 0xac, 0xe7, 0x99, 0x57, 0x12, 0xc4, 0x07, 0x32, 0x27, 0x04, 0x64, 0x4c, 0x00, 0xc8, 0x14, 0x27, - 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, - 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0xac, 0xc0, 0xe2, 0x51, - 0xb0, 0x41, 0x49, 0x6c, 0x60, 0x57, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x11, 0xb1, 0xd1, - 0x9a, 0x13, 0x01, 0x00, 0x00, + 0x62, 0x41, 0x74, 0x4a, 0x59, 0x11, 0x61, 0x17, 0xa6, 0x99, 0x10, 0xbd, 0x82, 0x89, 0xb9, 0x99, + 0x79, 0xf9, 0xfa, 0x60, 0x12, 0x22, 0xa4, 0x14, 0xc1, 0xc5, 0xe3, 0x0e, 0x71, 0x59, 0x70, 0x49, + 0x62, 0x49, 0xaa, 0x90, 0x07, 0x17, 0x5b, 0x41, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x04, 0xa3, 0x02, + 0xa3, 0x06, 0xb7, 0x91, 0x96, 0x1e, 0x61, 0x97, 0xea, 0x05, 0x80, 0x75, 0x38, 0xb1, 0x9c, 0xb8, + 0x27, 0xcf, 0x10, 0x04, 0xd5, 0xef, 0x64, 0x7c, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, + 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, + 0x0c, 0x51, 0x92, 0x15, 0x58, 0xdc, 0x5e, 0x52, 0x59, 0x90, 0x5a, 0x9c, 0xc4, 0x06, 0x76, 0x95, + 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xdc, 0x25, 0x9a, 0xf8, 0x52, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -112,11 +115,11 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l { - size := m.LastTotalPower.Size() - i -= size - if _, err := m.LastTotalPower.MarshalTo(dAtA[i:]); err != nil { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { return 0, err } + i -= size i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- @@ -141,7 +144,7 @@ func (m *GenesisState) Size() (n int) { } var l int _ = l - l = m.LastTotalPower.Size() + l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) return n } @@ -183,9 +186,9 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LastTotalPower", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) } - var byteLen int + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowGenesis @@ -195,22 +198,22 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + if msglen < 0 { return ErrInvalidLengthGenesis } - postIndex := iNdEx + byteLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthGenesis } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.LastTotalPower.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/stakingmiddleware/types/keys.go b/x/stakingmiddleware/types/keys.go index fc04bd47c..dcaab0090 100644 --- a/x/stakingmiddleware/types/keys.go +++ b/x/stakingmiddleware/types/keys.go @@ -1,13 +1,8 @@ package types -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/address" -) - // MinterKey is the key to use for the keeper store. var ( - DelegationKey = []byte{0x01} // key for a delegation + ParamsKey = []byte{0x01} // key for global staking middleware params in the keeper store ) const ( @@ -18,13 +13,3 @@ const ( StoreKey = "customstmiddleware" // not using the module name because of collisions with key "ibc" ) - -// GetDelegationKey creates the key for delegator bond with validator -// VALUE: staking/Delegation -func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.ValAddress) []byte { - return append(GetDelegationsKey(delAddr), address.MustLengthPrefix(valAddr)...) -} - -func GetDelegationsKey(delAddr sdk.AccAddress) []byte { - return append(DelegationKey, address.MustLengthPrefix(delAddr)...) -} diff --git a/x/stakingmiddleware/types/msg.go b/x/stakingmiddleware/types/msg.go deleted file mode 100644 index 4f182b9a2..000000000 --- a/x/stakingmiddleware/types/msg.go +++ /dev/null @@ -1,44 +0,0 @@ -package types - -import ( - errorsmod "cosmossdk.io/errors" - "github.com/cosmos/cosmos-sdk/codec/legacy" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -var _ sdk.Msg = &MsgSetPower{} - -// Route Implements Msg. -func (m MsgSetPower) Route() string { return sdk.MsgTypeURL(&m) } - -// Type Implements Msg. -func (m MsgSetPower) Type() string { return sdk.MsgTypeURL(&m) } - -// GetSigners returns the expected signers for a MsgMintAndAllocateExp . -func (m MsgSetPower) GetSigners() []sdk.AccAddress { - daoAccount, err := sdk.AccAddressFromBech32(m.FromAddress) - if err != nil { - panic(err) - } - return []sdk.AccAddress{daoAccount} -} - -// GetSignBytes Implements Msg. -func (m MsgSetPower) GetSignBytes() []byte { - return sdk.MustSortJSON(legacy.Cdc.MustMarshalJSON(&m)) -} - -// ValidateBasic does a sanity check on the provided data. -func (m MsgSetPower) ValidateBasic() error { - _, err := sdk.AccAddressFromBech32(m.FromAddress) - if err != nil { - return errorsmod.Wrap(err, "from address must be valid address") - } - return nil -} - -func NewMsgSetPower(fromAddr sdk.AccAddress) *MsgSetPower { - return &MsgSetPower{ - FromAddress: fromAddr.String(), - } -} diff --git a/x/stakingmiddleware/types/msgs.go b/x/stakingmiddleware/types/msgs.go new file mode 100644 index 000000000..4418aa784 --- /dev/null +++ b/x/stakingmiddleware/types/msgs.go @@ -0,0 +1,28 @@ +package types + +import ( + errorsmod "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ sdk.Msg = &MsgUpdateEpochParams{} + +// GetSignBytes implements the LegacyMsg interface. +func (m MsgUpdateEpochParams) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +// GetSigners returns the expected signers for a MsgUpdateParams message. +func (m *MsgUpdateEpochParams) GetSigners() []sdk.AccAddress { + addr, _ := sdk.AccAddressFromBech32(m.Authority) + return []sdk.AccAddress{addr} +} + +// ValidateBasic does a sanity check on the provided data. +func (m *MsgUpdateEpochParams) ValidateBasic() error { + if _, err := sdk.AccAddressFromBech32(m.Authority); err != nil { + return errorsmod.Wrapf(err, "invalid authority address") + } + + return nil +} diff --git a/x/stakingmiddleware/types/query.pb.go b/x/stakingmiddleware/types/query.pb.go index 4314b7bbe..772706fc6 100644 --- a/x/stakingmiddleware/types/query.pb.go +++ b/x/stakingmiddleware/types/query.pb.go @@ -30,21 +30,21 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QueryParamsRequest is the request type for the Query/Params RPC method. -type QueryPowerRequest struct { +type QueryParamsRequest struct { } -func (m *QueryPowerRequest) Reset() { *m = QueryPowerRequest{} } -func (m *QueryPowerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryPowerRequest) ProtoMessage() {} -func (*QueryPowerRequest) Descriptor() ([]byte, []int) { +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { return fileDescriptor_81a7c3c637f3f95a, []int{0} } -func (m *QueryPowerRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPowerRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -54,34 +54,36 @@ func (m *QueryPowerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *QueryPowerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPowerRequest.Merge(m, src) +func (m *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) } -func (m *QueryPowerRequest) XXX_Size() int { +func (m *QueryParamsRequest) XXX_Size() int { return m.Size() } -func (m *QueryPowerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPowerRequest.DiscardUnknown(m) +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryPowerRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo // QueryParamsResponse is the response type for the Query/Params RPC method. -type QueryPowerResponse struct { +type QueryParamsResponse struct { + // params defines the parameters of the module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` } -func (m *QueryPowerResponse) Reset() { *m = QueryPowerResponse{} } -func (m *QueryPowerResponse) String() string { return proto.CompactTextString(m) } -func (*QueryPowerResponse) ProtoMessage() {} -func (*QueryPowerResponse) Descriptor() ([]byte, []int) { +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { return fileDescriptor_81a7c3c637f3f95a, []int{1} } -func (m *QueryPowerResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryPowerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryParamsResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -91,21 +93,28 @@ func (m *QueryPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryPowerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryPowerResponse.Merge(m, src) +func (m *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) } -func (m *QueryPowerResponse) XXX_Size() int { +func (m *QueryParamsResponse) XXX_Size() int { return m.Size() } -func (m *QueryPowerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryPowerResponse.DiscardUnknown(m) +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryPowerResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} func init() { - proto.RegisterType((*QueryPowerRequest)(nil), "centauri.stakingmiddleware.v1beta1.QueryPowerRequest") - proto.RegisterType((*QueryPowerResponse)(nil), "centauri.stakingmiddleware.v1beta1.QueryPowerResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "centauri.stakingmiddleware.v1beta1.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "centauri.stakingmiddleware.v1beta1.QueryParamsResponse") } func init() { @@ -113,23 +122,26 @@ func init() { } var fileDescriptor_81a7c3c637f3f95a = []byte{ - // 250 bytes of a gzipped FileDescriptorProto + // 290 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4b, 0x4e, 0xcd, 0x2b, 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, 0x2c, 0x4d, 0x2d, 0xaa, 0xd4, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xa9, 0xd7, 0xc3, 0x50, 0xaf, 0x07, 0x55, 0x2f, 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xae, 0x0f, 0x62, 0x41, 0x74, 0x4a, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0xea, 0x27, 0x16, 0x64, 0xea, 0x27, 0xe6, - 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x64, 0x95, 0x84, 0xb9, 0x04, 0x03, - 0x41, 0xd6, 0x04, 0xe4, 0x97, 0xa7, 0x16, 0x05, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0x89, - 0x70, 0x09, 0x21, 0x0b, 0x16, 0x17, 0xe4, 0xe7, 0x15, 0xa7, 0x1a, 0x6d, 0x62, 0xe4, 0x62, 0x05, - 0x0b, 0x0b, 0xad, 0x60, 0xe4, 0x62, 0x05, 0xcb, 0x09, 0x99, 0xea, 0x11, 0x76, 0x97, 0x1e, 0x86, - 0x05, 0x52, 0x66, 0xa4, 0x6a, 0x83, 0x38, 0x41, 0xc9, 0xa0, 0xe9, 0xf2, 0x93, 0xc9, 0x4c, 0x5a, - 0x42, 0x1a, 0xfa, 0xc9, 0xf9, 0xc5, 0xb9, 0xf9, 0xc5, 0x78, 0x02, 0xaf, 0x20, 0xb1, 0x28, 0x31, - 0xb7, 0xd8, 0xc9, 0xf8, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, - 0x9c, 0xf0, 0x58, 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x24, 0x2b, - 0xb0, 0xe8, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x87, 0x8d, 0x31, 0x20, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0x72, 0xbe, 0xa5, 0x01, 0x00, 0x00, + 0xe5, 0xe5, 0x97, 0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x65, 0xad, 0x88, 0x70, 0x07, 0xa6, + 0x8d, 0x60, 0xbd, 0x4a, 0x22, 0x5c, 0x42, 0x81, 0x20, 0x27, 0x06, 0x24, 0x16, 0x25, 0xe6, 0x16, + 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x28, 0xc5, 0x73, 0x09, 0xa3, 0x88, 0x16, 0x17, 0xe4, + 0xe7, 0x15, 0xa7, 0x0a, 0x79, 0x70, 0xb1, 0x15, 0x80, 0x45, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, + 0x8d, 0xb4, 0xf4, 0x08, 0xfb, 0x48, 0x0f, 0x62, 0x86, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, + 0x50, 0xfd, 0x46, 0x2b, 0x18, 0xb9, 0x58, 0xc1, 0x36, 0x08, 0xcd, 0x63, 0xe4, 0x62, 0x83, 0x28, + 0x11, 0x32, 0x23, 0xc6, 0x38, 0x4c, 0xd7, 0x4a, 0x99, 0x93, 0xac, 0x0f, 0xe2, 0x1f, 0x25, 0xe5, + 0xa6, 0xcb, 0x4f, 0x26, 0x33, 0xc9, 0x0a, 0x49, 0xeb, 0x27, 0xe7, 0x17, 0xe7, 0xe6, 0x17, 0xeb, + 0xe7, 0x66, 0xe6, 0x95, 0xc0, 0x83, 0x0c, 0xe2, 0x54, 0x27, 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, + 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, + 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0xac, 0xc0, 0x12, 0xe0, 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, + 0x6c, 0xe0, 0xd0, 0x35, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xf8, 0x2d, 0x7d, 0x23, 0x02, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -145,7 +157,7 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { // Params returns the total set of minting parameters. - Power(ctx context.Context, in *QueryPowerRequest, opts ...grpc.CallOption) (*QueryPowerResponse, error) + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) } type queryClient struct { @@ -156,9 +168,9 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Power(ctx context.Context, in *QueryPowerRequest, opts ...grpc.CallOption) (*QueryPowerResponse, error) { - out := new(QueryPowerResponse) - err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Query/Power", in, out, opts...) +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Query/Params", in, out, opts...) if err != nil { return nil, err } @@ -168,35 +180,35 @@ func (c *queryClient) Power(ctx context.Context, in *QueryPowerRequest, opts ... // QueryServer is the server API for Query service. type QueryServer interface { // Params returns the total set of minting parameters. - Power(context.Context, *QueryPowerRequest) (*QueryPowerResponse, error) + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Power(ctx context.Context, req *QueryPowerRequest) (*QueryPowerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Power not implemented") +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Power_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryPowerRequest) +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Power(ctx, in) + return srv.(QueryServer).Params(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/centauri.stakingmiddleware.v1beta1.Query/Power", + FullMethod: "/centauri.stakingmiddleware.v1beta1.Query/Params", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Power(ctx, req.(*QueryPowerRequest)) + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) } return interceptor(ctx, in, info, handler) } @@ -206,15 +218,15 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Power", - Handler: _Query_Power_Handler, + MethodName: "Params", + Handler: _Query_Params_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "centauri/stakingmiddleware/v1beta1/query.proto", } -func (m *QueryPowerRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -224,12 +236,12 @@ func (m *QueryPowerRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPowerRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -237,7 +249,7 @@ func (m *QueryPowerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryPowerResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryParamsResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -247,16 +259,26 @@ func (m *QueryPowerResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryPowerResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryParamsResponse) 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 = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa return len(dAtA) - i, nil } @@ -271,7 +293,7 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *QueryPowerRequest) Size() (n int) { +func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 } @@ -280,12 +302,14 @@ func (m *QueryPowerRequest) Size() (n int) { return n } -func (m *QueryPowerResponse) Size() (n int) { +func (m *QueryParamsResponse) Size() (n int) { if m == nil { return 0 } var l int _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) return n } @@ -295,7 +319,7 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *QueryPowerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -318,10 +342,10 @@ func (m *QueryPowerRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPowerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPowerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -345,7 +369,7 @@ func (m *QueryPowerRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryPowerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -368,12 +392,45 @@ func (m *QueryPowerResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryPowerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + 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 ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + 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 := skipQuery(dAtA[iNdEx:]) diff --git a/x/stakingmiddleware/types/query.pb.gw.go b/x/stakingmiddleware/types/query.pb.gw.go index fdb182ad2..e7c79699d 100644 --- a/x/stakingmiddleware/types/query.pb.gw.go +++ b/x/stakingmiddleware/types/query.pb.gw.go @@ -33,20 +33,20 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Power_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPowerRequest +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := client.Power(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Power_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryPowerRequest +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := server.Power(ctx, &protoReq) + msg, err := server.Params(ctx, &protoReq) return msg, metadata, err } @@ -57,7 +57,7 @@ func local_request_Query_Power_0(ctx context.Context, marshaler runtime.Marshale // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Power_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -68,7 +68,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Power_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -76,7 +76,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Power_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -121,7 +121,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Power_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -130,14 +130,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Power_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Power_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -145,9 +145,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Power_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "stakingmiddleware", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "mint", "v1beta1", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( - forward_Query_Power_0 = runtime.ForwardResponseMessage + forward_Query_Params_0 = runtime.ForwardResponseMessage ) diff --git a/x/stakingmiddleware/types/stakingmiddleware.pb.go b/x/stakingmiddleware/types/stakingmiddleware.pb.go new file mode 100644 index 000000000..3b872272e --- /dev/null +++ b/x/stakingmiddleware/types/stakingmiddleware.pb.go @@ -0,0 +1,1423 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + 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 + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +type Delegation struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *Delegation) Reset() { *m = Delegation{} } +func (m *Delegation) String() string { return proto.CompactTextString(m) } +func (*Delegation) ProtoMessage() {} +func (*Delegation) Descriptor() ([]byte, []int) { + return fileDescriptor_b3eb4aece69e048d, []int{0} +} +func (m *Delegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Delegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Delegation.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 *Delegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_Delegation.Merge(m, src) +} +func (m *Delegation) XXX_Size() int { + return m.Size() +} +func (m *Delegation) XXX_DiscardUnknown() { + xxx_messageInfo_Delegation.DiscardUnknown(m) +} + +var xxx_messageInfo_Delegation proto.InternalMessageInfo + +// BeginRedelegate defines a SDK message for performing a begin redelegation of coins +// from a delegator to a validator. +type BeginRedelegate struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorSrcAddress string `protobuf:"bytes,2,opt,name=validator_src_address,json=validatorSrcAddress,proto3" json:"validator_src_address,omitempty"` + ValidatorDstAddress string `protobuf:"bytes,3,opt,name=validator_dst_address,json=validatorDstAddress,proto3" json:"validator_dst_address,omitempty"` + Amount types.Coin `protobuf:"bytes,4,opt,name=amount,proto3" json:"amount"` +} + +func (m *BeginRedelegate) Reset() { *m = BeginRedelegate{} } +func (m *BeginRedelegate) String() string { return proto.CompactTextString(m) } +func (*BeginRedelegate) ProtoMessage() {} +func (*BeginRedelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_b3eb4aece69e048d, []int{1} +} +func (m *BeginRedelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BeginRedelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BeginRedelegate.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 *BeginRedelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_BeginRedelegate.Merge(m, src) +} +func (m *BeginRedelegate) XXX_Size() int { + return m.Size() +} +func (m *BeginRedelegate) XXX_DiscardUnknown() { + xxx_messageInfo_BeginRedelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_BeginRedelegate proto.InternalMessageInfo + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +type Undelegate struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` +} + +func (m *Undelegate) Reset() { *m = Undelegate{} } +func (m *Undelegate) String() string { return proto.CompactTextString(m) } +func (*Undelegate) ProtoMessage() {} +func (*Undelegate) Descriptor() ([]byte, []int) { + return fileDescriptor_b3eb4aece69e048d, []int{2} +} +func (m *Undelegate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Undelegate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Undelegate.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 *Undelegate) XXX_Merge(src proto.Message) { + xxx_messageInfo_Undelegate.Merge(m, src) +} +func (m *Undelegate) XXX_Size() int { + return m.Size() +} +func (m *Undelegate) XXX_DiscardUnknown() { + xxx_messageInfo_Undelegate.DiscardUnknown(m) +} + +var xxx_messageInfo_Undelegate proto.InternalMessageInfo + +// MsgDelegate defines a SDK message for performing a delegation of coins +// from a delegator to a validator. +type CancelUnbondingDelegation struct { + DelegatorAddress string `protobuf:"bytes,1,opt,name=delegator_address,json=delegatorAddress,proto3" json:"delegator_address,omitempty"` + ValidatorAddress string `protobuf:"bytes,2,opt,name=validator_address,json=validatorAddress,proto3" json:"validator_address,omitempty"` + Amount types.Coin `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount"` + CreationHeight int64 `protobuf:"varint,4,opt,name=creation_height,json=creationHeight,proto3" json:"creation_height,omitempty"` +} + +func (m *CancelUnbondingDelegation) Reset() { *m = CancelUnbondingDelegation{} } +func (m *CancelUnbondingDelegation) String() string { return proto.CompactTextString(m) } +func (*CancelUnbondingDelegation) ProtoMessage() {} +func (*CancelUnbondingDelegation) Descriptor() ([]byte, []int) { + return fileDescriptor_b3eb4aece69e048d, []int{3} +} +func (m *CancelUnbondingDelegation) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *CancelUnbondingDelegation) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_CancelUnbondingDelegation.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 *CancelUnbondingDelegation) XXX_Merge(src proto.Message) { + xxx_messageInfo_CancelUnbondingDelegation.Merge(m, src) +} +func (m *CancelUnbondingDelegation) XXX_Size() int { + return m.Size() +} +func (m *CancelUnbondingDelegation) XXX_DiscardUnknown() { + xxx_messageInfo_CancelUnbondingDelegation.DiscardUnknown(m) +} + +var xxx_messageInfo_CancelUnbondingDelegation proto.InternalMessageInfo + +// Params holds parameters for the stakingmiddleware module. +type Params struct { + // expected blocks per year + BlocksPerEpoch uint64 `protobuf:"varint,1,opt,name=blocks_per_epoch,json=blocksPerEpoch,proto3" json:"blocks_per_epoch,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_b3eb4aece69e048d, []int{4} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetBlocksPerEpoch() uint64 { + if m != nil { + return m.BlocksPerEpoch + } + return 0 +} + +func init() { + proto.RegisterType((*Delegation)(nil), "centauri.stakingmiddleware.v1beta1.Delegation") + proto.RegisterType((*BeginRedelegate)(nil), "centauri.stakingmiddleware.v1beta1.BeginRedelegate") + proto.RegisterType((*Undelegate)(nil), "centauri.stakingmiddleware.v1beta1.Undelegate") + proto.RegisterType((*CancelUnbondingDelegation)(nil), "centauri.stakingmiddleware.v1beta1.CancelUnbondingDelegation") + proto.RegisterType((*Params)(nil), "centauri.stakingmiddleware.v1beta1.Params") +} + +func init() { + proto.RegisterFile("centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto", fileDescriptor_b3eb4aece69e048d) +} + +var fileDescriptor_b3eb4aece69e048d = []byte{ + // 529 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x95, 0x4f, 0x6b, 0x13, 0x41, + 0x00, 0xc5, 0x77, 0x93, 0x12, 0xe8, 0x08, 0xfd, 0x13, 0xab, 0x26, 0x05, 0x37, 0x65, 0x2f, 0x0d, + 0x81, 0x66, 0x49, 0x7b, 0x32, 0x7a, 0xd0, 0xb4, 0x05, 0x11, 0x85, 0xb2, 0xa5, 0x17, 0x2f, 0xcb, + 0xec, 0xce, 0x30, 0x19, 0xb2, 0x3b, 0x13, 0x66, 0xa6, 0x51, 0xaf, 0x9e, 0xc4, 0x93, 0x20, 0xde, + 0x7b, 0xf4, 0x98, 0x83, 0x1f, 0xa2, 0xc7, 0xe2, 0xc9, 0x83, 0x88, 0x24, 0x87, 0xf8, 0x01, 0xfc, + 0x00, 0xb2, 0x3b, 0x93, 0x84, 0x98, 0x4a, 0x8a, 0xf4, 0x20, 0x5e, 0x76, 0x77, 0xde, 0x9b, 0xf7, + 0x98, 0xf9, 0x31, 0xbb, 0x0b, 0x9a, 0x11, 0x66, 0x0a, 0x9e, 0x0a, 0xea, 0x49, 0x05, 0x3b, 0x94, + 0x91, 0x84, 0x22, 0x14, 0xe3, 0x17, 0x50, 0x60, 0xaf, 0xd7, 0x08, 0xb1, 0x82, 0x8d, 0x79, 0xa7, + 0xde, 0x15, 0x5c, 0xf1, 0xa2, 0x3b, 0xce, 0xd6, 0xe7, 0x67, 0x98, 0xec, 0xe6, 0x06, 0xe1, 0x84, + 0x67, 0xd3, 0xbd, 0xf4, 0x49, 0x27, 0x37, 0xcb, 0x11, 0x97, 0x09, 0x97, 0x81, 0x36, 0xf4, 0xc0, + 0x58, 0x8e, 0x1e, 0x79, 0x21, 0x94, 0xd3, 0x15, 0x44, 0x9c, 0x32, 0xe3, 0xaf, 0xc3, 0x84, 0x32, + 0xee, 0x65, 0x57, 0x23, 0xdd, 0x31, 0x91, 0x44, 0x12, 0xaf, 0xd7, 0x48, 0x6f, 0xda, 0x70, 0xdf, + 0xe7, 0x00, 0x38, 0xc0, 0x31, 0x26, 0x50, 0x51, 0xce, 0x8a, 0x87, 0x60, 0x1d, 0xe9, 0x11, 0x17, + 0x01, 0x44, 0x48, 0x60, 0x29, 0x4b, 0xf6, 0x96, 0x5d, 0x5d, 0x6e, 0x95, 0x3e, 0x7f, 0xda, 0xd9, + 0x30, 0xeb, 0x78, 0xa4, 0x9d, 0x63, 0x25, 0x28, 0x23, 0xfe, 0xda, 0x24, 0x62, 0xf4, 0xb4, 0xa6, + 0x07, 0x63, 0x8a, 0x66, 0x6a, 0x72, 0x8b, 0x6a, 0x26, 0x91, 0x71, 0xcd, 0x03, 0x50, 0x80, 0x09, + 0x3f, 0x65, 0xaa, 0x94, 0xdf, 0xb2, 0xab, 0x37, 0x76, 0xcb, 0x75, 0x13, 0x4c, 0x77, 0x3e, 0xe6, + 0x57, 0xdf, 0xe7, 0x94, 0xb5, 0x96, 0xcf, 0xbf, 0x55, 0xac, 0x8f, 0xa3, 0x7e, 0xcd, 0xf6, 0x4d, + 0xa6, 0x79, 0xef, 0xcd, 0x59, 0xc5, 0xfa, 0x71, 0x56, 0xb1, 0x5e, 0x8f, 0xfa, 0xb5, 0xf9, 0x6d, + 0xbd, 0x1d, 0xf5, 0x6b, 0xb7, 0x75, 0xdf, 0x8e, 0x44, 0x1d, 0xef, 0x99, 0x24, 0x06, 0x04, 0x76, + 0x7f, 0xe6, 0xc0, 0x6a, 0x0b, 0x13, 0xca, 0x7c, 0x6c, 0x72, 0xf8, 0xba, 0xd0, 0x3c, 0x05, 0xb7, + 0xa6, 0x68, 0xa4, 0x88, 0xae, 0x8c, 0xe7, 0xe6, 0x24, 0x76, 0x2c, 0xa2, 0x4b, 0xdb, 0x90, 0x54, + 0x93, 0xb6, 0xfc, 0x95, 0xdb, 0x0e, 0xa4, 0x9a, 0xe7, 0xbd, 0xf4, 0x17, 0xbc, 0x1f, 0x2e, 0xe6, + 0x7d, 0x77, 0x96, 0xf7, 0x6f, 0x88, 0xdd, 0x0f, 0x39, 0x00, 0x4e, 0xd8, 0x75, 0x13, 0xff, 0x27, + 0x0e, 0xe3, 0xfd, 0xc5, 0x70, 0x4a, 0xb3, 0x70, 0xa6, 0x20, 0xdc, 0xaf, 0x39, 0x50, 0xde, 0x87, + 0x2c, 0xc2, 0xf1, 0x09, 0x0b, 0x39, 0x43, 0x94, 0x91, 0xff, 0xf3, 0x9d, 0x2d, 0x6e, 0x83, 0xd5, + 0x48, 0xe0, 0x6c, 0x5f, 0x41, 0x1b, 0x53, 0xd2, 0xd6, 0x47, 0x31, 0xef, 0xaf, 0x8c, 0xe5, 0xc7, + 0x99, 0xda, 0x7c, 0xb2, 0x98, 0xe7, 0xf6, 0x2c, 0xcf, 0x3f, 0x02, 0x74, 0x77, 0x41, 0xe1, 0x08, + 0x0a, 0x98, 0xc8, 0x62, 0x15, 0xac, 0x85, 0x31, 0x8f, 0x3a, 0x32, 0xe8, 0x62, 0x11, 0xe0, 0x2e, + 0x8f, 0xda, 0x19, 0xc9, 0x25, 0x7f, 0x45, 0xeb, 0x47, 0x58, 0x1c, 0xa6, 0x6a, 0x6b, 0xef, 0x7c, + 0xe0, 0xd8, 0x17, 0x03, 0xc7, 0xfe, 0x3e, 0x70, 0xec, 0x77, 0x43, 0xc7, 0xba, 0x18, 0x3a, 0xd6, + 0x97, 0xa1, 0x63, 0x3d, 0x2f, 0xbf, 0xbc, 0xe4, 0x3f, 0xa1, 0x5e, 0x75, 0xb1, 0x0c, 0x0b, 0xd9, + 0x37, 0x77, 0xef, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6c, 0xb3, 0x16, 0xfb, 0x52, 0x06, 0x00, + 0x00, +} + +func (m *Delegation) 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 *Delegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Delegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStakingmiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *BeginRedelegate) 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 *BeginRedelegate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BeginRedelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStakingmiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + if len(m.ValidatorDstAddress) > 0 { + i -= len(m.ValidatorDstAddress) + copy(dAtA[i:], m.ValidatorDstAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.ValidatorDstAddress))) + i-- + dAtA[i] = 0x1a + } + if len(m.ValidatorSrcAddress) > 0 { + i -= len(m.ValidatorSrcAddress) + copy(dAtA[i:], m.ValidatorSrcAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.ValidatorSrcAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Undelegate) 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 *Undelegate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Undelegate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStakingmiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *CancelUnbondingDelegation) 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 *CancelUnbondingDelegation) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *CancelUnbondingDelegation) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CreationHeight != 0 { + i = encodeVarintStakingmiddleware(dAtA, i, uint64(m.CreationHeight)) + i-- + dAtA[i] = 0x20 + } + { + size, err := m.Amount.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintStakingmiddleware(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + if len(m.ValidatorAddress) > 0 { + i -= len(m.ValidatorAddress) + copy(dAtA[i:], m.ValidatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.ValidatorAddress))) + i-- + dAtA[i] = 0x12 + } + if len(m.DelegatorAddress) > 0 { + i -= len(m.DelegatorAddress) + copy(dAtA[i:], m.DelegatorAddress) + i = encodeVarintStakingmiddleware(dAtA, i, uint64(len(m.DelegatorAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlocksPerEpoch != 0 { + i = encodeVarintStakingmiddleware(dAtA, i, uint64(m.BlocksPerEpoch)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func encodeVarintStakingmiddleware(dAtA []byte, offset int, v uint64) int { + offset -= sovStakingmiddleware(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Delegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingmiddleware(uint64(l)) + return n +} + +func (m *BeginRedelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = len(m.ValidatorSrcAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = len(m.ValidatorDstAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingmiddleware(uint64(l)) + return n +} + +func (m *Undelegate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingmiddleware(uint64(l)) + return n +} + +func (m *CancelUnbondingDelegation) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.DelegatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = len(m.ValidatorAddress) + if l > 0 { + n += 1 + l + sovStakingmiddleware(uint64(l)) + } + l = m.Amount.Size() + n += 1 + l + sovStakingmiddleware(uint64(l)) + if m.CreationHeight != 0 { + n += 1 + sovStakingmiddleware(uint64(m.CreationHeight)) + } + return n +} + +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlocksPerEpoch != 0 { + n += 1 + sovStakingmiddleware(uint64(m.BlocksPerEpoch)) + } + return n +} + +func sovStakingmiddleware(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStakingmiddleware(x uint64) (n int) { + return sovStakingmiddleware(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Delegation) 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 ErrIntOverflowStakingmiddleware + } + 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: Delegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Delegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingmiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingmiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BeginRedelegate) 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 ErrIntOverflowStakingmiddleware + } + 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: BeginRedelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BeginRedelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorSrcAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorSrcAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorDstAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorDstAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingmiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingmiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Undelegate) 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 ErrIntOverflowStakingmiddleware + } + 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: Undelegate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Undelegate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingmiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingmiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *CancelUnbondingDelegation) 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 ErrIntOverflowStakingmiddleware + } + 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: CancelUnbondingDelegation: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: CancelUnbondingDelegation: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DelegatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DelegatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValidatorAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + 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 ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValidatorAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthStakingmiddleware + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthStakingmiddleware + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Amount.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreationHeight", wireType) + } + m.CreationHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreationHeight |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipStakingmiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingmiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Params) 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 ErrIntOverflowStakingmiddleware + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field BlocksPerEpoch", wireType) + } + m.BlocksPerEpoch = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingmiddleware + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.BlocksPerEpoch |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipStakingmiddleware(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingmiddleware + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStakingmiddleware(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, ErrIntOverflowStakingmiddleware + } + 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, ErrIntOverflowStakingmiddleware + } + 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, ErrIntOverflowStakingmiddleware + } + 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, ErrInvalidLengthStakingmiddleware + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStakingmiddleware + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStakingmiddleware + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStakingmiddleware = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStakingmiddleware = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStakingmiddleware = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/stakingmiddleware/types/tx.pb.go b/x/stakingmiddleware/types/tx.pb.go index 56c79d309..a3f3ad136 100644 --- a/x/stakingmiddleware/types/tx.pb.go +++ b/x/stakingmiddleware/types/tx.pb.go @@ -31,25 +31,31 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgSetPower is the Msg/SetPower request type. +// MsgUpdateParams is the Msg/UpdateParams request type. // // Since: cosmos-sdk 0.47 -type MsgSetPower struct { - FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"` -} - -func (m *MsgSetPower) Reset() { *m = MsgSetPower{} } -func (m *MsgSetPower) String() string { return proto.CompactTextString(m) } -func (*MsgSetPower) ProtoMessage() {} -func (*MsgSetPower) Descriptor() ([]byte, []int) { +type MsgUpdateEpochParams struct { + // authority is the address that controls the module (defaults to x/gov unless + // overwritten). + Authority string `protobuf:"bytes,1,opt,name=authority,proto3" json:"authority,omitempty"` + // params defines the x/stakingmiddleware parameters to update. + // + // NOTE: All parameters must be supplied. + Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"` +} + +func (m *MsgUpdateEpochParams) Reset() { *m = MsgUpdateEpochParams{} } +func (m *MsgUpdateEpochParams) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateEpochParams) ProtoMessage() {} +func (*MsgUpdateEpochParams) Descriptor() ([]byte, []int) { return fileDescriptor_d15665ac9877b062, []int{0} } -func (m *MsgSetPower) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateEpochParams) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateEpochParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetPower.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateEpochParams.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -59,44 +65,51 @@ func (m *MsgSetPower) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *MsgSetPower) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetPower.Merge(m, src) +func (m *MsgUpdateEpochParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateEpochParams.Merge(m, src) } -func (m *MsgSetPower) XXX_Size() int { +func (m *MsgUpdateEpochParams) XXX_Size() int { return m.Size() } -func (m *MsgSetPower) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetPower.DiscardUnknown(m) +func (m *MsgUpdateEpochParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateEpochParams.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetPower proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateEpochParams proto.InternalMessageInfo -func (m *MsgSetPower) GetFromAddress() string { +func (m *MsgUpdateEpochParams) GetAuthority() string { if m != nil { - return m.FromAddress + return m.Authority } return "" } -// MsgSetPowerResponse defines the response structure for executing a -// MsgSetPower message. +func (m *MsgUpdateEpochParams) 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 MsgSetPowerResponse struct { +type MsgUpdateParamsEpochResponse struct { } -func (m *MsgSetPowerResponse) Reset() { *m = MsgSetPowerResponse{} } -func (m *MsgSetPowerResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSetPowerResponse) ProtoMessage() {} -func (*MsgSetPowerResponse) Descriptor() ([]byte, []int) { +func (m *MsgUpdateParamsEpochResponse) Reset() { *m = MsgUpdateParamsEpochResponse{} } +func (m *MsgUpdateParamsEpochResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateParamsEpochResponse) ProtoMessage() {} +func (*MsgUpdateParamsEpochResponse) Descriptor() ([]byte, []int) { return fileDescriptor_d15665ac9877b062, []int{1} } -func (m *MsgSetPowerResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateParamsEpochResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSetPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateParamsEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSetPowerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateParamsEpochResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -106,21 +119,21 @@ func (m *MsgSetPowerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *MsgSetPowerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSetPowerResponse.Merge(m, src) +func (m *MsgUpdateParamsEpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsEpochResponse.Merge(m, src) } -func (m *MsgSetPowerResponse) XXX_Size() int { +func (m *MsgUpdateParamsEpochResponse) XXX_Size() int { return m.Size() } -func (m *MsgSetPowerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSetPowerResponse.DiscardUnknown(m) +func (m *MsgUpdateParamsEpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsEpochResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSetPowerResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateParamsEpochResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSetPower)(nil), "centauri.stakingmiddleware.v1beta1.MsgSetPower") - proto.RegisterType((*MsgSetPowerResponse)(nil), "centauri.stakingmiddleware.v1beta1.MsgSetPowerResponse") + proto.RegisterType((*MsgUpdateEpochParams)(nil), "centauri.stakingmiddleware.v1beta1.MsgUpdateEpochParams") + proto.RegisterType((*MsgUpdateParamsEpochResponse)(nil), "centauri.stakingmiddleware.v1beta1.MsgUpdateParamsEpochResponse") } func init() { @@ -128,7 +141,7 @@ func init() { } var fileDescriptor_d15665ac9877b062 = []byte{ - // 267 bytes of a gzipped FileDescriptorProto + // 360 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x4e, 0x4e, 0xcd, 0x2b, 0x49, 0x2c, 0x2d, 0xca, 0xd4, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0xcf, 0xcd, 0x4c, 0x49, 0xc9, 0x49, 0x2d, 0x4f, 0x2c, 0x4a, 0xd5, 0x2f, 0x33, 0x4c, 0x4a, 0x2d, 0x49, 0x34, 0xd4, 0x2f, @@ -136,16 +149,22 @@ var fileDescriptor_d15665ac9877b062 = []byte{ 0x55, 0x2c, 0x25, 0x9e, 0x9c, 0x5f, 0x9c, 0x9b, 0x5f, 0xac, 0x9f, 0x5b, 0x9c, 0xae, 0x5f, 0x66, 0x08, 0xa2, 0x20, 0x9a, 0xa5, 0x04, 0x13, 0x73, 0x33, 0xf3, 0xf2, 0xf5, 0xc1, 0x24, 0x54, 0x48, 0x24, 0x3d, 0x3f, 0x3d, 0x1f, 0xcc, 0xd4, 0x07, 0xb1, 0xa0, 0xa2, 0x92, 0x10, 0x13, 0xe2, 0x21, - 0x12, 0x10, 0x0e, 0x44, 0x4a, 0xc9, 0x80, 0x8b, 0xdb, 0xb7, 0x38, 0x3d, 0x38, 0xb5, 0x24, 0x20, - 0xbf, 0x3c, 0xb5, 0x48, 0x48, 0x91, 0x8b, 0x27, 0xad, 0x28, 0x3f, 0x37, 0x3e, 0x31, 0x25, 0xa5, - 0x28, 0xb5, 0xb8, 0x58, 0x82, 0x51, 0x81, 0x51, 0x83, 0x33, 0x88, 0x1b, 0x24, 0xe6, 0x08, 0x11, - 0x52, 0x12, 0xe5, 0x12, 0x46, 0xd2, 0x11, 0x94, 0x5a, 0x5c, 0x90, 0x9f, 0x57, 0x9c, 0x6a, 0xd4, - 0xc4, 0xc8, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0x54, 0xc2, 0xc5, 0x01, 0x37, 0x4d, 0x5f, 0x8f, 0xb0, - 0xf7, 0xf4, 0x90, 0x0c, 0x93, 0x32, 0x27, 0x51, 0x03, 0xcc, 0x76, 0x29, 0xd6, 0x86, 0xe7, 0x1b, - 0xb4, 0x18, 0x9d, 0x8c, 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, 0xb2, - 0x02, 0x4b, 0x74, 0x94, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x43, 0xc2, 0x18, 0x10, 0x00, - 0x00, 0xff, 0xff, 0x23, 0x35, 0xc7, 0x70, 0xb9, 0x01, 0x00, 0x00, + 0x12, 0x10, 0x0e, 0x54, 0xca, 0x8a, 0x08, 0xd7, 0x62, 0x3a, 0x0d, 0xac, 0x57, 0xe9, 0x1e, 0x23, + 0x97, 0x88, 0x6f, 0x71, 0x7a, 0x68, 0x41, 0x4a, 0x62, 0x49, 0xaa, 0x6b, 0x41, 0x7e, 0x72, 0x46, + 0x40, 0x62, 0x51, 0x62, 0x6e, 0xb1, 0x90, 0x19, 0x17, 0x67, 0x62, 0x69, 0x49, 0x46, 0x7e, 0x51, + 0x66, 0x49, 0xa5, 0x04, 0xa3, 0x02, 0xa3, 0x06, 0xa7, 0x93, 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, + 0x9b, 0x1d, 0x53, 0x52, 0x8a, 0x52, 0x8b, 0x8b, 0x83, 0x4b, 0x8a, 0x32, 0xf3, 0xd2, 0x83, 0x10, + 0x4a, 0x85, 0x7c, 0xb9, 0xd8, 0x0a, 0xc0, 0x26, 0x48, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x1b, 0x69, + 0xe9, 0x11, 0x0e, 0x1e, 0x3d, 0x88, 0x9d, 0x4e, 0x9c, 0x27, 0xee, 0xc9, 0x33, 0xac, 0x78, 0xbe, + 0x41, 0x8b, 0x31, 0x08, 0x6a, 0x88, 0x95, 0x7d, 0xd3, 0xf3, 0x0d, 0x5a, 0x08, 0xe3, 0xbb, 0x9e, + 0x6f, 0xd0, 0xd2, 0x81, 0x7b, 0xb7, 0x02, 0x8b, 0x87, 0xe1, 0x9e, 0x81, 0x98, 0xa9, 0x24, 0xc7, + 0x25, 0x83, 0x26, 0x04, 0xf6, 0x65, 0x50, 0x6a, 0x71, 0x41, 0x7e, 0x5e, 0x71, 0xaa, 0xd1, 0x3c, + 0x46, 0x2e, 0x66, 0xdf, 0xe2, 0x74, 0xa1, 0x7e, 0x46, 0x2e, 0x41, 0xcc, 0x50, 0xb0, 0x20, 0xc6, + 0xf5, 0xd8, 0xc2, 0x4f, 0xca, 0x81, 0x24, 0x9d, 0x58, 0x5c, 0x26, 0xc5, 0xda, 0x00, 0x0a, 0x09, + 0x27, 0xe3, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, + 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x92, 0xc4, 0xe6, 0xff, + 0x92, 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xec, 0x1a, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, + 0x89, 0xbf, 0x82, 0x72, 0xc9, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -160,7 +179,7 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { - SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc.CallOption) (*MsgSetPowerResponse, error) + UpdateEpochParams(ctx context.Context, in *MsgUpdateEpochParams, opts ...grpc.CallOption) (*MsgUpdateParamsEpochResponse, error) } type msgClient struct { @@ -171,9 +190,9 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc.CallOption) (*MsgSetPowerResponse, error) { - out := new(MsgSetPowerResponse) - err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Msg/SetPower", in, out, opts...) +func (c *msgClient) UpdateEpochParams(ctx context.Context, in *MsgUpdateEpochParams, opts ...grpc.CallOption) (*MsgUpdateParamsEpochResponse, error) { + out := new(MsgUpdateParamsEpochResponse) + err := c.cc.Invoke(ctx, "/centauri.stakingmiddleware.v1beta1.Msg/UpdateEpochParams", in, out, opts...) if err != nil { return nil, err } @@ -182,35 +201,35 @@ func (c *msgClient) SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc. // MsgServer is the server API for Msg service. type MsgServer interface { - SetPower(context.Context, *MsgSetPower) (*MsgSetPowerResponse, error) + UpdateEpochParams(context.Context, *MsgUpdateEpochParams) (*MsgUpdateParamsEpochResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) SetPower(ctx context.Context, req *MsgSetPower) (*MsgSetPowerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SetPower not implemented") +func (*UnimplementedMsgServer) UpdateEpochParams(ctx context.Context, req *MsgUpdateEpochParams) (*MsgUpdateParamsEpochResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateEpochParams not implemented") } func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } -func _Msg_SetPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSetPower) +func _Msg_UpdateEpochParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateEpochParams) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SetPower(ctx, in) + return srv.(MsgServer).UpdateEpochParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/centauri.stakingmiddleware.v1beta1.Msg/SetPower", + FullMethod: "/centauri.stakingmiddleware.v1beta1.Msg/UpdateEpochParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SetPower(ctx, req.(*MsgSetPower)) + return srv.(MsgServer).UpdateEpochParams(ctx, req.(*MsgUpdateEpochParams)) } return interceptor(ctx, in, info, handler) } @@ -220,15 +239,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "SetPower", - Handler: _Msg_SetPower_Handler, + MethodName: "UpdateEpochParams", + Handler: _Msg_UpdateEpochParams_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "centauri/stakingmiddleware/v1beta1/tx.proto", } -func (m *MsgSetPower) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateEpochParams) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -238,27 +257,37 @@ func (m *MsgSetPower) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetPower) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateEpochParams) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetPower) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateEpochParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.FromAddress) > 0 { - i -= len(m.FromAddress) - copy(dAtA[i:], m.FromAddress) - i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress))) + { + 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 *MsgSetPowerResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateParamsEpochResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -268,12 +297,12 @@ func (m *MsgSetPowerResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSetPowerResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateParamsEpochResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSetPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateParamsEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -292,20 +321,22 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgSetPower) Size() (n int) { +func (m *MsgUpdateEpochParams) Size() (n int) { if m == nil { return 0 } var l int _ = l - l = len(m.FromAddress) + 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 *MsgSetPowerResponse) Size() (n int) { +func (m *MsgUpdateParamsEpochResponse) Size() (n int) { if m == nil { return 0 } @@ -320,7 +351,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgSetPower) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateEpochParams) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -343,15 +374,15 @@ func (m *MsgSetPower) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetPower: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateEpochParams: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetPower: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateEpochParams: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Authority", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -379,7 +410,40 @@ func (m *MsgSetPower) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.FromAddress = string(dAtA[iNdEx:postIndex]) + 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 @@ -402,7 +466,7 @@ func (m *MsgSetPower) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSetPowerResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateParamsEpochResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -425,10 +489,10 @@ func (m *MsgSetPowerResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSetPowerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateParamsEpochResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSetPowerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateParamsEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: