Skip to content

Commit

Permalink
specially marked EIP4844 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hwwhww committed Jun 7, 2023
1 parent 468b5be commit b9f3a6c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 31 deletions.
38 changes: 20 additions & 18 deletions specs/deneb/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,15 @@

## Introduction

This upgrade adds blobs to the beacon chain as part of Deneb. This is an extension of the Capella upgrade.

The blob transactions are packed into the execution payload by the EL/builder with their corresponding blobs being independently transmitted and are limited by `MAX_DATA_GAS_PER_BLOCK // DATA_GAS_PER_BLOB`. However the CL limit is independently defined by `MAX_BLOBS_PER_BLOCK`.
Deneb is a consensus-layer upgrade containing a number of features. Including:
* [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844): Shard Blob Transactions scale data-availability of Ethereum in a simple, forwards-compatible manner.

## Custom types

| Name | SSZ equivalent | Description |
| - | - | - |
| `VersionedHash` | `Bytes32` | |
| `BlobIndex` | `uint64` | |
| `VersionedHash` | `Bytes32` | [New in Deneb:EIP4844] |
| `BlobIndex` | `uint64` | [New in Deneb:EIP4844] |

## Constants

Expand All @@ -73,8 +72,11 @@ The blob transactions are packed into the execution payload by the EL/builder wi

| Name | Value | Description |
| - | - | - |
| `MAX_BLOB_COMMITMENTS_PER_BLOCK` | `uint64(2**12)` (= 4096) | hardfork independent fixed theoretical limit same as `LIMIT_BLOBS_PER_TX` (see EIP 4844) |
| `MAX_BLOBS_PER_BLOCK` | `uint64(2**2)` (= 4) | Maximum number of blobs in a single block limited by `MAX_BLOB_COMMITMENTS_PER_BLOCK` |
| `MAX_BLOB_COMMITMENTS_PER_BLOCK` | `uint64(2**12)` (= 4096) | [New in Deneb:EIP4844] hardfork independent fixed theoretical limit same as `LIMIT_BLOBS_PER_TX` (see EIP 4844) |
| `MAX_BLOBS_PER_BLOCK` | `uint64(2**2)` (= 4) | [New in Deneb:EIP4844] Maximum number of blobs in a single block limited by `MAX_BLOB_COMMITMENTS_PER_BLOCK` |

*Note*: The blob transactions are packed into the execution payload by the EL/builder with their corresponding blobs being independently transmitted
and are limited by `MAX_DATA_GAS_PER_BLOCK // DATA_GAS_PER_BLOB`. However the CL limit is independently defined by `MAX_BLOBS_PER_BLOCK`.

## Configuration

Expand All @@ -100,9 +102,9 @@ class BeaconBlockBody(Container):
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
sync_aggregate: SyncAggregate
# Execution
execution_payload: ExecutionPayload # [Modified in Deneb]
execution_payload: ExecutionPayload # [Modified in Deneb:EIP4844]
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] # [New in Deneb]
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] # [New in Deneb:EIP4844]
```

#### `ExecutionPayload`
Expand All @@ -126,8 +128,8 @@ class ExecutionPayload(Container):
block_hash: Hash32 # Hash of execution block
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
data_gas_used: uint64 # [New in Deneb]
excess_data_gas: uint64 # [New in Deneb]
data_gas_used: uint64 # [New in Deneb:EIP4844]
excess_data_gas: uint64 # [New in Deneb:EIP4844]
```

