2021-12-22 07:46:18 +00:00
# Bellatrix -- Networking
2021-07-22 17:07:04 +00:00
2021-12-22 07:46:18 +00:00
This document contains the networking specification for the Bellatrix.
2021-07-22 17:07:04 +00:00
The specification of these changes continues in the same format as the network specifications of previous upgrades, and assumes them as pre-requisite. This document should be viewed as additive to the documents from [Phase 0 ](../phase0/p2p-interface.md ) and from [Altair ](../altair/p2p-interface.md )
and will be referred to as the "Phase 0 document" and "Altair document" respectively, hereafter.
Readers should understand the Phase 0 and Altair documents and use them as a basis to understand the changes outlined in this document.
## Table of contents
<!-- TOC -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE - RUN doctoc TO UPDATE -->
- [Warning ](#warning )
2021-12-22 07:46:18 +00:00
- [Modifications in Bellatrix ](#modifications-in-bellatrix )
2021-10-20 18:06:58 +00:00
- [Configuration ](#configuration )
2021-07-22 17:07:04 +00:00
- [The gossip domain: gossipsub ](#the-gossip-domain-gossipsub )
- [Topics and messages ](#topics-and-messages )
- [Global topics ](#global-topics )
- [`beacon_block` ](#beacon_block )
- [Transitioning the gossip ](#transitioning-the-gossip )
- [The Req/Resp domain ](#the-reqresp-domain )
- [Messages ](#messages )
- [BeaconBlocksByRange v2 ](#beaconblocksbyrange-v2 )
- [BeaconBlocksByRoot v2 ](#beaconblocksbyroot-v2 )
2021-10-20 18:06:58 +00:00
- [Design decision rationale ](#design-decision-rationale )
- [Gossipsub ](#gossipsub )
2021-12-22 07:46:18 +00:00
- [Why was the max gossip message size increased at Bellatrix? ](#why-was-the-max-gossip-message-size-increased-at-bellatrix )
2021-10-27 16:44:55 +00:00
- [Req/Resp ](#reqresp )
2021-12-22 07:46:18 +00:00
- [Why was the max chunk response size increased at Bellatrix? ](#why-was-the-max-chunk-response-size-increased-at-bellatrix )
2021-07-22 17:07:04 +00:00
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->
## Warning
2021-12-22 07:46:18 +00:00
This document is currently illustrative for early Bellatrix testnets and some parts are subject to change.
2021-07-22 17:07:04 +00:00
Refer to the note in the [validator guide ](./validator.md ) for further details.
2021-12-22 07:46:18 +00:00
# Modifications in Bellatrix
2021-07-22 17:07:04 +00:00
2021-10-20 18:06:58 +00:00
## Configuration
This section outlines modifications constants that are used in this spec.
| Name | Value | Description |
|---|---|---|
2021-12-23 09:32:15 +00:00
| `GOSSIP_MAX_SIZE_BELLATRIX` | `10 * 2**20` (= 10,485,760, 10 MiB) | The maximum allowed size of uncompressed gossip messages starting at Bellatrix upgrade. |
2021-12-22 07:46:18 +00:00
| `MAX_CHUNK_SIZE_BELLATRIX` | `10 * 2**20` (= 10,485,760, 10 MiB) | The maximum allowed size of uncompressed req/resp chunked responses starting at Bellatrix upgrade. |
2021-10-20 18:06:58 +00:00
2021-07-22 17:07:04 +00:00
## The gossip domain: gossipsub
2021-12-22 07:46:18 +00:00
Some gossip meshes are upgraded in Bellatrix to support upgraded types.
2021-07-22 17:07:04 +00:00
### Topics and messages
Topics follow the same specification as in prior upgrades.
All topics remain stable except the beacon block topic which is updated with the modified type.
2021-10-20 18:06:58 +00:00
The specification around the creation, validation, and dissemination of messages has not changed from the Phase 0 and Altair documents unless explicitly noted here.
2021-12-22 07:46:18 +00:00
Starting at Bellatrix upgrade, each gossipsub [message ](https://github.com/libp2p/go-libp2p-pubsub/blob/master/pb/rpc.proto#L17-L24 )
has a maximum size of `GOSSIP_MAX_SIZE_BELLATRIX` .
2021-10-20 18:06:58 +00:00
Clients MUST reject (fail validation) messages that are over this size limit.
Likewise, clients MUST NOT emit or propagate messages larger than this limit.
2021-07-22 17:07:04 +00:00
The derivation of the `message-id` remains stable.
The new topics along with the type of the `data` field of a gossipsub message are given in this table:
| Name | Message Type |
| - | - |
| `beacon_block` | `SignedBeaconBlock` (modified) |
Note that the `ForkDigestValue` path segment of the topic separates the old and the new `beacon_block` topics.
#### Global topics
2021-12-22 07:46:18 +00:00
Bellatrix changes the type of the global beacon block topic.
2021-07-22 17:07:04 +00:00
##### `beacon_block`
2021-12-22 07:46:18 +00:00
The *type* of the payload of this topic changes to the (modified) `SignedBeaconBlock` found in Bellatrix.
2021-08-09 23:50:56 +00:00
Specifically, this type changes with the addition of `execution_payload` to the inner `BeaconBlockBody` .
2021-12-22 07:46:18 +00:00
See Bellatrix [state transition document ](./beacon-chain.md#beaconblockbody ) for further details.
2021-07-22 17:07:04 +00:00
2021-08-09 23:50:56 +00:00
In addition to the gossip validations for this topic from prior specifications,
the following validations MUST pass before forwarding the `signed_beacon_block` on the network.
Alias `block = signed_beacon_block.message` , `execution_payload = block.body.execution_payload` .
- If the execution is enabled for the block -- i.e. `is_execution_enabled(state, block.body)`
then validate the following:
- _[REJECT]_ The block's execution payload timestamp is correct with respect to the slot
2021-09-24 19:15:42 +00:00
-- i.e. `execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot)` .
2021-08-09 23:50:56 +00:00
2021-07-22 17:07:04 +00:00
### Transitioning the gossip
2021-09-23 18:16:57 +00:00
See gossip transition details found in the [Altair document ](../altair/p2p-interface.md#transitioning-the-gossip ) for
2021-12-22 07:46:18 +00:00
details on how to handle transitioning gossip topics for Bellatrix.
2021-07-22 17:07:04 +00:00
## The Req/Resp domain
### Messages
#### BeaconBlocksByRange v2
**Protocol ID:** `/eth2/beacon_chain/req/beacon_blocks_by_range/2/`
2021-10-27 16:44:55 +00:00
Request and Response remain unchanged unless explicitly noted here.
2021-12-22 07:46:18 +00:00
Starting at Bellatrix upgrade,
a global maximum uncompressed byte size of `MAX_CHUNK_SIZE_BELLATRIX` MUST be applied to all method response chunks
2021-10-27 16:44:55 +00:00
regardless of type specific bounds that *MUST* also be respected.
2021-12-22 07:46:18 +00:00
Bellatrix fork-digest is introduced to the `context` enum to specify Bellatrix block type.
2021-07-22 17:07:04 +00:00
Per `context = compute_fork_digest(fork_version, genesis_validators_root)` :
[0]: # (eth2spec: skip)
| `fork_version` | Chunk SSZ type |
| ------------------------ | -------------------------- |
| `GENESIS_FORK_VERSION` | `phase0.SignedBeaconBlock` |
| `ALTAIR_FORK_VERSION` | `altair.SignedBeaconBlock` |
2021-12-22 07:46:18 +00:00
| `BELLATRIX_FORK_VERSION` | `bellatrix.SignedBeaconBlock` |
2021-07-22 17:07:04 +00:00
#### BeaconBlocksByRoot v2
**Protocol ID:** `/eth2/beacon_chain/req/beacon_blocks_by_root/2/`
Request and Response remain unchanged.
2021-12-22 07:46:18 +00:00
Bellatrix fork-digest is introduced to the `context` enum to specify Bellatrix block type.
2021-07-22 17:07:04 +00:00
Per `context = compute_fork_digest(fork_version, genesis_validators_root)` :
[1]: # (eth2spec: skip)
| `fork_version` | Chunk SSZ type |
| ------------------------ | -------------------------- |
| `GENESIS_FORK_VERSION` | `phase0.SignedBeaconBlock` |
| `ALTAIR_FORK_VERSION` | `altair.SignedBeaconBlock` |
2021-12-22 07:46:18 +00:00
| `BELLATRIX_FORK_VERSION` | `bellatrix.SignedBeaconBlock` |
2021-10-20 18:06:58 +00:00
# Design decision rationale
## Gossipsub
2021-12-22 07:46:18 +00:00
### Why was the max gossip message size increased at Bellatrix?
2021-10-20 18:06:58 +00:00
With the addition of `ExecutionPayload` to `BeaconBlock` s, there is a dynamic
field -- `transactions` -- which can validly exceed the `GOSSIP_MAX_SIZE` limit (1 MiB) put in place in
place at Phase 0. At the `GAS_LIMIT` (~30M) currently seen on mainnet in 2021, a single transaction
filled entirely with data at a cost of 16 gas per byte can create a valid
`ExecutionPayload` of ~2 MiB. Thus we need a size limit to at least account for
current mainnet conditions.
Geth currently has a [max gossip message size ](https://github.com/ethereum/go-ethereum/blob/3ce9f6d96f38712f5d6756e97b59ccc20cc403b3/eth/protocols/eth/protocol.go#L49 ) of 10 MiB.
To support backward compatibility with this previously defined network limit,
2021-12-22 07:46:18 +00:00
we adopt `GOSSIP_MAX_SIZE_BELLATRIX` of 10 MiB for maximum gossip sizes at the
point of Bellatrix and beyond. Note, that clients SHOULD still reject objects
that exceed their maximum theoretical bounds which in most cases is less than `GOSSIP_MAX_SIZE_BELLATRIX` .
2021-10-20 18:06:58 +00:00
Note, that due to additional size induced by the `BeaconBlock` contents (e.g.
proposer signature, operations lists, etc) this does reduce the
theoretical max valid `ExecutionPayload` (and `transactions` list) size as
slightly lower than 10 MiB. Considering that `BeaconBlock` max size is on the
order of 128 KiB in the worst case and the current gas limit (~30M) bounds max blocksize to less
than 2 MiB today, this marginal difference in theoretical bounds will have zero
impact on network functionality and security.
2021-10-27 16:44:55 +00:00
## Req/Resp
2021-12-22 07:46:18 +00:00
### Why was the max chunk response size increased at Bellatrix?
2021-10-27 16:44:55 +00:00
Similar to the discussion about the maximum gossip size increase, the
`ExecutionPayload` type can cause `BeaconBlock` s to exceed the 1 MiB bounds put
in place during Phase 0.
As with the gossip limit, 10 MiB is selected because this is firmly below any
valid block sizes in the range of gas limits expected in the medium term.
As with both gossip and req/rsp maximum values, type-specific limits should
always by simultaneously respected.