Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add oracle miss counters and ibc inflows grpc api #2352

Merged
merged 9 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions proto/umee/oracle/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,35 @@ service Query {
option (google.api.http).get =
"/umee/oracle/v1/denoms/exg_rates_timestamp";
}

// MissCounters returns oracle missing votes count of validators.
rpc MissCounters(QueryMissCounters)
returns (QueryMissCountersResponse) {
option (google.api.http).get =
"/umee/oracle/v1/miss_counters";
}
}

// QueryMissCounters is the request type for the Query/MissCounters RPC
// method.
message QueryMissCounters {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
string validator = 1;
}

// QueryMissCountersResponse is response type for the Query/MissCounters RPC method.
message QueryMissCountersResponse {
repeated PriceMissCounter miss_counters = 1 [
(gogoproto.nullable) = false
];
}

// PriceMissCounter is the validator's oracle price votes missing count.
message PriceMissCounter {
string validator = 1;
// miss_counter defines the oracle miss counter of a validator
uint64 miss_counter = 2;
}

// QueryExgRatesWithTimestamp is the request type for the Query/ExchangeRatesWithTimestamp RPC
Expand Down
43 changes: 43 additions & 0 deletions proto/umee/uibc/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "umee/uibc/v1/quota.proto";
import "google/protobuf/timestamp.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/umee-network/umee/v6/x/uibc";
Expand All @@ -28,6 +29,48 @@ service Query {
rpc AllOutflows(QueryAllOutflows) returns (QueryAllOutflowsResponse) {
option (google.api.http).get = "/umee/uibc/v1/all_outflows";
}

// Inflows returns registered IBC denoms inflows in the current quota period.
// If denom is not specified, returns sum of all registered inflows.
rpc Inflows(QueryInflows) returns (QueryInflowsResponse) {
option (google.api.http).get = "/umee/uibc/v1/inflows";
}

// QuotaExpires returns when current ibc quota will end.
rpc QuotaExpires(QueryQuotaExpires) returns (QueryQuotaExpiresResponse) {
option (google.api.http).get = "/umee/uibc/v1/quota_expires";
}
}

// QueryAllInflows defines request type for query the inflow quota of registered denoms.
message QueryQuotaExpires {}

// QueryAllInflowsResponse defines response type of Query/AllInflows
message QueryQuotaExpiresResponse {
google.protobuf.Timestamp end_time = 4 [
(gogoproto.nullable) = false,
(gogoproto.stdtime) = true,
(gogoproto.jsontag) = "end_time,omitempty",
(gogoproto.moretags) = "yaml:\"end_time\""
];
}

// QueryInflows defines request type for query the inflow quota of denoms
message QueryInflows {
string denom = 1;
}

// QueryInflowsResponse defines response type of Query/Inflows
message QueryInflowsResponse {
string sum = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec",
(gogoproto.nullable) = false
];
repeated cosmos.base.v1beta1.DecCoin inflows = 2 [
(gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.DecCoin",
(gogoproto.nullable) = false
];
}

// QueryParams defines the request structure for the Params gRPC service
Expand Down
35 changes: 35 additions & 0 deletions x/oracle/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,38 @@ func (q querier) ExgRatesWithTimestamp(

return &types.QueryExgRatesWithTimestampResponse{ExgRates: exgRates}, nil
}

// MissCounters implements types.QueryServer.
func (q querier) MissCounters(goCtx context.Context, req *types.QueryMissCounters) (*types.QueryMissCountersResponse,
error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

gsk967 marked this conversation as resolved.
Show resolved Hide resolved
ctx := sdk.UnwrapSDKContext(goCtx)

var pfMissCounts []types.PriceMissCounter
if len(req.Validator) != 0 {
valAddr, err := sdk.ValAddressFromBech32(req.Validator)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())
}
missCounter := q.GetMissCounter(ctx, valAddr)
pfMissCounts = append(pfMissCounts, types.PriceMissCounter{
Validator: req.Validator,
MissCounter: missCounter,
})
} else {
q.IterateMissCounters(ctx, func(val sdk.ValAddress, u uint64) bool {
pfMissCounts = append(pfMissCounts, types.PriceMissCounter{
Validator: val.String(),
MissCounter: u,
})
return false
})
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
}

return &types.QueryMissCountersResponse{
MissCounters: pfMissCounts,
}, nil
}
Loading
Loading