Skip to content

Commit

Permalink
Merge pull request #4023 from ethereum/electra-blob-count
Browse files Browse the repository at this point in the history
Add EIP-7691: Blob throughput increase
  • Loading branch information
jtraglia authored Dec 6, 2024
2 parents 554189d + 77cacaa commit 31cd9cb
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 43 deletions.
29 changes: 20 additions & 9 deletions configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,28 @@ ATTESTATION_SUBNET_PREFIX_BITS: 6
# Deneb
# `2**7` (=128)
MAX_REQUEST_BLOCKS_DENEB: 128
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768
# `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
## `uint64(6)`
# `uint64(6)`
MAX_BLOBS_PER_BLOCK: 6
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768

# Electra
# 2**7 * 10**9 (= 128,000,000,000)
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000
# 2**8 * 10**9 (= 256,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000
# `9`
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9
# `uint64(6)`
TARGET_BLOBS_PER_BLOCK_ELECTRA: 6
# `uint64(9)`
MAX_BLOBS_PER_BLOCK_ELECTRA: 9
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152

# Whisk
# `Epoch(2**8)`
Expand All @@ -166,13 +180,10 @@ DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
SAMPLES_PER_SLOT: 8
CUSTODY_REQUIREMENT: 4
MAX_BLOBS_PER_BLOCK_EIP7594: 8
TARGET_BLOBS_PER_BLOCK_EIP7594: 9
MAX_BLOBS_PER_BLOCK_EIP7594: 12
# `MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_EIP7594`
MAX_REQUEST_BLOB_SIDECARS_EIP7594: 1024

# [New in Electra:EIP7251]
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 128000000000 # 2**7 * 10**9 (= 128,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 256000000000 # 2**8 * 10**9 (= 256,000,000,000)
MAX_REQUEST_BLOB_SIDECARS_EIP7594: 1536

# EIP7732
MAX_REQUEST_PAYLOADS: 128
27 changes: 19 additions & 8 deletions configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,28 @@ ATTESTATION_SUBNET_PREFIX_BITS: 6
# Deneb
# `2**7` (=128)
MAX_REQUEST_BLOCKS_DENEB: 128
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768
# `2**12` (= 4096 epochs, ~18 days)
MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS: 4096
# `6`
BLOB_SIDECAR_SUBNET_COUNT: 6
## `uint64(6)`
MAX_BLOBS_PER_BLOCK: 6
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
MAX_REQUEST_BLOB_SIDECARS: 768

# Electra
# [customized] 2**6 * 10**9 (= 64,000,000,000)
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 64000000000
# [customized] 2**7 * 10**9 (= 128,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 128000000000
# `9`
BLOB_SIDECAR_SUBNET_COUNT_ELECTRA: 9
# `uint64(6)`
TARGET_BLOBS_PER_BLOCK_ELECTRA: 6
# `uint64(9)`
MAX_BLOBS_PER_BLOCK_ELECTRA: 9
# MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_ELECTRA
MAX_REQUEST_BLOB_SIDECARS_ELECTRA: 1152

# Whisk
WHISK_EPOCHS_PER_SHUFFLING_PHASE: 4
Expand All @@ -165,13 +179,10 @@ DATA_COLUMN_SIDECAR_SUBNET_COUNT: 128
MAX_REQUEST_DATA_COLUMN_SIDECARS: 16384
SAMPLES_PER_SLOT: 8
CUSTODY_REQUIREMENT: 4
MAX_BLOBS_PER_BLOCK_EIP7594: 8
TARGET_BLOBS_PER_BLOCK_EIP7594: 9
MAX_BLOBS_PER_BLOCK_EIP7594: 12
# `MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK_EIP7594`
MAX_REQUEST_BLOB_SIDECARS_EIP7594: 1024

# [New in Electra:EIP7251]
MIN_PER_EPOCH_CHURN_LIMIT_ELECTRA: 64000000000 # 2**6 * 10**9 (= 64,000,000,000)
MAX_PER_EPOCH_ACTIVATION_EXIT_CHURN_LIMIT: 128000000000 # 2**7 * 10**9 (= 128,000,000,000)
MAX_REQUEST_BLOB_SIDECARS_EIP7594: 1536

