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: added rest api for query the gov params #9979

Closed
wants to merge 4 commits into from
Closed

feat: added rest api for query the gov params #9979

wants to merge 4 commits into from

Conversation

gsk967
Copy link
Contributor

@gsk967 gsk967 commented Aug 21, 2021

Description

Closes: #9970
Added new rest api for query the params of gov module same like other modules x/module


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • followed the guidelines for building modules
  • included the necessary unit and integration tests
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed ! in the type prefix if API or client breaking change
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

@codecov
Copy link

codecov bot commented Aug 21, 2021

Codecov Report

Merging #9979 (0bc1088) into master (a87d4dc) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9979   +/-   ##
=======================================
  Coverage   63.80%   63.81%           
=======================================
  Files         566      566           
  Lines       53363    53374   +11     
=======================================
+ Hits        34047    34058   +11     
  Misses      17397    17397           
  Partials     1919     1919           
Impacted Files Coverage Δ
x/gov/keeper/grpc_query.go 74.75% <100.00%> (+1.45%) ⬆️

@gsk967 gsk967 marked this pull request as ready for review August 21, 2021 02:56
@amaury1093
Copy link
Contributor

The linked issue proposes

We should rather update x/gov to treat its parameters like the rest of the modules rather than make a one off gRPC change.

which is a solution that I prefer over this one. Wdyt @gsk967 ?

@alexanderbez
Copy link
Contributor

Thanks for the contribution @gsk967! Do you think you could instead take the approach on changing the x/gov parameter structure instead? Let us know if you need a hand or some guidance.

@gsk967
Copy link
Contributor Author

gsk967 commented Aug 24, 2021

Okay I will change the params struct for gov module @alexanderbez
Please can you check the changes

// Genesis State 
message GenesisState {
    ....
    Params params = 5  [(gogoproto.nullable) = false];
}

message Params {
    Deposit deposit = 1 
    Tally tally = 2 
    Voting voting = 3 
}



// GRPC Query 
service Query {
    rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
        option (google.api.http).get = "/cosmos/gov/v1beta1/params";
    }

    rpc Param(QueryParamRequest) returns (QueryParamResponse){
        option (google.api.http).get = "/cosmos/gov/v1beta1/params/{params_type}";
    }
}


message QueryParamsRequest {
}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
    Params params = 1 [(gogoproto.nullable) = false];
}

message QueryParamRequest {
  // "voting", "tallying" or "deposit".
  string params_type = 1;
}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
    oneof Param {
        Voting voting = 1 [(gogoproto.nullable) = false];
        Deposit deposit = 2 [(gogoproto.nullable) = false];
        Tallt tally = 3 [(gogoproto.nullable) = false];
    }
}

any suggestions @alexanderbez

@alexanderbez
Copy link
Contributor

Not quite @gsk967. The params need to be "flattened". I.e, we remove DepositParams, VotingParams, and TallyParams and collapse them into a single Params.

@gsk967
Copy link
Contributor Author

gsk967 commented Aug 24, 2021

Okay Understood @alexanderbez

// Genesis State 
message GenesisState {
    ....
    Params params = 5  [(gogoproto.nullable) = false];
}

message Params {
    min_deposit = 1;
    max_deposit_period = 2;
    voting_period = 3;
    quorum = 4;
    threshold = 5;
    veto_threshold = 6;
}



// GRPC Query 
service Query {
    rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
        option (google.api.http).get = "/cosmos/gov/v1beta1/params";
    }
}


message QueryParamsRequest {
}

// QueryParamsResponse is the response type for the Query/Params RPC method.
message QueryParamsResponse {
    Params params = 1 [(gogoproto.nullable) = false];
}

@amaury1093
Copy link
Contributor

amaury1093 commented Aug 25, 2021

Not quite @gsk967. The params need to be "flattened". I.e, we remove DepositParams, VotingParams, and TallyParams and collapse them into a single Params.

I agree with this. But this would be a proto-breaking change. I would make sure to have the green light from @blushi or @cmwaters (or someone else in the gov working group) before moving forward with this.

@mergify
Copy link
Contributor

mergify bot commented Aug 25, 2021

Sorry but I didn't understand the command. Please consult the commands documentation 📚.

Hey, I reacted but my real name is @Mergifyio

@blushi blushi self-assigned this Oct 6, 2021
@tac0turtle
Copy link
Member

@gsk967 want to migrate gov module to the new param design? #10514 ❤️

@gsk967
Copy link
Contributor Author

gsk967 commented Nov 9, 2021

@marbar3778 Yes , I will migrate gov params to new param design

@gsk967 gsk967 changed the title feat: added rest api for quert the gov params feat: added rest api for query the gov params Nov 9, 2021
@github-actions
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 25, 2021
@github-actions github-actions bot closed this Dec 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Rest Endpoint to Query the gov module params
6 participants