mirror of
https://github.com/ethereum/consensus-specs.git
synced 2026-02-01 15:34:55 -05:00
Fix py setup
And remove the ENABLE_WITHDRAWALS feature-flag. The Testing section in the spec has been updated to specify how withdrawals is to be disabled
This commit is contained in:
6
setup.py
6
setup.py
@@ -582,14 +582,14 @@ from eth2spec.bellatrix import {preset_name} as bellatrix
|
||||
#
|
||||
# EIP4844SpecBuilder
|
||||
#
|
||||
class EIP4844SpecBuilder(BellatrixSpecBuilder):
|
||||
class EIP4844SpecBuilder(CapellaSpecBuilder):
|
||||
fork: str = EIP4844
|
||||
|
||||
@classmethod
|
||||
def imports(cls, preset_name: str):
|
||||
return super().imports(preset_name) + f'''
|
||||
from eth2spec.utils import kzg
|
||||
from eth2spec.bellatrix import {preset_name} as bellatrix
|
||||
from eth2spec.capella import {preset_name} as capella
|
||||
from eth2spec.utils.ssz.ssz_impl import serialize as ssz_serialize
|
||||
'''
|
||||
|
||||
@@ -967,7 +967,7 @@ class PySpecCommand(Command):
|
||||
specs/bellatrix/p2p-interface.md
|
||||
sync/optimistic.md
|
||||
"""
|
||||
if self.spec_fork == CAPELLA:
|
||||
if self.spec_fork in (CAPELLA, EIP4844):
|
||||
self.md_doc_paths += """
|
||||
specs/capella/beacon-chain.md
|
||||
specs/capella/fork.md
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
- [Domain types](#domain-types)
|
||||
- [Preset](#preset)
|
||||
- [Execution](#execution)
|
||||
- [Test Parameters](#test-parameters)
|
||||
- [Configuration](#configuration)
|
||||
- [Containers](#containers)
|
||||
- [Extended containers](#extended-containers)
|
||||
@@ -35,13 +34,14 @@
|
||||
- [Modified `process_operations`](#modified-process_operations)
|
||||
- [Blob KZG commitments](#blob-kzg-commitments)
|
||||
- [Testing](#testing)
|
||||
- [Disabling Withdrawals](#disabling-withdrawals)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- /TOC -->
|
||||
|
||||
## Introduction
|
||||
|
||||
This upgrade adds blobs to the beacon chain as part of EIP-4844. This is an extension of the Capella upgrade. We introduce a new feature flag, `ENABLE_WITHDRAWALS`, to disable Capella-specific updates to the state transition function. This is done to minimize Capella specific issues that may arise during testing. `ENABLE_WITHDRAWALS` will be removed in the final upgrade specification.
|
||||
This upgrade adds blobs to the beacon chain as part of EIP-4844. This is an extension of the Capella upgrade.
|
||||
|
||||
## Custom types
|
||||
|
||||
@@ -75,10 +75,6 @@ This upgrade adds blobs to the beacon chain as part of EIP-4844. This is an exte
|
||||
| - | - |
|
||||
| `MAX_BLOBS_PER_BLOCK` | `uint64(2**4)` (= 16) |
|
||||
|
||||
### Test Parameters
|
||||
| Name | Value |
|
||||
| `ENABLE_WITHDRAWALS` | `uint64(0)` |
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -218,9 +214,8 @@ def process_epoch(state: BeaconState) -> None:
|
||||
process_historical_roots_update(state)
|
||||
process_participation_flag_updates(state)
|
||||
process_sync_committee_updates(state)
|
||||
if ENABLE_WITHDRAWALS:
|
||||
process_full_withdrawals(state)
|
||||
process_partial_withdrawals(state)
|
||||
process_full_withdrawals(state)
|
||||
process_partial_withdrawals(state)
|
||||
```
|
||||
|
||||
|
||||
@@ -230,8 +225,7 @@ def process_epoch(state: BeaconState) -> None:
|
||||
def process_block(state: BeaconState, block: BeaconBlock) -> None:
|
||||
process_block_header(state, block)
|
||||
if is_execution_enabled(state, block.body):
|
||||
if ENABLE_WITHDRAWALS: # [New in EIP-4844]
|
||||
process_withdrawals(state, block.body.execution_payload)
|
||||
process_withdrawals(state, block.body.execution_payload)
|
||||
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in EIP-4844]
|
||||
process_randao(state, block.body)
|
||||
process_eth1_data(state, block.body)
|
||||
@@ -273,7 +267,7 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe
|
||||
excess_blobs=payload.excess_blobs, # [New in EIP-4844]
|
||||
block_hash=payload.block_hash,
|
||||
transactions_root=hash_tree_root(payload.transactions),
|
||||
withdrawals_root=hash_tree_root(payload.withdrawals) if ENABLE_WITHDRAWALS else Bytes32(), # [New in EIP-4844]
|
||||
withdrawals_root=hash_tree_root(payload.withdrawals),
|
||||
)
|
||||
```
|
||||
|
||||
@@ -295,8 +289,7 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
|
||||
for_ops(body.attestations, process_attestation)
|
||||
for_ops(body.deposits, process_deposit)
|
||||
for_ops(body.voluntary_exits, process_voluntary_exit)
|
||||
if ENABLE_WITHDRAWALS: # [New in EIP-4844]
|
||||
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)
|
||||
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)
|
||||
```
|
||||
|
||||
|
||||
@@ -362,3 +355,12 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32,
|
||||
|
||||
return state
|
||||
```
|
||||
|
||||
### Disabling Withdrawals
|
||||
During testing we avoid Capella-specific updates the state transition. We do this by replacing the following functions with a no-op implementation:
|
||||
- `process_full_withdrawals`
|
||||
- `process_partial_withdrawals`
|
||||
- `process_withdrawals`
|
||||
- `process_bls_to_execution_change`
|
||||
|
||||
The `get_expected_withdrawals` function is also modified to return an empty withdrawals list. As such, the PayloadAttributes used to update forkchoice does not contain withdrawals.
|
||||
|
||||
@@ -67,7 +67,7 @@ Note that for the pure EIP-4844 networks, we don't apply `upgrade_to_eip4844` si
|
||||
Since the `eip4844.BeaconState` format is equal to the `Capella.BeaconState` format, we only have to update `BeaconState.fork`.
|
||||
|
||||
```python
|
||||
def upgrade_to_eip4844(pre: Capella.BeaconState) -> BeaconState:
|
||||
def upgrade_to_eip4844(pre: capella.BeaconState) -> BeaconState:
|
||||
epoch = capella.get_current_epoch(pre)
|
||||
post = BeaconState(
|
||||
# Versioning
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
- [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody)
|
||||
- [Blob KZG commitments](#blob-kzg-commitments)
|
||||
- [Beacon Block publishing time](#beacon-block-publishing-time)
|
||||
- [ExecutionPayload](#executionpayload)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- /TOC -->
|
||||
@@ -264,46 +263,3 @@ The validator MUST hold on to blobs for `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS`
|
||||
to ensure the data-availability of these blobs throughout the network.
|
||||
|
||||
After `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` nodes MAY prune the blobs and/or stop serving them.
|
||||
|
||||
##### ExecutionPayload
|
||||
|
||||
`ExecutionPayload`s are constructed as they were in Capella, except that we allow withdrawals to be disabled for testing.
|
||||
|
||||
```python
|
||||
def prepare_execution_payload(state: BeaconState,
|
||||
pow_chain: Dict[Hash32, PowBlock],
|
||||
safe_block_hash: Hash32,
|
||||
finalized_block_hash: Hash32,
|
||||
suggested_fee_recipient: ExecutionAddress,
|
||||
execution_engine: ExecutionEngine) -> Optional[PayloadId]:
|
||||
if not is_merge_transition_complete(state):
|
||||
is_terminal_block_hash_set = TERMINAL_BLOCK_HASH != Hash32()
|
||||
is_activation_epoch_reached = get_current_epoch(state) >= TERMINAL_BLOCK_HASH_ACTIVATION_EPOCH
|
||||
if is_terminal_block_hash_set and not is_activation_epoch_reached:
|
||||
# Terminal block hash is set but activation epoch is not yet reached, no prepare payload call is needed
|
||||
return None
|
||||
|
||||
terminal_pow_block = get_terminal_pow_block(pow_chain)
|
||||
if terminal_pow_block is None:
|
||||
# Pre-merge, no prepare payload call is needed
|
||||
return None
|
||||
# Signify merge via producing on top of the terminal PoW block
|
||||
parent_hash = terminal_pow_block.block_hash
|
||||
else:
|
||||
# Post-merge, normal payload
|
||||
parent_hash = state.latest_execution_payload_header.block_hash
|
||||
|
||||
# Set the forkchoice head and initiate the payload build process
|
||||
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=get_expected_withdrawals(state) if ENABLE_WITHDRAWALS else None, # [New in EIP-4844]
|
||||
)
|
||||
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,
|
||||
)
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user