# EIP7732
MAX_REQUEST_PAYLOADS: 128
6 changes: 3 additions & 3 deletions presets/minimal/deneb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
# `uint64(4096)`
FIELD_ELEMENTS_PER_BLOB: 4096
# [customized]
MAX_BLOB_COMMITMENTS_PER_BLOCK: 16
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 4 = 9
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 9
MAX_BLOB_COMMITMENTS_PER_BLOCK: 32
# [customized] `floorlog2(get_generalized_index(BeaconBlockBody, 'blob_kzg_commitments')) + 1 + ceillog2(MAX_BLOB_COMMITMENTS_PER_BLOCK)` = 4 + 1 + 5 = 10
KZG_COMMITMENT_INCLUSION_PROOF_DEPTH: 10
5 changes: 3 additions & 2 deletions specs/_features/eip7594/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

| Name | Value | Description |
| - | - | - |
| `MAX_BLOBS_PER_BLOCK_EIP7594` | `uint64(8)` | *[New in EIP7594]* Maximum number of blobs in a single block limited by `MAX_BLOB_COMMITMENTS_PER_BLOCK` |
| `TARGET_BLOBS_PER_BLOCK_EIP7594` | `uint64(9)` | *[New in EIP7594]* Target number of blobs in a single block limited by `MAX_BLOBS_PER_BLOCK_EIP7594` |
| `MAX_BLOBS_PER_BLOCK_EIP7594` | `uint64(12)` | *[New in EIP7594]* Maximum number of blobs in a single block limited by `MAX_BLOB_COMMITMENTS_PER_BLOCK` |

#### Execution payload

