Skip to content

Reducing size of data packet of web socket  #9696

@liangping

Description

@liangping

Summary

Currently, the websocket push a well-format json text, which is not efficient and not necessary.

Problem Definition

it increase usages of the bandwidth

Proposal

I would like to suggest that we use compact json format to reduce the size of data packet.

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "query": "tm.event='NewBlock'",
    "data": {
      "type": "tendermint/event/NewBlock",
      "value": {
        "block": {
          "header": {
            "version": {
              "block": "11"
            },
            "chain_id": "cosmoshub-4",
            "height": "12798821",
            "time": "2022-11-11T03:13:43.729399725Z",
            "last_block_id": {
              "hash": "120A987F7F08B73662C5DD02E21D51042148216185AA7AC4150DB80C5DAB23C7",
              "parts": {
                "total": 1,
                "hash": "C46D66314E7ECB74614B0501433A864CA638C11155818AE15F2CF93AF59B8A71"
              }
            },
            "last_commit_hash": "5DC996F57B1B12E7107D5A271973315A750677B84D05B0799B2183B4D40941EC",
            "data_hash": "445049B9704FC63DA35838341BBAE494B8D71BDA1B6B652A61ABA0046F2D7597",
            "validators_hash": "7C016C1EEF692BCB44BBA640969286D6E96716FA878C8C67765CB0510A2161C2",
            "next_validators_hash": "906B9185EA6D07E5E59270DD4849A82BDAEE13A73DABA76826C656CC0ADA1BD2",
            "consensus_hash": "80364965B7C2CC9DE961C0998B47A7F93F1970077EB882E0ED1C3822408888C7",
            "app_hash": "3738062FB00F9107C750B6FC9CD931F2A1B8919BE19CCC58592F0CF62EC6ACD9",
            "last_results_hash": "BC45DF6713ACAF7CE3AB5B80C8C6BB8E4910774F9993A89DDE0F1DF9160A34C4",
            "evidence_hash": "E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855",
            "proposer_address": "D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8"
          },
          "data": {
               ...
          }
    }
  }
}

This block is about 280K,

{"jsonrpc":"2.0","id":1,"result":{"query":"tm.event='NewBlock'","data":{"type":"tendermint/event/NewBlock","value":{"block":{"header":{"version":{"block":"11"},"chain_id":"cosmoshub-4","height":"12798821","time":"2022-11-11T03:13:43.729399725Z","last_block_id":{"hash":"120A987F7F08B73662C5DD02E21D51042148216185AA7AC4150DB80C5DAB23C7","parts":{"total":1,"hash":"C46D66314E7ECB74614B0501433A864CA638C11155818AE15F2CF93AF59B8A71"}},"last_commit_hash":"5DC996F57B1B12E7107D5A271973315A750677B84D05B0799B2183B4D40941EC","data_hash":"445049B9704FC63DA35838341BBAE494B8D71BDA1B6B652A61ABA0046F2D7597","validators_hash":"7C016C1EEF692BCB44BBA640969286D6E96716FA878C8C67765CB0510A2161C2","next_validators_hash":"906B9185EA6D07E5E59270DD4849A82BDAEE13A73DABA76826C656CC0ADA1BD2","consensus_hash":"80364965B7C2CC9DE961C0998B47A7F93F1970077EB882E0ED1C3822408888C7","app_hash":"3738062FB00F9107C750B6FC9CD931F2A1B8919BE19CCC58592F0CF62EC6ACD9","last_results_hash":"BC45DF6713ACAF7CE3AB5B80C8C6BB8E4910774F9993A89DDE0F1DF9160A34C4","evidence_hash":"E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855","proposer_address":"D68EEC0D2E8248F1EC64CDB585EDB61ECA432BD8"},"data":{}}}}}

and this is 160k, we simply use compact mode by removing spaces.

saved 1/3,

Users/developers can pretty it by themself

Metadata

Metadata

Assignees

Labels

C:rpcComponent: JSON RPC, gRPCbacklog-priorityA priority issue in the backlog

Type

No type

Projects

Status

Done/Merged

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions