-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4008 from ethereum/eip7594-param
Add `MAX_BLOBS_PER_BLOCK_EIP7594` and corresponding configs
- Loading branch information
Showing
13 changed files
with
279 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
# EIP7594 -- The Beacon Chain | ||
|
||
**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) | ||
- [Configuration](#configuration) | ||
- [Execution](#execution) | ||
- [Execution payload](#execution-payload) | ||
- [Modified `process_execution_payload`](#modified-process_execution_payload) | ||
- [Testing](#testing) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- /TOC --> | ||
|
||
## Introduction | ||
|
||
*Note:* This specification is built upon [Electra](../electra/beacon-chain.md) and is under active development. | ||
|
||
## Configuration | ||
|
||
### Execution | ||
|
||
| 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` | | ||
|
||
#### Execution payload | ||
|
||
##### Modified `process_execution_payload` | ||
|
||
```python | ||
def process_execution_payload(state: BeaconState, body: BeaconBlockBody, execution_engine: ExecutionEngine) -> None: | ||
payload = body.execution_payload | ||
|
||
# Verify consistency of the parent hash with respect to the previous execution payload header | ||
assert payload.parent_hash == state.latest_execution_payload_header.block_hash | ||
# Verify prev_randao | ||
assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state)) | ||
# 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_EIP7594 # [Modified in EIP7594] | ||
# 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( | ||
NewPayloadRequest( | ||
execution_payload=payload, | ||
versioned_hashes=versioned_hashes, | ||
parent_beacon_block_root=state.latest_block_header.parent_root, | ||
execution_requests=body.execution_requests, | ||
) | ||
) | ||
# Cache execution payload header | ||
state.latest_execution_payload_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), | ||
blob_gas_used=payload.blob_gas_used, | ||
excess_blob_gas=payload.excess_blob_gas, | ||
) | ||
``` | ||
|
||
## Testing | ||
|
||
*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure EIP7594 testing only. | ||
|
||
```python | ||
def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, | ||
eth1_timestamp: uint64, | ||
deposits: Sequence[Deposit], | ||
execution_payload_header: ExecutionPayloadHeader=ExecutionPayloadHeader() | ||
) -> BeaconState: | ||
fork = Fork( | ||
previous_version=EIP7594_FORK_VERSION, # [Modified in EIP7594] for testing only | ||
current_version=EIP7594_FORK_VERSION, # [Modified in EIP7594] | ||
epoch=GENESIS_EPOCH, | ||
) | ||
state = BeaconState( | ||
genesis_time=eth1_timestamp + GENESIS_DELAY, | ||
fork=fork, | ||
eth1_data=Eth1Data(block_hash=eth1_block_hash, deposit_count=uint64(len(deposits))), | ||
latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), | ||
randao_mixes=[eth1_block_hash] * EPOCHS_PER_HISTORICAL_VECTOR, # Seed RANDAO with Eth1 entropy | ||
deposit_requests_start_index=UNSET_DEPOSIT_REQUESTS_START_INDEX, | ||
) | ||
|
||
# Process deposits | ||
leaves = list(map(lambda deposit: deposit.data, deposits)) | ||
for index, deposit in enumerate(deposits): | ||
deposit_data_list = List[DepositData, 2**DEPOSIT_CONTRACT_TREE_DEPTH](*leaves[:index + 1]) | ||
state.eth1_data.deposit_root = hash_tree_root(deposit_data_list) | ||
process_deposit(state, deposit) | ||
|
||
# Process deposit balance updates | ||
validator_pubkeys = [v.pubkey for v in state.validators] | ||
for deposit in state.pending_deposits: | ||
validator_index = ValidatorIndex(validator_pubkeys.index(deposit.pubkey)) | ||
increase_balance(state, validator_index, deposit.amount) | ||
state.pending_deposits = [] | ||
|
||
# Process activations | ||
for index, validator in enumerate(state.validators): | ||
balance = state.balances[index] | ||
validator.effective_balance = min( | ||
balance - balance % EFFECTIVE_BALANCE_INCREMENT, get_max_effective_balance(validator)) | ||
if validator.effective_balance >= MIN_ACTIVATION_BALANCE: | ||
validator.activation_eligibility_epoch = GENESIS_EPOCH | ||
validator.activation_epoch = GENESIS_EPOCH | ||
|
||
# Set genesis validators root for domain separation and chain versioning | ||
state.genesis_validators_root = hash_tree_root(state.validators) | ||
|
||
# Fill in sync committees | ||
# Note: A duplicate committee is assigned for the current and next committee at genesis | ||
state.current_sync_committee = get_next_sync_committee(state) | ||
state.next_sync_committee = get_next_sync_committee(state) | ||
|
||
# Initialize the execution payload header | ||
state.latest_execution_payload_header = execution_payload_header | ||
|
||
return state | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.