Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple enhancements to the networking spec discovered after implementing it #1158

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions specs/networking/rpc-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ The details of the RPC-Over-`libp2p` protocol are similar to [JSON-RPC 2.0](http
6. The `result` member is OPTIONAL on errors, and MAY contain additional information about the error.
7. `response_code` MUST be `0` on success.

Structuring RPC requests in this manner allows multiple calls and responses to be multiplexed over the same stream without switching. Note that this implies that responses MAY arrive in a different order than requests.
A single LibP2P stream provides duplex mode communication for the connected peers. Requests and responses MAY be sent in arbitrary order by both parties. Requests and responses are discriminated through the value of their `id` member. Each request MUST use an even number as `id`, while the correponding response MUST use the value `id + 1`.

The "method ID" fields in the below messages refer to the `method` field in the request structure above.

The first 1,000 values in `response_code` are reserved for system use. The following response codes are predefined:

1. `0`: No error.
2. `10`: Parse error.
2. `20`: Invalid request.
3. `30`: Method not found.
4. `40`: Server error.
2. `1`: Response Chunk
4. `10`: Parse error.
5. `20`: Invalid request.
6. `30`: Method not found.
7. `40`: Server error.

Very large responses MAY be delivered in chunks. This MUST be indicated by sending multiple response messages using the same `id` and the `response_code` value `Response Chunk`. The last chunk MUST be indicated with a `response_code` value `No error`.

### Alternative for non-`libp2p` clients

Expand All @@ -102,7 +105,7 @@ Since some clients are waiting for `libp2p` implementations in their respective
)
```

Clients exchange `hello` messages upon connection, forming a two-phase handshake. The first message the initiating client sends MUST be the `hello` message. In response, the receiving client MUST respond with its own `hello` message.
Clients exchange `hello` messages upon connection, forming a two-phase handshake. The first message the initiating client sends MUST be the `hello` message. In response, the receiving client MUST respond with its own `hello` message within 10 seconds.

Clients SHOULD immediately disconnect from one another following the handshake above under the following conditions:

Expand Down Expand Up @@ -154,7 +157,11 @@ Client MAY send `goodbye` messages upon disconnection. The reason field MAY be o

- `1`: Client shut down.
- `2`: Irrelevant network.
- `3`: Fault/error.
- `3`: Breach of protocol.
- `4`: Useless peer.
- `5`: Already Connected.
- `6`: Self-connection.
- `7`: Fault/error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the RLPx error codes, do we need those? In particular 5 implies you cannot have more than one connection with another peer.


Clients MAY define custom goodbye reasons as long as the value is larger than `1000`.

Expand Down Expand Up @@ -281,3 +288,4 @@ Requests the `block_bodies` associated with the provided `block_roots` from the
Requests contain the hashes of Merkle tree nodes that when merkleized yield the block's `state_root`.

The response will contain the values that, when hashed, yield the hashes inside the request body.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added blank line