Expand description
JSON-RPC servers. Trusted access to the blockchain.
§Context
The traditional model used in the blockchain ecosystem is this one:
+---------------+ +--------+ +----------------------+
| | JSON-RPC | | libp2p | |
| Application | <--------> | Node | <------> | Blockchain network |
| (e.g. a UI) | | | | |
+---------------+ +--------+ +----------------------+
The node is connected to the blockchain network using the libp2p protocol, and one or more applications are connected to the node using the JSON-RPC protocol.
Note: An example application that can be put on top of a node is PolkadotJS Apps.
Contrary to the traffic with the blockchain network, the communication between the JSON-RPC client (i.e. the application) and the JSON-RPC server (i.e. the node) is not trustless. In other words, the client has no way to check the accuracy of what the server sends, and therefore trusts that the server isn’t malicious. The role of the node is precisely to turn untrusted data coming from the blockchain network into trusted information.
The trust goes the other way around: some of the JSON-RPC requests that the client can perform can modify the configuration of the node, while some others are very CPU or I/O-intensive. As such, the server also trusts the client to not be malicious.
§JSON-RPC protocol
The protocol used is the JSON-RPC v2.0 protocol described here.
As specified in the JSON-RPC v2.0 protocol, both sides of the TCP/IP connection may send requests and/or notifications to the other side.
In practice, the listening side of the connection should be capable of serving the various
JSON-RPC functions described in the methods
submodule. As part of the logic of these
functions, the listening side might send notifications to the initiator of the connection.
Modules§
- List of requests and how to answer them.
- Parse JSON-RPC method calls and notifications, and build responses messages.