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

Query proposal lcd endpoint not working #4927

Closed
4 tasks
sahith-narahari opened this issue Aug 20, 2019 · 3 comments · Fixed by #4932
Closed
4 tasks

Query proposal lcd endpoint not working #4927

sahith-narahari opened this issue Aug 20, 2019 · 3 comments · Fixed by #4932

Comments

@sahith-narahari
Copy link
Contributor

Summary of Bug

When I try to query voters of any proposal id,it only returns few of the voters and their response.And also query vote of a particular address returns an error "error": "'' is not a valid vote option"

Version

v0.34.7 - current mainnet version

Steps to Reproduce

You can checkitout on https://cosmos.network/rpc.I also tried on my own server lcd and still got the same outputs


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
@alexanderbez
Copy link
Contributor

Thanks @sahith-narahari!


And also query vote of a particular address returns an error "error": "'' is not a valid vote option"

Indeed, it seems this happens because the initial query for a vote returned an empty (pruned?) response and thus the following fails:

var vote gov.Vote
if err := cdc.UnmarshalJSON(res, &vote); err != nil {
	return err
}

because VoteOption has a custom JSON un/marshaller which calls:

func VoteOptionFromString(str string) (VoteOption, error) {
	switch str {
	case "Yes":
		return OptionYes, nil
	case "Abstain":
		return OptionAbstain, nil
	case "No":
		return OptionNo, nil
	case "NoWithVeto":
		return OptionNoWithVeto, nil
	default:
		return VoteOption(0xff), fmt.Errorf("'%s' is not a valid vote option", str)
	}
}

Solution:

We should just ignore the error in UnmarshalJSON because we want to check the possible Empty() case:

var vote gov.Vote
_ = cdc.UnmarshalJSON(res, &vote)

if vote.Empty() {
    // ...
}

When I try to query voters of any proposal id,it only returns few of the voters and their response.

You're querying for a proposal which has passed the voting period (all proposals have at the time of this writing). That being the case, the votes have been pruned from state. This means we query the txs for you behind the scenes. However, tx querying obviously uses pagination and this pagination has defaults (page 1, 30 limit), hence you're not getting the full result.

This ties into the larger scope of introducing pagination CLI flags into the CLI.

@sahith-narahari
Copy link
Contributor Author

Thanks for the explanation @alexanderbez .Can you also check /gov/proposals endpoint which happens to return only few proposals(missing 9 and 11 in response)

@alexanderbez
Copy link
Contributor

There is nothing custom in the proposals query handler. If you're only seeing a few resources returned, then you're probably querying against a pruning node. Any chance you can try against an archive node?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants