Skip to content

rpc: Inconsistent encoding of integer types #3898

@thanethomson

Description

@thanethomson

We currently seem to be encoding integers inconsistently in responses from the RPC.

Tendermint version: 0.32.2-76f3db06

ABCI app (name for built-in, URL for self-written if it's publicly available): kvstore

Have you tried the latest version: yes

How to reproduce it (as minimally and precisely as possible):

> curl "http://localhost:26657/broadcast_tx_sync?tx=\"abcd=1234\""
{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "code": 0,
    "data": "",
    "log": "",
    "hash": "F0732FA1810E26F15D3DF480ACE8B3AD5E429C563B22AEBDED33FC06273FD42B"
  }
}

Note how result -> code is encoded as an integer. Then:

> curl "http://localhost:26657/tx?hash=0xF0732FA1810E26F15D3DF480ACE8B3AD5E429C563B22AEBDED33FC06273FD42B"
{
  "jsonrpc": "2.0",
  "id": "",
  "result": {
    "hash": "F0732FA1810E26F15D3DF480ACE8B3AD5E429C563B22AEBDED33FC06273FD42B",
    "height": "3",
    "index": 0,
    "tx_result": {
      "events": [
        {
          "type": "app",
          "attributes": [
            {
              "key": "Y3JlYXRvcg==",
              "value": "Q29zbW9zaGkgTmV0b3dva28="
            },
            {
              "key": "a2V5",
              "value": "YWJjZA=="
            }
          ]
        }
      ]
    },
    "tx": "YWJjZD0xMjM0"
  }
}

Here, result -> index is encoded as an integer, but result -> height is encoded as a string.

Should we not prefer encoding integers consistently? Is this related to Amino? It seems as though int64's get encoded as strings, but other integers get encoded as integers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C:rpcComponent: JSON RPC, gRPC

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions