Repository navigation
Description
Bug Report
abci_query on gaiad is raising a marshaling error for me, and requiring the serialized request object to be passed raw rather than hex or base64 encoded.
11:51AM DBG HTTP HANDLER module=rpc-server req="marshaling error: json: unsupported type: func() (io.ReadCloser, error)"
11:51AM DBG HTTPRestRPC args=[{},{},{},{},{}] method=/abci_query module=rpc-server returns=[{},{}]
11:51AM DBG served RPC HTTP response duration=0 method=GET module=rpc-server remoteAddr=127.0.0.1:51840 status=200 url={"ForceQuery":false,"Fragment":"","Host":"","OmitHost":false,"Opaque":"","Path":"/abci_query","RawFragment":"","RawPath":"","RawQuery":"path=%22%2Fcosmos.auth.v1beta1.Query%2FModuleAccountByName%22\u0026data=%22%5Cn%5Crfee_collector%22\u0026height=null","Scheme":"","User":null}
Setup
CometBFT version (use cometbft version or git rev-parse --verify HEAD if installed from source):
v0.34.29
Have you tried the latest version: yes/no
i don't think so (although I might have); i tried a few versions and repositories, but have been focusing on gaiad which i am trying to troubleshoot interactions with. i haven't found any mention of this issue online, and it extends back to before gaia 4 (now at 13).
ABCI app (name for built-in, URL for self-written if it's publicly available):
This is the abci_query path to rpc server handling raw grpc request objects. The above test uses cosmos.auth.v1beta1.Query/ModuleAccountByName .
Environment:
- OS (e.g. from /etc/os-release): Red Hat Linux 7
- Install tools: Built gaia v13 and other versions from git.
- Others:
node command runtime flags: nothing special, gaiad start --log_level trace --home ~/src/gaia/mytestnet/node0/gaiad
Config
What happened?
When I pass nonempty request objects to /abci_query , I get an error in the log, and I only get success if I encode their bytes to a raw json string in the data field. This makes it difficult to pass the binary request objects, as it relies on string encoding in the client.
What did you expect to happen?
There shouldn't be an error in the log. Ideally the endpoint would accept hex-encoded or base64-encoded data.
How to reproduce it
gaiad testnet --keyring-backend test --v 1 --starting-ip-address 127.0.0.1
gaiad start --log_level trace --home mytestnet/node0/gaiad
curl -v 'http://127.0.0.1:26657/abci_query?path=%22%2Fcosmos.auth.v1beta1.Query%2FModuleAccountByName%22&data=%22%5Cn%5Crfee_collector%22'
Logs
11:51AM DBG HTTP HANDLER module=rpc-server req="marshaling error: json: unsupported type: func() (io.ReadCloser, error)"
11:51AM DBG HTTPRestRPC args=[{},{},{},{},{}] method=/abci_query module=rpc-server returns=[{},{}]
11:51AM DBG served RPC HTTP response duration=0 method=GET module=rpc-server remoteAddr=127.0.0.1:51840 status=200 url={"ForceQuery":false,"Fragment":"","Host":"","OmitHost":false,"Opaque":"","Path":"/abci_query","RawFragment":"","RawPath":"","RawQuery":"path=%22%2Fcosmos.auth.v1beta1.Query%2FModuleAccountByName%22\u0026data=%22%5Cn%5Crfee_collector%22\u0026height=null","Scheme":"","User":null}
dump_consensus_state output
This happens on a virgin testnet.
Anything else we need to know
It seems there are possibly a handful of bugs here that I haven't fully explained:
- there is an error in the debug log (topic of this issue)
- the data parameter is not accepted when hex encoded / the error message expresses hex encoding when the wrong type is passed
- request objects are rejected as malformed when the binary can't be encoded as UTF-8 (this can often be avoided but quickly happens with pagination keys)
I imagining correctly supporting hex or base64 encoding rather than requiring a raw encoding would resolve this. Falling back to a raw encoding if the data is not encoded correctly might provide for backward compatibility.
As a user resolving the question of how to pass pagination keys to gaia rpc is unanswered.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsIn Progress
Activity
andynog commentedon Oct 17, 2023
Hi @xloem, could it be related to this ? Based on the version you're using
#443
xloem commentedon Oct 25, 2023
This isn't quite the same thing as the linked issue, as the endpoint differs and it works for me only if data can be passed unencoded rather than hex or base64, but it does involve the same material of normalizing the binary encodings across endpoints.
[EDIT: I did look at this a little, but I am new to go and haven't yet found where in the source the abci_query parameters are decoded from json.]
xloem commentedon Nov 12, 2023
It seems one can mostly work around this by ensuring all
intfield values of request objects are either below 0x80 or above 0x4041 . It seems varint values in the range 0x80-0x4041 do not survive UTF-8 coding. This mostly works but it does become hard to request pages for anything beyond the first 127 items. Additionally strings are limited to 127 bytes length. I've also run into issues specifying blockheights that I haven't looked into, but these can be specified on the RPC side.mmsqe commentedon May 10, 2024
@xloem have you try hex encode the marshalled request? or you can try base64 encoded fee_collector from cronos.
refactor: improve debug information in HTTP handler logging (#3052)
melekes commentedon Sep 5, 2024
@xloem are you still experiencing this issue? Since you didn't respond to @mmsqe ^ above, I assume it's no longer true. Please reopen if I'm wrong.
xloem commentedon Sep 12, 2024
Hex encoding was not working for me with my local node, as made clear in the report repeatedly. It is unclear to me whether that has been fixed, but I hope it has.
I am no longer using cosmos blockchains, but I might come back in future years.
Thanks for all your time and effort.