2023-01-23 14:08:34 +00:00
|
|
|
# Deneb Light Client -- Full Node
|
2022-12-12 12:11:49 +00:00
|
|
|
|
|
|
|
**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)
|
|
|
|
- [Helper functions](#helper-functions)
|
|
|
|
- [Modified `block_to_light_client_header`](#modified-block_to_light_client_header)
|
|
|
|
|
|
|
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
|
|
<!-- /TOC -->
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
|
2023-01-23 14:08:34 +00:00
|
|
|
This upgrade adds information about the execution payload to light client data as part of the Deneb upgrade.
|
2022-12-12 12:11:49 +00:00
|
|
|
|
|
|
|
## Helper functions
|
|
|
|
|
|
|
|
### Modified `block_to_light_client_header`
|
|
|
|
|
|
|
|
```python
|
|
|
|
def block_to_light_client_header(block: SignedBeaconBlock) -> LightClientHeader:
|
|
|
|
epoch = compute_epoch_at_slot(block.message.slot)
|
|
|
|
|
|
|
|
if epoch >= CAPELLA_FORK_EPOCH:
|
|
|
|
payload = block.message.body.execution_payload
|
|
|
|
execution_header = ExecutionPayloadHeader(
|
|
|
|
parent_hash=payload.parent_hash,
|
|
|
|
fee_recipient=payload.fee_recipient,
|
|
|
|
state_root=payload.state_root,
|
|
|
|
receipts_root=payload.receipts_root,
|
|
|
|
logs_bloom=payload.logs_bloom,
|
|
|
|
prev_randao=payload.prev_randao,
|
|
|
|
block_number=payload.block_number,
|
|
|
|
gas_limit=payload.gas_limit,
|
|
|
|
gas_used=payload.gas_used,
|
|
|
|
timestamp=payload.timestamp,
|
|
|
|
extra_data=payload.extra_data,
|
|
|
|
base_fee_per_gas=payload.base_fee_per_gas,
|
|
|
|
block_hash=payload.block_hash,
|
|
|
|
transactions_root=hash_tree_root(payload.transactions),
|
|
|
|
withdrawals_root=hash_tree_root(payload.withdrawals),
|
|
|
|
)
|
|
|
|
|
2023-06-07 09:45:39 +00:00
|
|
|
# [New in Deneb:EIP4844]
|
2023-01-23 14:08:34 +00:00
|
|
|
if epoch >= DENEB_FORK_EPOCH:
|
2023-07-25 05:28:34 +00:00
|
|
|
execution_header.blob_gas_used = payload.blob_gas_used
|
|
|
|
execution_header.excess_blob_gas = payload.excess_blob_gas
|
2022-12-12 12:11:49 +00:00
|
|
|
|
2023-12-27 12:59:31 +00:00
|
|
|
execution_branch = ExecutionBranch(
|
2024-01-15 11:48:22 +00:00
|
|
|
compute_merkle_proof(block.message.body, EXECUTION_PAYLOAD_GINDEX))
|
2022-12-12 12:11:49 +00:00
|
|
|
else:
|
2023-01-13 10:19:53 +00:00
|
|
|
# Note that during fork transitions, `finalized_header` may still point to earlier forks.
|
|
|
|
# While Bellatrix blocks also contain an `ExecutionPayload` (minus `withdrawals_root`),
|
|
|
|
# it was not included in the corresponding light client data. To ensure compatibility
|
|
|
|
# with legacy data going through `upgrade_lc_header_to_capella`, leave out execution data.
|
2022-12-12 12:11:49 +00:00
|
|
|
execution_header = ExecutionPayloadHeader()
|
2023-12-27 12:59:31 +00:00
|
|
|
execution_branch = ExecutionBranch()
|
2022-12-12 12:11:49 +00:00
|
|
|
|
|
|
|
return LightClientHeader(
|
|
|
|
beacon=BeaconBlockHeader(
|
|
|
|
slot=block.message.slot,
|
|
|
|
proposer_index=block.message.proposer_index,
|
|
|
|
parent_root=block.message.parent_root,
|
|
|
|
state_root=block.message.state_root,
|
|
|
|
body_root=hash_tree_root(block.message.body),
|
|
|
|
),
|
|
|
|
execution=execution_header,
|
|
|
|
execution_branch=execution_branch,
|
|
|
|
)
|
|
|
|
```
|