Skip to content

Expect bank/balances use latest height when height param not specified #4903

Closed
@whunmr

Description

@whunmr

Summary of Bug

When height param not specified, do not using the latest height in REST API bank/balances
and returns error.

related with #4891

BJ00609:~$ curl http://localhost:1317/bank/balances/cosmos1w06eekstpe4njyrvx94ehal7yttcs5lm06a0sl?height=0
{"error":"cannot query with proof when height \u003c= 1; please provide a valid height"}
BJ00609:~$ curl http://localhost:1317/bank/balances/cosmos1w06eekstpe4njyrvx94ehal7yttcs5lm06a0sl?height=1
{"error":"cannot query with proof when height \u003c= 1; please provide a valid height"}
BJ00609:~$ curl http://localhost:1317/bank/balances/cosmos1w06eekstpe4njyrvx94ehal7yttcs5lm06a0sl
{"error":"cannot query with proof when height \u003c= 1; please provide a valid height"}
BJ00609:~$ curl http://localhost:1317/bank/balances/cosmos1w06eekstpe4njyrvx94ehal7yttcs5lm06a0sl?height=2
{"height":"2","result":[
  {
    "denom": "stake",
    "amount": "100000000"
  },
  {
    "denom": "validatortoken",
    "amount": "900000000"
  }
]}
BJ00609:~$ curl http://localhost:1317/bank/balances/cosmos1w06eekstpe4njyrvx94ehal7yttcs5lm06a0sl?height=2000
{"error":"{\"codespace\":\"sdk\",\"code\":1,\"message\":\"failed to load state at height 2000; version does not exist (latest height: 25)\"}"}

Expected behave

  • when height not specified, using the latest block height

Version

gaia v1.0.0

Steps to Reproduce

  • start gaiad
$ gaiad init --chain-id=testing testing
$ gaiacli keys add validator
$ gaiad add-genesis-account $(gaiacli keys show validator -a) 200000000stake,900000000validatortoken
$ gaiad gentx --name validator
$ gaiad collect-gentxs
$ gaiad start
  • start rest-server with trust-node=false
gaiacli rest-server --chain-id=testing  --laddr=tcp://localhost:1317  --node tcp://localhost:26657 --trust-node=false
  • curl request in Summary of Bug section

more context

when height param not specified in rest query,
ParseQueryHeightOrReturnBadRequest will set the default value as 0

func ParseQueryHeightOrReturnBadRequest(...) {
	heightStr := r.FormValue("height")
	if heightStr != "" {
...
	} else {
		cliCtx = cliCtx.WithHeight(0)
	}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions