Portal wire protocol
This means that the basic protocol is the same, but there are custom portal-specific messages.
Nodes identify each other by a protocol ID.
0x500Aportal state sub-protocol.
0x500Bportal history sub-protocol.
0x....Other networks (Ethereum execution, Ethreum consensus chain, others.)
Messages the define the portal sub-protocols are:
TALKREQ(talk requests). These have a request ID.
TALKRESP(talk responses). These refer to the reqest ID being responded to.
Messages contain data that is an SSZ union. This means that the message contains one of the possible message content types, and that the type will be specified.
# Python message = Union[ping, pong, find_nodes, nodes, find_content, content, offer, accept]
The SSZ Union encoding means that each component has a selector (
PING 0x00, PONG 0x01, FIND_NODES 0x02, ...).
That way, different clients on the network can listen to messages on the right protocol
and correctly decode them.
For example, receiving a message and seeing that the first byte is
0x02 indicates that the
message contains a
FIND_NODES type of content.
Each message has specific data that is sent. For example, a
find_content message component will have the content that is being sought. The details of these can be found in the spec.
The above message definitions are sufficient for a Portal node to participate in the network.
However, as Portal is a JSON-RPC server (serving Ethereum-related requests like
it also exposes the wire methods. This is not strictly required by the Portal Network specification,
but is very useful.
Messages that are wire responses are not exposed, as they are not requests.
The following table shows the wire definition, purpose and how it is exposed for querying via the JSON-RPC server.
Recall that each Portal can serve multiple sub-protocols simultaneously. Hence, the
following table is for the History sub-protocol (
0x500A in Discovery-terms), and
JSON-RPC methods start with
|message||SSZ union message selector||purpose||JSON-RPC|
|ping||"Are you alive?"|
|find_nodes||"Give me peers at specific distances x, y & z"|
|nodes||"Response to findnodes"||None|
|find_content||"I want content x, or peers who might have it"|
|content||"Here is content x, or peers who might have it."||None|
|offer||"I have content x, y & z, would you like any of them?"|
|accept||"Yes please, I would like x, y & z"||None|