diff --git a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto index 4ff0e83c8..d57da1145 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/genesis.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/genesis.proto @@ -17,9 +17,11 @@ message GenesisState { (gogoproto.nullable) = false ]; + Params params = 2 [ (gogoproto.nullable) = false ]; + // delegations defines the delegations active at genesis. - repeated Delegation delegations = 2 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - repeated BeginRedelegate begindelegations = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - repeated Undelegate undelegates = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; - repeated CancelUnbondingDelegation cancelunbondingdelegations = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated Delegation delegations = 3 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated BeginRedelegate begindelegations = 4 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated Undelegate undelegates = 5 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; + repeated CancelUnbondingDelegation cancelunbondingdelegations = 6 [(gogoproto.nullable) = false, (amino.dont_omitempty) = true]; } diff --git a/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto b/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto index 0038645e4..b427cbef0 100644 --- a/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto +++ b/proto/centauri/stakingmiddleware/v1beta1/stakingmiddleware.proto @@ -69,3 +69,11 @@ message CancelUnbondingDelegation { 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..4d71b6939 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,6 +13,8 @@ option go_package = "x/stakingmiddleware/types"; service Msg { option (cosmos.msg.v1.service) = true; + rpc UpdateEpochParams(MsgUpdateEpochParams) returns (MsgUpdateParamsEpochResponse); + rpc SetPower(MsgSetPower) returns (MsgSetPowerResponse); } @@ -27,3 +30,27 @@ message MsgSetPower { // // Since: cosmos-sdk 0.47 message MsgSetPowerResponse {} + +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +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 ]; +} + +// MsgUpdateParamsResponse defines the response structure for executing a +// MsgUpdateParams message. +// +// Since: cosmos-sdk 0.47 +message MsgUpdateParamsEpochResponse {} diff --git a/x/stakingmiddleware/keeper/genesis.go b/x/stakingmiddleware/keeper/genesis.go index 418884413..ff48282c9 100644 --- a/x/stakingmiddleware/keeper/genesis.go +++ b/x/stakingmiddleware/keeper/genesis.go @@ -8,10 +8,15 @@ 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) + power := keeper.GetLastTotalPower(ctx) + params := keeper.GetParams(ctx) + return types.NewGenesisState(power, params) } diff --git a/x/stakingmiddleware/keeper/keeper.go b/x/stakingmiddleware/keeper/keeper.go index 8bed69c57..5479a2bef 100644 --- a/x/stakingmiddleware/keeper/keeper.go +++ b/x/stakingmiddleware/keeper/keeper.go @@ -1,6 +1,8 @@ package keeper import ( + "fmt" + "github.com/cometbft/cometbft/libs/log" "github.com/notional-labs/composable/v6/x/stakingmiddleware/types" @@ -79,6 +81,35 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // store.Set(kkk, b) // } +// 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", + ) + + } + + 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 +} + // SetLastTotalPower Set the last total validator power. func (k Keeper) SetLastTotalPower(ctx sdk.Context, power sdkmath.Int) { store := ctx.KVStore(k.storeKey) diff --git a/x/stakingmiddleware/keeper/msg_server.go b/x/stakingmiddleware/keeper/msg_server.go index 30afdf83b..523b1610b 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" ) @@ -20,6 +23,20 @@ func NewMsgServerImpl(k Keeper) types.MsgServer { } } +// UpdateParams updates the params. +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.MsgUpdateParamsEpochResponse{}, nil +} + // UpdateParams updates the params. func (ms msgServer) SetPower(goCtx context.Context, req *types.MsgSetPower) (*types.MsgSetPowerResponse, error) { return &types.MsgSetPowerResponse{}, nil diff --git a/x/stakingmiddleware/types/codec.go b/x/stakingmiddleware/types/codec.go index 66b175743..ed9bf475d 100644 --- a/x/stakingmiddleware/types/codec.go +++ b/x/stakingmiddleware/types/codec.go @@ -17,12 +17,14 @@ import ( // 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..7557dfb64 100644 --- a/x/stakingmiddleware/types/genesis.go +++ b/x/stakingmiddleware/types/genesis.go @@ -6,9 +6,10 @@ import ( ) // NewGenesisState creates a new GenesisState object -func NewGenesisState(m math.Int) *GenesisState { +func NewGenesisState(m math.Int, params Params) *GenesisState { return &GenesisState{ LastTotalPower: m, + Params: params, } } @@ -16,6 +17,7 @@ func NewGenesisState(m math.Int) *GenesisState { 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 35177651a..7cb2d3daa 100644 --- a/x/stakingmiddleware/types/genesis.pb.go +++ b/x/stakingmiddleware/types/genesis.pb.go @@ -30,11 +30,12 @@ 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,2,opt,name=params,proto3" json:"params"` // delegations defines the delegations active at genesis. - Delegations []Delegation `protobuf:"bytes,2,rep,name=delegations,proto3" json:"delegations"` - Begindelegations []BeginRedelegate `protobuf:"bytes,3,rep,name=begindelegations,proto3" json:"begindelegations"` - Undelegates []Undelegate `protobuf:"bytes,4,rep,name=undelegates,proto3" json:"undelegates"` - Cancelunbondingdelegations []CancelUnbondingDelegation `protobuf:"bytes,5,rep,name=cancelunbondingdelegations,proto3" json:"cancelunbondingdelegations"` + Delegations []Delegation `protobuf:"bytes,3,rep,name=delegations,proto3" json:"delegations"` + Begindelegations []BeginRedelegate `protobuf:"bytes,4,rep,name=begindelegations,proto3" json:"begindelegations"` + Undelegates []Undelegate `protobuf:"bytes,5,rep,name=undelegates,proto3" json:"undelegates"` + Cancelunbondingdelegations []CancelUnbondingDelegation `protobuf:"bytes,6,rep,name=cancelunbondingdelegations,proto3" json:"cancelunbondingdelegations"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -70,6 +71,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 (m *GenesisState) GetDelegations() []Delegation { if m != nil { return m.Delegations @@ -107,31 +115,33 @@ func init() { } var fileDescriptor_1aa0bd912277c095 = []byte{ - // 382 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x4a, 0xeb, 0x40, - 0x14, 0x86, 0x93, 0xdb, 0xde, 0x0b, 0x37, 0x2d, 0x97, 0xde, 0xe0, 0xa2, 0x76, 0x91, 0x96, 0x2e, - 0xa4, 0x08, 0x4e, 0xac, 0xdd, 0x09, 0x6e, 0xa2, 0x20, 0xee, 0xa4, 0x5a, 0x10, 0x5d, 0x94, 0x49, - 0x72, 0x18, 0xc7, 0x26, 0x33, 0x25, 0x33, 0xb1, 0xfa, 0x06, 0x2e, 0xdd, 0xfa, 0x06, 0x2e, 0x7d, - 0x8c, 0x2e, 0xbb, 0x14, 0x17, 0x45, 0xda, 0x85, 0xaf, 0x21, 0x99, 0xb4, 0x12, 0x68, 0xd1, 0x6c, - 0x92, 0x30, 0xe4, 0xff, 0xbe, 0x73, 0xce, 0x1c, 0x63, 0xd7, 0x03, 0x26, 0x71, 0x1c, 0x51, 0x5b, - 0x48, 0x3c, 0xa0, 0x8c, 0x84, 0xd4, 0xf7, 0x03, 0x18, 0xe1, 0x08, 0xec, 0xdb, 0xb6, 0x0b, 0x12, - 0xb7, 0x6d, 0x02, 0x0c, 0x04, 0x15, 0x68, 0x18, 0x71, 0xc9, 0xcd, 0xe6, 0x32, 0x81, 0x56, 0x12, - 0x68, 0x91, 0xa8, 0x6d, 0x10, 0x4e, 0xb8, 0xfa, 0xdd, 0x4e, 0xbe, 0xd2, 0x64, 0x6d, 0x3f, 0x87, - 0x6b, 0x95, 0x99, 0x66, 0xff, 0xe3, 0x90, 0x32, 0x6e, 0xab, 0x67, 0x7a, 0xd4, 0x7c, 0x2a, 0x1a, - 0xe5, 0xe3, 0xb4, 0xb4, 0x33, 0x89, 0x25, 0x98, 0x17, 0x46, 0x25, 0xc0, 0x42, 0xf6, 0x25, 0x97, -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d6, 0x6c, 0x9f, 0xba, 0x79, 0xf7, 0x8f, 0xda, 0xab, 0xce, - 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3c, 0xc1, 0x1d, 0x94, 0x14, 0x03, 0x00, 0x00, + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xc1, 0x8a, 0xd3, 0x40, + 0x18, 0x80, 0x33, 0x6e, 0x2d, 0x98, 0x2e, 0xb2, 0x06, 0x0f, 0xb1, 0x87, 0x6c, 0xd9, 0x83, 0x94, + 0x05, 0x27, 0xb6, 0xbd, 0x09, 0x5e, 0xa2, 0xa0, 0xde, 0x4a, 0xb4, 0x20, 0x7a, 0x28, 0x93, 0xe4, + 0x67, 0x1c, 0x9b, 0xcc, 0x84, 0xcc, 0xc4, 0xea, 0x1b, 0x78, 0xf4, 0x31, 0x3c, 0xfa, 0x18, 0x3d, + 0xf6, 0x28, 0x1e, 0x8a, 0x34, 0x07, 0x5f, 0x43, 0x66, 0x92, 0x4a, 0xa0, 0xc5, 0xcd, 0xa5, 0x0d, + 0x43, 0xbe, 0xef, 0xcb, 0x3f, 0xfc, 0xf6, 0xe3, 0x18, 0xb8, 0x22, 0x65, 0xc1, 0x7c, 0xa9, 0xc8, + 0x8a, 0x71, 0x9a, 0xb1, 0x24, 0x49, 0x61, 0x4d, 0x0a, 0xf0, 0x3f, 0x4d, 0x22, 0x50, 0x64, 0xe2, + 0x53, 0xe0, 0x20, 0x99, 0xc4, 0x79, 0x21, 0x94, 0x70, 0xae, 0x0e, 0x04, 0x3e, 0x22, 0x70, 0x43, + 0x0c, 0xef, 0x53, 0x41, 0x85, 0x79, 0xdd, 0xd7, 0x4f, 0x35, 0x39, 0x7c, 0xd2, 0xa1, 0x75, 0xec, + 0xac, 0xd9, 0x7b, 0x24, 0x63, 0x5c, 0xf8, 0xe6, 0xb7, 0x3e, 0xba, 0xaa, 0x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0x38, 0x6d, 0xcf, 0xd4, 0x37, 0xb1, 0xa7, 0x5d, 0x62, 0xcf, 0x8c, 0x65, 0x71, 0xb0, 0x9c, + 0xbe, 0xc4, 0xff, 0xb4, 0x82, 0xd9, 0x66, 0xef, 0xa1, 0xed, 0xde, 0x43, 0xbf, 0xf7, 0x1e, 0xfa, + 0x56, 0x79, 0xd6, 0xb6, 0xf2, 0xac, 0x9f, 0x95, 0x67, 0xbd, 0x7b, 0xf0, 0xf9, 0xc4, 0x1e, 0x9b, + 0x1d, 0x8a, 0xfa, 0x66, 0x43, 0x67, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0x66, 0xe2, 0x9b, 0xf3, + 0x5e, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -165,7 +175,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } } if len(m.Undelegates) > 0 { @@ -179,7 +189,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } } if len(m.Begindelegations) > 0 { @@ -193,7 +203,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } } if len(m.Delegations) > 0 { @@ -207,9 +217,19 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) } + i-- + dAtA[i] = 0x12 { size := m.LastTotalPower.Size() i -= size @@ -242,6 +262,8 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.LastTotalPower.Size() n += 1 + l + sovGenesis(uint64(l)) + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) if len(m.Delegations) > 0 { for _, e := range m.Delegations { l = e.Size() @@ -338,6 +360,39 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } 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 ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Delegations", wireType) } @@ -371,7 +426,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Begindelegations", wireType) } @@ -405,7 +460,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Undelegates", wireType) } @@ -439,7 +494,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Cancelunbondingdelegations", wireType) } diff --git a/x/stakingmiddleware/types/keys.go b/x/stakingmiddleware/types/keys.go index f4f334983..0e2edc734 100644 --- a/x/stakingmiddleware/types/keys.go +++ b/x/stakingmiddleware/types/keys.go @@ -11,6 +11,7 @@ var ( BeginRedelegateKey = []byte{0x02} // key for a delegation UndelegateKey = []byte{0x03} // key for a delegation CancelUnbondingDelegationKey = []byte{0x04} // key for a delegation + ParamsKey = []byte{0x05} // key for global staking middleware params in the keeper store ) const ( 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/stakingmiddleware.pb.go b/x/stakingmiddleware/types/stakingmiddleware.pb.go index d89b2e1fa..3b872272e 100644 --- a/x/stakingmiddleware/types/stakingmiddleware.pb.go +++ b/x/stakingmiddleware/types/stakingmiddleware.pb.go @@ -193,11 +193,58 @@ func (m *CancelUnbondingDelegation) XXX_DiscardUnknown() { 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() { @@ -205,38 +252,41 @@ func init() { } var fileDescriptor_b3eb4aece69e048d = []byte{ - // 492 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xb2, 0x4a, 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, 0xc4, 0x94, - 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x52, 0x82, 0xe9, 0xd5, 0xc3, 0x54, 0x01, 0xd5, 0x2b, - 0x25, 0x92, 0x9e, 0x9f, 0x9e, 0x0f, 0x56, 0xae, 0x0f, 0x62, 0x41, 0x74, 0x4a, 0x49, 0x26, 0xe7, - 0x17, 0xe7, 0xe6, 0x17, 0xc7, 0x43, 0x24, 0x20, 0x1c, 0xa8, 0x94, 0x1c, 0x84, 0xa7, 0x9f, 0x94, - 0x58, 0x8c, 0x70, 0x41, 0x72, 0x7e, 0x66, 0x1e, 0x54, 0x5e, 0x30, 0x31, 0x37, 0x33, 0x2f, 0x5f, - 0x1f, 0x4c, 0x42, 0x85, 0xc4, 0xa1, 0x5a, 0x72, 0x8b, 0xd3, 0xf5, 0xcb, 0x0c, 0x41, 0x14, 0x44, - 0x42, 0x69, 0x32, 0x13, 0x17, 0x97, 0x4b, 0x6a, 0x4e, 0x6a, 0x7a, 0x62, 0x49, 0x66, 0x7e, 0x9e, - 0x90, 0x2b, 0x97, 0x60, 0x0a, 0x84, 0x97, 0x5f, 0x14, 0x9f, 0x98, 0x92, 0x52, 0x94, 0x5a, 0x5c, - 0x2c, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xe9, 0x24, 0x71, 0x69, 0x8b, 0xae, 0x08, 0xd4, 0x1d, 0x8e, - 0x10, 0x99, 0xe0, 0x92, 0xa2, 0xcc, 0xbc, 0xf4, 0x20, 0x01, 0xb8, 0x16, 0xa8, 0x38, 0xc8, 0x98, - 0xb2, 0xc4, 0x9c, 0xcc, 0x14, 0x14, 0x63, 0x98, 0x08, 0x19, 0x03, 0xd7, 0x02, 0x33, 0xc6, 0x86, - 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x59, 0x81, 0x51, 0x83, 0xdb, 0x48, 0x52, - 0x0f, 0xaa, 0x11, 0xe4, 0x73, 0x58, 0xf8, 0xe9, 0x39, 0xe7, 0x67, 0xe6, 0x39, 0x71, 0x9e, 0xb8, - 0x27, 0xcf, 0xb0, 0xe2, 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x1e, 0x2b, 0xcb, 0x8e, 0x05, 0xf2, - 0x0c, 0x2f, 0x16, 0xc8, 0x33, 0x34, 0x3d, 0xdf, 0xa0, 0x85, 0xe9, 0xad, 0xae, 0xe7, 0x1b, 0xb4, - 0xc4, 0x20, 0xe6, 0xe9, 0x16, 0xa7, 0x64, 0xeb, 0xfb, 0x16, 0xa7, 0x43, 0x03, 0x22, 0x55, 0xe9, - 0x0b, 0x13, 0x17, 0xbf, 0x53, 0x6a, 0x7a, 0x66, 0x5e, 0x50, 0x2a, 0x54, 0x5f, 0x2a, 0xb5, 0x82, - 0xc6, 0x87, 0x4b, 0x14, 0x11, 0x34, 0xc5, 0x45, 0xc9, 0x44, 0x07, 0x8f, 0x30, 0x5c, 0x5b, 0x70, - 0x51, 0x32, 0x56, 0xd3, 0x52, 0x8a, 0x4b, 0xe0, 0xa6, 0x31, 0x13, 0x6d, 0x9a, 0x4b, 0x71, 0x09, - 0x66, 0x78, 0xb3, 0x90, 0x11, 0xde, 0x0e, 0x84, 0xc3, 0x5b, 0x16, 0x35, 0xbc, 0xd1, 0x82, 0x58, - 0x69, 0x2a, 0x13, 0x17, 0x57, 0x68, 0x1e, 0xb5, 0x43, 0x7c, 0x50, 0x24, 0x46, 0x6b, 0xc2, 0x81, - 0x23, 0x81, 0x1a, 0x38, 0x88, 0x80, 0x50, 0xba, 0xc3, 0xc4, 0x25, 0xe9, 0x9c, 0x98, 0x97, 0x9c, - 0x9a, 0x13, 0x9a, 0x97, 0x94, 0x9f, 0x97, 0x92, 0x99, 0x97, 0x3e, 0x3c, 0xf3, 0xac, 0x90, 0x3a, - 0x17, 0x7f, 0x72, 0x51, 0x2a, 0xd8, 0x5f, 0xf1, 0x19, 0xa9, 0x99, 0xe9, 0x19, 0x90, 0xa4, 0xc8, - 0x1c, 0xc4, 0x07, 0x13, 0xf6, 0x00, 0x8b, 0x5a, 0x79, 0x11, 0x0e, 0x4f, 0x75, 0xd4, 0xf0, 0xc4, - 0x19, 0x80, 0x4e, 0xc6, 0x27, 0x1e, 0xc9, 0x31, 0x5e, 0x78, 0x24, 0xc7, 0xf8, 0xe0, 0x91, 0x1c, - 0xe3, 0x84, 0xc7, 0x72, 0x0c, 0x17, 0x1e, 0xcb, 0x31, 0xdc, 0x78, 0x2c, 0xc7, 0x10, 0x25, 0x59, - 0x81, 0xa5, 0xcc, 0x2f, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0x97, 0x9f, 0xc6, 0x80, 0x00, - 0x00, 0x00, 0xff, 0xff, 0xbb, 0x65, 0x42, 0xc6, 0x1e, 0x06, 0x00, 0x00, + // 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, 0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19, 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) { @@ -439,6 +489,34 @@ func (m *CancelUnbondingDelegation) MarshalToSizedBuffer(dAtA []byte) (int, erro 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 @@ -533,6 +611,18 @@ func (m *CancelUnbondingDelegation) Size() (n int) { 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 } @@ -1178,6 +1268,75 @@ func (m *CancelUnbondingDelegation) Unmarshal(dAtA []byte) error { } 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 diff --git a/x/stakingmiddleware/types/tx.pb.go b/x/stakingmiddleware/types/tx.pb.go index 56c79d309..189e21a45 100644 --- a/x/stakingmiddleware/types/tx.pb.go +++ b/x/stakingmiddleware/types/tx.pb.go @@ -118,9 +118,111 @@ func (m *MsgSetPowerResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetPowerResponse proto.InternalMessageInfo +// MsgUpdateParams is the Msg/UpdateParams request type. +// +// Since: cosmos-sdk 0.47 +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{2} +} +func (m *MsgUpdateEpochParams) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateEpochParams) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateEpochParams.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 *MsgUpdateEpochParams) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateEpochParams.Merge(m, src) +} +func (m *MsgUpdateEpochParams) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateEpochParams) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateEpochParams.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateEpochParams proto.InternalMessageInfo + +func (m *MsgUpdateEpochParams) GetAuthority() string { + if m != nil { + return m.Authority + } + return "" +} + +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 MsgUpdateParamsEpochResponse struct { +} + +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{3} +} +func (m *MsgUpdateParamsEpochResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateParamsEpochResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateParamsEpochResponse.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 *MsgUpdateParamsEpochResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateParamsEpochResponse.Merge(m, src) +} +func (m *MsgUpdateParamsEpochResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateParamsEpochResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateParamsEpochResponse.DiscardUnknown(m) +} + +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 +230,7 @@ func init() { } var fileDescriptor_d15665ac9877b062 = []byte{ - // 267 bytes of a gzipped FileDescriptorProto + // 422 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 +238,26 @@ 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, 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, 0xaa, 0x74, 0x8f, 0x91, 0x4b, 0xc4, 0xb7, 0x38, 0x3d, 0xb4, + 0x20, 0x25, 0xb1, 0x24, 0xd5, 0xb5, 0x20, 0x3f, 0x39, 0x23, 0x20, 0xb1, 0x28, 0x31, 0xb7, 0x58, + 0xc8, 0x8c, 0x8b, 0x33, 0xb1, 0xb4, 0x24, 0x23, 0xbf, 0x28, 0xb3, 0xa4, 0x12, 0x62, 0x9e, 0x93, + 0xc4, 0xa5, 0x2d, 0xba, 0x22, 0x50, 0x2f, 0x40, 0x8d, 0x0d, 0x2e, 0x29, 0xca, 0xcc, 0x4b, 0x0f, + 0x42, 0x28, 0x15, 0xf2, 0xe5, 0x62, 0x2b, 0x00, 0x9b, 0x20, 0xc1, 0xa4, 0xc0, 0xa8, 0xc1, 0x6d, + 0xa4, 0xa5, 0x47, 0x38, 0x9c, 0xf5, 0x20, 0x76, 0x3a, 0x71, 0x9e, 0xb8, 0x27, 0xcf, 0xb0, 0xe2, + 0xf9, 0x06, 0x2d, 0xc6, 0x20, 0xa8, 0x21, 0x56, 0xf6, 0x4d, 0xcf, 0x37, 0x68, 0x21, 0x8c, 0xef, + 0x7a, 0xbe, 0x41, 0x4b, 0x07, 0x1e, 0x6e, 0x15, 0x58, 0x42, 0x0e, 0xee, 0x19, 0x88, 0x99, 0x4a, + 0x72, 0x5c, 0x32, 0x68, 0x42, 0x60, 0x5f, 0xc2, 0x02, 0xc0, 0x68, 0x0a, 0x13, 0x17, 0xb3, 0x6f, + 0x71, 0xba, 0x50, 0x3f, 0x23, 0x97, 0x20, 0x66, 0x28, 0x58, 0x10, 0xe3, 0x7a, 0x6c, 0xe1, 0x27, + 0xe5, 0x40, 0x92, 0x4e, 0x2c, 0x2e, 0x13, 0x2a, 0xe1, 0xe2, 0x80, 0x47, 0xb0, 0x3e, 0x91, 0xa6, + 0xc1, 0x34, 0x48, 0x99, 0x93, 0xa8, 0x01, 0x66, 0xab, 0x14, 0x6b, 0x03, 0x28, 0xfc, 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, 0x12, 0x5b, 0xa8, 0x97, 0x54, + 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x13, 0xa7, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x78, 0x25, + 0x34, 0xad, 0x88, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -160,6 +272,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 { + UpdateEpochParams(ctx context.Context, in *MsgUpdateEpochParams, opts ...grpc.CallOption) (*MsgUpdateParamsEpochResponse, error) SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc.CallOption) (*MsgSetPowerResponse, error) } @@ -171,6 +284,15 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +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 + } + return out, nil +} + 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...) @@ -182,6 +304,7 @@ func (c *msgClient) SetPower(ctx context.Context, in *MsgSetPower, opts ...grpc. // MsgServer is the server API for Msg service. type MsgServer interface { + UpdateEpochParams(context.Context, *MsgUpdateEpochParams) (*MsgUpdateParamsEpochResponse, error) SetPower(context.Context, *MsgSetPower) (*MsgSetPowerResponse, error) } @@ -189,6 +312,9 @@ type MsgServer interface { type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) UpdateEpochParams(ctx context.Context, req *MsgUpdateEpochParams) (*MsgUpdateParamsEpochResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateEpochParams not implemented") +} func (*UnimplementedMsgServer) SetPower(ctx context.Context, req *MsgSetPower) (*MsgSetPowerResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SetPower not implemented") } @@ -197,6 +323,24 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +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).UpdateEpochParams(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/centauri.stakingmiddleware.v1beta1.Msg/UpdateEpochParams", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateEpochParams(ctx, req.(*MsgUpdateEpochParams)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SetPower_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSetPower) if err := dec(in); err != nil { @@ -219,6 +363,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "centauri.stakingmiddleware.v1beta1.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ + { + MethodName: "UpdateEpochParams", + Handler: _Msg_UpdateEpochParams_Handler, + }, { MethodName: "SetPower", Handler: _Msg_SetPower_Handler, @@ -281,6 +429,69 @@ func (m *MsgSetPowerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *MsgUpdateEpochParams) 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 *MsgUpdateEpochParams) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateEpochParams) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.Authority) > 0 { + i -= len(m.Authority) + copy(dAtA[i:], m.Authority) + i = encodeVarintTx(dAtA, i, uint64(len(m.Authority))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateParamsEpochResponse) 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 *MsgUpdateParamsEpochResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateParamsEpochResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -314,6 +525,30 @@ func (m *MsgSetPowerResponse) Size() (n int) { return n } +func (m *MsgUpdateEpochParams) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Authority) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.Params.Size() + n += 1 + l + sovTx(uint64(l)) + return n +} + +func (m *MsgUpdateParamsEpochResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -452,6 +687,171 @@ func (m *MsgSetPowerResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgUpdateEpochParams) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateEpochParams: wiretype end group for non-group") + } + if fieldNum <= 0 { + 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 Authority", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Authority = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateParamsEpochResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgUpdateParamsEpochResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateParamsEpochResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0