2022-03-10 05:31:11 +00:00
# EIP-4844 -- Honest Validator
**Notice**: This document is a work-in-progress for researchers and implementers.
## 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 )
- [Helpers ](#helpers )
2022-11-11 05:21:56 +00:00
- [`get_blobs_and_kzg_commitments` ](#get_blobs_and_kzg_commitments )
2022-03-10 05:31:11 +00:00
- [Beacon chain responsibilities ](#beacon-chain-responsibilities )
2022-10-22 15:13:14 +00:00
- [Block and sidecar proposal ](#block-and-sidecar-proposal )
2022-03-10 05:31:11 +00:00
- [Constructing the `BeaconBlockBody` ](#constructing-the-beaconblockbody )
2022-07-13 10:13:30 +00:00
- [Blob KZG commitments ](#blob-kzg-commitments )
2022-10-22 15:13:14 +00:00
- [Constructing the `SignedBeaconBlockAndBlobsSidecar` ](#constructing-the-signedbeaconblockandblobssidecar )
- [Block ](#block )
- [Sidecar ](#sidecar )
2022-03-10 05:31:11 +00:00
<!-- 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 EIP-4844.
## Prerequisites
2022-10-20 14:30:49 +00:00
This document is an extension of the [Capella -- Honest Validator ](../capella/validator.md ) guide.
2022-03-10 05:31:11 +00:00
All behaviors and definitions defined in this document, and documents it extends, carry over unless explicitly noted or overridden.
2022-12-13 16:07:37 +00:00
All terminology, constants, functions, and protocol mechanics defined in the updated [Beacon Chain doc of EIP-4844 ](./beacon-chain.md ) are requisite for this document and used throughout.
2022-03-10 05:31:11 +00:00
Please see related Beacon Chain doc before continuing and use them as a reference throughout.
## Helpers
2022-11-11 05:21:56 +00:00
### `get_blobs_and_kzg_commitments`
2022-10-20 14:30:49 +00:00
2022-11-11 05:21:56 +00:00
The interface to retrieve blobs and corresponding kzg commitments.
2022-10-20 14:30:49 +00:00
2022-11-11 05:21:56 +00:00
Note: This API is *unstable* . `get_blobs_and_kzg_commitments` and `get_payload` may be unified.
Implementers may also retrieve blobs individually per transaction.
2022-10-20 14:30:49 +00:00
2022-11-11 05:21:56 +00:00
```python
def get_blobs_and_kzg_commitments(payload_id: PayloadId) -> Tuple[Sequence[BLSFieldElement], Sequence[KZGCommitment]]:
2022-11-28 10:51:38 +00:00
# pylint: disable=unused-argument
2022-11-11 05:21:56 +00:00
...
```
2022-10-20 14:30:49 +00:00
2022-03-10 05:31:11 +00:00
## Beacon chain responsibilities
All validator responsibilities remain unchanged other than those noted below.
2022-10-22 00:33:55 +00:00
Namely, the blob handling and the addition of `SignedBeaconBlockAndBlobsSidecar` .
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
### Block and sidecar proposal
2022-03-10 05:31:11 +00:00
#### Constructing the `BeaconBlockBody`
2022-07-13 10:12:31 +00:00
##### Blob KZG commitments
2022-03-10 05:31:11 +00:00
2022-10-20 14:30:49 +00:00
1. After retrieving the execution payload from the execution engine as specified in Capella,
2022-07-15 15:29:22 +00:00
use the `payload_id` to retrieve `blobs` and `blob_kzg_commitments` via `get_blobs_and_kzg_commitments(payload_id)` .
2022-07-15 15:54:53 +00:00
2. Validate `blobs` and `blob_kzg_commitments` :
2022-03-10 05:31:11 +00:00
2022-07-15 15:29:22 +00:00
```python
2022-07-15 15:54:53 +00:00
def validate_blobs_and_kzg_commitments(execution_payload: ExecutionPayload,
2022-10-01 14:25:47 +00:00
blobs: Sequence[Blob],
2022-07-15 15:54:53 +00:00
blob_kzg_commitments: Sequence[KZGCommitment]) -> None:
2022-07-15 15:29:22 +00:00
# Optionally sanity-check that the KZG commitments match the versioned hashes in the transactions
assert verify_kzg_commitments_against_transactions(execution_payload.transactions, blob_kzg_commitments)
# Optionally sanity-check that the KZG commitments match the blobs (as produced by the execution engine)
assert len(blob_kzg_commitments) == len(blobs)
assert [blob_to_kzg_commitment(blob) == commitment for blob, commitment in zip(blobs, blob_kzg_commitments)]
2022-07-13 10:12:31 +00:00
```
2022-03-10 05:31:11 +00:00
2022-07-15 15:29:22 +00:00
3. If valid, set `block.body.blob_kzg_commitments = blob_kzg_commitments` .
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
#### Constructing the `SignedBeaconBlockAndBlobsSidecar`
To construct a `SignedBeaconBlockAndBlobsSidecar` , a `signed_beacon_block_and_blobs_sidecar` is defined with the necessary context for block and sidecar proposal.
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
##### Block
Set `signed_beacon_block_and_blobs_sidecar.beacon_block = block` where `block` is obtained above.
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
##### Sidecar
Coupled with block, the corresponding blobs are packaged into a sidecar object for distribution to the network.
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
Set `signed_beacon_block_and_blobs_sidecar.blobs_sidecar = sidecar` where `sidecar` is obtained from:
2022-03-10 05:31:11 +00:00
```python
2022-07-13 10:12:31 +00:00
def get_blobs_sidecar(block: BeaconBlock, blobs: Sequence[Blob]) -> BlobsSidecar:
return BlobsSidecar(
beacon_block_root=hash_tree_root(block),
beacon_block_slot=block.slot,
blobs=blobs,
2022-11-03 15:01:32 +00:00
kzg_aggregated_proof=compute_aggregate_kzg_proof(blobs),
2022-07-13 10:12:31 +00:00
)
2022-03-10 05:31:11 +00:00
```
2022-10-22 00:33:55 +00:00
This `signed_beacon_block_and_blobs_sidecar` is then published to the global `beacon_block_and_blobs_sidecar` topic.
2022-03-10 05:31:11 +00:00
2022-10-22 00:33:55 +00:00
After publishing the peers on the network may request the sidecar through sync-requests, or a local user may be interested.
The validator MUST hold on to sidecars for `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` epochs and serve when capable,
2022-03-10 05:31:11 +00:00
to ensure the data-availability of these blobs throughout the network.
2022-10-22 00:33:55 +00:00
After `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` nodes MAY prune the sidecars and/or stop serving them.