#### `ExecutionPayloadHeader`
Expand All @@ -151,8 +153,8 @@ class ExecutionPayloadHeader(Container):
block_hash: Hash32 # Hash of execution block
transactions_root: Root
withdrawals_root: Root
data_gas_used: uint64 # [New in Deneb]
excess_data_gas: uint64 # [New in Deneb]
data_gas_used: uint64 # [New in Deneb:EIP4844]
excess_data_gas: uint64 # [New in Deneb:EIP4844]
```

## Helper functions
Expand Down Expand Up @@ -205,7 +207,7 @@ def verify_and_notify_new_payload(self: ExecutionEngine,
if not self.is_valid_block_hash(new_payload_request.execution_payload):
return False

# [New in Deneb]
# [New in Deneb:EIP4844]
if not self.is_valid_versioned_hashes(new_payload_request):
return False

Expand All @@ -232,11 +234,11 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
# Verify timestamp
assert payload.timestamp == compute_timestamp_at_slot(state, state.slot)

# [New in Deneb] Verify commitments are under limit
# [New in Deneb:EIP4844] Verify commitments are under limit
assert len(body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK

# Verify the execution payload is valid
# [Modified in Deneb] Pass `versioned_hashes` to Execution Engine
# [Modified in Deneb:EIP4844] Pass `versioned_hashes` to Execution Engine
versioned_hashes = [kzg_commitment_to_versioned_hash(commitment) for commitment in body.blob_kzg_commitments]
assert execution_engine.verify_and_notify_new_payload(
NewPayloadRequest(execution_payload=payload, versioned_hashes=versioned_hashes)
Expand All @@ -259,8 +261,8 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi
block_hash=payload.block_hash,
transactions_root=hash_tree_root(payload.transactions),
withdrawals_root=hash_tree_root(payload.withdrawals),
data_gas_used=payload.data_gas_used, # [New in Deneb]
excess_data_gas=payload.excess_data_gas, # [New in Deneb]
data_gas_used=payload.data_gas_used, # [New in Deneb:EIP4844]
excess_data_gas=payload.excess_data_gas, # [New in Deneb:EIP4844]
)
```

Expand Down
4 changes: 3 additions & 1 deletion specs/deneb/fork-choice.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ This is the modification of the fork choice accompanying the Deneb upgrade.

#### `is_data_available`

[New in Deneb:EIP4844]

The implementation of `is_data_available` will become more sophisticated during later scaling upgrades.
Initially, verification requires every verifying actor to retrieve all matching `Blob`s and `KZGProof`s, and validate them with `verify_blob_kzg_proof_batch`.

Expand Down Expand Up @@ -76,7 +78,7 @@ def on_block(store: Store, signed_block: SignedBeaconBlock) -> None:
)
assert store.finalized_checkpoint.root == finalized_checkpoint_block

# [New in Deneb]
# [New in Deneb:EIP4844]
# Check if blob data is available
# If not, this block MAY be queued and subsequently considered when blob data becomes available
assert is_data_available(hash_tree_root(block), block.body.blob_kzg_commitments)
Expand Down
6 changes: 3 additions & 3 deletions specs/deneb/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def upgrade_to_deneb(pre: capella.BeaconState) -> BeaconState:
block_hash=pre.latest_execution_payload_header.block_hash,
transactions_root=pre.latest_execution_payload_header.transactions_root,
withdrawals_root=pre.latest_execution_payload_header.withdrawals_root,
data_gas_used=uint64(0), # [New in Deneb]
excess_data_gas=uint64(0), # [New in Deneb]
data_gas_used=uint64(0), # [New in Deneb:EIP4844]
excess_data_gas=uint64(0), # [New in Deneb:EIP4844]
)
post = BeaconState(
# Versioning
Expand Down Expand Up @@ -126,7 +126,7 @@ def upgrade_to_deneb(pre: capella.BeaconState) -> BeaconState:
current_sync_committee=pre.current_sync_committee,
next_sync_committee=pre.next_sync_committee,
# Execution-layer
latest_execution_payload_header=latest_execution_payload_header, # [Modified in Deneb]
latest_execution_payload_header=latest_execution_payload_header, # [Modified in Deneb:EIP4844]
# Withdrawals
next_withdrawal_index=pre.next_withdrawal_index,
next_withdrawal_validator_index=pre.next_withdrawal_validator_index,
Expand Down
4 changes: 2 additions & 2 deletions specs/deneb/light-client/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def upgrade_lc_header_to_deneb(pre: capella.LightClientHeader) -> LightClientHea
block_hash=pre.execution.block_hash,
transactions_root=pre.execution.transactions_root,
withdrawals_root=pre.execution.withdrawals_root,
data_gas_used=uint64(0), # [New in Deneb]
excess_data_gas=uint64(0), # [New in Deneb]
data_gas_used=uint64(0), # [New in Deneb:EIP4844]
excess_data_gas=uint64(0), # [New in Deneb:EIP4844]
),
execution_branch=pre.execution_branch,
)
Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/light-client/full-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
withdrawals_root=hash_tree_root(payload.withdrawals),
)

