Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Electra: Rename objects with prefix ExecutionLayerXXX #3791

Merged
merged 4 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions specs/electra/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
- [`DepositRequest`](#depositrequest)
- [`PendingBalanceDeposit`](#pendingbalancedeposit)
- [`PendingPartialWithdrawal`](#pendingpartialwithdrawal)
- [`ExecutionLayerWithdrawalRequest`](#executionlayerwithdrawalrequest)
- [`ExecutionLayerConsolidationRequest`](#executionlayerconsolidationrequest)
- [`WithdrawalRequest`](#withdrawalrequest)
- [`ConsolidationRequest`](#consolidationrequest)
- [`PendingConsolidation`](#pendingconsolidation)
- [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing)
Expand Down Expand Up @@ -91,11 +91,11 @@
- [Voluntary exits](#voluntary-exits)
- [Updated `process_voluntary_exit`](#updated-process_voluntary_exit)
- [Execution layer withdrawal requests](#execution-layer-withdrawal-requests)
- [New `process_execution_layer_withdrawal_request`](#new-process_execution_layer_withdrawal_request)
- [New `process_withdrawal_request`](#new-process_withdrawal_request)
- [Deposit requests](#deposit-requests)
- [New `process_deposit_request`](#new-process_deposit_request)
- [Execution layer consolidation requests](#execution-layer-consolidation-requests)
- [New `process_execution_layer_consolidation_request`](#new-process_execution_layer_consolidation_request)
- [New `process_consolidation_request`](#new-process_consolidation_request)
- [Testing](#testing)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->
Expand Down Expand Up @@ -227,23 +227,23 @@ class PendingPartialWithdrawal(Container):
amount: Gwei
withdrawable_epoch: Epoch
```
#### `ExecutionLayerWithdrawalRequest`
#### `WithdrawalRequest`

*Note*: The container is new in EIP7251:EIP7002.

```python
class ExecutionLayerWithdrawalRequest(Container):
class WithdrawalRequest(Container):
source_address: ExecutionAddress
validator_pubkey: BLSPubkey
amount: Gwei
```

#### `ExecutionLayerConsolidationRequest`
#### `ConsolidationRequest`

*Note*: The container is new in EIP7251.

```python
class ExecutionLayerConsolidationRequest(Container):
class ConsolidationRequest(Container):
source_address: ExecutionAddress
source_pubkey: BLSPubkey
target_pubkey: BLSPubkey
Expand Down Expand Up @@ -336,9 +336,9 @@ class ExecutionPayload(Container):
excess_blob_gas: uint64
deposit_requests: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251]
withdrawal_requests: List[ExecutionLayerWithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD]
withdrawal_requests: List[WithdrawalRequest, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD]
# [New in Electra:EIP7251]
consolidation_requests: List[ExecutionLayerConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD]
consolidation_requests: List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD]
```

#### `ExecutionPayloadHeader`
Expand Down Expand Up @@ -1075,9 +1075,9 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)
for_ops(body.execution_payload.deposit_requests, process_deposit_request) # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251]
for_ops(body.execution_payload.withdrawal_requests, process_execution_layer_withdrawal_request)
for_ops(body.execution_payload.withdrawal_requests, process_withdrawal_request)
# [New in Electra:EIP7251]
for_ops(body.execution_payload.consolidation_requests, process_execution_layer_consolidation_request)
for_ops(body.execution_payload.consolidation_requests, process_consolidation_request)
```

##### Attestations
Expand Down Expand Up @@ -1236,16 +1236,16 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu

##### Execution layer withdrawal requests

###### New `process_execution_layer_withdrawal_request`
###### New `process_withdrawal_request`

*Note*: This function is new in Electra following EIP-7002 and EIP-7251.

```python
def process_execution_layer_withdrawal_request(
def process_withdrawal_request(
state: BeaconState,
execution_layer_withdrawal_request: ExecutionLayerWithdrawalRequest
withdrawal_request: WithdrawalRequest
) -> None:
amount = execution_layer_withdrawal_request.amount
amount = withdrawal_request.amount
is_full_exit_request = amount == FULL_EXIT_REQUEST_AMOUNT

# If partial withdrawal queue is full, only full exits are processed
Expand All @@ -1254,7 +1254,7 @@ def process_execution_layer_withdrawal_request(

validator_pubkeys = [v.pubkey for v in state.validators]
# Verify pubkey exists
request_pubkey = execution_layer_withdrawal_request.validator_pubkey
request_pubkey = withdrawal_request.validator_pubkey
if request_pubkey not in validator_pubkeys:
return
index = ValidatorIndex(validator_pubkeys.index(request_pubkey))
Expand All @@ -1263,7 +1263,7 @@ def process_execution_layer_withdrawal_request(
# Verify withdrawal credentials
has_correct_credential = has_execution_withdrawal_credential(validator)
is_correct_source_address = (
validator.withdrawal_credentials[12:] == execution_layer_withdrawal_request.source_address
validator.withdrawal_credentials[12:] == withdrawal_request.source_address
)
if not (has_correct_credential and is_correct_source_address):
return
Expand Down Expand Up @@ -1326,12 +1326,12 @@ def process_deposit_request(state: BeaconState, deposit_request: DepositRequest)

##### Execution layer consolidation requests

###### New `process_execution_layer_consolidation_request`
###### New `process_consolidation_request`

```python
def process_execution_layer_consolidation_request(
def process_consolidation_request(
state: BeaconState,
execution_layer_consolidation_request: ExecutionLayerConsolidationRequest
consolidation_request: ConsolidationRequest
) -> None:
# If the pending consolidations queue is full, consolidation requests are ignored
if len(state.pending_consolidations) == PENDING_CONSOLIDATIONS_LIMIT:
Expand All @@ -1342,8 +1342,8 @@ def process_execution_layer_consolidation_request(

validator_pubkeys = [v.pubkey for v in state.validators]
# Verify pubkeys exists
request_source_pubkey = execution_layer_consolidation_request.source_pubkey
request_target_pubkey = execution_layer_consolidation_request.target_pubkey
request_source_pubkey = consolidation_request.source_pubkey
request_target_pubkey = consolidation_request.target_pubkey
if request_source_pubkey not in validator_pubkeys:
return
if request_target_pubkey not in validator_pubkeys:
Expand All @@ -1360,7 +1360,7 @@ def process_execution_layer_consolidation_request(
# Verify source withdrawal credentials
has_correct_credential = has_execution_withdrawal_credential(source_validator)
is_correct_source_address = (
source_validator.withdrawal_credentials[12:] == execution_layer_consolidation_request.source_address
source_validator.withdrawal_credentials[12:] == consolidation_request.source_address
)
if not (has_correct_credential and is_correct_source_address):
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_basic_consolidation_in_current_consolidation_epoch(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -88,7 +88,7 @@ def test_basic_consolidation_in_new_consolidation_epoch(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_basic_consolidation_with_preexisting_churn(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -178,7 +178,7 @@ def test_basic_consolidation_with_insufficient_preexisting_churn(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_basic_consolidation_with_compounding_credentials(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -274,7 +274,7 @@ def test_consolidation_churn_limit_balance(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -322,7 +322,7 @@ def test_consolidation_balance_larger_than_churn_limit(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -369,7 +369,7 @@ def test_consolidation_balance_through_two_churn_epochs(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -415,7 +415,7 @@ def test_incorrect_source_equals_target(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation from source to source
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[source_index].pubkey,
Expand Down Expand Up @@ -447,7 +447,7 @@ def test_incorrect_exceed_pending_consolidations_limit(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -476,7 +476,7 @@ def test_incorrect_not_enough_consolidation_churn_available(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -504,7 +504,7 @@ def test_incorrect_exited_source(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -536,7 +536,7 @@ def test_incorrect_exited_target(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -566,7 +566,7 @@ def test_incorrect_inactive_source(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -598,7 +598,7 @@ def test_incorrect_inactive_target(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -627,7 +627,7 @@ def test_incorrect_no_source_execution_withdrawal_credential(spec, state):
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
target_index = spec.get_active_validator_indices(state, current_epoch)[1]
source_address = b"\x22" * 20
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -656,7 +656,7 @@ def test_incorrect_no_target_execution_withdrawal_credential(spec, state):
set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address
)
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -684,7 +684,7 @@ def test_incorrect_incorrect_source_address(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with different source address
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=b"\x33" * 20,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -714,7 +714,7 @@ def test_incorrect_unknown_source_pubkey(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with different source pubkey
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=source_address,
source_pubkey=b"\x00" * 48,
target_pubkey=state.validators[target_index].pubkey,
Expand Down Expand Up @@ -744,7 +744,7 @@ def test_incorrect_unknown_target_pubkey(spec, state):
spec, state, source_index, address=source_address
)
# Make consolidation with different target pubkey
consolidation = spec.ExecutionLayerConsolidationRequest(
consolidation = spec.ConsolidationRequest(
source_address=b"\x33" * 20,
source_pubkey=state.validators[source_index].pubkey,
target_pubkey=b"\x00" * 48,
Expand All @@ -760,7 +760,7 @@ def run_consolidation_processing(spec, state, consolidation, success=True):
"""
Run ``process_consolidation``, yielding:
- pre-state ('pre')
- execution_layer_consolidation_request ('execution_layer_consolidation_request')
- consolidation_request ('consolidation_request')
- post-state ('post').
If ``valid == False``, run expecting ``AssertionError``
"""
Expand All @@ -778,9 +778,9 @@ def run_consolidation_processing(spec, state, consolidation, success=True):
pre_state = state.copy()

yield 'pre', state
yield 'execution_layer_consolidation_request', consolidation
yield 'consolidation_request', consolidation

spec.process_execution_layer_consolidation_request(state, consolidation)
spec.process_consolidation_request(state, consolidation)

yield 'post', state

Expand Down
Loading