Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
use nicer boundary for transport error
  • Loading branch information
sukunrt committed Feb 3, 2025
commit 43678477a8e5a284f664cfb812efb7264d73abd4
4 changes: 2 additions & 2 deletions error-codes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ application.
### Libp2p Reserved Error Codes
Error code 0 signals that no error code was provided. Implementations MUST handle closing a connection with error code 0 as they handle closing a connection with no error code, and resetting a stream with error code 0 as they handle resetting a stream without any error code.

Error codes from 1 to 0x3ff are reserved for transport errors. These are used by the transports to terminate connections or streams on transport errors.
Error codes from 1 to 0xfff are reserved for transport errors. These are used by the transports to terminate connections or streams on transport errors.

Error codes from 0x400 to 0xffff are reserved for libp2p. This includes multistream error codes, as it is necessary for libp2p connection establishment over TCP, but not kad-dht or gossip-sub error codes. See [Libp2p error codes](./libp2p-error-codes.md) for the libp2p reserved error codes.
Error codes from 0x1000 to 0xffff are reserved for libp2p. This includes multistream error codes, as it is necessary for libp2p connection establishment over TCP, but not kad-dht or gossip-sub error codes. See [Libp2p error codes](./libp2p-error-codes.md) for the libp2p reserved error codes.

Some transports, like QUIC, support sending an error code greater than a 32 bit int. On receiving such a value, implementations MUST use `CODE_OUT_OF_RANGE` as the libp2p error code.

Expand Down
4 changes: 2 additions & 2 deletions error-codes/error-codes.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
start_range,end_range,name
0, 0, No error code
1, 0x3ff, Transport errors
0x400, 0xffff, libp2p
1, 0xfff, Transport errors
0x1000, 0xffff, libp2p
40 changes: 20 additions & 20 deletions error-codes/libp2p-error-codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
| Name | Code | Description |
| --- | --- | --- |
| NO_ERROR | 0 | No reason provided for disconnection. This is equivalent to closing a connection or resetting a stream without any error code. |
| Reserved For Transport | 0x1 - 0x3ff | Reserved for transport level error codes. |
| PROTOCOL_NEGOTIATION_FAILED | 0x400 | Rejected because we couldn't negotiate a protocol. Used by multistream select for security negotiation |
| RESOURCE_LIMIT_EXCEEDED | 0x401 | Rejected because we ran into a resource limit. Implementations MAY retry with a backoff |
| RATE_LIMITED | 0x402 | Rejected because the connection was rate limited. Implementations MAY retry with a backoff |
| PROTOCOL_VIOLATION | 0x403 | Peer violated the protocol |
| SUPPLANTED | 0x404 | Connection closed because a connection over a better tranpsort was available |
| GARBAGE_COLLECTED | 0x405 | Connection was garbage collected |
| SHUTDOWN | 0x406 | The node is shutting down |
| GATED | 0x407 | The connection was gated. Most likely the IP / node is blacklisted. |
| CODE_OUT_OF_RANGE | 0x408 | The error code received from the peer was greater than 4294967295(Max uint32).
| Reserved For Transport | 0x1 - 0xfff | Reserved for transport level error codes. |
| PROTOCOL_NEGOTIATION_FAILED | 0x1000 | Rejected because we couldn't negotiate a protocol. Used by multistream select for security negotiation |
| RESOURCE_LIMIT_EXCEEDED | 0x1001 | Rejected because we ran into a resource limit. Implementations MAY retry with a backoff |
| RATE_LIMITED | 0x1002 | Rejected because the connection was rate limited. Implementations MAY retry with a backoff |
| PROTOCOL_VIOLATION | 0x1003 | Peer violated the protocol |
| SUPPLANTED | 0x1004 | Connection closed because a connection over a better tranpsort was available |
| GARBAGE_COLLECTED | 0x1005 | Connection was garbage collected |
| SHUTDOWN | 0x1006 | The node is shutting down |
| GATED | 0x1007 | The connection was gated. Most likely the IP / node is blacklisted. |
| CODE_OUT_OF_RANGE | 0x1008 | The error code received from the peer was greater than 4294967295(Max uint32).


## Stream Error Codes
| Name | Code | Description |
| --- | --- | --- |
| NO_ERROR | 0 | No reason provided for disconnection. This is equivalent to resetting a stream without any error code. |
| Reserved For Transport | 0x1 - 0x3ff | Reserved for transport level error codes. |
| PROTOCOL_NEGOTIATION_FAILED | 0x400 | Rejected because we couldn't negotiate a protocol. Used by multistream select|
| RESOURCE_LIMIT_EXCEEDED | 0x401 | Stream rejected because we ran into a resource limit. Implementations MAY retry with a backoff |
| RATE_LIMITED | 0x402 | Rejected because the connection was rate limited. Implementations MAY retry with a backoff |
| PROTOCOL_VIOLATION | 0x403 | Rejected because the stream protocol was violated. MAY be used interchangably with `BAD_REQUEST` |
| SUPPLANTED | 0x404 | Resetted because a better transport is available for the stream |
| GARBAGE_COLLECTED | 0x405 | Idle Stream was garbage collected |
| SHUTDOWN | 0x406 | The node is shutting down |
| GATED | 0x407 | The stream was gated. Most likely the IP / node is blacklisted. |
| CODE_OUT_OF_RANGE | 0x408 | The error code received from the peer was greater than 4294967295(Max uint32).
| Reserved For Transport | 0x1 - 0xfff | Reserved for transport level error codes. |
| PROTOCOL_NEGOTIATION_FAILED | 0x1000 | Rejected because we couldn't negotiate a protocol. Used by multistream select|
| RESOURCE_LIMIT_EXCEEDED | 0x1001 | Stream rejected because we ran into a resource limit. Implementations MAY retry with a backoff |
| RATE_LIMITED | 0x1002 | Rejected because the connection was rate limited. Implementations MAY retry with a backoff |
| PROTOCOL_VIOLATION | 0x1003 | Rejected because the stream protocol was violated. MAY be used interchangably with `BAD_REQUEST` |
| SUPPLANTED | 0x1004 | Resetted because a better transport is available for the stream |
| GARBAGE_COLLECTED | 0x1005 | Idle Stream was garbage collected |
| SHUTDOWN | 0x1006 | The node is shutting down |
| GATED | 0x1007 | The stream was gated. Most likely the IP / node is blacklisted. |
| CODE_OUT_OF_RANGE | 0x1008 | The error code received from the peer was greater than 4294967295(Max uint32).