Closed
Description
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