Repository navigation
rpc: fix hash encoding in JSON parameters - #6813
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6813 +/- ##
==========================================
- Coverage 62.74% 62.58% -0.16%
==========================================
Files 310 310
Lines 40815 40823 +8
==========================================
- Hits 25608 25550 -58
- Misses 13388 13450 +62
- Partials 1819 1823 +4
|
8803fb5 to
cf221dc
Compare
|
The code looks great. If you're able to get this running, would you mind posting a quick example of the RPC call? |
tac0turtle
left a comment
There was a problem hiding this comment.
utACK.
Changlog and upgrading.md entries would be good.
Also any docs that mention base64 should be changed
Repro: git clone https://github.com/tendermint/tendermint
pushd tendermint
git checkout -b repro origin/encoding-inconsistency
make build
# -- Terminal A
./build/tendermint --home repro.tendermint init validator
./build/tendermint --home repro.tendermint start --proxy-app=kvstore --consensus.create-empty-blocks=false
# N.B. Disabling empty blocks isn't necessary for repro, it just makes the logs less spammy.
# -- Terminal B
curl -s 'http://localhost:26657/broadcast_tx_commit?tx="hash-me=maybe"'
## output: https://git.io/JRP5L
## "hash": "BD83A7167763FEB5D0B137A3591C74A45E9BC87A47D7E500A8D933199A08AE27"
curl -s 'http://localhost:26657/tx?hash=0xBD83A7167763FEB5D0B137A3591C74A45E9BC87A47D7E500A8D933199A08AE27'
## output: https://git.io/JRP5o
curl -s -X POST \
-H "Content-Type: application/json" \
http://localhost:26657 \
-d '{"jsonrpc": "2.0", "id": 1000, "method": "tx", "params": {"hash": "BD83A7167763FEB5D0B137A3591C74A45E9BC87A47D7E500A8D933199A08AE27", "prove": false}}'
## output: https://git.io/JRPdiThis is essentially the same example as in #6802, but the |
The only documentation that explicitly mentions base64 is for transaction data, and that is still essentially correct. I did add a commit (2a344ca) to clarify the encoding rules a bit, and I think that's worth doing anyway, but it doesn't actually address the change here. |
|
I do not think the e2e test failure is related to this change. Specifically, the failure seems to change even if I re-run without updating the PR. But I'm not sure if there's a better way to be sure than that. |
to me it looks like it is. here the encoding is wrong on the query. |
Aha, thank you, that is very helpful. I'm surprised this didn't get reported as an error elsewhere in the log, though. Anyway, that's a clue I can use to find the case that needs fixed. |
137c1c0 to
af0ac3e
Compare
424bdc6 to
87ed3e5
Compare
|
I finally figured out why this was working locally but not in the end-to-end tests: I hadn't updated all the client implementations and the e2e plumbing tickled at least one of the ones I'd missed. Applying the change to all of them averts the inconsistency. Or at least I think I got them all this time. 🤪 |
The responses from node RPCs encode hash values as hexadecimal strings. In
some cases, however, hashes received as JSON parameters were being decoded as
byte buffers.
This resulted in the confusing situation that a hash reported by one request
(e.g., broadcast_tx_commit) could not be passed as a parameter to another
(e.g., tx) via JSON, without translating the hex-encoded output hash into the
base64 encoding used by JSON for opaque bytes.
Addresses #6802.
Note to reviewers: These changes satisfy the existing tests, but the existing test
suite verifies only that requests round-trip. We do not currently have any tests to
verify encoding expectations.