From 014239f0b8aa2a94dbe433cd7216565d718db8c0 Mon Sep 17 00:00:00 2001 From: Dev Ojha Date: Mon, 5 Dec 2022 19:22:02 -0600 Subject: [PATCH] Add types & boilerplate for the Downtime detector module (#3609) Sub-component of #3603 ## What is the purpose of the change Adds types for the thin module intended for downtime detection ## Brief Changelog - Add downtime detection module types ## Testing and Verifying No tests added ## Documentation and Release Note - Does this pull request introduce a new feature or user-facing behavior changes? somewhat - Is a relevant changelog entry added to the `Unreleased` section in `CHANGELOG.md`? yes - How is the feature or change documented? In its spec --- CHANGELOG.md | 1 + .../downtime-detector/v1beta1/genesis.proto | 40 + .../downtime-detector/v1beta1/query.proto | 49 + x/downtime-detector/README.md | 30 + .../client/queryproto/query.pb.go | 978 ++++++++++++++++++ .../client/queryproto/query.pb.gw.go | 236 +++++ .../downtimedetector_module/module.go | 119 +++ x/downtime-detector/keeper.go | 52 + x/downtime-detector/types/constants.go | 9 + x/downtime-detector/types/genesis.go | 9 + x/downtime-detector/types/genesis.pb.go | 798 ++++++++++++++ x/ibc-rate-limit/testutil/wasm.go | 7 +- 12 files changed, 2325 insertions(+), 3 deletions(-) create mode 100644 proto/osmosis/downtime-detector/v1beta1/genesis.proto create mode 100644 proto/osmosis/downtime-detector/v1beta1/query.proto create mode 100644 x/downtime-detector/README.md create mode 100644 x/downtime-detector/client/queryproto/query.pb.go create mode 100644 x/downtime-detector/client/queryproto/query.pb.gw.go create mode 100644 x/downtime-detector/downtimedetector_module/module.go create mode 100644 x/downtime-detector/keeper.go create mode 100644 x/downtime-detector/types/constants.go create mode 100644 x/downtime-detector/types/genesis.go create mode 100644 x/downtime-detector/types/genesis.pb.go diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fbc0af1c70..f612dd62956 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Features +* [#3609](https://github.com/osmosis-labs/osmosis/pull/3609) Add Downtime-detection module. * [#2788](https://github.com/osmosis-labs/osmosis/pull/2788) Add logarithm base 2 implementation. ### Bug fixes diff --git a/proto/osmosis/downtime-detector/v1beta1/genesis.proto b/proto/osmosis/downtime-detector/v1beta1/genesis.proto new file mode 100644 index 00000000000..a1ce25eedce --- /dev/null +++ b/proto/osmosis/downtime-detector/v1beta1/genesis.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; +package osmosis.downtimedetector.v1beta1; + +import "gogoproto/gogo.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types"; + +// Params holds parameters for the downtime-detector module +message Params {} + +message GenesisDowntimeEntry { + google.protobuf.Duration downtime_duration = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"downtime_duration\"" + ]; + google.protobuf.Timestamp last_downtime = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"last_downtime\"" + ]; +} + +// GenesisState defines the twap module's genesis state. +message GenesisState { + repeated GenesisDowntimeEntry downtimes = 1 [ (gogoproto.nullable) = false ]; + + google.protobuf.Timestamp last_block_time = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"last_block_time\"" + ]; + + // params is the container of twap parameters. + Params params = 3 [ (gogoproto.nullable) = false ]; +} diff --git a/proto/osmosis/downtime-detector/v1beta1/query.proto b/proto/osmosis/downtime-detector/v1beta1/query.proto new file mode 100644 index 00000000000..97c07b26930 --- /dev/null +++ b/proto/osmosis/downtime-detector/v1beta1/query.proto @@ -0,0 +1,49 @@ +syntax = "proto3"; +package osmosis.downtimedetector.v1beta1; + +import "gogoproto/gogo.proto"; +import "osmosis/downtime-detector/v1beta1/genesis.proto"; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "google/api/annotations.proto"; +import "google/protobuf/any.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/client/queryproto"; + +service Query { + rpc Params(ParamsRequest) returns (ParamsResponse) { + option (google.api.http).get = "/osmosis/downtime-detector/v1beta1/Params"; + } + rpc RecoveredSinceDowntimeOfLength(RecoveredSinceDowntimeOfLengthRequest) + returns (RecoveredSinceDowntimeOfLengthResponse) { + option (google.api.http).get = + "/osmosis/downtime-detector/v1beta1/RecoveredSinceDowntimeOfLength"; + } +} + +// Query for has it been at least $RECOVERY_DURATION units of time, +// since the chain has been down for $DOWNTIME_DURATION. +// Note: $DOWNTIME_DURATION must be in set {SPECIFY_SET} +message RecoveredSinceDowntimeOfLengthRequest { + google.protobuf.Duration downtime = 1 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"downtime_duration\"" + ]; + google.protobuf.Duration recovery = 2 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"recovery_duration\"" + ]; +} + +message RecoveredSinceDowntimeOfLengthResponse { + bool succesfully_recovered = 1; +} + +message ParamsRequest {} +message ParamsResponse { Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/x/downtime-detector/README.md b/x/downtime-detector/README.md new file mode 100644 index 00000000000..938354186de --- /dev/null +++ b/x/downtime-detector/README.md @@ -0,0 +1,30 @@ +# Downtime-detector + +For several use cases, we need a module that can detect when the chain is recovering from downtime. We want to be able to efficiently know "Has it been $RECOVERY_PERIOD minutes since the chain has been down for $DOWNTIME_PERIOD", and expose this as a query to contracts. + +So for instance, you'd want to know if it has been at least 10 minutes, since the chain was down for > 30 minutes. Since you assume in such an event that it may take ~10 minutes for price oracles to be arb'd to correct. +Suggested Design + +Theres a couple designs, such as: + +* Iterating over block times from the last N blocks (with a heuristic filter based on average block time) + * Implies bounds on recovery time + * Linear iteration if heuristic is met + * Requires encoding expected block time +* Restricting downtime period, and storing a state entry for last time a downtime of length $D occurred + +Because this will be in important txs for contracts, we need to go with the approach that has minimal query compute, which is the latter. So we explain that in more depth. + +We restrict the $DOWNTIME_PERIOD options that you can query, to be: 30seconds, 1 min, 2 min, 3 min, 4 min, 5 min, 10 min, 20 min, 30 min, 40 min, 50 min, 1 hr, 1.5hr, 2 hr, 2.5 hr, 3 hr, 4 hr, 5 hr, 6 hr, 9hr, 12hr, 18hr, 24hr, 36hr, 48hr. + +In the downtime detector module, we store state entries for: + +* Last blocks timestamp +* For each period, last time there was downtime + +Then in every begin block: + +* Store last blocks timestamp +* if time since last block timestamp >= 30 seconds, iterate through all $DOWNTIME_PERIODS less than the downtime, and in each add a state entry for the current block time + +Then our query for has it been $RECOVERY_PERIOD since $DOWNTIME_PERIOD, simply reads the state entry for that $DOWNTIME_PERIOD, and then checks if time difference between now and that block is > RECOVERY_PERIOD. \ No newline at end of file diff --git a/x/downtime-detector/client/queryproto/query.pb.go b/x/downtime-detector/client/queryproto/query.pb.go new file mode 100644 index 00000000000..a31ccb14e87 --- /dev/null +++ b/x/downtime-detector/client/queryproto/query.pb.go @@ -0,0 +1,978 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/downtime-detector/v1beta1/query.proto + +package queryproto + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/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 "github.com/gogo/protobuf/types" + types1 "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/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" + 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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Query for has it been at least $RECOVERY_DURATION units of time, +// since the chain has been down for $DOWNTIME_DURATION. +// Note: $DOWNTIME_DURATION must be in set {SPECIFY_SET} +type RecoveredSinceDowntimeOfLengthRequest struct { + Downtime time.Duration `protobuf:"bytes,1,opt,name=downtime,proto3,stdduration" json:"downtime" yaml:"downtime_duration"` + Recovery time.Duration `protobuf:"bytes,2,opt,name=recovery,proto3,stdduration" json:"recovery" yaml:"recovery_duration"` +} + +func (m *RecoveredSinceDowntimeOfLengthRequest) Reset() { *m = RecoveredSinceDowntimeOfLengthRequest{} } +func (m *RecoveredSinceDowntimeOfLengthRequest) String() string { return proto.CompactTextString(m) } +func (*RecoveredSinceDowntimeOfLengthRequest) ProtoMessage() {} +func (*RecoveredSinceDowntimeOfLengthRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b748b3d07fa8b8cb, []int{0} +} +func (m *RecoveredSinceDowntimeOfLengthRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecoveredSinceDowntimeOfLengthRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecoveredSinceDowntimeOfLengthRequest.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 *RecoveredSinceDowntimeOfLengthRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecoveredSinceDowntimeOfLengthRequest.Merge(m, src) +} +func (m *RecoveredSinceDowntimeOfLengthRequest) XXX_Size() int { + return m.Size() +} +func (m *RecoveredSinceDowntimeOfLengthRequest) XXX_DiscardUnknown() { + xxx_messageInfo_RecoveredSinceDowntimeOfLengthRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_RecoveredSinceDowntimeOfLengthRequest proto.InternalMessageInfo + +func (m *RecoveredSinceDowntimeOfLengthRequest) GetDowntime() time.Duration { + if m != nil { + return m.Downtime + } + return 0 +} + +func (m *RecoveredSinceDowntimeOfLengthRequest) GetRecovery() time.Duration { + if m != nil { + return m.Recovery + } + return 0 +} + +type RecoveredSinceDowntimeOfLengthResponse struct { + SuccesfullyRecovered bool `protobuf:"varint,1,opt,name=succesfully_recovered,json=succesfullyRecovered,proto3" json:"succesfully_recovered,omitempty"` +} + +func (m *RecoveredSinceDowntimeOfLengthResponse) Reset() { + *m = RecoveredSinceDowntimeOfLengthResponse{} +} +func (m *RecoveredSinceDowntimeOfLengthResponse) String() string { return proto.CompactTextString(m) } +func (*RecoveredSinceDowntimeOfLengthResponse) ProtoMessage() {} +func (*RecoveredSinceDowntimeOfLengthResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b748b3d07fa8b8cb, []int{1} +} +func (m *RecoveredSinceDowntimeOfLengthResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RecoveredSinceDowntimeOfLengthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RecoveredSinceDowntimeOfLengthResponse.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 *RecoveredSinceDowntimeOfLengthResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_RecoveredSinceDowntimeOfLengthResponse.Merge(m, src) +} +func (m *RecoveredSinceDowntimeOfLengthResponse) XXX_Size() int { + return m.Size() +} +func (m *RecoveredSinceDowntimeOfLengthResponse) XXX_DiscardUnknown() { + xxx_messageInfo_RecoveredSinceDowntimeOfLengthResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_RecoveredSinceDowntimeOfLengthResponse proto.InternalMessageInfo + +func (m *RecoveredSinceDowntimeOfLengthResponse) GetSuccesfullyRecovered() bool { + if m != nil { + return m.SuccesfullyRecovered + } + return false +} + +type ParamsRequest struct { +} + +func (m *ParamsRequest) Reset() { *m = ParamsRequest{} } +func (m *ParamsRequest) String() string { return proto.CompactTextString(m) } +func (*ParamsRequest) ProtoMessage() {} +func (*ParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_b748b3d07fa8b8cb, []int{2} +} +func (m *ParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsRequest.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 *ParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsRequest.Merge(m, src) +} +func (m *ParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *ParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsRequest proto.InternalMessageInfo + +type ParamsResponse struct { + Params types1.Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *ParamsResponse) Reset() { *m = ParamsResponse{} } +func (m *ParamsResponse) String() string { return proto.CompactTextString(m) } +func (*ParamsResponse) ProtoMessage() {} +func (*ParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_b748b3d07fa8b8cb, []int{3} +} +func (m *ParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ParamsResponse.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 *ParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ParamsResponse.Merge(m, src) +} +func (m *ParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *ParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ParamsResponse proto.InternalMessageInfo + +func (m *ParamsResponse) GetParams() types1.Params { + if m != nil { + return m.Params + } + return types1.Params{} +} + +func init() { + proto.RegisterType((*RecoveredSinceDowntimeOfLengthRequest)(nil), "osmosis.downtimedetector.v1beta1.RecoveredSinceDowntimeOfLengthRequest") + proto.RegisterType((*RecoveredSinceDowntimeOfLengthResponse)(nil), "osmosis.downtimedetector.v1beta1.RecoveredSinceDowntimeOfLengthResponse") + proto.RegisterType((*ParamsRequest)(nil), "osmosis.downtimedetector.v1beta1.ParamsRequest") + proto.RegisterType((*ParamsResponse)(nil), "osmosis.downtimedetector.v1beta1.ParamsResponse") +} + +func init() { + proto.RegisterFile("osmosis/downtime-detector/v1beta1/query.proto", fileDescriptor_b748b3d07fa8b8cb) +} + +var fileDescriptor_b748b3d07fa8b8cb = []byte{ + // 527 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x54, 0x4f, 0x8b, 0xd3, 0x4c, + 0x18, 0x6f, 0xf6, 0x7d, 0x2d, 0xcb, 0x88, 0x0a, 0x61, 0x85, 0x6e, 0x91, 0x74, 0x09, 0x2a, 0xab, + 0xd2, 0x8c, 0xdd, 0xde, 0xbc, 0x59, 0x17, 0x75, 0x41, 0x50, 0xe3, 0x45, 0x14, 0x29, 0x93, 0xe9, + 0xd3, 0x6c, 0x20, 0x99, 0xc9, 0x66, 0x26, 0xd5, 0x5c, 0xfd, 0x04, 0x82, 0x17, 0x4f, 0xde, 0xfd, + 0x26, 0x7b, 0x5c, 0xf0, 0xe2, 0x69, 0xd5, 0xd6, 0x4f, 0xe0, 0x07, 0x10, 0x49, 0x66, 0x26, 0x94, + 0x22, 0xdb, 0x88, 0xa7, 0x36, 0xf3, 0xfc, 0xfe, 0x3e, 0x4c, 0x82, 0xfa, 0x5c, 0x24, 0x5c, 0x44, + 0x02, 0x4f, 0xf8, 0x6b, 0x26, 0xa3, 0x04, 0xfa, 0x13, 0x90, 0x40, 0x25, 0xcf, 0xf0, 0x6c, 0x10, + 0x80, 0x24, 0x03, 0x7c, 0x94, 0x43, 0x56, 0x78, 0x69, 0xc6, 0x25, 0xb7, 0x77, 0x34, 0xdc, 0x33, + 0x70, 0x83, 0xf6, 0x34, 0xba, 0xbb, 0x15, 0xf2, 0x90, 0x57, 0x60, 0x5c, 0xfe, 0x53, 0xbc, 0x2e, + 0x5e, 0x6f, 0x13, 0x02, 0x83, 0x52, 0x59, 0x11, 0x1c, 0x5a, 0x31, 0x70, 0x40, 0x04, 0xd4, 0x10, + 0xca, 0x23, 0xa6, 0xe7, 0x37, 0x97, 0xe7, 0x55, 0xc2, 0x1a, 0x95, 0x92, 0x30, 0x62, 0x44, 0x46, + 0xdc, 0x60, 0xaf, 0x84, 0x9c, 0x87, 0x31, 0x60, 0x92, 0x46, 0x98, 0x30, 0xc6, 0x65, 0x35, 0x34, + 0x4e, 0xdb, 0x7a, 0x5a, 0x3d, 0x05, 0xf9, 0x14, 0x13, 0x56, 0x98, 0x91, 0x32, 0x19, 0xab, 0x3a, + 0xea, 0xc1, 0xe4, 0x5b, 0x65, 0x4d, 0xf2, 0x6c, 0xd9, 0xb3, 0xb7, 0x3a, 0x2f, 0x4b, 0x0b, 0x49, + 0x92, 0x54, 0x01, 0xdc, 0xef, 0x16, 0xba, 0xe6, 0x03, 0xe5, 0x33, 0xc8, 0x60, 0xf2, 0x2c, 0x62, + 0x14, 0xf6, 0xf5, 0x6a, 0x1e, 0x4f, 0x1f, 0x01, 0x0b, 0xe5, 0xa1, 0x0f, 0x47, 0x39, 0x08, 0x69, + 0xbf, 0x44, 0x9b, 0x66, 0x6b, 0x1d, 0x6b, 0xc7, 0xda, 0x3d, 0xbf, 0xb7, 0xed, 0x29, 0x75, 0xcf, + 0xa8, 0x7b, 0xfb, 0xda, 0x7d, 0x74, 0xf5, 0xf8, 0xb4, 0xd7, 0xfa, 0x79, 0xda, 0xeb, 0x14, 0x24, + 0x89, 0xef, 0xb8, 0x86, 0x38, 0x36, 0xf1, 0xdc, 0x0f, 0x5f, 0x7b, 0x96, 0x5f, 0x0b, 0x96, 0xe2, + 0x99, 0x4a, 0x51, 0x74, 0x36, 0xfe, 0x52, 0xdc, 0x10, 0x57, 0xc5, 0xcd, 0xb9, 0xfb, 0x0a, 0x5d, + 0x5f, 0x57, 0x51, 0xa4, 0x9c, 0x09, 0xb0, 0x87, 0xe8, 0xb2, 0xc8, 0x29, 0x05, 0x31, 0xcd, 0xe3, + 0xb8, 0x18, 0x67, 0x86, 0x55, 0x15, 0xde, 0xf4, 0xb7, 0x96, 0x86, 0xb5, 0xa2, 0x7b, 0x09, 0x5d, + 0x78, 0x42, 0x32, 0x92, 0x08, 0xbd, 0x29, 0xf7, 0x39, 0xba, 0x68, 0x0e, 0xb4, 0xee, 0x7d, 0xd4, + 0x4e, 0xab, 0x13, 0xbd, 0xb9, 0x5d, 0x6f, 0xdd, 0x05, 0xf6, 0x94, 0xc2, 0xe8, 0xff, 0xb2, 0xab, + 0xaf, 0xd9, 0x7b, 0x9f, 0xfe, 0x43, 0xe7, 0x9e, 0x96, 0xb7, 0xcc, 0xfe, 0x68, 0xa1, 0xb6, 0x82, + 0xd8, 0xb8, 0xa9, 0x98, 0xce, 0xd7, 0xbd, 0xdd, 0x9c, 0xa0, 0xf2, 0xbb, 0x83, 0xb7, 0x9f, 0x7f, + 0xbc, 0xdf, 0xb8, 0x65, 0xdf, 0x68, 0xf0, 0x02, 0xe9, 0x54, 0xbf, 0x2c, 0xe4, 0x9c, 0xbd, 0x75, + 0xfb, 0xc1, 0xfa, 0x1c, 0x8d, 0xae, 0x66, 0xf7, 0xe1, 0xbf, 0x0b, 0xe9, 0xa2, 0x07, 0x55, 0xd1, + 0x7b, 0xf6, 0xdd, 0x06, 0x45, 0xcf, 0x96, 0x1c, 0xd1, 0xe3, 0xb9, 0x63, 0x9d, 0xcc, 0x1d, 0xeb, + 0xdb, 0xdc, 0xb1, 0xde, 0x2d, 0x9c, 0xd6, 0xc9, 0xc2, 0x69, 0x7d, 0x59, 0x38, 0xad, 0x17, 0x07, + 0x61, 0x24, 0x0f, 0xf3, 0xc0, 0xa3, 0x3c, 0x31, 0x36, 0xfd, 0x98, 0x04, 0xa2, 0xf6, 0x9c, 0x0d, + 0x86, 0xf8, 0xcd, 0x1f, 0x9c, 0x69, 0x1c, 0x01, 0x93, 0xea, 0x3b, 0xa3, 0x5e, 0x8b, 0x76, 0xf5, + 0x33, 0xfc, 0x1d, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x09, 0x15, 0x2a, 0x40, 0x05, 0x00, 0x00, +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +const _ = grpc.SupportPackageIsVersion4 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) + RecoveredSinceDowntimeOfLength(ctx context.Context, in *RecoveredSinceDowntimeOfLengthRequest, opts ...grpc.CallOption) (*RecoveredSinceDowntimeOfLengthResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *ParamsRequest, opts ...grpc.CallOption) (*ParamsResponse, error) { + out := new(ParamsResponse) + err := c.cc.Invoke(ctx, "/osmosis.downtimedetector.v1beta1.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) RecoveredSinceDowntimeOfLength(ctx context.Context, in *RecoveredSinceDowntimeOfLengthRequest, opts ...grpc.CallOption) (*RecoveredSinceDowntimeOfLengthResponse, error) { + out := new(RecoveredSinceDowntimeOfLengthResponse) + err := c.cc.Invoke(ctx, "/osmosis.downtimedetector.v1beta1.Query/RecoveredSinceDowntimeOfLength", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + Params(context.Context, *ParamsRequest) (*ParamsResponse, error) + RecoveredSinceDowntimeOfLength(context.Context, *RecoveredSinceDowntimeOfLengthRequest) (*RecoveredSinceDowntimeOfLengthResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *ParamsRequest) (*ParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) RecoveredSinceDowntimeOfLength(ctx context.Context, req *RecoveredSinceDowntimeOfLengthRequest) (*RecoveredSinceDowntimeOfLengthResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RecoveredSinceDowntimeOfLength not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.downtimedetector.v1beta1.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*ParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_RecoveredSinceDowntimeOfLength_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(RecoveredSinceDowntimeOfLengthRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).RecoveredSinceDowntimeOfLength(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/osmosis.downtimedetector.v1beta1.Query/RecoveredSinceDowntimeOfLength", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).RecoveredSinceDowntimeOfLength(ctx, req.(*RecoveredSinceDowntimeOfLengthRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "osmosis.downtimedetector.v1beta1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "RecoveredSinceDowntimeOfLength", + Handler: _Query_RecoveredSinceDowntimeOfLength_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "osmosis/downtime-detector/v1beta1/query.proto", +} + +func (m *RecoveredSinceDowntimeOfLengthRequest) 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 *RecoveredSinceDowntimeOfLengthRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecoveredSinceDowntimeOfLengthRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Recovery, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Recovery):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintQuery(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x12 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Downtime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Downtime):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintQuery(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *RecoveredSinceDowntimeOfLengthResponse) 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 *RecoveredSinceDowntimeOfLengthResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RecoveredSinceDowntimeOfLengthResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.SuccesfullyRecovered { + i-- + if m.SuccesfullyRecovered { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *ParamsRequest) 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 *ParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *ParamsResponse) 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 *ParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RecoveredSinceDowntimeOfLengthRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Downtime) + n += 1 + l + sovQuery(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Recovery) + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *RecoveredSinceDowntimeOfLengthResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.SuccesfullyRecovered { + n += 2 + } + return n +} + +func (m *ParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *ParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RecoveredSinceDowntimeOfLengthRequest) 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: RecoveredSinceDowntimeOfLengthRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecoveredSinceDowntimeOfLengthRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Downtime", 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.StdDurationUnmarshal(&m.Downtime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Recovery", 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.StdDurationUnmarshal(&m.Recovery, 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 (m *RecoveredSinceDowntimeOfLengthResponse) 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: RecoveredSinceDowntimeOfLengthResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RecoveredSinceDowntimeOfLengthResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field SuccesfullyRecovered", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.SuccesfullyRecovered = bool(v != 0) + 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 *ParamsRequest) 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: ParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *ParamsResponse) 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: ParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/downtime-detector/client/queryproto/query.pb.gw.go b/x/downtime-detector/client/queryproto/query.pb.gw.go new file mode 100644 index 00000000000..0ff2bcbe174 --- /dev/null +++ b/x/downtime-detector/client/queryproto/query.pb.gw.go @@ -0,0 +1,236 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: osmosis/downtime-detector/v1beta1/query.proto + +/* +Package queryproto is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package queryproto + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq ParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_RecoveredSinceDowntimeOfLength_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_RecoveredSinceDowntimeOfLength_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecoveredSinceDowntimeOfLengthRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecoveredSinceDowntimeOfLength_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.RecoveredSinceDowntimeOfLength(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_RecoveredSinceDowntimeOfLength_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq RecoveredSinceDowntimeOfLengthRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_RecoveredSinceDowntimeOfLength_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.RecoveredSinceDowntimeOfLength(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. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + 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_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecoveredSinceDowntimeOfLength_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_RecoveredSinceDowntimeOfLength_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_RecoveredSinceDowntimeOfLength_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_RecoveredSinceDowntimeOfLength_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_RecoveredSinceDowntimeOfLength_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_RecoveredSinceDowntimeOfLength_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "downtime-detector", "v1beta1", "Params"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_RecoveredSinceDowntimeOfLength_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"osmosis", "downtime-detector", "v1beta1", "RecoveredSinceDowntimeOfLength"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_RecoveredSinceDowntimeOfLength_0 = runtime.ForwardResponseMessage +) diff --git a/x/downtime-detector/downtimedetector_module/module.go b/x/downtime-detector/downtimedetector_module/module.go new file mode 100644 index 00000000000..fc3c2ec7852 --- /dev/null +++ b/x/downtime-detector/downtimedetector_module/module.go @@ -0,0 +1,119 @@ +package downtimemodule + +import ( + "context" + "encoding/json" + "fmt" + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + + downtimedetector "github.com/osmosis-labs/osmosis/v13/x/downtime-detector" + "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types" + twapcli "github.com/osmosis-labs/osmosis/v13/x/twap/client/cli" + "github.com/osmosis-labs/osmosis/v13/x/twap/client/queryproto" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +type AppModuleBasic struct{} + +func (AppModuleBasic) Name() string { return types.ModuleName } + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { +} + +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +func (b AppModuleBasic) RegisterRESTRoutes(ctx client.Context, r *mux.Router) { +} + +func (b AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + queryproto.RegisterQueryHandlerClient(context.Background(), mux, queryproto.NewQueryClient(clientCtx)) //nolint:errcheck +} + +func (b AppModuleBasic) GetTxCmd() *cobra.Command { + return nil +} + +func (b AppModuleBasic) GetQueryCmd() *cobra.Command { + return twapcli.GetQueryCmd() +} + +func (AppModuleBasic) RegisterInterfaces(registry codectypes.InterfaceRegistry) { +} + +type AppModule struct { + AppModuleBasic + + k downtimedetector.Keeper +} + +func (am AppModule) RegisterServices(cfg module.Configurator) { + // queryproto.RegisterQueryServer(cfg.QueryServer(), grpc.Querier{Q: twapclient.Querier{K: am.k}}) +} + +func NewAppModule(k downtimedetector.Keeper) AppModule { + return AppModule{ + AppModuleBasic: AppModuleBasic{}, + k: k, + } +} + +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { +} + +func (am AppModule) Route() sdk.Route { + return sdk.Route{} +} + +func (AppModule) QuerierRoute() string { return types.RouterKey } + +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { + return func(sdk.Context, []string, abci.RequestQuery) ([]byte, error) { + return nil, fmt.Errorf("legacy querier not supported for the x/%s module", types.ModuleName) + } +} + +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + + cdc.MustUnmarshalJSON(gs, &genesisState) + + am.k.InitGenesis(ctx, &genesisState) + return []abci.ValidatorUpdate{} +} + +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := am.k.ExportGenesis(ctx) + return cdc.MustMarshalJSON(genState) +} + +func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +func (am AppModule) EndBlock(ctx sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} + +func (AppModule) ConsensusVersion() uint64 { return 1 } diff --git a/x/downtime-detector/keeper.go b/x/downtime-detector/keeper.go new file mode 100644 index 00000000000..c9c10f994f8 --- /dev/null +++ b/x/downtime-detector/keeper.go @@ -0,0 +1,52 @@ +package downtimedetector + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/osmosis-labs/osmosis/v13/x/downtime-detector/types" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type Keeper struct { + storeKey sdk.StoreKey + + paramSpace paramtypes.Subspace +} + +func NewKeeper(storeKey sdk.StoreKey, paramSpace paramtypes.Subspace) *Keeper { + // set KeyTable if it has not already been set + // if !paramSpace.HasKeyTable() { + // paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable()) + // } + + return &Keeper{storeKey: storeKey, paramSpace: paramSpace} +} + +// GetParams returns the total set of twap parameters. +// func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) { +// k.paramSpace.GetParamSet(ctx, ¶ms) +// return params +// } + +// // SetParams sets the total set of twap parameters. +// func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { +// k.paramSpace.SetParamSet(ctx, ¶ms) +// } + +// InitGenesis initializes the twap module's state from a provided genesis +// state. +func (k Keeper) InitGenesis(ctx sdk.Context, genState *types.GenesisState) { + if err := genState.Validate(); err != nil { + panic(err) + } + + // k.SetParams(ctx, genState.Params) +} + +// ExportGenesis returns the twap module's exported genesis. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + return &types.GenesisState{ + // Params: k.GetParams(ctx), + } +} diff --git a/x/downtime-detector/types/constants.go b/x/downtime-detector/types/constants.go new file mode 100644 index 00000000000..e01b37548c9 --- /dev/null +++ b/x/downtime-detector/types/constants.go @@ -0,0 +1,9 @@ +package types + +const ( + ModuleName = "downtime-detector" + StoreKey = ModuleName + RouterKey = ModuleName + + QuerierRoute = ModuleName +) diff --git a/x/downtime-detector/types/genesis.go b/x/downtime-detector/types/genesis.go new file mode 100644 index 00000000000..39508cca25b --- /dev/null +++ b/x/downtime-detector/types/genesis.go @@ -0,0 +1,9 @@ +package types + +func DefaultGenesis() *GenesisState { + return &GenesisState{} +} + +func (g *GenesisState) Validate() error { + return nil +} diff --git a/x/downtime-detector/types/genesis.pb.go b/x/downtime-detector/types/genesis.pb.go new file mode 100644 index 00000000000..75e41db1a3d --- /dev/null +++ b/x/downtime-detector/types/genesis.pb.go @@ -0,0 +1,798 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: osmosis/downtime-detector/v1beta1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + _ "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + 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. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params holds parameters for the downtime-detector module +type Params struct { +} + +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_4581e137a44782af, []int{0} +} +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 + +type GenesisDowntimeEntry struct { + DowntimeDuration time.Duration `protobuf:"bytes,1,opt,name=downtime_duration,json=downtimeDuration,proto3,stdduration" json:"downtime_duration" yaml:"downtime_duration"` + LastDowntime time.Time `protobuf:"bytes,2,opt,name=last_downtime,json=lastDowntime,proto3,stdtime" json:"last_downtime" yaml:"last_downtime"` +} + +func (m *GenesisDowntimeEntry) Reset() { *m = GenesisDowntimeEntry{} } +func (m *GenesisDowntimeEntry) String() string { return proto.CompactTextString(m) } +func (*GenesisDowntimeEntry) ProtoMessage() {} +func (*GenesisDowntimeEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_4581e137a44782af, []int{1} +} +func (m *GenesisDowntimeEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisDowntimeEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisDowntimeEntry.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 *GenesisDowntimeEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisDowntimeEntry.Merge(m, src) +} +func (m *GenesisDowntimeEntry) XXX_Size() int { + return m.Size() +} +func (m *GenesisDowntimeEntry) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisDowntimeEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisDowntimeEntry proto.InternalMessageInfo + +func (m *GenesisDowntimeEntry) GetDowntimeDuration() time.Duration { + if m != nil { + return m.DowntimeDuration + } + return 0 +} + +func (m *GenesisDowntimeEntry) GetLastDowntime() time.Time { + if m != nil { + return m.LastDowntime + } + return time.Time{} +} + +// GenesisState defines the twap module's genesis state. +type GenesisState struct { + Downtimes []GenesisDowntimeEntry `protobuf:"bytes,1,rep,name=downtimes,proto3" json:"downtimes"` + LastBlockTime time.Time `protobuf:"bytes,2,opt,name=last_block_time,json=lastBlockTime,proto3,stdtime" json:"last_block_time" yaml:"last_block_time"` + // params is the container of twap parameters. + Params Params `protobuf:"bytes,3,opt,name=params,proto3" json:"params"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_4581e137a44782af, []int{2} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetDowntimes() []GenesisDowntimeEntry { + if m != nil { + return m.Downtimes + } + return nil +} + +func (m *GenesisState) GetLastBlockTime() time.Time { + if m != nil { + return m.LastBlockTime + } + return time.Time{} +} + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func init() { + proto.RegisterType((*Params)(nil), "osmosis.downtimedetector.v1beta1.Params") + proto.RegisterType((*GenesisDowntimeEntry)(nil), "osmosis.downtimedetector.v1beta1.GenesisDowntimeEntry") + proto.RegisterType((*GenesisState)(nil), "osmosis.downtimedetector.v1beta1.GenesisState") +} + +func init() { + proto.RegisterFile("osmosis/downtime-detector/v1beta1/genesis.proto", fileDescriptor_4581e137a44782af) +} + +var fileDescriptor_4581e137a44782af = []byte{ + // 432 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x93, 0x4f, 0x8b, 0xd3, 0x40, + 0x18, 0xc6, 0x33, 0xbb, 0x52, 0x74, 0x76, 0x45, 0x0d, 0x45, 0xb2, 0x3d, 0x24, 0x21, 0x78, 0xe8, + 0x65, 0x67, 0xe8, 0x2e, 0x78, 0x10, 0xbc, 0x84, 0xaa, 0x57, 0xa9, 0x82, 0xd0, 0x4b, 0x98, 0xa4, + 0xd3, 0x18, 0x4c, 0x32, 0x21, 0x33, 0xad, 0xe6, 0x5b, 0xf4, 0x28, 0x7e, 0xa2, 0x1e, 0x7b, 0xf4, + 0x54, 0xa5, 0x3d, 0x78, 0xf7, 0x13, 0x48, 0xe6, 0x8f, 0xd5, 0xb6, 0xd0, 0xbd, 0x25, 0xf3, 0x3e, + 0xcf, 0xf3, 0xbe, 0xbf, 0x19, 0x5e, 0x88, 0x19, 0x2f, 0x18, 0xcf, 0x38, 0x9e, 0xb0, 0xcf, 0xa5, + 0xc8, 0x0a, 0x7a, 0x3d, 0xa1, 0x82, 0x26, 0x82, 0xd5, 0x78, 0x3e, 0x88, 0xa9, 0x20, 0x03, 0x9c, + 0xd2, 0x92, 0xf2, 0x8c, 0xa3, 0xaa, 0x66, 0x82, 0xd9, 0xbe, 0x36, 0x20, 0x63, 0x30, 0x7a, 0xa4, + 0xf5, 0xbd, 0x6e, 0xca, 0x52, 0x26, 0xc5, 0xb8, 0xfd, 0x52, 0xbe, 0xde, 0x55, 0xca, 0x58, 0x9a, + 0x53, 0x2c, 0xff, 0xe2, 0xd9, 0x14, 0x93, 0xb2, 0x31, 0xa5, 0x44, 0x66, 0x46, 0xca, 0xa3, 0x7e, + 0x74, 0xc9, 0xdd, 0x77, 0x4d, 0x66, 0x35, 0x11, 0x19, 0x2b, 0x75, 0xdd, 0xdb, 0xaf, 0xb7, 0x13, + 0x71, 0x41, 0x8a, 0x4a, 0x09, 0x82, 0xfb, 0xb0, 0xf3, 0x96, 0xd4, 0xa4, 0xe0, 0xc1, 0x2f, 0x00, + 0xbb, 0x6f, 0x14, 0xca, 0x50, 0x8f, 0xfe, 0xaa, 0x14, 0x75, 0x63, 0xe7, 0xf0, 0x89, 0x61, 0x89, + 0x4c, 0xbc, 0x03, 0x7c, 0xd0, 0xbf, 0xb8, 0xb9, 0x42, 0x2a, 0x1f, 0x99, 0x7c, 0x34, 0xd4, 0x82, + 0xf0, 0xd9, 0x72, 0xed, 0x59, 0xbf, 0xd7, 0x9e, 0xd3, 0x90, 0x22, 0x7f, 0x11, 0x1c, 0x24, 0x04, + 0x5f, 0x7f, 0x78, 0x60, 0xf4, 0xd8, 0x9c, 0x1b, 0x9f, 0x4d, 0xe0, 0xc3, 0x9c, 0x70, 0x11, 0x99, + 0x82, 0x73, 0x26, 0x3b, 0xf5, 0x0e, 0x3a, 0xbd, 0x37, 0x24, 0xa1, 0xaf, 0x5b, 0x75, 0x55, 0xab, + 0xff, 0xec, 0xc1, 0xa2, 0x6d, 0x73, 0xd9, 0x9e, 0x19, 0xaa, 0xe0, 0xdb, 0x19, 0xbc, 0xd4, 0xa4, + 0xef, 0x04, 0x11, 0xd4, 0x1e, 0xc3, 0x07, 0x46, 0xcf, 0x1d, 0xe0, 0x9f, 0xf7, 0x2f, 0x6e, 0x9e, + 0xa3, 0x53, 0xef, 0x88, 0x8e, 0x5d, 0x56, 0x78, 0xaf, 0x9d, 0x65, 0xb4, 0x8b, 0xb3, 0xa7, 0xf0, + 0x91, 0x1c, 0x28, 0xce, 0x59, 0xf2, 0x29, 0xba, 0x23, 0x51, 0xa0, 0x89, 0x9e, 0xfe, 0x43, 0xb4, + 0x0b, 0x50, 0x4c, 0xf2, 0x9a, 0xc2, 0xf6, 0xb0, 0xf5, 0xd9, 0xaf, 0x61, 0xa7, 0x92, 0x0f, 0xe9, + 0x9c, 0xcb, 0xf8, 0xfe, 0x69, 0x00, 0xf5, 0xf0, 0x7a, 0x64, 0xed, 0x0e, 0x3f, 0x2c, 0x37, 0x2e, + 0x58, 0x6d, 0x5c, 0xf0, 0x73, 0xe3, 0x82, 0xc5, 0xd6, 0xb5, 0x56, 0x5b, 0xd7, 0xfa, 0xbe, 0x75, + 0xad, 0xf1, 0xcb, 0x34, 0x13, 0x1f, 0x67, 0x31, 0x4a, 0x58, 0x61, 0xb6, 0xe2, 0x3a, 0x27, 0x31, + 0xff, 0xbb, 0x22, 0xf3, 0xc1, 0x2d, 0xfe, 0x72, 0x64, 0x51, 0x44, 0x53, 0x51, 0x1e, 0x77, 0x24, + 0xe7, 0xed, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x1c, 0x59, 0x62, 0x52, 0x03, 0x00, 0x00, +} + +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 + return len(dAtA) - i, nil +} + +func (m *GenesisDowntimeEntry) 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 *GenesisDowntimeEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisDowntimeEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastDowntime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastDowntime):]) + if err1 != nil { + return 0, err1 + } + i -= n1 + i = encodeVarintGenesis(dAtA, i, uint64(n1)) + i-- + dAtA[i] = 0x12 + n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.DowntimeDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.DowntimeDuration):]) + if err2 != nil { + return 0, err2 + } + i -= n2 + i = encodeVarintGenesis(dAtA, i, uint64(n2)) + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) 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 = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + n4, err4 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.LastBlockTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime):]) + if err4 != nil { + return 0, err4 + } + i -= n4 + i = encodeVarintGenesis(dAtA, i, uint64(n4)) + i-- + dAtA[i] = 0x12 + if len(m.Downtimes) > 0 { + for iNdEx := len(m.Downtimes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Downtimes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GenesisDowntimeEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.DowntimeDuration) + n += 1 + l + sovGenesis(uint64(l)) + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastDowntime) + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Downtimes) > 0 { + for _, e := range m.Downtimes { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + l = github_com_gogo_protobuf_types.SizeOfStdTime(m.LastBlockTime) + n += 1 + l + sovGenesis(uint64(l)) + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +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 ErrIntOverflowGenesis + } + 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 { + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisDowntimeEntry) 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 ErrIntOverflowGenesis + } + 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: GenesisDowntimeEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisDowntimeEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DowntimeDuration", 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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.DowntimeDuration, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastDowntime", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastDowntime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Downtimes", 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 + } + m.Downtimes = append(m.Downtimes, GenesisDowntimeEntry{}) + if err := m.Downtimes[len(m.Downtimes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field LastBlockTime", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.LastBlockTime, dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + 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 + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/ibc-rate-limit/testutil/wasm.go b/x/ibc-rate-limit/testutil/wasm.go index b764bfa4544..41d624da74a 100644 --- a/x/ibc-rate-limit/testutil/wasm.go +++ b/x/ibc-rate-limit/testutil/wasm.go @@ -2,7 +2,7 @@ package osmosisibctesting import ( "fmt" - "io/ioutil" + "os" "github.com/stretchr/testify/require" @@ -11,15 +11,16 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" - "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" "github.com/stretchr/testify/suite" + + "github.com/osmosis-labs/osmosis/v13/x/ibc-rate-limit/types" ) func (chain *TestChain) StoreContractCode(suite *suite.Suite, path string) { osmosisApp := chain.GetOsmosisApp() govKeeper := osmosisApp.GovKeeper - wasmCode, err := ioutil.ReadFile(path) + wasmCode, err := os.ReadFile(path) suite.Require().NoError(err) addr := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName)