Skip to content

Commit

Permalink
query protos
Browse files Browse the repository at this point in the history
  • Loading branch information
xmariachi committed Dec 13, 2024
1 parent 5deb1f1 commit 3487d17
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
26 changes: 26 additions & 0 deletions x/emissions/keeper/queryserver/query_server_inferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,32 @@ func (qs queryServer) GetNetworkInferencesAtBlock(ctx context.Context, req *emis
return &emissionstypes.GetNetworkInferencesAtBlockResponse{NetworkInferences: result.NetworkInferences}, nil
}

// An outlier resistant version of GetNetworkInferencesAtBlock
// TODO implement
func (qs queryServer) GetNetworkInferencesAtBlockOutlierResistant(ctx context.Context, req *emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest) (_ *emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse, err error) {

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / custom-linters

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / custom-linters

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse (typecheck)

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse) (typecheck)

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / lint

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse) (typecheck)

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / test

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantRequest

Check failure on line 103 in x/emissions/keeper/queryserver/query_server_inferences.go

View workflow job for this annotation

GitHub Actions / test

undefined: emissionstypes.GetNetworkInferencesAtBlockOutlierResistantResponse
defer metrics.RecordMetrics("GetNetworkInferencesAtBlockOutlierResistant", time.Now(), &err)

topic, err := qs.k.GetTopic(ctx, req.TopicId)
if err != nil {
return nil, status.Errorf(codes.NotFound, "topic %v not found", req.TopicId)
}
if topic.EpochLastEnded == 0 {
return nil, status.Errorf(codes.NotFound, "network inference not available for topic %v", req.TopicId)
}

result, err := synth.GetNetworkInferences(
sdk.UnwrapSDKContext(ctx),
qs.k,
req.TopicId,
&req.BlockHeightLastInference,
)
if err != nil {
return nil, err
}

return &emissionstypes.GetNetworkInferencesAtBlockResponse{NetworkInferences: result.NetworkInferences}, nil
}

// Return full set of inferences in I_i from the chain, as well as weights and forecast implied inferences
func (qs queryServer) GetLatestNetworkInferences(ctx context.Context, req *emissionstypes.GetLatestNetworkInferencesRequest) (_ *emissionstypes.GetLatestNetworkInferencesResponse, err error) {
defer metrics.RecordMetrics("GetLatestNetworkInferences", time.Now(), &err)
Expand Down
9 changes: 9 additions & 0 deletions x/emissions/module/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,15 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions {
{ProtoField: "block_height_last_inference"},
},
},
{
RpcMethod: "GetNetworkInferencesAtBlockOutlierResistant",
Use: "network-inferences-at-block-outlier-resistant [topic_id] [block_height_last_inference]",
Short: "Get the Network Inferences for a topic at a block height where the last inference was made",
PositionalArgs: []*autocliv1.PositionalArgDescriptor{
{ProtoField: "topic_id"},
{ProtoField: "block_height_last_inference"},
},
},
{
RpcMethod: "GetLatestNetworkInferences",
Use: "latest-network-inferences [topic_id]",
Expand Down
15 changes: 15 additions & 0 deletions x/emissions/proto/emissions/v6/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ service QueryService {
option (google.api.http).get = "/emissions/v6/network_inferences/{topic_id}/last_inference/{block_height_last_inference}";
}

rpc GetNetworkInferencesAtBlockOutlierResistant(GetNetworkInferencesAtBlockOutlierResistantRequest) returns (GetNetworkInferencesAtBlockOutlierResistantResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get =
"/emissions/v6/network_inferences_outlier_resistant/{topic_id}/last_inference/{block_height_last_inference}";
}

rpc GetLatestNetworkInferences(GetLatestNetworkInferencesRequest) returns (GetLatestNetworkInferencesResponse) {
option (cosmos.query.v1.module_query_safe) = true;
option (google.api.http).get = "/emissions/v6/latest_network_inferences/{topic_id}";
Expand Down Expand Up @@ -897,6 +903,11 @@ message GetNetworkInferencesAtBlockRequest {
int64 block_height_last_inference = 2;
}

message GetNetworkInferencesAtBlockOutlierResistantRequest {
uint64 topic_id = 1;
int64 block_height_last_inference = 2;
}

message GetLatestNetworkInferencesRequest {
uint64 topic_id = 1;
}
Expand Down Expand Up @@ -971,6 +982,10 @@ message GetNetworkInferencesAtBlockResponse {
emissions.v3.ValueBundle network_inferences = 1;
}

message GetNetworkInferencesAtBlockOutlierResistantResponse {
emissions.v3.ValueBundle network_inferences = 1;
}

message GetLatestNetworkInferencesResponse {
reserved 4;
reserved "forecast_implied_inferences";
Expand Down

0 comments on commit 3487d17

Please sign in to comment.