|
| 1 | +# Messages |
| 2 | +These messages are used to define a gossip protocol for Ethereum 2.0. These messages define a gossip protocol for clients to replicate information with each other. |
| 3 | + |
| 4 | +# Envelope |
| 5 | +All messages follow the envelope standard to Hobbits as described in [protocol.md]. |
| 6 | + |
| 7 | +This application protocol is classified under the `GOSSIP` command. |
| 8 | + |
| 9 | +The message must contain the following headers: |
| 10 | + |
| 11 | +| Header name | Type | Notes | |
| 12 | +|-------------|------|-------| |
| 13 | +| method_id | uint8| the method used in this exchange, as described below | |
| 14 | +| message_hash | bytes32 | a hash uniquely representing the message contents, with a hash function up to the application | |
| 15 | +| hash_signature | bytes32 | a signature of the message hash with a public key identifying the node sending data | |
| 16 | + |
| 17 | +Example (showing the bson snappy data as json): |
| 18 | + |
| 19 | +```python |
| 20 | +EWP 0.2 GOSSIP 24 0 |
| 21 | +{ |
| 22 | + "method_id": 3, |
| 23 | + "message_hash": "0x9D686F6262697473206172652074776F20616E6420666F75722066656574", |
| 24 | + "hash_signature": "0x0000000009A4672656E63682070656F706C6520617265207468652062657374" |
| 25 | +} |
| 26 | +``` |
| 27 | + |
| 28 | +# Methods |
| 29 | + |
| 30 | +## 0x00 GOSSIP |
| 31 | + |
| 32 | +Nodes use `GOSSIP` methods to send data to other nodes in the network. |
| 33 | + |
| 34 | +The body of a `GOSSIP` method consists in the data being gossiped. |
| 35 | + |
| 36 | +The `message_hash` header value must match the hash of the contents of the body according to a predefined hash function defined by the application. |
| 37 | + |
| 38 | +## 0x01 PRUNE |
| 39 | + |
| 40 | +Nodes use `PRUNE` messages to inform other nodes that they are removed from the list of peers that will receive data from them. |
| 41 | +Instead of sending data, nodes will send attestations as `IHAVE` messages. |
| 42 | + |
| 43 | +The header may contain the `message_hash` of a message that triggered the pruning. |
| 44 | + |
| 45 | +## 0x02 GRAFT |
| 46 | + |
| 47 | +Nodes use `PRUNE` messages to inform other nodes that they are added to the list of peers that will receive data from them. |
| 48 | +Instead of sending attestations as `IHAVE` messages, nodes will send data as `GOSSIP` messages. |
| 49 | + |
| 50 | +No body is present in `GRAFT` messages. |
| 51 | + |
| 52 | +The header may contain the `message_hash` of a message triggered the graft. |
| 53 | + |
| 54 | +Targets should reply with a `GOSSIP` message sending the message matching the hash. |
| 55 | + |
| 56 | +## 0x03 IHAVE |
| 57 | + |
| 58 | +Nodes use `IHAVE` messages to inform other nodes that they are in possession of data that matches the signature they are sending. |
| 59 | + |
| 60 | +No body is present in `IHAVE` messages. |
| 61 | + |
| 62 | +The header must contain the `message_hash` with the value of the hash of the data attested by the peer. |
0 commit comments