Expand All @@ -53,7 +54,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=body.execution_requests,
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
target_blobs_per_block=TARGET_BLOBS_PER_BLOCK_EIP7594, # [Modified in EIP7594]
)
)
# Cache execution payload header
Expand Down
16 changes: 8 additions & 8 deletions specs/_features/eip7594/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
- [`data_column_sidecar_{subnet_id}`](#data_column_sidecar_subnet_id)
- [The Req/Resp domain](#the-reqresp-domain)
- [Messages](#messages)
- [BlobSidecarsByRoot v2](#blobsidecarsbyroot-v2)
- [BlobSidecarsByRange v2](#blobsidecarsbyrange-v2)
- [BlobSidecarsByRoot v3](#blobsidecarsbyroot-v3)
- [BlobSidecarsByRange v3](#blobsidecarsbyrange-v3)
- [DataColumnSidecarsByRoot v1](#datacolumnsidecarsbyroot-v1)
- [DataColumnSidecarsByRange v1](#datacolumnsidecarsbyrange-v1)
- [GetMetaData v3](#getmetadata-v3)
Expand Down Expand Up @@ -211,11 +211,11 @@ The following validations MUST pass before forwarding the `sidecar: DataColumnSi

#### Messages

##### BlobSidecarsByRoot v2
##### BlobSidecarsByRoot v3

**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_root/2/`
**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_root/3/`

*[Updated in EIP7594]*
*[Modified in EIP7594]*

The `<context-bytes>` field is calculated as `context = compute_fork_digest(fork_version, genesis_validators_root)`:

Expand Down Expand Up @@ -245,11 +245,11 @@ Response Content:

No more than `MAX_REQUEST_BLOB_SIDECARS_EIP7594` may be requested at a time.

##### BlobSidecarsByRange v2
##### BlobSidecarsByRange v3

**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_range/2/`
**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_range/3/`

*[Updated in EIP7594]*
*[Modified in EIP7594]*

The `<context-bytes>` field is calculated as `context = compute_fork_digest(fork_version, genesis_validators_root)`:

Expand Down
68 changes: 68 additions & 0 deletions specs/_features/eip7594/validator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# EIP7594 -- Honest Validator

## 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 -->

- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Block proposal](#block-proposal)
- [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody)
- [Execution payload](#execution-payload)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
<!-- /TOC -->

## Introduction

This document represents the changes to be made in the code of an "honest validator" to implement EIP7594.

## Prerequisites

This document is an extension of the [Electra -- Honest Validator](../electra/validator.md) guide.
All behaviors and definitions defined in this document, and documents it extends, carry over unless explicitly noted or overridden.

All terminology, constants, functions, and protocol mechanics defined in the updated Beacon Chain doc of [EIP7594](./beacon-chain.md) are requisite for this document and used throughout.
Please see related Beacon Chain doc before continuing and use them as a reference throughout.

## Block proposal

### Constructing the `BeaconBlockBody`

#### Execution payload

`prepare_execution_payload` is updated from the Electra specs.

*Note*: In this section, `state` is the state of the slot for the block proposal _without_ the block yet applied.
That is, `state` is the `previous_state` processed through any empty slots up to the assigned slot using `process_slots(previous_state, slot)`.

``python
def prepare_execution_payload(state: BeaconState,
safe_block_hash: Hash32,
finalized_block_hash: Hash32,
suggested_fee_recipient: ExecutionAddress,
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
# Verify consistency of the parent hash with respect to the previous execution payload header
parent_hash = state.latest_execution_payload_header.block_hash

# Set the forkchoice head and initiate the payload build process
withdrawals, _ = get_expected_withdrawals(state)

payload_attributes = PayloadAttributes(
timestamp=compute_timestamp_at_slot(state, state.slot),
prev_randao=get_randao_mix(state, get_current_epoch(state)),
suggested_fee_recipient=suggested_fee_recipient,
withdrawals=withdrawals,
parent_beacon_block_root=hash_tree_root(state.latest_block_header),
target_blobs_per_block=TARGET_BLOBS_PER_BLOCK_EIP7594, # [Modified in EIP7594]
max_blobs_per_block=MAX_BLOBS_PER_BLOCK_EIP7594, # [Modified in EIP7594]
)
return execution_engine.notify_forkchoice_updated(
head_block_hash=parent_hash,
safe_block_hash=safe_block_hash,
finalized_block_hash=finalized_block_hash,
payload_attributes=payload_attributes,
)
```
2 changes: 1 addition & 1 deletion specs/_features/eip7732/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def process_execution_payload(state: BeaconState,
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=requests,
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2,
target_blobs_per_block=TARGET_BLOBS_PER_BLOCK_ELECTRA,
)
)

Expand Down
13 changes: 11 additions & 2 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- [Withdrawals processing](#withdrawals-processing)
- [Pending deposits processing](#pending-deposits-processing)
- [Configuration](#configuration)
- [Execution](#execution-1)
- [Validator cycle](#validator-cycle)
- [Containers](#containers)
- [New containers](#new-containers)
Expand Down Expand Up @@ -119,6 +120,7 @@ Electra is a consensus-layer upgrade containing a number of features. Including:
* [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002): Execution layer triggerable exits
* [EIP-7251](https://eips.ethereum.org/EIPS/eip-7251): Increase the MAX_EFFECTIVE_BALANCE
* [EIP-7549](https://eips.ethereum.org/EIPS/eip-7549): Move committee index outside Attestation
* [EIP-7691](https://eips.ethereum.org/EIPS/eip-7691): Blob throughput increase

*Note:* This specification is built upon [Deneb](../deneb/beacon-chain.md) and is under active development.

Expand Down Expand Up @@ -200,6 +202,13 @@ The following values are (non-configurable) constants used throughout the specif

## Configuration

### Execution

| Name | Value | Description |
| - | - | - |
| `TARGET_BLOBS_PER_BLOCK_ELECTRA` | `uint64(6)` | *[New in Electra:EIP7691]* Target number of blobs in a single block limited by `MAX_BLOBS_PER_BLOCK_ELECTRA` |
| `MAX_BLOBS_PER_BLOCK_ELECTRA` | `uint64(9)` | *[New in Electra:EIP7691]* Maximum number of blobs in a single block limited by `MAX_BLOB_COMMITMENTS_PER_BLOCK` |

### Validator cycle

| Name | Value |
Expand Down Expand Up @@ -1233,7 +1242,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)
# Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK_ELECTRA # [Modified in Electra:EIP7691]
# Verify the execution payload is valid
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments]
assert execution_engine.verify_and_notify_new_payload(
Expand All @@ -1242,7 +1251,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
versioned_hashes=versioned_hashes,
parent_beacon_block_root=state.latest_block_header.parent_root,
execution_requests=body.execution_requests, # [New in Electra]
target_blobs_per_block=MAX_BLOBS_PER_BLOCK // 2, # [New in Electra:EIP7742]
target_blobs_per_block=TARGET_BLOBS_PER_BLOCK_ELECTRA, # [New in Electra:EIP7691:EIP7742]
)
)
# Cache execution payload header
Expand Down
Loading

0 comments on commit 31cd9cb

Please sign in to comment.