Merge pull request #3791 from prestonvanloon/rename-executionlayer-objs

Electra: Rename objects with prefix ExecutionLayerXXX
This commit is contained in:
Hsiao-Wei Wang 2024-06-10 20:01:20 +08:00 committed by GitHub
commit e53c10edb0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 143 additions and 182 deletions

View File

@ -27,8 +27,8 @@
- [`DepositRequest`](#depositrequest) - [`DepositRequest`](#depositrequest)
- [`PendingBalanceDeposit`](#pendingbalancedeposit) - [`PendingBalanceDeposit`](#pendingbalancedeposit)
- [`PendingPartialWithdrawal`](#pendingpartialwithdrawal) - [`PendingPartialWithdrawal`](#pendingpartialwithdrawal)
- [`ExecutionLayerWithdrawalRequest`](#executionlayerwithdrawalrequest) - [`WithdrawalRequest`](#withdrawalrequest)
- [`ExecutionLayerConsolidationRequest`](#executionlayerconsolidationrequest) - [`ConsolidationRequest`](#consolidationrequest)
- [`PendingConsolidation`](#pendingconsolidation) - [`PendingConsolidation`](#pendingconsolidation)
- [Modified Containers](#modified-containers) - [Modified Containers](#modified-containers)
- [`AttesterSlashing`](#attesterslashing) - [`AttesterSlashing`](#attesterslashing)
@ -91,11 +91,11 @@
- [Voluntary exits](#voluntary-exits) - [Voluntary exits](#voluntary-exits)
- [Updated `process_voluntary_exit`](#updated-process_voluntary_exit) - [Updated `process_voluntary_exit`](#updated-process_voluntary_exit)
- [Execution layer withdrawal requests](#execution-layer-withdrawal-requests) - [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) - [Deposit requests](#deposit-requests)
- [New `process_deposit_request`](#new-process_deposit_request) - [New `process_deposit_request`](#new-process_deposit_request)
- [Execution layer consolidation requests](#execution-layer-consolidation-requests) - [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) - [Testing](#testing)
<!-- END doctoc generated TOC please keep comment here to allow auto update --> <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@ -227,23 +227,23 @@ class PendingPartialWithdrawal(Container):
amount: Gwei amount: Gwei
withdrawable_epoch: Epoch withdrawable_epoch: Epoch
``` ```
#### `ExecutionLayerWithdrawalRequest` #### `WithdrawalRequest`
*Note*: The container is new in EIP7251:EIP7002. *Note*: The container is new in EIP7251:EIP7002.
```python ```python
class ExecutionLayerWithdrawalRequest(Container): class WithdrawalRequest(Container):
source_address: ExecutionAddress source_address: ExecutionAddress
validator_pubkey: BLSPubkey validator_pubkey: BLSPubkey
amount: Gwei amount: Gwei
``` ```
#### `ExecutionLayerConsolidationRequest` #### `ConsolidationRequest`
*Note*: The container is new in EIP7251. *Note*: The container is new in EIP7251.
```python ```python
class ExecutionLayerConsolidationRequest(Container): class ConsolidationRequest(Container):
source_address: ExecutionAddress source_address: ExecutionAddress
source_pubkey: BLSPubkey source_pubkey: BLSPubkey
target_pubkey: BLSPubkey target_pubkey: BLSPubkey
@ -336,9 +336,9 @@ class ExecutionPayload(Container):
excess_blob_gas: uint64 excess_blob_gas: uint64
deposit_requests: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110] deposit_requests: List[DepositRequest, MAX_DEPOSIT_REQUESTS_PER_PAYLOAD] # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251] # [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] # [New in Electra:EIP7251]
consolidation_requests: List[ExecutionLayerConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD] consolidation_requests: List[ConsolidationRequest, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD]
``` ```
#### `ExecutionPayloadHeader` #### `ExecutionPayloadHeader`
@ -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.bls_to_execution_changes, process_bls_to_execution_change)
for_ops(body.execution_payload.deposit_requests, process_deposit_request) # [New in Electra:EIP6110] for_ops(body.execution_payload.deposit_requests, process_deposit_request) # [New in Electra:EIP6110]
# [New in Electra:EIP7002:EIP7251] # [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] # [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 ##### Attestations
@ -1236,16 +1236,16 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
##### Execution layer withdrawal requests ##### 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. *Note*: This function is new in Electra following EIP-7002 and EIP-7251.
```python ```python
def process_execution_layer_withdrawal_request( def process_withdrawal_request(
state: BeaconState, state: BeaconState,
execution_layer_withdrawal_request: ExecutionLayerWithdrawalRequest withdrawal_request: WithdrawalRequest
) -> None: ) -> None:
amount = execution_layer_withdrawal_request.amount amount = withdrawal_request.amount
is_full_exit_request = amount == FULL_EXIT_REQUEST_AMOUNT is_full_exit_request = amount == FULL_EXIT_REQUEST_AMOUNT
# If partial withdrawal queue is full, only full exits are processed # If partial withdrawal queue is full, only full exits are processed
@ -1254,7 +1254,7 @@ def process_execution_layer_withdrawal_request(
validator_pubkeys = [v.pubkey for v in state.validators] validator_pubkeys = [v.pubkey for v in state.validators]
# Verify pubkey exists # Verify pubkey exists
request_pubkey = execution_layer_withdrawal_request.validator_pubkey request_pubkey = withdrawal_request.validator_pubkey
if request_pubkey not in validator_pubkeys: if request_pubkey not in validator_pubkeys:
return return
index = ValidatorIndex(validator_pubkeys.index(request_pubkey)) index = ValidatorIndex(validator_pubkeys.index(request_pubkey))
@ -1263,7 +1263,7 @@ def process_execution_layer_withdrawal_request(
# Verify withdrawal credentials # Verify withdrawal credentials
has_correct_credential = has_execution_withdrawal_credential(validator) has_correct_credential = has_execution_withdrawal_credential(validator)
is_correct_source_address = ( 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): if not (has_correct_credential and is_correct_source_address):
return return
@ -1326,12 +1326,12 @@ def process_deposit_request(state: BeaconState, deposit_request: DepositRequest)
##### Execution layer consolidation requests ##### Execution layer consolidation requests
###### New `process_execution_layer_consolidation_request` ###### New `process_consolidation_request`
```python ```python
def process_execution_layer_consolidation_request( def process_consolidation_request(
state: BeaconState, state: BeaconState,
execution_layer_consolidation_request: ExecutionLayerConsolidationRequest consolidation_request: ConsolidationRequest
) -> None: ) -> None:
# If the pending consolidations queue is full, consolidation requests are ignored # If the pending consolidations queue is full, consolidation requests are ignored
if len(state.pending_consolidations) == PENDING_CONSOLIDATIONS_LIMIT: if len(state.pending_consolidations) == PENDING_CONSOLIDATIONS_LIMIT:
@ -1342,8 +1342,8 @@ def process_execution_layer_consolidation_request(
validator_pubkeys = [v.pubkey for v in state.validators] validator_pubkeys = [v.pubkey for v in state.validators]
# Verify pubkeys exists # Verify pubkeys exists
request_source_pubkey = execution_layer_consolidation_request.source_pubkey request_source_pubkey = consolidation_request.source_pubkey
request_target_pubkey = execution_layer_consolidation_request.target_pubkey request_target_pubkey = consolidation_request.target_pubkey
if request_source_pubkey not in validator_pubkeys: if request_source_pubkey not in validator_pubkeys:
return return
if request_target_pubkey not in validator_pubkeys: if request_target_pubkey not in validator_pubkeys:
@ -1360,7 +1360,7 @@ def process_execution_layer_consolidation_request(
# Verify source withdrawal credentials # Verify source withdrawal credentials
has_correct_credential = has_execution_withdrawal_credential(source_validator) has_correct_credential = has_execution_withdrawal_credential(source_validator)
is_correct_source_address = ( 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): if not (has_correct_credential and is_correct_source_address):
return return

View File

@ -39,7 +39,7 @@ def test_basic_consolidation_in_current_consolidation_epoch(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -88,7 +88,7 @@ def test_basic_consolidation_in_new_consolidation_epoch(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -131,7 +131,7 @@ def test_basic_consolidation_with_preexisting_churn(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -178,7 +178,7 @@ def test_basic_consolidation_with_insufficient_preexisting_churn(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -229,7 +229,7 @@ def test_basic_consolidation_with_compounding_credentials(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -274,7 +274,7 @@ def test_consolidation_churn_limit_balance(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -322,7 +322,7 @@ def test_consolidation_balance_larger_than_churn_limit(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -369,7 +369,7 @@ def test_consolidation_balance_through_two_churn_epochs(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with source address # Make consolidation with source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -415,7 +415,7 @@ def test_incorrect_source_equals_target(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation from source to source # Make consolidation from source to source
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[source_index].pubkey, target_pubkey=state.validators[source_index].pubkey,
@ -447,7 +447,7 @@ def test_incorrect_exceed_pending_consolidations_limit(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -476,7 +476,7 @@ def test_incorrect_not_enough_consolidation_churn_available(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -504,7 +504,7 @@ def test_incorrect_exited_source(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -536,7 +536,7 @@ def test_incorrect_exited_target(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -566,7 +566,7 @@ def test_incorrect_inactive_source(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -598,7 +598,7 @@ def test_incorrect_inactive_target(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -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] source_index = spec.get_active_validator_indices(state, current_epoch)[0]
target_index = spec.get_active_validator_indices(state, current_epoch)[1] target_index = spec.get_active_validator_indices(state, current_epoch)[1]
source_address = b"\x22" * 20 source_address = b"\x22" * 20
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -656,7 +656,7 @@ def test_incorrect_no_target_execution_withdrawal_credential(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -684,7 +684,7 @@ def test_incorrect_incorrect_source_address(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with different source address # Make consolidation with different source address
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=b"\x33" * 20, source_address=b"\x33" * 20,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -714,7 +714,7 @@ def test_incorrect_unknown_source_pubkey(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with different source pubkey # Make consolidation with different source pubkey
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=source_address, source_address=source_address,
source_pubkey=b"\x00" * 48, source_pubkey=b"\x00" * 48,
target_pubkey=state.validators[target_index].pubkey, target_pubkey=state.validators[target_index].pubkey,
@ -744,7 +744,7 @@ def test_incorrect_unknown_target_pubkey(spec, state):
spec, state, source_index, address=source_address spec, state, source_index, address=source_address
) )
# Make consolidation with different target pubkey # Make consolidation with different target pubkey
consolidation = spec.ExecutionLayerConsolidationRequest( consolidation = spec.ConsolidationRequest(
source_address=b"\x33" * 20, source_address=b"\x33" * 20,
source_pubkey=state.validators[source_index].pubkey, source_pubkey=state.validators[source_index].pubkey,
target_pubkey=b"\x00" * 48, target_pubkey=b"\x00" * 48,
@ -760,7 +760,7 @@ def run_consolidation_processing(spec, state, consolidation, success=True):
""" """
Run ``process_consolidation``, yielding: Run ``process_consolidation``, yielding:
- pre-state ('pre') - pre-state ('pre')
- execution_layer_consolidation_request ('execution_layer_consolidation_request') - consolidation_request ('consolidation_request')
- post-state ('post'). - post-state ('post').
If ``valid == False``, run expecting ``AssertionError`` If ``valid == False``, run expecting ``AssertionError``
""" """
@ -778,9 +778,9 @@ def run_consolidation_processing(spec, state, consolidation, success=True):
pre_state = state.copy() pre_state = state.copy()
yield 'pre', state 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 yield 'post', state

View File

@ -29,14 +29,14 @@ def test_basic_withdrawal_request(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, validator_index, address=address spec, state, validator_index, address=address
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request spec, state, withdrawal_request
) )
@ -51,14 +51,14 @@ def test_basic_withdrawal_request_with_compounding_credentials(spec, state):
validator_pubkey = state.validators[validator_index].pubkey validator_pubkey = state.validators[validator_index].pubkey
address = b"\x22" * 20 address = b"\x22" * 20
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request spec, state, withdrawal_request
) )
@ -74,7 +74,7 @@ def test_basic_withdrawal_request_with_full_partial_withdrawal_queue(spec, state
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, validator_index, address=address spec, state, validator_index, address=address
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
@ -89,10 +89,10 @@ def test_basic_withdrawal_request_with_full_partial_withdrawal_queue(spec, state
] * spec.PENDING_PARTIAL_WITHDRAWALS_LIMIT ] * spec.PENDING_PARTIAL_WITHDRAWALS_LIMIT
# Exit should still be processed # Exit should still be processed
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
@ -113,14 +113,14 @@ def test_incorrect_source_address(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, validator_index, address=address spec, state, validator_index, address=address
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=incorrect_address, source_address=incorrect_address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -142,14 +142,14 @@ def test_incorrect_withdrawal_credential_prefix(spec, state):
spec.BLS_WITHDRAWAL_PREFIX spec.BLS_WITHDRAWAL_PREFIX
+ state.validators[validator_index].withdrawal_credentials[1:] + state.validators[validator_index].withdrawal_credentials[1:]
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -168,14 +168,14 @@ def test_on_withdrawal_request_initiated_validator(spec, state):
) )
# Initiate exit earlier # Initiate exit earlier
spec.initiate_validator_exit(state, validator_index) spec.initiate_validator_exit(state, validator_index)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -189,7 +189,7 @@ def test_activation_epoch_less_than_shard_committee_period(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, validator_index, address=address spec, state, validator_index, address=address
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=spec.FULL_EXIT_REQUEST_AMOUNT, amount=spec.FULL_EXIT_REQUEST_AMOUNT,
@ -200,8 +200,8 @@ def test_activation_epoch_less_than_shard_committee_period(spec, state):
+ spec.config.SHARD_COMMITTEE_PERIOD + spec.config.SHARD_COMMITTEE_PERIOD
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -221,16 +221,16 @@ def test_basic_partial_withdrawal_request(spec, state):
state.balances[validator_index] += amount state.balances[validator_index] += amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -253,16 +253,16 @@ def test_basic_partial_withdrawal_request_higher_excess_balance(spec, state):
state.balances[validator_index] += 2 * amount state.balances[validator_index] += 2 * amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -286,16 +286,16 @@ def test_basic_partial_withdrawal_request_lower_than_excess_balance(spec, state)
state.balances[validator_index] += excess_balance state.balances[validator_index] += excess_balance
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -316,7 +316,7 @@ def test_partial_withdrawal_request_with_pending_withdrawals(spec, state):
amount = spec.EFFECTIVE_BALANCE_INCREMENT amount = spec.EFFECTIVE_BALANCE_INCREMENT
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -331,10 +331,10 @@ def test_partial_withdrawal_request_with_pending_withdrawals(spec, state):
# Set balance so that the validator still has excess balance even with the pending withdrawals # Set balance so that the validator still has excess balance even with the pending withdrawals
state.balances[validator_index] += 3 * amount state.balances[validator_index] += 3 * amount
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -357,7 +357,7 @@ def test_partial_withdrawal_request_with_pending_withdrawals_and_high_amount(
amount = spec.UINT64_MAX amount = spec.UINT64_MAX
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -376,10 +376,10 @@ def test_partial_withdrawal_request_with_pending_withdrawals_and_high_amount(
# Set balance so that the validator still has excess balance even with the pending withdrawals # Set balance so that the validator still has excess balance even with the pending withdrawals
state.balances[validator_index] = spec.MAX_EFFECTIVE_BALANCE_ELECTRA state.balances[validator_index] = spec.MAX_EFFECTIVE_BALANCE_ELECTRA
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
@ -399,7 +399,7 @@ def test_partial_withdrawal_request_with_high_balance(spec, state):
) )
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -407,10 +407,10 @@ def test_partial_withdrawal_request_with_high_balance(spec, state):
churn_limit = spec.get_activation_exit_churn_limit(state) churn_limit = spec.get_activation_exit_churn_limit(state)
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -435,16 +435,16 @@ def test_partial_withdrawal_request_with_high_amount(spec, state):
state.balances[validator_index] += 1 state.balances[validator_index] += 1
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -467,16 +467,16 @@ def test_partial_withdrawal_request_with_low_amount(spec, state):
state.balances[validator_index] += amount state.balances[validator_index] += amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
) )
# Check that the assigned exit epoch is correct # Check that the assigned exit epoch is correct
@ -501,7 +501,7 @@ def test_partial_withdrawal_queue_full(spec, state):
# Ensure that the validator has sufficient excess balance # Ensure that the validator has sufficient excess balance
state.balances[validator_index] += 2 * amount state.balances[validator_index] += 2 * amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -514,8 +514,8 @@ def test_partial_withdrawal_queue_full(spec, state):
state.pending_partial_withdrawals = [ state.pending_partial_withdrawals = [
partial_withdrawal partial_withdrawal
] * spec.PENDING_PARTIAL_WITHDRAWALS_LIMIT ] * spec.PENDING_PARTIAL_WITHDRAWALS_LIMIT
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -534,16 +534,16 @@ def test_no_compounding_credentials(spec, state):
set_eth1_withdrawal_credential_with_balance( set_eth1_withdrawal_credential_with_balance(
spec, state, validator_index, address=address spec, state, validator_index, address=address
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
success=False, success=False,
) )
@ -559,14 +559,14 @@ def test_no_excess_balance(spec, state):
amount = spec.EFFECTIVE_BALANCE_INCREMENT amount = spec.EFFECTIVE_BALANCE_INCREMENT
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -583,7 +583,7 @@ def test_pending_withdrawals_consume_all_excess_balance(spec, state):
state.balances[validator_index] += 10 * amount state.balances[validator_index] += 10 * amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -595,8 +595,8 @@ def test_pending_withdrawals_consume_all_excess_balance(spec, state):
) )
state.pending_partial_withdrawals = [partial_withdrawal] * 10 state.pending_partial_withdrawals = [partial_withdrawal] * 10
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -615,16 +615,16 @@ def test_insufficient_effective_balance(spec, state):
].effective_balance -= spec.EFFECTIVE_BALANCE_INCREMENT ].effective_balance -= spec.EFFECTIVE_BALANCE_INCREMENT
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, spec,
state, state,
execution_layer_withdrawal_request, withdrawal_request,
success=False, success=False,
) )
@ -644,14 +644,14 @@ def test_partial_withdrawal_incorrect_source_address(spec, state):
state.balances[validator_index] += 2 * amount state.balances[validator_index] += 2 * amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=incorrect_address, source_address=incorrect_address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -673,14 +673,14 @@ def test_partial_withdrawal_incorrect_withdrawal_credential_prefix(spec, state):
spec.BLS_WITHDRAWAL_PREFIX spec.BLS_WITHDRAWAL_PREFIX
+ state.validators[validator_index].withdrawal_credentials[1:] + state.validators[validator_index].withdrawal_credentials[1:]
) )
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -699,14 +699,14 @@ def test_partial_withdrawal_on_exit_initiated_validator(spec, state):
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
# Initiate exit earlier # Initiate exit earlier
spec.initiate_validator_exit(state, validator_index) spec.initiate_validator_exit(state, validator_index)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -722,7 +722,7 @@ def test_partial_withdrawal_activation_epoch_less_than_shard_committee_period(
amount = spec.EFFECTIVE_BALANCE_INCREMENT amount = spec.EFFECTIVE_BALANCE_INCREMENT
state.balances[validator_index] += 2 * amount state.balances[validator_index] += 2 * amount
set_compounding_withdrawal_credential(spec, state, validator_index, address=address) set_compounding_withdrawal_credential(spec, state, validator_index, address=address)
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
amount=amount, amount=amount,
@ -733,8 +733,8 @@ def test_partial_withdrawal_activation_epoch_less_than_shard_committee_period(
+ spec.config.SHARD_COMMITTEE_PERIOD + spec.config.SHARD_COMMITTEE_PERIOD
) )
yield from run_execution_layer_withdrawal_request_processing( yield from run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, success=False spec, state, withdrawal_request, success=False
) )
@ -743,28 +743,28 @@ def test_partial_withdrawal_activation_epoch_less_than_shard_committee_period(
# #
def run_execution_layer_withdrawal_request_processing( def run_withdrawal_request_processing(
spec, state, execution_layer_withdrawal_request, valid=True, success=True spec, state, withdrawal_request, valid=True, success=True
): ):
""" """
Run ``process_execution_layer_withdrawal_request``, yielding: Run ``process_withdrawal_request``, yielding:
- pre-state ('pre') - pre-state ('pre')
- execution_layer_withdrawal_request ('execution_layer_withdrawal_request') - withdrawal_request ('withdrawal_request')
- post-state ('post'). - post-state ('post').
If ``valid == False``, run expecting ``AssertionError`` If ``valid == False``, run expecting ``AssertionError``
If ``success == False``, it doesn't initiate exit successfully If ``success == False``, it doesn't initiate exit successfully
""" """
validator_index = get_validator_index_by_pubkey( validator_index = get_validator_index_by_pubkey(
state, execution_layer_withdrawal_request.validator_pubkey state, withdrawal_request.validator_pubkey
) )
yield "pre", state yield "pre", state
yield "execution_layer_withdrawal_request", execution_layer_withdrawal_request yield "withdrawal_request", withdrawal_request
if not valid: if not valid:
expect_assertion_error( expect_assertion_error(
lambda: spec.process_execution_layer_withdrawal_request( lambda: spec.process_withdrawal_request(
state, execution_layer_withdrawal_request state, withdrawal_request
) )
) )
yield "post", None yield "post", None
@ -776,11 +776,11 @@ def run_execution_layer_withdrawal_request_processing(
pre_effective_balance = state.validators[validator_index].effective_balance pre_effective_balance = state.validators[validator_index].effective_balance
pre_state = state.copy() pre_state = state.copy()
expected_amount_to_withdraw = compute_amount_to_withdraw( expected_amount_to_withdraw = compute_amount_to_withdraw(
spec, state, validator_index, execution_layer_withdrawal_request.amount spec, state, validator_index, withdrawal_request.amount
) )
spec.process_execution_layer_withdrawal_request( spec.process_withdrawal_request(
state, execution_layer_withdrawal_request state, withdrawal_request
) )
yield "post", state yield "post", state
@ -794,7 +794,7 @@ def run_execution_layer_withdrawal_request_processing(
state.validators[validator_index].effective_balance == pre_effective_balance state.validators[validator_index].effective_balance == pre_effective_balance
) )
# Full exit request # Full exit request
if execution_layer_withdrawal_request.amount == spec.FULL_EXIT_REQUEST_AMOUNT: if withdrawal_request.amount == spec.FULL_EXIT_REQUEST_AMOUNT:
assert pre_exit_epoch == spec.FAR_FUTURE_EPOCH assert pre_exit_epoch == spec.FAR_FUTURE_EPOCH
assert state.validators[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH assert state.validators[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH
assert spec.get_pending_balance_to_withdraw(state, validator_index) == 0 assert spec.get_pending_balance_to_withdraw(state, validator_index) == 0

View File

@ -36,12 +36,12 @@ def test_basic_el_withdrawal_request(spec, state):
assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH assert state.validators[validator_index].exit_epoch == spec.FAR_FUTURE_EPOCH
validator_pubkey = state.validators[validator_index].pubkey validator_pubkey = state.validators[validator_index].pubkey
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
) )
block = build_empty_block_for_next_slot(spec, state) block = build_empty_block_for_next_slot(spec, state)
block.body.execution_payload.withdrawal_requests = [execution_layer_withdrawal_request] block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
signed_block = state_transition_and_sign_block(spec, state, block) signed_block = state_transition_and_sign_block(spec, state, block)
@ -73,11 +73,11 @@ def test_basic_btec_and_el_withdrawal_request_in_same_block(spec, state):
block.body.bls_to_execution_changes = [signed_address_change] block.body.bls_to_execution_changes = [signed_address_change]
validator_pubkey = state.validators[validator_index].pubkey validator_pubkey = state.validators[validator_index].pubkey
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
) )
block.body.execution_payload.withdrawal_requests = [execution_layer_withdrawal_request] block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
signed_block = state_transition_and_sign_block(spec, state, block) signed_block = state_transition_and_sign_block(spec, state, block)
@ -125,12 +125,12 @@ def test_basic_btec_before_el_withdrawal_request(spec, state):
# block_2 contains an EL-Exit operation of the given validator # block_2 contains an EL-Exit operation of the given validator
validator_pubkey = state.validators[validator_index].pubkey validator_pubkey = state.validators[validator_index].pubkey
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
) )
block_2 = build_empty_block_for_next_slot(spec, state) block_2 = build_empty_block_for_next_slot(spec, state)
block_2.body.execution_payload.withdrawal_requests = [execution_layer_withdrawal_request] block_2.body.execution_payload.withdrawal_requests = [withdrawal_request]
block_2.body.execution_payload.block_hash = compute_el_block_hash(spec, block_2.body.execution_payload) block_2.body.execution_payload.block_hash = compute_el_block_hash(spec, block_2.body.execution_payload)
signed_block_2 = state_transition_and_sign_block(spec, state, block_2) signed_block_2 = state_transition_and_sign_block(spec, state, block_2)
@ -157,13 +157,13 @@ def test_cl_exit_and_el_withdrawal_request_in_same_block(spec, state):
signed_voluntary_exits = prepare_signed_exits(spec, state, indices=[validator_index]) signed_voluntary_exits = prepare_signed_exits(spec, state, indices=[validator_index])
# EL-Exit # EL-Exit
validator_pubkey = state.validators[validator_index].pubkey validator_pubkey = state.validators[validator_index].pubkey
execution_layer_withdrawal_request = spec.ExecutionLayerWithdrawalRequest( withdrawal_request = spec.WithdrawalRequest(
source_address=address, source_address=address,
validator_pubkey=validator_pubkey, validator_pubkey=validator_pubkey,
) )
block = build_empty_block_for_next_slot(spec, state) block = build_empty_block_for_next_slot(spec, state)
block.body.voluntary_exits = signed_voluntary_exits block.body.voluntary_exits = signed_voluntary_exits
block.body.execution_payload.withdrawal_requests = [execution_layer_withdrawal_request] block.body.execution_payload.withdrawal_requests = [withdrawal_request]
block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload) block.body.execution_payload.block_hash = compute_el_block_hash(spec, block.body.execution_payload)
signed_block = state_transition_and_sign_block(spec, state, block) signed_block = state_transition_and_sign_block(spec, state, block)

View File

@ -1,39 +0,0 @@
from eth2spec.test.context import expect_assertion_error
from eth2spec.test.helpers.state import get_validator_index_by_pubkey
#
# Run processing
#
def run_execution_layer_withdrawal_request_processing(spec, state, withdrawal_request, valid=True, success=True):
"""
Run ``process_execution_layer_withdrawal_request``, yielding:
- pre-state ('pre')
- withdrawal_request ('withdrawal_request')
- post-state ('post').
If ``valid == False``, run expecting ``AssertionError``
If ``success == False``, it doesn't initiate exit successfully
"""
validator_index = get_validator_index_by_pubkey(state, withdrawal_request.validator_pubkey)
yield 'pre', state
yield 'withdrawal_request', withdrawal_request
if not valid:
expect_assertion_error(lambda: spec.process_withdrawal_request(state, withdrawal_request))
yield 'post', None
return
pre_exit_epoch = state.validators[validator_index].exit_epoch
spec.process_withdrawal_request(state, withdrawal_request)
yield 'post', state
if success:
assert pre_exit_epoch == spec.FAR_FUTURE_EPOCH
assert state.validators[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH
else:
assert state.validators[validator_index].exit_epoch == pre_exit_epoch

View File

@ -46,8 +46,8 @@ Operations:
| `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) | | `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) |
| `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) | | `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) |
| `deposit_request` | `DepositRequest` | `deposit_request` | `process_deposit_request(state, deposit_request)` (new in Electra) | | `deposit_request` | `DepositRequest` | `deposit_request` | `process_deposit_request(state, deposit_request)` (new in Electra) |
| `execution_layer_withdrawal_request` | `ExecutionLayerWithdrawalRequest` | `execution_layer_withdrawal_request` | `process_execution_layer_withdrawal_request(state, execution_layer_withdrawal_request)` (new in Electra) | | `withdrawal_request` | `WithdrawalRequest` | `withdrawal_request` | `process_withdrawal_request(state, withdrawal_request)` (new in Electra) |
| `execution_layer_consolidation_request` | `ExecutionLayerConsolidationRequest` | `execution_layer_consolidation_request` | `process_execution_layer_consolidation_request(state, execution_layer_consolidation_request)` (new in Electra) | | `consolidation_request` | `ConsolidationRequest` | `consolidation_request` | `process_consolidation_request(state, consolidation_request)` (new in Electra) |
Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here.

View File

@ -45,10 +45,10 @@ if __name__ == "__main__":
_new_electra_mods = {key: 'eth2spec.test.electra.block_processing.test_process_' + key for key in [ _new_electra_mods = {key: 'eth2spec.test.electra.block_processing.test_process_' + key for key in [
'attestation', 'attestation',
'execution_layer_consolidation_request', 'consolidation_request',
'deposit_request', 'deposit_request',
'execution_layer_withdrawal_request',
'voluntary_exit' 'voluntary_exit'
'withdrawal_request',
]} ]}
electra_mods = combine_mods(_new_electra_mods, deneb_mods) electra_mods = combine_mods(_new_electra_mods, deneb_mods)