These messages are used to define an application protocol for Ethereum 2.0. These messages define a RPC protocol for clients to interact with each other.
All messages follow the envelope standard to Hobbits as described in the protocol definition.
This application protocol is classified under the RPC
command.
The body of the RPC calls must conform to:
{
method_id: uint16 // byte representing the method
id: uint64 // id of the request
body: // body of the request itself
}
Example (showing the bson snappy data as json):
EWP 0.2 RPC snappy bson 0 12
{
"method_id": 0x00,
"id": 1,
"body": {
"reason": 42
}
}
Nodes can send HELLO
messages to each other to exchange information on their status.
{
'network_id': 'uint8' // the ID of the network (1 for mainnet, and some predefined number for a testnet)
'chain_id': 'uint8' // the ID of the chain (1 for ETH)
'latest_finalized_root': 'bytes32' // the hash of the latest finalized root
'latest_finalized_epoch': 'uint64' // the number of the latest finalized epoch
'best_root': 'bytes32' // the hash of the best root this node can offer
'best_slot': 'uint64' // the number of the best slot this node can offer
}
Nodes may signal to other nodes that they are going away by sending a GOODBYE
message.
The reason given is optional. Reason codes are up to each client and should not be trusted.
{
'reason': 'uint64' // an optional reason code up to the client
}
Nodes may exchange metadata information using a GET_STATUS
message.
This information is useful to identify other nodes and clients and report that information to statistics services.
{
'sha': 'bytes32' // the commit hash of the node
'user_agent': 'bytes' // the human readable name of the client, optionally with its version and other metadata
'timestamp': 'uint64' // the current time of the node in milliseconds since epoch
}
Nodes may request block roots from other nodes using the GET_BLOCK_ROOTS
message.
{
'start_root': 'bytes32' // the root hash to start querying from
'start_slot': 'uint64' // the slot number to start querying from
'max': 'uint64' // the max number of elements to return
'skip': 'uint64' // the number of elements apart to pick from
'direction': 'uint8' // 0x01 is ascending, 0x00 is descending direction to query elements
}
Nodes may provide block roots to other nodes using the BLOCK_ROOTS
message, usually in response to a GET_BLOCK_ROOTS
message.
[
{
'block_root': 'bytes32',
'slot': 'uint64'
},
...
]
Nodes may request block headers from other nodes using the GET_BLOCK_HEADERS
message.
{
'start_root': 'bytes32' // the root hash to start querying from
'start_slot': 'uint64' // the slot number to start querying from
'max': 'uint64' // the max number of elements to return
'skip': 'uint64' // the number of elements apart to pick from
'direction': 'uint8' // 0x01 is ascending, 0x00 is descending direction to query elements
}
Nodes may provide block roots to other nodes using the BLOCK_HEADERS
message, usually in response to a GET_BLOCK_HEADERS
message.
'headers': '[]BeaconBlockHeader'
Nodes may request block bodies from other nodes using the GET_BLOCK_BODIES
message.
{
'start_root': 'bytes32' // the root hash to start querying from
'start_slot': 'uint64' // the slot number to start querying from
'max': 'uint64' // the max number of elements to return
'skip': 'uint64' // the number of elements apart to pick from
'direction': 'uint8' // 0x01 is ascending, 0x00 is descending direction to query elements
}
Nodes may provide block roots to other nodes using the BLOCK_BODIES
message, usually in response to a GET_BLOCK_BODIES
message.
[
{
'randao_reveal': 'bytes96',
'eth1_data': Eth1Data,
'proposer_slashings': [ProposerSlashing],
'attester_slashings': [AttesterSlashing],
'attestations': [Attestation],
'deposits': [Deposit],
'voluntary_exits': [VoluntaryExit],
'transfers': [Transfer],
'header_signature:' 'bytes96'
}
]
Upon discovering each other, nodes may exchange HELLO
messages.
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.
Upon receiving a HELLO
message, the node may reply with a HELLO
message.
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.
Peers may request blocks and headers from other peers.
Other peers may respond on a best effort basis with header and block data.
There is no SLA for responding. Peers may request blocks repeatidly from the same peers.