-
Notifications
You must be signed in to change notification settings - Fork 998
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
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
||
|
@@ -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: | ||
|
||
|
@@ -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. | ||
|
||
Clients MAY define custom goodbye reasons as long as the value is larger than `1000`. | ||
|
||
|
@@ -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. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added blank line |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.