You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: rpc-messages.md
+81-39
Original file line number
Diff line number
Diff line change
@@ -32,50 +32,65 @@ EWP 0.2 RPC snappy bson 0 12
32
32
33
33
## `0x00` HELLO
34
34
35
-
```python
35
+
Nodes can send `HELLO` messages to each other to exchange information on their status.
36
+
37
+
38
+
```java
36
39
{
37
-
'network_id': 'uint8'
38
-
'chain_id': 'uint8'
39
-
'latest_finalized_root': 'bytes32'
40
-
'latest_finalized_epoch': 'uint64'
41
-
'best_root': 'bytes32'
42
-
'best_slot': 'uint64'
40
+
'network_id':'uint8'// the ID of the network (1 for mainnet, and some predefined number for a testnet)
41
+
'chain_id':'uint8'// the ID of the chain (1 for ETH)
42
+
'latest_finalized_root':'bytes32'// the hash of the latest finalized root
43
+
'latest_finalized_epoch':'uint64'// the number of the latest finalized epoch
44
+
'best_root':'bytes32'// the hash of the best root this node can offer
45
+
'best_slot':'uint64'// the number of the best slot this node can offer
43
46
}
44
47
```
45
48
46
49
## `0x01` GOODBYE
47
50
48
-
```python
51
+
Nodes may signal to other nodes that they are going away by sending a `GOODBYE` message.
52
+
The reason given is optional. Reason codes are up to each client and should not be trusted.
53
+
54
+
```java
49
55
{
50
-
'reason': 'uint64'
56
+
'reason':'uint64'// an optional reason code up to the client
51
57
}
52
58
53
59
```
54
60
55
61
## `0x02` GET_STATUS
56
-
```python
62
+
63
+
Nodes may exchange metadata information using a `GET_STATUS` message.
64
+
65
+
This information is useful to identify other nodes and clients and report that information to statistics services.
66
+
67
+
```java
57
68
{
58
-
'sha': 'bytes32'
59
-
'user_agent': 'bytes'
60
-
'timestamp': 'uint64'
69
+
'sha':'bytes32'// the commit hash of the node
70
+
'user_agent':'bytes'// the human readable name of the client, optionally with its version and other metadata
71
+
'timestamp':'uint64'// the current time of the node in milliseconds since epoch
61
72
}
62
73
```
63
74
64
75
## `0x0A` GET_BLOCK_ROOTS
65
76
66
-
```python
77
+
Nodes may request block roots from other nodes using the `GET_BLOCK_ROOTS` message.
78
+
79
+
```java
67
80
{
68
-
'start_root': 'bytes32'
69
-
'start_slot': 'uint64'
70
-
'max': 'uint64'
71
-
'skip': 'uint64'
72
-
'direction': 'uint8'# 0x01 is forward, 0x00 is backwards
81
+
'start_root':'bytes32'// the root hash to start querying from
82
+
'start_slot':'uint64'// the slot number to start querying from
83
+
'max':'uint64'// the max number of elements to return
84
+
'skip':'uint64'// the number of elements apart to pick from
85
+
'direction':'uint8'// 0x01 is ascending, 0x00 is descending direction to query elements
73
86
}
74
87
```
75
88
76
89
## `0x0B` BLOCK_ROOTS
77
90
78
-
```python
91
+
Nodes may provide block roots to other nodes using the `BLOCK_ROOTS` message, usually in response to a `GET_BLOCK_ROOTS` message.
92
+
93
+
```java
79
94
[
80
95
{
81
96
'block_root':'bytes32',
@@ -88,40 +103,45 @@ EWP 0.2 RPC snappy bson 0 12
88
103
89
104
## `0x0C` GET_BLOCK_HEADERS
90
105
91
-
```python
106
+
Nodes may request block headers from other nodes using the `GET_BLOCK_HEADERS` message.
107
+
108
+
```java
92
109
{
93
-
'start_root': 'bytes32'
94
-
'start_slot': 'uint64'
95
-
'max': 'uint64'
96
-
'skip': 'uint64'
97
-
'direction': 'uint8'# 0x01 is forward, 0x00 is backwards
110
+
'start_root':'bytes32'// the root hash to start querying from
111
+
'start_slot':'uint64'// the slot number to start querying from
112
+
'max':'uint64'// the max number of elements to return
113
+
'skip':'uint64'// the number of elements apart to pick from
114
+
'direction':'uint8'// 0x01 is ascending, 0x00 is descending direction to query elements
98
115
}
99
116
```
100
117
101
118
## `0x0D` BLOCK_HEADERS
102
119
103
-
```python
120
+
Nodes may provide block roots to other nodes using the `BLOCK_HEADERS` message, usually in response to a `GET_BLOCK_HEADERS` message.
121
+
122
+
```java
104
123
'headers':'[]BeaconBlockHeader'
105
124
```
106
125
107
-
108
126
## `0x0E` GET_BLOCK_BODIES
109
127
110
-
```python
111
-
[
112
-
{
113
-
'start_root': 'bytes32'
114
-
'start_slot': 'uint64'
115
-
'max': 'uint64'
116
-
'skip': 'uint64'
117
-
'direction': 'uint8'# 0x01 is forward, 0x00 is backwards
118
-
}
119
-
]
128
+
Nodes may request block bodies from other nodes using the `GET_BLOCK_BODIES` message.
129
+
130
+
```java
131
+
{
132
+
'start_root':'bytes32'// the root hash to start querying from
133
+
'start_slot':'uint64'// the slot number to start querying from
134
+
'max':'uint64'// the max number of elements to return
135
+
'skip':'uint64'// the number of elements apart to pick from
136
+
'direction':'uint8'// 0x01 is ascending, 0x00 is descending direction to query elements
137
+
}
120
138
```
121
139
122
140
## `0x0F` BLOCK_BODIES
123
141
124
-
```python
142
+
Nodes may provide block roots to other nodes using the `BLOCK_BODIES` message, usually in response to a `GET_BLOCK_BODIES` message.
143
+
144
+
```java
125
145
[
126
146
{
127
147
'randao_reveal':'bytes96',
@@ -137,6 +157,28 @@ EWP 0.2 RPC snappy bson 0 12
137
157
]
138
158
```
139
159
160
+
# Lifecycle and message exchanges
161
+
162
+
## Initial hello
163
+
164
+
Upon discovering each other, nodes may exchange `HELLO` messages.
165
+
166
+
Nodes may send `HELLO` to other peers when they exchange messages for the first time or when their state changes to let them know new blocks are available.
167
+
168
+
Upon receiving a `HELLO` message, the node may reply with a `HELLO` message.
169
+
170
+
## Status messages
171
+
172
+
Any peer may provide information about their status and metadata to any other peer. Other peers may respond on a best effort basis, if at all.
173
+
174
+
## Block and header messages
175
+
176
+
Peers may request blocks and headers from other peers.
177
+
178
+
Other peers may respond on a best effort basis with header and block data.
179
+
180
+
There is no SLA for responding. Peers may request blocks repeatidly from the same peers.
181
+
140
182
#### The following definitions are aligned to v0.5.0 of the Beacon Chain Spec:
0 commit comments