eth2.0-specs/specs/networking/messaging.md

47 lines
1.7 KiB
Markdown
Raw Normal View History

2019-03-12 20:46:58 +00:00
ETH 2.0 Networking Spec - Messaging
===
# Abstract
This specification describes how individual Ethereum 2.0 messages are represented on the wire.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL”, NOT", “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC 2119.
# Motivation
This specification seeks to define a messaging protocol that is flexible enough to be changed easily as the ETH 2.0 specification evolves.
2019-03-19 22:32:38 +00:00
Note that while `libp2p` is the chosen networking stack for Ethereum 2.0, as of this writing some clients do not have workable `libp2p` implementations. To allow those clients to communicate, we define a message envelope that includes the body's compression, encoding, and body length. Once `libp2p` is available across all implementations, this message envelope will be removed because `libp2p` will negotiate the values defined in the envelope upfront.
2019-03-12 20:46:58 +00:00
# Specification
## Message Structure
2019-03-18 23:02:31 +00:00
An ETH 2.0 message consists of an envelope that defines the message's compression, encoding, and length followed by the body itself.
2019-03-12 20:46:58 +00:00
Visually, a message looks like this:
```
+--------------------------+
2019-03-18 23:02:31 +00:00
| compression nibble |
+--------------------------+
| encoding nibble |
+--------------------------+
| body length (uint64) |
2019-03-12 20:46:58 +00:00
+--------------------------+
| |
| body |
| |
+--------------------------+
```
2019-03-18 23:02:31 +00:00
Clients MUST ignore messages with mal-formed bodies. The compression/encoding nibbles MUST be one of the following values:
## Compression Nibble Values
2019-03-12 20:46:58 +00:00
2019-03-18 23:02:31 +00:00
- `0x0`: no compression
2019-03-12 20:46:58 +00:00
2019-03-18 23:02:31 +00:00
## Encoding Nibble Values
2019-03-12 20:46:58 +00:00
2019-03-18 23:02:31 +00:00
- `0x1`: SSZ