# [New in Deneb]
# [New in Deneb:EIP4844]
if epoch >= DENEB_FORK_EPOCH:
execution_header.data_gas_used = payload.data_gas_used
execution_header.excess_data_gas = payload.excess_data_gas
Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/light-client/sync-protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def get_lc_execution_root(header: LightClientHeader) -> Root:
def is_valid_light_client_header(header: LightClientHeader) -> bool:
epoch = compute_epoch_at_slot(header.beacon.slot)

# [New in Deneb]
# [New in Deneb:EIP4844]
if epoch < DENEB_FORK_EPOCH:
if header.execution.data_gas_used != uint64(0) or header.execution.excess_data_gas != uint64(0):
return False
Expand Down
14 changes: 11 additions & 3 deletions specs/deneb/p2p-interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ The specification of these changes continues in the same format as the network s

#### `BlobSidecar`

[New in Deneb:EIP4844]

```python
class BlobSidecar(Container):
block_root: Root
Expand All @@ -64,6 +66,8 @@ class BlobSidecar(Container):

#### `SignedBlobSidecar`

[New in Deneb:EIP4844]

```python
class SignedBlobSidecar(Container):
message: BlobSidecar
Expand All @@ -72,6 +76,8 @@ class SignedBlobSidecar(Container):

#### `BlobIdentifier`

[New in Deneb:EIP4844]

```python
class BlobIdentifier(Container):
block_root: Root
Expand Down Expand Up @@ -107,7 +113,7 @@ The new topics along with the type of the `data` field of a gossipsub message ar

| Name | Message Type |
| - | - |
| `blob_sidecar_{subnet_id}` | `SignedBlobSidecar` (new) |
| `blob_sidecar_{subnet_id}` | `SignedBlobSidecar` [New in Deneb:EIP4844] |

##### Global topics

Expand All @@ -124,6 +130,8 @@ New validation:

###### `blob_sidecar_{subnet_id}`

[New in Deneb:EIP4844]

This topic is used to propagate signed blob sidecars, where each blob index maps to some `subnet_id`.

The following validations MUST pass before forwarding the `signed_blob_sidecar` on the network, assuming the alias `sidecar = signed_blob_sidecar.message`:
Expand Down Expand Up @@ -191,7 +199,7 @@ No more than `MAX_REQUEST_BLOCKS_DENEB` may be requested at a time.

**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_root/1/`

New in deneb.
[New in Deneb:EIP4844]

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

Expand Down Expand Up @@ -240,7 +248,7 @@ Clients MAY limit the number of blocks and sidecars in the response.

**Protocol ID:** `/eth2/beacon_chain/req/blob_sidecars_by_range/1/`

New in deneb.
[New in Deneb:EIP4844]

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

Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/polynomial-commitments.md
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def evaluate_polynomial_in_evaluation_form(polynomial: Polynomial,

### KZG

KZG core functions. These are also defined in Deneb execution specs.
KZG core functions. These are also defined in Deneb execution specs for EIP-4844.

#### `blob_to_kzg_commitment`

Expand Down
2 changes: 1 addition & 1 deletion specs/deneb/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ All validator responsibilities remain unchanged other than those noted below.

#### Constructing the `BeaconBlockBody`

##### Blob KZG commitments
##### [New in Deneb:EIP4844] Blob KZG commitments

1. After retrieving the execution payload from the execution engine as specified in Capella,
use the `payload_id` to retrieve `blobs`, `blob_kzg_commitments`, and `blob_kzg_proofs`
Expand Down

0 comments on commit b9f3a6c

Please sign in to comment.