Skip to content
This repository was archived by the owner on Jun 3, 2022. It is now read-only.
This repository was archived by the owner on Jun 3, 2022. It is now read-only.

IPC RPC should have a transport layer with payload length #14

@axic

Description

@axic

JSON-RPC doesn't specify a transport layer. It relies on the transport protocol (HTTP) to do that. This however is missing in certain use cases, such as Unix socket based IPC.

There is no consistent way defined between Ethereum clients to deal with this:

  • geth uses a streaming JSON decoder which can detect the end of the input
  • soltest (solidity) looks for the first new line (\n), which is obviously dangerous
  • cpp-ethereum waits for a big enough input

There are some proposals to define a transport layer:

  • open a new connection every single time (not really suitable for our use)
  • use an encapsulation format (proposes netstrings)
  • rely on the JSON decoder

Since there is no widely adopted standard, I propose to have a single length field preceding the JSON request and the response.

For the encoding I propose to use either:

  • number as a string terminated with new line (this valid JSON)
  • a single member array with the length as the only member ([1234] - this is valid JSON too and is easy to search for the closing bracket ])
  • RLP or CBOR encoded number

Choosing a JSON compatible encoding would mean that clients could support backwards compatibility by reading another JSON message if the first message is not JSON-RPC (e.g. it is a single number in an array as above)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions