From f11bd885092ca86e64aec7543c4b388d3ede1d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20Martini=C4=87?= Date: Fri, 5 Aug 2022 11:29:00 +0200 Subject: [PATCH] Receive keep alive messages from pigeon #387 --- proto/valset/params.proto | 1 - proto/valset/query.proto | 18 + proto/valset/tx.proto | 8 + util/keeper/iter.go | 10 + x/consensus/keeper/msg_server.go | 4 + x/consensus/keeper/msg_server_add_evidence.go | 5 + .../msg_server_set_public_access_data.go | 4 + x/consensus/types/expected_keepers.go | 1 + .../types/mocks/QueuedSignedMessageI.go | 32 +- x/consensus/types/mocks/ValsetKeeper.go | 14 + x/consensus/types/query.pb.gw.go | 18 + x/evm/types/expected_keepers.go | 1 + x/evm/types/mocks/ValsetKeeper.go | 14 + x/valset/client/cli/query.go | 2 + .../cli/query_get_validator_alive_until.go | 42 ++ x/valset/client/cli/tx.go | 1 + x/valset/client/cli/tx_keep_alive.go | 40 ++ x/valset/handler.go | 3 + x/valset/keeper/errors.go | 1 + .../grpc_query_get_validator_alive_until.go | 27 + x/valset/keeper/keep_alive.go | 114 +++++ x/valset/keeper/keep_alive_test.go | 44 ++ x/valset/keeper/keeper.go | 18 - x/valset/keeper/keeper_test.go | 20 +- ...r_add_external_chain_info_for_validator.go | 4 + x/valset/keeper/msg_server_keep_alive.go | 21 + x/valset/keeper/setup_test.go | 2 +- x/valset/module.go | 6 + x/valset/module_simulation.go | 15 + x/valset/simulation/keep_alive.go | 29 ++ x/valset/types/codec.go | 4 + x/valset/types/expected_keepers.go | 1 + x/valset/types/message_keep_alive.go | 45 ++ x/valset/types/message_keep_alive_test.go | 40 ++ x/valset/types/mocks/StakingKeeper.go | 5 + x/valset/types/query.pb.go | 464 ++++++++++++++++-- x/valset/types/query.pb.gw.go | 65 +++ x/valset/types/tx.pb.go | 346 ++++++++++++- 38 files changed, 1423 insertions(+), 66 deletions(-) create mode 100644 x/valset/client/cli/query_get_validator_alive_until.go create mode 100644 x/valset/client/cli/tx_keep_alive.go create mode 100644 x/valset/keeper/grpc_query_get_validator_alive_until.go create mode 100644 x/valset/keeper/keep_alive.go create mode 100644 x/valset/keeper/keep_alive_test.go create mode 100644 x/valset/keeper/msg_server_keep_alive.go create mode 100644 x/valset/simulation/keep_alive.go create mode 100644 x/valset/types/message_keep_alive.go create mode 100644 x/valset/types/message_keep_alive_test.go diff --git a/proto/valset/params.proto b/proto/valset/params.proto index 41141d84..c836f809 100644 --- a/proto/valset/params.proto +++ b/proto/valset/params.proto @@ -8,5 +8,4 @@ option go_package = "github.com/palomachain/paloma/x/valset/types"; // Params defines the parameters for the module. message Params { option (gogoproto.goproto_stringer) = false; - } diff --git a/proto/valset/query.proto b/proto/valset/query.proto index 29eba708..561f33af 100644 --- a/proto/valset/query.proto +++ b/proto/valset/query.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "valset/params.proto"; import "valset/snapshot.proto"; +import "google/protobuf/timestamp.proto"; // this line is used by starport scaffolding # 1 option go_package = "github.com/palomachain/paloma/x/valset/types"; @@ -26,6 +27,11 @@ service Query { option (google.api.http).get = "/palomachain/paloma/valset/get_snapshot_by_id/{snapshotId}"; } +// Queries a list of GetValidatorAliveUntil items. + rpc GetValidatorAliveUntil(QueryGetValidatorAliveUntilRequest) returns (QueryGetValidatorAliveUntilResponse) { + option (google.api.http).get = "/palomachain/paloma/valset/get_validator_alive_until"; + } + // this line is used by starport scaffolding # 2 } @@ -54,4 +60,16 @@ message QueryGetSnapshotByIDResponse { Snapshot snapshot = 1; } +message QueryGetValidatorAliveUntilRequest { + bytes valAddress = 1[ (gogoproto.casttype) = + "github.com/cosmos/cosmos-sdk/types.ValAddress" ]; +} + +message QueryGetValidatorAliveUntilResponse { + google.protobuf.Timestamp aliveUntil = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true + ]; +} + // this line is used by starport scaffolding # 3 diff --git a/proto/valset/tx.proto b/proto/valset/tx.proto index 4fa5603c..93e1c4b1 100644 --- a/proto/valset/tx.proto +++ b/proto/valset/tx.proto @@ -10,6 +10,7 @@ option go_package = "github.com/palomachain/paloma/x/valset/types"; // Msg defines the Msg service. service Msg { rpc AddExternalChainInfoForValidator(MsgAddExternalChainInfoForValidator) returns (MsgAddExternalChainInfoForValidatorResponse); + rpc KeepAlive(MsgKeepAlive) returns (MsgKeepAliveResponse); // this line is used by starport scaffolding # proto/tx/rpc } @@ -21,4 +22,11 @@ message MsgAddExternalChainInfoForValidator { message MsgAddExternalChainInfoForValidatorResponse { } +message MsgKeepAlive { + string creator = 1; +} + +message MsgKeepAliveResponse { +} + // this line is used by starport scaffolding # proto/tx/message diff --git a/util/keeper/iter.go b/util/keeper/iter.go index 34d24f7d..9699ac7d 100644 --- a/util/keeper/iter.go +++ b/util/keeper/iter.go @@ -20,6 +20,16 @@ func IterAll[T codec.ProtoMarshaler](store sdk.KVStore, pu protoUnmarshaler) ([] return keys, res, nil } +func IterAllRaw(store sdk.KVStore, pu protoUnmarshaler) (keys [][]byte, values [][]byte, _err error) { + iterator := store.Iterator(nil, nil) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + keys = append(keys, iterator.Key()) + values = append(values, iterator.Value()) + } + return +} + func IterAllFnc[T codec.ProtoMarshaler](store sdk.KVStore, pu protoUnmarshaler, fnc func([]byte, T) bool) error { res := []T{} iterator := store.Iterator(nil, nil) diff --git a/x/consensus/keeper/msg_server.go b/x/consensus/keeper/msg_server.go index c739dea6..96ba4266 100644 --- a/x/consensus/keeper/msg_server.go +++ b/x/consensus/keeper/msg_server.go @@ -36,6 +36,10 @@ func (k msgServer) AddMessagesSignatures(goCtx context.Context, msg *types.MsgAd ); err != nil { return nil, err } + err := k.Keeper.valset.KeepValidatorAlive(ctx, valAddr) + if err != nil { + return nil, err + } return &types.MsgAddMessagesSignaturesResponse{}, nil } diff --git a/x/consensus/keeper/msg_server_add_evidence.go b/x/consensus/keeper/msg_server_add_evidence.go index ff30bddc..8dcae6fd 100644 --- a/x/consensus/keeper/msg_server_add_evidence.go +++ b/x/consensus/keeper/msg_server_add_evidence.go @@ -23,5 +23,10 @@ func (k msgServer) AddEvidence(goCtx context.Context, msg *types.MsgAddEvidence) return nil, err } + err = k.Keeper.valset.KeepValidatorAlive(ctx, valAddr) + if err != nil { + return nil, err + } + return &types.MsgAddEvidenceResponse{}, nil } diff --git a/x/consensus/keeper/msg_server_set_public_access_data.go b/x/consensus/keeper/msg_server_set_public_access_data.go index 3f4d97e3..bfc80914 100644 --- a/x/consensus/keeper/msg_server_set_public_access_data.go +++ b/x/consensus/keeper/msg_server_set_public_access_data.go @@ -22,6 +22,10 @@ func (k msgServer) SetPublicAccessData(goCtx context.Context, msg *types.MsgSetP if err != nil { return nil, err } + err = k.Keeper.valset.KeepValidatorAlive(ctx, valAddr) + if err != nil { + return nil, err + } return &types.MsgSetPublicAccessDataResponse{}, nil } diff --git a/x/consensus/types/expected_keepers.go b/x/consensus/types/expected_keepers.go index 50c1afc3..7d1fc262 100644 --- a/x/consensus/types/expected_keepers.go +++ b/x/consensus/types/expected_keepers.go @@ -23,4 +23,5 @@ type ValsetKeeper interface { GetSigningKey(ctx sdk.Context, valAddr sdk.ValAddress, chainType, chainReferenceID, signedByAddress string) ([]byte, error) GetCurrentSnapshot(ctx sdk.Context) (*valsettypes.Snapshot, error) CanAcceptValidator(ctx sdk.Context, valAddr sdk.ValAddress) error + KeepValidatorAlive(ctx sdk.Context, valAddr sdk.ValAddress) error } diff --git a/x/consensus/types/mocks/QueuedSignedMessageI.go b/x/consensus/types/mocks/QueuedSignedMessageI.go index b3f45ffd..c87a9cf8 100644 --- a/x/consensus/types/mocks/QueuedSignedMessageI.go +++ b/x/consensus/types/mocks/QueuedSignedMessageI.go @@ -6,6 +6,8 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" mock "github.com/stretchr/testify/mock" + time "time" + types "github.com/palomachain/paloma/x/consensus/types" ) @@ -15,7 +17,7 @@ type QueuedSignedMessageI struct { } // AddEvidence provides a mock function with given fields: _a0 -func (_m *QueuedSignedMessageI) AddEvidence(_a0 *types.Evidence) { +func (_m *QueuedSignedMessageI) AddEvidence(_a0 types.Evidence) { _m.Called(_a0) } @@ -47,6 +49,34 @@ func (_m *QueuedSignedMessageI) ConsensusMsg(_a0 codectypes.AnyUnpacker) (types. return r0, r1 } +// GetAddedAt provides a mock function with given fields: +func (_m *QueuedSignedMessageI) GetAddedAt() time.Time { + ret := _m.Called() + + var r0 time.Time + if rf, ok := ret.Get(0).(func() time.Time); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(time.Time) + } + + return r0 +} + +// GetAddedAtBlockHeight provides a mock function with given fields: +func (_m *QueuedSignedMessageI) GetAddedAtBlockHeight() int64 { + ret := _m.Called() + + var r0 int64 + if rf, ok := ret.Get(0).(func() int64); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(int64) + } + + return r0 +} + // GetBytesToSign provides a mock function with given fields: func (_m *QueuedSignedMessageI) GetBytesToSign() []byte { ret := _m.Called() diff --git a/x/consensus/types/mocks/ValsetKeeper.go b/x/consensus/types/mocks/ValsetKeeper.go index 62631a30..53be2454 100644 --- a/x/consensus/types/mocks/ValsetKeeper.go +++ b/x/consensus/types/mocks/ValsetKeeper.go @@ -74,6 +74,20 @@ func (_m *ValsetKeeper) GetSigningKey(ctx types.Context, valAddr types.ValAddres return r0, r1 } +// KeepValidatorAlive provides a mock function with given fields: ctx, valAddr +func (_m *ValsetKeeper) KeepValidatorAlive(ctx types.Context, valAddr types.ValAddress) error { + ret := _m.Called(ctx, valAddr) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, types.ValAddress) error); ok { + r0 = rf(ctx, valAddr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + type mockConstructorTestingTNewValsetKeeper interface { mock.TestingT Cleanup(func()) diff --git a/x/consensus/types/query.pb.gw.go b/x/consensus/types/query.pb.gw.go index a9308d5a..17c24d98 100644 --- a/x/consensus/types/query.pb.gw.go +++ b/x/consensus/types/query.pb.gw.go @@ -87,6 +87,10 @@ func local_request_Query_QueuedMessagesForSigning_0(ctx context.Context, marshal } +var ( + filter_Query_MessagesInQueue_0 = &utilities.DoubleArray{Encoding: map[string]int{"queueTypeName": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + func request_Query_MessagesInQueue_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryMessagesInQueueRequest var metadata runtime.ServerMetadata @@ -109,6 +113,13 @@ func request_Query_MessagesInQueue_0(ctx context.Context, marshaler runtime.Mars return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "queueTypeName", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MessagesInQueue_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := client.MessagesInQueue(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err @@ -136,6 +147,13 @@ func local_request_Query_MessagesInQueue_0(ctx context.Context, marshaler runtim return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "queueTypeName", err) } + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_MessagesInQueue_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + msg, err := server.MessagesInQueue(ctx, &protoReq) return msg, metadata, err diff --git a/x/evm/types/expected_keepers.go b/x/evm/types/expected_keepers.go index 159a4d26..d7db484a 100644 --- a/x/evm/types/expected_keepers.go +++ b/x/evm/types/expected_keepers.go @@ -29,4 +29,5 @@ type ConsensusKeeper interface { type ValsetKeeper interface { FindSnapshotByID(ctx sdk.Context, id uint64) (*valsettypes.Snapshot, error) GetCurrentSnapshot(ctx sdk.Context) (*valsettypes.Snapshot, error) + KeepValidatorAlive(ctx sdk.Context, valAddr sdk.ValAddress) error } diff --git a/x/evm/types/mocks/ValsetKeeper.go b/x/evm/types/mocks/ValsetKeeper.go index 05fdc932..4d70e9e7 100644 --- a/x/evm/types/mocks/ValsetKeeper.go +++ b/x/evm/types/mocks/ValsetKeeper.go @@ -60,6 +60,20 @@ func (_m *ValsetKeeper) GetCurrentSnapshot(ctx types.Context) (*valsettypes.Snap return r0, r1 } +// KeepValidatorAlive provides a mock function with given fields: ctx, valAddr +func (_m *ValsetKeeper) KeepValidatorAlive(ctx types.Context, valAddr types.ValAddress) error { + ret := _m.Called(ctx, valAddr) + + var r0 error + if rf, ok := ret.Get(0).(func(types.Context, types.ValAddress) error); ok { + r0 = rf(ctx, valAddr) + } else { + r0 = ret.Error(0) + } + + return r0 +} + type mockConstructorTestingTNewValsetKeeper interface { mock.TestingT Cleanup(func()) diff --git a/x/valset/client/cli/query.go b/x/valset/client/cli/query.go index 1f058fbb..f4e06850 100644 --- a/x/valset/client/cli/query.go +++ b/x/valset/client/cli/query.go @@ -29,6 +29,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdGetSnapshotByID()) + cmd.AddCommand(CmdGetValidatorAliveUntil()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/valset/client/cli/query_get_validator_alive_until.go b/x/valset/client/cli/query_get_validator_alive_until.go new file mode 100644 index 00000000..181128f9 --- /dev/null +++ b/x/valset/client/cli/query_get_validator_alive_until.go @@ -0,0 +1,42 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/palomachain/paloma/x/valset/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdGetValidatorAliveUntil() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-validator-alive-until", + Short: "Query GetValidatorAliveUntil", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetValidatorAliveUntilRequest{} + + res, err := queryClient.GetValidatorAliveUntil(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/valset/client/cli/tx.go b/x/valset/client/cli/tx.go index fb5295d3..fd007c8d 100644 --- a/x/valset/client/cli/tx.go +++ b/x/valset/client/cli/tx.go @@ -31,6 +31,7 @@ func GetTxCmd() *cobra.Command { } cmd.AddCommand(CmdAddExternalChainInfoForValidator()) + cmd.AddCommand(CmdKeepAlive()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/valset/client/cli/tx_keep_alive.go b/x/valset/client/cli/tx_keep_alive.go new file mode 100644 index 00000000..541eb2ff --- /dev/null +++ b/x/valset/client/cli/tx_keep_alive.go @@ -0,0 +1,40 @@ +package cli + +import ( + "strconv" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/palomachain/paloma/x/valset/types" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdKeepAlive() *cobra.Command { + cmd := &cobra.Command{ + Use: "keep-alive", + Short: "Broadcast message KeepAlive", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgKeepAlive( + clientCtx.GetFromAddress().String(), + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/valset/handler.go b/x/valset/handler.go index e90b929a..f64216f7 100644 --- a/x/valset/handler.go +++ b/x/valset/handler.go @@ -20,6 +20,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgAddExternalChainInfoForValidator: res, err := msgServer.AddExternalChainInfoForValidator(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgKeepAlive: + res, err := msgServer.KeepAlive(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/valset/keeper/errors.go b/x/valset/keeper/errors.go index 8c7967e1..384a43c5 100644 --- a/x/valset/keeper/errors.go +++ b/x/valset/keeper/errors.go @@ -6,6 +6,7 @@ import ( const ( ErrValidatorWithAddrNotFound = whoops.Errorf("validator with addr %s was not found") + ErrValidatorNotInKeepAlive = whoops.Errorf("validator is not in keep alive store %s") ErrMaxNumberOfExternalAccounts = whoops.Errorf("trying to submit %d accounts while the limit is %d") ErrValidatorCannotBePigeon = whoops.Errorf("validator %s cannot be a pigeon") diff --git a/x/valset/keeper/grpc_query_get_validator_alive_until.go b/x/valset/keeper/grpc_query_get_validator_alive_until.go new file mode 100644 index 00000000..c29919e1 --- /dev/null +++ b/x/valset/keeper/grpc_query_get_validator_alive_until.go @@ -0,0 +1,27 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/palomachain/paloma/x/valset/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetValidatorAliveUntil(goCtx context.Context, req *types.QueryGetValidatorAliveUntilRequest) (*types.QueryGetValidatorAliveUntilResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + aliveUntil, err := k.ValidatorAliveUntil(ctx, req.GetValAddress()) + if err != nil { + return nil, err + } + + return &types.QueryGetValidatorAliveUntilResponse{ + AliveUntil: aliveUntil, + }, nil +} diff --git a/x/valset/keeper/keep_alive.go b/x/valset/keeper/keep_alive.go new file mode 100644 index 00000000..9a959fea --- /dev/null +++ b/x/valset/keeper/keep_alive.go @@ -0,0 +1,114 @@ +package keeper + +import ( + "encoding/json" + "errors" + "time" + + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + keeperutil "github.com/palomachain/paloma/util/keeper" + "github.com/vizualni/whoops" +) + +const ( + // TODO: make this a param + defaultKeepAliveDuration = 5 * time.Minute +) + +type keepAliveData struct { + ValAddr sdk.ValAddress + ContactedAt time.Time + AliveUntil time.Time +} + +func (k Keeper) KeepValidatorAlive(ctx sdk.Context, valAddr sdk.ValAddress) error { + if err := k.CanAcceptValidator(ctx, valAddr); err != nil { + if !errors.Is(err, ErrValidatorNotInKeepAlive) { + return err + } + } + + store := k.keepAliveStore(ctx) + data := keepAliveData{ + ValAddr: valAddr, + ContactedAt: ctx.BlockTime(), + AliveUntil: ctx.BlockTime().Add(defaultKeepAliveDuration), + } + bz, err := json.Marshal(data) + if err != nil { + return err + } + store.Set(valAddr, bz) + return nil +} + +func (k Keeper) IsValidatorAlive(ctx sdk.Context, valAddr sdk.ValAddress) (bool, error) { + aliveUntil, err := k.ValidatorAliveUntil(ctx, valAddr) + if err != nil { + return false, err + } + return ctx.BlockTime().Before(aliveUntil), nil +} + +func (k Keeper) ValidatorAliveUntil(ctx sdk.Context, valAddr sdk.ValAddress) (time.Time, error) { + store := k.keepAliveStore(ctx) + if !store.Has(valAddr) { + return time.Time{}, ErrValidatorNotInKeepAlive.Format(valAddr) + } + dataBz := store.Get(valAddr) + var data keepAliveData + err := json.Unmarshal(dataBz, &data) + if err != nil { + return time.Time{}, err + } + return data.AliveUntil, nil +} + +func (k Keeper) CanAcceptValidator(ctx sdk.Context, valAddr sdk.ValAddress) error { + stakingVal := k.staking.Validator(ctx, valAddr) + + if stakingVal == nil { + return ErrValidatorWithAddrNotFound.Format(valAddr.String()) + } + + if stakingVal.IsJailed() { + return ErrValidatorCannotBePigeon.Format(valAddr.String()).WrapS("validator is jailed") + } + + if !stakingVal.IsBonded() { + return ErrValidatorCannotBePigeon.Format(valAddr.String()).WrapS("validator is not bonded") + } + + return nil +} + +func (k Keeper) JailInactiveValidators(ctx sdk.Context) error { + store := k.keepAliveStore(ctx) + keys, _, _ := keeperutil.IterAllRaw(store, k.cdc) + var g whoops.Group + for _, bz := range keys { + valAddr := sdk.ValAddress(bz) + alive, err := k.IsValidatorAlive(ctx, valAddr) + if err != nil { + g.Add(err) + continue + } + if alive { + continue + } + store.Delete(valAddr) + consAddr, err := k.staking.Validator(ctx, valAddr).GetConsAddr() + if err != nil { + g.Add(err) + continue + } + k.staking.Jail(ctx, consAddr) + + } + return g.Return() +} + +func (k Keeper) keepAliveStore(ctx sdk.Context) sdk.KVStore { + return prefix.NewStore(ctx.KVStore(k.storeKey), []byte("keep-alive/")) +} diff --git a/x/valset/keeper/keep_alive_test.go b/x/valset/keeper/keep_alive_test.go new file mode 100644 index 00000000..679f555e --- /dev/null +++ b/x/valset/keeper/keep_alive_test.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "fmt" + "testing" + "time" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/palomachain/paloma/x/valset/types/mocks" + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" +) + +func TestJailingInactiveValidators(t *testing.T) { + k, ms, ctx := newValsetKeeper(t) + ctx = ctx.WithBlockTime(time.Unix(1000000000, 0)) + + valBuild := func(id int, alive bool) sdk.ValAddress { + val := sdk.ValAddress(fmt.Sprintf("validator_%d", id)) + vali := mocks.NewStakingValidatorI(t) + ms.StakingKeeper.On("Validator", mock.Anything, val).Return(vali) + vali.On("IsJailed").Return(false) + vali.On("IsBonded").Return(true) + consAddr := sdk.ConsAddress(val) + if alive { + err := k.KeepValidatorAlive(ctx.WithBlockTime(time.Unix(1000, 0)), val) + require.NoError(t, err) + + vali.On("GetConsAddr").Return(consAddr, nil) + ms.StakingKeeper.On("Jail", mock.Anything, consAddr) + } else { + err := k.KeepValidatorAlive(ctx.WithBlockTime(ctx.BlockTime().Add(-defaultKeepAliveDuration/2)), val) + require.NoError(t, err) + } + return val + } + valBuild(1, false) + valBuild(2, false) + valBuild(3, true) + valBuild(4, true) + + err := k.JailInactiveValidators(ctx) + require.NoError(t, err) +} diff --git a/x/valset/keeper/keeper.go b/x/valset/keeper/keeper.go index 3dc2673d..d1694f90 100644 --- a/x/valset/keeper/keeper.go +++ b/x/valset/keeper/keeper.go @@ -78,24 +78,6 @@ func (k Keeper) AddExternalChainInfo(ctx sdk.Context, valAddr sdk.ValAddress, ne return k.SetExternalChainInfoState(ctx, valAddr, newChainInfo) } -func (k Keeper) CanAcceptValidator(ctx sdk.Context, valAddr sdk.ValAddress) error { - stakingVal := k.staking.Validator(ctx, valAddr) - - if stakingVal == nil { - return ErrValidatorWithAddrNotFound.Format(valAddr.String()) - } - - if stakingVal.IsJailed() { - return ErrValidatorCannotBePigeon.Format(valAddr.String()).WrapS("validator is jailed") - } - - if !stakingVal.IsBonded() { - return ErrValidatorCannotBePigeon.Format(valAddr.String()).WrapS("validator is not bonded") - } - - return nil -} - func (k Keeper) SetExternalChainInfoState(ctx sdk.Context, valAddr sdk.ValAddress, chainInfos []*types.ExternalChainInfo) error { if len(chainInfos) > maxNumOfAllowedExternalAccounts { return ErrMaxNumberOfExternalAccounts.Format( diff --git a/x/valset/keeper/keeper_test.go b/x/valset/keeper/keeper_test.go index e486da92..a6b20390 100644 --- a/x/valset/keeper/keeper_test.go +++ b/x/valset/keeper/keeper_test.go @@ -2,6 +2,7 @@ package keeper import ( "testing" + "time" sdk "github.com/cosmos/cosmos-sdk/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" @@ -53,8 +54,10 @@ func TestIfValidatorCanBeAccepted(t *testing.T) { require.ErrorIs(t, err, ErrValidatorWithAddrNotFound) }) } -func TestRegisterRunner(t *testing.T) { + +func TestRegisteringPigeon(t *testing.T) { k, ms, ctx := newValsetKeeper(t) + ctx = ctx.WithBlockTime(time.Unix(999999999, 0)) val := sdk.ValAddress("validator") val2 := sdk.ValAddress("validator2") nonExistingVal := sdk.ValAddress("i dont exist") @@ -71,6 +74,21 @@ func TestRegisterRunner(t *testing.T) { ms.StakingKeeper.On("Validator", mock.Anything, val2).Return(vali2) ms.StakingKeeper.On("Validator", mock.Anything, nonExistingVal).Return(nil) + t.Run("if validator has been alive before, but it's not now, then it returns an error", func(t *testing.T) { + err := k.KeepValidatorAlive(ctx.WithBlockTime(time.Unix(555, 0)), val) + require.NoError(t, err) + alive, err := k.IsValidatorAlive(ctx, val) + require.NoError(t, err) + require.False(t, alive) + }) + + t.Run("setting the validator to current ctx's block time", func(t *testing.T) { + err := k.KeepValidatorAlive(ctx, val) + require.NoError(t, err) + err = k.KeepValidatorAlive(ctx, val2) + require.NoError(t, err) + }) + t.Run("it adds a new chain info to the validator", func(t *testing.T) { err := k.AddExternalChainInfo( ctx, diff --git a/x/valset/keeper/msg_server_add_external_chain_info_for_validator.go b/x/valset/keeper/msg_server_add_external_chain_info_for_validator.go index 23952f45..f23babed 100644 --- a/x/valset/keeper/msg_server_add_external_chain_info_for_validator.go +++ b/x/valset/keeper/msg_server_add_external_chain_info_for_validator.go @@ -22,5 +22,9 @@ func (k msgServer) AddExternalChainInfoForValidator(goCtx context.Context, msg * return nil, err } + err = k.Keeper.KeepValidatorAlive(ctx, valAddr) + if err != nil { + return nil, err + } return &types.MsgAddExternalChainInfoForValidatorResponse{}, nil } diff --git a/x/valset/keeper/msg_server_keep_alive.go b/x/valset/keeper/msg_server_keep_alive.go new file mode 100644 index 00000000..cd4a2b24 --- /dev/null +++ b/x/valset/keeper/msg_server_keep_alive.go @@ -0,0 +1,21 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/palomachain/paloma/x/valset/types" +) + +func (k msgServer) KeepAlive(goCtx context.Context, msg *types.MsgKeepAlive) (*types.MsgKeepAliveResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + creator, _ := sdk.AccAddressFromBech32(msg.Creator) + valAddr := sdk.ValAddress(creator.Bytes()) + err := k.Keeper.KeepValidatorAlive(ctx, valAddr) + if err != nil { + return nil, err + } + + return &types.MsgKeepAliveResponse{}, nil +} diff --git a/x/valset/keeper/setup_test.go b/x/valset/keeper/setup_test.go index 82fdd829..a99d892e 100644 --- a/x/valset/keeper/setup_test.go +++ b/x/valset/keeper/setup_test.go @@ -21,7 +21,6 @@ type mockedServices struct { } func newValsetKeeper(t testing.TB) (*Keeper, mockedServices, sdk.Context) { - storeKey := sdk.NewKVStoreKey(types.StoreKey) memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) @@ -55,6 +54,7 @@ func newValsetKeeper(t testing.TB) (*Keeper, mockedServices, sdk.Context) { ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, nil) + ctx = ctx.WithMultiStore(stateStore).WithGasMeter(sdk.NewInfiniteGasMeter()) // Initialize params k.SetParams(ctx, types.DefaultParams()) diff --git a/x/valset/module.go b/x/valset/module.go index 9d0551a6..fdb5a42d 100644 --- a/x/valset/module.go +++ b/x/valset/module.go @@ -175,5 +175,11 @@ func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.Val if ctx.BlockHeight()%50 == 0 || ctx.BlockHeight() == 1 { am.keeper.TriggerSnapshotBuild(ctx) } + + if ctx.BlockHeight()%5 == 0 { + if err := am.keeper.JailInactiveValidators(ctx); err != nil { + am.keeper.Logger(ctx).Error("error while jailing inactive validators", "error", err) + } + } return []abci.ValidatorUpdate{} } diff --git a/x/valset/module_simulation.go b/x/valset/module_simulation.go index 82695d07..3bb48263 100644 --- a/x/valset/module_simulation.go +++ b/x/valset/module_simulation.go @@ -31,6 +31,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgAddExternalChainInfoForValidator int = 100 + opWeightMsgKeepAlive = "op_weight_msg_keep_alive" + // TODO: Determine the simulation weight value + defaultWeightMsgKeepAlive int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -75,6 +79,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp valsetsimulation.SimulateMsgAddExternalChainInfoForValidator(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgKeepAlive int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgKeepAlive, &weightMsgKeepAlive, nil, + func(_ *rand.Rand) { + weightMsgKeepAlive = defaultWeightMsgKeepAlive + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgKeepAlive, + valsetsimulation.SimulateMsgKeepAlive(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/valset/simulation/keep_alive.go b/x/valset/simulation/keep_alive.go new file mode 100644 index 00000000..7d532322 --- /dev/null +++ b/x/valset/simulation/keep_alive.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/palomachain/paloma/x/valset/keeper" + "github.com/palomachain/paloma/x/valset/types" +) + +func SimulateMsgKeepAlive( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgKeepAlive{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the KeepAlive simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "KeepAlive simulation not implemented"), nil, nil + } +} diff --git a/x/valset/types/codec.go b/x/valset/types/codec.go index 50e233dd..3aaa8428 100644 --- a/x/valset/types/codec.go +++ b/x/valset/types/codec.go @@ -9,6 +9,7 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgAddExternalChainInfoForValidator{}, "valset/AddExternalChainInfoForValidator", nil) + cdc.RegisterConcrete(&MsgKeepAlive{}, "valset/KeepAlive", nil) // this line is used by starport scaffolding # 2 } @@ -16,6 +17,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgAddExternalChainInfoForValidator{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgKeepAlive{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/valset/types/expected_keepers.go b/x/valset/types/expected_keepers.go index a6afa588..03a23412 100644 --- a/x/valset/types/expected_keepers.go +++ b/x/valset/types/expected_keepers.go @@ -23,6 +23,7 @@ type BankKeeper interface { type StakingKeeper interface { Validator(ctx sdk.Context, addr sdk.ValAddress) stakingtypes.ValidatorI IterateValidators(ctx sdk.Context, fn func(index int64, validator stakingtypes.ValidatorI) (stop bool)) + Jail(ctx sdk.Context, consAddr sdk.ConsAddress) } type OnSnapshotBuiltListener interface { diff --git a/x/valset/types/message_keep_alive.go b/x/valset/types/message_keep_alive.go new file mode 100644 index 00000000..75720c81 --- /dev/null +++ b/x/valset/types/message_keep_alive.go @@ -0,0 +1,45 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgKeepAlive = "keep_alive" + +var _ sdk.Msg = &MsgKeepAlive{} + +func NewMsgKeepAlive(creator string) *MsgKeepAlive { + return &MsgKeepAlive{ + Creator: creator, + } +} + +func (msg *MsgKeepAlive) Route() string { + return RouterKey +} + +func (msg *MsgKeepAlive) Type() string { + return TypeMsgKeepAlive +} + +func (msg *MsgKeepAlive) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgKeepAlive) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgKeepAlive) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + return nil +} diff --git a/x/valset/types/message_keep_alive_test.go b/x/valset/types/message_keep_alive_test.go new file mode 100644 index 00000000..f6c86afb --- /dev/null +++ b/x/valset/types/message_keep_alive_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/palomachain/paloma/testutil/sample" + "github.com/stretchr/testify/require" +) + +func TestMsgKeepAlive_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgKeepAlive + err error + }{ + { + name: "invalid address", + msg: MsgKeepAlive{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgKeepAlive{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/valset/types/mocks/StakingKeeper.go b/x/valset/types/mocks/StakingKeeper.go index 8e1579f6..1754be18 100644 --- a/x/valset/types/mocks/StakingKeeper.go +++ b/x/valset/types/mocks/StakingKeeper.go @@ -19,6 +19,11 @@ func (_m *StakingKeeper) IterateValidators(ctx types.Context, fn func(int64, sta _m.Called(ctx, fn) } +// Jail provides a mock function with given fields: ctx, consAddr +func (_m *StakingKeeper) Jail(ctx types.Context, consAddr types.ConsAddress) { + _m.Called(ctx, consAddr) +} + // Validator provides a mock function with given fields: ctx, addr func (_m *StakingKeeper) Validator(ctx types.Context, addr types.ValAddress) stakingtypes.ValidatorI { ret := _m.Called(ctx, addr) diff --git a/x/valset/types/query.pb.go b/x/valset/types/query.pb.go index d220d619..90e9e5d4 100644 --- a/x/valset/types/query.pb.go +++ b/x/valset/types/query.pb.go @@ -6,23 +6,28 @@ package types import ( context "context" fmt "fmt" + github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" _ "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" + time "time" ) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal var _ = fmt.Errorf var _ = math.Inf +var _ = time.Kitchen // This is a compile-time assertion to ensure that this generated file // is compatible with the proto package it is being compiled against. @@ -289,6 +294,94 @@ func (m *QueryGetSnapshotByIDResponse) GetSnapshot() *Snapshot { return nil } +type QueryGetValidatorAliveUntilRequest struct { + ValAddress github_com_cosmos_cosmos_sdk_types.ValAddress `protobuf:"bytes,1,opt,name=valAddress,proto3,casttype=github.com/cosmos/cosmos-sdk/types.ValAddress" json:"valAddress,omitempty"` +} + +func (m *QueryGetValidatorAliveUntilRequest) Reset() { *m = QueryGetValidatorAliveUntilRequest{} } +func (m *QueryGetValidatorAliveUntilRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetValidatorAliveUntilRequest) ProtoMessage() {} +func (*QueryGetValidatorAliveUntilRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_c5cac31ff5c559b6, []int{6} +} +func (m *QueryGetValidatorAliveUntilRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetValidatorAliveUntilRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetValidatorAliveUntilRequest.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 *QueryGetValidatorAliveUntilRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetValidatorAliveUntilRequest.Merge(m, src) +} +func (m *QueryGetValidatorAliveUntilRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetValidatorAliveUntilRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetValidatorAliveUntilRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetValidatorAliveUntilRequest proto.InternalMessageInfo + +func (m *QueryGetValidatorAliveUntilRequest) GetValAddress() github_com_cosmos_cosmos_sdk_types.ValAddress { + if m != nil { + return m.ValAddress + } + return nil +} + +type QueryGetValidatorAliveUntilResponse struct { + AliveUntil time.Time `protobuf:"bytes,1,opt,name=aliveUntil,proto3,stdtime" json:"aliveUntil"` +} + +func (m *QueryGetValidatorAliveUntilResponse) Reset() { *m = QueryGetValidatorAliveUntilResponse{} } +func (m *QueryGetValidatorAliveUntilResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetValidatorAliveUntilResponse) ProtoMessage() {} +func (*QueryGetValidatorAliveUntilResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_c5cac31ff5c559b6, []int{7} +} +func (m *QueryGetValidatorAliveUntilResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetValidatorAliveUntilResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetValidatorAliveUntilResponse.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 *QueryGetValidatorAliveUntilResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetValidatorAliveUntilResponse.Merge(m, src) +} +func (m *QueryGetValidatorAliveUntilResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetValidatorAliveUntilResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetValidatorAliveUntilResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetValidatorAliveUntilResponse proto.InternalMessageInfo + +func (m *QueryGetValidatorAliveUntilResponse) GetAliveUntil() time.Time { + if m != nil { + return m.AliveUntil + } + return time.Time{} +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "volumefi.paloma.valset.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "volumefi.paloma.valset.QueryParamsResponse") @@ -296,46 +389,57 @@ func init() { proto.RegisterType((*QueryValidatorInfoResponse)(nil), "volumefi.paloma.valset.QueryValidatorInfoResponse") proto.RegisterType((*QueryGetSnapshotByIDRequest)(nil), "volumefi.paloma.valset.QueryGetSnapshotByIDRequest") proto.RegisterType((*QueryGetSnapshotByIDResponse)(nil), "volumefi.paloma.valset.QueryGetSnapshotByIDResponse") + proto.RegisterType((*QueryGetValidatorAliveUntilRequest)(nil), "volumefi.paloma.valset.QueryGetValidatorAliveUntilRequest") + proto.RegisterType((*QueryGetValidatorAliveUntilResponse)(nil), "volumefi.paloma.valset.QueryGetValidatorAliveUntilResponse") } func init() { proto.RegisterFile("valset/query.proto", fileDescriptor_c5cac31ff5c559b6) } var fileDescriptor_c5cac31ff5c559b6 = []byte{ - // 533 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x94, 0xcf, 0x6e, 0xd3, 0x40, - 0x10, 0xc6, 0x63, 0x08, 0x01, 0xb6, 0x42, 0x48, 0xdb, 0x82, 0x8a, 0xa9, 0x4c, 0xe4, 0x03, 0x2a, - 0x05, 0x79, 0x49, 0x0a, 0x12, 0x42, 0xe5, 0x40, 0xf8, 0xa7, 0xdc, 0xc0, 0x95, 0x38, 0x20, 0xa4, - 0x68, 0x1d, 0x6f, 0x1c, 0x4b, 0xf6, 0x8e, 0xeb, 0xdd, 0x58, 0x8d, 0xaa, 0x5e, 0xb8, 0xf5, 0x86, - 0xc4, 0x8b, 0xf0, 0x08, 0x1c, 0x7b, 0xac, 0xc4, 0x85, 0x13, 0x42, 0x09, 0x0f, 0x82, 0xb2, 0xde, - 0x2d, 0x4d, 0x71, 0x2a, 0x7a, 0x4b, 0xc6, 0xdf, 0xf7, 0xcd, 0xcf, 0x33, 0x23, 0x23, 0x5c, 0xd0, - 0x44, 0x30, 0x49, 0x76, 0x46, 0x2c, 0x1f, 0x7b, 0x59, 0x0e, 0x12, 0xf0, 0xcd, 0x02, 0x92, 0x51, - 0xca, 0x06, 0xb1, 0x97, 0xd1, 0x04, 0x52, 0xea, 0x95, 0x1a, 0x7b, 0x25, 0x82, 0x08, 0x94, 0x84, - 0xcc, 0x7e, 0x95, 0x6a, 0x7b, 0x2d, 0x02, 0x88, 0x12, 0x46, 0x68, 0x16, 0x13, 0xca, 0x39, 0x48, - 0x2a, 0x63, 0xe0, 0x42, 0x3f, 0xdd, 0xe8, 0x83, 0x48, 0x41, 0x90, 0x80, 0x0a, 0x56, 0x36, 0x21, - 0x45, 0x2b, 0x60, 0x92, 0xb6, 0x48, 0x46, 0xa3, 0x98, 0x2b, 0xb1, 0xd6, 0x2e, 0x6b, 0x96, 0x8c, - 0xe6, 0x34, 0x35, 0x01, 0x37, 0x74, 0x51, 0x70, 0x9a, 0x89, 0x21, 0xc8, 0xb2, 0xec, 0xae, 0x20, - 0xfc, 0x6e, 0x96, 0xf6, 0x56, 0x69, 0x7d, 0xb6, 0x33, 0x62, 0x42, 0xba, 0xdb, 0x68, 0x79, 0xae, - 0x2a, 0x32, 0xe0, 0x82, 0xe1, 0x2d, 0xd4, 0x28, 0x33, 0x57, 0xad, 0xa6, 0xb5, 0xbe, 0xd4, 0x76, - 0xbc, 0xea, 0x37, 0xf4, 0x4a, 0x5f, 0xa7, 0x7e, 0xf8, 0xf3, 0x4e, 0xcd, 0xd7, 0x1e, 0xf7, 0x31, - 0xba, 0xa5, 0x42, 0xdf, 0xd3, 0x24, 0x0e, 0xa9, 0x84, 0xbc, 0xcb, 0x07, 0xa0, 0x3b, 0xe2, 0x55, - 0x74, 0xb9, 0xa0, 0xc9, 0xf3, 0x30, 0xcc, 0x55, 0xf6, 0x55, 0xdf, 0xfc, 0x75, 0x23, 0x64, 0x57, - 0xd9, 0x34, 0x52, 0x17, 0xa1, 0xfe, 0x90, 0xc6, 0x7c, 0x56, 0x9c, 0x61, 0x5d, 0x5c, 0x5f, 0x6a, - 0xdf, 0x5b, 0x84, 0xf5, 0x6a, 0x57, 0xb2, 0x9c, 0xd3, 0xe4, 0x85, 0x71, 0xf8, 0x27, 0xcc, 0xee, - 0x33, 0x74, 0x5b, 0x35, 0x7a, 0xc3, 0xe4, 0xb6, 0x1e, 0x52, 0x67, 0xdc, 0x7d, 0x69, 0x08, 0x1d, - 0x84, 0xcc, 0xec, 0xba, 0xa1, 0x82, 0xac, 0xfb, 0x27, 0x2a, 0xee, 0x47, 0xb4, 0x56, 0x6d, 0x3f, - 0x1e, 0xde, 0x15, 0xa3, 0xd6, 0xe3, 0x6b, 0x2e, 0xe2, 0x34, 0x7e, 0xff, 0xd8, 0xd1, 0x3e, 0xa8, - 0xa3, 0x4b, 0x2a, 0x1e, 0x1f, 0x58, 0xa8, 0x51, 0xce, 0x17, 0x6f, 0x2c, 0x0a, 0xf8, 0x77, 0xa5, - 0xf6, 0xfd, 0xff, 0xd2, 0x96, 0xac, 0xee, 0xdd, 0x4f, 0xdf, 0x7f, 0x7f, 0xb9, 0xd0, 0xc4, 0x0e, - 0x31, 0x26, 0x52, 0x9a, 0xc8, 0xdc, 0x69, 0xe1, 0xaf, 0x16, 0xba, 0x36, 0xb7, 0x17, 0xdc, 0x3a, - 0xb3, 0x4d, 0xd5, 0xea, 0xed, 0xf6, 0x79, 0x2c, 0x1a, 0xf0, 0x89, 0x02, 0x6c, 0xe3, 0x87, 0x8b, - 0x00, 0x0b, 0x63, 0xeb, 0xc5, 0x7c, 0x00, 0x64, 0x4f, 0x5f, 0xd3, 0x3e, 0xfe, 0x66, 0xa1, 0xeb, - 0xa7, 0x56, 0x84, 0x37, 0xcf, 0x24, 0xa8, 0xbe, 0x07, 0xfb, 0xd1, 0xf9, 0x4c, 0x1a, 0xbc, 0xa3, - 0xc0, 0xb7, 0xf0, 0x53, 0xcd, 0xab, 0xee, 0xef, 0x14, 0x7b, 0xc4, 0x64, 0xcf, 0x2c, 0xbe, 0x17, - 0x8c, 0x7b, 0x71, 0x48, 0xf6, 0xfe, 0x1e, 0xda, 0x7e, 0xe7, 0xf5, 0xe1, 0xc4, 0xb1, 0x8e, 0x26, - 0x8e, 0xf5, 0x6b, 0xe2, 0x58, 0x9f, 0xa7, 0x4e, 0xed, 0x68, 0xea, 0xd4, 0x7e, 0x4c, 0x9d, 0xda, - 0x87, 0x07, 0x51, 0x2c, 0x87, 0xa3, 0xc0, 0xeb, 0x43, 0x5a, 0x95, 0xbf, 0x6b, 0x3a, 0xc8, 0x71, - 0xc6, 0x44, 0xd0, 0x50, 0x9f, 0x80, 0xcd, 0x3f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xd6, 0x74, - 0x73, 0xbc, 0x04, 0x00, 0x00, + // 676 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x93, 0x41, 0x4f, 0x13, 0x41, + 0x14, 0xc7, 0xbb, 0x0a, 0x88, 0x0f, 0x8d, 0xc9, 0x80, 0x04, 0x57, 0xb2, 0x25, 0x6b, 0x62, 0x10, + 0x65, 0xc7, 0x16, 0x34, 0x06, 0xf1, 0x40, 0x45, 0x4d, 0x6f, 0xb2, 0x28, 0x07, 0x63, 0xd2, 0x4c, + 0xe9, 0x74, 0xd9, 0xb0, 0xbb, 0xb3, 0x74, 0xa6, 0x95, 0x86, 0x70, 0xf1, 0xe6, 0x8d, 0xc4, 0x2f, + 0xe2, 0x47, 0xf0, 0xc8, 0x4d, 0x12, 0x2f, 0x26, 0x26, 0x68, 0xc0, 0x4f, 0xe1, 0xc9, 0xec, 0xec, + 0x4c, 0x29, 0xb8, 0x05, 0xf1, 0x04, 0xfb, 0xfa, 0xfe, 0xef, 0xfd, 0xde, 0x9b, 0xff, 0x03, 0xd4, + 0x22, 0x01, 0xa7, 0x02, 0x6f, 0x34, 0x69, 0xa3, 0xed, 0xc4, 0x0d, 0x26, 0x18, 0x1a, 0x6d, 0xb1, + 0xa0, 0x19, 0xd2, 0xba, 0xef, 0xc4, 0x24, 0x60, 0x21, 0x71, 0xd2, 0x1c, 0x73, 0xc4, 0x63, 0x1e, + 0x93, 0x29, 0x38, 0xf9, 0x2f, 0xcd, 0x36, 0xc7, 0x3d, 0xc6, 0xbc, 0x80, 0x62, 0x12, 0xfb, 0x98, + 0x44, 0x11, 0x13, 0x44, 0xf8, 0x2c, 0xe2, 0xea, 0xd7, 0xa9, 0x55, 0xc6, 0x43, 0xc6, 0x71, 0x95, + 0x70, 0x9a, 0x36, 0xc1, 0xad, 0x42, 0x95, 0x0a, 0x52, 0xc0, 0x31, 0xf1, 0xfc, 0x48, 0x26, 0xab, + 0xdc, 0x61, 0xc5, 0x12, 0x93, 0x06, 0x09, 0x75, 0x81, 0xeb, 0x2a, 0xc8, 0x23, 0x12, 0xf3, 0x35, + 0x26, 0x54, 0x38, 0xaf, 0xba, 0xca, 0xaf, 0x6a, 0xb3, 0x8e, 0x85, 0x1f, 0x52, 0x2e, 0x48, 0x18, + 0xa7, 0x09, 0xf6, 0x08, 0xa0, 0xa5, 0xa4, 0xdd, 0x4b, 0x59, 0xcc, 0xa5, 0x1b, 0x4d, 0xca, 0x85, + 0xbd, 0x0c, 0xc3, 0xc7, 0xa2, 0x3c, 0x66, 0x11, 0xa7, 0x68, 0x1e, 0x06, 0xd2, 0xa6, 0x63, 0xc6, + 0x84, 0x31, 0x39, 0x54, 0xb4, 0x9c, 0xec, 0x15, 0x38, 0xa9, 0xae, 0xd4, 0xb7, 0xbb, 0x9f, 0xcf, + 0xb9, 0x4a, 0x63, 0x3f, 0x80, 0x1b, 0xb2, 0xe8, 0x0a, 0x09, 0xfc, 0x1a, 0x11, 0xac, 0x51, 0x8e, + 0xea, 0x4c, 0x75, 0x44, 0x63, 0x70, 0xa9, 0x45, 0x82, 0x85, 0x5a, 0xad, 0x21, 0x6b, 0x5f, 0x76, + 0xf5, 0xa7, 0xed, 0x81, 0x99, 0x25, 0x53, 0x48, 0x65, 0x80, 0xd5, 0x35, 0xe2, 0x47, 0x49, 0x30, + 0xc1, 0xba, 0x38, 0x39, 0x54, 0xbc, 0xd3, 0x0b, 0xeb, 0xd9, 0xa6, 0xa0, 0x8d, 0x88, 0x04, 0x4f, + 0xb5, 0xc2, 0xed, 0x12, 0xdb, 0x4f, 0xe0, 0xa6, 0x6c, 0xf4, 0x82, 0x8a, 0x65, 0xb5, 0xc5, 0x52, + 0xbb, 0xbc, 0xa8, 0x09, 0x2d, 0x00, 0xbd, 0xdc, 0x72, 0x4d, 0x42, 0xf6, 0xb9, 0x5d, 0x11, 0xfb, + 0x2d, 0x8c, 0x67, 0xcb, 0x3b, 0xcb, 0x1b, 0xd4, 0xd9, 0x6a, 0x7d, 0x13, 0xbd, 0x38, 0xb5, 0xde, + 0xed, 0x28, 0xec, 0x77, 0x60, 0xeb, 0xea, 0x9d, 0x45, 0x2c, 0x04, 0x7e, 0x8b, 0xbe, 0x8e, 0x84, + 0x1f, 0x68, 0xc6, 0x25, 0x00, 0xb5, 0x36, 0xca, 0xd3, 0x47, 0xba, 0x52, 0x2a, 0xfc, 0xde, 0xcf, + 0x4f, 0x7b, 0xbe, 0x58, 0x6b, 0x56, 0x9d, 0x55, 0x16, 0x62, 0xe5, 0xb4, 0xf4, 0xcf, 0x34, 0xaf, + 0xad, 0x63, 0xd1, 0x8e, 0x29, 0x77, 0x56, 0x3a, 0x42, 0xb7, 0xab, 0x88, 0xbd, 0x0e, 0xb7, 0x4e, + 0x6d, 0xac, 0xa6, 0x5b, 0x04, 0x20, 0x9d, 0xa8, 0x9a, 0xcf, 0x74, 0x52, 0xf7, 0x39, 0xda, 0x7d, + 0xce, 0x2b, 0xed, 0xbe, 0xd2, 0x60, 0x62, 0x8d, 0x9d, 0x1f, 0x79, 0xc3, 0xed, 0xd2, 0x15, 0xbf, + 0xf7, 0x43, 0xbf, 0xec, 0x86, 0x3e, 0x18, 0x30, 0x90, 0xba, 0x08, 0x4d, 0xf5, 0x5a, 0xd3, 0xdf, + 0xc6, 0x35, 0xef, 0xfe, 0x53, 0x6e, 0xca, 0x6c, 0xdf, 0x7e, 0xff, 0xf5, 0xd7, 0xc7, 0x0b, 0x13, + 0xc8, 0xc2, 0x5a, 0x84, 0x53, 0x11, 0x3e, 0x76, 0x61, 0xe8, 0x93, 0x01, 0x57, 0x8f, 0xb9, 0x0f, + 0x15, 0x4e, 0x6d, 0x93, 0x65, 0x70, 0xb3, 0x78, 0x1e, 0x89, 0x02, 0x7c, 0x24, 0x01, 0x8b, 0xe8, + 0x7e, 0x2f, 0xc0, 0x96, 0x96, 0x55, 0xfc, 0xa8, 0xce, 0xf0, 0x96, 0x7a, 0xb7, 0x6d, 0xf4, 0xd9, + 0x80, 0x6b, 0x27, 0x8c, 0x88, 0x66, 0x4e, 0x25, 0xc8, 0x76, 0xbd, 0x39, 0x7b, 0x3e, 0x91, 0x02, + 0x2f, 0x49, 0xf0, 0x79, 0x34, 0xa7, 0x78, 0xe5, 0x95, 0x9d, 0x60, 0xf7, 0xa8, 0xa8, 0x68, 0x7b, + 0x57, 0xaa, 0xed, 0x8a, 0x5f, 0xc3, 0x5b, 0x47, 0xe7, 0xb4, 0x8d, 0xbe, 0x18, 0x30, 0x9a, 0x6d, + 0x3a, 0x34, 0x77, 0x16, 0x54, 0xef, 0x13, 0x31, 0x1f, 0xff, 0x97, 0x56, 0xcd, 0x35, 0x2f, 0xe7, + 0x7a, 0x88, 0x66, 0xcf, 0x98, 0xeb, 0xe8, 0x5d, 0xa4, 0xb9, 0x2b, 0xcd, 0xa4, 0x4a, 0xe9, 0xf9, + 0xee, 0x81, 0x65, 0xec, 0x1d, 0x58, 0xc6, 0xcf, 0x03, 0xcb, 0xd8, 0x39, 0xb4, 0x72, 0x7b, 0x87, + 0x56, 0xee, 0xdb, 0xa1, 0x95, 0x7b, 0x73, 0xaf, 0xeb, 0x3e, 0x33, 0x2a, 0x6f, 0xea, 0xda, 0xf2, + 0x52, 0xab, 0x03, 0xf2, 0x9e, 0x66, 0xfe, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5b, 0x5c, 0x24, 0x45, + 0x95, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -356,6 +460,8 @@ type QueryClient interface { ValidatorInfo(ctx context.Context, in *QueryValidatorInfoRequest, opts ...grpc.CallOption) (*QueryValidatorInfoResponse, error) // Queries a list of GetSnapshotByID items. GetSnapshotByID(ctx context.Context, in *QueryGetSnapshotByIDRequest, opts ...grpc.CallOption) (*QueryGetSnapshotByIDResponse, error) + // Queries a list of GetValidatorAliveUntil items. + GetValidatorAliveUntil(ctx context.Context, in *QueryGetValidatorAliveUntilRequest, opts ...grpc.CallOption) (*QueryGetValidatorAliveUntilResponse, error) } type queryClient struct { @@ -393,6 +499,15 @@ func (c *queryClient) GetSnapshotByID(ctx context.Context, in *QueryGetSnapshotB return out, nil } +func (c *queryClient) GetValidatorAliveUntil(ctx context.Context, in *QueryGetValidatorAliveUntilRequest, opts ...grpc.CallOption) (*QueryGetValidatorAliveUntilResponse, error) { + out := new(QueryGetValidatorAliveUntilResponse) + err := c.cc.Invoke(ctx, "/volumefi.paloma.valset.Query/GetValidatorAliveUntil", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -401,6 +516,8 @@ type QueryServer interface { ValidatorInfo(context.Context, *QueryValidatorInfoRequest) (*QueryValidatorInfoResponse, error) // Queries a list of GetSnapshotByID items. GetSnapshotByID(context.Context, *QueryGetSnapshotByIDRequest) (*QueryGetSnapshotByIDResponse, error) + // Queries a list of GetValidatorAliveUntil items. + GetValidatorAliveUntil(context.Context, *QueryGetValidatorAliveUntilRequest) (*QueryGetValidatorAliveUntilResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -416,6 +533,9 @@ func (*UnimplementedQueryServer) ValidatorInfo(ctx context.Context, req *QueryVa func (*UnimplementedQueryServer) GetSnapshotByID(ctx context.Context, req *QueryGetSnapshotByIDRequest) (*QueryGetSnapshotByIDResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSnapshotByID not implemented") } +func (*UnimplementedQueryServer) GetValidatorAliveUntil(ctx context.Context, req *QueryGetValidatorAliveUntilRequest) (*QueryGetValidatorAliveUntilResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetValidatorAliveUntil not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -475,6 +595,24 @@ func _Query_GetSnapshotByID_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Query_GetValidatorAliveUntil_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetValidatorAliveUntilRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetValidatorAliveUntil(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/volumefi.paloma.valset.Query/GetValidatorAliveUntil", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetValidatorAliveUntil(ctx, req.(*QueryGetValidatorAliveUntilRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "volumefi.paloma.valset.Query", HandlerType: (*QueryServer)(nil), @@ -491,6 +629,10 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "GetSnapshotByID", Handler: _Query_GetSnapshotByID_Handler, }, + { + MethodName: "GetValidatorAliveUntil", + Handler: _Query_GetValidatorAliveUntil_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "valset/query.proto", @@ -682,6 +824,67 @@ func (m *QueryGetSnapshotByIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } +func (m *QueryGetValidatorAliveUntilRequest) 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 *QueryGetValidatorAliveUntilRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetValidatorAliveUntilRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ValAddress) > 0 { + i -= len(m.ValAddress) + copy(dAtA[i:], m.ValAddress) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ValAddress))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetValidatorAliveUntilResponse) 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 *QueryGetValidatorAliveUntilResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetValidatorAliveUntilResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n3, err3 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.AliveUntil, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.AliveUntil):]) + if err3 != nil { + return 0, err3 + } + i -= n3 + i = encodeVarintQuery(dAtA, i, uint64(n3)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -766,6 +969,30 @@ func (m *QueryGetSnapshotByIDResponse) Size() (n int) { return n } +func (m *QueryGetValidatorAliveUntilRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ValAddress) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetValidatorAliveUntilResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.AliveUntil) + n += 1 + l + sovQuery(uint64(l)) + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1226,6 +1453,173 @@ func (m *QueryGetSnapshotByIDResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetValidatorAliveUntilRequest) 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 ErrIntOverflowQuery + } + 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: QueryGetValidatorAliveUntilRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetValidatorAliveUntilRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ValAddress", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ValAddress = append(m.ValAddress[:0], dAtA[iNdEx:postIndex]...) + if m.ValAddress == nil { + m.ValAddress = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryGetValidatorAliveUntilResponse) 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 ErrIntOverflowQuery + } + 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: QueryGetValidatorAliveUntilResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetValidatorAliveUntilResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AliveUntil", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.AliveUntil, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/valset/types/query.pb.gw.go b/x/valset/types/query.pb.gw.go index d8295c57..0857bda0 100644 --- a/x/valset/types/query.pb.gw.go +++ b/x/valset/types/query.pb.gw.go @@ -159,6 +159,24 @@ func local_request_Query_GetSnapshotByID_0(ctx context.Context, marshaler runtim } +func request_Query_GetValidatorAliveUntil_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetValidatorAliveUntilRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetValidatorAliveUntil(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetValidatorAliveUntil_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetValidatorAliveUntilRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetValidatorAliveUntil(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -234,6 +252,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetValidatorAliveUntil_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetValidatorAliveUntil_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 { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetValidatorAliveUntil_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -335,6 +376,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetValidatorAliveUntil_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) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetValidatorAliveUntil_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_GetValidatorAliveUntil_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -344,6 +405,8 @@ var ( pattern_Query_ValidatorInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"volumefi", "paloma", "valset", "validator_info", "valAddr"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_GetSnapshotByID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"palomachain", "paloma", "valset", "get_snapshot_by_id", "snapshotId"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetValidatorAliveUntil_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"palomachain", "paloma", "valset", "get_validator_alive_until"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -352,4 +415,6 @@ var ( forward_Query_ValidatorInfo_0 = runtime.ForwardResponseMessage forward_Query_GetSnapshotByID_0 = runtime.ForwardResponseMessage + + forward_Query_GetValidatorAliveUntil_0 = runtime.ForwardResponseMessage ) diff --git a/x/valset/types/tx.pb.go b/x/valset/types/tx.pb.go index bc2c18b8..691f60bc 100644 --- a/x/valset/types/tx.pb.go +++ b/x/valset/types/tx.pb.go @@ -119,15 +119,97 @@ func (m *MsgAddExternalChainInfoForValidatorResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddExternalChainInfoForValidatorResponse proto.InternalMessageInfo +type MsgKeepAlive struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *MsgKeepAlive) Reset() { *m = MsgKeepAlive{} } +func (m *MsgKeepAlive) String() string { return proto.CompactTextString(m) } +func (*MsgKeepAlive) ProtoMessage() {} +func (*MsgKeepAlive) Descriptor() ([]byte, []int) { + return fileDescriptor_f173a384e172ec1f, []int{2} +} +func (m *MsgKeepAlive) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgKeepAlive) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgKeepAlive.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 *MsgKeepAlive) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgKeepAlive.Merge(m, src) +} +func (m *MsgKeepAlive) XXX_Size() int { + return m.Size() +} +func (m *MsgKeepAlive) XXX_DiscardUnknown() { + xxx_messageInfo_MsgKeepAlive.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgKeepAlive proto.InternalMessageInfo + +func (m *MsgKeepAlive) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type MsgKeepAliveResponse struct { +} + +func (m *MsgKeepAliveResponse) Reset() { *m = MsgKeepAliveResponse{} } +func (m *MsgKeepAliveResponse) String() string { return proto.CompactTextString(m) } +func (*MsgKeepAliveResponse) ProtoMessage() {} +func (*MsgKeepAliveResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f173a384e172ec1f, []int{3} +} +func (m *MsgKeepAliveResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgKeepAliveResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgKeepAliveResponse.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 *MsgKeepAliveResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgKeepAliveResponse.Merge(m, src) +} +func (m *MsgKeepAliveResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgKeepAliveResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgKeepAliveResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgKeepAliveResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgAddExternalChainInfoForValidator)(nil), "volumefi.paloma.valset.MsgAddExternalChainInfoForValidator") proto.RegisterType((*MsgAddExternalChainInfoForValidatorResponse)(nil), "volumefi.paloma.valset.MsgAddExternalChainInfoForValidatorResponse") + proto.RegisterType((*MsgKeepAlive)(nil), "volumefi.paloma.valset.MsgKeepAlive") + proto.RegisterType((*MsgKeepAliveResponse)(nil), "volumefi.paloma.valset.MsgKeepAliveResponse") } func init() { proto.RegisterFile("valset/tx.proto", fileDescriptor_f173a384e172ec1f) } var fileDescriptor_f173a384e172ec1f = []byte{ - // 263 bytes of a gzipped FileDescriptorProto + // 308 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0x4b, 0xcc, 0x29, 0x4e, 0x2d, 0xd1, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x2b, 0xcb, 0xcf, 0x29, 0xcd, 0x4d, 0x4d, 0xcb, 0xd4, 0x2b, 0x48, 0xcc, 0xc9, 0xcf, 0x4d, 0xd4, 0x83, 0x28, 0x90, @@ -137,14 +219,17 @@ var fileDescriptor_f173a384e172ec1f = []byte{ 0x4c, 0x49, 0x2c, 0xc9, 0x2f, 0x12, 0x92, 0xe0, 0x62, 0x4f, 0x2e, 0x4a, 0x05, 0x31, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x60, 0x5c, 0x21, 0x4f, 0x2e, 0xae, 0x64, 0x98, 0x96, 0x62, 0x09, 0x26, 0x05, 0x66, 0x0d, 0x6e, 0x23, 0x4d, 0x3d, 0xec, 0xae, 0xd0, 0xc3, 0xb0, 0x24, 0x08, 0x49, - 0xb3, 0x92, 0x2e, 0x97, 0x36, 0x11, 0x6e, 0x09, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x35, - 0x5a, 0xc3, 0xc8, 0xc5, 0xec, 0x5b, 0x9c, 0x2e, 0xb4, 0x84, 0x91, 0x4b, 0x81, 0xa0, 0x07, 0xac, - 0x71, 0x39, 0x89, 0x08, 0x1b, 0xa5, 0x9c, 0x29, 0xd0, 0x0c, 0x73, 0xae, 0x93, 0xdb, 0x89, 0x47, - 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, - 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, - 0x25, 0xe7, 0xe7, 0xea, 0x43, 0xcc, 0x07, 0x07, 0x0a, 0x94, 0xad, 0x5f, 0xa1, 0x0f, 0x8b, 0xe4, - 0xca, 0x82, 0xd4, 0xe2, 0x24, 0x36, 0x70, 0xcc, 0x19, 0x03, 0x02, 0x00, 0x00, 0xff, 0xff, 0x3a, - 0x1d, 0xcb, 0xa5, 0xfb, 0x01, 0x00, 0x00, + 0xb3, 0x92, 0x2e, 0x97, 0x36, 0x11, 0x6e, 0x09, 0x4a, 0x2d, 0x2e, 0xc8, 0xcf, 0x2b, 0x4e, 0x55, + 0xd2, 0xe0, 0xe2, 0xf1, 0x2d, 0x4e, 0xf7, 0x4e, 0x4d, 0x2d, 0x70, 0xcc, 0xc9, 0x2c, 0x4b, 0xc5, + 0xed, 0x46, 0x25, 0x31, 0x2e, 0x11, 0x64, 0x95, 0x30, 0x13, 0x8c, 0x7a, 0x99, 0xb8, 0x98, 0x7d, + 0x8b, 0xd3, 0x85, 0x96, 0x30, 0x72, 0x29, 0x10, 0x0c, 0x02, 0x6b, 0x5c, 0x9e, 0x22, 0xc2, 0xcd, + 0x52, 0xce, 0x14, 0x68, 0x86, 0x39, 0x57, 0x28, 0x9e, 0x8b, 0x13, 0xe1, 0x5b, 0x15, 0x3c, 0x26, + 0xc2, 0x55, 0x49, 0xe9, 0x10, 0xa3, 0x0a, 0x66, 0x81, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x43, 0x0c, 0x02, 0xc7, 0x1b, 0x94, 0xad, 0x5f, 0xa1, 0x0f, 0x4b, 0x87, 0x95, 0x05, 0xa9, + 0xc5, 0x49, 0x6c, 0xe0, 0xc4, 0x65, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x94, 0x73, 0x86, 0xa1, + 0x9e, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -160,6 +245,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 { AddExternalChainInfoForValidator(ctx context.Context, in *MsgAddExternalChainInfoForValidator, opts ...grpc.CallOption) (*MsgAddExternalChainInfoForValidatorResponse, error) + KeepAlive(ctx context.Context, in *MsgKeepAlive, opts ...grpc.CallOption) (*MsgKeepAliveResponse, error) } type msgClient struct { @@ -179,9 +265,19 @@ func (c *msgClient) AddExternalChainInfoForValidator(ctx context.Context, in *Ms return out, nil } +func (c *msgClient) KeepAlive(ctx context.Context, in *MsgKeepAlive, opts ...grpc.CallOption) (*MsgKeepAliveResponse, error) { + out := new(MsgKeepAliveResponse) + err := c.cc.Invoke(ctx, "/volumefi.paloma.valset.Msg/KeepAlive", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { AddExternalChainInfoForValidator(context.Context, *MsgAddExternalChainInfoForValidator) (*MsgAddExternalChainInfoForValidatorResponse, error) + KeepAlive(context.Context, *MsgKeepAlive) (*MsgKeepAliveResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -191,6 +287,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) AddExternalChainInfoForValidator(ctx context.Context, req *MsgAddExternalChainInfoForValidator) (*MsgAddExternalChainInfoForValidatorResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddExternalChainInfoForValidator not implemented") } +func (*UnimplementedMsgServer) KeepAlive(ctx context.Context, req *MsgKeepAlive) (*MsgKeepAliveResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method KeepAlive not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -214,6 +313,24 @@ func _Msg_AddExternalChainInfoForValidator_Handler(srv interface{}, ctx context. return interceptor(ctx, in, info, handler) } +func _Msg_KeepAlive_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgKeepAlive) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).KeepAlive(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/volumefi.paloma.valset.Msg/KeepAlive", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).KeepAlive(ctx, req.(*MsgKeepAlive)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "volumefi.paloma.valset.Msg", HandlerType: (*MsgServer)(nil), @@ -222,6 +339,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AddExternalChainInfoForValidator", Handler: _Msg_AddExternalChainInfoForValidator_Handler, }, + { + MethodName: "KeepAlive", + Handler: _Msg_KeepAlive_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "valset/tx.proto", @@ -294,6 +415,59 @@ func (m *MsgAddExternalChainInfoForValidatorResponse) MarshalToSizedBuffer(dAtA return len(dAtA) - i, nil } +func (m *MsgKeepAlive) 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 *MsgKeepAlive) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgKeepAlive) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgKeepAliveResponse) 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 *MsgKeepAliveResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgKeepAliveResponse) 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 @@ -333,6 +507,28 @@ func (m *MsgAddExternalChainInfoForValidatorResponse) Size() (n int) { return n } +func (m *MsgKeepAlive) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgKeepAliveResponse) 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 } @@ -505,6 +701,138 @@ func (m *MsgAddExternalChainInfoForValidatorResponse) Unmarshal(dAtA []byte) err } return nil } +func (m *MsgKeepAlive) 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: MsgKeepAlive: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgKeepAlive: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", 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.Creator = string(dAtA[iNdEx:postIndex]) + 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 *MsgKeepAliveResponse) 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: MsgKeepAliveResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgKeepAliveResponse: 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